agent-neckbeard 1.1.6 → 1.1.8
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 +50 -74
- package/dist/index.d.ts +50 -74
- 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,32 +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?;
|
|
264
|
+
private _sourceFile;
|
|
265
|
+
constructor(config: RunAgentConfig<TInput, TOutput>);
|
|
266
|
+
constructor(config: ServerAgentConfig<TInput, TFrame>);
|
|
275
267
|
constructor(config: AgentConfig<TInput, TOutput, TFrame>);
|
|
276
268
|
get sandboxId(): string | undefined;
|
|
277
269
|
private get sandboxEnv();
|
|
278
270
|
private createSandboxHandle;
|
|
279
271
|
private connectSandboxHandle;
|
|
280
|
-
private
|
|
272
|
+
private readRuntimeServerConfig;
|
|
273
|
+
private createRuntimeConnection;
|
|
274
|
+
private healthUrlFor;
|
|
275
|
+
private startRuntimeServer;
|
|
276
|
+
private resolveRuntimeConnection;
|
|
281
277
|
/**
|
|
282
|
-
* Kills the current sandbox and resets the cached
|
|
278
|
+
* Kills the current sandbox and resets the cached runtime.
|
|
283
279
|
*
|
|
284
280
|
* Use this to clean up sandbox resources after a run, especially when
|
|
285
281
|
* running multiple evaluations that each need their own sandbox.
|
|
286
282
|
*
|
|
287
|
-
* @param
|
|
283
|
+
* @param target - Optional sandbox ID to kill. Defaults to the cached sandbox.
|
|
288
284
|
*
|
|
289
285
|
* @example
|
|
290
286
|
* ```typescript
|
|
@@ -293,18 +289,19 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
293
289
|
* await agent.kill(sandboxId);
|
|
294
290
|
* ```
|
|
295
291
|
*/
|
|
296
|
-
kill(
|
|
292
|
+
kill(target?: string): Promise<void>;
|
|
297
293
|
/**
|
|
298
294
|
* Deploys the agent to a sandbox provider.
|
|
299
295
|
*
|
|
300
296
|
* This method bundles the agent code using esbuild, creates a new sandbox,
|
|
301
297
|
* installs any specified OS dependencies, downloads configured files, and
|
|
302
|
-
* uploads the agent code
|
|
298
|
+
* uploads the agent and runtime server code, then starts a long-running HTTP
|
|
299
|
+
* server inside the sandbox.
|
|
303
300
|
*
|
|
304
301
|
* @param options.fresh - When true, always creates a new sandbox without caching.
|
|
305
302
|
* Useful for concurrent evaluations where each run needs its own sandbox.
|
|
306
303
|
* The returned sandbox ID won't be stored on the instance.
|
|
307
|
-
* @returns The sandbox ID
|
|
304
|
+
* @returns The sandbox ID. Persist this ID when another host process should reuse the sandbox.
|
|
308
305
|
* @throws {ConfigurationError} If the selected provider credentials are not set
|
|
309
306
|
* @throws {DeploymentError} If sandbox creation, dependency installation, or file upload fails
|
|
310
307
|
*
|
|
@@ -315,39 +312,26 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
315
312
|
* console.log(`Deployed to sandbox: ${sandboxId}`);
|
|
316
313
|
*
|
|
317
314
|
* // For concurrent evals: each call gets its own sandbox
|
|
318
|
-
* const
|
|
319
|
-
* const result = await agent.run(input, { sandboxId
|
|
320
|
-
* await agent.kill(
|
|
315
|
+
* const sandboxId = await agent.deploy({ fresh: true });
|
|
316
|
+
* const result = await agent.run(input, { sandboxId });
|
|
317
|
+
* await agent.kill(sandboxId);
|
|
321
318
|
* ```
|
|
322
319
|
*/
|
|
323
|
-
/**
|
|
324
|
-
* Deploy a one-shot agent. Throws if called on a server-mode agent; use
|
|
325
|
-
* `deployServer()` for those. Returns the sandbox id so callers can pass it
|
|
326
|
-
* to `run(input, { sandboxId })`.
|
|
327
|
-
*/
|
|
328
320
|
deploy(options?: {
|
|
329
321
|
fresh?: boolean;
|
|
330
322
|
}): Promise<string>;
|
|
331
|
-
/**
|
|
332
|
-
* Deploy a server-mode agent. Throws if called on a one-shot agent; use
|
|
333
|
-
* `deploy()` for those. Returns the sandbox id, public server URL, bearer
|
|
334
|
-
* token, and Daytona preview token that `invoke()` needs to stream.
|
|
335
|
-
*/
|
|
336
|
-
deployServer(options?: {
|
|
337
|
-
fresh?: boolean;
|
|
338
|
-
}): Promise<ServerDeployResult>;
|
|
339
323
|
private _deploy;
|
|
340
324
|
/**
|
|
341
325
|
* Executes the agent with the given input.
|
|
342
326
|
*
|
|
343
|
-
* The agent must be deployed before calling this method, or a
|
|
344
|
-
* be provided in the options. Input is validated against the input
|
|
345
|
-
* then
|
|
346
|
-
*
|
|
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.
|
|
347
331
|
*
|
|
348
332
|
* @param input - The input data for the agent, must conform to inputSchema
|
|
349
333
|
* @param options - Optional configuration for this run
|
|
350
|
-
* @param options.sandboxId - Sandbox ID to use, overrides the
|
|
334
|
+
* @param options.sandboxId - Sandbox ID to use, overrides the cached sandbox
|
|
351
335
|
* @returns A result object indicating success or failure with output or error
|
|
352
336
|
*
|
|
353
337
|
* @example
|
|
@@ -355,29 +339,21 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
355
339
|
* // Using deployed sandbox
|
|
356
340
|
* const result = await agent.run({ prompt: 'Hello, world!' });
|
|
357
341
|
*
|
|
358
|
-
* //
|
|
359
|
-
* const result = await agent.run({ prompt: 'Hello!' }, { sandboxId
|
|
342
|
+
* // Reconnecting from another process
|
|
343
|
+
* const result = await agent.run({ prompt: 'Hello!' }, { sandboxId });
|
|
360
344
|
* ```
|
|
361
345
|
*/
|
|
362
346
|
run(input: TInput, options?: {
|
|
363
347
|
sandboxId?: string;
|
|
364
348
|
}): Promise<AgentRunResult<TOutput>>;
|
|
365
349
|
/**
|
|
366
|
-
* Invoke a
|
|
367
|
-
*
|
|
368
|
-
* `server: {...}` config; one-shot agents should use `run()` instead.
|
|
369
|
-
*
|
|
370
|
-
* Requires the agent to be deployed via `deploy()` (returns `serverUrl` and
|
|
371
|
-
* `authToken`) — callers must persist those values and pass them on each
|
|
372
|
-
* invocation. Deploy is not yet implemented for server mode; this method
|
|
373
|
-
* 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.
|
|
374
352
|
*/
|
|
375
353
|
invoke(input: TInput, options?: {
|
|
376
|
-
|
|
377
|
-
authToken?: string;
|
|
378
|
-
previewToken?: string;
|
|
354
|
+
sandboxId?: string;
|
|
379
355
|
signal?: AbortSignal;
|
|
380
356
|
}): AsyncGenerator<TFrame>;
|
|
381
357
|
}
|
|
382
358
|
|
|
383
|
-
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,32 +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?;
|
|
264
|
+
private _sourceFile;
|
|
265
|
+
constructor(config: RunAgentConfig<TInput, TOutput>);
|
|
266
|
+
constructor(config: ServerAgentConfig<TInput, TFrame>);
|
|
275
267
|
constructor(config: AgentConfig<TInput, TOutput, TFrame>);
|
|
276
268
|
get sandboxId(): string | undefined;
|
|
277
269
|
private get sandboxEnv();
|
|
278
270
|
private createSandboxHandle;
|
|
279
271
|
private connectSandboxHandle;
|
|
280
|
-
private
|
|
272
|
+
private readRuntimeServerConfig;
|
|
273
|
+
private createRuntimeConnection;
|
|
274
|
+
private healthUrlFor;
|
|
275
|
+
private startRuntimeServer;
|
|
276
|
+
private resolveRuntimeConnection;
|
|
281
277
|
/**
|
|
282
|
-
* Kills the current sandbox and resets the cached
|
|
278
|
+
* Kills the current sandbox and resets the cached runtime.
|
|
283
279
|
*
|
|
284
280
|
* Use this to clean up sandbox resources after a run, especially when
|
|
285
281
|
* running multiple evaluations that each need their own sandbox.
|
|
286
282
|
*
|
|
287
|
-
* @param
|
|
283
|
+
* @param target - Optional sandbox ID to kill. Defaults to the cached sandbox.
|
|
288
284
|
*
|
|
289
285
|
* @example
|
|
290
286
|
* ```typescript
|
|
@@ -293,18 +289,19 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
293
289
|
* await agent.kill(sandboxId);
|
|
294
290
|
* ```
|
|
295
291
|
*/
|
|
296
|
-
kill(
|
|
292
|
+
kill(target?: string): Promise<void>;
|
|
297
293
|
/**
|
|
298
294
|
* Deploys the agent to a sandbox provider.
|
|
299
295
|
*
|
|
300
296
|
* This method bundles the agent code using esbuild, creates a new sandbox,
|
|
301
297
|
* installs any specified OS dependencies, downloads configured files, and
|
|
302
|
-
* uploads the agent code
|
|
298
|
+
* uploads the agent and runtime server code, then starts a long-running HTTP
|
|
299
|
+
* server inside the sandbox.
|
|
303
300
|
*
|
|
304
301
|
* @param options.fresh - When true, always creates a new sandbox without caching.
|
|
305
302
|
* Useful for concurrent evaluations where each run needs its own sandbox.
|
|
306
303
|
* The returned sandbox ID won't be stored on the instance.
|
|
307
|
-
* @returns The sandbox ID
|
|
304
|
+
* @returns The sandbox ID. Persist this ID when another host process should reuse the sandbox.
|
|
308
305
|
* @throws {ConfigurationError} If the selected provider credentials are not set
|
|
309
306
|
* @throws {DeploymentError} If sandbox creation, dependency installation, or file upload fails
|
|
310
307
|
*
|
|
@@ -315,39 +312,26 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
315
312
|
* console.log(`Deployed to sandbox: ${sandboxId}`);
|
|
316
313
|
*
|
|
317
314
|
* // For concurrent evals: each call gets its own sandbox
|
|
318
|
-
* const
|
|
319
|
-
* const result = await agent.run(input, { sandboxId
|
|
320
|
-
* await agent.kill(
|
|
315
|
+
* const sandboxId = await agent.deploy({ fresh: true });
|
|
316
|
+
* const result = await agent.run(input, { sandboxId });
|
|
317
|
+
* await agent.kill(sandboxId);
|
|
321
318
|
* ```
|
|
322
319
|
*/
|
|
323
|
-
/**
|
|
324
|
-
* Deploy a one-shot agent. Throws if called on a server-mode agent; use
|
|
325
|
-
* `deployServer()` for those. Returns the sandbox id so callers can pass it
|
|
326
|
-
* to `run(input, { sandboxId })`.
|
|
327
|
-
*/
|
|
328
320
|
deploy(options?: {
|
|
329
321
|
fresh?: boolean;
|
|
330
322
|
}): Promise<string>;
|
|
331
|
-
/**
|
|
332
|
-
* Deploy a server-mode agent. Throws if called on a one-shot agent; use
|
|
333
|
-
* `deploy()` for those. Returns the sandbox id, public server URL, bearer
|
|
334
|
-
* token, and Daytona preview token that `invoke()` needs to stream.
|
|
335
|
-
*/
|
|
336
|
-
deployServer(options?: {
|
|
337
|
-
fresh?: boolean;
|
|
338
|
-
}): Promise<ServerDeployResult>;
|
|
339
323
|
private _deploy;
|
|
340
324
|
/**
|
|
341
325
|
* Executes the agent with the given input.
|
|
342
326
|
*
|
|
343
|
-
* The agent must be deployed before calling this method, or a
|
|
344
|
-
* be provided in the options. Input is validated against the input
|
|
345
|
-
* then
|
|
346
|
-
*
|
|
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.
|
|
347
331
|
*
|
|
348
332
|
* @param input - The input data for the agent, must conform to inputSchema
|
|
349
333
|
* @param options - Optional configuration for this run
|
|
350
|
-
* @param options.sandboxId - Sandbox ID to use, overrides the
|
|
334
|
+
* @param options.sandboxId - Sandbox ID to use, overrides the cached sandbox
|
|
351
335
|
* @returns A result object indicating success or failure with output or error
|
|
352
336
|
*
|
|
353
337
|
* @example
|
|
@@ -355,29 +339,21 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
|
355
339
|
* // Using deployed sandbox
|
|
356
340
|
* const result = await agent.run({ prompt: 'Hello, world!' });
|
|
357
341
|
*
|
|
358
|
-
* //
|
|
359
|
-
* const result = await agent.run({ prompt: 'Hello!' }, { sandboxId
|
|
342
|
+
* // Reconnecting from another process
|
|
343
|
+
* const result = await agent.run({ prompt: 'Hello!' }, { sandboxId });
|
|
360
344
|
* ```
|
|
361
345
|
*/
|
|
362
346
|
run(input: TInput, options?: {
|
|
363
347
|
sandboxId?: string;
|
|
364
348
|
}): Promise<AgentRunResult<TOutput>>;
|
|
365
349
|
/**
|
|
366
|
-
* Invoke a
|
|
367
|
-
*
|
|
368
|
-
* `server: {...}` config; one-shot agents should use `run()` instead.
|
|
369
|
-
*
|
|
370
|
-
* Requires the agent to be deployed via `deploy()` (returns `serverUrl` and
|
|
371
|
-
* `authToken`) — callers must persist those values and pass them on each
|
|
372
|
-
* invocation. Deploy is not yet implemented for server mode; this method
|
|
373
|
-
* 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.
|
|
374
352
|
*/
|
|
375
353
|
invoke(input: TInput, options?: {
|
|
376
|
-
|
|
377
|
-
authToken?: string;
|
|
378
|
-
previewToken?: string;
|
|
354
|
+
sandboxId?: string;
|
|
379
355
|
signal?: AbortSignal;
|
|
380
356
|
}): AsyncGenerator<TFrame>;
|
|
381
357
|
}
|
|
382
358
|
|
|
383
|
-
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 };
|