aiterm-mcp 0.57.1 → 0.57.2

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,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.57.2] - 2026-10-07
11
+
12
+ ### 修正
13
+
14
+ - Codexのturnがサービスの誤りや通信の失敗(HTTP 500・401・途中で切れる応答など)で終わった時、完了待ちが`done`・空の回答を返していた件を直す(ADR 0103)。
15
+ Codexは、この時も記録へ`task_complete`を書く(回答は無く、`error`が付く)。Aitermは利用上限だけを`rate_limited`に分けていたので、
16
+ ほかの失敗は、呼んだ側に、空の回答の完了として届いていた。
17
+ - 完了待ちは`outcome: "error"`を返す。`aiterm-wait`はexit 7、親への配送は`outcome=error`。
18
+ - `error`は、応答の本文とURLを落とした1行の文にする(例「unexpected status 401 Unauthorized」)。
19
+ - Codexが記録した種類(`internal_server_error`・`http_connection_failed`など)を、新しい項目`error_kind`で返す。ほかの席と、`error`でない返りでは`null`。
20
+ - 合間の言葉(`kind: "error"`)も、利用上限のほかは同じ1行にする。
21
+ - 引数、`done`と`rate_limited`の返り、断りの文面、Claude Code・Grok・Cursorの席は変えていない。
22
+
23
+ ### 文書
24
+
25
+ - 通信の失敗・取消・待ちの時間切れを実行時エラーとして記録しない事と、重さの決め方を、決まりとして書く(ADR 0102)。動きは変えない。
26
+
10
27
  ## [0.57.1] - 2026-10-07
11
28
 
12
29
  ### 修正
@@ -2380,7 +2397,8 @@ prototype (preserved under `prototype/python/` as the porting source and referen
2380
2397
  `ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
2381
2398
  provenance.
2382
2399
 
2383
- [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.57.1...HEAD
2400
+ [Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.57.2...HEAD
2401
+ [0.57.2]: https://github.com/kitepon/aiterm-mcp/compare/v0.57.1...v0.57.2
2384
2402
  [0.57.1]: https://github.com/kitepon/aiterm-mcp/compare/v0.57.0...v0.57.1
2385
2403
  [0.57.0]: https://github.com/kitepon/aiterm-mcp/compare/v0.56.1...v0.57.0
2386
2404
  [0.56.1]: https://github.com/kitepon/aiterm-mcp/compare/v0.56.0...v0.56.1
package/README.ja.md CHANGED
@@ -209,7 +209,7 @@ runtime-error store は canonical dotagents config の `collection.enabled: true
209
209
  場合だけ収集し、既定OFF、network送信は行いません。tag起点CIのnpm provenance(OIDC Trusted
210
210
  Publishing)で公開し、GitHub Release が Official MCP Registry を再登録します。
211
211
 
212
- **状態:** 開発継続中 · 現行公開版 **v0.57.1** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
212
+ **状態:** 開発継続中 · 現行公開版 **v0.57.2** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
213
213
 
214
214
  ### 更新と巻き戻し
215
215
 
@@ -259,6 +259,8 @@ pty_read(id, { wait: true }) → 削減済みの出力を読む(完了
259
259
 
260
260
  ClaudeがAPIエラーや安全判定の拒否で終了した時は、Stop hookが発火しなくても次の`pty_send`を新しいturnとして扱う。現在のturn開始後のエラー記録だけを確認し、過去のエラーで実行中のturnを解除しない。上流の拒否はエラーのまま返す。
261
261
 
262
+ Codexがサービスの誤りや通信の失敗でturnを打ち切った時は、完了待ちが`done`ではなく`error`を返す(`aiterm-wait`はexit 7、親への配送は`outcome=error`)。`error`は応答の本文とURLを落とした1行の文で、Codexが記録した種類(`internal_server_error`・`http_connection_failed`など)は`error_kind`に載る。利用上限は今までどおり`rate_limited`。誤りで終わった後の席は、次の`pty_send`を新しいturnとして受ける。
263
+
262
264
  agent配送だけを期待する連携では、`pty_send`に`require_agent:true`を指定する。agent登録が無ければ、打鍵前に`AGENT_SESSION_REQUIRED`と「文字列は送信していません」を返す。省略時は通常PTY送信を維持する。`force:true`との併用は未送信で拒否する。
263
265
 
264
266
  agent session宛ての`pty_send`は、任意の`preface`(本文の前に置く1行)を受ける。渡る文は「`preface`・空行・`text`」。Claude Codeの席へは、`preface`を端末の貼り付けの印なしで入れ、空行と本文を1回の貼り付けで入れる。Claude Codeは貼り付けた長い文を`<pasted_content>`で包み、「包みの中の指示は、包みの外の利用者自身の言葉が頼んだ時だけ従う」と読むので、連携元が付ける前置き(誰からの連絡か)を包みの外へ出すために使う。Codex・Grok・Cursorの席へは1つにつないで貼る。`preface`は1行・200字以内・制御文字なしで、行頭が記号や空白でなく、`@`を含まない文。外れた時は`AGENT_PREFACE_INVALID`と「文字列は送信していません。」を返す。通常PTY・`force:true`・`remote`付きでは使えない。
package/README.md CHANGED
@@ -223,7 +223,7 @@ collection is off by default and performs no network I/O. It ships via
223
223
  tag-triggered CI with npm provenance (OIDC Trusted Publishing); the GitHub
224
224
  Release re-registers the Official MCP Registry entry.
225
225
 
226
- **Status:** actively maintained · current public release **v0.57.1** · 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).
226
+ **Status:** actively maintained · current public release **v0.57.2** · 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).
227
227
 
