agent-neckbeard 1.1.7 → 1.1.9
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/README.md +114 -53
- package/dist/index.cjs +360 -475
- package/dist/index.d.cts +49 -75
- package/dist/index.d.ts +49 -75
- package/dist/index.js +310 -465
- package/dist/{invoke-client-Y3NPRFEE.js → invoke-client-WYMFPR3F.js} +45 -11
- package/dist/runtime/server.js +163 -0
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -147,21 +147,19 @@ interface AgentSharedConfig<TInput> {
|
|
|
147
147
|
build?: BuildOptions;
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
|
-
*
|
|
151
|
-
* validated output.
|
|
152
|
-
*
|
|
150
|
+
* Run-output agent config: a handler that receives input and returns one
|
|
151
|
+
* validated output. The handler runs inside the persistent sandbox server;
|
|
152
|
+
* each `run()` call is a POST to that server.
|
|
153
153
|
*/
|
|
154
|
-
interface
|
|
154
|
+
interface RunAgentConfig<TInput, TOutput> extends AgentSharedConfig<TInput> {
|
|
155
155
|
outputSchema: SchemaLike<TOutput>;
|
|
156
156
|
run: (input: TInput, ctx: AgentRunContext) => Promise<TOutput>;
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
|
-
*
|
|
160
|
-
* sandbox
|
|
159
|
+
* Streaming agent config: deploys the same long-running HTTP server into the
|
|
160
|
+
* sandbox and streams emitted frames from POST /invoke calls as SSE.
|
|
161
161
|
* Use this when turns benefit from real-time progress streaming, cancel
|
|
162
162
|
* signals, or bidirectional tool approvals.
|
|
163
|
-
*
|
|
164
|
-
* See .plans/server-mode-agents.md for the full design.
|
|
165
163
|
*/
|
|
166
164
|
interface ServerAgentConfig<TInput, TFrame> extends AgentSharedConfig<TInput> {
|
|
167
165
|
server: {
|
|
@@ -210,24 +208,17 @@ interface DaytonaSandboxConfig {
|
|
|
210
208
|
}
|
|
211
209
|
type SandboxConfig = E2BSandboxConfig | DaytonaSandboxConfig;
|
|
212
210
|
/**
|
|
213
|
-
* Agent config accepted by `new Agent(config)`. Can be either
|
|
214
|
-
* (
|
|
211
|
+
* Agent config accepted by `new Agent(config)`. Can be either request/response
|
|
212
|
+
* (`run`) or streaming (`server.handler`). Both run behind the same persistent
|
|
213
|
+
* in-sandbox HTTP server.
|
|
215
214
|
* Mode is discriminated at runtime by the presence of `server` vs `run`.
|
|
216
215
|
*/
|
|
217
|
-
type AgentConfig<TInput, TOutput, TFrame = unknown> =
|
|
218
|
-
|
|
219
|
-
* Returned by `deploy()` for server-mode agents. Callers should persist
|
|
220
|
-
* `sandboxId`, `serverUrl`, `authToken`, and `previewToken` so subsequent
|
|
221
|
-
* invocations can reconnect without redeploying.
|
|
222
|
-
*/
|
|
223
|
-
interface ServerDeployResult {
|
|
224
|
-
mode: 'server';
|
|
216
|
+
type AgentConfig<TInput, TOutput, TFrame = unknown> = RunAgentConfig<TInput, TOutput> | ServerAgentConfig<TInput, TFrame>;
|
|
217
|
+
interface RuntimeConnection {
|
|
225
218
|
sandboxId: string;
|
|
226
219
|
serverUrl: string;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
/** Daytona preview URL auth token; appended by invoke() as `?token=...`. */
|
|
230
|
-
previewToken: string;
|
|
220
|
+
provider: SandboxProvider;
|
|
221
|
+
trafficToken?: string;
|
|
231
222
|
}
|
|
232
223
|
/**
|
|
233
224
|
* Normalizes a path captured from a stack trace into a real on-disk file
|
|
@@ -242,15 +233,15 @@ interface ServerDeployResult {
|
|
|
242
233
|
* @internal Exported for testing.
|
|
243
234
|
*/
|
|
244
235
|
declare function normalizeStackFramePath(rawPath: string, cwd?: string): string | null;
|
|
245
|
-
type AgentMode = '
|
|
236
|
+
type AgentMode = 'run' | 'stream';
|
|
246
237
|
declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
247
238
|
readonly sandbox: SandboxConfig;
|
|
248
239
|
readonly provider: SandboxProvider;
|
|
249
240
|
readonly template: string;
|
|
250
241
|
readonly inputSchema: SchemaLike<TInput>;
|
|
251
|
-
/** Only populated for
|
|
242
|
+
/** Only populated for run-output agents; undefined for streaming agents. */
|
|
252
243
|
readonly outputSchema?: SchemaLike<TOutput>;
|
|
253
|
-
/** Only populated for
|
|
244
|
+
/** Only populated for streaming agents; undefined for run-output agents. */
|
|
254
245
|
readonly frameSchema?: SchemaLike<TFrame>;
|
|
255
246
|
readonly mode: AgentMode;
|
|
256
247
|
readonly maxDuration: number;
|
|
@@ -259,34 +250,37 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
259
250
|
readonly claudeDir?: string;
|
|
260
251
|
readonly envs: Record<string, string | undefined>;
|
|
261
252
|
readonly build: BuildOptions;
|
|
262
|
-
/** @internal Used by the sandbox
|
|
253
|
+
/** @internal Used by the in-sandbox server for run-output agents. */
|
|
263
254
|
_run?: (input: TInput, ctx: AgentRunContext) => Promise<TOutput>;
|
|
264
|
-
/** @internal Used by the in-sandbox
|
|
255
|
+
/** @internal Used by the in-sandbox server for streaming agents. */
|
|
265
256
|
_server?: ServerAgentConfig<TInput, TFrame>['server'];
|
|
266
|
-
/** @internal Runtime state populated by deploy()
|
|
257
|
+
/** @internal Runtime state populated by deploy(). */
|
|
267
258
|
_serverRuntime?: {
|
|
268
|
-
sessionId
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
previewToken: string;
|
|
259
|
+
sessionId?: string;
|
|
260
|
+
commandId?: string;
|
|
261
|
+
connection: RuntimeConnection;
|
|
272
262
|
};
|
|
273
|
-
private _sourceFile;
|
|
274
263
|
private _sandboxId?;
|
|
275
|
-
|
|
264
|
+
private _sourceFile;
|
|
265
|
+
constructor(config: RunAgentConfig<TInput, TOutput>);
|
|
276
266
|
constructor(config: ServerAgentConfig<TInput, TFrame>);
|
|
277
267
|
constructor(config: AgentConfig<TInput, TOutput, TFrame>);
|
|
278
268
|
get sandboxId(): string | undefined;
|
|
279
269
|
private get sandboxEnv();
|
|
280
270
|
private createSandboxHandle;
|
|
281
271
|
private connectSandboxHandle;
|
|
282
|
-
private
|
|
272
|
+
private readRuntimeServerConfig;
|
|
273
|
+
private createRuntimeConnection;
|
|
274
|
+
private healthUrlFor;
|
|
275
|
+
private startRuntimeServer;
|
|
276
|
+
private resolveRuntimeConnection;
|
|
283
277
|
/**
|
|
284
|
-
* Kills the current sandbox and resets the cached
|
|
278
|
+
* Kills the current sandbox and resets the cached runtime.
|
|
285
279
|
*
|
|
286
280
|
* Use this to clean up sandbox resources after a run, especially when
|
|
287
281
|
* running multiple evaluations that each need their own sandbox.
|
|
288
282
|
*
|
|
289
|
-
* @param
|
|
283
|
+
* @param target - Optional sandbox ID to kill. Defaults to the cached sandbox.
|
|
290
284
|
*
|
|
291
285
|
* @example
|
|
292
286
|
* ```typescript
|
|
@@ -295,18 +289,19 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
295
289
|
* await agent.kill(sandboxId);
|
|
296
290
|
* ```
|
|
297
291
|
*/
|
|
298
|
-
kill(
|
|
292
|
+
kill(target?: string): Promise<void>;
|
|
299
293
|
/**
|
|
300
294
|
* Deploys the agent to a sandbox provider.
|
|
301
295
|
*
|
|
302
296
|
* This method bundles the agent code using esbuild, creates a new sandbox,
|
|
303
297
|
* installs any specified OS dependencies, downloads configured files, and
|
|
304
|
-
* uploads the agent code
|
|
298
|
+
* uploads the agent and runtime server code, then starts a long-running HTTP
|
|
299
|
+
* server inside the sandbox.
|
|
305
300
|
*
|
|
306
301
|
* @param options.fresh - When true, always creates a new sandbox without caching.
|
|
307
302
|
* Useful for concurrent evaluations where each run needs its own sandbox.
|
|
308
303
|
* The returned sandbox ID won't be stored on the instance.
|
|
309
|
-
* @returns The sandbox ID
|
|
304
|
+
* @returns The sandbox ID. Persist this ID when another host process should reuse the sandbox.
|
|
310
305
|
* @throws {ConfigurationError} If the selected provider credentials are not set
|
|
311
306
|
* @throws {DeploymentError} If sandbox creation, dependency installation, or file upload fails
|
|
312
307
|
*
|
|
@@ -317,39 +312,26 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
317
312
|
* console.log(`Deployed to sandbox: ${sandboxId}`);
|
|
318
313
|
*
|
|
319
314
|
* // For concurrent evals: each call gets its own sandbox
|
|
320
|
-
* const
|
|
321
|
-
* const result = await agent.run(input, { sandboxId
|
|
322
|
-
* await agent.kill(
|
|
315
|
+
* const sandboxId = await agent.deploy({ fresh: true });
|
|
316
|
+
* const result = await agent.run(input, { sandboxId });
|
|
317
|
+
* await agent.kill(sandboxId);
|
|
323
318
|
* ```
|
|
324
319
|
*/
|
|
325
|
-
/**
|
|
326
|
-
* Deploy a one-shot agent. Throws if called on a server-mode agent; use
|
|
327
|
-
* `deployServer()` for those. Returns the sandbox id so callers can pass it
|
|
328
|
-
* to `run(input, { sandboxId })`.
|
|
329
|
-
*/
|
|
330
320
|
deploy(options?: {
|
|
331
321
|
fresh?: boolean;
|
|
332
322
|
}): Promise<string>;
|
|
333
|
-
/**
|
|
334
|
-
* Deploy a server-mode agent. Throws if called on a one-shot agent; use
|
|
335
|
-
* `deploy()` for those. Returns the sandbox id, public server URL, bearer
|
|
336
|
-
* token, and Daytona preview token that `invoke()` needs to stream.
|
|
337
|
-
*/
|
|
338
|
-
deployServer(options?: {
|
|
339
|
-
fresh?: boolean;
|
|
340
|
-
}): Promise<ServerDeployResult>;
|
|
341
323
|
private _deploy;
|
|
342
324
|
/**
|
|
343
325
|
* Executes the agent with the given input.
|
|
344
326
|
*
|
|
345
|
-
* The agent must be deployed before calling this method, or a
|
|
346
|
-
* be provided in the options. Input is validated against the input
|
|
347
|
-
* then
|
|
348
|
-
*
|
|
327
|
+
* The agent must be deployed before calling this method, or a sandbox ID
|
|
328
|
+
* must be provided in the options. Input is validated against the input
|
|
329
|
+
* schema, then POSTed to the in-sandbox server. Output is validated against
|
|
330
|
+
* the output schema before being returned.
|
|
349
331
|
*
|
|
350
332
|
* @param input - The input data for the agent, must conform to inputSchema
|
|
351
333
|
* @param options - Optional configuration for this run
|
|
352
|
-
* @param options.sandboxId - Sandbox ID to use, overrides the
|
|
334
|
+
* @param options.sandboxId - Sandbox ID to use, overrides the cached sandbox
|
|
353
335
|
* @returns A result object indicating success or failure with output or error
|
|
354
336
|
*
|
|
355
337
|
* @example
|
|
@@ -357,29 +339,21 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
357
339
|
* // Using deployed sandbox
|
|
358
340
|
* const result = await agent.run({ prompt: 'Hello, world!' });
|
|
359
341
|
*
|
|
360
|
-
* //
|
|
361
|
-
* const result = await agent.run({ prompt: 'Hello!' }, { sandboxId
|
|
342
|
+
* // Reconnecting from another process
|
|
343
|
+
* const result = await agent.run({ prompt: 'Hello!' }, { sandboxId });
|
|
362
344
|
* ```
|
|
363
345
|
*/
|
|
364
346
|
run(input: TInput, options?: {
|
|
365
347
|
sandboxId?: string;
|
|
366
348
|
}): Promise<AgentRunResult<TOutput>>;
|
|
367
349
|
/**
|
|
368
|
-
* Invoke a
|
|
369
|
-
*
|
|
370
|
-
* `server: {...}` config; one-shot agents should use `run()` instead.
|
|
371
|
-
*
|
|
372
|
-
* Requires the agent to be deployed via `deploy()` (returns `serverUrl` and
|
|
373
|
-
* `authToken`) — callers must persist those values and pass them on each
|
|
374
|
-
* invocation. Deploy is not yet implemented for server mode; this method
|
|
375
|
-
* currently throws `ConfigurationError` if `serverUrl` is not supplied.
|
|
350
|
+
* Invoke a streaming agent. Streams user frames emitted by the in-sandbox
|
|
351
|
+
* handler as an async iterator.
|
|
376
352
|
*/
|
|
377
353
|
invoke(input: TInput, options?: {
|
|
378
|
-
|
|
379
|
-
authToken?: string;
|
|
380
|
-
previewToken?: string;
|
|
354
|
+
sandboxId?: string;
|
|
381
355
|
signal?: AbortSignal;
|
|
382
356
|
}): AsyncGenerator<TFrame>;
|
|
383
357
|
}
|
|
384
358
|
|
|
385
|
-
export { Agent, type AgentConfig, type AgentMode, type AgentRunContext, type AgentRunResult, type AgentSandboxContext, type BuildOptions, ConfigurationError, DEFAULT_DEPENDENCIES, type DaytonaSandboxConfig, DeploymentError, type E2BSandboxConfig, ExecutionError, type FileDownload, NeckbeardError, type
|
|
359
|
+
export { Agent, type AgentConfig, type AgentMode, type AgentRunContext, type AgentRunResult, type AgentSandboxContext, type BuildOptions, ConfigurationError, DEFAULT_DEPENDENCIES, type DaytonaSandboxConfig, DeploymentError, type E2BSandboxConfig, ExecutionError, type FileDownload, NeckbeardError, type OsDependencies, type RunAgentConfig, type SandboxConfig, type SandboxProvider, type ServerAgentConfig, ValidationError, normalizeStackFramePath };
|
package/dist/index.d.ts
CHANGED
|
@@ -147,21 +147,19 @@ interface AgentSharedConfig<TInput> {
|
|
|
147
147
|
build?: BuildOptions;
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
|
-
*
|
|
151
|
-
* validated output.
|
|
152
|
-
*
|
|
150
|
+
* Run-output agent config: a handler that receives input and returns one
|
|
151
|
+
* validated output. The handler runs inside the persistent sandbox server;
|
|
152
|
+
* each `run()` call is a POST to that server.
|
|
153
153
|
*/
|
|
154
|
-
interface
|
|
154
|
+
interface RunAgentConfig<TInput, TOutput> extends AgentSharedConfig<TInput> {
|
|
155
155
|
outputSchema: SchemaLike<TOutput>;
|
|
156
156
|
run: (input: TInput, ctx: AgentRunContext) => Promise<TOutput>;
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
|
-
*
|
|
160
|
-
* sandbox
|
|
159
|
+
* Streaming agent config: deploys the same long-running HTTP server into the
|
|
160
|
+
* sandbox and streams emitted frames from POST /invoke calls as SSE.
|
|
161
161
|
* Use this when turns benefit from real-time progress streaming, cancel
|
|
162
162
|
* signals, or bidirectional tool approvals.
|
|
163
|
-
*
|
|
164
|
-
* See .plans/server-mode-agents.md for the full design.
|
|
165
163
|
*/
|
|
166
164
|
interface ServerAgentConfig<TInput, TFrame> extends AgentSharedConfig<TInput> {
|
|
167
165
|
server: {
|
|
@@ -210,24 +208,17 @@ interface DaytonaSandboxConfig {
|
|
|
210
208
|
}
|
|
211
209
|
type SandboxConfig = E2BSandboxConfig | DaytonaSandboxConfig;
|
|
212
210
|
/**
|
|
213
|
-
* Agent config accepted by `new Agent(config)`. Can be either
|
|
214
|
-
* (
|
|
211
|
+
* Agent config accepted by `new Agent(config)`. Can be either request/response
|
|
212
|
+
* (`run`) or streaming (`server.handler`). Both run behind the same persistent
|
|
213
|
+
* in-sandbox HTTP server.
|
|
215
214
|
* Mode is discriminated at runtime by the presence of `server` vs `run`.
|
|
216
215
|
*/
|
|
217
|
-
type AgentConfig<TInput, TOutput, TFrame = unknown> =
|
|
218
|
-
|
|
219
|
-
* Returned by `deploy()` for server-mode agents. Callers should persist
|
|
220
|
-
* `sandboxId`, `serverUrl`, `authToken`, and `previewToken` so subsequent
|
|
221
|
-
* invocations can reconnect without redeploying.
|
|
222
|
-
*/
|
|
223
|
-
interface ServerDeployResult {
|
|
224
|
-
mode: 'server';
|
|
216
|
+
type AgentConfig<TInput, TOutput, TFrame = unknown> = RunAgentConfig<TInput, TOutput> | ServerAgentConfig<TInput, TFrame>;
|
|
217
|
+
interface RuntimeConnection {
|
|
225
218
|
sandboxId: string;
|
|
226
219
|
serverUrl: string;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
/** Daytona preview URL auth token; appended by invoke() as `?token=...`. */
|
|
230
|
-
previewToken: string;
|
|
220
|
+
provider: SandboxProvider;
|
|
221
|
+
trafficToken?: string;
|
|
231
222
|
}
|
|
232
223
|
/**
|
|
233
224
|
* Normalizes a path captured from a stack trace into a real on-disk file
|
|
@@ -242,15 +233,15 @@ interface ServerDeployResult {
|
|
|
242
233
|
* @internal Exported for testing.
|
|
243
234
|
*/
|
|
244
235
|
declare function normalizeStackFramePath(rawPath: string, cwd?: string): string | null;
|
|
245
|
-
type AgentMode = '
|
|
236
|
+
type AgentMode = 'run' | 'stream';
|
|
246
237
|
declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
247
238
|
readonly sandbox: SandboxConfig;
|
|
248
239
|
readonly provider: SandboxProvider;
|
|
249
240
|
readonly template: string;
|
|
250
241
|
readonly inputSchema: SchemaLike<TInput>;
|
|
251
|
-
/** Only populated for
|
|
242
|
+
/** Only populated for run-output agents; undefined for streaming agents. */
|
|
252
243
|
readonly outputSchema?: SchemaLike<TOutput>;
|
|
253
|
-
/** Only populated for
|
|
244
|
+
/** Only populated for streaming agents; undefined for run-output agents. */
|
|
254
245
|
readonly frameSchema?: SchemaLike<TFrame>;
|
|
255
246
|
readonly mode: AgentMode;
|
|
256
247
|
readonly maxDuration: number;
|
|
@@ -259,34 +250,37 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
259
250
|
readonly claudeDir?: string;
|
|
260
251
|
readonly envs: Record<string, string | undefined>;
|
|
261
252
|
readonly build: BuildOptions;
|
|
262
|
-
/** @internal Used by the sandbox
|
|
253
|
+
/** @internal Used by the in-sandbox server for run-output agents. */
|
|
263
254
|
_run?: (input: TInput, ctx: AgentRunContext) => Promise<TOutput>;
|
|
264
|
-
/** @internal Used by the in-sandbox
|
|
255
|
+
/** @internal Used by the in-sandbox server for streaming agents. */
|
|
265
256
|
_server?: ServerAgentConfig<TInput, TFrame>['server'];
|
|
266
|
-
/** @internal Runtime state populated by deploy()
|
|
257
|
+
/** @internal Runtime state populated by deploy(). */
|
|
267
258
|
_serverRuntime?: {
|
|
268
|
-
sessionId
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
previewToken: string;
|
|
259
|
+
sessionId?: string;
|
|
260
|
+
commandId?: string;
|
|
261
|
+
connection: RuntimeConnection;
|
|
272
262
|
};
|
|
273
|
-
private _sourceFile;
|
|
274
263
|
private _sandboxId?;
|
|
275
|
-
|
|
264
|
+
private _sourceFile;
|
|
265
|
+
constructor(config: RunAgentConfig<TInput, TOutput>);
|
|
276
266
|
constructor(config: ServerAgentConfig<TInput, TFrame>);
|
|
277
267
|
constructor(config: AgentConfig<TInput, TOutput, TFrame>);
|
|
278
268
|
get sandboxId(): string | undefined;
|
|
279
269
|
private get sandboxEnv();
|
|
280
270
|
private createSandboxHandle;
|
|
281
271
|
private connectSandboxHandle;
|
|
282
|
-
private
|
|
272
|
+
private readRuntimeServerConfig;
|
|
273
|
+
private createRuntimeConnection;
|
|
274
|
+
private healthUrlFor;
|
|
275
|
+
private startRuntimeServer;
|
|
276
|
+
private resolveRuntimeConnection;
|
|
283
277
|
/**
|
|
284
|
-
* Kills the current sandbox and resets the cached
|
|
278
|
+
* Kills the current sandbox and resets the cached runtime.
|
|
285
279
|
*
|
|
286
280
|
* Use this to clean up sandbox resources after a run, especially when
|
|
287
281
|
* running multiple evaluations that each need their own sandbox.
|
|
288
282
|
*
|
|
289
|
-
* @param
|
|
283
|
+
* @param target - Optional sandbox ID to kill. Defaults to the cached sandbox.
|
|
290
284
|
*
|
|
291
285
|
* @example
|
|
292
286
|
* ```typescript
|
|
@@ -295,18 +289,19 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
295
289
|
* await agent.kill(sandboxId);
|
|
296
290
|
* ```
|
|
297
291
|
*/
|
|
298
|
-
kill(
|
|
292
|
+
kill(target?: string): Promise<void>;
|
|
299
293
|
/**
|
|
300
294
|
* Deploys the agent to a sandbox provider.
|
|
301
295
|
*
|
|
302
296
|
* This method bundles the agent code using esbuild, creates a new sandbox,
|
|
303
297
|
* installs any specified OS dependencies, downloads configured files, and
|
|
304
|
-
* uploads the agent code
|
|
298
|
+
* uploads the agent and runtime server code, then starts a long-running HTTP
|
|
299
|
+
* server inside the sandbox.
|
|
305
300
|
*
|
|
306
301
|
* @param options.fresh - When true, always creates a new sandbox without caching.
|
|
307
302
|
* Useful for concurrent evaluations where each run needs its own sandbox.
|
|
308
303
|
* The returned sandbox ID won't be stored on the instance.
|
|
309
|
-
* @returns The sandbox ID
|
|
304
|
+
* @returns The sandbox ID. Persist this ID when another host process should reuse the sandbox.
|
|
310
305
|
* @throws {ConfigurationError} If the selected provider credentials are not set
|
|
311
306
|
* @throws {DeploymentError} If sandbox creation, dependency installation, or file upload fails
|
|
312
307
|
*
|
|
@@ -317,39 +312,26 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
317
312
|
* console.log(`Deployed to sandbox: ${sandboxId}`);
|
|
318
313
|
*
|
|
319
314
|
* // For concurrent evals: each call gets its own sandbox
|
|
320
|
-
* const
|
|
321
|
-
* const result = await agent.run(input, { sandboxId
|
|
322
|
-
* await agent.kill(
|
|
315
|
+
* const sandboxId = await agent.deploy({ fresh: true });
|
|
316
|
+
* const result = await agent.run(input, { sandboxId });
|
|
317
|
+
* await agent.kill(sandboxId);
|
|
323
318
|
* ```
|
|
324
319
|
*/
|
|
325
|
-
/**
|
|
326
|
-
* Deploy a one-shot agent. Throws if called on a server-mode agent; use
|
|
327
|
-
* `deployServer()` for those. Returns the sandbox id so callers can pass it
|
|
328
|
-
* to `run(input, { sandboxId })`.
|
|
329
|
-
*/
|
|
330
320
|
deploy(options?: {
|
|
331
321
|
fresh?: boolean;
|
|
332
322
|
}): Promise<string>;
|
|
333
|
-
/**
|
|
334
|
-
* Deploy a server-mode agent. Throws if called on a one-shot agent; use
|
|
335
|
-
* `deploy()` for those. Returns the sandbox id, public server URL, bearer
|
|
336
|
-
* token, and Daytona preview token that `invoke()` needs to stream.
|
|
337
|
-
*/
|
|
338
|
-
deployServer(options?: {
|
|
339
|
-
fresh?: boolean;
|
|
340
|
-
}): Promise<ServerDeployResult>;
|
|
341
323
|
private _deploy;
|
|
342
324
|
/**
|
|
343
325
|
* Executes the agent with the given input.
|
|
344
326
|
*
|
|
345
|
-
* The agent must be deployed before calling this method, or a
|
|
346
|
-
* be provided in the options. Input is validated against the input
|
|
347
|
-
* then
|
|
348
|
-
*
|
|
327
|
+
* The agent must be deployed before calling this method, or a sandbox ID
|
|
328
|
+
* must be provided in the options. Input is validated against the input
|
|
329
|
+
* schema, then POSTed to the in-sandbox server. Output is validated against
|
|
330
|
+
* the output schema before being returned.
|
|
349
331
|
*
|
|
350
332
|
* @param input - The input data for the agent, must conform to inputSchema
|
|
351
333
|
* @param options - Optional configuration for this run
|
|
352
|
-
* @param options.sandboxId - Sandbox ID to use, overrides the
|
|
334
|
+
* @param options.sandboxId - Sandbox ID to use, overrides the cached sandbox
|
|
353
335
|
* @returns A result object indicating success or failure with output or error
|
|
354
336
|
*
|
|
355
337
|
* @example
|
|
@@ -357,29 +339,21 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
357
339
|
* // Using deployed sandbox
|
|
358
340
|
* const result = await agent.run({ prompt: 'Hello, world!' });
|
|
359
341
|
*
|
|
360
|
-
* //
|
|
361
|
-
* const result = await agent.run({ prompt: 'Hello!' }, { sandboxId
|
|
342
|
+
* // Reconnecting from another process
|
|
343
|
+
* const result = await agent.run({ prompt: 'Hello!' }, { sandboxId });
|
|
362
344
|
* ```
|
|
363
345
|
*/
|
|
364
346
|
run(input: TInput, options?: {
|
|
365
347
|
sandboxId?: string;
|
|
366
348
|
}): Promise<AgentRunResult<TOutput>>;
|
|
367
349
|
/**
|
|
368
|
-
* Invoke a
|
|
369
|
-
*
|
|
370
|
-
* `server: {...}` config; one-shot agents should use `run()` instead.
|
|
371
|
-
*
|
|
372
|
-
* Requires the agent to be deployed via `deploy()` (returns `serverUrl` and
|
|
373
|
-
* `authToken`) — callers must persist those values and pass them on each
|
|
374
|
-
* invocation. Deploy is not yet implemented for server mode; this method
|
|
375
|
-
* currently throws `ConfigurationError` if `serverUrl` is not supplied.
|
|
350
|
+
* Invoke a streaming agent. Streams user frames emitted by the in-sandbox
|
|
351
|
+
* handler as an async iterator.
|
|
376
352
|
*/
|
|
377
353
|
invoke(input: TInput, options?: {
|
|
378
|
-
|
|
379
|
-
authToken?: string;
|
|
380
|
-
previewToken?: string;
|
|
354
|
+
sandboxId?: string;
|
|
381
355
|
signal?: AbortSignal;
|
|
382
356
|
}): AsyncGenerator<TFrame>;
|
|
383
357
|
}
|
|
384
358
|
|
|
385
|
-
export { Agent, type AgentConfig, type AgentMode, type AgentRunContext, type AgentRunResult, type AgentSandboxContext, type BuildOptions, ConfigurationError, DEFAULT_DEPENDENCIES, type DaytonaSandboxConfig, DeploymentError, type E2BSandboxConfig, ExecutionError, type FileDownload, NeckbeardError, type
|
|
359
|
+
export { Agent, type AgentConfig, type AgentMode, type AgentRunContext, type AgentRunResult, type AgentSandboxContext, type BuildOptions, ConfigurationError, DEFAULT_DEPENDENCIES, type DaytonaSandboxConfig, DeploymentError, type E2BSandboxConfig, ExecutionError, type FileDownload, NeckbeardError, type OsDependencies, type RunAgentConfig, type SandboxConfig, type SandboxProvider, type ServerAgentConfig, ValidationError, normalizeStackFramePath };
|