@zvada/agent-server 0.3.25 → 0.3.27
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 +113 -0
- package/README.md +4 -1
- package/dist/client/client.js +27 -11
- package/dist/client/connection.js +35 -3
- package/dist/core/agents/acp/acp-agent.js +91 -14
- package/dist/core/agents/acp/mappings.js +5 -1
- package/dist/core/agents/claude-code/approvals.js +3 -2
- package/dist/core/agents/claude-code/claude-agent.js +12 -2
- package/dist/core/agents/claude-code/mcp.js +9 -1
- package/dist/core/agents/claude-code/models.js +16 -10
- package/dist/core/agents/claude-code/options.js +23 -2
- package/dist/core/agents/claude-code/session.js +21 -1
- package/dist/core/agents/claude-code/tools.js +9 -4
- package/dist/core/agents/claude-code/turn.js +2 -0
- package/dist/core/agents/codex-app-server/adapter.js +2 -0
- package/dist/core/agents/codex-app-server/client.js +8 -5
- package/dist/core/agents/codex-app-server/codex-agent.js +35 -2
- package/dist/core/agents/codex-app-server/effort.js +13 -6
- package/dist/core/agents/codex-app-server/mcp.js +35 -18
- package/dist/core/agents/codex-app-server/models.js +10 -10
- package/dist/core/agents/codex-app-server/options.js +11 -2
- package/dist/core/agents/codex-app-server/plan-approval.js +1 -1
- package/dist/core/agents/codex-app-server/session.js +11 -4
- package/dist/core/agents/codex-app-server/thread-settings.js +30 -11
- package/dist/core/agents/host-tools.js +493 -0
- package/dist/core/agents/mcp-config.js +6 -2
- package/dist/core/agents/scripted/scripted-agent.js +39 -6
- package/dist/core/agents/scripted/steps.js +5 -1
- package/dist/core/agents/session-agent.js +70 -2
- package/dist/core/agents/thinking-levels.js +8 -5
- package/dist/core/index.js +1 -0
- package/dist/core/presets.js +16 -3
- package/dist/core/processes/lifeline.js +9 -5
- package/dist/core/provision/pins.js +7 -16
- package/dist/core/provision/releases.js +25 -25
- package/dist/core/proxy/loopback.js +22 -4
- package/dist/core/runtime/agent-runtime.js +15 -5
- package/dist/core/runtime/event-processor.js +13 -8
- package/dist/core/runtime/origin-line.js +42 -0
- package/dist/core/runtime/request-broker.js +2 -1
- package/dist/core/runtime/steering.js +4 -3
- package/dist/core/runtime/turn.js +6 -4
- package/dist/operator/errors.js +97 -0
- package/dist/operator/index.js +10 -5
- package/dist/operator/mcp.js +7 -12
- package/dist/operator/operator.js +1336 -380
- package/dist/operator/refs.js +59 -0
- package/dist/operator/render.js +171 -74
- package/dist/operator/session-tools.js +87 -0
- package/dist/operator/types.js +30 -0
- package/dist/operator/view.js +82 -27
- package/dist/protocol/config.js +33 -6
- package/dist/protocol/conversation.js +3 -0
- package/dist/protocol/history.js +2 -1
- package/dist/protocol/index.js +1 -0
- package/dist/protocol/lifecycle.js +19 -0
- package/dist/protocol/model-catalog.js +58 -18
- package/dist/protocol/models.js +6 -27
- package/dist/protocol/origin.js +39 -0
- package/dist/protocol/reduce.js +2 -0
- package/dist/protocol/thinking.js +22 -9
- package/dist/protocol/wire-api.js +2 -2
- package/dist/protocol/wire.js +17 -0
- package/dist/server/bin.js +6 -4
- package/dist/server/routes.js +15 -5
- package/dist/types/client/client.d.ts.map +1 -1
- package/dist/types/client/connection.d.ts +14 -2
- package/dist/types/client/connection.d.ts.map +1 -1
- package/dist/types/client/turns.d.ts +2 -2
- package/dist/types/client/turns.d.ts.map +1 -1
- package/dist/types/core/agents/acp/acp-agent.d.ts +15 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
- package/dist/types/core/agents/acp/mappings.d.ts +5 -1
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
- package/dist/types/core/agents/acp/requests.d.ts +2 -0
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -1
- package/dist/types/core/agents/base.d.ts +2 -0
- package/dist/types/core/agents/base.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/approvals.d.ts +2 -1
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +1 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/mcp.d.ts +8 -1
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/models.d.ts +9 -5
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/options.d.ts +10 -1
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/session.d.ts +2 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/turn.d.ts +3 -0
- package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/client.d.ts +2 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +11 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/effort.d.ts +7 -7
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +11 -3
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/models.d.ts +4 -1
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/options.d.ts +9 -2
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/requests.d.ts +2 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/session.d.ts +6 -3
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -1
- package/dist/types/core/agents/host-tools.d.ts +162 -0
- package/dist/types/core/agents/host-tools.d.ts.map +1 -0
- package/dist/types/core/agents/mcp-config.d.ts +11 -2
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -1
- package/dist/types/core/agents/scripted/scripted-agent.d.ts +14 -1
- package/dist/types/core/agents/scripted/scripted-agent.d.ts.map +1 -1
- package/dist/types/core/agents/scripted/steps.d.ts.map +1 -1
- package/dist/types/core/agents/session-agent.d.ts +2 -7
- package/dist/types/core/agents/session-agent.d.ts.map +1 -1
- package/dist/types/core/agents/thinking-levels.d.ts +7 -3
- package/dist/types/core/agents/thinking-levels.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/index.d.ts.map +1 -1
- package/dist/types/core/presets.d.ts +11 -1
- package/dist/types/core/presets.d.ts.map +1 -1
- package/dist/types/core/processes/lifeline.d.ts.map +1 -1
- package/dist/types/core/provision/pins.d.ts +5 -4
- package/dist/types/core/provision/pins.d.ts.map +1 -1
- package/dist/types/core/proxy/loopback.d.ts.map +1 -1
- package/dist/types/core/runtime/agent-runtime.d.ts +4 -2
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
- package/dist/types/core/runtime/event-processor.d.ts +2 -2
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -1
- package/dist/types/core/runtime/origin-line.d.ts +15 -0
- package/dist/types/core/runtime/origin-line.d.ts.map +1 -0
- package/dist/types/core/runtime/request-broker.d.ts +1 -1
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -1
- package/dist/types/core/runtime/steering.d.ts +7 -4
- package/dist/types/core/runtime/steering.d.ts.map +1 -1
- package/dist/types/core/runtime/turn.d.ts.map +1 -1
- package/dist/types/operator/errors.d.ts +83 -0
- package/dist/types/operator/errors.d.ts.map +1 -0
- package/dist/types/operator/index.d.ts +10 -5
- package/dist/types/operator/index.d.ts.map +1 -1
- package/dist/types/operator/mcp.d.ts +1 -1
- package/dist/types/operator/mcp.d.ts.map +1 -1
- package/dist/types/operator/operator.d.ts +15 -197
- package/dist/types/operator/operator.d.ts.map +1 -1
- package/dist/types/operator/refs.d.ts +25 -0
- package/dist/types/operator/refs.d.ts.map +1 -0
- package/dist/types/operator/render.d.ts +59 -19
- package/dist/types/operator/render.d.ts.map +1 -1
- package/dist/types/operator/session-tools.d.ts +61 -0
- package/dist/types/operator/session-tools.d.ts.map +1 -0
- package/dist/types/operator/types.d.ts +441 -0
- package/dist/types/operator/types.d.ts.map +1 -0
- package/dist/types/operator/view.d.ts +19 -29
- package/dist/types/operator/view.d.ts.map +1 -1
- package/dist/types/protocol/config.d.ts +32 -24
- package/dist/types/protocol/config.d.ts.map +1 -1
- package/dist/types/protocol/conversation.d.ts +48 -39
- package/dist/types/protocol/conversation.d.ts.map +1 -1
- package/dist/types/protocol/execution.d.ts +2 -18
- package/dist/types/protocol/execution.d.ts.map +1 -1
- package/dist/types/protocol/history.d.ts +1 -1
- package/dist/types/protocol/history.d.ts.map +1 -1
- package/dist/types/protocol/index.d.ts +1 -0
- package/dist/types/protocol/index.d.ts.map +1 -1
- package/dist/types/protocol/lifecycle.d.ts +48 -74
- package/dist/types/protocol/lifecycle.d.ts.map +1 -1
- package/dist/types/protocol/model-catalog.d.ts.map +1 -1
- package/dist/types/protocol/models.d.ts +4 -42
- package/dist/types/protocol/models.d.ts.map +1 -1
- package/dist/types/protocol/origin.d.ts +49 -0
- package/dist/types/protocol/origin.d.ts.map +1 -0
- package/dist/types/protocol/reduce.d.ts.map +1 -1
- package/dist/types/protocol/thinking.d.ts +19 -19
- package/dist/types/protocol/thinking.d.ts.map +1 -1
- package/dist/types/protocol/wire-api.d.ts +59 -106
- package/dist/types/protocol/wire-api.d.ts.map +1 -1
- package/dist/types/protocol/wire.d.ts +81 -119
- package/dist/types/protocol/wire.d.ts.map +1 -1
- package/dist/types/server/routes.d.ts.map +1 -1
- package/docs/consuming.md +124 -132
- package/docs/deploy.md +6 -5
- package/docs/harnesses.md +79 -31
- package/docs/sync-history.md +2 -1
- package/package.json +4 -4
- package/src/client/client.ts +36 -9
- package/src/client/connection.ts +31 -1
- package/src/client/turns.ts +2 -1
- package/src/core/agents/acp/acp-agent.ts +123 -17
- package/src/core/agents/acp/mappings.ts +5 -1
- package/src/core/agents/acp/requests.ts +2 -0
- package/src/core/agents/base.ts +2 -0
- package/src/core/agents/claude-code/approvals.ts +4 -3
- package/src/core/agents/claude-code/claude-agent.ts +14 -2
- package/src/core/agents/claude-code/mcp.ts +11 -1
- package/src/core/agents/claude-code/models.ts +15 -10
- package/src/core/agents/claude-code/options.ts +33 -3
- package/src/core/agents/claude-code/session.ts +26 -1
- package/src/core/agents/claude-code/tools.ts +10 -4
- package/src/core/agents/claude-code/turn.ts +4 -0
- package/src/core/agents/codex-app-server/adapter.ts +2 -0
- package/src/core/agents/codex-app-server/client.ts +11 -5
- package/src/core/agents/codex-app-server/codex-agent.ts +45 -1
- package/src/core/agents/codex-app-server/effort.ts +15 -20
- package/src/core/agents/codex-app-server/mcp.ts +46 -23
- package/src/core/agents/codex-app-server/models.ts +10 -10
- package/src/core/agents/codex-app-server/options.ts +16 -2
- package/src/core/agents/codex-app-server/plan-approval.ts +1 -1
- package/src/core/agents/codex-app-server/requests.ts +2 -0
- package/src/core/agents/codex-app-server/session.ts +19 -4
- package/src/core/agents/codex-app-server/thread-settings.ts +31 -11
- package/src/core/agents/host-tools.ts +649 -0
- package/src/core/agents/mcp-config.ts +15 -3
- package/src/core/agents/scripted/scripted-agent.ts +51 -5
- package/src/core/agents/scripted/steps.ts +5 -1
- package/src/core/agents/session-agent.ts +78 -2
- package/src/core/agents/thinking-levels.ts +9 -6
- package/src/core/index.ts +9 -0
- package/src/core/presets.ts +28 -4
- package/src/core/processes/lifeline.ts +9 -5
- package/src/core/provision/pins.ts +7 -16
- package/src/core/provision/releases.ts +25 -25
- package/src/core/proxy/loopback.ts +25 -4
- package/src/core/runtime/agent-runtime.ts +31 -7
- package/src/core/runtime/event-processor.ts +13 -6
- package/src/core/runtime/origin-line.ts +43 -0
- package/src/core/runtime/request-broker.ts +2 -0
- package/src/core/runtime/steering.ts +8 -4
- package/src/core/runtime/turn.ts +11 -4
- package/src/operator/errors.ts +218 -0
- package/src/operator/index.ts +18 -23
- package/src/operator/mcp.ts +7 -16
- package/src/operator/operator.ts +1583 -613
- package/src/operator/refs.ts +75 -0
- package/src/operator/render.ts +208 -98
- package/src/operator/session-tools.ts +126 -0
- package/src/operator/types.ts +505 -0
- package/src/operator/view.ts +93 -42
- package/src/protocol/config.ts +36 -7
- package/src/protocol/conversation.ts +3 -0
- package/src/protocol/history.ts +2 -1
- package/src/protocol/index.ts +1 -0
- package/src/protocol/lifecycle.ts +21 -0
- package/src/protocol/model-catalog.ts +58 -18
- package/src/protocol/models.ts +6 -26
- package/src/protocol/origin.ts +47 -0
- package/src/protocol/reduce.ts +4 -0
- package/src/protocol/thinking.ts +27 -14
- package/src/protocol/wire-api.ts +2 -2
- package/src/protocol/wire.ts +18 -0
- package/src/server/bin.ts +6 -4
- package/src/server/routes.ts +16 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncQueue, clampThinkingLevel, } from "../../../protocol/index.js";
|
|
2
2
|
import { onAbort } from "../../utils/deadline.js";
|
|
3
|
-
import {
|
|
3
|
+
import { listedThinkingLevels } from "../thinking-levels.js";
|
|
4
4
|
import { buildClaudeOptions } from "./options.js";
|
|
5
5
|
/**
|
|
6
6
|
* Claude Code's model rows in the shared shape. `default` (the account's
|
|
@@ -18,7 +18,7 @@ export function claudeModelDescriptors(models) {
|
|
|
18
18
|
...(model.resolvedModel &&
|
|
19
19
|
model.resolvedModel !== model.value && { resolvedId: model.resolvedModel }),
|
|
20
20
|
...(model.value === "default" && { isDefault: true }),
|
|
21
|
-
thinking: { levels:
|
|
21
|
+
thinking: { levels: listedThinkingLevels(model.supportedEffortLevels ?? []) },
|
|
22
22
|
}));
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
@@ -26,20 +26,26 @@ export function claudeModelDescriptors(models) {
|
|
|
26
26
|
* lowers a level its model lacks on its own and does not say so (`max` and
|
|
27
27
|
* `xhigh` become `high`), so the level is fitted here, where the model's levels
|
|
28
28
|
* are known. `off` is sent as it is: some models do not let thinking be
|
|
29
|
-
* disabled
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
29
|
+
* disabled (Haiku 5.5 at `off` still spends thinking tokens, with an empty
|
|
30
|
+
* reasoning part, on Claude Code 2.1.327); Haiku 4.5, which Claude Code
|
|
31
|
+
* otherwise starts thinking, does not think with it. A model known to have no
|
|
32
|
+
* effort levels (`levels: []`, Haiku 4.5) is sent no other level, so it is not
|
|
33
|
+
* started on adaptive thinking at an effort it has no control for: it thinks
|
|
34
|
+
* at its own default, as Claude Code starts it. Neither is a model sent a
|
|
35
|
+
* level that has no fit among the levels it lists. A model whose levels are
|
|
36
|
+
* unknown (`undefined`) is sent the level as asked, but `ultra` as `max`,
|
|
37
|
+
* Claude's ceiling; a model that lists `ultra` is sent it.
|
|
34
38
|
*/
|
|
35
39
|
export function fitClaudeThinking(level, levels) {
|
|
36
40
|
if (level === undefined)
|
|
37
41
|
return {};
|
|
38
|
-
if (level === "off"
|
|
42
|
+
if (level === "off")
|
|
39
43
|
return { send: level };
|
|
40
|
-
if (
|
|
44
|
+
if (levels === undefined)
|
|
45
|
+
return { send: level === "ultra" ? "max" : level };
|
|
46
|
+
const fitted = clampThinkingLevel(level, levels);
|
|
47
|
+
if (fitted === undefined)
|
|
41
48
|
return {};
|
|
42
|
-
const fitted = clampThinkingLevel(level, levels) ?? level;
|
|
43
49
|
return { send: fitted, applied: fitted };
|
|
44
50
|
}
|
|
45
51
|
/**
|
|
@@ -149,6 +149,10 @@ function buildEnv(config, level) {
|
|
|
149
149
|
}),
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
+
/** Whether Claude Code reads a flag as on: `1`, `true`, `yes` or `on`, in any case (2.1.327). */
|
|
153
|
+
function envFlagOn(value) {
|
|
154
|
+
return ["1", "true", "yes", "on"].includes((value ?? "").trim().toLowerCase());
|
|
155
|
+
}
|
|
152
156
|
/** The environment Claude Code runs a turn with this `env` in, which decides whose login it runs on. */
|
|
153
157
|
export function claudeEnv(config) {
|
|
154
158
|
return buildEnv(config, inherited(config));
|
|
@@ -191,8 +195,10 @@ export function buildClaudeOptions(config, sdkMcpServers, overrides, spawn) {
|
|
|
191
195
|
}
|
|
192
196
|
else {
|
|
193
197
|
options.thinking = { type: "adaptive" };
|
|
194
|
-
//
|
|
195
|
-
|
|
198
|
+
// The level as `fitClaudeThinking` gave it. The SDK types `effort` as
|
|
199
|
+
// the levels it knows; one beyond them (a level the model lists, or
|
|
200
|
+
// any when its levels are unknown) goes to the CLI as it is named.
|
|
201
|
+
options.effort = config.thinkingLevel;
|
|
196
202
|
}
|
|
197
203
|
}
|
|
198
204
|
if (config.resumeSessionId) {
|
|
@@ -217,8 +223,23 @@ export function buildClaudeOptions(config, sdkMcpServers, overrides, spawn) {
|
|
|
217
223
|
// ClaudeSdkOptionOverrides type excludes them anyway).
|
|
218
224
|
if (overrides)
|
|
219
225
|
Object.assign(options, overrides);
|
|
226
|
+
// @ref LLP 0001#d4--permission-requests-are-first-class-protocol — plan mode asks through the broker
|
|
227
|
+
// On a model with auto mode, plan mode takes auto mode's semantics: calls run that the broker
|
|
228
|
+
// never sees. Off beneath the operator's own settings object; a path, or `extraArgs.settings`, stays theirs.
|
|
229
|
+
if (typeof options.settings !== "string" && options.extraArgs?.settings === undefined)
|
|
230
|
+
options.settings = { useAutoModeDuringPlan: false, ...options.settings };
|
|
220
231
|
if (config.subagentMode === "turn")
|
|
221
232
|
options.forwardSubagentText = true;
|
|
233
|
+
// @ref LLP 0001#d14--nothing-the-agent-does-is-off-the-stream — a watch outlives its turn
|
|
234
|
+
// Claude Code 2.1.327 offers `Monitor` with background tasks off: its watch
|
|
235
|
+
// runs past the turn and Claude answers each line with a query of its own,
|
|
236
|
+
// which no turn shows. With background tasks off it is off too, beside the
|
|
237
|
+
// operator's own denials; an env that turns them on leaves it alone.
|
|
238
|
+
if (envFlagOn(options.env?.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)) {
|
|
239
|
+
const denied = options.disallowedTools ?? [];
|
|
240
|
+
if (!denied.includes("Monitor"))
|
|
241
|
+
options.disallowedTools = [...denied, "Monitor"];
|
|
242
|
+
}
|
|
222
243
|
// Engine wiring over the operator's: their spawner still runs, as theirs.
|
|
223
244
|
if (spawn)
|
|
224
245
|
options.spawnClaudeCodeProcess = claudeSpawner(spawn, overrides?.spawnClaudeCodeProcess, overrides?.stderr);
|
|
@@ -170,12 +170,25 @@ export class ClaudeSession {
|
|
|
170
170
|
}
|
|
171
171
|
return true;
|
|
172
172
|
}
|
|
173
|
+
/** The turn running now and the mode the process runs in, for a host tool's caller. */
|
|
174
|
+
liveTurn() {
|
|
175
|
+
return this.turn
|
|
176
|
+
? {
|
|
177
|
+
turnId: this.turn.id,
|
|
178
|
+
permissionMode: this.config.permissionMode ?? "default",
|
|
179
|
+
signal: this.turn.signal,
|
|
180
|
+
}
|
|
181
|
+
: undefined;
|
|
182
|
+
}
|
|
173
183
|
async start() {
|
|
174
184
|
if (this.state !== "starting")
|
|
175
185
|
throw new Error(`Cannot start in state: ${this.state}`);
|
|
176
186
|
const sdk = await import("@anthropic-ai/claude-agent-sdk");
|
|
177
187
|
const spawn = { sessionId: this.id, cwd: this.config.cwd };
|
|
178
|
-
const
|
|
188
|
+
const source = await this.settings.host?.source(this.id, this.config.cwd);
|
|
189
|
+
const hostServers = { ...(await this.settings.sdkMcpServers?.(spawn)) };
|
|
190
|
+
if (source && this.settings.host)
|
|
191
|
+
hostServers[source.name] = this.settings.host.inProcess(this.id, source, () => this.liveTurn());
|
|
179
192
|
this.mcp.useHostServers(hostServers);
|
|
180
193
|
const overrides = await this.settings.sdkOptions?.(spawn);
|
|
181
194
|
this.thinkingOverridden = Boolean(overrides && ("effort" in overrides || "thinking" in overrides));
|
|
@@ -186,6 +199,13 @@ export class ClaudeSession {
|
|
|
186
199
|
this.native = native;
|
|
187
200
|
},
|
|
188
201
|
});
|
|
202
|
+
// @ref LLP 0018#permissions — a read-only host tool runs unasked, as on Codex; any other asks
|
|
203
|
+
const readOnly = (source?.tools ?? []).filter((tool) => tool.annotations?.readOnly);
|
|
204
|
+
if (source && readOnly.length)
|
|
205
|
+
options.allowedTools = [
|
|
206
|
+
...(options.allowedTools ?? []),
|
|
207
|
+
...readOnly.map((tool) => `mcp__${source.name}__${tool.name}`),
|
|
208
|
+
];
|
|
189
209
|
if (this.settings.hooks) {
|
|
190
210
|
options.hooks = this.settings.hooks({
|
|
191
211
|
sessionId: this.id,
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
* CLI offers that is not here, so a pin bump decides it.
|
|
12
12
|
*/
|
|
13
13
|
export const CLAUDE_TOOL_KINDS = new Map([
|
|
14
|
-
// What the pinned CLI
|
|
14
|
+
// What the pinned CLI offers, with the engine's options or a product's.
|
|
15
15
|
["Read", "read"],
|
|
16
16
|
["Edit", "edit"],
|
|
17
17
|
["Write", "edit"],
|
|
18
18
|
["NotebookEdit", "edit"],
|
|
19
19
|
["Bash", "execute"],
|
|
20
|
+
// Runs a shell command and reports its output as it comes.
|
|
21
|
+
["Monitor", "execute"],
|
|
20
22
|
// Stops a background shell or sub-agent the agent started.
|
|
21
23
|
["TaskStop", "execute"],
|
|
22
24
|
// Runs a script the agent wrote, which starts sub-agents of its own.
|
|
@@ -25,6 +27,8 @@ export const CLAUDE_TOOL_KINDS = new Map([
|
|
|
25
27
|
["WebSearch", "fetch"],
|
|
26
28
|
// Loads a skill's instructions into the conversation.
|
|
27
29
|
["Skill", "read"],
|
|
30
|
+
// Loads the definition of a tool the CLI held back: nothing of the person's.
|
|
31
|
+
["ToolSearch", "other"],
|
|
28
32
|
// The sub-agent tool: `init` names it `Task`, the model `Agent`. A spawn is `task` by its subagent.
|
|
29
33
|
["Task", "think"],
|
|
30
34
|
["Agent", "think"],
|
|
@@ -71,8 +75,8 @@ function toolLocationsFromInput(input) {
|
|
|
71
75
|
}
|
|
72
76
|
const MCP_PREFIX = "mcp__";
|
|
73
77
|
/**
|
|
74
|
-
* A server's name as Claude Code spells it in a tool name (the pinned CLI
|
|
75
|
-
* 2.1.288
|
|
78
|
+
* A server's name as Claude Code spells it in a tool name (the pinned CLI;
|
|
79
|
+
* 2.1.288 and 2.1.325 spell it alike, observed 2026-11-16):
|
|
76
80
|
* other than letters, digits, `_` and `-` become `_`, and a claude.ai
|
|
77
81
|
* connector's runs of `_` collapse.
|
|
78
82
|
*/
|
|
@@ -119,7 +123,8 @@ function textOf(input, key) {
|
|
|
119
123
|
*/
|
|
120
124
|
export function claudeToolMeta(toolName, input, servers) {
|
|
121
125
|
const mcp = claudeMcpTool(toolName, servers);
|
|
122
|
-
|
|
126
|
+
// A `Monitor` on a WebSocket has no command.
|
|
127
|
+
const command = toolName === "Bash" || toolName === "Monitor" ? textOf(input, "command") : undefined;
|
|
123
128
|
const url = toolName === "WebFetch" ? textOf(input, "url") : undefined;
|
|
124
129
|
return {
|
|
125
130
|
kind: CLAUDE_TOOL_KINDS.get(toolName) ?? "other",
|
|
@@ -13,6 +13,7 @@ const STEER_QUERY_TIMEOUT_MS = 60_000;
|
|
|
13
13
|
*/
|
|
14
14
|
export class ClaudeTurn {
|
|
15
15
|
id;
|
|
16
|
+
signal;
|
|
16
17
|
permissions;
|
|
17
18
|
elicitation;
|
|
18
19
|
/** What the turn yields, until its result or its failure. */
|
|
@@ -48,6 +49,7 @@ export class ClaudeTurn {
|
|
|
48
49
|
watchdog;
|
|
49
50
|
constructor(start, prompt) {
|
|
50
51
|
this.id = start.turnId;
|
|
52
|
+
this.signal = start.signal;
|
|
51
53
|
this.permissions = start.permissions;
|
|
52
54
|
this.elicitation = start.elicitation;
|
|
53
55
|
this.prompt = prompt;
|
|
@@ -442,6 +442,8 @@ export function codexErrorCategory(info) {
|
|
|
442
442
|
case "unauthorized":
|
|
443
443
|
return "auth";
|
|
444
444
|
case "badRequest":
|
|
445
|
+
// A model the provider does not have, or the account cannot run.
|
|
446
|
+
case "modelNotFound":
|
|
445
447
|
return "invalid_request";
|
|
446
448
|
case "internalServerError":
|
|
447
449
|
return "internal";
|
|
@@ -44,6 +44,13 @@ export class CodexRpcError extends Error {
|
|
|
44
44
|
this.name = "CodexRpcError";
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
/** The `-c key=value` overrides the app-server starts with, for these options. */
|
|
48
|
+
export function configArgs(opts) {
|
|
49
|
+
return [
|
|
50
|
+
...(opts.ephemeralCredentials ? ["-c", 'cli_auth_credentials_store="ephemeral"'] : []),
|
|
51
|
+
...(opts.pluginsOff ? ["-c", "features.plugins=false"] : []),
|
|
52
|
+
];
|
|
53
|
+
}
|
|
47
54
|
/**
|
|
48
55
|
* Newline-delimited (JSONL) JSON-RPC client over a `codex app-server` subprocess.
|
|
49
56
|
* Requests get monotonic ids resolved against a pending map; notifications fan
|
|
@@ -203,11 +210,7 @@ export class CodexAppServerClient {
|
|
|
203
210
|
this.nativeShutdownFailed = false;
|
|
204
211
|
const native = this.opts.processes.spawn({
|
|
205
212
|
command: this.opts.codexPath ?? "codex",
|
|
206
|
-
args: [
|
|
207
|
-
"app-server",
|
|
208
|
-
...(this.opts.ephemeralCredentials ? ["-c", 'cli_auth_credentials_store="ephemeral"'] : []),
|
|
209
|
-
...(this.opts.pluginsOff ? ["-c", "features.plugins=false"] : []),
|
|
210
|
-
],
|
|
213
|
+
args: ["app-server", ...configArgs(this.opts)],
|
|
211
214
|
cwd: this.opts.cwd,
|
|
212
215
|
env: this.opts.env ?? process.env,
|
|
213
216
|
harness: "codex-app-server",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { sharedNativeProcesses } from "../../processes/native-processes.js";
|
|
2
2
|
import { onAbort, untilAborted } from "../../utils/deadline.js";
|
|
3
|
+
import { McpUnavailableError } from "../../utils/errors.js";
|
|
3
4
|
import { configFingerprint } from "../config-fingerprint.js";
|
|
5
|
+
import { hostToolSessions, refuseHostName, } from "../host-tools.js";
|
|
4
6
|
import { IDLE_TIMEOUT_MS } from "../process-pool.js";
|
|
5
7
|
import { SessionAgent } from "../session-agent.js";
|
|
6
8
|
import { CodexAppServerClient, } from "./client.js";
|
|
@@ -55,6 +57,7 @@ export class CodexAppServerAgent extends SessionAgent {
|
|
|
55
57
|
processes;
|
|
56
58
|
timing;
|
|
57
59
|
sessions;
|
|
60
|
+
host;
|
|
58
61
|
login = new CodexCliLogin({
|
|
59
62
|
connect: (env) => this.connect({ cwd: process.cwd(), ...(env && { env }) }, { experimentalApi: false }),
|
|
60
63
|
cliPath: async () => (await this.cliPath()) ?? "codex",
|
|
@@ -87,6 +90,9 @@ export class CodexAppServerAgent extends SessionAgent {
|
|
|
87
90
|
inheritConfig: agentOptions.inheritConfig,
|
|
88
91
|
builtInTools: agentOptions.builtInTools,
|
|
89
92
|
});
|
|
93
|
+
this.host = hostToolSessions(agentOptions.hostTools, this.harness, {
|
|
94
|
+
live: (sessionId) => this.sessions.live(sessionId),
|
|
95
|
+
});
|
|
90
96
|
}
|
|
91
97
|
/** On a product's credentials, each session may list as a different account. */
|
|
92
98
|
get modelsPerSession() {
|
|
@@ -100,6 +106,7 @@ export class CodexAppServerAgent extends SessionAgent {
|
|
|
100
106
|
signal,
|
|
101
107
|
items: new TurnItems(),
|
|
102
108
|
mode: options.permissionMode ?? "default",
|
|
109
|
+
turnId: options.turnId,
|
|
103
110
|
};
|
|
104
111
|
let session;
|
|
105
112
|
let stop;
|
|
@@ -129,7 +136,8 @@ export class CodexAppServerAgent extends SessionAgent {
|
|
|
129
136
|
const predecessor = this.sessions.stopUnsettled(options.sessionId);
|
|
130
137
|
if (predecessor && !(await predecessor))
|
|
131
138
|
throw new Error("Previous Codex execution has not stopped");
|
|
132
|
-
const
|
|
139
|
+
const host = await untilAborted(this.hostServer(options), signal);
|
|
140
|
+
const mcp = this.sessions.mcpFor(options, host);
|
|
133
141
|
scope.auth = await authFor({
|
|
134
142
|
credentials: this.agentOptions.credentials,
|
|
135
143
|
sessionId: options.sessionId,
|
|
@@ -188,6 +196,29 @@ export class CodexAppServerAgent extends SessionAgent {
|
|
|
188
196
|
this.sessions.leave(options.sessionId, session, scope);
|
|
189
197
|
}
|
|
190
198
|
}
|
|
199
|
+
hostSecret(sessionId) {
|
|
200
|
+
return this.host?.secretOf(sessionId);
|
|
201
|
+
}
|
|
202
|
+
/** The host's server for the session, by the name its source gives, when it has one. */
|
|
203
|
+
async hostServer(options) {
|
|
204
|
+
const lease = await this.host?.lease(options.sessionId, options.cwd);
|
|
205
|
+
if (!lease)
|
|
206
|
+
return undefined;
|
|
207
|
+
refuseHostName(options.mcpServers, lease.source.name);
|
|
208
|
+
try {
|
|
209
|
+
return { [lease.source.name]: await lease.http() };
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
// @ref LLP 0018#codex — a loopback that cannot start: the turn goes on without the host's tools, and says so
|
|
213
|
+
if (!(error instanceof McpUnavailableError))
|
|
214
|
+
throw error;
|
|
215
|
+
await options.onWarning?.({
|
|
216
|
+
category: "mcp_unavailable",
|
|
217
|
+
message: `${error.message.split(";")[0]}; the turn goes on without the host's tools`,
|
|
218
|
+
});
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
191
222
|
/**
|
|
192
223
|
* The user's own login, for a turn (or a model list) whose `env` names a
|
|
193
224
|
* home, when the operator set `userLogin`: read again for each, so a login
|
|
@@ -261,10 +292,12 @@ export class CodexAppServerAgent extends SessionAgent {
|
|
|
261
292
|
await super.release(sessionId);
|
|
262
293
|
// @ref LLP 0001#d10--built-in-turns-own-their-logical-session-through-cleanup — released once its process has exited, as a Claude session is
|
|
263
294
|
await this.sessions.release(sessionId);
|
|
295
|
+
this.host?.release(sessionId);
|
|
264
296
|
}
|
|
265
297
|
async terminateAll() {
|
|
266
298
|
await super.terminateAll();
|
|
267
299
|
await this.sessions.terminateAll();
|
|
300
|
+
await this.host?.close();
|
|
268
301
|
}
|
|
269
302
|
/**
|
|
270
303
|
* The CLI to run: the provisioner's, else `$CODEX_CLI_PATH`; PATH's `codex`
|
|
@@ -285,7 +318,7 @@ export class CodexAppServerAgent extends SessionAgent {
|
|
|
285
318
|
const codexPath = (await this.cliPath(signal)) ?? "codex";
|
|
286
319
|
signal?.throwIfAborted();
|
|
287
320
|
const clientOptions = {
|
|
288
|
-
...clientOptionsFor(codexPath, options, auth, experimentalApi, this.agentOptions.inheritConfig),
|
|
321
|
+
...clientOptionsFor(codexPath, options, auth, experimentalApi, this.agentOptions.inheritConfig, this.host !== undefined),
|
|
289
322
|
processes: this.processes,
|
|
290
323
|
...(sessionId !== undefined && { sessionId }),
|
|
291
324
|
};
|
|
@@ -2,12 +2,19 @@ import { clampThinkingLevel } from "../../../protocol/index.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* The effort Codex runs for `level`. `supported` is what the model accepts, in
|
|
4
4
|
* this vocabulary, where `off` stands for its least effort: `offEffort`, the
|
|
5
|
-
* native `none` or `minimal` the model advertises. A level it
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* native `none` or `minimal` the model advertises. A level it lists is sent as
|
|
6
|
+
* it is, and one it lacks is fitted to the nearest level this build can order;
|
|
7
|
+
* when there is none (a level this build does not know, or a model listing
|
|
8
|
+
* none it knows), the level is not applied: `undefined`. Without `supported`,
|
|
9
|
+
* the level is sent as asked, and `off` becomes `low`: no model the pinned CLI
|
|
10
|
+
* lists accepts `none` or `minimal`, and every one accepts `low`.
|
|
8
11
|
*/
|
|
9
12
|
export function codexReasoningEffort(level, supported, offEffort) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
if (supported?.length) {
|
|
14
|
+
const clamped = clampThinkingLevel(level, supported);
|
|
15
|
+
if (clamped === undefined)
|
|
16
|
+
return undefined;
|
|
17
|
+
return clamped === "off" ? (offEffort ?? "minimal") : clamped;
|
|
18
|
+
}
|
|
19
|
+
return level === "off" ? "low" : level;
|
|
13
20
|
}
|
|
@@ -5,7 +5,7 @@ import { configFingerprint } from "../config-fingerprint.js";
|
|
|
5
5
|
import { UnavailableMcpServers, mcpConnectionErrors, settleMcpFailures, snapshotMcpServers, } from "../mcp-config.js";
|
|
6
6
|
import { pages } from "./client.js";
|
|
7
7
|
/** Codex supports stdio and Streamable HTTP, not the legacy SSE transport. */
|
|
8
|
-
function codexMcpServers(servers) {
|
|
8
|
+
export function codexMcpServers(servers) {
|
|
9
9
|
return Object.fromEntries(Object.entries(servers).map(([name, server]) => {
|
|
10
10
|
if (name === "codex_apps")
|
|
11
11
|
throw new Error("MCP server name codex_apps is reserved by Codex");
|
|
@@ -14,13 +14,22 @@ function codexMcpServers(servers) {
|
|
|
14
14
|
}
|
|
15
15
|
return [
|
|
16
16
|
name,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
{
|
|
18
|
+
...(server.type === "stdio"
|
|
19
|
+
? {
|
|
20
|
+
command: server.command,
|
|
21
|
+
...(server.args && { args: server.args }),
|
|
22
|
+
...(server.env && { env: server.env }),
|
|
23
|
+
}
|
|
24
|
+
: { url: server.url, ...(server.headers && { http_headers: server.headers }) }),
|
|
25
|
+
// Whole seconds, rounded up (1118 ms becomes 2 s): Codex reads a fraction
|
|
26
|
+
// back as a float (1.118 as 1.1179999999999999, Codex 0.160.0), which a
|
|
27
|
+
// home's read-back takes for an override; an integer reads back unchanged.
|
|
28
|
+
// The thread's config and its fingerprint take this same value.
|
|
29
|
+
...(server.timeoutMs !== undefined && {
|
|
30
|
+
tool_timeout_sec: Math.ceil(server.timeoutMs / 1000),
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
24
33
|
];
|
|
25
34
|
}));
|
|
26
35
|
}
|
|
@@ -177,13 +186,21 @@ async function settleCodexMcp(client, threadId, servers, causes) {
|
|
|
177
186
|
updates.end();
|
|
178
187
|
}
|
|
179
188
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
189
|
+
// @ref LLP 0018#codex — the host's server rides the thread, never a home's config file
|
|
190
|
+
/**
|
|
191
|
+
* The turn's servers, snapshotted before anything asynchronous can let the
|
|
192
|
+
* caller change them. The host's server goes in the thread's own config
|
|
193
|
+
* whether or not the turn names a home: its secret is never written to disk.
|
|
194
|
+
*/
|
|
195
|
+
export function codexTurnMcp(options, homes, host = {}) {
|
|
196
|
+
const turn = snapshotMcpServers(options.mcpServers);
|
|
197
|
+
const wire = { ...turn, ...host };
|
|
198
|
+
const servers = codexMcpServers(turn);
|
|
199
|
+
const own = codexMcpServers(host);
|
|
184
200
|
if (homes.claim(options))
|
|
185
|
-
return { wire, servers };
|
|
186
|
-
|
|
201
|
+
return Object.keys(own).length ? { wire, servers, thread: own } : { wire, servers };
|
|
202
|
+
const thread = { ...servers, ...own };
|
|
203
|
+
return Object.keys(thread).length ? { wire, thread } : { wire };
|
|
187
204
|
}
|
|
188
205
|
// @ref LLP 0001#d21--a-codex-turn-that-names-no-home-carries-its-mcp-servers-in-its-thread — a thread's config is fixed once it is open
|
|
189
206
|
/**
|
|
@@ -257,9 +274,9 @@ export class CodexMcpState {
|
|
|
257
274
|
* Read before the thread opens, so no connection is made first, and
|
|
258
275
|
* before each turn.
|
|
259
276
|
*/
|
|
260
|
-
async threadServers({
|
|
261
|
-
// A home the turn names holds the turn's servers, written there.
|
|
262
|
-
if (
|
|
277
|
+
async threadServers({ thread }) {
|
|
278
|
+
// A home the turn names holds the turn's servers, written there; the thread only the host's.
|
|
279
|
+
if (!thread)
|
|
263
280
|
return undefined;
|
|
264
281
|
const result = (await this.client.request("config/read", { cwd: this.cwd }));
|
|
265
282
|
assertCodexThreadMcp(result.config?.mcp_servers ?? {}, thread);
|
|
@@ -276,7 +293,7 @@ export class CodexMcpState {
|
|
|
276
293
|
// down), or at once when this turn requires it: its old failure must
|
|
277
294
|
// not decide. So is every server after a turn whose servers did not settle.
|
|
278
295
|
const again = this.unavailable.retryNow(mcp.wire).length > 0 || this.unsettled;
|
|
279
|
-
const started = mcp.
|
|
296
|
+
const started = mcp.servers === undefined
|
|
280
297
|
? await this.startThreadServers(again)
|
|
281
298
|
: await this.startHomeServers(mcp, again);
|
|
282
299
|
let unavailable;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { isThinkingLevel } from "../../../protocol/index.js";
|
|
2
1
|
import { onAbort } from "../../utils/deadline.js";
|
|
3
|
-
import {
|
|
2
|
+
import { listedThinkingLevels } from "../thinking-levels.js";
|
|
4
3
|
import { pages } from "./client.js";
|
|
5
4
|
const MODEL_LIST_TIMEOUT_MS = 5_000;
|
|
6
5
|
/** How many pages of `model/list` are read; Codex lists a dozen models in one. */
|
|
7
6
|
const MODEL_LIST_PAGES = 10;
|
|
8
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* The level a native Codex effort is: `none` and `minimal` are `off`, and any
|
|
9
|
+
* other effort is a level of its own name, known to this build or not.
|
|
10
|
+
*/
|
|
9
11
|
export function codexThinkingLevel(effort) {
|
|
10
12
|
if (effort === "none" || effort === "minimal")
|
|
11
13
|
return "off";
|
|
12
|
-
return typeof effort === "string" && effort !== "off" &&
|
|
13
|
-
? effort
|
|
14
|
-
: undefined;
|
|
14
|
+
return typeof effort === "string" && effort !== "off" && /\S/.test(effort) ? effort : undefined;
|
|
15
15
|
}
|
|
16
16
|
function efforts(model) {
|
|
17
17
|
return Array.isArray(model.supportedReasoningEfforts)
|
|
@@ -29,8 +29,8 @@ async function readCodexModels(client) {
|
|
|
29
29
|
* What each model accepts, by its `model` and `id`. Codex's `none` or
|
|
30
30
|
* `minimal` is `off`, remembered so `off` sends the value the model
|
|
31
31
|
* advertised (`none` when it offers both). A model that lists no efforts at
|
|
32
|
-
* all has none (`levels: []`); one that
|
|
33
|
-
*
|
|
32
|
+
* all has none (`levels: []`); one that says nothing is left out, so what it
|
|
33
|
+
* accepts stays unknown.
|
|
34
34
|
*/
|
|
35
35
|
function codexModelThinking(models) {
|
|
36
36
|
const thinking = new Map();
|
|
@@ -41,7 +41,7 @@ function codexModelThinking(models) {
|
|
|
41
41
|
: native.includes("minimal")
|
|
42
42
|
? "minimal"
|
|
43
43
|
: undefined;
|
|
44
|
-
const levels =
|
|
44
|
+
const levels = listedThinkingLevels(native.map(codexThinkingLevel));
|
|
45
45
|
const none = Array.isArray(model.supportedReasoningEfforts) && native.length === 0;
|
|
46
46
|
if (!levels.length && !none)
|
|
47
47
|
continue;
|
|
@@ -110,7 +110,7 @@ export function codexModelDescriptors(models, harness, configuredModel) {
|
|
|
110
110
|
const id = typeof model.model === "string" ? model.model : model.id;
|
|
111
111
|
if (typeof id !== "string" || model.hidden === true)
|
|
112
112
|
return [];
|
|
113
|
-
const levels =
|
|
113
|
+
const levels = listedThinkingLevels(efforts(model).map(codexThinkingLevel));
|
|
114
114
|
const fallback = codexThinkingLevel(model.defaultReasoningEffort);
|
|
115
115
|
return [
|
|
116
116
|
{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { configFingerprint, directoriesFingerprint } from "../config-fingerprint.js";
|
|
2
|
+
import { withLoopbackDirect } from "../host-tools.js";
|
|
2
3
|
/**
|
|
3
4
|
* Why a turn without tools (`disableTools`) fails on Codex. With every
|
|
4
5
|
* feature that offers one turned off, Codex 0.160 still gives a code-mode
|
|
@@ -67,11 +68,15 @@ export function codexSessionCompatible(existing, options) {
|
|
|
67
68
|
* How the harness starts `codex app-server` for a folder, its `env` and a
|
|
68
69
|
* login, at the operator's `inheritConfig`.
|
|
69
70
|
*/
|
|
70
|
-
export function clientOptionsFor(codexPath, { cwd, env }, auth, experimentalApi, inheritConfig = "all"
|
|
71
|
+
export function clientOptionsFor(codexPath, { cwd, env }, auth, experimentalApi, inheritConfig = "all",
|
|
72
|
+
/** The engine serves host tools on loopback: reach it directly, past any proxy. */
|
|
73
|
+
loopback = false) {
|
|
74
|
+
const base = env ? { ...process.env, ...env } : process.env;
|
|
71
75
|
return {
|
|
72
76
|
codexPath,
|
|
73
77
|
cwd,
|
|
74
|
-
|
|
78
|
+
// @ref LLP 0018#codex — the bearer never travels through a proxy
|
|
79
|
+
env: loopback ? withLoopbackDirect(base) : base,
|
|
75
80
|
...(experimentalApi && { experimentalApi: true }),
|
|
76
81
|
...(auth && { ephemeralCredentials: true }),
|
|
77
82
|
// @ref LLP 0001#d17--a-turn-inherits-what-the-operator-chooses-all-the-projects-or-none — a session's home loads no plugins
|
|
@@ -110,6 +115,10 @@ export function threadParams(options, policy = {}, mcpServers) {
|
|
|
110
115
|
if (tools.local === false) {
|
|
111
116
|
features.shell_tool = false;
|
|
112
117
|
features.unified_exec = false;
|
|
118
|
+
// @ref LLP 0017#each-turn-names-its-environments — view_image has a switch, apply_patch none
|
|
119
|
+
// Since 0.164 Codex lists `view_image` and `apply_patch` whatever a turn's environments:
|
|
120
|
+
// this takes the first away, and `environments: []` refuses a call to the second.
|
|
121
|
+
features.view_image = false;
|
|
113
122
|
}
|
|
114
123
|
if (tools.imageGeneration === false)
|
|
115
124
|
features.image_generation = false;
|
|
@@ -60,7 +60,7 @@ export async function* askPlan(turn, native) {
|
|
|
60
60
|
kind: CODEX_TOOL_KINDS.plan,
|
|
61
61
|
title: PLAN_TITLE,
|
|
62
62
|
rawInput: { plan: offered.text },
|
|
63
|
-
}, { signal: asking.signal, options: PLAN_OPTIONS });
|
|
63
|
+
}, { signal: asking.signal, options: PLAN_OPTIONS, purpose: "plan" });
|
|
64
64
|
}
|
|
65
65
|
finally {
|
|
66
66
|
offAbort();
|
|
@@ -4,7 +4,7 @@ import { ProcessPool } from "../process-pool.js";
|
|
|
4
4
|
import { authFingerprint, logIn } from "./credentials.js";
|
|
5
5
|
import { CodexHomes, holdHome, homeIdentity } from "./homes.js";
|
|
6
6
|
import { codexLoginMark, codexLoginStore } from "./login.js";
|
|
7
|
-
import { CodexMcpState, codexTurnMcp, threadServersFingerprint } from "./mcp.js";
|
|
7
|
+
import { CodexMcpState, codexTurnMcp, threadServersFingerprint, } from "./mcp.js";
|
|
8
8
|
import { codexSessionCompatible, processIdentity, threadParams, } from "./options.js";
|
|
9
9
|
import { bindServerRequests } from "./requests.js";
|
|
10
10
|
import { CodexThread } from "./thread-settings.js";
|
|
@@ -76,9 +76,16 @@ export class CodexSessions {
|
|
|
76
76
|
get(sessionId) {
|
|
77
77
|
return this.pool.get(sessionId);
|
|
78
78
|
}
|
|
79
|
-
/** The turn's MCP servers, in the `CODEX_HOME` the session claims when the turn names one. */
|
|
80
|
-
mcpFor(options) {
|
|
81
|
-
return codexTurnMcp(options, this.homes);
|
|
79
|
+
/** The turn's MCP servers, in the `CODEX_HOME` the session claims when the turn names one, and the host's. */
|
|
80
|
+
mcpFor(options, host) {
|
|
81
|
+
return codexTurnMcp(options, this.homes, host);
|
|
82
|
+
}
|
|
83
|
+
/** The turn the session runs now, and its mode, for a host tool's caller. */
|
|
84
|
+
live(sessionId) {
|
|
85
|
+
const turn = this.pool.get(sessionId)?.turn;
|
|
86
|
+
return turn?.turnId
|
|
87
|
+
? { turnId: turn.turnId, permissionMode: turn.mode, signal: turn.signal }
|
|
88
|
+
: undefined;
|
|
82
89
|
}
|
|
83
90
|
/**
|
|
84
91
|
* The session's process for the turn, which takes it (the pool's rule):
|