aiterm-mcp 0.70.60 → 0.70.62
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 +11 -1
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/dist/agent-metadata-reader.js +9 -5
- package/dist/core.js +46 -9
- package/dist/harnesses/caller-mcp.js +64 -3
- package/dist/harnesses/claude.js +20 -1
- package/dist/harnesses/codex.js +5 -2
- package/dist/index.js +16 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.70.62] - 2026-11-15
|
|
11
|
+
|
|
12
|
+
- A caller MCP server (`mcp_config`) no longer replaces a server the seat's own harness config already defines under the same name. Without a flag the caller entry is dropped and the seat still launches. A server entry may say `"replace": true` (a boolean) to replace that server knowingly. The launch receipt carries `caller_mcp: {dropped, replaced}` whenever `mcp_config` is given. The own config is read on the machine that runs the seat: Claude user, local and project scope; Codex and Grok `config.toml`; Antigravity `~/.gemini/config/mcp_config.json` and `<cwd>/.agents/mcp_config.json`. Cursor already ran caller servers beside its own. A resume keeps its launch's dropped names. A terminal below 0.70.62 gets the config without `replace` keys and keeps its old precedence (launch-identity-input.md "Caller name precedence", a138).
|
|
13
|
+
|
|
14
|
+
## [0.70.61] - 2026-11-14
|
|
15
|
+
|
|
16
|
+
- `pty_list` no longer fails for every seat when one saved seat's record is unreadable or was removed by a close between the directory read and the record read (BugHub d90f8b67: BellTeam's Bot list answered 500). That seat is left out; the rows of the others are unchanged.
|
|
17
|
+
|
|
10
18
|
## [0.70.60] - 2026-11-14
|
|
11
19
|
|
|
12
20
|
- Removed `configureNativeExecutionHooks` and the `aiterm-mcp/execution-native-setup` entry point (bd14). BellTeam writes the CLI files itself from `aiterm-setup harness-entries --json` since body 2c948242, and no branch calls the old writer (Molly 2026-11-14). An older body keeps working: it uses the Aiterm installed in its own image. `setup-integrations` stays for BellTeam's fallback branch. The standalone `aiterm-setup` is unchanged.
|
|
@@ -3490,7 +3498,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
|
|
|
3490
3498
|
`ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
|
|
3491
3499
|
provenance.
|
|
3492
3500
|
|
|
3493
|
-
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.
|
|
3501
|
+
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.62...HEAD
|
|
3502
|
+
[0.70.62]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.61...v0.70.62
|
|
3503
|
+
[0.70.61]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.60...v0.70.61
|
|
3494
3504
|
[0.70.60]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.59...v0.70.60
|
|
3495
3505
|
[0.70.59]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.58...v0.70.59
|
|
3496
3506
|
[0.70.58]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.57...v0.70.58
|
package/README.ja.md
CHANGED
|
@@ -215,7 +215,7 @@ runtime-error store は canonical dotagents config の `collection.enabled: true
|
|
|
215
215
|
場合だけ収集し、既定OFF、network送信は行いません。tag起点CIのnpm provenance(OIDC Trusted
|
|
216
216
|
Publishing)で公開し、GitHub Release が Official MCP Registry を再登録します。
|
|
217
217
|
|
|
218
|
-
**状態:** 開発継続中 · 現行公開版 **v0.70.
|
|
218
|
+
**状態:** 開発継続中 · 現行公開版 **v0.70.62** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
|
|
219
219
|
|
|
220
220
|
### 更新と巻き戻し
|
|
221
221
|
|
package/README.md
CHANGED
|
@@ -227,7 +227,7 @@ collection is off by default and performs no network I/O. It ships via
|
|
|
227
227
|
tag-triggered CI with npm provenance (OIDC Trusted Publishing); the GitHub
|
|
228
228
|
Release re-registers the Official MCP Registry entry.
|
|
229
229
|
|
|
230
|
-
**Status:** actively maintained · current public release **v0.70.
|
|
230
|
+
**Status:** actively maintained · current public release **v0.70.62** · runs on Linux · WSL2 · macOS · native Windows (tmux on POSIX, the tmux-CLI-compatible [psmux](https://github.com/psmux/psmux) on native Windows — no WSL required) · MIT · see the [CHANGELOG](CHANGELOG.md).
|
|
231
231
|
|
|
232
232
|
### Update and rollback
|
|
233
233
|
|
|
@@ -123,6 +123,10 @@ export function loadAgentMetadata(name) {
|
|
|
123
123
|
...(typeof m.fast === "boolean" ? { fast: m.fast } : {}),
|
|
124
124
|
...(typeof m.model === "string" || m.model === null ? { model: m.model } : {}),
|
|
125
125
|
};
|
|
126
|
+
// Caller name precedence (launch-identity-input.md): what the launch dropped or replaced, kept for the receipt and a resume.
|
|
127
|
+
const names = (v) => Array.isArray(v) && v.every(name => typeof name === "string");
|
|
128
|
+
const callerMcpFields = m.caller_mcp && names(m.caller_mcp.dropped) && names(m.caller_mcp.replaced)
|
|
129
|
+
? { caller_mcp: { dropped: m.caller_mcp.dropped, replaced: m.caller_mcp.replaced } } : {};
|
|
126
130
|
const startupShapes = Array.isArray(m.startup_process_shapes) && m.startup_process_shapes.every((shape) => shape && typeof shape.identity === "string" && (shape.parent === null || typeof shape.parent === "string") && typeof shape.argv_digest === "string")
|
|
127
131
|
? { startup_process_shapes: m.startup_process_shapes } : {};
|
|
128
132
|
const startupFields = Array.isArray(m.startup_processes) && m.startup_processes.every((identity) => typeof identity === "string")
|
|
@@ -137,7 +141,7 @@ export function loadAgentMetadata(name) {
|
|
|
137
141
|
hook_route: "shared_antigravity_home", antigravity_home: m.antigravity_home, node_platform: process.platform,
|
|
138
142
|
...(typeof m.write_scope === "string" ? { write_scope: m.write_scope } : {}),
|
|
139
143
|
...(m.antigravity_caller_mcp_dir === agentAntigravityCallerDir(name) ? { antigravity_caller_mcp_dir: m.antigravity_caller_mcp_dir } : {}),
|
|
140
|
-
...deliveryFields, ...executableFields, ...fastFields, ...startupFields, ...loadAgentLineageFields(m, true) };
|
|
144
|
+
...deliveryFields, ...executableFields, ...fastFields, ...callerMcpFields, ...startupFields, ...loadAgentLineageFields(m, true) };
|
|
141
145
|
}
|
|
142
146
|
if (m.kind === "claude") {
|
|
143
147
|
const expectedSettings = agentManagedClaudeSettingsPath(name, m.launch_id);
|
|
@@ -168,7 +172,7 @@ export function loadAgentMetadata(name) {
|
|
|
168
172
|
initial_prompt: normalizeInitialPromptState(m.initial_prompt),
|
|
169
173
|
...deliveryFields,
|
|
170
174
|
...executableFields,
|
|
171
|
-
...fastFields,
|
|
175
|
+
...fastFields, ...callerMcpFields,
|
|
172
176
|
...resumeFields,
|
|
173
177
|
...startupFields,
|
|
174
178
|
launch_operation_id: launchOperationId,
|
|
@@ -206,7 +210,7 @@ export function loadAgentMetadata(name) {
|
|
|
206
210
|
initial_prompt: normalizeInitialPromptState(m.initial_prompt),
|
|
207
211
|
...deliveryFields,
|
|
208
212
|
...executableFields,
|
|
209
|
-
...fastFields,
|
|
213
|
+
...fastFields, ...callerMcpFields,
|
|
210
214
|
...resumeFields,
|
|
211
215
|
...startupFields,
|
|
212
216
|
hook_route: "shared_codex_home",
|
|
@@ -238,7 +242,7 @@ export function loadAgentMetadata(name) {
|
|
|
238
242
|
initial_prompt: normalizeInitialPromptState(m.initial_prompt),
|
|
239
243
|
...deliveryFields,
|
|
240
244
|
...executableFields,
|
|
241
|
-
...fastFields,
|
|
245
|
+
...fastFields, ...callerMcpFields,
|
|
242
246
|
...resumeFields,
|
|
243
247
|
...startupFields,
|
|
244
248
|
hook_route: "shared_cursor_home",
|
|
@@ -278,7 +282,7 @@ export function loadAgentMetadata(name) {
|
|
|
278
282
|
initial_prompt: normalizeInitialPromptState(m.initial_prompt),
|
|
279
283
|
...deliveryFields,
|
|
280
284
|
...executableFields,
|
|
281
|
-
...fastFields,
|
|
285
|
+
...fastFields, ...callerMcpFields,
|
|
282
286
|
...startupFields,
|
|
283
287
|
hook_route: "shared_grok_home",
|
|
284
288
|
completion_route: "grok_transcript",
|
package/dist/core.js
CHANGED
|
@@ -26,9 +26,10 @@ import { spawnSync } from "node:child_process";
|
|
|
26
26
|
import * as fs from "node:fs";
|
|
27
27
|
import { z } from "zod";
|
|
28
28
|
import * as path from "node:path";
|
|
29
|
+
import * as os from "node:os";
|
|
29
30
|
import { createHash, randomBytes } from "node:crypto";
|
|
30
31
|
import { launchEnvValue } from "./private-env.js";
|
|
31
|
-
import { assertCallerEnv } from "./harnesses/caller-mcp.js";
|
|
32
|
+
import { applyCallerPrecedence, assertCallerEnv, jsonMcpServerNames, tomlMcpServerNames } from "./harnesses/caller-mcp.js";
|
|
32
33
|
import { fileURLToPath } from "node:url";
|
|
33
34
|
import * as rtk from "./rtk.js";
|
|
34
35
|
import { manageClaudeAgentGoal, manageGrokAgentGoal } from "./agent-goal-native-result.js";
|
|
@@ -69,7 +70,7 @@ import { readFileOrNull, restoreJsonSetting, withUserConfigLock, restoreUserDefa
|
|
|
69
70
|
import { isDeepStrictEqual } from "node:util";
|
|
70
71
|
import { grokAuthPlan, grokAuthStatus, grokAuthPane, GROK_MODEL_DEFAULTS, realGrokHome, resolveAndValidateGrokAuth, assertGrokModelAvailable, grokModelChoices, grokModelFromFooter, grokFooterModelName, grokModelDefaultsFromBody, restoreGrokModelDefaults, grokEventsTranscript, grokSessionDirectory, latestGrokCompletion, grokTurnSettled, observeGrokDone, buildGrokAgentCmd, grokAgentArgv, writeGrokCallerFiles, checkGrokCallerInput, grokLaunchNote, grokEnvTokens, grokEnvEntries, grokTuiReady, grokPaneObservation, GROK_INTERRUPT_KEY, grokRateLimitDialog, grokPromptAwaitingAccept, grokUnacceptedPromptRestored, grokStartupAction, grokFooterHasConfiguration, grokTranscriptText, createGrokAgentMetadata, } from "./harnesses/grok.js";
|
|
71
72
|
import { codexAuthPlan, codexAuthStatus, codexAuthPane, realCodexHome, readCodexConfigPins, bindCodexTranscriptSession, latestCodexCompletion, codexTurnSettled, codexCompletedTurnId, codexWorkingResumeConfiguration, captureCodexRecoveryProof, captureCodexResumeProof, readCodexResumeProof, codexResumeProofDigest, codexRootTranscript, codexRolloutSessionId, codexRunningTurn, codexInterruptionRecord, observeCodexDone, buildCodexAgentCmd, codexAgentArgv, codexResumeArgv, writeCodexCallerFiles, refuseCodexCallerInput, codexLaunchNote, codexPaneObservation, CODEX_INTERRUPT_KEY, codexHelperProcess, codexRateLimitModelSwitchDialog, codexApprovalDialog, codexStartupAction, codexModelChoice, codexEffortChoice, codexMoreReasoningChoice, codexTranscriptText, createCodexAgentMetadata, codexModelChoices, codexFastCommandOffered, codexFooterShowsFast, codexServiceTierNotices, restoreCodexDefaults, restoreCodexDefaultInFile, } from "./harnesses/codex.js";
|
|
72
|
-
import { claudeAuthPlan, claudeAuthStatus, claudeAuthPane, claudeOauthTokenFile, claudeSetupTokenPlan, claudeOauthToken, claudeOauthTokenPresent, writeClaudeOauthToken, OPERATION_ID_RE, CLAUDE_RESULT_MAX_BYTES, CLAUDE_EFFORTS, agentClaudeOperationPath, agentClaudeApprovalReceiptPath, agentClaudeDispatchReceiptPath, validateOperationId, readClaudeResultText, claudeModelChoices, claudeConfigDir, claudeProjectSlug, claudeFastIndicatorShown, claudeFastResult, buildClaudeAgentCmd, claudeAgentArgv, claudeResumeArgv, claudeLaunchNote, claudePaneObservation, CLAUDE_INTERRUPT_KEY, claudeUsageLimit, claudeLiveSelectMenu, claudeStartupAction, createClaudeAgentMetadata, writeClaudeCallerFiles, claudeSessionTranscriptPath, claudeApiErrorFromLine, claudeApiErrorAfter, claudeLimitEnd, claudeInterruptedAfter, claudeLimitResetAt, claudeApiErrorEndingTurn, claudeFailureCategory, } from "./harnesses/claude.js";
|
|
73
|
+
import { claudeAuthPlan, claudeAuthStatus, claudeAuthPane, claudeOauthTokenFile, claudeSetupTokenPlan, claudeOauthToken, claudeOauthTokenPresent, writeClaudeOauthToken, OPERATION_ID_RE, CLAUDE_RESULT_MAX_BYTES, CLAUDE_EFFORTS, agentClaudeOperationPath, agentClaudeApprovalReceiptPath, agentClaudeDispatchReceiptPath, validateOperationId, readClaudeResultText, claudeModelChoices, claudeConfigDir, claudeProjectSlug, claudeFastIndicatorShown, claudeFastResult, buildClaudeAgentCmd, claudeAgentArgv, claudeResumeArgv, claudeLaunchNote, claudePaneObservation, CLAUDE_INTERRUPT_KEY, claudeUsageLimit, claudeLiveSelectMenu, claudeStartupAction, createClaudeAgentMetadata, writeClaudeCallerFiles, claudeSessionTranscriptPath, claudeApiErrorFromLine, claudeApiErrorAfter, claudeLimitEnd, claudeInterruptedAfter, claudeLimitResetAt, claudeApiErrorEndingTurn, claudeFailureCategory, claudeOwnMcpNames, } from "./harnesses/claude.js";
|
|
73
74
|
import { cursorAuthPlan, cursorAuthStatus, cursorAuthPane, bindCursorTranscriptSession, cursorTurnBoundary, latestCursorCompletion, cursorTranscript, cursorTranscriptSessionId, observeCursorDone, cursorTranscriptText, assertCursorAuthenticationReady, assertCursorModelAvailable, cursorModelChoices, cursorModelIsFastVariant, cursorFastParameter, cursorHeaderShowsFast, cursorPickerView, cursorEffortSelected, cursorParameterRows, cursorUserConfigPath, CURSOR_DEFAULT_MODEL_KEYS, realCursorHome, buildCursorAgentCmd, cursorAgentArgv, cursorPromptWithLineage, cursorLineagePreface, writeCursorCallerFiles, checkCursorCallerInput, createCursorAgentMetadata, cursorLaunchNote, cursorEffortNavigation, cursorTuiReady, cursorPaneObservation, CURSOR_INTERRUPT_KEY, cursorPromptHooksRunning, cursorUsageLimit, CURSOR_SUBMIT_SEQUENCE, validateCursorModelEffort, } from "./harnesses/cursor.js";
|
|
74
75
|
import { interimFromNow, interimFromToken, readInterimWords, recordInterimBoundary } from "./interim-words.js";
|
|
75
76
|
import { codexSeatAwaitingRollout, codexSeatTurn, grokSteerAcceptance, observeSteerDone, readSteerEntry, recordSteer } from "./steer-follow.js";
|
|
@@ -2494,8 +2495,8 @@ export function listSessionsResult(envKeys = [], runTmux = tmux, o = {}) {
|
|
|
2494
2495
|
const result = listNativeSessionsResult(envKeys, runTmux);
|
|
2495
2496
|
const present = new Set(result.sessions.map(row => row.session_id));
|
|
2496
2497
|
for (const name of savedAgentSessionNames()) {
|
|
2497
|
-
//
|
|
2498
|
-
const meta =
|
|
2498
|
+
// An unreadable record, or one a close removed after the readdir, drops only that seat; the list still answers (BugHub d90f8b67).
|
|
2499
|
+
const meta = tryLoadAgentMetadata(name);
|
|
2499
2500
|
if (!meta)
|
|
2500
2501
|
continue;
|
|
2501
2502
|
const state = agentDormantState(meta);
|
|
@@ -8382,15 +8383,22 @@ function prepareAgentLaunch(kind, opts = {}) {
|
|
|
8382
8383
|
if (hasExecutionCreationScope())
|
|
8383
8384
|
meta.execution_native = executionCreatedNativeBinding(sid);
|
|
8384
8385
|
meta.agent_executable = bin;
|
|
8386
|
+
// Caller name precedence: a server the seat's own config defines stays its own unless the entry says replace.
|
|
8387
|
+
let callerMcp = opts.mcp_config ?? null;
|
|
8388
|
+
if (callerMcp !== null) {
|
|
8389
|
+
const applied = applyCallerPrecedence(callerMcp, ownMcpNames(meta, claudeEnv));
|
|
8390
|
+
callerMcp = applied.config;
|
|
8391
|
+
meta.caller_mcp = applied.precedence;
|
|
8392
|
+
}
|
|
8385
8393
|
if (meta.kind === "claude")
|
|
8386
|
-
writeClaudeCallerFiles(meta, opts.append_system_prompt ?? null,
|
|
8394
|
+
writeClaudeCallerFiles(meta, opts.append_system_prompt ?? null, callerMcp);
|
|
8387
8395
|
if (meta.kind === "codex")
|
|
8388
|
-
writeCodexCallerFiles(meta, opts.append_system_prompt ?? null,
|
|
8396
|
+
writeCodexCallerFiles(meta, opts.append_system_prompt ?? null, callerMcp);
|
|
8389
8397
|
if (meta.kind === "grok" || meta.kind === "cursor" || meta.kind === "antigravity") {
|
|
8390
8398
|
// The seat's own environment: what ${NAME} in a header resolves to (and what a harness reads at run time).
|
|
8391
8399
|
const seatEnv = new Map(agentEnvEntries(meta, sid, envVars));
|
|
8392
8400
|
const write = meta.kind === "grok" ? writeGrokCallerFiles : meta.kind === "cursor" ? writeCursorCallerFiles : writeAntigravityCallerFiles;
|
|
8393
|
-
write(meta, opts.append_system_prompt ?? null,
|
|
8401
|
+
write(meta, opts.append_system_prompt ?? null, callerMcp, name => seatEnv.get(name));
|
|
8394
8402
|
}
|
|
8395
8403
|
if (opts.fork_of)
|
|
8396
8404
|
meta.fork_of = opts.fork_of;
|
|
@@ -8629,10 +8637,35 @@ export function resolveForkSource(kind, from, opts, probe = probeWriteBan) {
|
|
|
8629
8637
|
return { fork_of: { session_id: from.session_id, vendor_session_id: mainVendorId, ...(from.fork_id ? { fork_id: from.fork_id } : {}),
|
|
8630
8638
|
write_ban, ...(first_input ? { first_input } : {}) }, cwd: main.cwd, ...(root ? { root } : {}) };
|
|
8631
8639
|
}
|
|
8640
|
+
/** Names the seat's own harness config defines (launch-identity-input.md "Caller name precedence"). Cursor runs a caller
|
|
8641
|
+
* server as plugin-aiterm-caller-<name> beside its own, so nothing collides there. */
|
|
8642
|
+
function ownMcpNames(meta, claudeEnv) {
|
|
8643
|
+
const cwd = meta.cwd ?? process.cwd();
|
|
8644
|
+
if (meta.kind === "claude")
|
|
8645
|
+
return claudeOwnMcpNames(claudeEnv, cwd);
|
|
8646
|
+
if (meta.kind === "codex")
|
|
8647
|
+
return new Set(tomlMcpServerNames(path.join(meta.codex_home ?? realCodexHome(), "config.toml")));
|
|
8648
|
+
if (meta.kind === "grok")
|
|
8649
|
+
return new Set(tomlMcpServerNames(grokUserConfigPath(meta.grok_home ?? realGrokHome())));
|
|
8650
|
+
if (meta.kind === "antigravity")
|
|
8651
|
+
return new Set([
|
|
8652
|
+
...jsonMcpServerNames(path.join(process.env.HOME ?? os.homedir(), ".gemini", "config", "mcp_config.json")),
|
|
8653
|
+
...jsonMcpServerNames(path.join(cwd, ".agents", "mcp_config.json")),
|
|
8654
|
+
]);
|
|
8655
|
+
return new Set();
|
|
8656
|
+
}
|
|
8632
8657
|
/** Caller launch fields refused from the arguments alone, before any session or file exists (phase "input"). */
|
|
8633
8658
|
function refuseCallerInput(kind, opts) {
|
|
8634
8659
|
if (kind === "codex")
|
|
8635
8660
|
return refuseCodexCallerInput(opts.append_system_prompt, opts.mcp_config);
|
|
8661
|
+
if (kind === "claude" && opts.mcp_config != null) {
|
|
8662
|
+
try {
|
|
8663
|
+
applyCallerPrecedence(opts.mcp_config, new Set());
|
|
8664
|
+
}
|
|
8665
|
+
catch (e) {
|
|
8666
|
+
throw e instanceof AitermError ? launchInputRefusal(agentHarness(kind), e.message) : e;
|
|
8667
|
+
}
|
|
8668
|
+
}
|
|
8636
8669
|
if (kind !== "grok" && kind !== "cursor" && kind !== "antigravity")
|
|
8637
8670
|
return;
|
|
8638
8671
|
try {
|
|
@@ -8732,9 +8765,13 @@ export async function openAgentWithInitialPrompt(kind, opts = {}) {
|
|
|
8732
8765
|
if (opts.mcp_config != null && (kind === "claude" ? previous.claude_caller_mcp_file : previous.codex_caller_mcp_file)) {
|
|
8733
8766
|
const file = (kind === "claude" ? previous.claude_caller_mcp_file : previous.codex_caller_mcp_file);
|
|
8734
8767
|
const serverNames = (config) => Object.keys((config ?? {}).mcpServers ?? {}).sort();
|
|
8735
|
-
|
|
8768
|
+
// The names the launch dropped stay dropped (Caller name precedence): saved + dropped = the caller's names.
|
|
8769
|
+
const dropped = new Set(previous.caller_mcp?.dropped ?? []);
|
|
8770
|
+
if (!isDeepStrictEqual([...serverNames(JSON.parse(fs.readFileSync(file, "utf8"))), ...dropped].sort(), serverNames(opts.mcp_config)))
|
|
8736
8771
|
throw new AitermError("AGENT_RESUME_CONFLICT: 同名の休止席は保存したMCP serverの名前で再開します。", 2);
|
|
8737
|
-
|
|
8772
|
+
const kept = { ...opts.mcp_config, mcpServers: Object.fromEntries(Object.entries((opts.mcp_config.mcpServers ?? {}))
|
|
8773
|
+
.filter(([server]) => !dropped.has(server))) };
|
|
8774
|
+
(kind === "claude" ? writeClaudeCallerFiles : writeCodexCallerFiles)({ ...previous }, null, kept);
|
|
8738
8775
|
}
|
|
8739
8776
|
if (preparedLifecycle)
|
|
8740
8777
|
commitWorkingAgentResume(previous, preparedLifecycle);
|
|
@@ -24,8 +24,10 @@ export function parseCallerMcp(mcp, label) {
|
|
|
24
24
|
const spec = server;
|
|
25
25
|
if (!spec || typeof spec !== "object" || Array.isArray(spec))
|
|
26
26
|
return refuse(`server '${name}' must be an object`);
|
|
27
|
-
if (Object.keys(spec).some(key => !["type", "url", "headers"].includes(key)))
|
|
28
|
-
return refuse(`server '${name}' may only have type, url and
|
|
27
|
+
if (Object.keys(spec).some(key => !["type", "url", "headers", "replace"].includes(key)))
|
|
28
|
+
return refuse(`server '${name}' may only have type, url, headers and replace`);
|
|
29
|
+
if (spec.replace !== undefined && typeof spec.replace !== "boolean")
|
|
30
|
+
return refuse(`server '${name}': replace must be true or false`);
|
|
29
31
|
if (spec.type !== undefined && spec.type !== "http")
|
|
30
32
|
return refuse(`server '${name}': only type 'http' is supported here (got '${String(spec.type)}')`);
|
|
31
33
|
let url = null;
|
|
@@ -56,7 +58,7 @@ export function parseCallerMcp(mcp, label) {
|
|
|
56
58
|
return refuse(`server '${name}': header '${header}' mixes text with \${NAME}; only the whole value or 'Bearer \${NAME}' can be given`);
|
|
57
59
|
return { name: header, kind: "literal", value };
|
|
58
60
|
});
|
|
59
|
-
return { name, url: spec.url, headers };
|
|
61
|
+
return { name, url: spec.url, headers, replace: spec.replace === true };
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
64
|
/** The text and servers of a caller input, or the refusal. `null` mcp -> no servers. */
|
|
@@ -92,3 +94,62 @@ export function writeCallerJson(file, value) {
|
|
|
92
94
|
export function readCallerText(file) {
|
|
93
95
|
return file ? fs.readFileSync(file, "utf8") : null;
|
|
94
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* The caller config the seat gets: an entry whose name the seat's own harness config defines is dropped unless it says
|
|
99
|
+
* `replace: true`. Not a refusal: the seat launches with the rest. Throws only on a `replace` that is not a boolean.
|
|
100
|
+
*/
|
|
101
|
+
export function applyCallerPrecedence(mcp, own) {
|
|
102
|
+
const servers = (mcp.mcpServers ?? {});
|
|
103
|
+
const kept = {};
|
|
104
|
+
const precedence = { dropped: [], replaced: [] };
|
|
105
|
+
for (const [name, server] of Object.entries(servers)) {
|
|
106
|
+
const replace = server?.replace;
|
|
107
|
+
if (replace !== undefined && typeof replace !== "boolean")
|
|
108
|
+
throw new AitermError(`mcp_config server '${name}': replace must be true or false`, 2);
|
|
109
|
+
if (own.has(name))
|
|
110
|
+
(replace === true ? precedence.replaced : precedence.dropped).push(name);
|
|
111
|
+
if (!own.has(name) || replace === true)
|
|
112
|
+
kept[name] = server;
|
|
113
|
+
}
|
|
114
|
+
return { config: { ...mcp, mcpServers: kept }, precedence };
|
|
115
|
+
}
|
|
116
|
+
/** The same config with every `replace` key removed (for a harness file that takes only its own keys). */
|
|
117
|
+
export function withoutReplaceKeys(mcp) {
|
|
118
|
+
const servers = (mcp.mcpServers ?? {});
|
|
119
|
+
return { ...mcp, mcpServers: Object.fromEntries(Object.entries(servers).map(([name, server]) => {
|
|
120
|
+
if (!server || typeof server !== "object" || Array.isArray(server))
|
|
121
|
+
return [name, server];
|
|
122
|
+
const { replace: _replace, ...rest } = server;
|
|
123
|
+
return [name, rest];
|
|
124
|
+
})) };
|
|
125
|
+
}
|
|
126
|
+
/** Keys of `mcpServers` in a JSON file (Claude, Antigravity); a missing or unreadable file names nothing. */
|
|
127
|
+
export function jsonMcpServerNames(file, pick = config => config?.mcpServers) {
|
|
128
|
+
let config;
|
|
129
|
+
try {
|
|
130
|
+
config = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
const servers = pick(config);
|
|
136
|
+
return servers && typeof servers === "object" && !Array.isArray(servers) ? Object.keys(servers) : [];
|
|
137
|
+
}
|
|
138
|
+
/** `[mcp_servers.NAME]` table names in a config.toml (Codex, Grok); a missing file names nothing.
|
|
139
|
+
* shortcut: reads section headers only, an inline-table or dotted-key definition is not seen; upgrade with a TOML parser. */
|
|
140
|
+
export function tomlMcpServerNames(file) {
|
|
141
|
+
let body = "";
|
|
142
|
+
try {
|
|
143
|
+
body = fs.readFileSync(file, "utf8");
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
const names = [];
|
|
149
|
+
for (const line of body.split(/\r?\n/)) {
|
|
150
|
+
const header = /^\s*\[\s*mcp_servers\s*\.\s*(?:"([^"]+)"|'([^']+)'|([A-Za-z0-9_-]+))\s*\]\s*(?:#.*)?$/.exec(line);
|
|
151
|
+
if (header)
|
|
152
|
+
names.push(header[1] ?? header[2] ?? header[3]);
|
|
153
|
+
}
|
|
154
|
+
return names;
|
|
155
|
+
}
|
package/dist/harnesses/claude.js
CHANGED
|
@@ -11,6 +11,7 @@ import { AitermError } from "../errors.js";
|
|
|
11
11
|
import { modeBitsWorldAccessible } from "../tmux-runtime.js";
|
|
12
12
|
import { runAgentProtocolCommand, spawnAgentControlCommand } from "../agent-resolver.js";
|
|
13
13
|
import { claudeCatalogRoot } from "../claude-catalog-root.js";
|
|
14
|
+
import { jsonMcpServerNames, withoutReplaceKeys } from "./caller-mcp.js";
|
|
14
15
|
import { catalogInvalid, catalogUnavailable, checkedCatalog, findJsonLine, processSummary } from "../model-catalog.js";
|
|
15
16
|
import { currentUid, writeJson0600, shq, subagentInstruction, AGENT_DEFAULT_PREFACE, writeScopeLaunchNote, agentEventPath, createEmpty0600, writeAgentMetadata, agentLineageFields, assertSessionName, agentsDir, LAUNCH_ID_RE, AGENT_EVENT_TAIL_BYTES, readFileRange, } from "../agent-shared.js";
|
|
16
17
|
export const OPERATION_ID_RE = /^sha256:[0-9a-f]{64}$/;
|
|
@@ -46,7 +47,7 @@ export function writeClaudeCallerFiles(meta, prompt, mcp) {
|
|
|
46
47
|
if (Object.keys(mcp).some(key => key !== "mcpServers") || !servers || typeof servers !== "object" || Array.isArray(servers))
|
|
47
48
|
throw new AitermError("mcp_config must be {mcpServers: {...}}", 2);
|
|
48
49
|
const file = agentClaudeCallerMcpPath(meta.aiterm_session);
|
|
49
|
-
writeJson0600(file, mcp);
|
|
50
|
+
writeJson0600(file, withoutReplaceKeys(mcp));
|
|
50
51
|
meta.claude_caller_mcp_file = file;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
@@ -705,6 +706,24 @@ export function createClaudeAgentMetadata(name, cwd, initialPrompt, launchOperat
|
|
|
705
706
|
// `type:"assistant", isApiErrorMessage:true, apiErrorStatus:<code>` の1行を書く(実測 2026-09-03、
|
|
706
707
|
// BellTeamのチャイム席で70分の待機を生んだ529)。完了eventだけを待つと永久に running になるため、
|
|
707
708
|
// dispatch後に増えた記録行からこの印を読み、outcome=error として親へ返す。
|
|
709
|
+
/** Names the seat's own Claude config defines (launch-identity-input.md "Caller name precedence"): user scope and local
|
|
710
|
+
* scope in the global config, project scope in `<cwd>/.mcp.json`. `env` is the seat's environment (its CLAUDE_CONFIG_DIR).
|
|
711
|
+
* shortcut: `.mcp.json` is read in the cwd only, not in parent folders; upgrade if seats start below a project root. */
|
|
712
|
+
export function claudeOwnMcpNames(env, cwd) {
|
|
713
|
+
const global = env.CLAUDE_CONFIG_DIR ? path.join(env.CLAUDE_CONFIG_DIR, ".claude.json") : path.join(env.HOME ?? os.homedir(), ".claude.json");
|
|
714
|
+
let real = cwd;
|
|
715
|
+
try {
|
|
716
|
+
real = fs.realpathSync(cwd);
|
|
717
|
+
}
|
|
718
|
+
catch { /* the cwd as given */ }
|
|
719
|
+
// Claude keys local scope by the project path; on Windows with forward slashes.
|
|
720
|
+
const keys = [...new Set([cwd, real, cwd.replace(/\\/g, "/"), real.replace(/\\/g, "/")])];
|
|
721
|
+
return new Set([
|
|
722
|
+
...jsonMcpServerNames(global),
|
|
723
|
+
...keys.flatMap(key => jsonMcpServerNames(global, config => config?.projects?.[key]?.mcpServers)),
|
|
724
|
+
...jsonMcpServerNames(path.join(cwd, ".mcp.json")),
|
|
725
|
+
]);
|
|
726
|
+
}
|
|
708
727
|
export function claudeConfigDir() {
|
|
709
728
|
return process.env.CLAUDE_CONFIG_DIR ?? path.join(process.env.HOME ?? os.homedir(), ".claude");
|
|
710
729
|
}
|
package/dist/harnesses/codex.js
CHANGED
|
@@ -914,6 +914,7 @@ const HEADER_NAME = /^[A-Za-z0-9-]{1,128}$/;
|
|
|
914
914
|
const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
915
915
|
const toml = (value) => JSON.stringify(value); // JSON strings are valid TOML basic strings
|
|
916
916
|
/** `mcp_config` -> one `-c` value per server. Refuses (CODEX_MCP_CONFIG_UNSUPPORTED) what Codex's http server table cannot say.
|
|
917
|
+
* A same-name user server reaches here only with `replace: true` (core.ts drops the others, launch-identity-input.md "Caller name precedence").
|
|
917
918
|
* `userStdio`: names the user's config.toml already defines as stdio servers. `-c` merges key by key into that table and
|
|
918
919
|
* Codex refuses `command` + `url`, so such a server is taken over as stdio running Aiterm's relay to the same url and headers
|
|
919
920
|
* (mcp-http-bridge.ts); the user's other keys of that table (env, cwd, timeouts, enabled_tools) still apply. */
|
|
@@ -928,8 +929,10 @@ export function codexMcpOverrides(mcp, userStdio = new Set()) {
|
|
|
928
929
|
const spec = server;
|
|
929
930
|
if (!spec || typeof spec !== "object" || Array.isArray(spec))
|
|
930
931
|
return refuse(`server '${name}' must be an object`);
|
|
931
|
-
if (Object.keys(spec).some(key => !["type", "url", "headers"].includes(key)))
|
|
932
|
-
return refuse(`server '${name}' may only have type, url and
|
|
932
|
+
if (Object.keys(spec).some(key => !["type", "url", "headers", "replace"].includes(key)))
|
|
933
|
+
return refuse(`server '${name}' may only have type, url, headers and replace`);
|
|
934
|
+
if (spec.replace !== undefined && typeof spec.replace !== "boolean")
|
|
935
|
+
return refuse(`server '${name}': replace must be true or false`);
|
|
933
936
|
if (spec.type !== undefined && spec.type !== "http")
|
|
934
937
|
return refuse(`server '${name}': Codex takes only type 'http' here (got '${String(spec.type)}')`);
|
|
935
938
|
let url = null;
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import { readPrivateEnvLine, setPrivateEnv, privateEnvValue } from "./private-en
|
|
|
23
23
|
import { withTerminalLaunchAction, withErrorCode, launchNotStartedMeta, ERROR_CODE_META } from "./terminal-launch-error.js";
|
|
24
24
|
import { readSeatTurnsOffLoop } from "./seat-turns-worker.js";
|
|
25
25
|
import { codexMcpOverrides } from "./harnesses/codex.js";
|
|
26
|
+
import { withoutReplaceKeys } from "./harnesses/caller-mcp.js";
|
|
26
27
|
import { CallToolRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
27
28
|
import { z } from "zod";
|
|
28
29
|
import { agentModelsResult } from "./model-catalog.js";
|
|
@@ -1341,6 +1342,12 @@ export function createAitermServer(options = {}) {
|
|
|
1341
1342
|
if (!versionAtLeast(version, needs.minimum))
|
|
1342
1343
|
throw new AitermError(`REMOTE_AITERM_TOO_OLD: the remote runs Aiterm ${version}; ${needs.what} needs ${needs.minimum} or later`, 2);
|
|
1343
1344
|
}
|
|
1345
|
+
// An older remote does not know `replace` (Grok, Cursor, Antigravity and Codex refuse the key): it keeps its old
|
|
1346
|
+
// precedence, where every caller server replaces a same-name one, so the key carries nothing there.
|
|
1347
|
+
if (args.mcp_config && JSON.stringify(withoutReplaceKeys(args.mcp_config)) !== JSON.stringify(args.mcp_config)
|
|
1348
|
+
&& !versionAtLeast((target.trusted_ref ? terminalVersions.get(target.trusted_ref) : undefined)
|
|
1349
|
+
?? (await callRemoteTool(target, "pty_list", {}, 60_000)).remote_version ?? "0.0.0", CALLER_REPLACE_MINIMUM_VERSION))
|
|
1350
|
+
args = { ...args, mcp_config: withoutReplaceKeys(args.mcp_config) };
|
|
1344
1351
|
const delivery = args.prompt || args.throughline_source_session ? await deliveryForRequest(extra, true) : null;
|
|
1345
1352
|
// A terminal's claude_agent takes append_system_prompt / mcp_config since 0.65.0; its agent_launch drops them until this release.
|
|
1346
1353
|
// claude_agent has no fork_from, so a fork always goes through agent_launch.
|
|
@@ -1375,6 +1382,10 @@ export function createAitermServer(options = {}) {
|
|
|
1375
1382
|
}
|
|
1376
1383
|
/** First release whose agent_launch knows fork_from (ADR 0140). */
|
|
1377
1384
|
const FORK_MINIMUM_VERSION = "0.70.6";
|
|
1385
|
+
const callerMcpOutputSchema = z.object({ dropped: z.array(z.string()), replaced: z.array(z.string()) }).optional()
|
|
1386
|
+
.describe("mcp_config only: caller servers dropped because the seat's own harness config defines the name, and those that replaced it (replace: true). A terminal below 0.70.62 does not return it");
|
|
1387
|
+
/** First release that reads `replace` in a caller server (launch-identity-input.md "Caller name precedence"). */
|
|
1388
|
+
const CALLER_REPLACE_MINIMUM_VERSION = "0.70.62";
|
|
1378
1389
|
/** First release whose agent_launch takes append_system_prompt / mcp_config for codex-cli, and the first a terminal may run a Codex seat on. */
|
|
1379
1390
|
const CODEX_REMOTE_MINIMUM_VERSION = "0.70.7";
|
|
1380
1391
|
/** The oldest terminal Aiterm per harness: Grok, Cursor and Antigravity seats need 0.70.9 (checked before any private value is sent). */
|
|
@@ -1504,6 +1515,7 @@ export function createAitermServer(options = {}) {
|
|
|
1504
1515
|
}
|
|
1505
1516
|
: {}),
|
|
1506
1517
|
...(forkOf ? { fork_of: { session_id: forkOf.session_id, vendor_session_id: forkOf.vendor_session_id, write_ban: forkOf.write_ban } } : {}),
|
|
1518
|
+
...(mcp_config != null ? { caller_mcp: loadAgentMetadata(sid).caller_mcp ?? { dropped: [], replaced: [] } } : {}),
|
|
1507
1519
|
};
|
|
1508
1520
|
// 開始未確認(submitted_unconfirmed)は誤りにしない。sessionは立ち、promptは入力欄を離れ、配送も登録済み。
|
|
1509
1521
|
// 誤りで返すとClaude Code親は受け口のhookを走らせず、子の回答が届かない(ADR 0093)。状態はinitial_promptと本文で伝える。
|
|
@@ -1580,7 +1592,7 @@ export function createAitermServer(options = {}) {
|
|
|
1580
1592
|
session_name: z.string().nullish().describe("セッション名(省略で自動採番)"),
|
|
1581
1593
|
...(kind === "claude" ? {
|
|
1582
1594
|
append_system_prompt: z.string().min(1).optional().describe("Launch instructions added to the system prompt; kept in Aiterm state, not in the project or home"),
|
|
1583
|
-
mcp_config: z.object({ mcpServers: z.record(z.string(), z.unknown()) }).strict().optional().describe("Extra MCP servers for this seat; write secrets as ${ENV} names given in env_vars"),
|
|
1595
|
+
mcp_config: z.object({ mcpServers: z.record(z.string(), z.unknown()) }).strict().optional().describe("Extra MCP servers for this seat; write secrets as ${ENV} names given in env_vars. A same-name server of the seat's own config wins and the entry is dropped (caller_mcp.dropped) unless it has replace: true"),
|
|
1584
1596
|
} : {}),
|
|
1585
1597
|
...writeScopeInputSchema,
|
|
1586
1598
|
...correlatedLaunchSchema,
|
|
@@ -1606,6 +1618,7 @@ export function createAitermServer(options = {}) {
|
|
|
1606
1618
|
fast: z.boolean().optional().describe("起こした後の、席のfastの状態"),
|
|
1607
1619
|
fast_error: fastModeFailureSchema.nullable().optional().describe("fastを頼まれたが、通常の速度で起こした時の訳"),
|
|
1608
1620
|
...writeScopeOutputSchema,
|
|
1621
|
+
caller_mcp: callerMcpOutputSchema,
|
|
1609
1622
|
},
|
|
1610
1623
|
}, async ({ terminal, ...args }, extra) => terminal ? launchTerminalAgent(core.agentHarness(kind), terminal, args, extra) : launchAgent(kind, args, extra));
|
|
1611
1624
|
}
|
|
@@ -1635,7 +1648,7 @@ export function createAitermServer(options = {}) {
|
|
|
1635
1648
|
remote: remoteInputField,
|
|
1636
1649
|
terminal: terminalArgumentSchema.optional().describe(terminalArgumentDescription),
|
|
1637
1650
|
append_system_prompt: z.string().min(1).optional().describe("Launch instructions added to the system prompt; kept in Aiterm state, not in the project or home. Never put secrets here. Codex: appended to developer_instructions after Aiterm's marker; Grok: appended to --rules; Antigravity: an always-on rule in the seat's own --add-dir folder; at most 64 KiB for these. Cursor has no system-prompt channel: the text goes in front of the first prompt, or of the first input sent to a promptless seat (at most 64 KiB)"),
|
|
1638
|
-
mcp_config: z.object({ mcpServers: z.record(z.string(), z.unknown()) }).strict().optional().describe("Extra MCP servers for this seat. Secret header values: write ${NAME} and list NAME in env_vars. Codex, Grok, Cursor and Antigravity take only http servers {type?: \"http\", url, headers}: a literal header, 'Authorization: Bearer ${NAME}' or a header whose whole value is ${NAME}; other shapes, and a ${NAME} with no value at launch, are refused before the seat starts.
|
|
1651
|
+
mcp_config: z.object({ mcpServers: z.record(z.string(), z.unknown()) }).strict().optional().describe("Extra MCP servers for this seat. Secret header values: write ${NAME} and list NAME in env_vars. Codex, Grok, Cursor and Antigravity take only http servers {type?: \"http\", url, headers, replace?: boolean}: a literal header, 'Authorization: Bearer ${NAME}' or a header whose whole value is ${NAME}; other shapes, and a ${NAME} with no value at launch, are refused before the seat starts. A server the seat's own harness config already defines under the same name is dropped for this seat (listed in caller_mcp.dropped) unless its entry has replace: true; then it replaces that server (Codex: a user stdio server of that name runs Aiterm's relay to the given url instead). Cursor runs a server as plugin-aiterm-caller-<name> beside a same-name user server, so nothing is dropped there"),
|
|
1639
1652
|
fork_from: z.object({
|
|
1640
1653
|
session_id: z.string().regex(/^[A-Za-z0-9_-]{1,64}$/).describe("The main Aiterm seat on the same machine (the terminal or remote when given)"),
|
|
1641
1654
|
fork_id: z.string().min(1).max(200).optional().describe("Caller's fork ID, passed to the seat as THROUGHLINE_FORK_ID"),
|
|
@@ -1661,6 +1674,7 @@ export function createAitermServer(options = {}) {
|
|
|
1661
1674
|
fast_error: fastModeFailureSchema.nullable().optional().describe("fastを頼まれたが、通常の速度で起こした時の訳"),
|
|
1662
1675
|
write_scope: z.string().optional(),
|
|
1663
1676
|
write_scope_enforcement: z.enum(["enforced_read_only", "declaration_only_unsupported"]).optional(),
|
|
1677
|
+
caller_mcp: callerMcpOutputSchema,
|
|
1664
1678
|
fork_of: z.object({ session_id: z.string(), vendor_session_id: z.string(),
|
|
1665
1679
|
write_ban: z.object({ path: z.string(), method: z.enum(["landlock", "seatbelt", "restricted-token"]) }) }).optional().describe("The seat this fork copies and the folder it cannot write"),
|
|
1666
1680
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiterm-mcp",
|
|
3
|
-
"version": "0.70.
|
|
3
|
+
"version": "0.70.62",
|
|
4
4
|
"mcpName": "io.github.kitepon/aiterm-mcp",
|
|
5
5
|
"description": "Persistent terminal MCP with one harness-based launcher for Claude Code, Codex CLI, Grok CLI, Cursor Agent CLI, and Antigravity CLI, plus durable PTYs for SSH, containers, and REPLs.",
|
|
6
6
|
"keywords": [
|