@clearideas/agent-runtime-model-ai-sdk 0.6.2 → 0.7.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/dist/model-adapter.d.ts +4 -0
- package/dist/model-adapter.js +24 -0
- package/package.json +5 -5
package/dist/model-adapter.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface AiSdkCallOptions {
|
|
|
18
18
|
system?: string | SystemModelMessage | SystemModelMessage[];
|
|
19
19
|
messages: AiSdkModelMessage[];
|
|
20
20
|
tools?: ToolSet;
|
|
21
|
+
toolChoice?: "auto" | "none" | "required";
|
|
21
22
|
output?: unknown;
|
|
22
23
|
providerOptions?: JsonObject;
|
|
23
24
|
maxOutputTokens?: number;
|
|
@@ -41,6 +42,9 @@ export interface AiSdkToolCall {
|
|
|
41
42
|
toolName: string;
|
|
42
43
|
input: unknown;
|
|
43
44
|
providerExecuted?: boolean;
|
|
45
|
+
/** Set by the AI SDK for unknown tool names and inputs that fail the tool schema. */
|
|
46
|
+
invalid?: boolean;
|
|
47
|
+
error?: unknown;
|
|
44
48
|
}
|
|
45
49
|
export interface AiSdkGenerateResult {
|
|
46
50
|
text: string;
|
package/dist/model-adapter.js
CHANGED
|
@@ -101,6 +101,9 @@ export class AiSdkModelAdapter {
|
|
|
101
101
|
...(typeof part.providerExecuted === "boolean"
|
|
102
102
|
? { providerExecuted: part.providerExecuted }
|
|
103
103
|
: {}),
|
|
104
|
+
...(part.invalid === true
|
|
105
|
+
? { invalid: true, error: part.error }
|
|
106
|
+
: {}),
|
|
104
107
|
});
|
|
105
108
|
toolCalls.push(call);
|
|
106
109
|
yield { type: "tool-call", call };
|
|
@@ -181,6 +184,8 @@ export class AiSdkModelAdapter {
|
|
|
181
184
|
};
|
|
182
185
|
if (request.tools != null && request.tools.length > 0) {
|
|
183
186
|
options.tools = toAiSdkTools(request.tools);
|
|
187
|
+
if (request.toolChoice != null)
|
|
188
|
+
options.toolChoice = request.toolChoice;
|
|
184
189
|
}
|
|
185
190
|
if (request.outputSchema != null) {
|
|
186
191
|
options.output = Output.object({
|
|
@@ -650,6 +655,11 @@ function partsAsText(parts) {
|
|
|
650
655
|
.filter(Boolean)
|
|
651
656
|
.join("\n");
|
|
652
657
|
}
|
|
658
|
+
/**
|
|
659
|
+
* Invalid calls (an unknown tool name, or input that fails the tool schema)
|
|
660
|
+
* are marked so Agent Runtime answers them with an error instead of running
|
|
661
|
+
* them. The AI SDK has already added a tool-error result to the response.
|
|
662
|
+
*/
|
|
653
663
|
function toToolCall(call) {
|
|
654
664
|
return {
|
|
655
665
|
id: call.toolCallId,
|
|
@@ -658,6 +668,20 @@ function toToolCall(call) {
|
|
|
658
668
|
...(call.providerExecuted != null
|
|
659
669
|
? { providerExecuted: call.providerExecuted }
|
|
660
670
|
: {}),
|
|
671
|
+
...(call.invalid === true
|
|
672
|
+
? {
|
|
673
|
+
metadata: {
|
|
674
|
+
agentRuntime: {
|
|
675
|
+
invalid: true,
|
|
676
|
+
error: call.error instanceof Error
|
|
677
|
+
? call.error.message
|
|
678
|
+
: call.error == null
|
|
679
|
+
? "Invalid tool call."
|
|
680
|
+
: String(call.error),
|
|
681
|
+
},
|
|
682
|
+
},
|
|
683
|
+
}
|
|
684
|
+
: {}),
|
|
661
685
|
};
|
|
662
686
|
}
|
|
663
687
|
function toModelUsage(usage) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearideas/agent-runtime-model-ai-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "AI SDK model adapter for the vendor-neutral Clear Ideas Agent Runtime.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Clear Ideas Incorporated",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"postpack": "node ../../scripts/cleanup-package-license.mjs"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@clearideas/agent-runtime-contracts": "0.
|
|
40
|
-
"@clearideas/agent-runtime-core": "0.
|
|
41
|
-
"ai": "^7.0.
|
|
39
|
+
"@clearideas/agent-runtime-contracts": "0.7.0",
|
|
40
|
+
"@clearideas/agent-runtime-core": "0.7.0",
|
|
41
|
+
"ai": "^7.0.163"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"typescript": "^7.0.2",
|
|
45
|
-
"vitest": "^5.
|
|
45
|
+
"vitest": "^5.1.0"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=24"
|