@composio/vercel 0.12.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +26 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -45,12 +45,18 @@ For multi-turn conversations, store `session.sessionId` and reuse it with `compo
|
|
|
45
45
|
|
|
46
46
|
## Strict mode
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
Pass `strict: true` to rewrite each tool's input schema into the form OpenAI strict mode (structured outputs) accepts before it reaches the AI SDK: every object lists all of its properties in `required` and is closed, and optional properties stay available but accept `null`. A `null` is dropped before the tool runs unless the tool's own schema accepts `null` for that parameter, so nullable fields still receive an explicit `null`. Tools whose schema cannot be expressed in strict mode, such as objects that accept arbitrary keys, `allOf`, `prefixItems`, or unresolved `$ref`s, keep their original schema and log a warning:
|
|
49
49
|
|
|
50
50
|
```typescript
|
|
51
51
|
const composio = new Composio({ provider: new VercelProvider({ strict: true }) });
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
The option does not set the AI SDK's per-tool `strict` flag, so the model provider does not enforce the schema. It does change what the provider accepts locally: tool-call arguments are validated against the rewritten schema, so a call that leaves out an optional parameter instead of sending `null` fails validation, and those `null`s are dropped before the tool runs, as described above. If you set that flag yourself, use it only with OpenAI models and only on tools that did not log the warning above, since OpenAI rejects a tool that kept its original schema. Don't set it for Anthropic models: Anthropic strict mode allows at most 16 parameters with union types and 24 optional parameters across all strict tools in a request, and the rewrite turns every optional parameter into a union, so a request with about ten Composio tools is rejected. Anthropic strict mode also rejects recursive definitions and keywords such as `minimum` and `maximum` that some Composio tools use.
|
|
55
|
+
|
|
56
|
+
## Tool schemas
|
|
57
|
+
|
|
58
|
+
The provider passes each tool's JSON Schema to the AI SDK with `jsonSchema()`, so the model sees it as is, including keywords such as `format`, `contentEncoding`, and `contentMediaType`. Internal `$ref`s are inlined first. Tool-call arguments are validated with a Zod schema built from the same JSON Schema. In strict mode the model sees the strict rewrite instead, which drops string formats strict structured outputs reject.
|
|
59
|
+
|
|
54
60
|
## Links
|
|
55
61
|
|
|
56
62
|
- [Vercel AI SDK provider docs](https://docs.composio.dev/docs/providers/vercel)
|
package/dist/index.d.mts
CHANGED
|
@@ -25,6 +25,12 @@ export declare class VercelProvider extends BaseAgenticProvider<VercelToolCollec
|
|
|
25
25
|
* // Use the provider to wrap tools for Vercel AI SDK
|
|
26
26
|
* const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
|
|
27
27
|
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param options.strict - Rewrites each tool's input schema into the form
|
|
30
|
+
* OpenAI strict mode accepts, and validates tool-call arguments against it.
|
|
31
|
+
* It does not set the AI SDK's per-tool `strict` flag, so the model provider
|
|
32
|
+
* does not enforce the schema. Anthropic strict mode rejects requests with
|
|
33
|
+
* typical sets of rewritten tools; see the README.
|
|
28
34
|
*/
|
|
29
35
|
constructor({ strict }?: {
|
|
30
36
|
strict?: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseAgenticProvider, deduplicateJsonSchemaRequiredArrays, dereferenceJsonSchema, jsonSchemaToZodSchema, logger, normalizeToolArguments, omitNullToolArguments, toStrictJsonSchema } from "@composio/core";
|
|
2
|
-
import { tool } from "ai";
|
|
2
|
+
import { jsonSchema, tool } from "ai";
|
|
3
3
|
|
|
4
4
|
//#region src/index.ts
|
|
5
5
|
/**
|
|
@@ -14,6 +14,23 @@ import { tool } from "ai";
|
|
|
14
14
|
* @packageDocumentation
|
|
15
15
|
* @module providers/vercel
|
|
16
16
|
*/
|
|
17
|
+
/**
|
|
18
|
+
* The AI SDK schema for a tool input: the model is shown `schema` itself, and
|
|
19
|
+
* tool-call arguments are validated with the Zod schema built from it.
|
|
20
|
+
*/
|
|
21
|
+
const toolInputSchema = (schema) => {
|
|
22
|
+
const validator = jsonSchemaToZodSchema(schema);
|
|
23
|
+
return jsonSchema(schema, { validate: async (value) => {
|
|
24
|
+
const result = await validator.safeParseAsync(value);
|
|
25
|
+
return result.success ? {
|
|
26
|
+
success: true,
|
|
27
|
+
value: result.data
|
|
28
|
+
} : {
|
|
29
|
+
success: false,
|
|
30
|
+
error: result.error
|
|
31
|
+
};
|
|
32
|
+
} });
|
|
33
|
+
};
|
|
17
34
|
var VercelProvider = class extends BaseAgenticProvider {
|
|
18
35
|
name = "vercel";
|
|
19
36
|
strict;
|
|
@@ -37,6 +54,12 @@ var VercelProvider = class extends BaseAgenticProvider {
|
|
|
37
54
|
* // Use the provider to wrap tools for Vercel AI SDK
|
|
38
55
|
* const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
|
|
39
56
|
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param options.strict - Rewrites each tool's input schema into the form
|
|
59
|
+
* OpenAI strict mode accepts, and validates tool-call arguments against it.
|
|
60
|
+
* It does not set the AI SDK's per-tool `strict` flag, so the model provider
|
|
61
|
+
* does not enforce the schema. Anthropic strict mode rejects requests with
|
|
62
|
+
* typical sets of rewritten tools; see the README.
|
|
40
63
|
*/
|
|
41
64
|
constructor({ strict = false } = {}) {
|
|
42
65
|
super();
|
|
@@ -106,10 +129,10 @@ var VercelProvider = class extends BaseAgenticProvider {
|
|
|
106
129
|
strictSource = strict.source;
|
|
107
130
|
}
|
|
108
131
|
}
|
|
109
|
-
const
|
|
132
|
+
const inputSchema = toolInputSchema(dereferenceJsonSchema(parameters, { onUnresolved: "sentinel" }));
|
|
110
133
|
return tool({
|
|
111
134
|
description: composioTool.description,
|
|
112
|
-
inputSchema
|
|
135
|
+
inputSchema,
|
|
113
136
|
execute: async (params) => {
|
|
114
137
|
const normalized = normalizeToolArguments(params, composioTool.slug);
|
|
115
138
|
return await executeTool(composioTool.slug, strictSource ? omitNullToolArguments(normalized, strictSource) : normalized);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/vercel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"ai": "^6.0.0 || ^7.0.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"ai": "^7.0.
|
|
41
|
-
"tsdown": "^0.23.
|
|
40
|
+
"ai": "^7.0.137",
|
|
41
|
+
"tsdown": "^0.23.1",
|
|
42
42
|
"typescript": "^7.0.2",
|
|
43
|
-
"vitest": "^5.0.
|
|
43
|
+
"vitest": "^5.0.3",
|
|
44
44
|
"zod": "^4.5.4",
|
|
45
|
-
"@composio/core": "0.
|
|
45
|
+
"@composio/core": "0.26.0"
|
|
46
46
|
},
|
|
47
47
|
"gitHead": "4fae6e54d5c150fba955cc5fa314281da5a1e064",
|
|
48
48
|
"scripts": {
|