feat(ai-harness): first-party plugins in @tanstack/ai-harness/plugins: permissions, agent profiles, questions, todos, titles, and usage #1759
feat/harness-core fromrefs/pull/1759/head·merged by AlemTuzlak View on GitHubWith this PR, a harness gets ready-made plugins from @tanstack/ai-harness/plugins. The main ones are permissions(), which asks before risky tool calls, and agents(), which gives the harness a plan and a build agent and your own agent profiles. The others are question(), todos(), title(), modelPicker(), projectInstructions(), fileCommands(), compact(), usage(), and boundToolOutput().
This PR targets the core harness PR #1755 (feat/harness-core), not main. It is split out of #1555. The goal, provider keys, and code mode PRs stack on this branch.
🎯 Changes#
Source (packages/ai-harness):
src/first-party/*: the plugins above, plusglob.ts,workspace-hooks.ts, and theindex.tsof the entry. Ported from #1555 withoutcoding/,goal, andprovider-keys../pluginssubpath export and avite.config.tsentry. No new dependencies.- The package root exports
PermissionRules,PermissionResources,PermissionDecisionCapability, anddecidePermission(and their types) again. See the decision below.
Changes from #1555 (adapted to the core branch and to main):
agents()docs and tests use one tool per subagent, named after the agent.mainhas no singlesubagenttool.- A subagent run of
agents()usescombineStrategies([maxIterations(50), untilFinishReason(['length'])]). Onmain,maxIterations(50)alone retries an answer cut at the output limit. Now the cut answer ends the run, the same as the harness default. projectInstructions()reads the git branch withexecFilefromnode:child_process. #1555 usedhostBackendfromfirst-party/coding, which is not in this PR.usage()docs and JSDoc use your own price table.@tanstack/ai-modelsis not onmain.- A
todo_writecall with a bad status gets the plugin's own error.maindoes not check a plain JSON Schema input, so the #1555 TypeBox error text does not apply (session-plugins.test.ts).
Changes from the code review:
- A saved
alwaysrule is stored once, anddeleteSavedPermissionremoves every copy. /compactwithkeepLastnever keeps a tool result without the call before it.- A question that the session rejects (it closed) refuses the call. A failed save of an
alwaysanswer does not fail the call: the session keeps the answer in memory. - The step-limit note goes into the system prompts once, also when a model call retries.
tools: a, bin an agent Markdown file is a list. Outsideplanmode, a deny saysA permission rule denies this tool.. Saved rules are read only when the rules giveask.isYesis removed (no user in this PR; the coding tools PR adds it back if it needs it).
Changes from the second code review:
/compactthrows and keeps the conversation when the summary model returns empty text. Before, the history was replaced with an empty summary.- The approval question says when it cut the call arguments:
... (131 more characters not shown). A risky part after character 300 is no longer hidden without a sign. - In permission rules and agent
toolspatterns,**/matches whole folders only.src/**/test.tsmatchessrc/test.tsandsrc/a/test.ts, notsrc/mytest.ts.{a,b}now matches one of the parts, so*.{pem,key}works.permissions.mdlists both.
Changes from the #1779 merge (feat/harness-core now takes one object):
agents(),modelPicker(), andpermissions()callctx.session.setConfig({ key, value }).- The tests call
session.setConfig({ key, value })andsession.answer({ questionId, value }). Prompt results in the tests havemedia: []. - The docs use the same object shapes.
- Merge conflicts:
docs/config.jsonkeeps both sides (newupdatedAtfrom #1779 and the two new pages).session-plugins.test.tskeeps the #1779 imports and this branch's first-party imports.
Changes from the #1757 merge (feat/harness-core now has the HTTP transport, the typed client, and the view):
package.jsonexports and thevite.config.tsentries keep./client,./view, and./plugins.docs/config.jsonkeeps all five new pages:permissionsandagentsfrom this PR, andauth,shared-threads, andcustom-uifrom #1757.- The core branch now has
session.onQuestion. The permissions page answers each question with it, with noCUSTOMevent filter and no list of answered ids.
Decisions:
- Permissions re-export. The core branch does not export anything from
first-party/*. This PR adds the four portable permission names back to the root, as #1555 had them. They load no Node module, so an edge-safe plugin (code mode) can read the rules without the Node-only./pluginsentry. The edge-safety test now allows Node imports only infirst-party/files.tsandfirst-party/bound-output.ts. - Tests that need other PRs are left out. The two
workspaceToolscases offirst-party.test.tsand theread_filecase ofinstructions.test.tsgo to the coding tools PR. ThestartLoopbackReceivercases ofdiscover-tools.test.tsgo to the transport PR.expose-inputs.test.tsneeds both this PR and the transport PR (applyInput,createHarnessHandler), so it lands with the later of the two. The URL question case ofquestion.test.tsreads the snapshot instead of a session view. - Restored cases. The core branch removed the first-party cases from
agent-middleware.test.tsandsession-plugins.test.ts, and left outagents.test.tsandinstructions.test.ts. This PR puts them back. - Plan mode and tools with no rule. The review found that a tool with no rule and no
kindstill runs inplanmode. That is the #1555 behavior, and the docs say so under Known limits. Not changed here.
Docs. New pages docs/harness/permissions.md ("Ask before risky tool calls") and docs/harness/agents.md ("Switch between agent profiles"). A usage() section in docs/harness/usage.md, and a link from docs/harness/plugins.md. docs/config.json has the new entries (addedAt 2026-10-13) and updatedAt 2026-10-14 for each changed page. The samples use only the core harness and this entry: no CLI, client, view, or coding tools. Readers: agent builders on @tanstack/ai-harness. Tone: plain second person, short sentences.
Changeset. @tanstack/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. After the #1757 merge, all of these passed:
nx run-many --targets=test:types,test:oxlint --projects=@tanstack/ai-harness.vitest runinpackages/ai-harness: 80 test files, 1134 tests (after the review fixes).pnpm test:docs, andkiira check docs/harness(51 snippets).tsc --noEmitintesting/e2e: no errors in the files of this PR.
Before the #1757 merge, these also passed: nx run-many --targets=test:types --projects='examples/**,testing/**' (27 projects), kiira check docs/harness, pnpm test:knip, and pnpm test:sherif.
Not run: the full pnpm test:pr and the E2E suite. CI runs them.
Manual test.
- Run
pnpm --filter @tanstack/ai-e2e test:e2e --grep "harness first-party". - The
agents()case switches to asteps: 1agent and checks that the last model call hastool_choice: 'none'. - The
permissions()case starts a subagent inplanmode and checks that itswrite_filecall does not run. - The
projectInstructions()andtitle()cases check the environment block and the session title.
How this PR makes testing easy.
- Unit tests in
packages/ai-harness/tests/:permissions,agents,question,title-usage,bound-output,first-party,instructions,discover-tools, plus the restored cases inagent-middlewareandsession-plugins. - E2E:
testing/e2e/tests/harness-first-party.spec.tswith the routeapi.harness-first-party.tsand the fixturefixtures/harness-first-party/basic.json.
Risk / rollback#
Low. The plugins are a new opt-in subpath, and the root gets four new exports. Revert the PR to remove them.
Public API change#
Before: no first-party plugins.
After
import { defineHarness } from '@tanstack/ai-harness'
import { agents, permissions } from '@tanstack/ai-harness/plugins'
defineHarness({
name: 'acme/coder',
adapter,
plugins: () => [
permissions({ root, rules: [{ tool: 'write_file', decision: 'ask', kind: 'edit' }] }),
agents({ adapter: () => adapter }),
],
})
🤖 Generated with Claude Code
- 1
Important
Review skipped#
Auto reviews are disabled on base/target branches other than the default branch.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
-
- Configuration used: Repository: TanStack/ai/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
253ca3ee-3ffd-488a-9787-226920f738b8
You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- 🔍 Trigger review
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Comment `@coderabbitai help` to get the list of available commands.-
View your CI Pipeline Execution ↗ for commit f2f5e247315fc9c4f6563d63d46d20d331771a80
Command Status Duration Result nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded 5m 15s View ↗ nx run-many --targets=test:coverage --projects=...✅ Succeeded 2s View ↗ nx run-many --targets=build --exclude=examples/...✅ Succeeded 43s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-15 11:33:40UTC@tanstack/ai
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai@1759@tanstack/ai-acp
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-acp@1759@tanstack/ai-angular
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-angular@1759@tanstack/ai-anthropic
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-anthropic@1759@tanstack/ai-bedrock
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-bedrock@1759@tanstack/ai-byteplus
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-byteplus@1759@tanstack/ai-claude-code
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-claude-code@1759@tanstack/ai-client
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-client@1759@tanstack/ai-cloudflare
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cloudflare@1759@tanstack/ai-code-mode
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode@1759@tanstack/ai-code-mode-snippets
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode-snippets@1759@tanstack/ai-codex
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-codex@1759@tanstack/ai-cohere
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cohere@1759@tanstack/ai-compaction
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-compaction@1759@tanstack/ai-devtools-core
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-devtools-core@1759@tanstack/ai-durable-stream
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-durable-stream@1759@tanstack/ai-elevenlabs
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-elevenlabs@1759@tanstack/ai-event-client
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-event-client@1759@tanstack/ai-fal
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-fal@1759@tanstack/ai-gemini
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-gemini@1759@tanstack/ai-grok
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok@1759@tanstack/ai-grok-build
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok-build@1759@tanstack/ai-groq
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-groq@1759@tanstack/ai-harness
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-harness@1759@tanstack/ai-isolate-cloudflare
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-cloudflare@1759@tanstack/ai-isolate-daytona
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-daytona@1759@tanstack/ai-isolate-e2b
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-e2b@1759@tanstack/ai-isolate-node
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-node@1759@tanstack/ai-isolate-quickjs
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs@1759@tanstack/ai-isolate-quickjs-bun
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs-bun@1759@tanstack/ai-llmgateway
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-llmgateway@1759@tanstack/ai-lovable
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-lovable@1759@tanstack/ai-mcp
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mcp@1759@tanstack/ai-memory
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-memory@1759@tanstack/ai-mistral
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mistral@1759@tanstack/ai-octane
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-octane@1759@tanstack/ai-ollama
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollama@1759@tanstack/ai-ollaya
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollaya@1759@tanstack/ai-openai
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openai@1759@tanstack/ai-opencode
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-opencode@1759@tanstack/ai-openrouter
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openrouter@1759@tanstack/ai-perplexity
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-perplexity@1759@tanstack/ai-persistence
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-persistence@1759@tanstack/ai-preact
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-preact@1759@tanstack/ai-react
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react@1759@tanstack/ai-react-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react-ui@1759@tanstack/ai-reactor
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-reactor@1759@tanstack/ai-remix
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-remix@1759@tanstack/ai-sandbox
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox@1759@tanstack/ai-sandbox-blaxel
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-blaxel@1759@tanstack/ai-sandbox-boxd
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-boxd@1759@tanstack/ai-sandbox-cloudflare
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-cloudflare@1759@tanstack/ai-sandbox-daytona
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-daytona@1759@tanstack/ai-sandbox-docker
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-docker@1759@tanstack/ai-sandbox-e2b
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-e2b@1759@tanstack/ai-sandbox-local-process
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-local-process@1759@tanstack/ai-sandbox-railway
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-railway@1759@tanstack/ai-sandbox-sprites
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-sprites@1759@tanstack/ai-sandbox-upstash-box
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-upstash-box@1759@tanstack/ai-sandbox-vercel
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-vercel@1759@tanstack/ai-skills
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-skills@1759@tanstack/ai-solid
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid@1759@tanstack/ai-solid-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid-ui@1759@tanstack/ai-svelte
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-svelte@1759@tanstack/ai-typesafe
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-typesafe@1759@tanstack/ai-utils
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-utils@1759@tanstack/ai-vercel-gateway
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vercel-gateway@1759@tanstack/ai-vertex
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vertex@1759@tanstack/ai-vue
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue@1759@tanstack/ai-vue-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue-ui@1759@tanstack/ai-worldlabs
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-worldlabs@1759@tanstack/openai-base
npm i https://pkg.pr.new/TanStack/ai/@tanstack/openai-base@1759@tanstack/preact-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/preact-ai-devtools@1759@tanstack/react-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/react-ai-devtools@1759@tanstack/solid-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/solid-ai-devtools@1759@tanstack/svelte-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/svelte-ai-devtools@1759commit:
743367cCoverage#
✅ Coverage held across 21 compared package(s).
Each package is measured twice in this job — on this PR and on its merge-base with
main— and compared. A metric fails only when it is at or above 60% on the merge-base and under 60% on this PR. Other drops are listed but do not fail. Packages your PR doesn't affect are not measured and not listed.package statements branches functions lines ai-acp 82.32% (0.00) 71.27% (0.00) 77.08% (0.00) 83.97% (0.00) ok ai-claude-code 88.93% (0.00) 76.88% (0.00) 86.88% (0.00) 90.40% (0.00) ok ai-codex 94.55% (0.00) 85.10% (0.00) 89.28% (0.00) 95.56% (0.00) ok ai-durable-stream 86.70% (0.00) 82.25% (0.00) 92.30% (0.00) 88.72% (0.00) ok ai-grok-build 79.19% (0.00) 63.56% (0.00) 77.39% (0.00) 81.02% (0.00) ok ai-harness 92.88% (+0.39) 87.42% (+0.19) 93.21% (+0.79) 94.45% (+0.39) ok ai-mcp 96.71% (0.00) 91.77% (0.00) 96.86% (0.00) 98.66% (0.00) ok ai-opencode 68.77% (0.00) 60.82% (0.00) 64.04% (0.00) 70.78% (0.00) ok ai-sandbox 77.45% (0.00) 82.80% (0.00) 74.47% (0.00) 77.97% (0.00) ok ai-sandbox-blaxel 87.64% (0.00) 77.18% (0.00) 82.26% (0.00) 89.71% (0.00) ok ai-sandbox-boxd 95.86% (0.00) 87.12% (0.00) 95.31% (0.00) 98.17% (0.00) ok ai-sandbox-cloudflare 67.91% (0.00) 57.47% (0.00) 71.79% (0.00) 69.62% (0.00) ok ai-sandbox-daytona 82.70% (0.00) 81.89% (0.00) 67.14% (0.00) 85.18% (0.00) ok ai-sandbox-docker 80.15% (+0.44) 71.49% (+0.15) 77.38% (+1.00) 82.13% (+0.48) ok ai-sandbox-e2b 94.42% (0.00) 88.97% (0.00) 93.24% (0.00) 98.63% (0.00) ok ai-sandbox-local-process 68.00% (0.00) 53.59% (0.00) 75.86% (0.00) 68.88% (0.00) ok ai-sandbox-railway 94.75% (0.00) 92.68% (0.00) 90.90% (0.00) 97.59% (0.00) ok ai-sandbox-sprites 73.23% (0.00) 59.70% (0.00) 73.83% (0.00) 76.17% (0.00) ok ai-sandbox-upstash-box 94.82% (0.00) 91.52% (0.00) 91.04% (0.00) 97.76% (0.00) ok ai-sandbox-vercel 44.67% (0.00) 38.18% (0.00) 35.18% (0.00) 45.76% (0.00) ok ai-skills 83.39% (0.00) 68.53% (0.00) 87.36% (0.00) 85.48% (0.00) ok github-actions[bot](GitHub profile, opens in a new tab) assignedtombeckenham
github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer
AlemTuzlak merged thisd326802
AlemTuzlak closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 743367cb1f46d7b77dd2695aa5f3c2d01225fa84
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR