aiterm-mcp 0.70.33 → 0.70.34

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,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.70.34] - 2026-11-12
11
+
12
+ - `agent_goal` `inspect` on a Claude Code seat no longer types anything into the seat. It used to paste `/goal` into the composer, press Enter, read the dialog and press Escape, so a plain read depended on an empty composer, the turn state, the TTY owner, the screen layout of one Claude Code version and on being the only writer to that composer. Every goal-read failure of 2026-11-12 came from one of those conditions; the last one left `/goal/goal` in a Mac seat's composer when two SSH-forwarded reads (one `aiterm-mcp` process each) pasted at the same time, and every later read was refused. The read now takes the last `goal_status` row of the seat's own session transcript, which is the record Claude Code itself restores the goal from on resume and carries across compaction (2.1.322). It takes no send lock, works while a turn runs or the composer holds a draft, reads a seat that has not had its first turn as "no goal", and does not check the Claude Code version. Result schema and reasons are unchanged, except that the dialog-only reasons (`native_goal_fresh_dialog_unavailable`, `native_goal_dialog_changed`, `goal_input_not_empty_or_ready` on inspect) no longer occur and an unknown row shape reports `native_status_format_unavailable`. Measured on a live seat mid-turn: 64 ms instead of 0.7 s (17 s on Windows).
13
+ - A goal Claude gave up on (`failed: true` row, present in 2.1.322) reads as no current goal. The strict row schema used to reject that row, which would have made every later read of that session unavailable.
14
+ - Claude `create` / `edit` / `clear` still type `/goal …` (user origin only). If the pasted command is not confirmed within 1.5 s, nothing is submitted, as before; when the composer then shows exactly the pasted command, Aiterm removes it (one Backspace per code point) and returns `mutation: "not_issued"`, so the seat does not keep the leftover. Text mixed with another writer's input is not touched. Readback after a mutation polls the transcript for up to 2 s.
15
+ - Not changed: Aiterm still orders composer writes only inside one process; callers serialize writes to one seat across processes (0.63.12). Grok `inspect` still types `/goal status`.
16
+
10
17
  ## [0.70.33] - 2026-11-12
11
18
 
12
19
  - `agent_launch` with `fork_from` works on a closed main seat (ADR 0140). Closing a seat used to delete its launch record, so a fork of a Bot whose seat BellTeam had idle-closed was refused with `FORK_SOURCE_UNAVAILABLE` ("no managed seat of this harness") although the conversation was saved. Closing a Claude Code or Codex seat now leaves `<seat>.fork-source.json` in Aiterm's state (0600: kind, cwd, last conversation ID, Claude root or Codex rollout). The fork reads it and never wakes the main. The file is replaced at the next close of that name and removed after 30 days. A seat closed before this version has no such file. If the saved conversation is gone, the refusal is still `FORK_SOURCE_UNAVAILABLE`.
@@ -3342,7 +3349,8 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3342
3349
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3343
3350
  provenance.
3344
3351
 
3345
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.33...HEAD
3352
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.34...HEAD
3353
+ [0.70.34]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.33...v0.70.34
3346
3354
  [0.70.33]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.32...v0.70.33
3347
3355
  [0.70.32]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.31...v0.70.32
3348
3356
  [0.70.31]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.30...v0.70.31
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.33** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
218
+ **状態:** 開発継続中 · 現行公開版 **v0.70.34** · 動作対象は 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.33** · 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.34** · 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
 
@@ -156,16 +156,23 @@ export async function manageClaudeAgentGoal(input, runtime, origin = "automatic"
156
156
  }
157
157
  if (!sameGoalTarget(runtime.resolve(), target))
158
158
  throw new Error("generation_replaced_after_mutation");
159
- const after = await runtime.read(target);
159
+ const matched = (after) => input.action === "clear" ? after.current === null && (observed.current === null || (after.history?.terminal === "cleared" && after.history.native.condition === observed.current.native.condition)) : after.current?.phase === "active" && after.current.native.condition === input.objective;
160
+ // Claude appends the new goal_status row shortly after it takes the command.
161
+ const pause = runtime.pause ?? ((ms) => new Promise(done => setTimeout(done, ms)));
162
+ let after = await runtime.read(target);
163
+ for (let polls = 0; polls < 40 && !matched(after); polls++) {
164
+ await pause(50);
165
+ after = await runtime.read(target);
166
+ }
160
167
  if (!sameGoalTarget(runtime.resolve(), target))
161
168
  throw new Error("generation_replaced_after_readback");