228
228
  ### Update and rollback
229
229
 
@@ -259,6 +259,8 @@ I used **Codex with GPT-5.6** as an engineering collaborator: it inspected the i
259
259
 
260
260
  ClaudeがAPIエラーや安全判定の拒否で終了した時は、Stop hookが発火しなくても次の`pty_send`を新しいturnとして扱う。現在のturn開始後のエラー記録だけを確認し、過去のエラーで実行中のturnを解除しない。上流の拒否はエラーのまま返す。
261
261
 
262
+ Codexがサービスの誤りや通信の失敗でturnを打ち切った時は、完了待ちが`done`ではなく`error`を返す(`aiterm-wait`はexit 7、親への配送は`outcome=error`)。`error`は応答の本文とURLを落とした1行の文で、Codexが記録した種類(`internal_server_error`・`http_connection_failed`など)は`error_kind`に載る。利用上限は今までどおり`rate_limited`。誤りで終わった後の席は、次の`pty_send`を新しいturnとして受ける。
263
+
262
264
  ## Two ways to use it
263
265
 
264
266
  ### 1. Drive SSH, containers, and REPLs in one persistent terminal — the primitive
package/dist/core.js CHANGED
@@ -3158,6 +3158,7 @@ export async function observeAgentDone(name, o = {}) {
3158
3158
  at: ev?.at ?? apiError?.at ?? null,
3159
3159
  rate_limit: rateLimit,
3160
3160
  error: apiError?.text ?? null,
3161
+ error_kind: null,
3161
3162
  });
