Skip to content
Source
Sign inSign up
TanStack/ai

feat(ai-code-mode, ai-harness): code mode for harnesses with pluggable isolates #1524

ClosedAlemTuzlakwants to merge 7 commits intofeat/harness-p7-connectors-media fromfeat/harness-p8-code-modeopened View on GitHub

AlemTuzlakcommented

Add 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

  • codeMode at @tanstack/ai-code-mode/harness: a harness plugin. driver takes any @tanstack/ai-isolate-* driver. The other createCodeMode options pass through.
  • Which tools move: tools with execute that do not set needsApproval and that the permission rules allow in plan mode (file reads, read-only MCP tools). include picks 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-search are not JavaScript identifiers. The plugin gives code mode a copy named notion_search. If two names clash, the second tool stays a direct tool.
  • prepareTools plugin hook in @tanstack/ai-harness: change the tool list of each turn, after discoverTools and before prompts resolve.
  • PermissionRules and decidePermission are also exported from the @tanstack/ai-harness root, because ./plugins is Node only and code mode stays edge-safe.
  • examples/harness-cli turns 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 behind execute_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, oxlint on the changed files.
  • Skipped the full pnpm test:pr because 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)

  1. Do steps 1 and 2 of the Phase 7 manual test (build, .env, /connect linear, /connect notion).
  2. Ask: in one execute_typescript program, list my Linear issues and search Notion for "Teams CLI", then summarize.
  3. Result on my run: one program ran in QuickJS in 1.5 seconds, called external_linear_list_issues and external_notion_notion_search, and the answer used both results.

How this PR makes testing easy

  • packages/ai-code-mode/tests/harness.test.ts and packages/ai-harness/tests/prepare-tools.test.ts.
  • examples/harness-cli runs 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

https://claude.ai/code/session_01APYv1qshKyjPPpkFyRZhfZ

    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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.yaml is excluded by !**/pnpm-lock.yaml
      📒 Files selected for processing (17)
      • .changeset/harness-p8-code-mode.md
      • docs/config.json
      • docs/harness/code-mode.md
      • docs/harness/dashboard.md
      • docs/harness/deploy.md
      • docs/harness/subagents.md
      • examples/harness-cli/README.md
      • examples/harness-cli/package.json
      • examples/harness-cli/src/harness.ts
      • packages/ai-code-mode/package.json
      • packages/ai-code-mode/src/harness.ts
      • packages/ai-code-mode/tests/harness.test.ts
      • packages/ai-code-mode/vite.config.ts
      • packages/ai-harness/src/index.ts
      • packages/ai-harness/src/plugins.ts
      • packages/ai-harness/src/session.ts
      • packages/ai-harness/tests/prepare-tools.test.ts

      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.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 17f92ef93d9d6c7cc974e362d20be7baddb71a5d

      CommandStatusDurationResult
      nx run-many --targets=build --exclude=examples/...✅ Succeeded3sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-09-28 15:58:35 UTC

    3. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented

      Open in StackBlitz

      @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@1524

      commit: 17f92ef

    4. github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer

    5. AlemTuzlakcommented

      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.

    6. AlemTuzlak closed this

Sign in to join this conversation.