162
- const matches = input.action === "clear" ? after.current === null && (observed.current === null || (after.history?.terminal === "cleared" && after.history.native.condition === observed.current.native.condition)) : after.current?.phase === "active" && after.current.native.condition === input.objective;
169
+ const matches = matched(after);
163
170
  return agentGoalNativeResultSchema.parse({ ...result, ...snapshot(after), mutation: matches ? "acknowledged" : "outcome_unknown", outcome: matches ? "applied" : "outcome_unknown", readback: matches ? "confirmed" : "mismatch", reason: matches ? "native_goal_readback_confirmed" : "native_goal_changed_before_readback", observed_at: new Date().toISOString() });
164
171
  }
165
172
  catch (error) {
166
173
  if (issued)
167
174
  return { ...result, outcome: "outcome_unknown", mutation: "outcome_unknown", readback: "failed", reason: "native_goal_mutation_unconfirmed" };
168
- const reasons = new Set(["native_goal_status_input_unconfirmed", "native_goal_fresh_dialog_unavailable", "native_goal_dialog_changed", "native_goal_binding_mismatch"]);
175
+ const reasons = new Set(["native_goal_status_input_unconfirmed", "native_status_format_unavailable"]);
169
176
  const reason = error instanceof AgentGoalNotIssuedError ? error.reason : error instanceof Error && reasons.has(error.message) ? error.message : "native_goal_fresh_status_unavailable";
170
177
  if (error instanceof AgentGoalNotIssuedError && error.outcome === "unsupported")
171
178
  return { ...result, availability: "unsupported", outcome: "unsupported", reason };
package/dist/core.js CHANGED
@@ -32,7 +32,7 @@ import * as rtk from "./rtk.js";
32
32
  import { manageClaudeAgentGoal, manageGrokAgentGoal } from "./agent-goal-native-result.js";
33
33
  import { grokCurrentSessionOwner, readFreshGrokGoal, clearGrokGoal, grokGoalClearReady } from './harnesses/grok-goal.js';
34
34
  import { nativeGoalClickBytes } from './agent-goal-ui.js';
35
- import { readClaudeGoalDialog, clearClaudeGoal, setClaudeGoalObjective, claudeCurrentSessionOwner } from "./harnesses/claude-goal.js";
35
+ import { observeClaudeGoalRows, clearClaudeGoal, setClaudeGoalObjective, claudeCurrentSessionOwner } from "./harnesses/claude-goal.js";
36
36
  import { AgentGoalNotIssuedError, manageAgentGoal } from "./agent-goal.js";
37
37
  import { withCodexGoal } from "./harnesses/codex-goal.js";
38
38
  import { configureWithPausedGoal } from "./configure-goal.js";
@@ -6216,19 +6216,29 @@ async function agentGoalInContext(input, origin, expectedGoal, sendHeld = false)
6216
6216
  canClear: target => grokGoalClearReady(grokPort(target).ui),
6217
6217
  clear: (target, before) => clearGrokGoal(target.vendor_session_id, before, grokPort(target)),
6218
6218
  }, origin));
