Skip to content

feat(agent): replace OAR with direct native CLI runtimes - #6639

Merged
M4n5ter merged 17 commits into
rust-previewfrom
feat/native-cli-runtimes
Nov 5, 2026
Merged

M4n5ter merged 17 commits into
rust-previewfrom
feat/native-cli-runtimes

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Replace OAR with direct Codex, Claude Code and Antigravity integrations, native catalogs, Host MCP tools, attachments and same-conversation resume.
  • Busy input steers Codex and Claude; agy soft-interrupts and starts a new Host invocation only after native terminal, original Host operations and physical settlement. Explicit delivery: "queue" never interrupts. Follow-ups preserve an explicitly selected backend.
  • Keep conversation MCP addresses/configuration paths stable within a Host activation and capture immutable tool definitions for each invocation, refreshing changed catalogs only after settlement. Credentials, permissions and receipts remain invocation-bound; unknown outcomes stay fenced. Uses rmcp 3.8.0.
  • Initialize native MCP setup once and deliver Maka instructions as independent ordinary user messages, without changing native system prompts. Confirmed digests avoid repeats; changed or cleared instructions explicitly replace old blocks. Setup asks for acknowledgement only; imported Claude/Codex histories omit synthetic setup dialogue while retaining real tools. Skills autocomplete, send, steering and queue edits use the actual bridged Session tool selection. Runtime-specific validation avoids unrelated CLI probes and reuses a completed full catalog.
  • Use one current native journal format in maka.agent.external, with no old-format decoder or retired setup receipt route. Runtime opt-in is controlled only by external.runtimes; remove the redundant top-level gate and regenerate SDK/configuration schemas.
  • Images use native input or ordered immutable paths/media types. Refresh dependency notices, retain V8 native cache inputs, and exclude PR-only images from source releases.

Limits: agy busy soft interruption is Unix-only. Windows requires native .exe or explicit node.exe plus CLI script arguments, not .cmd/.bat shims. Host restart rebinds the local MCP endpoint without discarding native conversation identity.

Breaking storage/configuration change

There is no in-product compatibility reader, migration fallback, or retired oarSetup recovery branch. Before upgrading an existing installation, settle its original pending operations on the old build and back up the stopped Root/configuration/client journals. Update the deployment source to external with per-runtime opt-in; remove external.enabled (if it was false, first set every runtime switch to false). Old worker configuration and queued admissions are not automatically reinterpreted as native calls.

An optional standalone offline migration Gist prepares a new partitions directory for the complete cd5f02535 journal format, preserving native IDs, delivery watermarks, CAS revisions and unresolved-run fences. It moves the records to the correctly routed new namespace partition; it does not modify the input databases or install/activate the result. It rejects incomplete older formats and destination collisions rather than guessing. It is not shipped with Maka. Older OAR formats need a separately reviewed offline migration or new native conversations.

Verification

On macOS, using the configured default Cargo:

  • just check: passed — 2234 workspace tests (30 skipped), 194 tooling tests, 5 product tests and 46 terminal tests (format, generated contracts/TypeScript, tooling/product, workspace tests, terminal checks and licenses/notices).
  • Offline migration fixture tests: 3 passed (cross-partition copy, identity/fence/revision preservation, collision/incomplete-format rejection; no user database was opened).
  • Browser-discovery fixtures isolate their user directories rather than requiring access to real Chrome profiles. Existing provider-uncertainty and REPL language assertions remain intact.
  • Additional Clippy remains blocked by the installed Cargo fork’s check/build unit-identity bug, confirmed with an independent two-dependency reproducer. No alternate toolchain or source workaround was used. Windows-specific execution and paid-provider live checks were not run.
Runtime selection and full-access consent

Existing real Host / NSH render-buffer captures (not desktop screenshots); the corresponding UI test was rerun after syncing rust-preview.

Runtime selection
Full-access consent

AI use

  • Generative tooling made a substantive contribution

Maka / OpenAI Codex: implementation, tests and documentation. Material commits carry Generated-by: Maka.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally
  • Yes — behavior changes are described above

Bind invocation-scoped MCP tools to Host execution custody, original receipts and resource-only reads. Preserve cancellation settlement and archive access, and narrowly support Antigravity 1.5.0 HTTP MCP.

Generated-by: Maka
Generated-by: OpenAI Codex
Generated-by: Antigravity Argon
… import

Add an opt-in acceptance for the real Claude Code MCP probe transcript. Verify all three turns, resumed model provenance, tool/result correlation, read-only import and original receipt replay.

Generated-by: Maka
Direct ACP, app-server and interactive PTY with native full-access permissions. Retain execution custody, original Host receipts and native conversation fences. Remove the OAR/Deno worker distribution and installer.\n\nValidation and integration are still in progress; this local checkpoint precedes synchronization with the updated rust-preview baseline.

Generated-by: Maka
Generated-by: OpenAI Codex
Preserve fatal discovery observations across cache eviction, revoke only unspawned provisional Claude identities, and settle correlated Claude API failures without replay. Strengthen real-runtime resume checks to require a fresh Host tool call on every invocation. Repair settings navigation after installer removal and record real NSH buffer evidence.

Generated-by: Maka
Generated-by: OpenAI Codex
Connect through the native WebSocket proxy after idempotent daemon start. Keep per-invocation MCP credentials in thread configuration, not shared process environment. Interrupt only the correlated turn and wait for its terminal; retain unknown and cleanup fences after proxy loss. Cover cancellation boundaries and the native WebSocket protocol without changing Host receipt or resource custody.

Generated-by: Maka
@github-actions github-actions Bot added the effort/XXL Over 2500 readable lines label Nov 5, 2026
Automate scoped native workspace trust, wait for the fresh Host catalog, paste multiple immutable images and stream text before one Enter. Preserve native JSONL admission and pre-submission cancellation custody. Expand byte/setup budgets, remove count cutoffs, follow Codex native model cursors and permit provider/feature defaults without changing full-access policy.

