🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@ai-sdk/provider-utils

Package Overview
Dependencies
Maintainers
3
Versions
326
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/provider-utils - npm Package Compare versions

Comparing version
5.0.0-canary.44
to
5.0.0-canary.45
+7
-0
CHANGELOG.md
# @ai-sdk/provider-utils
## 5.0.0-canary.45
### Patch Changes
- ee798eb: chore(provider-utils): rename `Experimental_Sandbox` to `Experimental_SandboxSession`
- daf6637: feat(provider-utils): add `env` option to `spawn` and `run` methods of `Experimental_SandboxSession`
## 5.0.0-canary.44

@@ -4,0 +11,0 @@

+1
-1
{
"name": "@ai-sdk/provider-utils",
"version": "5.0.0-canary.44",
"version": "5.0.0-canary.45",
"type": "module",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -17,14 +17,16 @@ import type { ZodPipelineDef } from 'zod/v3';

const a = parseDef(def.in._def, {
const inputSchema = parseDef(def.in._def, {
...refs,
currentPath: [...refs.currentPath, 'allOf', '0'],
});
const b = parseDef(def.out._def, {
const outputSchema = parseDef(def.out._def, {
...refs,
currentPath: [...refs.currentPath, 'allOf', a ? '1' : '0'],
currentPath: [...refs.currentPath, 'allOf', inputSchema ? '1' : '0'],
});
return {
allOf: [a, b].filter((x): x is JsonSchema7Type => x !== undefined),
allOf: [inputSchema, outputSchema].filter(
(schema): schema is JsonSchema7Type => schema !== undefined,
),
};
};

@@ -35,4 +35,4 @@ export type {

export type {
Experimental_Sandbox,
Experimental_SandboxProcess,
SandboxSession as Experimental_SandboxSession,
SandboxProcess as Experimental_SandboxProcess,
} from './sandbox';

@@ -39,0 +39,0 @@ export type { SystemModelMessage } from './system-model-message';

/**
* Sandbox environment that can execute commands and read/write files.
* Options for executing a command in the sandbox via `run` or `spawn`.
*/
export type Experimental_Sandbox = {
type SandboxProcessOptions = {
/**
* Description of the sandbox environment that can be added to the agent's instructions
* so that the agent knows about relevant details such as the root directory, exposed
* ports, the public hostname, etc.
* Command to execute in the sandbox.
*/
readonly description: string;
command: string;
/**
* Run a command in the sandbox.
* Working directory to execute the command in.
*/
readonly run: (options: {
/**
* Command to execute in the sandbox.
*/
command: string;
workingDirectory?: string;
/**
* Working directory to execute the command in.
*/
workingDirectory?: string;
/**
* Environment variables to set for this command. Merged with the
* sandbox's default environment; values here take precedence.
* Supporting environment variables as an option is preferable from a
* security perspective, e.g. to avoid them leaking in logs.
*/
env?: Record<string, string>;
/**
* Signal that can be used to abort the command.
*/
abortSignal?: AbortSignal;
}) => PromiseLike<{
/**
* Exit code returned by the command.
*/
exitCode: number;
/**
* Signal that can be used to abort the command. When aborted, the running
* process is killed; for `spawn`, `wait()` rejects with the abort reason.
*/
abortSignal?: AbortSignal;
};
/**
* Standard output produced by the command.
*/
stdout: string;
/**
* Options for reading a file from the sandbox.
*/
type ReadFileOptions = {
/**
* Path of the file to read.
*/
path: string;
/**
* Standard error produced by the command.
*/
stderr: string;
}>;
/**
* Signal that can be used to abort the read.
*/
abortSignal?: AbortSignal;
};
/**
* Options for writing a file to the sandbox. `CONTENT` is the payload written
* to the file: a byte stream, raw bytes, or a string.
*/
type WriteFileOptions<CONTENT> = {
/**
* Path of the file to write.
*/
path: string;
/**
* Content to write to the file.
*/
content: CONTENT;
/**
* Signal that can be used to abort the write.
*/
abortSignal?: AbortSignal;
};
/**
* Sandbox session that can execute commands and read/write files.
*/
export type SandboxSession = {
/**
* Description of the sandbox environment that can be added to the agent's instructions
* so that the agent knows about relevant details such as the root directory, exposed
* ports, the public hostname, etc.
*/
readonly description: string;
/**
* Read one file from the sandbox as a stream of bytes. Resolves to `null`

@@ -55,14 +85,6 @@ * when the file does not exist.

*/
readonly readFile: (options: {
/**
* Path of the file to read.
*/
path: string;
readonly readFile: (
options: ReadFileOptions,
) => PromiseLike<ReadableStream<Uint8Array> | null>;
/**
* Signal that can be used to abort the read.
*/
abortSignal?: AbortSignal;
}) => PromiseLike<ReadableStream<Uint8Array> | null>;
/**

@@ -72,14 +94,6 @@ * Read one file from the sandbox as raw bytes. Resolves to `null` when the

*/
readonly readBinaryFile: (options: {
/**
* Path of the file to read.
*/
path: string;
readonly readBinaryFile: (
options: ReadFileOptions,
) => PromiseLike<Uint8Array | null>;
/**
* Signal that can be used to abort the read.
*/
abortSignal?: AbortSignal;
}) => PromiseLike<Uint8Array | null>;
/**

@@ -92,30 +106,22 @@ * Read one text file from the sandbox, decoded using the requested encoding.

*/
readonly readTextFile: (options: {
/**
* Path of the file to read.
*/
path: string;
readonly readTextFile: (
options: ReadFileOptions & {
/**
* Text encoding used to decode the file bytes. Defaults to `"utf-8"`.
*/
encoding?: string;
/**
* Text encoding used to decode the file bytes. Defaults to `"utf-8"`.
*/
encoding?: string;
/**
* 1-based inclusive start line. Defaults to 1.
*/
startLine?: number;
/**
* 1-based inclusive start line. Defaults to 1.
*/
startLine?: number;
/**
* 1-based inclusive end line. When past the file's line count, the read
* returns through EOF without error.
*/
endLine?: number;
},
) => PromiseLike<string | null>;
/**
* 1-based inclusive end line. When past the file's line count, the read
* returns through EOF without error.
*/
endLine?: number;
/**
* Signal that can be used to abort the read.
*/
abortSignal?: AbortSignal;
}) => PromiseLike<string | null>;
/**

@@ -128,19 +134,6 @@ * Write one file to the sandbox from a stream of bytes. Creates parent

*/
readonly writeFile: (options: {
/**
* Path of the file to write.
*/
path: string;
readonly writeFile: (
options: WriteFileOptions<ReadableStream<Uint8Array>>,
) => PromiseLike<void>;
/**
* Stream of bytes to write.
*/
content: ReadableStream<Uint8Array>;
/**
* Signal that can be used to abort the write.
*/
abortSignal?: AbortSignal;
}) => PromiseLike<void>;
/**

@@ -150,19 +143,6 @@ * Write one file to the sandbox from raw bytes. Creates parent directories

*/
readonly writeBinaryFile: (options: {
/**
* Path of the file to write.
*/
path: string;
readonly writeBinaryFile: (
options: WriteFileOptions<Uint8Array>,
) => PromiseLike<void>;
/**
* Raw bytes to write.
*/
content: Uint8Array;
/**
* Signal that can be used to abort the write.
*/
abortSignal?: AbortSignal;
}) => PromiseLike<void>;
/**

@@ -173,24 +153,11 @@ * Write one file to the sandbox from a string, encoded using the requested

*/
readonly writeTextFile: (options: {
/**
* Path of the file to write.
*/
path: string;
readonly writeTextFile: (
options: WriteFileOptions<string> & {
/**
* Text encoding used to encode the string to bytes. Defaults to `"utf-8"`.
*/
encoding?: string;
},
) => PromiseLike<void>;
/**
* Text content to write.
*/
content: string;
/**
* Text encoding used to encode the string to bytes. Defaults to `"utf-8"`.
*/
encoding?: string;
/**
* Signal that can be used to abort the write.
*/
abortSignal?: AbortSignal;
}) => PromiseLike<void>;
/**

@@ -203,25 +170,31 @@ * Spawn a long-running process in the sandbox. Returns immediately with a

*/
readonly spawn: (options: {
readonly spawn: (
options: SandboxProcessOptions,
) => PromiseLike<SandboxProcess>;
/**
* Run a command in the sandbox.
*/
readonly run: (options: SandboxProcessOptions) => PromiseLike<{
/**
* Command to execute in the sandbox.
* Exit code returned by the command.
*/
command: string;
exitCode: number;
/**
* Working directory to execute the command in.
* Standard output produced by the command.
*/
workingDirectory?: string;
stdout: string;
/**
* Signal that can be used to abort the process. When aborted, the process
* is killed and `wait()` rejects with the abort reason.
* Standard error produced by the command.
*/
abortSignal?: AbortSignal;
}) => PromiseLike<Experimental_SandboxProcess>;
stderr: string;
}>;
};
/**
* Handle to a long-running process started via `Experimental_Sandbox.spawn`.
* Handle to a long-running process started via `SandboxSession.spawn`.
*/
export type Experimental_SandboxProcess = {
export type SandboxProcess = {
/**

@@ -228,0 +201,0 @@ * Process identifier, if the sandbox implementation exposes one.

import type { Context } from './context';
import type { ModelMessage } from './model-message';
import type { Experimental_Sandbox as Sandbox } from './sandbox';
import type { SandboxSession } from './sandbox';

@@ -43,3 +43,3 @@ /**

*/
experimental_sandbox?: Sandbox;
experimental_sandbox?: SandboxSession;
}

@@ -46,0 +46,0 @@

@@ -13,3 +13,3 @@ import type { JSONValue, JSONObject } from '@ai-sdk/provider';

import type { ToolNeedsApprovalFunction } from './tool-needs-approval-function';
import type { Experimental_Sandbox as Sandbox } from './sandbox';
import type { SandboxSession } from './sandbox';

@@ -194,3 +194,3 @@ /**

context: NoInfer<CONTEXT>;
experimental_sandbox?: Sandbox;
experimental_sandbox?: SandboxSession;
}) => string);

@@ -197,0 +197,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display