@agentchatme/agent-core 0.4.1 → 0.5.1
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 +83 -3
- package/dist/chunk-3ERPUP4M.js +97 -0
- package/dist/chunk-3ERPUP4M.js.map +1 -0
- package/dist/{chunk-AE4XHKHQ.js → chunk-AFDD53DD.js} +234 -10
- package/dist/chunk-AFDD53DD.js.map +1 -0
- package/dist/{chunk-7LAAAXUO.js → chunk-CDJASQ3X.js} +509 -104
- package/dist/chunk-CDJASQ3X.js.map +1 -0
- package/dist/daemon-entry.d.ts +58 -3
- package/dist/daemon-entry.js +287 -33
- package/dist/daemon-entry.js.map +1 -1
- package/dist/index.d.ts +94 -13
- package/dist/index.js +402 -354
- package/dist/index.js.map +1 -1
- package/dist/presets.d.ts +352 -21
- package/dist/presets.js +700 -105
- package/dist/presets.js.map +1 -1
- package/dist/{runner-B-ZZDAAm.d.ts → runner-DYVqz_9P.d.ts} +38 -2
- package/dist/{served-manual-99vEOjJS.d.ts → served-manual-Be_eUo0m.d.ts} +157 -26
- package/package.json +2 -2
- package/dist/chunk-7LAAAXUO.js.map +0 -1
- package/dist/chunk-AE4XHKHQ.js.map +0 -1
- package/dist/chunk-QDM4EFI7.js +0 -139
- package/dist/chunk-QDM4EFI7.js.map +0 -1
- package/dist/chunk-XDWBTX5J.js +0 -30
- package/dist/chunk-XDWBTX5J.js.map +0 -1
package/dist/presets.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextsRuntime } from 'agentchatme';
|
|
2
|
-
import { a as RunProfile, b as RunRunner, f as RunPreflight, g as RunRequest, c as RunOutcome } from './runner-
|
|
2
|
+
import { a as RunProfile, b as RunRunner, q as RunPreflightOptions, f as RunPreflight, g as RunRequest, c as RunOutcome } from './runner-DYVqz_9P.js';
|
|
3
3
|
|
|
4
4
|
/** What a preset needs to build a runner acting as one agent. */
|
|
5
5
|
interface PresetContext {
|
|
@@ -35,8 +35,12 @@ interface Preset {
|
|
|
35
35
|
readonly label: string;
|
|
36
36
|
/** How the served texts spell the hosted tools for this runtime (`GET /v1/texts?runtime=`). */
|
|
37
37
|
readonly runtime: TextsRuntime;
|
|
38
|
-
/**
|
|
39
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Is the runtime installed, new enough and signed in? For `doctor` and
|
|
40
|
+
* `status`. Async: its probes are killed with their whole tree when they
|
|
41
|
+
* hang (a Windows `.cmd` shim, an npm launcher), never left blocking.
|
|
42
|
+
*/
|
|
43
|
+
inspect(env?: NodeJS.ProcessEnv, command?: string): Promise<PresetInspection>;
|
|
40
44
|
/**
|
|
41
45
|
* A runner whose runs act as the agent in `ctx`: the hosted tool server is
|
|
42
46
|
* given to each run with that agent's key (a file or an environment
|
|
@@ -59,6 +63,51 @@ interface Preset {
|
|
|
59
63
|
/** Whether the run can read files under the identity home (decides how the manual is pointed to). */
|
|
60
64
|
readonly readsIdentityHome: boolean;
|
|
61
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Documented `CLAUDE_CODE_*` variables that configure how Claude Code signs in
|
|
68
|
+
* and reaches its provider, or switch off traffic and secrets — the user's own
|
|
69
|
+
* settings, kept (code.claude.com/docs/en/env-vars). Every other `CLAUDE_CODE_*`
|
|
70
|
+
* variable is dropped: the ones Claude Code sets for the processes it spawns
|
|
71
|
+
* share the prefix (CLAUDE_CODE_SESSION_ID, _CHILD_SESSION, _MESSAGING_SOCKET,
|
|
72
|
+
* _MESSAGING_TOKEN, _BRIDGE_SESSION_ID, _REMOTE_SESSION_ID, …), and a variable
|
|
73
|
+
* not listed here is one a headless run can do without.
|
|
74
|
+
*/
|
|
75
|
+
declare const CLAUDE_CODE_ENV_KEPT: readonly string[];
|
|
76
|
+
/**
|
|
77
|
+
* Claude Code session variables outside the `CLAUDE_CODE_` prefix
|
|
78
|
+
* (code.claude.com/docs/en/env-vars, hooks.md): what it sets in the processes
|
|
79
|
+
* it spawns — its pid, the effort level, a background job's folder, the
|
|
80
|
+
* project folder, the W3C trace context — and `AI_AGENT`. Not `CLAUDE_ENV_FILE`:
|
|
81
|
+
* that one the user sets (a file sourced before each shell command).
|
|
82
|
+
*/
|
|
83
|
+
declare const CLAUDE_SESSION_ENV: readonly string[];
|
|
84
|
+
/**
|
|
85
|
+
* What a Codex session sets in the processes it spawns (openai/codex at
|
|
86
|
+
* rust-v0.154.0: core/src/spawn.rs, core/src/exec_env.rs,
|
|
87
|
+
* protocol/src/shell_environment.rs, network-proxy/src/proxy.rs,
|
|
88
|
+
* shell-escalation/src/unix/escalate_protocol.rs). Not the whole `CODEX_`
|
|
89
|
+
* prefix: CODEX_HOME, CODEX_API_KEY, CODEX_CA_CERTIFICATE are the user's.
|
|
90
|
+
*/
|
|
91
|
+
declare const CODEX_SESSION_ENV: readonly string[];
|
|
92
|
+
/**
|
|
93
|
+
* What a Codex session's managed network proxy puts in its children's
|
|
94
|
+
* environment (openai/codex rust-v0.154.0 network-proxy/src/proxy.rs:578-628
|
|
95
|
+
* `PROXY_ENV_KEYS`): proxy URLs pointing at the parent's proxy, which dies
|
|
96
|
+
* with it. Dropped only when the environment says that proxy was active
|
|
97
|
+
* (`CODEX_NETWORK_PROXY_ACTIVE`): otherwise they are the user's own proxy.
|
|
98
|
+
*/
|
|
99
|
+
declare const CODEX_MANAGED_PROXY_ENV: readonly string[];
|
|
100
|
+
/** Whether `key` is a parent session's variable by its name alone. Case-insensitive, as Windows names are. */
|
|
101
|
+
declare function isParentSessionEnv(key: string): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* A copy of `env` without any Claude Code or Codex parent-session variable:
|
|
104
|
+
* what every preset run, in every profile, starts from. By name: the session
|
|
105
|
+
* markers above. By value: a parent Codex proxy's URLs and its generated CA
|
|
106
|
+
* bundle (only while its marker says it was active), its SSH command, the
|
|
107
|
+
* dummy credentials its broker substituted. The user's own proxy, CA bundle
|
|
108
|
+
* and settings stay.
|
|
109
|
+
*/
|
|
110
|
+
declare function withoutParentSession(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
62
111
|
|
|
63
112
|
/** `actual` (any text containing `x.y.z`) is at least `minimum`. False when either has no version in it. */
|
|
64
113
|
declare function semverAtLeast(actual: string, minimum: string): boolean;
|
|
@@ -76,40 +125,115 @@ declare const MIN_CLAUDE_CODE_VERSION = "2.1.274";
|
|
|
76
125
|
/** The MCP server name the runs see; every hosted tool is `mcp__agentchat__<tool>`, as the served texts spell them. */
|
|
77
126
|
declare const CLAUDE_MCP_SERVER_NAME = "agentchat";
|
|
78
127
|
declare const AGENTCHAT_TOOL_ALLOW = "mcp__agentchat__*";
|
|
79
|
-
/**
|
|
80
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Built-in tools an `answer` run has: the file-reading tools, and only on the
|
|
130
|
+
* run's own working folder (`workdirReadRules`, `ANSWER_SETTINGS`). An `answer`
|
|
131
|
+
* run is started by any peer's message — a stranger's cold DM included — so
|
|
132
|
+
* the only way out it has is the AgentChat tools: no web, no shell, no edits,
|
|
133
|
+
* and nothing outside its workdir to read.
|
|
134
|
+
*/
|
|
135
|
+
declare const ANSWER_TOOLS: readonly ["Read", "Glob", "Grep"];
|
|
136
|
+
/** The web tools: `work` pre-approves them; `answer` never has them. */
|
|
137
|
+
declare const WEB_TOOLS: readonly ["WebSearch", "WebFetch"];
|
|
81
138
|
/** Built-in tools a `work` run additionally pre-approves. */
|
|
82
139
|
declare const WORK_TOOLS: readonly ["Bash", "Edit", "Write", "MultiEdit", "NotebookEdit"];
|
|
83
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* Denied to every `answer` run by name, on top of `--tools` leaving them out:
|
|
142
|
+
* the ways out (web) and the shell. A bare tool name in a deny rule removes
|
|
143
|
+
* the tool, so even a widened `--tools` list could not bring them back.
|
|
144
|
+
*/
|
|
145
|
+
declare const ANSWER_DENIED_TOOLS: readonly ["WebFetch", "WebSearch", "Bash"];
|
|
146
|
+
/**
|
|
147
|
+
* The `--settings` an `answer` run is given. A constant, never built from a
|
|
148
|
+
* path: in print mode a settings value that fails validation is silently
|
|
149
|
+
* ignored (`claude --help`, `-p`), so nothing variable may ride in it. Every
|
|
150
|
+
* key exists at the 2.1.274 floor.
|
|
151
|
+
*
|
|
152
|
+
* permissions.blockReadsOutsideWorkingDirectories (2.1.257+) no file tool
|
|
153
|
+
* reads outside the working directories, whatever allow rule another
|
|
154
|
+
* settings file holds.
|
|
155
|
+
* env the two `ANSWER_ENV` switches again. A settings file's `env` overrides
|
|
156
|
+
* the process environment, and a workdir repository's own
|
|
157
|
+
* `.claude/settings.json` is applied in print mode: there it could turn
|
|
158
|
+
* CLAUDE.md and auto memory back on. `--settings` outranks user, project
|
|
159
|
+
* and local settings (settings.md, "Settings precedence").
|
|
160
|
+
* disableAllHooks (1.0.68+) no hook, status line or file-suggestion command:
|
|
161
|
+
* the user's own hooks and a workdir repository's would run a shell
|
|
162
|
+
* command, and inject text, on every peer's message. Managed hooks still
|
|
163
|
+
* run (only managed settings can turn those off).
|
|
164
|
+
*/
|
|
165
|
+
declare const ANSWER_SETTINGS: string;
|
|
166
|
+
/**
|
|
167
|
+
* Env a parent Claude Code session leaks that would make the child think it is
|
|
168
|
+
* nested — a sample kept for callers that named it; the rule is
|
|
169
|
+
* `withoutParentSession` (every `CLAUDE_CODE_*` but the user's documented
|
|
170
|
+
* settings, `CLAUDE_PID`, and the Codex session variables).
|
|
171
|
+
*/
|
|
84
172
|
declare const PARENT_ENV_KEYS: string[];
|
|
85
173
|
/** Claude Code's supported relocation knob. Unset is NOT the same as `~/.claude`. */
|
|
86
174
|
declare function claudeConfigDirFrom(env?: NodeJS.ProcessEnv): string | undefined;
|
|
87
175
|
/** `~/.claude`, or the relocated config dir. */
|
|
88
176
|
declare function claudeHomeFor(configDirOverride: string | undefined): string;
|
|
177
|
+
/** Where Claude Code keeps every project's transcripts and auto memory: `<config dir>/projects`. */
|
|
178
|
+
declare function claudeProjectsDirFor(configDirOverride: string | undefined): string;
|
|
89
179
|
/**
|
|
90
180
|
* Where Claude Code keeps user-scoped MCP servers (and so any key registered
|
|
91
181
|
* there): `~/.claude.json`, or `$CLAUDE_CONFIG_DIR/.claude.json`.
|
|
92
182
|
*/
|
|
93
183
|
declare function claudeUserStatePathFor(configDirOverride: string | undefined): string;
|
|
94
184
|
declare function buildClaudeEnv(configDirOverride: string | undefined, source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
185
|
+
/** How long a probe (`--version`, the sign-in check) may take; a hung one is killed with its whole tree. */
|
|
186
|
+
declare const PROBE_TIMEOUT_MS = 10000;
|
|
95
187
|
/**
|
|
96
188
|
* Is Claude Code signed in? `claude auth status` prints JSON with a boolean
|
|
97
189
|
* `loggedIn` and exits 0 if logged in, 1 if not. When that JSON is there it is
|
|
98
190
|
* the answer. The file/keychain probes are a fallback for builds without the
|
|
99
191
|
* subcommand; the keychain probe is existence-only and never prompts — a
|
|
100
|
-
* resident listener must never trigger a keychain prompt.
|
|
192
|
+
* resident listener must never trigger a keychain prompt. Async: a hung probe
|
|
193
|
+
* is killed with everything it started (`runProbe`), never left holding the
|
|
194
|
+
* daemon.
|
|
101
195
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
196
|
+
/** What Claude Code's sign-in check found: signed in or not, or no answer (it hung, or was stopped): then `detail` says so. */
|
|
197
|
+
interface ClaudeSignIn {
|
|
198
|
+
readonly signedIn: boolean;
|
|
199
|
+
/** Why it could not tell: `claude auth status did not answer within 10 s (killed)`. Null when it answered. */
|
|
200
|
+
readonly unanswered: string | null;
|
|
201
|
+
}
|
|
202
|
+
declare function claudeSignIn(configDirOverride?: string, command?: string, timeoutMs?: number, signal?: AbortSignal): Promise<ClaudeSignIn>;
|
|
203
|
+
/** `claudeSignIn`, as a yes/no (no answer is not signed in). */
|
|
204
|
+
declare function claudeIsLoggedIn(configDirOverride?: string, command?: string, timeoutMs?: number): Promise<boolean>;
|
|
205
|
+
declare function inspectClaudeRuntime(configDirOverride?: string, command?: string, timeoutMs?: number, signal?: AbortSignal): Promise<PresetInspection>;
|
|
104
206
|
/**
|
|
105
207
|
* The entry of `denied` that is `dir` or contains it, or null. Whole path
|
|
106
208
|
* segments only: `~/.claude/agentchat` does not contain `~/.claude/agentchat-workdir`.
|
|
107
209
|
*/
|
|
108
210
|
declare function deniedAncestorOf(dir: string, denied: readonly string[]): string | null;
|
|
109
|
-
|
|
211
|
+
/**
|
|
212
|
+
* The paths a workdir is reached by: as given (absolute), and where it really
|
|
213
|
+
* is when that differs (`/tmp/w` is `/private/tmp/w` on macOS; a symlinked
|
|
214
|
+
* workdir). An allow rule matches only when the requested path and the file
|
|
215
|
+
* it resolves to both match, so both spellings are carried. A workdir that
|
|
216
|
+
* does not exist yet is carried as given.
|
|
217
|
+
*/
|
|
218
|
+
declare function workdirPaths(workdir: string): string[];
|
|
219
|
+
/**
|
|
220
|
+
* `/w` → `Read(//w)` and `Read(//w/**)`, for each spelling of the workdir: the
|
|
221
|
+
* only paths an `answer` run's Read, Glob and Grep are pre-approved on. A
|
|
222
|
+
* spelling no allow rule can carry (whitespace, a comma, a gitignore pattern
|
|
223
|
+
* character; every path on Windows) gets no rule — that fails closed: the run
|
|
224
|
+
* still reads its workdir as its working directory, and nothing else.
|
|
225
|
+
*/
|
|
226
|
+
declare function workdirReadRules(workdir: string | undefined): string[];
|
|
227
|
+
/**
|
|
228
|
+
* The flags for one run profile. `workdir` is the run's working directory:
|
|
229
|
+
* `answer` scopes its file tools to it (absent, they get no allow rule at all).
|
|
230
|
+
*/
|
|
231
|
+
declare function claudeProfileArgs(profile: RunProfile, workdir?: string): string[];
|
|
110
232
|
interface ClaudeRunArgOptions {
|
|
111
233
|
/** `AGENTCHAT_RUN_MAX_BUDGET_USD`: stop the run once estimated spend reaches this (print mode only). */
|
|
112
234
|
readonly maxBudgetUsd?: string | undefined;
|
|
235
|
+
/** The run's working directory: the one folder an `answer` run's file tools are allowed (`workdirReadRules`). */
|
|
236
|
+
readonly workdir?: string | undefined;
|
|
113
237
|
/**
|
|
114
238
|
* Absolute paths the run's file tools may not read (a directory covers its
|
|
115
239
|
* tree). Rendered as `Read(//<path>)` / `Read(//<dir>/**)` deny rules. A
|
|
@@ -124,6 +248,13 @@ interface ClaudeRunArgOptions {
|
|
|
124
248
|
* the run uses the user-scope server the integration registered.
|
|
125
249
|
*/
|
|
126
250
|
readonly mcpConfigPath?: string | undefined;
|
|
251
|
+
/**
|
|
252
|
+
* A file whose text is appended to the system prompt (`--append-system-prompt-file`,
|
|
253
|
+
* documented since 2.1.69): how an `answer` run, which loads no CLAUDE.md,
|
|
254
|
+
* is told its identity line. A file, not argv text: an argument cannot carry
|
|
255
|
+
* a line break through a Windows `.cmd` shim.
|
|
256
|
+
*/
|
|
257
|
+
readonly appendSystemPromptFile?: string | undefined;
|
|
127
258
|
}
|
|
128
259
|
/**
|
|
129
260
|
* The deny paths no rule can carry: on Windows all of them (the rule syntax
|
|
@@ -150,19 +281,74 @@ declare function claudeRunArgs(profile: RunProfile, options?: ClaudeRunArgOption
|
|
|
150
281
|
* tools, a second way of being woken that the listener makes unnecessary.
|
|
151
282
|
*/
|
|
152
283
|
declare function claudeMcpConfig(apiBase: string, apiKey: string, clientVersion?: string): string;
|
|
284
|
+
/**
|
|
285
|
+
* What an `answer` run's environment adds: no CLAUDE.md of any scope (user,
|
|
286
|
+
* project, ancestors, `.claude/rules`, `@` imports) and no auto memory
|
|
287
|
+
* (code.claude.com/docs/en/env-vars; both read by 2.1.274, the floor). The
|
|
288
|
+
* user's own files are not a peer-started run's context: what it could read
|
|
289
|
+
* there it could send. Its identity line comes in by
|
|
290
|
+
* `--append-system-prompt-file` instead.
|
|
291
|
+
*/
|
|
292
|
+
declare const ANSWER_ENV: Readonly<Record<string, string>>;
|
|
293
|
+
/** The system folder Claude Code reads managed settings from (code.claude.com/docs/en/managed-settings). */
|
|
294
|
+
declare function claudeManagedSettingsDir(platform?: NodeJS.Platform): string;
|
|
295
|
+
/**
|
|
296
|
+
* The settings files that can give an `answer` run more working directories
|
|
297
|
+
* than its own: `permissions.additionalDirectories` there counts as a working
|
|
298
|
+
* directory even under `blockReadsOutsideWorkingDirectories`
|
|
299
|
+
* (settings-reference.md) — the user's settings, the managed file and its
|
|
300
|
+
* `managed-settings.d/` drop-ins, and `.claude/settings.local.json` at the
|
|
301
|
+
* workdir's repository root and in the workdir itself (counted when git does
|
|
302
|
+
* not track it; checked whenever it is there). MDM and server-managed policies
|
|
303
|
+
* are not files and are not covered.
|
|
304
|
+
*/
|
|
305
|
+
declare function claudeSettingsFilesGrantingDirectories(configDirOverride: string | undefined, workdir: string): string[];
|
|
306
|
+
/**
|
|
307
|
+
* The first of those files that lists `permissions.additionalDirectories`, with
|
|
308
|
+
* why, or null. A file that is not JSON is ignored by Claude Code (and so here),
|
|
309
|
+
* unless it names the key — then it counts, as it may be read another way.
|
|
310
|
+
*/
|
|
311
|
+
declare function claudeExtraDirectoriesGrant(configDirOverride: string | undefined, workdir: string): {
|
|
312
|
+
file: string;
|
|
313
|
+
detail: string;
|
|
314
|
+
} | null;
|
|
315
|
+
/**
|
|
316
|
+
* The AgentChat hosted server alone, for `answer` runs that have no
|
|
317
|
+
* `mcpConfigPath`: written owner-only for each run beside `file`, under a name
|
|
318
|
+
* of that run's own (`<file stem>.<run id>.json`, so a late cleanup of an
|
|
319
|
+
* abandoned run cannot remove the next run's), from the key `apiKey()` returns
|
|
320
|
+
* then (a credential change is followed), passed with `--strict-mcp-config`,
|
|
321
|
+
* and removed when the run ends. An `answer` run then
|
|
322
|
+
* loads no other MCP server — the user's own, a project's, a plugin's, a
|
|
323
|
+
* claude.ai connector — whatever the user scope registers. `file` must sit
|
|
324
|
+
* inside a `denyReadPaths` entry (it holds the key), or preflight refuses.
|
|
325
|
+
*/
|
|
326
|
+
interface ClaudeAnswerMcp {
|
|
327
|
+
readonly file: string;
|
|
328
|
+
readonly apiBase: string;
|
|
329
|
+
readonly apiKey: () => string | null;
|
|
330
|
+
/** The version named in `X-AgentChat-Client-Version` (the front door that placed the run). Defaults to this engine's. */
|
|
331
|
+
readonly clientVersion?: string;
|
|
332
|
+
}
|
|
153
333
|
interface ClaudeRunnerOptions {
|
|
154
334
|
readonly configDir: string | undefined;
|
|
155
335
|
/**
|
|
156
336
|
* The run's working directory; the `work` profile edits and runs shell here.
|
|
157
337
|
* Must lie outside `denyReadPaths`, or the run cannot read its own cwd —
|
|
158
|
-
* preflight says so once and still runs.
|
|
338
|
+
* preflight says so once and still runs. An `answer` run whose workdir is the
|
|
339
|
+
* home folder or contains it works in `answerFallbackWorkdir` instead.
|
|
159
340
|
*/
|
|
160
341
|
readonly workdir: string;
|
|
161
342
|
readonly profile: RunProfile;
|
|
162
343
|
/** Paths every run's file tools are denied: the key store (identity home, the user-scope MCP state). */
|
|
163
344
|
readonly denyReadPaths: readonly string[];
|
|
164
|
-
/** See `ClaudeRunArgOptions.mcpConfigPath
|
|
345
|
+
/** See `ClaudeRunArgOptions.mcpConfigPath`: every profile, strict. */
|
|
165
346
|
readonly mcpConfigPath?: string;
|
|
347
|
+
/**
|
|
348
|
+
* See `ClaudeAnswerMcp`. Without it (and without `mcpConfigPath`) an `answer`
|
|
349
|
+
* run does not start: it would load every MCP server the user registered.
|
|
350
|
+
*/
|
|
351
|
+
readonly answerMcp?: ClaudeAnswerMcp;
|
|
166
352
|
/** The one-line fix printed when the workdir sits inside a denied path. */
|
|
167
353
|
readonly workdirAdvice?: string;
|
|
168
354
|
/**
|
|
@@ -175,6 +361,13 @@ interface ClaudeRunnerOptions {
|
|
|
175
361
|
readonly command?: string;
|
|
176
362
|
readonly env?: NodeJS.ProcessEnv;
|
|
177
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* The folder an `answer` run works in when its configured workdir is the
|
|
366
|
+
* user's home folder or contains it (`workdirExposesHome`): an empty folder of
|
|
367
|
+
* its own beside Claude Code's config, never inside a denied path. The run
|
|
368
|
+
* keeps working — it only cannot read the user's files.
|
|
369
|
+
*/
|
|
370
|
+
declare function claudeAnswerFallbackWorkdir(configDirOverride: string | undefined): string;
|
|
178
371
|
declare class ClaudeRunner implements RunRunner {
|
|
179
372
|
private readonly options;
|
|
180
373
|
readonly name = "claude";
|
|
@@ -182,12 +375,39 @@ declare class ClaudeRunner implements RunRunner {
|
|
|
182
375
|
/** The workdir warning is one line per process, not one per preflight (preflight repeats every few minutes). */
|
|
183
376
|
private warnedWorkdir;
|
|
184
377
|
private warnedDeny;
|
|
378
|
+
private warnedHome;
|
|
185
379
|
constructor(options: ClaudeRunnerOptions);
|
|
186
|
-
/**
|
|
380
|
+
/**
|
|
381
|
+
* Where this runner's runs work: the configured workdir, except that an
|
|
382
|
+
* `answer` run never works in the home folder or above it — it gets
|
|
383
|
+
* `claudeAnswerFallbackWorkdir` (its readable folder would be the whole home).
|
|
384
|
+
*/
|
|
385
|
+
workdir(): string;
|
|
386
|
+
/** The denied path the workdir sits in, or null when the run can read its own cwd. */
|
|
187
387
|
workdirDeniedBy(): string | null;
|
|
188
|
-
preflight(): Promise<RunPreflight>;
|
|
189
|
-
/**
|
|
190
|
-
|
|
388
|
+
preflight(options?: RunPreflightOptions): Promise<RunPreflight>;
|
|
389
|
+
/** `<dir>/<stem>.<run id><ext>`: a file of this run's own beside `file` (the run id reduced to letters, digits and `-`). */
|
|
390
|
+
private static perRun;
|
|
391
|
+
/** The answer run's own files for `runId`: its AgentChat-only tool config (integration path) and its identity-line file. */
|
|
392
|
+
private answerRunFiles;
|
|
393
|
+
/**
|
|
394
|
+
* What this runner's runs are denied reading: the key store, and for an
|
|
395
|
+
* `answer` run also Claude Code's own record of every project
|
|
396
|
+
* (`<config dir>/projects`: transcripts and auto memory). Claude Code lets a
|
|
397
|
+
* run read its project's memory folder even with auto memory off and reads
|
|
398
|
+
* blocked outside the working directories (seen on 2.1.322); a deny rule
|
|
399
|
+
* wins over that.
|
|
400
|
+
*/
|
|
401
|
+
readDenyPaths(): string[];
|
|
402
|
+
private argsFor;
|
|
403
|
+
/**
|
|
404
|
+
* The argv of a run — exported for tests to pin per profile. With a `runId`,
|
|
405
|
+
* that run's own files (an answer run's tool config and identity-line file);
|
|
406
|
+
* without, the configured `answerMcp.file` stands in and no identity file.
|
|
407
|
+
*/
|
|
408
|
+
args(runId?: string, identityLine?: boolean): string[];
|
|
409
|
+
/** The run's environment: no parent session; an answer run loads no CLAUDE.md and no auto memory (`ANSWER_ENV`). */
|
|
410
|
+
runEnv(): NodeJS.ProcessEnv;
|
|
191
411
|
start(request: RunRequest): Promise<RunOutcome>;
|
|
192
412
|
}
|
|
193
413
|
/** Where a listener keeps the `--mcp-config` file for this preset, inside its identity home. */
|
|
@@ -213,9 +433,21 @@ declare const LISTENER_KEY_ENV = "AGENTCHAT_LISTENER_API_KEY";
|
|
|
213
433
|
declare const CODEX_PROMPT_FROM_STDIN = "-";
|
|
214
434
|
/** Codex's config root. Honouring CODEX_HOME matters: users relocate it. */
|
|
215
435
|
declare function codexHomeFrom(env?: NodeJS.ProcessEnv): string;
|
|
216
|
-
|
|
436
|
+
/** How long a probe (`--version`, `login status`) may take; a hung one is killed with its whole tree (`runProbe`). */
|
|
437
|
+
declare const CODEX_PROBE_TIMEOUT_MS = 10000;
|
|
438
|
+
declare function inspectCodexRuntime(codexHome: string, command?: string, timeoutMs?: number, signal?: AbortSignal): Promise<PresetInspection>;
|
|
217
439
|
/** `codex login status` exits 0 when signed in. */
|
|
218
|
-
declare function codexIsLoggedIn(codexHome: string, command?: string): PresetInspection
|
|
440
|
+
declare function codexIsLoggedIn(codexHome: string, command?: string, timeoutMs?: number, signal?: AbortSignal): Promise<PresetInspection>;
|
|
441
|
+
/** The permission profile an `answer` run is given: its own name, so a user's profiles are never selected. */
|
|
442
|
+
declare const CODEX_ANSWER_PERMISSIONS = "agentchat_answer";
|
|
443
|
+
/** Its filesystem table: read the workspace root (the `-C` workdir) and nothing else; no write anywhere. */
|
|
444
|
+
declare const CODEX_ANSWER_FILESYSTEM = "{ \":workspace_roots\" = \"read\" }";
|
|
445
|
+
/**
|
|
446
|
+
* Codex features an `answer` run turns off: every model-visible tool that runs
|
|
447
|
+
* a command, reads a local file or reaches out beside the hosted AgentChat
|
|
448
|
+
* tools (see the header). Names as `codex features list` prints them (0.154.0).
|
|
449
|
+
*/
|
|
450
|
+
declare const CODEX_ANSWER_DISABLED_FEATURES: readonly ["shell_tool", "view_image", "image_generation", "plugins", "apps", "memories", "browser_use", "browser_use_external", "computer_use", "in_app_browser"];
|
|
219
451
|
declare function codexProfileArgs(profile: RunProfile): string[];
|
|
220
452
|
/** Where a run's hosted tool server points, and which variable carries its bearer token. */
|
|
221
453
|
interface CodexMcpOverride {
|
|
@@ -233,6 +465,8 @@ interface CodexMcpOverride {
|
|
|
233
465
|
* a run is an unknown client and is shown the wake-webhook tools.
|
|
234
466
|
*/
|
|
235
467
|
declare function codexClientHeadersToml(clientVersion?: string): string;
|
|
468
|
+
/** `-c mcp_servers.agentchat.url="<url>"`: the hosted server's URL pinned for one run, whatever another config layer says. */
|
|
469
|
+
declare function codexPinnedUrlArgs(url: string): string[];
|
|
236
470
|
/** The `-c` overrides that make `[mcp_servers.agentchat]` this agent's, for one run. TOML values, no key in them. */
|
|
237
471
|
declare function codexMcpOverrideArgs(override: CodexMcpOverride): string[];
|
|
238
472
|
/**
|
|
@@ -257,20 +491,117 @@ interface CodexRunnerOptions {
|
|
|
257
491
|
readonly keyEnv: string;
|
|
258
492
|
/** Point the hosted server at this agent for each run (`-c` overrides); absent, config.toml decides. */
|
|
259
493
|
readonly mcp?: CodexMcpOverride;
|
|
494
|
+
/**
|
|
495
|
+
* Without `mcp` (an integration's own runs): the hosted server's URL
|
|
496
|
+
* (`<api base>/mcp`), pinned on every run with `-c mcp_servers.agentchat.url=…`
|
|
497
|
+
* so no other config layer — a trusted project's `.codex/config.toml`
|
|
498
|
+
* among them — can point the agentchat server, and the key its bearer
|
|
499
|
+
* variable carries, anywhere else. A layer that gives it a `command`
|
|
500
|
+
* instead makes the merged table invalid: the run does not start.
|
|
501
|
+
*/
|
|
502
|
+
readonly pinMcpUrl?: string;
|
|
260
503
|
/** Test seam: the binary to run. */
|
|
261
504
|
readonly command?: string;
|
|
262
505
|
readonly env?: NodeJS.ProcessEnv;
|
|
506
|
+
/** Test seam: how long `codex mcp list` may take (`CODEX_MCP_LIST_TIMEOUT_MS`). */
|
|
507
|
+
readonly mcpListTimeoutMs?: number;
|
|
263
508
|
}
|
|
509
|
+
/**
|
|
510
|
+
* The folder an `answer` run works in when its configured workdir is the
|
|
511
|
+
* user's home folder or contains it (`workdirExposesHome`): an empty folder of
|
|
512
|
+
* its own under CODEX_HOME. The run keeps working — it only cannot reach the
|
|
513
|
+
* user's files through its workspace root.
|
|
514
|
+
*/
|
|
515
|
+
declare function codexAnswerFallbackWorkdir(codexHome: string): string;
|
|
516
|
+
/** How long `codex mcp list` may take before an answer run is given up (not started). */
|
|
517
|
+
declare const CODEX_MCP_LIST_TIMEOUT_MS = 20000;
|
|
518
|
+
/**
|
|
519
|
+
* A server name a `-c mcp_servers.<name>.enabled=false` override can address.
|
|
520
|
+
* Codex splits a `-c` key on every `.` (codex-rs/config/src/overrides.rs) and
|
|
521
|
+
* the value at the first `=`, but allows `.` in a server name
|
|
522
|
+
* (codex-mcp/src/rmcp_client.rs: `^[a-zA-Z0-9_:@/.-]+$`).
|
|
523
|
+
*/
|
|
524
|
+
declare function codexServerNameAddressable(name: string): boolean;
|
|
525
|
+
/**
|
|
526
|
+
* The names of the MCP servers `codex mcp list --json` reports enabled, or why
|
|
527
|
+
* that output cannot be trusted. Names only: an entry's transport can carry
|
|
528
|
+
* header and env values, and none of it is kept.
|
|
529
|
+
*/
|
|
530
|
+
declare function parseCodexMcpList(stdout: string): {
|
|
531
|
+
ok: true;
|
|
532
|
+
names: string[];
|
|
533
|
+
} | {
|
|
534
|
+
ok: false;
|
|
535
|
+
detail: string;
|
|
536
|
+
};
|
|
537
|
+
/**
|
|
538
|
+
* `-c mcp_servers.<name>.enabled=false` for every listed server but AgentChat's,
|
|
539
|
+
* or why that cannot be done. Only names Codex listed: an override for a server
|
|
540
|
+
* no config layer defines is a config error ("invalid transport").
|
|
541
|
+
*/
|
|
542
|
+
declare function codexMcpDisableArgs(names: readonly string[]): {
|
|
543
|
+
ok: true;
|
|
544
|
+
args: string[];
|
|
545
|
+
} | {
|
|
546
|
+
ok: false;
|
|
547
|
+
detail: string;
|
|
548
|
+
};
|
|
549
|
+
/** How long a listing is reused while none of the files it was read from changed (layers that are not files: a cloud bundle). */
|
|
550
|
+
declare const CODEX_MCP_LIST_MAX_AGE_MS: number;
|
|
551
|
+
/**
|
|
552
|
+
* The config files `codex mcp list` (and the run) read, in the loader's order
|
|
553
|
+
* (openai/codex rust-v0.154.0 config/src/loader/mod.rs:79-95, 800-841,
|
|
554
|
+
* layer_io.rs:22, 78-92, loader/macos.rs:20):
|
|
555
|
+
*
|
|
556
|
+
* * system: `/etc/codex/config.toml`, the legacy `/etc/codex/managed_config.toml`
|
|
557
|
+
* and `/etc/codex/requirements.toml`; on Windows `<ProgramData>\OpenAI\Codex\`
|
|
558
|
+
* `config.toml` and `requirements.toml` (the ProgramData known folder,
|
|
559
|
+
* `C:\ProgramData` when it cannot be resolved; `CODEX_HOME\managed_config.toml`
|
|
560
|
+
* is ignored there),
|
|
561
|
+
* * macOS managed preferences (`com.openai.codex`),
|
|
562
|
+
* * the user's `$CODEX_HOME/config.toml`,
|
|
563
|
+
* * `config.toml` in the workdir and `.codex/config.toml` from the workdir up
|
|
564
|
+
* to its root (a drive root on Windows).
|
|
565
|
+
*
|
|
566
|
+
* Paths are built for `platform` (its own separators and roots), whatever the
|
|
567
|
+
* host: the list is what that platform's Codex reads.
|
|
568
|
+
*/
|
|
569
|
+
declare function codexConfigLayerFiles(codexHome: string, workdir: string, platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): string[];
|
|
264
570
|
declare class CodexRunner implements RunRunner {
|
|
265
571
|
private readonly options;
|
|
266
572
|
readonly name = "codex";
|
|
267
573
|
private readonly command;
|
|
574
|
+
private warnedHome;
|
|
575
|
+
/** The last good listing and what it depended on: a stranger's DM does not cost a listing (and its contacts to the user's MCP hosts) on every run. */
|
|
576
|
+
private listing;
|
|
268
577
|
constructor(options: CodexRunnerOptions);
|
|
269
|
-
|
|
270
|
-
|
|
578
|
+
/**
|
|
579
|
+
* Where this runner's runs work (`-C`): the configured workdir, except that an
|
|
580
|
+
* `answer` run never has the home folder or above it as its workspace root —
|
|
581
|
+
* it gets `codexAnswerFallbackWorkdir`.
|
|
582
|
+
*/
|
|
583
|
+
workdir(): string;
|
|
584
|
+
preflight(options?: RunPreflightOptions): Promise<RunPreflight>;
|
|
585
|
+
/** The exact argv one run uses — exported for tests to pin per profile. An `answer` run adds `answerMcpDisables()` before the prompt. */
|
|
271
586
|
args(): string[];
|
|
272
587
|
/** The child environment: Codex's home and the key the hosted server needs, under the configured name. */
|
|
273
588
|
env(): NodeJS.ProcessEnv;
|
|
589
|
+
/**
|
|
590
|
+
* For an `answer` run: `-c mcp_servers.<name>.enabled=false` for every MCP
|
|
591
|
+
* server the run would load but AgentChat's — the user's own in config.toml,
|
|
592
|
+
* a project's, a managed one. Codex has no "only this server" switch, and a
|
|
593
|
+
* tool such a server marks read-only runs without approval. Asked of Codex
|
|
594
|
+
* itself (`codex mcp list --json`, with the run's own `-c`/`--disable`
|
|
595
|
+
* flags, from the run's workdir), so every layer is counted. Any failure —
|
|
596
|
+
* an error, a timeout, output that is not the list — means no run.
|
|
597
|
+
*/
|
|
598
|
+
answerMcpDisables(): Promise<{
|
|
599
|
+
ok: true;
|
|
600
|
+
args: string[];
|
|
601
|
+
} | {
|
|
602
|
+
ok: false;
|
|
603
|
+
detail: string;
|
|
604
|
+
}>;
|
|
274
605
|
start(request: RunRequest): Promise<RunOutcome>;
|
|
275
606
|
}
|
|
276
607
|
/**
|
|
@@ -286,4 +617,4 @@ declare const PRESETS: Readonly<Record<string, Preset>>;
|
|
|
286
617
|
declare function presetNamed(name: string): Preset | null;
|
|
287
618
|
declare function presetNames(): string[];
|
|
288
619
|
|
|
289
|
-
export { AGENTCHAT_TOOL_ALLOW, ANSWER_TOOLS, CLAUDE_CODE_PRESET, CLAUDE_MCP_SERVER_NAME, CODEX_MCP_SERVER_NAME, CODEX_PRESET, CODEX_PROMPT_FROM_STDIN, type ClaudeRunArgOptions, ClaudeRunner, type ClaudeRunnerOptions, type CodexMcpOverride, CodexRunner, type CodexRunnerOptions, LISTENER_KEY_ENV, MIN_CLAUDE_CODE_VERSION, MIN_CODEX_VERSION, PARENT_ENV_KEYS, PRESETS, type Preset, type PresetContext, type PresetInspection, WORK_TOOLS, agentchatTableKeys, buildClaudeEnv, claudeCodePreset, claudeConfigDirFrom, claudeHomeFor, claudeIsLoggedIn, claudeMcpConfig, claudeMcpConfigPath, claudeProfileArgs, claudeRunArgs, claudeUserStatePathFor, codexClientHeadersToml, codexHomeFrom, codexIsLoggedIn, codexMcpOverrideArgs, codexPreset, codexProfileArgs, codexRunArgs, deniedAncestorOf, inexpressibleDenyPaths, inspectClaudeRuntime, inspectCodexRuntime, presetNamed, presetNames, readDenyRules, semverAtLeast };
|
|
620
|
+
export { AGENTCHAT_TOOL_ALLOW, ANSWER_DENIED_TOOLS, ANSWER_ENV, ANSWER_SETTINGS, ANSWER_TOOLS, CLAUDE_CODE_ENV_KEPT, CLAUDE_CODE_PRESET, CLAUDE_MCP_SERVER_NAME, CLAUDE_SESSION_ENV, CODEX_ANSWER_DISABLED_FEATURES, CODEX_ANSWER_FILESYSTEM, CODEX_ANSWER_PERMISSIONS, CODEX_MANAGED_PROXY_ENV, CODEX_MCP_LIST_MAX_AGE_MS, CODEX_MCP_LIST_TIMEOUT_MS, CODEX_MCP_SERVER_NAME, CODEX_PRESET, CODEX_PROBE_TIMEOUT_MS, CODEX_PROMPT_FROM_STDIN, CODEX_SESSION_ENV, type ClaudeAnswerMcp, type ClaudeRunArgOptions, ClaudeRunner, type ClaudeRunnerOptions, type ClaudeSignIn, type CodexMcpOverride, CodexRunner, type CodexRunnerOptions, LISTENER_KEY_ENV, MIN_CLAUDE_CODE_VERSION, MIN_CODEX_VERSION, PARENT_ENV_KEYS, PRESETS, PROBE_TIMEOUT_MS, type Preset, type PresetContext, type PresetInspection, WEB_TOOLS, WORK_TOOLS, agentchatTableKeys, buildClaudeEnv, claudeAnswerFallbackWorkdir, claudeCodePreset, claudeConfigDirFrom, claudeExtraDirectoriesGrant, claudeHomeFor, claudeIsLoggedIn, claudeManagedSettingsDir, claudeMcpConfig, claudeMcpConfigPath, claudeProfileArgs, claudeProjectsDirFor, claudeRunArgs, claudeSettingsFilesGrantingDirectories, claudeSignIn, claudeUserStatePathFor, codexAnswerFallbackWorkdir, codexClientHeadersToml, codexConfigLayerFiles, codexHomeFrom, codexIsLoggedIn, codexMcpDisableArgs, codexMcpOverrideArgs, codexPinnedUrlArgs, codexPreset, codexProfileArgs, codexRunArgs, codexServerNameAddressable, deniedAncestorOf, inexpressibleDenyPaths, inspectClaudeRuntime, inspectCodexRuntime, isParentSessionEnv, parseCodexMcpList, presetNamed, presetNames, readDenyRules, semverAtLeast, withoutParentSession, workdirPaths, workdirReadRules };
|