aiterm-mcp 0.70.7 → 0.70.9
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 +24 -1
- package/README.ja.md +3 -1
- package/README.md +3 -1
- package/dist/agent-metadata-reader.js +10 -2
- package/dist/agent-resolver.js +10 -0
- package/dist/core.js +60 -19
- package/dist/errors.js +6 -0
- package/dist/harnesses/antigravity.js +48 -3
- package/dist/harnesses/caller-mcp.js +94 -0
- package/dist/harnesses/cursor.js +50 -5
- package/dist/harnesses/grok.js +52 -3
- package/dist/index.js +23 -15
- package/dist/remote-authorize.js +51 -6
- package/dist/remote-contract.js +4 -4
- package/dist/remote-path.js +29 -5
- package/dist/remote-provision.js +94 -14
- package/dist/remote-terminal-cli.js +8 -5
- package/dist/remote-terminal.js +164 -63
- package/dist/remote.js +48 -8
- package/dist/terminal-launch-error.js +12 -9
- package/dist/transcript-read-cli.js +5 -10
- package/dist/write-ban.js +22 -7
- package/native/write-ban/win32-x64/aiterm-write-ban.exe +0 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.70.9] - 2026-11-10
|
|
11
|
+
|
|
12
|
+
- All five harnesses can run on a terminal. `agent_launch` (and the per-harness launchers) with `terminal` now accepts `grok-cli`, `cursor-cli` and `antigravity-cli` beside `claude-code` and `codex-cli`, routed to the terminal's `agent_launch` the same way, with the seat-forward URL rewrite and header extraction unchanged. These three need Aiterm 0.70.9 on the terminal (`REMOTE_AITERM_TOO_OLD` before any private value is sent). `TERMINAL_HARNESS_UNSUPPORTED` stays only as a guard for a name outside the five.
|
|
13
|
+
- `remote_terminal_command` gains `cli_version`, `cli_install`, `cli_update` and `cli_auth_status`, each with a required `harness` (`claude-code`, `codex-cli`, `grok-cli`, `cursor-cli`, `antigravity-cli`; a missing or unknown one is `COMMAND_INVALID`; a terminal older than 0.70.9 is `REMOTE_AITERM_TOO_OLD`). The first three answer `{op, harness, exit_code, version, output_tail}` with each CLI's official installer and updater (Windows: PowerShell). `cli_auth_status` answers `{op, harness, logged_in}` and nothing else, from the same status commands Aiterm uses locally; an answer that is not clearly logged in or out is `AUTH_STATUS_UNCONFIRMED`, a missing CLI `CLI_NOT_INSTALLED`. `claude_version`, `claude_install` and `claude_update` stay as aliases for `claude-code` (their version is now also read from `~/.local/bin/claude` when it is not on PATH).
|
|
14
|
+
- A launch of a CLI that is not logged in is `AGENT_LAUNCH_NOT_STARTED` with `_meta["aiterm/launch_error"]` `code: "AGENT_AUTH_REQUIRED"` (`phase: "input"`, `effect: "not_started"`, `session_created: false`, `harness`) for Claude Code, Cursor and Antigravity, locally and on a terminal; Claude keeps its `CLAUDE_AUTH_NOT_AUTHENTICATED` structured answer beside it. Codex and Grok have no launch preflight.
|
|
15
|
+
- `agent_launch` accepts `append_system_prompt` and `mcp_config` for grok-cli, cursor-cli and antigravity-cli too (same shapes as claude-code and codex-cli: http servers `{type?: "http", url, headers}`, headers literal, a whole `${NAME}` or `Bearer ${NAME}`). Nothing is written to the project or to `~/.grok`, `~/.cursor`, `~/.gemini`: the files are 0600 (folders 0700) in Aiterm's launch state and are removed with the seat. Grok: the text is appended to the one `--rules` value after Aiterm's lineage text; the servers are a per-seat agent file passed as `--agent` (frontmatter `mcpServers:` list, empty body, so the default agent stays; Grok does not expand `${VAR}` in headers, so `Bearer ${NAME}` becomes `bearer_token_env_var` and any other `${NAME}` is resolved from the seat env into the 0600 file). Cursor: no system-prompt channel, so the text joins Aiterm's first-prompt block; the servers are a per-seat plugin folder passed as `--plugin-dir` (`${env:NAME}` references; the server runs as `plugin-aiterm-caller-<name>` beside a same-name user server). Antigravity: the servers are `<seat folder>/.agents/mcp_config.json` (values resolved, 0600) passed as `--add-dir`, with `trustedWorkspaces` added to `--settings`; the text prefixes the first prompt, so `append_system_prompt` needs a prompt. A shape a harness cannot say, or a `${NAME}` with no value at launch, is refused before the seat starts (`AGENT_LAUNCH_NOT_STARTED`, phase `input`).
|
|
16
|
+
|
|
17
|
+
## [0.70.8] - 2026-11-10
|
|
18
|
+
|
|
19
|
+
- Windows forks (x64): `agent_launch.fork_from` now starts the fork with every write inside the project folder refused instead of answering `READONLY_UNENFORCEABLE`. A bundled helper (`native/write-ban/win32-x64/aiterm-write-ban.exe`, about 24 KB, built reproducibly with the Linux ones) runs the CLI under a restricted copy of the user's token with no privileges and an Aiterm marker SID. The project folder carries, once, an inheritable Deny ACE for that marker SID (plus OWNER RIGHTS = READ_CONTROL and WRITE_DAC, so the DACL cannot be rewritten). The ACEs affect no other process, so the main seat writes as before and nothing is cleaned up later. npm shims run through `pwsh -File`. Measured on fox: new file, append, delete, rename, attributes, Set-Acl, icacls, takeown, git and cmd redirects inside were refused; writes outside succeeded. `fork_of.write_ban.method` is `restricted-token`.
|
|
20
|
+
- The Linux terminal runtime now carries its own tmux, so a Linux terminal needs no tmux installed. `aiterm-runtime-<version>-linux-<x64|arm64>.tar.gz` holds `bin/tmux` 3.8, a fully static musl binary (libevent 2.1.13, utf8proc 2.12.0 and ncurses 6.5 linked in, no libc of the terminal), cross-built on the runner with `zig cc` (`ziglang` 0.15.2 from PyPI, as the write-ban helper) from source tarballs pinned by sha256 in `scripts/build-linux-runtime.mjs`. ncurses keeps compiled-in entries for `screen-256color`, `tmux-256color`, `xterm-256color`, `xterm`, `screen`, `tmux`, `linux`, `vt100`, `dumb` and `ansi`, so tmux also starts on a machine without a terminfo database; it still reads the terminal's own database first. `default-terminal` stays `screen-256color`. The runtime `bin` is first on PATH, so seats use it.
|
|
21
|
+
- `provision` no longer checks for tmux on a Linux terminal, and `PROVISION_TMUX_MISSING` is gone (the bootstrap and `runtime-smoke` never answer it). `runtime-smoke` runs the runtime's own `bin/tmux -V` on both systems. The runtime build checks both tmux binaries are static ELF files of the right machine and, for the host architecture, starts a session with no terminfo database in reach. `runtime.yml` installs `ziglang` in the Linux job and no longer installs a system tmux there.
|
|
22
|
+
- Windows: a local Claude Code / Codex launch no longer types the whole PowerShell launch command (several KB with the sub-agent instruction) into the pane. The psmux send worker drains 300 ms per 256 bytes, so that one call took about 6.4 s of a 9.9 s launch (fox, 0.70.7). Aiterm now writes the command to a private 0600 file in its launch state and types one short line that reads it, deletes it and runs it in the pane's scope. The command, its exit tracking and the drains are unchanged. Environment values no longer appear in the pane's scrollback. POSIX launches are unchanged.
|
|
23
|
+
- Windows terminals (x64) can host Claude Code and Codex seats. A terminal whose OpenSSH Server default shell is PowerShell 7, Windows PowerShell 5.1 or `cmd` is no longer refused with `TERMINAL_PLATFORM_UNSUPPORTED` (that code stays for a system that is none of macOS, Linux and Windows). Every command Aiterm sends to a trusted terminal now comes from one builder, `terminalCommand(shell, {posix, windows})`: POSIX terminals get the same `/bin/sh -c` line as before; on Windows the line puts `%USERPROFILE%\.aiterm\runtime\current\bin` first on PATH when it holds `aiterm-mcp.cmd`, allows scripts for that process only (npm's `.ps1` shims), runs `& 'prog' 'arg'...` with every argument single-quoted, and ends with the real exit code (`pwsh -c` alone turns every native failure into 1). A missing `aiterm-*` program prints `<prog>: command not found` and exits 127, so `REMOTE_AITERM_UNAVAILABLE` does not depend on the language of Windows' own error (fox's is Japanese and CP932); the English cmd and PowerShell "is not recognized as ..." texts that name an `aiterm-*` program are classified the same way. `cmd` is not a PowerShell: its body goes through `powershell -EncodedCommand`. This covers the MCP connection (open, private env line, per-call tools), `aiterm-wait`, `aiterm-transcript-read` and `remote_terminal_command`. The platform probe now also fixes the shell kind in the per-ref cache, so no second probe is made.
|
|
24
|
+
- A terminal launch's `cwd` is checked in the terminal's own form: `/...` on macOS and Linux, a drive-absolute `X:\...` on Windows (UNC, device, relative, drive-relative, `/` separators and forbidden characters are `TERMINAL_INVALID`). Without `os` the form is checked against the probed system, still before any session. `path_status`, `make_dir` and `list_dirs` take the same native paths on both sides and need Aiterm 0.70.8 on a Windows terminal (`REMOTE_AITERM_TOO_OLD` otherwise); `list_dirs` on Windows leaves out `$Recycle.Bin` and `System Volume Information` besides dot names.
|
|
25
|
+
- The seat MCP forward keeper holds its reverse forward with a remote command that ends when its stdin closes on every shell: `cat >/dev/null` on POSIX, `[Console]::In.ReadToEnd() | Out-Null` on Windows. It reads the shell from the per-ref cache and probes once when this process has not. A SIGKILLed holder ended the Windows forward within seconds.
|
|
26
|
+
- `remote_terminal_command` `claude_install` on Windows is the official `irm https://claude.ai/install.ps1 | iex` (a failure stops with exit 1 and its message); `claude_version` and `claude_update` are unchanged, and after an install the version is also read from `%USERPROFILE%\.local\bin\claude.exe`.
|
|
27
|
+
- `aiterm-remote-terminal authorize-key --ref R --os windows` appends the held public key on a Windows terminal: to `%ProgramData%\ssh\administrators_authorized_keys` when the user is in Administrators and `sshd_config` still has the default `Match Group administrators` block (the file's ACL is reset to Administrators and SYSTEM only, as sshd requires), else to `%USERPROFILE%\.ssh\authorized_keys`; same duplicate check by key type and blob, UTF-8 without BOM, the file's own line ending. The password login cannot be probed first (no key works yet), so the caller names the system with `--os`; without it, or with `macos` / `linux`, the POSIX script runs as before.
|
|
28
|
+
- `aiterm-remote-terminal provision` installs the runtime on Windows x64 from `aiterm-runtime-<version>-win32-x64.zip` in the same `SHA256SUMS` (now five files), through a PowerShell 5.1 bootstrap that verifies the checksum, extracts with `tar.exe`, runs `runtime-smoke` and repoints a `current` junction (previous kept as `previous`, an old folder in use stays). `runtime-smoke` on Windows checks `psmux -V` by Aiterm's own lookup. `scripts/build-windows-runtime.mjs` builds the zip (official Node win-x64 zip checked against its pinned sha256, the npm package, CRLF `bin\*.cmd` wrappers) and `.github/workflows/runtime.yml` runs it on `windows-latest`; `scripts/upload-runtime-assets.mjs` lists the five assets. The zip carries its own psmux 3.3.8 (`bin\psmux.exe`, the official MIT release, sha256-pinned; the wrappers set `AITERM_PSMUX` to it), so the terminal needs no psmux installed, as Linux needs no tmux.
|
|
29
|
+
- The `CONNECTION_REFUSED` and `TERMINAL_PLATFORM_UNSUPPORTED` sentences for the Owner name the Windows steps (the optional OpenSSH Server feature and the sshd service).
|
|
30
|
+
|
|
10
31
|
## [0.70.7] - 2026-11-10
|
|
11
32
|
|
|
12
33
|
- `pty_list` seat turns (`aiterm.seat-turns.v1`, BellTeam caller only) add `unread: [session_id]`. It names the terminal-bound sessions whose terminal failed or did not answer within 4 s, so the caller can keep their last state instead of reading them as gone. A session missing from a terminal that did answer is absent, as before.
|
|
@@ -3207,7 +3228,9 @@ prototype (preserved under `prototype/python/` as the porting source and referen
|
|
|
3207
3228
|
`ubuntu-latest` for Node 18/20/22, publishing to npm on `v*` tags with
|
|
3208
3229
|
provenance.
|
|
3209
3230
|
|
|
3210
|
-
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.
|
|
3231
|
+
[Unreleased]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.9...HEAD
|
|
3232
|
+
[0.70.9]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.8...v0.70.9
|
|
3233
|
+
[0.70.8]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.7...v0.70.8
|
|
3211
3234
|
[0.70.7]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.6...v0.70.7
|
|
3212
3235
|
[0.70.6]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.5...v0.70.6
|
|
3213
3236
|
[0.70.5]: https://github.com/kitepon/aiterm-mcp/compare/v0.70.4...v0.70.5
|
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.
|
|
218
|
+
**状態:** 開発継続中 · 現行公開版 **v0.70.9** · 動作対象は Linux · WSL2 · macOS · Windows ネイティブ · MIT · [変更履歴](CHANGELOG.md)。
|
|
219
219
|
|
|
220
220
|
### 更新と巻き戻し
|
|
221
221
|
|
|
@@ -762,6 +762,8 @@ Claudeをリンク経由の`cwd`から起動した場合も、実体パスに対
|
|
|
762
762
|
|
|
763
763
|
Claudeの認証事前確認による起動拒否は従来のエラー文を保ち、`structuredContent`へ`schema:"aiterm.agent-launch-error.v1"`、`harness:"claude-code"`、`phase:"authentication_preflight"`、`effect:"not_issued"`、`session_created:false`を返す。`code`は`CLAUDE_AUTH_NOT_AUTHENTICATED`(公式statusが未認証)、`CLAUDE_AUTH_STATUS_UNCONFIRMED`(確認不能)を区別する。確認が5秒で終わらない時は拒否せず起動へ進み、未ログインならlogin画面で`vendor_onboarding_required`として止まる。`CLAUDE_AUTH_STATUS_TIMEOUT`は0.70.1より前の端末だけが返す。資格情報の故障原因やログイン期限切れは断定せず、公式status本文・stderrは返さない。
|
|
764
764
|
|
|
765
|
+
ログインしていないと確かめられたCLIは、起動前確認のあるClaude Code・Cursor・Antigravityで同じ形で起動を断る。`_meta["aiterm/launch_error"]`が`code:"AGENT_AUTH_REQUIRED"`・`phase:"input"`・`effect:"not_started"`・`session_created:false`・`harness`を持つ(本文は`AGENT_LAUNCH_NOT_STARTED: AGENT_AUTH_REQUIRED: ...`。Claudeは従来の本文と`structuredContent`も残す)。CodexとGrokには起動前確認が無く、各CLIのログイン画面で止まる。状態を読めなかった場合はこのcodeにしない。
|
|
766
|
+
|
|
765
767
|
### 別端末のagentを1回で起動する(`remote`)
|
|
766
768
|
|
|
767
769
|
`agent_launch`に`remote`を付けると、SSHで入った別端末のAitermで同じ起動を行う。端末へ入る操作と現地のagentを起動する操作が1回で済み、親から見た完了の届き方はこの端末の子と同じになる。Linux・macOS・Windowsの端末へ同じ依頼を並行して投げる用途を想定している。
|
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.
|
|
230
|
+
**Status:** actively maintained · current public release **v0.70.9** · 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
|
|
|
@@ -772,6 +772,8 @@ The selected harness CLI must be installed and authenticated. Use each product o
|
|
|
772
772
|
|
|
773
773
|
Claude authentication preflight refusals retain the existing error text and add `structuredContent` with schema `aiterm.agent-launch-error.v1`, `harness:"claude-code"`, `phase:"authentication_preflight"`, `effect:"not_issued"`, and `session_created:false`. `code` distinguishes `CLAUDE_AUTH_NOT_AUTHENTICATED` and `CLAUDE_AUTH_STATUS_UNCONFIRMED`. A status check that does not finish in 5 seconds no longer refuses: the launch goes on, and a logged-out Claude stops at its login screen as `vendor_onboarding_required`. `CLAUDE_AUTH_STATUS_TIMEOUT` comes only from terminals older than 0.70.1. These describe the official status check, not the cause of a credential failure or a confirmed login expiry. Native status bodies and stderr are omitted.
|
|
774
774
|
|
|
775
|
+
A CLI that is positively not logged in refuses the launch the same way for Claude Code, Cursor and Antigravity (the harnesses with a launch preflight): `_meta["aiterm/launch_error"]` carries `code:"AGENT_AUTH_REQUIRED"`, `phase:"input"`, `effect:"not_started"`, `session_created:false` and the `harness`; the text is `AGENT_LAUNCH_NOT_STARTED: AGENT_AUTH_REQUIRED: ...` (Claude keeps its older text and structured answer beside it). Codex and Grok have no launch preflight and stop at their own login screen. A status check that cannot be read is not this code.
|
|
776
|
+
|
|
775
777
|
Set `throughline_source_session` together with a non-empty mission in `prompt` to prepend
|
|
776
778
|
Throughline's read-only handoff context. This optional route requires `throughline >= 0.9.0`,
|
|
777
779
|
cannot be combined with `launch_operation_id`, and leaves the source session's database ownership
|
|
@@ -5,7 +5,9 @@ import { AitermError } from "./errors.js";
|
|
|
5
5
|
import { executionNativeBindingSchema } from "./execution-close.js";
|
|
6
6
|
import { OPERATION_ID_RE, agentManagedClaudeSettingsPath, agentClaudeResultPath, agentClaudeCallerPromptPath, agentClaudeCallerMcpPath } from "./harnesses/claude.js";
|
|
7
7
|
import { agentCodexCallerPromptPath, agentCodexCallerMcpPath } from "./harnesses/codex.js";
|
|
8
|
-
import { resolveAndValidateGrokAuth } from "./harnesses/grok.js";
|
|
8
|
+
import { resolveAndValidateGrokAuth, agentGrokCallerPromptPath, agentGrokCallerAgentPath } from "./harnesses/grok.js";
|
|
9
|
+
import { agentCursorCallerPromptPath, agentCursorCallerPluginDir } from "./harnesses/cursor.js";
|
|
10
|
+
import { agentAntigravityCallerPromptPath, agentAntigravityCallerDir } from "./harnesses/antigravity.js";
|
|
9
11
|
import { assertSessionName, agentsDir, readAgentGeneration, selectAgentMetadataFile, agentEventPath, agentLineageFields, LAUNCH_ID_RE, AGENT_LINEAGE_RE } from "./agent-shared.js";
|
|
10
12
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
11
13
|
function normalizeInitialPromptState(v) {
|
|
@@ -58,7 +60,7 @@ function forkOfField(v) {
|
|
|
58
60
|
|| typeof v.vendor_session_id !== "string" || !UUID_RE.test(v.vendor_session_id)
|
|
59
61
|
|| (v.fork_id !== undefined && typeof v.fork_id !== "string") || (v.first_input !== undefined && typeof v.first_input !== "string")
|
|
60
62
|
|| !v.write_ban || typeof v.write_ban.path !== "string" || !path.isAbsolute(v.write_ban.path)
|
|
61
|
-
||
|
|
63
|
+
|| !["landlock", "seatbelt", "restricted-token"].includes(v.write_ban.method))
|
|
62
64
|
throw new AitermError("agent metadata fork_of が不正です", 2);
|
|
63
65
|
return { fork_of: { session_id: v.session_id, vendor_session_id: v.vendor_session_id, ...(v.fork_id === undefined ? {} : { fork_id: v.fork_id }),
|
|
64
66
|
write_ban: { path: v.write_ban.path, method: v.write_ban.method }, ...(v.first_input === undefined ? {} : { first_input: v.first_input }) } };
|
|
@@ -134,6 +136,8 @@ export function loadAgentMetadata(name) {
|
|
|
134
136
|
vendor_session_id: m.vendor_session_id ?? null, initial_prompt: normalizeInitialPromptState(m.initial_prompt),
|
|
135
137
|
hook_route: "shared_antigravity_home", antigravity_home: m.antigravity_home, node_platform: process.platform,
|
|
136
138
|
...(typeof m.write_scope === "string" ? { write_scope: m.write_scope } : {}),
|
|
139
|
+
...(m.antigravity_caller_prompt_file === agentAntigravityCallerPromptPath(name) ? { antigravity_caller_prompt_file: m.antigravity_caller_prompt_file } : {}),
|
|
140
|
+
...(m.antigravity_caller_mcp_dir === agentAntigravityCallerDir(name) ? { antigravity_caller_mcp_dir: m.antigravity_caller_mcp_dir } : {}),
|
|
137
141
|
...deliveryFields, ...executableFields, ...fastFields, ...startupFields, ...loadAgentLineageFields(m, true) };
|
|
138
142
|
}
|
|
139
143
|
if (m.kind === "claude") {
|
|
@@ -242,6 +246,8 @@ export function loadAgentMetadata(name) {
|
|
|
242
246
|
completion_route: "cursor_transcript",
|
|
243
247
|
...loadAgentLineageFields(m, true),
|
|
244
248
|
node_platform: process.platform,
|
|
249
|
+
...(m.cursor_caller_prompt_file === agentCursorCallerPromptPath(name) ? { cursor_caller_prompt_file: m.cursor_caller_prompt_file } : {}),
|
|
250
|
+
...(m.cursor_caller_mcp_dir === agentCursorCallerPluginDir(name) ? { cursor_caller_mcp_dir: m.cursor_caller_mcp_dir } : {}),
|
|
245
251
|
cursor_home: recordedHome,
|
|
246
252
|
};
|
|
247
253
|
}
|
|
@@ -279,6 +285,8 @@ export function loadAgentMetadata(name) {
|
|
|
279
285
|
completion_route: "grok_transcript",
|
|
280
286
|
...loadAgentLineageFields(m, true),
|
|
281
287
|
node_platform: process.platform,
|
|
288
|
+
...(m.grok_caller_prompt_file === agentGrokCallerPromptPath(name) ? { grok_caller_prompt_file: m.grok_caller_prompt_file } : {}),
|
|
289
|
+
...(m.grok_caller_mcp_file === agentGrokCallerAgentPath(name) ? { grok_caller_mcp_file: m.grok_caller_mcp_file } : {}),
|
|
282
290
|
grok_home: recordedGrokHome,
|
|
283
291
|
grok_auth_path: expectedAuthPath,
|
|
284
292
|
};
|
package/dist/agent-resolver.js
CHANGED
|
@@ -277,6 +277,16 @@ export function windowsAgentLaunchLine(cwd, env, argv, exited) {
|
|
|
277
277
|
const command = parts.join("; ");
|
|
278
278
|
return exited ? `try { ${command} } finally { [IO.File]::WriteAllText(${psq(exited.file)}, ${psq(exited.launch_id)}) }` : command;
|
|
279
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* The one short line typed into a Windows pane instead of the long launch command, which is read
|
|
282
|
+
* from `file` (0600, Aiterm launch state), deleted, and run in the pane's own scope. The psmux
|
|
283
|
+
* worker drains 300 ms per 256 bytes, so a multi-KB line cost 6 s (fox, 0.70.7). Invoke-Expression
|
|
284
|
+
* is not subject to ExecutionPolicy, unlike running a .ps1.
|
|
285
|
+
*/
|
|
286
|
+
export function windowsLaunchIndirection(file) {
|
|
287
|
+
const f = `'${file.replace(/'/g, "''")}'`;
|
|
288
|
+
return `$aitermLaunch=[IO.File]::ReadAllText(${f}); Remove-Item -LiteralPath ${f}; Invoke-Expression $aitermLaunch`;
|
|
289
|
+
}
|
|
280
290
|
/**
|
|
281
291
|
* Keep accepted shebang wrappers in the same pane, as for control commands.
|
|
282
292
|
* Invoking .sh directly in PowerShell uses its file association and can open a
|
package/dist/core.js
CHANGED
|
@@ -26,6 +26,7 @@ import * as fs from "node:fs";
|
|
|
26
26
|
import * as path from "node:path";
|
|
27
27
|
import { createHash, randomBytes } from "node:crypto";
|
|
28
28
|
import { launchEnvValue } from "./private-env.js";
|
|
29
|
+
import { assertCallerEnv } from "./harnesses/caller-mcp.js";
|
|
29
30
|
import { fileURLToPath } from "node:url";
|
|
30
31
|
import * as rtk from "./rtk.js";
|
|
31
32
|
import { manageClaudeAgentGoal, manageGrokAgentGoal } from "./agent-goal-native-result.js";
|
|
@@ -47,16 +48,16 @@ import { withExecutionInterruptEffectScope, bindExecutionNativeTarget, beforeExe
|
|
|
47
48
|
import { ExecutionError } from "./execution-wire.js";
|
|
48
49
|
import { readExecutionParentProcess } from "./execution-parent-process.js";
|
|
49
50
|
import { isCursorMcpClient } from "aiterm-steer-delivery";
|
|
50
|
-
import { antigravityBinding, antigravityAuthChoiceKey, antigravityCurrentModel, antigravityStartupAction, antigravityAgentArgv, antigravityModelChoices, antigravityAuthStatus, antigravityAuthPane, antigravityTranscriptText, bindAntigravitySession, createAntigravityAgentMetadata, mergeAntigravityHooks } from "./harnesses/antigravity.js";
|
|
51
|
+
import { antigravityBinding, antigravityAuthChoiceKey, antigravityCurrentModel, antigravityStartupAction, antigravityAgentArgv, writeAntigravityCallerFiles, checkAntigravityCallerInput, antigravityPromptWithCaller, antigravityModelChoices, antigravityAuthStatus, antigravityAuthPane, antigravityTranscriptText, bindAntigravitySession, createAntigravityAgentMetadata, mergeAntigravityHooks } from "./harnesses/antigravity.js";
|
|
51
52
|
import { paneTokenHint } from "./harnesses/pane-tokens.js";
|
|
52
53
|
import { unfinishedDeliveriesOwnedBy } from "./parent-delivery-owners.js";
|
|
53
54
|
import { readLinuxProcessRegistrationIdentity, readRuntimeProcesses, readProcessIdentities, processSubtree, parentProcess, processIdentity, signalRuntimeProcess, backgroundProcesses, lazyRelayProcess, aitermProcessProbe, windowsConsoleHost, macKeepAwakeProcess, processElapsedSeconds } from "./process-runtime.js";
|
|
54
55
|
import { liveNodeExecutable } from "./live-node.js";
|
|
55
56
|
import { resolveClaudeConfigurationRoot, withClaudeConfigRoot } from "./claude-config-root.js";
|
|
56
|
-
import { probeWriteBan, writeBanPrefix } from "./write-ban.js";
|
|
57
|
-
import { AitermError, AgentResumeUnavailableError, AgentResumeError, telemetryOwnedFailure, ownTelemetryFailure } from "./errors.js";
|
|
57
|
+
import { probeWriteBan, writeBanPrefix, windowsWriteBanArgv } from "./write-ban.js";
|
|
58
|
+
import { AitermError, launchAuthRequired, launchInputRefusal, AgentResumeUnavailableError, AgentResumeError, telemetryOwnedFailure, ownTelemetryFailure } from "./errors.js";
|
|
58
59
|
import { isWin, SOCKDIR, SOCK, tmuxCommand, readOnlyTmuxList, PtyDiagnosticError, tmuxCommandWithInput, sendPsmuxPayload, loadPtyBufferChunk, pasteBufferBaseArgs, tmuxNewSession, withNativeSessionCreation, withNativeSessionTarget, hasVerifiedNativeSessionTarget, withNativeSessionSetupRollback, hasNativeSessionSetupRollback, registeredSessionEnvironment, registerSessionEnvironment, attachCommand, normalizePaneCommand, atomicShellMultiline, appendMarkSentinel, paneShellForSubmission, adaptShellSubmission, settlePaneLog, paneCwdArgument, sessionEnvironmentLaunch, paneCommandArgs, rememberPaneShell, } from "./tmux-runtime.js";
|
|
59
|
-
import { AGENT_DEFAULT_PREFACE, sleep, currentUid, runtimeStateBase, safeStatSize, readFileRange, writeJson0600, createEmpty0600, shq, LAUNCH_ID_RE, AGENT_LINEAGE_RE, AGENT_DONE_POLL_MS, AGENT_RATE_LIMIT_POLL_MS, pollGate, AGENT_EVENT_MAX_BYTES, assertSessionName, agentsDir, readAgentGeneration, selectAgentMetadataFile, publishAgentGeneration, agentMetadataPath, writeAgentMetadata, AGENT_EVENT_TAIL_BYTES, agentLabel, agentHarness,
|
|
60
|
+
import { AGENT_DEFAULT_PREFACE, sleep, currentUid, runtimeStateBase, safeStatSize, readFileRange, writeJson0600, writeText0600, createEmpty0600, shq, LAUNCH_ID_RE, AGENT_LINEAGE_RE, AGENT_DONE_POLL_MS, AGENT_RATE_LIMIT_POLL_MS, pollGate, AGENT_EVENT_MAX_BYTES, assertSessionName, agentsDir, readAgentGeneration, selectAgentMetadataFile, publishAgentGeneration, agentMetadataPath, writeAgentMetadata, AGENT_EVENT_TAIL_BYTES, agentLabel, agentHarness, } from "./agent-shared.js";
|
|
60
61
|
import { AuthResponseError, authUi, authPromptDigest, authBindingSchema, authResponseSchema } from "./agent-auth-ui.js";
|
|
61
62
|
import { processStartIdentity } from "./runtime-error-os.js";
|
|
62
63
|
import { processStartIdentities } from "./process-start.js";
|
|
@@ -64,13 +65,13 @@ import { catalogUnavailable } from "./model-catalog.js";
|
|
|
64
65
|
import { FastModeError, fastModeFailure } from "./fast-mode.js";
|
|
65
66
|
import { readFileOrNull, restoreJsonSetting, withUserConfigLock, restoreUserDefaults, keepingUserDefaults, USER_DEFAULT_SETTLE_MS } from "./user-config.js";
|
|
66
67
|
import { isDeepStrictEqual } from "node:util";
|
|
67
|
-
import { grokAuthPlan, grokAuthStatus, grokAuthPane, GROK_MODEL_DEFAULTS, realGrokHome, resolveAndValidateGrokAuth, assertGrokModelAvailable, grokModelChoices, grokModelFromFooter, grokFooterModelName, grokModelDefaultsFromBody, restoreGrokModelDefaults, grokEventsTranscript, grokSessionDirectory, latestGrokCompletion, grokTurnSettled, observeGrokDone, buildGrokAgentCmd, grokAgentArgv, grokLaunchNote, grokEnvTokens, grokEnvEntries, grokTuiReady, grokPaneObservation, GROK_INTERRUPT_KEY, grokRateLimitDialog, grokPromptAwaitingAccept, grokUnacceptedPromptRestored, grokStartupAction, grokFooterHasConfiguration, grokTranscriptText, createGrokAgentMetadata, } from "./harnesses/grok.js";
|
|
68
|
+
import { grokAuthPlan, grokAuthStatus, grokAuthPane, GROK_MODEL_DEFAULTS, realGrokHome, resolveAndValidateGrokAuth, assertGrokModelAvailable, grokModelChoices, grokModelFromFooter, grokFooterModelName, grokModelDefaultsFromBody, restoreGrokModelDefaults, grokEventsTranscript, grokSessionDirectory, latestGrokCompletion, grokTurnSettled, observeGrokDone, buildGrokAgentCmd, grokAgentArgv, writeGrokCallerFiles, checkGrokCallerInput, grokLaunchNote, grokEnvTokens, grokEnvEntries, grokTuiReady, grokPaneObservation, GROK_INTERRUPT_KEY, grokRateLimitDialog, grokPromptAwaitingAccept, grokUnacceptedPromptRestored, grokStartupAction, grokFooterHasConfiguration, grokTranscriptText, createGrokAgentMetadata, } from "./harnesses/grok.js";
|
|
68
69
|
import { codexAuthPlan, codexAuthStatus, codexAuthPane, realCodexHome, readCodexConfigPins, bindCodexTranscriptSession, latestCodexCompletion, codexTurnSettled, codexCompletedTurnId, codexWorkingResumeConfiguration, captureCodexRecoveryProof, captureCodexResumeProof, readCodexResumeProof, codexResumeProofDigest, codexRootTranscript, codexRolloutSessionId, codexRunningTurn, codexInterruptionRecord, observeCodexDone, buildCodexAgentCmd, codexAgentArgv, codexResumeArgv, writeCodexCallerFiles, refuseCodexCallerInput, codexLaunchNote, codexPaneObservation, CODEX_INTERRUPT_KEY, codexHelperProcess, codexRateLimitModelSwitchDialog, codexApprovalDialog, codexStartupAction, codexModelChoice, codexEffortChoice, codexMoreReasoningChoice, codexTranscriptText, createCodexAgentMetadata, codexModelChoices, codexFastCommandOffered, codexFooterShowsFast, codexServiceTierNotices, restoreCodexDefaults, restoreCodexDefaultInFile, } from "./harnesses/codex.js";
|
|
69
70
|
import { claudeAuthPlan, claudeAuthStatus, claudeAuthPane, OPERATION_ID_RE, CLAUDE_RESULT_MAX_BYTES, CLAUDE_EFFORTS, agentClaudeOperationPath, agentClaudeApprovalReceiptPath, agentClaudeDispatchReceiptPath, validateOperationId, readClaudeResultText, assertClaudeAuthenticationReady, claudeModelChoices, claudeConfigDir, claudeProjectSlug, claudeFastIndicatorShown, claudeFastResult, buildClaudeAgentCmd, claudeAgentArgv, claudeResumeArgv, claudeLaunchNote, claudePaneObservation, CLAUDE_INTERRUPT_KEY, claudeUsageLimit, claudeLiveSelectMenu, claudeStartupAction, createClaudeAgentMetadata, writeClaudeCallerFiles, claudeSessionTranscriptPath, claudeApiErrorFromLine, claudeApiErrorAfter, claudeApiErrorEndingTurn, claudeFailureCategory, } from "./harnesses/claude.js";
|
|
70
|
-
import { cursorAuthPlan, cursorAuthStatus, cursorAuthPane, bindCursorTranscriptSession, cursorTurnBoundary, latestCursorCompletion, cursorTranscript, cursorTranscriptSessionId, observeCursorDone, cursorTranscriptText, assertCursorAuthenticationReady, assertCursorModelAvailable, cursorModelChoices, cursorModelIsFastVariant, cursorFastParameter, cursorHeaderShowsFast, cursorPickerView, cursorEffortSelected, cursorParameterRows, cursorUserConfigPath, CURSOR_DEFAULT_MODEL_KEYS, realCursorHome, buildCursorAgentCmd, cursorAgentArgv, cursorPromptWithLineage, createCursorAgentMetadata, cursorLaunchNote, cursorEffortNavigation, cursorTuiReady, cursorPaneObservation, CURSOR_INTERRUPT_KEY, cursorPromptHooksRunning, cursorUsageLimit, CURSOR_SUBMIT_SEQUENCE, validateCursorModelEffort, } from "./harnesses/cursor.js";
|
|
71
|
+
import { cursorAuthPlan, cursorAuthStatus, cursorAuthPane, bindCursorTranscriptSession, cursorTurnBoundary, latestCursorCompletion, cursorTranscript, cursorTranscriptSessionId, observeCursorDone, cursorTranscriptText, assertCursorAuthenticationReady, assertCursorModelAvailable, cursorModelChoices, cursorModelIsFastVariant, cursorFastParameter, cursorHeaderShowsFast, cursorPickerView, cursorEffortSelected, cursorParameterRows, cursorUserConfigPath, CURSOR_DEFAULT_MODEL_KEYS, realCursorHome, buildCursorAgentCmd, cursorAgentArgv, cursorPromptWithLineage, cursorLineagePreface, writeCursorCallerFiles, checkCursorCallerInput, createCursorAgentMetadata, cursorLaunchNote, cursorEffortNavigation, cursorTuiReady, cursorPaneObservation, CURSOR_INTERRUPT_KEY, cursorPromptHooksRunning, cursorUsageLimit, CURSOR_SUBMIT_SEQUENCE, validateCursorModelEffort, } from "./harnesses/cursor.js";
|
|
71
72
|
import { interimFromNow, interimFromToken, readInterimWords, recordInterimBoundary } from "./interim-words.js";
|
|
72
73
|
import { codexSeatTurn, grokSteerAcceptance, observeSteerDone, readSteerEntry, recordSteer } from "./steer-follow.js";
|
|
73
|
-
import { resolveAgentBin, resolveThroughlineBin, runThroughlineHandoffContext, isWindowsNativeExecutable, isUsableAgentExecutableFile, agentBinForPaneShell, resolveWinPaneShell, windowsAgentArgv, windowsAgentLaunchLine } from "./agent-resolver.js";
|
|
74
|
+
import { resolveAgentBin, resolveThroughlineBin, runThroughlineHandoffContext, isWindowsNativeExecutable, isUsableAgentExecutableFile, agentBinForPaneShell, resolveWinPaneShell, windowsAgentArgv, windowsAgentLaunchLine, windowsLaunchIndirection } from "./agent-resolver.js";
|
|
74
75
|
export { AitermError } from "./errors.js";
|
|
75
76
|
export { tmuxSpawnEnv } from "./tmux-runtime.js";
|
|
76
77
|
export { agentHarness } from "./agent-shared.js";
|
|
@@ -350,6 +351,12 @@ function savedAgentSessionNames() {
|
|
|
350
351
|
return match ? [match[1]] : [];
|
|
351
352
|
}))] : [];
|
|
352
353
|
}
|
|
354
|
+
/** Windows: the full PowerShell launch command goes to a private file; only the short reader line is typed (and shown). */
|
|
355
|
+
export function windowsLaunchTyped(name, launchId, full) {
|
|
356
|
+
const file = agentMetadataPath(name, launchId) + ".launch.ps1";
|
|
357
|
+
writeText0600(file, full);
|
|
358
|
+
return windowsLaunchIndirection(file);
|
|
359
|
+
}
|
|
353
360
|
function cleanupAgentState(name) {
|
|
354
361
|
assertSessionName(name);
|
|
355
362
|
agentMetadataNegativeCache.delete(name);
|
|
@@ -366,6 +373,7 @@ function cleanupAgentState(name) {
|
|
|
366
373
|
if (f.endsWith(".agent.json") ||
|
|
367
374
|
f.endsWith(".active-launch.json") ||
|
|
368
375
|
f.endsWith(".launch-exited") ||
|
|
376
|
+
f.endsWith(".launch.ps1") ||
|
|
369
377
|
f.endsWith(".events.jsonl") ||
|
|
370
378
|
f.endsWith(".activity.jsonl") ||
|
|
371
379
|
f.endsWith(".resume.json") ||
|
|
@@ -387,6 +395,10 @@ function cleanupAgentState(name) {
|
|
|
387
395
|
f.endsWith(".claude-caller-mcp.json") ||
|
|
388
396
|
f.endsWith(".codex-caller-prompt.md") ||
|
|
389
397
|
f.endsWith(".codex-caller-mcp.json") ||
|
|
398
|
+
f.endsWith(".grok-caller-prompt.md") ||
|
|
399
|
+
f.endsWith(".grok-caller-agent.md") ||
|
|
400
|
+
f.endsWith(".cursor-caller-prompt.md") ||
|
|
401
|
+
f.endsWith(".antigravity-caller-prompt.md") ||
|
|
390
402
|
f.endsWith(".launch-env") ||
|
|
391
403
|
f.endsWith(".claude-result.json") ||
|
|
392
404
|
f.endsWith(".cursor-result.json") ||
|
|
@@ -399,7 +411,7 @@ function cleanupAgentState(name) {
|
|
|
399
411
|
f.endsWith(".steers.jsonl") ||
|
|
400
412
|
f.endsWith(".auth.json"))
|
|
401
413
|
fs.unlinkSync(p);
|
|
402
|
-
else if (f.endsWith(".seat-span.d") || f.endsWith(".codex-home") || f.endsWith(".grok-home") || f.endsWith(".cursor-plugin") || f.endsWith(".home") || f.endsWith(".resume-restore.d")) {
|
|
414
|
+
else if (f.endsWith(".seat-span.d") || f.endsWith(".codex-home") || f.endsWith(".grok-home") || f.endsWith(".cursor-plugin") || f.endsWith(".antigravity-caller") || f.endsWith(".home") || f.endsWith(".resume-restore.d")) {
|
|
403
415
|
fs.rmSync(p, { recursive: true, force: true });
|
|
404
416
|
}
|
|
405
417
|
}
|
|
@@ -4660,7 +4672,7 @@ async function sendInitialAgentPromptInLock(name, text, o) {
|
|
|
4660
4672
|
startupBlockedHint(startup.reason), 2);
|
|
4661
4673
|
}
|
|
4662
4674
|
await o.after_ready?.(name, meta);
|
|
4663
|
-
const promptText = meta.kind === "cursor" ? cursorPromptWithLineage(meta, text) : text;
|
|
4675
|
+
const promptText = meta.kind === "cursor" ? cursorPromptWithLineage(meta, text) : meta.kind === "antigravity" ? antigravityPromptWithCaller(meta, text) : text;
|
|
4664
4676
|
const startOffset = agentCompletionCursor(meta);
|
|
4665
4677
|
const inputId = meta.kind === "claude" ? randomBytes(16).toString("hex") : undefined;
|
|
4666
4678
|
try {
|
|
@@ -6914,10 +6926,12 @@ async function resumeAgentInLock(name, readyTimeout, claudeRoot) {
|
|
|
6914
6926
|
if (registerSessionEnvironment(true, name, [...(registeredSessionEnvironment(name) ?? []), ...Object.keys(recipe.environment)]).code !== 0)
|
|
6915
6927
|
throw uncertain();
|
|
6916
6928
|
phase = "vendor_start";
|
|
6917
|
-
const
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
const
|
|
6929
|
+
const cliArgv = next.kind === "claude" ? claudeResumeArgv(recipe.executable, recipe.model, recipe.reasoning_effort, next)
|
|
6930
|
+
: codexResumeArgv(recipe.executable, recipe.model, recipe.reasoning_effort, next, recipe.cwd);
|
|
6931
|
+
const argv = [...(next.fork_of && !isWin ? writeBanPrefix(next.fork_of.write_ban) : []), ...cliArgv];
|
|
6932
|
+
const forkBan = next.fork_of?.write_ban;
|
|
6933
|
+
const winArgv = () => (cli => forkBan ? windowsWriteBanArgv(forkBan, cli) : cli)(windowsAgentArgv(cliArgv, () => resolveWinPaneShell("bash")));
|
|
6934
|
+
const full = isWin ? windowsLaunchTyped(name, next.launch_id, windowsAgentLaunchLine(recipe.cwd, environment, winArgv(), { file: agentMetadataPath(name, next.launch_id) + ".launch-exited", launch_id: next.launch_id }))
|
|
6921
6935
|
: `cd ${shq(recipe.cwd)} && /usr/bin/env ${environment.filter(([, value]) => value === null).map(([key]) => `-u ${shq(key)}`).join(" ")} `
|
|
6922
6936
|
+ `${environment.filter(([, value]) => value !== null).map(([key, value]) => shq(`${key}=${value}`)).join(" ")} ${argv.map(shq).join(" ")}`;
|
|
6923
6937
|
agentLaunchLines.set(name, atomicShellMultiline(full, shell));
|
|
@@ -7064,7 +7078,7 @@ async function dispatchAgentTurnInLock(name, text, o, pendingSend) {
|
|
|
7064
7078
|
// 画面の確かめを飛ばす送信(force)と、加工なしの送信(raw)には、既定の前置きを打たない(打った文は入力欄がそのまま読む)。
|
|
7065
7079
|
const prefaced = splitAgentPreface(meta.kind, o.preface, text, { defaultForWrapped: !o.force && !o.raw });
|
|
7066
7080
|
const dispatchText = meta.kind === "cursor" && !meta.vendor_session_id
|
|
7067
|
-
? `${
|
|
7081
|
+
? `${cursorLineagePreface(meta)}\n\n${prefaced.body}`
|
|
7068
7082
|
: prefaced.body;
|
|
7069
7083
|
prepareSendText(dispatchText, { raw: o.raw });
|
|
7070
7084
|
const inputId = meta.kind === "claude" ? randomBytes(16).toString("hex") : undefined;
|
|
@@ -7500,7 +7514,7 @@ function buildAgentCmd(kind, bin, model, effort, prompt, meta = null, cursorFast
|
|
|
7500
7514
|
if (kind === "cursor")
|
|
7501
7515
|
return buildCursorAgentCmd(bin, model, effort, prompt, meta, cursorFast);
|
|
7502
7516
|
if (kind === "antigravity")
|
|
7503
|
-
return antigravityAgentArgv(bin, model, effort, prompt).map(shq).join(" ");
|
|
7517
|
+
return antigravityAgentArgv(bin, model, effort, prompt, meta).map(shq).join(" ");
|
|
7504
7518
|
return buildGrokAgentCmd(kind, bin, model, effort, prompt, meta);
|
|
7505
7519
|
}
|
|
7506
7520
|
/**
|
|
@@ -7714,6 +7728,8 @@ function prepareAgentLaunch(kind, opts = {}) {
|
|
|
7714
7728
|
assertCursorAuthenticationReady(bin);
|
|
7715
7729
|
if (kind === "antigravity") {
|
|
7716
7730
|
const auth = antigravityAuthStatus(bin, cwd ?? process.cwd());
|
|
7731
|
+
if (auth.status === "unauthenticated")
|
|
7732
|
+
throw launchAuthRequired("antigravity-cli", `${auth.message}`);
|
|
7717
7733
|
if (auth.status !== "authenticated")
|
|
7718
7734
|
throw new AitermError(`ANTIGRAVITY_AUTH_REQUIRED: ${auth.message}`, 2);
|
|
7719
7735
|
const catalog = antigravityModelChoices(bin, cwd ?? process.cwd());
|
|
@@ -7794,6 +7810,12 @@ function prepareAgentLaunch(kind, opts = {}) {
|
|
|
7794
7810
|
writeClaudeCallerFiles(meta, opts.append_system_prompt ?? null, opts.mcp_config ?? null);
|
|
7795
7811
|
if (meta.kind === "codex")
|
|
7796
7812
|
writeCodexCallerFiles(meta, opts.append_system_prompt ?? null, opts.mcp_config ?? null);
|
|
7813
|
+
if (meta.kind === "grok" || meta.kind === "cursor" || meta.kind === "antigravity") {
|
|
7814
|
+
// The seat's own environment: what ${NAME} in a header resolves to (and what a harness reads at run time).
|
|
7815
|
+
const seatEnv = new Map(agentEnvEntries(meta, sid, envVars));
|
|
7816
|
+
const write = meta.kind === "grok" ? writeGrokCallerFiles : meta.kind === "cursor" ? writeCursorCallerFiles : writeAntigravityCallerFiles;
|
|
7817
|
+
write(meta, opts.append_system_prompt ?? null, opts.mcp_config ?? null, name => seatEnv.get(name));
|
|
7818
|
+
}
|
|
7797
7819
|
if (opts.fork_of)
|
|
7798
7820
|
meta.fork_of = opts.fork_of;
|
|
7799
7821
|
if (isWin && ["claude", "codex", "grok", "antigravity"].includes(kind))
|
|
@@ -7833,11 +7855,13 @@ function prepareAgentLaunch(kind, opts = {}) {
|
|
|
7833
7855
|
const argv = kind === "claude" ? claudeAgentArgv(bin, model, effort, prompt, meta)
|
|
7834
7856
|
: kind === "codex" ? codexAgentArgv(bin, model, effort, prompt, meta)
|
|
7835
7857
|
: kind === "cursor" ? cursorAgentArgv(bin, model, effort, prompt, meta, cursorFast)
|
|
7836
|
-
: kind === "antigravity" ? antigravityAgentArgv(bin, model, effort, prompt)
|
|
7858
|
+
: kind === "antigravity" ? antigravityAgentArgv(bin, model, effort, prompt, meta)
|
|
7837
7859
|
: grokAgentArgv(kind, bin, model, effort, prompt, meta);
|
|
7838
7860
|
full = windowsAgentLaunchLine(cwd, [
|
|
7839
7861
|
...claudeRootEntries, ...(meta?.kind === "grok" ? grokEnvEntries(meta) : []), ...agentEnvEntries(meta, sid, envVars),
|
|
7840
|
-
], windowsAgentArgv(argv, () => resolveWinPaneShell("bash")), meta?.windows_launch_exit_tracked ? { file: agentMetadataPath(sid, meta.launch_id) + ".launch-exited", launch_id: meta.launch_id } : undefined);
|
|
7862
|
+
], (cli => meta?.fork_of ? windowsWriteBanArgv(meta.fork_of.write_ban, cli) : cli)(windowsAgentArgv(argv, () => resolveWinPaneShell("bash"))), meta?.windows_launch_exit_tracked ? { file: agentMetadataPath(sid, meta.launch_id) + ".launch-exited", launch_id: meta.launch_id } : undefined);
|
|
7863
|
+
if (meta)
|
|
7864
|
+
full = windowsLaunchTyped(sid, meta.launch_id, full);
|
|
7841
7865
|
}
|
|
7842
7866
|
else {
|
|
7843
7867
|
const cmd = (meta?.fork_of ? writeBanPrefix(meta.fork_of.write_ban).map(shq).join(" ") + " " : "")
|
|
@@ -8024,10 +8048,27 @@ export function resolveForkSource(kind, from, opts, probe = probeWriteBan) {
|
|
|
8024
8048
|
return { fork_of: { session_id: from.session_id, vendor_session_id: mainVendorId, ...(from.fork_id ? { fork_id: from.fork_id } : {}),
|
|
8025
8049
|
write_ban, ...(first_input ? { first_input } : {}) }, cwd: main.cwd, ...(root ? { root } : {}) };
|
|
8026
8050
|
}
|
|
8051
|
+
/** Caller launch fields refused from the arguments alone, before any session or file exists (phase "input"). */
|
|
8052
|
+
function refuseCallerInput(kind, opts) {
|
|
8053
|
+
if (kind === "codex")
|
|
8054
|
+
return refuseCodexCallerInput(opts.append_system_prompt, opts.mcp_config);
|
|
8055
|
+
if (kind !== "grok" && kind !== "cursor" && kind !== "antigravity")
|
|
8056
|
+
return;
|
|
8057
|
+
try {
|
|
8058
|
+
const servers = (kind === "grok" ? checkGrokCallerInput : kind === "cursor" ? checkCursorCallerInput : checkAntigravityCallerInput)(opts.append_system_prompt, opts.mcp_config);
|
|
8059
|
+
// Cursor puts the text in the seat's first dispatch whatever it is; agy's only channel is the launch prompt itself.
|
|
8060
|
+
if (kind === "antigravity" && opts.append_system_prompt != null && opts.prompt == null && opts.throughline_source_session == null)
|
|
8061
|
+
throw new AitermError("append_system_prompt needs a prompt for antigravity-cli (agy has no instruction channel; the text prefixes the first prompt)", 2);
|
|
8062
|
+
const envVars = opts.env_vars ?? [];
|
|
8063
|
+
assertCallerEnv(kind.toUpperCase(), servers, name => envVars.includes(name) ? launchEnvValue(name) : undefined, true);
|
|
8064
|
+
}
|
|
8065
|
+
catch (e) {
|
|
8066
|
+
throw e instanceof AitermError ? launchInputRefusal(agentHarness(kind), e.message) : e;
|
|
8067
|
+
}
|
|
8068
|
+
}
|
|
8027
8069
|
export async function openAgentWithInitialPrompt(kind, opts = {}) {
|
|
8028
8070
|
// Caller launch fields: refused from the arguments alone, before any session or file exists (phase "input").
|
|
8029
|
-
|
|
8030
|
-
refuseCodexCallerInput(opts.append_system_prompt, opts.mcp_config);
|
|
8071
|
+
refuseCallerInput(kind, opts);
|
|
8031
8072
|
const fork = opts.fork_from ? resolveForkSource(kind, opts.fork_from, opts) : null;
|
|
8032
8073
|
if (opts.configuration_root != null && kind !== "claude")
|
|
8033
8074
|
throw new AitermError("AGENT_CONFIGURATION_ROOT_REJECTED: configuration_rootはclaude-code harnessだけで使えます。", 2);
|
package/dist/errors.js
CHANGED
|
@@ -21,6 +21,12 @@ export function launchInputRefusal(harness, reason) {
|
|
|
21
21
|
error.launchNotStarted = { harness, phase: "input" };
|
|
22
22
|
return error;
|
|
23
23
|
}
|
|
24
|
+
/** The harness CLI is not logged in; the launch is refused before any session exists (remote-terminal.md R18, code AGENT_AUTH_REQUIRED). */
|
|
25
|
+
export function launchAuthRequired(harness, reason) {
|
|
26
|
+
const error = new AitermError(`AGENT_LAUNCH_NOT_STARTED: AGENT_AUTH_REQUIRED: ${reason}`, 2);
|
|
27
|
+
error.launchNotStarted = { harness, phase: "input", code: "AGENT_AUTH_REQUIRED" };
|
|
28
|
+
return error;
|
|
29
|
+
}
|
|
24
30
|
/** A harness authentication check refused launch before any session creation.
|
|
25
31
|
* Keep the native CLI's status body and credential diagnostics out of the wire. */
|
|
26
32
|
export class AgentAuthenticationPreflightError extends AitermError {
|
|
@@ -10,7 +10,8 @@ import { checkedCatalog, catalogInvalid, catalogUnavailable } from "../model-cat
|
|
|
10
10
|
import { spawnAgentControlCommand } from "../agent-resolver.js";
|
|
11
11
|
import { liveNodeExecutable } from "../live-node.js";
|
|
12
12
|
import { powershellInvocation } from "../windows-powershell.js";
|
|
13
|
-
import { agentEventPath, agentLineageFields, agentsDir, createEmpty0600, readFileRange, safeStatSize, shq, writeAgentMetadata, writeJson0600 } from "../agent-shared.js";
|
|
13
|
+
import { agentEventPath, agentLineageFields, agentsDir, assertSessionName, createEmpty0600, writeText0600, readFileRange, safeStatSize, shq, writeAgentMetadata, writeJson0600 } from "../agent-shared.js";
|
|
14
|
+
import { assertCallerEnv, checkCallerInput, readCallerText, resolveCallerHeader, writeCallerJson } from "./caller-mcp.js";
|
|
14
15
|
import { authUrl } from "../agent-auth.js";
|
|
15
16
|
// agy 1.4.10 exposes effort-specific IDs; overriding an ID's effort is rejected by the CLI.
|
|
16
17
|
export function antigravityCatalog(stdout, selected) {
|
|
@@ -190,8 +191,52 @@ export function createAntigravityAgentMetadata(name, cwd, initial, writeScope, l
|
|
|
190
191
|
writeAgentMetadata(meta);
|
|
191
192
|
return meta;
|
|
192
193
|
}
|
|
193
|
-
|
|
194
|
-
|
|
194
|
+
// ---- Caller launch fields (launch-identity-input.md "Caller launch fields"). agy has no per-run instruction channel Aiterm could
|
|
195
|
+
// prove (the .agents/rules route was not confirmed), so the text prefixes the first prompt; the servers are .agents/mcp_config.json
|
|
196
|
+
// in a per-seat folder passed as --add-dir. Both live in Aiterm state (0600 files), never in ~/.gemini or the project.
|
|
197
|
+
export function agentAntigravityCallerPromptPath(name) {
|
|
198
|
+
assertSessionName(name);
|
|
199
|
+
return path.join(agentsDir(), `${name}.antigravity-caller-prompt.md`);
|
|
200
|
+
}
|
|
201
|
+
export function agentAntigravityCallerDir(name) {
|
|
202
|
+
assertSessionName(name);
|
|
203
|
+
return path.join(agentsDir(), `${name}.antigravity-caller`);
|
|
204
|
+
}
|
|
205
|
+
/** agy does not expand header references, so every ${NAME} is written as the seat's value. */
|
|
206
|
+
export function antigravityCallerMcpJson(servers, valueOf) {
|
|
207
|
+
return { mcpServers: Object.fromEntries(servers.map(server => [server.name, {
|
|
208
|
+
serverUrl: server.url,
|
|
209
|
+
...(server.headers.length ? { headers: Object.fromEntries(server.headers.map(header => [header.name, resolveCallerHeader("ANTIGRAVITY", header, valueOf)])) } : {}),
|
|
210
|
+
}])) };
|
|
211
|
+
}
|
|
212
|
+
export function checkAntigravityCallerInput(prompt, mcp) {
|
|
213
|
+
return checkCallerInput("ANTIGRAVITY", prompt, mcp);
|
|
214
|
+
}
|
|
215
|
+
export function writeAntigravityCallerFiles(meta, prompt, mcp, valueOf) {
|
|
216
|
+
const servers = checkAntigravityCallerInput(prompt, mcp);
|
|
217
|
+
assertCallerEnv("ANTIGRAVITY", servers, valueOf);
|
|
218
|
+
if (prompt !== null) {
|
|
219
|
+
const file = agentAntigravityCallerPromptPath(meta.aiterm_session);
|
|
220
|
+
writeText0600(file, prompt);
|
|
221
|
+
meta.antigravity_caller_prompt_file = file;
|
|
222
|
+
}
|
|
223
|
+
if (mcp !== null) {
|
|
224
|
+
const dir = agentAntigravityCallerDir(meta.aiterm_session);
|
|
225
|
+
writeCallerJson(path.join(dir, ".agents", "mcp_config.json"), antigravityCallerMcpJson(servers, valueOf));
|
|
226
|
+
meta.antigravity_caller_mcp_dir = dir;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/** The first prompt with the caller's text in front (the seat's only instruction channel here). */
|
|
230
|
+
export function antigravityPromptWithCaller(meta, prompt) {
|
|
231
|
+
const caller = readCallerText(meta.antigravity_caller_prompt_file);
|
|
232
|
+
return caller === null ? prompt : `${caller}\n\n${prompt}`;
|
|
233
|
+
}
|
|
234
|
+
export function antigravityAgentArgv(bin, model, effort, prompt, meta) {
|
|
235
|
+
// The seat folder and the cwd are trusted by --settings, or agy asks and then writes settings.json in ~/.gemini.
|
|
236
|
+
const folder = meta?.antigravity_caller_mcp_dir;
|
|
237
|
+
const trusted = folder ? [...new Set([meta.cwd, meta.cwd && fs.existsSync(meta.cwd) ? fs.realpathSync(meta.cwd) : null, folder].filter((item) => !!item))] : [];
|
|
238
|
+
const settings = JSON.stringify({ queuedMessages: "send-immediately", ...(folder ? { trustedWorkspaces: trusted } : {}) });
|
|
239
|
+
return [bin, "--dangerously-skip-permissions", "--settings", settings, ...(folder ? ["--add-dir", folder] : []), ...(model ? ["--model", model] : []), ...(effort ? ["--effort", effort] : []), ...(prompt ? ["--prompt-interactive", prompt] : [])];
|
|
195
240
|
}
|
|
196
241
|
export function antigravityBindingFile(meta) {
|
|
197
242
|
return path.join(agentsDir(), `${meta.aiterm_session}.${meta.launch_id}.antigravity-session.json`);
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Caller launch fields (launch-identity-input.md "Caller launch fields") shared by grok-cli, cursor-cli and antigravity-cli:
|
|
2
|
+
// one reading of `mcp_config` and the checks that decide, before any seat exists, whether a harness can carry it.
|
|
3
|
+
// Codex keeps its own copy of the same rules (codex.ts codexMcpOverrides) and error codes.
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import { AitermError } from "../errors.js";
|
|
7
|
+
import { writeJson0600 } from "../agent-shared.js";
|
|
8
|
+
// The text travels in one argv element (Linux caps one at 128 KiB) or the typed first prompt.
|
|
9
|
+
export const CALLER_PROMPT_MAX = 64 * 1024;
|
|
10
|
+
const MCP_SERVER_NAME = /^[A-Za-z0-9_-]{1,64}$/;
|
|
11
|
+
const HEADER_NAME = /^[A-Za-z0-9-]{1,128}$/;
|
|
12
|
+
const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
13
|
+
// Names every seat has whatever env_vars says (core.ts agentEnvEntries), known before the seat exists.
|
|
14
|
+
const SEAT_ENV_NAMES = new Set(["AITERM_SESSION_ID", "AITERM_AGENT_SESSION_ID", "AITERM_AGENT_LAUNCH_ID"]);
|
|
15
|
+
/** `mcp_config` -> servers. Refuses (<LABEL>_MCP_CONFIG_UNSUPPORTED) what an http server table with env-named headers cannot say. */
|
|
16
|
+
export function parseCallerMcp(mcp, label) {
|
|
17
|
+
const refuse = (message) => { throw new AitermError(`${label}_MCP_CONFIG_UNSUPPORTED: ${message}`, 2); };
|
|
18
|
+
const servers = mcp?.mcpServers;
|
|
19
|
+
if (!mcp || typeof mcp !== "object" || Object.keys(mcp).some(key => key !== "mcpServers") || !servers || typeof servers !== "object" || Array.isArray(servers))
|
|
20
|
+
return refuse("mcp_config must be {mcpServers: {...}}");
|
|
21
|
+
return Object.entries(servers).map(([name, server]) => {
|
|
22
|
+
if (!MCP_SERVER_NAME.test(name))
|
|
23
|
+
return refuse(`server name '${name}' must be letters, digits, '_' or '-'`);
|
|
24
|
+
const spec = server;
|
|
25
|
+
if (!spec || typeof spec !== "object" || Array.isArray(spec))
|
|
26
|
+
return refuse(`server '${name}' must be an object`);
|
|
27
|
+
if (Object.keys(spec).some(key => !["type", "url", "headers"].includes(key)))
|
|
28
|
+
return refuse(`server '${name}' may only have type, url and headers`);
|
|
29
|
+
if (spec.type !== undefined && spec.type !== "http")
|
|
30
|
+
return refuse(`server '${name}': only type 'http' is supported here (got '${String(spec.type)}')`);
|
|
31
|
+
let url = null;
|
|
32
|
+
try {
|
|
33
|
+
url = typeof spec.url === "string" ? new URL(spec.url) : null;
|
|
34
|
+
}
|
|
35
|
+
catch { /* refused below */ }
|
|
36
|
+
if (!url || (url.protocol !== "http:" && url.protocol !== "https:"))
|
|
37
|
+
return refuse(`server '${name}': url must be an http(s) URL`);
|
|
38
|
+
if (spec.headers !== undefined && (!spec.headers || typeof spec.headers !== "object" || Array.isArray(spec.headers)))
|
|
39
|
+
return refuse(`server '${name}': headers must be an object`);
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
const headers = Object.entries((spec.headers ?? {})).map(([header, value]) => {
|
|
42
|
+
if (!HEADER_NAME.test(header) || typeof value !== "string")
|
|
43
|
+
return refuse(`server '${name}': header '${header}' must be a plain name with a string value`);
|
|
44
|
+
if (seen.has(header.toLowerCase()))
|
|
45
|
+
return refuse(`server '${name}': header '${header}' is given twice`);
|
|
46
|
+
seen.add(header.toLowerCase());
|
|
47
|
+
const bearer = header.toLowerCase() === "authorization" ? /^Bearer \$\{([^}]*)\}$/.exec(value)?.[1] : undefined;
|
|
48
|
+
const whole = /^\$\{([^}]*)\}$/.exec(value)?.[1];
|
|
49
|
+
if (bearer !== undefined || whole !== undefined) {
|
|
50
|
+
const envName = (bearer ?? whole);
|
|
51
|
+
if (!ENV_NAME.test(envName))
|
|
52
|
+
return refuse(`server '${name}': header '${header}' names an invalid environment variable`);
|
|
53
|
+
return { name: header, kind: bearer !== undefined ? "bearer" : "env", value: envName };
|
|
54
|
+
}
|
|
55
|
+
if (value.includes("${"))
|
|
56
|
+
return refuse(`server '${name}': header '${header}' mixes text with \${NAME}; only the whole value or 'Bearer \${NAME}' can be given`);
|
|
57
|
+
return { name: header, kind: "literal", value };
|
|
58
|
+
});
|
|
59
|
+
return { name, url: spec.url, headers };
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** The text and servers of a caller input, or the refusal. `null` mcp -> no servers. */
|
|
63
|
+
export function checkCallerInput(label, prompt, mcp) {
|
|
64
|
+
if (prompt != null && (!prompt.trim() || Buffer.byteLength(prompt, "utf8") > CALLER_PROMPT_MAX))
|
|
65
|
+
throw new AitermError(`append_system_prompt must be non-empty and at most 64 KiB for ${label.toLowerCase()}`, 2);
|
|
66
|
+
return mcp == null ? [] : parseCallerMcp(mcp, label);
|
|
67
|
+
}
|
|
68
|
+
/** Every `${NAME}` the servers name must have a value at launch, or the seat would start with an empty secret. */
|
|
69
|
+
export function assertCallerEnv(label, servers, valueOf, preStart = false) {
|
|
70
|
+
for (const server of servers)
|
|
71
|
+
for (const header of server.headers) {
|
|
72
|
+
if (header.kind === "literal")
|
|
73
|
+
continue;
|
|
74
|
+
if (valueOf(header.value) === undefined && !(preStart && SEAT_ENV_NAMES.has(header.value)))
|
|
75
|
+
throw new AitermError(`${label}_MCP_ENV_UNAVAILABLE: header '${header.name}' of server '${server.name}' uses \${${header.value}}, which has no value at launch; list ${header.value} in env_vars`, 2);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** The header value with every `${NAME}` replaced by the seat's value (for a harness that does not expand them). */
|
|
79
|
+
export function resolveCallerHeader(label, header, valueOf) {
|
|
80
|
+
if (header.kind === "literal")
|
|
81
|
+
return header.value;
|
|
82
|
+
const value = valueOf(header.value);
|
|
83
|
+
if (value === undefined || value === "")
|
|
84
|
+
throw new AitermError(`${label}_MCP_ENV_UNAVAILABLE: \${${header.value}} has no value at launch`, 2);
|
|
85
|
+
return header.kind === "bearer" ? `Bearer ${value}` : value;
|
|
86
|
+
}
|
|
87
|
+
/** 0600 file inside a seat folder (created 0700) of Aiterm's launch state. */
|
|
88
|
+
export function writeCallerJson(file, value) {
|
|
89
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
90
|
+
writeJson0600(file, value);
|
|
91
|
+
}
|
|
92
|
+
export function readCallerText(file) {
|
|
93
|
+
return file ? fs.readFileSync(file, "utf8") : null;
|
|
94
|
+
}
|