From 11921075a4462cb27032512ff8736e572402e9f7 Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Wed, 16 Sep 2026 14:24:32 -0500 Subject: [PATCH] Add first-task onboarding skill and Runner E2E coverage (#13517) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The first task helps a new user define and approve useful work. > - That workflow needs reusable instructions and tests against the production experience. > - Native Codex and Claude must load the assigned skill, including after resume. > - Maintainers need recorded conversations and precise failed checks to judge regressions. > - This pull request adds the first-task skill and a suite in the shared Runner E2E harness. > - It keeps behavior results separate from informational quality scores and incomplete recordings. ## Linked Issues or Issue Description **What existing behavior does this improve?** The first onboarding task and the Runner E2E report used to review it. **Current behavior** Onboarding embeds its policy in a hidden brief. Native Codex drops the skill-instructions setting at the Rust boundary. The shared E2E harness has no onboarding suite or full conversation view. **Proposed behavior** Assign and invoke `/first-task` for the onboarding task. Send selected Codex skills as structured protocol inputs. Run twelve scenarios across legacy Codex, legacy Claude, native Codex, and native ACPX Claude. Include all 48 cells in full campaigns. Show recorded chat, question and approval cards, exact checks, instructions, and billing in the shared dashboard. **Reason and benefit** Measure the real onboarding experience before changing prompts. Distinguish infrastructure failures, behavior failures, and unexercised journey steps. **Breaking changes** No database migration or production API change. First-task instructions now live in an assigned skill. The user-edited persona is preserved; the skill includes the maintainer-approved proposal-mode mapping and saved-plan requirement. Related: #11043 is earlier onboarding work. #13422 already fixes native Claude model pinning, context delivery, and read permissions on master; this branch includes those fixes through its base. The new Claude recovery test supplements them. ## What Changed - Extract and assign the first-task skill while retaining the production greeting and opening question. - Carry the Codex skill-instructions flag through thread start and resume. Resolve explicit task skill references only against assigned skills and send native skill inputs. - Invoke an unambiguously selected assigned skill through Claude ACPX’s native slash-command parser on initial and resumed turns, retaining the entire task/wake envelope as its argument. Do not carry that invocation into ordinary tasks. - Restore the saved single-task proposal modes: confirmation card, or saved plan with revision-targeted checkbox approval. Explicit plan requests also require a saved plan. - Add first-response and complete-journey cases with fixed user facts, acceptance checkpoints, durable outcome checks, and accounting for child runs. - Fail the eval when choice questions have fewer than two real options. Recognize planning documents without treating them as completed work. - Add optional, bounded quality judging as explicit post-processing. - Render full conversations and static interaction cards in the shared report. Conversations start folded. Show original and regraded results and incomplete journeys distinctly. - Keep credential-persistence scanning outside the first-task behavioral suite; retain public evidence redaction. - Refresh generated capability references after the API-reference edits. - Correct shared native question guidance and tool schemas: choices need at least two meaningful options; open-ended questions use canonical text fields with the required compatibility payload. Verify both formats through real tool-authority persistence. - Disable announcements automatically for every isolated Runner E2E process and label the gallery environment/provider/target explicitly. - Remove CI races in the GitHub connection browser test and native session recovery test by waiting for the actual async work before asserting its results. ## Verification - `pnpm exec vitest run server/src/services/onboarding-first-task-assets.test.ts server/src/__tests__/issue-onboarding-first-task-routes.test.ts`: 19 passed. - `pnpm --dir packages/paperclip-runner exec vitest run src/drivers/acpx/runtime-host.test.ts src/drivers/acpx/native-skill-prompt.test.ts src/cli/acpx-runtime-sidecar.test.ts`: 70 passed. Native command forwarding and the 1 MiB input boundary both failed before their fixes and passed afterward. Coverage includes changed skills on reopen, approval context, and an ordinary subsequent task. - Runner E2E unit suite: 306 passed. Harness typecheck passed. The 64 first-task fixture and grader tests also pass. - Full repository typecheck and build passed locally. Server typecheck and Runner build passed again after the native-command change. - Full GitHub Actions CI passed on `23e56447b`: all server/workspace/browser shards, Runner verification, typecheck/release registry, build, canary, policy, and Docker checks. Greptile reviewed this exact head at 5/5 with no unresolved threads. The earlier broad local run had database startup/timing failures that passed isolated retries; the complete remote suite is green. - Merge verification against current master: 312 harness tests and 13 native recovery tests passed. Regenerated semantic contracts and fixture hashes pass their consistency check. Full local typecheck and build also passed on the stacked queue branch. After merging the latest master and preserving the GitHub setup timing regression in the split browser suite, both focused GitHub browser tests passed. Three CI timing/startup flakes passed local verification and one remote retry; all latest-head checks are green. - Real pinned Claude SDK and Claude ACP JSON-RPC probes against a local mock API confirmed that `/skill-name` expands the assigned skill body before the model request and retains the task arguments. A prose mention does not. The probes made no paid model calls. The ACP probe used the current first-task skill body and retained the wake arguments. - [Full 48-case campaign and report](https://pages.paperclip.ing/runner-e2e-first-task-35053063880/): 44 passed after three interrupted Codex cases completed in targeted reruns. Original results, regrades, and all 51 executions remain in the report provenance. - [Claude campaign after the shared-question fix](https://pages.paperclip.ing/runner-e2e-first-task-claude-35099525201/): 10/12 passed with zero single-option failures. All 12 recorded the current assigned skill and corrected guidance. The failures exposed skipped skill invocation and a missing saved plan. This PR adds native command invocation and explicit saved-plan instructions; the subsequent report below still shows behavior failures. - [Fresh 12-case Claude report](https://pages.paperclip.ing/runner-e2e-first-task-claude-35102737804/) at `78452129e`: 10/12 pass after correcting two false proposal-matcher failures. The recordings said “Here is the task I will create and run/complete” in approval cards; the old matcher missed that word order. Regression tests failed before the fix and pass after it. Original results and offline regrade provenance remain linked. No agent rerun was needed. Zero single-option-question failures; two behavior failures remain: direct work before acceptance on a plain first message, and an explicit plan request without a saved plan. Neither check was relaxed. The follow-up `82087ac7e` fixes command-prefix size accounting; `94aefb1f3` fixes only that proposal matcher. - Report browser checks confirm folded conversations, rendered cards, explicit Local/Daytona labels, and no page errors. The published-object audit scanned 1,306 text files across 2,154 objects with no credential-format findings or prohibited files. Image pixels and unknown token formats are outside that scan. ## Risks - Model behavior is nondeterministic. One campaign is evidence, not a guarantee. The two remaining Claude behavior failures are visible in the report and require further product work; this PR does not claim all onboarding scenarios pass. - The suite checks persisted Paperclip effects. It cannot prove the absence of arbitrary external effects. - Historical recordings can miss later journey steps. These remain incomplete, never passes. - Native profiles switch runtime after the production onboarding wizard because it does not yet expose a native option. - Quality scores are informational and cannot override behavioral failures. ## Model Used OpenAI Codex, GPT-6, with reasoning, repository tools, and code execution. The exact deployed model identifier and context-window size are not exposed in this session. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip --- .../editing-first-task-texts.md | 13 +- package.json | 1 + .../docs/capability-contract.md | 34 +- .../paperclip-runner/docs/codex-driver.md | 28 + .../generated/capability/capabilities.yaml | 72 +- .../capability/capability-contract.md | 2 +- .../capability/semantic-tool-contracts.json | 2 +- .../evals/native-execution-seeded.json | 2 +- .../paperclip-runner/protocol/manifest.json | 2 +- .../src/bin/fake-codex-app-server.rs | 8 + .../crates/runner-core/src/codex_provider.rs | 75 +- .../runner-core/src/provider_backend.rs | 68 +- .../runner-core/tests/codex_provider.rs | 132 ++ .../spec/capability/capabilities.yaml | 102 +- .../src/backends/codex-native-backend.ts | 7 + .../src/backends/runtime-context.test.ts | 28 + .../src/backends/runtime-context.ts | 30 +- .../src/contracts/runtime-context.ts | 7 + .../drivers/acpx/native-skill-prompt.test.ts | 28 + .../src/drivers/acpx/native-skill-prompt.ts | 22 + .../src/drivers/acpx/runtime-host.test.ts | 40 +- .../src/drivers/acpx/runtime-host.ts | 14 +- .../src/drivers/acpx/runtime-sandbox.test.ts | 12 + .../codex/codex-app-server-driver-impl.ts | 1 + .../codex-app-server-driver.lifecycle.test.ts | 39 + .../src/drivers/codex/codex-driver-types.ts | 2 + .../drivers/codex/codex-harness-session.ts | 11 +- .../src/drivers/codex/codex-session-state.ts | 3 + .../src/live/runnerd-codex-transport.test.ts | 31 +- .../src/live/runnerd-codex-transport.ts | 42 +- .../protocol-actions/request-human-input.ts | 4 +- .../src/__tests__/agent-skills-routes.test.ts | 27 +- .../__tests__/company-skills-service.test.ts | 28 + ...issue-onboarding-first-task-routes.test.ts | 18 +- .../native-session-resumption.test.ts | 12 +- .../onboarding-assets/first-task/README.md | 56 +- .../src/onboarding-assets/first-task/brief.md | 22 +- .../first-task/chief-of-staff/AGENTS.md | 16 +- .../first-task/proposal-confirmation.md | 1 - .../first-task/proposal-plan.md | 1 - .../first-task/skills/first-task/SKILL.md | 45 + server/src/routes/agents.ts | 7 +- server/src/routes/issues.ts | 2 +- server/src/services/company-skills.ts | 13 +- .../native-execution-input.test.ts | 6 + .../native-runtime/native-execution-input.ts | 2 +- .../paperclip-runner-tool-authority.test.ts | 35 +- .../paperclip-runner-tool-authority.ts | 2 +- .../native-runtime/runner-api-reference.ts | 13 +- .../onboarding-first-task-assets.test.ts | 41 +- .../services/onboarding-first-task-assets.ts | 18 +- skills/paperclip/references/api-reference.md | 15 +- tests/e2e/chat-adapters-ui-providers.spec.ts | 3 +- tests/runner-e2e/README.md | 180 ++- tests/runner-e2e/SECURITY.md | 5 +- tests/runner-e2e/billing.ts | 21 +- tests/runner-e2e/case-outcome.ts | 73 + tests/runner-e2e/catalog.test.ts | 15 +- tests/runner-e2e/catalog.ts | 11 + tests/runner-e2e/chat-flow.ts | 6 + tests/runner-e2e/dashboard-regenerate.ts | 4 +- tests/runner-e2e/dashboard.ts | 155 ++- tests/runner-e2e/evidence.ts | 2 + tests/runner-e2e/first-task-attachments.ts | 24 + tests/runner-e2e/first-task-cases.ts | 84 ++ tests/runner-e2e/first-task-fixtures.ts | 92 ++ tests/runner-e2e/first-task-flow.ts | 611 +++++++++ tests/runner-e2e/first-task-judge.ts | 79 ++ tests/runner-e2e/first-task-quality.ts | 266 ++++ tests/runner-e2e/first-task-replies.ts | 24 + tests/runner-e2e/first-task-report.test.ts | 292 ++++ tests/runner-e2e/first-task-report.ts | 50 + tests/runner-e2e/first-task-scoring.ts | 430 ++++++ tests/runner-e2e/first-task-transcript.ts | 188 +++ tests/runner-e2e/first-task.test.ts | 1201 +++++++++++++++++ tests/runner-e2e/harness-env.ts | 2 + tests/runner-e2e/history-index.ts | 11 +- tests/runner-e2e/history.test.ts | 47 + tests/runner-e2e/history.ts | 14 +- tests/runner-e2e/interaction-report.test.ts | 355 +++++ tests/runner-e2e/interaction-report.ts | 302 +++++ tests/runner-e2e/launch.ts | 74 +- tests/runner-e2e/live-fixtures.ts | 7 + tests/runner-e2e/report.test.ts | 32 + tests/runner-e2e/report.ts | 15 +- tests/runner-e2e/result-validation.ts | 17 +- tests/runner-e2e/runner.spec.ts | 39 +- tests/runner-e2e/support.test.ts | 13 +- tests/runner-e2e/types.ts | 27 +- 89 files changed, 5662 insertions(+), 351 deletions(-) create mode 100644 packages/paperclip-runner/src/drivers/acpx/native-skill-prompt.test.ts create mode 100644 packages/paperclip-runner/src/drivers/acpx/native-skill-prompt.ts delete mode 100644 server/src/onboarding-assets/first-task/proposal-confirmation.md delete mode 100644 server/src/onboarding-assets/first-task/proposal-plan.md create mode 100644 server/src/onboarding-assets/first-task/skills/first-task/SKILL.md create mode 100644 tests/runner-e2e/case-outcome.ts create mode 100644 tests/runner-e2e/first-task-attachments.ts create mode 100644 tests/runner-e2e/first-task-cases.ts create mode 100644 tests/runner-e2e/first-task-fixtures.ts create mode 100644 tests/runner-e2e/first-task-flow.ts create mode 100644 tests/runner-e2e/first-task-judge.ts create mode 100644 tests/runner-e2e/first-task-quality.ts create mode 100644 tests/runner-e2e/first-task-replies.ts create mode 100644 tests/runner-e2e/first-task-report.test.ts create mode 100644 tests/runner-e2e/first-task-report.ts create mode 100644 tests/runner-e2e/first-task-scoring.ts create mode 100644 tests/runner-e2e/first-task-transcript.ts create mode 100644 tests/runner-e2e/first-task.test.ts create mode 100644 tests/runner-e2e/interaction-report.test.ts create mode 100644 tests/runner-e2e/interaction-report.ts diff --git a/docs/guides/board-operator/editing-first-task-texts.md b/docs/guides/board-operator/editing-first-task-texts.md index aaf0e4d255f..506f80ac8fc 100644 --- a/docs/guides/board-operator/editing-first-task-texts.md +++ b/docs/guides/board-operator/editing-first-task-texts.md @@ -10,19 +10,20 @@ The text for a new organization's first task lives in `server/src/onboarding-ass | File | Purpose | | --- | --- | | `greeting.md` | The welcome the user sees. | -| `brief.md` | The first-task instructions. Contains `{{proposalStep}}`. | -| `proposal-confirmation.md` | The single-card proposal used when the plan toggle is off. | -| `proposal-plan.md` | The plan document and checkbox-card proposal used when the toggle is on. | +| `brief.md` | The hidden `/first-task` skill invocation. Contains `{{proposalMode}}`. | +| `skills/first-task/SKILL.md` | The first-task instructions, including both proposal modes. | | `opening-question.json` | The opening card: its prompt and two options. | | `chief-of-staff/AGENTS.md` | The first agent's chief-of-staff persona. | | `README.md` | A maintainer reference for the files, placeholders, toggle, and update behavior. | -The templates support `{{agentName}}`, `{{organizationName}}`, and `{{proposalStep}}`. Paperclip fills them when it creates the organization, first agent, and first task. +The templates support `{{agentName}}`, `{{organizationName}}`, and `{{proposalMode}}`. Paperclip fills them when it creates the first agent and first task. The proposal mode is `confirmation` or `plan`; the full policy lives in the skill. ## How the first-task flow works The server posts the greeting and an opening card with two options. Nothing runs until the user answers the card or writes a message. +The first agent receives the `first-task` skill automatically. The first task's hidden description tells it to read and follow that skill; the user does not need to type `/first-task`. The skill also applies to later replies on that onboarding task, but not to the agent's other tasks. + - **Interview me:** the agent asks 3–4 questions in one card, then proposes a plan and a team. - **I have a task in mind:** the typed text is the task. When it is clear enough, the agent proposes right away. Otherwise it asks 2–3 clarifying questions first. - A plain message instead of an answer counts as a task. @@ -33,7 +34,9 @@ The agent may create hires or tasks only after the user accepts a confirmation o Edit the Markdown with GitHub's web editor or locally, open a pull request, and merge it. A local instance loads the change after its next server restart; Cloud tenants receive it with the next release. -Only new organizations receive updated text. An existing first task keeps its stored description, and an existing first agent keeps its instruction file. You can edit the task description on the task and the agent's copy in the app under **Instructions**. +An existing first task keeps its stored description, and an existing first agent keeps its instruction file. The skill is assigned automatically to new onboarding agents; existing agents are not migrated. You can edit the agent's copy of its persona in the app under **Instructions**. + +Skill edits follow normal bundled-skill refresh: agents already assigned the unpinned `first-task` skill receive its updated policy. The proposal mode saved in each task stays the same. ## Choose the proposal form diff --git a/package.json b/package.json index 8f653413a72..da311d64d92 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "test:e2e": "npx playwright test --config tests/e2e/playwright.config.ts", "test:e2e:runner": "node cli/node_modules/tsx/dist/cli.mjs tests/runner-e2e/launch.ts", "test:e2e:runner:image-id": "node cli/node_modules/tsx/dist/cli.mjs tests/runner-e2e/daytona-image-content.ts", + "test:e2e:runner:judge-first-task": "node cli/node_modules/tsx/dist/cli.mjs tests/runner-e2e/first-task-judge.ts", "test:e2e:runner:dashboard": "node cli/node_modules/tsx/dist/cli.mjs tests/runner-e2e/dashboard-regenerate.ts", "test:e2e:runner:models:update": "node cli/node_modules/tsx/dist/cli.mjs tests/runner-e2e/openrouter-models-update.ts", "test:e2e:runner:history:publish": "node cli/node_modules/tsx/dist/cli.mjs tests/runner-e2e/history-publish.ts", diff --git a/packages/paperclip-runner/docs/capability-contract.md b/packages/paperclip-runner/docs/capability-contract.md index 665626eb119..d121c267587 100644 --- a/packages/paperclip-runner/docs/capability-contract.md +++ b/packages/paperclip-runner/docs/capability-contract.md @@ -179,23 +179,23 @@ The skill/reference inventory and eval cases are the only normative behavior sou | skill:skills/paperclip/references/api-reference.md:requesting-a-hire-management-only:861 | optional_agent_tool | skills/paperclip/references/api-reference.md:861 | | skill:skills/paperclip/references/api-reference.md:ceo-strategy-approval:893 | optional_agent_tool | skills/paperclip/references/api-reference.md:893 | | skill:skills/paperclip/references/api-reference.md:questions-and-waiting-for-human-input:902 | always_agent_tool | skills/paperclip/references/api-reference.md:902 | -| skill:skills/paperclip/references/api-reference.md:issue-thread-confirmations:984 | always_agent_tool | skills/paperclip/references/api-reference.md:984 | -| skill:skills/paperclip/references/api-reference.md:checkbox-confirmations:1042 | always_agent_tool | skills/paperclip/references/api-reference.md:1042 | -| skill:skills/paperclip/references/api-reference.md:item-verdict-requests:1157 | optional_agent_tool | skills/paperclip/references/api-reference.md:1157 | -| skill:skills/paperclip/references/api-reference.md:checking-approval-status:1267 | optional_agent_tool | skills/paperclip/references/api-reference.md:1267 | -| skill:skills/paperclip/references/api-reference.md:approval-follow-up-requesting-agent:1273 | always_agent_tool | skills/paperclip/references/api-reference.md:1273 | -| skill:skills/paperclip/references/api-reference.md:issue-lifecycle:1291 | always_agent_tool | skills/paperclip/references/api-reference.md:1291 | -| skill:skills/paperclip/references/api-reference.md:error-handling:1321 | control_plane_owned | skills/paperclip/references/api-reference.md:1321 | -| skill:skills/paperclip/references/api-reference.md:full-api-reference:1335 | optional_agent_tool | skills/paperclip/references/api-reference.md:1335 | -| skill:skills/paperclip/references/api-reference.md:agents:1337 | optional_agent_tool | skills/paperclip/references/api-reference.md:1337 | -| skill:skills/paperclip/references/api-reference.md:issues-tasks:1358 | optional_agent_tool | skills/paperclip/references/api-reference.md:1358 | -| skill:skills/paperclip/references/api-reference.md:companies-projects-goals:1398 | optional_agent_tool | skills/paperclip/references/api-reference.md:1398 | -| skill:skills/paperclip/references/api-reference.md:routines:1422 | optional_agent_tool | skills/paperclip/references/api-reference.md:1422 | -| skill:skills/paperclip/references/api-reference.md:approvals-costs-activity-dashboard:1438 | optional_agent_tool | skills/paperclip/references/api-reference.md:1438 | -| skill:skills/paperclip/references/api-reference.md:secrets:1460 | optional_agent_tool | skills/paperclip/references/api-reference.md:1460 | -| skill:skills/paperclip/references/api-reference.md:agent-secret-proposals:1473 | optional_agent_tool | skills/paperclip/references/api-reference.md:1473 | -| skill:skills/paperclip/references/api-reference.md:agent-secret-access:1573 | optional_agent_tool | skills/paperclip/references/api-reference.md:1573 | -| skill:skills/paperclip/references/api-reference.md:common-mistakes:1613 | optional_agent_tool | skills/paperclip/references/api-reference.md:1613 | +| skill:skills/paperclip/references/api-reference.md:issue-thread-confirmations:993 | always_agent_tool | skills/paperclip/references/api-reference.md:993 | +| skill:skills/paperclip/references/api-reference.md:checkbox-confirmations:1051 | always_agent_tool | skills/paperclip/references/api-reference.md:1051 | +| skill:skills/paperclip/references/api-reference.md:item-verdict-requests:1166 | optional_agent_tool | skills/paperclip/references/api-reference.md:1166 | +| skill:skills/paperclip/references/api-reference.md:checking-approval-status:1276 | optional_agent_tool | skills/paperclip/references/api-reference.md:1276 | +| skill:skills/paperclip/references/api-reference.md:approval-follow-up-requesting-agent:1282 | always_agent_tool | skills/paperclip/references/api-reference.md:1282 | +| skill:skills/paperclip/references/api-reference.md:issue-lifecycle:1300 | always_agent_tool | skills/paperclip/references/api-reference.md:1300 | +| skill:skills/paperclip/references/api-reference.md:error-handling:1330 | control_plane_owned | skills/paperclip/references/api-reference.md:1330 | +| skill:skills/paperclip/references/api-reference.md:full-api-reference:1344 | optional_agent_tool | skills/paperclip/references/api-reference.md:1344 | +| skill:skills/paperclip/references/api-reference.md:agents:1346 | optional_agent_tool | skills/paperclip/references/api-reference.md:1346 | +| skill:skills/paperclip/references/api-reference.md:issues-tasks:1367 | optional_agent_tool | skills/paperclip/references/api-reference.md:1367 | +| skill:skills/paperclip/references/api-reference.md:companies-projects-goals:1407 | optional_agent_tool | skills/paperclip/references/api-reference.md:1407 | +| skill:skills/paperclip/references/api-reference.md:routines:1431 | optional_agent_tool | skills/paperclip/references/api-reference.md:1431 | +| skill:skills/paperclip/references/api-reference.md:approvals-costs-activity-dashboard:1447 | optional_agent_tool | skills/paperclip/references/api-reference.md:1447 | +| skill:skills/paperclip/references/api-reference.md:secrets:1469 | optional_agent_tool | skills/paperclip/references/api-reference.md:1469 | +| skill:skills/paperclip/references/api-reference.md:agent-secret-proposals:1482 | optional_agent_tool | skills/paperclip/references/api-reference.md:1482 | +| skill:skills/paperclip/references/api-reference.md:agent-secret-access:1582 | optional_agent_tool | skills/paperclip/references/api-reference.md:1582 | +| skill:skills/paperclip/references/api-reference.md:common-mistakes:1622 | optional_agent_tool | skills/paperclip/references/api-reference.md:1622 | ## Legacy MCP Alias Index diff --git a/packages/paperclip-runner/docs/codex-driver.md b/packages/paperclip-runner/docs/codex-driver.md index 1164723e239..a3021d88e67 100644 --- a/packages/paperclip-runner/docs/codex-driver.md +++ b/packages/paperclip-runner/docs/codex-driver.md @@ -169,3 +169,31 @@ than surfacing a raw filesystem `ENOENT`. See the This phase changes no browser surface, so no new browser screenshot applies. The canonical events are proved through the existing reducer/replay path and JSON trace evidence. + + +## Explicit assigned skills in native tasks + +A task description can explicitly invoke an assigned skill with `/skill-name` +or `$skill-name`. The native Codex backend resolves these references against +that run's assigned runtime context; assignment alone does not invoke a skill. +Selections are recomputed from the current task description on each wake, +including approval replies and recovered sessions. Ordinary tasks without an +explicit reference receive no structured skill invocation. + +The driver sends both the `$skill-name` text reference and Codex's structured +`{ type: "skill", name, path }` input on every requested turn. Runnerd validates +the assigned source path, maps it to the provider's isolated +`codex-home/skills//SKILL.md` (including remote runners), and preserves it +through the durable `turn.start` command. `turn.submitted.skillInputs` records +the controller's selected inputs for inspection; protocol tests separately +verify the outgoing provider request and mapped path. + +`includeSkillInstructions` is forwarded to Codex on both `thread/start` and +`thread/resume`. Old persisted configurations without the field retain their +provider default until a fresh, settled run supplies an explicit value. That +one-time upgrade reopens the same thread with the new setting. OpenCode does +not receive Codex's skill configuration or structured skill inputs. + +These are delivery guarantees, not guarantees of model adherence. The onboarding +`first-task` skill uses this generic mechanism; its prompt and persona are not +changed by the wiring. diff --git a/packages/paperclip-runner/generated/capability/capabilities.yaml b/packages/paperclip-runner/generated/capability/capabilities.yaml index 7a7b1839abb..3352ff5112f 100644 --- a/packages/paperclip-runner/generated/capability/capabilities.yaml +++ b/packages/paperclip-runner/generated/capability/capabilities.yaml @@ -740,162 +740,162 @@ "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:984", + "id": "skill:skills/paperclip/references/api-reference.md:993", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L984:issue-thread-confirmations", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L993:issue-thread-confirmations", "heading": "Issue-thread confirmations", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1042", + "id": "skill:skills/paperclip/references/api-reference.md:1051", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1042:checkbox-confirmations", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1051:checkbox-confirmations", "heading": "Checkbox confirmations", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1157", + "id": "skill:skills/paperclip/references/api-reference.md:1166", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1157:item-verdict-requests", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1166:item-verdict-requests", "heading": "Item verdict requests", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1267", + "id": "skill:skills/paperclip/references/api-reference.md:1276", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1267:checking-approval-status", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1276:checking-approval-status", "heading": "Checking approval status", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1273", + "id": "skill:skills/paperclip/references/api-reference.md:1282", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1273:approval-follow-up-requesting-agent", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1282:approval-follow-up-requesting-agent", "heading": "Approval follow-up (requesting agent)", "primaryDisposition": "control_plane_owned", "semanticOperation": "runtime_reconciliation", "expectedMockState": "runtime_decision_record" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1291", + "id": "skill:skills/paperclip/references/api-reference.md:1300", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1291:issue-lifecycle", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1300:issue-lifecycle", "heading": "Issue Lifecycle", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1321", + "id": "skill:skills/paperclip/references/api-reference.md:1330", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1321:error-handling", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1330:error-handling", "heading": "Error Handling", "primaryDisposition": "control_plane_owned", "semanticOperation": "runtime_reconciliation", "expectedMockState": "runtime_decision_record" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1335", + "id": "skill:skills/paperclip/references/api-reference.md:1344", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1335:full-api-reference", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1344:full-api-reference", "heading": "Full API Reference", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1337", + "id": "skill:skills/paperclip/references/api-reference.md:1346", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1337:agents", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1346:agents", "heading": "Agents", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1358", + "id": "skill:skills/paperclip/references/api-reference.md:1367", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1358:issues-tasks", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1367:issues-tasks", "heading": "Issues (Tasks)", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1398", + "id": "skill:skills/paperclip/references/api-reference.md:1407", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1398:companies-projects-goals", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1407:companies-projects-goals", "heading": "Companies, Projects, Goals", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1422", + "id": "skill:skills/paperclip/references/api-reference.md:1431", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1422:routines", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1431:routines", "heading": "Routines", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1438", + "id": "skill:skills/paperclip/references/api-reference.md:1447", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1438:approvals-costs-activity-dashboard", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1447:approvals-costs-activity-dashboard", "heading": "Approvals, Costs, Activity, Dashboard", "primaryDisposition": "control_plane_owned", "semanticOperation": "runtime_reconciliation", "expectedMockState": "runtime_decision_record" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1460", + "id": "skill:skills/paperclip/references/api-reference.md:1469", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1460:secrets", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1469:secrets", "heading": "Secrets", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1473", + "id": "skill:skills/paperclip/references/api-reference.md:1482", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1473:agent-secret-proposals", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1482:agent-secret-proposals", "heading": "Agent secret proposals", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1526", + "id": "skill:skills/paperclip/references/api-reference.md:1535", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1526:re-bind-an-existing-secret-under-a-new-path-no-secret-id", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1535:re-bind-an-existing-secret-under-a-new-path-no-secret-id", "heading": "Re-bind an existing secret under a new path (no secret ID)", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1573", + "id": "skill:skills/paperclip/references/api-reference.md:1582", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1573:agent-secret-access", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1582:agent-secret-access", "heading": "Agent secret access", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", "expectedMockState": "operation_result" }, { - "id": "skill:skills/paperclip/references/api-reference.md:1613", + "id": "skill:skills/paperclip/references/api-reference.md:1622", "kind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md#L1613:common-mistakes", + "sourceAnchor": "skills/paperclip/references/api-reference.md#L1622:common-mistakes", "heading": "Common Mistakes", "primaryDisposition": "optional_agent_tool", "semanticOperation": "scoped_discovery", diff --git a/packages/paperclip-runner/generated/capability/capability-contract.md b/packages/paperclip-runner/generated/capability/capability-contract.md index cda7b5b9cc1..f2204e09d2e 100644 --- a/packages/paperclip-runner/generated/capability/capability-contract.md +++ b/packages/paperclip-runner/generated/capability/capability-contract.md @@ -5,6 +5,6 @@ Generated by `scripts/generate-capability-contract.mjs`; do not edit generated f - Skill/reference headings: 156 - Legacy MCP tools: 42 - Eval cases: 106 across 16 groups -- Deterministic content SHA-256: `8447cdf6ddc5fa7b36e9724b3df1ea695ac084cf3e104273186fbec3ed9bc5fd` +- Deterministic content SHA-256: `5ffebd5f684e312c07cc87723aa25864e85fc3f320e24341ed678852eef5c638` Every row has exactly one primary disposition, a source anchor, a semantic operation, and a mock-state expectation. diff --git a/packages/paperclip-runner/generated/capability/semantic-tool-contracts.json b/packages/paperclip-runner/generated/capability/semantic-tool-contracts.json index 634d09c9f03..e068d42e501 100644 --- a/packages/paperclip-runner/generated/capability/semantic-tool-contracts.json +++ b/packages/paperclip-runner/generated/capability/semantic-tool-contracts.json @@ -1 +1 @@ -[{"annotations":{"exposure":"always","operationId":"get_task_context","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read the active task and actor, including the exact approved Markdown revision when this issue has an accepted plan.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"get_task_context","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"always","operationId":"get_task_history","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read bounded comments on the active task.","inputSchema":{"additionalProperties":false,"properties":{"limit":{"default":50,"maximum":200,"minimum":1,"type":"integer"}},"required":[],"type":"object"},"name":"get_task_history","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"always","operationId":"list_documents","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"List revisioned documents on the active task.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"list_documents","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"always","operationId":"read_document","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read the current revision of one active-task document.","inputSchema":{"additionalProperties":false,"properties":{"key":{"description":"Stable issue-document key.","maxLength":120,"minLength":1,"type":"string"}},"required":["key"],"type":"object"},"name":"read_document","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"always","operationId":"list_document_revisions","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read bounded revision history for one active-task document.","inputSchema":{"additionalProperties":false,"properties":{"key":{"description":"Stable issue-document key.","maxLength":120,"minLength":1,"type":"string"},"limit":{"default":50,"maximum":200,"minimum":1,"type":"integer"}},"required":["key"],"type":"object"},"name":"list_document_revisions","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"always","operationId":"report_progress","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Append a durable progress comment to the active task.","inputSchema":{"additionalProperties":false,"properties":{"body":{"description":"Multiline progress update.","maxLength":20000,"minLength":1,"type":"string"},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"}},"required":["idempotencyKey","body"],"type":"object"},"name":"report_progress","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"answer_status_question","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Append the answer to a status-only wake without changing task disposition.","inputSchema":{"additionalProperties":false,"properties":{"body":{"description":"Concise status answer.","maxLength":20000,"minLength":1,"type":"string"},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"}},"required":["idempotencyKey","body"],"type":"object"},"name":"answer_status_question","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"write_document","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Create or update an active-task document with optimistic revision safety.","inputSchema":{"additionalProperties":false,"properties":{"baseRevisionId":{"description":"Current revision id, or null when creating.","maxLength":20000,"type":["string","null"]},"body":{"description":"Markdown document body.","maxLength":200000,"minLength":1,"type":"string"},"changeSummary":{"description":"Optional revision summary.","maxLength":20000,"type":["string","null"]},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"key":{"description":"Stable issue-document key.","maxLength":120,"minLength":1,"type":"string"},"title":{"description":"Document title.","maxLength":300,"minLength":1,"type":"string"}},"required":["idempotencyKey","key","title","body","baseRevisionId"],"type":"object"},"name":"write_document","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"request_human_input","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Create a typed, durable interaction on the active task.","inputSchema":{"additionalProperties":false,"properties":{"continuationPolicy":{"enum":["none","wake_assignee","wake_assignee_on_accept"]},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"interactionKind":{"enum":["confirmation","checkbox","questions","suggest_tasks","item_verdicts"]},"payload":{"additionalProperties":true,"description":"Kind-specific interaction data. For interactionKind='questions', use exactly {version:1, questions:[{id,prompt,selectionMode:'single'|'multi',required?,options:[{id,label,description?,freeText?}]}]}; option keys are id/label, not value, and question choice cardinality is selectionMode, not type. For confirmation, payload may be {}. Keep all ids stable across retries.","type":"object"},"prompt":{"description":"Question or decision prompt.","maxLength":10000,"minLength":1,"type":"string"},"targetRevisionId":{"description":"Optional bound document revision.","maxLength":20000,"type":["string","null"]},"title":{"description":"Interaction card title.","maxLength":300,"minLength":1,"type":"string"}},"required":["idempotencyKey","interactionKind","title","prompt","continuationPolicy"],"type":"object"},"name":"request_human_input","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"register_deliverable","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Register attachment metadata and its artifact work product without credentials or bytes in the tool result.","inputSchema":{"additionalProperties":false,"properties":{"byteSize":{"maximum":100000000,"minimum":0,"type":"integer"},"contentRef":{"description":"Opaque package-local content reference.","maxLength":2000,"minLength":1,"type":"string"},"contentType":{"description":"Media type.","maxLength":200,"minLength":1,"type":"string"},"filename":{"description":"Display filename.","maxLength":500,"minLength":1,"type":"string"},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"sha256":{"pattern":"^[a-fA-F0-9]{64}$","type":"string"},"title":{"description":"Work-product title.","maxLength":500,"minLength":1,"type":"string"}},"required":["idempotencyKey","filename","contentType","byteSize","sha256","contentRef","title"],"type":"object"},"name":"register_deliverable","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"finish_task","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Finish the active task with a durable summary.","inputSchema":{"additionalProperties":false,"properties":{"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"summary":{"description":"Completion summary.","maxLength":20000,"minLength":1,"type":"string"}},"required":["idempotencyKey","summary"],"type":"object"},"name":"finish_task","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"block_task","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Block the active task with a durable reason and optional first-class dependencies.","inputSchema":{"additionalProperties":false,"properties":{"blockedByTaskIds":{"description":"Internal task ids that block this task.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"reason":{"description":"Block reason.","maxLength":20000,"minLength":1,"type":"string"}},"required":["idempotencyKey","reason"],"type":"object"},"name":"block_task","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"request_review","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Move the active task to review with a durable summary.","inputSchema":{"additionalProperties":false,"properties":{"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"summary":{"description":"Review handoff summary.","maxLength":20000,"minLength":1,"type":"string"}},"required":["idempotencyKey","summary"],"type":"object"},"name":"request_review","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"list_agents","requiredClaims":["discovery:agents:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"List redacted actor profiles.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"list_agents","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"get_agent","requiredClaims":["discovery:agents:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read one redacted actor profile.","inputSchema":{"additionalProperties":false,"properties":{"actorId":{"description":"Actor id.","maxLength":200,"minLength":1,"type":"string"}},"required":["actorId"],"type":"object"},"name":"get_agent","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"search_tasks","requiredClaims":["discovery:tasks:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Search tasks by text and status within the run company.","inputSchema":{"additionalProperties":false,"properties":{"limit":{"default":50,"maximum":200,"minimum":1,"type":"integer"},"query":{"maxLength":500,"type":"string"},"statuses":{"items":{"enum":["backlog","todo","in_progress","in_review","done","blocked","cancelled"]},"maxItems":7,"type":"array","uniqueItems":true}},"required":[],"type":"object"},"name":"search_tasks","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"list_approvals","requiredClaims":["governance:approvals:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"List approvals in the run company.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"list_approvals","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"get_approval","requiredClaims":["governance:approvals:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read one approval without protected data.","inputSchema":{"additionalProperties":false,"properties":{"approvalId":{"description":"Approval id.","maxLength":200,"minLength":1,"type":"string"}},"required":["approvalId"],"type":"object"},"name":"get_approval","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"get_approval_context","requiredClaims":["governance:approvals:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read one approval, its comments, and linked tasks.","inputSchema":{"additionalProperties":false,"properties":{"approvalId":{"description":"Approval id.","maxLength":200,"minLength":1,"type":"string"}},"required":["approvalId"],"type":"object"},"name":"get_approval_context","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"get_workspace_runtime","requiredClaims":["workspace:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read active-task workspace services.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"get_workspace_runtime","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"control_workspace_service","requiredClaims":["workspace:control"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Start, stop, or fault one active-task workspace service.","inputSchema":{"additionalProperties":false,"properties":{"action":{"enum":["start","stop","fail"]},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"serviceId":{"description":"Workspace service id.","maxLength":200,"minLength":1,"type":"string"},"url":{"description":"Optional service URL.","maxLength":20000,"type":["string","null"]}},"required":["idempotencyKey","serviceId","action"],"type":"object"},"name":"control_workspace_service","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"set_dependencies","requiredClaims":["dependencies:write"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Replace the active task's first-class blocker set.","inputSchema":{"additionalProperties":false,"properties":{"blockedByTaskIds":{"description":"Replacement blocker task ids.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"}},"required":["idempotencyKey","blockedByTaskIds"],"type":"object"},"name":"set_dependencies","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"create_task","requiredClaims":["delegation:tasks:create"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Create a project task from a conversation, or a child from an ordinary task. Persist initialPlan before execution.","inputSchema":{"additionalProperties":false,"properties":{"assigneeActorId":{"description":"Optional agent assignee. Omit to assign the current agent.","maxLength":20000,"type":["string","null"]},"blockedByTaskIds":{"description":"Initial blocker task ids.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"description":{"description":"Child task description.","maxLength":20000,"type":["string","null"]},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"initialPlan":{"description":"Relevant markdown plan saved on the new task before execution starts.","maxLength":200000,"type":["string","null"]},"priority":{"enum":["critical","high","medium","low"]},"projectId":{"description":"Project ID for the task.","type":["string","null"]},"title":{"description":"Child task title.","maxLength":500,"minLength":1,"type":"string"}},"required":["idempotencyKey","title"],"type":"object"},"name":"create_task","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"},"task":{"additionalProperties":false,"properties":{"assigneeActorId":{"type":["string","null"]},"id":{"minLength":1,"type":"string"},"identifier":{"type":["string","null"]},"parentId":{"minLength":1,"type":["string","null"]},"projectId":{"minLength":1,"type":["string","null"]},"status":{"minLength":1,"type":"string"}},"required":["id","identifier","parentId","status","assigneeActorId"],"type":"object"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds","task"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"request_approval","requiredClaims":["governance:approvals:request"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Create a governed approval and waiting posture.","inputSchema":{"additionalProperties":false,"properties":{"approvalType":{"description":"Stable approval type.","maxLength":200,"minLength":1,"type":"string"},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"payload":{"additionalProperties":true,"type":"object"}},"required":["idempotencyKey","approvalType","payload"],"type":"object"},"name":"request_approval","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"decide_approval","requiredClaims":["governance:approvals:decide"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Decide an approval as an explicitly authorized approver.","inputSchema":{"additionalProperties":false,"properties":{"approvalId":{"description":"Approval id.","maxLength":200,"minLength":1,"type":"string"},"decision":{"enum":["approved","rejected","cancelled"]},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"note":{"description":"Decision note.","maxLength":20000,"minLength":1,"type":"string"}},"required":["idempotencyKey","approvalId","decision","note"],"type":"object"},"name":"decide_approval","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"comment_on_approval","requiredClaims":["governance:approvals:comment"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Add a durable comment to an approval.","inputSchema":{"additionalProperties":false,"properties":{"approvalId":{"description":"Approval id.","maxLength":200,"minLength":1,"type":"string"},"body":{"description":"Approval comment.","maxLength":20000,"minLength":1,"type":"string"},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"}},"required":["idempotencyKey","approvalId","body"],"type":"object"},"name":"comment_on_approval","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"schedule_wake","requiredClaims":["control_plane:wakes"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Schedule a deterministic continuation wake.","inputSchema":{"additionalProperties":false,"properties":{"delayTicks":{"maximum":10000,"minimum":1,"type":"integer"},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"payload":{"additionalProperties":true,"type":"object"},"reason":{"enum":["manual","issue_commented","interaction_resolved","approval_resolved","blockers_resolved","scheduled_retry","resume"]}},"required":["idempotencyKey","reason","delayTicks"],"type":"object"},"name":"schedule_wake","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"generic_api_request","requiredClaims":["test:generic_api_request"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Test-only escape hatch. Disabled unless the scenario and explicit claim both enable it.","inputSchema":{"additionalProperties":false,"properties":{"body":{"additionalProperties":true,"type":"object"},"method":{"enum":["GET","POST","PATCH"]},"path":{"maxLength":500,"pattern":"^/mock/","type":"string"}},"required":["method","path"],"type":"object"},"name":"generic_api_request","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"search_api","requiredClaims":["api:discover"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Fallback only: discover Paperclip API operations when the available dedicated tools cannot express the task. Prefer dedicated tools for common operations; do not search before using them.","inputSchema":{"additionalProperties":false,"properties":{"cursor":{"maxLength":200,"type":"string"},"limit":{"default":5,"maximum":10,"minimum":1,"type":"integer"},"query":{"maxLength":500,"minLength":1,"type":"string"}},"required":["query"],"type":"object"},"name":"search_api","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"call_api","requiredClaims":["api:call"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Fallback only: call a discovered Paperclip API operation when dedicated tools lack the required operation or parameters. Uses your existing permissions. Prefer dedicated tools; never bypass a denial or runner lifecycle tool.","inputSchema":{"additionalProperties":false,"properties":{"body":{"anyOf":[{"additionalProperties":true,"type":"object"},{"items":{},"type":"array"},{"type":"string"},{"type":"number"},{"type":"boolean"},{"type":"null"}],"description":"Request value matching the discovered schema. For JSON object or array requests, pass the object or array directly, never a JSON-encoded string. Strings are for text bodies or endpoints whose schema explicitly accepts a string."},"contentType":{"maxLength":120,"type":"string"},"files":{"items":{"additionalProperties":false,"oneOf":[{"properties":{"artifactId":{}},"required":["artifactId"]},{"properties":{"path":{}},"required":["path"]}],"properties":{"artifactId":{"type":"string"},"field":{"type":"string"},"path":{"description":"File relative to the active issue workspace. Remote files must first be uploaded as an artifact.","type":"string"}},"type":"object"},"maxItems":10,"type":"array"},"operationId":{"description":"Exact operationId returned by search_api, for example GET /api/projects/{id}. Do not guess identifiers.","maxLength":500,"minLength":1,"type":"string"},"pathParams":{"additionalProperties":{"type":"string"},"type":"object"},"query":{"additionalProperties":true,"type":"object"}},"required":["operationId"],"type":"object"},"name":"call_api","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"create_project","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Create a project after considering existing projects and available repositories. repositoryIds and repositoryUrls accept multiple existing repositories. Use HTTPS GitHub repositoryUrls when an accessible repo is not in the catalog; this registers project repositories, not remote GitHub repositories. Non-code projects may omit repositories. Cannot combine repositoryIds/repositoryUrls with workspace. Reuse the idempotency key on retries.","inputSchema":{"additionalProperties":false,"properties":{"archivedAt":{"description":"Archive timestamp.","maxLength":20000,"type":["string","null"]},"color":{"description":"Project color.","maxLength":20000,"type":["string","null"]},"description":{"description":"Project outcome and context.","maxLength":20000,"type":["string","null"]},"env":{"additionalProperties":true,"type":"object"},"executionWorkspacePolicy":{"additionalProperties":true,"type":"object"},"goalId":{"description":"Goal ID.","maxLength":20000,"type":["string","null"]},"goalIds":{"description":"Goal IDs.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"icon":{"description":"Project icon.","maxLength":20000,"type":["string","null"]},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"leadAgentId":{"description":"Lead agent ID.","maxLength":20000,"type":["string","null"]},"name":{"description":"Project name.","maxLength":500,"minLength":1,"type":"string"},"repositoryIds":{"description":"Authorized repository IDs from list_project_repositories; may contain multiple repositories.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"repositoryUrls":{"description":"Existing HTTPS GitHub repository URLs, including repos absent from the catalog.","items":{"maxLength":2000,"pattern":"^https://github\\.com/(?!\\.{1,2}/)[A-Za-z0-9_.-]+/(?!\\.{1,2}/?$)[A-Za-z0-9_.-]+/?$","type":"string"},"maxItems":100,"type":"array"},"status":{"enum":["backlog","planned","in_progress","completed","cancelled"]},"targetDate":{"description":"Target date.","maxLength":20000,"type":["string","null"]},"workspace":{"additionalProperties":true,"type":"object"}},"required":["idempotencyKey","name"],"type":"object"},"name":"create_project","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"list_project_repositories","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"List authorized repositories with stable IDs and names. Consider appropriate repositories before creating a project; never invent IDs.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"list_project_repositories","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"list_projects","requiredClaims":["discovery:projects:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Inspect available company projects before selecting a project for new work.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"list_projects","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"create_skill","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Create a reusable single-file skill in the company library. Supply a complete SKILL.md whose name and description match the inputs. This saves the skill and shows a card; it does not assign the skill to any agent. Reuse idempotencyKey on retries.","inputSchema":{"additionalProperties":false,"properties":{"description":{"maxLength":2000,"minLength":1,"type":"string"},"idempotencyKey":{"maxLength":240,"minLength":1,"type":"string"},"markdown":{"description":"Complete SKILL.md including name and description frontmatter and substantive instructions.","maxLength":200000,"minLength":1,"type":"string"},"name":{"description":"Lowercase skill name, matching SKILL.md frontmatter.","maxLength":120,"minLength":1,"pattern":"^[a-z0-9]+(?:-[a-z0-9]+)*$","type":"string"},"slug":{"description":"Optional; must equal name.","maxLength":120,"minLength":1,"pattern":"^[a-z0-9]+(?:-[a-z0-9]+)*$","type":"string"}},"required":["idempotencyKey","name","description","markdown"],"type":"object"},"name":"create_skill","outputSchema":{"additionalProperties":true,"type":"object"}}] +[{"annotations":{"exposure":"always","operationId":"get_task_context","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read the active task and actor, including the exact approved Markdown revision when this issue has an accepted plan.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"get_task_context","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"always","operationId":"get_task_history","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read bounded comments on the active task.","inputSchema":{"additionalProperties":false,"properties":{"limit":{"default":50,"maximum":200,"minimum":1,"type":"integer"}},"required":[],"type":"object"},"name":"get_task_history","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"always","operationId":"list_documents","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"List revisioned documents on the active task.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"list_documents","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"always","operationId":"read_document","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read the current revision of one active-task document.","inputSchema":{"additionalProperties":false,"properties":{"key":{"description":"Stable issue-document key.","maxLength":120,"minLength":1,"type":"string"}},"required":["key"],"type":"object"},"name":"read_document","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"always","operationId":"list_document_revisions","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read bounded revision history for one active-task document.","inputSchema":{"additionalProperties":false,"properties":{"key":{"description":"Stable issue-document key.","maxLength":120,"minLength":1,"type":"string"},"limit":{"default":50,"maximum":200,"minimum":1,"type":"integer"}},"required":["key"],"type":"object"},"name":"list_document_revisions","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"always","operationId":"report_progress","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Append a durable progress comment to the active task.","inputSchema":{"additionalProperties":false,"properties":{"body":{"description":"Multiline progress update.","maxLength":20000,"minLength":1,"type":"string"},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"}},"required":["idempotencyKey","body"],"type":"object"},"name":"report_progress","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"answer_status_question","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Append the answer to a status-only wake without changing task disposition.","inputSchema":{"additionalProperties":false,"properties":{"body":{"description":"Concise status answer.","maxLength":20000,"minLength":1,"type":"string"},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"}},"required":["idempotencyKey","body"],"type":"object"},"name":"answer_status_question","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"write_document","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Create or update an active-task document with optimistic revision safety.","inputSchema":{"additionalProperties":false,"properties":{"baseRevisionId":{"description":"Current revision id, or null when creating.","maxLength":20000,"type":["string","null"]},"body":{"description":"Markdown document body.","maxLength":200000,"minLength":1,"type":"string"},"changeSummary":{"description":"Optional revision summary.","maxLength":20000,"type":["string","null"]},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"key":{"description":"Stable issue-document key.","maxLength":120,"minLength":1,"type":"string"},"title":{"description":"Document title.","maxLength":300,"minLength":1,"type":"string"}},"required":["idempotencyKey","key","title","body","baseRevisionId"],"type":"object"},"name":"write_document","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"request_human_input","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Create a typed, durable interaction on the active task.","inputSchema":{"additionalProperties":false,"properties":{"continuationPolicy":{"enum":["none","wake_assignee","wake_assignee_on_accept"]},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"interactionKind":{"enum":["confirmation","checkbox","questions","suggest_tasks","item_verdicts"]},"payload":{"additionalProperties":true,"description":"Kind-specific interaction data. For interactionKind='questions', use version:1 and questions:[{id,prompt,selectionMode:'single'|'multi',required?,options:[{id,label,description?,freeText?}]}]. Choice questions need at least two distinct meaningful options. For an open-ended text answer, ALSO include questionSet:{schema:'paperclip.question_set.v1',questions:[{id,prompt,answerMode:'text',required?}]} with no options or customAnswer in its text questions. Keep matching IDs/prompts in both arrays; the required compatibility questions entry uses selectionMode:'single' and options:[{id:'describe',label:'Your answer',freeText:true}]. Without questionSet this incorrectly renders as a one-option choice. Never use a lone Other or describe option as the presentation. Option keys are id/label, not value. For confirmation, payload may be {}. Keep IDs stable across retries.","type":"object"},"prompt":{"description":"Question or decision prompt.","maxLength":10000,"minLength":1,"type":"string"},"targetRevisionId":{"description":"Optional bound document revision.","maxLength":20000,"type":["string","null"]},"title":{"description":"Interaction card title.","maxLength":300,"minLength":1,"type":"string"}},"required":["idempotencyKey","interactionKind","title","prompt","continuationPolicy"],"type":"object"},"name":"request_human_input","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"register_deliverable","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Register attachment metadata and its artifact work product without credentials or bytes in the tool result.","inputSchema":{"additionalProperties":false,"properties":{"byteSize":{"maximum":100000000,"minimum":0,"type":"integer"},"contentRef":{"description":"Opaque package-local content reference.","maxLength":2000,"minLength":1,"type":"string"},"contentType":{"description":"Media type.","maxLength":200,"minLength":1,"type":"string"},"filename":{"description":"Display filename.","maxLength":500,"minLength":1,"type":"string"},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"sha256":{"pattern":"^[a-fA-F0-9]{64}$","type":"string"},"title":{"description":"Work-product title.","maxLength":500,"minLength":1,"type":"string"}},"required":["idempotencyKey","filename","contentType","byteSize","sha256","contentRef","title"],"type":"object"},"name":"register_deliverable","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"finish_task","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Finish the active task with a durable summary.","inputSchema":{"additionalProperties":false,"properties":{"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"summary":{"description":"Completion summary.","maxLength":20000,"minLength":1,"type":"string"}},"required":["idempotencyKey","summary"],"type":"object"},"name":"finish_task","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"block_task","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Block the active task with a durable reason and optional first-class dependencies.","inputSchema":{"additionalProperties":false,"properties":{"blockedByTaskIds":{"description":"Internal task ids that block this task.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"reason":{"description":"Block reason.","maxLength":20000,"minLength":1,"type":"string"}},"required":["idempotencyKey","reason"],"type":"object"},"name":"block_task","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"always","operationId":"request_review","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Move the active task to review with a durable summary.","inputSchema":{"additionalProperties":false,"properties":{"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"summary":{"description":"Review handoff summary.","maxLength":20000,"minLength":1,"type":"string"}},"required":["idempotencyKey","summary"],"type":"object"},"name":"request_review","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"list_agents","requiredClaims":["discovery:agents:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"List redacted actor profiles.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"list_agents","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"get_agent","requiredClaims":["discovery:agents:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read one redacted actor profile.","inputSchema":{"additionalProperties":false,"properties":{"actorId":{"description":"Actor id.","maxLength":200,"minLength":1,"type":"string"}},"required":["actorId"],"type":"object"},"name":"get_agent","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"search_tasks","requiredClaims":["discovery:tasks:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Search tasks by text and status within the run company.","inputSchema":{"additionalProperties":false,"properties":{"limit":{"default":50,"maximum":200,"minimum":1,"type":"integer"},"query":{"maxLength":500,"type":"string"},"statuses":{"items":{"enum":["backlog","todo","in_progress","in_review","done","blocked","cancelled"]},"maxItems":7,"type":"array","uniqueItems":true}},"required":[],"type":"object"},"name":"search_tasks","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"list_approvals","requiredClaims":["governance:approvals:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"List approvals in the run company.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"list_approvals","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"get_approval","requiredClaims":["governance:approvals:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read one approval without protected data.","inputSchema":{"additionalProperties":false,"properties":{"approvalId":{"description":"Approval id.","maxLength":200,"minLength":1,"type":"string"}},"required":["approvalId"],"type":"object"},"name":"get_approval","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"get_approval_context","requiredClaims":["governance:approvals:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read one approval, its comments, and linked tasks.","inputSchema":{"additionalProperties":false,"properties":{"approvalId":{"description":"Approval id.","maxLength":200,"minLength":1,"type":"string"}},"required":["approvalId"],"type":"object"},"name":"get_approval_context","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"get_workspace_runtime","requiredClaims":["workspace:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Read active-task workspace services.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"get_workspace_runtime","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"control_workspace_service","requiredClaims":["workspace:control"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Start, stop, or fault one active-task workspace service.","inputSchema":{"additionalProperties":false,"properties":{"action":{"enum":["start","stop","fail"]},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"serviceId":{"description":"Workspace service id.","maxLength":200,"minLength":1,"type":"string"},"url":{"description":"Optional service URL.","maxLength":20000,"type":["string","null"]}},"required":["idempotencyKey","serviceId","action"],"type":"object"},"name":"control_workspace_service","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"set_dependencies","requiredClaims":["dependencies:write"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Replace the active task's first-class blocker set.","inputSchema":{"additionalProperties":false,"properties":{"blockedByTaskIds":{"description":"Replacement blocker task ids.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"}},"required":["idempotencyKey","blockedByTaskIds"],"type":"object"},"name":"set_dependencies","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"create_task","requiredClaims":["delegation:tasks:create"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Create a project task from a conversation, or a child from an ordinary task. Persist initialPlan before execution.","inputSchema":{"additionalProperties":false,"properties":{"assigneeActorId":{"description":"Optional agent assignee. Omit to assign the current agent.","maxLength":20000,"type":["string","null"]},"blockedByTaskIds":{"description":"Initial blocker task ids.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"description":{"description":"Child task description.","maxLength":20000,"type":["string","null"]},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"initialPlan":{"description":"Relevant markdown plan saved on the new task before execution starts.","maxLength":200000,"type":["string","null"]},"priority":{"enum":["critical","high","medium","low"]},"projectId":{"description":"Project ID for the task.","type":["string","null"]},"title":{"description":"Child task title.","maxLength":500,"minLength":1,"type":"string"}},"required":["idempotencyKey","title"],"type":"object"},"name":"create_task","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"},"task":{"additionalProperties":false,"properties":{"assigneeActorId":{"type":["string","null"]},"id":{"minLength":1,"type":"string"},"identifier":{"type":["string","null"]},"parentId":{"minLength":1,"type":["string","null"]},"projectId":{"minLength":1,"type":["string","null"]},"status":{"minLength":1,"type":"string"}},"required":["id","identifier","parentId","status","assigneeActorId"],"type":"object"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds","task"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"request_approval","requiredClaims":["governance:approvals:request"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Create a governed approval and waiting posture.","inputSchema":{"additionalProperties":false,"properties":{"approvalType":{"description":"Stable approval type.","maxLength":200,"minLength":1,"type":"string"},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"payload":{"additionalProperties":true,"type":"object"}},"required":["idempotencyKey","approvalType","payload"],"type":"object"},"name":"request_approval","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"decide_approval","requiredClaims":["governance:approvals:decide"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Decide an approval as an explicitly authorized approver.","inputSchema":{"additionalProperties":false,"properties":{"approvalId":{"description":"Approval id.","maxLength":200,"minLength":1,"type":"string"},"decision":{"enum":["approved","rejected","cancelled"]},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"note":{"description":"Decision note.","maxLength":20000,"minLength":1,"type":"string"}},"required":["idempotencyKey","approvalId","decision","note"],"type":"object"},"name":"decide_approval","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"comment_on_approval","requiredClaims":["governance:approvals:comment"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Add a durable comment to an approval.","inputSchema":{"additionalProperties":false,"properties":{"approvalId":{"description":"Approval id.","maxLength":200,"minLength":1,"type":"string"},"body":{"description":"Approval comment.","maxLength":20000,"minLength":1,"type":"string"},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"}},"required":["idempotencyKey","approvalId","body"],"type":"object"},"name":"comment_on_approval","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"schedule_wake","requiredClaims":["control_plane:wakes"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Schedule a deterministic continuation wake.","inputSchema":{"additionalProperties":false,"properties":{"delayTicks":{"maximum":10000,"minimum":1,"type":"integer"},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"payload":{"additionalProperties":true,"type":"object"},"reason":{"enum":["manual","issue_commented","interaction_resolved","approval_resolved","blockers_resolved","scheduled_retry","resume"]}},"required":["idempotencyKey","reason","delayTicks"],"type":"object"},"name":"schedule_wake","outputSchema":{"additionalProperties":false,"properties":{"commandId":{"description":"Stable command identifier.","maxLength":200,"minLength":1,"type":"string"},"disposition":{"enum":["applied","duplicate"]},"entityRefs":{"description":"Entities affected by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"scheduledWakeIds":{"description":"Wake identifiers scheduled by the operation.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"stateRevision":{"minimum":0,"type":"integer"}},"required":["commandId","disposition","stateRevision","entityRefs","scheduledWakeIds"],"type":"object"}},{"annotations":{"exposure":"optional","operationId":"generic_api_request","requiredClaims":["test:generic_api_request"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Test-only escape hatch. Disabled unless the scenario and explicit claim both enable it.","inputSchema":{"additionalProperties":false,"properties":{"body":{"additionalProperties":true,"type":"object"},"method":{"enum":["GET","POST","PATCH"]},"path":{"maxLength":500,"pattern":"^/mock/","type":"string"}},"required":["method","path"],"type":"object"},"name":"generic_api_request","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"search_api","requiredClaims":["api:discover"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Fallback only: discover Paperclip API operations when the available dedicated tools cannot express the task. Prefer dedicated tools for common operations; do not search before using them.","inputSchema":{"additionalProperties":false,"properties":{"cursor":{"maxLength":200,"type":"string"},"limit":{"default":5,"maximum":10,"minimum":1,"type":"integer"},"query":{"maxLength":500,"minLength":1,"type":"string"}},"required":["query"],"type":"object"},"name":"search_api","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"call_api","requiredClaims":["api:call"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Fallback only: call a discovered Paperclip API operation when dedicated tools lack the required operation or parameters. Uses your existing permissions. Prefer dedicated tools; never bypass a denial or runner lifecycle tool.","inputSchema":{"additionalProperties":false,"properties":{"body":{"anyOf":[{"additionalProperties":true,"type":"object"},{"items":{},"type":"array"},{"type":"string"},{"type":"number"},{"type":"boolean"},{"type":"null"}],"description":"Request value matching the discovered schema. For JSON object or array requests, pass the object or array directly, never a JSON-encoded string. Strings are for text bodies or endpoints whose schema explicitly accepts a string."},"contentType":{"maxLength":120,"type":"string"},"files":{"items":{"additionalProperties":false,"oneOf":[{"properties":{"artifactId":{}},"required":["artifactId"]},{"properties":{"path":{}},"required":["path"]}],"properties":{"artifactId":{"type":"string"},"field":{"type":"string"},"path":{"description":"File relative to the active issue workspace. Remote files must first be uploaded as an artifact.","type":"string"}},"type":"object"},"maxItems":10,"type":"array"},"operationId":{"description":"Exact operationId returned by search_api, for example GET /api/projects/{id}. Do not guess identifiers.","maxLength":500,"minLength":1,"type":"string"},"pathParams":{"additionalProperties":{"type":"string"},"type":"object"},"query":{"additionalProperties":true,"type":"object"}},"required":["operationId"],"type":"object"},"name":"call_api","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"create_project","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Create a project after considering existing projects and available repositories. repositoryIds and repositoryUrls accept multiple existing repositories. Use HTTPS GitHub repositoryUrls when an accessible repo is not in the catalog; this registers project repositories, not remote GitHub repositories. Non-code projects may omit repositories. Cannot combine repositoryIds/repositoryUrls with workspace. Reuse the idempotency key on retries.","inputSchema":{"additionalProperties":false,"properties":{"archivedAt":{"description":"Archive timestamp.","maxLength":20000,"type":["string","null"]},"color":{"description":"Project color.","maxLength":20000,"type":["string","null"]},"description":{"description":"Project outcome and context.","maxLength":20000,"type":["string","null"]},"env":{"additionalProperties":true,"type":"object"},"executionWorkspacePolicy":{"additionalProperties":true,"type":"object"},"goalId":{"description":"Goal ID.","maxLength":20000,"type":["string","null"]},"goalIds":{"description":"Goal IDs.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"icon":{"description":"Project icon.","maxLength":20000,"type":["string","null"]},"idempotencyKey":{"description":"Caller-stable retry key.","maxLength":240,"minLength":1,"type":"string"},"leadAgentId":{"description":"Lead agent ID.","maxLength":20000,"type":["string","null"]},"name":{"description":"Project name.","maxLength":500,"minLength":1,"type":"string"},"repositoryIds":{"description":"Authorized repository IDs from list_project_repositories; may contain multiple repositories.","items":{"minLength":1,"type":"string"},"maxItems":200,"type":"array","uniqueItems":true},"repositoryUrls":{"description":"Existing HTTPS GitHub repository URLs, including repos absent from the catalog.","items":{"maxLength":2000,"pattern":"^https://github\\.com/(?!\\.{1,2}/)[A-Za-z0-9_.-]+/(?!\\.{1,2}/?$)[A-Za-z0-9_.-]+/?$","type":"string"},"maxItems":100,"type":"array"},"status":{"enum":["backlog","planned","in_progress","completed","cancelled"]},"targetDate":{"description":"Target date.","maxLength":20000,"type":["string","null"]},"workspace":{"additionalProperties":true,"type":"object"}},"required":["idempotencyKey","name"],"type":"object"},"name":"create_project","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"list_project_repositories","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"List authorized repositories with stable IDs and names. Consider appropriate repositories before creating a project; never invent IDs.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"list_project_repositories","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"list_projects","requiredClaims":["discovery:projects:read"],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Inspect available company projects before selecting a project for new work.","inputSchema":{"additionalProperties":false,"properties":{},"required":[],"type":"object"},"name":"list_projects","outputSchema":{"additionalProperties":true,"type":"object"}},{"annotations":{"exposure":"optional","operationId":"create_skill","requiredClaims":[],"semanticContract":"paperclip.semantic-tool.v1","version":1},"description":"Create a reusable single-file skill in the company library. Supply a complete SKILL.md whose name and description match the inputs. This saves the skill and shows a card; it does not assign the skill to any agent. Reuse idempotencyKey on retries.","inputSchema":{"additionalProperties":false,"properties":{"description":{"maxLength":2000,"minLength":1,"type":"string"},"idempotencyKey":{"maxLength":240,"minLength":1,"type":"string"},"markdown":{"description":"Complete SKILL.md including name and description frontmatter and substantive instructions.","maxLength":200000,"minLength":1,"type":"string"},"name":{"description":"Lowercase skill name, matching SKILL.md frontmatter.","maxLength":120,"minLength":1,"pattern":"^[a-z0-9]+(?:-[a-z0-9]+)*$","type":"string"},"slug":{"description":"Optional; must equal name.","maxLength":120,"minLength":1,"pattern":"^[a-z0-9]+(?:-[a-z0-9]+)*$","type":"string"}},"required":["idempotencyKey","name","description","markdown"],"type":"object"},"name":"create_skill","outputSchema":{"additionalProperties":true,"type":"object"}}] diff --git a/packages/paperclip-runner/protocol/fixtures/evals/native-execution-seeded.json b/packages/paperclip-runner/protocol/fixtures/evals/native-execution-seeded.json index 7dbc80557ef..b4a9412ef41 100644 --- a/packages/paperclip-runner/protocol/fixtures/evals/native-execution-seeded.json +++ b/packages/paperclip-runner/protocol/fixtures/evals/native-execution-seeded.json @@ -24,7 +24,7 @@ "prpVersion": 1, "nativeExecutionVersion": 1, "catalogVersion": 1, - "catalogSha256": "sha256:e2491dd8cb6629b19b80ebd38a0698f7e3b8880eb8915c82c549852060419a3a", + "catalogSha256": "sha256:5c700d06dc9073b91589cbbda1f7cbfe2faff1092686626362baab4d16a9bffd", "driverContractVersion": 1, "driverKind": "paperclip-deterministic", "driverVersion": "1.0.0" diff --git a/packages/paperclip-runner/protocol/manifest.json b/packages/paperclip-runner/protocol/manifest.json index 910c75393dd..411c143b797 100644 --- a/packages/paperclip-runner/protocol/manifest.json +++ b/packages/paperclip-runner/protocol/manifest.json @@ -160,7 +160,7 @@ }, { "path": "fixtures/evals/native-execution-seeded.json", - "sha256": "ffb22f6d0cdd39f5fa74220a035f4d1cc93ec2ca1cdde3d876c25dde5c82bf8b", + "sha256": "d53e1f42dc422a873c800f30e628dd434faea5b64dcee170bef9c0ef9a61446a", "expectation": "accept", "compatibilityCase": "canonical" }, diff --git a/packages/paperclip-runner/runner/crates/runner-core/src/bin/fake-codex-app-server.rs b/packages/paperclip-runner/runner/crates/runner-core/src/bin/fake-codex-app-server.rs index 696c214d2d8..f39f9341321 100644 --- a/packages/paperclip-runner/runner/crates/runner-core/src/bin/fake-codex-app-server.rs +++ b/packages/paperclip-runner/runner/crates/runner-core/src/bin/fake-codex-app-server.rs @@ -607,6 +607,7 @@ fn run() -> Result<(), Box> { .any(|value| value == "--require-existing-resume-state") && !state_path.exists(); let call_log = argument(&args, "--call-log").map(PathBuf::from); + let request_log = argument(&args, "--request-log").map(PathBuf::from); if args.iter().any(|value| value == "--record-process-start") { log_call(call_log.as_deref(), "process-start")?; } @@ -966,6 +967,13 @@ fn run() -> Result<(), Box> { continue; }; log_call(call_log.as_deref(), method)?; + log_call(request_log.as_deref(), &serde_json::to_string(&message)?)?; + if require_skill_instructions + && matches!(method, "thread/start" | "thread/resume") + && message.pointer("/params/config/skills.include_instructions") != Some(&json!(true)) + { + return Err("thread request omitted skills.include_instructions=true".into()); + } let id = message.get("id").cloned(); match method { "initialize" => { diff --git a/packages/paperclip-runner/runner/crates/runner-core/src/codex_provider.rs b/packages/paperclip-runner/runner/crates/runner-core/src/codex_provider.rs index 3356b63fb39..1854de6d446 100644 --- a/packages/paperclip-runner/runner/crates/runner-core/src/codex_provider.rs +++ b/packages/paperclip-runner/runner/crates/runner-core/src/codex_provider.rs @@ -353,9 +353,51 @@ pub struct CodexProviderConfig { pub approval_policy: String, #[serde(default)] pub externally_sandboxed: bool, + // Older persisted configurations deliberately retain the provider default. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub include_skill_instructions: Option, +} + +/// Explicit per-turn skill selection. The controller resolves assigned skill +/// names to paths on the provider filesystem before submitting the command. +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +#[serde(deny_unknown_fields)] +pub struct CodexSkillInput { + #[serde(rename = "type")] + pub input_type: String, + pub name: String, + pub path: String, +} + +impl CodexSkillInput { + pub fn validate(&self) -> Result<(), LocalRunnerError> { + if self.input_type != "skill" + || self.name.is_empty() + || self.name.len() > 256 + || !self + .name + .chars() + .all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_') + || self.path.contains('\0') + || self.path.len() > 4096 + || !std::path::Path::new(&self.path).is_absolute() + { + return Err(LocalRunnerError::invalid( + "invalid explicit Codex skill input", + )); + } + Ok(()) + } } impl CodexProviderConfig { + fn skill_instructions_config(&self) -> Option { + (self.provider == "codex") + .then_some(self.include_skill_instructions) + .flatten() + .map(|include| json!({"skills.include_instructions": include})) + } + pub fn validate(&self) -> Result<(), LocalRunnerError> { if !matches!( (self.provider.as_str(), self.driver.as_str()), @@ -1010,6 +1052,9 @@ impl CodexProvider { ); } } + if let Some(skill_config) = config.skill_instructions_config() { + params_object.insert("config".to_owned(), skill_config); + } let method = if let Some(thread_id) = resume_thread_id { params_object.insert("threadId".to_owned(), json!(thread_id)); if config.provider == "codex" { @@ -1583,6 +1628,23 @@ impl CodexProvider { } pub fn start_turn(&mut self, message: &str, cwd: &str) -> Result { + self.start_turn_with_skills(message, cwd, &[]) + } + + pub fn start_turn_with_skills( + &mut self, + message: &str, + cwd: &str, + skills: &[CodexSkillInput], + ) -> Result { + if skills.len() > 64 || (self.config.provider != "codex" && !skills.is_empty()) { + return Err(LocalRunnerError::invalid( + "explicit skills require Codex and at most 64 selections", + )); + } + for skill in skills { + skill.validate()?; + } if self.quarantined { return Err(LocalRunnerError::invalid( "Codex provider is quarantined after unsafe recovered work", @@ -1612,11 +1674,13 @@ impl CodexProvider { let prior_buffered_message_count = self.pending_messages.len(); self.ambiguous_turn_start_pending = true; let runtime_request_scope = new_runtime_request_scope()?; + let mut input = vec![json!({"type": "text", "text": message, "text_elements": []})]; + input.extend(skills.iter().map(|skill| json!(skill))); let mut turn_params = json!({ "threadId": self.thread_id, "cwd": cwd, "runtimeWorkspaceRoots": [cwd], - "input": [{"type": "text", "text": message, "text_elements": []}], + "input": input, }); let turn_params_object = turn_params .as_object_mut() @@ -3909,6 +3973,7 @@ done instructions: "Test only.".to_owned(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }; let mut provider = CodexProvider::start(&config, None).unwrap(); provider.start_turn("First turn", &config.cwd).unwrap(); @@ -4269,6 +4334,7 @@ done instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }; let mut spawned = None; let mut failure = None; @@ -4369,7 +4435,14 @@ done instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }; + config.include_skill_instructions = Some(true); + assert_eq!( + config.skill_instructions_config(), + None, + "OpenCode must not receive Codex skill settings" + ); config.validate().unwrap(); config.provider_version = "1.18.18".to_owned(); let error = config.validate().unwrap_err(); diff --git a/packages/paperclip-runner/runner/crates/runner-core/src/provider_backend.rs b/packages/paperclip-runner/runner/crates/runner-core/src/provider_backend.rs index 6f9a9533fec..6b04cdd71e5 100644 --- a/packages/paperclip-runner/runner/crates/runner-core/src/provider_backend.rs +++ b/packages/paperclip-runner/runner/crates/runner-core/src/provider_backend.rs @@ -13,8 +13,9 @@ use serde_json::{json, Value}; use sha2::{Digest, Sha256}; use crate::codex_provider::{ - CodexProvider, CodexProviderConfig, CodexProviderEvent, ProviderStartupObservation, - ProviderStartupStage, RejectedAcceptedTurn, MAX_SETTLED_PROVIDER_TURN_IDS, + CodexProvider, CodexProviderConfig, CodexProviderEvent, CodexSkillInput, + ProviderStartupObservation, ProviderStartupStage, RejectedAcceptedTurn, + MAX_SETTLED_PROVIDER_TURN_IDS, }; use crate::durable::{ create_private_temporary_file, current_unix_ms, open_private_regular_file, @@ -2199,7 +2200,7 @@ impl CodexCommandExecutor { } fn prepare(&mut self, payload: &Value) -> Result { - let config: CodexProviderConfig = serde_json::from_value( + let mut config: CodexProviderConfig = serde_json::from_value( payload .get("provider") .cloned() @@ -2208,6 +2209,11 @@ impl CodexCommandExecutor { .map_err(|error| { DurableRunnerError::invalid(format!("run.prepare provider is invalid: {error}")) })?; + // This field used to be discarded for every facade. Keep non-Codex + // persisted profiles unchanged even when an older controller sends it. + if config.provider != "codex" { + config.include_skill_instructions = None; + } config .validate() .map_err(|error| DurableRunnerError::invalid(error.to_string()))?; @@ -2436,11 +2442,15 @@ impl CodexCommandExecutor { .map_err(|_| { DurableRunnerError::invalid("run.attach runtime launch arguments are invalid") })?; + let mut upgraded_skill_config = false; if let Some(provider) = payload.get("provider") { let mut config: CodexProviderConfig = serde_json::from_value(provider.clone()) .map_err(|error| { DurableRunnerError::invalid(format!("run.attach provider is invalid: {error}")) })?; + if config.provider != "codex" { + config.include_skill_instructions = None; + } config .validate() .map_err(|error| DurableRunnerError::invalid(error.to_string()))?; @@ -2451,6 +2461,17 @@ impl CodexCommandExecutor { { config.args = next_state.config.args.clone(); } + // Pre-fix checkpoints dropped this field. A fresh settled run may + // adopt the explicit controller setting once, then must reopen the + // same thread so the provider receives it. Known settings remain + // immutable within this profile, like the other durable fields. + if next_state.config.provider == "codex" + && next_state.config.include_skill_instructions.is_none() + && config.include_skill_instructions.is_some() + { + next_state.config.include_skill_instructions = config.include_skill_instructions; + upgraded_skill_config = true; + } if config != next_state.config { return Err(DurableRunnerError::invalid( "run.attach cannot change the durable Codex provider profile", @@ -2500,6 +2521,7 @@ impl CodexCommandExecutor { next_state.last_agent_message = None; let retained_provider = if let Some(provider) = self.provider.as_mut() { !runtime_launch_changed + && !upgraded_skill_config && provider .attach_run_in_place( next_state.tool_bridge.authorized_tools().cloned(), @@ -2852,6 +2874,21 @@ impl CodexCommandExecutor { } fn start_turn(&mut self, payload: &Value) -> Result { + // Validate before recovery or marking dispatch ambiguous: malformed + // selections must not launch a provider or poison a durable session. + let skills: Vec = + serde_json::from_value(payload.get("skills").cloned().unwrap_or_else(|| json!([]))) + .map_err(|error| { + DurableRunnerError::invalid(format!("invalid turn.start skills: {error}")) + })?; + if skills.len() > 64 { + return Err(DurableRunnerError::invalid("too many turn.start skills")); + } + for skill in &skills { + skill + .validate() + .map_err(|error| DurableRunnerError::invalid(error.to_string()))?; + } self.restore_provider_if_needed()?; if self .state @@ -2911,6 +2948,14 @@ impl CodexCommandExecutor { .config .cwd .clone(); + if !skills.is_empty() + && self + .state + .as_ref() + .is_some_and(|state| state.config.provider != "codex") + { + return Err(DurableRunnerError::invalid("explicit skills require Codex")); + } self.ensure_provider()?; { let state = self @@ -2927,7 +2972,7 @@ impl CodexCommandExecutor { rejected_accepted_turn, ) = { let provider = self.ensure_provider()?; - let result = provider.start_turn(text, &cwd); + let result = provider.start_turn_with_skills(text, &cwd, &skills); ( result, provider.completed_turn_authority().is_some(), @@ -4851,6 +4896,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, Some(CompletionContractBinding { revision: "revision-1".to_owned(), @@ -5211,6 +5257,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, Some(CompletionContractBinding { revision: "revision-1".to_owned(), @@ -5300,6 +5347,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, opencode_launch_profile_digest: None, completion_contract: None, @@ -5351,6 +5399,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, None, ProviderToolBridge::default(), @@ -5392,6 +5441,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, Some(CompletionContractBinding { revision: "1".to_owned(), @@ -5483,6 +5533,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, None, ProviderToolBridge::default(), @@ -5548,6 +5599,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, None, ProviderToolBridge::default(), @@ -5596,6 +5648,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, None, ProviderToolBridge::default(), @@ -5718,6 +5771,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, None, bridge, @@ -5828,6 +5882,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, None, bridge, @@ -5883,6 +5938,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, None, ProviderToolBridge::default(), @@ -6002,6 +6058,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, None, bridge, @@ -6041,6 +6098,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, None, ProviderToolBridge::default(), @@ -6077,6 +6135,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, None, ProviderToolBridge::default(), @@ -6152,6 +6211,7 @@ mod tests { instructions: String::new(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, }, None, ProviderToolBridge::default(), diff --git a/packages/paperclip-runner/runner/crates/runner-core/tests/codex_provider.rs b/packages/paperclip-runner/runner/crates/runner-core/tests/codex_provider.rs index e02389e8191..356e2fd1401 100644 --- a/packages/paperclip-runner/runner/crates/runner-core/tests/codex_provider.rs +++ b/packages/paperclip-runner/runner/crates/runner-core/tests/codex_provider.rs @@ -65,6 +65,7 @@ fn provider_config(directory: &Path, switches: &[&str]) -> CodexProviderConfig { instructions: "Stay inside the test workspace.".to_owned(), approval_policy: "never".to_owned(), externally_sandboxed: false, + include_skill_instructions: None, } } @@ -6098,3 +6099,134 @@ fn lightweight_history_repeated_cursor_is_not_idle_evidence() { provider.shutdown().unwrap(); fs::remove_dir_all(directory).unwrap(); } + +fn skill_wire_requests(directory: &Path) -> Vec { + fs::read_to_string(directory.join("requests.ndjson")) + .unwrap() + .lines() + .map(|line| serde_json::from_str(line).unwrap()) + .collect() +} + +#[test] +fn skill_instructions_flag_reaches_start_and_resume_and_preserves_absent_config() { + for flag in [Some(true), Some(false), None] { + let directory = temporary_directory("skill-config-wire"); + let log = directory.join("requests.ndjson"); + let config = provider_config(&directory, &["--request-log", log.to_str().unwrap()]); + // Exercise exactly the JSON boundary used by run.prepare (old persisted + // configurations omit the field entirely). + let mut value = serde_json::to_value(config).unwrap(); + value + .as_object_mut() + .unwrap() + .remove("includeSkillInstructions"); + if let Some(flag) = flag { + value["includeSkillInstructions"] = json!(flag); + } + let config: CodexProviderConfig = serde_json::from_value(value).unwrap(); + let mut provider = CodexProvider::start(&config, None).unwrap(); + let thread_id = provider.thread_id().to_owned(); + provider.shutdown().unwrap(); + let mut resumed = CodexProvider::start(&config, Some(&thread_id)).unwrap(); + resumed.shutdown().unwrap(); + let frames = skill_wire_requests(&directory); + for method in ["thread/start", "thread/resume"] { + let frame = frames.iter().find(|v| v["method"] == method).unwrap(); + assert_eq!( + frame.pointer("/params/config/skills.include_instructions"), + flag.as_ref().map(|f| if *f { + &Value::Bool(true) + } else { + &Value::Bool(false) + }), + "{method}: {flag:?}" + ); + } + fs::remove_dir_all(directory).unwrap(); + } +} + +#[test] +fn explicit_skill_input_survives_durable_turn_and_cold_restore() { + let directory = temporary_directory("skill-input-wire"); + let log = directory.join("requests.ndjson"); + let config = provider_config(&directory, &["--request-log", log.to_str().unwrap()]); + let runner_config = durable_config(&directory); + let mut executor = CodexCommandExecutor::with_runner_config(&directory, &runner_config); + executor + .execute(&command( + "prepare", + 1, + "run.prepare", + json!({"provider": config}), + )) + .unwrap(); + executor + .execute(&command("open", 2, "session.open", json!({}))) + .unwrap(); + executor.shutdown().unwrap(); + drop(executor); + let mut restored = CodexCommandExecutor::with_runner_config(&directory, &runner_config); + let skill = json!({"type":"skill", "name":"first-task", "path":"/materialized/skills/first-task/SKILL.md"}); + restored + .execute(&command( + "turn", + 3, + "turn.start", + json!({"text":"$first-task Continue after approval", "skills":[skill]}), + )) + .unwrap(); + restored.shutdown().unwrap(); + let frames = skill_wire_requests(&directory); + assert!(frames.iter().any(|f| f["method"] == "thread/resume")); + let turn = frames.iter().find(|f| f["method"] == "turn/start").unwrap(); + assert_eq!(turn["params"]["input"][1], skill); + fs::remove_dir_all(directory).unwrap(); +} + +#[test] +fn skill_flag_can_be_added_to_an_old_checkpoint_at_settled_run_attach() { + let directory = temporary_directory("skill-old-checkpoint"); + let log = directory.join("requests.ndjson"); + let mut config = provider_config(&directory, &["--request-log", log.to_str().unwrap()]); + let runner_config = durable_config(&directory); + let mut executor = CodexCommandExecutor::with_runner_config(&directory, &runner_config); + executor + .execute(&command( + "prepare", + 1, + "run.prepare", + json!({"provider": config}), + )) + .unwrap(); + executor + .execute(&command("open", 2, "session.open", json!({}))) + .unwrap(); + for _ in 0..8 { + poll_and_ack(&mut executor).unwrap(); + } + config.include_skill_instructions = Some(true); + executor + .execute(&command( + "attach", + 3, + "run.attach", + json!({"provider": config}), + )) + .unwrap(); + executor + .execute(&command("turn", 4, "turn.start", json!({"text":"New run"}))) + .unwrap(); + executor.shutdown().unwrap(); + let frames = skill_wire_requests(&directory); + let resume = frames + .iter() + .rfind(|f| f["method"] == "thread/resume") + .unwrap(); + assert_eq!( + resume["params"]["config"]["skills.include_instructions"], + true + ); + fs::remove_dir_all(directory).unwrap(); +} diff --git a/packages/paperclip-runner/spec/capability/capabilities.yaml b/packages/paperclip-runner/spec/capability/capabilities.yaml index 3aba87fa444..a065c90caf6 100644 --- a/packages/paperclip-runner/spec/capability/capabilities.yaml +++ b/packages/paperclip-runner/spec/capability/capabilities.yaml @@ -2084,9 +2084,9 @@ ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:issue-thread-confirmations:984", + "id": "skill:skills/paperclip/references/api-reference.md:issue-thread-confirmations:993", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:984", + "sourceAnchor": "skills/paperclip/references/api-reference.md:993", "title": "Issue-thread confirmations", "expectedSemantics": "Skill guidance headed “Issue-thread confirmations”.", "primaryDisposition": "always_agent_tool", @@ -2095,13 +2095,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:984" + "skill:skills/paperclip/references/api-reference.md:993" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:checkbox-confirmations:1042", + "id": "skill:skills/paperclip/references/api-reference.md:checkbox-confirmations:1051", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1042", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1051", "title": "Checkbox confirmations", "expectedSemantics": "Skill guidance headed “Checkbox confirmations”.", "primaryDisposition": "always_agent_tool", @@ -2110,13 +2110,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1042" + "skill:skills/paperclip/references/api-reference.md:1051" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:item-verdict-requests:1157", + "id": "skill:skills/paperclip/references/api-reference.md:item-verdict-requests:1166", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1157", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1166", "title": "Item verdict requests", "expectedSemantics": "Skill guidance headed “Item verdict requests”.", "primaryDisposition": "optional_agent_tool", @@ -2125,13 +2125,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1157" + "skill:skills/paperclip/references/api-reference.md:1166" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:checking-approval-status:1267", + "id": "skill:skills/paperclip/references/api-reference.md:checking-approval-status:1276", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1267", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1276", "title": "Checking approval status", "expectedSemantics": "Skill guidance headed “Checking approval status”.", "primaryDisposition": "optional_agent_tool", @@ -2140,13 +2140,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1267" + "skill:skills/paperclip/references/api-reference.md:1276" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:approval-follow-up-requesting-agent:1273", + "id": "skill:skills/paperclip/references/api-reference.md:approval-follow-up-requesting-agent:1282", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1273", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1282", "title": "Approval follow-up (requesting agent)", "expectedSemantics": "Skill guidance headed “Approval follow-up (requesting agent)”.", "primaryDisposition": "always_agent_tool", @@ -2155,13 +2155,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1273" + "skill:skills/paperclip/references/api-reference.md:1282" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:issue-lifecycle:1291", + "id": "skill:skills/paperclip/references/api-reference.md:issue-lifecycle:1300", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1291", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1300", "title": "Issue Lifecycle", "expectedSemantics": "Skill guidance headed “Issue Lifecycle”.", "primaryDisposition": "always_agent_tool", @@ -2170,13 +2170,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1291" + "skill:skills/paperclip/references/api-reference.md:1300" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:error-handling:1321", + "id": "skill:skills/paperclip/references/api-reference.md:error-handling:1330", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1321", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1330", "title": "Error Handling", "expectedSemantics": "Skill guidance headed “Error Handling”.", "primaryDisposition": "control_plane_owned", @@ -2185,13 +2185,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1321" + "skill:skills/paperclip/references/api-reference.md:1330" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:full-api-reference:1335", + "id": "skill:skills/paperclip/references/api-reference.md:full-api-reference:1344", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1335", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1344", "title": "Full API Reference", "expectedSemantics": "Skill guidance headed “Full API Reference”.", "primaryDisposition": "optional_agent_tool", @@ -2200,13 +2200,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1335" + "skill:skills/paperclip/references/api-reference.md:1344" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:agents:1337", + "id": "skill:skills/paperclip/references/api-reference.md:agents:1346", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1337", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1346", "title": "Agents", "expectedSemantics": "Skill guidance headed “Agents”.", "primaryDisposition": "optional_agent_tool", @@ -2215,13 +2215,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1337" + "skill:skills/paperclip/references/api-reference.md:1346" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:issues-tasks:1358", + "id": "skill:skills/paperclip/references/api-reference.md:issues-tasks:1367", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1358", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1367", "title": "Issues (Tasks)", "expectedSemantics": "Skill guidance headed “Issues (Tasks)”.", "primaryDisposition": "optional_agent_tool", @@ -2230,13 +2230,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1358" + "skill:skills/paperclip/references/api-reference.md:1367" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:companies-projects-goals:1398", + "id": "skill:skills/paperclip/references/api-reference.md:companies-projects-goals:1407", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1398", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1407", "title": "Companies, Projects, Goals", "expectedSemantics": "Skill guidance headed “Companies, Projects, Goals”.", "primaryDisposition": "optional_agent_tool", @@ -2245,13 +2245,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1398" + "skill:skills/paperclip/references/api-reference.md:1407" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:routines:1422", + "id": "skill:skills/paperclip/references/api-reference.md:routines:1431", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1422", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1431", "title": "Routines", "expectedSemantics": "Skill guidance headed “Routines”.", "primaryDisposition": "optional_agent_tool", @@ -2260,13 +2260,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1422" + "skill:skills/paperclip/references/api-reference.md:1431" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:approvals-costs-activity-dashboard:1438", + "id": "skill:skills/paperclip/references/api-reference.md:approvals-costs-activity-dashboard:1447", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1438", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1447", "title": "Approvals, Costs, Activity, Dashboard", "expectedSemantics": "Skill guidance headed “Approvals, Costs, Activity, Dashboard”.", "primaryDisposition": "optional_agent_tool", @@ -2275,13 +2275,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1438" + "skill:skills/paperclip/references/api-reference.md:1447" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:secrets:1460", + "id": "skill:skills/paperclip/references/api-reference.md:secrets:1469", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1460", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1469", "title": "Secrets", "expectedSemantics": "Skill guidance headed “Secrets”.", "primaryDisposition": "optional_agent_tool", @@ -2290,13 +2290,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1460" + "skill:skills/paperclip/references/api-reference.md:1469" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:agent-secret-proposals:1473", + "id": "skill:skills/paperclip/references/api-reference.md:agent-secret-proposals:1482", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1473", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1482", "title": "Agent secret proposals", "expectedSemantics": "Skill guidance headed “Agent secret proposals”.", "primaryDisposition": "optional_agent_tool", @@ -2305,13 +2305,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1473" + "skill:skills/paperclip/references/api-reference.md:1482" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:agent-secret-access:1573", + "id": "skill:skills/paperclip/references/api-reference.md:agent-secret-access:1582", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1573", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1582", "title": "Agent secret access", "expectedSemantics": "Skill guidance headed “Agent secret access”.", "primaryDisposition": "optional_agent_tool", @@ -2320,13 +2320,13 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1573" + "skill:skills/paperclip/references/api-reference.md:1582" ] }, { - "id": "skill:skills/paperclip/references/api-reference.md:common-mistakes:1613", + "id": "skill:skills/paperclip/references/api-reference.md:common-mistakes:1622", "sourceKind": "skill_heading", - "sourceAnchor": "skills/paperclip/references/api-reference.md:1613", + "sourceAnchor": "skills/paperclip/references/api-reference.md:1622", "title": "Common Mistakes", "expectedSemantics": "Skill guidance headed “Common Mistakes”.", "primaryDisposition": "optional_agent_tool", @@ -2335,7 +2335,7 @@ "control_plane_invariant" ], "evidenceIds": [ - "skill:skills/paperclip/references/api-reference.md:1613" + "skill:skills/paperclip/references/api-reference.md:1622" ] } ] diff --git a/packages/paperclip-runner/src/backends/codex-native-backend.ts b/packages/paperclip-runner/src/backends/codex-native-backend.ts index 905a76c638f..f1042a98543 100644 --- a/packages/paperclip-runner/src/backends/codex-native-backend.ts +++ b/packages/paperclip-runner/src/backends/codex-native-backend.ts @@ -11,6 +11,7 @@ import type { CodexWorkingDirectoryAuthority } from "../drivers/codex/codex-boun import { HarnessDriverBackend } from "./harness-driver-backend.js"; import { nativeSystemInstructions, + nativeTaskSkillInputs, nativeTaskConstraints, } from "./runtime-context.js"; @@ -139,6 +140,12 @@ function createTransportBackedNativeSessionBackend( : "never", baseInstructions: nativeSystemInstructions(input), includeSkillInstructions: isCodex && "runtimeContext" in input, + skillInputs: isCodex + ? nativeTaskSkillInputs( + input.task.description, + "runtimeContext" in input ? input.runtimeContext : null, + ) + : [], requestedCollaborationMode: supportsCollaborativePlanning && "executionMode" in input ? input.executionMode diff --git a/packages/paperclip-runner/src/backends/runtime-context.test.ts b/packages/paperclip-runner/src/backends/runtime-context.test.ts index e14f4575af8..3208b665775 100644 --- a/packages/paperclip-runner/src/backends/runtime-context.test.ts +++ b/packages/paperclip-runner/src/backends/runtime-context.test.ts @@ -16,6 +16,7 @@ import { } from "../contracts/native-execution.js"; import { nativeSystemInstructions, + nativeTaskSkillInputs, nativeTaskConstraints, } from "./runtime-context.js"; @@ -366,3 +367,30 @@ describe("native runtime context files", () => { ).toThrow("native_runtime_context_entry_outside_bundle"); }); }); + + +describe("explicit task skill selection", () => { + const context = { + skills: [{ key: "company/onboarding", runtimeName: "first-task", bundle: { rootPath: "/assigned/content-addressed-bundle" } }, + { key: "company/research", runtimeName: "research", bundle: { rootPath: "/assigned/research" } }], + } as unknown as import("../contracts/runtime-context.js").NativeRuntimeContextSnapshot; + it("resolves the actual assigned path for initial and subsequent onboarding wakes", () => { + const description = "Use the `first-task` skill (/first-task) for this onboarding task, including subsequent wakes."; + for (const _wake of ["opening", "approval", "cold resume"]) { + expect(nativeTaskSkillInputs(description, context)).toEqual([ + { type: "skill", name: "first-task", path: "/assigned/content-addressed-bundle/SKILL.md" }, + ]); + } + }); + it("does not invoke skills merely because they are assigned to the agent", () => { + for (const description of [null, "Write a welcome note", "my first-task", "Inspect /first-task/SKILL.md", "https://example.com/first-task"]) { + expect(nativeTaskSkillInputs(description, context)).toEqual([]); + } + }); + it("supports generic explicit references, deduplicates them, and ignores unassigned skills", () => { + expect(nativeTaskSkillInputs("$research then /research and /not-assigned", context)).toEqual([ + { type: "skill", name: "research", path: "/assigned/research/SKILL.md" }, + ]); + expect(nativeTaskSkillInputs("/first-task", null)).toEqual([]); + }); +}); diff --git a/packages/paperclip-runner/src/backends/runtime-context.ts b/packages/paperclip-runner/src/backends/runtime-context.ts index 1a1b709d87a..39a84a86fa8 100644 --- a/packages/paperclip-runner/src/backends/runtime-context.ts +++ b/packages/paperclip-runner/src/backends/runtime-context.ts @@ -2,7 +2,11 @@ import { readFileSync, realpathSync } from "node:fs"; import { isAbsolute, relative, resolve, sep } from "node:path"; import { CODEX_SKILLLESS_BASE_INSTRUCTIONS } from "../contracts/codex.js"; import type { NativeExecutionInput } from "../contracts/native-execution.js"; -import { composeNativeSystemInstructions } from "../contracts/runtime-context.js"; +import { + type NativeRuntimeContextSnapshot, + type NativeSkillInput, + composeNativeSystemInstructions, +} from "../contracts/runtime-context.js"; export function nativeSystemInstructions(input: NativeExecutionInput): string { if (!("runtimeContext" in input)) return CODEX_SKILLLESS_BASE_INSTRUCTIONS; @@ -105,3 +109,27 @@ export function nativeTaskConstraints(input: NativeExecutionInput): string[] { finalResponseConstraint, ]; } + +/** + * Resolve explicit /skill or $skill references only from the current task's + * description, never agent-wide assignments, comments, or previous task history. + * Recomputed per run so approval wakes retain the invocation without leaking it + * into ordinary tasks assigned to the same agent. + */ +export function nativeTaskSkillInputs( + description: string | null, + context: NativeRuntimeContextSnapshot | null, +): NativeSkillInput[] { + if (!description || !context) return []; + const names = new Set(Array.from( + description.matchAll(/(?:^|[\s(`])[$/]([a-zA-Z0-9_-]+)(?=$|[\s)`,.;:!?])/g), + (match) => match[1], + )); + return context.skills + .filter((skill) => names.has(skill.runtimeName)) + .map((skill) => ({ + type: "skill", + name: skill.runtimeName, + path: resolve(skill.bundle.rootPath, "SKILL.md"), + })); +} diff --git a/packages/paperclip-runner/src/contracts/runtime-context.ts b/packages/paperclip-runner/src/contracts/runtime-context.ts index f9d1c1f74a9..494285c72b5 100644 --- a/packages/paperclip-runner/src/contracts/runtime-context.ts +++ b/packages/paperclip-runner/src/contracts/runtime-context.ts @@ -144,3 +144,10 @@ export function composeNativeSystemInstructions(context: NativeRuntimeContextSna `Read-only instruction sibling root: ${context.instructions.bundle.rootPath}`, ].filter(Boolean).join("\n\n"); } + +/** Explicit per-turn selection; availability alone never invokes a skill. */ +export interface NativeSkillInput { + type: "skill"; + name: string; + path: string; +} diff --git a/packages/paperclip-runner/src/drivers/acpx/native-skill-prompt.test.ts b/packages/paperclip-runner/src/drivers/acpx/native-skill-prompt.test.ts new file mode 100644 index 00000000000..e605d83428c --- /dev/null +++ b/packages/paperclip-runner/src/drivers/acpx/native-skill-prompt.test.ts @@ -0,0 +1,28 @@ +import { describe, expect, it } from "vitest"; +import { claudeNativeSkillPrompt } from "./native-skill-prompt.js"; + +const envelope = (description: unknown, prompt = "Write the welcome note now.") => JSON.stringify({ + schema: "paperclip.native-model-envelope.v2", + task: { description, prompt }, + interactionResponses: [{ response: { status: "accepted" } }], +}); + +describe("Claude native task skill invocation", () => { + it.each(["Use the `first-task` skill (/first-task).", "$first-task"])("invokes %s before the unchanged current request", (description) => { + const text = envelope(description); + expect(claudeNativeSkillPrompt(text, ["first-task", "paperclip"])).toBe(`/first-task ${text}`); + }); + it.each([ + envelope("Ordinary task", "Please mention /first-task in the output."), + envelope("/not-assigned"), envelope(null), envelope("/first-task-extra"), + JSON.stringify({ schema: "another-envelope", task: { description: "/first-task" } }), + "Use /first-task", "null", "[]", + ])("does not invoke from unrelated or malformed input: %s", (text) => { + expect(claudeNativeSkillPrompt(text, ["first-task"])).toBe(text); + }); + it("does not invent an assignment or pick between multiple requested skills", () => { + const text = envelope("/first-task and /research"); + expect(claudeNativeSkillPrompt(text, [])).toBe(text); + expect(claudeNativeSkillPrompt(text, ["first-task", "research"])).toBe(text); + }); +}); diff --git a/packages/paperclip-runner/src/drivers/acpx/native-skill-prompt.ts b/packages/paperclip-runner/src/drivers/acpx/native-skill-prompt.ts new file mode 100644 index 00000000000..a94a556e8c8 --- /dev/null +++ b/packages/paperclip-runner/src/drivers/acpx/native-skill-prompt.ts @@ -0,0 +1,22 @@ +import { NATIVE_MODEL_ENVELOPE_SCHEMA } from "../../contracts/native-execution.js"; + +/** Invoke one unambiguously selected assigned skill through Claude's native + * command parser. Keep the complete envelope as its argument, including the + * current request and approval context. Comments never select a command. + * Multiple selections remain available to the Skill tool rather than picking one. + */ +export function claudeNativeSkillPrompt(text: string, assignedNames: readonly string[]): string { + let envelope: unknown; + try { envelope = JSON.parse(text); } catch { return text; } + if (!envelope || typeof envelope !== "object" || Array.isArray(envelope)) return text; + const value = envelope as Record; + if (value.schema !== NATIVE_MODEL_ENVELOPE_SCHEMA || !value.task || typeof value.task !== "object") return text; + const description = (value.task as Record).description; + if (typeof description !== "string") return text; + const references = new Set(Array.from( + description.matchAll(/(?:^|[\s(`])[$/]([a-zA-Z0-9_-]+)(?=$|[\s)`,.;:!?])/g), + (match) => match[1], + )); + const selected = [...new Set(assignedNames)].filter((name) => references.has(name)); + return selected.length === 1 ? `/${selected[0]} ${text}` : text; +} diff --git a/packages/paperclip-runner/src/drivers/acpx/runtime-host.test.ts b/packages/paperclip-runner/src/drivers/acpx/runtime-host.test.ts index fdae735e86e..f6b637a4f16 100644 --- a/packages/paperclip-runner/src/drivers/acpx/runtime-host.test.ts +++ b/packages/paperclip-runner/src/drivers/acpx/runtime-host.test.ts @@ -276,17 +276,22 @@ describe("ACPX runtime host", () => { aggregateDigest: canonicalNativeRuntimeContextDigest(snapshot), }; let skillsHome = ""; + const providerStartTurn = vi.fn(() => runtimeTurn()); let assigned = true; + let expectedReference = "ASSIGNED_SKILL_MARKER"; const dependencies = fixture.dependencies({ openRuntime: async (options) => { skillsHome = join(options.launchEnvironment.CLAUDE_CONFIG_DIR!, "skills"); expect(await readdir(skillsHome)).toEqual(assigned ? ["assigned"] : []); if (assigned) { const reference = join(skillsHome, "assigned", "references", "answer.txt"); - expect(await readFile(reference, "utf8")).toBe("ASSIGNED_SKILL_MARKER"); + expect(await readFile(reference, "utf8")).toBe(expectedReference); + expect(await readFile(join(skillsHome, "assigned", "SKILL.md"), "utf8")) + .toBe(await readFile(join(skillRoot, "SKILL.md"), "utf8")); expect((await stat(reference)).mode & 0o222).toBe(0); } return runtimePort({ + startTurn: providerStartTurn, getStatus: async () => ({ models: { currentModelId: "claude-sonnet-5" } }), }); }, @@ -304,8 +309,41 @@ describe("ACPX runtime host", () => { { ...options, runtimeContext: context }, dependencies, ); + let message = JSON.stringify({ + schema: "paperclip.native-model-envelope.v2", + task: { description: "Use /assigned", prompt: "A new direct user request" }, + interactionResponses: index ? [{ response: { status: "accepted" } }] : [], + }); + if (index === 1) { + // The provider command is internal overhead, not part of the caller's + // 1 MiB allowance. Keep the exact envelope even at that boundary. + message += " ".repeat(1024 * 1024 - Buffer.byteLength(message)); + expect(() => host.startTurn({ text: `${message} `, requestId: "oversized" })) + .toThrow("turn text exceeds its bounded size"); + } + host.startTurn({ text: message, requestId: `skill-turn-${index}` }); + expect(providerStartTurn).toHaveBeenLastCalledWith({ + text: `/assigned ${message}`, requestId: `skill-turn-${index}`, + }); await host.close({ reason: "reopen test" }); + // A changed source must replace the prior materialized revision on resume. + expectedReference = "UPDATED_ASSIGNED_SKILL_MARKER"; + await writeFile(join(skillRoot, "references", "answer.txt"), expectedReference); + await writeFile(join(skillRoot, "SKILL.md"), "---\nname: assigned\ndescription: Updated instructions.\n---\nRead references/answer.txt before responding."); } + // The same agent's next ordinary task must not inherit the command. + const ordinary = await AcpxRuntimeHost.open( + { ...options, runtimeContext: context }, dependencies, + ); + const ordinaryMessage = JSON.stringify({ + schema: "paperclip.native-model-envelope.v2", + task: { description: "An ordinary task", prompt: "Mention /assigned in a note" }, + }); + ordinary.startTurn({ text: ordinaryMessage, requestId: "ordinary-task" }); + expect(providerStartTurn).toHaveBeenLastCalledWith({ + text: ordinaryMessage, requestId: "ordinary-task", + }); + await ordinary.close({ reason: "ordinary task verified" }); // No stale assignment survives a later launch without runtime context. assigned = false; const host = await AcpxRuntimeHost.open(options, dependencies); diff --git a/packages/paperclip-runner/src/drivers/acpx/runtime-host.ts b/packages/paperclip-runner/src/drivers/acpx/runtime-host.ts index 072dba41a03..efc09052a5b 100644 --- a/packages/paperclip-runner/src/drivers/acpx/runtime-host.ts +++ b/packages/paperclip-runner/src/drivers/acpx/runtime-host.ts @@ -1,4 +1,5 @@ import { join } from "node:path"; +import { claudeNativeSkillPrompt } from "./native-skill-prompt.js"; import { nativeMcpLaunchBinding } from "../native-mcp.js"; import type { @@ -255,6 +256,7 @@ export class AcpxRuntimeHost { readonly #credential: AcpxProviderLifetimeLease | null; readonly #command: VerifiedAcpxCommandLease; readonly #toolBridge: RunnerToolBridge | null; + readonly #claudeSkillNames: readonly string[]; #activeTurn: AcpxRuntimeTurn | null = null; #closingStarted = false; #closePromise: Promise | null = null; @@ -268,6 +270,7 @@ export class AcpxRuntimeHost { credential: AcpxProviderLifetimeLease | null; command: VerifiedAcpxCommandLease; toolBridge: RunnerToolBridge | null; + claudeSkillNames: readonly string[]; }) { this.#runtime = input.runtime; this.#binding = input.binding; @@ -276,6 +279,7 @@ export class AcpxRuntimeHost { this.#credential = input.credential; this.#command = input.command; this.#toolBridge = input.toolBridge; + this.#claudeSkillNames = [...input.claudeSkillNames]; } static async open( @@ -546,6 +550,9 @@ export class AcpxRuntimeHost { credential, command, toolBridge, + claudeSkillNames: options.agent === "claude" + ? (options.runtimeContext?.skills.map((skill) => skill.runtimeName) ?? []) + : [], }); } catch (error) { const cleanup = cleanupRuntimeResources( @@ -642,7 +649,12 @@ export class AcpxRuntimeHost { throw new Error("ACPX runtime host already has an active turn"); } const requestId = boundedRequestId(input.requestId); - const text = boundedTurnText(input.text); + // Bound caller input before adding the provider's assigned-skill command. + // The command is internal framing; it must not consume the envelope's + // allowance or cause an otherwise valid envelope to be truncated/rejected. + const text = claudeNativeSkillPrompt( + boundedTurnText(input.text), this.#claudeSkillNames, + ); const turn = this.#runtime.startTurn({ text, requestId, diff --git a/packages/paperclip-runner/src/drivers/acpx/runtime-sandbox.test.ts b/packages/paperclip-runner/src/drivers/acpx/runtime-sandbox.test.ts index 17aab6c8690..cba482523a5 100644 --- a/packages/paperclip-runner/src/drivers/acpx/runtime-sandbox.test.ts +++ b/packages/paperclip-runner/src/drivers/acpx/runtime-sandbox.test.ts @@ -51,6 +51,18 @@ describe("ACPX runtime sandbox", () => { }, ); + it("pins Claude's exact model in isolated settings on open and recovery", async () => { + const fixture = await sandboxFixture("claude"); + for (const model of ["claude-sonnet-5", "custom-claude-model"]) { + const binding = { ...fixture.binding, requestedModel: model, effectiveModel: model }; + for (let attempt = 0; attempt < 2; attempt += 1) { + const sandbox = await prepareAcpxRuntimeSandbox({ binding, agent: "claude" }); + const settings = JSON.parse(await readFile(join(sandbox.agentHomeDirectory, "settings.json"), "utf8")); + expect(settings).toMatchObject({ model, availableModels: [model] }); + } + } + }); + it.each([ ["pi", "OPENROUTER_API_KEY", "pi-home"], ["claude", "ANTHROPIC_API_KEY", "claude-home"], diff --git a/packages/paperclip-runner/src/drivers/codex/codex-app-server-driver-impl.ts b/packages/paperclip-runner/src/drivers/codex/codex-app-server-driver-impl.ts index 89fd70e4595..fc834ee1484 100644 --- a/packages/paperclip-runner/src/drivers/codex/codex-app-server-driver-impl.ts +++ b/packages/paperclip-runner/src/drivers/codex/codex-app-server-driver-impl.ts @@ -915,6 +915,7 @@ export class CodexAppServerDriver implements HarnessDriver { capabilities: this.#caps, goalCapability: this.#goalCapability, dynamicTools: this.#providerDynamicTools(), + skillInputs: this.#options.skillInputs, dynamicToolHandler: this.#options.dynamicToolHandler, completionFeedback: this.#options.completionFeedback, }); diff --git a/packages/paperclip-runner/src/drivers/codex/codex-app-server-driver.lifecycle.test.ts b/packages/paperclip-runner/src/drivers/codex/codex-app-server-driver.lifecycle.test.ts index 6883a404d70..91ec041ee11 100644 --- a/packages/paperclip-runner/src/drivers/codex/codex-app-server-driver.lifecycle.test.ts +++ b/packages/paperclip-runner/src/drivers/codex/codex-app-server-driver.lifecycle.test.ts @@ -731,3 +731,42 @@ describe("Codex app-server Codex driver", () => { }); }); }); + + +it("sends explicit skill input on every requested turn", async () => { + const transport = new FakeCodexTransport(); + const skillInputs = [{ type: "skill" as const, name: "first-task", path: "/runtime/assigned/first-task/SKILL.md" }]; + const driver = makeDriver([transport], { conversationMode: "direct", skillInputs }); + const session = await driver.openSession({ runId: "run-skills", normalizedSessionId: "session-skills", workingDirectory: WORKSPACE }); + for (const text of ["Start onboarding", "Yes, I approve"]) { + const turn = await session.startTurn({ message: { role: "user", text } }); + const call = transport.calls.filter((call) => call.method === "turn/start").at(-1); + expect(call?.params.input).toEqual([{ type: "text", text: `$first-task\n\n${text}`, text_elements: [] }, ...skillInputs]); + transport.push("turn/completed", { threadId: "thread-1", turn: { id: turn.turnId, status: "completed", items: [] } }); + await collectUntilTerminal(session.events()); + transport.turnStartResponse = Promise.resolve({ turn: { id: "turn-2", status: "inProgress", items: [] } }); + } + await session.close(); +}); + + +it("reapplies explicit skills after recovery without persisting them into ordinary tasks", async () => { + const skillInputs = [{ type: "skill" as const, name: "first-task", path: "/runtime/onboarding/SKILL.md" }]; + const first = new FakeCodexTransport(); + const original = await makeDriver([first], { skillInputs }).openSession({ + runId: "initial", normalizedSessionId: "skill-recovery", workingDirectory: WORKSPACE, + }); + const snapshot = await original.snapshot(); + await original.close(); + for (const selected of [skillInputs, []]) { + const transport = new FakeCodexTransport(); + const recovery = await makeDriver([transport], { skillInputs: selected }).recoverSession(snapshot); + expect(recovery.recovered).toBe(true); + const session = recovery.session!; + try { + await session.startTurn({ message: { role: "user", text: "Continue" } }); + const items = transport.calls.find((call) => call.method === "turn/start")?.params.input as Array<{type:string}>; + expect(items.filter((item) => item.type === "skill")).toEqual(selected); + } finally { await session.close(); } + } +}); diff --git a/packages/paperclip-runner/src/drivers/codex/codex-driver-types.ts b/packages/paperclip-runner/src/drivers/codex/codex-driver-types.ts index 4575454c48f..22abe8c2d4b 100644 --- a/packages/paperclip-runner/src/drivers/codex/codex-driver-types.ts +++ b/packages/paperclip-runner/src/drivers/codex/codex-driver-types.ts @@ -20,6 +20,8 @@ export interface CodexAppServerDriverOptions { approvalPolicy?: "never" | "on-request" | "untrusted"; baseInstructions?: string; includeSkillInstructions?: boolean; + /** Explicit selected skills, resolved from this task's assigned runtime assets. */ + skillInputs?: readonly import("../../contracts/runtime-context.js").NativeSkillInput[]; conversationMode?: "task" | "direct"; requestedCollaborationMode?: "default" | "plan"; /** diff --git a/packages/paperclip-runner/src/drivers/codex/codex-harness-session.ts b/packages/paperclip-runner/src/drivers/codex/codex-harness-session.ts index a4b9d918915..62d6c92533a 100644 --- a/packages/paperclip-runner/src/drivers/codex/codex-harness-session.ts +++ b/packages/paperclip-runner/src/drivers/codex/codex-harness-session.ts @@ -192,6 +192,7 @@ export class CodexHarnessSession this.emit("turn.submitted", { envelopeSchema: this.taskEnvelope.schema, text: input.message.text, + ...(this.skillInputs.length ? { skillInputs: this.skillInputs } : {}), requestedCollaborationMode: input.requestedCollaborationMode ?? effectiveCollaborationMode, effectiveCollaborationMode, @@ -215,7 +216,15 @@ export class CodexHarnessSession ...(this.opened.collaborationMode === null ? {} : { collaborationMode: this.opened.collaborationMode }), - input: [userInput({ role: "user", text: taskText })], + input: [ + userInput({ + role: "user", + text: this.skillInputs.length + ? `${this.skillInputs.map((skill) => `$${skill.name}`).join(" ")}\n\n${taskText}` + : taskText, + }), + ...this.skillInputs, + ], ...(this.conversationMode === "direct" ? {} : { outputSchema: CODEX_RESULT_OUTPUT_SCHEMA }), diff --git a/packages/paperclip-runner/src/drivers/codex/codex-session-state.ts b/packages/paperclip-runner/src/drivers/codex/codex-session-state.ts index 5018a4971bc..9301a3a2962 100644 --- a/packages/paperclip-runner/src/drivers/codex/codex-session-state.ts +++ b/packages/paperclip-runner/src/drivers/codex/codex-session-state.ts @@ -100,6 +100,7 @@ export class CodexSessionState { readonly goalAvailability: CodexGoalAvailability; readonly goalReasonCode: string | null; readonly goalReason: string | null; + readonly skillInputs: NonNullable; readonly dynamicTools: readonly Readonly>[]; readonly completionFeedback: CodexAppServerDriverOptions["completionFeedback"]; readonly dynamicToolHandler: CodexAppServerDriverOptions["dynamicToolHandler"]; @@ -172,6 +173,7 @@ export class CodexSessionState { goalAvailability: CodexGoalAvailability; goalReasonCode: string | null; goalReason: string | null; + skillInputs?: CodexAppServerDriverOptions["skillInputs"]; dynamicTools: readonly Readonly>[]; completionFeedback?: CodexAppServerDriverOptions["completionFeedback"]; dynamicToolHandler?: CodexAppServerDriverOptions["dynamicToolHandler"]; @@ -195,6 +197,7 @@ export class CodexSessionState { this.goalAvailability = input.goalAvailability; this.goalReasonCode = input.goalReasonCode; this.goalReason = input.goalReason; + this.skillInputs = structuredClone(input.skillInputs ?? []); this.dynamicTools = input.dynamicTools; this.dynamicToolHandler = input.dynamicToolHandler; this.completionFeedback = input.completionFeedback; diff --git a/packages/paperclip-runner/src/live/runnerd-codex-transport.test.ts b/packages/paperclip-runner/src/live/runnerd-codex-transport.test.ts index a37d519d579..69bb413bace 100644 --- a/packages/paperclip-runner/src/live/runnerd-codex-transport.test.ts +++ b/packages/paperclip-runner/src/live/runnerd-codex-transport.test.ts @@ -88,6 +88,7 @@ import { unseenRunnerdCommittedEvents, unwrapRunnerdProviderNotification, unwrapRunnerdProviderNotifications, + resolveRunnerdCodexSkillInputs, withCodexCollaborationRuntimeInstructions, } from "./runnerd-codex-transport.js"; @@ -8122,7 +8123,7 @@ it("cold-restores a suspended provider session under its durable run binding", a ).mode & 0o222, ).toBe(0); await first.transport.request("turn/start", { - input: [{ type: "text", text: "first process" }], + input: [{ type: "text", text: "$assigned first process" }, { type: "skill", name: "assigned", path: join(skillRoot, "SKILL.md") }], }); for await (const event of first.transport.notifications()) { if (event.method === "turn/completed") break; @@ -8166,7 +8167,7 @@ it("cold-restores a suspended provider session under its durable run binding", a cwd: tmpdir(), }); await rotated.transport.request("turn/start", { - input: [{ type: "text", text: "second authority epoch" }], + input: [{ type: "text", text: "$assigned second authority epoch" }, { type: "skill", name: "assigned", path: join(skillRoot, "SKILL.md") }], }); for await (const event of rotated.transport.notifications()) { if (event.method === "paperclip/runResult") break; @@ -8178,7 +8179,7 @@ it("cold-restores a suspended provider session under its durable run binding", a } finally { await rotated.transport.close(); } - const resumeFrames = (await readFile(tracePath, "utf8")) + const requestFrames = (await readFile(tracePath, "utf8")) .trim() .split("\n") .map((line) => JSON.parse(line) as Record) @@ -8192,7 +8193,16 @@ it("cold-restores a suspended provider session under its durable run binding", a Buffer.from(String(entry.rawBase64), "base64").toString("utf8"), ) as Record, ) - .filter((frame) => frame.method === "thread/resume"); + ; + const resumeFrames = requestFrames.filter((frame) => frame.method === "thread/resume"); + for (const frame of requestFrames.filter((f) => ["thread/start", "thread/resume"].includes(String(f.method)))) { + expect(frame.params).toMatchObject({ config: { "skills.include_instructions": true } }); + } + const turnFrames = requestFrames.filter((f) => f.method === "turn/start"); + expect(turnFrames).toHaveLength(2); + for (const frame of turnFrames) { + expect(frame.params).toMatchObject({ input: expect.arrayContaining([{ type: "skill", name: "assigned", path: join(stateDirectory, "codex-home", "skills", "assigned", "SKILL.md") }]) }); + } expect(resumeFrames.length).toBeGreaterThanOrEqual(1); for (const frame of resumeFrames) { expect(frame).toEqual( @@ -8870,3 +8880,16 @@ it.each(["claude", "codex"] as const)("keeps the explicitly assigned gateway in expect(environment.PAPERCLIP_API_KEY).toBeUndefined(); expect(environment.DATABASE_URL).toBeUndefined(); }); + +it("resolves explicit skills to the remote provider home and rejects unassigned paths", () => { + const context = assignedRuntimeContext("/controller/bundle", "/controller/instructions"); + const skill = { type: "skill", name: "assigned", path: "/controller/bundle/SKILL.md" }; + expect(resolveRunnerdCodexSkillInputs([skill], context, "/runner/codex-home")).toEqual([ + { type: "skill", name: "assigned", path: "/runner/codex-home/skills/assigned/SKILL.md" }, + ]); + expect(resolveRunnerdCodexSkillInputs([], context, "/runner/codex-home")).toEqual([]); + for (const inputs of [[{ ...skill, path: "/arbitrary/SKILL.md" }], [{ ...skill, name: "other" }], [skill, skill]]) { + expect(() => resolveRunnerdCodexSkillInputs(inputs, context, "/runner/codex-home")).toThrow("unique assigned runtime skill"); + } + expect(() => resolveRunnerdCodexSkillInputs([skill], null, "/runner/codex-home")).toThrow("assigned runtime skill"); +}); diff --git a/packages/paperclip-runner/src/live/runnerd-codex-transport.ts b/packages/paperclip-runner/src/live/runnerd-codex-transport.ts index 41b9c3fc536..c456eb299c7 100644 --- a/packages/paperclip-runner/src/live/runnerd-codex-transport.ts +++ b/packages/paperclip-runner/src/live/runnerd-codex-transport.ts @@ -4633,8 +4633,9 @@ class DurablePrpCodexTransport implements CodexAppServerTransport { : "default", includeCollaborationModeInstructions: includeCodexCollaborationInstructions, - includeSkillInstructions: - provider === "codex" && runtimeContext !== null, + ...(provider === "codex" + ? { includeSkillInstructions: runtimeContext !== null } + : {}), runtimeContext, }, }; @@ -5487,8 +5488,17 @@ class DurablePrpCodexTransport implements CodexAppServerTransport { const commandDeadline = Date.now() + turnStartTimeoutMs; const input = Array.isArray(params.input) ? params.input.map(record) : []; const message = input + .filter((item) => item.type !== "skill") .map((item) => (typeof item.text === "string" ? item.text : "")) .join("\n"); + const skills = resolveRunnerdCodexSkillInputs( + input.filter((item) => item.type === "skill"), + this.options.runtimeContext ?? null, + resolve(this.options.runnerFilesystemRoot ?? this.#root, "codex-home"), + ); + if (skills.length && (this.options.provider ?? "codex") !== "codex") { + throw new Error("Explicit skill inputs are supported only by Codex"); + } const pendingTurnId = `turn_lab_${randomUUID().replaceAll("-", "")}`; this.#turnId = pendingTurnId; const responseEpoch = ++this.#turnStartResponseEpoch; @@ -5514,6 +5524,7 @@ class DurablePrpCodexTransport implements CodexAppServerTransport { "turn.start", { text: message, + ...(skills.length ? { skills } : {}), turnId: pendingTurnId, }, commandDeadline, @@ -6608,3 +6619,30 @@ export const runnerdRecoveryInternals = Object.freeze({ turnStartNotificationDisposition, turnStartResponseReady, }); + + +/** Map controller asset paths to the assigned copy on the provider filesystem. */ +export function resolveRunnerdCodexSkillInputs( + inputs: Record[], + context: NativeRuntimeContextSnapshot | null, + codexHome: string, +): Array<{ type: "skill"; name: string; path: string }> { + if (inputs.length > 64) throw new Error("Too many explicit skill inputs"); + const seen = new Set(); + return inputs.map((input) => { + const assigned = context?.skills.find((skill) => skill.runtimeName === input.name); + if ( + !assigned || !/^[a-zA-Z0-9_-]+$/.test(assigned.runtimeName) + || input.path !== resolve(assigned.bundle.rootPath, "SKILL.md") + || seen.has(assigned.runtimeName) + ) { + throw new Error("Explicit skill input must reference a unique assigned runtime skill"); + } + seen.add(assigned.runtimeName); + return { + type: "skill", + name: assigned.runtimeName, + path: resolve(codexHome, "skills", assigned.runtimeName, "SKILL.md"), + }; + }); +} diff --git a/packages/paperclip-runner/src/protocol-actions/request-human-input.ts b/packages/paperclip-runner/src/protocol-actions/request-human-input.ts index c6396ca0270..041df16a837 100644 --- a/packages/paperclip-runner/src/protocol-actions/request-human-input.ts +++ b/packages/paperclip-runner/src/protocol-actions/request-human-input.ts @@ -115,7 +115,7 @@ export const requestHumanInputAction = { }, "payload": { "type": "object", - "description": "Kind-specific interaction data. For interactionKind='questions', use exactly {version:1, questions:[{id,prompt,selectionMode:'single'|'multi',required?,options:[{id,label,description?,freeText?}]}]}; option keys are id/label, not value, and question choice cardinality is selectionMode, not type. For confirmation, payload may be {}. Keep all ids stable across retries.", + "description": "Kind-specific interaction data. For interactionKind='questions', use version:1 and questions:[{id,prompt,selectionMode:'single'|'multi',required?,options:[{id,label,description?,freeText?}]}]. Choice questions need at least two distinct meaningful options. For an open-ended text answer, ALSO include questionSet:{schema:'paperclip.question_set.v1',questions:[{id,prompt,answerMode:'text',required?}]} with no options or customAnswer in its text questions. Keep matching IDs/prompts in both arrays; the required compatibility questions entry uses selectionMode:'single' and options:[{id:'describe',label:'Your answer',freeText:true}]. Without questionSet this incorrectly renders as a one-option choice. Never use a lone Other or describe option as the presentation. Option keys are id/label, not value. For confirmation, payload may be {}. Keep IDs stable across retries.", "additionalProperties": true }, "targetRevisionId": { @@ -238,7 +238,7 @@ export const requestHumanInputAction = { "minLength": 1 }, "payload": { - "description": "Kind-specific interaction data. Questions use {version:1, questions:[{id,prompt,selectionMode:'single'|'multi',required?,options:[{id,label,description?,freeText?}]}]}; do not use type:'single_choice' or option.value." + "description": "Kind-specific interaction data. For interactionKind='questions', use version:1 and questions:[{id,prompt,selectionMode:'single'|'multi',required?,options:[{id,label,description?,freeText?}]}]. Choice questions need at least two distinct meaningful options. For an open-ended text answer, ALSO include questionSet:{schema:'paperclip.question_set.v1',questions:[{id,prompt,answerMode:'text',required?}]} with no options or customAnswer in its text questions. Keep matching IDs/prompts in both arrays; the required compatibility questions entry uses selectionMode:'single' and options:[{id:'describe',label:'Your answer',freeText:true}]. Without questionSet this incorrectly renders as a one-option choice. Never use a lone Other or describe option as the presentation. Option keys are id/label, not value. For confirmation, payload may be {}. Keep IDs stable across retries." }, "targetRevisionId": { "oneOf": [ diff --git a/server/src/__tests__/agent-skills-routes.test.ts b/server/src/__tests__/agent-skills-routes.test.ts index cbf77aa7add..ff8fd049ac2 100644 --- a/server/src/__tests__/agent-skills-routes.test.ts +++ b/server/src/__tests__/agent-skills-routes.test.ts @@ -1225,21 +1225,26 @@ describe.sequential("agent skill routes", () => { // The generic default persona must NOT be what was seeded over the entry file. const seededCalls = mockAgentInstructionsService.materializeManagedBundle.mock.calls; const entrySeed = seededCalls.at(-1)?.[1] as Record | undefined; - expect(entrySeed?.["AGENTS.md"]).toContain("# Hiring and delegation"); + expect(entrySeed?.["AGENTS.md"]).toContain("chief of staff"); + // The normal onboarding flow has beta skill version selection disabled. + expect(mockAgentService.create.mock.calls[0][1].adapterConfig.paperclipSkillSync.desiredSkills) + .toContain("paperclipai/paperclip/first-task"); }); - it.each([ + it.each(["codex_local", "claude_local"].flatMap((adapterType) => [ ["agents", "paperclipai/paperclip/paperclip-create-agent"], ["agent-hires", "paperclipai/paperclip/paperclip-create-agent"], ["agents", "paperclip"], ["agent-hires", "paperclip"], - ])("gives a general onboarding chief core skills and preserves %s version pins for %s", async (route, skill) => { + ["agents", "paperclipai/paperclip/first-task"], + ["agent-hires", "paperclipai/paperclip/first-task"], + ].map(([route, skill]) => ({ adapterType, route, skill }))))("gives $adapterType onboarding agents core and first-task skills via $route, preserving $skill pins", async ({ adapterType, route, skill }) => { mockInstanceSettingsService.getExperimental.mockResolvedValue({ enableBetaSkills: true }); const versionId = "22222222-2222-4222-8222-222222222222"; const res = await request(await createApp(createDb(route === "agent-hires"))) .post(`/api/companies/company-1/${route}`) .send({ - name: "Chiff", role: "general", adapterType: "codex_local", + name: "Chiff", role: "general", adapterType, onboardingFirstAgent: true, desiredSkills: [{ key: skill, versionId }], }); @@ -1247,10 +1252,10 @@ describe.sequential("agent skill routes", () => { const input = mockAgentService.create.mock.calls[0][1]; expect(input.role).toBe("general"); const canonicalKey = skill === "paperclip" ? "paperclipai/paperclip/paperclip" : skill; - const expected = ["paperclip", "paperclip-board", "paperclip-converting-plans-to-tasks", "paperclip-create-agent", "para-memory-files"] + const expected = ["paperclip", "paperclip-board", "paperclip-converting-plans-to-tasks", "paperclip-create-agent", "para-memory-files", "first-task"] .map((name) => ({ key: `paperclipai/paperclip/${name}`, versionId: `paperclipai/paperclip/${name}` === canonicalKey ? versionId : null })); expect(input.adapterConfig.paperclipSkillSync.desiredSkills).toEqual(expect.arrayContaining(expected)); - expect(input.adapterConfig.paperclipSkillSync.desiredSkills).toHaveLength(5); + expect(input.adapterConfig.paperclipSkillSync.desiredSkills).toHaveLength(6); }); it.each(["agents", "agent-hires"])("leaves ordinary general agents' defaults unchanged via %s", async (route) => { @@ -1261,6 +1266,16 @@ describe.sequential("agent skill routes", () => { expect(mockAgentService.create.mock.calls[0][1].adapterConfig.paperclipSkillSync).toBeUndefined(); }); + it.each(["agents", "agent-hires"])("does not assign first-task to ordinary CEOs via %s", async (route) => { + const res = await request(await createApp()) + .post(`/api/companies/company-1/${route}`) + .send({ name: "CEO", role: "ceo", adapterType: "codex_local" }); + expect(res.status, JSON.stringify(res.body)).toBe(201); + const desiredSkills = mockAgentService.create.mock.calls[0][1].adapterConfig.paperclipSkillSync.desiredSkills; + expect(desiredSkills).toContain("paperclipai/paperclip/paperclip"); + expect(desiredSkills).not.toContain("paperclipai/paperclip/first-task"); + }); + it("does not trust an agent-supplied onboarding marker to select chief-of-staff defaults", async () => { mockAgentService.getById.mockResolvedValue(makeAgent("claude_local")); const res = await request(await createApp(createDb(), { diff --git a/server/src/__tests__/company-skills-service.test.ts b/server/src/__tests__/company-skills-service.test.ts index c157a73d6a8..7217eb4f2be 100644 --- a/server/src/__tests__/company-skills-service.test.ts +++ b/server/src/__tests__/company-skills-service.test.ts @@ -694,6 +694,34 @@ describeEmbeddedPostgres("companySkillService.list", () => { expect(refreshedSkill?.updatedAt.toISOString()).toBe(preservedUpdatedAt.toISOString()); }); + it("makes the onboarding skill resolvable and available to agent runtimes", async () => { + const companyId = randomUUID(); + await db.insert(companies).values({ + id: companyId, + name: "Onboarding", + issuePrefix: `T${companyId.slice(0, 6)}`, + }); + const key = "paperclipai/paperclip/first-task"; + // Assignment resolves before the company has ever opened its skill library. + expect(await svc.resolveRequestedSkillEntries(companyId, [key])).toEqual({ + resolved: [{ key, versionId: null }], + unresolved: [], + }); + const entries = await svc.listRuntimeSkillEntries(companyId); + const entry = entries.find((skill) => skill.key === key); + expect(entry).toMatchObject({ runtimeName: "first-task", sourceStatus: "available" }); + if (!entry) throw new Error("Expected first-task runtime skill"); + const markdown = await fs.readFile(path.join(entry.source, "SKILL.md"), "utf8"); + expect(parseFrontmatterMarkdown(markdown).frontmatter.name).toBe("first-task"); + expect(markdown).toContain("`interview` →"); + expect(markdown).toContain("`task` →"); + expect(markdown).toBe(await fs.readFile(new URL("../onboarding-assets/first-task/skills/first-task/SKILL.md", import.meta.url), "utf8")); + expect(markdown).not.toContain("{{"); + // Repeated inventory refreshes do not install duplicate skill rows. + const refreshed = await svc.list(companyId); + expect(refreshed.filter((skill) => skill.key === key)).toHaveLength(1); + }); + it("seeds bundled skill releases idempotently and materializes the frozen champion snapshot", async () => { const companyId = randomUUID(); await db.insert(companies).values({ diff --git a/server/src/__tests__/issue-onboarding-first-task-routes.test.ts b/server/src/__tests__/issue-onboarding-first-task-routes.test.ts index b4f814be1e4..4e6015a802e 100644 --- a/server/src/__tests__/issue-onboarding-first-task-routes.test.ts +++ b/server/src/__tests__/issue-onboarding-first-task-routes.test.ts @@ -277,7 +277,7 @@ describeEmbeddedPostgres("issue create onboarding first-task routes", () => { expect(await listOnboardingIssues(companyId)).toHaveLength(1); }); - it("stores the server-assembled brief as the description and ignores the client description", async () => { + it("stores the server-selected skill invocation and ignores the client description", async () => { const companyId = await seedCompany(); const agentId = await seedAgent(companyId); const app = createApp(); @@ -292,15 +292,13 @@ describeEmbeddedPostgres("issue create onboarding first-task routes", () => { }) .expect(201); - expect(created.body.description).toContain("This is the user's first task in Paperclip."); - expect(created.body.description).toContain("Take the path the user picked."); - // Toggle defaults off → the confirmation proposal form is inlined. - expect(created.body.description).toContain("post ONE request_confirmation that says, in a few lines"); - expect(created.body.description).not.toContain("treat it like the plan path"); + expect(created.body.description).toContain("Use the `first-task` skill (/first-task)"); + expect(created.body.description).toContain("Single-task proposal mode: `confirmation`."); + expect(created.body.description).not.toContain("Take the path the user picked."); expect(created.body.description).not.toContain("client supplied description"); }); - it("uses the plan proposal brief when enableFirstTaskPlanProposal is on", async () => { + it("invokes the skill in plan mode when enableFirstTaskPlanProposal is on", async () => { const companyId = await seedCompany(); const app = createApp(); await db @@ -316,9 +314,9 @@ describeEmbeddedPostgres("issue create onboarding first-task routes", () => { .send({ title: "Get started", onboardingFirstTask: true }) .expect(201); - expect(created.body.description).toContain("This is the user's first task in Paperclip."); - expect(created.body.description).toContain("treat it like the plan path"); - expect(created.body.description).not.toContain("post ONE request_confirmation that says, in a few lines"); + expect(created.body.description).toContain("Use the `first-task` skill (/first-task)"); + expect(created.body.description).toContain("Single-task proposal mode: `plan`."); + expect(created.body.description).not.toContain("request_checkbox_confirmation"); await db.delete(instanceSettings); }); diff --git a/server/src/__tests__/native-session-resumption.test.ts b/server/src/__tests__/native-session-resumption.test.ts index fcf42d37efc..169c1acb5e1 100644 --- a/server/src/__tests__/native-session-resumption.test.ts +++ b/server/src/__tests__/native-session-resumption.test.ts @@ -40,6 +40,7 @@ import { } from "../vendor/paperclip-runner/testing.js"; import { startEmbeddedPostgresTestDatabase } from "./helpers/embedded-postgres.js"; import { drainHeartbeatRunsToQuiescence } from "./helpers/drain-heartbeat-runs.js"; +import { waitForPendingRunFailureReports } from "../services/run-failure-report.js"; import { claimNativeSessionResumptions, dispatchNativeSessionResumptions, @@ -563,11 +564,10 @@ describe("P6-25 pre-result native session recovery", () => { const captureCallsBefore = mockCaptureRunFailure.mock.calls.length; await claimNativeSessionResumptions({ db, runnerInstanceId: "reaper", runIds: [freshRunId] }); - // Reporting is deliberately fire-and-forget. An unrelated database query - // cannot synchronize it; wait for the actual event before checking payload. - await vi.waitFor(() => { - expect(mockCaptureRunFailure.mock.calls.slice(captureCallsBefore)).toHaveLength(1); - }, { timeout: 5_000 }); + // The reconciler reports asynchronously; an unrelated database round trip + // does not guarantee that callback has completed. + await waitForPendingRunFailureReports(); + expect(mockCaptureRunFailure.mock.calls.slice(captureCallsBefore)).toHaveLength(1); const newCaptures = mockCaptureRunFailure.mock.calls.slice(captureCallsBefore); expect(newCaptures[0]?.[0]).toMatchObject({ runId: freshRunId, runStatus: "failed" }); }); @@ -600,7 +600,7 @@ describe("P6-25 pre-result native session recovery", () => { const captureCallsBefore = mockCaptureRunFailure.mock.calls.length; await claimNativeSessionResumptions({ db, runnerInstanceId: "reaper", runIds: [freshRunId] }); - await db.select().from(heartbeatRuns).where(eq(heartbeatRuns.id, freshRunId)); + await waitForPendingRunFailureReports(); expect(mockCaptureRunFailure.mock.calls.slice(captureCallsBefore)).toHaveLength(0); }); diff --git a/server/src/onboarding-assets/first-task/README.md b/server/src/onboarding-assets/first-task/README.md index 6ed839cf045..499ed0a34b4 100644 --- a/server/src/onboarding-assets/first-task/README.md +++ b/server/src/onboarding-assets/first-task/README.md @@ -4,17 +4,18 @@ Everything the very first agent is told during onboarding lives here as plain markdown so the board can edit the wording without touching TypeScript. The server loads these files (see `server/src/services/onboarding-first-task-assets.ts` and `server/src/services/onboarding-greeting.ts`) when it creates a new -organization's first task and when it hires the first agent. +organization's first task and when it hires the first agent. The first agent +also receives the bundled `first-task` skill through the normal company skill +inventory and agent skill assignment flow. ## Files | File | Layer | What it is | | --- | --- | --- | | `greeting.md` | C | The deterministic greeting the server posts as the agent on the first task, before anything runs. No LLM. | -| `opening-question.json` | C | The deterministic `ask_user_questions` card the server posts as the agent right after the greeting: "Interview me and propose a plan and an agent team to execute it." or "I have a task in mind" (free text). The option ids `interview` and `task` are fixed because `brief.md` refers to them; the `task` option must keep `freeText: true`. No LLM. | -| `brief.md` | A (steps 1, 3, 4) | The first task's description. Contains the `{{proposalStep}}` placeholder and tells the agent what to do with each answer to the opening card. | -| `proposal-confirmation.md` | A (step 2, task path) | The proposal instructions used when the plan-proposal toggle is **off** (default): a one-card `request_confirmation`. | -| `proposal-plan.md` | A (step 2, task path) | The proposal instructions used when the toggle is **on**: a short plan document plus a checkbox card. | +| `opening-question.json` | C | The deterministic `ask_user_questions` card the server posts as the agent right after the greeting: "Interview me and propose a plan and an agent team to execute it." or "I have a task in mind" (free text). The option ids `interview` and `task` are fixed because the `first-task` skill refers to them; the `task` option must keep `freeText: true`. No LLM. | +| `brief.md` | A | The first task's hidden description: a short `/first-task` invocation and the `{{proposalMode}}` selected at creation. | +| `skills/first-task/SKILL.md` | A (workflow) | The full first-task policy: opening-answer handling, interview, proposals, approval, and execution. Includes both single-task proposal modes. | | `chief-of-staff/AGENTS.md` | B | The chief-of-staff persona seeded over the first agent's entry instruction file at hire time. | | `README.md` | — | This file. | @@ -28,7 +29,7 @@ question card behaves: Next / Submit answers, Skip (optional questions only), and Cancel, which returns the plain composer and leaves the card pending. The server validates the file when it creates a first task and refuses (logging a warning, the task is still created) if either option id changes or the `task` option loses `freeText: true`. When the user answers, the -answer reaches the agent in its wake payload and `brief.md` step 1 tells it +answer reaches the agent in its wake payload and the `first-task` skill tells it which path to take; when the user types a message instead, the card expires and the message wakes the agent as before. @@ -39,27 +40,50 @@ and the message wakes the agent as before. the historical behaviour. Used in `greeting.md` and `chief-of-staff/AGENTS.md`. - `{{organizationName}}` → the organization (company) name. Used in `chief-of-staff/AGENTS.md`. -- `{{proposalStep}}` (in `brief.md` only) → replaced with the contents of - `proposal-confirmation.md` or `proposal-plan.md`, chosen by the - `enableFirstTaskPlanProposal` toggle. +- `{{proposalMode}}` (in `brief.md` only) → `confirmation` or `plan`, chosen by + the `enableFirstTaskPlanProposal` toggle. The skill contains the policy for + both modes; no policy text is expanded into the task description. ## The toggle `enableFirstTaskPlanProposal` (Settings → Experimental, tier `preference`, default **off** on cloud and self-hosted). Title: "First task: propose with a -plan document". When on, the first task's brief uses `proposal-plan.md` for the -single-task path so the chief of staff writes a short plan document and a +plan document". When on, the first task's invocation selects `plan` mode for +the single-task path so the chief of staff writes a short plan document and a checkbox card instead of a one-card confirmation. The create route reads the toggle **once**, when the first task is created; flipping it later does not change an existing first task. -## Two rules +## Skill assignment and invocation + +The company skill service imports `skills/first-task/SKILL.md` with canonical +key `paperclipai/paperclip/first-task` and runtime name `first-task`. The agent +create and hire routes add it alongside the five core skills for board-created +`onboardingFirstAgent` agents on skills-capable adapters, including Codex and +Claude. Ordinary CEOs and other agents do not receive it automatically. + +The hidden description asks the agent to read and follow the skill before +responding, including subsequent wakes on that task. The user does not need to +type a slash command. Native Codex sends the selected skill as a structured +skill input. Native ACPX Claude invokes the assigned skill through its native +`/first-task` command, with the complete task/wake envelope as the argument, +on initial and resumed turns. Legacy adapters retain the brief's instruction +to read the installed skill. None of these adds a separate model run. The skill +applies only to the onboarding task that invokes it, not to every task assigned +to that agent. The deterministic greeting, +opening card, and initial no-wake behavior are unchanged. + +## Updates 1. **Edits take effect on the next server restart locally, or the next release on cloud.** The files are read from disk (bundled into `dist/` at build time), not baked into TypeScript, so a plain markdown edit + restart/release is all that is needed. -2. **Only NEW organizations get new text.** An existing first task keeps the - description it was created with, and an existing first agent keeps the - persona it was seeded with (editable per agent under Instructions). Changing - these files never rewrites text an existing organization already received. +2. **Task descriptions and personas are snapshots.** An existing first task + keeps the description it was created with, and an existing first agent keeps + its seeded persona (editable per agent under Instructions). This change does + not migrate existing first tasks or assign the skill to existing agents. +3. **Skill text follows normal bundled-skill refresh.** Agents assigned the + unpinned `first-task` skill receive its current bundled contents through the + company inventory. Its policy can therefore update independently of the + saved invocation; the proposal mode remains the one stored on the task. diff --git a/server/src/onboarding-assets/first-task/brief.md b/server/src/onboarding-assets/first-task/brief.md index f423b6ef180..5b0b28e7549 100644 --- a/server/src/onboarding-assets/first-task/brief.md +++ b/server/src/onboarding-assets/first-task/brief.md @@ -1,21 +1,3 @@ -This is the user's first task in Paperclip. Your job is to understand what they want and propose a path forward. A greeting and an opening question card were already posted for you; the card offered two choices: "Interview me and propose a plan and an agent team to execute it." (option `interview`) or "I have a task in mind" (option `task`, with a text field). You are running because the user answered that card (the answer is in your wake payload) or wrote a message instead of answering. Don't re-introduce yourself and don't post the opening card again. +Use the `first-task` skill (/first-task) for this onboarding task. Read its SKILL.md and follow it before responding, including on subsequent wakes of this task. -Work in this order. - -1. Take the path the user picked. - - - `interview` → reply with ONE ask_user_questions card of 3–4 questions that pin down what the organization does, what they want to achieve first, any constraints (time, budget, tools), and what "done" looks like. Don't guess; ask. Don't post anything else before the card. The answers lead to the plan-and-team path in step 2. - - - `task` → the text they typed is the task. If it is clear enough to propose on, go straight to step 2. If not, reply with ONE ask_user_questions card of 2–3 questions specific to their message (concrete goal, constraints, what "done" looks like), then go to step 2. - - - If they wrote a message instead of answering the card, treat the message as the `task` path. - -2. Propose, don't decide. From what you now know, pick the path: - - - They want a plan and/or a team → write a short `plan` document (goal, approach, team as one line per hire: name, role, responsibility; follow-up tasks). Then post ONE request_checkbox_confirmation targeting the plan, each hire and follow-up task as its own option, checked by default, each with a stable id. Keep the card's message to a line or two and point to the Plan in the right sidebar. - -{{proposalStep}} - -3. Wait. Do nothing until a card is accepted. If they ask for changes, revise and re-confirm. Hiring or creating tasks without an accepted card is never allowed on this task. - -4. On acceptance, execute only what was approved: hire the checked agents, create and delegate the checked tasks, or do the single task yourself and post the result as a document on this task. +Single-task proposal mode: `{{proposalMode}}`. diff --git a/server/src/onboarding-assets/first-task/chief-of-staff/AGENTS.md b/server/src/onboarding-assets/first-task/chief-of-staff/AGENTS.md index f44e541d3d3..43b2ecfb046 100644 --- a/server/src/onboarding-assets/first-task/chief-of-staff/AGENTS.md +++ b/server/src/onboarding-assets/first-task/chief-of-staff/AGENTS.md @@ -9,17 +9,7 @@ You are {{agentName}}, chief of staff for {{organizationName}}. You report to th # Chat hygiene -- Everything you post is read by the user. Keep it terse and written for them. +- Everything you post is read by the user. Keep it terse and written for them. Speak simply and be easy to understand. For technical topics speak close to ASD-STE100 so that people understand you. - Lead with the answer. Never narrate tool calls, API steps, or your own thinking. -- Ask only about material ambiguity that prevents useful work. Accept responsibilities in the user's own words; do not demand an artificial job category. Use `general` when no specialized structural role is needed. -- When input is needed, save one `ask_user_questions` card using the operational API reference, then set the issue to `in_review`. The saved pending interaction provides the waiting path; a question in prose alone does not. Do not try to set a board/user unblock owner as an agent. - -# Hiring and delegation - -An explicit user request to hire an agent or create a task authorizes that requested action. Proceed within that scope without asking them to approve it again. For additional hires or tasks you propose, first use a request_confirmation or checkbox card naming what will be created. A proposed hire is one line: name, role, responsibility. Formal company approval gates still apply to every hire, including directly requested hires. - -Read `paperclip-create-agent` before hiring. Supply managed instructions with `instructionsBundle.files` as a record of paths to file contents, not an array; do not use retired `adapterConfig.promptTemplate` fields. Keep timer heartbeats off unless requested or needed for recurring work. - -A hire response with HTTP 201 succeeded; its body is `{"agent": …, "approval": …}`. Check whether the agent is pending company approval before reporting it ready. An identical same-run retry returns the existing agent (HTTP 200, `idempotent: true`); changed payloads or later runs can create duplicates. Do not resubmit after success. If the outcome is uncertain (timeout, lost response, or server error), first list the company's agents and reconcile the result before considering any retry. - -A confirmed pre-creation validation rejection created no agent. Correct the invalid fields under the original authorization when the requested name, responsibilities, and scope stay the same; do not request another confirmation just to fix the payload. Use the validation error and `GET /api/openapi.json` to fix the shape. This exception is only for confirmed validation failures, not uncertain outcomes or permission/approval denials. Keep the operational skill's bounded write retry limit. +- Ask about material ambiguity that prevents useful work. +- You have tools from Paperclip, use them \ No newline at end of file diff --git a/server/src/onboarding-assets/first-task/proposal-confirmation.md b/server/src/onboarding-assets/first-task/proposal-confirmation.md deleted file mode 100644 index 5b99b9751ea..00000000000 --- a/server/src/onboarding-assets/first-task/proposal-confirmation.md +++ /dev/null @@ -1 +0,0 @@ - - They want one thing done now → post ONE request_confirmation that says, in a few lines, what you will do and what they will get (and by when, if you can say). No plan document. diff --git a/server/src/onboarding-assets/first-task/proposal-plan.md b/server/src/onboarding-assets/first-task/proposal-plan.md deleted file mode 100644 index 6611a11bb9b..00000000000 --- a/server/src/onboarding-assets/first-task/proposal-plan.md +++ /dev/null @@ -1 +0,0 @@ - - They want one thing done now → treat it like the plan path: write the short `plan` document (goal, approach, what you will produce) and post ONE request_checkbox_confirmation targeting it, with the task itself and any optional follow-up as options. diff --git a/server/src/onboarding-assets/first-task/skills/first-task/SKILL.md b/server/src/onboarding-assets/first-task/skills/first-task/SKILL.md new file mode 100644 index 00000000000..f15ffff4fbd --- /dev/null +++ b/server/src/onboarding-assets/first-task/skills/first-task/SKILL.md @@ -0,0 +1,45 @@ +--- +name: first-task +description: > + Guide the user's first Paperclip task when its description invokes /first-task. + Interpret the opening answer, clarify their goal, propose a plan or a single + task, and wait for approval before hiring agents or executing approved work. +--- + +# First task + +Use this workflow only for the onboarding task that invokes `/first-task`, +including later replies and approval wakes on that same task. Do not apply it +to the agent's other tasks just because this skill is installed. Follow it +without announcing the skill invocation to the user. + +This is the user's first task in Paperclip. Your job is to understand what they want and propose a path forward. A greeting and an opening question card were already posted for you; the card offered two choices: "Interview me and propose a plan and an agent team to execute it." (option `interview`) or "I have a task in mind" (option `task`, with a text field). You are running because the user answered that card (the answer is in your wake payload) or wrote a message instead of answering. Don't re-introduce yourself and don't post the opening card again. + +Work in this order. + +1. Take the path the user picked. + + - `interview` → ask the user 3–4 questions in one `ask_user_questions` card that pin down what their organization does, what they want to achieve first, any constraints (time, budget, tools), and what "done" looks like. Don't guess; ask. Don't post anything else before the card. The answers lead to the plan-and-team path in step 2. + + - `task` → the text they typed is the task. If it is clear enough to propose on, go straight to step 2. If not, reply by asking 2–3 questions specific to their message (concrete goal, constraints, what "done" looks like), then go to step 2. + + - If they wrote a message instead of answering the card, treat the message as the `task` path. + +2. Propose, then wait for acceptance. + + - If they want a plan, save a `plan` document on this onboarding task describing the goal, scope, steps, proposed team, and what done means. Post one `request_checkbox_confirmation` targeting the saved plan revision. A card or thread message alone is not a saved plan. This applies to explicit plan requests regardless of the single-task proposal mode. Proposing a team does not authorize hiring it. + - If they want one thing done, propose exactly one child task with a clear outcome and scope. Ask them to accept it before creating the child. Do not produce the requested finished work inside the proposal, even when it is quick to do. + - For a single-task proposal, follow the `Single-task proposal mode` saved in the task description: `confirmation` means one `request_confirmation` card describing the child task, without a plan document; `plan` means save a short `plan` document describing that same child task and post one `request_checkbox_confirmation` targeting its saved revision. + - Keep this task `in_review` while waiting. You may clarify, research for planning, and save or revise a plan/proposal before acceptance. Do not hire, create execution tasks, perform the deliverable, save finished output, or claim completion yet. + +3. Interpret the next reply against the latest proposal. + + - Acceptance is an accepted confirmation card or an explicit conversational reply agreeing to the proposal. The opening answer, a clear request, and answers to clarification questions supply scope; they are not acceptance of a proposal you have not yet made. + - A clarification answer means update the proposal if needed and ask for acceptance. A requested revision supersedes the old scope: revise the proposal and wait for acceptance of the revised version. + - If they reject the proposal, acknowledge and stop. Do not execute it. You may close the onboarding task after acknowledging the rejection; do not describe rejected work as completed. + +4. Carry out the accepted scope. + + - For a plan-only request, retain the accepted plan on this task. Do not start its implementation or hire the proposed team without authorization to do that work. + - For an accepted single task, check for an existing child from this proposal before creating anything. Create exactly one child linked to this onboarding task, assign it to yourself, and execute it. On later wakes, continue that same child instead of creating another. + - Save the finished output as a document on the child task and mark that child done. Link it from the onboarding conversation. Completing the onboarding parent in place, or saving the output only on the parent, does not fulfill the accepted child-task proposal. diff --git a/server/src/routes/agents.ts b/server/src/routes/agents.ts index 8baa38c3d22..85d9f1a173a 100644 --- a/server/src/routes/agents.ts +++ b/server/src/routes/agents.ts @@ -80,7 +80,7 @@ import { workspaceOperationService, } from "../services/index.js"; import { badRequest, conflict, forbidden, HttpError, notFound, unprocessable } from "../errors.js"; -import { PAPERCLIP_CORE_SKILL_KEYS } from "../services/company-skills.js"; +import { ONBOARDING_FIRST_TASK_SKILL_KEY, PAPERCLIP_CORE_SKILL_KEYS } from "../services/company-skills.js"; import { createRunSecretRedactionRegistry } from "../services/run-secret-redaction.js"; import { assertAuthenticated, assertBoard, assertCompanyAccess, assertInstanceAdmin, buildActorSecretContext, getAccessibleResource, getActorInfo, hasCompanyAccess } from "./authz.js"; import { runAdapterLoginStartSpine } from "./adapter-login-route-spine.js"; @@ -2916,7 +2916,10 @@ export function agentRoutes( if (role !== "ceo" && !boardOnboardingFirstAgent) return undefined; const adapter = findActiveServerAdapter(adapterType); if (!adapter?.listSkills && !adapter?.syncSkills) return undefined; - return PAPERCLIP_CORE_SKILL_KEYS + const keys = boardOnboardingFirstAgent + ? [...PAPERCLIP_CORE_SKILL_KEYS, ONBOARDING_FIRST_TASK_SKILL_KEY] + : PAPERCLIP_CORE_SKILL_KEYS; + return keys .filter((key) => adapterType !== "paperclip_runner" || key !== PAPERCLIP_OPERATIONAL_SKILL_KEY) .map((key) => ({ key, versionId: null })); } diff --git a/server/src/routes/issues.ts b/server/src/routes/issues.ts index 1436aecc304..7f11fbdadcf 100644 --- a/server/src/routes/issues.ts +++ b/server/src/routes/issues.ts @@ -11664,7 +11664,7 @@ export function issueRoutes( ? null : await resolveRunIssueWorkspaceInheritanceSource(companyId, actor); // When this is genuinely the onboarding first task, the server owns the task - // description: assemble it from brief.md plus the proposal file the + // description: invoke the first-task skill and save the proposal mode the // enableFirstTaskPlanProposal toggle selects, read once here at creation // time, and ignore any client-supplied description. Flipping the toggle // later does not change an existing first task. Best-effort: a read failure diff --git a/server/src/services/company-skills.ts b/server/src/services/company-skills.ts index cc55e1b375c..85724abc9aa 100644 --- a/server/src/services/company-skills.ts +++ b/server/src/services/company-skills.ts @@ -641,6 +641,8 @@ export const PAPERCLIP_CORE_SKILL_KEYS = [ "paperclipai/paperclip/para-memory-files", ] as const; +export const ONBOARDING_FIRST_TASK_SKILL_KEY = "paperclipai/paperclip/first-task"; + function deriveCanonicalSkillKey( companyId: string, input: Pick, @@ -2947,6 +2949,13 @@ export function companySkillService(db: Db) { } async function ensureBundledSkills(companyId: string) { + // Onboarding owns this skill's wording. The server build copies this asset + // directory into dist, so it uses the same import path in source and npm. + const firstTaskSkill = await readLocalSkillImportFromDirectory( + companyId, + fileURLToPath(new URL("../onboarding-assets/first-task/skills/first-task/", import.meta.url)), + { metadata: { sourceKind: "paperclip_bundled" } }, + ); for (const skillsRoot of resolveBundledSkillsRoot()) { const stats = await fs.stat(skillsRoot).catch(() => null); if (!stats?.isDirectory()) continue; @@ -2967,9 +2976,9 @@ export function companySkillService(db: Db) { }))) .catch(() => [] as ImportedSkill[]); if (bundledSkills.length === 0) continue; - return upsertImportedSkills(companyId, bundledSkills); + return upsertImportedSkills(companyId, [...bundledSkills, firstTaskSkill]); } - return []; + return upsertImportedSkills(companyId, [firstTaskSkill]); } async function readBundledSkillReleaseRegistry() { diff --git a/server/src/services/native-runtime/native-execution-input.test.ts b/server/src/services/native-runtime/native-execution-input.test.ts index f93507c8cdd..da3d01b10cf 100644 --- a/server/src/services/native-runtime/native-execution-input.test.ts +++ b/server/src/services/native-runtime/native-execution-input.test.ts @@ -110,6 +110,9 @@ describe("native execution input external-chat framing", () => { ); expect(input.task.prompt).toContain("request_human_input"); expect(input.task.prompt).toContain('interactionKind="questions"'); + expect(input.task.prompt).toContain("at least two distinct meaningful options"); + expect(input.task.prompt).toContain("payload.questionSet"); + expect(input.task.prompt).toContain('answerMode="text"'); expect(input.task.prompt).toContain("one question at a time"); expect(input.task.prompt).toContain("Never fabricate answer URLs"); expect(input.task.prompt.indexOf("Choose a color: Amber")).toBeLessThan( @@ -468,6 +471,9 @@ describe("native execution input external-chat framing", () => { runtimeContext: nativeRuntimeContextFixture(), }); expect(input.task.prompt).toContain('interactionKind="questions"'); + expect(input.task.prompt).toContain("at least two distinct meaningful options"); + expect(input.task.prompt).toContain("payload.questionSet"); + expect(input.task.prompt).toContain('answerMode="text"'); expect(input.task.prompt).toContain('continuationPolicy="wake_assignee"'); expect(input.task.prompt).toContain("Create the actual question before yielding"); expect(input.task.prompt).toContain("Wait for its real answer"); diff --git a/server/src/services/native-runtime/native-execution-input.ts b/server/src/services/native-runtime/native-execution-input.ts index f027ca28a41..c4c8065754f 100644 --- a/server/src/services/native-runtime/native-execution-input.ts +++ b/server/src/services/native-runtime/native-execution-input.ts @@ -22,7 +22,7 @@ import { const NATIVE_QUESTION_GUIDANCE = [ "## Questions that need a user response", "A request for clickable choices, buttons, or a decision needed before continuing is not a self-contained text answer. The zero-API-call shortcut does not prohibit the structured question tool.", - 'Use the available request_human_input tool with interactionKind="questions", continuationPolicy="wake_assignee", a title, prompt, and a stable idempotencyKey. Put the actual requested choices in payload.questions: each question needs an id, prompt, selectionMode="single", and options with stable id and label fields. Reuse the same key if that creation call must be retried.', + 'Use the available request_human_input tool with interactionKind="questions", continuationPolicy="wake_assignee", a title, prompt, and a stable idempotencyKey. For choices, use payload.questions with stable id and prompt, selectionMode="single" or "multi", and at least two distinct meaningful options with stable id and label fields. For open-ended answers, include payload.questionSet with schema="paperclip.question_set.v1" and questions containing id, prompt, answerMode="text", and no options or customAnswer. Include matching payload.questions entries with the same IDs/prompts and a freeText option only for storage compatibility; questionSet supplies the text-field presentation. Never present a lone "Other" or "I will describe it" choice. Reuse the same key if that creation call must be retried.', "Paperclip renders the supported question controls and authenticates the answer. Never fabricate answer URLs, query-string choice links, callback tokens, or fake Markdown buttons. Do not manually post a duplicate question card or use call_api as a substitute.", "For one question at a time, read the current request and authoritative prior answers, then create only the next unanswered question. Wait for its real answer before asking another; do not infer a selection or answer your own interaction. Keep completion and disposition truthful while waiting, and preserve existing review or approval gates.", "If the tool is unavailable or creation fails, report that actual limitation plainly; do not pretend interactive controls were created.", diff --git a/server/src/services/native-runtime/paperclip-runner-tool-authority.test.ts b/server/src/services/native-runtime/paperclip-runner-tool-authority.test.ts index 83d0d64511a..a480ef1f2ad 100644 --- a/server/src/services/native-runtime/paperclip-runner-tool-authority.test.ts +++ b/server/src/services/native-runtime/paperclip-runner-tool-authority.test.ts @@ -269,7 +269,7 @@ describe("PaperclipRunnerToolAuthority", () => { }, ); - it("executes the advertised payload.questions shape once on the bound reviewed task", async () => { + it.each(["choice", "text"] as const)("executes the advertised %s question once on the bound reviewed task", async (answerMode) => { const binding = { companyId: randomUUID(), agentId: randomUUID(), @@ -279,7 +279,7 @@ describe("PaperclipRunnerToolAuthority", () => { await db.insert(companies).values({ id: binding.companyId, name: "Question invocation", - issuePrefix: "RQA", + issuePrefix: answerMode === "choice" ? "RQA" : "RQT", }); await db.insert(agents).values({ id: binding.agentId, @@ -329,6 +329,33 @@ describe("PaperclipRunnerToolAuthority", () => { ], }, ]; + const payloadDescription = (advertised.inputSchema as { + properties: { payload: { description: string } }; + }).properties.payload.description; + expect(payloadDescription).toContain("at least two distinct meaningful options"); + expect(payloadDescription).toContain("questionSet"); + expect(payloadDescription).not.toContain("use exactly"); + const payload = answerMode === "choice" + ? { version: 1, questions } + : { + version: 1, + questions: [{ + id: "goal", + prompt: "What should we accomplish?", + selectionMode: "single", + required: true, + options: [{ id: "describe", label: "Your answer", freeText: true }], + }], + questionSet: { + schema: "paperclip.question_set.v1", + questions: [{ + id: "goal", + prompt: "What should we accomplish?", + answerMode: "text", + required: true, + }], + }, + }; const call = { tool: "request_human_input", callId: "advertised-question", @@ -338,7 +365,7 @@ describe("PaperclipRunnerToolAuthority", () => { title: "Choose one color", prompt: "Choose one color", continuationPolicy: "wake_assignee", - payload: { version: 1, questions }, + payload, }, }; const first = await authority.execute(call); @@ -351,7 +378,7 @@ describe("PaperclipRunnerToolAuthority", () => { kind: "ask_user_questions", status: "pending", continuationPolicy: "wake_assignee", - payload: { version: 1, questions }, + payload, }, }); await expect( diff --git a/server/src/services/native-runtime/paperclip-runner-tool-authority.ts b/server/src/services/native-runtime/paperclip-runner-tool-authority.ts index 6277e0bc012..51bc8fb0f02 100644 --- a/server/src/services/native-runtime/paperclip-runner-tool-authority.ts +++ b/server/src/services/native-runtime/paperclip-runner-tool-authority.ts @@ -155,7 +155,7 @@ export class PaperclipRunnerToolAuthority { descriptor.operationId === "register_deliverable" ? "Prepare one verified workspace file for Paperclip's final task or external-chat response. This records the attachment, work product, and explicit same-run selection; it does not confirm provider delivery." : descriptor.operationId === "request_human_input" - ? "Create a typed, durable human-input interaction on the current Paperclip task bound to this run. For structured questions and choices, use interactionKind 'questions' with payload.questions as described by the payload schema. Paperclip renders the interaction in its UI and, for connected chats, uses supported provider question controls or a safe fallback. Normal task permissions and review gates still apply." + ? "Create a typed, durable human-input interaction on the current Paperclip task bound to this run. For structured questions and choices, use interactionKind 'questions' with payload.questions for choices (at least two distinct meaningful options), or include payload.questionSet for open-ended text fields as described by the payload schema. Paperclip renders the interaction in its UI and, for connected chats, uses supported provider question controls or a safe fallback. Normal task permissions and review gates still apply." : descriptor.description, inputSchema: descriptor.operationId === "register_deliverable" diff --git a/server/src/services/native-runtime/runner-api-reference.ts b/server/src/services/native-runtime/runner-api-reference.ts index f201b6a861c..0ec14a7d61a 100644 --- a/server/src/services/native-runtime/runner-api-reference.ts +++ b/server/src/services/native-runtime/runner-api-reference.ts @@ -245,7 +245,18 @@ export const runnerApiReference: Record { }); describe("buildOnboardingFirstTaskBrief", () => { - it("assembles the brief with the confirmation proposal when the toggle is off", async () => { - const brief = await buildOnboardingFirstTaskBrief({ usePlanProposal: false }); - expect(brief).toContain("This is the user's first task in Paperclip."); - // Step 1 branches on the opening card's two option ids. - expect(brief).toContain("Take the path the user picked."); - expect(brief).toContain(`\`${ONBOARDING_FIRST_TASK_OPENING_INTERVIEW_OPTION_ID}\` →`); - expect(brief).toContain(`\`${ONBOARDING_FIRST_TASK_OPENING_TASK_OPTION_ID}\` →`); - // The confirmation form is inlined at the {{proposalStep}} slot. - expect(brief).toContain("post ONE request_confirmation that says, in a few lines"); - expect(brief).not.toContain("{{proposalStep}}"); - // The plan-form-only wording must not appear. - expect(brief).not.toContain("treat it like the plan path"); + it.each([ + { usePlanProposal: false, mode: "confirmation" }, + { usePlanProposal: true, mode: "plan" }, + ])("invokes the skill with $mode mode without inlining the policy", async ({ usePlanProposal, mode }) => { + const brief = await buildOnboardingFirstTaskBrief({ usePlanProposal }); + expect(brief).toContain("Use the `first-task` skill (/first-task)"); + expect(brief).toContain("Read its SKILL.md"); + expect(brief).toContain("subsequent wakes of this task"); + expect(brief).toContain(`Single-task proposal mode: \`${mode}\`.`); + expect(brief).not.toContain("{{"); + expect(brief).not.toContain("Take the path the user picked."); + expect(brief).not.toContain("request_confirmation"); + expect(brief).not.toContain("request_checkbox_confirmation"); }); +}); - it("assembles the brief with the plan proposal when the toggle is on", async () => { - const brief = await buildOnboardingFirstTaskBrief({ usePlanProposal: true }); - expect(brief).toContain("treat it like the plan path"); - expect(brief).not.toContain("post ONE request_confirmation that says, in a few lines"); - expect(brief).not.toContain("{{proposalStep}}"); +describe("first-task proposal mode policy", () => { + it("maps both persisted brief modes to their proposal forms", async () => { + const skill = await readFile(new URL("../onboarding-assets/first-task/skills/first-task/SKILL.md", import.meta.url), "utf8"); + expect(skill).toContain("`confirmation` means one `request_confirmation`"); + expect(skill).toContain("`plan` means save a short `plan` document"); + expect(skill).toContain("`request_checkbox_confirmation` targeting its saved revision"); + expect(skill).toContain("explicit plan requests regardless of the single-task proposal mode"); }); }); @@ -97,7 +102,7 @@ describe("chief-of-staff persona", () => { organizationName: "Acme", }); expect(persona).toContain("You are Ada, chief of staff for Acme."); - expect(persona).toContain("# Hiring and delegation"); + expect(persona).toContain("# Working with the user"); expect(persona).not.toContain("{{agentName}}"); expect(persona).not.toContain("{{organizationName}}"); }); diff --git a/server/src/services/onboarding-first-task-assets.ts b/server/src/services/onboarding-first-task-assets.ts index 0e4c0a3a0f1..2030faa519c 100644 --- a/server/src/services/onboarding-first-task-assets.ts +++ b/server/src/services/onboarding-first-task-assets.ts @@ -11,7 +11,7 @@ import { // without touching TypeScript. These loaders read those files at runtime the // same way loadDefaultAgentInstructionsBundle reads default/ and ceo/ (the build // copies src/onboarding-assets/. into dist/onboarding-assets/), and fill the -// {{agentName}} / {{organizationName}} / {{proposalStep}} placeholders. +// {{agentName}} / {{organizationName}} / {{proposalMode}} placeholders. export interface OnboardingFirstTaskPlaceholders { agentName?: string | null; @@ -20,7 +20,7 @@ export interface OnboardingFirstTaskPlaceholders { // The opening card seeded on the first task right after the greeting: one // single-select question with two options, "interview me" or "I have a task in -// mind" (free text). The brief refers to these ids, so they are fixed here; +// mind" (free text). The first-task skill refers to these ids, so they are fixed here; // only the wording lives in opening-question.json. export const ONBOARDING_FIRST_TASK_OPENING_QUESTION_ID = "first-task-opening"; export const ONBOARDING_FIRST_TASK_OPENING_INTERVIEW_OPTION_ID = "interview"; @@ -120,19 +120,13 @@ export async function buildOnboardingFirstTaskOpeningQuestion(): Promise