@ai-sdk/provider-utils 5.0.0-canary.31 → 5.0.0-canary.33
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.ts +70 -21
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/types/content-part.ts +67 -6
- package/src/types/index.ts +0 -1
- package/src/types/tool.ts +8 -9
- package/src/types/sensitive-context.ts +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @ai-sdk/provider-utils
|
|
2
2
|
|
|
3
|
+
## 5.0.0-canary.33
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2427d88: feat(ai): change Tool.sensitiveContext to telemetry.includeToolsContext and make it opt-in
|
|
8
|
+
|
|
9
|
+
## 5.0.0-canary.32
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- 5463d0d: feat(provider): align tool result output content file part types with top-level message file part types
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [5463d0d]
|
|
18
|
+
- @ai-sdk/provider@4.0.0-canary.16
|
|
19
|
+
|
|
3
20
|
## 5.0.0-canary.31
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -348,6 +348,45 @@ type ToolResultOutput = {
|
|
|
348
348
|
*/
|
|
349
349
|
providerOptions?: ProviderOptions;
|
|
350
350
|
} | {
|
|
351
|
+
type: 'file';
|
|
352
|
+
/**
|
|
353
|
+
* File data as a tagged discriminated union:
|
|
354
|
+
*
|
|
355
|
+
* - `{ type: 'data', data }`: raw bytes
|
|
356
|
+
* (base64 string, Uint8Array, ArrayBuffer, Buffer)
|
|
357
|
+
* - `{ type: 'url', url }`: a URL that points to the file
|
|
358
|
+
* - `{ type: 'reference', reference }`: a provider reference
|
|
359
|
+
* from `uploadFile`
|
|
360
|
+
* - `{ type: 'text', text }`: inline text content (e.g. an inline
|
|
361
|
+
* text document)
|
|
362
|
+
*/
|
|
363
|
+
data: FileData;
|
|
364
|
+
/**
|
|
365
|
+
* Either a full IANA media type (`type/subtype`, e.g. `image/png`) or just
|
|
366
|
+
* the top-level IANA segment (e.g. `image`, `audio`, `video`, `text`).
|
|
367
|
+
*
|
|
368
|
+
* `*`-subtype wildcards (e.g. `image/*`) are normalized as equivalent to the
|
|
369
|
+
* top-level segment alone (e.g. `image`). Providers can use the helpers in
|
|
370
|
+
* `@ai-sdk/provider-utils` (`isFullMediaType`, `getTopLevelMediaType`,
|
|
371
|
+
* `detectMediaType`) to resolve the field according to their API
|
|
372
|
+
* requirements.
|
|
373
|
+
*
|
|
374
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
375
|
+
*/
|
|
376
|
+
mediaType: string;
|
|
377
|
+
/**
|
|
378
|
+
* Optional filename of the file.
|
|
379
|
+
*/
|
|
380
|
+
filename?: string;
|
|
381
|
+
/**
|
|
382
|
+
* Provider-specific options.
|
|
383
|
+
*/
|
|
384
|
+
providerOptions?: ProviderOptions;
|
|
385
|
+
} | {
|
|
386
|
+
/**
|
|
387
|
+
* @deprecated Use 'file' with mediaType + tagged data instead:
|
|
388
|
+
* `{ type: 'file', mediaType, data: { type: 'data', data } }`.
|
|
389
|
+
*/
|
|
351
390
|
type: 'file-data';
|
|
352
391
|
/**
|
|
353
392
|
* Base-64 encoded media data.
|
|
@@ -367,6 +406,10 @@ type ToolResultOutput = {
|
|
|
367
406
|
*/
|
|
368
407
|
providerOptions?: ProviderOptions;
|
|
369
408
|
} | {
|
|
409
|
+
/**
|
|
410
|
+
* @deprecated Use 'file' with mediaType and tagged data instead:
|
|
411
|
+
* `{ type: 'file', mediaType, data: { type: 'url', url: new URL(url) } }`.
|
|
412
|
+
*/
|
|
370
413
|
type: 'file-url';
|
|
371
414
|
/**
|
|
372
415
|
* URL of the file.
|
|
@@ -383,7 +426,8 @@ type ToolResultOutput = {
|
|
|
383
426
|
providerOptions?: ProviderOptions;
|
|
384
427
|
} | {
|
|
385
428
|
/**
|
|
386
|
-
* @deprecated Use file
|
|
429
|
+
* @deprecated Use 'file' with tagged data instead:
|
|
430
|
+
* `{ type: 'file', mediaType, data: { type: 'reference', reference } }`.
|
|
387
431
|
*/
|
|
388
432
|
type: 'file-id';
|
|
389
433
|
/**
|
|
@@ -400,6 +444,10 @@ type ToolResultOutput = {
|
|
|
400
444
|
*/
|
|
401
445
|
providerOptions?: ProviderOptions;
|
|
402
446
|
} | {
|
|
447
|
+
/**
|
|
448
|
+
* @deprecated Use 'file' with tagged data instead:
|
|
449
|
+
* `{ type: 'file', mediaType, data: { type: 'reference', reference } }`.
|
|
450
|
+
*/
|
|
403
451
|
type: 'file-reference';
|
|
404
452
|
/**
|
|
405
453
|
* Provider-specific references for the file.
|
|
@@ -412,7 +460,9 @@ type ToolResultOutput = {
|
|
|
412
460
|
providerOptions?: ProviderOptions;
|
|
413
461
|
} | {
|
|
414
462
|
/**
|
|
415
|
-
* @deprecated Use file
|
|
463
|
+
* @deprecated Use 'file' with mediaType (e.g. 'image' or a specific
|
|
464
|
+
* `image/*` subtype) and tagged data instead:
|
|
465
|
+
* `{ type: 'file', mediaType: 'image', data: { type: 'data', data } }`.
|
|
416
466
|
*/
|
|
417
467
|
type: 'image-data';
|
|
418
468
|
/**
|
|
@@ -430,7 +480,9 @@ type ToolResultOutput = {
|
|
|
430
480
|
providerOptions?: ProviderOptions;
|
|
431
481
|
} | {
|
|
432
482
|
/**
|
|
433
|
-
* @deprecated Use file
|
|
483
|
+
* @deprecated Use 'file' with `mediaType: 'image'` (or a specific
|
|
484
|
+
* `image/*` subtype) and tagged data instead:
|
|
485
|
+
* `{ type: 'file', mediaType: 'image', data: { type: 'url', url: new URL(url) } }`.
|
|
434
486
|
*/
|
|
435
487
|
type: 'image-url';
|
|
436
488
|
/**
|
|
@@ -443,7 +495,9 @@ type ToolResultOutput = {
|
|
|
443
495
|
providerOptions?: ProviderOptions;
|
|
444
496
|
} | {
|
|
445
497
|
/**
|
|
446
|
-
* @deprecated Use file
|
|
498
|
+
* @deprecated Use 'file' with `mediaType: 'image'` (or a specific
|
|
499
|
+
* `image/*` subtype) and tagged data instead:
|
|
500
|
+
* `{ type: 'file', mediaType: 'image', data: { type: 'reference', reference } }`.
|
|
447
501
|
*/
|
|
448
502
|
type: 'image-file-id';
|
|
449
503
|
/**
|
|
@@ -461,7 +515,9 @@ type ToolResultOutput = {
|
|
|
461
515
|
providerOptions?: ProviderOptions;
|
|
462
516
|
} | {
|
|
463
517
|
/**
|
|
464
|
-
* @deprecated Use file
|
|
518
|
+
* @deprecated Use 'file' with `mediaType: 'image'` (or a specific
|
|
519
|
+
* `image/*` subtype) and tagged data instead:
|
|
520
|
+
* `{ type: 'file', mediaType: 'image', data: { type: 'reference', reference } }`.
|
|
465
521
|
*/
|
|
466
522
|
type: 'image-file-reference';
|
|
467
523
|
/**
|
|
@@ -1102,14 +1158,6 @@ type Context = Record<string, unknown>;
|
|
|
1102
1158
|
|
|
1103
1159
|
type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
|
|
1104
1160
|
|
|
1105
|
-
/**
|
|
1106
|
-
* Top-level context properties that contain sensitive data and should be
|
|
1107
|
-
* excluded from telemetry.
|
|
1108
|
-
*/
|
|
1109
|
-
type SensitiveContext<CONTEXT extends Context | unknown | never> = {
|
|
1110
|
-
[KEY in keyof CONTEXT]?: boolean;
|
|
1111
|
-
} | undefined;
|
|
1112
|
-
|
|
1113
1161
|
/**
|
|
1114
1162
|
* Tool approval request prompt part.
|
|
1115
1163
|
*/
|
|
@@ -1363,11 +1411,6 @@ type BaseTool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JS
|
|
|
1363
1411
|
* The context is passed to execute function as part of the execution options.
|
|
1364
1412
|
*/
|
|
1365
1413
|
contextSchema?: FlexibleSchema<CONTEXT>;
|
|
1366
|
-
/**
|
|
1367
|
-
* Marks top-level context properties that contain sensitive data and should be excluded from telemetry.
|
|
1368
|
-
* Properties marked as `true` are omitted from telemetry integrations.
|
|
1369
|
-
*/
|
|
1370
|
-
sensitiveContext?: SensitiveContext<CONTEXT>;
|
|
1371
1414
|
/**
|
|
1372
1415
|
* Whether the tool needs approval before it can be executed.
|
|
1373
1416
|
*
|
|
@@ -1447,14 +1490,16 @@ type BaseFunctionTool<INPUT extends JSONValue | unknown | never = any, OUTPUT ex
|
|
|
1447
1490
|
supportsDeferredResults?: never;
|
|
1448
1491
|
};
|
|
1449
1492
|
/**
|
|
1450
|
-
* Tool with user-defined input and output schemas.
|
|
1493
|
+
* Tool with user-defined input and output schemas that is executed by the AI SDK.
|
|
1451
1494
|
*/
|
|
1452
1495
|
type FunctionTool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONValue | unknown | never = any, CONTEXT extends Context | unknown | never = any> = BaseFunctionTool<INPUT, OUTPUT, CONTEXT> & {
|
|
1453
1496
|
type?: undefined | 'function';
|
|
1454
1497
|
};
|
|
1455
1498
|
/**
|
|
1456
|
-
* Tool that is defined at runtime
|
|
1499
|
+
* Tool that is defined at runtime.
|
|
1457
1500
|
* The types of input and output are not known at development time.
|
|
1501
|
+
*
|
|
1502
|
+
* For example, MCP tools that are not known at development time.
|
|
1458
1503
|
*/
|
|
1459
1504
|
type DynamicTool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONValue | unknown | never = any, CONTEXT extends Context | unknown | never = any> = BaseFunctionTool<INPUT, OUTPUT, CONTEXT> & {
|
|
1460
1505
|
type: 'dynamic';
|
|
@@ -1479,6 +1524,8 @@ type BaseProviderTool<INPUT extends JSONValue | unknown | never = any, OUTPUT ex
|
|
|
1479
1524
|
/**
|
|
1480
1525
|
* Tool with provider-defined input and output schemas that is executed by the
|
|
1481
1526
|
* user.
|
|
1527
|
+
*
|
|
1528
|
+
* For example, shell tools that are executed in a local shell, but have provider-defined input and output schemas.
|
|
1482
1529
|
*/
|
|
1483
1530
|
type ProviderDefinedTool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONValue | unknown | never = any, CONTEXT extends Context | unknown | never = any> = BaseProviderTool<INPUT, OUTPUT, CONTEXT> & {
|
|
1484
1531
|
/**
|
|
@@ -1490,6 +1537,8 @@ type ProviderDefinedTool<INPUT extends JSONValue | unknown | never = any, OUTPUT
|
|
|
1490
1537
|
/**
|
|
1491
1538
|
* Tool with provider-defined input and output schemas that is executed by the
|
|
1492
1539
|
* provider.
|
|
1540
|
+
*
|
|
1541
|
+
* For example, web search tools and code execution tools that are executed by the provider itself.
|
|
1493
1542
|
*/
|
|
1494
1543
|
type ProviderExecutedTool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONValue | unknown | never = any, CONTEXT extends Context | unknown | never = any> = BaseProviderTool<INPUT, OUTPUT, CONTEXT> & {
|
|
1495
1544
|
/**
|
|
@@ -1981,4 +2030,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
1981
2030
|
dynamic?: boolean;
|
|
1982
2031
|
}
|
|
1983
2032
|
|
|
1984
|
-
export { type Arrayable, type AssistantContent, type AssistantModelMessage, type Context, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type DynamicTool, type ExecutableTool, type FetchFunction, type FileData, type FileDataData, type FileDataReference, type FileDataText, type FileDataUrl, type FilePart, type FlexibleSchema, type FunctionTool, type HasRequiredKey, type IdGenerator, type ImagePart, type InferSchema, type InferToolContext, type InferToolInput, type InferToolOutput, type InferToolSetContext, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderDefinedTool, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderExecutedTool, type ProviderExecutedToolFactory, type ProviderOptions, type ProviderReference, type ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type
|
|
2033
|
+
export { type Arrayable, type AssistantContent, type AssistantModelMessage, type Context, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type DynamicTool, type ExecutableTool, type FetchFunction, type FileData, type FileDataData, type FileDataReference, type FileDataText, type FileDataUrl, type FilePart, type FlexibleSchema, type FunctionTool, type HasRequiredKey, type IdGenerator, type ImagePart, type InferSchema, type InferToolContext, type InferToolInput, type InferToolOutput, type InferToolSetContext, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderDefinedTool, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderExecutedTool, type ProviderExecutedToolFactory, type ProviderOptions, type ProviderReference, type ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type StreamingToolCallDelta, StreamingToolCallTracker, type StreamingToolCallTrackerOptions, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type ToolSet, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asArray, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertInlineFileDataToUint8Array, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, detectMediaType, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, filterNullable, generateId, getFromApi, getRuntimeEnvironmentUserAgent, getTopLevelMediaType, injectJsonInstructionIntoMessages, isAbortError, isBuffer, isCustomReasoning, isExecutableTool, isFullMediaType, isNonNullable, isParsableJson, isProviderReference, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, serializeModelOptions, stripFileExtension, tool, validateDownloadUrl, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.js
CHANGED
|
@@ -862,7 +862,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
862
862
|
}
|
|
863
863
|
|
|
864
864
|
// src/version.ts
|
|
865
|
-
var VERSION = true ? "5.0.0-canary.
|
|
865
|
+
var VERSION = true ? "5.0.0-canary.33" : "0.0.0-test";
|
|
866
866
|
|
|
867
867
|
// src/get-from-api.ts
|
|
868
868
|
var getOriginalFetch = () => globalThis.fetch;
|