@ai-sdk/provider-utils 5.0.0-canary.43 → 5.0.0-canary.44
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 +7 -0
- package/dist/index.d.ts +69 -13
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/types/index.ts +4 -1
- package/src/types/sandbox.ts +56 -1
- package/src/types/tool.ts +14 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @ai-sdk/provider-utils
|
|
2
2
|
|
|
3
|
+
## 5.0.0-canary.44
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6c93e36: feat(provider-utils): add `spawnCommand` method to `Experimental_Sandbox` to allow for detached command execution
|
|
8
|
+
- f617ac2: feat(provider-utils): narrow `tool()` return type to `ExecutableTool<...>` when `execute` is provided
|
|
9
|
+
|
|
3
10
|
## 5.0.0-canary.43
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1171,6 +1171,17 @@ declare const postToApi: <T>({ url, headers, body, successfulResponseHandler, fa
|
|
|
1171
1171
|
*/
|
|
1172
1172
|
type Context = Record<string, unknown>;
|
|
1173
1173
|
|
|
1174
|
+
/**
|
|
1175
|
+
* A tool that is guaranteed to expose an execute function.
|
|
1176
|
+
*/
|
|
1177
|
+
type ExecutableTool<TOOL extends Tool = Tool> = TOOL & {
|
|
1178
|
+
execute: NonNullable<TOOL['execute']>;
|
|
1179
|
+
};
|
|
1180
|
+
/**
|
|
1181
|
+
* Checks whether a tool exposes an execute function.
|
|
1182
|
+
*/
|
|
1183
|
+
declare function isExecutableTool<TOOL extends Tool>(tool: TOOL | undefined): tool is ExecutableTool<TOOL>;
|
|
1184
|
+
|
|
1174
1185
|
type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
|
|
1175
1186
|
|
|
1176
1187
|
/**
|
|
@@ -1310,7 +1321,7 @@ type Experimental_Sandbox = {
|
|
|
1310
1321
|
/**
|
|
1311
1322
|
* Run a command in the sandbox.
|
|
1312
1323
|
*/
|
|
1313
|
-
readonly
|
|
1324
|
+
readonly run: (options: {
|
|
1314
1325
|
/**
|
|
1315
1326
|
* Command to execute in the sandbox.
|
|
1316
1327
|
*/
|
|
@@ -1461,6 +1472,55 @@ type Experimental_Sandbox = {
|
|
|
1461
1472
|
*/
|
|
1462
1473
|
abortSignal?: AbortSignal;
|
|
1463
1474
|
}) => PromiseLike<void>;
|
|
1475
|
+
/**
|
|
1476
|
+
* Spawn a long-running process in the sandbox. Returns immediately with a
|
|
1477
|
+
* handle that streams stdout/stderr, can be waited on, and can be killed.
|
|
1478
|
+
*
|
|
1479
|
+
* `run` is conceptually a thin wrapper over this primitive: spawn,
|
|
1480
|
+
* collect both streams to strings, await `wait()`, return the result.
|
|
1481
|
+
*/
|
|
1482
|
+
readonly spawn: (options: {
|
|
1483
|
+
/**
|
|
1484
|
+
* Command to execute in the sandbox.
|
|
1485
|
+
*/
|
|
1486
|
+
command: string;
|
|
1487
|
+
/**
|
|
1488
|
+
* Working directory to execute the command in.
|
|
1489
|
+
*/
|
|
1490
|
+
workingDirectory?: string;
|
|
1491
|
+
/**
|
|
1492
|
+
* Signal that can be used to abort the process. When aborted, the process
|
|
1493
|
+
* is killed and `wait()` rejects with the abort reason.
|
|
1494
|
+
*/
|
|
1495
|
+
abortSignal?: AbortSignal;
|
|
1496
|
+
}) => PromiseLike<Experimental_SandboxProcess>;
|
|
1497
|
+
};
|
|
1498
|
+
/**
|
|
1499
|
+
* Handle to a long-running process started via `Experimental_Sandbox.spawn`.
|
|
1500
|
+
*/
|
|
1501
|
+
type Experimental_SandboxProcess = {
|
|
1502
|
+
/**
|
|
1503
|
+
* Process identifier, if the sandbox implementation exposes one.
|
|
1504
|
+
*/
|
|
1505
|
+
readonly pid?: number;
|
|
1506
|
+
/**
|
|
1507
|
+
* Stream of bytes written by the process to standard output.
|
|
1508
|
+
*/
|
|
1509
|
+
readonly stdout: ReadableStream<Uint8Array>;
|
|
1510
|
+
/**
|
|
1511
|
+
* Stream of bytes written by the process to standard error.
|
|
1512
|
+
*/
|
|
1513
|
+
readonly stderr: ReadableStream<Uint8Array>;
|
|
1514
|
+
/**
|
|
1515
|
+
* Resolve when the process exits, yielding its exit code.
|
|
1516
|
+
*/
|
|
1517
|
+
wait(): PromiseLike<{
|
|
1518
|
+
exitCode: number;
|
|
1519
|
+
}>;
|
|
1520
|
+
/**
|
|
1521
|
+
* Terminate the process. Idempotent.
|
|
1522
|
+
*/
|
|
1523
|
+
kill(): PromiseLike<void>;
|
|
1464
1524
|
};
|
|
1465
1525
|
|
|
1466
1526
|
/**
|
|
@@ -1768,7 +1828,14 @@ type Tool<INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONVa
|
|
|
1768
1828
|
* Infer the tool type from a tool object.
|
|
1769
1829
|
*
|
|
1770
1830
|
* This is useful for type inference when working with tool objects.
|
|
1831
|
+
*
|
|
1832
|
+
* When the input has an `execute` function, the return type narrows to
|
|
1833
|
+
* `ExecutableTool<Tool<...>>` so that `.execute` is non-nullable without
|
|
1834
|
+
* needing `isExecutableTool` or a `!` assertion at the call site.
|
|
1771
1835
|
*/
|
|
1836
|
+
declare function tool<INPUT, OUTPUT, CONTEXT extends Context>(tool: Tool<INPUT, OUTPUT, CONTEXT> & {
|
|
1837
|
+
execute: ToolExecuteFunction<INPUT, OUTPUT, CONTEXT>;
|
|
1838
|
+
}): ExecutableTool<Tool<INPUT, OUTPUT, CONTEXT>>;
|
|
1772
1839
|
declare function tool<INPUT, OUTPUT, CONTEXT extends Context>(tool: Tool<INPUT, OUTPUT, CONTEXT>): Tool<INPUT, OUTPUT, CONTEXT>;
|
|
1773
1840
|
declare function tool<INPUT, CONTEXT extends Context>(tool: Tool<INPUT, never, CONTEXT>): Tool<INPUT, never, CONTEXT>;
|
|
1774
1841
|
declare function tool<OUTPUT, CONTEXT extends Context>(tool: Tool<never, OUTPUT, CONTEXT>): Tool<never, OUTPUT, CONTEXT>;
|
|
@@ -2099,17 +2166,6 @@ declare function withUserAgentSuffix(headers: HeadersInit | Record<string, strin
|
|
|
2099
2166
|
|
|
2100
2167
|
declare function withoutTrailingSlash(url: string | undefined): string | undefined;
|
|
2101
2168
|
|
|
2102
|
-
/**
|
|
2103
|
-
* A tool that is guaranteed to expose an execute function.
|
|
2104
|
-
*/
|
|
2105
|
-
type ExecutableTool<TOOL extends Tool = Tool> = TOOL & {
|
|
2106
|
-
execute: NonNullable<TOOL['execute']>;
|
|
2107
|
-
};
|
|
2108
|
-
/**
|
|
2109
|
-
* Checks whether a tool exposes an execute function.
|
|
2110
|
-
*/
|
|
2111
|
-
declare function isExecutableTool<TOOL extends Tool>(tool: TOOL | undefined): tool is ExecutableTool<TOOL>;
|
|
2112
|
-
|
|
2113
2169
|
/**
|
|
2114
2170
|
* Detects the `any` type so untyped tools can be treated as having no explicit
|
|
2115
2171
|
* context type.
|
|
@@ -2261,4 +2317,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
2261
2317
|
dynamic?: boolean;
|
|
2262
2318
|
}
|
|
2263
2319
|
|
|
2264
|
-
export { type Arrayable, type AssistantContent, type AssistantModelMessage, type Context, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type DynamicTool, type ExecutableTool, type Experimental_Sandbox, 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, extractLines, 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 };
|
|
2320
|
+
export { type Arrayable, type AssistantContent, type AssistantModelMessage, type Context, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type DynamicTool, type ExecutableTool, type Experimental_Sandbox, type Experimental_SandboxProcess, 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, extractLines, 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
|
@@ -876,7 +876,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
876
876
|
}
|
|
877
877
|
|
|
878
878
|
// src/version.ts
|
|
879
|
-
var VERSION = true ? "5.0.0-canary.
|
|
879
|
+
var VERSION = true ? "5.0.0-canary.44" : "0.0.0-test";
|
|
880
880
|
|
|
881
881
|
// src/get-from-api.ts
|
|
882
882
|
var getOriginalFetch = () => globalThis.fetch;
|