Generated-by: Maka

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

This is a focused dependency/build follow-up at 4e0b1fd52e7a34d47753d6b965e286761af6ab83, not a completed review of the native runtime replacement.

P2: the changed Rust dependency graph has no matching dependency inventory. The new native dependencies and lockfile introduce packages such as [email protected], [email protected] and [email protected], while products/maka/cli/DEPENDENCIES.rust.tsv is unchanged from the parent and has no rows for these packages. The production checker rejects that inventory, failing both the Rust audit in job 127073226945 and tooling in job 127075400559. Regenerate and commit the inventory for this graph, then run its check.

I read the manifest/lockfile changes, the inventory and scripts/rust/dependencies.mjs, and the actual failed logs. The checker reaches licenses ok before rejecting the stale inventory; this is not a finding that a dependency's license is prohibited. The same checker passes on parent 390360d0 in job 127048365632.

The desktop-build and bridge jobs also fail to link the native rusty_v8 library. I have not established the cause and am not presenting that observation as a second confirmed PR defect. I did not run a local native build, independently repeat the documented CLI/Host tests, inspect the visual captures, or complete the configuration-upgrade and lifecycle review. Those checks remain necessary for the broader change.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

publish.workspace = true

[dependencies]
axum = { version = "0.8", default-features = false, features = ["http1", "tokio"] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Regenerate the native Rust inventory with the new dependencies

These additions change the shipped Rust graph (including the new axum/axum-core/matchit packages), but products/maka/cli/DEPENDENCIES.rust.tsv remains byte-identical to the parent and does not contain those rows. The actual Rust audit and tooling jobs both stop at scripts/rust/dependencies.mjs:80 with “Rust dependency inventory is stale”; the parent tooling check passes. Run the inventory generator and commit its output alongside the dependency change, then verify the check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed fixed at 8a2cecd846fc3962bca0004c4d7cc38e1c5cfafd. The missing dependency rows and rmcp version are synchronized, and the successful rust-licenses job 127179831048 actually ran node scripts/rust/dependencies.mjs check; I checked its raw log and completed result. The dependency-audit run 42008084825 also completed successfully.

This clears my stale dependency-inventory finding. It does not establish correctness of the native runtime, MCP lifetime, instruction updates or configuration migration, and it is not evidence that the full PR CI has passed.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

Preserve native system prompts with separate Maka instruction messages, reuse native identities and original Host receipts, and adapt agy image uploads through immutable paths.

Generated-by: Maka
Preserve native interruption evidence and physical settlement before resuming queued input. Match the documented status and tool-error protocol and native MCP plugin namespace.

Generated-by: Maka
Generated-by: Maka
Regenerate the SDK delivery contract and restore the atomic fixture state update used by the merged native CLI UI regression.

Generated-by: Maka

@M4n5ter M4n5ter left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English

Reviewed 23608af46. Replacing the OAR/Deno sidecar stack with per-invocation local HTTP MCP bridges (127.0.0.1:0, 256-bit random Bearer tokens, Phase admission gates, lastDeliveredRun watermarks, and single-transaction deliver_steering validation) gives a much cleaner runtime boundary.

Here are the CI/release blockers, everyday-path runtime/platform bugs, and legacy compatibility remnants to address for a clean final implementation:

A. CI & Release Blockers

  1. Regenerate Rust license manifests and third-party notices (products/maka/cli/DEPENDENCIES.rust.tsv, notices.json, THIRD_PARTY_NOTICES.txt)

    • plugins/agent/native/Cargo.toml:26-27, 82 added non-dev axum = "0.8", rmcp (transport-streamable-http-server), and tokio-tungstenite, introducing 4 new shipped crates into maka-cli (axum, axum-core, matchit, pastey).
    • products/maka/cli/DEPENDENCIES.rust.tsv was not updated (already failing Dependency audit / rust-licenses), notices.json / THIRD_PARTY_NOTICES.txt were hand-edited instead of regenerated, and scripts/rust/licenses/deno-2.9.6-source-notices.txt is now orphaned after removing deno_core / v8. Run just licenses-generate and remove unused license source files.
  2. Include target/**/gn_out in CI compiler caches so desktop-build and bridge do not fail linking rusty_v8 (.github/actions/ci-setup/action.yml:122-129, .github/actions/ci-cache/action.yml:42-48)

    • v8's build.rs downloads librusty_v8.a into target/debug/gn_out/obj/ (three parents above OUT_DIR), outside target/**/build.
    • Because Cargo.lock changed here, restore-keys: compiled_prefix restores a fallback cache containing v8's fresh build-script-build fingerprint without gn_out; Cargo skips re-running v8's build.rs and fails when relinking v8 with could not find native static library rusty_v8.
    • Add target/**/gn_out to both cache actions, and in ci-setup purge target/**/build/v8-* + target/**/.fingerprint/v8-* whenever v8 fingerprints exist without gn_out/obj so existing caches self-heal.
  3. Exclude PR screenshots from git archive so ASF source-release validation passes (.gitattributes, docs/_pr/native-cli-runtimes/*.png)

    • scripts/asf-source-release.mjs:623-664 (validateNonTextInputs) rejects any binary file in git archive not listed in docs/code-origin-audit.md:287-313. Adding /docs/_pr export-ignore to .gitattributes keeps PR-only screenshots out of release archives (and fixes the same latent issue for docs/_pr/6603/*.png).

B. Everyday Runtime & Cross-Platform Bugs

  1. Do not re-inject <maka_system_instructions> on every resumed turn, guard bootstrap turns against premature execution, and filter synthetic instructions in session-import

    • Locations: plugins/agent/native/src/owner/queue.rs:1128-1131, plugins/agent/native/src/executor/external.rs:395-400, external/claude.rs:219-248, external/agy.rs:229-249, external/codex.rs:174-191, and plugins/agent/session-import/src/{claude/wire.rs:170-197, codex.rs:55-65, catalog/summary.rs:174-224}.
    • Three concrete issues hit on normal multi-turn sessions:
      1. Unconditional re-injection on every resumed turn ($O(N)$ context bloat + 2x sequential LLM turns in Claude): request["instructions"] is Some(...) on every turn in Maka. None of the three drivers check resume (or whether instructions changed):
        • Claude: claude/input.rs:212 already awaits bridge.listed at startup before any input is sent, yet every --resume turn still pastes the full <maka_system_instructions> into the PTY and runs a complete extra LLM turn before submitting the user's message ($2N$ sequential LLM turns and $N$ full copies of AGENTS.md in ~/.claude/projects/.../<uuid>.jsonl).
        • Codex: Every thread/resume turn calls thread/inject_items again, appending another full copy of <maka_system_instructions> into the persisted thread.
        • Antigravity: While each fresh agy process needs an initial message to trigger lazy MCP loading (bridge.listed), resumed --conversation <id> turns with unchanged instructions should use a minimal MCP readiness ping rather than resending multi-KB system instructions every turn.
      2. Missing "acknowledge only / do not act yet" directive while full access & Host MCP are already live: runtime::instruction_message only wraps <maka_system_instructions>...</maka_system_instructions>. In agy.rs:230-232, "Initialize the available MCP tool catalog ... Do not perform a user task yet." sits inside instructions.unwrap_or(...), so it disappears whenever instructions is Some (all real Maka sessions), and claude.rs never includes one. With --dangerously-skip-permissions and bridge.admit() already open, imperative rules in AGENTS.md or /skill:... prompts can trigger tool side effects during the hidden bootstrap turn.
      3. Leaks into Session Import titles, chat bubbles, and Recall: Because Claude and Codex persist <maka_system_instructions> as the first ordinary user row in their native JSONL transcripts, Session Import displays <maka_system_instructions> ... as the session title and imports every synthetic block (plus Claude's hidden bootstrap reply) as visible chat messages.
  2. Update the 4 sibling /skill: and steering paths missed when enabling "external" skills and live steering

    • Owner::send (plugins/agent/native/src/owner.rs:1505-1510) and active_delivery (owner.rs:1259-1270) were updated for "external", but four sibling entrypoints still enforce the old rules:
      1. Owner::skill_candidates (plugins/agent/native/src/owner/skills.rs:115-122): Returns empty SkillCandidates::default() for BackendPreference::Executor, so typing /skill: in Composer shows zero autocomplete candidates when Claude, Codex, or Antigravity is selected.
      2. Owner::steer_message (plugins/agent/native/src/owner/steering.rs:43-50): Validates /skill: against self.selected_tools(...) (the full native Maka toolset such as Bash / Edit) instead of self.external_tools(...), falsely admitting skills whose required Host tools are not bridged to external runtimes.
      3. QueueAction::Update (plugins/agent/native/src/owner/queue/controls.rs:252-254): Hardcodes if basis.executor.is_some() { vec![] }, rejecting edits to queued external messages that reference valid Host-bridged skills with QueueRejection::InvalidEdit.
      4. QueueAction::Promote (plugins/agent/native/src/owner/queue/controls.rs:289-293): Unconditionally rejects control.basis.executor.is_some() with QueueRejection::ExecutionChanged, breaking Promote / Steer-now on queued messages even during active Codex or Claude turns that support ActiveDelivery::Steer.
  3. Fix Windows .cmd / .bat CLI spawning and Claude path/config resolution on Windows

    • .cmd / .bat shims fail with ERROR_BAD_EXE_FORMAT (193): external/runtime.rs:155-157 resolves ["exe", "cmd", "bat"] on Windows (npm global installs produce %APPDATA%\npm\claude.cmd and codex.cmd), then passes that path to maka_process::Command -> CreateProcessW(buffers.executable.as_ptr(), ...) (platform/process/src/command/windows.rs:122-134), which rejects batch files whenever lpApplicationName is non-null.
    • Claude Windows verbatim paths & USERPROFILE:
      • external/claude.rs:124 uses tokio::fs::canonicalize(cwd), producing \\?\C:\... on Windows. That encodes as ----C--Users-... in transcript() (316-327) instead of Claude's C--Users-..., so Cursor watches a JSONL path Claude never writes; it also breaks workspace trust matching path != Some(cwd) (claude/input.rs:156).
      • external/claude.rs:300-314 only checks CLAUDE_CONFIG_DIR and HOME, missing USERPROFILE on Windows.
  4. Preserve explicit Send.backend across InterruptResume on busy Antigravity turns (plugins/agent/native/src/owner.rs:1271-1273, 1313-1324)

    • Primary Enter/Send in Composer.tsx:356-358 always sends { backend, delivery: 'steer' }. When Antigravity is running, active_delivery selects InterruptResume (cancelling the current turn to start a new Followup invocation), and owner.rs:1313-1322 unconditionally overwrites input.backend with control.basis.executor.selection. Switching the model/backend picker while Antigravity is busy and pressing Enter interrupts Antigravity only to launch the new turn on the old Antigravity model instead of the user's newly selected backend.
  5. Scope external discovery/validation per runtime where appropriate and fix catalog TTL / transient error caching (plugins/agent/native/src/owner/models.rs:90-109, 283-297, external.rs:212-249)

    • Removing runtime from the external_choices query forces single-model validation (Owner::model) for Claude (which needs zero subprocesses) or Antigravity to also spawn agy models and codex app-server daemon + WebSocket proxy whenever Codex is enabled.
    • Stamping started: Instant::now() before discover runs (SETUP_TIMEOUT = 300s) gives any probe taking >=30s a 0ms TTL on completion, while memoizing fast transient Err(Error::Provider | Error::Invalid) results inside the Shared future for the full 30s window.

C. Clean Removal of Legacy oar Shims, Redundant Schema Fields & Stale Prompts/Docs

  1. Remove remaining oar compatibility shims, switch physical namespace to "maka.agent.external", and drop redundant external.enabled

    • Broken half-retained 'oarSetup' shim: products/maka/client/src/journal.rs:38-42, products/maka/client/src/lib.rs:112-119, and plugins/settings/settings/ui.tsx:165-168 still retain 'oarSetup', whereas plugins/settings/settings/settingsOperations.ts already removed its 'oarSetup' handler (making ui.tsx:165 dead code that throws Unsupported settings receipt anyway). Delete all three remnants.
    • Switch "maka.agent.oar" -> "maka.agent.external" and drop legacy decode shims: Replace Namespace::new("maka.agent.oar", Scope::Profile) in plugins/agent/native/src/executor/external.rs:125 (and associated tests/READMEs) with "maka.agent.external", remove backward-compat #[serde(default)] on internal journal::Record::last_delivered_run (external/journal.rs:29), and clean up stale "oar" fixture IDs in platform/event-log/tests/integration/archive/mod.rs:595-625 (if needed for local dev data, attach a one-off migration script gist in the PR body).
    • Drop redundant ExternalConfiguration.enabled: runtimes: { antigravity, codex, claude } already represents whether any runtime is enabled; externalAgentSettingsState.ts:176-180 only writes enabled: true as a holdover from OarConfiguration with no separate UI toggle. Removing external.enabled across configurations.ts, plugins/agent/api/src/{executor.rs, external.rs}, and externalAgentSettingsState.ts keeps a single source of truth.
  2. Update SessionSend tool description and products/maka/bundle/README* to match current semantics

    • products/maka/bundle/src/installation.ts:209 still tells models "external executor turns always queue follow-ups", whereas omitting delivery="queue" now steers active Codex/Claude turns and interrupts active Antigravity turns via SIGINT.
    • products/maka/bundle/README.md:68-74 and README.zh-CN.md:70-76 still describe the superseded 64 KiB / 128 fragments history cap, queue-only external follow-ups, and Claude PTY rejecting image attachments.
简体中文

看完了 23608af46。整体把 OAR/Deno 侧车栈替换成按调用隔离的本机 HTTP MCP 桥(127.0.0.1:0、256-bit 随机 Bearer token、Phase 准入门控、lastDeliveredRun 水位与单事务 deliver_steering 校验),主干边界清爽了很多。

下面整理出需要一并收敛的 CI / 发版必挂项、常规使用即可触发的运行时 / 跨平台缺陷,以及需彻底清理的旧命名与兼容残留:

一、CI 与发版必挂阻塞项

  1. 重新生成 Rust 依赖台账与第三方声明(products/maka/cli/DEPENDENCIES.rust.tsv、notices.json、THIRD_PARTY_NOTICES.txt)

    • plugins/agent/native/Cargo.toml:26-27, 82 新增了运行期依赖 axum = "0.8"、rmcp(transport-streamable-http-server)与 tokio-tungstenite,为 maka-cli 引入了 4 个新发布 crate(axum、axum-core、matchit、pastey)。
    • products/maka/cli/DEPENDENCIES.rust.tsv 未同步(当前 CI Dependency audit / rust-licenses 已挂),notices.json / THIRD_PARTY_NOTICES.txt 系手工删改,且移除 deno_core / v8 后 scripts/rust/licenses/deno-2.9.6-source-notices.txt 已成孤儿文件。请执行 just licenses-generate 并清理不再引用的 license 源文件。
  2. CI 编译器缓存补齐 target/**/gn_out,修复 desktop-build 与 bridge 链接 rusty_v8 失败(.github/actions/ci-setup/action.yml:122-129、.github/actions/ci-cache/action.yml:42-48)

    • v8 的 build.rs 会将预编译 librusty_v8.a 下载到 target/debug/gn_out/obj/(OUT_DIR 往上三层),不在 target/**/build 内。
    • 本 PR 更新 Cargo.lock 后通过 compiled_prefix 命中旧缓存,Cargo 看到 v8 的 build-script-build fingerprint 未变跳过下载,重编 v8 lib 时就会报 could not find native static library rusty_v8。
    • 建议两处缓存路径均加入 target/**/gn_out,并在 ci-setup 恢复缓存后检查:若存在 v8-* fingerprint 但缺少 gn_out/obj,主动清理 target/**/build/v8-* 与 target/**/.fingerprint/v8-* 实现旧缓存自愈。
  3. 将 PR 截图目录排除出 git archive,避免 just source 源码包检查失败(.gitattributes、docs/_pr/native-cli-runtimes/*.png)

    • scripts/asf-source-release.mjs:623-664(validateNonTextInputs)要求归档包内所有二进制文件必须在 docs/code-origin-audit.md:287-313 登记。在 .gitattributes 增加 /docs/_pr export-ignore 即可避免发版源码包校验失败(同时修复 docs/_pr/6603/*.png 的同类隐患)。

二、常规路径可触发的运行时与跨平台缺陷

  1. 避免在每次续轮(resume)重复注入 <maka_system_instructions>,补齐 bootstrap 回合“勿提前执行”约束,并在 session-import 过滤合成指令消息

    • 位置:plugins/agent/native/src/owner/queue.rs:1128-1131、plugins/agent/native/src/executor/external.rs:395-400、external/claude.rs:219-248、external/agy.rs:229-249、external/codex.rs:174-191,以及 plugins/agent/session-import/src/{claude/wire.rs:170-197, codex.rs:55-65, catalog/summary.rs:174-224}。
    • 多轮对话下必现的三个问题:
      1. 每轮重复注入导致 $O(N)$ 上下文膨胀 + Claude 2 倍串行回合耗时:真实 Maka 会话每轮 request["instructions"] 都是 Some(...),三个驱动均未检查 resume(及指令是否变化):
        • Claude:claude/input.rs:212 在发消息前已等完 bridge.listed,本不依赖 bootstrap 消息触发 MCP 加载;但每次 --resume 仍把整份 <maka_system_instructions> 粘贴进 PTY 跑完整整一轮额外 LLM 往返后再发用户消息($N$ 轮对话实际串行跑 $2N$ 轮,且 JSONL 中堆积 $N$ 份完整 AGENTS.md)。
        • Codex:每次 thread/resume 都再次 thread/inject_items 追加一份完整 <maka_system_instructions>。
        • Antigravity:虽然每个新 agy 进程需首条消息触发懒加载 MCP(bridge.listed),但 --conversation <id> 续轮且指令未变时只需发极简 MCP 就绪确认,不应每轮重发数 KB 的系统指令。
      2. 真实会话丢失“仅确认、勿执行”约束,而此时最高权限与 Host MCP 已开启:agy.rs:230-232 把 "Initialize the available MCP tool catalog ... Do not perform a user task yet." 放在 instructions.unwrap_or(...) 里,只要 instructions 为 Some(所有真实会话)该约束就消失;claude.rs 则始终没有该约束。此时 --dangerously-skip-permissions 与 bridge.admit() 均已放行,AGENTS.md 或 /skill: 中的行动式指令会在隐藏回合直接触发工具副作用。
      3. 污染 Session Import 标题与导入历史:Claude 和 Codex 将首条 <maka_system_instructions> 作为普通 user 消息写入原生 JSONL,打开 Session Import 会直接显示 <maka_system_instructions> ... 作为会话标题,导入后所有注入块与 Claude 隐藏回复都会变成可见聊天气泡并进入 Recall 索引。
  2. 补齐 "external" 启用 /skill: 与运行中 Steer 后漏改的 4 条同类路径

    • Owner::send(plugins/agent/native/src/owner.rs:1505-1510)与 active_delivery(owner.rs:1259-1270)已支持 external,但以下 4 处同源路径仍停留在旧限制:
      1. Owner::skill_candidates(plugins/agent/native/src/owner/skills.rs:115-122):遇到 BackendPreference::Executor 直接返回空候选,选中 Claude / Codex / Antigravity 时在输入框敲 /skill: 没有任何补全。
      2. Owner::steer_message(plugins/agent/native/src/owner/steering.rs:43-50):运行中对 Claude / Codex 走 steer_message 时用了 self.selected_tools(...)(完整原生工具集,含 Bash / Edit 等)而非 self.external_tools(...) 校验技能,会错误放行依赖未桥接工具的技能。
      3. QueueAction::Update(plugins/agent/native/src/owner/queue/controls.rs:252-254):仍写死 if basis.executor.is_some() { vec![] },在队列中编辑带合法 /skill: 的外部消息会直接报 QueueRejection::InvalidEdit。
      4. QueueAction::Promote(plugins/agent/native/src/owner/queue/controls.rs:289-293):无条件拦截 control.basis.executor.is_some() 并返回 QueueRejection::ExecutionChanged,导致即便在支持 Steer 的 Codex / Claude 运行期间点击队列插队也会失败。
  3. 修复 Windows 下 .cmd / .bat CLI 启动失败及 Claude 的 Windows 路径与配置目录解析

    • .cmd / .bat 启动必报 os error 193:external/runtime.rs:155-157 在 Windows 查找 ["exe", "cmd", "bat"](npm 全局安装的 claude / codex 默认均为 %APPDATA%\npm\*.cmd),随后传给 CreateProcessW(buffers.executable.as_ptr(), ...)(platform/process/src/command/windows.rs:122-134);Win32 CreateProcessW 在 lpApplicationName 非空时不支持批处理脚本,必现 ERROR_BAD_EXE_FORMAT (193)。
    • Claude Windows 路径与 USERPROFILE:
      • external/claude.rs:124 的 tokio::fs::canonicalize(cwd) 在 Windows 返回 \\?\C:\...,导致 transcript()(316-327)编码为 ----C--Users-...(与 Claude 实际写入的 C--Users-... 不一致)而永远等不到 JSONL;同时首次工作区信任弹窗 path != Some(cwd)(claude/input.rs:156)也会因 \\? 前缀失配直接报错。
      • external/claude.rs:300-314 查找 .claude 目录仅读取了 CLAUDE_CONFIG_DIR 与 HOME,遗漏了 Windows 标准环境变量 USERPROFILE。
  4. Antigravity 运行中 InterruptResume 不应丢弃调用方显式传入的 Send.backend(plugins/agent/native/src/owner.rs:1271-1273, 1313-1324)

    • Composer.tsx:356-358 回车发送默认带 { backend, delivery: 'steer' }。Antigravity 运行时走 InterruptResume 取消当前轮并排入新 Followup 轮,但 owner.rs:1313-1322 用旧轮的 control.basis.executor.selection 无条件覆盖了 input.backend(应优先保留显式传入的 selection,仅缺省时回退)。否则用户在运行中切换模型或切到 Claude/Codex 后按回车中断重发,新轮仍会跑在旧的 Antigravity 模型上。
  5. 解耦单模型校验对无关 CLI 的探测,并修正目录缓存 TTL 与瞬时错误缓存(plugins/agent/native/src/owner/models.rs:90-109, 283-297、external.rs:212-249)

    • external_choices 去掉 runtime 维度后,校验单个 Claude 选择(本无需任何子进程)或单个 Antigravity 选择时,只要同时启用了 Codex,就会连带拉起 agy models 与 codex app-server daemon/proxy。
    • external.rs:218-220, 238 在 discover 开始前记录 started: Instant::now(),慢探测(>=30s)完成即过期;而快速瞬时失败(Err(Error::Provider | Error::Invalid))又会被 Shared future 缓存满 30s。

三、彻底清理 oar 兼容残留、冗余配置字段与过时工具提示 / 文档

  1. 移除 oar 兼容残留,物理命名空间切为 "maka.agent.external",并删掉冗余的 external.enabled

    • 删除半截残留的 'oarSetup':products/maka/client/src/journal.rs:38-42、products/maka/client/src/lib.rs:112-119 与 plugins/settings/settings/ui.tsx:165-168 保留了 'oarSetup',但 plugins/settings/settings/settingsOperations.ts 已移除对应分支,导致 ui.tsx:165 成为死代码且遇到旧收据仍会抛异常,直接全部删净即可。
    • 物理命名空间切为 "maka.agent.external" 并清理旧兼容:将 plugins/agent/native/src/executor/external.rs:125(及相关测试与 README)中的 Namespace::new("maka.agent.oar", Scope::Profile) 直接改为 "maka.agent.external";去掉内部 journal::Record::last_delivered_run(external/journal.rs:29)上的旧记录兼容 #[serde(default)];顺带清理 platform/event-log/tests/integration/archive/mod.rs:595-625 残留的 "oar" 测试夹具 ID(本地旧开发数据如需迁移,在 PR body 附一份一次性迁移脚本 gist 即可)。
    • 移除冗余的 ExternalConfiguration.enabled:runtimes: { antigravity, codex, claude } 已经完整表达启用状态;externalAgentSettingsState.ts:176-180 没有独立总开关 UI,只是沿用旧 OarConfiguration 在开启任意 runtime 时顺手写 enabled: true。删掉 configurations.ts、plugins/agent/api/src/{executor.rs, external.rs} 与 externalAgentSettingsState.ts 中的 external.enabled,保持单一事实源。
  2. 同步更新 SessionSend 工具提示词与 products/maka/bundle/README*

    • products/maka/bundle/src/installation.ts:209 的 SessionSend 描述仍写着 "external executor turns always queue follow-ups",而当前默认不传 delivery="queue" 会直接 steer Codex/Claude,并通过 SIGINT 中断正在运行的 Antigravity。
    • products/maka/bundle/README.md:68-74 与 README.zh-CN.md:70-76 仍残留已废弃的 64 KiB / 128 fragments 预算、外部运行期仅排队、以及 Claude PTY 拒绝图片附件等旧说明。

Automated review generated by Antigravity.

Keep conversation endpoints, native configuration paths and durable tool catalogs stable while binding each invocation to fresh credentials, isolated transport sessions and original operation receipts. Bootstrap native conversations only once and release their resources on session retirement.

Generated-by: Maka
Include profile-level gn_out outputs in both compiler-cache actions and version fallback keys to exclude incomplete archives. Regenerate dependency notices from the shipped graph and exclude PR-only evidence from source distributions.

Generated-by: Maka
Preserve explicit successor backends, apply the bridged tool ceiling consistently to skill candidates and queued steering, and scope native discovery without losing bounded caching. Keep setup dialogue out of imported histories, clarify Windows launch constraints, and update runtime documentation.

Generated-by: Maka

@M4n5ter M4n5ter left a comment •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English

Reviewed the latest updates up to 8a2cecd84 (dfa6afc80 / f04452c37 / 8a2cecd84).

Most items from the previous round (license/dependency inventories, /docs/_pr archive exclusion, target/**/gn_out caching, unified skill_tool_names ceiling & Codex/Claude queue Promote, agy InterruptResume preserving explicit successor backend/model, runtime-scoped discovery without caching transient failures, Claude dunce::simplified + USERPROFILE, and session-import synthetic bootstrap filtering) are cleanly resolved. However, 4 blocking issues remain before this PR can be merged:

1. [Regression in dfa6afc80] Subsequent turns drop updated request["instructions"], and durable mcp_catalog equality bricks existing sessions across normal upgrades/tool toggles

  • Per-turn instructions updates are permanently dropped after Turn 1 (plugins/agent/native/src/executor/external/agy.rs:230, claude.rs:221, codex.rs:174):
    • Owner::input (plugins/agent/native/src/owner/queue.rs:1027-1038, 1128-1131) dynamically computes request.instructions on every turn from basis.behavior (Collaboration Mode Plan vs Build prompts, assistant behavior instructions, language) plus skills::prompt (which embeds the current skill catalog revision required by SkillLoad).
    • Gating request["instructions"] behind a one-way boolean if !journal.bootstrap_completed() means that once Turn 1 sets bootstrap_completed = true, all subsequent updates to request["instructions"] are silently discarded. If a user starts Turn 1 in Plan mode (injecting read-only planning instructions) and switches to Build mode on Turn 2 to implement the plan, the native CLI never receives the Build instructions and stays locked in Plan instructions for the rest of the conversation; similarly, if .maka/skills changes between turns, the model never receives the updated revision needed to call SkillLoad, or if Turn 1 had instructions: None (codex.rs:193 / agy.rs:248), later behavior/skill instructions are never delivered.
    • Fix: Instead of a boolean bootstrap_completed, persist the digest of the last delivered instructions (still running the initial agy setup turn when no native session has been bootstrapped yet so agy confirms MCP discovery), and re-inject <maka_system_instructions> whenever the instructions digest changes on a subsequent turn. Add a multi-turn test covering instructions changes (e.g. Plan -> Build or updated skill metadata) on Turn 2.
  • Persisting full mcp_catalog JSON in journal::Record and enforcing exact tool == definition equality bricks sessions on benign upgrades or tool changes (plugins/agent/native/src/executor/external/journal.rs:78-90, mcp.rs:132, 229-237):
    • journal.bind_catalog permanently writes full tool JSON (name, description, inputSchema) into CAS and validate_catalog fails with "Native MCP catalog changed; start a new conversation" whenever any current tool definition differs even by a single word in description (such as the SessionSend description update in 8a2cecd84!) or when a user enables an additional tool/plugin mid-session.
    • Keeping the catalog consistent for a live in-memory Endpoint is fine, or refreshing the endpoint catalog when definitions change across restarts/turns is fine, but durable journal state must not permanently brick existing conversations over tool description edits or newly enabled tools.

2. [Incomplete fix in 8a2cecd84] Windows .cmd / .bat detection is inconsistent between executable(), discovery::query(), and command()

  • In plugins/agent/native/src/executor/external/runtime.rs:161-199 and discovery.rs:38-69:
    1. runtime::executable (runtime.rs:162) still matches ["exe", "cmd", "bat"] in PATH order and returns Some(path), while only runtime::command (runtime.rs:193-199) rejects .cmd/.bat.
    2. Consequently, discovery::query (discovery.rs:38-42, 73-75) reports npm-installed claude.cmd as installation: "available" in Settings and the model picker, failing only when the user sends a message; for codex.cmd / agy.cmd, discovery.rs:67 (Err(_) =>) swallows command()'s actionable .cmd/.bat diagnostic and reports installation: "available" with generic "Native protocol model discovery failed".
    3. If an older .cmd shim appears earlier in PATH than a native .exe, executable() stops at the .cmd shim and fails instead of resolving the native .exe later in PATH.
  • Fix: Prefer native executables (.exe) across PATH before considering .cmd/.bat, and surface an explicit unsupported-batch-shim installation diagnostic directly in discovery::query as well as runtime::command when only .cmd/.bat is present.

3. [Required cleanup] Remove remaining legacy oar shims, rename physical namespace to "maka.agent.external", drop intra-PR #[serde(default)] shims, and remove redundant ExternalConfiguration.enabled

Maka currently makes no backward-compatibility guarantees for internal schemas, uncommitted/pre-release formats, or superseded namespaces: we always converge directly on the cleanest target design rather than carrying compatibility branches or legacy names. In addition, the rationale given for keeping these shims does not hold in the code:

  • Dead 'oarSetup' recovery branches: plugins/settings/settings/settingsOperations.ts already removed 'oarSetup' and throws Unsupported settings receipt, so the leftover 'oarSetup' branches in products/maka/client/src/journal.rs:41, products/maka/client/src/lib.rs:118, and plugins/settings/settings/ui.tsx:165 are unreachable/broken dead code. Remove 'oarSetup' completely.
  • Physical namespace "maka.agent.oar" -> "maka.agent.external": Rename the CAS namespace in plugins/agent/native/src/executor/external.rs:155, its tests (claude.rs:840, external_history.rs:93, external_persistence.rs:34-36, external_support.rs:148, platform/event-log/tests/integration/archive/mod.rs:595-625), and plugins/agent/native/README{.md,.zh-CN.md}:63/61.
  • Intra-PR #[serde(default)] on journal::Record (plugins/agent/native/src/executor/external/journal.rs:25-35): journal::Record is a brand-new struct introduced in this PR and should not carry #[serde(default)] compatibility attributes (last_delivered_run, bootstrap_completed, mcp_catalog) for intermediate development snapshots.
  • Redundant ExternalConfiguration.enabled: bool (plugins/agent/api/src/executor.rs:47-59, plugins/agent/api/src/external.rs:58-60, packages/plugin-sdk/src/configurations.ts, and Settings UI state): "external" is a new configuration block introduced in this PR; having both top-level enabled: bool and runtimes: { antigravity, codex, claude } duplicates enablement state. Derive overall enablement directly from any runtime switch being enabled and remove top-level enabled.

4. [CI cache naming in f04452c37] Avoid -v2 suffix in scripts/ci/setup.mjs

  • scripts/ci/setup.mjs:77 (and scripts/ci.test.mjs:275) renamed rust-deps- to rust-deps-v2-. Avoid versioned -v2 key prefixes; instead, include .github/actions/ci-setup/action.yml (or the cached path specification) in the compiler hash input right above line 77 so compiled_prefix naturally invalidates incomplete fallback caches whenever cached paths change.
简体中文

已审阅更新至 8a2cecd84 的最新提交(dfa6afc80 / f04452c37 / 8a2cecd84)。

上一轮提出的大部分问题(依赖与许可证清单重算、/docs/_pr 归档排除、target/**/gn_out 缓存、统一 skill_tool_names 工具上限与 Codex/Claude 队列 Promote、agy InterruptResume 保留显式 backend/model、按 runtime 限缩探测且不再缓存瞬时失败、Claude dunce::simplified + USERPROFILE 回退、session-import 过滤合成初始化轮次)均已修好。但合并前仍需解决以下 4 个阻塞问题:

1. 【dfa6afc80 新引入回归】首轮之后永久丢弃 request["instructions"] 更新,且持久化 mcp_catalog 全等校验会在正常升级/开关工具后锁死已有会话

  • 第 2 轮起完全丢弃 request["instructions"](plugins/agent/native/src/executor/external/agy.rs:230、claude.rs:221、codex.rs:174):
    • Owner::input(plugins/agent/native/src/owner/queue.rs:1027-1038, 1128-1131)在每一轮都会根据当前 basis.behavior(含 Plan / Build 协作模式提示词、assistant 行为指令、语言偏好)与 skills::prompt(含 SkillLoad 所需的最新技能目录 revision)动态生成 request.instructions。
    • 当前实现用单向布尔值 if !journal.bootstrap_completed() 把指令注入一次性锁死:一旦首轮置为 true,后续所有轮次的 request["instructions"] 都会被静默丢弃。用户第 1 轮在 Plan 模式下规划(注入只读规划指令)、第 2 轮切到 Build 模式要求落地实现时,原生 CLI 永远收不到新的 Build 指令;工作区技能变更后的新 revision(或首轮 instructions: None 后续新增的指令)同样无法送达。
    • 修复建议:不要使用单向布尔值锁死,改为记录上次已投递的 instructions 摘要(agy 首次会话无指令时仍执行一次空 bootstrap 以确认 MCP 懒加载),后续轮次只要 instructions 摘要发生变化就补发更新后的 <maka_system_instructions>,并补充第 2 轮切换指令/模式的回归测试。
  • 持久化 mcp_catalog 逐字 JSON 相等校验会在正常升级或开启工具后废掉存量会话(journal.rs:78-90、mcp.rs:132, 229-237):
    • journal.bind_catalog 将完整工具定义(含 description、inputSchema)永久写入 CAS,而 validate_catalog 要求当前工具定义与历史记录逐字相等(tool == definition),否则直接报错 "Native MCP catalog changed; start a new conversation"。这意味着只要升级 Maka 改了某个工具 description 的一两个字(例如本轮刚改了 SessionSend 的描述),或者用户在会话中途开启了新工具/插件,存量会话就会永久报错。不要在持久化 journal 中用历史 description 文案锁死跨重启/升级的会话。

2. 【8a2cecd84 未修完整】Windows .cmd / .bat 在 executable()、discovery::query() 与 command() 之间行为自相矛盾

  • 见 plugins/agent/native/src/executor/external/runtime.rs:161-199 与 discovery.rs:38-69:
    1. runtime::executable 仍按 ["exe", "cmd", "bat"] 收集候选并返回 Some(path),仅在 runtime::command 中拦截 .cmd/.bat。
    2. 这导致 discovery::query(discovery.rs:38)把 npm 安装的 claude.cmd 在设置页和模型选择器中误报为 available,直到发消息才失败;而 codex.cmd / agy.cmd 在 discovery.rs:67 被 Err(_) => 吞掉具体报错,对外仍显示 installation: "available" + 笼统的 "Native protocol model discovery failed",用户看不到 .cmd/.bat 诊断提示。
    3. 若 PATH 前面有旧 .cmd shim、后面有原生 .exe,executable() 命中 .cmd 就提前返回报错,找不到后面的 .exe。
  • 修复建议:Windows 下在整条 PATH 上优先解析原生 .exe;仅当没有任何 .exe 而存在 .cmd/.bat 时,在 discovery::query 与 runtime::command 中统一暴露明确的 .cmd/.bat 不支持诊断。

3. 【必须清理的兼容残留】移除死代码 'oarSetup'、将物理命名空间改为 "maka.agent.external"、删除新建 journal::Record 上的 #[serde(default)]、去掉冗余的 ExternalConfiguration.enabled

当前项目不提供内部状态/未发布配置的向后兼容保证,所有协议、命名空间与配置结构一律直接收敛到最干净的最终模型,不保留兼容分支或历史命名;且保留理由在代码事实上也不成立:

  • 'oarSetup' 已是无法闭环的死代码:settingsOperations.ts 已移除 'oarSetup' 并直接抛 Unsupported settings receipt,因此 products/maka/client/src/journal.rs:41、products/maka/client/src/lib.rs:118、plugins/settings/settings/ui.tsx:165 中的 'oarSetup' 分支根本无法完成恢复,应彻底删除。
  • 物理存储命名空间改为 "maka.agent.external":同步更新 plugins/agent/native/src/executor/external.rs:155、相关测试(claude.rs:840、external_history.rs:93、external_persistence.rs:34-36、external_support.rs:148、platform/event-log/tests/integration/archive/mod.rs:595-625)及 plugins/agent/native/README{.md,.zh-CN.md}:63/61,不再保留 "maka.agent.oar" 与测试中的旧 "oar" fixture。
  • 去掉新建 journal::Record 上的 #[serde(default)](journal.rs:25-35):journal::Record 是本 PR 新引入的结构体,不应为 PR 开发期的中间本地快照保留任何 #[serde(default)]。
  • 去掉冗余顶层开关 ExternalConfiguration.enabled: bool(plugins/agent/api/src/executor.rs:47-59、plugins/agent/api/src/external.rs:58-60、packages/plugin-sdk/src/configurations.ts 及设置页状态):"external" 是本 PR 新增配置块,直接由 runtimes: { antigravity, codex, claude } 任一开启表达启用状态即可,删去重复的顶层 enabled。

4. 【f04452c37 缓存键命名】去掉 scripts/ci/setup.mjs 中的 -v2 后缀

  • scripts/ci/setup.mjs:77(及 scripts/ci.test.mjs:275)把缓存前缀改成了 rust-deps-v2-。不要引入 -v2 版本号后缀;直接把 .github/actions/ci-setup/action.yml(或缓存目录配置)并入第 77 行上方的 compiler 哈希输入即可自然更新 compiled_prefix,自动隔离缺少 gn_out 的旧 fallback 缓存。

Deliver changed instructions only after native confirmation, refresh settled MCP catalogs without resetting conversation identity, and reuse complete discovery catalogs for scoped validation. Align Windows discovery with launchable commands.

Isolate browser fixtures from real user profiles, derive cache restore keys from actual actions, and validate Cargo outputs without relying on their directory layout.

Generated-by: Maka
@M4n5ter
M4n5ter merged commit a6176b0 into rust-preview Nov 5, 2026
2 checks passed
@M4n5ter
M4n5ter deleted the feat/native-cli-runtimes branch November 5, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XXL Over 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants