aiterm-mcp 0.70.43 → 0.70.45

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,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.45] - 2026-11-13
11
+
12
+ - A Claude seat now reads `idle` in seat-turns right after `agent_configure`. The `/model`, `/effort` or `/fast` it types is a local command that runs no turn and prints no "for Ns" completion line, so the reader kept such a seat `null` (unknown) on every read until the next delivered turn. The command's own `⎿` result line now counts as the finished-state cue; any other screen without a completion line is still unknown.
13
+
14
+ ## [0.70.44] - 2026-11-13
15
+
16
+ - A seat's own work (`pty_observe` `activity.post_startup_process_count` and seat-turns `own_work.processes`) now counts only what runs under the harness's own command-execution shell: Claude's Bash (incl. `run_in_background`), Codex exec, and the Grok and Cursor tool shells, recognised per OS by their wrapper shapes (ADR 0141). MCP servers, hooks, relays, helpers and Aiterm's own process-table reads are never counted, so an idle seat with a waiting hook or a restarted MCP server reads 0 and can hibernate. No startup snapshot is used any more, so seats launched by older versions are counted too (0 instead of null). Antigravity commands are not counted yet (exec shape not captured).
17
+
10
18
  ## [0.70.43] - 2026-11-13
11
19
 
12
20
  - A kept (hibernated) seat can be closed, sent to, resumed or deleted on a fresh container before any launch: the send locks create the socket directory (`claude-tmux-sockets`) when it is missing, as a launch does. Before, the first `pty_close` / `pty_send` failed with `ENOENT ... <name>.agent-send.lock` until some other seat had been launched (a46 lab, 2026-11-13).
@@ -3397,7 +3405,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3397
3405
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3398
3406
  provenance.
3399
3407
 
3400
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.43...HEAD
3408
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.45...HEAD
3409
+ [0.70.45]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.44...v0.70.45
3410
+ [0.70.44]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.43...v0.70.44
3401
3411
  [0.70.43]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.42...v0.70.43
3402
3412
  [0.70.42]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.41...v0.70.42
3403
3413
  [0.70.41]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.40...v0.70.41
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.43** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.70.45** · 動作対象は 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.43** · 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.45** · 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
 
@@ -592,15 +592,12 @@ A confirmed hibernation keeps the same logical session in `pty_list`, with the s
592
592
  Codex can start a native queued turn during resume. At standard speed, Aiterm accepts that busy state only with the saved conversation proof, a new `task_started` after the hibernation cursor and the same live native launch. A busy screen alone is insufficient. This path does not capture user work as startup scaffolding: its post-startup process count remains unknown and automatic hibernation stays disabled for that launch. Fast restoration still requires an idle composer. Failed attempts remain blocked. Resume failures return `isError: true` and `structuredContent` with schema `aiterm.agent-resume-error.v1`, code `AGENT_RESUME_UNCONFIRMED` or `AGENT_RESUME_FAILED`, `session_id`, `launch_id`, `input: "not_sent"` and `recovery: "inspect_session"`. The input status describes only this request's body; it does not prove that the CLI was never started or that other native input was not processed. Inspect the seat; do not automatically resend or restart it.
593
593
 
594
594
  Two fields tell a caller what closing an agent session would lose. `activity.post_startup_process_count` is the number of
