feat(ai-code-mode, ai-harness): code mode for harnesses with pluggable isolates #1524
feat/harness-p7-connectors-media fromfeat/harness-p8-code-mode·opened View on GitHubAdd codeMode({ driver }) to a harness, and the model gets one execute_typescript tool. It writes one TypeScript program that calls several tools, and the program runs in the isolate you pick: QuickJS, Node, Cloudflare, or Daytona. Read-only tools move into code mode, including MCP tools found after /connect. Tools that need approval stay normal tool calls.
Stacked on #1523 (Phase 7) → #1522 → #1521 → #1520 → #1519 → #1518 → #1515 → #1513 → #1509. Merge those first.
🎯 Changes#
codeModeat@tanstack/ai-code-mode/harness: a harness plugin.drivertakes any@tanstack/ai-isolate-*driver. The othercreateCodeModeoptions pass through.- Which tools move: tools with
executethat do not setneedsApprovaland that the permission rules allow in plan mode (file reads, read-only MCP tools).includepicks the tools yourself. A call inside the isolate does not stop for approval, so edits and commands stay out. - Safe names: MCP tool names like
notion-searchare not JavaScript identifiers. The plugin gives code mode a copy namednotion_search. If two names clash, the second tool stays a direct tool. prepareToolsplugin hook in@tanstack/ai-harness: change the tool list of each turn, afterdiscoverToolsand before prompts resolve.PermissionRulesanddecidePermissionare also exported from the@tanstack/ai-harnessroot, because./pluginsis Node only and code mode stays edge-safe.examples/harness-cliturns on code mode with the QuickJS driver.- Docs:
docs/harness/code-mode.md(new). Changeset: ai-code-mode, ai-harness (minor).
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with
pnpm run test:pr, or these tests do not apply to this pull request. - I fully understand the code in this pull request, including any code generated with AI assistance.
- Docs: I updated
docs/for this change, or this change is not user-facing. - Changeset: I added a changeset (
pnpm changeset), or this PR does not change a published package.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Testing#
Commands run (not the full pnpm test:pr, see below):
@tanstack/ai-code-mode:vitest run(153 passed),test:types,publint --strict. New:tests/harness.test.ts(tools move behindexecute_typescript, discovered MCP tools included, approvals and edits kept,include, no match, safe names and clashes).@tanstack/ai-harness:vitest run(147 passed),test:types. New:tests/prepare-tools.test.ts.examples/harness-cli:tsc --noEmit.kiira check docs/harness/code-mode.md,oxfmt,oxlinton the changed files.- Skipped the full
pnpm test:prbecause it is slow on this machine. CI runs it. No new E2E test: the tests use a stand-in isolate, and the manual run below used the real QuickJS driver.
Manual test (done with real accounts)
- Do steps 1 and 2 of the Phase 7 manual test (build,
.env,/connect linear,/connect notion). - Ask:
in one execute_typescript program, list my Linear issues and search Notion for "Teams CLI", then summarize. - Result on my run: one program ran in QuickJS in 1.5 seconds, called
external_linear_list_issuesandexternal_notion_notion_search, and the answer used both results.
How this PR makes testing easy
packages/ai-code-mode/tests/harness.test.tsandpackages/ai-harness/tests/prepare-tools.test.ts.examples/harness-cliruns code mode with the QuickJS driver.
Risk / rollback#
Low. A new subpath and a new plugin hook. Code mode is opt-in. Revert the PR to undo.
Public API change#
Before
defineHarness({ name: 'acme/assistant', adapter, plugins: () => [linear] })
After
import { codeMode } from '@tanstack/ai-code-mode/harness'
import { createQuickJSIsolateDriver } from '@tanstack/ai-isolate-quickjs'
defineHarness({
name: 'acme/assistant',
adapter,
plugins: () => [linear, codeMode({ driver: createQuickJSIsolateDriver() })],
})
🤖 Generated with Claude Code
- 1
View your CI Pipeline Execution ↗ for commit 17f92ef93d9d6c7cc974e362d20be7baddb71a5d
Command Status Duration Result nx run-many --targets=build --exclude=examples/...✅ Succeeded 3s View ↗
☁️ Nx Cloud last updated this comment at
2026-09-28 15:58:35UTC@tanstack/ai
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai@1524@tanstack/ai-acp
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-acp@1524@tanstack/ai-angular
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-angular@1524@tanstack/ai-anthropic
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-anthropic@1524@tanstack/ai-bedrock
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-bedrock@1524@tanstack/ai-byteplus
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-byteplus@1524@tanstack/ai-claude-code
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-claude-code@1524@tanstack/ai-client
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-client@1524@tanstack/ai-cloudflare
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cloudflare@1524@tanstack/ai-code-mode
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode@1524@tanstack/ai-code-mode-snippets
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode-snippets@1524@tanstack/ai-codex
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-codex@1524@tanstack/ai-cohere
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cohere@1524@tanstack/ai-compaction
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-compaction@1524@tanstack/ai-dashboard
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-dashboard@1524@tanstack/ai-devtools-core
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-devtools-core@1524@tanstack/ai-durable-stream
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-durable-stream@1524@tanstack/ai-elevenlabs
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-elevenlabs@1524@tanstack/ai-event-client
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-event-client@1524@tanstack/ai-fal
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-fal@1524@tanstack/ai-gemini
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-gemini@1524@tanstack/ai-grok
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok@1524@tanstack/ai-grok-build
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok-build@1524@tanstack/ai-groq
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-groq@1524@tanstack/ai-harness
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-harness@1524@tanstack/ai-harness-cli
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-harness-cli@1524@tanstack/ai-isolate-cloudflare
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-cloudflare@1524@tanstack/ai-isolate-daytona
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-daytona@1524@tanstack/ai-isolate-node
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-node@1524@tanstack/ai-isolate-quickjs
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs@1524@tanstack/ai-isolate-quickjs-bun
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs-bun@1524@tanstack/ai-llmgateway
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-llmgateway@1524@tanstack/ai-lovable
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-lovable@1524@tanstack/ai-mcp
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mcp@1524@tanstack/ai-memory
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-memory@1524@tanstack/ai-mistral
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mistral@1524@tanstack/ai-octane
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-octane@1524@tanstack/ai-ollama
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollama@1524@tanstack/ai-openai
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openai@1524@tanstack/ai-opencode
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-opencode@1524@tanstack/ai-openrouter
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openrouter@1524@tanstack/ai-perplexity
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-perplexity@1524@tanstack/ai-persistence
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-persistence@1524@tanstack/ai-preact
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-preact@1524@tanstack/ai-react
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react@1524@tanstack/ai-react-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react-ui@1524@tanstack/ai-reactor
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-reactor@1524@tanstack/ai-remix
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-remix@1524@tanstack/ai-sandbox
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox@1524@tanstack/ai-sandbox-blaxel
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-blaxel@1524@tanstack/ai-sandbox-boxd
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-boxd@1524@tanstack/ai-sandbox-cloudflare
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-cloudflare@1524@tanstack/ai-sandbox-daytona
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-daytona@1524@tanstack/ai-sandbox-docker
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-docker@1524@tanstack/ai-sandbox-e2b
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-e2b@1524@tanstack/ai-sandbox-local-process
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-local-process@1524@tanstack/ai-sandbox-sprites
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-sprites@1524@tanstack/ai-sandbox-upstash-box
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-upstash-box@1524@tanstack/ai-sandbox-vercel
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-vercel@1524@tanstack/ai-skills
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-skills@1524@tanstack/ai-solid
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid@1524@tanstack/ai-solid-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid-ui@1524@tanstack/ai-svelte
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-svelte@1524@tanstack/ai-typesafe
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-typesafe@1524@tanstack/ai-utils
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-utils@1524@tanstack/ai-vercel-gateway
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vercel-gateway@1524@tanstack/ai-vertex
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vertex@1524@tanstack/ai-vue
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue@1524@tanstack/ai-vue-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue-ui@1524@tanstack/ai-worldlabs
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-worldlabs@1524@tanstack/openai-base
npm i https://pkg.pr.new/TanStack/ai/@tanstack/openai-base@1524@tanstack/preact-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/preact-ai-devtools@1524@tanstack/react-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/react-ai-devtools@1524@tanstack/solid-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/solid-ai-devtools@1524@tanstack/svelte-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/svelte-ai-devtools@1524commit:
17f92efgithub-actions[bot](GitHub profile, opens in a new tab) assignedtombeckenham
github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer
Closed in favor of the combined PR #1555, which holds this phase and every other phase of the harness (P0 to P14) on one branch against main. All further fixes go there. This PR stays as the review record of P8.
AlemTuzlak closed this
Sign in to join this conversation.
Warning
Review limit reached#
Next included review available in 7 minutes.
Check out review usage here.
View limit details
Limit details: You’ve used all 8 included reviews currently available.
You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.
Learn how review limits work.
Review configuration:
⚙️ Run configuration
Configuration used: Repository: TanStack/ai/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
9af58de2-e785-461f-922f-acb78f4e5e9a📥 Commits
Reviewing files that changed from the base of the PR and between 1f24e283faf3b19fd47ec2b63ae4439fd1f00d9f and 17f92ef93d9d6c7cc974e362d20be7baddb71a5d.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml📒 Files selected for processing (17)
.changeset/harness-p8-code-mode.mddocs/config.jsondocs/harness/code-mode.mddocs/harness/dashboard.mddocs/harness/deploy.mddocs/harness/subagents.mdexamples/harness-cli/README.mdexamples/harness-cli/package.jsonexamples/harness-cli/src/harness.tspackages/ai-code-mode/package.jsonpackages/ai-code-mode/src/harness.tspackages/ai-code-mode/tests/harness.test.tspackages/ai-code-mode/vite.config.tspackages/ai-harness/src/index.tspackages/ai-harness/src/plugins.tspackages/ai-harness/src/session.tspackages/ai-harness/tests/prepare-tools.test.tsThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share