@jini-ai/daemon 0.3.8 → 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/CHANGELOG.md +124 -0
- package/README.md +50 -8
- package/dist/agent-executor/contracts.d.ts +736 -0
- package/dist/agent-executor/contracts.js +28 -0
- package/dist/agent-executor/event-translation.d.ts +87 -0
- package/dist/agent-executor/event-translation.js +230 -0
- package/dist/agent-executor/events.d.ts +190 -0
- package/dist/agent-executor/events.js +848 -0
- package/dist/agent-executor/handoff.d.ts +18 -0
- package/dist/agent-executor/handoff.js +16 -0
- package/dist/agent-executor/index.d.ts +98 -0
- package/dist/agent-executor/index.js +98 -0
- package/dist/agent-executor/launch.d.ts +375 -0
- package/dist/agent-executor/launch.js +1001 -0
- package/dist/agent-executor/mcp-bridge.d.ts +338 -0
- package/dist/agent-executor/mcp-bridge.js +835 -0
- package/dist/agent-executor/values.d.ts +5 -0
- package/dist/agent-executor/values.js +13 -0
- package/dist/agent-executor.d.ts +375 -176
- package/dist/agent-executor.js +388 -335
- package/dist/close-status.d.ts +11 -8
- package/dist/close-status.js +31 -19
- package/dist/continuation/continuation-transport.d.ts +3 -1
- package/dist/continuation/continuation-transport.js +1 -1
- package/dist/continuation/journal.d.ts +12 -5
- package/dist/continuation/journal.js +4 -4
- package/dist/continuation/run-scoped-context-store.d.ts +13 -4
- package/dist/continuation/run-scoped-context-store.js +6 -6
- package/dist/continuation/run-start-handler.d.ts +1 -1
- package/dist/continuation/run-start-handler.js +3 -16
- package/dist/delegated-tool-bridge.d.ts +7 -3
- package/dist/delegated-tool-bridge.js +32 -31
- package/dist/event-log.d.ts +7 -5
- package/dist/event-log.js +12 -11
- package/dist/frontend-capability-tools.d.ts +1 -1
- package/dist/frontend-capability-tools.js +3 -2
- package/dist/frontend-session-registry.d.ts +32 -9
- package/dist/frontend-session-registry.js +12 -11
- package/dist/http/active-context.d.ts +105 -0
- package/dist/http/active-context.js +67 -0
- package/dist/http/agents.d.ts +68 -0
- package/dist/http/agents.js +12 -0
- package/dist/http/attachments.d.ts +618 -0
- package/dist/http/attachments.js +1034 -0
- package/dist/http/cancel-owned-runs.d.ts +49 -0
- package/dist/http/cancel-owned-runs.js +35 -0
- package/dist/http/component-catalog.d.ts +84 -0
- package/dist/http/component-catalog.js +64 -0
- package/dist/http/connectors.d.ts +209 -0
- package/dist/http/connectors.js +409 -0
- package/dist/http/daemon-status.d.ts +76 -0
- package/dist/http/daemon-status.js +55 -0
- package/dist/http/db-ops.d.ts +123 -0
- package/dist/http/db-ops.js +189 -0
- package/dist/http/delegated-tools.d.ts +113 -0
- package/dist/http/delegated-tools.js +230 -0
- package/dist/http/frontend-control.d.ts +136 -0
- package/dist/http/frontend-control.js +79 -0
- package/dist/http/frontend-sessions.d.ts +110 -0
- package/dist/http/frontend-sessions.js +180 -0
- package/dist/http/health.d.ts +95 -0
- package/dist/http/health.js +40 -0
- package/dist/http/host-tools.d.ts +214 -0
- package/dist/http/host-tools.js +329 -0
- package/dist/http/index.d.ts +52 -0
- package/dist/http/index.js +27 -0
- package/dist/http/media.d.ts +146 -0
- package/dist/http/media.js +346 -0
- package/dist/http/memory.d.ts +265 -0
- package/dist/http/memory.js +328 -0
- package/dist/http/model-proxy.d.ts +49 -0
- package/dist/http/model-proxy.js +642 -0
- package/dist/http/remote-run-events.d.ts +70 -0
- package/dist/http/remote-run-events.js +224 -0
- package/dist/http/research.d.ts +48 -0
- package/dist/http/research.js +315 -0
- package/dist/http/route-manifest.d.ts +35 -0
- package/dist/http/route-manifest.js +103 -0
- package/dist/http/routines.d.ts +120 -0
- package/dist/http/routines.js +298 -0
- package/dist/http/run-credentials.d.ts +73 -0
- package/dist/http/run-credentials.js +71 -0
- package/dist/http/runs.d.ts +91 -0
- package/dist/http/runs.js +221 -0
- package/dist/http/terminals.d.ts +138 -0
- package/dist/http/terminals.js +325 -0
- package/dist/http/tool-catalog.d.ts +78 -0
- package/dist/http/tool-catalog.js +66 -0
- package/dist/http/workspace-root.d.ts +77 -0
- package/dist/http/workspace-root.js +63 -0
- package/dist/http/xai.d.ts +90 -0
- package/dist/http/xai.js +655 -0
- package/dist/image-prompt-delivery.d.ts +13 -3
- package/dist/image-prompt-delivery.js +5 -5
- package/dist/index.d.ts +556 -4
- package/dist/index.js +556 -4
- package/dist/legacy-data-migration.d.ts +59 -8
- package/dist/legacy-data-migration.js +38 -33
- package/dist/read-only-tools.d.ts +130 -0
- package/dist/read-only-tools.js +115 -0
- package/dist/remote-tool-bridge.d.ts +11 -5
- package/dist/remote-tool-bridge.js +15 -15
- package/dist/routines/index.d.ts +1 -1
- package/dist/routines/index.js +1 -1
- package/dist/routines/routine-store.d.ts +34 -12
- package/dist/routines/routine-store.js +21 -20
- package/dist/routines/schedule.d.ts +48 -10
- package/dist/routines/schedule.js +21 -21
- package/dist/routines/scheduler.d.ts +32 -11
- package/dist/routines/scheduler.js +61 -57
- package/dist/routines/types.d.ts +10 -3
- package/dist/run/core/result.d.ts +6 -2
- package/dist/run/core/result.js +3 -3
- package/dist/run/core/retry.d.ts +17 -4
- package/dist/run/core/retry.js +7 -11
- package/dist/run/diagnostics/diagnostics.d.ts +14 -4
- package/dist/run/diagnostics/diagnostics.js +7 -7
- package/dist/run/index.d.ts +1 -1
- package/dist/run/index.js +1 -1
- package/dist/run-credentials.d.ts +138 -0
- package/dist/run-credentials.js +152 -0
- package/dist/run-lifecycle.d.ts +92 -33
- package/dist/run-lifecycle.js +81 -74
- package/dist/scheduler.d.ts +8 -0
- package/dist/scheduler.js +2 -0
- package/dist/session-coordination.d.ts +115 -0
- package/dist/session-coordination.js +111 -0
- package/dist/store/agent-sessions/errors.d.ts +8 -0
- package/dist/store/agent-sessions/errors.js +10 -0
- package/dist/store/agent-sessions/index.d.ts +12 -0
- package/dist/store/agent-sessions/index.js +19 -0
- package/dist/store/agent-sessions/pglite.d.ts +12 -0
- package/dist/store/agent-sessions/pglite.js +7 -0
- package/dist/store/agent-sessions/ports.d.ts +24 -0
- package/dist/store/agent-sessions/ports.js +2 -0
- package/dist/store/agent-sessions/postgres.d.ts +12 -0
- package/dist/store/agent-sessions/postgres.js +7 -0
- package/dist/store/agent-sessions/schema.d.ts +3 -0
- package/dist/store/agent-sessions/schema.js +23 -0
- package/dist/store/agent-sessions/sql.d.ts +35 -0
- package/dist/store/agent-sessions/sql.js +59 -0
- package/dist/store/agent-sessions/sqlite.d.ts +117 -0
- package/dist/store/agent-sessions/sqlite.js +128 -0
- package/dist/store/event-log/sqlite.d.ts +75 -0
- package/dist/store/event-log/sqlite.js +230 -0
- package/dist/surface-exchanges.d.ts +97 -0
- package/dist/surface-exchanges.js +153 -0
- package/dist/terminal-session.d.ts +43 -11
- package/dist/terminal-session.js +22 -20
- package/dist/tokens.js +4 -4
- package/dist/tool-audit.d.ts +114 -0
- package/dist/tool-audit.js +95 -0
- package/dist/tool-executor.d.ts +22 -7
- package/dist/tool-executor.js +16 -16
- package/dist/tool-result-media.d.ts +3 -1
- package/dist/tool-result-media.js +1 -1
- package/dist/tool-result-surfaces.d.ts +3 -1
- package/dist/tool-result-surfaces.js +1 -1
- package/package.json +127 -9
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { type AcpMcpServerInput, type RuntimeAgentDef } from '@jini-ai/agent-runtime';
|
|
2
|
+
import { type McpJsonInjectionOptions, type McpJsonServerEntry, type McpBridgeDelivery, type PreparedCodexHome, type PreparedClaudeConfigDir, type ClaudeConfigDirIsolationOptions, type FailBeforeSpawn } from './contracts.js';
|
|
3
|
+
/** The run-error code a run gets when its CLI reports the injected `jini` bridge as anything but connected. */
|
|
4
|
+
export declare const MCP_BRIDGE_UNAVAILABLE = "MCP_BRIDGE_UNAVAILABLE";
|
|
5
|
+
/**
|
|
6
|
+
* Judges a CLI's startup report of the injected bridge. Returns the bridge's status (`'missing'`
|
|
7
|
+
* when the list omits it) when it is not `'connected'`, and `undefined` when it is connected or
|
|
8
|
+
* when `rawEvent` is not an init status carrying an MCP server list (nothing to judge).
|
|
9
|
+
*
|
|
10
|
+
* `'pending'` counts as a failure on purpose: the CLI decides which MCP tools a session has at
|
|
11
|
+
* startup, so a bridge that is not connected by then never joins this run.
|
|
12
|
+
* @param rawEvent - One parsed stream event, as `@jini-ai/agent-runtime`'s parser emits it.
|
|
13
|
+
* @complexity O(n) in the number of reported servers.
|
|
14
|
+
*/
|
|
15
|
+
export declare function unavailableJiniBridgeStatus({ rawEvent }: {
|
|
16
|
+
readonly rawEvent: unknown;
|
|
17
|
+
}): string | undefined;
|
|
18
|
+
/** The user-readable reason a run stopped because its bridge did not connect. */
|
|
19
|
+
export declare function bridgeUnavailableMessage(status: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Builds this run's `mcpServers.jini` entry — pure and synchronous, so every field mapping is
|
|
22
|
+
* directly assertable without touching the filesystem. The credential arrives already resolved:
|
|
23
|
+
* `McpJsonInjectionOptions.credential` is a possibly-async per-run resolver, and awaiting it is
|
|
24
|
+
* `writeMcpJsonForRun`'s job, which keeps the effect out of this function.
|
|
25
|
+
*
|
|
26
|
+
* @param runId - The run this entry scopes its child to.
|
|
27
|
+
* @param options - `command`/`args`/`daemonUrl`/`env` from the host's injection options.
|
|
28
|
+
* @param credential - The already-resolved bearer token, or `undefined` to omit `JINI_DAEMON_TOKEN`
|
|
29
|
+
* entirely. Omitting produces byte-identical output to before this parameter existed.
|
|
30
|
+
* @complexity O(1).
|
|
31
|
+
* @overallScore 100/100
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildMcpJsonServerEntry({ runId, options }: {
|
|
34
|
+
readonly runId: string;
|
|
35
|
+
readonly options: Pick<McpJsonInjectionOptions, 'command' | 'args' | 'daemonUrl' | 'env'>;
|
|
36
|
+
}, { credential }?: {
|
|
37
|
+
readonly credential?: string;
|
|
38
|
+
}): McpJsonServerEntry;
|
|
39
|
+
/**
|
|
40
|
+
* Merges {@link JINI_MCP_SERVER_KEY} into an existing `.mcp.json`'s `mcpServers` map, preserving
|
|
41
|
+
* every other key and every other registered server untouched. A missing (`existingRaw ===
|
|
42
|
+
* undefined`), empty, or unparseable-as-a-JSON-object existing file all degrade to "start from an
|
|
43
|
+
* empty document" rather than throwing — an unparseable project `.mcp.json` is a pre-existing
|
|
44
|
+
* problem this driver did not create and cannot safely repair, so it is deliberately overwritten
|
|
45
|
+
* with a fresh, valid file containing just this run's bridge entry rather than left broken or
|
|
46
|
+
* left blocking the run. Pure — no I/O — so every branch is directly assertable.
|
|
47
|
+
* @complexity O(1) plus `JSON.parse`/`JSON.stringify`'s own cost on a small config file.
|
|
48
|
+
* @overallScore 100/100
|
|
49
|
+
*/
|
|
50
|
+
export declare function mergeMcpJsonContent({ existingRaw, serverEntry }: {
|
|
51
|
+
readonly existingRaw: string | undefined;
|
|
52
|
+
readonly serverEntry: McpJsonServerEntry;
|
|
53
|
+
}): string;
|
|
54
|
+
/**
|
|
55
|
+
* Mechanism 2 of 5 — `'acp-merge'`. Re-shapes the same bridge entry into the `mcpServers` element
|
|
56
|
+
* an ACP `session/new` call carries, for the 9 ACP-native defs declaring this strategy (amr, devin,
|
|
57
|
+
* hermes, kilo, kimi, kiro, reasonix, trae-cli, vibe). Pure.
|
|
58
|
+
*
|
|
59
|
+
* `env` is emitted as a plain object on purpose: `@jini-ai/agent-runtime`'s
|
|
60
|
+
* `buildAcpSessionNewParams` already normalises a plain-object `env` into either the
|
|
61
|
+
* `[{name, value}]` array form or the `{"KEY": "val"}` map form according to each def's own
|
|
62
|
+
* `acpMcpEnvFormat`, so the per-vendor wire-shape difference stays in the one place that already
|
|
63
|
+
* owns it rather than being re-decided here.
|
|
64
|
+
*
|
|
65
|
+
* **The credential travels in `env`, never in `args`.** An ACP agent spawns this server itself and
|
|
66
|
+
* applies `env` to that child's environment; a token in `args` would land in the child's process
|
|
67
|
+
* arguments, readable by any other local user via `ps`. Same rule as the `.mcp.json` path.
|
|
68
|
+
*
|
|
69
|
+
* @param entry - The shared bridge entry from {@link buildMcpJsonServerEntry}.
|
|
70
|
+
* @returns A single-element list — this driver contributes exactly its own bridge server and never
|
|
71
|
+
* removes or rewrites servers a def or host added by other means.
|
|
72
|
+
* @complexity O(1).
|
|
73
|
+
* @overallScore 100/100
|
|
74
|
+
*/
|
|
75
|
+
export declare function buildAcpMcpBridgeServers({ entry }: {
|
|
76
|
+
readonly entry: McpJsonServerEntry;
|
|
77
|
+
}): AcpMcpServerInput[];
|
|
78
|
+
/**
|
|
79
|
+
* Serialises the bridge entry into the OpenCode-schema config JSON that `OPENCODE_CONFIG_CONTENT`
|
|
80
|
+
* / `MIMOCODE_CONFIG_CONTENT` carries, merging into whatever the host already put in that variable
|
|
81
|
+
* rather than replacing it — the same "merge, never clobber" discipline
|
|
82
|
+
* {@link mergeMcpJsonContent} applies to `.mcp.json`, and for the same reason: a host may already
|
|
83
|
+
* be handing the CLI the *user's* configured MCP servers through this exact variable, and
|
|
84
|
+
* overwriting it would silently delete them.
|
|
85
|
+
*
|
|
86
|
+
* A missing, empty, or unparseable-as-a-JSON-object existing value degrades to "start from an empty
|
|
87
|
+
* document". Overwriting an unparseable value is deliberate and matches `mergeMcpJsonContent`: this
|
|
88
|
+
* driver did not create it, cannot safely repair it, and must not block the run on it.
|
|
89
|
+
*
|
|
90
|
+
* Emitted per server: `{type: 'local', command: [<command>, ...<args>], environment: {...},
|
|
91
|
+
* enabled: true}` — the shape `@jini-ai/mcp`'s own `buildOpenCodeMcpConfigContent` emits for a
|
|
92
|
+
* stdio server, so both producers stay schema-compatible.
|
|
93
|
+
*
|
|
94
|
+
* **The credential lands in `environment`, i.e. the MCP child's env — never in `command`.** OpenCode
|
|
95
|
+
* spawns the bridge from `command`, so a token placed there would be visible in `ps` output to
|
|
96
|
+
* every other local user. This is the same constraint that keeps `JINI_DAEMON_TOKEN` out of argv on
|
|
97
|
+
* the `.mcp.json` and ACP paths.
|
|
98
|
+
*
|
|
99
|
+
* @param existingRaw - Whatever the spawn env already held for this variable, or `undefined`.
|
|
100
|
+
* @param entry - The shared bridge entry from {@link buildMcpJsonServerEntry}.
|
|
101
|
+
* @returns The full JSON string to set as the env var's value.
|
|
102
|
+
* @complexity O(1) plus `JSON.parse`/`JSON.stringify` over a small config document.
|
|
103
|
+
* @overallScore 100/100
|
|
104
|
+
*/
|
|
105
|
+
export declare function mergeEnvContentMcpConfig({ existingRaw, entry }: {
|
|
106
|
+
readonly existingRaw: string | undefined;
|
|
107
|
+
readonly entry: McpJsonServerEntry;
|
|
108
|
+
}): string;
|
|
109
|
+
/**
|
|
110
|
+
* Merges a staged system-prompt overlay file's path into the `instructions` array of the same
|
|
111
|
+
* OpenCode-schema config document {@link mergeEnvContentMcpConfig} writes `mcp` into — for a
|
|
112
|
+
* `systemPromptDelivery: { strategy: 'config-instructions-file' }` def (`opencode` today).
|
|
113
|
+
*
|
|
114
|
+
* Confirmed live (2026-09-01, opencode-cli 1.17.10), not inferred from docs alone:
|
|
115
|
+
* 1. `instructions` is honored — a run configured with it visibly followed the file's directive
|
|
116
|
+
* (a required exact-token prefix), while an identical run without it did not.
|
|
117
|
+
* 2. It appends, never replaces: the same run that followed the custom instruction ALSO still
|
|
118
|
+
* answered correctly using opencode's own baked-in environment-context system prompt (asked
|
|
119
|
+
* for its cwd, with nothing about cwd anywhere in the custom instructions file) — proof
|
|
120
|
+
* opencode's own defaults survive alongside a custom `instructions` entry, not just proof the
|
|
121
|
+
* file was read at all.
|
|
122
|
+
* 3. Adding this key alongside `mcp` in the same `OPENCODE_CONFIG_CONTENT` document disturbs
|
|
123
|
+
* neither: in one combined run, the MCP bridge still got its connection attempt (logged
|
|
124
|
+
* `key=jini type=local`) AND the custom instruction was still followed — same as running each
|
|
125
|
+
* key alone.
|
|
126
|
+
* 4. `instructions` is re-read fresh from the env on every spawn, including a `-s <id>`-resumed
|
|
127
|
+
* turn (proved by swapping in a second instructions file between two turns of one resumed
|
|
128
|
+
* session and seeing the second turn immediately reflect it while still recalling
|
|
129
|
+
* conversation memory from turn one) — so this mechanism is safe to redeliver every turn like
|
|
130
|
+
* `'append-flag'`/`'env-var'`, exempt from the prompt-prefix fallback's create-only gating
|
|
131
|
+
* (see {@link resolveSystemPromptOverlayDelivery}'s doc): nothing here is ever baked into
|
|
132
|
+
* opencode's own persisted session state the way re-injecting fallback prompt text would be.
|
|
133
|
+
*
|
|
134
|
+
* @param existingRaw - Whatever the spawn env already held for this variable (already possibly
|
|
135
|
+
* carrying `mcp`, if `mergeEnvContentMcpConfig` ran first on the same value — order between the two
|
|
136
|
+
* doesn't matter, each only touches its own top-level key), or `undefined`.
|
|
137
|
+
* @param instructionsFilePath - The staged overlay file's absolute path (see
|
|
138
|
+
* {@link prepareSystemPromptOverlayFileIfNeeded}).
|
|
139
|
+
* @returns The full JSON string to set as the env var's value. Appends to, never clobbers, any
|
|
140
|
+
* `instructions` entries already present — the same "merge, never clobber" discipline
|
|
141
|
+
* {@link mergeEnvContentMcpConfig} applies to `mcp`, in case a host is already using this same
|
|
142
|
+
* config-content variable to carry the operator's own instruction files.
|
|
143
|
+
* @complexity O(1) plus `JSON.parse`/`JSON.stringify` over a small config document.
|
|
144
|
+
* @overallScore 100/100
|
|
145
|
+
*/
|
|
146
|
+
export declare function mergeEnvContentInstructions({ existingRaw, instructionsFilePath }: {
|
|
147
|
+
readonly existingRaw: string | undefined;
|
|
148
|
+
readonly instructionsFilePath: string;
|
|
149
|
+
}): string;
|
|
150
|
+
/**
|
|
151
|
+
* Mechanism 5 of 5 — `'codex-toml'`'s serialization step. Builds the `[mcp_servers.jini]` TOML
|
|
152
|
+
* table (plus, when the entry carries any env vars, a separate `[mcp_servers.jini.env]` table)
|
|
153
|
+
* Codex's own config schema expects.
|
|
154
|
+
*
|
|
155
|
+
* Confirmed against a real installed Codex CLI (0.151.0), not assumed from docs: round-tripping
|
|
156
|
+
* `codex mcp add <name> --env K=V -- <cmd> <args>` against a scratch `CODEX_HOME` and reading back
|
|
157
|
+
* `config.toml` produced exactly this shape (`command`/`args` as TOML strings/array in the main
|
|
158
|
+
* table, env vars in a nested `.env` table) — see `archived provenance ledger` for the transcript.
|
|
159
|
+
* @param entry - The shared bridge entry from {@link buildMcpJsonServerEntry}.
|
|
160
|
+
* @returns A TOML fragment with no leading/trailing blank-line padding — {@link buildCodexHomeConfigToml} owns spacing when combining it with existing content.
|
|
161
|
+
* @complexity O(n) in the number of argv/env entries.
|
|
162
|
+
* @overallScore 100/100
|
|
163
|
+
*/
|
|
164
|
+
export declare function buildCodexMcpServerToml({ entry }: {
|
|
165
|
+
readonly entry: McpJsonServerEntry;
|
|
166
|
+
}): string;
|
|
167
|
+
/**
|
|
168
|
+
* Builds the full `config.toml` a run's scratch `CODEX_HOME` gets: the real Codex home's own
|
|
169
|
+
* config, with any pre-existing `[mcp_servers.jini]` table removed (see
|
|
170
|
+
* {@link stripExistingJiniMcpServerTable}), then this run's own table appended.
|
|
171
|
+
*
|
|
172
|
+
* **Append-only by design, not a parse-and-merge, for everything but the jini table itself.**
|
|
173
|
+
* `mergeMcpJsonContent`/`mergeEnvContentMcpConfig` above can safely parse-merge-reserialize because
|
|
174
|
+
* their formats have a JS-native parser (`JSON.parse`); this driver has no general TOML parser in
|
|
175
|
+
* its dependency graph (see `buildCodexMcpServerToml`'s doc), and every other setting a real Codex
|
|
176
|
+
* install carries — model choice, sandbox policy, the trusted-project list, the operator's own
|
|
177
|
+
* other MCP servers — must survive a spawn byte-for-byte. Only the one table this driver itself
|
|
178
|
+
* owns (`jini` is this integration's own reserved server name — see {@link JINI_MCP_SERVER_KEY}) is
|
|
179
|
+
* ever removed, via the narrow line-oriented scan above, never a full TOML parse.
|
|
180
|
+
* @param existingRaw - The real Codex home's `config.toml` content, or `undefined` when it does not
|
|
181
|
+
* exist (a fresh Codex install — degrades to "start from just this run's block", matching
|
|
182
|
+
* {@link mergeMcpJsonContent}'s own "missing file" handling).
|
|
183
|
+
* @param entry - The shared bridge entry.
|
|
184
|
+
* @returns The full text to write to the scratch `CODEX_HOME`'s `config.toml`.
|
|
185
|
+
* @complexity O(n) in the existing config's length.
|
|
186
|
+
*/
|
|
187
|
+
export declare function buildCodexHomeConfigToml({ existingRaw, entry }: {
|
|
188
|
+
readonly existingRaw: string | undefined;
|
|
189
|
+
readonly entry: McpJsonServerEntry;
|
|
190
|
+
}): string;
|
|
191
|
+
/**
|
|
192
|
+
* Where `'codex-toml'` reads the operator's REAL Codex config from, to seed a run's scratch copy —
|
|
193
|
+
* never where it writes. Resolved against the daemon HOST process's own environment (`hostEnv`,
|
|
194
|
+
* `process.env` at the real call site), not a run's sandboxed spawn env: `CODEX_HOME` is not in
|
|
195
|
+
* `BASELINE_AGENT_ENV_KEYS`, so a spawned child never inherits it anyway, and the whole point here
|
|
196
|
+
* is finding wherever the *operator's actual* Codex install lives, which is a host-machine fact.
|
|
197
|
+
* @param hostEnv - The daemon process's own environment.
|
|
198
|
+
* @returns `hostEnv.CODEX_HOME` when set to a non-blank value (matching Codex's own resolution
|
|
199
|
+
* order), else the CLI's documented default, `~/.codex`.
|
|
200
|
+
* @complexity O(1).
|
|
201
|
+
* @overallScore 100/100
|
|
202
|
+
*/
|
|
203
|
+
export declare function resolveSourceCodexHomeDir({ hostEnv }: {
|
|
204
|
+
readonly hostEnv: NodeJS.ProcessEnv;
|
|
205
|
+
}): string;
|
|
206
|
+
/**
|
|
207
|
+
* **The single dispatch point from an `externalMcpInjection` strategy to its delivery mechanism.**
|
|
208
|
+
* Pure and synchronous — the one effectful input (the per-run bearer credential) arrives already
|
|
209
|
+
* resolved, so every strategy's mapping is directly assertable without touching the filesystem,
|
|
210
|
+
* the environment, or a keystore.
|
|
211
|
+
*
|
|
212
|
+
* Keyed off the declared *strategy*, never off `def.id`: a def gets a working bridge by declaring a
|
|
213
|
+
* mechanism, not by being named in this file. That is what makes the 9 `'acp-merge'` defs work
|
|
214
|
+
* without any of their own files being touched.
|
|
215
|
+
*
|
|
216
|
+
* @param input.cwd - The run's working directory; only `'claude-mcp-json'` uses it, to place this
|
|
217
|
+
* run's own config file (see {@link mcpJsonPathForRun}) — never `cwd/.mcp.json` itself.
|
|
218
|
+
* @param input.runId - Scopes the bridge child to this run.
|
|
219
|
+
* @param input.strategy - The def's declared `externalMcpInjection`, or `undefined` for a def with no native MCP transport.
|
|
220
|
+
* @param input.options - The host's bridge options, or `undefined` when the host never configured injection.
|
|
221
|
+
* @param input.credential - Already-resolved bearer token, or `undefined` to omit `JINI_DAEMON_TOKEN` entirely.
|
|
222
|
+
* @returns `null` when this run delivers nothing — an unconfigured host, or a def declaring no
|
|
223
|
+
* strategy — which is byte-identical to this feature not existing.
|
|
224
|
+
* @complexity O(1).
|
|
225
|
+
* @overallScore 100/100
|
|
226
|
+
*/
|
|
227
|
+
export declare function buildMcpBridgeDelivery(input: {
|
|
228
|
+
readonly cwd: string;
|
|
229
|
+
readonly runId: string;
|
|
230
|
+
readonly strategy: RuntimeAgentDef['externalMcpInjection'];
|
|
231
|
+
readonly options: McpJsonInjectionOptions | undefined;
|
|
232
|
+
readonly credential: string | undefined;
|
|
233
|
+
}): McpBridgeDelivery | null;
|
|
234
|
+
export declare function defaultRemoveMcpJsonFile({ path }: {
|
|
235
|
+
readonly path: string;
|
|
236
|
+
}): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Where `claude`'s own config resolution reads the operator's REAL config from, to seed a run's
|
|
239
|
+
* scratch copy — never where it writes. Mirrors {@link resolveSourceCodexHomeDir}'s exact reasoning
|
|
240
|
+
* and resolution order: `CLAUDE_CONFIG_DIR` is not in `BASELINE_AGENT_ENV_KEYS`, so a spawned child
|
|
241
|
+
* never inherits it anyway — the whole point is finding wherever the *operator's actual* Claude Code
|
|
242
|
+
* install lives, a host-machine fact resolved against the daemon HOST process's own environment.
|
|
243
|
+
* @param hostEnv - The daemon process's own environment.
|
|
244
|
+
* @returns `hostEnv.CLAUDE_CONFIG_DIR` when set to a non-blank value (matching Claude Code's own
|
|
245
|
+
* resolution order, confirmed against installed Claude Code 2.1.263), else the CLI's documented
|
|
246
|
+
* default, `~/.claude`.
|
|
247
|
+
* @complexity O(1).
|
|
248
|
+
*/
|
|
249
|
+
export declare function resolveSourceClaudeConfigDir({ hostEnv }: {
|
|
250
|
+
readonly hostEnv: NodeJS.ProcessEnv;
|
|
251
|
+
}): string;
|
|
252
|
+
/** Phase 5: resolves this run's MCP bridge delivery (credential resolution + {@link buildMcpBridgeDelivery}). */
|
|
253
|
+
export declare function resolveMcpBridgeForRun({ input, deps }: {
|
|
254
|
+
readonly input: {
|
|
255
|
+
readonly runId: string;
|
|
256
|
+
readonly cwd: string;
|
|
257
|
+
readonly def: RuntimeAgentDef;
|
|
258
|
+
};
|
|
259
|
+
readonly deps: {
|
|
260
|
+
readonly mcpJsonInjection: McpJsonInjectionOptions | undefined;
|
|
261
|
+
readonly cleanupStagedFiles: () => Promise<void>;
|
|
262
|
+
readonly failBeforeSpawn: FailBeforeSpawn;
|
|
263
|
+
};
|
|
264
|
+
}): Promise<McpBridgeDelivery | null>;
|
|
265
|
+
/** Phase 10: mechanism 1 of 5's one effect — stages this run's own `.mcp.json`, returning the path `cleanupStagedFiles` should later remove (`undefined` for every other mechanism / unconfigured host). */
|
|
266
|
+
export declare function writeMcpJsonIfNeeded({ input, deps }: {
|
|
267
|
+
readonly input: {
|
|
268
|
+
readonly runId: string;
|
|
269
|
+
readonly cwd: string;
|
|
270
|
+
readonly def: RuntimeAgentDef;
|
|
271
|
+
readonly mcpBridge: McpBridgeDelivery | null;
|
|
272
|
+
};
|
|
273
|
+
readonly deps: {
|
|
274
|
+
readonly mcpJsonInjection: McpJsonInjectionOptions | undefined;
|
|
275
|
+
readonly releaseStagedResources: () => Promise<void>;
|
|
276
|
+
readonly failBeforeSpawn: FailBeforeSpawn;
|
|
277
|
+
};
|
|
278
|
+
}): Promise<string | undefined>;
|
|
279
|
+
/**
|
|
280
|
+
* Phase 10b: mechanism 5 of 5's one effect — stages this run's scratch `CODEX_HOME` directory,
|
|
281
|
+
* returning the prepared handle `cleanupStagedFiles` should later release (`null` for every other
|
|
282
|
+
* mechanism, or for an unconfigured host — matching {@link writeMcpJsonIfNeeded}'s identical gate).
|
|
283
|
+
* @param input.def - Only used for its `id`, in the failure message.
|
|
284
|
+
* @param input.mcpBridge - This run's resolved bridge delivery — a no-op unless its `kind` is `'codex-toml'`.
|
|
285
|
+
* @param deps.hostEnv - The daemon's own environment, threaded through to {@link resolveSourceCodexHomeDir} rather than read from a module-level `process.env` so this phase stays testable with an injected env.
|
|
286
|
+
* @complexity O(1) plus {@link prepareCodexHomeForRun}'s own cost.
|
|
287
|
+
* @overallScore 100/100
|
|
288
|
+
*/
|
|
289
|
+
export declare function prepareCodexHomeIfNeeded({ input, deps }: {
|
|
290
|
+
readonly input: {
|
|
291
|
+
readonly runId: string;
|
|
292
|
+
readonly def: RuntimeAgentDef;
|
|
293
|
+
readonly mcpBridge: McpBridgeDelivery | null;
|
|
294
|
+
};
|
|
295
|
+
readonly deps: {
|
|
296
|
+
readonly mcpJsonInjection: McpJsonInjectionOptions | undefined;
|
|
297
|
+
readonly hostEnv: NodeJS.ProcessEnv;
|
|
298
|
+
readonly releaseStagedResources: () => Promise<void>;
|
|
299
|
+
readonly failBeforeSpawn: FailBeforeSpawn;
|
|
300
|
+
};
|
|
301
|
+
}): Promise<PreparedCodexHome | null>;
|
|
302
|
+
/**
|
|
303
|
+
* Finding 1 of SEC-assistant-env-isolation-2026-09-07's one effect — stages this run's scratch
|
|
304
|
+
* `CLAUDE_CONFIG_DIR` directory, returning the prepared handle `cleanupStagedFiles` should later
|
|
305
|
+
* release (`null` for every def other than `claude` — see {@link prepareClaudeConfigDirForRun}'s
|
|
306
|
+
* own doc for why this is unconditional for `claude` runs, unlike {@link prepareCodexHomeIfNeeded}'s
|
|
307
|
+
* gate on a host-configured MCP bridge strategy).
|
|
308
|
+
*
|
|
309
|
+
* Gated on `def.id === 'claude'` directly rather than on `externalMcpInjection === 'claude-mcp-json'`
|
|
310
|
+
* (which `codebuddy` also declares): isolating the operator's personal `~/.claude` is specific to
|
|
311
|
+
* the real `claude` CLI's own config resolution, not to every def that happens to share its `.mcp.
|
|
312
|
+
* json` delivery shape. Matches the existing `USER`-for-claude-login special case already singled
|
|
313
|
+
* out by id in `BASELINE_AGENT_ENV_KEYS`'s own doc in `launch.ts`.
|
|
314
|
+
*
|
|
315
|
+
* ALSO gated on `deps.enabled` (`CreateAgentExecutorOptions.claudeConfigDirIsolationEnabled`, default
|
|
316
|
+
* `false`) since this task's own fix — see that field's doc for why it defaults off (Keychain login
|
|
317
|
+
* is `CLAUDE_CONFIG_DIR`-keyed and no caller was supplying a credential when this was unconditional).
|
|
318
|
+
* `def.id === 'claude'` is still checked first and independently: a host that flips this flag on
|
|
319
|
+
* should not suddenly stage a directory for `codebuddy` or any other def.
|
|
320
|
+
* @param input.def - Used for both the `id` gate and the failure message.
|
|
321
|
+
* @param deps.enabled - The isolation on/off switch — see this function's own doc above.
|
|
322
|
+
* @param deps.hostEnv - The daemon's own environment, threaded through to {@link resolveSourceClaudeConfigDir} rather than read from a module-level `process.env`, matching {@link prepareCodexHomeIfNeeded}'s identical testability reasoning.
|
|
323
|
+
* @complexity O(1) plus {@link prepareClaudeConfigDirForRun}'s own cost.
|
|
324
|
+
*/
|
|
325
|
+
export declare function prepareClaudeConfigDirIfNeeded({ input, deps }: {
|
|
326
|
+
readonly input: {
|
|
327
|
+
readonly runId: string;
|
|
328
|
+
readonly def: RuntimeAgentDef;
|
|
329
|
+
};
|
|
330
|
+
readonly deps: {
|
|
331
|
+
readonly enabled: boolean;
|
|
332
|
+
readonly claudeConfigDirIsolation: ClaudeConfigDirIsolationOptions | undefined;
|
|
333
|
+
readonly hostEnv: NodeJS.ProcessEnv;
|
|
334
|
+
readonly releaseStagedResources: () => Promise<void>;
|
|
335
|
+
readonly failBeforeSpawn: FailBeforeSpawn;
|
|
336
|
+
};
|
|
337
|
+
}): Promise<PreparedClaudeConfigDir | null>;
|
|
338
|
+
//# sourceMappingURL=mcp-bridge.d.ts.map
|