aiterm-mcp 0.70.40 → 0.70.42

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 CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.70.42] - 2026-11-13
11
+
12
+ - `pty_list` `aiterm/seat_turns` rows carry `own_work` when the caller sends `_meta["aiterm/own_work_exclusions"]` (a41; Kiro, Owner-approved design 2026-11-13): `{processes, excluded, child_results, exclusions_digest, oldest}` beside `turn`. `processes` are the processes the seat's CLI started after startup and still runs (the same set as `post_startup_process_count`), minus those a process entry of the caller's list names for this seat (exe + leading args, with the match's descendants and post-startup ancestors); `oldest` is the oldest one's descriptor and start time. Descriptors are built where the process runs and never carry raw argv: program basename, first two non-flag arguments as basenames, and any token over 40 characters or containing `=`, `://` or `@` becomes `…` (on macOS arguments are split on whitespace). One process-table read per call; terminals compute their own rows inside the relayed read.
13
+ - A seat no longer waits forever for child results it does not own. `pending_child_deliveries` (and `own_work.child_results`) count an unfinished delivery for the parent seat the child names, not for whichever process adopted the dead owner's records (Kiro, 2026-11-13: a seat running the execution server read 4 adopted deliveries of another seat and could never hibernate or close). A delivery whose local child was replaced, removed, hibernated or vanished now ends after two readings 30 s apart with `AGENT_RESULT_UNAVAILABLE: PARENT_DELIVERY_CHILD_GONE: <reason>`, delivered to its parent; before, the wait never ended.
14
+
15
+ ## [0.70.41] - 2026-11-13
16
+
17
+ - Antigravity CLI 1.5.7 seats start again. agy 1.5.7 draws a mode hint in the empty composer (`> Auto mode: edits & safe commands auto-approved (shift+tab to cycle)`, also Accept-edits, Plan and Best-of-N), and Aiterm accepted only a bare `>` line as the empty composer, so every `agent_launch` ended `AGENT_STARTUP_BLOCKED vendor_state_unknown` (Kiro, 2026-11-13; container agy replaced 2026-11-12 23:38 UTC). The empty composer is now the footer plus a bare `>` line or exactly such a hint line (also when it wraps at the pane edge); a typed draft still reads as not empty.
18
+ - Calls to a trusted terminal (`terminal`-bound seats) reuse one warm MCP session per terminal instead of starting `ssh`, the terminal's shell, a fresh `aiterm-mcp` and MCP initialize for every call (a37; Kiro, 2026-11-13: BellTeam `GET /api/goals` 5-9.5 s, waiting on terminal seats). Measured from the container with the terminals' 0.70.40, one seat's `pty_observe` + `agent_goal inspect`: MacBook 3.8 s → about 0.4 s; Windows (fox) 5.3 s → about 2.0 s, of which inspect itself takes 1.5 s on the terminal (three Windows process table reads). A request already sent is never replayed: a session found closed before a send is reopened, one lost after a send fails as before. A session is closed after 2 minutes unused or 10 minutes of age (a terminal's `aiterm-update` takes effect within 10 minutes), and it never keeps an otherwise idle process alive. `agent_launch` with private values still uses its own connection.
19
+ - A Claude or Codex seat whose launch env names a secret (`…TOKEN`, `…KEY`, `…AUTH` and the like, or a terminal seat's `AITERM_MCP_HEADER_n`) can now hibernate and resume into the same conversation (E8; Kiro, 2026-11-13, chart t29). Until 0.70.40 such a seat got no resume template at all, so `pty_close {hibernate:true}` answered `AGENT_HIBERNATE_UNAVAILABLE resume_unavailable` and every BellTeam seat (which names `BELLTEAM_MCP_TOKEN`) could only be started fresh. The template and recipe now keep the secret names only (`secret_environment`); values are never written to disk, and a 0.70.23-0.70.40 recipe that held the Claude login value is rewritten without it. `agent_launch` with `session_name` takes each value from that launch (private env line, then process env) and refuses with `AGENT_RESUME_SECRET_MISSING` (not started, seat stays hibernated) when one is missing; the Claude login keeps its 0.70.23 rule (not named: the seat resumes on the root's login). A send or dispatch that would resume such a seat refuses with `AGENT_RESUME_SECRETS_REQUIRED` and sends nothing; the idle clock leaves such seats running (`resume_needs_launch_values`). A resume that brings `mcp_config` with the same server names rewrites the seat's caller MCP file, so a terminal seat reaches the current forward port.
20
+ - `pty_list` `aiterm/seat_turns` rows of terminal-bound seats carry `route_since` (E9): when the terminal's seat-MCP reverse forward was last established (the forward keeper records `ready_at`), null while it is not ready.
21
+
10
22
  ## [0.70.40] - 2026-11-12
11
23
 
12
24
  - Parallel `agent_goal` `inspect` calls no longer run one at a time or stall the server. Every binding check (`resolve`, run 2-4 times per call) ran `tmux display-message` and the full `ps` table with `spawnSync`, so N inspects arriving together ran serially and blocked the event loop, delivery to every seat included (Kiro, 2026-11-13: BellTeam `GET /api/goals` took 8-17 s with ~25 live seats). These checks now run asynchronously, and checks that arrive together share one `tmux list-panes -a` read and one process table read (`freshShared`: a check only receives a read that began after its call, so no generation check uses an older table). Measured on the BellTeam container's live state, 27 seats (21 Claude, 6 Codex), inspect only: all in parallel 3.5 s → 0.68 s, longest event-loop block 3.1 s → 0.2 s, results identical to 0.70.39 for every seat. The check right before an input effect (`goalUi`) stays synchronous; inside a native target frame and on Windows the pane is read per session (asynchronously).
@@ -3376,7 +3388,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3376
3388
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3377
3389
  provenance.
3378
3390
 
3379
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.40...HEAD
3391
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.42...HEAD
3392
+ [0.70.42]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.41...v0.70.42
3393
+ [0.70.41]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.40...v0.70.41
3380
3394
  [0.70.40]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.39...v0.70.40
3381
3395
  [0.70.39]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.38...v0.70.39
3382
3396
  [0.70.38]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.37...v0.70.38
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.40** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.70.42** · 動作対象は 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.40** · 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).
230
+ **Status:** actively maintained · current public release **v0.70.42** · 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
 
@@ -29,6 +29,8 @@ export function decideIdleSeat(seat, now, minutes = 30, expectedAnchor, immediat
29
29
  return { ...result, reason: "conversation_id_unavailable" };
30
30
  if (!seat.resume_ready)
31
31
  return { ...result, reason: "resume_unavailable" };
32
+ if (!immediate && seat.resume_needs_launch_values)
33
+ return { ...result, reason: "resume_needs_launch_values" };
32
34
  if (!limited && seat.turn_settled !== true)
33
35
  return { ...result, reason: "turn_end_unconfirmed" };
34
36
  const anchor = limited ?? seat.activity.last_turn_end_at ?? (!seat.activity.tracked ? seat.created_at : null);
@@ -7,11 +7,18 @@ import { agentMetadataPath, writeJson0600 } from "./agent-shared.js";
7
7
  import { AitermError } from "./errors.js";
8
8
  const launchId = z.string().regex(/^[a-f0-9]{32}$/);
9
9
  const absolute = z.string().min(1).refine(value => path.isAbsolute(value) && !value.includes("\0"));
10
+ const envName = z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/);
11
+ /** A credential-shaped name, or a header value the body moved to the private line for a terminal seat (remote-terminal R5). */
12
+ export function isSecretEnvName(name) {
13
+ return /(?:TOKEN|KEY|SECRET|PASSWORD|PASSWD|CREDENTIALS?|AUTH)$/i.test(name) || /^AITERM_MCP_HEADER_\d+$/.test(name);
14
+ }
10
15
  export const agentResumeRecipeSchema = z.object({
11
16
  schema: z.literal("aiterm.agent-resume.v1"), launch_id: launchId,
12
17
  kind: z.enum(["claude", "codex"]), vendor_session_id: z.string().regex(/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i),
13
18
  executable: absolute, cwd: absolute, configuration_root: absolute, model: z.string().nullable(), reasoning_effort: z.string().nullable(), reasoning_effort_source: z.literal("vendor_default").optional(), fast: z.boolean(),
14
- environment: z.record(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/), z.string().refine(value => !value.includes("\0")).nullable()),
19
+ environment: z.record(envName, z.string().refine(value => !value.includes("\0")).nullable()),
20
+ // E8: names whose values a resume takes from its own launch; the values are never stored.
21
+ secret_environment: z.array(envName).optional(),
15
22
  }).strict();
16
23
  const identity = z.object({ pid: z.number().int().positive(), process_group_id: z.number().int().positive().nullable(),
17
24
  started_identity: z.string().min(1), argv_digest: z.string().regex(/^[a-f0-9]{64}$/) }).strict();
@@ -59,6 +66,16 @@ export function writeAgentResumeRecipe(meta, input) {
59
66
  throw unavailable();
60
67
  writeJson0600(file(meta, ".resume.json"), value);
61
68
  }
