@ai-sdk/provider-utils 4.0.24 → 4.0.26

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/index.d.mts +12 -1
  3. package/dist/index.d.ts +12 -1
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +4 -2
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +2 -2
  9. package/src/add-additional-properties-to-json-schema.ts +1 -1
  10. package/src/convert-image-model-file-to-data-uri.ts +1 -1
  11. package/src/create-tool-name-mapping.ts +1 -1
  12. package/src/get-from-api.ts +2 -2
  13. package/src/inject-json-instruction.ts +1 -1
  14. package/src/parse-json-event-stream.ts +3 -3
  15. package/src/parse-json.ts +2 -2
  16. package/src/parse-provider-options.ts +1 -1
  17. package/src/post-to-api.ts +2 -2
  18. package/src/provider-tool-factory.ts +2 -2
  19. package/src/resolve.ts +1 -1
  20. package/src/response-handler.ts +2 -2
  21. package/src/schema.ts +6 -3
  22. package/src/to-json-schema/zod3-to-json-schema/options.ts +3 -3
  23. package/src/to-json-schema/zod3-to-json-schema/parse-def.ts +3 -3
  24. package/src/to-json-schema/zod3-to-json-schema/parse-types.ts +22 -22
  25. package/src/to-json-schema/zod3-to-json-schema/parsers/array.ts +3 -3
  26. package/src/to-json-schema/zod3-to-json-schema/parsers/bigint.ts +1 -1
  27. package/src/to-json-schema/zod3-to-json-schema/parsers/branded.ts +2 -2
  28. package/src/to-json-schema/zod3-to-json-schema/parsers/catch.ts +2 -2
  29. package/src/to-json-schema/zod3-to-json-schema/parsers/date.ts +3 -3
  30. package/src/to-json-schema/zod3-to-json-schema/parsers/default.ts +3 -3
  31. package/src/to-json-schema/zod3-to-json-schema/parsers/effects.ts +3 -3
  32. package/src/to-json-schema/zod3-to-json-schema/parsers/enum.ts +1 -1
  33. package/src/to-json-schema/zod3-to-json-schema/parsers/intersection.ts +4 -4
  34. package/src/to-json-schema/zod3-to-json-schema/parsers/literal.ts +1 -1
  35. package/src/to-json-schema/zod3-to-json-schema/parsers/map.ts +4 -4
  36. package/src/to-json-schema/zod3-to-json-schema/parsers/native-enum.ts +1 -1
  37. package/src/to-json-schema/zod3-to-json-schema/parsers/never.ts +1 -1
  38. package/src/to-json-schema/zod3-to-json-schema/parsers/nullable.ts +4 -4
  39. package/src/to-json-schema/zod3-to-json-schema/parsers/number.ts +1 -1
  40. package/src/to-json-schema/zod3-to-json-schema/parsers/object.ts +3 -3
  41. package/src/to-json-schema/zod3-to-json-schema/parsers/optional.ts +3 -3
  42. package/src/to-json-schema/zod3-to-json-schema/parsers/pipeline.ts +4 -4
  43. package/src/to-json-schema/zod3-to-json-schema/parsers/promise.ts +3 -3
  44. package/src/to-json-schema/zod3-to-json-schema/parsers/readonly.ts +2 -2
  45. package/src/to-json-schema/zod3-to-json-schema/parsers/record.ts +7 -7
  46. package/src/to-json-schema/zod3-to-json-schema/parsers/set.ts +3 -3
  47. package/src/to-json-schema/zod3-to-json-schema/parsers/string.ts +2 -2
  48. package/src/to-json-schema/zod3-to-json-schema/parsers/tuple.ts +3 -3
  49. package/src/to-json-schema/zod3-to-json-schema/parsers/undefined.ts +1 -1
  50. package/src/to-json-schema/zod3-to-json-schema/parsers/union.ts +3 -3
  51. package/src/to-json-schema/zod3-to-json-schema/parsers/unknown.ts +1 -1
  52. package/src/to-json-schema/zod3-to-json-schema/refs.ts +3 -3
  53. package/src/to-json-schema/zod3-to-json-schema/select-parser.ts +2 -2
  54. package/src/to-json-schema/zod3-to-json-schema/zod3-to-json-schema.ts +3 -3
  55. package/src/types/assistant-model-message.ts +3 -3
  56. package/src/types/content-part.ts +3 -3
  57. package/src/types/execute-tool.ts +1 -1
  58. package/src/types/index.ts +2 -1
  59. package/src/types/model-message.ts +4 -4
  60. package/src/types/provider-options.ts +1 -1
  61. package/src/types/system-model-message.ts +1 -1
  62. package/src/types/tool-model-message.ts +3 -3
  63. package/src/types/tool.ts +17 -5
  64. package/src/types/user-model-message.ts +2 -2
  65. package/src/validate-types.ts +5 -2