6219
- if (harness === "claude-code")
6220
- return withAgentSendLock(input.session_id, () => manageClaudeAgentGoal(input, { resolve,
6221
- read: target => readClaudeGoalDialog(target.vendor_session_id, goalUi(target), () => {
6219
+ if (harness === "claude-code") {
6220
+ // Reading is the session transcript only: it writes nothing to the seat, so it needs no send lock,
6221
+ // composer, turn state, TTY owner or version check. Only a mutation types into the composer.
6222
+ const run = () => manageClaudeAgentGoal(input, { resolve,
6223
+ read: async (target) => {
6222
6224
  const meta = tryLoadAgentMetadata(input.session_id);
6223
6225
  if (!meta || meta.launch_id !== target.launch_id || meta.vendor_session_id !== target.vendor_session_id)
6224
6226
  throw new Error("generation_replaced");
6225
6227
  const file = claudeSessionTranscriptPath(meta);
6226
- if (!file || !fs.existsSync(file))
6228
+ // No transcript yet (before the first turn) is a session without a goal. A half-written last line is skipped.
6229
+ const rows = !file || !fs.existsSync(file) ? [] : readTranscriptLines(file).filter(line => line.includes('"goal_status"'))
6230
+ .flatMap(line => { try {
6231
+ return [JSON.parse(line)];
6232
+ }
6233
+ catch {
6227
6234
  return [];
6228
- return readTranscriptLines(file).filter(line => line.trim()).map(line => JSON.parse(line));
6229
- }),
6235
+ } });
6236
+ return observeClaudeGoalRows(rows, target.vendor_session_id);
6237
+ },
6230
6238
  clear: target => clearClaudeGoal(goalUi(target)),
6231
- setObjective: (target, objective) => setClaudeGoalObjective(goalUi(target), objective), }, origin));
6239
+ setObjective: (target, objective) => setClaudeGoalObjective(goalUi(target), objective), }, origin);
6240
+ return input.action === "inspect" ? run() : withAgentSendLock(input.session_id, run);
6241
+ }
6232
6242
  const run = () => manageAgentGoal(input, { resolve,
6233
6243
  ...(expectedGoal ? { beforeMutation: (current) => JSON.stringify(current) === JSON.stringify(expectedGoal) } : {}),
6234
6244
  connect: (target, callback) => withCodexGoal(target, (request, supported, fields) => callback((method, params) => {
@@ -1,5 +1,6 @@
1
- // Claude owns goal state. A fresh local status command, never a historical
2
- // attachment alone, establishes current state for the bound native session.
1
+ // Claude owns goal state and persists it as goal_status attachment rows in the session transcript.
2
+ // It restores the goal from the last such row on resume and re-carries it across compaction
3
+ // (2.1.322 lBn/sVo/uit), so reading that row is reading the current state. A read types nothing.
3
4
  import { z } from "zod";
4
5
  // Measured /goal surface: 2.1.310 and 2.1.322 (dialog, attachment, sessions/<pid>.json).
5
6
  // Patch updates of the 2.1 line keep it; every step below still proves the screen and records.
@@ -75,6 +76,33 @@ export function observeClaudeGoalStatus(rows, nativeSessionId, queryUuid) {
75
76
  throw new Error("native_goal_status_mismatch");
76
77
  return { ...result, current: claudeCurrentGoalSchema.parse({ kind: "claude-code", phase: "active", native: current, reported_turns: Number(active[1]) }) };
77
78
  }
79
+ const goalRowSchema = claudeNativeGoalStatusSchema.extend({ failed: z.boolean().optional() }).strip();
80
+ /** Current goal of the bound session from its own transcript rows. No UI, no composer, no lock. */
81
+ export function observeClaudeGoalRows(rows, sessionId) {
82
+ let current = null, unknown = false;
83
+ let history;
84
+ for (const value of rows) {
85
+ const row = value;
86
+ if (row?.type !== "attachment" || row.attachment?.type !== "goal_status" || row.sessionId !== sessionId || row.isSidechain !== false)
87
+ continue;
88
+ const parsed = goalRowSchema.safeParse(row.attachment);
89
+ current = null;
90
+ unknown = !parsed.success;
91
+ // An unknown row shape or a failed goal ends what was known; neither is an achieved/cleared history.
92
+ if (!parsed.success || parsed.data.failed) {
93
+ history = undefined;
94
+ continue;
95
+ }
96
+ const { failed: _failed, ...native } = parsed.data;
97
+ if (native.met)
98
+ history = { kind: "claude-code", terminal: native.sentinel ? "cleared" : "achieved", native };
99
+ else
100
+ current = { kind: "claude-code", phase: "active", native: { ...native, met: false } };
101
+ }
102
+ if (unknown)
103
+ throw new Error("native_status_format_unavailable");
104
+ return { current, ...(history ? { history } : {}) };
105
+ }
78
106
  export async function readFreshClaudeGoal(nativeSessionId, port) {
79
107
  if (!port.same())
80
108
  throw new Error("generation_replaced");
@@ -136,53 +164,6 @@ export function claudeGoalComposer(screen) {
136
164
  export function claudeGoalComposerEmpty(screen) {
137
165
  return claudeGoalComposer(screen)?.text === "";
138
166
  }
139
- export function observeClaudeGoalDialog(screen, rows, sessionId) {
140
- const lines = plain(screen).split("\n").map(line => line.trim());
141
- const knownVersion = lines.some(line => claudeGoalVersionSupported(/Claude Code v(\S+)(?:\s|$)/u.exec(line)?.[1]))
142
- || rows.some(value => { const row = value; return row?.sessionId === sessionId && row.isSidechain === false && claudeGoalVersionSupported(row.version); });
143
- if (!knownVersion)
144
- return null;
145
- let end = lines.length - 1;
146
- while (end >= 0 && lines[end] !== "Esc to dismiss" && lines[end] !== "/goal clear to stop early · Esc to dismiss")
147
- end--;
148
- if (end < 0 || lines.slice(end + 1).some(line => line !== ""))
149
- return null;
150
- let current = null;
151
- let history;
152
- for (const value of rows) {
153
- const row = value;
154
- if (row?.type !== "attachment" || row.attachment?.type !== "goal_status")
155
- continue;
156
- if (row.sessionId !== sessionId || row.isSidechain !== false || !claudeGoalVersionSupported(row.version))
157
- throw new Error("native_goal_binding_mismatch");
158
- const native = claudeNativeGoalStatusSchema.parse(row.attachment);
159
- if (native.met) {
160
- current = null;
161
- history = { kind: "claude-code", terminal: native.sentinel ? "cleared" : "achieved", native };
162
- }
163
- else
164
- current = native;
165
- }
166
- if (lines[end] === "Esc to dismiss" && lines.slice(end - 5, end).filter(Boolean).join("\n") === "Goal\nNo goal set\n/goal <condition> to set one")
167
- return { current: null, ...(history ? { history } : {}) };
168
- if (!current || lines[end] !== "/goal clear to stop early · Esc to dismiss")
169
- return null;
170
- let header = end - 1;
171
- while (header >= 0 && lines[header] !== "◎ Goal active")
172
- header--;
173
- if (header < 0)
174
- return null;
175
- const body = lines.slice(header + 1, end).filter(Boolean);
176
- // Wrapped/truncated conditions are not a canonical match. Keep the native
177
- // original and refuse this viewport rather than inventing a normalized goal.
178
- const conditionLines = current.condition.split("\n");
179
- // Exact native newlines are supported; no guessed wrapping/whitespace.
180
- if (conditionLines.some(line => !line || line !== line.trim()))
181
- return null;
182
- if (!/^running .+ · .+ tokens$/u.test(body[0]) || JSON.stringify(body.slice(1)) !== JSON.stringify(["Goal: " + conditionLines[0], ...conditionLines.slice(1)]))
183
- return null;
184
- return { current: { kind: "claude-code", phase: "active", native: { ...current, met: false } }, ...(history ? { history } : {}) };
185
- }
186
167
  export async function submitClaudeGoalCommand(ui, command) {
187
168
  if (!claudeGoalComposerEmpty(ui.read()))
188
169
  throw new AgentGoalNotIssuedError("goal_input_not_empty_or_ready");
@@ -196,8 +177,19 @@ export async function submitClaudeGoalCommand(ui, command) {
196
177
  }
197
178
  await ui.pause(40);
198
179
  } while (now() < until);
199
- if (!ready)
180
+ if (!ready) {
181
+ // A paste that renders late must not stay behind. Only text that is exactly ours is removed
182
+ // (one Backspace per code point; extra ones on an empty composer do nothing). Nothing was submitted.
183
+ const settle = async (done) => { for (const end = now() + 1500; now() < end; await ui.pause(40))
184
+ if (done())
185
+ return true; return false; };
186
+ if (await settle(() => claudeGoalComposer(ui.read())?.text === command)) {
187
+ await ui.keys(Array.from(command, () => "BSpace"));
188
+ if (await settle(() => claudeGoalComposerEmpty(ui.read())))
189
+ throw new AgentGoalNotIssuedError("native_goal_status_input_unconfirmed");
190
+ }
200
191
  throw new Error("native_goal_status_input_unconfirmed");
192
+ }
201
193
  await ui.keys(["Enter"]);
202
194
  }
203
195
  /** A bounded, fully visible literal objective. Native wrapping and file
@@ -237,20 +229,3 @@ export async function clearClaudeGoal(ui) {
237
229
  } while (now() < until);
238
230
  throw new Error("native_goal_clear_command_unconfirmed");
239
231
  }
240
- export async function readClaudeGoalDialog(sessionId, ui, readRows) {
241
- await submitClaudeGoalCommand(ui, "/goal");
242
- const now = ui.now ?? (() => performance.now());
243
- let until = now() + 2000;
244
- do {
245
- const observation = observeClaudeGoalDialog(ui.read(), readRows(), sessionId);
246
- if (observation) {
247
- // Dismiss only the same recognized native goal dialog, once.
248
- if (!observeClaudeGoalDialog(ui.read(), readRows(), sessionId))
249
- throw new Error("native_goal_dialog_changed");
250
- await ui.keys(["Escape"]);
251
- return observation;
252
- }
253
- await ui.pause(40);
254
- } while (now() < until);
255
- throw new Error("native_goal_fresh_dialog_unavailable");
256
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.33",
3
+ "version": "0.70.34",
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": [