Skip to content

feat(cli): initialize model connections and default target from stdin - #6805

Merged
M4n5ter merged 3 commits into
apache:rust-previewfrom
Colafornia:feat/cli-init-connection-settings
Nov 12, 2026
Merged

M4n5ter merged 3 commits into
apache:rust-previewfrom
Colafornia:feat/cli-init-connection-settings

Conversation

@Colafornia

@Colafornia Colafornia commented Nov 11, 2026 •

Copy link
Copy Markdown
Member
English

Summary

maka host init --settings-stdin can bootstrap model connections, credentials and a default model on a fresh State Root, so ACP clients and evaluation harnesses can configure Maka without the desktop UI.

Refs #6667 and the public connection bootstrap request.

  • Accept connections and defaultTarget alongside the existing proxy settings, with provider defaults, API keys, request headers, enabled models, model overrides and request body overlays.
  • Validate input before detaching a worker or creating the Root. Resolve the default model through the same provider preparation used by execution; incompatible thinking levels and protocols fail without leaving a Root or exposing secrets.
  • Keep endpoint constraints in providers and explicit token-limit constraints in shared configuration validation. Reuse credential enrollment and share the local-only authentication transport between settings and CLI.
  • Document the stdin JSON in the English and Chinese CLI READMEs.

Verification

Validated at 63a4b2d5e04d6ac6e3d5219efb5942286479b8f5, including rust-preview through 08bcd01a03e48cd56764790002c26efd11094402:

  • cargo test -p maka-cli --test integration initialize: 4 passed. Covers persistence, disabled connections, proxy settings, reconfiguration rejection, invalid-input redaction, default-model preflight and unfinished-stdin timeout.
  • cargo test -p maka-providers -p maka-config --test integration: 32 passed (7 provider tests and 25 configuration-store tests).
  • The new invalid-default subprocess regression was first run against d8868e37 and failed because initialization incorrectly succeeded.
  • Public CLI/ACP smoke against a local HTTP gateway: initialized a fresh Root, prompted using its default model, and verified the API key, custom header, body overlay and output-token limit at the gateway. Repeated successfully after stopping and restarting the Host; the Root identity persisted and Host epoch changed.
  • Changed Rust files passed rustfmt and git diff --check. Clippy with --no-deps and -D warnings passed for CLI, providers, configuration store, agent facts and agent ports.

The dependency-inclusive Clippy attempt stopped on the existing clippy::needless_update in plugins/agent/provider-protocol/src/chat_completions/response.rs:87, outside this PR's diff. Full just check and live upstream model requests were not run. Remote CI is still running; it is not recorded as passed here.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Antigravity authored the initial implementation. OpenAI Codex reviewed and refined provider-owned validation, added regression coverage and documentation, and performed the verification above. Preserve both tools' Generated-by trailers when squashing.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described above
  • No
中文

概述

maka host init --settings-stdin 支持为新的 State Root 初始化模型连接、凭据和默认模型,让 ACP 客户端及评测框架无需桌面界面即可配置 Maka。

关联 #6667,具体对应公开连接初始化入口的需求。

  • 在已有代理配置之外接受 connections 和 defaultTarget,支持 provider 默认配置、API key、自定义请求头、启用模型、模型参数与请求体覆盖。
  • 在分离 worker 或创建 Root 前校验输入,并通过执行时使用的 provider preparation 校验默认模型。不兼容的 thinking level 或协议会直接失败,不留下 Root,也不回显密钥。
  • 端点约束归 provider,显式 token limit 约束归共享配置 validator。凭据复用现有 enrollment,CLI 与 settings 共享仅限本地的认证 transport。
  • 中英文 CLI README 补充可直接参考的 stdin JSON。

验证

验证提交:63a4b2d5e04d6ac6e3d5219efb5942286479b8f5,已同步 rust-preview 至 08bcd01a03e48cd56764790002c26efd11094402。

  • CLI 初始化集成测试 4 项通过,覆盖持久化、禁用连接、代理配置、拒绝重新配置、错误脱敏、默认模型预检及 stdin 超时。
  • provider 与配置存储集成测试 32 项通过,分别为 7 项和 25 项。
  • 新增的错误默认模型回归先在 d8868e37 上运行,确认因 init 错误返回成功而失败。
  • 通过公开 CLI 初始化新 Root,并向本地 HTTP gateway 发起真实 ACP 请求,核对默认模型、API key、自定义 header、body overlay 与输出 token limit。停止并重启 Host 后再次通过,同时确认 Root ID 保持、Host epoch 改变。
  • 改动的 Rust 文件通过 rustfmt 和 diff 检查。CLI、providers、配置存储、agent facts、agent ports 通过带 --no-deps、-D warnings 的 Clippy。

包含依赖的 Clippy 被当前基线中 plugins/agent/provider-protocol/src/chat_completions/response.rs:87 的 clippy::needless_update 阻断,该文件不在本 PR 的 diff 中。未运行完整 just check 或真实上游模型请求。远端 CI 仍在执行,未宣称通过。

AI 使用

  • 没有生成式工具作出实质性贡献
  • 生成式工具作出了实质性贡献

Antigravity 编写初始实现。OpenAI Codex 完成审查、校验职责收口、回归测试与文档,并执行上述验证。Squash 时保留两个工具的 Generated-by trailers。

@Colafornia Colafornia self-assigned this Nov 11, 2026
@Colafornia Colafornia changed the title feat(cli): support model connections and default target in host init feat(cli): initialize model connections and default target from stdin Nov 11, 2026
Extend maka host init --settings-stdin with model connections, API keys,
request headers, enabled models, model overrides, request body overlays,
and default target selection for a fresh State Root.

