Skip to content

feat(chat): Claude Code as local chat provider#2767

Open
vibegui wants to merge 1 commit intomainfrom
feat/claude-code-chat
Open

feat(chat): Claude Code as local chat provider#2767
vibegui wants to merge 1 commit intomainfrom
feat/claude-code-chat

Conversation

@vibegui
Copy link
Contributor

@vibegui vibegui commented Mar 19, 2026

Summary

  • Adds Claude Code (Claude Agent SDK) as a first-class chat model provider in Decopilot
  • Auto-wires MCP tools via ephemeral API keys (created per session, revoked after completion)
  • Supports vision (image analysis), reasoning blocks (inline), and plan mode (tool-free planning)
  • Maps three model variants: Opus (1M context), Sonnet (1M context), Haiku (200k context)
  • Enhanced system prompt with comprehensive tool reference (shared-prompts.ts)
  • Chat store improvements: planMode state, resumeStream message seeding, transport URL fix

Files Changed

  • apps/mesh/src/api/routes/decopilot/claude-code-provider.tsNEW SDK adapter (1,274 lines)
  • apps/mesh/src/api/routes/decopilot/stream-core.ts — Claude Code branch with ephemeral API key lifecycle
  • apps/mesh/src/api/routes/decopilot/schemas.ts — Add claude-code provider + planMode
  • apps/mesh/src/api/routes/decopilot/routes.ts — Skip model permissions for Claude Code
  • apps/mesh/src/api/routes/decopilot/constants.ts — Enhanced system prompt
  • apps/mesh/src/api/routes/decopilot/types.ts — Connection auth + prompt suggestion data parts
  • apps/mesh/src/tools/shared-prompts.tsNEW shared tool reference prompt
  • apps/mesh/src/web/components/chat/store/ — planMode state + transport fixes
  • apps/mesh/src/web/components/chat/select-model.tsx — Claude Code tier mappings
  • apps/mesh/src/web/components/chat/types.ts — planMode metadata field

Test plan

  • Install deps: bun install
  • Start dev server: bun run dev
  • Select "Claude Code" model in chat model selector
  • Send a message — verify response streams via Claude Agent SDK
  • Verify tool calls work (ephemeral API key auto-wires MCP)
  • Test plan mode toggle (if UI available)
  • Verify bun run lint and bun run check pass (no new errors)

🤖 Generated with Claude Code


Summary by cubic

Adds Claude Code as a local chat provider using @anthropic-ai/claude-agent-sdk. Streams text, reasoning, tools, and vision into chat with per-session MCP auto-wiring and an optional plan mode.

  • New Features

    • New provider with model IDs claude-code:opus, claude-code:sonnet, claude-code:haiku; mapped to tiers; uses local auth and skips model permission checks.
    • Ephemeral API key auto-wires Mesh MCP over HTTP per session and is revoked after; streams tool inputs/results, prompt suggestions, subtask updates, and tool latency; persists streamed tool parts for accurate history.
    • Vision reads images from the last user message.
    • Plan mode flows from UI to backend; toggles Claude Code between planning (plan) and execution (bypassPermissions).
    • System prompt is enriched with server agent instructions for consistent tool guidance.
    • Records LLM usage and cost; simple thread title is derived from the user prompt.
  • Bug Fixes

    • Fixed chat reconnect by seeding existing messages before resume and correcting the transport URL.

Written for commit 043219c. Summary will update on new commits.

@github-actions
Copy link
Contributor

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

Release Options

Should a new version be published when this PR is merged?

React with an emoji to vote on the release type:

Reaction Type Next Version
👍 Prerelease 2.181.4-alpha.1
🎉 Patch 2.181.4
❤️ Minor 2.182.0
🚀 Major 3.0.0

Current version: 2.181.3

Deployment

  • Deploy to production (triggers ArgoCD sync after Docker image is published)

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 12 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/mesh/src/api/routes/decopilot/stream-core.ts">

<violation number="1" location="apps/mesh/src/api/routes/decopilot/stream-core.ts:360">
P2: Tool execution metrics are recorded with `durationMs: 0`, which provides no meaningful timing data for monitoring dashboards. The `claude-code-provider.ts` tracks tool timing internally but doesn't expose it. Consider either passing actual durations through `ccResult.parts` or recording metrics at the actual call site in the provider.

(Based on your team's feedback about recording tool execution metrics at the call site with actual timing.) [FEEDBACK_USED]</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@vibegui vibegui force-pushed the feat/claude-code-chat branch 2 times, most recently from e7ce030 to 2ea1fb1 Compare March 20, 2026 00:44
Integrate the Claude Agent SDK as a first-class chat model provider in
Decopilot. When "claude-code" is selected, the system creates an ephemeral
API key to auto-wire MCP tools, streams responses through the Claude SDK,
and revokes the key after completion.

Changes:
- New claude-code-provider.ts: SDK adapter converting to AI SDK stream format
  (text, reasoning, tool calls, vision, subtasks)
- stream-core.ts: Claude Code branch with ephemeral API key lifecycle
- schemas.ts: Add "claude-code" provider and planMode option
- constants.ts: Enhanced system prompt with shared tool reference
- Chat store: planMode state, resumeStream seeding, transport URL fix
- Model selector: Claude Code model tier mappings (opus/sonnet/haiku)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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