coding-agents-sdk 0.14.1 → 0.16.0
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 +46 -0
- package/dist/Agent-BjaeRtLk.mjs +4 -0
- package/dist/SdkAgent-Dtsr8Ycr.mjs +1 -0
- package/dist/adapters/claude-code-cli/index.d.mts +2 -2
- package/dist/adapters/claude-code-cli/index.mjs +1 -1
- package/dist/adapters/claude-code-cli-pty/index.d.mts +2 -2
- package/dist/adapters/claude-code-cli-pty/index.mjs +5 -5
- package/dist/adapters/claude-code-sdk/index.d.mts +1 -1
- package/dist/adapters/claude-code-sdk/index.mjs +4 -4
- package/dist/adapters/codex-cli/index.d.mts +2 -2
- package/dist/adapters/codex-cli/index.mjs +2 -2
- package/dist/adapters/codex-sdk/index.d.mts +1 -1
- package/dist/adapters/codex-sdk/index.mjs +1 -1
- package/dist/adapters/cursor-cli/index.d.mts +1 -1
- package/dist/adapters/cursor-cli/index.mjs +1 -1
- package/dist/adapters/cursor-sdk/index.d.mts +1 -1
- package/dist/adapters/cursor-sdk/index.mjs +1 -1
- package/dist/adapters/gemini-cli/index.d.mts +1 -1
- package/dist/adapters/gemini-cli/index.mjs +1 -1
- package/dist/adapters/opencode-cli/index.d.mts +1 -1
- package/dist/adapters/opencode-cli/index.mjs +1 -1
- package/dist/adapters/pi-cli/index.d.mts +1 -1
- package/dist/adapters/pi-cli/index.mjs +1 -1
- package/dist/classify-error-DOqkMCcy.mjs +8 -0
- package/dist/container/index.d.mts +1 -1
- package/dist/container/index.mjs +1 -1
- package/dist/{container-B3SrSQYp.mjs → container-Bdb90GJb.mjs} +1 -1
- package/dist/{container-B5suwmUQ.mjs → container-DMFxf-kn.mjs} +1 -1
- package/dist/{container-DQzVZjLd.mjs → container-Dvr-p53c.mjs} +1 -1
- package/dist/{container-BPllAKd8.mjs → container-dCRMBvQw.mjs} +1 -1
- package/dist/container-w0rl1QMH.mjs +1 -0
- package/dist/core/process/index.d.mts +3 -0
- package/dist/core/process/index.mjs +1 -0
- package/dist/diff-Dqyk2cdt.mjs +1 -0
- package/dist/errors-aYGbvsaq.mjs +1 -0
- package/dist/index-65Dv7ed0.d.mts +415 -0
- package/dist/{index-tmvnx5wp.d.mts → index-BbZPkmE-.d.mts} +4 -3
- package/dist/{index-f1x-Ugwa.d.mts → index-Bi9Dh34t.d.mts} +4 -4
- package/dist/{index-D1IlwEGE.d.mts → index-BiUoRRsR.d.mts} +4 -3
- package/dist/{index-C_WwuF3E.d.mts → index-CN0WGc9T.d.mts} +3 -2
- package/dist/{index-BXgvYZSv.d.mts → index-CQzF8Cli.d.mts} +1 -1
- package/dist/{index-CGGPY1qE.d.mts → index-CZbgTv8P.d.mts} +1 -1
- package/dist/{index-Dm9HCmWK.d.mts → index-CjjUmMwQ.d.mts} +1 -1
- package/dist/{index-CSty5NNW.d.mts → index-CyIiBK-O.d.mts} +130 -4
- package/dist/{index-TzOW2t1h.d.mts → index-DmpVdnKm.d.mts} +4 -3
- package/dist/index-DvwVRB7K.d.mts +10 -0
- package/dist/{index-BQwDFirP.d.mts → index-kXfBtyJn.d.mts} +3 -4
- package/dist/{index-Cxegh1Rs.d.mts → index-m5Pqs8Jz.d.mts} +4 -3
- package/dist/index.d.mts +27 -25
- package/dist/index.mjs +1 -1
- package/dist/oci-DTNwW-WH.mjs +1 -0
- package/dist/parser-C1kvDtRD.mjs +2 -0
- package/dist/sandbox/index.d.mts +1 -1
- package/dist/sandbox/index.mjs +1 -1
- package/dist/sandbox-CYA69miM.mjs +4 -0
- package/dist/{structured-output-Bfzi3RU4.mjs → session-markers-Dt7TWdKY.mjs} +1 -1
- package/dist/spawner-CgfyvnR4.mjs +1 -0
- package/dist/{types-CeIQCAFV.d.mts → types-Ba2NYJOB.d.mts} +10 -57
- package/dist/types-COmjfh8B.d.mts +57 -0
- package/dist/{util-DcPzh_0u.mjs → util-B4HTdOSc.mjs} +1 -1
- package/package.json +15 -11
- package/dist/Agent-YQZmTatB.mjs +0 -4
- package/dist/SdkAgent-Dv3I0OW2.mjs +0 -1
- package/dist/classify-error-UZrj89Yi.mjs +0 -8
- package/dist/container-BH5So6E_.mjs +0 -1
- package/dist/diff-Bh8JPwVM.mjs +0 -1
- package/dist/index-CSfb-Q3A.d.mts +0 -154
- package/dist/oci-C5y_whHx.mjs +0 -1
- package/dist/parser-CTagqQyR.mjs +0 -2
- package/dist/sandbox-DQWTg5YL.mjs +0 -4
- package/dist/spawner-BE2hAC0w.mjs +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
1
|
+
import { i as ProcessSpawner } from "./types-COmjfh8B.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-Ba2NYJOB.mjs";
|
|
3
|
+
import { t as Container } from "./index-kXfBtyJn.mjs";
|
|
4
|
+
import { l as Sandbox } from "./index-CN0WGc9T.mjs";
|
|
4
5
|
import { z } from "zod/v4";
|
|
5
6
|
//#region src/adapters/pi-cli/events/schemas.d.ts
|
|
6
7
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { i as ProcessSpawner } from "./types-COmjfh8B.mjs";
|
|
2
|
+
import "./types-Ba2NYJOB.mjs";
|
|
3
|
+
import { A as VolumeMount } from "./index-kXfBtyJn.mjs";
|
|
3
4
|
//#region src/sandbox/types.d.ts
|
|
4
5
|
/** Which sandbox binary backs the policy. The binary must be installed on the host. */
|
|
5
6
|
type SandboxType = "bubblewrap" | "firejail" | "nsjail";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-
|
|
1
|
+
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-Ba2NYJOB.mjs";
|
|
2
2
|
import "@openai/codex-sdk";
|
|
3
3
|
//#region src/adapters/codex-sdk/types.d.ts
|
|
4
4
|
type CodexSdkSandboxMode = "danger-full-access" | "read-only" | "workspace-write";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-
|
|
1
|
+
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-Ba2NYJOB.mjs";
|
|
2
2
|
import "@cursor/sdk";
|
|
3
3
|
//#region src/adapters/cursor-sdk/types.d.ts
|
|
4
4
|
/** OAuth-style credentials for HTTP/SSE MCP servers configured for the agent. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { S as McpServerConfig } from "./events-BxEB6zHt.mjs";
|
|
2
|
-
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-
|
|
2
|
+
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-Ba2NYJOB.mjs";
|
|
3
3
|
import "@anthropic-ai/claude-agent-sdk";
|
|
4
4
|
//#region src/adapters/claude-code-sdk/types.d.ts
|
|
5
5
|
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { S as McpServerConfig } from "./events-BxEB6zHt.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
2
|
+
import { i as ProcessSpawner } from "./types-COmjfh8B.mjs";
|
|
3
|
+
import { _ as ProviderEventHandler, f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-Ba2NYJOB.mjs";
|
|
4
|
+
import { t as Container } from "./index-kXfBtyJn.mjs";
|
|
5
|
+
import { l as Sandbox } from "./index-CN0WGc9T.mjs";
|
|
5
6
|
import { z } from "zod/v4";
|
|
6
7
|
//#region src/adapters/claude-code-cli/events/schemas.d.ts
|
|
7
8
|
declare const claudeSystemEventSchema: z.ZodObject<{
|
|
@@ -282,6 +283,129 @@ declare const claudeEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
282
283
|
}, z.core.$strip>;
|
|
283
284
|
}, z.core.$strip>], "type">;
|
|
284
285
|
type ClaudeEvent = z.infer<typeof claudeEventSchema>;
|
|
286
|
+
declare const claudeProviderEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
287
|
+
type: z.ZodLiteral<"system">;
|
|
288
|
+
session_id: z.ZodString;
|
|
289
|
+
subtype: z.ZodEnum<{
|
|
290
|
+
hook_failed: "hook_failed";
|
|
291
|
+
hook_finished: "hook_finished";
|
|
292
|
+
hook_response: "hook_response";
|
|
293
|
+
hook_skipped: "hook_skipped";
|
|
294
|
+
hook_started: "hook_started";
|
|
295
|
+
init: "init";
|
|
296
|
+
}>;
|
|
297
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
298
|
+
model: z.ZodOptional<z.ZodString>;
|
|
299
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
300
|
+
hook_name: z.ZodOptional<z.ZodString>;
|
|
301
|
+
hook_event: z.ZodOptional<z.ZodString>;
|
|
302
|
+
stdout: z.ZodOptional<z.ZodString>;
|
|
303
|
+
stderr: z.ZodOptional<z.ZodString>;
|
|
304
|
+
exit_code: z.ZodOptional<z.ZodNumber>;
|
|
305
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
306
|
+
mcp_servers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
307
|
+
name: z.ZodString;
|
|
308
|
+
status: z.ZodString;
|
|
309
|
+
}, z.core.$strip>>>;
|
|
310
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
311
|
+
type: z.ZodLiteral<"assistant">;
|
|
312
|
+
session_id: z.ZodString;
|
|
313
|
+
parent_tool_use_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
314
|
+
message: z.ZodObject<{
|
|
315
|
+
id: z.ZodString;
|
|
316
|
+
type: z.ZodLiteral<"message">;
|
|
317
|
+
role: z.ZodLiteral<"assistant">;
|
|
318
|
+
model: z.ZodString;
|
|
319
|
+
content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
320
|
+
type: z.ZodLiteral<"text">;
|
|
321
|
+
text: z.ZodString;
|
|
322
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
323
|
+
type: z.ZodLiteral<"tool_use">;
|
|
324
|
+
id: z.ZodString;
|
|
325
|
+
name: z.ZodString;
|
|
326
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
327
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
328
|
+
type: z.ZodLiteral<"thinking">;
|
|
329
|
+
thinking: z.ZodString;
|
|
330
|
+
signature: z.ZodOptional<z.ZodString>;
|
|
331
|
+
}, z.core.$strip>]>>;
|
|
332
|
+
stop_reason: z.ZodNullable<z.ZodEnum<{
|
|
333
|
+
end_turn: "end_turn";
|
|
334
|
+
max_tokens: "max_tokens";
|
|
335
|
+
stop_sequence: "stop_sequence";
|
|
336
|
+
tool_use: "tool_use";
|
|
337
|
+
}>>;
|
|
338
|
+
stop_sequence: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
339
|
+
context_management: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
340
|
+
usage: z.ZodObject<{
|
|
341
|
+
input_tokens: z.ZodNumber;
|
|
342
|
+
output_tokens: z.ZodNumber;
|
|
343
|
+
cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
344
|
+
cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
345
|
+
service_tier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
346
|
+
premium: "premium";
|
|
347
|
+
standard: "standard";
|
|
348
|
+
}>>>;
|
|
349
|
+
}, z.core.$strip>;
|
|
350
|
+
ttftMs: z.ZodOptional<z.ZodNumber>;
|
|
351
|
+
}, z.core.$strip>;
|
|
352
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
353
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
354
|
+
type: z.ZodLiteral<"user">;
|
|
355
|
+
session_id: z.ZodString;
|
|
356
|
+
message: z.ZodObject<{
|
|
357
|
+
role: z.ZodLiteral<"user">;
|
|
358
|
+
content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
359
|
+
type: z.ZodLiteral<"tool_result">;
|
|
360
|
+
tool_use_id: z.ZodString;
|
|
361
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
362
|
+
type: z.ZodLiteral<"text">;
|
|
363
|
+
text: z.ZodString;
|
|
364
|
+
}, z.core.$strip>>]>;
|
|
365
|
+
is_error: z.ZodOptional<z.ZodBoolean>;
|
|
366
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
367
|
+
type: z.ZodLiteral<"text">;
|
|
368
|
+
text: z.ZodString;
|
|
369
|
+
}, z.core.$strip>]>>;
|
|
370
|
+
}, z.core.$strip>;
|
|
371
|
+
parent_tool_use_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
372
|
+
isSynthetic: z.ZodOptional<z.ZodBoolean>;
|
|
373
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
374
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
375
|
+
type: z.ZodLiteral<"result">;
|
|
376
|
+
session_id: z.ZodString;
|
|
377
|
+
duration_ms: z.ZodNumber;
|
|
378
|
+
duration_api_ms: z.ZodNumber;
|
|
379
|
+
is_error: z.ZodBoolean;
|
|
380
|
+
num_turns: z.ZodNumber;
|
|
381
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
382
|
+
structured_output: z.ZodOptional<z.ZodUnknown>;
|
|
383
|
+
total_cost_usd: z.ZodNumber;
|
|
384
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
385
|
+
input_tokens: z.ZodNumber;
|
|
386
|
+
cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
387
|
+
cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
388
|
+
output_tokens: z.ZodNumber;
|
|
389
|
+
server_tool_use: z.ZodOptional<z.ZodObject<{
|
|
390
|
+
web_search_requests: z.ZodNumber;
|
|
391
|
+
}, z.core.$strip>>;
|
|
392
|
+
}, z.core.$strip>>;
|
|
393
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
394
|
+
subtype: z.ZodString;
|
|
395
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
396
|
+
type: z.ZodLiteral<"rate_limit_event">;
|
|
397
|
+
uuid: z.ZodString;
|
|
398
|
+
session_id: z.ZodOptional<z.ZodString>;
|
|
399
|
+
rate_limit_info: z.ZodObject<{
|
|
400
|
+
status: z.ZodString;
|
|
401
|
+
resetsAt: z.ZodOptional<z.ZodNumber>;
|
|
402
|
+
rateLimitType: z.ZodOptional<z.ZodString>;
|
|
403
|
+
overageStatus: z.ZodOptional<z.ZodString>;
|
|
404
|
+
overageDisabledReason: z.ZodOptional<z.ZodString>;
|
|
405
|
+
isUsingOverage: z.ZodOptional<z.ZodBoolean>;
|
|
406
|
+
}, z.core.$strip>;
|
|
407
|
+
}, z.core.$strip>], "type">;
|
|
408
|
+
type ClaudeProviderEvent = z.infer<typeof claudeProviderEventSchema>;
|
|
285
409
|
//#endregion
|
|
286
410
|
//#region src/adapters/claude-code-cli/types.d.ts
|
|
287
411
|
/**
|
|
@@ -337,10 +461,12 @@ type ClaudeCodeCliAgentOptions = ClaudeCodeCliRunOptions & ExclusiveExecutionTar
|
|
|
337
461
|
spawner?: ProcessSpawner;
|
|
338
462
|
/** Convenience: equivalent to calling `agent.onEvent(handler)` post-construction. */
|
|
339
463
|
onEvent?: AgentEventHandler;
|
|
464
|
+
onProviderEvent?: ProviderEventHandler<ClaudeProviderEvent>;
|
|
340
465
|
};
|
|
341
466
|
/** Agent instance returned by `createAgent("claude-code-cli", ...)`. */
|
|
342
467
|
interface ClaudeCodeCliAgent extends BaseAgent<EnsureDisjoint<ClaudeCodeCliRunOptions>> {
|
|
343
468
|
readonly type: "claude-code-cli";
|
|
469
|
+
onProviderEvent: (handler: ProviderEventHandler<ClaudeProviderEvent>) => () => void;
|
|
344
470
|
/**
|
|
345
471
|
* Branch a sibling agent from the current session.
|
|
346
472
|
*
|
|
@@ -353,4 +479,4 @@ interface ClaudeCodeCliAgent extends BaseAgent<EnsureDisjoint<ClaudeCodeCliRunOp
|
|
|
353
479
|
//#region src/adapters/claude-code-cli/adapter.d.ts
|
|
354
480
|
declare const createClaudeCodeCliAgent: (options?: ClaudeCodeCliAgentOptions) => ClaudeCodeCliAgent;
|
|
355
481
|
//#endregion
|
|
356
|
-
export { ClaudeCodeCliRunOptions as a,
|
|
482
|
+
export { ClaudeCodeCliRunOptions as a, ClaudeProviderEvent as c, ClaudeSystemEvent as d, ClaudeUserEvent as f, ClaudeCodeCliPermissionMode as i, ClaudeRateLimitEvent as l, ClaudeCodeCliAgent as n, ClaudeAssistantEvent as o, ClaudeCodeCliAgentOptions as r, ClaudeEvent as s, createClaudeCodeCliAgent as t, ClaudeResultEvent as u };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
1
|
+
import { i as ProcessSpawner } from "./types-COmjfh8B.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-Ba2NYJOB.mjs";
|
|
3
|
+
import { t as Container } from "./index-kXfBtyJn.mjs";
|
|
4
|
+
import { l as Sandbox } from "./index-CN0WGc9T.mjs";
|
|
4
5
|
import { z } from "zod/v4";
|
|
5
6
|
//#region src/adapters/opencode-cli/events/schemas.d.ts
|
|
6
7
|
/**
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { a as SpawnOptions, t as AgentProcess } from "./types-COmjfh8B.mjs";
|
|
2
|
+
//#region src/core/process/spawner.d.ts
|
|
3
|
+
declare const spawnProcess: (command: string, args: string[], options?: SpawnOptions) => AgentProcess;
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/core/process/errors.d.ts
|
|
6
|
+
declare class ProcessStdinError extends Error {
|
|
7
|
+
constructor(cause: unknown);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { spawnProcess as n, ProcessStdinError as t };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as ProcessSpawner } from "./types-COmjfh8B.mjs";
|
|
2
|
+
import "./types-Ba2NYJOB.mjs";
|
|
2
3
|
//#region src/container/types.d.ts
|
|
3
4
|
/** Which provider backs a container. Selects which CLI/SDK the adapter speaks. */
|
|
4
5
|
type ContainerType = "docker" | "e2b" | "nerdctl" | "podman";
|
|
@@ -210,8 +211,6 @@ interface E2BSandboxLifecycleOptions {
|
|
|
210
211
|
interface E2BConnectionConfig {
|
|
211
212
|
/** E2B API key. Falls back to `E2B_API_KEY` if omitted. */
|
|
212
213
|
apiKey?: string;
|
|
213
|
-
/** Personal access token; an alternative to `apiKey`. Falls back to `E2B_ACCESS_TOKEN`. */
|
|
214
|
-
accessToken?: string;
|
|
215
214
|
/** Override the E2B API domain. Use for self-hosted or staging endpoints. */
|
|
216
215
|
domain?: string;
|
|
217
216
|
/** HTTP request timeout in milliseconds. */
|
|
@@ -376,7 +375,7 @@ type Container = DockerContainer | E2BContainer | NerdctlContainer | PodmanConta
|
|
|
376
375
|
* The `type` field on `config` selects the provider; supported values are
|
|
377
376
|
* `"docker"`, `"e2b"`, `"nerdctl"`, and `"podman"`. The provider's daemon
|
|
378
377
|
* (Docker, Podman, etc.) must be running locally, except for `"e2b"` which
|
|
379
|
-
* requires `E2B_API_KEY`
|
|
378
|
+
* requires `E2B_API_KEY` and the optional `e2b` peer
|
|
380
379
|
* dependency.
|
|
381
380
|
*
|
|
382
381
|
* Containers are async-disposable. Use `await using` to ensure cleanup:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
1
|
+
import { i as ProcessSpawner } from "./types-COmjfh8B.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-Ba2NYJOB.mjs";
|
|
3
|
+
import { t as Container } from "./index-kXfBtyJn.mjs";
|
|
4
|
+
import { l as Sandbox } from "./index-CN0WGc9T.mjs";
|
|
4
5
|
import { z } from "zod/v4";
|
|
5
6
|
//#region src/adapters/cursor-cli/events/schemas.d.ts
|
|
6
7
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { C as TextContentPart, S as McpServerConfig, a as SessionStartEvent, b as ImageContentPart, c as ToolResultEvent, i as SessionEndEvent, n as MessageEvent, o as StderrEvent, r as ReasoningEvent, s as ToolCallEvent, t as AgentEvent, u as eventSchema, v as AgentCapabilities, w as agentCapabilitiesSchema, x as JsonSchema, y as ContentPart } from "./events-BxEB6zHt.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { A as
|
|
4
|
-
import { a as
|
|
5
|
-
import { a as
|
|
6
|
-
import { a as
|
|
7
|
-
import { a as
|
|
8
|
-
import { a as
|
|
9
|
-
import { a as
|
|
10
|
-
import { a as
|
|
11
|
-
import { a as
|
|
12
|
-
import { a as
|
|
13
|
-
import { a as
|
|
14
|
-
import { a as
|
|
2
|
+
import { a as SpawnOptions, i as ProcessSpawner, n as ProcessResult, r as ProcessSignal, t as AgentProcess } from "./types-COmjfh8B.mjs";
|
|
3
|
+
import { A as PermissionRequest, C as RunStatus, D as ZodRunRequest, E as StructuredRunRequest, O as PermissionDecision, S as RunStats, T as StopReason, _ as ProviderEventHandler, a as AgentValidationError, b as RunRequest, c as AnyRunResult, d as CompletedRunResult, g as ProviderEvent, h as JsonSchemaRunRequest, i as AgentType, k as PermissionHandler, l as BaseAgent, m as FailedRunResult, n as AgentMetrics, o as AnyCompletedRunResult, r as AgentRunError, s as AnyRunRequest, t as AgentEventHandler, u as CancelledRunResult, v as RunError, w as RunTiming, x as RunResult, y as RunProcessInfo } from "./types-Ba2NYJOB.mjs";
|
|
4
|
+
import { A as VolumeMount, C as DockerContainer, D as ExecOptions, E as ContainerType, F as WorkdirSnapshot, I as WorkdirSnapshotOptions, M as WorkdirDiff, N as WorkdirDiffStats, O as ExecResult, P as WorkdirFileChange, S as E2BProviderConfig, T as ContainerStatus, _ as E2BConnectConfig, a as ContainerDiffError, b as E2BContainerConfig, c as ContainerExecError, d as MountValidationError, f as PodmanContainer, g as NerdctlProviderConfig, h as NerdctlContainerConfig, i as ContainerCreateError, j as WorkdirChangeKind, k as PortMapping, l as ContainerNotRunningError, m as NerdctlContainer, n as ContainerConfig, o as ContainerDisposedError, p as PodmanContainerConfig, r as createContainer, s as ContainerError, t as Container, u as ContainerStartError, v as E2BConnectionConfig, w as DockerContainerConfig, x as E2BCreateConfig, y as E2BContainer } from "./index-kXfBtyJn.mjs";
|
|
5
|
+
import { a as FirejailSandbox, c as NsjailSandboxConfig, d as SandboxStatus, f as SandboxType, i as BubblewrapSandboxConfig, l as Sandbox, n as createSandbox, o as FirejailSandboxConfig, r as BubblewrapSandbox, s as NsjailSandbox, t as SandboxCreateError, u as SandboxConfig } from "./index-CN0WGc9T.mjs";
|
|
6
|
+
import { a as ClaudeCodeCliRunOptions, c as ClaudeProviderEvent, d as ClaudeSystemEvent, f as ClaudeUserEvent, i as ClaudeCodeCliPermissionMode, l as ClaudeRateLimitEvent, n as ClaudeCodeCliAgent, o as ClaudeAssistantEvent, r as ClaudeCodeCliAgentOptions, s as ClaudeEvent, u as ClaudeResultEvent } from "./index-CyIiBK-O.mjs";
|
|
7
|
+
import { a as ClaudeCodeCliPtyPermissionMode, i as ClaudeCodeCliPtyModule, n as ClaudeCodeCliPtyAgent, o as ClaudeCodeCliPtyProcess, r as ClaudeCodeCliPtyAgentOptions, s as ClaudeCodeCliPtyRunOptions } from "./index-Bi9Dh34t.mjs";
|
|
8
|
+
import { a as ClaudeCodeSdkExecutable, c as ClaudeCodeSdkSettingSource, i as ClaudeCodeSdkEvent, l as ClaudeCodeSdkSettings, n as ClaudeCodeSdkAgent, o as ClaudeCodeSdkPermissionMode, r as ClaudeCodeSdkAgentOptions, s as ClaudeCodeSdkRunOptions } from "./index-CjjUmMwQ.mjs";
|
|
9
|
+
import { a as CodexCliRunOptions, c as CodexEvent, d as CodexItemUpdatedEvent, f as CodexProviderEvent, g as CodexTurnFailedEvent, h as CodexTurnCompletedEvent, i as CodexCliPermissionMode, l as CodexItemCompletedEvent, m as CodexThreadStartedEvent, n as CodexCliAgent, o as CodexCliSandboxMode, p as CodexProviderItem, r as CodexCliAgentOptions, s as CodexErrorEvent, u as CodexItemStartedEvent } from "./index-65Dv7ed0.mjs";
|
|
10
|
+
import { a as CodexSdkItem, i as CodexSdkEvent, n as CodexSdkAgent, o as CodexSdkPermissionMode, r as CodexSdkAgentOptions, s as CodexSdkRunOptions } from "./index-CQzF8Cli.mjs";
|
|
11
|
+
import { a as CursorCliRunOptions, i as CursorCliPermissionMode, n as CursorCliAgent, o as CursorCliSandboxMode, r as CursorCliAgentOptions, s as CursorCliEvent } from "./index-m5Pqs8Jz.mjs";
|
|
12
|
+
import { a as CursorSdkMcpHttpAuth, c as CursorSdkSettingSource, i as CursorSdkEvent, n as CursorSdkAgent, o as CursorSdkMcpServerConfig, r as CursorSdkAgentOptions, s as CursorSdkRunOptions } from "./index-CZbgTv8P.mjs";
|
|
13
|
+
import { a as GeminiCliRunOptions, i as GeminiCliPermissionMode, n as GeminiCliAgent, o as GeminiEvent, r as GeminiCliAgentOptions } from "./index-BbZPkmE-.mjs";
|
|
14
|
+
import { a as OpencodeEvent, i as OpencodeCliRunOptions, n as OpencodeCliAgent, r as OpencodeCliAgentOptions } from "./index-DmpVdnKm.mjs";
|
|
15
|
+
import { a as PiCliThinkingLevel, i as PiCliRunOptions, n as PiCliAgent, o as PiEvent, r as PiCliAgentOptions } from "./index-BiUoRRsR.mjs";
|
|
16
|
+
import { n as spawnProcess, t as ProcessStdinError } from "./index-DvwVRB7K.mjs";
|
|
15
17
|
import "./schemas/index.mjs";
|
|
16
18
|
//#region src/core/agent/create-agent.d.ts
|
|
17
19
|
interface AgentOptionsByType {
|
|
@@ -66,16 +68,16 @@ interface AgentInstanceByType {
|
|
|
66
68
|
* @returns A promise that resolves to the typed agent instance.
|
|
67
69
|
* @throws {AgentValidationError} If a required peer dependency is missing or required options are absent.
|
|
68
70
|
*/
|
|
69
|
-
declare function createAgent(type: "claude-code-cli-pty", options?: ClaudeCodeCliPtyAgentOptions): Promise<ClaudeCodeCliPtyAgent>;
|
|
70
|
-
declare function createAgent(type: "claude-code-cli", options?: ClaudeCodeCliAgentOptions): Promise<ClaudeCodeCliAgent>;
|
|
71
|
-
declare function createAgent(type: "claude-code-sdk", options?: ClaudeCodeSdkAgentOptions): Promise<ClaudeCodeSdkAgent>;
|
|
72
|
-
declare function createAgent(type: "codex-cli", options?: CodexCliAgentOptions): Promise<CodexCliAgent>;
|
|
73
|
-
declare function createAgent(type: "codex-sdk", options?: CodexSdkAgentOptions): Promise<CodexSdkAgent>;
|
|
74
|
-
declare function createAgent(type: "cursor-cli", options?: CursorCliAgentOptions): Promise<CursorCliAgent>;
|
|
75
|
-
declare function createAgent(type: "cursor-sdk", options?: CursorSdkAgentOptions): Promise<CursorSdkAgent>;
|
|
76
|
-
declare function createAgent(type: "gemini-cli", options?: GeminiCliAgentOptions): Promise<GeminiCliAgent>;
|
|
77
|
-
declare function createAgent(type: "opencode-cli", options?: OpencodeCliAgentOptions): Promise<OpencodeCliAgent>;
|
|
78
|
-
declare function createAgent(type: "pi-cli", options?: PiCliAgentOptions): Promise<PiCliAgent>;
|
|
79
|
-
declare function createAgent<T extends AgentType>(type: T, options?: AgentOptionsByType[T]): Promise<AgentInstanceByType[T]>;
|
|
71
|
+
export declare function createAgent(type: "claude-code-cli-pty", options?: ClaudeCodeCliPtyAgentOptions): Promise<ClaudeCodeCliPtyAgent>;
|
|
72
|
+
export declare function createAgent(type: "claude-code-cli", options?: ClaudeCodeCliAgentOptions): Promise<ClaudeCodeCliAgent>;
|
|
73
|
+
export declare function createAgent(type: "claude-code-sdk", options?: ClaudeCodeSdkAgentOptions): Promise<ClaudeCodeSdkAgent>;
|
|
74
|
+
export declare function createAgent(type: "codex-cli", options?: CodexCliAgentOptions): Promise<CodexCliAgent>;
|
|
75
|
+
export declare function createAgent(type: "codex-sdk", options?: CodexSdkAgentOptions): Promise<CodexSdkAgent>;
|
|
76
|
+
export declare function createAgent(type: "cursor-cli", options?: CursorCliAgentOptions): Promise<CursorCliAgent>;
|
|
77
|
+
export declare function createAgent(type: "cursor-sdk", options?: CursorSdkAgentOptions): Promise<CursorSdkAgent>;
|
|
78
|
+
export declare function createAgent(type: "gemini-cli", options?: GeminiCliAgentOptions): Promise<GeminiCliAgent>;
|
|
79
|
+
export declare function createAgent(type: "opencode-cli", options?: OpencodeCliAgentOptions): Promise<OpencodeCliAgent>;
|
|
80
|
+
export declare function createAgent(type: "pi-cli", options?: PiCliAgentOptions): Promise<PiCliAgent>;
|
|
81
|
+
export declare function createAgent<T extends AgentType>(type: T, options?: AgentOptionsByType[T]): Promise<AgentInstanceByType[T]>;
|
|
80
82
|
//#endregion
|
|
81
|
-
export { type AgentCapabilities, type AgentEvent, type AgentEventHandler, type AgentMetrics, AgentRunError, type AgentType, AgentValidationError, type AnyCompletedRunResult, type AnyRunRequest, type AnyRunResult, type BaseAgent, type BubblewrapSandbox, type BubblewrapSandboxConfig, type CancelledRunResult, type ClaudeAssistantEvent, type ClaudeCodeCliAgent, type ClaudeCodeCliAgentOptions, type ClaudeCodeCliPermissionMode, type ClaudeCodeCliPtyAgent, type ClaudeCodeCliPtyAgentOptions, type ClaudeCodeCliPtyModule, type ClaudeCodeCliPtyPermissionMode, type ClaudeCodeCliPtyProcess, type ClaudeCodeCliPtyRunOptions, type ClaudeCodeCliRunOptions, type ClaudeCodeSdkAgent, type ClaudeCodeSdkAgentOptions, type ClaudeCodeSdkEvent, type ClaudeCodeSdkExecutable, type ClaudeCodeSdkPermissionMode, type ClaudeCodeSdkRunOptions, type ClaudeCodeSdkSettingSource, type ClaudeCodeSdkSettings, type ClaudeEvent, type ClaudeRateLimitEvent, type ClaudeResultEvent, type ClaudeSystemEvent, type ClaudeUserEvent, type CodexCliAgent, type CodexCliAgentOptions, type CodexCliPermissionMode, type CodexCliRunOptions, type CodexCliSandboxMode, type CodexErrorEvent, type CodexEvent, type CodexItemCompletedEvent, type CodexItemStartedEvent, type CodexItemUpdatedEvent, type CodexSdkAgent, type CodexSdkAgentOptions, type CodexSdkEvent, type CodexSdkItem, type CodexSdkPermissionMode, type CodexSdkRunOptions, type CodexThreadStartedEvent, type CodexTurnCompletedEvent, type CodexTurnFailedEvent, type CompletedRunResult, type Container, type ContainerConfig, ContainerCreateError, ContainerDiffError, ContainerDisposedError, ContainerError, ContainerExecError, ContainerNotRunningError, ContainerStartError, type ContainerStatus, type ContainerType, type ContentPart, type CursorCliAgent, type CursorCliAgentOptions, type CursorCliEvent, type CursorCliPermissionMode, type CursorCliRunOptions, type CursorCliSandboxMode, type CursorSdkAgent, type CursorSdkAgentOptions, type CursorSdkEvent, type CursorSdkMcpHttpAuth, type CursorSdkMcpServerConfig, type CursorSdkRunOptions, type CursorSdkSettingSource, type DockerContainer, type DockerContainerConfig, type E2BConnectConfig, type E2BConnectionConfig, type E2BContainer, type E2BContainerConfig, type E2BCreateConfig, type E2BProviderConfig, type ExecOptions, type ExecResult, type FailedRunResult, type FirejailSandbox, type FirejailSandboxConfig, type GeminiCliAgent, type GeminiCliAgentOptions, type GeminiCliPermissionMode, type GeminiCliRunOptions, type GeminiEvent, type ImageContentPart, type JsonSchema, type JsonSchemaRunRequest, type McpServerConfig, type MessageEvent, MountValidationError, type NerdctlContainer, type NerdctlContainerConfig, type NerdctlProviderConfig, type NsjailSandbox, type NsjailSandboxConfig, type OpencodeCliAgent, type OpencodeCliAgentOptions, type OpencodeCliRunOptions, type OpencodeEvent, type PermissionDecision, type PermissionHandler, type PermissionRequest, type PiCliAgent, type PiCliAgentOptions, type PiCliRunOptions, type PiCliThinkingLevel, type PiEvent, type PodmanContainer, type PodmanContainerConfig, type PortMapping, type ReasoningEvent, type RunError, type RunProcessInfo, type RunRequest, type RunResult, type RunStats, type RunStatus, type RunTiming, type Sandbox, type SandboxConfig, SandboxCreateError, type SandboxStatus, type SandboxType, type SessionEndEvent, type SessionStartEvent, type StderrEvent, type StopReason, type StructuredRunRequest, type TextContentPart, type ToolCallEvent, type ToolResultEvent, type VolumeMount, type WorkdirChangeKind, type WorkdirDiff, type WorkdirDiffStats, type WorkdirFileChange, type WorkdirSnapshot, type WorkdirSnapshotOptions, type ZodRunRequest, agentCapabilitiesSchema,
|
|
83
|
+
export { type AgentCapabilities, type AgentEvent, type AgentEventHandler, type AgentMetrics, type AgentProcess, AgentRunError, type AgentType, AgentValidationError, type AnyCompletedRunResult, type AnyRunRequest, type AnyRunResult, type BaseAgent, type BubblewrapSandbox, type BubblewrapSandboxConfig, type CancelledRunResult, type ClaudeAssistantEvent, type ClaudeCodeCliAgent, type ClaudeCodeCliAgentOptions, type ClaudeCodeCliPermissionMode, type ClaudeCodeCliPtyAgent, type ClaudeCodeCliPtyAgentOptions, type ClaudeCodeCliPtyModule, type ClaudeCodeCliPtyPermissionMode, type ClaudeCodeCliPtyProcess, type ClaudeCodeCliPtyRunOptions, type ClaudeCodeCliRunOptions, type ClaudeCodeSdkAgent, type ClaudeCodeSdkAgentOptions, type ClaudeCodeSdkEvent, type ClaudeCodeSdkExecutable, type ClaudeCodeSdkPermissionMode, type ClaudeCodeSdkRunOptions, type ClaudeCodeSdkSettingSource, type ClaudeCodeSdkSettings, type ClaudeEvent, type ClaudeProviderEvent, type ClaudeRateLimitEvent, type ClaudeResultEvent, type ClaudeSystemEvent, type ClaudeUserEvent, type CodexCliAgent, type CodexCliAgentOptions, type CodexCliPermissionMode, type CodexCliRunOptions, type CodexCliSandboxMode, type CodexErrorEvent, type CodexEvent, type CodexItemCompletedEvent, type CodexItemStartedEvent, type CodexItemUpdatedEvent, type CodexProviderEvent, type CodexProviderItem, type CodexSdkAgent, type CodexSdkAgentOptions, type CodexSdkEvent, type CodexSdkItem, type CodexSdkPermissionMode, type CodexSdkRunOptions, type CodexThreadStartedEvent, type CodexTurnCompletedEvent, type CodexTurnFailedEvent, type CompletedRunResult, type Container, type ContainerConfig, ContainerCreateError, ContainerDiffError, ContainerDisposedError, ContainerError, ContainerExecError, ContainerNotRunningError, ContainerStartError, type ContainerStatus, type ContainerType, type ContentPart, type CursorCliAgent, type CursorCliAgentOptions, type CursorCliEvent, type CursorCliPermissionMode, type CursorCliRunOptions, type CursorCliSandboxMode, type CursorSdkAgent, type CursorSdkAgentOptions, type CursorSdkEvent, type CursorSdkMcpHttpAuth, type CursorSdkMcpServerConfig, type CursorSdkRunOptions, type CursorSdkSettingSource, type DockerContainer, type DockerContainerConfig, type E2BConnectConfig, type E2BConnectionConfig, type E2BContainer, type E2BContainerConfig, type E2BCreateConfig, type E2BProviderConfig, type ExecOptions, type ExecResult, type FailedRunResult, type FirejailSandbox, type FirejailSandboxConfig, type GeminiCliAgent, type GeminiCliAgentOptions, type GeminiCliPermissionMode, type GeminiCliRunOptions, type GeminiEvent, type ImageContentPart, type JsonSchema, type JsonSchemaRunRequest, type McpServerConfig, type MessageEvent, MountValidationError, type NerdctlContainer, type NerdctlContainerConfig, type NerdctlProviderConfig, type NsjailSandbox, type NsjailSandboxConfig, type OpencodeCliAgent, type OpencodeCliAgentOptions, type OpencodeCliRunOptions, type OpencodeEvent, type PermissionDecision, type PermissionHandler, type PermissionRequest, type PiCliAgent, type PiCliAgentOptions, type PiCliRunOptions, type PiCliThinkingLevel, type PiEvent, type PodmanContainer, type PodmanContainerConfig, type PortMapping, type ProcessResult, type ProcessSignal, type ProcessSpawner, ProcessStdinError, type ProviderEvent, type ProviderEventHandler, type ReasoningEvent, type RunError, type RunProcessInfo, type RunRequest, type RunResult, type RunStats, type RunStatus, type RunTiming, type Sandbox, type SandboxConfig, SandboxCreateError, type SandboxStatus, type SandboxType, type SessionEndEvent, type SessionStartEvent, type SpawnOptions, type StderrEvent, type StopReason, type StructuredRunRequest, type TextContentPart, type ToolCallEvent, type ToolResultEvent, type VolumeMount, type WorkdirChangeKind, type WorkdirDiff, type WorkdirDiffStats, type WorkdirFileChange, type WorkdirSnapshot, type WorkdirSnapshotOptions, type ZodRunRequest, agentCapabilitiesSchema, createContainer, createSandbox, eventSchema, spawnProcess };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./types-B72tDMEZ.mjs";import{a as n,c as r,i,l as a,n as o,o as s,r as c,s as l,t as u}from"./container-
|
|
1
|
+
import{n as e,t}from"./types-B72tDMEZ.mjs";import{a as n,c as r,i,l as a,n as o,o as s,r as c,s as l,t as u}from"./container-DMFxf-kn.mjs";import{t as d}from"./errors-aYGbvsaq.mjs";import{n as f}from"./spawner-CgfyvnR4.mjs";import{n as p,t as m}from"./sandbox-CYA69miM.mjs";import"./core/process/index.mjs";import{n as h,u as g}from"./schemas-CkdQXAep.mjs";const _=(e,t)=>{if(!(e instanceof Error)||!e.message.includes(t))return!1;let n=typeof e==`object`&&e&&`code`in e?e.code:void 0;return n===`ERR_MODULE_NOT_FOUND`||n===`MODULE_NOT_FOUND`},v=(t,n,r)=>{throw _(r,n)?new e(`Agent type "${t}" requires the optional peer dependency "${n}". Install it to use this adapter.`):r};async function y(t,n){switch(t){case`claude-code-cli-pty`:{let{createClaudeCodeCliPtyAgent:e}=await import(`./adapters/claude-code-cli-pty/index.mjs`);return e(n)}case`claude-code-cli`:{let{createClaudeCodeCliAgent:e}=await import(`./adapters/claude-code-cli/index.mjs`);return e(n)}case`claude-code-sdk`:{let e=n;try{let{createClaudeCodeSdkAgent:t}=await import(`./adapters/claude-code-sdk/index.mjs`);return t(e)}catch(e){return v(`claude-code-sdk`,`@anthropic-ai/claude-agent-sdk`,e)}}case`codex-cli`:{let{createCodexCliAgent:e}=await import(`./adapters/codex-cli/index.mjs`);return e(n)}case`codex-sdk`:{let e=n;try{let{createCodexSdkAgent:t}=await import(`./adapters/codex-sdk/index.mjs`);return t(e)}catch(e){return v(`codex-sdk`,`@openai/codex-sdk`,e)}}case`cursor-cli`:{let{createCursorCliAgent:e}=await import(`./adapters/cursor-cli/index.mjs`);return e(n)}case`cursor-sdk`:{let e=n;try{let{createCursorSdkAgent:t}=await import(`./adapters/cursor-sdk/index.mjs`);return t(e)}catch(e){return v(`cursor-sdk`,`@cursor/sdk`,e)}}case`gemini-cli`:{let{createGeminiCliAgent:e}=await import(`./adapters/gemini-cli/index.mjs`);return e(n)}case`opencode-cli`:{let{createOpencodeCliAgent:e}=await import(`./adapters/opencode-cli/index.mjs`);return e(n)}case`pi-cli`:{let{createPiCliAgent:e}=await import(`./adapters/pi-cli/index.mjs`);return e(n)}default:throw new e(`Unsupported agent type.`)}}export{t as AgentRunError,e as AgentValidationError,o as ContainerCreateError,c as ContainerDiffError,i as ContainerDisposedError,n as ContainerError,s as ContainerExecError,l as ContainerNotRunningError,r as ContainerStartError,a as MountValidationError,d as ProcessStdinError,m as SandboxCreateError,g as agentCapabilitiesSchema,y as createAgent,u as createContainer,p as createSandbox,h as eventSchema,f as spawnProcess};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./util-B4HTdOSc.mjs";import{c as t,i as n,l as r,n as i,o as a,r as o,s}from"./container-DMFxf-kn.mjs";import{n as c}from"./env-Cb8MIvH7.mjs";import{n as l}from"./errors-aYGbvsaq.mjs";import{t as u}from"./spawner-CgfyvnR4.mjs";import{t as d}from"./shell-DvWFuFKb.mjs";import{n as f,t as p}from"./diff-Dqyk2cdt.mjs";import{execFile as m}from"node:child_process";import{isAbsolute as h,join as g,posix as _,resolve as v}from"node:path";import{promisify as y}from"node:util";import{existsSync as b}from"node:fs";import{tmpdir as x}from"node:os";import{mkdtemp as S,rm as C,writeFile as w}from"node:fs/promises";import{randomBytes as T}from"node:crypto";const E=(e,t)=>{let n=_.relative(e,t);return n===``||!n.startsWith(`..`)&&!_.isAbsolute(n)},D=(e,t)=>{if(!e||e.length===0)return;let n=_.normalize(t),r;for(let t of e){if(!h(t.source))continue;let e=_.normalize(t.target);E(e,n)&&(!r||e.length>_.normalize(r.target).length)&&(r=t)}if(!r)return;let i=_.relative(_.normalize(r.target),n);return i===``?r.source:_.join(r.source,...i.split(`/`))},O=(e,t)=>{let n=h(e.source)?e.source:v(t.cwd,e.source);if(!b(n))throw new r(`Mount source does not exist: ${n}`);return{...e,source:n}},k=y(m),A=()=>`cw-${T(6).toString(`hex`)}`,j=(e,t)=>e.baseArgs?[...e.baseArgs,...t]:t,M=e=>{if(e.env)return{...c(),...e.env}},N=async(e,t,n)=>{let r=await k(e.binary,j(e,t),{encoding:`utf8`,env:M(e),timeout:n?.timeoutMs,signal:n?.signal,maxBuffer:52428800});return{stdout:r.stdout,stderr:r.stderr}},P=async(t,n)=>{let r=n.tag??`cw-build-${T(4).toString(`hex`)}`,a=[`build`,`-t`,r];if(n.args)for(let[e,t]of Object.entries(n.args))a.push(`--build-arg`,`${e}=${t}`);`dockerfile`in n&&n.dockerfile&&(a.push(`-f`,n.dockerfile),a.push(n.context??`.`));let o;if(`content`in n&&n.content){o=await S(g(x(),`cw-oci-build-`));let e=g(o,`Dockerfile`);await w(e,n.content,{encoding:`utf8`,mode:384}),a.push(`-f`,e),a.push(n.context??o)}try{await N(t,a)}catch(t){throw new i(`Image build failed: ${e(t)}`)}finally{o&&await C(o,{recursive:!0,force:!0}).catch(()=>{})}return r},F=async(e,t,n)=>{let r=await Promise.all(n.map(async n=>{try{let{container:r,protocol:i=`tcp`}=n,{stdout:a}=await N(e,[`port`,t,`${r}/${i}`]),o=/:(\d+)$/m.exec(a.trim());if(o?.[1])return[r,Number(o[1])]}catch{}})),i=/* @__PURE__ */ new Map;for(let e of r)e&&i.set(e[0],e[1]);return i},I=(e,t)=>({spawn:(n,r,i={})=>{let a=[`exec`,`-i`];if(i.cwd&&a.push(`-w`,i.cwd),i.env)for(let[e,t]of Object.entries(i.env))a.push(`-e`,`${e}=${t}`);return a.push(e,n,...r),u.spawn(t.binary,j(t,a),{env:M(t),stdio:i.stdio})}}),L=async(r,c,m)=>{let{commandContext:h,builtImage:g,containerName:v,workdir:y,user:b,network:x,platform:S,env:C,ports:w,mounts:T,mountCwd:E,extraArgs:k,image:P}=c,L=v??A(),R=T?.map(e=>O(e,{cwd:E??process.cwd()})),z=[`create`,`--name`,L];if(b&&z.push(`--user`,b),x&&z.push(`--network`,x),S&&z.push(`--platform`,S),C)for(let[e,t]of Object.entries(C))z.push(`-e`,`${e}=${t}`);if(w)for(let e of w){let{host:t,container:n,protocol:r=`tcp`}=e;z.push(`-p`,`${t??``}:${n}/${r}`)}if(R)for(let e of R){let{readonly:t,source:n,target:r}=e,i=t?`ro`:`rw`;z.push(`-v`,`${n}:${r}:${i}`)}k&&z.push(...k),z.push(P,`sleep`,`infinity`);let B;try{let{stdout:e}=await N(h,z);B=e.trim()}catch(t){throw new i(`Container create failed: ${e(t)}`)}let V=`created`,H=/* @__PURE__ */ new Map,U=()=>{if(V===`disposed`)throw new n},W=()=>{if(U(),V!==`running`)throw new s},G=I(B,h),K=f({owner:{},workdir:y,materialize:async(t,n)=>{U();let r=D(R,t);if(r){await p(r,n);return}W();try{await N(h,[`exec`,B,`sh`,`-c`,`test -d ${d(t)}`])}catch{throw new o(`Target path is not a directory: ${t}`)}try{await N(h,[`cp`,`${B}:${t}/.`,n])}catch(n){throw new o(`Failed to materialize container path ${t}: ${e(n)}`)}}}),q={get type(){return r},get id(){return B},get name(){return L},get config(){return m},get status(){return V},get workdir(){return y},get spawner(){return G},async start(){if(U(),V!==`running`){try{await N(h,[`start`,B])}catch(n){throw new t(`Container start failed: ${e(n)}`)}try{await N(h,[`exec`,B,`mkdir`,`-p`,y])}catch(n){try{await N(h,[`stop`,`-t`,`0`,B]),V=`stopped`}catch{try{let{stdout:e}=await N(h,[`inspect`,`--format`,`{{.State.Status}}`,B]);V=e.trim()===`running`?`running`:`stopped`}catch{V=`disposed`}}throw new t(`Container start failed: ${e(n)}`)}V=`running`,w?.length&&(H=await F(h,B,w))}},async stop(){if(U(),V===`running`){try{await N(h,[`stop`,`-t`,`2`,B])}catch{try{let{stdout:e}=await N(h,[`inspect`,`--format`,`{{.State.Status}}`,B]);if(e.trim()===`running`)return}catch{V=`disposed`;return}}V=`stopped`}},async dispose(){if(V!==`disposed`){try{await N(h,[`stop`,`-t`,`0`,B])}catch{}try{await N(h,[`rm`,`-f`,B])}catch{}g&&await N(h,[`rmi`,P]).catch(()=>{}),await K.disposeSnapshots().catch(()=>{}),V=`disposed`}},async exec(e,t,n={}){W();let r=[`exec`];if(n.cwd&&r.push(`-w`,n.cwd),n.env)for(let[e,t]of Object.entries(n.env))r.push(`-e`,`${e}=${t}`);r.push(B,e,...t);try{let{stdout:e,stderr:t}=await N(h,r,{timeoutMs:n.timeoutMs,signal:n.signal});return{exitCode:0,stdout:e,stderr:t}}catch(e){if(l(e))return{exitCode:typeof e.code==`number`?e.code:-1,stdout:String(e.stdout??``),stderr:String(e.stderr??``)};throw e}},async copyTo(e,t){W(),await N(h,[`cp`,e,`${B}:${t}`])},async copyFrom(e,t){W(),await N(h,[`cp`,`${B}:${e}`,t])},async writeFile(t,n){W();let r=_.isAbsolute(t)?t:_.resolve(y,t),i=_.dirname(r),o=typeof n==`string`?Buffer.from(n,`utf8`):n,s=[`exec`,`-i`];b&&s.push(`--user`,b),s.push(B,`sh`,`-c`,`mkdir -p ${d(i)} && cat > ${d(r)}`);let c=u.spawn(h.binary,j(h,s),{env:M(h),stdio:[`pipe`,`ignore`,`ignore`]}),l;try{c.stdin?.write?.(o),c.stdin?.end(),l=await c.wait()}catch(t){throw c.kill(),c.wait().catch(()=>{}),new a(`writeFile failed for ${r}: ${e(t)}`)}if(l.exitCode!==0)throw new a(`writeFile failed for ${r} (exit ${l.exitCode})`)},async readFile(e){W();let t=_.isAbsolute(e)?e:_.resolve(y,e),{stdout:n}=await N(h,[`exec`,B,`cat`,t]);return n},async fileExists(e){W();let t=_.isAbsolute(e)?e:_.resolve(y,e);try{return await N(h,[`exec`,B,`test`,`-e`,t]),!0}catch{return!1}},async mkdir(e){W();let t=_.isAbsolute(e)?e:_.resolve(y,e);await N(h,[`exec`,B,`mkdir`,`-p`,t])},async execShell(e,t={}){return q.exec(`sh`,[`-c`,e],t)},async logs(e={}){U();let t=[`logs`];e.tail!==void 0&&t.push(`--tail`,String(e.tail)),t.push(B);let{stdout:n}=await N(h,t);return n},async syncStatus(){U();try{let{stdout:e}=await N(h,[`inspect`,`--format`,`{{.State.Status}}`,B]),t=e.trim();V=t===`running`?`running`:t===`created`?`created`:`stopped`}catch{V=`disposed`}return V},async snapshotWorkdir(e={}){return K.snapshotWorkdir(e)},async diffWorkdir(e){return K.diffWorkdir(e)},async releaseWorkdirSnapshot(e){return K.releaseWorkdirSnapshot(e)},getMappedPort(e){return H.get(e)},[Symbol.asyncDispose](){return q.dispose()}};return q},R=async(e,t)=>{if(t.image)return t.image;if(t.build)return P(e,t.build);throw new i(`Either image or build must be provided.`)};export{R as n,L as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"./util-B4HTdOSc.mjs";import{c as t,s as n,u as r}from"./classify-error-DOqkMCcy.mjs";import{r as i}from"./session-markers-Dt7TWdKY.mjs";import{z as a}from"zod/v4";const o=e=>`session_id`in e?e.session_id:void 0,s=e=>typeof e.content==`string`?e.content:e.content.map(e=>e.text).join(`
|
|
2
|
+
`),c=e=>typeof e.result==`string`&&e.result.trim()!==``?e.result:e.subtype,l=(e,t)=>{let i=[`[${e.subtype}]`];if(e.subtype===`init`){if(e.tools&&i.push(`tools: ${e.tools.length}`),e.mcp_servers){let t=e.mcp_servers.filter(e=>e.status===`connected`).length;i.push(`mcp: ${t}/${e.mcp_servers.length} connected`)}}else e.hook_name&&(i.push(e.hook_name),e.exit_code!==void 0&&i.push(`exit: ${e.exit_code}`));let a=i.join(` `);return{events:[n(t.runId,`message`,{sessionId:t.sessionId,model:e.model??null,role:`system`,content:[r(a)],text:a})]}},u=(e,t)=>{let i=[],a=[];for(let o of e.message.content)switch(o.type){case`text`:i.push(n(t.runId,`message`,{sessionId:t.sessionId,model:e.message.model??null,role:`assistant`,content:[r(o.text)],text:o.text}));break;case`thinking`:i.push(n(t.runId,`reasoning`,{sessionId:t.sessionId,model:e.message.model??null,content:[r(o.thinking)],text:o.thinking}));break;case`tool_use`:a.push({toolCallId:o.id,toolName:o.name,input:o.input}),i.push(n(t.runId,`tool-call`,{sessionId:t.sessionId,model:e.message.model??null,toolCallId:o.id,toolName:o.name,input:o.input}))}return{events:i,toolCalls:a}},d=(e,t)=>{let i=[];for(let a of e.message.content)switch(a.type){case`text`:i.push(n(t.runId,`message`,{sessionId:t.sessionId,model:null,role:`user`,content:[r(a.text)],text:a.text}));break;case`tool_result`:{let e=t.toolCalls.get(a.tool_use_id),r=s(a);i.push(n(t.runId,`tool-result`,{sessionId:t.sessionId,toolCallId:a.tool_use_id,toolName:e?.toolName,input:e?.input,output:r,isError:a.is_error,error:a.is_error?r:void 0}));break}}return{events:i}},f=(t,n)=>{let r=t.usage?.input_tokens,a=t.usage?.cache_creation_input_tokens,o=t.usage?.cache_read_input_tokens,s=t.usage?.output_tokens,l=e(r,a,o,s),u={stats:{durationMs:t.duration_ms,apiDurationMs:t.duration_api_ms,turns:t.num_turns,inputTokens:r,cacheCreationInputTokens:a,cacheReadInputTokens:o,outputTokens:s,totalTokens:l,costUsd:t.total_cost_usd}};typeof t.result==`string`&&(u.output={...u.output,text:t.result});let d=!t.is_error&&t.subtype===`success`,f=i(t.structured_output,{schemaRequested:n.schemaRequested,toolCalls:n.toolCalls,allowToolCallFallback:!1},{isSuccess:d},`Structured output was requested but Claude did not return structured_output.`);return f.value!==void 0&&(u.output={...u.output,value:f.value}),f.error&&(u.status=`failed`,u.error=f.error),t.is_error||t.subtype!==`success`?(u.status=`failed`,u.error={kind:`provider`,message:c(t)}):u.error||(u.status=`completed`),{events:[],state:u}},p=(e,t)=>{let i=`rate limited: ${e.rate_limit_info.status}`;return{events:[n(t.runId,`message`,{sessionId:t.sessionId,model:null,role:`system`,content:[r(i)],text:i})]}},m=(e,t)=>{switch(e.type){case`system`:return l(e,t);case`assistant`:return u(e,t);case`user`:return d(e,t);case`result`:return f(e,t);case`rate_limit_event`:return p(e,t);default:return{events:[]}}},h=a.enum([`init`,`hook_response`,`hook_started`,`hook_finished`,`hook_failed`,`hook_skipped`]),g=a.object({name:a.string(),status:a.string()}),_=a.object({type:a.literal(`system`),session_id:a.string(),subtype:h,uuid:a.string(),tools:a.array(a.string()).optional(),mcp_servers:a.array(g.extend({status:a.enum([`connected`,`disconnected`,`error`,`failed`])})).optional(),model:a.string().optional(),cwd:a.string().optional(),hook_name:a.string().optional(),hook_event:a.string().optional(),stdout:a.string().optional(),stderr:a.string().optional(),exit_code:a.number().optional()}),v=a.object({type:a.literal(`assistant`),session_id:a.string(),uuid:a.string(),parent_tool_use_id:a.string().nullable().optional(),message:a.object({id:a.string(),type:a.literal(`message`),role:a.literal(`assistant`),model:a.string(),content:a.array(a.union([a.object({type:a.literal(`text`),text:a.string()}),a.object({type:a.literal(`tool_use`),id:a.string(),name:a.string(),input:a.record(a.string(),a.unknown())}),a.object({type:a.literal(`thinking`),thinking:a.string(),signature:a.string().optional()})])),stop_reason:a.enum([`end_turn`,`max_tokens`,`tool_use`,`stop_sequence`]).nullable(),stop_sequence:a.string().nullable().optional(),context_management:a.unknown().nullable().optional(),usage:a.object({input_tokens:a.number(),output_tokens:a.number(),cache_creation_input_tokens:a.number().optional(),cache_read_input_tokens:a.number().optional(),service_tier:a.enum([`premium`,`standard`]).nullable().optional()}),ttftMs:a.number().optional()})}),y=a.object({type:a.literal(`user`),session_id:a.string(),message:a.object({role:a.literal(`user`),content:a.array(a.union([a.object({type:a.literal(`tool_result`),tool_use_id:a.string(),content:a.union([a.string(),a.array(a.object({type:a.literal(`text`),text:a.string()}))]),is_error:a.boolean().optional()}),a.object({type:a.literal(`text`),text:a.string()})]))}),parent_tool_use_id:a.string().nullable().optional(),uuid:a.string(),isSynthetic:a.boolean().optional()}),b=a.object({type:a.literal(`result`),session_id:a.string(),uuid:a.string(),subtype:a.enum([`success`,`error_max_turns`,`error_during_execution`]),duration_ms:a.number(),duration_api_ms:a.number(),is_error:a.boolean(),num_turns:a.number(),result:a.unknown().optional(),structured_output:a.unknown().optional(),total_cost_usd:a.number(),usage:a.object({input_tokens:a.number(),cache_creation_input_tokens:a.number().optional(),cache_read_input_tokens:a.number().optional(),output_tokens:a.number(),server_tool_use:a.object({web_search_requests:a.number()}).optional()}).optional()}),x=a.object({type:a.literal(`rate_limit_event`),uuid:a.string(),session_id:a.string().optional(),rate_limit_info:a.object({status:a.string(),resetsAt:a.number().optional(),rateLimitType:a.string().optional(),overageStatus:a.string().optional(),overageDisabledReason:a.string().optional(),isUsingOverage:a.boolean().optional()})}),S=a.discriminatedUnion(`type`,[_,v,y,b,x]),C=a.discriminatedUnion(`type`,[_.extend({uuid:a.string().optional(),mcp_servers:a.array(g).optional()}),v.extend({uuid:a.string().optional()}),y.extend({uuid:a.string().optional()}),b.extend({uuid:a.string().optional(),subtype:a.string()}),x]),w=t(S);export{m as i,C as n,o as r,w as t};
|
package/dist/sandbox/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as FirejailSandbox, c as NsjailSandboxConfig, d as SandboxStatus, f as SandboxType, i as BubblewrapSandboxConfig, l as Sandbox, n as createSandbox, o as FirejailSandboxConfig, r as BubblewrapSandbox, s as NsjailSandbox, t as SandboxCreateError, u as SandboxConfig } from "../index-
|
|
1
|
+
import { a as FirejailSandbox, c as NsjailSandboxConfig, d as SandboxStatus, f as SandboxType, i as BubblewrapSandboxConfig, l as Sandbox, n as createSandbox, o as FirejailSandboxConfig, r as BubblewrapSandbox, s as NsjailSandbox, t as SandboxCreateError, u as SandboxConfig } from "../index-CN0WGc9T.mjs";
|
|
2
2
|
export { type BubblewrapSandbox, type BubblewrapSandboxConfig, type FirejailSandbox, type FirejailSandboxConfig, type NsjailSandbox, type NsjailSandboxConfig, type Sandbox, type SandboxConfig, SandboxCreateError, type SandboxStatus, type SandboxType, createSandbox };
|
package/dist/sandbox/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"../sandbox-
|
|
1
|
+
import{n as e,t}from"../sandbox-CYA69miM.mjs";export{t as SandboxCreateError,e as createSandbox};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{t as e}from"./util-B4HTdOSc.mjs";import{n as t,r as n,t as r}from"./env-Cb8MIvH7.mjs";import{t as i}from"./spawner-CgfyvnR4.mjs";import{t as a}from"./shell-DvWFuFKb.mjs";import{execFile as o}from"node:child_process";import{delimiter as s,isAbsolute as c,join as l,posix as u,resolve as d}from"node:path";import{promisify as f}from"node:util";import{accessSync as p,constants as m,mkdtempSync as h,realpathSync as g,rmSync as _,writeFileSync as v}from"node:fs";import{tmpdir as y}from"node:os";const b=e=>{let t=e.type.charAt(0).toUpperCase()+e.type.slice(1),n=`created`,r=/* @__PURE__ */ new Set,i=()=>{if(n===`disposed`)throw Error(`${t} sandbox has been disposed.`)},a=()=>{if(i(),n!==`running`)throw Error(`${t} sandbox is not running.`)},o=e=>{let t={process:e,waitPromise:e.wait().finally(()=>{r.delete(t)})};return r.add(t),{...e,wait:()=>t.waitPromise}},s=async()=>{let e=Array.from(r,e=>(e.process.kill(`SIGKILL`),e.waitPromise));await Promise.allSettled(e)},c=e.createSpawner(a,o),l={type:e.type,config:e.config,get status(){return n},get workdir(){return e.config.workdir},get spawner(){return c},async start(){i(),n!==`running`&&(await e.onValidate(),n=`running`)},async stop(){i(),n===`running`&&(n=`stopped`,await s())},async dispose(){n!==`disposed`&&(n=`disposed`,await s(),await e.onDispose?.())},[Symbol.asyncDispose](){return l.dispose()}};return e.extend?e.extend(l):l},x=`bwrap`,S=[`/tmp`],C=f(o),w=(e,t)=>e.binds?.some(e=>e.target===t)??!1,T=(e,t)=>{let n=u.relative(e,t);return n===``||!n.startsWith(`..`)&&!u.isAbsolute(n)},E=(e,t)=>e.target.length-t.target.length,ee=e=>{let t=w(e,e.workdir)?[...e.binds??[]]:[{source:e.workdir,target:e.workdir},...e.binds??[]],n=e.tmpfs??S,r=t.filter(e=>!n.some(t=>T(t,e.target))).toSorted(E),i=t.filter(e=>n.some(t=>T(t,e.target))).toSorted(E);return[...r,...i]},te=e=>{let t=[`--ro-bind`,`/`,`/`];for(let n of ee(e))t.push(n.readonly?`--ro-bind`:`--bind`,n.source,n.target);return t},ne=(e,t)=>{let n=[];(e.clearEnv??!0)&&n.push(`--clearenv`);for(let t of e.unsetEnv??[])n.push(`--unsetenv`,t);let r={...e.setEnv,...t.env};for(let[e,t]of Object.entries(r))n.push(`--setenv`,e,t);return n},re=e=>{let t=[`--die-with-parent`,`--new-session`];return(e.unshareAll??!0)&&t.push(`--unshare-all`),e.shareNetwork&&t.push(`--share-net`),e.uid!==void 0&&t.push(`--uid`,String(e.uid)),e.gid!==void 0&&t.push(`--gid`,String(e.gid)),e.hostname&&t.push(`--hostname`,e.hostname),t},ie=e=>{let t=[`--ro-bind`,`/`,`/`];e.proc!==!1&&t.push(`--proc`,e.proc??`/proc`),e.dev!==!1&&t.push(`--dev`,e.dev??`/dev`);for(let n of e.tmpfs??S)t.push(`--tmpfs`,n);t.push(...te(e).slice(3));for(let n of e.remountReadonly??[])t.push(`--remount-ro`,n);return t},ae=(e,t,n,r={})=>[...re(e),...ie(e),...ne(e,r),`--chdir`,r.cwd??e.workdir,...e.args??[],`--`,t,...n],oe=async t=>{try{await C(t,[`--version`],{env:r(),encoding:`utf8`})}catch(t){throw Error(`Bubblewrap start failed: ${e(t)}`)}},D=(e,t,n,i)=>({spawn(a,o,s={}){return t(),n(i.spawn(e.binary??x,ae(e,a,o,s),{env:r(),stdio:s.stdio}))}}),O=async(e,t=i)=>b({type:`bubblewrap`,config:e,onValidate:()=>oe(e.binary??x),createSpawner:(n,r)=>D(e,n,r,t)}),k=e=>new Set((e??[]).flatMap(e=>[e,e.toUpperCase(),e.toLowerCase()])),A=(e,t)=>{let n=k(t);return n.size===0?e:Object.fromEntries(Object.entries(e).filter(([e])=>!n.has(e)))},j=e=>{try{return p(e,m.X_OK),!0}catch{return!1}},M=(e,t)=>c(e)?e:d(t,e),N=(e,t,r)=>{if(c(e)||e.includes(`/`))return e;let i=t[n(t)];if(!i)return e;for(let t of i.split(s)){let n=l(M(t,r),e);if(j(n))return n}return e},P=(e,r)=>{if((r??[]).some(e=>e.toLowerCase()===`path`))return;let i=n(e);if(i in e)return;let a=t(),o=a[n(a)];o&&Object.assign(e,{[i]:o})},F=[`/run/wrappers/bin`,`/usr/local/bin`,`/usr/bin`,`/bin`],I=f(o),L=e=>e.binary??`firejail`,R=()=>{let e=t();return e[n(e)]},z=e=>{if(e.clearEnv===!1)return r({extraPaths:F});let t=r({propagateEnv:!1,extraPaths:F}),i=R();return i&&(t[n(t)]=[...F,i].filter(Boolean).join(s)),t},B=(e,t,n)=>{let r=A({...n,...e.setEnv,...t.env},e.unsetEnv);return P(r,e.unsetEnv),r},V=(e,t,n)=>{let r=[];for(let t of e.unsetEnv??[])r.push(`--rmenv=${t}`);let i={...e.setEnv,...t.env};for(let[e,t]of Object.entries(i))n[e]!==t&&r.push(`--env=${e}=${t}`);return r},H=(e,t,n,r={},i={})=>{let a=[`--noprofile`];e.shareNetwork||a.push(`--net=none`);for(let t of e.whitelist??[])a.push(`--whitelist=${t}`);for(let t of e.blacklist??[])a.push(`--blacklist=${t}`);for(let t of e.readOnly??[])a.push(`--read-only=${t}`);for(let t of e.readWrite??[])a.push(`--read-write=${t}`);return e.privateTmp&&a.push(`--private-tmp`),a.push(...V(e,r,i)),e.args?.length&&a.push(...e.args),a.push(`--`,t,...n),a},U=async t=>{try{await I(t,[`--version`],{env:r({extraPaths:F}),encoding:`utf8`})}catch(t){throw Error(`Firejail start failed: ${e(t)}`)}},W=(e,t,n,r)=>({spawn(i,o,s={}){t();let c=s.cwd??e.workdir,l=z(e),u=`exec ${[N(i,B(e,s,l),c),...o].map(a).join(` `)}`;return n(r.spawn(L(e),H(e,`sh`,[`-c`,u],s,l),{cwd:c,env:l,stdio:s.stdio}))}}),G=async(e,t=i)=>b({type:`firejail`,config:e,onValidate:()=>U(L(e)),createSpawner:(n,r)=>W(e,n,r,t)}),K=`nsjail`,se=[`/tmp`],ce=f(o),q=e=>JSON.stringify(e),J=(e,t)=>e.target.length-t.target.length||Number(!!e.readonly)-Number(!!t.readonly),le=(e,t)=>e.binds?.some(e=>e.target===t)??!1,Y=e=>e.tmpfs??[...se],ue=(e,t)=>Y(e).includes(t),de=e=>{let t=le(e,e.workdir)?[...e.binds??[]]:[{source:e.workdir,target:e.workdir},...e.binds??[]],n=(e.readOnly??[]).map(e=>({source:e,target:e,readonly:!0,type:`bind`}));return[...t.map(e=>({source:e.source,target:e.target,readonly:e.readonly,type:`bind`})),...n].filter(t=>!ue(e,t.target)).toSorted(J)},fe=e=>Y(e).map(t=>({target:t,readonly:e.readOnly?.includes(t),type:`tmpfs`})).toSorted(J),pe=e=>[{source:`/`,target:`/`,readonly:!0,type:`bind`},...fe(e),...de(e)],X=(e,t)=>{let n=A(e.clearEnv===!1?r():r({propagateEnv:!1}),e.unsetEnv);return Object.assign(n,e.setEnv,t.env),P(n,e.unsetEnv),n},Z=(e,t,n)=>[`${e} {`,` inside_id: ${q(String(t))}`,` outside_id: ${q(String(n))}`,` count: 1`,`}`].join(`
|
|
2
|
+
`),me=e=>{if(e!==void 0)try{return g(e)}catch{return e}},Q=e=>{let t=[`mount {`],n=me(e.source);return n!==void 0&&t.push(` src: ${q(n)}`),t.push(` dst: ${q(e.target)}`),e.type===`tmpfs`?t.push(` fstype: ${q(`tmpfs`)}`):t.push(` is_bind: true`),t.push(` rw: ${e.readonly?`false`:`true`}`),t.push(` mandatory: true`),t.push(`}`),t.join(`
|
|
3
|
+
`)},he=(e,t,n)=>{let r=t.cwd??e.workdir,i=n??X(e,t),a=e.hostname??`NSJAIL`,o=typeof process.getuid==`function`?process.getuid():0,s=typeof process.getgid==`function`?process.getgid():0,c=e.uid??o,l=e.gid??s,u=e.clearEnv===!1&&(e.unsetEnv?.length??0)===0,d=[`name: "coding-agents-sdk"`,`mode: ONCE`,`hostname: ${q(a)}`,`cwd: ${q(r)}`,`keep_env: ${u?`true`:`false`}`,`clone_newnet: ${e.shareNetwork?`false`:`true`}`,`clone_newuser: true`,`clone_newns: true`,`clone_newpid: true`,`clone_newipc: true`,`clone_newuts: true`,`mount_proc: true`,`time_limit: ${String(e.timeLimitSec??0)}`,Z(`uidmap`,c,o),Z(`gidmap`,l,s)];e.seccompString&&d.push(`seccomp_string: ${q(e.seccompString)}`);for(let[e,t]of Object.entries(i)){let n=`${e}=${t}`;d.push(`envar: ${q(n)}`)}for(let t of pe(e))d.push(Q(t));return`${d.join(`
|
|
4
|
+
`)}\n`},ge=(e,t,n,r)=>{let i=[`-C`,t];return(e.disableRlimits??!0)&&i.push(`--disable_rlimits`),i.push(...e.args??[],`--`,n,...r),i},_e=async t=>{try{await ce(t,[`--help`],{env:r(),encoding:`utf8`})}catch(t){throw Error(`Nsjail start failed: ${e(t)}`)}},ve=(e,t,n,i,a)=>({spawn(o,s,c={}){n();let u=t(),d=X(e,c),f=c.cwd??e.workdir,p=N(o,d,f),m=l(u.configDir,`spawn-${Date.now()}-${Math.random().toString(16).slice(2)}.cfg`);v(m,he(e,c,d),{encoding:`utf8`,mode:384});try{let t=i(a.spawn(e.binary??K,ge(e,m,p,s),{env:r(),stdio:c.stdio})),n=t.wait().finally(()=>{_(m,{force:!0})});return{...t,wait:()=>n}}catch(e){throw _(m,{force:!0}),e}}}),ye=async(e,t=i)=>{let n,r=()=>{if(!n)throw Error(`Nsjail sandbox has not been started.`);return n};return b({type:`nsjail`,config:e,async onValidate(){await _e(e.binary??K),n??={configDir:h(l(y(),`cw-nsjail-`))}},onDispose(){n&&_(n.configDir,{recursive:!0,force:!0})},createSpawner:(n,i)=>ve(e,r,n,i,t)})};var $=class extends Error{constructor(e){super(e),this.name=`SandboxCreateError`}};async function be(e){switch(e.type){case`bubblewrap`:return O(e);case`firejail`:return G(e);case`nsjail`:return ye(e);default:throw new $(`Unsupported sandbox type.`)}}export{be as n,$ as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=`SendUserMessage`,t=t=>t?.includes(e)?[...t]:[...t??[],e],n=e=>{let t;for(let[,n]of e)n.toolName===`StructuredOutput`&&n.input!==void 0&&(t=n.input);return t},r=(e,t,r,i)=>{if(e!=null)return{value:e};if(!t.schemaRequested)return{};if(t.allowToolCallFallback??!0){let e=n(t.toolCalls);if(e!==void 0)return{value:e}}return r.isSuccess?{error:{kind:`parse`,message:i}}:{}};export{t as n,r as t};
|
|
1
|
+
const e=`SendUserMessage`,t=t=>t?.includes(e)?[...t]:[...t??[],e],n=e=>{let t;for(let[,n]of e)n.toolName===`StructuredOutput`&&n.input!==void 0&&(t=n.input);return t},r=(e,t,r,i)=>{if(e!=null)return{value:e};if(!t.schemaRequested)return{};if(t.allowToolCallFallback??!0){let e=n(t.toolCalls);if(e!==void 0)return{value:e}}return r.isSuccess?{error:{kind:`parse`,message:i}}:{}},i=e=>{let t={...e};return delete t.$schema,t},a=[`CLAUDECODE`,`CLAUDE_CODE_CHILD_SESSION`],o=e=>{for(let t of a)delete e[t]};export{t as i,i as n,r,o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./errors-aYGbvsaq.mjs";import{spawn as t}from"node:child_process";const n=e=>({async*[Symbol.asyncIterator](){for await(let t of e){if(t instanceof Buffer){yield new Uint8Array(t);continue}if(typeof t==`string`){yield new TextEncoder().encode(t);continue}if(t instanceof Uint8Array){yield t;continue}throw Error(`Unsupported stdout/stderr chunk type: ${typeof t}`)}}}),r=(r,i,a={})=>{let o=t(r,i,{cwd:a.cwd,env:a.env,stdio:a.stdio,detached:!0}),s,c=t=>{s??=new e(t)};o.stdin?.on(`error`,c);let l=new Promise((e,t)=>{let n=(n,i)=>{if(o.removeListener(`error`,r),s){t(s);return}e({exitCode:n,signal:i})},r=e=>{o.removeListener(`close`,n),t(e)};o.once(`error`,r),o.once(`close`,n)}),u=o.stdin;return{stdout:o.stdout?n(o.stdout):null,stderr:o.stderr?n(o.stderr):null,stdin:u?{write:e=>{let t=new Promise((t,n)=>{u.write(e,e=>{if(e){n(e);return}t()})});return t.catch(c),t},end:()=>{let e=new Promise((e,t)=>{u.end(n=>{if(n){t(n);return}e()})});return e.catch(c),e}}:null,kill:e=>{if(o.pid===void 0){o.kill(e);return}try{process.kill(-o.pid,e??`SIGTERM`)}catch{o.kill(e)}},wait:()=>l}},i={spawn:r};export{r as n,i as t};
|
|
@@ -1,61 +1,6 @@
|
|
|
1
1
|
import { t as AgentEvent, v as AgentCapabilities, x as JsonSchema, y as ContentPart } from "./events-BxEB6zHt.mjs";
|
|
2
|
+
import { r as ProcessSignal } from "./types-COmjfh8B.mjs";
|
|
2
3
|
import { ZodType } from "zod/v4";
|
|
3
|
-
//#region src/core/process/types.d.ts
|
|
4
|
-
type StdioOption = "ignore" | "inherit" | "pipe" | number;
|
|
5
|
-
/** POSIX signal name (re-export of `NodeJS.Signals`). */
|
|
6
|
-
type ProcessSignal = NodeJS.Signals;
|
|
7
|
-
/**
|
|
8
|
-
* Options accepted by {@link ProcessSpawner.spawn} when launching a
|
|
9
|
-
* subprocess. Adapters set sensible defaults; callers typically only need to
|
|
10
|
-
* override these inside custom spawners.
|
|
11
|
-
*/
|
|
12
|
-
interface SpawnOptions {
|
|
13
|
-
/** Working directory for the subprocess. Defaults to the spawner's default. */
|
|
14
|
-
cwd?: string;
|
|
15
|
-
/** Environment variables for the subprocess. */
|
|
16
|
-
env?: Record<string, string>;
|
|
17
|
-
/** Stdio disposition for [stdin, stdout, stderr]. Default is `["pipe", "pipe", "pipe"]`. */
|
|
18
|
-
stdio?: [StdioOption, StdioOption, StdioOption];
|
|
19
|
-
}
|
|
20
|
-
/** Subprocess termination result returned by {@link AgentProcess.wait}. */
|
|
21
|
-
interface ProcessResult {
|
|
22
|
-
/** Exit code; `null` if the process was killed by signal. */
|
|
23
|
-
exitCode: number | null;
|
|
24
|
-
/** Signal that terminated the process; `null` if it exited normally. */
|
|
25
|
-
signal: ProcessSignal | null;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Handle to a running subprocess returned by {@link ProcessSpawner.spawn}.
|
|
29
|
-
* Exposes byte streams for stdio, a kill signal, and a `wait` for terminal
|
|
30
|
-
* status. Each stream is `null` when its slot was set to `"ignore"` or
|
|
31
|
-
* `"inherit"` in {@link SpawnOptions.stdio}.
|
|
32
|
-
*/
|
|
33
|
-
interface AgentProcess {
|
|
34
|
-
/** Stdout byte stream, or `null` if not piped. */
|
|
35
|
-
stdout: AsyncIterable<Uint8Array> | null;
|
|
36
|
-
/** Stderr byte stream, or `null` if not piped. */
|
|
37
|
-
stderr: AsyncIterable<Uint8Array> | null;
|
|
38
|
-
/** Stdin writer with optional `write` and required `end`, or `null` if not piped. */
|
|
39
|
-
stdin: {
|
|
40
|
-
write?: (chunk: Uint8Array | string) => void;
|
|
41
|
-
end: () => void;
|
|
42
|
-
} | null;
|
|
43
|
-
kill: (signal?: ProcessSignal | number) => void;
|
|
44
|
-
/** Resolve with the {@link ProcessResult} once the process exits. */
|
|
45
|
-
wait: () => Promise<ProcessResult>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Pluggable process launcher used by CLI adapters and exposed by
|
|
49
|
-
* containers and sandboxes via their `spawner` field. Pass a custom
|
|
50
|
-
* `ProcessSpawner` to an adapter's `spawner` option to intercept how the
|
|
51
|
-
* underlying agent CLI is launched (for instrumentation, sandboxing, or
|
|
52
|
-
* remote execution).
|
|
53
|
-
*/
|
|
54
|
-
interface ProcessSpawner {
|
|
55
|
-
/** Launch `command` with `args` and return a live {@link AgentProcess} handle. */
|
|
56
|
-
spawn: (command: string, args: string[], options?: SpawnOptions) => AgentProcess;
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
4
|
//#region src/core/agent/permissions.d.ts
|
|
60
5
|
/**
|
|
61
6
|
* Information about a tool call the adapter is requesting permission for.
|
|
@@ -347,6 +292,14 @@ declare class AgentValidationError extends Error {
|
|
|
347
292
|
}
|
|
348
293
|
/** Callback registered via `agent.onEvent(...)`; invoked synchronously for every emitted event. */
|
|
349
294
|
type AgentEventHandler = (event: AgentEvent) => void;
|
|
295
|
+
interface ProviderEvent<TEvent> {
|
|
296
|
+
agentType: AgentType;
|
|
297
|
+
runId: string;
|
|
298
|
+
sessionId?: string;
|
|
299
|
+
timestamp: Date;
|
|
300
|
+
event: TEvent;
|
|
301
|
+
}
|
|
302
|
+
type ProviderEventHandler<TEvent> = (event: ProviderEvent<TEvent>) => void;
|
|
350
303
|
/**
|
|
351
304
|
* Lifetime counters for an agent instance.
|
|
352
305
|
*
|
|
@@ -488,4 +441,4 @@ interface BaseAgent<TRunOptions extends object = {}> {
|
|
|
488
441
|
onPermissionRequest: (handler: PermissionHandler) => () => void;
|
|
489
442
|
}
|
|
490
443
|
//#endregion
|
|
491
|
-
export {
|
|
444
|
+
export { PermissionRequest as A, RunStatus as C, ZodRunRequest as D, StructuredRunRequest as E, PermissionDecision as O, RunStats as S, StopReason as T, ProviderEventHandler as _, AgentValidationError as a, RunRequest as b, AnyRunResult as c, CompletedRunResult as d, EnsureDisjoint as f, ProviderEvent as g, JsonSchemaRunRequest as h, AgentType as i, PermissionHandler as k, BaseAgent as l, FailedRunResult as m, AgentMetrics as n, AnyCompletedRunResult as o, ExclusiveExecutionTargetOptions as p, AgentRunError as r, AnyRunRequest as s, AgentEventHandler as t, CancelledRunResult as u, RunError as v, RunTiming as w, RunResult as x, RunProcessInfo as y };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//#region src/core/process/types.d.ts
|
|
2
|
+
type StdioOption = "ignore" | "inherit" | "pipe" | number;
|
|
3
|
+
/** POSIX signal name (re-export of `NodeJS.Signals`). */
|
|
4
|
+
type ProcessSignal = NodeJS.Signals;
|
|
5
|
+
/**
|
|
6
|
+
* Options accepted by {@link ProcessSpawner.spawn} when launching a
|
|
7
|
+
* subprocess. Adapters set sensible defaults; callers typically only need to
|
|
8
|
+
* override these inside custom spawners.
|
|
9
|
+
*/
|
|
10
|
+
interface SpawnOptions {
|
|
11
|
+
/** Working directory for the subprocess. Defaults to the spawner's default. */
|
|
12
|
+
cwd?: string;
|
|
13
|
+
/** Environment variables for the subprocess. */
|
|
14
|
+
env?: Record<string, string>;
|
|
15
|
+
/** Stdio disposition for [stdin, stdout, stderr]. Default is `["pipe", "pipe", "pipe"]`. */
|
|
16
|
+
stdio?: [StdioOption, StdioOption, StdioOption];
|
|
17
|
+
}
|
|
18
|
+
/** Subprocess termination result returned by {@link AgentProcess.wait}. */
|
|
19
|
+
interface ProcessResult {
|
|
20
|
+
/** Exit code; `null` if the process was killed by signal. */
|
|
21
|
+
exitCode: number | null;
|
|
22
|
+
/** Signal that terminated the process; `null` if it exited normally. */
|
|
23
|
+
signal: ProcessSignal | null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Handle to a running subprocess returned by {@link ProcessSpawner.spawn}.
|
|
27
|
+
* Exposes byte streams for stdio, a kill signal, and a `wait` for terminal
|
|
28
|
+
* status. Each stream is `null` when its slot was set to `"ignore"` or
|
|
29
|
+
* `"inherit"` in {@link SpawnOptions.stdio}.
|
|
30
|
+
*/
|
|
31
|
+
interface AgentProcess {
|
|
32
|
+
/** Stdout byte stream, or `null` if not piped. */
|
|
33
|
+
stdout: AsyncIterable<Uint8Array> | null;
|
|
34
|
+
/** Stderr byte stream, or `null` if not piped. */
|
|
35
|
+
stderr: AsyncIterable<Uint8Array> | null;
|
|
36
|
+
/** Stdin writer with optional `write` and required `end`, or `null` if not piped. */
|
|
37
|
+
stdin: {
|
|
38
|
+
write?: (chunk: Uint8Array | string) => void | Promise<void>;
|
|
39
|
+
end: () => void | Promise<void>;
|
|
40
|
+
} | null;
|
|
41
|
+
kill: (signal?: ProcessSignal | number) => void;
|
|
42
|
+
/** Resolve with the {@link ProcessResult} once the process exits. */
|
|
43
|
+
wait: () => Promise<ProcessResult>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Pluggable process launcher used by CLI adapters and exposed by
|
|
47
|
+
* containers and sandboxes via their `spawner` field. Pass a custom
|
|
48
|
+
* `ProcessSpawner` to an adapter's `spawner` option to intercept how the
|
|
49
|
+
* underlying agent CLI is launched (for instrumentation, sandboxing, or
|
|
50
|
+
* remote execution).
|
|
51
|
+
*/
|
|
52
|
+
interface ProcessSpawner {
|
|
53
|
+
/** Launch `command` with `args` and return a live {@link AgentProcess} handle. */
|
|
54
|
+
spawn: (command: string, args: string[], options?: SpawnOptions) => AgentProcess;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { SpawnOptions as a, ProcessSpawner as i, ProcessResult as n, ProcessSignal as r, AgentProcess as t };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=e=>Array.isArray(e)?e:[e],t=e=>e instanceof Error?e.message:String(e),n=e=>typeof e==`object`&&!!e,r=(...e)=>{if(!e.every(e=>e===void 0))return e.reduce((e,t)=>e+(t??0),0)},i=e=>{let t=e.trim();return t.startsWith("```")?t.replace(/^```[\w-]*\s*/i,``).replace(/\s*```$/i,``).trim():t},a=e=>/```[\w-]*\s*([\S\s]*?)\s*```/i.exec(e)?.[1]?.trim(),o=e=>{let t=-1,n=[],r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o){if(t===-1){(o===`{`||o===`[`)&&(t=a,n.push(o));continue}if(r){if(i){i=!1;continue}if(o===`\\`){i=!0;continue}o===`"`&&(r=!1);continue}if(o===`"`){r=!0;continue}if(o===`{`||o===`[`){n.push(o);continue}if(o===`}`||o===`]`){let r=n.pop();if(r===`{`&&o!==`}`||r===`[`&&o!==`]`)return;if(n.length===0)return e.slice(t,a+1).trim()}}}},s=e=>{let t=e.trim(),n=[i(t),a(t),o(t)],r;for(let e of new Set(n))if(e)try{return JSON.parse(e)}catch(e){r=e}throw r instanceof Error?r
|
|
1
|
+
const e=e=>Array.isArray(e)?e:[e],t=e=>e instanceof Error?e.message:String(e),n=e=>typeof e==`object`&&!!e,r=(...e)=>{if(!e.every(e=>e===void 0))return e.reduce((e,t)=>e+(t??0),0)},i=e=>{let t=e.trim();return t.startsWith("```")?t.replace(/^```[\w-]*\s*/i,``).replace(/\s*```$/i,``).trim():t},a=e=>/```[\w-]*\s*([\S\s]*?)\s*```/i.exec(e)?.[1]?.trim(),o=e=>{let t=-1,n=[],r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o){if(t===-1){(o===`{`||o===`[`)&&(t=a,n.push(o));continue}if(r){if(i){i=!1;continue}if(o===`\\`){i=!0;continue}o===`"`&&(r=!1);continue}if(o===`"`){r=!0;continue}if(o===`{`||o===`[`){n.push(o);continue}if(o===`}`||o===`]`){let r=n.pop();if(r===`{`&&o!==`}`||r===`[`&&o!==`]`)return;if(n.length===0)return e.slice(t,a+1).trim()}}}},s=e=>{let t=e.trim(),n=[i(t),a(t),o(t)],r;for(let e of new Set(n))if(e)try{return JSON.parse(e)}catch(e){r=e}throw r instanceof Error?r:/* @__PURE__ */ SyntaxError(`Failed to parse JSON response text.`)};export{e as a,r as i,n,s as r,t};
|