Repository navigation
Conversation
Port upstream opencode PR 58782 ("feat(core): add Claude Agent provider") to the
shipped runtime. Claude models run through the user's own Claude Code login via
`@anthropic-ai/claude-agent-sdk`, so a Claude Pro/Max subscription covers usage.
The CLI never reads or stores the Claude Code token.
- Copy upstream's process, sync, tools and language-model modules into
`src/altimate/provider/claude-agent/` with import paths adjusted, and their
replay tests and recordings into `test/altimate/provider/claude-agent/`
- Replace upstream's core plugin-context wiring with Altimate-owned modules:
per-instance session registry and AI SDK factory (`index.ts`), saved model
list and login-based pricing (`catalog.ts`), JSON storage (`storage.ts`), and
an internal plugin for the `/connect` login check and idle release (`plugin.ts`)
- Marked hooks in `provider.ts` (bundled factory, provider entry, `haiku` small
model), `transform.ts` (effort variants), `llm.ts` (request kind and session
headers, agent role and instructions, no default output cap), `plugin/index.ts`
and the TUI provider list
- Emit `tool-input-start/delta/end` before each `tool-call`, because the session
processor drops a tool call no `tool-input-start` opened
- Build the MCP tool server on the bundled `@modelcontextprotocol/sdk` 1.x
- Add `@anthropic-ai/claude-agent-sdk@0.3.301` and document the provider
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
…per-project state - Implement `doGenerate` by collecting the streamed reply, so `generateObject` and `generateText` callers (`agent create`, learning reflection) work; JSON requests are asked for in the prompt and a markdown fence is removed - Flag stopped Claude Agent tool calls with `toolAborted` in `message-v2.ts` history conversion, so the waiting Claude turn is interrupted as upstream does - Keep connection settings, login status and the session registry per project, so one project's config or open instance no longer affects another's - Drop only the default output cap before `chat.params`, so a plugin's explicit `maxOutputTokens` still applies Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
full receipts (1 session)
codex ·
|
`authorize()` ran the full Claude Code probe, including context-window discovery for every model, before returning, so `/connect` sat on the previous dialog for about 9 seconds and then jumped to the model list. It now returns at once, the dialog shows its waiting screen, and the check (with retries) runs in the callback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue for this PR
No issue. Ports upstream opencode PR 58782, "feat(core): add Claude Agent provider".
Type of change
What does this PR do?
Lets a user chat with Claude models on their Claude Pro/Max subscription. The CLI starts the user's installed
claudethrough Anthropic's Claude Agent SDK, so the login stays with Claude Code. The CLI never reads or stores its token. Setup isclaude auth login, then/connect→ Claude Agent.The existing
opencode-anthropic-authplugin sends subscription OAuth tokens straight to the Anthropic API, which Anthropic now restricts for third-party apps. Upstream replaced that approach with this provider.Why this is a port, not a cherry-pick. Upstream built the provider in
packages/coreon its v2 plugin context (ctx.provider,ctx.aisdk.hook,ctx.session.hook). Our shipped CLI does not run that runtime: providers resolve inprovider/provider.tsand requests are built insession/llm.ts.src/altimate/provider/claude-agent/{claude,sync,tools,language-model}/are upstream's modules, copied with import paths adjusted. They manage theclaudeprocess, keep the CLI's history in sync with Claude's saved session, and hold Claude's tool calls until the CLI runs them.index.ts,catalog.ts,storage.tsandplugin.tsreplace upstream's plugin-context wiring.provider.ts,transform.ts,llm.ts,plugin/index.tsand the TUI provider list connect it.README.mdlists every difference from upstream for the next bridge merge.Behaviour. Claude uses Altimate's tools, permissions, agent prompt, skills and
AGENTS.md. Claude Code's own tools, settings files,CLAUDE.md, hooks, MCP servers, memory and auto compaction are turned off. The per-turn environment block is not sent, because upstream found that forwarding it made subscriptions reject chats as a third-party app. A subscription shows $0 cost; an API key or cloud login is priced from that provider's catalog.One fix on top of upstream. Our session processor only records a tool call whose part a
tool-input-startopened. Upstream sends a baretool-call, so the first live chat looped on empty steps. The stream converter now emitstool-input-start/delta/endbefore each call.Known gaps, documented in the README:
headerTimeoutandchunkTimeoutnever reach Claude Code, because the provider loader removes them first.Dependency.
@anthropic-ai/claude-agent-sdk@0.3.301, upstream's version. Installing it also downloads a ~270 MB per-platform copy ofclaudethat is never run.How did you verify your code works?
Live runs with a real Claude Max login and
claude2.1.322, in an isolated data directory:/connect→ Claude Agent saved only the marker, not a token. Models listed: Opus 5.5, Fable 5.2, Sonnet 5.5, Haiku 5.5, with effort variants.globand tworeads and answered correctly. The follow-up ransql_analyzeand reused the same Claude session and process. Cost was $0, ~58K prompt tokens came from cache, and Haiku generated the title.altimate run -m claude-agent/haikuand thebuild:localbinary: both answered correctly with tool calls, so the SDK survives bundling.Not covered yet:
claudepaths, and Linux/Windows.Checks:
bun turbo typecheckpasses.integration.test.ts.packages/opencodemain pass: 20,934 pass, 6 fail. The 6 failures (mcp.headersandmcp HttpApi) fail the same way on a clean checkout ofmainon this machine.Codex review fixes (second commit):
agent createwith a Claude model ran live and wrote an agent file.maxOutputTokensis kept.review-fixes.test.ts. After these fixes, I re-ran the Claude Agent tests and the message-conversion suite, not the full suite.Cost side effects
None that grow with user data. Each chat runs on the user's own Claude login. The
/connectlogin check startsclaudewithout sending a prompt, so it uses no tokens.Screenshots / recordings
Not included yet.
Checklist
🤖 Generated with Claude Code