Validate the complete input before detaching the worker or creating the
Root. Reuse canonical header validation, provider authentication, and
credential enrollment. Share local-only authentication transport between
settings and CLI code, and authenticate against the claimed connection
basis. Keep initialization tests focused on distinct behaviors.

Refs apache#6667

Generated-by: Antigravity
Generated-by: OpenAI Codex
@Colafornia
Colafornia marked this pull request as ready for review November 11, 2026 16:14
@Colafornia
Colafornia force-pushed the feat/cli-init-connection-settings branch from de3056f to d8868e3 Compare November 11, 2026 16:19

@jackwener jackwener left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Finding

  • [P2][normal headless bootstrap path] Preflight the configured default model before creating the Root. Settings::prepare currently checks only that defaultTarget names an enabled connection and model (products/maka/cli/src/initialize.rs:472). It never asks the provider to resolve that model and its overrides. On exact head d8868e37fa59e4b93c19bf342c5b52231b9e677b, I supplied an enabled default model with thinkingLevels: ["off"] and defaultThinkingLevel: "medium"; maka host init --settings-stdin exited successfully and persisted the Root. The first Agent or ACP model selection then follows Source::select -> Definition::prepare, where the same configuration is rejected as UnsupportedThinkingLevel and surfaces as agent_model_unavailable. Because this initializer also rejects an existing Root, a generic headless caller cannot correct the invalid bootstrap through the same interface. Please resolve the selected provider/model/overrides before RootOwner::create, and add a subprocess regression proving that an invalid default exits nonzero and leaves no Root.

Conclusion

I found no P0 or P1 issue. The implementation reuses the existing configuration, credential, and provider authorities, but the broken-default case above is a real, recoverable P2 and should be fixed.

I reviewed exact head d8868e37fa59e4b93c19bf342c5b52231b9e677b against current rust-preview 51e24532283f30e71bbafb9f008dd64dd6dfbbaf; the clean merge tree is 2b907d5c9c9aa7667fae83858a9b056c42e35aa8, and the relevant initialization/provider/model files are unchanged by the new base. Formatting and diff checks passed. Three initialization integration tests passed locally. The unchanged unfinished-stdin deadline test timed out twice on macOS, so I am not treating the local suite as fully green. GitHub's exact-head run is also not green: its remaining failures are in compaction, steering-fixture, and Desktop UI paths outside this PR's changed files.

Follow-up on final head 63a4b2d5 / landed e84c0742

The original finding above is fixed on the final head. The initializer now runs the selected default model through Definition::prepare before RootOwner::create, and the added public subprocess regression covers the contradictory thinking-level case, generic diagnostics, and absence of a Root. The landed tree exactly matches the final base-plus-head merge, and both Generated-by trailers were preserved.

Remaining finding

  • [P2][normal headless bootstrap path] Reject a required-auth default when this bootstrap supplied no credential. The new preflight calls Definition::prepare, which validates model policy but does not call Definition::authorize. For example, an enabled provider: "openai" connection can be selected as the default without apiKey; OpenAI's descriptor is non-anonymous, and its provider rejects authorize(..., None, ...). The bootstrap nevertheless passes its checks, creates the Root and stores that default. The first Agent or ACP request then fails as agent_authentication_unavailable. Protected Authorization and x-api-key request-header names cannot supply the missing provider credential, while host init refuses an existing Root. Please reject a selected non-anonymous provider unless this input prepared a supported credential, and add a public subprocess regression proving the failure leaves no Root.

I found no P0 or P1 on final head 63a4b2d5e04d6ac6e3d5219efb5942286479b8f5; the required-credential case above is the remaining P2. The 18-file final patch passed formatting and diff checks. I independently ran the provider configuration-admission test and the provider policy test that proves required-auth providers reject a missing credential. I did not independently rerun the full CLI or HTTP ACP/restart scenarios. Exact-head CI 43172019593 is not green because its root build stopped on the already-reported live_workspace compile failure inherited from #6816; current Rust contains the source fix, but its replacement run was still active at this review cut.


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

@github-actions github-actions Bot added the effort/L Under 1000 readable lines label Nov 12, 2026
Keep endpoint constraints in providers and explicit token limits in shared configuration validation. Preflight the selected default model before creating a Root, extend public CLI regression coverage, and document the stdin payload.

Generated-by: OpenAI Codex
@M4n5ter
M4n5ter merged commit e84c074 into apache:rust-preview Nov 12, 2026
11 of 14 checks passed
@Colafornia
Colafornia deleted the feat/cli-init-connection-settings branch November 13, 2026 02:15
M4n5ter pushed a commit that referenced this pull request Nov 15, 2026
…6909)

Extend `maka host init --settings-stdin` to accept optional `chatDefaults` and `projectDirectoryRoots` so headless ACP clients and `maka-eval` containers can seed the default sandbox policy and register explicit workspace roots outside `$HOME` before starting a Host.

- Accept `chatDefaults` and non-empty `projectDirectoryRoots` in `Settings` / `PreparedSettings`, normalizing directory roots before `RootOwner::create` with redacted failure diagnostics.
- Reject workspace roots overlapping the resolved target State Root (including non-existent parent `..` traversals), Host control directory, or ownership lease directory without creating `.maka-storage-root.json`.
- Thread `policy_revision` from `update_network_proxy` into `set_chat_defaults` and persist workspace locations via `configure_workspace_locations` after shutting down `ConfigurationStore`.
- Update CLI README examples (`README.md` / `README.zh-CN.md`) and integration tests (`maka acp --root` `session/new` plus redacted rejection cases).

Refs #6667 and #6805.

Generated-by: Google Antigravity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/L Under 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants