feat: engine resolution — claude code → codex → openrouter (harness runtime)#1
Merged
Conversation
…ment and editing capabilities with project structure visibility
…de editing and preview capabilities; remove unnecessary components and integrate custom styles for improved UI
…ack functionality for real-time file operations; update project structure handling and improve initialization logic
- Updated chat API to accept files and file instructions in the request. - Introduced new client-side tools for file writing and command execution. - Added attemptCompletion tool to summarize task completion. - Improved system prompt to include current project files and organization guidelines. - Refactored right panel to expose Sandpack API for file operations. - Adjusted UI components for better spacing and layout. - Enhanced Sandpack editor and file explorer for improved usability. - Updated project template with a more structured React setup and Tailwind CSS integration. - Removed unused server-side tool definitions and related code.
…ve executeCommand functionality and integrate client-side tools
…untime) Add lib/engine/ (resolve + harness + local sandbox, ported from kobe) so the chat route auto-detects a locally logged-in claude/codex CLI and drives it via @ai-sdk/harness rooted at the project directory, falling back to OpenRouter. Upgrades ai to ^7 (@ai-sdk/react ^4, @ai-sdk/openai ^4 replacing the ai@6-only openrouter provider) and fixes pre-existing HEAD build breaks (missing streamdown dep, orphaned tool-definition type imports, removed setUrl).
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.
What changed
codefox-local no longer hardcodes OpenRouter. A new
lib/engine/layer resolves which AI engine backs the app, per process:claudeCLI on PATH + logged in (oauthAccountin~/.claude.json). Default when present; uses the local subscription login, no API key.codexCLI on PATH +~/.codex/auth.jsoncredentials.OPENROUTER_API_KEY.Override with
CODEFOX_ENGINE=claude|codex|openrouter. No engine available → clear error.lib/engine/resolve.ts— detection + per-process cache.lib/engine/local-sandbox.ts— harness sandbox provider that runs on this machine, rooted at the project dir (ported from kobe).lib/engine/harness.ts— oneHarnessAgentruntime per (vendor, project dir), stateful session per project, returns the turn as a UIMessage stream Response (same wire format as the streamText path, so theuseChatclient is engine-agnostic). Runtimes are stashed onglobalThisto survive dev HMR;serverExternalPackageskeeps the harness bridge unbundled.app/api/chat/route.ts— resolves the engine per request. Harness path sends only the newest user message (the session is stateful) and passes no client tools — the runtime owns its own coding tools and edits the project files directly. OpenRouter path is unchanged..env.example— supported-engines list, resolution order, env vars.Smoke-tested live:
claudeengine streamed a two-turn stateful conversation throughPOST /api/chatundernext dev.ai@7 upgrade
The harness packages require
ai^7, so:ai^5 → ^7,@ai-sdk/react^2 → ^4, and@openrouter/ai-sdk-provider(peers ai ^6, incompatible) replaced by@ai-sdk/openai^4 withbaseURL: https://openrouter.ai/api/v1(chat/title routes). App-code breaks were mechanical:convertToModelMessagesis now async;isToolOrDynamicToolUIPart→isToolUIPart.Pre-existing build fixes
HEAD did not build (
next buildfails before this PR): missingstreamdowndependency, three tool renderers importing types removed fromlib/tool-definitions, andlib/client-tools.tscalling a removedRightPanelRef.setUrl. Fixed minimally (added the dep, inlined the types locally, dropped the deadsetPreviewUrlhelper) to get the build gate green.Notes
~/.codefox-local/projects/<id>directly; the Sandpack panel won't see those edits until it re-reads files (clientwriteFiletool only fires on the OpenRouter path). Follow-up if live-sync matters.app/api/chat/route.tshas uncommitted WIP in a local checkout that may conflict on merge.