595
- processes in the session that did not exist when `agent_launch` finished startup (before the first prompt), so background work
596
- started in the first minute is counted too. Two kinds of process are not counted: Codex's own `codex-code-mode-host` helper, and
597
- the direct children of an `mcp-lazy` relay (the MCP server it starts on first use and its wake predicate). What runs below them
598
- is counted. A startup process that the harness restarted (a process with the same parent and the same arguments as a startup
599
- process that has exited, such as a reconnected MCP server) is not counted either, and neither are the processes Aiterm itself
600
- starts to read the process table (`ps`, or PowerShell and its console host on Windows). `pending_child_deliveries`
595
+ processes running under the harness's own command-execution shell: the shell the CLI starts to run a command for the model
596
+ (Claude's Bash tool, including `run_in_background`; Codex exec; the Grok, Cursor and Antigravity tool shells), and everything
597
+ below it. MCP servers, hooks, relays, helpers and Aiterm's own process-table reads are not counted, however long they run
598
+ (ADR 0141, 0.70.44; the name is kept from the older startup-snapshot rule). `pending_child_deliveries`
601
599
  is the number of sub-agent results this session is still waiting for as a parent, whoever the caller is. Both are null when
602
- Aiterm cannot tell (ordinary terminals, agents launched by 0.48.0 or earlier for the process count, or an unresolved harness
603
- process), and may be absent when a remote host runs an older Aiterm. Treat null or absent as unknown, not as zero.
600
+ Aiterm cannot tell (ordinary terminals, an unresolved harness process, or an unreadable process table), and may be absent when a remote host runs an older Aiterm. Treat null or absent as unknown, not as zero.
604
601
 
605
602
  Another product that needs to deliver an answer to a Codex parent can ask Aiterm with `aiterm-parent-delivery` instead of registering its own hooks.
606
603
  Aiterm's registered hooks and the official queue deliver it. `codex verify --thread <uuid>` checks the parent and reports configuration in `steer`
@@ -351,7 +351,8 @@ export function parentPaneEvidence(kind, screen) {
351
351
  return "unknown";
352
352
  if (kind === "claude" && observed.state === "idle" && /^⏺ Compacted while idle\b/u.test(current))
353
353
  return "ready_compacted";
354
- if (kind === "claude" && observed.state === "idle"
354
+ // Aiterm's configure commands are local and run no turn: their own ⎿ result line, not a completed-progress line, ends them.
355
+ if (kind === "claude" && observed.state === "idle" && !/^\s*❯ \/(?:model|effort|fast)\b[^\n]*\n\s*⎿\s+\S/u.test(current)
355
356
  && !/^[·✢✳✶✻✽*∗] [^…\n]+ for \d[^…\n]*$/mu.test(current))
356
357
  return "ready_no_completion";
357
358
  if (kind === "cursor") {
package/dist/core.js CHANGED
@@ -52,7 +52,7 @@ import { isCursorMcpClient } from "aiterm-steer-delivery";
52
52
  import { antigravityBinding, antigravityAuthChoiceKey, antigravityCurrentModel, antigravityStartupAction, antigravityAgentArgv, writeAntigravityCallerFiles, checkAntigravityCallerInput, antigravityPromptWithCaller, antigravityQuotaLimit, antigravityModelChoices, antigravityAuthStatus, antigravityAuthPane, antigravityTranscriptText, bindAntigravitySession, createAntigravityAgentMetadata, mergeAntigravityHooks } from "./harnesses/antigravity.js";
53
53
  import { paneTokenHint } from "./harnesses/pane-tokens.js";
54
54
  import { pendingChildResultsFor } from "./parent-delivery-owners.js";
55
- import { readLinuxProcessRegistrationIdentity, readClaudeRegistrationIdentity, readProcessEnvironment, readRuntimeProcesses, readRuntimeProcessesShared, readProcessIdentities, processSubtree, parentProcess, processIdentity, signalRuntimeProcess, backgroundProcesses, lazyRelayProcess, aitermProcessProbe, windowsConsoleHost, macKeepAwakeProcess, processElapsedSeconds } from "./process-runtime.js";
55
+ import { readLinuxProcessRegistrationIdentity, readClaudeRegistrationIdentity, readProcessEnvironment, readRuntimeProcesses, readRuntimeProcessesShared, readProcessIdentities, processSubtree, parentProcess, processIdentity, signalRuntimeProcess, backgroundProcesses, processElapsedSeconds } from "./process-runtime.js";
56
56
  import { liveNodeExecutable } from "./live-node.js";
57
57
  import { resolveClaudeConfigurationRoot, withClaudeConfigRoot, withClaudeSlotLogin } from "./claude-config-root.js";
58
58
  import { probeWriteBan, writeBanPrefix, windowsWriteBanArgv } from "./write-ban.js";
@@ -150,6 +150,36 @@ const AGENT_COMMAND_PATTERNS = {
150
150
  grok: /(^|[\s/])grok(-[^\s/]+)?([\s]|$)/,
151
151
  cursor: /(^|[\s/])(cursor-agent|agent)([\s]|$)/,
152
152
  };
153
+ // The shell each harness starts to run a model's command (ADR 0141; fixtures in test/own-exec-processes.test.mjs).
154
+ // Hooks, MCP servers and helpers are started another way, so they never match. Matched on the table's command line.
155
+ const AGENT_EXEC_SHELLS = {
156
+ // Bash tool and run_in_background (bash/zsh; Git Bash on Windows): the command ends by writing its cwd to claude-<hex>-cwd.
157
+ // Hooks are `sh -c <hook>`, Git Bash or pwsh without that file.
158
+ claude: command => /claude-[0-9a-f]+-cwd\b/.test(command),
159
+ // exec / unified exec: POSIX [shell, -c|-lc, command]; Windows pwsh -Command starting with its UTF-8 console line.
160
+ // Hooks and MCP servers are spawned with their own argv (Windows hooks: pwsh -NoProfile -Command "& ...").
161
+ codex: command => /^\s*\S+\s+-l?c\s/.test(command)
162
+ || command.includes(" -Command \"try { [Console]::OutputEncoding=[System.Text.Encoding]::UTF8 } catch {}"),
163
+ // POSIX: the fd-5 wrapper. Windows: pwsh -ExecutionPolicy Bypass -Command <command>; hooks carry the $__grokExitCode tail.
164
+ grok: command => command.includes("__grok_user_cmd") || (/ -ExecutionPolicy Bypass -Command /.test(command) && !command.includes("__grokExitCode")),
165
+ // Cursor runs hooks through the same wrapper but passes them stdin (pipeStdin); a model's command gets none:
166
+ // bash/zsh `builtin eval "$1"[ 3<&- 4>&-] < /dev/null`, Windows pwsh `-NonInteractive -File …ps-script-<uuid>.ps1`.
167
+ // shortcut: a command run with the write-to-stdin tool also gets stdin and is not counted; read the script if that matters.
168
+ cursor: command => /builtin eval "\$1"(?: 3<&- 4>&-)? < \/dev\/null/.test(command)
169
+ || /-NonInteractive -File \S*ps-script-[0-9a-f-]+\.ps1/i.test(command),
170
+ // shortcut: Antigravity's exec shape is not captured yet (quota), so its commands are not counted; add it from a real run.
171
+ antigravity: () => false,
172
+ };
173
+ const EXEC_SHELL_NAMES = new Set([...SHELLS, "pwsh", "powershell", "cmd"]);
174
+ // Sandboxes a harness puts between itself and its exec shell.
175
+ const SANDBOX_WRAPPERS = new Set(["codex-linux-sandbox", "sandbox-exec"]);
176
+ // Hosts that exist only to run the model's tools: each child is own work.
177
+ const toolHost = (kind, command) => kind === "codex"
178
+ && (codexHelperProcess(command) || /^codex-command-runner(?:-[\d.]+)?$/.test(commandExecutable(command)));
179
+ function commandExecutable(command) {
180
+ const first = /^(?:"([^"]+)"|(\S+))/.exec(command);
181
+ return path.posix.basename((first?.[1] ?? first?.[2] ?? "").replace(/\\/g, "/")).replace(/\.exe$/i, "").replace(/^-/, "").toLowerCase();
182
+ }
153
183
  /**
154
184
  * `ps -t <tty> -o stat=,command=` の出力を分類する(純粋関数)。
155
185
  * ログイン shell は command が `-zsh` のように先頭 `-` 付きで出るので剥がして判定する。
@@ -1576,9 +1606,7 @@ function decodeActivityCursor(cursor, name) {
1576
1606
  }
1577
1607
  export function selectHarnessProcesses(meta, rows, subtree) {
1578
1608
  const matches = (row) => {
1579
- const first = /^(?:"([^"]+)"|(\S+))/.exec(row.command);
1580
- const executable = path.posix.basename((first?.[1] ?? first?.[2] ?? "").replace(/\\/g, "/"))
1581
- .replace(/\.exe$/i, "").replace(/^-/, "").toLowerCase();
1609
+ const executable = commandExecutable(row.command);
1582
1610
  const command = row.command.replace(/\\/g, "/").replace(/\.exe(?=["\s]|$)/gi, "").replace(/"/g, "");
1583
1611
  const tokens = row.command.match(/"[^"]*"|'[^']*'|\S+/g) ?? [];
1584
1612
  // native本体の先頭tokenと、sh/cmd経由で2番目以降に来るlauncherの両方を照合する。
@@ -1607,66 +1635,35 @@ export function selectHarnessProcesses(meta, rows, subtree) {
1607
1635
  });
1608
1636
  return roots;
1609
1637
  }
1610
- const processKey = (row) => `${row.pid}:${row.started_identity}`;
1611
- /** 起動完了の控えに入れたprocessの、親とargvのdigest。控えた後に終了したprocessは入らない。 */
1612
- export function startupProcessShapes(identities, rows) {
1613
- const byPid = new Map(rows.map(row => [row.pid, row]));
1614
- const byKey = new Map(rows.map(row => [processKey(row), row]));
1615
- return identities.flatMap(identity => {
1616
- const row = byKey.get(identity);
1617
- if (!row)
1618
- return [];
1619
- const parent = parentProcess(row, byPid);
1620
- return [{ identity, parent: parent ? processKey(parent) : null, argv_digest: row.argv_digest }];
1621
- });
1622
- }
1623
- // 起動完了の控えに無いprocessの数。harness・中継・Aitermが自分のために立てるprocessは、利用者の作業ではないので数えない。
1624
- // その下で動くprocessは数える。
1625
- // harnessは起動の足場(MCP、language server)を自分で立て直す。控えた後に立て直されると、控えに無いprocessとして残る。
1626
- // 控えの物が終了していて、同じ親の下に同じargvで立ったprocessは、その立て直しとして数えない。
1627
- // 親も立て直されている時は、立て直された親の下を見る。終了した控え1つにつき、数えないのは1つまで。
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) {
1638
+ /** Own work (ADR 0141): each exec shell the harness started for a model's command, with everything below it. */
1639
+ export function ownExecProcesses(meta, agent, rows) {
1640
+ const kind = meta.kind;
1633
1641
  const byPid = new Map(rows.map(row => [row.pid, row]));
1634
- const relayChild = (row) => {
1635
- const parent = parentProcess(row, byPid);
1636
- return parent !== undefined && lazyRelayProcess(parent.command);
1637
- };
1638
- // 席の中のAitermも、配送の持ち主の生存確認でprocess表を引く。その問い合わせと、付いて立つconsole hostは数えない。
1639
- // 親の問い合わせが先に終わって残ったconsole hostも同じ扱いにする(console hostは最後のconsole processと一緒に消える)。
1640
- const ownProbe = (row) => {
1641
- if (aitermProcessProbe(row.command))
1642
- return true;
1643
- const parent = parentProcess(row, byPid);
1644
- return windowsConsoleHost(row) && (parent === undefined || aitermProcessProbe(parent.command));
1645
- };
1646
- const present = new Set(activityRows.map(processKey));
1647
- const added = new Map(activityRows
1648
- .filter(row => !startup.has(processKey(row)) && !(kind === "codex" && codexHelperProcess(row.command))
1649
- && !(kind === "claude" && macKeepAwakeProcess(row, harness)) && !relayChild(row) && !ownProbe(row))
1650
- .map(row => [processKey(row), row]));
1651
- const gone = shapes.filter(shape => startup.has(shape.identity) && !present.has(shape.identity));
1652
- const replacedBy = new Map();
1653
- for (let changed = gone.length > 0; changed;) {
1654
- changed = false;
1655
- for (const [key, row] of added) {
1656
- const parent = parentProcess(row, byPid);
1657
- if (!parent)
1658
- continue;
1659
- const parentKey = processKey(parent);
1660
- const original = gone.find(shape => !replacedBy.has(shape.identity) && shape.argv_digest === row.argv_digest
1661
- && shape.parent !== null && (shape.parent === parentKey || replacedBy.get(shape.parent) === parentKey));
1662
- if (!original)
1642
+ const children = new Map();
1643
+ for (const row of rows)
1644
+ if (parentProcess(row, byPid))
1645
+ children.set(row.parent_pid, [...children.get(row.parent_pid) ?? [], row]);
1646
+ const roots = [];
1647
+ const seen = new Set();
1648
+ const walk = (parent, hosted) => {
1649
+ for (const child of children.get(parent.pid) ?? []) {
1650
+ if (seen.has(child.pid))
1663
1651
  continue;
1664
- replacedBy.set(original.identity, key);
1665
- added.delete(key);
1666
- changed = true;
1652
+ seen.add(child.pid);
1653
+ const executable = commandExecutable(child.command);
1654
+ if (hosted || (EXEC_SHELL_NAMES.has(executable) && AGENT_EXEC_SHELLS[kind](child.command)))
1655
+ roots.push(child);
1656
+ else if (toolHost(kind, child.command))
1657
+ walk(child, true);
1658
+ // The harness itself again (e.g. Codex's native binary under its npm shim): its executable name, or the launch's own
1659
+ // arguments passed on (selectHarnessProcesses correlates the same way). A hook or server that merely names the harness is not.
1660
+ else if (SANDBOX_WRAPPERS.has(executable) || AGENT_COMMAND_PATTERNS[kind].test(executable)
1661
+ || (!EXEC_SHELL_NAMES.has(executable) && child.command.includes(meta.launch_id)))
1662
+ walk(child, false);
1667
1663
  }
1668
- }
1669
- return [...added.values()];
1664
+ };
1665
+ walk(agent, false);
1666
+ return roots.flatMap(root => processSubtree(rows, root.pid));
1670
1667
  }
1671
1668
  // ---- own_work (a41, observation-results.md): what a seat started itself and has not finished ----
1672
1669
  const ownWorkExclusionsSchema = z.object({
@@ -1799,9 +1796,7 @@ export async function seatOwnWork(names, requested) {
1799
1796
  continue;
1800
1797
  const activityRows = subtree.some(row => row.pid === agent.pid) ? subtree : [...subtree, ...processSubtree(rows, agent.pid)];
1801
1798
  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);
1799
+ const counted = ownExecProcesses(meta, agent, rows);
1805
1800
  const processEntries = entries.filter(entry => entry.kind === "process");
1806
1801
  const descriptors = new Map(counted.map(row => [row.pid, processDescriptor(processArgv(row))]));
1807
1802
  const byPid = new Map(rows.map(row => [row.pid, row]));
@@ -2013,8 +2008,6 @@ function observeNativeSession(name, cursor) {
2013
2008
  screen_digest: createHash("sha256").update(screen).digest("hex"), processes, background_processes: backgroundCpu,
2014
2009
  };
2015
2010
  const comparable = previous?.pane_identity === sample.pane_identity;
2016
- // 起動完了の控えが無いsession(通常PTY、控える前の版で起動したagent)とharnessを特定できない時は数えない。
2017
- const startup = agent && Array.isArray(meta?.startup_processes) ? new Set(meta.startup_processes) : null;
2018
2011
  // このsessionが親として待っている子の結果。子の記録が名指す親の席に数える(名指しが無ければ持ち主processで)。
2019
2012
  result.pending_child_deliveries = agent ? pendingChildResultsFor(name, activityRows) : null;
2020
2013
  result.activity = {
@@ -2026,8 +2019,7 @@ function observeNativeSession(name, cursor) {
2026
2019
  background_cpu_seconds: Object.values(backgroundCpu).reduce((sum, cpu) => sum + cpu, 0),
2027
2020
  background_cpu_delta_seconds: comparable ? Object.entries(backgroundCpu).reduce((sum, [identity, cpu]) => sum + cpu - (previous.background_processes[identity] ?? 0), 0) : null,
2028
2021
  background_cpu_delta_complete: comparable ? Object.keys(previous.background_processes).every(identity => identity in backgroundCpu) : null,
2029
- post_startup_process_count: startup
2030
- ? postStartupProcessCount(meta.kind, activityRows, rows, startup, meta.startup_process_shapes, agent) : null,
2022
+ post_startup_process_count: meta && agent ? ownExecProcesses(meta, agent, rows).length : null,
2031
2023
  };
2032
2024
  return result;
2033
2025
  }
@@ -4996,13 +4988,6 @@ async function prepareAgentInput(name, meta, options, acceptRunningCodex = false
4996
4988
  if (live.harness_alive !== true || live.harness_process === null
4997
4989
  || (live.state !== "idle" && !(ready.steer && live.state === "busy" && codexRunningTurn(meta) !== null)))
4998
4990
  return { status: "blocked", reason: live.reason };
4999
- // ここまでに居るprocessは起動時の足場(harness・MCP・起動時hook)。初手を送る前に控える。
5000
- // shortcut: a native queued turn can already own children, so leave its startup baseline unknown until a future lifecycle can distinguish them.
5001
- if (live.activity.cursor !== null && !ready.steer) {
5002
- meta.startup_processes = Object.keys(decodeActivityCursor(live.activity.cursor, name).processes);
5003
- meta.startup_process_shapes = startupProcessShapes(meta.startup_processes, readRuntimeProcesses());
5004
- writeAgentMetadata(meta);
5005
- }
5006
4991
  return { status: "ready", reason: "composer_ready" };
5007
4992
  }
5008
4993
  export async function sendInitialAgentPrompt(name, text, o = {}) {
@@ -5,9 +5,7 @@ import { processStartIdentity } from "./process-start.js";
5
5
  import { spawnSync } from "node:child_process";
6
6
  import { freshShared, spawnCollect } from "./spawn-collect.js";
7
7
  import { createHash } from "node:crypto";
8
- import path from "node:path";
9
8
  import { AitermError } from "./errors.js";
10
- import { lazyRelayExecutable } from "./lazy-relay.js";
11
9
  import { isWin } from "./tmux-runtime.js";
12
10
  import { resolveWindowsPowerShell7 } from "./windows-powershell.js";
13
11
  /**
@@ -37,12 +35,6 @@ export function readProcessEnvironment(pid, names, platform = process.platform,
37
35
  // shortcut: ps joins entries with spaces, so a value with a space is cut there; Aiterm's values (token, root path) have none.
38
36
  return Object.fromEntries(names.map(name => [name, [...psOutput.trimEnd().matchAll(new RegExp(`(?:^| )${name}=(\\S*)`, "gu"))].at(-1)?.[1] ?? null]));
39
37
  }
40
- /** Claude's native macOS keep-awake helper does no user work of its own. */
41
- export function macKeepAwakeProcess(row, harness, platform = process.platform) {
42
- const started = Date.parse(row.started_identity), parentStarted = Date.parse(harness?.started_identity ?? "");
43
- return platform === "darwin" && !!harness && row.parent_pid === harness.pid && Number.isFinite(started)
44
- && Number.isFinite(parentStarted) && started >= parentStarted && /^(?:\/usr\/bin\/)?caffeinate -i -t 300$/.test(row.command.trim());
45
- }
46
38
  export function processIdentity(process) {
47
39
  return {
48
40
  pid: process.pid, process_group_id: process.process_group_id,
@@ -93,7 +85,7 @@ export function parsePosixProcessTable(text, includeSession = false, platform =
93
85
  }
94
86
  return rows;
95
87
  }
96
- // AitermがOSのprocess表を引く時のコマンドの形。席のprocessを数える側が、これを利用者の作業と取り違えないために使う。
88
+ // AitermがOSのprocess表を引く時のコマンドの形。
97
89
  const POSIX_PS = "/bin/ps";
98
90
  const POSIX_TABLE_ARGS = ["-axww", "-o", "pid=,ppid=,pgid=,stat=,lstart=,time=,command="];
99
91
  const POSIX_SESSION_TABLE_ARGS = ["-axww", "-o", "pid=,ppid=,pgid=,sess=,stat=,lstart=,time=,command="];
@@ -101,25 +93,6 @@ const POSIX_IDENTITY_ARGS = ["-o", "pid=,lstart=", "-p"];
101
93
  const POSIX_ELAPSED_ARGS = ["-o", "etime=", "-p"];
102
94
  const WINDOWS_PROBE_HEADER = ["$ErrorActionPreference='Stop'", "[Console]::OutputEncoding=[Text.UTF8Encoding]::new($false)"];
103
95
  const WINDOWS_PROBE_ARGS = ["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand"];
104
- // 先頭2行だけのbase64。3 byteの区切りで切り、後ろの行に左右されない前方一致にする。
105
- const WINDOWS_PROBE_PREFIX = (() => {
106
- const bytes = Buffer.from(WINDOWS_PROBE_HEADER.join("\n") + "\n", "utf16le");
107
- return bytes.subarray(0, bytes.length - bytes.length % 3).toString("base64");
108
- })();
109
- /** Aitermがprocess表を引くために起こしたprocessか。引く側のAitermは、数えられる席の中のMCP processでもある。 */
110
- export function aitermProcessProbe(command) {
111
- if (command.includes(` ${WINDOWS_PROBE_ARGS.join(" ")} ${WINDOWS_PROBE_PREFIX}`))
112
- return true;
113
- return command === `${POSIX_PS} ${POSIX_TABLE_ARGS.join(" ")}` || command.startsWith(`${POSIX_PS} ${POSIX_IDENTITY_ARGS.join(" ")} `)
114
- || command === `${POSIX_PS} ${POSIX_SESSION_TABLE_ARGS.join(" ")}`
115
- || command.startsWith(`${POSIX_PS} ${POSIX_ELAPSED_ARGS.join(" ")} `);
116
- }
117
- /** Windowsのconsole host。console processの起動に付いて立ち、最後のconsole processが終わると消える。 */
118
- export function windowsConsoleHost(row) {
119
- const first = /^(?:"([^"]+)"|(\S+))/.exec(row.command);
120
- const name = (row.executable || first?.[1] || first?.[2] || "").replace(/\\/g, "/");
121
- return path.posix.basename(name).toLowerCase() === "conhost.exe";
122
- }
123
96
  export class ProcessProbeError extends AitermError {
124
97
  processFailure;
125
98
  constructor(message, processFailure) {
@@ -391,12 +364,6 @@ export function processSubtree(rows, rootPid) {
391
364
  }
392
365
  return rows.filter(row => selected.has(row.pid));
393
366
  }
394
- // 中継(mcp-lazy)は、登録されたMCPの本体と先行起動の判定を、自分の直接の子として起こす。
395
- // 見分けるのは起動した実行ファイルの名前(argvの先頭のbasenameが`mcp-lazy`で始まる)。取り決めはmcp-lazyのREADMEにある。
396
- export function lazyRelayProcess(command) {
397
- const first = /^(?:"([^"]+)"|(\S+))/.exec(command);
398
- return lazyRelayExecutable(first?.[1] ?? first?.[2] ?? "");
399
- }
400
367
  export function backgroundProcesses(rows, root) {
401
368
  // 起動時の足場processを除く既存契約。pane開始から60秒以上後に生成された子孫だけを集計する。
402
369
  const rootStart = Date.parse(root.started_identity);
package/docs/DESIGN.md CHANGED
@@ -151,11 +151,9 @@ PIDは開始識別子・argv digestと組にし、paneとharnessを同一視し
151
151
  同じlaunchに属するnpm shimとnative本体は、中間の非候補processも含めた祖先関係から一つの起動として扱う。
152
152
  祖先を共有しない候補は別々に残し、複数候補を一つと推測しない。
153
153
  POSIXの停止状態はOSのprocess表から取得し、SIGSTOP中は残画面より優先して`blocked/harness_stopped`を返す。
154
- sessionを閉じると失うものは数で返す(ADR 0080)。`activity.post_startup_process_count`は起動完了の時点に居なかったprocessの数、
154
+ sessionを閉じると失うものは数で返す(ADR 0080)。`activity.post_startup_process_count`は、harnessが命令を走らせるために立てたshell(ClaudeのBash、Codexのexec、Grok・Cursor・Antigravityの道具のshell)の下で動くprocessの数、
155
155
  `pending_child_deliveries`はそのsessionが親として待つ未配送の数。数えられない時はnullで、0と区別する。
156
- harnessと中継が自分のために立てるprocessは数えない(Codexの`codex-code-mode-host`、中継`mcp-lazy`の直接の子。ADR 0082)。その下は数える。
157
- harnessが同じ親の下に同じargvで立て直した起動時のprocessも数えない(ADR 0083)。
158
- Aitermがprocess表を引くために起こしたprocess(`ps`、WindowsのPowerShellと付いて立つconsole host)も数えない(ADR 0084)。
156
+ MCP、hook、中継、補助process、Aiterm自身のprocess表の問い合わせは、その道を通らないので数えない(ADR 0141。起動完了の控えとADR 0082〜0084の除外を置き換えた)。
159
157
  中継の後ろで眠っている本体を配送の引き取りのために起こすかは、`aiterm-delivery-wake`が返す(ADR 0082)。
160
158
  ほかの製品がCodexの親へ回答を届ける時は、製品のhookを登録せず、`aiterm-parent-delivery`でAitermの親配送へ頼む(ADR 0098)。
161
159
  Aitermの登録済みhookと公式キューで届け、設定(`steer`)・受付(`queued_submission_id`)・実際に届いた事(`hook:"emitted"`と`turn_id`)を分けて返す。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.43",
3
+ "version": "0.70.45",
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": [