utcp 0.3.0
utcp: ^0.3.0 copied to clipboard
LLM tool calling for Dart and Flutter: a UTCP client that calls tools over HTTP, SSE and OpenAPI directly, with no wrapper server.
0.3.0 #
registerManualreturns an unsuccessful result instead of throwing when a substituted variable makes the manual call template invalid, such as a URL variable a transport refuses.- A tool's
inputsandoutputsschemas drop keywords whose value is null,constanddefaultincluded, which the Python SDK writes for every unset keyword and the TypeScript SDK rejects. AddedJsonSchema.fromJson. - Breaking:
ToolRepositoryaddsremoveToolandtoJson, andToolSearchStrategyaddstoJson; custom implementations must add them.InMemoryToolRepository.removeToolalso drops the tool from its manual. - Breaking:
VariableLoaderaddstoJson; custom implementations must add it.UtcpClientConfig.toJsonwrites the shared configuration format and round-trips throughfromJson; loaders are written when theirtoJsonis not null. tool_repositoryandtool_search_strategyare parsed withToolRepository.registryandToolSearchStrategy.registry, so plugins can add their own types.UtcpClient.fromFileandUtcpClientConfig.fromFileread a JSON or YAML configuration file, andUtcpClienttakes arootDirfor transports that resolve relative paths, likeroot_dirin Python and TypeScript.- Manuals are written with
utcp_version1.1.0, the spec version this package implements, fromutcpProtocolVersion. - Variables that start with
ref, such as$refresh_token, are substituted; only a$refnot followed by a word character marks a JSON Schema reference, as in Python. - Manual names keep Unicode letters and numbers when sanitized, as in Python, so
cafékeeps its name and variable namespace. - A client parses call templates with its own protocols first and no longer replaces parsers in
CallTemplate.registry, so one client's protocols do not change parsing for other clients. AddedTypeRegistry.scoped. - A tool call that supplies a body to a GET
streamable_httptemplate fails with a clear error instead of sending it, as in the TypeScript SDK;httpkeeps sending it, as both reference SDKs do.buildToolRequesttakesgetWithBodyto choose. - The OAuth2 token request omits
scopewhen it is unset or empty instead of sendingscope=. streamable_httpreadschunk_size: 0andtimeout: 0as the defaults, as the reference SDKs do, andtimeoutandsseretry_timeoutaccept fractional milliseconds.- Only the first 64 KiB of an HTTP error body is read (
HttpStreamedResult.maxErrorBodyBytes), as in the Python SDK. streamable_httpbinary responses are regrouped intochunk_size-byte chunks, the last one possibly shorter, as the spec describes. Before, chunks were at mostchunk_sizeand followed the network's reads.- Docs: tag search follows the TypeScript SDK's scoring and
limit(0 returns every tool), andoauth2_userauth is TypeScript-only. - Breaking: HTTP tool results are parsed as JSON only for
application/jsonand+jsoncontent types, matched case-insensitively, as the spec requires, so a JSON body with another or no content type comes back as aString. Invalid JSON is returned as text instead of throwing. - Breaking: tool results are no longer parsed as YAML, so a YAML body comes back as a
String, andHttpResult.decodeno longer parses YAML; useHttpResult.decodeManualfor manuals. - OAuth2:
expires_insent as a string is accepted, anaccess_tokenthat is not a usable bearer token is rejected before it is cached, and a cached token is dropped when the server answers 401 or 403. - OpenAPI-generated http tools without a request body keep
body_field: "body"instead ofnull, which the TypeScript SDK rejects. - An unknown
dotenvvariable loader error says how to register it.
0.2.1 #
- Docs: package cross-links, badges and platform notes.
- Example:
example/claude_tool_use.dartgives UTCP tools to an LLM through the Claude Messages API tool-use loop.
0.2.0 #
- Breaking:
UtcpClient.createtakesprotocolsas a list; each protocol declares itscallTemplateTypes. - Breaking: tool arguments are
Map<String, Object?>andTool.inputs/outputsare typedJsonSchemas. - Breaking:
HttpCallTemplate.httpMethodis anHttpMethodenum;Auth.registerandCallTemplate.registermoved toAuth.registryandCallTemplate.registry. - Added
UtcpClient.fromJsonfor the configuration format shared with the other UTCP SDKs. HttpTransportandbuildToolRequestare public for transports built on HTTP.httpmanuals may be OpenAPI 2.0 or 3.x documents, converted to tools;OpenApiConverterconverts documents loaded elsewhere.- Added the
texttransport for UTCP manuals and OpenAPI documents supplied inline. - Added
substituteArgumentPlaceholdersandutcpDiscoveryMessagefor transports that sendUTCP_ARG_<name>_UTCP_ARGtemplates. - Redirects to another origin drop every credential-like header, static template headers included, and a request body is never resent to another origin.
- The remote-loopback rule covers every transport through
CallTemplate.endpoints. - YAML alias expansion is bounded (
decodeYaml), so a small hostile document cannot exhaust memory or CPU; aliases and collections used as mapping keys are rejected. Nesting too deep to parse fails with aFormatExceptioninstead of a stack overflow. - OpenAPI-generated tools send the manual's static headers only to the spec's own origin, and a spec reached through a cross-origin redirect gets neither those headers nor
auth_tools(a warning is logged). - Fixed concurrent registrations of the same manual name both succeeding.
- Fixed loopback detection of decimal IPv4 addresses on the web.
- Added the
ssetransport: event-type filtering,Last-Event-IDreconnects, and streaming as events arrive. - Added the
streamable_httptransport for NDJSON, JSON and chunked binary responses. - Added
filter_dictandlimit_stringsresult post-processors, configured withpost_processing. - A timed-out or cancelled HTTP request now releases its connection.
- A remotely discovered manual may not point
sseorstreamable_httptools at loopback either. - Requires
http1.6.0 or later.
0.1.0 #
- Initial release: UTCP manual, tool, call-template, and auth models.
UtcpClientwith manual registration, tool calls, streaming calls, and tag/description search.- Namespaced
${VAR}substitution from config, variable loaders, and the environment. - HTTP transport with API key, Basic, OAuth2 client-credentials, and user OAuth2 auth.
- HTTPS-only remote requests, redirect re-validation, and auth stripping on cross-origin redirects.