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/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 { generateId } from "@ai-sdk/provider-utils";
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/schema.ts
1347
- import { validatorSymbol } from "@ai-sdk/provider-utils";
1348
-
1349
- // core/util/zod-schema.ts
1350
- import zodToJsonSchema from "zod-to-json-schema";
1351
- function zodSchema(zodSchema2, options) {
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 useReferences = (_a17 = options == null ? void 0 : options.useReferences) != null ? _a17 : false;
1354
- return jsonSchema(
1355
- zodToJsonSchema(zodSchema2, {
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
- // core/util/schema.ts
1370
- var schemaSymbol = Symbol.for("vercel.ai.schema");
1371
- function jsonSchema(jsonSchema2, {
1372
- validate
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
- function isSchema(value) {
1384
- return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
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.getSupportedUrls()
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.getSupportedUrls()
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.getSupportedUrls()
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.getSupportedUrls()
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
- async getSupportedUrls() {
7878
- return model.getSupportedUrls();
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