aiterm-mcp 0.61.19 → 0.61.20
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 +30 -1
- package/README.ja.md +29 -4
- package/README.md +30 -5
- package/dist/agent-goal-native-result.js +172 -0
- package/dist/agent-goal-ui.js +50 -0
- package/dist/agent-goal.js +221 -0
- package/dist/codex-goal-connection.js +23 -0
- package/dist/codex-relay-client.js +3 -2
- package/dist/core.js +254 -2
- package/dist/execution-contract.js +1 -1
- package/dist/execution-dispatch.js +4 -1
- package/dist/execution-immediate-stop.js +77 -24
- package/dist/execution-native-server.js +9 -5
- package/dist/harnesses/claude-goal.js +243 -0
- package/dist/harnesses/codex-goal-editor.js +134 -0
- package/dist/harnesses/codex-goal.js +94 -0
- package/dist/harnesses/grok-goal.js +261 -0
- package/dist/index.js +22 -0
- package/dist/process-runtime.js +18 -0
- package/dist/process-start.js +35 -0
- package/dist/runtime-error-os.js +2 -32
- package/docs/DESIGN.md +38 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.61.20] - 2026-10-26
|
|
11
|
+
|
|
12
|
+
- Clear an existing UserPaused/Idle Grok goal on the original worker through one user-origin native command, with fresh durable acknowledgement and authoritative no-goal readback. Refuse busy input, drafts and replaced bindings; preserve unknown effects without retry.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Add Linux Grok current-session binding and fresh idle-composer goal inspection. Keep the persisted native snapshot separate from current_status, reject replaced goals and busy minimal-view commands before input, and leave unverified mutations unsupported.
|
|
17
|
+
- Inspect live fullscreen Grok Goal detail on the original worker without queuing a slash command or stopping it. Validate the current hit target and modal before each input; keep rounded display values distinct from exact native fields.
|
|
18
|
+
|
|
19
|
+
- Native Claude Code goal inspection uses a fresh dialog on the original live TUI and native attachments; v2 preserves Claude native data and clear/achievement history without invented Codex accounting. Codex v1 remains supported. Claude clear preserves the current turn and confirms fresh native empty/cleared state; objective creation/editing use the same CLI with exact native readback and per-field constraints; pause/resume remain unsupported.
|
|
20
|
+
- Recognize the current official Claude PKCE authorization URL without exposing callback codes or tokens.
|
|
21
|
+
|
|
22
|
+
- `agent_goal` reads and manages the real Codex thread goal through an existing native control socket. Operations bind the original session/launch generation, require host-established user provenance for changes, and distinguish acknowledged changes, readback, and an unknown result without retrying. Cursor adapters report explicit unsupported status; missing native connections report unavailable.
|
|
23
|
+
|
|
24
|
+
- Goal results expose optional field capabilities. Ordinary embedded Codex supports budget-only edits through the official service; unsupported objective or mixed edits issue no mutation.
|
|
25
|
+
|
|
26
|
+
- Ordinary Codex objective-only edits use its native editor with literal reserved/multiline input, draft preservation, and fresh readback on proven no-submission refusals. Field capabilities distinguish independent fields from combined edits; file-backed objectives and combined edits remain disabled.
|
|
27
|
+
|
|
28
|
+
- Ordinary Codex creates literal goals through its existing CLI with bounded ordered paste input and complete native readback. Reserved controls and budget-bearing creation are explicitly unsupported before any goal is issued; existing goals and drafts are preserved.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- Goal TUI input requires original foreground process-group ownership and explicit raw/no-echo TTY state at each input boundary. Invalid ownership refuses before any input; loss after input preserves unknown results without terminal recovery or replay.
|
|
33
|
+
- Goal creation requires its requested active status to match the native readback; concurrent native status changes retain the observed state and an unknown result.
|
|
34
|
+
- Explicit whole-application goal stops wait only for selected descendants, so one native timeout does not delay independent roots. Ordinary interruption and partial goal receipts remain unchanged.
|
|
35
|
+
|
|
10
36
|
## [0.61.19] - 2026-10-26
|
|
11
37
|
|
|
12
38
|
- Fix native Windows shell selection for current Git Bash prompts wrapped across pane columns, preserving unknown and historical prompt boundaries. Both ordinary and marked literal multiline sends retain the correct shell syntax.
|
|
@@ -2874,7 +2900,8 @@ prototype (preserved under `prototype/python/` as the porting source and referen
|
|
|
2874
2900
|
`ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
|
|
2875
2901
|
provenance.
|
|
2876
2902
|
|
|
2877
|
-
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.61.
|
|
2903
|
+
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.61.20...HEAD
|
|
2904
|
+
[0.61.20]: https://github.com/kitepon/aiterm-mcp/compare/v0.61.19...v0.61.20
|
|
2878
2905
|
[0.61.19]: https://github.com/kitepon/aiterm-mcp/compare/v0.61.18...v0.61.19
|
|
2879
2906
|
[0.61.18]: https://github.com/kitepon/aiterm-mcp/compare/v0.61.17...v0.61.18
|
|
2880
2907
|
[0.61.17]: https://github.com/kitepon/aiterm-mcp/compare/v0.61.16...v0.61.17
|
|
@@ -3083,3 +3110,5 @@ prototype (preserved under `prototype/python/` as the porting source and referen
|
|
|
3083
3110
|
|
|
3084
3111
|
|
|
3085
3112
|
Claude authentication URL receipts recognize the official claude.com/cai/oauth/authorize PKCE authorization request and its nonsecret code=true display flag. Callback authorization codes and tokens remain excluded; the common URL credential filter is unchanged. This auth-only patch contains no native goal feature.
|
|
3113
|
+
|
|
3114
|
+
Native Claude goal input also verifies the official per-PID current-session registration, including native session ID, process birth ticks and PID namespace before each input boundary. A switched conversation is refused before goal input; ownership loss after input remains unknown. No conversation is switched back automatically. This registration birth format is currently verified on Linux; unverified OS/registry data remains unavailable.
|
package/README.ja.md
CHANGED
|
@@ -149,7 +149,7 @@ diagnostics、recovery、update、releaseを所有します。このREADMEと[
|
|
|
149
149
|
|
|
150
150
|
**言葉でなく実測で:** 記録済み203テストのベンチマークでは、`pty_read` はコンテキストに載るトークンを生ログの **約 7.1 分の 1** に減らす。しかも pass/fail の判定は畳んでも残る。→ [組み込みシェルツールとの使い分け](#組み込みシェルツールとの使い分け)
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
19ツール: 7つのPTYツール、正規のagent起動入口`agent_launch`、移行用の旧3alias、`agent_models`、`agent_configure`、`agent_goal`、`agent_auth`、`agent_approval`、`claude_turn`、`claude_approval`、`diagnostics`。backendはPOSIXのtmux/Windows nativeのpsmuxなので、MCPサーバやAIクライアントが再起動してもsessionは生き残る。
|
|
153
153
|
|
|
154
154
|
**v0.28.0では実行基盤harnessとmodelを分離した。** harnessはagent loop・認証・hook・session・transcriptを所有し、modelはその上で選ぶ。Cursor Agent CLIでGPT/Claude/Grokを選んでも完了契約はCursor方式のまま。ComposerはCursorのmodelの一つで、harnessでもGrokのmodelでもない。`harness:"cursor-cli", model:"composer-2.5-fast"`(または`composer-2.5`)で表す。旧起動ツールは同じ実装へ流れる互換alias。
|
|
155
155
|
|
|
@@ -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.61.
|
|
212
|
+
**状態:** 開発継続中 · 現行公開版 **v0.61.20** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
|
|
213
213
|
|
|
214
214
|
### 更新と巻き戻し
|
|
215
215
|
|
|
@@ -441,7 +441,7 @@ agentの起動はPowerShell 7のpaneでargvを渡して実行し、受入済みs
|
|
|
441
441
|
|
|
442
442
|
```mermaid
|
|
443
443
|
flowchart LR
|
|
444
|
-
AI["AI / MCP client<br/>(the orchestrator)"] -->|"pty_send · pty_observe · agent_launch · agent_models · agent_configure · agent_auth · agent_approval · claude_turn · claude_approval<br/>旧launcher alias · diagnostics"| S["aiterm-mcp<br/>stdio MCP ·
|
|
444
|
+
AI["AI / MCP client<br/>(the orchestrator)"] -->|"pty_send · pty_observe · agent_launch · agent_models · agent_configure · agent_auth · agent_approval · claude_turn · claude_approval<br/>旧launcher alias · diagnostics"| S["aiterm-mcp<br/>stdio MCP · 19 tools"]
|
|
445
445
|
S -->|"pty_read<br/>token-reduced"| AI
|
|
446
446
|
S -->|"tmux / psmux<br/>send · capture"| P["persistent PTYs<br/>再起動を跨ぐ"]
|
|
447
447
|
P -->|"ssh · docker · repl"| R["nested<br/>remote · container · REPL"]
|
|
@@ -813,4 +813,29 @@ aiterm が、あなたの AI に別のエージェントへ仕事を渡させた
|
|
|
813
813
|
MIT
|
|
814
814
|
|
|
815
815
|
|
|
816
|
-
Claude認証は公式claude.com/cai/oauth/authorizeのPKCE要求と非秘密のcode=true表示flagを認証URLとして返す。callback認可codeやtokenは除外し、共通URL credential filter
|
|
816
|
+
Claude認証は公式claude.com/cai/oauth/authorizeのPKCE要求と非秘密のcode=true表示flagを認証URLとして返す。callback認可codeやtokenは除外し、共通URL credential filterは変更しない。
|
|
817
|
+
|
|
818
|
+
## CLIの実ゴール
|
|
819
|
+
|
|
820
|
+
`agent_goal` は `session_id`、元の32桁 `launch_id`、`action: inspect|create|edit|pause|resume|clear` を受ける。`expected_thread_id` は既存の結合の照合用で、別threadを選ぶ引数ではない。createはobjective必須、editはobjective又は正の整数token_budgetを指定する。他の操作には目的や予算を付けない。
|
|
821
|
+
|
|
822
|
+
最初のadapterはPOSIXの既存Codex control socketへ接続し、同じthreadが読み込まれていることを確認する。workerの起動・保存threadのresumeは行わない。元launchのharnessが生存し識別できることが必要。CursorのadapterとWindows native Codex接続は未対応、結合・設定・接続が確認できない時は取得不能を返す。
|
|
823
|
+
|
|
824
|
+
元のCLIが外部接続口のないembedded workerを使う場合、公式の読取専用native APIで取得し、一時停止・再開・削除は同じCLI自身へ一回だけ送る。この経路は予算だけの編集も公式goal serviceで扱う。capabilitiesはcreate:true/edit:true、createのfieldはobjective:true/token_budget:false。作成は既存goal/既存draft/制御文字、clear/edit/pause/resumeへ完全一致する予約語(大小文字を区別しない)を未発行で拒否する。予算付き作成では、予算を落としたgoalを作らない。大きいpasteがnative fileへ変わらないよう小さいliteral pasteを順番に渡し、完全な目的文とactiveの正規読戻しを必須にする。既存のliteral目的文ならfield_capabilities.editはobjective:true/token_budget:true/combined:false。目的文だけの編集は現在CLIのnative editorへ渡し、予約語や複数行もliteralとして扱う。native file参照の目的文は目的文編集を無効のまま保持する。目的文と予算の複合要求は両方とも発行せず拒否し、clientは自動分割しない。clientは操作とfieldの両capabilityに従い、旧serverでfield省略時だけ従来の操作全体、combined省略時だけ従来のfield全体の意味を適用する。元PID/process groupが同じTTYの前面にありraw/no-echoであることを読取りで確認する。停止/背面/cooked/所有不明は入力前に拒否し、入力開始後の所有喪失はunknownを保持。fg復帰・端末設定変更・下書き消去で条件を通さない。装飾付きplaceholderと実入力を区別し、空欄・貼付反映を確認してEnterを一回送る。既存draftへ送らず、確定した未発行拒否は新しいnative読戻しを伴うnot_issued、送信/取消し不明はunknownを保って再送しない。予約語・native editor・予算指定を完全なnative APIと同じ対応範囲にしない。
|
|
825
|
+
|
|
826
|
+
Owner認証済みの本体だけが、既存のローカルbellteam MCP接続に `_meta: {"aiterm/goal":{"origin":"user"}}` を付ける。席からの変更を拒否しOwnerを認証する責任は本体が持つ。この由来情報を新しい認証と扱わない。モデルの引数や他クライアントのmetadataでは利用者操作へ昇格しない。組み込みhostはserver constructorへ厳密なgoalOrigin resolverを渡せる。
|
|
827
|
+
|
|
828
|
+
結果は正本のbinding、capabilities、availability、outcome、mutation、readbackを分ける。goal省略は未確認、availableかつgoal:nullだけが「ゴールなし」。createのactiveを含む明示要求fieldは全て正規読戻しとの一致を確認する。変化した状態は観測値を残して結果不明とし、再送しない。clearは現在turnの停止ではなく、resumeはpausedから、目的を変える編集はCodexの使用量を初期化する。Ownerの明示的な全体停止だけ、native delivery入口のagent_stopへpause_goals:trueと同じuser metadataを渡す。子のgoal一時停止と停止キー一回を親より先に完了し、独立rootは並行する。goal未確認はキー送信済みでもpartialを保持。通常の一Bot中断のwireは維持し、AI ONでgoalを暗黙に再開しない。
|
|
829
|
+
|
|
830
|
+
Claude Code 2.1.310は同じ生存TUIへのinspectと利用者由来create・目的文edit・clearに対応する。空のcomposerと元TTY所有を確認し、新しいnative goal dialogと同native root sessionのattachmentを照合し、確認したdialogだけを閉じる。draftは消さず、未知/切れた表示はunavailable。Claude結果はaiterm.agent-goal-result.v2で、goalはnull又は{kind:claude-code,phase:active,native,reported_turns?}。達成と明示clearは別native_historyへ保持し、欠測会計は作らない。Codexのv1は維持。Claude pause/resumeは未対応で、全体停止でもactive goalのpause未確認を保持する。
|
|
831
|
+
|
|
832
|
+
Claude公式claude.com/cai/oauth/authorizeのPKCE認証要求と非秘密code=true表示flagを認識する。callbackの認可codeやtokenは公開しない。
|
|
833
|
+
|
|
834
|
+
Claude clearはnative /goal clearを一回送り、新しい空dialogと、元active goalの条件に一致するnative cleared履歴を確認する。進行中のモデル要求を中断せずgoalの次の継続を解除する。入力所有/世代喪失や読戻し欠測、別goalの終了はunknownで再送しない。未発行が確定した拒否もstatusを新しく取り、古いgoalを復元しない。
|
|
835
|
+
|
|
836
|
+
Claude作成/目的文編集はcomposerとnative goal dialogの全行を確認できるliteral入力に対応する。空/字下げ/末尾空白の内側行、制御文字、viewportを超える目的、大小を区別しないclear予約語は送信前に未対応として拒否する。pause/resume/status/--budgetは通常の目的文字列。createは既存goalを拒否しeditは存在を必要とする。両field.objective:true/token_budget:false、combined:falseで、予算要求を部分実行しない。nativeの改行と完全な目的を照合する。薄い入力案内と同文の実draftは装飾で区別して保護する。
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
Claudeのgoal入力は公式PID別の現在session記録も確認し、native session ID・process開始tick・PID namespaceを各入力境界で照合する。会話切替はgoal入力前に拒否し、入力後の所有喪失はunknownを保持する。会話を勝手に切り戻さない。この開始形式は現在Linuxで検証済みで、未検証OS/記録はunavailableとする。
|
|
840
|
+
|
|
841
|
+
Grok 1.0.70のLinux読取は公式active_sessions.jsonのPID・開始tick・cwd・会話を元のTUIへ結ぶ。入力欄がidleなら、同じ会話への新しい公式status応答から「ゴールなし」又は既存goalを確認する。goal.nativeは保存snapshot、goal.current_statusは元workerの新しい状態・phase・token数・経過表示であり、保存phaseや会計を現在値へ代入しない。既にfullscreenのTUIなら、元workerを止めずに公式Goal詳細を開閉して実行中の状態も読む。current_status.sourceはgoal detail、正確なphaseとtokens_usedはnullとし、phase_display/status_display/budget_displayへ丸めを含むUI原文を保持する。画面モードを勝手に替えず、空の入力欄を保つ。minimalのbusy時は命令をキューへ積まず取得不能。ユーザー由来のclearだけは、同じ元workerの公式statusがUserPaused/Idleで空の入力欄で公式local命令を一回送る。新しいdurable clear応答・native state消失に加え、続く新しいstatusのgoalなしを確認する。作用が不明なら再送やGoal復元をせずunknownとする。他の変更操作は未対応。通常launcherからのmetadata結合は手修正なしで確認済み。他OSはnative登録と入力所有が未受入のため取得不能とし、Grok全対応とはしない。
|
package/README.md
CHANGED
|
@@ -155,7 +155,7 @@ Aiterm and is not a runtime dependency.
|
|
|
155
155
|
|
|
156
156
|
**Measured, not claimed:** in the recorded 203-test benchmark, a `pty_read` puts **~7.1× fewer tokens** in your context than the raw log — and the pass/fail verdict survives the fold. → [When to reach for it vs. the built-in shell](#when-to-reach-for-it-vs-the-built-in-shell)
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
19 tools: seven **PTY tools** — `pty_open` / `pty_send` / `pty_read` / `pty_key` / `pty_close` / `pty_list` / `pty_observe` — to open, drive, read, and observe one persistent terminal; one canonical **agent launcher**, `agent_launch`, which selects `claude-code`, `codex-cli`, `grok-cli`, or `cursor-cli` as the execution harness; three deprecated launcher aliases kept for migration; `agent_models`; `agent_configure`; `agent_goal`; `agent_auth`; `agent_approval`; `claude_turn`; `claude_approval`; and `diagnostics`. The backend is **tmux on POSIX and psmux on native Windows**, so sessions survive even if the MCP server or the AI client restarts.
|
|
159
159
|
|
|
160
160
|
**v0.28.0 separates the execution harness from the model.** The harness owns the agent loop, authentication, hooks, session, and transcript; `model` is what that harness runs. Cursor Agent CLI can therefore select GPT, Claude, or Grok without changing the completion contract from Cursor hooks to another harness's. Composer is one of Cursor's models, not a harness and not a Grok model: use `harness: "cursor-cli", model: "composer-2.5-fast"` (or `composer-2.5`). The old launcher tools are thin compatibility aliases over the same implementation.
|
|
161
161
|
|
|
@@ -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.61.
|
|
230
|
+
**Status:** actively maintained · current public release **v0.61.20** · 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
|
|
|
@@ -428,7 +428,7 @@ The only edits to the captures above are the two `⋮` lines (a long head/tail r
|
|
|
428
428
|
`aiterm-setup --json`が`ready`になったら、利用するMCP clientを再起動して接続を確認する。Claude Codeの場合:
|
|
429
429
|
|
|
430
430
|
```bash
|
|
431
|
-
/mcp # aiterm should show as connected, exposing
|
|
431
|
+
/mcp # aiterm should show as connected, exposing 19 tools
|
|
432
432
|
```
|
|
433
433
|
|
|
434
434
|
Your first session — four calls, one persistent terminal:
|
|
@@ -472,7 +472,7 @@ The terminal is real and shared, so a human *can* jump in ([A human can watch](#
|
|
|
472
472
|
|
|
473
473
|
```mermaid
|
|
474
474
|
flowchart LR
|
|
475
|
-
AI["AI / MCP client<br/>(the orchestrator)"] -->|"pty_send · pty_observe · agent_launch · agent_models · agent_configure · agent_auth · agent_approval · claude_turn · claude_approval<br/>legacy launcher aliases · diagnostics"| S["aiterm-mcp<br/>stdio MCP ·
|
|
475
|
+
AI["AI / MCP client<br/>(the orchestrator)"] -->|"pty_send · pty_observe · agent_launch · agent_models · agent_configure · agent_auth · agent_approval · claude_turn · claude_approval<br/>legacy launcher aliases · diagnostics"| S["aiterm-mcp<br/>stdio MCP · 19 tools"]
|
|
476
476
|
S -->|"pty_read<br/>token-reduced"| AI
|
|
477
477
|
S -->|"tmux / psmux<br/>send · capture"| P["persistent PTYs<br/>survive restarts"]
|
|
478
478
|
P -->|"ssh · docker · repl"| R["nested<br/>remote · container · REPL"]
|
|
@@ -884,4 +884,29 @@ started the persistent multiplexer server (since 0.50.0). Every harness still ac
|
|
|
884
884
|
MIT
|
|
885
885
|
|
|
886
886
|
|
|
887
|
-
Claude authentication URL receipts recognize the official claude.com/cai/oauth/authorize PKCE authorization request and its nonsecret code=true display flag. Callback authorization codes and tokens remain excluded; the common URL credential filter is unchanged.
|
|
887
|
+
Claude authentication URL receipts recognize the official claude.com/cai/oauth/authorize PKCE authorization request and its nonsecret code=true display flag. Callback authorization codes and tokens remain excluded; the common URL credential filter is unchanged.
|
|
888
|
+
|
|
889
|
+
## Native agent goals
|
|
890
|
+
|
|
891
|
+
`agent_goal` accepts `session_id`, the original 32-character `launch_id`, and `action`: `inspect`, `create`, `edit`, `pause`, `resume`, or `clear`. `expected_thread_id` compares a previously observed native binding; it never selects a different thread. `create` requires `objective`; `edit` requires `objective` or a positive integer `token_budget`. Other actions do not accept those fields.
|
|
892
|
+
|
|
893
|
+
The first adapter attaches to an existing Codex native control socket on POSIX and verifies the thread is loaded there. It never starts a worker or resumes a stored thread to make an unavailable Bot appear running. The launch must still have an identifiable live harness. Cursor adapters and native Windows Codex transport return explicit unsupported status; a missing binding, disabled feature, or missing connection returns unavailable.
|
|
894
|
+
|
|
895
|
+
If the original CLI uses an embedded worker without an attachable control endpoint, inspection uses the official read-only native API and pause/resume/clear run once through that same CLI. This mode also supports budget-only edits through the official goal service. It advertises `create:true` with `{objective:true, token_budget:false}`, and `edit:true`. Creation refuses an existing goal, an existing draft, terminal control characters, or an objective exactly equal to the native reserved controls `clear`, `edit`, `pause`, or `resume` (case-insensitive). Budget-bearing creation is rejected before either field is issued, rather than creating an unbudgeted goal. For a literal existing objective, `field_capabilities.edit` is `{objective:true, token_budget:true, combined:false}`. Creation uses bounded ordered literal paste events so native large-paste attachment folding does not replace the objective; complete canonical objective and active-status readback remain required. Objective-only edits use the current CLI’s native editor, including reserved words and multiline text. File-backed native objectives keep objective editing disabled. Combined objective/budget edits are rejected before either mutation; clients must not split them automatically. Clients must honor both action and field capabilities. Missing field capabilities on older servers retain the older action-wide meaning; missing `combined` retains the existing field-wide meaning. The TUI path verifies that the original PID and process group own foreground input on the same TTY, with explicit raw/no-echo flags; unknown, stopped, background, cooked or changed ownership rejects before input, and ownership lost after input remains unknown. It never resumes a job, changes terminal mode, or clears a draft to pass this check. The TUI path distinguishes styled placeholders from existing input, confirms cleared and pasted editor contents before one Enter, and preserves an existing draft. A proven input refusal reads fresh native state and reports `not_issued`; unconfirmed submission or cancellation remains unknown without replay. Slash-command reserved words, native editor input, and token budgets are not interchangeable with the full native API.
|
|
896
|
+
|
|
897
|
+
Only an authenticated host action may stamp MCP metadata `{"aiterm/goal":{"origin":"user"}}` on the existing local `bellteam` client connection. BellTeam must reject seat-origin changes and authenticate the Owner before stamping this provenance. This metadata is not a new authentication mechanism. Other clients and missing provenance remain automatic and cannot mutate a goal. Embedded hosts may supply a stricter `goalOrigin` resolver to the server constructor.
|
|
898
|
+
|
|
899
|
+
`aiterm.agent-goal-result.v1` includes native binding, per-action capabilities, availability, operation outcome, mutation acknowledgment, and readback status. A missing goal field is unknown; `available` with `goal:null` is an authoritative empty goal. All explicitly requested native fields, including the active status requested by create, must match the readback. A changed result remains unknown with the observed native state. Unknown mutations are never retried. `clear` does not interrupt a running turn, `resume` requires `paused`, and a new objective resets Codex usage accounting. For an explicit Owner whole-application stop, the native delivery entry accepts `agent_stop` with `pause_goals:true` and the same user metadata. Each selected descendant completes goal pause and one ordinary interruption key before its parent; independent roots proceed concurrently. Unconfirmed goal pause stays partial even when a key was sent. Ordinary per-Bot interruption is unchanged, and enabling AI does not resume goals.
|
|
900
|
+
|
|
901
|
+
Claude Code 2.1.310 supports `inspect` and user-authorized `create`, objective-only `edit`, and `clear` on the same live TUI. It opens the native goal dialog from a strictly empty composer, verifies the original TTY owner, combines the fresh dialog with matching native root-session attachments, and dismisses only the recognized dialog. A draft or unknown viewport returns unavailable without clearing it. Wrapped conditions that cannot be matched exactly remain unavailable. Claude replies use `aiterm.agent-goal-result.v2`: `goal` is null or `{kind:"claude-code",phase:"active",native,reported_turns?}`, with an optional separate `native_history` for achieved versus explicitly cleared goals. Missing native accounting stays missing. Codex replies retain v1. Claude pause/resume remain unsupported; whole-app stop must retain an active Claude goal as unconfirmed when native pause is unsupported.
|
|
902
|
+
|
|
903
|
+
Claude authorization receipts recognize the official `claude.com/cai/oauth/authorize` PKCE request and its nonsecret `code=true` display flag. Callback authorization codes and tokens remain excluded.
|
|
904
|
+
|
|
905
|
+
Claude clear submits the native `/goal clear` once and requires a fresh empty dialog; a previously active goal must also have matching native cleared history. It leaves an in-flight model request running and removes further goal continuation. Lost ownership, replaced generation, missing readback or another goal's terminal event remains unknown without replay. Refusal proved before submission refreshes status without restoring an older goal.
|
|
906
|
+
|
|
907
|
+
Claude objective creation and replacement accept literal lines that can be fully observed in both the composer and native goal dialog. Blank/indented/trailing-space inner lines, control text, viewport overflow and the case-insensitive reserved objective `clear` are unsupported before submission. Ordinary `pause`, `resume`, `status` and `--budget` text remain literal objectives. Create refuses an existing goal; edit requires one. Both advertise objective support with `token_budget:false`; combined edits remain false and budget-bearing requests never issue a partial update. Exact newlines and native objective readback are preserved. Native dim queued-input hints are distinguished from an actual draft containing the same text by their styling.
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
Native Claude goal input also verifies the official per-PID current-session registration, including native session ID, process birth ticks and PID namespace before each input boundary. A switched conversation is refused before goal input; ownership loss after input remains unknown. No conversation is switched back automatically. This registration birth format is currently verified on Linux; unverified OS/registry data remains unavailable.
|
|
911
|
+
|
|
912
|
+
The Linux Grok 1.0.70 inspector binds the native current-session registry to the original PID, birth ticks, cwd and conversation. A fresh local status reply confirms no goal or an existing goal when the composer is idle. `goal.native` is the persisted snapshot; `goal.current_status` holds the fresh worker status, phase, token count and exact elapsed display. Stored phase and accounting values are never substituted for these current values. An already fullscreen TUI can also expose its live Goal detail without stopping the worker: inspection opens and closes that native view, preserving an empty composer. Its `current_status.source` is `goal detail`; `phase` and exact `tokens_used` remain null while `phase_display`, `status_display` and `budget_display` preserve the UI text, including rounded usage. Inspection never changes the screen mode. Busy minimal views remain unavailable without queuing a command. A user-origin clear is supported only on the same worker with fresh UserPaused/Idle status and an empty composer: it submits the official local command once, requires its fresh durable-clear reply and deleted native state, then confirms a fresh no-goal status. Uncertain effects remain unknown without retry or restoring the goal. Other mutations remain unsupported. The ordinary launcher has been checked without manually editing its metadata. This adapter is limited to the verified Linux contract; other operating systems remain unavailable until their native registration and input ownership are accepted.
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { sameGoalTarget, AgentGoalNotIssuedError, agentGoalResultSchema, nativeGoalSchema, agentGoalInputSchema } from "./agent-goal.js";
|
|
3
|
+
import { claudeCurrentGoalSchema, claudeGoalHistorySchema } from "./harnesses/claude-goal.js";
|
|
4
|
+
import { grokCurrentGoalSchema } from './harnesses/grok-goal.js';
|
|
5
|
+
export const agentGoalNativeResultSchema = agentGoalResultSchema.extend({
|
|
6
|
+
schema: z.literal("aiterm.agent-goal-result.v2"),
|
|
7
|
+
goal: z.discriminatedUnion("kind", [
|
|
8
|
+
z.object({ kind: z.literal("codex-cli"), native: nativeGoalSchema }).strict(), claudeCurrentGoalSchema, grokCurrentGoalSchema,
|
|
9
|
+
]).nullable().optional(), native_history: claudeGoalHistorySchema.optional(),
|
|
10
|
+
}).strict();
|
|
11
|
+
export const agentGoalWireResultSchema = z.discriminatedUnion("schema", [agentGoalResultSchema, agentGoalNativeResultSchema]);
|
|
12
|
+
// MCP requires an object root. Validate the tagged branches as well as the
|
|
13
|
+
// advertised property shape; Codex v1 remains byte-compatible.
|
|
14
|
+
export const agentGoalOutputSchema = agentGoalResultSchema.extend({
|
|
15
|
+
schema: z.enum(["aiterm.agent-goal-result.v1", "aiterm.agent-goal-result.v2"]),
|
|
16
|
+
goal: z.union([nativeGoalSchema, agentGoalNativeResultSchema.shape.goal.unwrap().unwrap()]).nullable().optional(),
|
|
17
|
+
native_history: claudeGoalHistorySchema.optional(),
|
|
18
|
+
}).superRefine((value, context) => {
|
|
19
|
+
const parsed = agentGoalWireResultSchema.safeParse(value);
|
|
20
|
+
if (!parsed.success) {
|
|
21
|
+
for (const issue of parsed.error.issues)
|
|
22
|
+
context.addIssue({ ...issue });
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (value.schema === "aiterm.agent-goal-result.v2" && value.goal && "kind" in value.goal && value.goal.kind !== value.harness)
|
|
26
|
+
context.addIssue({ code: "custom", path: ["goal"], message: "native goal kind must match bound harness" });
|
|
27
|
+
});
|
|
28
|
+
export async function manageGrokAgentGoal(input, runtime, origin = "automatic") {
|
|
29
|
+
input = agentGoalInputSchema.parse(input);
|
|
30
|
+
const result = { schema: 'aiterm.agent-goal-result.v2', session_id: input.session_id, launch_id: input.launch_id, harness: 'grok-cli', binding: null,
|
|
31
|
+
availability: 'unavailable', capabilities: { inspect: false, create: false, edit: false, pause: false, resume: false, clear: false }, outcome: 'unavailable', mutation: input.action === 'inspect' ? 'not_requested' : 'not_issued', readback: 'not_attempted', reason: 'binding_unavailable', observed_at: new Date().toISOString() };
|
|
32
|
+
let issued = false;
|
|
33
|
+
const unavailable = () => { delete result.goal; result.binding = null; result.availability = 'unavailable'; for (const key of Object.keys(result.capabilities))
|
|
34
|
+
result.capabilities[key] = false; };
|
|
35
|
+
try {
|
|
36
|
+
const target = runtime.resolve();
|
|
37
|
+
if (!target || target.session_id !== input.session_id || target.launch_id !== input.launch_id || target.harness !== 'grok-cli' || !target.vendor_session_id)
|
|
38
|
+
return result;
|
|
39
|
+
if (input.expected_thread_id !== undefined && input.expected_thread_id !== target.vendor_session_id)
|
|
40
|
+
return { ...result, reason: 'thread_binding_mismatch' };
|
|
41
|
+
if (input.action !== 'inspect' && !(input.action === 'clear' && runtime.clear))
|
|
42
|
+
return { ...result, availability: 'unsupported', outcome: 'unsupported', reason: 'native_goal_operation_unsupported' };
|
|
43
|
+
if (input.action !== 'inspect' && origin !== 'user')
|
|
44
|
+
return { ...result, outcome: 'rejected', reason: 'user_authorization_required' };
|
|
45
|
+
if (input.action === 'clear' && (input.objective !== undefined || input.token_budget !== undefined))
|
|
46
|
+
return { ...result, outcome: 'unsupported', reason: 'native_goal_field_unsupported' };
|
|
47
|
+
const observed = await runtime.read(target);
|
|
48
|
+
if (!sameGoalTarget(runtime.resolve(), target))
|
|
49
|
+
return { ...result, reason: 'generation_replaced_after_status', readback: 'failed' };
|
|
50
|
+
const clearStatus = observed.current?.current_status;
|
|
51
|
+
const ready = !!runtime.clear && observed.current?.native.status === 'user_paused' && clearStatus?.source === '/goal status' && clearStatus.status === 'UserPaused' && clearStatus.phase === 'Idle' && runtime.canClear?.(target) === true;
|
|
52
|
+
Object.assign(result, { binding: { session_id: target.session_id, launch_id: target.launch_id, thread_id: target.vendor_session_id }, availability: 'available', capabilities: { ...result.capabilities, inspect: true, clear: ready }, goal: observed.current, outcome: 'observed', readback: 'confirmed', reason: 'native_goal_observed' });
|
|
53
|
+
if (input.action === 'inspect')
|
|
54
|
+
return agentGoalNativeResultSchema.parse(result);
|
|
55
|
+
if (observed.current === null)
|
|
56
|
+
return { ...result, outcome: 'rejected', reason: 'goal_missing' };
|
|
57
|
+
if (!ready)
|
|
58
|
+
return { ...result, outcome: 'rejected', reason: 'native_goal_clear_input_unconfirmed' };
|
|
59
|
+
if (!sameGoalTarget(runtime.resolve(), target)) {
|
|
60
|
+
unavailable();
|
|
61
|
+
return { ...result, outcome: 'unavailable', reason: 'generation_replaced' };
|
|
62
|
+
}
|
|
63
|
+
issued = true;
|
|
64
|
+
delete result.goal;
|
|
65
|
+
result.readback = 'not_attempted';
|
|
66
|
+
try {
|
|
67
|
+
await runtime.clear(target, observed.current);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (!(error instanceof AgentGoalNotIssuedError))
|
|
71
|
+
throw error;
|
|
72
|
+
issued = false;
|
|
73
|
+
unavailable();
|
|
74
|
+
try {
|
|
75
|
+
if (!sameGoalTarget(runtime.resolve(), target))
|
|
76
|
+
throw Error('generation_replaced');
|
|
77
|
+
const fresh = await runtime.read(target);
|
|
78
|
+
if (!sameGoalTarget(runtime.resolve(), target))
|
|
79
|
+
throw Error('generation_replaced');
|
|
80
|
+
return { ...result, goal: fresh.current, binding: { session_id: target.session_id, launch_id: target.launch_id, thread_id: target.vendor_session_id }, availability: 'available', capabilities: { ...result.capabilities, inspect: true }, outcome: error.outcome, mutation: 'not_issued', readback: 'confirmed', reason: error.reason };
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return { ...result, outcome: error.outcome, mutation: 'not_issued', readback: 'failed', reason: error.reason };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!sameGoalTarget(runtime.resolve(), target))
|
|
87
|
+
throw Error('generation_replaced_after_mutation');
|
|
88
|
+
const after = await runtime.read(target);
|
|
89
|
+
if (!sameGoalTarget(runtime.resolve(), target) || after.current !== null)
|
|
90
|
+
throw Error('native_goal_clear_readback_unconfirmed');
|
|
91
|
+
return agentGoalNativeResultSchema.parse({ ...result, goal: null, capabilities: { ...result.capabilities, clear: false }, outcome: 'applied', mutation: 'acknowledged', readback: 'confirmed', reason: 'native_goal_readback_confirmed', observed_at: new Date().toISOString() });
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
unavailable();
|
|
95
|
+
return { ...result, outcome: issued ? 'outcome_unknown' : 'unavailable', mutation: issued ? 'outcome_unknown' : result.mutation, reason: issued ? 'native_goal_mutation_unconfirmed' : error instanceof AgentGoalNotIssuedError ? error.reason : 'native_goal_fresh_status_unavailable', readback: 'failed' };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export async function manageClaudeAgentGoal(input, runtime, origin = "automatic") {
|
|
99
|
+
input = agentGoalInputSchema.parse(input);
|
|
100
|
+
const result = { schema: "aiterm.agent-goal-result.v2", session_id: input.session_id, launch_id: input.launch_id, harness: "claude-code", binding: null,
|
|
101
|
+
availability: "unavailable", capabilities: { inspect: false, create: false, edit: false, pause: false, resume: false, clear: false },
|
|
102
|
+
field_capabilities: { create: { objective: false, token_budget: false }, edit: { objective: false, token_budget: false, combined: false } },
|
|
103
|
+
outcome: "unavailable", mutation: input.action === "inspect" ? "not_requested" : "not_issued", readback: "not_attempted", reason: "binding_unavailable", observed_at: new Date().toISOString() };
|
|
104
|
+
let issued = false;
|
|
105
|
+
try {
|
|
106
|
+
const target = runtime.resolve();
|
|
107
|
+
if (!target || target.session_id !== input.session_id || target.launch_id !== input.launch_id || target.harness !== "claude-code" || !target.vendor_session_id)
|
|
108
|
+
return result;
|
|
109
|
+
if (input.expected_thread_id !== undefined && input.expected_thread_id !== target.vendor_session_id)
|
|
110
|
+
return { ...result, reason: "thread_binding_mismatch" };
|
|
111
|
+
if (input.action !== "inspect" && !(input.action === "clear" && runtime.clear) && !(["create", "edit"].includes(input.action) && runtime.setObjective))
|
|
112
|
+
return { ...result, availability: "unsupported", outcome: "unsupported", reason: "native_goal_operation_unsupported" };
|
|
113
|
+
if (input.action !== "inspect" && origin !== "user")
|
|
114
|
+
return { ...result, outcome: "rejected", reason: "user_authorization_required" };
|
|
115
|
+
const observed = await runtime.read(target);
|
|
116
|
+
if (!sameGoalTarget(runtime.resolve(), target))
|
|
117
|
+
return { ...result, reason: "generation_replaced_after_status", readback: "failed" };
|
|
118
|
+
const snapshot = (value) => ({ goal: value.current, ...(value.history ? { native_history: value.history } : {}) });
|
|
119
|
+
Object.assign(result, { availability: "available", capabilities: { ...result.capabilities, inspect: true, clear: !!runtime.clear, create: !!runtime.setObjective, edit: !!runtime.setObjective },
|
|
120
|
+
field_capabilities: { create: { objective: !!runtime.setObjective, token_budget: false }, edit: { objective: !!runtime.setObjective, token_budget: false, combined: false } },
|
|
121
|
+
binding: { session_id: target.session_id, launch_id: target.launch_id, thread_id: target.vendor_session_id },
|
|
122
|
+
...snapshot(observed), outcome: "observed", readback: "confirmed", reason: "native_goal_observed", observed_at: new Date().toISOString() });
|
|
123
|
+
if (input.action === "inspect")
|
|
124
|
+
return agentGoalNativeResultSchema.parse(result);
|
|
125
|
+
if (input.token_budget !== undefined)
|
|
126
|
+
return { ...result, outcome: "unsupported", reason: "native_goal_field_unsupported" };
|
|
127
|
+
if (input.action === "create" && observed.current !== null)
|
|
128
|
+
return { ...result, outcome: "rejected", reason: "goal_already_exists" };
|
|
129
|
+
if (input.action === "edit" && observed.current === null)
|
|
130
|
+
return { ...result, outcome: "rejected", reason: "goal_missing" };
|
|
131
|
+
if (!sameGoalTarget(runtime.resolve(), target))
|
|
132
|
+
return { ...result, availability: "unavailable", outcome: "unavailable", reason: "generation_replaced" };
|
|
133
|
+
issued = true;
|
|
134
|
+
delete result.goal;
|
|
135
|
+
delete result.native_history;
|
|
136
|
+
result.readback = "not_attempted";
|
|
137
|
+
try {
|
|
138
|
+
if (input.action === "clear")
|
|
139
|
+
await runtime.clear(target);
|
|
140
|
+
else
|
|
141
|
+
await runtime.setObjective(target, input.objective);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
if (!(error instanceof AgentGoalNotIssuedError))
|
|
145
|
+
throw error;
|
|
146
|
+
issued = false;
|
|
147
|
+
try {
|
|
148
|
+
const fresh = await runtime.read(target);
|
|
149
|
+
if (!sameGoalTarget(runtime.resolve(), target))
|
|
150
|
+
throw new Error("generation_replaced");
|
|
151
|
+
return { ...result, ...snapshot(fresh), outcome: error.outcome, mutation: "not_issued", readback: "confirmed", reason: error.reason };
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return { ...result, outcome: error.outcome, mutation: "not_issued", readback: "failed", reason: error.reason };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!sameGoalTarget(runtime.resolve(), target))
|
|
158
|
+
throw new Error("generation_replaced_after_mutation");
|
|
159
|
+
const after = await runtime.read(target);
|
|
160
|
+
if (!sameGoalTarget(runtime.resolve(), target))
|
|
161
|
+
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;
|
|
163
|
+
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
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
if (issued)
|
|
167
|
+
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"]);
|
|
169
|
+
const reason = error instanceof AgentGoalNotIssuedError ? error.reason : error instanceof Error && reasons.has(error.message) ? error.message : "native_goal_fresh_status_unavailable";
|
|
170
|
+
return { ...result, reason, readback: "failed" };
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export function nativeGoalClickBytes(column, row, columns, rows) {
|
|
2
|
+
if (![column, row, columns, rows].every(value => Number.isSafeInteger(value) && value > 0 && value <= 10000)
|
|
3
|
+
|| column > columns || row > rows)
|
|
4
|
+
throw new Error("Goal pointer outside pane");
|
|
5
|
+
return `\x1b[<0;${column};${row}M\x1b[<0;${column};${row}m`;
|
|
6
|
+
}
|
|
7
|
+
export function nativeGoalStyledRows(raw) {
|
|
8
|
+
let dim = false, bold = false, color = false, inverse = false;
|
|
9
|
+
const result = [[]];
|
|
10
|
+
for (const token of raw.matchAll(/\x1b\[([0-9;]*)m|([^\x1b])/gu)) {
|
|
11
|
+
if (token[1] !== undefined) {
|
|
12
|
+
const codes = token[1].split(';').map(Number);
|
|
13
|
+
for (let i = 0; i < codes.length; i++) {
|
|
14
|
+
const code = codes[i];
|
|
15
|
+
if (code === 0) {
|
|
16
|
+
dim = false;
|
|
17
|
+
bold = false;
|
|
18
|
+
color = false;
|
|
19
|
+
inverse = false;
|
|
20
|
+
}
|
|
21
|
+
if (code === 2)
|
|
22
|
+
dim = true;
|
|
23
|
+
if (code === 7)
|
|
24
|
+
inverse = true;
|
|
25
|
+
if (code === 27)
|
|
26
|
+
inverse = false;
|
|
27
|
+
if (code === 22) {
|
|
28
|
+
dim = false;
|
|
29
|
+
bold = false;
|
|
30
|
+
}
|
|
31
|
+
if (code === 1)
|
|
32
|
+
bold = true;
|
|
33
|
+
if (code === 39)
|
|
34
|
+
color = false;
|
|
35
|
+
if (code >= 30 && code <= 37 || code >= 90 && code <= 97)
|
|
36
|
+
color = true;
|
|
37
|
+
if (code === 38 || code === 48) {
|
|
38
|
+
if (code === 38)
|
|
39
|
+
color = true;
|
|
40
|
+
i += codes[i + 1] === 5 ? 2 : codes[i + 1] === 2 ? 4 : 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (token[2] === '\n')
|
|
45
|
+
result.push([]);
|
|
46
|
+
else
|
|
47
|
+
result.at(-1).push({ text: token[2], dim, decorated: bold || color, inverse });
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|