@clearideas/agent-runtime-model-ai-sdk 0.6.1 → 0.6.2
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.js +23 -4
- package/package.json +3 -3
package/dist/model-adapter.js
CHANGED
|
@@ -131,7 +131,11 @@ export class AiSdkModelAdapter {
|
|
|
131
131
|
break;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
// A turn that calls tools is not the step's final answer, so there is no
|
|
135
|
+
// structured output to read yet; only the final turn is parsed.
|
|
136
|
+
const structuredOutput = request.outputSchema == null || toolCalls.length > 0
|
|
137
|
+
? undefined
|
|
138
|
+
: await result.output;
|
|
135
139
|
const responseMessages = result.responseMessages == null
|
|
136
140
|
? undefined
|
|
137
141
|
: await result.responseMessages;
|
|
@@ -196,16 +200,20 @@ export class AiSdkModelAdapter {
|
|
|
196
200
|
return options;
|
|
197
201
|
}
|
|
198
202
|
#toModelResult(request, result) {
|
|
203
|
+
const toolCalls = result.toolCalls.map(toToolCall);
|
|
199
204
|
return this.#buildModelResult({
|
|
200
205
|
request,
|
|
201
206
|
text: result.text,
|
|
202
207
|
reasoning: result.reasoningText ?? "",
|
|
203
|
-
toolCalls
|
|
208
|
+
toolCalls,
|
|
204
209
|
finishReason: result.finishReason,
|
|
205
210
|
usage: result.totalUsage,
|
|
206
211
|
providerMetadata: result.providerMetadata,
|
|
207
212
|
responseMessages: result.responseMessages,
|
|
208
|
-
|
|
213
|
+
// Reading `output` on a tool-call turn throws (there is no final answer).
|
|
214
|
+
structuredOutput: request.outputSchema == null || toolCalls.length > 0
|
|
215
|
+
? undefined
|
|
216
|
+
: result.output,
|
|
209
217
|
});
|
|
210
218
|
}
|
|
211
219
|
#buildModelResult(input) {
|
|
@@ -289,6 +297,17 @@ const mediaType = (part) => {
|
|
|
289
297
|
}
|
|
290
298
|
return value;
|
|
291
299
|
};
|
|
300
|
+
/**
|
|
301
|
+
* Tool-result files accept only tagged file data in AI SDK 7. step-prompt
|
|
302
|
+
* resolves stored artifacts to base64 data: URLs, which are sent as inline
|
|
303
|
+
* bytes; any other URI is sent as a URL.
|
|
304
|
+
*/
|
|
305
|
+
const toolResultFileData = (uri) => {
|
|
306
|
+
const inline = /^data:[^,]*;base64,(.*)$/su.exec(uri);
|
|
307
|
+
return inline
|
|
308
|
+
? { type: "data", data: inline[1] }
|
|
309
|
+
: { type: "url", url: new URL(uri) };
|
|
310
|
+
};
|
|
292
311
|
const toAiSdkToolResultPart = (part) => {
|
|
293
312
|
const result = part.result;
|
|
294
313
|
let output;
|
|
@@ -308,7 +327,7 @@ const toAiSdkToolResultPart = (part) => {
|
|
|
308
327
|
}
|
|
309
328
|
value.push({
|
|
310
329
|
type: "file",
|
|
311
|
-
data:
|
|
330
|
+
data: toolResultFileData(artifact.uri),
|
|
312
331
|
mediaType: artifact.mediaType,
|
|
313
332
|
filename: artifact.name,
|
|
314
333
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearideas/agent-runtime-model-ai-sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
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,8 +36,8 @@
|
|
|
36
36
|
"postpack": "node ../../scripts/cleanup-package-license.mjs"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@clearideas/agent-runtime-contracts": "0.6.
|
|
40
|
-
"@clearideas/agent-runtime-core": "0.6.
|
|
39
|
+
"@clearideas/agent-runtime-contracts": "0.6.2",
|
|
40
|
+
"@clearideas/agent-runtime-core": "0.6.2",
|
|
41
41
|
"ai": "^7.0.98"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|