@@ -1,7 +1,7 @@
1
- import { AssistantModelMessage } from './assistant-model-message';
2
- import { SystemModelMessage } from './system-model-message';
3
- import { ToolModelMessage } from './tool-model-message';
4
- import { UserModelMessage } from './user-model-message';
1
+ import type { AssistantModelMessage } from './assistant-model-message';
2
+ import type { SystemModelMessage } from './system-model-message';
3
+ import type { ToolModelMessage } from './tool-model-message';
4
+ import type { UserModelMessage } from './user-model-message';
5
5
 
6
6
  /**
7
7
  * A message that can be used in the `messages` field of a prompt.
@@ -1,4 +1,4 @@
1
- import { SharedV3ProviderOptions } from '@ai-sdk/provider';
1
+ import type { SharedV3ProviderOptions } from '@ai-sdk/provider';
2
2
 
3
3
  /**
4
4
  * Additional provider-specific options.
@@ -1,4 +1,4 @@
1
- import { ProviderOptions } from './provider-options';
1
+ import type { ProviderOptions } from './provider-options';
2
2
 
3
3
  /**
4
4
  * A system message. It can contain system information.
@@ -1,6 +1,6 @@
1
- import { ToolResultPart } from './content-part';
2
- import { ProviderOptions } from './provider-options';
3
- import { ToolApprovalResponse } from './tool-approval-response';
1
+ import type { ToolResultPart } from './content-part';
2
+ import type { ProviderOptions } from './provider-options';
3
+ import type { ToolApprovalResponse } from './tool-approval-response';
4
4
 
5
5
  /**
6
6
  * A tool message. It contains the result of one or more tool calls.
package/src/types/tool.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { JSONValue } from '@ai-sdk/provider';
2
- import { FlexibleSchema } from '../schema';
3
- import { ToolResultOutput } from './content-part';
4
- import { ModelMessage } from './model-message';
5
- import { ProviderOptions } from './provider-options';
1
+ import type { JSONValue, SharedV3ProviderMetadata } from '@ai-sdk/provider';
2
+ import type { FlexibleSchema } from '../schema';
3
+ import type { ToolResultOutput } from './content-part';
4
+ import type { ModelMessage } from './model-message';
5
+ import type { ProviderOptions } from './provider-options';
6
6
 
7
7
  /**
8
8
  * Additional options that are sent into each tool call.
@@ -128,6 +128,17 @@ export type Tool<
128
128
  */
129
129
  providerOptions?: ProviderOptions;
130
130
 
131
+ /**
132
+ * Optional metadata about the tool itself (e.g. its source).
133
+ *
134
+ * Unlike `providerOptions`, this metadata is not sent to the language
135
+ * model. Instead, it is propagated onto the resulting tool call's
136
+ * `providerMetadata` so consumers can read it from tool call / result
137
+ * parts and UI message parts. This is useful for sources of dynamic
138
+ * tools (e.g. an MCP server) to identify themselves.
139
+ */
140
+ providerMetadata?: SharedV3ProviderMetadata;
141
+
131
142
  /**
132
143
  * The schema of the input that the tool expects.
133
144
  * The language model will use this to generate the input.
@@ -288,6 +299,7 @@ export function dynamicTool(tool: {
288
299
  description?: string;
289
300
  title?: string;
290
301
  providerOptions?: ProviderOptions;
302
+ providerMetadata?: SharedV3ProviderMetadata;
291
303
  inputSchema: FlexibleSchema<unknown>;
292
304
  execute: ToolExecuteFunction<unknown, unknown>;
293
305
 
@@ -1,5 +1,5 @@
1
- import { FilePart, ImagePart, TextPart } from './content-part';
2
- import { ProviderOptions } from './provider-options';
1
+ import type { FilePart, ImagePart, TextPart } from './content-part';
2
+ import type { ProviderOptions } from './provider-options';
3
3
 
4
4
  /**
5
5
  * A user message. It can contain text or a combination of text and images.
@@ -1,5 +1,8 @@
1
- import { TypeValidationContext, TypeValidationError } from '@ai-sdk/provider';
2
- import { FlexibleSchema, asSchema } from './schema';
1
+ import {
2
+ TypeValidationError,
3
+ type TypeValidationContext,
4
+ } from '@ai-sdk/provider';
5
+ import { asSchema, type FlexibleSchema } from './schema';
3
6
 
4
7
  /**
5
8
  * Validates the types of an unknown object using a schema and