@ai-sdk/provider-utils 5.0.0-canary.44 → 5.0.0-canary.45
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 +81 -116
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/pipeline.ts +6 -4
- package/src/types/index.ts +2 -2
- package/src/types/sandbox.ts +120 -147
- package/src/types/tool-execute-function.ts +2 -2
- package/src/types/tool.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @ai-sdk/provider-utils
|
|
2
2
|
|
|
3
|
+
## 5.0.0-canary.45
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ee798eb: chore(provider-utils): rename `Experimental_Sandbox` to `Experimental_SandboxSession`
|
|
8
|
+
- daf6637: feat(provider-utils): add `env` option to `spawn` and `run` methods of `Experimental_SandboxSession`
|
|
9
|
+
|
|
3
10
|
## 5.0.0-canary.44
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1309,45 +1309,71 @@ type UserContent = string | Array<TextPart | ImagePart | FilePart>;
|
|
|
1309
1309
|
type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessage | ToolModelMessage;
|
|
1310
1310
|
|
|
1311
1311
|
/**
|
|
1312
|
-
*
|
|
1312
|
+
* Options for executing a command in the sandbox via `run` or `spawn`.
|
|
1313
1313
|
*/
|
|
1314
|
-
type
|
|
1314
|
+
type SandboxProcessOptions = {
|
|
1315
|
+
/**
|
|
1316
|
+
* Command to execute in the sandbox.
|
|
1317
|
+
*/
|
|
1318
|
+
command: string;
|
|
1319
|
+
/**
|
|
1320
|
+
* Working directory to execute the command in.
|
|
1321
|
+
*/
|
|
1322
|
+
workingDirectory?: string;
|
|
1323
|
+
/**
|
|
1324
|
+
* Environment variables to set for this command. Merged with the
|
|
1325
|
+
* sandbox's default environment; values here take precedence.
|
|
1326
|
+
* Supporting environment variables as an option is preferable from a
|
|
1327
|
+
* security perspective, e.g. to avoid them leaking in logs.
|
|
1328
|
+
*/
|
|
1329
|
+
env?: Record<string, string>;
|
|
1330
|
+
/**
|
|
1331
|
+
* Signal that can be used to abort the command. When aborted, the running
|
|
1332
|
+
* process is killed; for `spawn`, `wait()` rejects with the abort reason.
|
|
1333
|
+
*/
|
|
1334
|
+
abortSignal?: AbortSignal;
|
|
1335
|
+
};
|
|
1336
|
+
/**
|
|
1337
|
+
* Options for reading a file from the sandbox.
|
|
1338
|
+
*/
|
|
1339
|
+
type ReadFileOptions = {
|
|
1340
|
+
/**
|
|
1341
|
+
* Path of the file to read.
|
|
1342
|
+
*/
|
|
1343
|
+
path: string;
|
|
1344
|
+
/**
|
|
1345
|
+
* Signal that can be used to abort the read.
|
|
1346
|
+
*/
|
|
1347
|
+
abortSignal?: AbortSignal;
|
|
1348
|
+
};
|
|
1349
|
+
/**
|
|
1350
|
+
* Options for writing a file to the sandbox. `CONTENT` is the payload written
|
|
1351
|
+
* to the file: a byte stream, raw bytes, or a string.
|
|
1352
|
+
*/
|
|
1353
|
+
type WriteFileOptions<CONTENT> = {
|
|
1354
|
+
/**
|
|
1355
|
+
* Path of the file to write.
|
|
1356
|
+
*/
|
|
1357
|
+
path: string;
|
|
1358
|
+
/**
|
|
1359
|
+
* Content to write to the file.
|
|
1360
|
+
*/
|
|
1361
|
+
content: CONTENT;
|
|
1362
|
+
/**
|
|
1363
|
+
* Signal that can be used to abort the write.
|
|
1364
|
+
*/
|
|
1365
|
+
abortSignal?: AbortSignal;
|
|
1366
|
+
};
|
|
1367
|
+
/**
|
|
1368
|
+
* Sandbox session that can execute commands and read/write files.
|
|
1369
|
+
*/
|
|
1370
|
+
type SandboxSession = {
|
|
1315
1371
|
/**
|
|
1316
1372
|
* Description of the sandbox environment that can be added to the agent's instructions
|
|
1317
1373
|
* so that the agent knows about relevant details such as the root directory, exposed
|
|
1318
1374
|
* ports, the public hostname, etc.
|
|
1319
1375
|
*/
|
|
1320
1376
|
readonly description: string;
|
|
1321
|
-
/**
|
|
1322
|
-
* Run a command in the sandbox.
|
|
1323
|
-
*/
|
|
1324
|
-
readonly run: (options: {
|
|
1325
|
-
/**
|
|
1326
|
-
* Command to execute in the sandbox.
|
|
1327
|
-
*/
|
|
1328
|
-
command: string;
|
|
1329
|
-
/**
|
|
1330
|
-
* Working directory to execute the command in.
|
|
1331
|
-
*/
|
|
1332
|
-
workingDirectory?: string;
|
|
1333
|
-
/**
|
|
1334
|
-
* Signal that can be used to abort the command.
|
|
1335
|
-
*/
|
|
1336
|
-
abortSignal?: AbortSignal;
|
|
1337
|
-
}) => PromiseLike<{
|
|
1338
|
-
/**
|
|
1339
|
-
* Exit code returned by the command.
|
|
1340
|
-
*/
|
|
1341
|
-
exitCode: number;
|
|
1342
|
-
/**
|
|
1343
|
-
* Standard output produced by the command.
|
|
1344
|
-
*/
|
|
1345
|
-
stdout: string;
|
|
1346
|
-
/**
|
|
1347
|
-
* Standard error produced by the command.
|
|
1348
|
-
*/
|
|
1349
|
-
stderr: string;
|
|
1350
|
-
}>;
|
|
1351
1377
|
/**
|
|
1352
1378
|
* Read one file from the sandbox as a stream of bytes. Resolves to `null`
|
|
1353
1379
|
* when the file does not exist.
|
|
@@ -1356,30 +1382,12 @@ type Experimental_Sandbox = {
|
|
|
1356
1382
|
* read primitive; prefer `readBinaryFile` or `readTextFile` unless you need
|
|
1357
1383
|
* to stream bytes.
|
|
1358
1384
|
*/
|
|
1359
|
-
readonly readFile: (options:
|
|
1360
|
-
/**
|
|
1361
|
-
* Path of the file to read.
|
|
1362
|
-
*/
|
|
1363
|
-
path: string;
|
|
1364
|
-
/**
|
|
1365
|
-
* Signal that can be used to abort the read.
|
|
1366
|
-
*/
|
|
1367
|
-
abortSignal?: AbortSignal;
|
|
1368
|
-
}) => PromiseLike<ReadableStream<Uint8Array> | null>;
|
|
1385
|
+
readonly readFile: (options: ReadFileOptions) => PromiseLike<ReadableStream<Uint8Array> | null>;
|
|
1369
1386
|
/**
|
|
1370
1387
|
* Read one file from the sandbox as raw bytes. Resolves to `null` when the
|
|
1371
1388
|
* file does not exist.
|
|
1372
1389
|
*/
|
|
1373
|
-
readonly readBinaryFile: (options:
|
|
1374
|
-
/**
|
|
1375
|
-
* Path of the file to read.
|
|
1376
|
-
*/
|
|
1377
|
-
path: string;
|
|
1378
|
-
/**
|
|
1379
|
-
* Signal that can be used to abort the read.
|
|
1380
|
-
*/
|
|
1381
|
-
abortSignal?: AbortSignal;
|
|
1382
|
-
}) => PromiseLike<Uint8Array | null>;
|
|
1390
|
+
readonly readBinaryFile: (options: ReadFileOptions) => PromiseLike<Uint8Array | null>;
|
|
1383
1391
|
/**
|
|
1384
1392
|
* Read one text file from the sandbox, decoded using the requested encoding.
|
|
1385
1393
|
* Resolves to `null` when the file does not exist.
|
|
@@ -1387,11 +1395,7 @@ type Experimental_Sandbox = {
|
|
|
1387
1395
|
* Line ranges are 1-based and inclusive. When `endLine` is past EOF the read
|
|
1388
1396
|
* returns through EOF without error.
|
|
1389
1397
|
*/
|
|
1390
|
-
readonly readTextFile: (options: {
|
|
1391
|
-
/**
|
|
1392
|
-
* Path of the file to read.
|
|
1393
|
-
*/
|
|
1394
|
-
path: string;
|
|
1398
|
+
readonly readTextFile: (options: ReadFileOptions & {
|
|
1395
1399
|
/**
|
|
1396
1400
|
* Text encoding used to decode the file bytes. Defaults to `"utf-8"`.
|
|
1397
1401
|
*/
|
|
@@ -1405,10 +1409,6 @@ type Experimental_Sandbox = {
|
|
|
1405
1409
|
* returns through EOF without error.
|
|
1406
1410
|
*/
|
|
1407
1411
|
endLine?: number;
|
|
1408
|
-
/**
|
|
1409
|
-
* Signal that can be used to abort the read.
|
|
1410
|
-
*/
|
|
1411
|
-
abortSignal?: AbortSignal;
|
|
1412
1412
|
}) => PromiseLike<string | null>;
|
|
1413
1413
|
/**
|
|
1414
1414
|
* Write one file to the sandbox from a stream of bytes. Creates parent
|
|
@@ -1417,60 +1417,22 @@ type Experimental_Sandbox = {
|
|
|
1417
1417
|
* This is the lowest-level write primitive; prefer `writeBinaryFile` or
|
|
1418
1418
|
* `writeTextFile` when the full content is already materialized in memory.
|
|
1419
1419
|
*/
|
|
1420
|
-
readonly writeFile: (options:
|
|
1421
|
-
/**
|
|
1422
|
-
* Path of the file to write.
|
|
1423
|
-
*/
|
|
1424
|
-
path: string;
|
|
1425
|
-
/**
|
|
1426
|
-
* Stream of bytes to write.
|
|
1427
|
-
*/
|
|
1428
|
-
content: ReadableStream<Uint8Array>;
|
|
1429
|
-
/**
|
|
1430
|
-
* Signal that can be used to abort the write.
|
|
1431
|
-
*/
|
|
1432
|
-
abortSignal?: AbortSignal;
|
|
1433
|
-
}) => PromiseLike<void>;
|
|
1420
|
+
readonly writeFile: (options: WriteFileOptions<ReadableStream<Uint8Array>>) => PromiseLike<void>;
|
|
1434
1421
|
/**
|
|
1435
1422
|
* Write one file to the sandbox from raw bytes. Creates parent directories
|
|
1436
1423
|
* recursively and overwrites any existing file.
|
|
1437
1424
|
*/
|
|
1438
|
-
readonly writeBinaryFile: (options:
|
|
1439
|
-
/**
|
|
1440
|
-
* Path of the file to write.
|
|
1441
|
-
*/
|
|
1442
|
-
path: string;
|
|
1443
|
-
/**
|
|
1444
|
-
* Raw bytes to write.
|
|
1445
|
-
*/
|
|
1446
|
-
content: Uint8Array;
|
|
1447
|
-
/**
|
|
1448
|
-
* Signal that can be used to abort the write.
|
|
1449
|
-
*/
|
|
1450
|
-
abortSignal?: AbortSignal;
|
|
1451
|
-
}) => PromiseLike<void>;
|
|
1425
|
+
readonly writeBinaryFile: (options: WriteFileOptions<Uint8Array>) => PromiseLike<void>;
|
|
1452
1426
|
/**
|
|
1453
1427
|
* Write one file to the sandbox from a string, encoded using the requested
|
|
1454
1428
|
* encoding. Creates parent directories recursively and overwrites any
|
|
1455
1429
|
* existing file.
|
|
1456
1430
|
*/
|
|
1457
|
-
readonly writeTextFile: (options: {
|
|
1458
|
-
/**
|
|
1459
|
-
* Path of the file to write.
|
|
1460
|
-
*/
|
|
1461
|
-
path: string;
|
|
1462
|
-
/**
|
|
1463
|
-
* Text content to write.
|
|
1464
|
-
*/
|
|
1465
|
-
content: string;
|
|
1431
|
+
readonly writeTextFile: (options: WriteFileOptions<string> & {
|
|
1466
1432
|
/**
|
|
1467
1433
|
* Text encoding used to encode the string to bytes. Defaults to `"utf-8"`.
|
|
1468
1434
|
*/
|
|
1469
1435
|
encoding?: string;
|
|
1470
|
-
/**
|
|
1471
|
-
* Signal that can be used to abort the write.
|
|
1472
|
-
*/
|
|
1473
|
-
abortSignal?: AbortSignal;
|
|
1474
1436
|
}) => PromiseLike<void>;
|
|
1475
1437
|
/**
|
|
1476
1438
|
* Spawn a long-running process in the sandbox. Returns immediately with a
|
|
@@ -1479,26 +1441,29 @@ type Experimental_Sandbox = {
|
|
|
1479
1441
|
* `run` is conceptually a thin wrapper over this primitive: spawn,
|
|
1480
1442
|
* collect both streams to strings, await `wait()`, return the result.
|
|
1481
1443
|
*/
|
|
1482
|
-
readonly spawn: (options:
|
|
1444
|
+
readonly spawn: (options: SandboxProcessOptions) => PromiseLike<SandboxProcess>;
|
|
1445
|
+
/**
|
|
1446
|
+
* Run a command in the sandbox.
|
|
1447
|
+
*/
|
|
1448
|
+
readonly run: (options: SandboxProcessOptions) => PromiseLike<{
|
|
1483
1449
|
/**
|
|
1484
|
-
*
|
|
1450
|
+
* Exit code returned by the command.
|
|
1485
1451
|
*/
|
|
1486
|
-
|
|
1452
|
+
exitCode: number;
|
|
1487
1453
|
/**
|
|
1488
|
-
*
|
|
1454
|
+
* Standard output produced by the command.
|
|
1489
1455
|
*/
|
|
1490
|
-
|
|
1456
|
+
stdout: string;
|
|
1491
1457
|
/**
|
|
1492
|
-
*
|
|
1493
|
-
* is killed and `wait()` rejects with the abort reason.
|
|
1458
|
+
* Standard error produced by the command.
|
|
1494
1459
|
*/
|
|
1495
|
-
|
|
1496
|
-
}
|
|
1460
|
+
stderr: string;
|
|
1461
|
+
}>;
|
|
1497
1462
|
};
|
|
1498
1463
|
/**
|
|
1499
|
-
* Handle to a long-running process started via `
|
|
1464
|
+
* Handle to a long-running process started via `SandboxSession.spawn`.
|
|
1500
1465
|
*/
|
|
1501
|
-
type
|
|
1466
|
+
type SandboxProcess = {
|
|
1502
1467
|
/**
|
|
1503
1468
|
* Process identifier, if the sandbox implementation exposes one.
|
|
1504
1469
|
*/
|
|
@@ -1555,7 +1520,7 @@ interface ToolExecutionOptions<CONTEXT extends Context | unknown | never> {
|
|
|
1555
1520
|
/**
|
|
1556
1521
|
* The sandbox environment that the tool is operating in.
|
|
1557
1522
|
*/
|
|
1558
|
-
experimental_sandbox?:
|
|
1523
|
+
experimental_sandbox?: SandboxSession;
|
|
1559
1524
|
}
|
|
1560
1525
|
/**
|
|
1561
1526
|
* Function that executes the tool and returns either a single result or a stream of results.
|
|
@@ -1723,7 +1688,7 @@ type BaseFunctionTool<INPUT extends JSONValue | unknown | never = any, OUTPUT ex
|
|
|
1723
1688
|
*/
|
|
1724
1689
|
description?: string | ((options: {
|
|
1725
1690
|
context: NoInfer<CONTEXT>;
|
|
1726
|
-
experimental_sandbox?:
|
|
1691
|
+
experimental_sandbox?: SandboxSession;
|
|
1727
1692
|
}) => string);
|
|
1728
1693
|
/**
|
|
1729
1694
|
* Strict mode setting for the tool.
|
|
@@ -2317,4 +2282,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
2317
2282
|
dynamic?: boolean;
|
|
2318
2283
|
}
|
|
2319
2284
|
|
|
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
|
|
2285
|
+
export { type Arrayable, type AssistantContent, type AssistantModelMessage, type Context, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type DynamicTool, type ExecutableTool, type SandboxProcess as Experimental_SandboxProcess, type SandboxSession as Experimental_SandboxSession, 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.45" : "0.0.0-test";
|
|
880
880
|
|
|
881
881
|
// src/get-from-api.ts
|
|
882
882
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -2148,16 +2148,18 @@ var parsePipelineDef = (def, refs) => {
|
|
|
2148
2148
|
} else if (refs.pipeStrategy === "output") {
|
|
2149
2149
|
return parseDef(def.out._def, refs);
|
|
2150
2150
|
}
|
|
2151
|
-
const
|
|
2151
|
+
const inputSchema = parseDef(def.in._def, {
|
|
2152
2152
|
...refs,
|
|
2153
2153
|
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
2154
2154
|
});
|
|
2155
|
-
const
|
|
2155
|
+
const outputSchema = parseDef(def.out._def, {
|
|
2156
2156
|
...refs,
|
|
2157
|
-
currentPath: [...refs.currentPath, "allOf",
|
|
2157
|
+
currentPath: [...refs.currentPath, "allOf", inputSchema ? "1" : "0"]
|
|
2158
2158
|
});
|
|
2159
2159
|
return {
|
|
2160
|
-
allOf: [
|
|
2160
|
+
allOf: [inputSchema, outputSchema].filter(
|
|
2161
|
+
(schema) => schema !== void 0
|
|
2162
|
+
)
|
|
2161
2163
|
};
|
|
2162
2164
|
};
|
|
2163
2165
|
|