ai 5.0.0-canary.14 → 5.0.0-canary.15
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/CHANGELOG.md +17 -0
- package/dist/index.d.mts +98 -160
- package/dist/index.d.ts +98 -160
- package/dist/index.js +85 -154
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -86
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +24 -60
- package/dist/internal/index.d.ts +24 -60
- package/dist/internal/index.js +10 -67
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +5 -48
- package/dist/internal/index.mjs.map +1 -1
- package/dist/test/index.d.mts +4 -3
- package/dist/test/index.d.ts +4 -3
- package/dist/test/index.js +5 -2
- package/dist/test/index.js.map +1 -1
- package/dist/test/index.mjs +5 -2
- package/dist/test/index.mjs.map +1 -1
- package/package.json +3 -4
package/dist/index.mjs
CHANGED
@@ -8,7 +8,11 @@ var __export = (target, all) => {
|
|
8
8
|
import { createIdGenerator as createIdGenerator5, generateId as generateId2 } from "@ai-sdk/provider-utils";
|
9
9
|
|
10
10
|
// core/util/index.ts
|
11
|
-
import {
|
11
|
+
import {
|
12
|
+
generateId,
|
13
|
+
jsonSchema,
|
14
|
+
asSchema
|
15
|
+
} from "@ai-sdk/provider-utils";
|
12
16
|
|
13
17
|
// core/util/process-chat-response.ts
|
14
18
|
import { generateId as generateIdFunction } from "@ai-sdk/provider-utils";
|
@@ -823,7 +827,6 @@ async function processChatResponse({
|
|
823
827
|
execUpdate();
|
824
828
|
},
|
825
829
|
onReasoningPart(value) {
|
826
|
-
var _a18;
|
827
830
|
if (currentReasoningPart == null) {
|
828
831
|
currentReasoningPart = {
|
829
832
|
type: "reasoning",
|
@@ -835,7 +838,6 @@ async function processChatResponse({
|
|
835
838
|
currentReasoningPart.reasoning += value.text;
|
836
839
|
currentReasoningPart.providerMetadata = value.providerMetadata;
|
837
840
|
}
|
838
|
-
message.reasoning = ((_a18 = message.reasoning) != null ? _a18 : "") + value.text;
|
839
841
|
execUpdate();
|
840
842
|
},
|
841
843
|
onReasoningPartFinish(value) {
|
@@ -1258,12 +1260,6 @@ function getMessageParts(message) {
|
|
1258
1260
|
type: "tool-invocation",
|
1259
1261
|
toolInvocation
|
1260
1262
|
})) : [],
|
1261
|
-
...message.reasoning ? [
|
1262
|
-
{
|
1263
|
-
type: "reasoning",
|
1264
|
-
reasoning: message.reasoning
|
1265
|
-
}
|
1266
|
-
] : [],
|
1267
1263
|
...message.content ? [{ type: "text", text: message.content }] : []
|
1268
1264
|
];
|
1269
1265
|
}
|
@@ -1343,51 +1339,29 @@ async function prepareAttachmentsForRequest(attachmentsFromOptions) {
|
|
1343
1339
|
throw new Error("Invalid attachments type");
|
1344
1340
|
}
|
1345
1341
|
|
1346
|
-
// core/util/
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1342
|
+
// core/util/update-tool-call-result.ts
|
1343
|
+
function updateToolCallResult({
|
1344
|
+
messages,
|
1345
|
+
toolCallId,
|
1346
|
+
toolResult: result
|
1347
|
+
}) {
|
1352
1348
|
var _a17;
|
1353
|
-
const
|
1354
|
-
|
1355
|
-
|
1356
|
-
$refStrategy: useReferences ? "root" : "none",
|
1357
|
-
target: "jsonSchema7"
|
1358
|
-
// note: openai mode breaks various gemini conversions
|
1359
|
-
}),
|
1360
|
-
{
|
1361
|
-
validate: (value) => {
|
1362
|
-
const result = zodSchema2.safeParse(value);
|
1363
|
-
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
1364
|
-
}
|
1365
|
-
}
|
1349
|
+
const lastMessage = messages[messages.length - 1];
|
1350
|
+
const invocationPart = lastMessage.parts.find(
|
1351
|
+
(part) => part.type === "tool-invocation" && part.toolInvocation.toolCallId === toolCallId
|
1366
1352
|
);
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
return {
|
1375
|
-
[schemaSymbol]: true,
|
1376
|
-
_type: void 0,
|
1377
|
-
// should never be used directly
|
1378
|
-
[validatorSymbol]: true,
|
1379
|
-
jsonSchema: jsonSchema2,
|
1380
|
-
validate
|
1353
|
+
if (invocationPart == null) {
|
1354
|
+
return;
|
1355
|
+
}
|
1356
|
+
const toolResult = {
|
1357
|
+
...invocationPart.toolInvocation,
|
1358
|
+
state: "result",
|
1359
|
+
result
|
1381
1360
|
};
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
function asSchema(schema) {
|
1387
|
-
return schema == null ? jsonSchema({
|
1388
|
-
properties: {},
|
1389
|
-
additionalProperties: false
|
1390
|
-
}) : isSchema(schema) ? schema : zodSchema(schema);
|
1361
|
+
invocationPart.toolInvocation = toolResult;
|
1362
|
+
lastMessage.toolInvocations = (_a17 = lastMessage.toolInvocations) == null ? void 0 : _a17.map(
|
1363
|
+
(toolInvocation) => toolInvocation.toolCallId === toolCallId ? toolResult : toolInvocation
|
1364
|
+
);
|
1391
1365
|
}
|
1392
1366
|
|
1393
1367
|
// core/util/should-resubmit-messages.ts
|
@@ -1419,31 +1393,6 @@ function isAssistantMessageWithCompletedToolCalls(message) {
|
|
1419
1393
|
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => "result" in part.toolInvocation);
|
1420
1394
|
}
|
1421
1395
|
|
1422
|
-
// core/util/update-tool-call-result.ts
|
1423
|
-
function updateToolCallResult({
|
1424
|
-
messages,
|
1425
|
-
toolCallId,
|
1426
|
-
toolResult: result
|
1427
|
-
}) {
|
1428
|
-
var _a17;
|
1429
|
-
const lastMessage = messages[messages.length - 1];
|
1430
|
-
const invocationPart = lastMessage.parts.find(
|
1431
|
-
(part) => part.type === "tool-invocation" && part.toolInvocation.toolCallId === toolCallId
|
1432
|
-
);
|
1433
|
-
if (invocationPart == null) {
|
1434
|
-
return;
|
1435
|
-
}
|
1436
|
-
const toolResult = {
|
1437
|
-
...invocationPart.toolInvocation,
|
1438
|
-
state: "result",
|
1439
|
-
result
|
1440
|
-
};
|
1441
|
-
invocationPart.toolInvocation = toolResult;
|
1442
|
-
lastMessage.toolInvocations = (_a17 = lastMessage.toolInvocations) == null ? void 0 : _a17.map(
|
1443
|
-
(toolInvocation) => toolInvocation.toolCallId === toolCallId ? toolResult : toolInvocation
|
1444
|
-
);
|
1445
|
-
}
|
1446
|
-
|
1447
1396
|
// core/data-stream/create-data-stream.ts
|
1448
1397
|
function createDataStream({
|
1449
1398
|
execute,
|
@@ -4122,7 +4071,7 @@ async function generateObject(options) {
|
|
4122
4071
|
});
|
4123
4072
|
const promptMessages = await convertToLanguageModelPrompt({
|
4124
4073
|
prompt: standardizedPrompt,
|
4125
|
-
supportedUrls: await model.
|
4074
|
+
supportedUrls: await model.supportedUrls
|
4126
4075
|
});
|
4127
4076
|
const generateResult = await retry(
|
4128
4077
|
() => recordSpan({
|
@@ -4595,7 +4544,7 @@ var DefaultStreamObjectResult = class {
|
|
4595
4544
|
...prepareCallSettings(settings),
|
4596
4545
|
prompt: await convertToLanguageModelPrompt({
|
4597
4546
|
prompt: standardizedPrompt,
|
4598
|
-
supportedUrls: await model.
|
4547
|
+
supportedUrls: await model.supportedUrls
|
4599
4548
|
}),
|
4600
4549
|
providerOptions,
|
4601
4550
|
abortSignal,
|
@@ -5389,7 +5338,7 @@ async function generateText({
|
|
5389
5338
|
system: initialPrompt.system,
|
5390
5339
|
messages: stepInputMessages
|
5391
5340
|
},
|
5392
|
-
supportedUrls: await model.
|
5341
|
+
supportedUrls: await model.supportedUrls
|
5393
5342
|
});
|
5394
5343
|
const stepModel = (_a17 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a17 : model;
|
5395
5344
|
const { toolChoice: stepToolChoice, tools: stepTools } = prepareToolsAndToolChoice({
|
@@ -6725,7 +6674,7 @@ var DefaultStreamTextResult = class {
|
|
6725
6674
|
system: initialPrompt.system,
|
6726
6675
|
messages: stepInputMessages
|
6727
6676
|
},
|
6728
|
-
supportedUrls: await model.
|
6677
|
+
supportedUrls: await model.supportedUrls
|
6729
6678
|
});
|
6730
6679
|
const toolsAndToolChoice = {
|
6731
6680
|
...prepareToolsAndToolChoice({ tools, toolChoice, activeTools })
|
@@ -7874,8 +7823,8 @@ var doWrap = ({
|
|
7874
7823
|
provider: providerId != null ? providerId : model.provider,
|
7875
7824
|
modelId: modelId != null ? modelId : model.modelId,
|
7876
7825
|
// TODO middleware should be able to modify the supported urls
|
7877
|
-
|
7878
|
-
return model.
|
7826
|
+
get supportedUrls() {
|
7827
|
+
return model.supportedUrls;
|
7879
7828
|
},
|
7880
7829
|
async doGenerate(params) {
|
7881
7830
|
const transformedParams = await doTransform({ params, type: "generate" });
|
@@ -7992,7 +7941,6 @@ function appendResponseMessages({
|
|
7992
7941
|
);
|
7993
7942
|
(_b = lastMessage.parts) != null ? _b : lastMessage.parts = [];
|
7994
7943
|
lastMessage.content = textContent;
|
7995
|
-
lastMessage.reasoning = reasoningTextContent;
|
7996
7944
|
lastMessage.parts.push(...parts);
|
7997
7945
|
lastMessage.toolInvocations = [
|
7998
7946
|
...(_c = lastMessage.toolInvocations) != null ? _c : [],
|
@@ -8011,7 +7959,6 @@ function appendResponseMessages({
|
|
8011
7959
|
createdAt: currentDate(),
|
8012
7960
|
// generate a createdAt date for the message, will be overridden by the client
|
8013
7961
|
content: textContent,
|
8014
|
-
reasoning: reasoningTextContent,
|
8015
7962
|
toolInvocations: getToolInvocations2(0),
|
8016
7963
|
parts: [
|
8017
7964
|
...parts,
|
@@ -8963,7 +8910,6 @@ export {
|
|
8963
8910
|
streamText,
|
8964
8911
|
tool,
|
8965
8912
|
updateToolCallResult,
|
8966
|
-
wrapLanguageModel
|
8967
|
-
zodSchema
|
8913
|
+
wrapLanguageModel
|
8968
8914
|
};
|
8969
8915
|
//# sourceMappingURL=index.mjs.map
|