openpencil/crates
Fini ec8df2c05d refactor(host): orchestrator uses chat-panel agent, drop Anthropic-key dependency
User pointed out: the desktop chat panel already has 5 CLI agents
(Claude Code / Codex / OpenCode / Copilot / Gemini) that manage their
own auth — Claude Code is logged in by the user, Copilot rides GitHub
auth, Gemini rides gcloud. The #27 intent-gate landing required a
separate `OPENPENCIL_ANTHROPIC_API_KEY` env var to launch the
orchestrator, which broke UX consistency and was a real design defect:
the existing CLI agents already provide LLM access, the orchestrator
should reuse them instead of requiring users to wire up a parallel
direct-API key.

Root cause was a trait mismatch: `Orchestrator` needs an
`LlmClient` impl, and `DesktopLlmClient` (now deleted) was written to
take `Arc<dyn agent::Provider>` — but `agent::Provider` is only
implemented by `AnthropicProvider` / `OpenAiCompatProvider`, NOT the
CLI-backed `ChatProvider`s (`ClaudeCodeProvider` etc).

Fix is a thin `ChatProvider → LlmClient` adapter:

- New `chat_provider_llm::ChatProviderLlmClient` (~80 lines): owns
  an `Arc<dyn ChatProvider>`, each `LlmClient::call` spawns a thread
  that drains the provider's blocking iterator into a futures mpsc
  channel and returns the receive half as a `BoxStream`. Same
  async↔sync bridge `BlockingRecvIter` uses in the opposite
  direction.
- `DesignSession::start` now generic over `L: LlmClient + Send +
  'static` instead of taking `Arc<dyn Provider>` + default_model;
  caller picks the LlmClient impl. Test e2e path
  (`from_channels`) unaffected.
- `chat_session::launch_if_pending`: Design branch reads
  `chat_selected_agent`, wraps the existing `provider_for_agent`
  output in `ChatProviderLlmClient`, hands it to `DesignSession`.
  Unwired agents (Codex / OpenCode) fall through to the chat-path
  unwired-agent error bubble — same UX as a chat send to an
  unwired agent.

Deletions:

- `chat_orchestrator.rs` — `DesktopLlmClient` was its last
  surviving content; with the new adapter no caller needs it.
  Removed the file + the `mod chat_orchestrator;` line.
- `chat_session::provider_for_design` and the
  `OPENPENCIL_ANTHROPIC_API_KEY` / `ANTHROPIC_API_KEY` /
  `OPENPENCIL_ORCHESTRATOR_MODEL` env reads.
- `op-host-desktop/Cargo.toml` `agent` crate's `["anthropic"]`
  feature — no path inside the host needs an `agent::Provider`
  impl anymore (the trait stays imported for the
  `BuiltInProvider` shim in `chat_runtime.rs`, future-facing).

`op-smoke` keeps `AnthropicProvider` + `OpenAiCompatProvider`
directly because the smoke deliberately bypasses any CLI auth path
to validate the orchestrator against a raw API endpoint
independently of the host UI.

cargo test -p op-host-desktop 106 passed (unchanged). cargo fmt
--all -- --check + cargo clippy --workspace --all-targets -- -D
warnings clean.
2026-05-24 20:41:36 +08:00
..
op-acp style: clear clippy lints for the workspace -D warnings gate 2026-05-17 23:12:16 +08:00
op-ai feat(ai): chat image attachments + per-provider thinking/effort 2026-05-17 22:44:28 +08:00
op-ai-skills style: clear clippy lints for the workspace -D warnings gate 2026-05-17 23:12:16 +08:00
op-app refactor(rust): add op-app composition-root crate 2026-05-16 23:57:03 +08:00
op-cli feat: close six TS-parity gaps in the Rust shell 2026-05-17 13:03:11 +08:00
op-codegen feat(editor): add Design-MD panel and complete i18n coverage 2026-05-19 22:29:22 +08:00
op-design-lint Merge branch 'v0.8.0-new' of github.com:ZSeven-W/openpencil into v0.8.0-new 2026-05-24 13:03:26 +08:00
op-editor-core fix(editor): improve shape controls and drag snapping 2026-05-24 19:03:11 +08:00
op-editor-ui fix(editor): improve shape controls and drag snapping 2026-05-24 19:03:11 +08:00
op-figma feat(editor): add Design-MD panel and complete i18n coverage 2026-05-19 22:29:22 +08:00
op-git Merge branch 's3a-orchestrator' into v0.8.0-new 2026-05-23 01:27:30 +08:00
op-host-desktop refactor(host): orchestrator uses chat-panel agent, drop Anthropic-key dependency 2026-05-24 20:41:36 +08:00
op-host-native fix(editor): improve shape controls and drag snapping 2026-05-24 19:03:11 +08:00
op-host-web fix(panels): keep image fill popover interactive 2026-05-24 14:01:39 +08:00
op-i18n Merge branch 's3a-orchestrator' into v0.8.0-new 2026-05-23 01:27:30 +08:00
op-mcp fix(editor): wire rust ui interactions 2026-05-24 12:57:32 +08:00
op-opmerge Merge branch 's3a-orchestrator' into v0.8.0-new 2026-05-23 01:27:30 +08:00
op-orchestrator refactor(ai): drop dead node_base_role helper in validation_fixes_apply 2026-05-24 16:41:36 +08:00
op-pen-loader fix(editor): improve shape controls and drag snapping 2026-05-24 19:03:11 +08:00
op-smoke refactor(host): orchestrator uses chat-panel agent, drop Anthropic-key dependency 2026-05-24 20:41:36 +08:00
wasm-libc-shim fix: clear clippy -D warnings across the workspace 2026-05-17 01:26:29 +08:00
CLAUDE.md docs: fix stale i18n + renderer paths flagged by Codex review 2026-05-16 15:45:54 +08:00