69
+ /** Secret names of a recipe. A recipe from 0.70.40 or older may hold one in `environment`: its value is never used. */
70
+ export function recipeSecretNames(recipe) {
71
+ return [...new Set([...recipe.secret_environment ?? [], ...Object.keys(recipe.environment).filter(isSecretEnvName)])].sort();
72
+ }
73
+ /** The recipe as stored: secret names only, never their values. */
74
+ export function withoutSecretValues(recipe, secrets = recipeSecretNames(recipe)) {
75
+ const { secret_environment: _, ...rest } = recipe;
76
+ return { ...rest, environment: Object.fromEntries(Object.entries(recipe.environment).filter(([name]) => !isSecretEnvName(name) && !secrets.includes(name))),
77
+ ...(secrets.length ? { secret_environment: secrets } : {}) };
78
+ }
62
79
  export function agentResumeRecipeDigest(recipe) {
63
80
  return createHash("sha256").update(JSON.stringify(agentResumeRecipeSchema.parse(recipe))).digest("hex");
64
81
  }
@@ -151,12 +168,13 @@ export function writeAgentResumeTemplate(meta, input) {
151
168
  export function captureAgentResumeTemplate(meta, effort, envNames, configurationRoot, env = process.env) {
152
169
  if (meta.kind !== "claude" && meta.kind !== "codex")
153
170
  return;
154
- // Explicit credential variables cannot be persisted as a conversation recipe.
155
- if (envNames.some(name => /(?:TOKEN|KEY|SECRET|PASSWORD|PASSWD|CREDENTIALS?|AUTH)$/i.test(name)))
156
- return;
171
+ // Secret names are kept without values (E8): a resume takes them from its own launch.
172
+ const names = [...new Set([...envNames, ...(meta.kind === "claude" ? ["CLAUDE_CONFIG_DIR"] : [])])];
173
+ const secrets = names.filter(isSecretEnvName).sort();
157
174
  writeAgentResumeTemplate(meta, { schema: "aiterm.agent-resume-template.v1", launch_id: meta.launch_id, kind: meta.kind,
158
175
  executable: meta.agent_executable, cwd: meta.cwd, configuration_root: configurationRoot, model: meta.model ?? null, reasoning_effort: effort,
159
- environment: Object.fromEntries([...new Set([...envNames, ...(meta.kind === "claude" ? ["CLAUDE_CONFIG_DIR"] : [])])].map(name => [name, launchEnvValue(name, env) ?? null])), state: "confirmed" });
176
+ environment: Object.fromEntries(names.filter(name => !isSecretEnvName(name)).map(name => [name, launchEnvValue(name, env) ?? null])),
177
+ ...(secrets.length ? { secret_environment: secrets } : {}), state: "confirmed" });
160
178
  }
