coding-agents-sdk 0.10.0 → 0.11.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 +8 -7
- package/dist/adapters/claude-code-cli/index.d.mts +1 -1
- package/dist/adapters/claude-code-cli-pty/index.d.mts +3 -0
- package/dist/adapters/claude-code-cli-pty/index.mjs +35 -0
- package/dist/adapters/claude-code-sdk/index.d.mts +1 -1
- package/dist/adapters/codex-cli/index.d.mts +1 -1
- package/dist/adapters/codex-sdk/index.d.mts +1 -1
- package/dist/adapters/cursor-cli/index.d.mts +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/opencode-cli/index.d.mts +1 -1
- package/dist/adapters/pi-cli/index.d.mts +1 -1
- package/dist/container/index.d.mts +1 -1
- package/dist/{events-Dd9r9luo.d.mts → events-Bwfw__Q3.d.mts} +139 -0
- package/dist/index-B0x76PaA.d.mts +104 -0
- package/dist/{index-J7V9dJTb.d.mts → index-BQNj8DHq.d.mts} +46 -15
- package/dist/index-B_MIEnNS.d.mts +60 -0
- package/dist/index-BeejNCvc.d.mts +429 -0
- package/dist/index-C8wbKjj3.d.mts +188 -0
- package/dist/index-CEHYyi4k.d.mts +68 -0
- package/dist/{index-BNeL0BbU.d.mts → index-ClURbAqF.d.mts} +67 -1
- package/dist/index-CyxdNK5W.d.mts +58 -0
- package/dist/{index-DZDlHIep.d.mts → index-D5zrCo6s.d.mts} +43 -12
- package/dist/index-ILgtPW1P.d.mts +97 -0
- package/dist/index-dPV54_sZ.d.mts +69 -0
- package/dist/{index-B-rto_J2.d.mts → index-p8MJ49dZ.d.mts} +77 -1
- package/dist/index.d.mts +69 -19
- package/dist/index.mjs +1 -1
- package/dist/sandbox/index.d.mts +1 -1
- package/dist/schemas/index.d.mts +1 -1
- package/dist/types-Bk-YpdbX.d.mts +476 -0
- package/package.json +14 -14
- package/dist/adapters/claude-cli-pty/index.d.mts +0 -3
- package/dist/adapters/claude-cli-pty/index.mjs +0 -7
- package/dist/index-B4RAMnx_.d.mts +0 -46
- package/dist/index-BdDz7C4J.d.mts +0 -39
- package/dist/index-BiWkGgnz.d.mts +0 -46
- package/dist/index-BllemWbi.d.mts +0 -42
- package/dist/index-C7J_hmQs.d.mts +0 -67
- package/dist/index-CaUzD36R.d.mts +0 -42
- package/dist/index-D-8EmRnQ.d.mts +0 -85
- package/dist/index-lGZ1lQkG.d.mts +0 -246
- package/dist/types-D6kxBNzj.d.mts +0 -195
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { A as ProcessSpawner } from "./types-Bk-YpdbX.mjs";
|
|
2
|
+
import { X as VolumeMount } from "./index-BeejNCvc.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/sandbox/types.d.ts
|
|
5
|
+
/** Which sandbox binary backs the policy. The binary must be installed on the host. */
|
|
6
|
+
type SandboxType = "bubblewrap" | "firejail" | "nsjail";
|
|
7
|
+
/** Lifecycle state of a sandbox. */
|
|
8
|
+
type SandboxStatus = "created" | "disposed" | "running" | "stopped";
|
|
9
|
+
/** Fields shared by every sandbox config. */
|
|
10
|
+
interface SandboxConfigBase<TType extends SandboxType> {
|
|
11
|
+
type: TType;
|
|
12
|
+
/** Working directory the wrapped agent process operates against. */
|
|
13
|
+
workdir: string;
|
|
14
|
+
}
|
|
15
|
+
/** Identity facet of a sandbox. */
|
|
16
|
+
interface SandboxIdentity<TType extends SandboxType, TConfig extends SandboxConfigBase<TType>> {
|
|
17
|
+
readonly type: TType;
|
|
18
|
+
readonly config: TConfig;
|
|
19
|
+
readonly status: SandboxStatus;
|
|
20
|
+
readonly workdir: string;
|
|
21
|
+
}
|
|
22
|
+
/** Lifecycle facet of a sandbox. Unlike containers, sandboxes typically have nothing to "start" — `dispose` releases any temp resources. */
|
|
23
|
+
interface SandboxLifecycle {
|
|
24
|
+
/** No-op for most backends; reserved for backends that need to materialize state. */
|
|
25
|
+
start: () => Promise<void>;
|
|
26
|
+
/** No-op for most backends; reserved for backends that need to release resources. */
|
|
27
|
+
stop: () => Promise<void>;
|
|
28
|
+
/** Release any temporary files, mounts, or seccomp rules associated with this sandbox. Idempotent. */
|
|
29
|
+
dispose: () => Promise<void>;
|
|
30
|
+
[Symbol.asyncDispose]: () => Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
/** Execution facet — exposes the spawner the adapter wires into the wrapped agent. */
|
|
33
|
+
interface SandboxExecution {
|
|
34
|
+
/** Process spawner that runs subprocesses inside the sandbox. */
|
|
35
|
+
readonly spawner: ProcessSpawner;
|
|
36
|
+
}
|
|
37
|
+
/** Composed shape of every concrete sandbox instance. */
|
|
38
|
+
interface SandboxBase<TType extends SandboxType, TConfig extends SandboxConfigBase<TType>> extends SandboxExecution, SandboxIdentity<TType, TConfig>, SandboxLifecycle {}
|
|
39
|
+
/**
|
|
40
|
+
* Bubblewrap-backed sandbox. Lightweight, namespace-based, no setuid required
|
|
41
|
+
* on modern kernels. Good default for most use cases.
|
|
42
|
+
*/
|
|
43
|
+
interface BubblewrapSandboxConfig extends SandboxConfigBase<"bubblewrap"> {
|
|
44
|
+
/** Override the path to the `bwrap` binary. Defaults to looking up `bwrap` on `PATH`. */
|
|
45
|
+
binary?: string;
|
|
46
|
+
/** Mounts to bind into the sandbox. Use `readonly: true` for read-only mounts. */
|
|
47
|
+
binds?: VolumeMount[];
|
|
48
|
+
/** Start from an empty environment, ignoring the host's `process.env`. */
|
|
49
|
+
clearEnv?: boolean;
|
|
50
|
+
/** Environment variables to set inside the sandbox. */
|
|
51
|
+
setEnv?: Record<string, string>;
|
|
52
|
+
/** Environment variable names to delete inside the sandbox. */
|
|
53
|
+
unsetEnv?: string[];
|
|
54
|
+
/** Unshare all namespaces (PID, IPC, mount, network, UTS, user). */
|
|
55
|
+
unshareAll?: boolean;
|
|
56
|
+
/** When `unshareAll` is set, keep the host network namespace. */
|
|
57
|
+
shareNetwork?: boolean;
|
|
58
|
+
/** Hostname inside the sandbox. */
|
|
59
|
+
hostname?: string;
|
|
60
|
+
/** Inside-sandbox UID. */
|
|
61
|
+
uid?: number;
|
|
62
|
+
/** Inside-sandbox GID. */
|
|
63
|
+
gid?: number;
|
|
64
|
+
/** Paths to mount as tmpfs inside the sandbox. */
|
|
65
|
+
tmpfs?: string[];
|
|
66
|
+
/** Paths to remount read-only. */
|
|
67
|
+
remountReadonly?: string[];
|
|
68
|
+
/** Where to mount `/proc`. `false` disables; defaults to `/proc`. */
|
|
69
|
+
proc?: false | string;
|
|
70
|
+
/** Where to mount `/dev`. `false` disables; defaults to `/dev`. */
|
|
71
|
+
dev?: false | string;
|
|
72
|
+
/** Extra `bwrap` flags appended verbatim. */
|
|
73
|
+
args?: string[];
|
|
74
|
+
}
|
|
75
|
+
/** Bubblewrap sandbox instance. */
|
|
76
|
+
interface BubblewrapSandbox extends SandboxBase<"bubblewrap", BubblewrapSandboxConfig> {}
|
|
77
|
+
/**
|
|
78
|
+
* Firejail-backed sandbox. Higher-level than bubblewrap; uses seccomp profiles
|
|
79
|
+
* and a curated `whitelist`/`blacklist` model.
|
|
80
|
+
*/
|
|
81
|
+
interface FirejailSandboxConfig extends SandboxConfigBase<"firejail"> {
|
|
82
|
+
/** Override the path to the `firejail` binary. */
|
|
83
|
+
binary?: string;
|
|
84
|
+
/** Start from an empty environment, ignoring the host's `process.env`. */
|
|
85
|
+
clearEnv?: boolean;
|
|
86
|
+
/** Environment variables to set inside the sandbox. */
|
|
87
|
+
setEnv?: Record<string, string>;
|
|
88
|
+
/** Environment variable names to delete inside the sandbox. */
|
|
89
|
+
unsetEnv?: string[];
|
|
90
|
+
/** Allow network access. Disabled by default. */
|
|
91
|
+
shareNetwork?: boolean;
|
|
92
|
+
/** Paths visible to the sandboxed process; everything else is hidden. */
|
|
93
|
+
whitelist?: string[];
|
|
94
|
+
/** Paths hidden from the sandboxed process. */
|
|
95
|
+
blacklist?: string[];
|
|
96
|
+
/** Paths exposed read-only. */
|
|
97
|
+
readOnly?: string[];
|
|
98
|
+
/** Paths exposed read-write. */
|
|
99
|
+
readWrite?: string[];
|
|
100
|
+
/** Use a private tmpfs `/tmp`. */
|
|
101
|
+
privateTmp?: boolean;
|
|
102
|
+
/** Extra `firejail` flags appended verbatim. */
|
|
103
|
+
args?: string[];
|
|
104
|
+
}
|
|
105
|
+
/** Firejail sandbox instance. */
|
|
106
|
+
interface FirejailSandbox extends SandboxBase<"firejail", FirejailSandboxConfig> {}
|
|
107
|
+
/**
|
|
108
|
+
* nsjail-backed sandbox. Most flexible (full namespace and rlimit control,
|
|
109
|
+
* custom seccomp policies), most complex to configure.
|
|
110
|
+
*/
|
|
111
|
+
interface NsjailSandboxConfig extends SandboxConfigBase<"nsjail"> {
|
|
112
|
+
/** Override the path to the `nsjail` binary. */
|
|
113
|
+
binary?: string;
|
|
114
|
+
/** Mounts to bind into the sandbox. */
|
|
115
|
+
binds?: VolumeMount[];
|
|
116
|
+
/** Paths exposed read-only. */
|
|
117
|
+
readOnly?: string[];
|
|
118
|
+
/** Start from an empty environment, ignoring the host's `process.env`. */
|
|
119
|
+
clearEnv?: boolean;
|
|
120
|
+
/** Environment variables to set inside the sandbox. */
|
|
121
|
+
setEnv?: Record<string, string>;
|
|
122
|
+
/** Environment variable names to delete inside the sandbox. */
|
|
123
|
+
unsetEnv?: string[];
|
|
124
|
+
/** Allow network access. Disabled by default. */
|
|
125
|
+
shareNetwork?: boolean;
|
|
126
|
+
/** Inside-sandbox UID. Host IDs are mapped from the current process. */
|
|
127
|
+
uid?: number;
|
|
128
|
+
/** Inside-sandbox GID. Host IDs are mapped from the current process. */
|
|
129
|
+
gid?: number;
|
|
130
|
+
hostname?: string;
|
|
131
|
+
/** Paths to mount as tmpfs. */
|
|
132
|
+
tmpfs?: string[];
|
|
133
|
+
/** Wall-clock time limit for jailed processes, in seconds. */
|
|
134
|
+
timeLimitSec?: number;
|
|
135
|
+
/** Disable nsjail's default rlimits. */
|
|
136
|
+
disableRlimits?: boolean;
|
|
137
|
+
/** Custom seccomp BPF program as a string (advanced). */
|
|
138
|
+
seccompString?: string;
|
|
139
|
+
/** Extra `nsjail` flags appended verbatim. */
|
|
140
|
+
args?: string[];
|
|
141
|
+
}
|
|
142
|
+
/** nsjail sandbox instance. */
|
|
143
|
+
interface NsjailSandbox extends SandboxBase<"nsjail", NsjailSandboxConfig> {}
|
|
144
|
+
/** Union of all sandbox configs accepted by `createSandbox(...)`. */
|
|
145
|
+
type SandboxConfig = BubblewrapSandboxConfig | FirejailSandboxConfig | NsjailSandboxConfig;
|
|
146
|
+
/** Union of all sandbox instance types. */
|
|
147
|
+
type Sandbox = BubblewrapSandbox | FirejailSandbox | NsjailSandbox;
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/sandbox/index.d.ts
|
|
150
|
+
/**
|
|
151
|
+
* Create a Linux-only process sandbox for confined agent execution.
|
|
152
|
+
*
|
|
153
|
+
* Unlike `createContainer`, sandboxes don't isolate the filesystem in a new
|
|
154
|
+
* mount namespace by default — they wrap subprocess invocation with a sandbox
|
|
155
|
+
* binary (`bubblewrap`, `firejail`, or `nsjail`) that enforces a configured
|
|
156
|
+
* policy: which paths are readable, writable, executable, and which syscalls
|
|
157
|
+
* or network operations are allowed.
|
|
158
|
+
*
|
|
159
|
+
* The `type` field selects which sandbox binary is used; the binary must be
|
|
160
|
+
* installed on the host. Bubblewrap is the most common; firejail and nsjail
|
|
161
|
+
* suit stricter syscall-filtering policies.
|
|
162
|
+
*
|
|
163
|
+
* Pass the resulting sandbox to a cli-adapter's `sandbox` option to wrap the
|
|
164
|
+
* agent's subprocess. Container and sandbox are mutually exclusive — use one
|
|
165
|
+
* or the other.
|
|
166
|
+
*
|
|
167
|
+
* ```ts
|
|
168
|
+
* const sandbox = await createSandbox({
|
|
169
|
+
* type: "bubblewrap",
|
|
170
|
+
* workdir: process.cwd(),
|
|
171
|
+
* binds: [
|
|
172
|
+
* { source: "/usr", target: "/usr", readonly: true },
|
|
173
|
+
* { source: process.cwd(), target: process.cwd() },
|
|
174
|
+
* ],
|
|
175
|
+
* shareNetwork: false,
|
|
176
|
+
* });
|
|
177
|
+
* await using agent = await createAgent("claude-code-cli", { sandbox });
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @param config Sandbox configuration. Required: `type`. Optional: binds, env, network policy.
|
|
181
|
+
* @returns A promise that resolves to a sandbox handle whose `spawner` is wired into the chosen agent adapter.
|
|
182
|
+
* @throws {Error} If `config.type` is not one of the supported sandbox kinds.
|
|
183
|
+
*/
|
|
184
|
+
declare function createSandbox(config: BubblewrapSandboxConfig): Promise<BubblewrapSandbox>;
|
|
185
|
+
declare function createSandbox(config: FirejailSandboxConfig): Promise<FirejailSandbox>;
|
|
186
|
+
declare function createSandbox(config: NsjailSandboxConfig): Promise<NsjailSandbox>;
|
|
187
|
+
//#endregion
|
|
188
|
+
export { FirejailSandboxConfig as a, Sandbox as c, SandboxConfigBase as d, SandboxExecution as f, SandboxType as g, SandboxStatus as h, FirejailSandbox as i, SandboxBase as l, SandboxLifecycle as m, BubblewrapSandbox as n, NsjailSandbox as o, SandboxIdentity as p, BubblewrapSandboxConfig as r, NsjailSandboxConfig as s, createSandbox as t, SandboxConfig as u };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { A as ProcessSpawner, f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-Bk-YpdbX.mjs";
|
|
2
|
+
import { t as Container } from "./index-BeejNCvc.mjs";
|
|
3
|
+
import { c as Sandbox } from "./index-C8wbKjj3.mjs";
|
|
4
|
+
import { z } from "zod/v4";
|
|
5
|
+
|
|
6
|
+
//#region src/adapters/pi-cli/events/schemas.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Permissive raw-event shape for Pi CLI: `{ type: string }` plus arbitrary
|
|
9
|
+
* additional fields the CLI may emit.
|
|
10
|
+
*/
|
|
11
|
+
declare const piEventSchema: z.ZodObject<{
|
|
12
|
+
type: z.ZodString;
|
|
13
|
+
}, z.core.$loose>;
|
|
14
|
+
type PiEvent = z.infer<typeof piEventSchema>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/adapters/pi-cli/types.d.ts
|
|
17
|
+
/** How much hidden reasoning Pi should perform per turn. */
|
|
18
|
+
type PiCliThinkingLevel = "high" | "low" | "medium" | "minimal" | "off" | "xhigh";
|
|
19
|
+
/** Per-run options for the `pi-cli` adapter. */
|
|
20
|
+
interface PiCliRunOptions {
|
|
21
|
+
/** Backend provider override (`"anthropic"`, `"openai"`, etc.). */
|
|
22
|
+
provider?: string;
|
|
23
|
+
/** Thinking budget for the run. */
|
|
24
|
+
thinking?: PiCliThinkingLevel;
|
|
25
|
+
/** Text appended to Pi's default system prompt. */
|
|
26
|
+
appendSystemPrompt?: string;
|
|
27
|
+
/** Allowlist of tool names. */
|
|
28
|
+
tools?: string[];
|
|
29
|
+
/** Disable all tool use for this run. */
|
|
30
|
+
noTools?: boolean;
|
|
31
|
+
/** Run without persisting session history. */
|
|
32
|
+
noSession?: boolean;
|
|
33
|
+
/** Directory where session files are persisted. */
|
|
34
|
+
sessionDir?: string;
|
|
35
|
+
/** Branch a new session off the current one. */
|
|
36
|
+
forkSession?: boolean;
|
|
37
|
+
/** Extra CLI flags appended verbatim. */
|
|
38
|
+
extraArgs?: string[];
|
|
39
|
+
}
|
|
40
|
+
/** Constructor options for `createAgent("pi-cli", ...)`. */
|
|
41
|
+
type PiCliAgentOptions = ExclusiveExecutionTargetOptions<Container, Sandbox> & PiCliRunOptions & {
|
|
42
|
+
/** Path or argv to the `pi` binary. */command?: string[] | string; /** Working directory the agent operates against. */
|
|
43
|
+
cwd?: string; /** Environment variables for the subprocess. Layered on top of host env when `propagateEnv` is `true` (default). */
|
|
44
|
+
env?: Record<string, string>; /** Default `true`: `process.env` is inherited and `env` overlays it. Set `false` to suppress host-env propagation. */
|
|
45
|
+
propagateEnv?: boolean; /** Existing Pi session ID to resume. */
|
|
46
|
+
sessionId?: string; /** Pi model identifier (provider-dependent). */
|
|
47
|
+
model?: string; /** Replaces Pi's default system prompt entirely; use `appendSystemPrompt` to add to it. */
|
|
48
|
+
systemPrompt?: string; /** File path to write the raw CLI log to (useful for debugging). */
|
|
49
|
+
logPath?: string; /** Custom process spawner; set by `createContainer`/`createSandbox`, rarely needed manually. */
|
|
50
|
+
spawner?: ProcessSpawner; /** Convenience: equivalent to calling `agent.onEvent(handler)` post-construction. */
|
|
51
|
+
onEvent?: AgentEventHandler;
|
|
52
|
+
};
|
|
53
|
+
/** Agent instance returned by `createAgent("pi-cli", ...)`. */
|
|
54
|
+
interface PiCliAgent extends BaseAgent<EnsureDisjoint<PiCliRunOptions>> {
|
|
55
|
+
readonly type: "pi-cli";
|
|
56
|
+
/**
|
|
57
|
+
* Branch a sibling agent from the current session.
|
|
58
|
+
*
|
|
59
|
+
* Throws `AgentValidationError` when called before this agent has
|
|
60
|
+
* acquired a session ID — run at least one prompt first.
|
|
61
|
+
*/
|
|
62
|
+
fork: () => PiCliAgent;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/adapters/pi-cli/adapter.d.ts
|
|
66
|
+
declare const createPiCliAgent: (options?: PiCliAgentOptions) => PiCliAgent;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { PiCliThinkingLevel as a, PiCliRunOptions as i, PiCliAgent as n, PiEvent as o, PiCliAgentOptions as r, createPiCliAgent as t };
|
|
@@ -1,10 +1,15 @@
|
|
|
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-Bk-YpdbX.mjs";
|
|
2
2
|
//#region src/adapters/cursor-sdk/types.d.ts
|
|
3
|
+
/** OAuth-style credentials for HTTP/SSE MCP servers configured for the agent. */
|
|
3
4
|
interface CursorSdkMcpHttpAuth {
|
|
4
5
|
CLIENT_ID: string;
|
|
5
6
|
CLIENT_SECRET?: string;
|
|
6
7
|
scopes?: string[];
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* MCP server config accepted by the Cursor SDK. Either an HTTP/SSE endpoint
|
|
11
|
+
* or a stdio command spawned by the SDK runtime.
|
|
12
|
+
*/
|
|
8
13
|
type CursorSdkMcpServerConfig = {
|
|
9
14
|
type?: "http" | "sse";
|
|
10
15
|
url: string;
|
|
@@ -17,11 +22,21 @@ type CursorSdkMcpServerConfig = {
|
|
|
17
22
|
env?: Record<string, string>;
|
|
18
23
|
cwd?: string;
|
|
19
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Which Cursor settings layers to load from the local filesystem. Forwarded
|
|
27
|
+
* as `local.settingSources` to `Agent.create`. `"all"` loads everything;
|
|
28
|
+
* `"project"`, `"user"`, `"team"`, `"plugins"`, `"mdm"` load only that layer.
|
|
29
|
+
*/
|
|
20
30
|
type CursorSdkSettingSource = "all" | "mdm" | "plugins" | "project" | "team" | "user";
|
|
31
|
+
/** One model parameter (e.g. reasoning effort) for {@link CursorSdkModelSelection}. */
|
|
21
32
|
interface CursorSdkModelParameterValue {
|
|
22
33
|
id: string;
|
|
23
34
|
value: string;
|
|
24
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Internal model selection shape used by the Cursor SDK. Most callers pass a
|
|
38
|
+
* plain model ID string and let the adapter wrap it.
|
|
39
|
+
*/
|
|
25
40
|
interface CursorSdkModelSelection {
|
|
26
41
|
id: string;
|
|
27
42
|
params?: CursorSdkModelParameterValue[];
|
|
@@ -103,20 +118,71 @@ interface CursorSdkTaskEvent {
|
|
|
103
118
|
status?: string;
|
|
104
119
|
text?: string;
|
|
105
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Discriminated union of raw events the Cursor SDK emits before this adapter
|
|
123
|
+
* normalizes them. Narrow on `event.type`:
|
|
124
|
+
*
|
|
125
|
+
* - `"system"` — init metadata (model, tools).
|
|
126
|
+
* - `"user"` — echo of the user prompt for this run.
|
|
127
|
+
* - `"assistant"` — model text/tool-use chunk (may arrive in fragments).
|
|
128
|
+
* - `"thinking"` — reasoning content with duration.
|
|
129
|
+
* - `"tool_call"` — tool invocation lifecycle (`running` → `completed`/`error`).
|
|
130
|
+
* - `"status"` — run lifecycle (`RUNNING`, `FINISHED`, etc.).
|
|
131
|
+
* - `"task"` — task-level milestones.
|
|
132
|
+
* - `"request"` — Cursor is asking for user input/approval (unsupported by this adapter).
|
|
133
|
+
*/
|
|
106
134
|
type CursorSdkEvent = CursorSdkAssistantEvent | CursorSdkRequestEvent | CursorSdkStatusEvent | CursorSdkSystemEvent | CursorSdkTaskEvent | CursorSdkThinkingEvent | CursorSdkToolCallEvent | CursorSdkUserEvent;
|
|
135
|
+
/**
|
|
136
|
+
* Per-run options for the `cursor-sdk` adapter. Merge with {@link RunRequest}
|
|
137
|
+
* when calling `agent.run(...)`.
|
|
138
|
+
*/
|
|
107
139
|
interface CursorSdkRunOptions {
|
|
140
|
+
/**
|
|
141
|
+
* Recovery-only flag. Forwards to `local.force` on `Agent.send(...)`, which
|
|
142
|
+
* expires a stale persisted "active run" left by a crashed previous
|
|
143
|
+
* process. Set this only when a normal send errors with "agent busy" /
|
|
144
|
+
* "active run exists." Not a routine option.
|
|
145
|
+
*/
|
|
108
146
|
localForce?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Per-run MCP server overrides. Replaces the agent-level set if provided.
|
|
149
|
+
*/
|
|
109
150
|
mcpServers?: Record<string, CursorSdkMcpServerConfig>;
|
|
151
|
+
/** Not supported by the Cursor SDK — cursor manages its own system prompt. */
|
|
110
152
|
systemPrompt?: never;
|
|
111
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Constructor options for `createAgent("cursor-sdk", ...)`. Passed to
|
|
156
|
+
* `Agent.create` (or `Agent.resume` if `sessionId` is set) under the hood.
|
|
157
|
+
*/
|
|
112
158
|
interface CursorSdkAgentOptions extends CursorSdkRunOptions {
|
|
159
|
+
/**
|
|
160
|
+
* Cursor API key. Falls back to `process.env.CURSOR_API_KEY` for some
|
|
161
|
+
* surfaces but the local `send` path requires it to be set explicitly.
|
|
162
|
+
*/
|
|
113
163
|
apiKey?: string;
|
|
164
|
+
/** Working directory passed as `local.cwd`. Defaults to `process.cwd()`. */
|
|
114
165
|
cwd?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Existing Cursor agent ID to resume. When set, the adapter calls
|
|
168
|
+
* `Agent.resume(sessionId, ...)` on the first run instead of
|
|
169
|
+
* `Agent.create(...)`. Required if you don't pass a `model`.
|
|
170
|
+
*/
|
|
115
171
|
sessionId?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Cursor model identifier (e.g. `"composer-2.5"`, `"claude-sonnet-4-6"`).
|
|
174
|
+
* Use `Cursor.models.list()` to enumerate; required for new local agents.
|
|
175
|
+
*/
|
|
116
176
|
model?: string;
|
|
177
|
+
/**
|
|
178
|
+
* Cursor settings layers to load from the local filesystem (`"project"`,
|
|
179
|
+
* `"user"`, etc.). Defaults to nothing if omitted.
|
|
180
|
+
*/
|
|
117
181
|
settingSources?: CursorSdkSettingSource[];
|
|
182
|
+
/** Convenience: equivalent to calling `agent.onEvent(handler)` post-construction. */
|
|
118
183
|
onEvent?: AgentEventHandler;
|
|
119
184
|
}
|
|
185
|
+
/** Agent instance returned by `createAgent("cursor-sdk", ...)`. */
|
|
120
186
|
interface CursorSdkAgent extends BaseAgent<EnsureDisjoint<CursorSdkRunOptions>> {
|
|
121
187
|
readonly type: "cursor-sdk";
|
|
122
188
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { A as ProcessSpawner, f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-Bk-YpdbX.mjs";
|
|
2
|
+
import { t as Container } from "./index-BeejNCvc.mjs";
|
|
3
|
+
import { c as Sandbox } from "./index-C8wbKjj3.mjs";
|
|
4
|
+
import { z } from "zod/v4";
|
|
5
|
+
|
|
6
|
+
//#region src/adapters/opencode-cli/events/schemas.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Permissive raw-event shape for OpenCode CLI: `{ type: string }` plus
|
|
9
|
+
* arbitrary additional fields the CLI may emit.
|
|
10
|
+
*/
|
|
11
|
+
declare const opencodeEventSchema: z.ZodObject<{
|
|
12
|
+
type: z.ZodString;
|
|
13
|
+
}, z.core.$loose>;
|
|
14
|
+
type OpencodeEvent = z.infer<typeof opencodeEventSchema>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/adapters/opencode-cli/types.d.ts
|
|
17
|
+
/** Per-run options for the `opencode-cli` adapter. */
|
|
18
|
+
interface OpencodeCliRunOptions {
|
|
19
|
+
/** Named OpenCode agent profile (e.g. `"coding"`, `"reviewer"`). */
|
|
20
|
+
agent?: string;
|
|
21
|
+
/** Initial files to attach to the conversation context. */
|
|
22
|
+
files?: string[];
|
|
23
|
+
/** Branch a new session off the current one. */
|
|
24
|
+
forkSession?: boolean;
|
|
25
|
+
/** Make the session shareable via OpenCode's share-link feature. */
|
|
26
|
+
share?: boolean;
|
|
27
|
+
/** Enable extended thinking output for supported models. */
|
|
28
|
+
thinking?: boolean;
|
|
29
|
+
/** Human-readable title for the session. */
|
|
30
|
+
title?: string;
|
|
31
|
+
/** Named variant of the selected agent profile. */
|
|
32
|
+
variant?: string;
|
|
33
|
+
/** Extra CLI flags appended verbatim. */
|
|
34
|
+
extraArgs?: string[];
|
|
35
|
+
/** Not supported — OpenCode manages its own system prompt. */
|
|
36
|
+
systemPrompt?: never;
|
|
37
|
+
}
|
|
38
|
+
/** Constructor options for `createAgent("opencode-cli", ...)`. */
|
|
39
|
+
type OpencodeCliAgentOptions = ExclusiveExecutionTargetOptions<Container, Sandbox> & OpencodeCliRunOptions & {
|
|
40
|
+
/** Path or argv to the `opencode` binary. */command?: string[] | string; /** Working directory the agent operates against. */
|
|
41
|
+
cwd?: string; /** Environment variables for the subprocess. Layered on top of host env when `propagateEnv` is `true` (default). */
|
|
42
|
+
env?: Record<string, string>; /** Default `true`: `process.env` is inherited and `env` overlays it. Set `false` to suppress host-env propagation. */
|
|
43
|
+
propagateEnv?: boolean; /** Existing OpenCode session ID to resume. */
|
|
44
|
+
sessionId?: string; /** OpenCode model identifier. */
|
|
45
|
+
model?: string; /** File path to write the raw CLI log to (useful for debugging). */
|
|
46
|
+
logPath?: string; /** Custom process spawner; set by `createContainer`/`createSandbox`, rarely needed manually. */
|
|
47
|
+
spawner?: ProcessSpawner; /** Convenience: equivalent to calling `agent.onEvent(handler)` post-construction. */
|
|
48
|
+
onEvent?: AgentEventHandler;
|
|
49
|
+
};
|
|
50
|
+
/** Agent instance returned by `createAgent("opencode-cli", ...)`. */
|
|
51
|
+
interface OpencodeCliAgent extends BaseAgent<EnsureDisjoint<OpencodeCliRunOptions>> {
|
|
52
|
+
readonly type: "opencode-cli";
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/adapters/opencode-cli/adapter.d.ts
|
|
56
|
+
declare const createOpencodeCliAgent: (options?: OpencodeCliAgentOptions) => OpencodeCliAgent;
|
|
57
|
+
//#endregion
|
|
58
|
+
export { OpencodeEvent as a, OpencodeCliRunOptions as i, OpencodeCliAgent as n, OpencodeCliAgentOptions as r, createOpencodeCliAgent as t };
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { S as McpServerConfig } from "./events-
|
|
2
|
-
import { A as ProcessSpawner, f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-
|
|
3
|
-
import { t as Container } from "./index-
|
|
4
|
-
import { c as Sandbox } from "./index-
|
|
1
|
+
import { S as McpServerConfig } from "./events-Bwfw__Q3.mjs";
|
|
2
|
+
import { A as ProcessSpawner, f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-Bk-YpdbX.mjs";
|
|
3
|
+
import { t as Container } from "./index-BeejNCvc.mjs";
|
|
4
|
+
import { c as Sandbox } from "./index-C8wbKjj3.mjs";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
6
|
|
|
7
7
|
//#region src/adapters/codex-cli/events/schemas.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Permissive shape for any raw event Codex CLI emits — `{ type: string }`
|
|
10
|
+
* plus arbitrary additional fields. Narrow on `event.type` against the
|
|
11
|
+
* specific exported event types (`CodexThreadStartedEvent`,
|
|
12
|
+
* `CodexTurnCompletedEvent`, `CodexItemStartedEvent`, etc.) when you need
|
|
13
|
+
* field-level access.
|
|
14
|
+
*/
|
|
8
15
|
declare const codexEventSchema: z.ZodObject<{
|
|
9
16
|
type: z.ZodString;
|
|
10
17
|
}, z.core.$loose>;
|
|
@@ -76,30 +83,54 @@ declare const codexErrorEventSchema: z.ZodObject<{
|
|
|
76
83
|
type CodexErrorEvent = z.infer<typeof codexErrorEventSchema>;
|
|
77
84
|
//#endregion
|
|
78
85
|
//#region src/adapters/codex-cli/types.d.ts
|
|
86
|
+
/**
|
|
87
|
+
* Filesystem sandbox policy for Codex CLI.
|
|
88
|
+
* - `"read-only"`: tools cannot write.
|
|
89
|
+
* - `"workspace-write"`: writes allowed inside `cwd` only.
|
|
90
|
+
* - `"danger-full-access"`: no filesystem restrictions.
|
|
91
|
+
*/
|
|
79
92
|
type CodexCliSandboxMode = "danger-full-access" | "read-only" | "workspace-write";
|
|
93
|
+
/**
|
|
94
|
+
* How Codex CLI handles approval prompts.
|
|
95
|
+
* - `"default"`: leave Codex CLI's own default approval behavior in place (this adapter does not bridge approvals to a permission handler).
|
|
96
|
+
* - `"auto-approve"`: pass `--auto-approve` to Codex CLI; accept all approval prompts.
|
|
97
|
+
* - `"bypass-sandbox"`: pass `--dangerously-bypass-approvals-and-sandbox`; bypasses both approvals AND the sandbox.
|
|
98
|
+
*/
|
|
80
99
|
type CodexCliPermissionMode = "auto-approve" | "bypass-sandbox" | "default";
|
|
100
|
+
/** Per-run options for the `codex-cli` adapter. */
|
|
81
101
|
interface CodexCliRunOptions {
|
|
102
|
+
/** Filesystem sandbox policy. See {@link CodexCliSandboxMode}. */
|
|
82
103
|
codexSandboxMode?: CodexCliSandboxMode;
|
|
104
|
+
/** Extra directories outside `cwd` writable under `workspace-write`. */
|
|
83
105
|
additionalDirectories?: string[];
|
|
106
|
+
/** Suppress Codex's "not a git repo" confirmation prompt (`--skip-git-repo-check`). */
|
|
84
107
|
skipGitRepoCheck?: boolean;
|
|
108
|
+
/** Approval prompt strategy. */
|
|
85
109
|
permissionMode?: CodexCliPermissionMode;
|
|
110
|
+
/** When `true`, Codex does not persist this run's history. */
|
|
86
111
|
ephemeral?: boolean;
|
|
112
|
+
/** Path to an MCP config file passed via `--mcp-config`. */
|
|
87
113
|
mcpConfig?: string;
|
|
114
|
+
/** Inline MCP server config map. */
|
|
88
115
|
mcpServers?: Record<string, McpServerConfig>;
|
|
116
|
+
/** Extra CLI flags appended verbatim. */
|
|
89
117
|
extraArgs?: string[];
|
|
118
|
+
/** Not supported — Codex manages its own system prompt. */
|
|
90
119
|
systemPrompt?: never;
|
|
91
120
|
}
|
|
121
|
+
/** Constructor options for `createAgent("codex-cli", ...)`. */
|
|
92
122
|
type CodexCliAgentOptions = CodexCliRunOptions & ExclusiveExecutionTargetOptions<Container, Sandbox> & {
|
|
93
|
-
command?: string[] | string;
|
|
94
|
-
cwd?: string;
|
|
95
|
-
env?: Record<string, string>;
|
|
96
|
-
propagateEnv?: boolean;
|
|
97
|
-
sessionId?: string;
|
|
98
|
-
model?: string;
|
|
99
|
-
logPath?: string;
|
|
100
|
-
spawner?: ProcessSpawner;
|
|
123
|
+
/** Path or argv to the `codex` binary. */command?: string[] | string; /** Working directory the agent operates against. */
|
|
124
|
+
cwd?: string; /** Environment variables for the subprocess. Layered on top of host env when `propagateEnv` is `true` (default). */
|
|
125
|
+
env?: Record<string, string>; /** Default `true`: `process.env` is inherited and `env` overlays it. Set `false` to suppress host-env propagation. */
|
|
126
|
+
propagateEnv?: boolean; /** Existing Codex thread ID to resume via `codex resume`. */
|
|
127
|
+
sessionId?: string; /** Codex model identifier. */
|
|
128
|
+
model?: string; /** File path to write the raw CLI log to (useful for debugging). */
|
|
129
|
+
logPath?: string; /** Custom process spawner; set by `createContainer`/`createSandbox`, rarely needed manually. */
|
|
130
|
+
spawner?: ProcessSpawner; /** Convenience: equivalent to calling `agent.onEvent(handler)` post-construction. */
|
|
101
131
|
onEvent?: AgentEventHandler;
|
|
102
132
|
};
|
|
133
|
+
/** Agent instance returned by `createAgent("codex-cli", ...)`. */
|
|
103
134
|
interface CodexCliAgent extends BaseAgent<EnsureDisjoint<CodexCliRunOptions>> {
|
|
104
135
|
readonly type: "codex-cli";
|
|
105
136
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { S as McpServerConfig } from "./events-Bwfw__Q3.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-Bk-YpdbX.mjs";
|
|
3
|
+
//#region src/adapters/claude-code-sdk/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* How Claude Code handles tool-permission prompts.
|
|
6
|
+
* - `"default"`: stop and ask via the permission handler.
|
|
7
|
+
* - `"acceptEdits"`: auto-accept file edits, still ask for shell commands.
|
|
8
|
+
* - `"auto"`: a model classifier decides per-call whether to approve.
|
|
9
|
+
* - `"dontAsk"`: don't prompt; deny anything not pre-approved.
|
|
10
|
+
* - `"bypassPermissions"`: disable the permission system entirely (dangerous).
|
|
11
|
+
* - `"plan"`: read-only planning mode; no edits, no shell.
|
|
12
|
+
*/
|
|
13
|
+
type ClaudeCodeSdkPermissionMode = "acceptEdits" | "auto" | "bypassPermissions" | "default" | "dontAsk" | "plan";
|
|
14
|
+
/** Which runtime to use when spawning the Claude Code SDK subprocess. */
|
|
15
|
+
type ClaudeCodeSdkExecutable = "bun" | "deno" | "node";
|
|
16
|
+
/** Which Claude Code settings layers to load from the local filesystem. */
|
|
17
|
+
type ClaudeCodeSdkSettingSource = "local" | "project" | "user";
|
|
18
|
+
/** Inline settings object, or a path to a JSON settings file. */
|
|
19
|
+
type ClaudeCodeSdkSettings = Record<string, unknown> | string;
|
|
20
|
+
/** Per-run options for the `claude-code-sdk` adapter. */
|
|
21
|
+
interface ClaudeCodeSdkRunOptions {
|
|
22
|
+
/** Allowlist of tool names. When set, all other tools are denied. */
|
|
23
|
+
allowedTools?: string[];
|
|
24
|
+
/** Denylist of tool names. Applied after `allowedTools`. */
|
|
25
|
+
disallowedTools?: string[];
|
|
26
|
+
/** Text appended to Claude Code's default system prompt. */
|
|
27
|
+
appendSystemPrompt?: string;
|
|
28
|
+
/** Tool-permission strategy for this run. See {@link ClaudeCodeSdkPermissionMode}. */
|
|
29
|
+
permissionMode?: ClaudeCodeSdkPermissionMode;
|
|
30
|
+
/** Per-run MCP server overrides. Replaces the agent-level set if provided. */
|
|
31
|
+
mcpServers?: Record<string, McpServerConfig>;
|
|
32
|
+
/** Start a new branch off the current session rather than continuing it. */
|
|
33
|
+
forkSession?: boolean;
|
|
34
|
+
/** Hard cap on assistant turns for this run. */
|
|
35
|
+
maxTurns?: number;
|
|
36
|
+
}
|
|
37
|
+
/** Constructor options for `createAgent("claude-code-sdk", ...)`. */
|
|
38
|
+
interface ClaudeCodeSdkAgentOptions extends ClaudeCodeSdkRunOptions {
|
|
39
|
+
/** Override the path to the Claude Code CLI binary. */
|
|
40
|
+
command?: string;
|
|
41
|
+
/** Environment variables for the SDK subprocess; `undefined` values delete the key. */
|
|
42
|
+
env?: Record<string, string | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* Default `true`: `process.env` is inherited and `env` overlays it. Set
|
|
45
|
+
* `false` to suppress host-env propagation and use only `env`.
|
|
46
|
+
*/
|
|
47
|
+
propagateEnv?: boolean;
|
|
48
|
+
/** Which JS runtime executes the SDK. Defaults to `node`. */
|
|
49
|
+
executable?: ClaudeCodeSdkExecutable;
|
|
50
|
+
/** Extra arguments passed to the runtime (e.g. Bun/Deno flags). */
|
|
51
|
+
executableArgs?: string[];
|
|
52
|
+
/** Inline settings object or path to a settings file. */
|
|
53
|
+
settings?: ClaudeCodeSdkSettings;
|
|
54
|
+
/** Which settings layers to load (`"local"`, `"project"`, `"user"`). */
|
|
55
|
+
settingSources?: ClaudeCodeSdkSettingSource[];
|
|
56
|
+
/** Not supported — claude-code-sdk runs in-process; use `claude-code-cli` for container wrapping. */
|
|
57
|
+
container?: never;
|
|
58
|
+
/** Not supported — claude-code-sdk runs in-process; use `claude-code-cli` for sandbox wrapping. */
|
|
59
|
+
sandbox?: never;
|
|
60
|
+
/** Working directory the agent operates against. */
|
|
61
|
+
cwd?: string;
|
|
62
|
+
/** Existing Claude Code session ID to resume. */
|
|
63
|
+
sessionId?: string;
|
|
64
|
+
/** Model identifier (e.g. `"claude-sonnet-4-6"`). */
|
|
65
|
+
model?: string;
|
|
66
|
+
/** Replaces Claude Code's system prompt entirely. Use `appendSystemPrompt` to add to it instead. */
|
|
67
|
+
systemPrompt?: string;
|
|
68
|
+
/** Convenience: equivalent to calling `agent.onEvent(handler)` post-construction. */
|
|
69
|
+
onEvent?: AgentEventHandler;
|
|
70
|
+
}
|
|
71
|
+
/** Agent instance returned by `createAgent("claude-code-sdk", ...)`. */
|
|
72
|
+
interface ClaudeCodeSdkAgent extends BaseAgent<EnsureDisjoint<ClaudeCodeSdkRunOptions>> {
|
|
73
|
+
readonly type: "claude-code-sdk";
|
|
74
|
+
/**
|
|
75
|
+
* Create a sibling agent that shares the same session lineage. Both agents
|
|
76
|
+
* can be run independently; useful for parallel exploration branches.
|
|
77
|
+
*
|
|
78
|
+
* Throws {@link AgentValidationError} when called before this agent has
|
|
79
|
+
* acquired a session ID — run at least one prompt first.
|
|
80
|
+
*/
|
|
81
|
+
fork: () => ClaudeCodeSdkAgent;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Permissive raw-event shape for the Claude Code SDK. Provides at minimum
|
|
85
|
+
* `type` (discriminator) and `session_id`; all other fields vary by event
|
|
86
|
+
* type.
|
|
87
|
+
*/
|
|
88
|
+
interface ClaudeCodeSdkEvent {
|
|
89
|
+
type: string;
|
|
90
|
+
session_id?: string;
|
|
91
|
+
[key: string]: unknown;
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/adapters/claude-code-sdk/adapter.d.ts
|
|
95
|
+
declare const createClaudeCodeSdkAgent: (options?: ClaudeCodeSdkAgentOptions) => ClaudeCodeSdkAgent;
|
|
96
|
+
//#endregion
|
|
97
|
+
export { ClaudeCodeSdkExecutable as a, ClaudeCodeSdkSettingSource as c, ClaudeCodeSdkEvent as i, ClaudeCodeSdkSettings as l, ClaudeCodeSdkAgent as n, ClaudeCodeSdkPermissionMode as o, ClaudeCodeSdkAgentOptions as r, ClaudeCodeSdkRunOptions as s, createClaudeCodeSdkAgent as t };
|