Skip to content

feat(assistant): subscription-auth Claude Code via local CLI + MCP bridge#8

Merged
juacker merged 2 commits into
mainfrom
feat/cli-support
May 21, 2026
Merged

feat(assistant): subscription-auth Claude Code via local CLI + MCP bridge#8
juacker merged 2 commits into
mainfrom
feat/cli-support

Conversation

@juacker
Copy link
Copy Markdown
Owner

@juacker juacker commented May 21, 2026

Summary

  • Add a parallel agent runtime for CLI-backed providers (Claude Code first; Codex/OpenCode registered as stubs) so users can drive agents through their existing vendor subscriptions instead of paying per-token API access.
  • CLAI hosts an in-process MCP server that exposes the existing tool registry (fs_*, bash_exec, inter-agent calls, workspace tasks) to the CLI; the CLI's built-in tools are disabled, leaving CLAI's permission gates (workspace_permissions, command_splitter, path grants) as the single source of truth.
  • Settings UI gains a CLI branch: no API key field, model <select> populated from the descriptor, "CLI binary path" relabel, auth-flow hint. Agent picker shows a "via CLI" badge so subscription-backed connections are distinguishable from API ones.
  • Design rationale and rollout plan in docs/CLI_AGENT_INTEGRATION_RFC.md.

What's working end-to-end now

  • Claude Code: streaming text + thinking, MCP tool calls visible in the timeline, --session-id on the first turn / --resume <id> on follow-ups, stderr-tail in failure messages, orphan-session recovery when --resume reports "no conversation found", --permission-mode bypassPermissions so MCP tools aren't blocked by Claude's headless approval layer.

What's stubbed (deferred)

  • Codex and OpenCode drivers (providers register but the runtime returns "not implemented yet"). Codex is the next planned addition; OpenCode after that. Long-lived process refactor is deferred because per-turn latency was acceptable in testing.

Test plan

  • cargo fmt + cargo clippy --lib -- -D warnings (pre-push hook) clean
  • cargo test --lib — 301 pass, 1 ignored
  • npm run build + ESLint on touched JS files
  • Manual: create Claude Code connection through Settings → AI Provider → Add Connection; verify the form hides the API key, shows the model select, accepts subscription_login
  • Manual: Test button runs claude auth status --json and reports loggedIn state
  • Manual: assign connection to an agent, send a message, see streaming text and tool calls in the timeline
  • Manual: verify multi-turn works (--session-id first, --resume after)
  • Manual: verify fs_write lands in the agent workspace and shows up in the timeline (--permission-mode bypassPermissions fix)
  • Manual: Codex / OpenCode UI shows "not implemented yet" path when selected (driver code lands in a follow-up)

juacker added 2 commits May 21, 2026 18:23
…idge

Add a parallel agent runtime for CLI-backed providers (Claude Code first;
Codex/OpenCode registered as stubs) so users can drive agents through their
existing vendor subscriptions instead of paying for API access. CLAI hosts
an in-process MCP server that exposes its own tool registry (fs_*, bash_exec,
inter-agent, workspace tasks) to the CLI; the CLI's built-in tools are
disabled, keeping CLAI's permission gates as the single source of truth.

- providers/cli.rs: claude-code/codex/opencode descriptors with
  SubscriptionLogin auth mode and static model lists
- local_mcp.rs: rmcp streamable-http server bound to 127.0.0.1, per-session
  bearer-token bindings carrying run_id/cancel/notices into tools::router
- local_agent.rs: Claude Code driver — stream-json parser, --session-id on
  first turn / --resume after, --permission-mode bypassPermissions so MCP
  tools aren't blocked by Claude's headless approval layer, stderr-tail
  enrichment on failures, orphan-session recovery when --resume reports
  "no conversation found"
- engine.rs: route CLI providers to the new runtime
- commands/provider_connections.rs: subscription-login create path,
  provider_descriptor_models command for static CLI model lists, CLI
  test-connection probe (`claude auth status --json`)
- types.rs / context plumbing: cli_session_id persisted on session context
- AssistantProviderSettings.jsx: CLI branch (no API key, auth hint, model
  select, "CLI binary path" relabel)
- AgentFormModal.jsx: "via CLI" badges so users can tell subscription
  connections apart from API ones
- docs/CLI_AGENT_INTEGRATION_RFC.md: design doc covering the architecture,
  per-CLI specifics, risks, and phased rollout
Scheduled-run trigger messages start with `--- New scheduled run at ... ---`
which Claude Code's argv parser treats as an unknown long option, breaking
every scheduled CLI run. Stop passing the prompt as a positional arg and
pipe it via stdin instead — the parser never sees the content. Also
forward-compatible with the long-lived `--input-format stream-json` mode
we may add later.
@juacker juacker merged commit d7bc61d into main May 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant