mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 09:39:53 +01:00
feat(plugins): let an environment plugin report its task's startup stage (#22970)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A run's environment can come from a plugin, which runs the agent's task through environment task operations such as prepare and submit. > - The stacked pull requests below this one make Core publish each run's startup stage from the steps it times, and show that stage in the task view. > - Core cannot see inside a plugin's task operation. A slow step there, such as a stopped machine starting, shows as whatever stage Core was in when it called the plugin. > - This pull request lets an environment plugin report its task's stage, from the same closed list Core uses, while one of its task operations runs. > - The benefit is that the task view names the real reason a plugin-backed turn has not started yet, with no stages only plugins know about. ## Linked Issues or Issue Description No public issue exists. Stacked on #22956 (UI), which is stacked on #22953 (server). **Subsystem affected** Plugin SDK (`packages/plugins/sdk`), plugin host services and environment task runtime (`server/src/services`), and the plugin docs. **Problem or motivation** A plugin's environment task operation can take many seconds, for example when it starts a stopped machine. The task view keeps the stage Core showed when it called the plugin, so the wait has the wrong name. **Proposed solution** Add `ctx.environmentTasks.reportStartupStage({ taskId, stage })`. Core accepts a report only while one of that plugin's task operations for a run is in flight. The reported stage shows instead of Core's stage until the operation returns. **Alternatives considered** - Free-form status text from the plugin. It would not match Core's stages, and each plugin would word the same step in a different way. - Stages that only plugins can report. One shared list keeps Core and plugins aligned, so the task view needs no plugin-specific labels. ## What Changed - SDK: `ctx.environmentTasks.reportStartupStage({ taskId, stage })` and the `environmentTasks.reportStartupStage` host method. The call needs the existing `environment.drivers.register` capability. The test harness records reports in `startupStageReports`. - Server: the environment task runtime opens a reporting window for the plugin and task while each task operation for a run is in flight. Inside the window, the plugin's stage shows instead of Core's stage, and may be an earlier stage (for example `starting_environment` during submit). When the last operation returns, Core's stage shows again. - Server: Core ignores a report outside a window, for another plugin's task, with an unknown stage, or after the agent's turn starts. A report never fails the task operation. - Docs: `PLUGIN_ENVIRONMENT_TASKS.md` has a "Startup stages" section, and `PLUGIN_SPEC.md` lists `ctx.environmentTasks`. - `tests/runner-e2e/source-sdk-public-inputs.json`: regenerated for the changed SDK sources. ## Verification - `npx vitest run tests/host-client-factory.test.ts tests/testing-environment-tasks.test.ts` in `packages/plugins/sdk`: the capability gate and the harness record (26 tests pass). - `npx vitest run src/services/run-startup-stage.test.ts src/__tests__/environment-task-runtime.test.ts` in `server`: windows open and close per operation, overlapping operations, reports outside a window or after the turn starts are ignored, an earlier stage shows during the window, and a report from inside a real task operation reaches the run (78 tests pass). - `node tests/runner-e2e/source-sdk-public-inputs.mjs <head> --write` reports no changes. - `pnpm --filter @paperclipai/plugin-sdk typecheck` and `pnpm --filter @paperclipai/server typecheck` pass. - CI runs the full suite. ## Risks - Low risk. The call is new and optional. Plugins that do not call it see no change. - A plugin can only report for its own task, only while Core waits on one of its operations, and only from the shared stage list. It cannot change the stage after the agent's turn starts. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits). ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1a726eaccf
commit
fa283aeea2
16 files changed
+281
-17
No files matched your search
@@ -14,22 +14,22 @@
|
||||
"packages/plugins/sdk/src/environment-sync-error.ts": "7d6a51a95da49a7da4525aebbab6382dc5c44ae8",
|
||||
"packages/plugins/sdk/src/environment-task-error.ts": "98aae8a06743b38884b68cb9a3ec44c57b34c0e4",
|
||||
"packages/plugins/sdk/src/environment-tasks.ts": "ebdf0950379645dda416300acaa65718daf2795e",
|
||||
"packages/plugins/sdk/src/host-client-factory.ts": "e0301c390ea13f2340b669383f07af2455e48c8a",
|
||||
"packages/plugins/sdk/src/host-client-factory.ts": "8f76d518b4b43a41436b516cb2929165611bd483",
|
||||
"packages/plugins/sdk/src/idle-drain.test.ts": "cc59f7881e7d46c89395a1d93d74f6c6b9b0a64a",
|
||||
"packages/plugins/sdk/src/idle-drain.ts": "ae6e4c6be4657a3d541396922b3bc551b8db557f",
|
||||
"packages/plugins/sdk/src/index.ts": "686c87d177f180a05e4162dd762fd0447572956f",
|
||||
"packages/plugins/sdk/src/invocation-tracer.ts": "b28ac4aa4bc3e82658abac4a8081ed4508008696",
|
||||
"packages/plugins/sdk/src/protocol.duplex-channel.test.ts": "18255eb3d63038dc459240c111cbcb29fcba25cc",
|
||||
"packages/plugins/sdk/src/protocol.ts": "4861d78f1c57f1485a79e037932f39e8c91446b8",
|
||||
"packages/plugins/sdk/src/testing.ts": "5a3994447fd84ce176978fa8bc3548c14c37b189",
|
||||
"packages/plugins/sdk/src/types.ts": "e3532de0e1341dae241a44e6b6e5419bd0645687",
|
||||
"packages/plugins/sdk/src/protocol.ts": "a540b56dee310bfacc0d9100a795d12dfbc9396a",
|
||||
"packages/plugins/sdk/src/testing.ts": "d40b4c1cada40a3a371085612774b64aa1b984a0",
|
||||
"packages/plugins/sdk/src/types.ts": "1391d1599de9da2c0a3e7c9cacaf1448cedf6dac",
|
||||
"packages/plugins/sdk/src/ui/clipboard.ts": "1f42069c97d731e636a6ad5481dad22d20c0ed63",
|
||||
"packages/plugins/sdk/src/ui/components.ts": "3f0594408a1bb5ac3a8d00e709f91877dd260359",
|
||||
"packages/plugins/sdk/src/ui/hooks.ts": "686d02cf4b35f1cddb79a83a4c4d81fd52f0100e",
|
||||
"packages/plugins/sdk/src/ui/index.ts": "f7d1cee64a8f0c924bd10a1bd20745a52fe2060e",
|
||||
"packages/plugins/sdk/src/ui/runtime.ts": "998428e9701eba3b762d3417236d32c2d0d5763d",
|
||||
"packages/plugins/sdk/src/ui/types.ts": "5a5644acf6554d2e5e1d000bfd03b97d57001eb2",
|
||||
"packages/plugins/sdk/src/worker-rpc-host.ts": "820c73c7d4c681296ef8c813a68ab2bd9901d339",
|
||||
"packages/plugins/sdk/src/worker-rpc-host.ts": "1fe5ce2c81362af765db249a4c804dfd04688683",
|
||||
"packages/plugins/sdk/src/workspace-operation-error.ts": "2cd247d002d83b163239229e631bca4e519e5075",
|
||||
"packages/plugins/sdk/src/workspace-provider.ts": "38e945b807f22150710c11b136af0a28aab2cb7c",
|
||||
"packages/plugins/sdk/tsconfig.json": "d62ebdff94bc4b75dabf1fcad187e1e7a90fc794",
|
||||
|
||||
Reference in new issue
Block a user