agent-neckbeard 1.1.3 → 1.1.5
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/dist/index.cjs +479 -9
- package/dist/index.d.cts +94 -11
- package/dist/index.d.ts +94 -11
- package/dist/index.js +375 -9
- package/dist/invoke-client-Y3NPRFEE.js +88 -0
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -102,12 +102,10 @@ interface FileDownload {
|
|
|
102
102
|
}
|
|
103
103
|
/** Default dependencies - empty by default, specify what you need */
|
|
104
104
|
declare const DEFAULT_DEPENDENCIES: OsDependencies;
|
|
105
|
-
interface
|
|
105
|
+
interface AgentSharedConfig<TInput> {
|
|
106
106
|
/** Sandbox provider selection and base environment template/snapshot */
|
|
107
107
|
sandbox: SandboxConfig;
|
|
108
108
|
inputSchema: SchemaLike<TInput>;
|
|
109
|
-
outputSchema: SchemaLike<TOutput>;
|
|
110
|
-
run: (input: TInput, ctx: AgentRunContext) => Promise<TOutput>;
|
|
111
109
|
maxDuration?: number;
|
|
112
110
|
/** OS-level dependencies to install in the sandbox. Defaults to Claude Code. Set to {} to skip. */
|
|
113
111
|
dependencies?: OsDependencies;
|
|
@@ -148,6 +146,42 @@ interface AgentCommonConfig<TInput, TOutput> {
|
|
|
148
146
|
/** Build-time options for bundling */
|
|
149
147
|
build?: BuildOptions;
|
|
150
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* One-shot agent config: a handler that receives input and returns a single
|
|
151
|
+
* validated output. Each run invokes the handler as a one-shot subprocess
|
|
152
|
+
* inside the sandbox. This is the original neckbeard execution model.
|
|
153
|
+
*/
|
|
154
|
+
interface OneShotAgentConfig<TInput, TOutput> extends AgentSharedConfig<TInput> {
|
|
155
|
+
outputSchema: SchemaLike<TOutput>;
|
|
156
|
+
run: (input: TInput, ctx: AgentRunContext) => Promise<TOutput>;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Server-mode agent config: deploys a long-running HTTP server into the
|
|
160
|
+
* sandbox that accepts POST /invoke calls and streams emitted frames as SSE.
|
|
161
|
+
* Use this when turns benefit from real-time progress streaming, cancel
|
|
162
|
+
* signals, or bidirectional tool approvals.
|
|
163
|
+
*
|
|
164
|
+
* See .plans/server-mode-agents.md for the full design.
|
|
165
|
+
*/
|
|
166
|
+
interface ServerAgentConfig<TInput, TFrame> extends AgentSharedConfig<TInput> {
|
|
167
|
+
server: {
|
|
168
|
+
/** Port the in-sandbox HTTP server listens on. @default 3000 */
|
|
169
|
+
port?: number;
|
|
170
|
+
/** Schema used to validate each frame the server emits. */
|
|
171
|
+
frameSchema: SchemaLike<TFrame>;
|
|
172
|
+
/**
|
|
173
|
+
* User-provided async handler. Receives validated input, a cancel signal
|
|
174
|
+
* wired from the host, and an `emit` callback used to push SSE frames to
|
|
175
|
+
* the host as the handler runs.
|
|
176
|
+
*/
|
|
177
|
+
handler: (args: {
|
|
178
|
+
input: TInput;
|
|
179
|
+
ctx: AgentRunContext;
|
|
180
|
+
signal: AbortSignal;
|
|
181
|
+
emit: (frame: TFrame) => Promise<void>;
|
|
182
|
+
}) => Promise<void>;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
151
185
|
interface E2BSandboxConfig {
|
|
152
186
|
provider: 'e2b';
|
|
153
187
|
/**
|
|
@@ -175,7 +209,26 @@ interface DaytonaSandboxConfig {
|
|
|
175
209
|
template: string;
|
|
176
210
|
}
|
|
177
211
|
type SandboxConfig = E2BSandboxConfig | DaytonaSandboxConfig;
|
|
178
|
-
|
|
212
|
+
/**
|
|
213
|
+
* Agent config accepted by `new Agent(config)`. Can be either one-shot
|
|
214
|
+
* (original model) or server-mode (persistent HTTP server, SSE streaming).
|
|
215
|
+
* Mode is discriminated at runtime by the presence of `server` vs `run`.
|
|
216
|
+
*/
|
|
217
|
+
type AgentConfig<TInput, TOutput, TFrame = unknown> = OneShotAgentConfig<TInput, TOutput> | ServerAgentConfig<TInput, TFrame>;
|
|
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';
|
|
225
|
+
sandboxId: string;
|
|
226
|
+
serverUrl: string;
|
|
227
|
+
/** Bearer token for the `Authorization` header on invoke() calls. */
|
|
228
|
+
authToken: string;
|
|
229
|
+
/** Daytona preview URL auth token; appended by invoke() as `?token=...`. */
|
|
230
|
+
previewToken: string;
|
|
231
|
+
}
|
|
179
232
|
/**
|
|
180
233
|
* Normalizes a path captured from a stack trace into a real on-disk file
|
|
181
234
|
* path. Handles plain paths, `file://` URLs, and `webpack-internal://` URLs
|
|
@@ -189,23 +242,37 @@ type AgentConfig<TInput, TOutput> = AgentCommonConfig<TInput, TOutput>;
|
|
|
189
242
|
* @internal Exported for testing.
|
|
190
243
|
*/
|
|
191
244
|
declare function normalizeStackFramePath(rawPath: string, cwd?: string): string | null;
|
|
192
|
-
|
|
245
|
+
type AgentMode = 'one-shot' | 'server';
|
|
246
|
+
declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
193
247
|
readonly sandbox: SandboxConfig;
|
|
194
248
|
readonly provider: SandboxProvider;
|
|
195
249
|
readonly template: string;
|
|
196
250
|
readonly inputSchema: SchemaLike<TInput>;
|
|
197
|
-
|
|
251
|
+
/** Only populated for one-shot agents; undefined for server-mode. */
|
|
252
|
+
readonly outputSchema?: SchemaLike<TOutput>;
|
|
253
|
+
/** Only populated for server-mode agents; undefined for one-shot. */
|
|
254
|
+
readonly frameSchema?: SchemaLike<TFrame>;
|
|
255
|
+
readonly mode: AgentMode;
|
|
198
256
|
readonly maxDuration: number;
|
|
199
257
|
readonly dependencies: OsDependencies;
|
|
200
258
|
readonly files: FileDownload[];
|
|
201
259
|
readonly claudeDir?: string;
|
|
202
260
|
readonly envs: Record<string, string | undefined>;
|
|
203
261
|
readonly build: BuildOptions;
|
|
204
|
-
/** @internal Used by the sandbox runner
|
|
205
|
-
_run
|
|
262
|
+
/** @internal Used by the sandbox runner for one-shot agents. */
|
|
263
|
+
_run?: (input: TInput, ctx: AgentRunContext) => Promise<TOutput>;
|
|
264
|
+
/** @internal Used by the in-sandbox HTTP server for server-mode agents. */
|
|
265
|
+
_server?: ServerAgentConfig<TInput, TFrame>['server'];
|
|
266
|
+
/** @internal Runtime state populated by deploy() for server-mode agents. */
|
|
267
|
+
_serverRuntime?: {
|
|
268
|
+
sessionId: string;
|
|
269
|
+
serverUrl: string;
|
|
270
|
+
authToken: string;
|
|
271
|
+
previewToken: string;
|
|
272
|
+
};
|
|
206
273
|
private _sourceFile;
|
|
207
274
|
private _sandboxId?;
|
|
208
|
-
constructor(config: AgentConfig<TInput, TOutput>);
|
|
275
|
+
constructor(config: AgentConfig<TInput, TOutput, TFrame>);
|
|
209
276
|
get sandboxId(): string | undefined;
|
|
210
277
|
private get sandboxEnv();
|
|
211
278
|
private createSandboxHandle;
|
|
@@ -255,7 +322,7 @@ declare class Agent<TInput, TOutput> {
|
|
|
255
322
|
*/
|
|
256
323
|
deploy(options?: {
|
|
257
324
|
fresh?: boolean;
|
|
258
|
-
}): Promise<string>;
|
|
325
|
+
}): Promise<string | ServerDeployResult>;
|
|
259
326
|
/**
|
|
260
327
|
* Executes the agent with the given input.
|
|
261
328
|
*
|
|
@@ -281,6 +348,22 @@ declare class Agent<TInput, TOutput> {
|
|
|
281
348
|
run(input: TInput, options?: {
|
|
282
349
|
sandboxId?: string;
|
|
283
350
|
}): Promise<AgentRunResult<TOutput>>;
|
|
351
|
+
/**
|
|
352
|
+
* Invoke a server-mode agent. Streams the agent's emitted frames back as an
|
|
353
|
+
* async iterator as the handler runs. Only valid for agents constructed with
|
|
354
|
+
* `server: {...}` config; one-shot agents should use `run()` instead.
|
|
355
|
+
*
|
|
356
|
+
* Requires the agent to be deployed via `deploy()` (returns `serverUrl` and
|
|
357
|
+
* `authToken`) — callers must persist those values and pass them on each
|
|
358
|
+
* invocation. Deploy is not yet implemented for server mode; this method
|
|
359
|
+
* currently throws `ConfigurationError` if `serverUrl` is not supplied.
|
|
360
|
+
*/
|
|
361
|
+
invoke(input: TInput, options?: {
|
|
362
|
+
serverUrl?: string;
|
|
363
|
+
authToken?: string;
|
|
364
|
+
previewToken?: string;
|
|
365
|
+
signal?: AbortSignal;
|
|
366
|
+
}): AsyncGenerator<TFrame>;
|
|
284
367
|
}
|
|
285
368
|
|
|
286
|
-
export { Agent, type AgentConfig, type AgentRunContext, type AgentRunResult, type AgentSandboxContext, type BuildOptions, ConfigurationError, DEFAULT_DEPENDENCIES, type DaytonaSandboxConfig, DeploymentError, type E2BSandboxConfig, ExecutionError, type FileDownload, NeckbeardError, type OsDependencies, type SandboxConfig, type SandboxProvider, ValidationError, normalizeStackFramePath };
|
|
369
|
+
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 OneShotAgentConfig, type OsDependencies, type SandboxConfig, type SandboxProvider, type ServerAgentConfig, type ServerDeployResult, ValidationError, normalizeStackFramePath };
|
package/dist/index.d.ts
CHANGED
|
@@ -102,12 +102,10 @@ interface FileDownload {
|
|
|
102
102
|
}
|
|
103
103
|
/** Default dependencies - empty by default, specify what you need */
|
|
104
104
|
declare const DEFAULT_DEPENDENCIES: OsDependencies;
|
|
105
|
-
interface
|
|
105
|
+
interface AgentSharedConfig<TInput> {
|
|
106
106
|
/** Sandbox provider selection and base environment template/snapshot */
|
|
107
107
|
sandbox: SandboxConfig;
|
|
108
108
|
inputSchema: SchemaLike<TInput>;
|
|
109
|
-
outputSchema: SchemaLike<TOutput>;
|
|
110
|
-
run: (input: TInput, ctx: AgentRunContext) => Promise<TOutput>;
|
|
111
109
|
maxDuration?: number;
|
|
112
110
|
/** OS-level dependencies to install in the sandbox. Defaults to Claude Code. Set to {} to skip. */
|
|
113
111
|
dependencies?: OsDependencies;
|
|
@@ -148,6 +146,42 @@ interface AgentCommonConfig<TInput, TOutput> {
|
|
|
148
146
|
/** Build-time options for bundling */
|
|
149
147
|
build?: BuildOptions;
|
|
150
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* One-shot agent config: a handler that receives input and returns a single
|
|
151
|
+
* validated output. Each run invokes the handler as a one-shot subprocess
|
|
152
|
+
* inside the sandbox. This is the original neckbeard execution model.
|
|
153
|
+
*/
|
|
154
|
+
interface OneShotAgentConfig<TInput, TOutput> extends AgentSharedConfig<TInput> {
|
|
155
|
+
outputSchema: SchemaLike<TOutput>;
|
|
156
|
+
run: (input: TInput, ctx: AgentRunContext) => Promise<TOutput>;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Server-mode agent config: deploys a long-running HTTP server into the
|
|
160
|
+
* sandbox that accepts POST /invoke calls and streams emitted frames as SSE.
|
|
161
|
+
* Use this when turns benefit from real-time progress streaming, cancel
|
|
162
|
+
* signals, or bidirectional tool approvals.
|
|
163
|
+
*
|
|
164
|
+
* See .plans/server-mode-agents.md for the full design.
|
|
165
|
+
*/
|
|
166
|
+
interface ServerAgentConfig<TInput, TFrame> extends AgentSharedConfig<TInput> {
|
|
167
|
+
server: {
|
|
168
|
+
/** Port the in-sandbox HTTP server listens on. @default 3000 */
|
|
169
|
+
port?: number;
|
|
170
|
+
/** Schema used to validate each frame the server emits. */
|
|
171
|
+
frameSchema: SchemaLike<TFrame>;
|
|
172
|
+
/**
|
|
173
|
+
* User-provided async handler. Receives validated input, a cancel signal
|
|
174
|
+
* wired from the host, and an `emit` callback used to push SSE frames to
|
|
175
|
+
* the host as the handler runs.
|
|
176
|
+
*/
|
|
177
|
+
handler: (args: {
|
|
178
|
+
input: TInput;
|
|
179
|
+
ctx: AgentRunContext;
|
|
180
|
+
signal: AbortSignal;
|
|
181
|
+
emit: (frame: TFrame) => Promise<void>;
|
|
182
|
+
}) => Promise<void>;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
151
185
|
interface E2BSandboxConfig {
|
|
152
186
|
provider: 'e2b';
|
|
153
187
|
/**
|
|
@@ -175,7 +209,26 @@ interface DaytonaSandboxConfig {
|
|
|
175
209
|
template: string;
|
|
176
210
|
}
|
|
177
211
|
type SandboxConfig = E2BSandboxConfig | DaytonaSandboxConfig;
|
|
178
|
-
|
|
212
|
+
/**
|
|
213
|
+
* Agent config accepted by `new Agent(config)`. Can be either one-shot
|
|
214
|
+
* (original model) or server-mode (persistent HTTP server, SSE streaming).
|
|
215
|
+
* Mode is discriminated at runtime by the presence of `server` vs `run`.
|
|
216
|
+
*/
|
|
217
|
+
type AgentConfig<TInput, TOutput, TFrame = unknown> = OneShotAgentConfig<TInput, TOutput> | ServerAgentConfig<TInput, TFrame>;
|
|
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';
|
|
225
|
+
sandboxId: string;
|
|
226
|
+
serverUrl: string;
|
|
227
|
+
/** Bearer token for the `Authorization` header on invoke() calls. */
|
|
228
|
+
authToken: string;
|
|
229
|
+
/** Daytona preview URL auth token; appended by invoke() as `?token=...`. */
|
|
230
|
+
previewToken: string;
|
|
231
|
+
}
|
|
179
232
|
/**
|
|
180
233
|
* Normalizes a path captured from a stack trace into a real on-disk file
|
|
181
234
|
* path. Handles plain paths, `file://` URLs, and `webpack-internal://` URLs
|
|
@@ -189,23 +242,37 @@ type AgentConfig<TInput, TOutput> = AgentCommonConfig<TInput, TOutput>;
|
|
|
189
242
|
* @internal Exported for testing.
|
|
190
243
|
*/
|
|
191
244
|
declare function normalizeStackFramePath(rawPath: string, cwd?: string): string | null;
|
|
192
|
-
|
|
245
|
+
type AgentMode = 'one-shot' | 'server';
|
|
246
|
+
declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
|
|
193
247
|
readonly sandbox: SandboxConfig;
|
|
194
248
|
readonly provider: SandboxProvider;
|
|
195
249
|
readonly template: string;
|
|
196
250
|
readonly inputSchema: SchemaLike<TInput>;
|
|
197
|
-
|
|
251
|
+
/** Only populated for one-shot agents; undefined for server-mode. */
|
|
252
|
+
readonly outputSchema?: SchemaLike<TOutput>;
|
|
253
|
+
/** Only populated for server-mode agents; undefined for one-shot. */
|
|
254
|
+
readonly frameSchema?: SchemaLike<TFrame>;
|
|
255
|
+
readonly mode: AgentMode;
|
|
198
256
|
readonly maxDuration: number;
|
|
199
257
|
readonly dependencies: OsDependencies;
|
|
200
258
|
readonly files: FileDownload[];
|
|
201
259
|
readonly claudeDir?: string;
|
|
202
260
|
readonly envs: Record<string, string | undefined>;
|
|
203
261
|
readonly build: BuildOptions;
|
|
204
|
-
/** @internal Used by the sandbox runner
|
|
205
|
-
_run
|
|
262
|
+
/** @internal Used by the sandbox runner for one-shot agents. */
|
|
263
|
+
_run?: (input: TInput, ctx: AgentRunContext) => Promise<TOutput>;
|
|
264
|
+
/** @internal Used by the in-sandbox HTTP server for server-mode agents. */
|
|
265
|
+
_server?: ServerAgentConfig<TInput, TFrame>['server'];
|
|
266
|
+
/** @internal Runtime state populated by deploy() for server-mode agents. */
|
|
267
|
+
_serverRuntime?: {
|
|
268
|
+
sessionId: string;
|
|
269
|
+
serverUrl: string;
|
|
270
|
+
authToken: string;
|
|
271
|
+
previewToken: string;
|
|
272
|
+
};
|
|
206
273
|
private _sourceFile;
|
|
207
274
|
private _sandboxId?;
|
|
208
|
-
constructor(config: AgentConfig<TInput, TOutput>);
|
|
275
|
+
constructor(config: AgentConfig<TInput, TOutput, TFrame>);
|
|
209
276
|
get sandboxId(): string | undefined;
|
|
210
277
|
private get sandboxEnv();
|
|
211
278
|
private createSandboxHandle;
|
|
@@ -255,7 +322,7 @@ declare class Agent<TInput, TOutput> {
|
|
|
255
322
|
*/
|
|
256
323
|
deploy(options?: {
|
|
257
324
|
fresh?: boolean;
|
|
258
|
-
}): Promise<string>;
|
|
325
|
+
}): Promise<string | ServerDeployResult>;
|
|
259
326
|
/**
|
|
260
327
|
* Executes the agent with the given input.
|
|
261
328
|
*
|
|
@@ -281,6 +348,22 @@ declare class Agent<TInput, TOutput> {
|
|
|
281
348
|
run(input: TInput, options?: {
|
|
282
349
|
sandboxId?: string;
|
|
283
350
|
}): Promise<AgentRunResult<TOutput>>;
|
|
351
|
+
/**
|
|
352
|
+
* Invoke a server-mode agent. Streams the agent's emitted frames back as an
|
|
353
|
+
* async iterator as the handler runs. Only valid for agents constructed with
|
|
354
|
+
* `server: {...}` config; one-shot agents should use `run()` instead.
|
|
355
|
+
*
|
|
356
|
+
* Requires the agent to be deployed via `deploy()` (returns `serverUrl` and
|
|
357
|
+
* `authToken`) — callers must persist those values and pass them on each
|
|
358
|
+
* invocation. Deploy is not yet implemented for server mode; this method
|
|
359
|
+
* currently throws `ConfigurationError` if `serverUrl` is not supplied.
|
|
360
|
+
*/
|
|
361
|
+
invoke(input: TInput, options?: {
|
|
362
|
+
serverUrl?: string;
|
|
363
|
+
authToken?: string;
|
|
364
|
+
previewToken?: string;
|
|
365
|
+
signal?: AbortSignal;
|
|
366
|
+
}): AsyncGenerator<TFrame>;
|
|
284
367
|
}
|
|
285
368
|
|
|
286
|
-
export { Agent, type AgentConfig, type AgentRunContext, type AgentRunResult, type AgentSandboxContext, type BuildOptions, ConfigurationError, DEFAULT_DEPENDENCIES, type DaytonaSandboxConfig, DeploymentError, type E2BSandboxConfig, ExecutionError, type FileDownload, NeckbeardError, type OsDependencies, type SandboxConfig, type SandboxProvider, ValidationError, normalizeStackFramePath };
|
|
369
|
+
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 OneShotAgentConfig, type OsDependencies, type SandboxConfig, type SandboxProvider, type ServerAgentConfig, type ServerDeployResult, ValidationError, normalizeStackFramePath };
|