aiterm-mcp 0.57.2 → 0.57.4
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 +51 -1
- package/README.ja.md +2 -1
- package/README.md +2 -1
- package/dist/harnesses/codex.js +185 -23
- package/dist/harnesses/cursor.js +36 -6
- package/dist/interim-words.js +3 -2
- package/docs/DESIGN.md +9 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.57.4] - 2026-10-08
|
|
11
|
+
|
|
12
|
+
### 修正
|
|
13
|
+
|
|
14
|
+
- Codexの席で、警告の画面(足元の「⚠ N warnings · f2 to view」をF2で開いた所)が開いている間に送った文が、届かないのに
|
|
15
|
+
`agent_dispatch`で返っていた件を直す(ADR 0107)。
|
|
16
|
+
起動の見出し(`>_ OpenAI Codex`)の`>_`を入力欄の印と読んでいたので、見出しが画面に残る席では、入力欄が警告の画面に
|
|
17
|
+
置き換わっていても入力待ちと読んでいた。文は警告の画面に吸われ、turnは始まらず、完了は来なかった。
|
|
18
|
+
- 見出しの`>_`を入力欄の印に数えない。入力欄の行がある時だけ入力待ちと読む。
|
|
19
|
+
- 警告の画面を、応答の要る画面と同じに数える。`pty_observe`は`blocked`・`unknown_dialog`、`pty_send`は待たずに、今までと同じ
|
|
20
|
+
文面(「…入力受付状態になりません。文字列は送信していません。…」)で断る。番が動いている席・回答を流している席でも同じ。
|
|
21
|
+
見出しが流れた後の席では、今まで30秒待ってから同じ文面(`state=unknown reason=unrecognized_screen`)で断っていた。
|
|
22
|
+
- Aitermは警告の画面を閉じない(`Esc`はその警告を消す)。引数、返りの項目、断りの文面、警告の画面が開いていない席の読みは変えていない。
|
|
23
|
+
警告の画面は人がF2を押した時だけ開くので、BellTeamの席の動きは変わらない。
|
|
24
|
+
|
|
25
|
+
## [0.57.3] - 2026-10-08
|
|
26
|
+
|
|
27
|
+
### 修正
|
|
28
|
+
|
|
29
|
+
- Codexの席で、入力欄の`/new`・`/clear`で会話が切り替わった後、完了待ちが完了を拾えずに時間切れになっていた件を直す(ADR 0105)。
|
|
30
|
+
Codexは、processを生かしたまま、新しい会話を別の記録(rollout)へ書く。Aitermは最初の会話の記録を見続けていたので、
|
|
31
|
+
切り替えた後のturnは完了が届かず、回答の読み出しは前の会話の回答を返していた。席を閉じるまで直らなかった。
|
|
32
|
+
- 今の会話の記録を、結び付けた会話より後に書かれた、同じ起動の印を持つ派生でないroot会話(`codex-tui`・`cli`)から決める。
|
|
33
|
+
- 新しいturnを送る時に、席の`vendor_session_id`を今の会話へ結び付け直す。完了待ちは、読み始めた記録が3秒増えない時に今の会話を見直す。
|
|
34
|
+
- 引数、返りの形、断りの文面、会話が切り替わっていない席の読みは変えていない。BellTeamは席へ命令を打たないので、動きは変わらない。
|
|
35
|
+
- 切り替えた後の最初のturnでは、合間の言葉は出ず、完了は最長で3秒遅れる。派生させた会話(`/fork`)は追わない。
|
|
36
|
+
- 手で打った`/compact`の途中に届いた文が、差し込みで返るのにCodexでは後の別のturnになる件は、直していない(理由はADR 0105)。
|
|
37
|
+
自動の圧縮の途中に届いた文は、同じturnへ入る事を実物で確かめた。
|
|
38
|
+
|
|
39
|
+
- Cursorのturnが誤りで終わった時、完了待ちが`done`を返していた件を直す(ADR 0106)。
|
|
40
|
+
Cursorは、記録の`turn_ended`へ`status: "error"`と文を書く。Aitermは`status`を見ていなかったので、呼んだ側に、
|
|
41
|
+
失敗が、空の(または途中までの)回答の完了として届いていた。Codexで0.57.2に直したのと同じ形。
|
|
42
|
+
- サービスの誤り(`[unavailable] Error`など): `outcome: "error"`。`aiterm-wait`はexit 7。`error`は1行の文、
|
|
43
|
+
文の頭の角括弧の名前を`error_kind`で返す。
|
|
44
|
+
- 利用上限の文: `outcome: "rate_limited"`。画面から読めた時と同じ返りに揃える。
|
|
45
|
+
- 席で止めたturn(`User aborted request`)と、`status: "success"`は、今までどおり`done`。
|
|
46
|
+
- 引数、断りの文面、送信の振り分け、ほかの席は変えていない。
|
|
47
|
+
|
|
48
|
+
### Tests
|
|
49
|
+
|
|
50
|
+
- 試験の前処理(`test/seat-env.mjs`)が作る置き場(`/tmp/at-*`)を、試験processの終わりに消す(ADR 0104)。
|
|
51
|
+
今までは誰も消しておらず、全部の試験を1回流すと約100個残っていた。つながるtmuxのserverが残っている置き場は消さず、場所を標準エラーへ書く。
|
|
52
|
+
製品の動きは変えない。
|
|
53
|
+
- `test/codex-relay-official.test.mjs`を、対象のOS(macOSとWindows)でだけ流す。Linuxで公式のCodexの実行ファイルを指定すると、
|
|
54
|
+
対象でない確かめ(`ps`の`comm=`、socketの確かめ)で2件落ちていた。
|
|
55
|
+
- `test/claude-exit-before-close.test.mjs`の2件を、席を閉じた0.3秒後に記録を読む形から、切断の合図の記録が出るまで待つ形へ直す。
|
|
56
|
+
混んだmacOSのCIで、記録が0.3秒より遅れて1件落ちた。
|
|
57
|
+
|
|
10
58
|
## [0.57.2] - 2026-10-07
|
|
11
59
|
|
|
12
60
|
### 修正
|
|
@@ -2397,7 +2445,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
|
|
|
2397
2445
|
`ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
|
|
2398
2446
|
provenance.
|
|
2399
2447
|
|
|
2400
|
-
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.57.
|
|
2448
|
+
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.57.4...HEAD
|
|
2449
|
+
[0.57.4]: https://github.com/kitepon/aiterm-mcp/compare/v0.57.3...v0.57.4
|
|
2450
|
+
[0.57.3]: https://github.com/kitepon/aiterm-mcp/compare/v0.57.2...v0.57.3
|
|
2401
2451
|
[0.57.2]: https://github.com/kitepon/aiterm-mcp/compare/v0.57.1...v0.57.2
|
|
2402
2452
|
[0.57.1]: https://github.com/kitepon/aiterm-mcp/compare/v0.57.0...v0.57.1
|
|
2403
2453
|
[0.57.0]: https://github.com/kitepon/aiterm-mcp/compare/v0.56.1...v0.57.0
|
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.
|
|
212
|
+
**状態:** 開発継続中 · 現行公開版 **v0.57.4** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
|
|
213
213
|
|
|
214
214
|
### 更新と巻き戻し
|
|
215
215
|
|
|
@@ -260,6 +260,7 @@ pty_read(id, { wait: true }) → 削減済みの出力を読む(完了
|
|
|
260
260
|
ClaudeがAPIエラーや安全判定の拒否で終了した時は、Stop hookが発火しなくても次の`pty_send`を新しいturnとして扱う。現在のturn開始後のエラー記録だけを確認し、過去のエラーで実行中のturnを解除しない。上流の拒否はエラーのまま返す。
|
|
261
261
|
|
|
262
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
|
+
Cursorが誤りでturnを終えた時(記録の`turn_ended`が`status: "error"`)も同じで、完了待ちは`error`を返し、文の頭の角括弧の名前(`unavailable`など)を`error_kind`に載せる。利用上限の文は`rate_limited`、席で止めたturn(`User aborted request`)は今までどおり`done`。
|
|
263
264
|
|
|
264
265
|
agent配送だけを期待する連携では、`pty_send`に`require_agent:true`を指定する。agent登録が無ければ、打鍵前に`AGENT_SESSION_REQUIRED`と「文字列は送信していません」を返す。省略時は通常PTY送信を維持する。`force:true`との併用は未送信で拒否する。
|
|
265
266
|
|
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.
|
|
226
|
+
**Status:** actively maintained · current public release **v0.57.4** · 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
|
|
|
@@ -260,6 +260,7 @@ I used **Codex with GPT-5.6** as an engineering collaborator: it inspected the i
|
|
|
260
260
|
ClaudeがAPIエラーや安全判定の拒否で終了した時は、Stop hookが発火しなくても次の`pty_send`を新しいturnとして扱う。現在のturn開始後のエラー記録だけを確認し、過去のエラーで実行中のturnを解除しない。上流の拒否はエラーのまま返す。
|
|
261
261
|
|
|
262
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
|
+
Cursorが誤りでturnを終えた時(記録の`turn_ended`が`status: "error"`)も同じで、完了待ちは`error`を返し、文の頭の角括弧の名前(`unavailable`など)を`error_kind`に載せる。利用上限の文は`rate_limited`、席で止めたturn(`User aborted request`)は今までどおり`done`。
|
|
263
264
|
|
|
264
265
|
## Two ways to use it
|
|
265
266
|
|
package/dist/harnesses/codex.js
CHANGED
|
@@ -127,22 +127,31 @@ export function listCodexTranscripts(codexHome) {
|
|
|
127
127
|
visit(sessionsDir);
|
|
128
128
|
return files.sort();
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
/**
|
|
131
|
+
* rolloutがこの起動のroot会話かを、頭の1MBから読む。
|
|
132
|
+
* - match: Codex CLIのroot会話で、developerの文にこの起動の印がある。
|
|
133
|
+
* - other: root会話でない。または、最初のturnの文脈(turn_context)まで書かれているのに印が無い。後から変わらない。
|
|
134
|
+
* - undecided: 書いている途中などで、まだ決められない。
|
|
135
|
+
* forkedは、ほかの会話から派生した会話(session_metaのforked_from_id)か。派生は元の会話の文を写すので、印だけでは持ち主を決められない。
|
|
136
|
+
*/
|
|
137
|
+
function codexLaunchVerdict(file, meta) {
|
|
131
138
|
const createdAt = Date.parse(meta.created_at);
|
|
132
139
|
try {
|
|
133
140
|
const st = fs.statSync(file);
|
|
134
141
|
if (Number.isFinite(createdAt) && st.mtimeMs + 5_000 < createdAt)
|
|
135
|
-
return false;
|
|
142
|
+
return { verdict: "other", forked: false };
|
|
136
143
|
}
|
|
137
144
|
catch {
|
|
138
|
-
return false;
|
|
145
|
+
return { verdict: "undecided", forked: false };
|
|
139
146
|
}
|
|
140
147
|
const size = Math.min(safeStatSize(file), 1024 * 1024);
|
|
141
148
|
if (size === 0)
|
|
142
|
-
return false;
|
|
149
|
+
return { verdict: "undecided", forked: false };
|
|
143
150
|
const marker = `AITERM_AGENT_LAUNCH_ID=${meta.launch_id}`;
|
|
144
151
|
let rootCli = false;
|
|
152
|
+
let forked = false;
|
|
145
153
|
let launchMarker = false;
|
|
154
|
+
let firstTurnContext = false;
|
|
146
155
|
for (const line of readFileRange(file, 0, size).toString("utf8").split("\n")) {
|
|
147
156
|
if (!line.trim())
|
|
148
157
|
continue;
|
|
@@ -156,8 +165,11 @@ export function codexTranscriptMatchesLaunch(file, meta) {
|
|
|
156
165
|
if (record?.type === "session_meta") {
|
|
157
166
|
rootCli = record?.payload?.originator === "codex-tui" && record?.payload?.source === "cli";
|
|
158
167
|
if (!rootCli)
|
|
159
|
-
return false;
|
|
168
|
+
return { verdict: "other", forked: false };
|
|
169
|
+
forked = typeof record?.payload?.forked_from_id === "string" && record.payload.forked_from_id !== "";
|
|
160
170
|
}
|
|
171
|
+
if (record?.type === "turn_context")
|
|
172
|
+
firstTurnContext = true;
|
|
161
173
|
if (record?.type === "response_item" &&
|
|
162
174
|
record?.payload?.type === "message" &&
|
|
163
175
|
record?.payload?.role === "developer" &&
|
|
@@ -167,9 +179,12 @@ export function codexTranscriptMatchesLaunch(file, meta) {
|
|
|
167
179
|
item.text.includes(marker));
|
|
168
180
|
}
|
|
169
181
|
if (rootCli && launchMarker)
|
|
170
|
-
return
|
|
182
|
+
return { verdict: "match", forked };
|
|
171
183
|
}
|
|
172
|
-
return
|
|
184
|
+
return { verdict: rootCli && firstTurnContext ? "other" : "undecided", forked };
|
|
185
|
+
}
|
|
186
|
+
export function codexTranscriptMatchesLaunch(file, meta) {
|
|
187
|
+
return codexLaunchVerdict(file, meta).verdict === "match";
|
|
173
188
|
}
|
|
174
189
|
export function codexTranscriptSessionId(file) {
|
|
175
190
|
const size = Math.min(safeStatSize(file), AGENT_EVENT_TAIL_BYTES);
|
|
@@ -191,11 +206,96 @@ export function codexTranscriptSessionId(file) {
|
|
|
191
206
|
}
|
|
192
207
|
return null;
|
|
193
208
|
}
|
|
209
|
+
/** rolloutのfile名にある会話ID(UUIDv7)と、そこに入っている作成時刻(ms)。v7でなければnull。 */
|
|
210
|
+
function codexRolloutCreation(file) {
|
|
211
|
+
const id = /-([0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})\.jsonl$/.exec(path.basename(file))?.[1];
|
|
212
|
+
return id ? { id, ms: Number.parseInt(id.slice(0, 8) + id.slice(9, 13), 16) } : null;
|
|
213
|
+
}
|
|
214
|
+
// 起動ごとの、rolloutの判定の控え(file → この起動の会話か)。頭の読み直しを避ける。決められなかったfileは入れない。
|
|
215
|
+
const CODEX_LAUNCH_VERDICT_MEMO_MAX = 64;
|
|
216
|
+
const codexLaunchVerdictMemo = new Map();
|
|
217
|
+
function codexLaunchVerdictMemoFor(launchId) {
|
|
218
|
+
let memo = codexLaunchVerdictMemo.get(launchId);
|
|
219
|
+
if (!memo) {
|
|
220
|
+
if (codexLaunchVerdictMemo.size >= CODEX_LAUNCH_VERDICT_MEMO_MAX) {
|
|
221
|
+
codexLaunchVerdictMemo.delete(codexLaunchVerdictMemo.keys().next().value);
|
|
222
|
+
}
|
|
223
|
+
memo = new Map();
|
|
224
|
+
codexLaunchVerdictMemo.set(launchId, memo);
|
|
225
|
+
}
|
|
226
|
+
return memo;
|
|
227
|
+
}
|
|
228
|
+
/** 結び付けた会話(vendor_session_id)のroot rollout。会話の切り替えは追わない。完了の読み位置(cursor)はこのfileの位置。 */
|
|
229
|
+
export function codexBoundTranscript(meta) {
|
|
230
|
+
if (meta.kind !== "codex" || !meta.codex_home || !meta.vendor_session_id)
|
|
231
|
+
return null;
|
|
232
|
+
return findLatestCodexTranscript(meta.codex_home, meta.vendor_session_id);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* 結び付けた会話より後に書かれた、この起動の別の会話のroot rollout。無ければnull(ADR 0105)。
|
|
236
|
+
* Codexは、入力欄の /new・/clear で、processを生かしたまま新しい会話(別のrollout)へ移る。古いrolloutには何も書かない。
|
|
237
|
+
* 新しい会話の候補は、次を全部満たすrolloutだけ。
|
|
238
|
+
* - 会話IDがUUIDv7で、その作成時刻がこの席の起動より後。
|
|
239
|
+
* - 結び付けた会話のrolloutより後に書かれている(mtime)。
|
|
240
|
+
* - Codex CLIのroot会話で、派生(forked_from_id)でなく、developerの文にこの起動の印がある。
|
|
241
|
+
* 印は起動時に渡したdeveloper_instructionsから来るので、派生でない会話が持つなら、この席のprocessが始めた会話。
|
|
242
|
+
* 派生は元の会話の文を写すので、別の端末で派生させた会話を拾わないよう、追わない。
|
|
243
|
+
* 候補が複数なら、最後に書かれた物。
|
|
244
|
+
*/
|
|
245
|
+
function codexSwitchedTranscript(meta, bound) {
|
|
246
|
+
if (!meta.codex_home || meta.hook_route !== "shared_codex_home")
|
|
247
|
+
return null;
|
|
248
|
+
const launchedAt = Date.parse(meta.created_at);
|
|
249
|
+
if (!Number.isFinite(launchedAt))
|
|
250
|
+
return null;
|
|
251
|
+
let boundMtime;
|
|
252
|
+
try {
|
|
253
|
+
boundMtime = fs.statSync(bound).mtimeMs;
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
const memo = codexLaunchVerdictMemoFor(meta.launch_id);
|
|
259
|
+
let latest = null;
|
|
260
|
+
let latestMtime = boundMtime;
|
|
261
|
+
for (const file of listCodexTranscripts(meta.codex_home)) {
|
|
262
|
+
if (file === bound || memo.get(file) === false)
|
|
263
|
+
continue;
|
|
264
|
+
const creation = codexRolloutCreation(file);
|
|
265
|
+
if (!creation || creation.ms + 5_000 < launchedAt)
|
|
266
|
+
continue;
|
|
267
|
+
let mtime;
|
|
268
|
+
try {
|
|
269
|
+
mtime = fs.statSync(file).mtimeMs;
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (mtime <= latestMtime)
|
|
275
|
+
continue;
|
|
276
|
+
let own = memo.get(file);
|
|
277
|
+
if (own === undefined) {
|
|
278
|
+
const { verdict, forked } = codexLaunchVerdict(file, meta);
|
|
279
|
+
if (verdict === "undecided")
|
|
280
|
+
continue;
|
|
281
|
+
own = verdict === "match" && !forked;
|
|
282
|
+
memo.set(file, own);
|
|
283
|
+
}
|
|
284
|
+
if (!own)
|
|
285
|
+
continue;
|
|
286
|
+
latest = file;
|
|
287
|
+
latestMtime = mtime;
|
|
288
|
+
}
|
|
289
|
+
return latest;
|
|
290
|
+
}
|
|
291
|
+
/** この起動の、今の会話のroot rollout。結び付けた会話から、同じprocessの新しい会話へ移っていれば、新しい方。 */
|
|
194
292
|
export function codexRootTranscript(meta) {
|
|
195
293
|
if (meta.kind !== "codex" || !meta.codex_home)
|
|
196
294
|
return null;
|
|
197
|
-
if (meta.vendor_session_id)
|
|
198
|
-
|
|
295
|
+
if (meta.vendor_session_id) {
|
|
296
|
+
const bound = findLatestCodexTranscript(meta.codex_home, meta.vendor_session_id);
|
|
297
|
+
return bound ? codexSwitchedTranscript(meta, bound) ?? bound : null;
|
|
298
|
+
}
|
|
199
299
|
if (meta.hook_route === "shared_codex_home") {
|
|
200
300
|
const matches = listCodexTranscripts(meta.codex_home).filter((file) => codexTranscriptMatchesLaunch(file, meta));
|
|
201
301
|
if (matches.length > 1) {
|
|
@@ -205,12 +305,22 @@ export function codexRootTranscript(meta) {
|
|
|
205
305
|
}
|
|
206
306
|
return listCodexTranscripts(meta.codex_home)[0] ?? null;
|
|
207
307
|
}
|
|
308
|
+
/** rolloutの会話ID。結び付けた会話のrolloutならそのID、会話が切り替わった後のrolloutなら、その頭に書かれたID。 */
|
|
309
|
+
function codexRolloutSessionId(meta, transcript) {
|
|
310
|
+
if (meta.vendor_session_id && path.basename(transcript).includes(meta.vendor_session_id))
|
|
311
|
+
return meta.vendor_session_id;
|
|
312
|
+
return codexTranscriptSessionId(transcript) ?? codexRolloutCreation(transcript)?.id ?? meta.vendor_session_id;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* 今の会話のroot rolloutを返し、席の登録の会話ID(vendor_session_id)をその会話へ合わせる。
|
|
316
|
+
* 会話が切り替わっていた時は、ここで結び付け直す。呼ぶのは席の持ち主(送信の道)だけ。完了待ちは書かない。
|
|
317
|
+
*/
|
|
208
318
|
export function bindCodexTranscriptSession(meta) {
|
|
209
319
|
const transcript = codexRootTranscript(meta);
|
|
210
320
|
if (!transcript)
|
|
211
321
|
return null;
|
|
212
|
-
const harnessSessionId = codexTranscriptSessionId(transcript);
|
|
213
|
-
if (harnessSessionId &&
|
|
322
|
+
const harnessSessionId = meta.vendor_session_id ? codexRolloutSessionId(meta, transcript) : codexTranscriptSessionId(transcript);
|
|
323
|
+
if (harnessSessionId && meta.vendor_session_id !== harnessSessionId) {
|
|
214
324
|
meta.vendor_session_id = harnessSessionId;
|
|
215
325
|
writeAgentMetadata(meta);
|
|
216
326
|
}
|
|
@@ -271,6 +381,8 @@ export function codexUsageLimit(record) {
|
|
|
271
381
|
const error = codexTurnError(record);
|
|
272
382
|
return error?.info === "usage_limit_exceeded" ? error.message : null;
|
|
273
383
|
}
|
|
384
|
+
// 完了待ちが、会話の切り替えを確かめる間隔。送った文はすぐ記録へ書かれるので、普通のturnはここへ来ない。
|
|
385
|
+
const CODEX_SWITCH_CHECK_MS = 3_000;
|
|
274
386
|
/**
|
|
275
387
|
* この起動のroot rolloutの、末尾から見て最初のturnの境界。
|
|
276
388
|
* Codexはturnの開始でtask_started、終わりでtask_complete、止めた時はturn_aborted(reasonはinterrupted)を書く(0.160.1の実記録)。
|
|
@@ -332,7 +444,7 @@ export function latestCodexCompletion(meta, readTranscriptLines) {
|
|
|
332
444
|
const transcript = codexRootTranscript(meta);
|
|
333
445
|
if (!transcript)
|
|
334
446
|
return null;
|
|
335
|
-
const harnessSessionId = meta
|
|
447
|
+
const harnessSessionId = codexRolloutSessionId(meta, transcript);
|
|
336
448
|
let latest = null;
|
|
337
449
|
for (const line of readTranscriptLines(transcript)) {
|
|
338
450
|
if (!line.trim())
|
|
@@ -348,13 +460,19 @@ export function latestCodexCompletion(meta, readTranscriptLines) {
|
|
|
348
460
|
}
|
|
349
461
|
export async function observeCodexDone(meta, timeout, requestedCursor, signal) {
|
|
350
462
|
const metadataFile = agentMetadataPath(meta.aiterm_session, meta.launch_id);
|
|
351
|
-
|
|
352
|
-
const
|
|
463
|
+
// 読み位置(cursor)は、送った時に結び付いていた会話のrolloutの位置。結び付けが済んだ席は、そのrolloutから読み始める。
|
|
464
|
+
const anchored = () => meta.vendor_session_id ? codexBoundTranscript(meta) : codexRootTranscript(meta);
|
|
465
|
+
let transcript = anchored();
|
|
466
|
+
let startOffset = requestedCursor ?? (transcript ? safeStatSize(transcript) : 0);
|
|
353
467
|
let cursor = startOffset;
|
|
354
468
|
let carry = "";
|
|
355
469
|
let malformedEvents = 0;
|
|
356
470
|
let discardLeadingFragment = false;
|
|
357
471
|
let initializedBoundary = false;
|
|
472
|
+
// 待ち始めてからrolloutが1行も増えない時、会話が切り替わっていないかを見る時刻(ADR 0105)。
|
|
473
|
+
let switchCheckAt = performance.now() + CODEX_SWITCH_CHECK_MS;
|
|
474
|
+
// 切り替わった後の会話では、前の会話の最後の書き込みより後の完了だけを数える。
|
|
475
|
+
let completedAfter = null;
|
|
358
476
|
const deadline = performance.now() + timeout * 1000;
|
|
359
477
|
const observation = (outcome, ev = null, rateLimit = null, failed = null) => ({
|
|
360
478
|
schema: "aiterm.agent-wait-result.v1",
|
|
@@ -376,7 +494,37 @@ export async function observeCodexDone(meta, timeout, requestedCursor, signal) {
|
|
|
376
494
|
signal?.throwIfAborted();
|
|
377
495
|
if (!fs.existsSync(metadataFile))
|
|
378
496
|
return observation("closed");
|
|
379
|
-
transcript ??=
|
|
497
|
+
transcript ??= anchored();
|
|
498
|
+
if (transcript && meta.vendor_session_id && cursor === startOffset && performance.now() >= switchCheckAt) {
|
|
499
|
+
switchCheckAt = performance.now() + CODEX_SWITCH_CHECK_MS;
|
|
500
|
+
let current = null;
|
|
501
|
+
try {
|
|
502
|
+
current = codexRootTranscript(meta);
|
|
503
|
+
}
|
|
504
|
+
catch { /* 読めない時は、今のrolloutを見続ける */ }
|
|
505
|
+
if (current && current !== transcript && safeStatSize(transcript) === cursor) {
|
|
506
|
+
// 送った後に、同じprocessの新しい会話へ移っていた。送る時に無かった会話なので、前の会話の最後の書き込みより後の記録が今回の分。
|
|
507
|
+
// 読み位置を指定せずに待ち始めた時は、今までどおり、今より後の完了を待つ。
|
|
508
|
+
const size = safeStatSize(current);
|
|
509
|
+
if (requestedCursor == null) {
|
|
510
|
+
cursor = size;
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
try {
|
|
514
|
+
completedAfter = fs.statSync(transcript).mtimeMs;
|
|
515
|
+
}
|
|
516
|
+
catch {
|
|
517
|
+
completedAfter = null;
|
|
518
|
+
}
|
|
519
|
+
cursor = Math.max(0, size - CODEX_TRANSCRIPT_INCREMENT_MAX_BYTES);
|
|
520
|
+
}
|
|
521
|
+
transcript = current;
|
|
522
|
+
startOffset = cursor;
|
|
523
|
+
carry = "";
|
|
524
|
+
initializedBoundary = false;
|
|
525
|
+
discardLeadingFragment = false;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
380
528
|
if (transcript) {
|
|
381
529
|
if (!initializedBoundary) {
|
|
382
530
|
if (cursor > 0) {
|
|
@@ -401,7 +549,7 @@ export async function observeCodexDone(meta, timeout, requestedCursor, signal) {
|
|
|
401
549
|
parts.shift();
|
|
402
550
|
discardLeadingFragment = false;
|
|
403
551
|
}
|
|
404
|
-
const harnessSessionId = meta.vendor_session_id
|
|
552
|
+
const harnessSessionId = meta.vendor_session_id ? codexRolloutSessionId(meta, transcript) : codexTranscriptSessionId(transcript);
|
|
405
553
|
for (const line of parts) {
|
|
406
554
|
if (!line.trim())
|
|
407
555
|
continue;
|
|
@@ -412,6 +560,11 @@ export async function observeCodexDone(meta, timeout, requestedCursor, signal) {
|
|
|
412
560
|
try {
|
|
413
561
|
const record = JSON.parse(line);
|
|
414
562
|
const done = codexCompletionEvent(meta, harnessSessionId, record);
|
|
563
|
+
if (done && completedAfter !== null) {
|
|
564
|
+
const at = Date.parse(record.timestamp);
|
|
565
|
+
if (Number.isFinite(at) && at <= completedAfter)
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
415
568
|
if (done) {
|
|
416
569
|
// 上限の知らせはこのturnの終わりにだけ書かれる。画面やpane logの文字は、上限が明けた後も
|
|
417
570
|
// 残り、道具の出力や依頼文にも現れるので見ない(2026-09-28)。
|
|
@@ -479,6 +632,11 @@ export function codexLaunchNote(model, effort, meta) {
|
|
|
479
632
|
const summary = meta?.kind === "codex" && meta.codex_home ? codexConfigSummary(configPath) : "";
|
|
480
633
|
return (summary ? `${launch}\n${summary}\n` : launch) + writeScopeNote;
|
|
481
634
|
}
|
|
635
|
+
// 入力欄の行頭の印(「›」。古い描画では「>」)。番号つきの行(「› 1. …」)はmodalで選択中の選択肢。
|
|
636
|
+
// 起動の見出し(「>_ OpenAI Codex (v0.161.0)」)の「>_」は入力欄ではない。これを入力欄と数えると、見出しが残っている席で
|
|
637
|
+
// 入力欄が別の画面(F2で開いた警告の画面など)に置き換わっていても入力待ちと読み、文がその画面に吸われる
|
|
638
|
+
// (Codex 0.161.0の実物、2026-10-08。ADR 0107)。
|
|
639
|
+
const CODEX_COMPOSER_LINE = String.raw `(?:^|\n)[ \t]*[›>](?!_)(?![ \t]*\d+\.)`;
|
|
482
640
|
export function codexTuiReady(screen) {
|
|
483
641
|
if (codexStartupFailure(screen))
|
|
484
642
|
return false;
|
|
@@ -486,11 +644,14 @@ export function codexTuiReady(screen) {
|
|
|
486
644
|
// capture-paneは直近45行だけなので、会話が進むとheaderは正常に画面外へ流れる。
|
|
487
645
|
const codexFrontend = screen.includes("OpenAI Codex")
|
|
488
646
|
|| /(^|\n)\s*\S+\s+(?:default|low|medium|high|xhigh|max|ultra)(?:\s+fast)?\s+·\s+\S.*$/m.test(screen);
|
|
489
|
-
return codexFrontend &&
|
|
647
|
+
return codexFrontend && new RegExp(CODEX_COMPOSER_LINE).test(screen);
|
|
490
648
|
}
|
|
491
649
|
// 0.155までは文章のfooter、0.157からは「enter select · esc back」のようなkey hint行になった。
|
|
492
|
-
|
|
493
|
-
|
|
650
|
+
// 足元の「⚠ N warnings · f2 to view」をF2で開いた警告の画面は、入力欄の場所に出て、鍵を自分で受ける
|
|
651
|
+
// (足元は「k keep & next · esc dismiss & close · ^o copy · ←/→ warning · ↓ scroll」、見出しは「Warnings · 1 of 3 · Startup」)。
|
|
652
|
+
// 開いている間に打った文は入力欄へ入らないので、応答の要るmodalと同じに数える。Aitermは閉じない(Escはその警告を消す)。
|
|
653
|
+
const CODEX_MODAL_FOOTER = /Press enter to confirm or esc to (?:cancel|go back)|enter to submit\s*\|\s*esc to cancel|(?<=^|\n)[ \t]*(?:[^\n]*· )?enter [a-z]+ · (?:[^\n]* · )?esc [a-z]+[ \t]*(?=\n|$)|(?<=^|\n)[ \t]*(?:[^\n]*· )?esc dismiss(?: & close)?(?: · [^\n]*)?[ \t]*(?=\n|$)/gi;
|
|
654
|
+
const CODEX_DIALOG_HEADING = /Would you like to run the following command\?|Allow the [^\n]+ MCP server to run tool|Hooks need review|Do you trust the contents of this directory|Trust this folder\?|Update available!|Approaching rate limits|(?<=^|\n)[ \t]*Warnings · \d+ of \d+(?= ·|[ \t]*(?:\n|$))/g;
|
|
494
655
|
const CODEX_MODAL_MARKER = new RegExp(`${CODEX_MODAL_FOOTER.source}|${CODEX_DIALOG_HEADING.source}`, "gi");
|
|
495
656
|
function currentCodexDialog(screen) {
|
|
496
657
|
const footers = [...screen.matchAll(CODEX_MODAL_FOOTER)];
|
|
@@ -522,7 +683,7 @@ export function codexPaneObservation(screen) {
|
|
|
522
683
|
// psmuxはmodalを画面上部へ描き、下の空行もcaptureへ含める。空行を落としてから末尾を取る。
|
|
523
684
|
const tail = screen.replace(/\s+$/, "").split("\n").slice(-24).join("\n");
|
|
524
685
|
// 現在のmodal footerがある時だけ、折返しで上へ出た質問を画面全体から探す。
|
|
525
|
-
const lastComposer = [...tail.matchAll(
|
|
686
|
+
const lastComposer = [...tail.matchAll(new RegExp(CODEX_COMPOSER_LINE, "g"))].at(-1)?.index ?? -1;
|
|
526
687
|
const lastDialog = [...tail.matchAll(CODEX_MODAL_MARKER)].at(-1)?.index ?? -1;
|
|
527
688
|
const modal = lastDialog > lastComposer;
|
|
528
689
|
if (!modal) {
|
|
@@ -554,7 +715,7 @@ export function codexPaneObservation(screen) {
|
|
|
554
715
|
export function codexRateLimitModelSwitchDialog(screen) {
|
|
555
716
|
const current = currentCodexDialog(screen);
|
|
556
717
|
const footer = [...current.matchAll(CODEX_MODAL_FOOTER)].at(-1)?.index ?? -1;
|
|
557
|
-
const composer = [...current.matchAll(
|
|
718
|
+
const composer = [...current.matchAll(new RegExp(CODEX_COMPOSER_LINE, "g"))].at(-1)?.index ?? -1;
|
|
558
719
|
// footerが無いか、現在のcomposerがmodal footerより後なら、scrollbackの古いmodalである。
|
|
559
720
|
if (footer < 0 || composer > footer)
|
|
560
721
|
return null;
|
|
@@ -643,7 +804,7 @@ export function codexStartupAction(screen, trustProject) {
|
|
|
643
804
|
return { kind, keys: [...Array(Math.abs(distance)).fill(distance > 0 ? "Down" : "Up"), "Enter"] };
|
|
644
805
|
}
|
|
645
806
|
// submit座礁観測のcomposer領域マーカー(ready判定と同じ記号を行頭基準で探す)。
|
|
646
|
-
export const CODEX_COMPOSER_MARKER_RE = /^\s*[›>]/;
|
|
807
|
+
export const CODEX_COMPOSER_MARKER_RE = /^\s*[›>](?!_)/;
|
|
647
808
|
// Codexの起動前modalダイアログ検知。表示中はheader/footerが描かれず codexTuiReady が
|
|
648
809
|
// 恒久falseになるため、ready gate失敗の原因究明用に画面から種別を特定する
|
|
649
810
|
// (実被弾 2026-08-25: update確認で初手prompt未送信のまま30秒timeout→40分停滞)。
|
|
@@ -706,7 +867,8 @@ export function codexMoreReasoningChoice(screen) {
|
|
|
706
867
|
export function codexTranscriptText(meta, turnId, readTranscriptLines, transcriptUnavailable, exactCompletion = false) {
|
|
707
868
|
if (!meta.codex_home || !meta.vendor_session_id)
|
|
708
869
|
transcriptUnavailable();
|
|
709
|
-
|
|
870
|
+
// 完了待ちが切り替わった後の会話で完了を見つけた時も、同じ会話から回答を読む(ADR 0105)。
|
|
871
|
+
const transcript = codexRootTranscript(meta);
|
|
710
872
|
if (!transcript)
|
|
711
873
|
transcriptUnavailable();
|
|
712
874
|
const lines = readTranscriptLines(transcript);
|
package/dist/harnesses/cursor.js
CHANGED
|
@@ -114,6 +114,29 @@ export function bindCursorTranscriptSession(meta) {
|
|
|
114
114
|
}
|
|
115
115
|
return transcript;
|
|
116
116
|
}
|
|
117
|
+
// Cursorは、turnが誤りで終わると、turn_endedへ status "error" と文を書く(普通の終わりは "success" で、errorは無い)。
|
|
118
|
+
// 実記録(2026-08-24〜09-28、macbook 23件・rabbit 1件)にあった文:
|
|
119
|
+
// "[unavailable] Error" / "[resource_exhausted] Error"(サービスの誤り)
|
|
120
|
+
// "You've hit your usage limit You've saved $… Your usage limits will reset when …" / "Other Models usage limit reached Switched to …"(利用上限)
|
|
121
|
+
// "User aborted request"(席で止めたturn)
|
|
122
|
+
// 席で止めたturnは誤りに数えない(今までどおり完了として返す)。文は呼んだ側の画面にそのまま出るので、1行にしてURLを伏せ、長さを切る。
|
|
123
|
+
const CURSOR_ERROR_LINE_MAX = 200;
|
|
124
|
+
const CURSOR_LIMIT_LINE_MAX = 600;
|
|
125
|
+
export function cursorTurnError(record) {
|
|
126
|
+
if (record?.type !== "turn_ended" || record?.status !== "error")
|
|
127
|
+
return null;
|
|
128
|
+
const flat = typeof record.error === "string" ? record.error.replace(/\s+/g, " ").trim() : "";
|
|
129
|
+
if (/^user aborted request\b/i.test(flat))
|
|
130
|
+
return null;
|
|
131
|
+
const limit = /usage limit/i.test(flat);
|
|
132
|
+
const text = flat.replace(/https?:\/\/[^\s)\]>"']+/gi, "…") || "Cursorのturnが誤りで終わりました(理由の文は記録にありません)";
|
|
133
|
+
const max = limit ? CURSOR_LIMIT_LINE_MAX : CURSOR_ERROR_LINE_MAX;
|
|
134
|
+
return {
|
|
135
|
+
message: text.length > max ? `${text.slice(0, max - 1)}…` : text,
|
|
136
|
+
kind: /^\[([a-z][a-z0-9_]*)\]/i.exec(flat)?.[1].toLowerCase() ?? null,
|
|
137
|
+
limit,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
117
140
|
export function cursorCompletionEvent(meta, harnessSessionId, record, turnId) {
|
|
118
141
|
if (meta.kind !== "cursor" || record?.type !== "turn_ended" || typeof record?.status !== "string")
|
|
119
142
|
return null;
|
|
@@ -126,7 +149,7 @@ export function cursorCompletionEvent(meta, harnessSessionId, record, turnId) {
|
|
|
126
149
|
turn_id: turnId,
|
|
127
150
|
operation_id: null,
|
|
128
151
|
reason: `Cursor transcript turn_ended:${record.status}`,
|
|
129
|
-
done_status: "turn_done",
|
|
152
|
+
done_status: cursorTurnError(record) ? "turn_error" : "turn_done",
|
|
130
153
|
stop_hook_active: false,
|
|
131
154
|
at: new Date().toISOString(),
|
|
132
155
|
};
|
|
@@ -193,7 +216,7 @@ export async function observeCursorDone(meta, timeout, requestedCursor, readScre
|
|
|
193
216
|
const deadline = performance.now() + timeout * 1000;
|
|
194
217
|
// 画面を読むたびにtmuxを1回起動する。完了の見回りより間隔を空け、1回読んだ画面で利用上限とhook拒否の両方を見る。
|
|
195
218
|
const screenDue = pollGate(CURSOR_SCREEN_POLL_MS);
|
|
196
|
-
const observation = (outcome, ev = null, rateLimit = null, error = null) => ({
|
|
219
|
+
const observation = (outcome, ev = null, rateLimit = null, error = null, errorKind = null) => ({
|
|
197
220
|
schema: "aiterm.agent-wait-result.v1",
|
|
198
221
|
session_id: meta.aiterm_session,
|
|
199
222
|
launch_id: meta.launch_id,
|
|
@@ -207,7 +230,7 @@ export async function observeCursorDone(meta, timeout, requestedCursor, readScre
|
|
|
207
230
|
at: ev?.at ?? null,
|
|
208
231
|
rate_limit: rateLimit,
|
|
209
232
|
error,
|
|
210
|
-
error_kind:
|
|
233
|
+
error_kind: errorKind,
|
|
211
234
|
});
|
|
212
235
|
for (;;) {
|
|
213
236
|
signal?.throwIfAborted();
|
|
@@ -220,8 +243,13 @@ export async function observeCursorDone(meta, timeout, requestedCursor, readScre
|
|
|
220
243
|
if (state.userTurns > startBoundary && state.terminalRecord) {
|
|
221
244
|
const harnessSessionId = meta.vendor_session_id ?? cursorTranscriptSessionId(transcript);
|
|
222
245
|
const done = cursorCompletionEvent(meta, harnessSessionId, state.terminalRecord, `cursor:${state.userTurns}`);
|
|
223
|
-
if (done)
|
|
224
|
-
|
|
246
|
+
if (done) {
|
|
247
|
+
// 誤りで終わったturnを完了として返すと、失敗が空の回答に見える。Codexと同じく、typedな終了として返す(ADR 0106)。
|
|
248
|
+
const failed = cursorTurnError(state.terminalRecord);
|
|
249
|
+
if (failed?.limit)
|
|
250
|
+
return observation("rate_limited", done, failed.message);
|
|
251
|
+
return failed ? observation("error", done, null, failed.message, failed.kind) : observation("done", done);
|
|
252
|
+
}
|
|
225
253
|
}
|
|
226
254
|
}
|
|
227
255
|
// 最初の周回では必ず読む(timeout=0の照会も1回は読む)。
|
|
@@ -526,7 +554,9 @@ export function cursorTuiReady(screen) {
|
|
|
526
554
|
return /Cursor Agent/i.test(screen) &&
|
|
527
555
|
(CURSOR_COMPOSER_MARKER_RE.test(screen) || CURSOR_START_PROMPT_MARKER_RE.test(screen));
|
|
528
556
|
}
|
|
529
|
-
// 利用上限に達したCursor
|
|
557
|
+
// 利用上限に達したCursorは、入力欄も戻さずに説明を出して止まる(2026.09.26-dd393fe、macOSで実測)。
|
|
558
|
+
// transcriptには、user turnを残さずにturn_ended(status "error")だけを書く事がある(実記録で8件)。その時は完了の条件
|
|
559
|
+
// (user turnが増えている)に当たらないので、画面で見る。user turnがある時は、完了待ちが記録から読む(cursorTurnError)。
|
|
530
560
|
// Error: You've hit your usage limit
|
|
531
561
|
// You've saved $766 ... Switch to a different model or set a Spend Limit to continue with Sonnet. ...
|
|
532
562
|
// fallbackModel: / spendLimitHit: true / chatMessage: ...
|
package/dist/interim-words.js
CHANGED
|
@@ -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, codexTurnErrorLine } from "./harnesses/codex.js";
|
|
17
|
+
import { codexBoundTranscript, 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" の時だけ合間の言葉を返す。 */
|
|
@@ -248,8 +248,9 @@ export function readInterimWords(meta, after) {
|
|
|
248
248
|
const boundary = recorded?.boundary ?? 0;
|
|
249
249
|
if (meta.kind === "claude")
|
|
250
250
|
found = claudeInterimWords(readLines(claudeSessionTranscriptPath(meta), boundary));
|
|
251
|
+
// 境界は、送った時に結び付いていた会話のrolloutの位置。会話の切り替えは追わない(ADR 0105)。
|
|
251
252
|
else if (meta.kind === "codex")
|
|
252
|
-
found = codexInterimWords(readLines(codexRootTranscript(meta), boundary));
|
|
253
|
+
found = codexInterimWords(readLines(meta.vendor_session_id ? codexBoundTranscript(meta) : codexRootTranscript(meta), boundary));
|
|
253
254
|
else if (meta.kind === "grok")
|
|
254
255
|
found = grokInterimWords(readLines(grokChatHistory(meta)), boundary);
|
|
255
256
|
else
|
package/docs/DESIGN.md
CHANGED
|
@@ -52,6 +52,7 @@ sessionの表には環境が丸ごと入るので、名指しで登録した名
|
|
|
52
52
|
対象の一覧取得やserver終了が失敗した場合は登録を削除しない(ADR 0087)。
|
|
53
53
|
試験の正規入口(`npm test`とCI)は`test/seat-env.mjs`を前処理として読み、席の保存場所・系譜・tmux環境を外し、
|
|
54
54
|
試験processごとの一時領域を指定する。個別試験が指定する`TMPDIR`と`XDG_RUNTIME_DIR`もそのまま利用できる。
|
|
55
|
+
前処理は、作った一時領域をprocessの終わりに消す。つながるtmuxのserverが残っている時だけ、消さずに場所を標準エラーへ書く(ADR 0104)。
|
|
55
56
|
|
|
56
57
|
agent配送だけを期待する連携元は`pty_send(require_agent:true)`を指定する。agent登録が無ければ、通常PTYへ送る前に
|
|
57
58
|
`AGENT_SESSION_REQUIRED`と「文字列は送信していません」を返す。未送信を確定してから対象sessionを復旧できる。
|
|
@@ -65,6 +66,9 @@ agentの席への`pty_send`は、任意の`preface`(本文の前に置く1行
|
|
|
65
66
|
Codexは回答を流している間、画面に動作中の行を出さない。`pty_send`の振り分けは、Codexの席に限り、画面が入力待ちでも、この起動の記録の
|
|
66
67
|
最後の境界がturnの開始で、processが生きていて、0.4秒おいて見直しても記録が同じturnのままで画面が動いている時を、動いていると数える
|
|
67
68
|
(ADR 0101)。止まっている席を動いていると読まないよう、1つでも欠けたら新しいturnの道へ回す。
|
|
69
|
+
Codexの席の記録は、結び付けた会話(`vendor_session_id`)のrolloutか、それより後に書かれた、同じ起動の印を持つ派生でないroot会話のrollout。
|
|
70
|
+
入力欄の`/new`・`/clear`で会話が切り替わった後も、今の会話から完了・回答・turnの境界を読む。結び付け直すのは送信の道だけで、
|
|
71
|
+
完了待ちは、読み始めた記録が3秒増えない時に今の会話を見直す(ADR 0105)。
|
|
68
72
|
|
|
69
73
|
Windowsの`pty_close`は、Claude Codeの席を止める前に、C-cを間を空けずに2回送って、Claude Codeが自分で終わるのを待つ(ADR 0100)。
|
|
70
74
|
psmuxは切断の合図なしでsessionを止めるので、そのままでは会話終了のhook(SessionEnd)が走らない。動いている番の席へは、先にC-cを
|
|
@@ -124,6 +128,8 @@ Cursorのsubmitはadapterがextended keyboard protocolのEnterへ変換し、呼
|
|
|
124
128
|
Codex・Grok・Cursorの席は、新しいturnを送るたびに入力受付を確かめる。起動の途中の入力欄を採らないよう、500msおきに11回続けて
|
|
125
129
|
入力待ちを読む(ADR 0014)。席のharnessが自分の記録で「この起動でturnを1つ終えていて、次のturnを始めていない」と示している時は、
|
|
126
130
|
100msおきに2回で通す(ADR 0097)。記録の上でturnが動いている間は、画面が入力待ちに見えても11回の確かめを通る。
|
|
131
|
+
Codexの入力待ちは、入力欄の行(`›`、古い描画の`>`)がある時だけ読む。起動の見出しの`>_`は入力欄ではない。足元の警告をF2で開いた
|
|
132
|
+
警告の画面は、入力欄の場所に出て鍵を受けるので、応答の要る画面と同じに数え、`pty_send`は打鍵の前に断る。Aitermは閉じない(ADR 0107)。
|
|
127
133
|
|
|
128
134
|
### 親配送の共通モジュール化(設計)
|
|
129
135
|
|
|
@@ -351,6 +357,9 @@ lockより後に始まったprocessなら別人と読んで片付ける。消す
|
|
|
351
357
|
Codexは、サービスの誤りや通信の失敗でturnを打ち切る時も、記録へ`task_complete`を書く(回答は無く、`error`が付く)。完了待ちは、
|
|
352
358
|
利用上限(`usage_limit_exceeded`)を`rate_limited`、ほかの`error`つきを`error`で返す。`error`は応答の本文とURLを落とした1行の文、
|
|
353
359
|
Codexが書いた種類は`error_kind`で返す。失敗を空の回答の完了として返さない(ADR 0103)。判定と文の整え方は`src/harnesses/codex.ts`が所有する。
|
|
360
|
+
Cursorは、誤りで終わったturnを、記録の`turn_ended`へ`status: "error"`と文で書く。完了待ちは、利用上限の文を`rate_limited`、
|
|
361
|
+
席で止めたturn(`User aborted request`)を今までどおり`done`、ほかを`error`で返す。`error`は1行の文、文の頭の角括弧の名前は
|
|
362
|
+
`error_kind`で返す(ADR 0106)。判定と文の整え方は`src/harnesses/cursor.ts`が所有する。
|
|
354
363
|
|
|
355
364
|
Grokのread-only sandbox起動拒否は、`src/harnesses/grok.ts`の
|
|
356
365
|
`assertGrokSandboxNotRejected`がCLIのエラー表示から検出する。`src/core.ts`の共通入力受付待機は
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiterm-mcp",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.4",
|
|
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": [
|