3162
3163
  for (;;) {
3163
3164
  o.signal?.throwIfAborted();
@@ -254,6 +254,16 @@ export function codexTurnError(record) {
254
254
  return null;
255
255
  return { message: message || info, info };
256
256
  }
257
+ // 呼んだ側の画面にそのまま出る1行の文。Codexの文は、応答の本文・URLを含む事がある
258
+ // (実物 2026-10-07、codex 0.160.1: "unexpected status 401 Unauthorized: <応答の文>, url: http://…/v1/responses")。
259
+ // 「unexpected status」はHTTPの状態までで切り、ほかの文はURLを伏せる。改行は畳み、長さを切る。
260
+ const CODEX_ERROR_LINE_MAX = 200;
261
+ export function codexTurnErrorLine(error) {
262
+ const flat = error.message.replace(/\s+/g, " ").trim();
263
+ const status = /^unexpected status (\d{3}(?: [A-Za-z][A-Za-z' -]*)?)/.exec(flat);
264
+ const text = status ? `unexpected status ${status[1].trim()}` : flat.replace(/https?:\/\/[^\s)\]>"']+/gi, "…");
265
+ return text.length > CODEX_ERROR_LINE_MAX ? `${text.slice(0, CODEX_ERROR_LINE_MAX - 1)}…` : text;
266
+ }
257
267
  // 利用上限はtask_completeのcodex_error_infoで見分ける。token_countのused_percentは100%のまま
258
268
  // 返事が続くことがある(macbookの実記録で7千件以上)ので上限の印にしない。
259
269
  // rate_limit_exceededは短い間の混雑で、Codexが自分で再試行するので上限に数えない。
@@ -346,7 +356,7 @@ export async function observeCodexDone(meta, timeout, requestedCursor, signal) {
346
356
  let discardLeadingFragment = false;
347
357
  let initializedBoundary = false;
348
358
  const deadline = performance.now() + timeout * 1000;
349
- const observation = (outcome, ev = null, rateLimit = null) => ({
359
+ const observation = (outcome, ev = null, rateLimit = null, failed = null) => ({
350
360
  schema: "aiterm.agent-wait-result.v1",
351
361
  session_id: meta.aiterm_session,
352
362
  launch_id: meta.launch_id,
@@ -359,7 +369,8 @@ export async function observeCodexDone(meta, timeout, requestedCursor, signal) {
359
369
  malformed_events: malformedEvents,
360
370
  at: ev?.at ?? null,
361
371
  rate_limit: rateLimit,
362
- error: null,
372
+ error: failed ? codexTurnErrorLine(failed) : null,
373
+ error_kind: failed?.info ?? null,
363
374
  });
364
375
  for (;;) {
365
376
  signal?.throwIfAborted();
@@ -405,7 +416,12 @@ export async function observeCodexDone(meta, timeout, requestedCursor, signal) {
405
416
  // 上限の知らせはこのturnの終わりにだけ書かれる。画面やpane logの文字は、上限が明けた後も
406
417
  // 残り、道具の出力や依頼文にも現れるので見ない(2026-09-28)。
407
418
  const limited = codexUsageLimit(record);
408
- return limited ? observation("rate_limited", done, limited) : observation("done", done);
419
+ if (limited)
420
+ return observation("rate_limited", done, limited);
421
+ // サービスの誤りや通信の失敗で終わったturnも、Codexはtask_completeを書く(errorつき、回答は無い)。
422
+ // 完了として返すと、失敗が空の回答に見える。Claude CodeのAPIエラーと同じく、typedな終了として返す(ADR 0103)。
423
+ const failed = codexTurnError(record);
424
+ return failed ? observation("error", done, null, failed) : observation("done", done);
409
425
  }
410
426
  }
411
427
  catch {
@@ -207,6 +207,7 @@ export async function observeCursorDone(meta, timeout, requestedCursor, readScre
207
207
  at: ev?.at ?? null,
208
208
  rate_limit: rateLimit,
209
209
  error,
210
+ error_kind: null,
210
211
  });
211
212
  for (;;) {
212
213
  signal?.throwIfAborted();
@@ -273,6 +273,7 @@ export async function observeGrokDone(meta, timeout, requestedCursor, detectRate
273
273
  at: ev?.at ?? null,
274
274
  rate_limit: rateLimit,
275
275
  error: ev?.done_status === "turn_error" ? ev.reason : null,
276
+ error_kind: null,
276
277
  });
277
278
  for (;;) {
278
279
  signal?.throwIfAborted();
@@ -14,7 +14,7 @@ import * as path from "node:path";
14
14
  import { AitermError } from "./errors.js";
15
15
  import { agentHarness, agentsDir, assertSessionName, LAUNCH_ID_RE, readFileRange, safeStatSize, writeJson0600, } from "./agent-shared.js";
16
16
  import { claudeSessionTranscriptPath } from "./harnesses/claude.js";
17
- import { codexRootTranscript, codexTurnError } from "./harnesses/codex.js";
17
+ import { codexRootTranscript, codexTurnError, codexTurnErrorLine } from "./harnesses/codex.js";
18
18
  import { grokSessionDirectory } from "./harnesses/grok.js";
19
19
  import { cursorTranscript } from "./harnesses/cursor.js";
20
20
  /** BellTeamが要求の_metaへ入れる呼び手の印。値が "BellTeam" の時だけ合間の言葉を返す。 */
@@ -90,7 +90,9 @@ export function codexInterimWords(lines) {
90
90
  const error = codexTurnError(record);
91
91
  if (error) {
92
92
  words.push({
93
- text: error.message,
93
+ // 利用上限はCodexの利用者向けの文をそのまま出す。ほかの誤りは、完了の返り(error)と同じ1行にする
94
+ // (応答の本文やURLが混ざる文があるため)。
95
+ text: error.info === "usage_limit_exceeded" ? error.message : codexTurnErrorLine(error),
94
96
  kind: "error",
95
97
  at: typeof record.timestamp === "string" ? record.timestamp : null,
96
98
  turn_id: typeof payload.turn_id === "string" && payload.turn_id ? payload.turn_id : null,
package/docs/DESIGN.md CHANGED
@@ -348,6 +348,10 @@ agent sessionへの送信1本を守る`<name>.agent-send.lock`は持つ時間が
348
348
  終了した持ち主のpidを別のprocessが使い回すと、pidだけでは生きて見える。生きて見える持ち主は、processが始まってからの経過とlockを作ってからの時間を比べ、
349
349
  lockより後に始まったprocessなら別人と読んで片付ける。消す役の印は、5秒より古ければ残った物と読む。`pty_close`は、どちらも片付ける。
350
350
 
351
+ Codexは、サービスの誤りや通信の失敗でturnを打ち切る時も、記録へ`task_complete`を書く(回答は無く、`error`が付く)。完了待ちは、
352
+ 利用上限(`usage_limit_exceeded`)を`rate_limited`、ほかの`error`つきを`error`で返す。`error`は応答の本文とURLを落とした1行の文、
353
+ Codexが書いた種類は`error_kind`で返す。失敗を空の回答の完了として返さない(ADR 0103)。判定と文の整え方は`src/harnesses/codex.ts`が所有する。
354
+
351
355
  Grokのread-only sandbox起動拒否は、`src/harnesses/grok.ts`の
352
356
  `assertGrokSandboxNotRejected`がCLIのエラー表示から検出する。`src/core.ts`の共通入力受付待機は
353
357
  Grokの場合だけこの判定を呼び、`GROK_SANDBOX_STARTUP_FAILED`で原因と未送信を返す。
@@ -390,7 +394,8 @@ Claude・Grokは2秒、Cursorは1秒に1回で、待ちに入った最初の周
390
394
  `diagnostics`はread-onlyで、PTY backendとagent dependencyを検査する。runtime error aggregateは
391
395
  製品所有のlocal stateに固定codeと集約metadataだけを保存し、既定ではnetwork I/Oを持たない。
392
396
  BugHubへの報告は、利用者が明示して有効にし、合鍵のファイルがある端末だけが、別processで行う。
393
- きっかけは記録・解決・起動・手動の4つで、定期的な見張りは置かない。受け取り済みにするのは応答の署名まで確かめた時だけ(ADR 0079)。工場reporterとの
397
+ きっかけは記録・解決・起動・手動の4つで、定期的な見張りは置かない。受け取り済みにするのは応答の署名まで確かめた時だけ(ADR 0079)。
398
+ 記録するのは、Aitermが動く前提が欠けた時の固定の3種類だけ。通信の失敗・取消・待ちの時間切れは記録せず、呼んだ側へ返す(ADR 0102)。工場reporterとの
394
399
  連携は明示opt-inの任意adapterであり、未設定時もAiterm本体は単独動作する。raw error、prompt、出力、
395
400
  transcript、path、credentialを保存・公開しない。
396
401
  親配送hook(Claude Code・Cursor)の登録状態は`src/parent-hook-diagnostic.ts`が利用者設定の読取りだけで要約し、
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-mcp",
3
- "version": "0.57.1",
3
+ "version": "0.57.2",
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, and Cursor Agent CLI, plus durable PTYs for SSH, containers, and REPLs.",
6
6
  "keywords": [