161
179
  export function finishAgentResumeConfiguration(meta, before, model, effort) {
162
180
  const complete = !!model && !!effort;
@@ -168,9 +186,14 @@ export function finishAgentResumeConfiguration(meta, before, model, effort) {
168
186
  export function refreshAgentResumeRecipe(meta) {
169
187
  const template = readAgentResumeTemplate(meta);
170
188
  if (!template) {
171
- const recipe = readAgentResumeRecipe(meta);
172
- return recipe?.model && recipe.reasoning_effort
173
- && (meta.kind !== "claude" || Object.hasOwn(recipe.environment, "CLAUDE_CONFIG_DIR")) ? recipe : null;
189
+ const stored = readAgentResumeRecipe(meta);
190
+ if (!stored?.model || !stored.reasoning_effort || (meta.kind === "claude" && !Object.hasOwn(stored.environment, "CLAUDE_CONFIG_DIR")))
191
+ return null;
192
+ // A 0.70.23-0.70.40 recipe may hold the Claude login value: keep its name only (E8).
193
+ const recipe = withoutSecretValues(stored);
194
+ if (agentResumeRecipeDigest(recipe) !== agentResumeRecipeDigest(stored))
195
+ writeAgentResumeRecipe(meta, recipe);
196
+ return recipe;
174
197
  }
175
198
  if (template.state !== "confirmed" || !template.model || (!template.reasoning_effort && !(meta.kind === "codex" && template.reasoning_effort === null && template.reasoning_effort_source === "vendor_default")) || template.model !== meta.model
176
199
  || template.executable !== meta.agent_executable || template.cwd !== meta.cwd || typeof meta.fast !== "boolean")
@@ -179,8 +202,8 @@ export function refreshAgentResumeRecipe(meta) {
179
202
  || !["low", "medium", "high", "xhigh", "max"].includes(template.reasoning_effort ?? "")))
180
203
  return null;
181
204
  const { state, ...settings } = template;
182
- const candidate = agentResumeRecipeSchema.safeParse({ ...settings, schema: "aiterm.agent-resume.v1",
183
- vendor_session_id: meta.vendor_session_id, fast: meta.fast });
205
+ const candidate = agentResumeRecipeSchema.safeParse(withoutSecretValues({ ...settings, schema: "aiterm.agent-resume.v1",
206
+ vendor_session_id: meta.vendor_session_id, fast: meta.fast }));
184
207
  if (!candidate.success)
185
208
  return null;
186
209
  const previous = readAgentResumeRecipe(meta);
package/dist/core.js CHANGED
@@ -23,6 +23,7 @@ import { withManagedSpan, observeManagedSpan, closeManagedSpan, SPAN_HELD } from
23
23
  */
24
24
  import { spawnSync } from "node:child_process";
25
25
  import * as fs from "node:fs";
26
+ import { z } from "zod";
26
27
  import * as path from "node:path";
27
28
  import { createHash, randomBytes } from "node:crypto";
28
29
  import { launchEnvValue } from "./private-env.js";
@@ -40,7 +41,7 @@ import { initializeAgentActivity, recordAgentInput, recordAgentTurnEnd, readAgen
40
41
  import { checkIdleSeat, decideIdleSeat, idleMinutes } from "./agent-idle.js";
41
42
  import { AGENT_IDLE_ENABLED, armAgentIdleClock, endAgentIdleClock, idleClockDeadline, isAgentIdleClockOwner, requestAgentIdleClock, requestAgentIdleClocks } from "./agent-idle-clock.js";
42
43
  import { stopProcessTree } from "./process-tree-stop.js";
43
- import { writeAgentResumeRecoveryOrigin, confirmedAgentResumeRecoveryOrigin, readAgentResumeResolution, writeAgentResumeResolution, agentResumeRecordDigest, captureAgentResumeTemplate, readAgentResumeTemplate, writeAgentResumeTemplate, finishAgentResumeConfiguration, refreshAgentResumeRecipe, readAgentIdleClock, retireAgentIdleClock, readAgentResumeRecipe, writeAgentResumeRecipe, agentResumeRecipeDigest, readAgentLifecycle, writeAgentLifecycle, cancelAgentStopping, readAgentResumeAttempt, writeAgentResumeAttempt, readAgentResumeNative, writeAgentResumeNative } from "./agent-lifecycle.js";
44
+ import { writeAgentResumeRecoveryOrigin, confirmedAgentResumeRecoveryOrigin, readAgentResumeResolution, writeAgentResumeResolution, agentResumeRecordDigest, captureAgentResumeTemplate, readAgentResumeTemplate, writeAgentResumeTemplate, finishAgentResumeConfiguration, refreshAgentResumeRecipe, readAgentIdleClock, retireAgentIdleClock, readAgentResumeRecipe, writeAgentResumeRecipe, agentResumeRecipeDigest, isSecretEnvName, recipeSecretNames, withoutSecretValues, readAgentLifecycle, writeAgentLifecycle, cancelAgentStopping, readAgentResumeAttempt, writeAgentResumeAttempt, readAgentResumeNative, writeAgentResumeNative } from "./agent-lifecycle.js";
44
45
  import { createCodexGoalObjective, editCodexGoalObjective, submitCodexGoalCommand } from "./harnesses/codex-goal-editor.js";
45
46
  import { closeExpectedExecution, parseExecutionNativeSessions, executionNativeBindingSchema } from "./execution-close.js";
46
47
  import { executionLaunchSchema, executionPointSchema } from "./execution-contract.js";
@@ -50,12 +51,12 @@ import { readExecutionParentProcess } from "./execution-parent-process.js";
50
51
  import { isCursorMcpClient } from "aiterm-steer-delivery";
51
52
  import { antigravityBinding, antigravityAuthChoiceKey, antigravityCurrentModel, antigravityStartupAction, antigravityAgentArgv, writeAntigravityCallerFiles, checkAntigravityCallerInput, antigravityPromptWithCaller, antigravityQuotaLimit, antigravityModelChoices, antigravityAuthStatus, antigravityAuthPane, antigravityTranscriptText, bindAntigravitySession, createAntigravityAgentMetadata, mergeAntigravityHooks } from "./harnesses/antigravity.js";
52
53
  import { paneTokenHint } from "./harnesses/pane-tokens.js";
53
- import { unfinishedDeliveriesOwnedBy } from "./parent-delivery-owners.js";
54
+ import { pendingChildResultsFor } from "./parent-delivery-owners.js";
54
55
  import { readLinuxProcessRegistrationIdentity, readClaudeRegistrationIdentity, readProcessEnvironment, readRuntimeProcesses, readRuntimeProcessesShared, readProcessIdentities, processSubtree, parentProcess, processIdentity, signalRuntimeProcess, backgroundProcesses, lazyRelayProcess, aitermProcessProbe, windowsConsoleHost, macKeepAwakeProcess, processElapsedSeconds } from "./process-runtime.js";
55
56
  import { liveNodeExecutable } from "./live-node.js";
56
57
  import { resolveClaudeConfigurationRoot, withClaudeConfigRoot, withClaudeSlotLogin } from "./claude-config-root.js";
57
58
  import { probeWriteBan, writeBanPrefix, windowsWriteBanArgv } from "./write-ban.js";
58
- import { AitermError, launchAuthRequired, launchInputRefusal, launchStartupBlocked, AgentResumeUnavailableError, AgentResumeError, telemetryOwnedFailure, ownTelemetryFailure } from "./errors.js";
59
+ import { AitermError, launchAuthRequired, launchInputRefusal, launchStartupBlocked, AgentResumeUnavailableError, AgentResumeError, AgentResumeSecretsError, telemetryOwnedFailure, ownTelemetryFailure } from "./errors.js";
59
60
  import { isWin, SOCKDIR, SOCK, tmuxCommand, readOnlyTmuxList, PtyDiagnosticError, tmuxCommandWithInput, sendPsmuxPayload, loadPtyBufferChunk, pasteBufferBaseArgs, tmuxNewSession, withNativeSessionCreation, withNativeSessionTarget, hasVerifiedNativeSessionTarget, withNativeSessionSetupRollback, hasNativeSessionSetupRollback, registeredSessionEnvironment, registerSessionEnvironment, attachCommand, normalizePaneCommand, atomicShellMultiline, appendMarkSentinel, paneShellForSubmission, adaptShellSubmission, settlePaneLog, paneCwdArgument, sessionEnvironmentLaunch, paneCommandArgs, rememberPaneShell, sessionPaneAsync, } from "./tmux-runtime.js";
60
61
  import { AGENT_DEFAULT_PREFACE, sleep, currentUid, runtimeStateBase, safeStatSize, readFileRange, writeJson0600, writeText0600, createEmpty0600, shq, LAUNCH_ID_RE, AGENT_LINEAGE_RE, AGENT_DONE_POLL_MS, AGENT_RATE_LIMIT_POLL_MS, pollGate, AGENT_EVENT_MAX_BYTES, assertSessionName, agentsDir, readAgentGeneration, selectAgentMetadataFile, publishAgentGeneration, agentMetadataPath, writeAgentMetadata, AGENT_EVENT_TAIL_BYTES, agentLabel, agentHarness, } from "./agent-shared.js";
61
62
  import { AuthResponseError, authUi, authPromptDigest, authBindingSchema, authResponseSchema } from "./agent-auth-ui.js";
@@ -1625,6 +1626,10 @@ export function startupProcessShapes(identities, rows) {
1625
1626
  // 控えの物が終了していて、同じ親の下に同じargvで立ったprocessは、その立て直しとして数えない。
1626
1627
  // 親も立て直されている時は、立て直された親の下を見る。終了した控え1つにつき、数えないのは1つまで。
1627
1628
  export function postStartupProcessCount(kind, activityRows, rows, startup, shapes = [], harness) {
1629
+ return postStartupProcesses(kind, activityRows, rows, startup, shapes, harness).length;
1630
+ }
1631
+ /** The processes postStartupProcessCount counts (own_work, a41). */
1632
+ export function postStartupProcesses(kind, activityRows, rows, startup, shapes = [], harness) {
1628
1633
  const byPid = new Map(rows.map(row => [row.pid, row]));
1629
1634
  const relayChild = (row) => {
1630
1635
  const parent = parentProcess(row, byPid);
@@ -1661,7 +1666,167 @@ export function postStartupProcessCount(kind, activityRows, rows, startup, shape
1661
1666
  changed = true;
1662
1667
  }
1663
1668
  }
1664
- return added.size;
1669
+ return [...added.values()];
1670
+ }
1671
+ // ---- own_work (a41, observation-results.md): what a seat started itself and has not finished ----
1672
+ const ownWorkExclusionsSchema = z.object({
1673
+ digest: z.string().min(1).max(128),
1674
+ entries: z.array(z.union([
1675
+ z.object({ id: z.string(), kind: z.literal("process"), exe: z.string().min(1), args: z.array(z.string()), sessions: z.array(z.string()) }),
1676
+ z.object({ id: z.string(), kind: z.literal("child"), harness: z.string().min(1), session: z.string().nullable(), sessions: z.array(z.string()) }),
1677
+ ])).max(256),
1678
+ });
1679
+ /** Windows argv from one command line (CommandLineToArgvW rules: backslashes before a quote, doubled quotes). */
1680
+ export function windowsCommandLineArgv(line) {
1681
+ const argv = [];
1682
+ let at = 0;
1683
+ while (at < line.length) {
1684
+ while (line[at] === " " || line[at] === "\t")
1685
+ at++;
1686
+ if (at >= line.length)
1687
+ break;
1688
+ let token = "", quoted = false, first = argv.length === 0;
1689
+ for (; at < line.length; at++) {
1690
+ const char = line[at];
1691
+ if (!quoted && (char === " " || char === "\t"))
1692
+ break;
1693
+ if (first) {
1694
+ if (char === '"')
1695
+ quoted = !quoted;
1696
+ else
1697
+ token += char;
1698
+ continue;
1699
+ } // argv[0]: quotes only, no escapes
1700
+ if (char === "\\") {
1701
+ let slashes = 0;
1702
+ while (line[at] === "\\") {
1703
+ slashes++;
1704
+ at++;
1705
+ }
1706
+ if (line[at] === '"') {
1707
+ token += "\\".repeat(slashes >> 1);
1708
+ if (slashes % 2)
1709
+ token += '"';
1710
+ else {
1711
+ at--;
1712
+ }
1713
+ }
1714
+ else {
1715
+ token += "\\".repeat(slashes);
1716
+ at--;
1717
+ }
1718
+ continue;
1719
+ }
1720
+ if (char === '"') {
1721
+ if (quoted && line[at + 1] === '"') {
1722
+ token += '"';
1723
+ at++;
1724
+ }
1725
+ else
1726
+ quoted = !quoted;
1727
+ continue;
1728
+ }
1729
+ token += char;
1730
+ }
1731
+ argv.push(token);
1732
+ }
1733
+ return argv;
1734
+ }
1735
+ function processArgv(row) {
1736
+ if (process.platform === "linux") {
1737
+ try {
1738
+ const parts = fs.readFileSync(`/proc/${row.pid}/cmdline`, "utf8").split("\0");
1739
+ if (parts.at(-1) === "")
1740
+ parts.pop();
1741
+ if (parts.length)
1742
+ return parts;
1743
+ }
1744
+ catch { /* gone or unreadable: the table's command line */ }
1745
+ }
1746
+ if (isWin)
1747
+ return windowsCommandLineArgv(row.command);
1748
+ // shortcut: macOS ps gives only the joined command line, so an argument containing a space splits; exact argv needs a native call.
1749
+ return row.command.trim().split(/\s+/);
1750
+ }
1751
+ /** The descriptor an exclusion entry matches (raw argv never leaves this machine). */
1752
+ export function processDescriptor(argv, windows = isWin) {
1753
+ const base = (value) => value.replace(/^["']+|["']+$/g, "").split(/[\\/]/).filter(Boolean).pop() ?? "";
1754
+ // Judged on the whole token before it is shortened: a URL or user@host must not survive as its last path part.
1755
+ const secret = (value) => /=|:\/\/|@/.test(value);
1756
+ const token = (value) => { const short = base(value); return secret(value) || short.length > 40 ? "…" : short; };
1757
+ let exe = token(argv[0] ?? "").replace(/\.(?:exe|cmd)$/i, "");
1758
+ if (windows)
1759
+ exe = exe.toLowerCase();
1760
+ return { exe, args: argv.slice(1).filter(arg => !arg.startsWith("-")).slice(0, 2).map(token) };
1761
+ }
1762
+ /** own_work for each local agent seat, from one shared process table (seat_turns rows of an opted-in caller). */
1763
+ export async function seatOwnWork(names, requested) {
1764
+ const parsed = ownWorkExclusionsSchema.safeParse(requested);
1765
+ const list = parsed.success ? parsed.data : null;
1766
+ const result = new Map();
1767
+ let rows = null;
1768
+ try {
1769
+ rows = await readRuntimeProcessesShared();
1770
+ }
1771
+ catch { /* table unreadable: processes null */ }
1772
+ for (const name of names) {
1773
+ const meta = tryLoadAgentMetadata(name);
1774
+ if (!meta)
1775
+ continue;
1776
+ const entries = list?.entries.filter(entry => entry.sessions.includes(name)) ?? [];
1777
+ const childExcluded = (child) => entries.some(entry => entry.kind === "child"
1778
+ && entry.harness === child.harness && (entry.session === null || entry.session === child.session));
1779
+ const work = { processes: null, excluded: 0, child_results: null, exclusions_digest: list?.digest ?? null, oldest: null };
1780
+ result.set(name, work);
1781
+ try {
1782
+ const state = agentDormantState(meta);
1783
+ if (state === "hibernated") {
1784
+ work.processes = 0;
1785
+ work.child_results = 0;
1786
+ continue;
1787
+ }
1788
+ if (state !== null || !rows)
1789
+ continue;
1790
+ const pane = await sessionPaneAsync(name);
1791
+ const [pidText, dead] = pane.code === 0 ? pane.stdout.trim().split("\t") : [];
1792
+ const root = dead === "0" ? rows.find(row => row.pid === Number(pidText)) : undefined;
1793
+ if (!root)
1794
+ continue;
1795
+ const subtree = processSubtree(rows, root.pid);
1796
+ const candidates = selectHarnessProcesses(meta, rows, subtree);
1797
+ const agent = candidates.length === 1 ? candidates[0] : null;
1798
+ if (!agent)
1799
+ continue;
1800
+ const activityRows = subtree.some(row => row.pid === agent.pid) ? subtree : [...subtree, ...processSubtree(rows, agent.pid)];
1801
+ work.child_results = pendingChildResultsFor(name, activityRows, childExcluded);
1802
+ if (!Array.isArray(meta.startup_processes))
1803
+ continue;
1804
+ const counted = postStartupProcesses(meta.kind, activityRows, rows, new Set(meta.startup_processes), meta.startup_process_shapes, agent);
1805
+ const processEntries = entries.filter(entry => entry.kind === "process");
1806
+ const descriptors = new Map(counted.map(row => [row.pid, processDescriptor(processArgv(row))]));
1807
+ const byPid = new Map(rows.map(row => [row.pid, row]));
1808
+ const countedPids = new Set(counted.map(row => row.pid));
1809
+ const excluded = new Set();
1810
+ for (const row of counted) {
1811
+ const descriptor = descriptors.get(row.pid);
1812
+ if (!processEntries.some(entry => entry.exe === descriptor.exe && entry.args.every((arg, at) => descriptor.args[at] === arg)))
1813
+ continue;
1814
+ // The match, its descendants and its post-startup ancestors (the bash -c wrappers CLIs put around commands).
1815
+ for (const below of processSubtree(rows, row.pid))
1816
+ if (countedPids.has(below.pid))
1817
+ excluded.add(below.pid);
1818
+ for (let up = parentProcess(row, byPid); up && countedPids.has(up.pid); up = parentProcess(up, byPid))
1819
+ excluded.add(up.pid);
1820
+ }
1821
+ const remaining = counted.filter(row => !excluded.has(row.pid));
1822
+ work.processes = remaining.length;
1823
+ work.excluded = excluded.size;
1824
+ const oldest = remaining.reduce((first, row) => !first || Date.parse(row.started_identity) < Date.parse(first.started_identity) ? row : first, null);
1825
+ work.oldest = oldest ? { ...descriptors.get(oldest.pid), since: new Date(oldest.started_identity).toISOString() } : null;
1826
+ }
1827
+ catch { /* this seat could not be read: nulls */ }
1828
+ }
1829
+ return result;
1665
1830
  }
1666
1831
  function emptySessionObservation(name, exists) {
1667
1832
  return {
@@ -1848,8 +2013,8 @@ function observeNativeSession(name, cursor) {
1848
2013
  const comparable = previous?.pane_identity === sample.pane_identity;
1849
2014
  // 起動完了の控えが無いsession(通常PTY、控える前の版で起動したagent)とharnessを特定できない時は数えない。
1850
2015
  const startup = agent && Array.isArray(meta?.startup_processes) ? new Set(meta.startup_processes) : null;
1851
- // このsessionが親として待っている子の結果。持ち主はharnessの下で動くAitermのMCP process。
1852
- result.pending_child_deliveries = agent ? unfinishedDeliveriesOwnedBy(activityRows) : null;
2016
+ // このsessionが親として待っている子の結果。子の記録が名指す親の席に数える(名指しが無ければ持ち主processで)。
2017
+ result.pending_child_deliveries = agent ? pendingChildResultsFor(name, activityRows) : null;
1853
2018
  result.activity = {
1854
2019
  cursor: Buffer.from(JSON.stringify(sample)).toString("base64url"),
1855
2020
  output_changed: comparable ? previous.screen_digest !== sample.screen_digest : null,
@@ -1966,7 +2131,7 @@ export async function checkAgentIdle(expectedInput, expectedAnchor, immediate =
1966
2131
  const settled = meta.kind === "claude" ? done !== null && readClaudeOperationMarker(meta) === null
1967
2132
  : meta.kind === "codex" ? done?.turn_id != null && done.turn_id === codexCompletedTurnId(meta) : agentTurnSettled(meta);
1968
2133
  return { launch_id: meta.launch_id, created_at: meta.created_at, vendor_session_id: meta.vendor_session_id,
1969
- resume_ready: resumeReady, native_configuration_confirmed: configurationScreen !== null
2134
+ resume_ready: resumeReady, resume_needs_launch_values: !!recipe && recipeSecretNames(recipe).length > 0, native_configuration_confirmed: configurationScreen !== null
1970
2135
  && (effectIssued || (slot?.last_attached_at != null && slot.last_attached_at < configurationStartedAt
1971
2136
  && configurationScreen === captureScreen(name, AGENT_TUI_READY_LINES))), activity: readAgentActivity(meta), state: live.state, reason: live.reason,
1972
2137
  attached: slot?.attached ?? (effectIssued ? false : null), turn_settled: settled,
@@ -2246,6 +2411,28 @@ function listNativeSessionRows(runTmux = tmux) {
2246
2411
  }
2247
2412
  /** Same listing and failure as pty_list, without loading every seat's metadata: one seat's existence check stays one
2248
2413
  * tmux call (2026-11-11: per-seat full lists made a CurrentWork pty_list take 10-27 s for ~140 members). */
2414
+ /**
2415
+ * Why a parent delivery's local child can no longer complete its boundary (parent-delivery.md), or null while it still can
2416
+ * or when this cannot be told (tmux unreadable). Replaced launch, missing record, hibernated, or vanished native.
2417
+ */
2418
+ export function deliveryChildGone(boundary) {
2419
+ if (boundary.remote)
2420
+ return null;
2421
+ try {
2422
+ const meta = tryLoadAgentMetadata(boundary.session_id);
2423
+ if (!meta)
2424
+ return "child_missing";
2425
+ if (meta.launch_id !== boundary.launch_id)
2426
+ return "child_replaced";
2427
+ const state = agentDormantState(meta);
2428
+ if (state === "hibernated")
2429
+ return "child_hibernated";
2430
+ return state === null && !nativeSessionExists(boundary.session_id) ? "child_vanished" : null;
2431
+ }
2432
+ catch {
2433
+ return null;
2434
+ }
2435
+ }
2249
2436
  function nativeSessionExists(name) {
2250
2437
  return listNativeSessionRows().some(([listed]) => listed === name);
2251
2438
  }
@@ -2298,7 +2485,7 @@ export function listSessionsResult(envKeys = [], runTmux = tmux, o = {}) {
2298
2485
  const recipe = readAgentResumeRecipe(meta);
2299
2486
  if (recipe?.kind === meta.kind && recipe.vendor_session_id === meta.vendor_session_id)
2300
2487
  for (const key of envKeys)
2301
- environment[key] = key === CLAUDE_LOGIN_ENV ? null : recipe.environment[key] ?? null;
2488
+ environment[key] = isSecretEnvName(key) ? null : recipe.environment[key] ?? null;
2302
2489
  if (state === "hibernated") {
2303
2490
  try {
2304
2491
  confirmedAgentResumeRecipe(meta, readAgentLifecycle(meta));
@@ -7073,7 +7260,11 @@ function adoptVanishedAgentNative(meta) {
7073
7260
  }
7074
7261
  // Claude's login, not a recipe setting (lifecycle-state-ownership 4b): a resume through agent_launch may replace it.
7075
7262
  const CLAUDE_LOGIN_ENV = "CLAUDE_CODE_OAUTH_TOKEN";
7076
- async function resumeAgentInLock(name, readyTimeout, claudeRoot, claudeLogin) {
7263
+ /**
7264
+ * `secretValues` (E8, lifecycle-state-ownership 4c): the values agent_launch brought for the recipe's secret names (null = unset,
7265
+ * only the Claude login). Without them (pty_send, dispatch, vanished adopt) a recipe naming a secret is refused before any effect.
7266
+ */
7267
+ async function resumeAgentInLock(name, readyTimeout, claudeRoot, secretValues) {
7077
7268
  const previous = loadAgentMetadata(name);
7078
7269
  readyTimeout ??= previous.kind === "codex" ? AGENT_TUI_FIRST_DRAW_TIMEOUT_MS : AGENT_TUI_READY_TIMEOUT_MS;
7079
7270
  let lifecycle = readAgentLifecycle(previous);
@@ -7123,12 +7314,19 @@ async function resumeAgentInLock(name, readyTimeout, claudeRoot, claudeLogin) {
7123
7314
  try {
7124
7315
  assertExecutionResumeSupported();
7125
7316
  const confirmed = confirmedAgentResumeRecipe(previous, lifecycle);
7317
+ const secretNames = [...new Set([...recipeSecretNames(confirmed), ...Object.keys(secretValues ?? {})])].sort();
7318
+ if (secretNames.length && !secretValues) {
7319
+ recorded = true; // a refusal before any effect, not a failed resume
7320
+ throw new AgentResumeSecretsError("AGENT_RESUME_SECRETS_REQUIRED", name, secretNames);
7321
+ }
7322
+ const stored = withoutSecretValues(confirmed, secretNames);
7126
7323
  // Same vendor session under another Claude root; the caller proved the transcript is there.
7127
- const rooted = claudeRoot && confirmed.kind === "claude" ? { ...confirmed, configuration_root: claudeRoot.root,
7128
- environment: { ...confirmed.environment, CLAUDE_CONFIG_DIR: claudeRoot.selector } } : confirmed;
7129
- // null = unset in the seat: it resumes on the root's own login.
7130
- const recipe = claudeLogin && rooted.kind === "claude"
7131
- ? { ...rooted, environment: { ...rooted.environment, [CLAUDE_LOGIN_ENV]: claudeLogin.value } } : rooted;
7324
+ const rooted = claudeRoot && stored.kind === "claude" ? { ...stored, configuration_root: claudeRoot.root,
7325
+ environment: { ...stored.environment, CLAUDE_CONFIG_DIR: claudeRoot.selector } } : stored;
7326
+ // Values of this launch only; null = unset in the seat (the Claude login: it resumes on the root's own login).
7327
+ const recipe = { ...rooted, environment: { ...rooted.environment, ...Object.fromEntries(secretNames.map(key => [key, secretValues[key] ?? null])) } };
7328
+ // What goes to disk: the names still set, never their values.
7329
+ const saved = withoutSecretValues(recipe, secretNames.filter(key => recipe.environment[key] != null));
7132
7330
  if (sessionExists(name))
7133
7331
  throw uncertain();
7134
7332
  const controlEnv = { ...process.env };
@@ -7208,7 +7406,7 @@ async function resumeAgentInLock(name, readyTimeout, claudeRoot, claudeLogin) {
7208
7406
  next.fork_of = previous.fork_of;
7209
7407
  writeAgentMetadata(next);
7210
7408
  initializeAgentActivity(next);
7211
- writeAgentResumeRecipe(next, { ...recipe, launch_id: next.launch_id });
7409
+ writeAgentResumeRecipe(next, { ...saved, launch_id: next.launch_id });
7212
7410
  attempt = { schema: "aiterm.agent-resume-attempt.v1", launch_id: previous.launch_id, next_launch_id: next.launch_id,
7213
7411
  state: "resuming", at: new Date().toISOString(), recipe_digest: lifecycle.recipe_digest };
7214
7412
  phase = "attempt_save";
@@ -7222,8 +7420,8 @@ async function resumeAgentInLock(name, readyTimeout, claudeRoot, claudeLogin) {
7222
7420
  const environment = [...Object.entries(recipe.environment),
7223
7421
  ...(next.kind === "codex" ? [["CODEX_HOME", recipe.configuration_root]] : []), ...agentEnvEntries(next, name)];
7224
7422
  for (const [key, value] of environment) {
7225
- // The Claude login never goes on a multiplexer argv or into pty_list; the launch reads it from the 0600 file.
7226
- if (value !== null && key === CLAUDE_LOGIN_ENV)
7423
+ // Secret values never go on a multiplexer argv or into pty_list; the launch reads them from the 0600 file.
7424
+ if (value !== null && secretNames.includes(key))
7227
7425
  continue;
7228
7426
  const stored = value === null ? tmux("set-environment", isWin ? "-u" : "-r", "-t", name, key) : tmux("set-environment", "-t", name, key, value);
7229
7427
  if (stored.code !== 0)
@@ -7265,9 +7463,10 @@ async function resumeAgentInLock(name, readyTimeout, claudeRoot, claudeLogin) {
7265
7463
  phase = "ready_save";
7266
7464
  writeAgentResumeTemplate(resumed, { schema: "aiterm.agent-resume-template.v1", launch_id: resumed.launch_id, state: "confirmed",
7267
7465
  kind: recipe.kind, executable: recipe.executable, cwd: recipe.cwd, configuration_root: recipe.configuration_root,
7268
- model: recipe.model, reasoning_effort: recipe.reasoning_effort, environment: recipe.environment,
7466
+ model: recipe.model, reasoning_effort: recipe.reasoning_effort, environment: saved.environment,
7467
+ ...(saved.secret_environment ? { secret_environment: saved.secret_environment } : {}),
7269
7468
  ...(recipe.reasoning_effort_source ? { reasoning_effort_source: recipe.reasoning_effort_source } : {}) });
7270
- writeAgentResumeRecipe(resumed, { ...recipe, launch_id: resumed.launch_id });
7469
+ writeAgentResumeRecipe(resumed, { ...saved, launch_id: resumed.launch_id });
7271
7470
  writeAgentResumeAttempt(previous, { ...attempt, state: "ready", at: new Date().toISOString() });
7272
7471
  return resumed;
7273
7472
  }
@@ -8453,7 +8652,7 @@ export async function openAgentWithInitialPrompt(kind, opts = {}) {
8453
8652
  || (opts.fast != null && opts.fast !== recipe.fast)
8454
8653
  || (opts.cwd != null && path.resolve(opts.cwd) !== recipe.cwd)
8455
8654
  || (opts.write_scope !== undefined && opts.write_scope !== previous.write_scope)
8456
- || (opts.env_vars !== undefined && !isDeepStrictEqual(resumeEnvNames(kind, opts.env_vars), resumeEnvNames(kind, Object.keys(recipe.environment)))))
8655
+ || (opts.env_vars !== undefined && !isDeepStrictEqual(resumeEnvNames(kind, opts.env_vars), resumeEnvNames(kind, [...Object.keys(recipe.environment), ...recipeSecretNames(recipe)]))))
8457
8656
  throw opts.require_existing_resume ? new AgentResumeUnavailableError(name) : new AitermError("AGENT_RESUME_CONFLICT: 同名の休止席は保存したharness・設定・project・明示envで再開します。変更は再開後に行ってください。", 2);
8458
8657
  // The only setting a resume may change: the Claude root, when it holds this conversation's transcript.
8459
8658
  const rootChange = claudeRoot && (claudeRoot.root !== recipe.configuration_root
@@ -8463,11 +8662,26 @@ export async function openAgentWithInitialPrompt(kind, opts = {}) {
8463
8662
  if (opts.launch_operation_id != null)
8464
8663
  requireMatchingClaudeLaunch(name, validateOperationId(opts.launch_operation_id), claudeLaunchRequestDigest({ sessionName: name, model: opts.model ?? null, effort: opts.reasoning_effort ?? null,
8465
8664
  cwd: opts.cwd ?? null, agentDone: true }));
8665
+ // E8: every secret name takes this launch's value (private line, then env). The Claude login keeps 4b: named or
8666
+ // env_vars omitted -> this launch's value, else unset (root login); every other name without a value refuses.
8667
+ const isLogin = (key) => kind === "claude" && key === CLAUDE_LOGIN_ENV;
8668
+ const secretNames = [...new Set([...recipeSecretNames(recipe), ...(kind === "claude" && opts.env_vars?.includes(CLAUDE_LOGIN_ENV) ? [CLAUDE_LOGIN_ENV] : [])])];
8669
+ const secretValues = Object.fromEntries(secretNames.map(key => [key,
8670
+ isLogin(key) && opts.env_vars !== undefined && !opts.env_vars.includes(key) ? null : launchEnvValue(key) ?? null]));
8671
+ const missing = secretNames.filter(key => secretValues[key] === null && !isLogin(key));
8672
+ if (missing.length)
8673
+ throw new AgentResumeSecretsError("AGENT_RESUME_SECRET_MISSING", name, missing);
8674
+ // A terminal seat's forward port P may have changed: the caller MCP file takes the new URLs, same servers only.
8675
+ if (opts.mcp_config != null && (kind === "claude" ? previous.claude_caller_mcp_file : previous.codex_caller_mcp_file)) {
8676
+ const file = (kind === "claude" ? previous.claude_caller_mcp_file : previous.codex_caller_mcp_file);
8677
+ const serverNames = (config) => Object.keys((config ?? {}).mcpServers ?? {}).sort();
8678
+ if (!isDeepStrictEqual(serverNames(JSON.parse(fs.readFileSync(file, "utf8"))), serverNames(opts.mcp_config)))
8679
+ throw new AitermError("AGENT_RESUME_CONFLICT: 同名の休止席は保存したMCP serverの名前で再開します。", 2);
8680
+ (kind === "claude" ? writeClaudeCallerFiles : writeCodexCallerFiles)({ ...previous }, null, opts.mcp_config);
8681
+ }
8466
8682
  if (preparedLifecycle)
8467
8683
  commitWorkingAgentResume(previous, preparedLifecycle);
8468
- const claudeLogin = kind === "claude" && opts.env_vars !== undefined
8469
- ? { value: opts.env_vars.includes(CLAUDE_LOGIN_ENV) ? launchEnvValue(CLAUDE_LOGIN_ENV) ?? null : null } : undefined;
8470
- const resumed = await resumeAgentInLock(name, opts.ready_timeout ?? undefined, rootChange, claudeLogin);
8684
+ const resumed = await resumeAgentInLock(name, opts.ready_timeout ?? undefined, rootChange, secretValues);
8471
8685
  return withAgentResumeTarget(resumed, async () => {
8472
8686
  const hint = `${agentLabel(kind)} を保存した同じ会話へ再開した。\n${attachHint(name)}`;
8473
8687
  const fastState = { fast: resumed.fast === true, fast_error: null };
package/dist/errors.js CHANGED
@@ -52,6 +52,17 @@ export class AgentResumeError extends AitermError {
52
52
  session_id: sessionId, launch_id: launchId, input: "not_sent", recovery: "inspect_session" };
53
53
  }
54
54
  }
55
+ /** E8: a resume needs secret values only the caller's agent_launch carries; nothing was started or sent, the seat stays hibernated. */
56
+ export class AgentResumeSecretsError extends AitermError {
57
+ resumeSecrets;
58
+ constructor(code, sessionId, names) {
59
+ super(`${code}: ${code === "AGENT_RESUME_SECRET_MISSING"
60
+ ? `再開に要る秘密の値がこの起動にありません(${names.join(", ")})。`
61
+ : `この席の再開には秘密の値が要ります(${names.join(", ")})。agent_launch(session_name)で値を渡して再開してください。`}新規起動も本文送信もしていません。`, 2);
62
+ this.resumeSecrets = { schema: "aiterm.agent-resume-secrets.v1", code, session_id: sessionId, names,
63
+ effect: "not_started", input: "not_sent", state: "hibernated" };
64
+ }
65
+ }
55
66
  export class TelemetryOwnedError extends AitermError {
56
67
  telemetryCode;
57
68
  constructor(message, code, telemetryCode, cause) {
@@ -147,7 +147,8 @@ function nativeParentDependencies(provider, profile) {
147
147
  else
148
148
  await provider.verifyCodexParent(profile, parent);
149
149
  },
150
- processes: readProcessIdentities, exists: nativeProcessExists, now: () => performance.now(), wall: () => Date.now() };
150
+ processes: readProcessIdentities, exists: nativeProcessExists, childGone: core.deliveryChildGone, childCheckMs: 30_000,
151
+ now: () => performance.now(), wall: () => Date.now() };
151
152
  }
152
153
  /** Historical injected worker; normal parent-hook CLI no longer uses it. */
153
154
  export function createNativeExecutionWorker(input) {
@@ -56,6 +56,14 @@ export function antigravityAuthStatus(bin, cwd, env = process.env) {
56
56
  return { status: "unauthenticated", message: "Antigravity CLIのGoogleサインインが必要です" };
57
57
  return { status: "failed", message: "Antigravity CLIの認証状態を確認できません" };
58
58
  }
59
+ /**
60
+ * The empty composer under the `? for shortcuts` footer: a bare `>` line, or the mode hint agy 1.5.7 draws there until
61
+ * the first key (`> Auto mode: edits & safe commands auto-approved (shift+tab to cycle)`; the hint may wrap at the pane edge).
62
+ */
63
+ export function antigravityEmptyComposer(screen) {
64
+ return /\? for shortcuts/.test(screen)
65
+ && /^\s*>\s*(?:[A-Z][\w-]* mode: [^\n]*(?:\n[^\n─>]*)?\(shift\+tab\s+to\s+cycle\)\s*)?$/m.test(screen);
66
+ }
59
67
  export function antigravityAuthPane(screen) {
60
68
  if (/\binvalid_grant\b/i.test(screen))
61
69
  return { url: null, user_code: null, input_required: false,
@@ -70,7 +78,7 @@ export function antigravityAuthPane(screen) {
70
78
  }
71
79
  const url = authUrl(urlLines.join(""), ["accounts.google.com"]);
72
80
  const complete = /Do you trust the contents of this project\?/.test(screen)
73
- || (/\? for shortcuts/.test(screen) && /^\s*>\s*$/m.test(screen));
81
+ || antigravityEmptyComposer(screen);
74
82
  const base = { url, user_code: null, input_required: false, message: null, onboarding_complete: complete };
75
83
  if (complete)
76
84
  return base;
@@ -134,7 +142,7 @@ export function antigravityPaneObservation(screen) {
134
142
  return { state: "blocked", reason: "vendor_action_required" };
135
143
  if (/(?:Generating|Working)(?:\.{3}|…)|esc to interrupt/i.test(screen))
136
144
  return { state: "busy", reason: "vendor_generating" };
137
- if (/\? for shortcuts/.test(screen) && /^\s*>\s*$/m.test(screen))
145
+ if (antigravityEmptyComposer(screen))
138
146
  return { state: "idle", reason: "composer_ready" };
139
147
  return { state: "unknown", reason: "vendor_state_unknown" };
140
148
  }
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { terminalCwdFits } from "./remote-path.js";
6
6
  import { launchEnvValue } from "./private-env.js";
7
7
  import { AuthResponseError, authUiSchema, authBindingSchema, authResponseSchema } from "./agent-auth-ui.js";
8
8
  import { configurationRequestSchema, configurationToolOutputSchema, applyConfigurationRequest, reconcileConfigurationRequest } from "./configure-request.js";
9
- import { AitermError, AgentResumeUnavailableError, AgentResumeError, launchInputRefusal } from "./errors.js";
9
+ import { AitermError, AgentResumeUnavailableError, AgentResumeError, AgentResumeSecretsError, launchInputRefusal } from "./errors.js";
10
10
  /**
11
11
  * aiterm-mcp — AI が握るローカル永続端末を stdio MCP サーバとして公開する(Node/TS 版)。
12
12
  *
@@ -241,6 +241,9 @@ export function createAitermServer(options = {}) {
241
241
  if (e instanceof AgentResumeUnavailableError)
242
242
  return { content: [{ type: "text", text: "aiterm: " + msg }], isError: true,
243
243
  _meta: { "aiterm/resume_unavailable": { ...e.resumeUnavailable } } };
244
+ if (e instanceof AgentResumeSecretsError)
245
+ return { content: [{ type: "text", text: "aiterm: " + msg }], isError: true,
246
+ structuredContent: { ...e.resumeSecrets } };
244
247
  if (e instanceof AgentResumeError)
245
248
  return { content: [{ type: "text", text: "aiterm: " + msg }], isError: true,
246
249
  structuredContent: { ...e.resumeFailure } };
@@ -874,7 +877,7 @@ export function createAitermServer(options = {}) {
874
877
  // two readers of one seat at once leave one of them without the span lock (that seat comes back in its `unread`).
875
878
  // Relays start before the synchronous local read so the terminal works meanwhile; their 4 s counts only time this
876
879
  // process's event loop was free (loopDeadline), since a blocked loop cannot take the answer however soon it came.
877
- const relays = Promise.all(terminalSeatGroups().map(({ target, sessions: bound }) => {
880
+ const relays = Promise.all(terminalSeatGroups().map(({ target, sessions: bound, route_since }) => {
878
881
  const key = JSON.stringify([target, requestMeta]);
879
882
  let call = remoteSeatTurnsInFlight.get(key);
880
883
  if (!call) {
@@ -886,7 +889,7 @@ export function createAitermServer(options = {}) {
886
889
  }
887
890
  return Promise.race([
888
891
  call.then(answer => Array.isArray(answer?.seats)
889
- ? { seats: answer.seats.filter((seat) => bound.includes(seat?.session_id)),
892
+ ? { seats: answer.seats.filter((seat) => bound.includes(seat?.session_id)).map((seat) => ({ ...seat, route_since })),
890
893
  unread: Array.isArray(answer.unread) ? answer.unread.filter((name) => bound.includes(name)) : [] }
891
894
  : { seats: [], unread: bound }),
892
895
  loopDeadline(4_000, { seats: [], unread: bound }),
@@ -895,6 +898,16 @@ export function createAitermServer(options = {}) {
895
898
  // callRemoteTool spawns its ssh only after an await: let the relays start before this process blocks on the local read.
896
899
  await new Promise(resolve => setImmediate(resolve));
897
900
  const local = core.readSeatTurns(sessions.filter(session => session.harness !== null).map(session => session.session_id));
901
+ // a41: own_work only for a caller that sends its exclusion list (observation-results.md); terminals compute their own rows.
902
+ const ownWork = requestMeta && typeof requestMeta === "object" ? requestMeta["aiterm/own_work_exclusions"] : undefined;
903
+ if (ownWork !== undefined) {
904
+ const work = await core.seatOwnWork(local.seats.map(seat => seat.session_id), ownWork);
905
+ for (const seat of local.seats) {
906
+ const value = work.get(seat.session_id);
907
+ if (value)
908
+ Object.assign(seat, { own_work: value });
909
+ }
910
+ }
898
911
  const remote = await relays;
899
912
  return { _meta: { [SEAT_TURNS_RESULT_META_KEY]: { ...local, seats: [...local.seats, ...remote.flatMap(r => r.seats)], unread: [...local.unread, ...remote.flatMap(r => r.unread)] } } };
900
913
  }
@@ -3,15 +3,29 @@
3
3
  import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
5
  import { createHash } from "node:crypto";
6
- import { ensureStateRoot } from "./agent-shared.js";
6
+ import { agentHarness, agentMetadataPath, agentsDir, ensureStateRoot } from "./agent-shared.js";
7
7
  const DELIVERY_DIRECTORIES = ["parent-deliveries", "claude-parent-deliveries", "cursor-parent-deliveries"];
8
8
  /** 持ち主の保存場所の名前の先頭。pidの使い回しと取り違えないよう、開始時刻も入れる。 */
9
9
  export function deliveryOwnerPrefix(owner) {
10
10
  return `${owner.pid}-${createHash("sha256").update(owner.started_identity).digest("hex").slice(0, 16)}-`;
11
11
  }
12
- /** 渡したprocessのどれかが持ち主で、まだ親へ届け終えていない配送の数。届け終えた記録はactiveから出ている。 */
13
- export function unfinishedDeliveriesOwnedBy(processes, stateRoot = ensureStateRoot()) {
12
+ /**
13
+ * The unfinished deliveries that `seat` waits for (parent-delivery.md "親の席への数え方"): a local child's metadata names its
14
+ * parent seat (`parent_session_id`). Only when that names no Aiterm seat here, the child is on another terminal, or its metadata
15
+ * cannot be read, the owner process in the seat's subtree decides, as before 0.70.42. A manager that adopted a dead owner's
16
+ * records is not charged for them.
17
+ */
18
+ export function pendingChildResultsFor(seat, processes, excluded = () => false, stateRoot = ensureStateRoot()) {
14
19
  const prefixes = processes.map(deliveryOwnerPrefix);
20
+ // A parent named by a child is a seat here when Aiterm holds an agent record for that name (host-root and the like are not).
21
+ let listing = null;
22
+ const isSeat = (name) => (listing ??= (() => { try {
23
+ return fs.readdirSync(agentsDir());
24
+ }
25
+ catch {
26
+ return [];
27
+ } })())
28
+ .some(file => file.startsWith(`${name}.`) && file.endsWith(".agent.json"));
15
29
  let count = 0;
16
30
  for (const prefix of ["", "remote-"]) {
17
31
  for (const directory of DELIVERY_DIRECTORIES) {
@@ -26,14 +40,37 @@ export function unfinishedDeliveriesOwnedBy(processes, stateRoot = ensureStateRo
26
40
  throw error;
27
41
  }
28
42
  for (const owner of owners) {
29
- if (!owner.isDirectory() || !prefixes.some(candidate => owner.name.startsWith(candidate)))
43
+ if (!owner.isDirectory())
30
44
  continue;
45
+ const ownedHere = prefixes.some(candidate => owner.name.startsWith(candidate));
46
+ let names;
31
47
  try {
32
- count += fs.readdirSync(path.join(active, owner.name)).filter(name => name !== "owner.json" && name.endsWith(".json")).length;
48
+ names = fs.readdirSync(path.join(active, owner.name)).filter(name => name !== "owner.json" && name.endsWith(".json"));
33
49
  }
34
50
  catch (error) {
35
- if (error.code !== "ENOENT")
36
- throw error;
51
+ if (error.code === "ENOENT")
52
+ continue;
53
+ throw error;
54
+ }
55
+ for (const name of names) {
56
+ let child = null, parent = null;
57
+ try {
58
+ const boundary = JSON.parse(fs.readFileSync(path.join(active, owner.name, name), "utf8"))?.boundary;
59
+ if (typeof boundary?.session_id === "string")
60
+ child = { session: boundary.session_id, harness: null };
61
+ if (child && !boundary.remote && typeof boundary.launch_id === "string") {
62
+ const meta = JSON.parse(fs.readFileSync(agentMetadataPath(child.session, boundary.launch_id), "utf8"));
63
+ child.harness = typeof meta?.kind === "string" ? agentHarness(meta.kind) : null;
64
+ if (typeof meta?.parent_session_id === "string" && isSeat(meta.parent_session_id))
65
+ parent = meta.parent_session_id;
66
+ }
67
+ }
68
+ catch { /* unreadable record or child: the owner decides */ }
69
+ if (!(parent === null ? ownedHere : parent === seat))
70
+ continue;
71
+ if (child && excluded(child))
72
+ continue;
73
+ count++;
37
74
  }
38
75
  }
39
76
  }
@@ -4,6 +4,7 @@ import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
5
  import { randomUUID } from "node:crypto";
6
6
  import { z } from "zod";
7
+ import { deliveryChildGone } from "./core.js";
7
8
  import { ensureStateRoot, writeJson0600 } from "./agent-shared.js";
8
9
  import { readProcessIdentities } from "./process-runtime.js";
9
10
  import { deliveryOwnerPrefix } from "./parent-delivery-owners.js";
@@ -118,7 +119,7 @@ export class ParentDeliveryManager {
118
119
  constructor(options = {}) {
119
120
  this.execution = options.execution;
120
121
  this.deps = { observe: observeAnywhere, answer: answerAnywhere, submit: submitParentAnswer,
121
- verify: verifyParent, processes: readProcessIdentities, exists: processExists,
122
+ verify: verifyParent, processes: readProcessIdentities, exists: processExists, childGone: deliveryChildGone, childCheckMs: 30_000,
122
123
  now: () => performance.now(), wall: () => Date.now(), ...options.dependencies,
123
124
  ...(options.execution ? { submit: options.execution.submit } : {}) };
124
125
  if (options.state_root !== undefined && !path.isAbsolute(options.state_root))
@@ -414,19 +415,34 @@ export class ParentDeliveryManager {
414
415
  }
415
416
  watch(job) {
416
417
  const boundary = job.record.boundary;
418
+ // A child that can no longer complete this boundary (replaced, gone, hibernated) ends the wait: before 0.70.42 it never did.
419
+ const childStop = new AbortController();
420
+ let gone = null, seen = null;
421
+ const check = setInterval(() => {
422
+ const reason = this.deps.childGone(boundary);
423
+ if (reason && reason === seen) {
424
+ gone = reason;
425
+ childStop.abort();
426
+ }
427
+ seen = reason;
428
+ }, this.deps.childCheckMs);
429
+ check.unref?.();
417
430
  job.task = (async () => {
418
431
  try {
419
432
  const completion = await this.deps.observe(boundary.session_id, {
420
433
  cursor: boundary.event_cursor, operation_id: boundary.operation_id,
421
434
  ...(boundary.input_id ? { input_id: boundary.input_id } : {}),
422
- timeout: Infinity, signal: job.controller.signal, ...(boundary.remote ? { remote: boundary.remote } : {}),
435
+ timeout: Infinity, signal: AbortSignal.any([job.controller.signal, childStop.signal]), ...(boundary.remote ? { remote: boundary.remote } : {}),
423
436
  });
424
437
  await this.capture(job, completion);
425
438
  }
426
439
  catch (error) {
427
440
  if (job.controller.signal.aborted)
428
441
  return;
429
- await this.captureFailure(job, error);
442
+ await this.captureFailure(job, gone ? new AitermError(`PARENT_DELIVERY_CHILD_GONE: ${gone}`, 2) : error);
443
+ }
444
+ finally {
445
+ clearInterval(check);
430
446
  }
431
447
  })().catch((error) => this.reportServiceError(error));
432
448
  }
@@ -266,7 +266,13 @@ export class SshStdioTransport {
266
266
  child.on("error", error => this.onerror?.(error));
267
267
  child.on("close", () => { this.child = null; this.onclose?.(); });
268
268
  child.stdin.on("error", error => this.onerror?.(error));
269
- child.stdin.write(this.privateLine);
269
+ if (this.privateLine)
270
+ child.stdin.write(this.privateLine);
271
+ }
272
+ /** A kept session must not keep an idle process alive; it holds the loop only while a request waits on it. */
273
+ hold(on) {
274
+ for (const handle of [this.child, this.child?.stdin, this.child?.stdout, this.child?.stderr])
275
+ on ? handle?.ref?.() : handle?.unref?.();
270
276
  }
271
277
  async send(message) {
272
278
  if (!this.child?.stdin)
@@ -747,7 +753,7 @@ export function terminalSeatGroups() {
747
753
  for (const [session, ref] of Object.entries(readSeats()))
748
754
  groups.set(ref, [...groups.get(ref) ?? [], session]);
749
755
  return [...groups].flatMap(([ref, sessions]) => { try {
750
- return [{ target: trustedTarget(binding(ref)), sessions }];
756
+ return [{ target: trustedTarget(binding(ref)), sessions, route_since: forwardRouteSince(ref) }];
751
757
  }
752
758
  catch {
753
759
  return [];
@@ -869,7 +875,8 @@ function markReady(ref, ready) {
869
875
  return;
870
876
  const file = lockFile(ref), staged = `${file}.${process.pid}`;
871
877
  try {
872
- fs.writeFileSync(staged, JSON.stringify(ready ? { ...lockIdentity(), ready } : lockIdentity()), { mode: 0o600 });
878
+ // ready_at (E9): when this ssh -R became ready; a newer one tells BellTeam the seats' route was rebuilt.
879
+ fs.writeFileSync(staged, JSON.stringify(ready ? { ...lockIdentity(), ready, ready_at: new Date().toISOString() } : lockIdentity()), { mode: 0o600 });
873
880
  fs.renameSync(staged, file);
874
881
  }
875
882
  catch {
@@ -911,6 +918,11 @@ function forwardReady(ref, port) {
911
918
  return false;
912
919
  return Number(owner.pid) === process.pid ? Boolean(keepers.get(ref)?.child) : ownerAlive(owner);
913
920
  }
921
+ /** E9: when the seats' current reverse forward was established; null when it is not ready or the time is unknown. */
922
+ export function forwardRouteSince(ref) {
923
+ const port = binding(ref).seat_forward_port, readyAt = lockOwner(ref)?.ready_at;
924
+ return port && typeof readyAt === "string" && forwardReady(ref, port) ? readyAt : null;
925
+ }
914
926
  // T3: a launch in any process keeps the forward needed (the seat is bound only after it), so the owner never stops it meanwhile.
915
927
  const launchFile = (ref) => path.join(ensureStateRoot(), `terminal-forward-${ref}.launch`);
916
928
  function forwardNeeded(ref) {
package/dist/remote.js CHANGED
@@ -223,6 +223,60 @@ export function remoteServerCommand(shell) {
223
223
  }
224
224
  export const REMOTE_CLIENT_NAME = "aiterm-remote";
225
225
  /** 現地のaiterm-mcpへ1回だけMCP接続し、指定toolを呼んで閉じる。privateEnvは暗号化されたstdinの先頭行だけで渡す(remote-terminal.md R5)。 */
226
+ // a37: a trusted terminal keeps one warm MCP session (ssh + its aiterm-mcp, initialized) for calls without private values,
227
+ // so a call costs one round trip instead of a shell start, a node start and initialize. A sent request is never replayed.
228
+ const WARM_IDLE_MS = 2 * 60_000, WARM_MAX_AGE_MS = 10 * 60_000;
229
+ const warmSessions = new Map();
230
+ function retireWarm(ref, session) {
231
+ if (warmSessions.get(ref) === session)
232
+ warmSessions.delete(ref);
233
+ if (session.idle)
234
+ clearTimeout(session.idle);
235
+ if (!session.inflight)
236
+ void session.client.close().catch(() => { });
237
+ }
238
+ function warmSession(target, sshArgs) {
239
+ const ref = target.trusted_ref;
240
+ const kept = warmSessions.get(ref);
241
+ if (kept && !kept.dead && Date.now() - kept.born < WARM_MAX_AGE_MS)
242
+ return kept;
243
+ if (kept)
244
+ retireWarm(ref, kept);
245
+ const transport = new SshStdioTransport(sshArgs, ""), client = new Client({ name: REMOTE_CLIENT_NAME, version: pkg.version });
246
+ const session = { client, transport, born: Date.now(), inflight: 0, idle: null, dead: false,
247
+ ready: client.connect(transport, { timeout: 60_000 }).catch(() => {
248
+ retireWarm(ref, session);
249
+ const failure = classifySshFailure(transport.stderr);
250
+ throw new AitermError(`${failure.code}: ${failure.message}${failure.action ? ` (${failure.action})` : ""}`, 2);
251
+ }) };
252
+ client.onclose = () => { session.dead = true; if (warmSessions.get(ref) === session)
253
+ warmSessions.delete(ref); };
254
+ warmSessions.set(ref, session);
255
+ return session;
256
+ }
257
+ async function callWarm(target, sshArgs, request, timeoutMs) {
258
+ const session = warmSession(target, sshArgs);
259
+ session.inflight++;
260
+ if (session.idle) {
261
+ clearTimeout(session.idle);
262
+ session.idle = null;
263
+ }
264
+ session.transport.hold(true);
265
+ try {
266
+ await session.ready;
267
+ const result = await session.client.callTool(request, undefined, { timeout: timeoutMs, resetTimeoutOnProgress: true });
268
+ return { result, version: session.client.getServerVersion()?.version ?? null };
269
+ }
270
+ finally {
271
+ if (--session.inflight === 0) {
272
+ session.transport.hold(false);
273
+ if (session.dead || warmSessions.get(target.trusted_ref) !== session)
274
+ void session.client.close().catch(() => { });
275
+ else
276
+ session.idle = setTimeout(() => retireWarm(target.trusted_ref, session), WARM_IDLE_MS).unref();
277
+ }
278
+ }
279
+ }
226
280
  export async function callRemoteTool(target, name, args, timeoutMs = 600_000, privateEnv, meta) {
227
281
  if (privateEnv && !target.trusted_ref)
228
282
  throw new AitermError("REMOTE_PRIVATE_ENV_UNSUPPORTED: private values travel only to a terminal binding", 2);
@@ -231,6 +285,20 @@ export async function callRemoteTool(target, name, args, timeoutMs = 600_000, pr
231
285
  const command = target.trusted_ref ? terminalCommand(shell, terminalProgram(privateEnv ? ["aiterm-mcp", "--private-env-stdin"] : ["aiterm-mcp"]))
232
286
  : privateEnv ? posixCommand("exec aiterm-mcp --private-env-stdin") : remoteServerCommand(shell);
233
287
  const { args: sshArgs, env } = sshInvocation(target, command);
288
+ // Request _meta is opaque to the relay; progressToken belongs to this hop's client, not the caller's.
289
+ const { progressToken: _hop, ...forwarded } = meta ?? {};
290
+ const request = Object.keys(forwarded).length ? { name, arguments: args, _meta: forwarded } : { name, arguments: args };
291
+ const shape = (result, version) => ({
292
+ content: result.content ?? [],
293
+ ...(result.structuredContent ? { structuredContent: result.structuredContent } : {}),
294
+ ...(result.isError ? { isError: true } : {}),
295
+ ...(result._meta ? { _meta: result._meta } : {}),
296
+ remote_version: version,
297
+ });
298
+ if (target.trusted_ref && !privateEnv) {
299
+ const { result, version } = await callWarm(target, sshArgs, request, timeoutMs);
300
+ return shape(result, version);
301
+ }
234
302
  const transport = privateEnv
235
303
  ? new SshStdioTransport(sshArgs, `${JSON.stringify({ schema: PRIVATE_ENV_SCHEMA, env: privateEnv })}\n`)
236
304
  : new StdioClientTransport({ command: "ssh", args: sshArgs, env, stderr: "pipe" });
@@ -252,17 +320,8 @@ export async function callRemoteTool(target, name, args, timeoutMs = 600_000, pr
252
320
  const detail = stderr.trim().split("\n").slice(-3).join(" / ") || (error instanceof Error ? error.message : String(error));
253
321
  throw new AitermError(`REMOTE_CONNECT_FAILED: ${remoteLabel(target)} のAitermへ接続できません(${detail})`, 2);
254
322
  }
255
- // Request _meta is opaque to the relay; progressToken belongs to this hop's client, not the caller's.
256
- const { progressToken: _hop, ...forwarded } = meta ?? {};
257
- const request = Object.keys(forwarded).length ? { name, arguments: args, _meta: forwarded } : { name, arguments: args };
258
323
  const result = await client.callTool(request, undefined, { timeout: timeoutMs, resetTimeoutOnProgress: true });
259
- return {
260
- content: result.content ?? [],
261
- ...(result.structuredContent ? { structuredContent: result.structuredContent } : {}),
262
- ...(result.isError ? { isError: true } : {}),
263
- ...(result._meta ? { _meta: result._meta } : {}),
264
- remote_version: client.getServerVersion()?.version ?? null,
265
- };
324
+ return shape(result, client.getServerVersion()?.version ?? null);
266
325
  }
267
326
  finally {
268
327
  await client.close().catch(() => { });
@@ -87,7 +87,7 @@ export function validateResumeCheckpoint(input) {
87
87
  || recipe.kind !== 'codex' || recipe.vendor_session_id !== scope.vendor_session_id || recipe.configuration_root !== scope.configuration_root
88
88
  || recipe.fast !== false || recipe.cwd !== m.cwd || recipe.executable !== m.agent_executable || recipe.model !== (m.model ?? null))
89
89
  refuse();
90
- if (Object.keys(recipe.environment).some(key => /(?:TOKEN|KEY|SECRET|PASSWORD|PASSWD|CREDENTIALS?|AUTH)$/i.test(key)))
90
+ if (recipe.secret_environment?.length || Object.keys(recipe.environment).some(key => /(?:TOKEN|KEY|SECRET|PASSWORD|PASSWD|CREDENTIALS?|AUTH)$/i.test(key)))
91
91
  refuse();
92
92
  const lineage = ['agent_role', 'parent_session_id', 'delegation_depth', 'lineage', 'delegation_allowed'];
93
93
  if (lineage.some(k => m[k] !== undefined) && lineage.some(k => m[k] === undefined))
@@ -120,7 +120,7 @@ export function validateResumeCheckpoint(input) {
120
120
  refuse();
121
121
  const template = get(id, 'template', false);
122
122
  if (template && (template.kind !== 'codex' || template.configuration_root !== scope.configuration_root
123
- || Object.keys(template.environment).some(key => /(?:TOKEN|KEY|SECRET|PASSWORD|PASSWD|CREDENTIALS?|AUTH)$/i.test(key))))
123
+ || template.secret_environment?.length || Object.keys(template.environment).some(key => /(?:TOKEN|KEY|SECRET|PASSWORD|PASSWD|CREDENTIALS?|AUTH)$/i.test(key))))
124
124
  refuse();
125
125
  const failure = get(id, 'failure', false);
126
126
  if (failure && failure.session_id !== scope.session_id)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.40",
3
+ "version": "0.70.42",
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": [