aiterm-mcp 0.70.32 → 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,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.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
+
17
+ ## [0.70.33] - 2026-11-12
18
+
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`.
20
+ - A local or `remote` `agent_launch` refusal now carries `_meta["aiterm/error_code"]` (for example `FORK_SOURCE_UNAVAILABLE`, `FORK_INVALID`, `READONLY_UNENFORCEABLE`), as terminal launches already did. The text is unchanged.
21
+
10
22
  ## [0.70.32] - 2026-11-12
11
23
 
12
24
  - `agent_goal` on a Claude Code seat on Windows no longer fails with `native_goal_status_input_unconfirmed` right after pasting `/goal`. On Windows, Claude draws the slash-command menu (whose first row also starts with `❯`) under the composer's bottom rule, and Aiterm took that menu row for the composer. The composer is now the lowest `❯` row framed by a rule above and below. Measured on fox with Claude Code 2.1.322.
@@ -3337,7 +3349,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
3337
3349
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
3338
3350
  provenance.
3339
3351
 
3340
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.32...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
3354
+ [0.70.33]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.32...v0.70.33
3341
3355
  [0.70.32]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.31...v0.70.32
3342
3356
  [0.70.31]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.30...v0.70.31
3343
3357
  [0.70.30]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.29...v0.70.30
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.32** · 動作対象は 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.32** · 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";
@@ -357,12 +357,56 @@ export function windowsLaunchTyped(name, launchId, full) {
357
357
  writeText0600(file, full);
358
358
  return windowsLaunchIndirection(file);
359
359
  }
360
+ const FORK_SOURCE_DAYS = 30; // Claude's own transcript retention default (cleanupPeriodDays)
361
+ function forkSourcePath(dir, name) { return path.join(dir, `${name}.fork-source.json`); }
362
+ /** ADR 0140: a closed main's last conversation, so a fork never needs the main woken. Never a resume or send authority. */
363
+ function saveForkSource(dir, name) {
364
+ const meta = tryLoadAgentMetadata(name);
365
+ if (!meta || (meta.kind !== "claude" && meta.kind !== "codex") || !meta.cwd)
366
+ return;
367
+ let rollout = null;
368
+ try {
369
+ rollout = meta.kind === "codex" ? codexRootTranscript(meta) : null;
370
+ }
371
+ catch {
372
+ rollout = null;
373
+ }
374
+ const vendor = meta.kind === "codex" ? (rollout ? codexRolloutSessionId(meta, rollout) : null) : meta.vendor_session_id;
375
+ if (!vendor || (meta.kind === "claude" && !meta.claude_home))
376
+ return;
377
+ const source = { kind: meta.kind, cwd: meta.cwd, vendor_session_id: vendor,
378
+ ...(meta.kind === "claude" ? { claude_home: meta.claude_home } : { rollout: rollout }) };
379
+ writeText0600(forkSourcePath(dir, name), JSON.stringify(source));
380
+ const stale = Date.now() - FORK_SOURCE_DAYS * 86_400_000;
381
+ for (const f of fs.readdirSync(dir))
382
+ if (f.endsWith(".fork-source.json"))
383
+ try {
384
+ if (fs.statSync(path.join(dir, f)).mtimeMs < stale)
385
+ fs.unlinkSync(path.join(dir, f));
386
+ }
387
+ catch { /* another close removed it */ }
388
+ }
389
+ function readForkSource(name) {
390
+ const dir = existingAgentsDir();
391
+ try {
392
+ const v = dir ? JSON.parse(fs.readFileSync(forkSourcePath(dir, name), "utf8")) : null;
393
+ return v && (v.kind === "claude" || v.kind === "codex") && typeof v.cwd === "string" && typeof v.vendor_session_id === "string"
394
+ && (v.kind === "claude" ? typeof v.claude_home === "string" : typeof v.rollout === "string") ? v : null;
395
+ }
396
+ catch {
397
+ return null;
398
+ }
399
+ }
360
400
  function cleanupAgentState(name) {
361
401
  assertSessionName(name);
362
402
  agentMetadataNegativeCache.delete(name);
363
403
  const dir = existingAgentsDir();
364
404
  if (!dir)
365
405
  return;
406
+ try {
407
+ saveForkSource(dir, name);
408
+ }
409
+ catch { /* best-effort like the cleanup below: a missing copy only refuses a later fork */ }
366
410
  const prefix = `${name}.`;
367
411
  try {
368
412
  for (const f of fs.readdirSync(dir)) {
@@ -6172,19 +6216,29 @@ async function agentGoalInContext(input, origin, expectedGoal, sendHeld = false)
6172
6216
  canClear: target => grokGoalClearReady(grokPort(target).ui),
6173
6217
  clear: (target, before) => clearGrokGoal(target.vendor_session_id, before, grokPort(target)),
6174
6218
  }, origin));
6175
- if (harness === "claude-code")
6176
- return withAgentSendLock(input.session_id, () => manageClaudeAgentGoal(input, { resolve,
6177
- 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) => {
6178
6224
  const meta = tryLoadAgentMetadata(input.session_id);
6179
6225
  if (!meta || meta.launch_id !== target.launch_id || meta.vendor_session_id !== target.vendor_session_id)
6180
6226
  throw new Error("generation_replaced");
6181
6227
  const file = claudeSessionTranscriptPath(meta);
6182
- 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 {
6183
6234
  return [];
6184
- return readTranscriptLines(file).filter(line => line.trim()).map(line => JSON.parse(line));
6185
- }),
6235
+ } });
6236
+ return observeClaudeGoalRows(rows, target.vendor_session_id);
6237
+ },
6186
6238
  clear: target => clearClaudeGoal(goalUi(target)),
6187
- 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
+ }
6188
6242
  const run = () => manageAgentGoal(input, { resolve,
6189
6243
  ...(expectedGoal ? { beforeMutation: (current) => JSON.stringify(current) === JSON.stringify(expectedGoal) } : {}),
6190
6244
  connect: (target, callback) => withCodexGoal(target, (request, supported, fields) => callback((method, params) => {
@@ -8233,21 +8287,26 @@ export function resolveForkSource(kind, from, opts, probe = probeWriteBan) {
8233
8287
  throw new AitermError(`FORK_INVALID: session_name ${opts.session_name} already names a seat`, 2);
8234
8288
  assertSessionName(from.session_id);
8235
8289
  const unavailable = (why) => new AitermError(`FORK_SOURCE_UNAVAILABLE: ${from.session_id}: ${why}`, 2);
8236
- const main = tryLoadAgentMetadata(from.session_id);
8290
+ const live = tryLoadAgentMetadata(from.session_id);
8291
+ // A closed main is read from the copy its close left; it is not woken (ADR 0140).
8292
+ const main = live ?? readForkSource(from.session_id);
8237
8293
  if (!main || main.kind !== kind || !main.cwd)
8238
- throw unavailable("no managed seat of this harness");
8294
+ throw unavailable("no managed seat of this harness and no saved conversation from its close");
8239
8295
  // Codex binds its conversation lazily and may switch it (/new): read the current one without writing the main's record.
8240
8296
  let rollout = null;
8241
- try {
8242
- rollout = main.kind === "codex" ? codexRootTranscript(main) : null;
8243
- }
8244
- catch {
8245
- rollout = null;
8246
- }
8247
- const mainVendorId = main.kind === "codex" ? (rollout ? codexRolloutSessionId(main, rollout) : null) : main.vendor_session_id;
8297
+ if (live)
8298
+ try {
8299
+ rollout = live.kind === "codex" ? codexRootTranscript(live) : null;
8300
+ }
8301
+ catch {
8302
+ rollout = null;
8303
+ }
8304
+ else
8305
+ rollout = main.rollout ?? null;
8306
+ const mainVendorId = !live ? main.vendor_session_id : live.kind === "codex" ? (rollout ? codexRolloutSessionId(live, rollout) : null) : live.vendor_session_id;
8248
8307
  if (!mainVendorId || (main.kind === "claude" ? !main.claude_home
8249
- || !fs.existsSync(path.join(main.claude_home, "projects", claudeProjectSlug(main.cwd), `${mainVendorId}.jsonl`)) : !rollout))
8250
- throw unavailable("the saved conversation file does not exist yet");
8308
+ || !fs.existsSync(path.join(main.claude_home, "projects", claudeProjectSlug(main.cwd), `${mainVendorId}.jsonl`)) : !rollout || !fs.existsSync(rollout)))
8309
+ throw unavailable(live ? "the saved conversation file does not exist yet" : "the closed seat's saved conversation file no longer exists");
8251
8310
  if (opts.cwd != null && (!fs.existsSync(opts.cwd) || fs.realpathSync(opts.cwd) !== fs.realpathSync(main.cwd)))
8252
8311
  throw new AitermError("FORK_INVALID: a fork runs in its main seat's cwd; omit cwd", 2);
8253
8312
  // The main's cwd is the project folder the Owner forbade writing (ADR 0140).
@@ -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/dist/index.js CHANGED
@@ -1473,7 +1473,7 @@ export function createAitermServer(options = {}) {
1473
1473
  },
1474
1474
  };
1475
1475
  }
1476
- return fail(e);
1476
+ return withErrorCode(fail(e));
1477
1477
  }
1478
1478
  }
1479
1479
  function registerAgentTool(toolName, kind, desc) {
@@ -1618,10 +1618,10 @@ export function createAitermServer(options = {}) {
1618
1618
  if (!remote)
1619
1619
  return launchAgent(kindForHarness(harness), args, extra);
1620
1620
  try {
1621
- return await launchRemoteAgent(acceptRemote(remote), harness, args, extra);
1621
+ return withErrorCode(await launchRemoteAgent(acceptRemote(remote), harness, args, extra));
1622
1622
  }
1623
1623
  catch (e) {
1624
- return fail(e);
1624
+ return withErrorCode(fail(e));
1625
1625
  }
1626
1626
  });
1627
1627
  registerAgentTool("claude_agent", "claude", "【旧互換alias。新規連携は agent_launch(harness=claude-code)】Claude Codeの対話エージェントTUIを永続端末に起動する。`claude -p`ではなく、" +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.70.32",
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": [