@xingular/harness 2.0.0 → 2.0.1-unstable
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +635 -0
- package/LICENSE +202 -0
- package/NOTICE.md +50 -0
- package/README.md +241 -90
- package/THIRD_PARTY_LICENSES.md +942 -0
- package/browser-extension/README.md +32 -0
- package/browser-extension/background.js +612 -0
- package/browser-extension/manifest.json +16 -0
- package/browser-extension/overlay.js +97 -0
- package/browser-extension/popup.css +19 -0
- package/browser-extension/popup.html +30 -0
- package/browser-extension/popup.js +101 -0
- package/browser-extension/site-access.js +63 -0
- package/builtin/skills/plugin-authoring/SKILL.md +53 -0
- package/dist/cli.js +32851 -17155
- package/dist/sdk/accounts/accounts.d.ts +195 -0
- package/dist/sdk/accounts/accounts.js +821 -0
- package/dist/sdk/accounts/choices.d.ts +41 -0
- package/dist/sdk/accounts/choices.js +89 -0
- package/dist/sdk/accounts/env.d.ts +78 -0
- package/dist/sdk/accounts/env.js +294 -0
- package/dist/sdk/accounts/secrets.d.ts +28 -0
- package/dist/sdk/accounts/secrets.js +147 -0
- package/dist/sdk/accounts/store.d.ts +139 -0
- package/dist/sdk/accounts/store.js +255 -0
- package/dist/sdk/agents/builtin.d.ts +2 -0
- package/dist/sdk/agents/builtin.js +50 -0
- package/dist/sdk/agents/narrow.d.ts +13 -0
- package/dist/sdk/agents/narrow.js +29 -0
- package/dist/sdk/agents/planResearch.d.ts +27 -0
- package/dist/sdk/agents/planResearch.js +82 -0
- package/dist/sdk/agents/profiles.d.ts +93 -0
- package/dist/sdk/agents/profiles.js +289 -0
- package/dist/sdk/annotations/bridge.d.ts +44 -0
- package/dist/sdk/annotations/bridge.js +268 -0
- package/dist/sdk/annotations/capture.d.ts +158 -0
- package/dist/sdk/annotations/capture.js +409 -0
- package/dist/sdk/annotations/delivery.d.ts +79 -0
- package/dist/sdk/annotations/delivery.js +163 -0
- package/dist/sdk/annotations/inspect.d.ts +10 -0
- package/dist/sdk/annotations/inspect.js +34 -0
- package/dist/sdk/annotations/isolated.d.ts +6 -0
- package/dist/sdk/annotations/isolated.js +51 -0
- package/dist/sdk/annotations/pageScript.d.ts +28 -0
- package/dist/sdk/annotations/pageScript.js +871 -0
- package/dist/sdk/annotations/part.d.ts +8 -0
- package/dist/sdk/annotations/part.js +126 -0
- package/dist/sdk/annotations/queue.d.ts +4 -0
- package/dist/sdk/annotations/queue.js +45 -0
- package/dist/sdk/annotations/serverMethods.d.ts +3 -0
- package/dist/sdk/annotations/serverMethods.js +66 -0
- package/dist/sdk/annotations/store.d.ts +159 -0
- package/dist/sdk/annotations/store.js +404 -0
- package/dist/sdk/browser/backend.d.ts +16 -0
- package/dist/sdk/browser/backend.js +17 -0
- package/dist/sdk/browser/config.d.ts +19 -0
- package/dist/sdk/browser/config.js +23 -0
- package/dist/sdk/browser/contracts.d.ts +19 -0
- package/dist/sdk/browser/contracts.js +116 -0
- package/dist/sdk/browser/diagnostics.d.ts +4 -0
- package/dist/sdk/browser/diagnostics.js +38 -0
- package/dist/sdk/browser/extension/bridge.d.ts +55 -0
- package/dist/sdk/browser/extension/bridge.js +336 -0
- package/dist/sdk/browser/extension/session.d.ts +50 -0
- package/dist/sdk/browser/extension/session.js +321 -0
- package/dist/sdk/browser/index.d.ts +33 -0
- package/dist/sdk/browser/index.js +105 -0
- package/dist/sdk/browser/network.d.ts +10 -0
- package/dist/sdk/browser/network.js +59 -0
- package/dist/sdk/browser/serverMethods.d.ts +3 -0
- package/dist/sdk/browser/serverMethods.js +10 -0
- package/dist/sdk/browser/session.d.ts +85 -0
- package/dist/sdk/browser/session.js +228 -0
- package/dist/sdk/browser/tools.d.ts +102 -0
- package/dist/sdk/browser/tools.js +257 -0
- package/dist/sdk/capabilities/api.d.ts +22 -0
- package/dist/sdk/capabilities/api.js +54 -0
- package/dist/sdk/capabilities/runSnapshot.d.ts +18 -0
- package/dist/sdk/capabilities/runSnapshot.js +53 -0
- package/dist/sdk/capabilities/types.d.ts +29 -0
- package/dist/sdk/capabilities/types.js +1 -0
- package/dist/sdk/cli.d.ts +2 -0
- package/dist/sdk/cli.js +172 -0
- package/dist/sdk/commands/extensionOwners.d.ts +4 -0
- package/dist/sdk/commands/extensionOwners.js +17 -0
- package/dist/sdk/commands/list.d.ts +3 -0
- package/dist/sdk/commands/list.js +90 -0
- package/dist/sdk/commands/promptLoader.d.ts +5 -0
- package/dist/sdk/commands/promptLoader.js +76 -0
- package/dist/sdk/commands/promptRoutes.d.ts +13 -0
- package/dist/sdk/commands/promptRoutes.js +46 -0
- package/dist/sdk/commands/registry.d.ts +299 -0
- package/dist/sdk/commands/registry.js +54 -0
- package/dist/sdk/commands/routes.d.ts +16 -0
- package/dist/sdk/commands/routes.js +33 -0
- package/dist/sdk/commands/runtimeRouter.d.ts +4 -0
- package/dist/sdk/commands/runtimeRouter.js +48 -0
- package/dist/sdk/computer/boundary.d.ts +40 -0
- package/dist/sdk/computer/boundary.js +79 -0
- package/dist/sdk/computer/contracts.d.ts +127 -0
- package/dist/sdk/computer/contracts.js +13 -0
- package/dist/sdk/computer/control.d.ts +34 -0
- package/dist/sdk/computer/control.js +112 -0
- package/dist/sdk/computer/screenshot.d.ts +32 -0
- package/dist/sdk/computer/screenshot.js +35 -0
- package/dist/sdk/computer/terminalCapture.d.ts +26 -0
- package/dist/sdk/computer/terminalCapture.js +64 -0
- package/dist/sdk/computer/volatileImages.d.ts +9 -0
- package/dist/sdk/computer/volatileImages.js +50 -0
- package/dist/sdk/context/attribution.d.ts +18 -0
- package/dist/sdk/context/attribution.js +295 -0
- package/dist/sdk/context/runDetails.d.ts +16 -0
- package/dist/sdk/context/runDetails.js +22 -0
- package/dist/sdk/context/types.d.ts +94 -0
- package/dist/sdk/context/types.js +10 -0
- package/dist/sdk/core/bus.d.ts +23 -0
- package/dist/sdk/core/bus.js +76 -0
- package/dist/sdk/core/caller.d.ts +22 -0
- package/dist/sdk/core/caller.js +16 -0
- package/dist/sdk/core/changes.d.ts +15 -0
- package/dist/sdk/core/changes.js +15 -0
- package/dist/sdk/core/commandBudget.d.ts +23 -0
- package/dist/sdk/core/commandBudget.js +62 -0
- package/dist/sdk/core/effort.d.ts +2 -0
- package/dist/sdk/core/effort.js +1 -0
- package/dist/sdk/core/env.d.ts +18 -0
- package/dist/sdk/core/env.js +8 -0
- package/dist/sdk/core/errors.d.ts +15 -0
- package/dist/sdk/core/errors.js +24 -0
- package/dist/sdk/core/frontmatter.d.ts +12 -0
- package/dist/sdk/core/frontmatter.js +50 -0
- package/dist/sdk/core/fs.d.ts +18 -0
- package/dist/sdk/core/fs.js +106 -0
- package/dist/sdk/core/index.d.ts +24 -0
- package/dist/sdk/core/index.js +203 -0
- package/dist/sdk/core/interactiveProfile.d.ts +46 -0
- package/dist/sdk/core/interactiveProfile.js +143 -0
- package/dist/sdk/core/links.d.ts +51 -0
- package/dist/sdk/core/links.js +155 -0
- package/dist/sdk/core/path.d.ts +7 -0
- package/dist/sdk/core/path.js +79 -0
- package/dist/sdk/core/projects.d.ts +18 -0
- package/dist/sdk/core/projects.js +67 -0
- package/dist/sdk/core/secrets.d.ts +2 -0
- package/dist/sdk/core/secrets.js +5 -0
- package/dist/sdk/core/shell.d.ts +20 -0
- package/dist/sdk/core/shell.js +73 -0
- package/dist/sdk/core/text.d.ts +7 -0
- package/dist/sdk/core/text.js +40 -0
- package/dist/sdk/core/workspace.d.ts +13 -0
- package/dist/sdk/core/workspace.js +88 -0
- package/dist/sdk/core/workspaceBashTool.d.ts +20 -0
- package/dist/sdk/core/workspaceBashTool.js +50 -0
- package/dist/sdk/core/workspaceSandbox.d.ts +41 -0
- package/dist/sdk/core/workspaceSandbox.js +360 -0
- package/dist/sdk/core/workspaceWriteOperations.d.ts +57 -0
- package/dist/sdk/core/workspaceWriteOperations.js +245 -0
- package/dist/sdk/doctor/checks.d.ts +5 -0
- package/dist/sdk/doctor/checks.js +270 -0
- package/dist/sdk/doctor/probe.d.ts +4 -0
- package/dist/sdk/doctor/probe.js +94 -0
- package/dist/sdk/doctor/serverMethods.d.ts +3 -0
- package/dist/sdk/doctor/serverMethods.js +8 -0
- package/dist/sdk/doctor/service.d.ts +23 -0
- package/dist/sdk/doctor/service.js +144 -0
- package/dist/sdk/doctor/types.d.ts +141 -0
- package/dist/sdk/doctor/types.js +29 -0
- package/dist/sdk/harness.d.ts +172 -0
- package/dist/sdk/harness.js +387 -0
- package/dist/sdk/history/lessonPrompt.d.ts +2 -0
- package/dist/sdk/history/lessonPrompt.js +15 -0
- package/dist/sdk/history/lessons.d.ts +52 -0
- package/dist/sdk/history/lessons.js +173 -0
- package/dist/sdk/history/recall.d.ts +68 -0
- package/dist/sdk/history/recall.js +199 -0
- package/dist/sdk/history/serverMethods.d.ts +3 -0
- package/dist/sdk/history/serverMethods.js +8 -0
- package/dist/sdk/history/trajectory.d.ts +7 -0
- package/dist/sdk/history/trajectory.js +218 -0
- package/dist/sdk/hub/catalog.json +123 -0
- package/dist/sdk/hub/cli.d.ts +7 -0
- package/dist/sdk/hub/cli.js +81 -0
- package/dist/sdk/hub/hub.d.ts +74 -0
- package/dist/sdk/hub/hub.js +476 -0
- package/dist/sdk/hub/schema.d.ts +280 -0
- package/dist/sdk/hub/schema.js +78 -0
- package/dist/sdk/hub/serverMethods.d.ts +3 -0
- package/dist/sdk/hub/serverMethods.js +11 -0
- package/dist/sdk/index.d.ts +80 -0
- package/dist/sdk/index.js +60 -0
- package/dist/sdk/mcp/connections.d.ts +83 -0
- package/dist/sdk/mcp/connections.js +676 -0
- package/dist/sdk/mcp/manager.d.ts +26 -0
- package/dist/sdk/mcp/manager.js +124 -0
- package/dist/sdk/mcp/oauth.d.ts +35 -0
- package/dist/sdk/mcp/oauth.js +171 -0
- package/dist/sdk/mcp/scopeMigration.d.ts +19 -0
- package/dist/sdk/mcp/scopeMigration.js +198 -0
- package/dist/sdk/mcp/serverMethods.d.ts +3 -0
- package/dist/sdk/mcp/serverMethods.js +22 -0
- package/dist/sdk/mcp/service.d.ts +160 -0
- package/dist/sdk/mcp/service.js +510 -0
- package/dist/sdk/mcp/types.d.ts +131 -0
- package/dist/sdk/mcp/types.js +49 -0
- package/dist/sdk/pi/retryPolicy.d.ts +19 -0
- package/dist/sdk/pi/retryPolicy.js +11 -0
- package/dist/sdk/pi/runtime.d.ts +14 -0
- package/dist/sdk/pi/runtime.js +31 -0
- package/dist/sdk/plugins/api.d.ts +66 -0
- package/dist/sdk/plugins/api.js +155 -0
- package/dist/sdk/plugins/attachments.d.ts +46 -0
- package/dist/sdk/plugins/attachments.js +111 -0
- package/dist/sdk/plugins/builtin.d.ts +7 -0
- package/dist/sdk/plugins/builtin.js +182 -0
- package/dist/sdk/plugins/builtinRegistry.d.ts +62 -0
- package/dist/sdk/plugins/builtinRegistry.js +77 -0
- package/dist/sdk/plugins/catalogue.d.ts +29 -0
- package/dist/sdk/plugins/catalogue.js +197 -0
- package/dist/sdk/plugins/cli.d.ts +13 -0
- package/dist/sdk/plugins/cli.js +188 -0
- package/dist/sdk/plugins/commandPrefix.d.ts +8 -0
- package/dist/sdk/plugins/commandPrefix.js +21 -0
- package/dist/sdk/plugins/discover.d.ts +48 -0
- package/dist/sdk/plugins/discover.js +230 -0
- package/dist/sdk/plugins/firstParty.d.ts +50 -0
- package/dist/sdk/plugins/firstParty.js +119 -0
- package/dist/sdk/plugins/hooks.d.ts +94 -0
- package/dist/sdk/plugins/hooks.js +162 -0
- package/dist/sdk/plugins/identity.d.ts +19 -0
- package/dist/sdk/plugins/identity.js +48 -0
- package/dist/sdk/plugins/install.d.ts +24 -0
- package/dist/sdk/plugins/install.js +160 -0
- package/dist/sdk/plugins/inventory.d.ts +22 -0
- package/dist/sdk/plugins/inventory.js +111 -0
- package/dist/sdk/plugins/manifest.d.ts +21 -0
- package/dist/sdk/plugins/manifest.js +94 -0
- package/dist/sdk/plugins/plugins.d.ts +106 -0
- package/dist/sdk/plugins/plugins.js +165 -0
- package/dist/sdk/plugins/proposals.d.ts +17 -0
- package/dist/sdk/plugins/proposals.js +147 -0
- package/dist/sdk/plugins/runtime.d.ts +9 -0
- package/dist/sdk/plugins/runtime.js +95 -0
- package/dist/sdk/plugins/surfaces.d.ts +5 -0
- package/dist/sdk/plugins/surfaces.js +11 -0
- package/dist/sdk/plugins/trust.d.ts +44 -0
- package/dist/sdk/plugins/trust.js +120 -0
- package/dist/sdk/plugins/types.d.ts +174 -0
- package/dist/sdk/plugins/types.js +7 -0
- package/dist/sdk/prompt/compile.d.ts +245 -0
- package/dist/sdk/prompt/compile.js +535 -0
- package/dist/sdk/prompt/reporting.d.ts +2 -0
- package/dist/sdk/prompt/reporting.js +94 -0
- package/dist/sdk/prompt/standard.d.ts +32 -0
- package/dist/sdk/prompt/standard.js +76 -0
- package/dist/sdk/refine/cli.d.ts +4 -0
- package/dist/sdk/refine/cli.js +186 -0
- package/dist/sdk/refine/demo.d.ts +21 -0
- package/dist/sdk/refine/demo.js +114 -0
- package/dist/sdk/refine/evidence.d.ts +55 -0
- package/dist/sdk/refine/evidence.js +330 -0
- package/dist/sdk/refine/host.d.ts +59 -0
- package/dist/sdk/refine/host.js +105 -0
- package/dist/sdk/refine/ledger.d.ts +48 -0
- package/dist/sdk/refine/ledger.js +76 -0
- package/dist/sdk/refine/library.d.ts +55 -0
- package/dist/sdk/refine/library.js +177 -0
- package/dist/sdk/refine/pi.d.ts +72 -0
- package/dist/sdk/refine/pi.js +248 -0
- package/dist/sdk/refine/prompts.d.ts +60 -0
- package/dist/sdk/refine/prompts.js +434 -0
- package/dist/sdk/refine/recursion.d.ts +113 -0
- package/dist/sdk/refine/recursion.js +258 -0
- package/dist/sdk/refine/runner.d.ts +83 -0
- package/dist/sdk/refine/runner.js +151 -0
- package/dist/sdk/refine/selection.d.ts +57 -0
- package/dist/sdk/refine/selection.js +251 -0
- package/dist/sdk/refine/serverMethods.d.ts +3 -0
- package/dist/sdk/refine/serverMethods.js +23 -0
- package/dist/sdk/refine/service.d.ts +115 -0
- package/dist/sdk/refine/service.js +280 -0
- package/dist/sdk/refine/suite.d.ts +67 -0
- package/dist/sdk/refine/suite.js +174 -0
- package/dist/sdk/refine/trajectory.d.ts +9 -0
- package/dist/sdk/refine/trajectory.js +73 -0
- package/dist/sdk/refine/types.d.ts +93 -0
- package/dist/sdk/refine/types.js +10 -0
- package/dist/sdk/remote/addresses.d.ts +19 -0
- package/dist/sdk/remote/addresses.js +52 -0
- package/dist/sdk/remote/pairing.d.ts +59 -0
- package/dist/sdk/remote/pairing.js +160 -0
- package/dist/sdk/remote/seal.d.ts +28 -0
- package/dist/sdk/remote/seal.js +84 -0
- package/dist/sdk/remote/server.d.ts +28 -0
- package/dist/sdk/remote/server.js +158 -0
- package/dist/sdk/remote/service.d.ts +125 -0
- package/dist/sdk/remote/service.js +330 -0
- package/dist/sdk/remote/webClient.d.ts +4 -0
- package/dist/sdk/remote/webClient.js +452 -0
- package/dist/sdk/server/methods.d.ts +3 -0
- package/dist/sdk/server/methods.js +365 -0
- package/dist/sdk/server/params.d.ts +4 -0
- package/dist/sdk/server/params.js +11 -0
- package/dist/sdk/server/remote.d.ts +19 -0
- package/dist/sdk/server/remote.js +109 -0
- package/dist/sdk/server/rpc.d.ts +20 -0
- package/dist/sdk/server/rpc.js +102 -0
- package/dist/sdk/server/serve.d.ts +13 -0
- package/dist/sdk/server/serve.js +25 -0
- package/dist/sdk/server/socket.d.ts +28 -0
- package/dist/sdk/server/socket.js +122 -0
- package/dist/sdk/sessions/approvals.d.ts +47 -0
- package/dist/sdk/sessions/approvals.js +119 -0
- package/dist/sdk/sessions/checkpoint.d.ts +7 -0
- package/dist/sdk/sessions/checkpoint.js +41 -0
- package/dist/sdk/sessions/compactionCheckpoint.d.ts +18 -0
- package/dist/sdk/sessions/compactionCheckpoint.js +79 -0
- package/dist/sdk/sessions/completionCheck.d.ts +51 -0
- package/dist/sdk/sessions/completionCheck.js +161 -0
- package/dist/sdk/sessions/continuation.d.ts +53 -0
- package/dist/sdk/sessions/continuation.js +90 -0
- package/dist/sdk/sessions/contracts.d.ts +991 -0
- package/dist/sdk/sessions/contracts.js +545 -0
- package/dist/sdk/sessions/control.d.ts +72 -0
- package/dist/sdk/sessions/control.js +158 -0
- package/dist/sdk/sessions/extensionUi.d.ts +19 -0
- package/dist/sdk/sessions/extensionUi.js +64 -0
- package/dist/sdk/sessions/goal.d.ts +145 -0
- package/dist/sdk/sessions/goal.js +405 -0
- package/dist/sdk/sessions/goalLoop.d.ts +37 -0
- package/dist/sdk/sessions/goalLoop.js +125 -0
- package/dist/sdk/sessions/goalPrompts.d.ts +4 -0
- package/dist/sdk/sessions/goalPrompts.js +93 -0
- package/dist/sdk/sessions/goalStop.d.ts +27 -0
- package/dist/sdk/sessions/goalStop.js +41 -0
- package/dist/sdk/sessions/history.d.ts +16 -0
- package/dist/sdk/sessions/history.js +68 -0
- package/dist/sdk/sessions/initialBash.d.ts +7 -0
- package/dist/sdk/sessions/initialBash.js +7 -0
- package/dist/sdk/sessions/lineageJoin.d.ts +2 -0
- package/dist/sdk/sessions/lineageJoin.js +61 -0
- package/dist/sdk/sessions/live.d.ts +101 -0
- package/dist/sdk/sessions/live.js +265 -0
- package/dist/sdk/sessions/planMode.d.ts +116 -0
- package/dist/sdk/sessions/planMode.js +281 -0
- package/dist/sdk/sessions/policy.d.ts +43 -0
- package/dist/sdk/sessions/policy.js +1 -0
- package/dist/sdk/sessions/pricing.d.ts +34 -0
- package/dist/sdk/sessions/pricing.js +40 -0
- package/dist/sdk/sessions/reasoningSummaries.d.ts +11 -0
- package/dist/sdk/sessions/reasoningSummaries.js +61 -0
- package/dist/sdk/sessions/registry.d.ts +124 -0
- package/dist/sdk/sessions/registry.js +392 -0
- package/dist/sdk/sessions/runIndex.d.ts +21 -0
- package/dist/sdk/sessions/runIndex.js +65 -0
- package/dist/sdk/sessions/runStore.d.ts +82 -0
- package/dist/sdk/sessions/runStore.js +393 -0
- package/dist/sdk/sessions/runner.d.ts +291 -0
- package/dist/sdk/sessions/runner.js +1040 -0
- package/dist/sdk/sessions/sessionState.d.ts +13 -0
- package/dist/sdk/sessions/sessionState.js +31 -0
- package/dist/sdk/sessions/sessions.d.ts +238 -0
- package/dist/sdk/sessions/sessions.js +923 -0
- package/dist/sdk/sessions/sideQuestionServerMethods.d.ts +3 -0
- package/dist/sdk/sessions/sideQuestionServerMethods.js +19 -0
- package/dist/sdk/sessions/sideQuestions.d.ts +66 -0
- package/dist/sdk/sessions/sideQuestions.js +290 -0
- package/dist/sdk/sessions/stallWatch.d.ts +35 -0
- package/dist/sdk/sessions/stallWatch.js +42 -0
- package/dist/sdk/sessions/subagentServerMethods.d.ts +3 -0
- package/dist/sdk/sessions/subagentServerMethods.js +41 -0
- package/dist/sdk/sessions/subagentService.d.ts +88 -0
- package/dist/sdk/sessions/subagentService.js +546 -0
- package/dist/sdk/sessions/subagents.d.ts +98 -0
- package/dist/sdk/sessions/subagents.js +136 -0
- package/dist/sdk/sessions/workSlice.d.ts +167 -0
- package/dist/sdk/sessions/workSlice.js +266 -0
- package/dist/sdk/sessions/workspaceBoundary.d.ts +15 -0
- package/dist/sdk/sessions/workspaceBoundary.js +46 -0
- package/dist/sdk/terminal/accountsMenu.d.ts +46 -0
- package/dist/sdk/terminal/accountsMenu.js +392 -0
- package/dist/sdk/terminal/browser.d.ts +62 -0
- package/dist/sdk/terminal/browser.js +41 -0
- package/dist/sdk/terminal/browserControl.d.ts +29 -0
- package/dist/sdk/terminal/browserControl.js +187 -0
- package/dist/sdk/terminal/cli.d.ts +20 -0
- package/dist/sdk/terminal/cli.js +121 -0
- package/dist/sdk/terminal/client.d.ts +20 -0
- package/dist/sdk/terminal/client.js +148 -0
- package/dist/sdk/terminal/commandHelp.d.ts +17 -0
- package/dist/sdk/terminal/commandHelp.js +20 -0
- package/dist/sdk/terminal/control.d.ts +4 -0
- package/dist/sdk/terminal/control.js +25 -0
- package/dist/sdk/terminal/controller.d.ts +136 -0
- package/dist/sdk/terminal/controller.js +579 -0
- package/dist/sdk/terminal/credentialStore.d.ts +4 -0
- package/dist/sdk/terminal/credentialStore.js +33 -0
- package/dist/sdk/terminal/daemon.d.ts +44 -0
- package/dist/sdk/terminal/daemon.js +264 -0
- package/dist/sdk/terminal/hubMenu.d.ts +10 -0
- package/dist/sdk/terminal/hubMenu.js +34 -0
- package/dist/sdk/terminal/launch.d.ts +5 -0
- package/dist/sdk/terminal/launch.js +27 -0
- package/dist/sdk/terminal/liveTerminal.d.ts +96 -0
- package/dist/sdk/terminal/liveTerminal.js +436 -0
- package/dist/sdk/terminal/logs.d.ts +14 -0
- package/dist/sdk/terminal/logs.js +59 -0
- package/dist/sdk/terminal/opentui/ansi.d.ts +25 -0
- package/dist/sdk/terminal/opentui/ansi.js +192 -0
- package/dist/sdk/terminal/opentui/model.d.ts +163 -0
- package/dist/sdk/terminal/opentui/model.js +484 -0
- package/dist/sdk/terminal/opentui/subagentsWidget.d.ts +28 -0
- package/dist/sdk/terminal/opentui/subagentsWidget.js +54 -0
- package/dist/sdk/terminal/opentui/theme.d.ts +47 -0
- package/dist/sdk/terminal/opentui/theme.js +93 -0
- package/dist/sdk/terminal/piExtension.d.ts +12 -0
- package/dist/sdk/terminal/piExtension.js +847 -0
- package/dist/sdk/terminal/pluginMenu.d.ts +34 -0
- package/dist/sdk/terminal/pluginMenu.js +101 -0
- package/dist/sdk/terminal/socket.d.ts +73 -0
- package/dist/sdk/terminal/socket.js +287 -0
- package/dist/sdk/terminal/standalone.d.ts +52 -0
- package/dist/sdk/terminal/standalone.js +329 -0
- package/dist/sdk/terminal/subagentMonitor.d.ts +62 -0
- package/dist/sdk/terminal/subagentMonitor.js +176 -0
- package/dist/sdk/terminal/terminals.d.ts +312 -0
- package/dist/sdk/terminal/terminals.js +1782 -0
- package/dist/sdk/terminal/toolName.d.ts +6 -0
- package/dist/sdk/terminal/toolName.js +12 -0
- package/dist/sdk/terminal/trajectory.d.ts +15 -0
- package/dist/sdk/terminal/trajectory.js +38 -0
- package/dist/sdk/terminal/tui/annotateCommand.d.ts +7 -0
- package/dist/sdk/terminal/tui/annotateCommand.js +36 -0
- package/dist/sdk/terminal/tui/annotateSend.d.ts +30 -0
- package/dist/sdk/terminal/tui/annotateSend.js +40 -0
- package/dist/sdk/terminal/tui/chrome.d.ts +68 -0
- package/dist/sdk/terminal/tui/chrome.js +182 -0
- package/dist/sdk/terminal/tui/clipboardFiles.d.ts +11 -0
- package/dist/sdk/terminal/tui/clipboardFiles.js +74 -0
- package/dist/sdk/terminal/tui/commandPages.d.ts +16 -0
- package/dist/sdk/terminal/tui/commandPages.js +136 -0
- package/dist/sdk/terminal/tui/commands.d.ts +71 -0
- package/dist/sdk/terminal/tui/commands.js +496 -0
- package/dist/sdk/terminal/tui/dialogGeometry.d.ts +27 -0
- package/dist/sdk/terminal/tui/dialogGeometry.js +52 -0
- package/dist/sdk/terminal/tui/dialogs.d.ts +81 -0
- package/dist/sdk/terminal/tui/dialogs.js +372 -0
- package/dist/sdk/terminal/tui/goalCommand.d.ts +19 -0
- package/dist/sdk/terminal/tui/goalCommand.js +83 -0
- package/dist/sdk/terminal/tui/harnessRuntime.d.ts +8 -0
- package/dist/sdk/terminal/tui/harnessRuntime.js +771 -0
- package/dist/sdk/terminal/tui/keybindings.d.ts +11 -0
- package/dist/sdk/terminal/tui/keybindings.js +49 -0
- package/dist/sdk/terminal/tui/list.d.ts +86 -0
- package/dist/sdk/terminal/tui/list.js +278 -0
- package/dist/sdk/terminal/tui/markdown.d.ts +16 -0
- package/dist/sdk/terminal/tui/markdown.js +55 -0
- package/dist/sdk/terminal/tui/modeChoices.d.ts +61 -0
- package/dist/sdk/terminal/tui/modeChoices.js +95 -0
- package/dist/sdk/terminal/tui/modelPicker.d.ts +55 -0
- package/dist/sdk/terminal/tui/modelPicker.js +150 -0
- package/dist/sdk/terminal/tui/mouse.d.ts +3 -0
- package/dist/sdk/terminal/tui/mouse.js +3 -0
- package/dist/sdk/terminal/tui/mouseReport.d.ts +30 -0
- package/dist/sdk/terminal/tui/mouseReport.js +80 -0
- package/dist/sdk/terminal/tui/page.d.ts +17 -0
- package/dist/sdk/terminal/tui/page.js +1 -0
- package/dist/sdk/terminal/tui/pageOverlay.d.ts +30 -0
- package/dist/sdk/terminal/tui/pageOverlay.js +183 -0
- package/dist/sdk/terminal/tui/pages/accountsPage.d.ts +76 -0
- package/dist/sdk/terminal/tui/pages/accountsPage.js +409 -0
- package/dist/sdk/terminal/tui/pages/agentsPage.d.ts +74 -0
- package/dist/sdk/terminal/tui/pages/agentsPage.js +193 -0
- package/dist/sdk/terminal/tui/pages/annotatePage.d.ts +148 -0
- package/dist/sdk/terminal/tui/pages/annotatePage.js +576 -0
- package/dist/sdk/terminal/tui/pages/browserPage.d.ts +87 -0
- package/dist/sdk/terminal/tui/pages/browserPage.js +739 -0
- package/dist/sdk/terminal/tui/pages/componentsPage.d.ts +47 -0
- package/dist/sdk/terminal/tui/pages/componentsPage.js +119 -0
- package/dist/sdk/terminal/tui/pages/contextPage.d.ts +91 -0
- package/dist/sdk/terminal/tui/pages/contextPage.js +585 -0
- package/dist/sdk/terminal/tui/pages/doctorPage.d.ts +39 -0
- package/dist/sdk/terminal/tui/pages/doctorPage.js +233 -0
- package/dist/sdk/terminal/tui/pages/followUpQueuePage.d.ts +34 -0
- package/dist/sdk/terminal/tui/pages/followUpQueuePage.js +130 -0
- package/dist/sdk/terminal/tui/pages/hubPage.d.ts +52 -0
- package/dist/sdk/terminal/tui/pages/hubPage.js +292 -0
- package/dist/sdk/terminal/tui/pages/logPage.d.ts +38 -0
- package/dist/sdk/terminal/tui/pages/logPage.js +189 -0
- package/dist/sdk/terminal/tui/pages/permissionsPage.d.ts +44 -0
- package/dist/sdk/terminal/tui/pages/permissionsPage.js +124 -0
- package/dist/sdk/terminal/tui/pages/pluginsPage.d.ts +65 -0
- package/dist/sdk/terminal/tui/pages/pluginsPage.js +519 -0
- package/dist/sdk/terminal/tui/pages/remoteControlPage.d.ts +32 -0
- package/dist/sdk/terminal/tui/pages/remoteControlPage.js +170 -0
- package/dist/sdk/terminal/tui/pages/settingsPage.d.ts +63 -0
- package/dist/sdk/terminal/tui/pages/settingsPage.js +103 -0
- package/dist/sdk/terminal/tui/pages/subagentsPage.d.ts +24 -0
- package/dist/sdk/terminal/tui/pages/subagentsPage.js +155 -0
- package/dist/sdk/terminal/tui/pages/textPage.d.ts +17 -0
- package/dist/sdk/terminal/tui/pages/textPage.js +52 -0
- package/dist/sdk/terminal/tui/pages/trajectoryPage.d.ts +66 -0
- package/dist/sdk/terminal/tui/pages/trajectoryPage.js +490 -0
- package/dist/sdk/terminal/tui/pages/usagePage.d.ts +45 -0
- package/dist/sdk/terminal/tui/pages/usagePage.js +397 -0
- package/dist/sdk/terminal/tui/pages/worktreesPage.d.ts +72 -0
- package/dist/sdk/terminal/tui/pages/worktreesPage.js +203 -0
- package/dist/sdk/terminal/tui/piAdapter.d.ts +17 -0
- package/dist/sdk/terminal/tui/piAdapter.js +46 -0
- package/dist/sdk/terminal/tui/planMode.d.ts +2 -0
- package/dist/sdk/terminal/tui/planMode.js +2 -0
- package/dist/sdk/terminal/tui/pluginCommands.d.ts +16 -0
- package/dist/sdk/terminal/tui/pluginCommands.js +41 -0
- package/dist/sdk/terminal/tui/qr.d.ts +4 -0
- package/dist/sdk/terminal/tui/qr.js +35 -0
- package/dist/sdk/terminal/tui/questionPicker.d.ts +20 -0
- package/dist/sdk/terminal/tui/questionPicker.js +150 -0
- package/dist/sdk/terminal/tui/questions.d.ts +21 -0
- package/dist/sdk/terminal/tui/questions.js +42 -0
- package/dist/sdk/terminal/tui/runtime.d.ts +117 -0
- package/dist/sdk/terminal/tui/runtime.js +544 -0
- package/dist/sdk/terminal/tui/search.d.ts +22 -0
- package/dist/sdk/terminal/tui/search.js +61 -0
- package/dist/sdk/terminal/tui/selection.d.ts +16 -0
- package/dist/sdk/terminal/tui/selection.js +16 -0
- package/dist/sdk/terminal/tui/sessionPicker.d.ts +40 -0
- package/dist/sdk/terminal/tui/sessionPicker.js +141 -0
- package/dist/sdk/terminal/tui/sessionUi.d.ts +3 -0
- package/dist/sdk/terminal/tui/sessionUi.js +30 -0
- package/dist/sdk/terminal/tui/settingsModel.d.ts +14 -0
- package/dist/sdk/terminal/tui/settingsModel.js +195 -0
- package/dist/sdk/terminal/tui/sideQuestion.d.ts +57 -0
- package/dist/sdk/terminal/tui/sideQuestion.js +241 -0
- package/dist/sdk/terminal/tui/skillInvocation.d.ts +28 -0
- package/dist/sdk/terminal/tui/skillInvocation.js +63 -0
- package/dist/sdk/terminal/tui/status.d.ts +18 -0
- package/dist/sdk/terminal/tui/status.js +67 -0
- package/dist/sdk/terminal/tui/theme.d.ts +54 -0
- package/dist/sdk/terminal/tui/theme.js +185 -0
- package/dist/sdk/terminal/tui/thinkingLevels.d.ts +11 -0
- package/dist/sdk/terminal/tui/thinkingLevels.js +31 -0
- package/dist/sdk/terminal/tui/treeModel.d.ts +79 -0
- package/dist/sdk/terminal/tui/treeModel.js +483 -0
- package/dist/sdk/terminal/tui/treePicker.d.ts +49 -0
- package/dist/sdk/terminal/tui/treePicker.js +251 -0
- package/dist/sdk/terminal/tui/ui.d.ts +49 -0
- package/dist/sdk/terminal/tui/ui.js +149 -0
- package/dist/sdk/terminal/tui/variantCommands.d.ts +32 -0
- package/dist/sdk/terminal/tui/variantCommands.js +359 -0
- package/dist/sdk/terminal/tui/workingStatus.d.ts +9 -0
- package/dist/sdk/terminal/tui/workingStatus.js +229 -0
- package/dist/sdk/terminal/variantControl.d.ts +24 -0
- package/dist/sdk/terminal/variantControl.js +145 -0
- package/dist/sdk/tools/askUser.d.ts +6 -0
- package/dist/sdk/tools/askUser.js +92 -0
- package/dist/sdk/tools/defaultSkills.d.ts +23 -0
- package/dist/sdk/tools/defaultSkills.js +46 -0
- package/dist/sdk/tools/definitions.d.ts +32 -0
- package/dist/sdk/tools/definitions.js +133 -0
- package/dist/sdk/tools/dispatch.d.ts +16 -0
- package/dist/sdk/tools/dispatch.js +92 -0
- package/dist/sdk/tools/getCapabilities.d.ts +31 -0
- package/dist/sdk/tools/getCapabilities.js +34 -0
- package/dist/sdk/tools/harnessTools.d.ts +8 -0
- package/dist/sdk/tools/harnessTools.js +20 -0
- package/dist/sdk/tools/sessionName.d.ts +16 -0
- package/dist/sdk/tools/sessionName.js +78 -0
- package/dist/sdk/tools/spawnSubagent.d.ts +4 -0
- package/dist/sdk/tools/spawnSubagent.js +63 -0
- package/dist/sdk/tools/todo.d.ts +15 -0
- package/dist/sdk/tools/todo.js +66 -0
- package/dist/sdk/tools/types.d.ts +48 -0
- package/dist/sdk/tools/types.js +1 -0
- package/dist/sdk/usage/analytics.d.ts +20 -0
- package/dist/sdk/usage/analytics.js +151 -0
- package/dist/sdk/usage/ledger.d.ts +38 -0
- package/dist/sdk/usage/ledger.js +142 -0
- package/dist/sdk/usage/limits/adapters.d.ts +11 -0
- package/dist/sdk/usage/limits/adapters.js +349 -0
- package/dist/sdk/usage/limits/capture.d.ts +8 -0
- package/dist/sdk/usage/limits/capture.js +47 -0
- package/dist/sdk/usage/limits/http.d.ts +12 -0
- package/dist/sdk/usage/limits/http.js +51 -0
- package/dist/sdk/usage/limits/normalize.d.ts +15 -0
- package/dist/sdk/usage/limits/normalize.js +211 -0
- package/dist/sdk/usage/limits/service.d.ts +30 -0
- package/dist/sdk/usage/limits/service.js +176 -0
- package/dist/sdk/usage/limits/types.d.ts +65 -0
- package/dist/sdk/usage/limits/types.js +1 -0
- package/dist/sdk/usage/serverMethods.d.ts +3 -0
- package/dist/sdk/usage/serverMethods.js +22 -0
- package/dist/sdk/usage/service.d.ts +32 -0
- package/dist/sdk/usage/service.js +66 -0
- package/dist/sdk/usage/settings.d.ts +7 -0
- package/dist/sdk/usage/settings.js +28 -0
- package/dist/sdk/usage/types.d.ts +60 -0
- package/dist/sdk/usage/types.js +4 -0
- package/dist/sdk/variant/components.d.ts +34 -0
- package/dist/sdk/variant/components.js +230 -0
- package/dist/sdk/variant/materialise.d.ts +66 -0
- package/dist/sdk/variant/materialise.js +81 -0
- package/dist/sdk/variant/migrate.d.ts +4 -0
- package/dist/sdk/variant/migrate.js +41 -0
- package/dist/sdk/variant/seed.d.ts +20 -0
- package/dist/sdk/variant/seed.js +116 -0
- package/dist/sdk/variant/store.d.ts +114 -0
- package/dist/sdk/variant/store.js +256 -0
- package/dist/sdk/variant/surface.d.ts +56 -0
- package/dist/sdk/variant/surface.js +81 -0
- package/dist/sdk/variant/trust.d.ts +27 -0
- package/dist/sdk/variant/trust.js +64 -0
- package/dist/sdk/variant/variant.d.ts +71 -0
- package/dist/sdk/variant/variant.js +331 -0
- package/dist/sdk/web/markdown.d.ts +10 -0
- package/dist/sdk/web/markdown.js +66 -0
- package/dist/sdk/web/part.d.ts +10 -0
- package/dist/sdk/web/part.js +6 -0
- package/dist/sdk/web/safeRequest.d.ts +34 -0
- package/dist/sdk/web/safeRequest.js +175 -0
- package/dist/sdk/web/search.d.ts +53 -0
- package/dist/sdk/web/search.js +168 -0
- package/dist/sdk/web/serverMethods.d.ts +3 -0
- package/dist/sdk/web/serverMethods.js +7 -0
- package/dist/sdk/web/text.d.ts +2 -0
- package/dist/sdk/web/text.js +7 -0
- package/dist/sdk/web/tools.d.ts +22 -0
- package/dist/sdk/web/tools.js +195 -0
- package/dist/sdk/web/turndown-plugin-gfm.d.ts +4 -0
- package/dist/sdk/wiki/notes.d.ts +68 -0
- package/dist/sdk/wiki/notes.js +297 -0
- package/dist/sdk/wiki/serverMethods.d.ts +3 -0
- package/dist/sdk/wiki/serverMethods.js +26 -0
- package/dist/sdk/worktrees/cli.d.ts +11 -0
- package/dist/sdk/worktrees/cli.js +146 -0
- package/dist/sdk/worktrees/copy.d.ts +9 -0
- package/dist/sdk/worktrees/copy.js +111 -0
- package/dist/sdk/worktrees/git.d.ts +18 -0
- package/dist/sdk/worktrees/git.js +89 -0
- package/dist/sdk/worktrees/serverMethods.d.ts +3 -0
- package/dist/sdk/worktrees/serverMethods.js +30 -0
- package/dist/sdk/worktrees/service.d.ts +73 -0
- package/dist/sdk/worktrees/service.js +483 -0
- package/dist/sdk/worktrees/setup.d.ts +23 -0
- package/dist/sdk/worktrees/setup.js +65 -0
- package/dist/sdk/worktrees/snapshot.d.ts +16 -0
- package/dist/sdk/worktrees/snapshot.js +83 -0
- package/dist/sdk/worktrees/types.d.ts +91 -0
- package/dist/sdk/worktrees/types.js +1 -0
- package/dist/sdk/world/actions.d.ts +23 -0
- package/dist/sdk/world/actions.js +31 -0
- package/dist/sdk/world/cli.d.ts +12 -0
- package/dist/sdk/world/cli.js +166 -0
- package/dist/sdk/world/images.d.ts +20 -0
- package/dist/sdk/world/images.js +48 -0
- package/dist/sdk/world/untrusted.d.ts +12 -0
- package/dist/sdk/world/untrusted.js +20 -0
- package/dist/sdk/world/world.d.ts +75 -0
- package/dist/sdk/world/world.js +117 -0
- package/dist/terminal-opentui.js +30986 -0
- package/dist/terminal-pi.js +3008 -610
- package/docs/README.md +45 -1
- package/docs/architecture/00-overview.md +171 -0
- package/docs/architecture/01-extension-points.md +78 -0
- package/docs/architecture/02-sessions-and-runs.md +505 -0
- package/docs/architecture/03-variants.md +122 -0
- package/docs/architecture/04-prompt.md +277 -0
- package/docs/architecture/05-refinement.md +134 -0
- package/docs/architecture/06-plugins-and-capabilities.md +208 -0
- package/docs/architecture/07-tools-and-gate.md +245 -0
- package/docs/architecture/08-memory-and-history.md +100 -0
- package/docs/architecture/09-accounts-and-connectors.md +153 -0
- package/docs/architecture/10-server-protocol.md +403 -0
- package/docs/architecture/11-terminal.md +555 -0
- package/docs/architecture/12-storage.md +118 -0
- package/docs/architecture/13-world-tools.md +114 -0
- package/docs/architecture/14-surfaces-and-parity.md +151 -0
- package/docs/architecture/15-remote-control.md +120 -0
- package/docs/architecture/README.md +143 -0
- package/docs/architecture/proposals/PROP-0001-reporting-section.md +106 -0
- package/docs/architecture/proposals/PROP-0002-retain-rollout-workspaces.md +104 -0
- package/docs/architecture/proposals/PROP-0003-executor-settings.md +81 -0
- package/docs/architecture/proposals/PROP-0004-flexible-reporting-guidance.md +71 -0
- package/docs/architecture/proposals/PROP-0005-xharness-cli-name.md +78 -0
- package/docs/architecture/proposals/PROP-0006-run-checklist.md +72 -0
- package/docs/architecture/proposals/PROP-0007-run-continuation.md +80 -0
- package/docs/architecture/proposals/PROP-0008-lessons-from-runs.md +80 -0
- package/docs/architecture/proposals/PROP-0009-foundation-and-variants.md +78 -0
- package/docs/architecture/proposals/PROP-0010-session-names.md +73 -0
- package/docs/architecture/proposals/PROP-0011-doctor.md +63 -0
- package/docs/architecture/proposals/PROP-0012-release-baseline.md +56 -0
- package/docs/architecture/proposals/PROP-0013-resource-browser.md +58 -0
- package/docs/architecture/proposals/PROP-0014-fullscreen-browser-tabs.md +58 -0
- package/docs/architecture/proposals/PROP-0015-one-capability-surface.md +88 -0
- package/docs/architecture/proposals/PROP-0016-managed-worktrees.md +156 -0
- package/docs/architecture/proposals/PROP-0017-page-annotations.md +131 -0
- package/docs/architecture/proposals/PROP-0018-annotation-queue-and-app-targets.md +183 -0
- package/docs/architecture/proposals/PROP-0019-contextual-side-questions.md +122 -0
- package/docs/architecture/proposals/PROP-0020-builtin-feature-plugins.md +105 -0
- package/docs/architecture/proposals/PROP-0021-command-namespaces-and-duplicates.md +99 -0
- package/docs/architecture/proposals/PROP-0022-plan-only-questions.md +102 -0
- package/docs/architecture/proposals/PROP-0023-xagent-cli-name.md +61 -0
- package/docs/architecture/proposals/PROP-0024-question-sketch-previews.md +130 -0
- package/docs/architecture/proposals/PROP-0025-contextual-question-wireframes.md +49 -0
- package/docs/architecture/proposals/PROP-0026-connected-sketch-display.md +96 -0
- package/docs/architecture/proposals/PROP-0027-xingular-agent-product-identity.md +60 -0
- package/docs/architecture/proposals/PROP-0028-normalize-question-wireframes.md +55 -0
- package/docs/architecture/proposals/PROP-0029-agent-profiles.md +124 -0
- package/docs/architecture/proposals/PROP-0030-subagent-title.md +86 -0
- package/docs/architecture/proposals/PROP-0031-plugin-command-owner-namespaces.md +54 -0
- package/docs/architecture/proposals/PROP-0032-planning-quality.md +196 -0
- package/docs/architecture/proposals/PROP-0033-compaction-plan-checkpoints.md +75 -0
- package/docs/architecture/proposals/PROP-0034-conversation-fast-mode.md +120 -0
- package/docs/architecture/proposals/PROP-0035-retain-subagent-status.md +47 -0
- package/docs/architecture/proposals/PROP-0036-first-class-harness-commands.md +59 -0
- package/docs/architecture/proposals/PROP-0037-workspace-write-boundary.md +63 -0
- package/docs/architecture/proposals/PROP-0038-annotate-open-shadow-roots.md +73 -0
- package/docs/architecture/proposals/PROP-0039-workspace-boundary-hardening.md +139 -0
- package/docs/architecture/proposals/PROP-0040-one-launch-path.md +87 -0
- package/docs/architecture/proposals/PROP-0041-bounded-work-slices.md +260 -0
- package/docs/architecture/proposals/PROP-0042-usage-and-provider-limits.md +127 -0
- package/docs/architecture/proposals/PROP-0043-read-only-plan-bash.md +74 -0
- package/docs/architecture/proposals/PROP-0044-work-slice-defaults.md +93 -0
- package/docs/architecture/proposals/PROP-0045-rename-checklist-to-todo.md +132 -0
- package/docs/architecture/proposals/PROP-0046-progress-aware-stall-guards.md +82 -0
- package/docs/architecture/proposals/PROP-0047-plugins-hub-separation.md +122 -0
- package/docs/architecture/proposals/PROP-0048-simple-annotate.md +85 -0
- package/docs/architecture/proposals/PROP-0049-context-attribution.md +415 -0
- package/docs/architecture/proposals/PROP-0050-run-stop-codes-and-refusals.md +30 -0
- package/docs/architecture/proposals/PROP-0051-unfinished-run-handoff.md +110 -0
- package/docs/architecture/proposals/PROP-0052-terminal-refine-and-variant-switch.md +111 -0
- package/docs/architecture/proposals/README.md +123 -0
- package/docs/decisions/ADR-0001-owned-terminal.md +10 -3
- package/docs/decisions/ADR-0003-shared-asynchronous-subagents.md +3 -1
- package/docs/decisions/ADR-0004-fullscreen-terminal-layout.md +3 -2
- package/docs/decisions/ADR-0006-opentui-only-terminal.md +47 -0
- package/docs/decisions/ADR-0007-reporting-section.md +33 -0
- package/docs/decisions/ADR-0008-flexible-reporting-guidance.md +41 -0
- package/docs/decisions/ADR-0009-xharness-command.md +39 -0
- package/docs/decisions/ADR-0010-lessons-in-the-wiki.md +31 -0
- package/docs/decisions/ADR-0011-foundation-and-variants.md +28 -0
- package/docs/decisions/ADR-0012-native-session-names.md +34 -0
- package/docs/decisions/ADR-0013-doctor.md +27 -0
- package/docs/decisions/ADR-0014-public-release-baseline.md +22 -0
- package/docs/decisions/ADR-0015-resource-browser.md +28 -0
- package/docs/decisions/ADR-0016-fullscreen-browser-tabs.md +31 -0
- package/docs/decisions/ADR-0017-one-capability-surface.md +34 -0
- package/docs/decisions/ADR-0018-builtin-feature-plugins.md +35 -0
- package/docs/decisions/ADR-0019-managed-git-worktrees.md +31 -0
- package/docs/decisions/ADR-0020-page-annotations.md +37 -0
- package/docs/decisions/ADR-0021-required-command-namespaces.md +40 -0
- package/docs/decisions/ADR-0022-plan-only-question-tools.md +34 -0
- package/docs/decisions/ADR-0023-contextual-side-question-runs.md +35 -0
- package/docs/decisions/ADR-0024-xagent-command.md +40 -0
- package/docs/decisions/ADR-0025-question-choice-sketches.md +49 -0
- package/docs/decisions/ADR-0026-contextual-question-wireframes.md +58 -0
- package/docs/decisions/ADR-0027-connected-sketch-display.md +62 -0
- package/docs/decisions/ADR-0028-xingular-agent-product-identity.md +56 -0
- package/docs/decisions/ADR-0029-normalized-question-wireframe-borders.md +33 -0
- package/docs/decisions/ADR-0030-agent-profiles.md +43 -0
- package/docs/decisions/ADR-0031-plugin-command-owner-namespaces.md +37 -0
- package/docs/decisions/ADR-0032-compaction-run-checkpoints.md +35 -0
- package/docs/decisions/ADR-0033-plan-mode-research-delegation.md +47 -0
- package/docs/decisions/ADR-0034-first-class-harness-terminal-commands.md +25 -0
- package/docs/decisions/ADR-0035-one-launch-path.md +40 -0
- package/docs/decisions/ADR-0036-workspace-write-operation-boundary.md +54 -0
- package/docs/decisions/ADR-0037-usage-ledger-and-provider-limits.md +44 -0
- package/docs/decisions/ADR-0038-plan-bash-os-read-only.md +29 -0
- package/docs/decisions/ADR-0039-progress-aware-stall-guards.md +43 -0
- package/docs/decisions/ADR-0040-architecture-change-workflow.md +31 -0
- package/docs/decisions/ADR-0041-plugins-hub-separation.md +41 -0
- package/docs/decisions/ADR-0042-windows-shell-without-sandbox.md +40 -0
- package/docs/decisions/ADR-0043-parents-continue-stopped-subagents.md +49 -0
- package/docs/decisions/ADR-0044-annotations-pending-or-sent.md +24 -0
- package/docs/decisions/ADR-0045-default-plugin-authoring-skill.md +9 -0
- package/docs/decisions/ADR-0046-hash-bound-plugin-proposals.md +20 -0
- package/docs/decisions/ADR-0047-links-open-with-the-os-handler.md +47 -0
- package/docs/decisions/ADR-0048-required-skills-from-a-message.md +42 -0
- package/docs/decisions/ADR-0050-approved-window-screenshots.md +19 -0
- package/docs/decisions/ADR-0051-terminal-decision-wait.md +10 -0
- package/docs/decisions/ADR-0052-per-profile-subagent-budgets.md +25 -0
- package/docs/decisions/ADR-0053-no-repeated-work-guard.md +45 -0
- package/docs/decisions/ADR-0054-terminal-reply-heartbeat-and-stall.md +52 -0
- package/docs/decisions/ADR-0055-plan-output-repair.md +51 -0
- package/docs/decisions/ADR-0056-remote-control.md +53 -0
- package/docs/decisions/ADR-0057-structured-plan-outcomes.md +39 -0
- package/docs/decisions/ADR-0058-ask-user-only-plan-clarification.md +36 -0
- package/docs/decisions/ADR-0059-run-diagnostic-evidence.md +35 -0
- package/docs/decisions/ADR-0060-approvals-are-controls.md +40 -0
- package/docs/decisions/ADR-0061-strict-plugin-command-namespaces.md +41 -0
- package/docs/decisions/ADR-0062-shared-account-state.md +67 -0
- package/docs/decisions/ADR-0063-unfinished-work-handoffs.md +34 -0
- package/docs/decisions/ADR-0064-account-model-fallback-on-resume.md +79 -0
- package/docs/decisions/ADR-0065-variant-switch-at-turn-boundaries.md +31 -0
- package/docs/decisions/ADR-0066-guided-refinement-from-turn-snapshots.md +37 -0
- package/docs/decisions/ADR-0067-cache-stable-compaction-checkpoint.md +54 -0
- package/docs/decisions/ADR-0068-scope-and-completion-report.md +60 -0
- package/docs/decisions/ADR-0069-stop-gate-and-finish.md +136 -0
- package/docs/decisions/ADR-0070-terminal-slice-continuation.md +49 -0
- package/docs/decisions/ADR-0071-completion-check.md +104 -0
- package/docs/decisions/ADR-0072-codex-prompts-and-goal.md +108 -0
- package/docs/decisions/ADR-0073-large-reporting-prompt.md +89 -0
- package/docs/decisions/ADR-0074-report-content-not-report-blocks.md +90 -0
- package/docs/decisions/ADR-0075-no-todo-gate.md +84 -0
- package/docs/decisions/ADR-0076-codex-final-answer-verbatim.md +98 -0
- package/docs/decisions/ADR-0077-plan-runs-may-conclude-no-plan-needed.md +120 -0
- package/docs/decisions/ADR-0078-child-aware-stall-watch.md +46 -0
- package/docs/decisions/ADR-0079-phase-led-reporting-guidance.md +72 -0
- package/docs/decisions/ADR-0080-fixed-width-question-sketch-canvas.md +50 -0
- package/docs/decisions/ADR-0081-no-work-slice-budget-by-default.md +36 -0
- package/docs/decisions/ADR-0082-connected-brave-browser.md +72 -0
- package/docs/decisions/ADR-0083-one-live-session-runtime.md +256 -0
- package/docs/doctor.md +95 -0
- package/docs/experiments/EXP-0001-terminal-input-latency/plan.md +81 -0
- package/docs/experiments/EXP-0001-terminal-input-latency/results.md +46 -0
- package/docs/experiments/EXP-0002-opentui-typing-latency/plan.md +70 -0
- package/docs/experiments/EXP-0002-opentui-typing-latency/results.md +92 -0
- package/docs/experiments/EXP-0003-performance-audit/data/session-runtime-replication.json +420 -0
- package/docs/experiments/EXP-0003-performance-audit/data/session-runtime.json +420 -0
- package/docs/experiments/EXP-0003-performance-audit/data/terminal-compact.json +376 -0
- package/docs/experiments/EXP-0003-performance-audit/data/terminal-history.json +422 -0
- package/docs/experiments/EXP-0003-performance-audit/data/terminal-question.json +95 -0
- package/docs/experiments/EXP-0003-performance-audit/data/terminal-wide.json +1036 -0
- package/docs/experiments/EXP-0003-performance-audit/plan.md +109 -0
- package/docs/experiments/EXP-0003-performance-audit/results.md +151 -0
- package/docs/features/README.md +46 -0
- package/docs/features/automations/README.md +41 -0
- package/docs/features/cores/README.md +39 -0
- package/docs/features/google-harness2/README.md +52 -0
- package/docs/features/integrations/README.md +40 -0
- package/docs/features/interfaces/README.md +29 -0
- package/docs/features/memory/README.md +28 -0
- package/docs/future-work.md +48 -0
- package/docs/handoff-2026-10-25-app-parity-and-solo-tabs.md +202 -0
- package/docs/parity.md +158 -0
- package/docs/releases/1.0.0.md +40 -0
- package/docs/releases/1.1.1.md +28 -0
- package/docs/releases/1.2.0.md +49 -0
- package/docs/releases/1.3.0.md +21 -0
- package/docs/releases/1.3.1-unstable.1.md +8 -0
- package/docs/releases/1.3.1-unstable.2.md +11 -0
- package/docs/releases/1.3.1-unstable.3.md +54 -0
- package/docs/releases/1.3.1-unstable.4.md +56 -0
- package/docs/releases/1.3.1-unstable.5.md +53 -0
- package/docs/releases/1.3.1-unstable.6.md +31 -0
- package/docs/releases/1.3.1-unstable.7.md +17 -0
- package/docs/releases/1.3.1-unstable.8.md +19 -0
- package/docs/releases/1.3.1-unstable.9.md +54 -0
- package/docs/releases/1.4.0-unstable.md +25 -0
- package/docs/releases/1.5.0-unstable.md +32 -0
- package/docs/releases/1.5.1-unstable.md +24 -0
- package/docs/releases/1.6.0-unstable.md +59 -0
- package/docs/releases/2.0.1-unstable.md +63 -0
- package/docs/releases/4.0.0.md +47 -0
- package/docs/releases/README.md +49 -0
- package/docs/study/00-index.md +112 -0
- package/docs/study/STUDY-0003-long-horizon-runs.md +210 -0
- package/docs/study/STUDY-0004-turn-end-controls.md +130 -0
- package/docs/study/STUDY-0005-skill-installation-guidance.md +146 -0
- package/docs/study/STUDY-0006-reporting-prompts.md +119 -0
- package/docs/study/STUDY-0007-claude-code-prompt.md +162 -0
- package/docs/study/STUDY-0008-browser-control.md +281 -0
- package/docs/study/STUDY-0009-claude-code-reporting.md +205 -0
- package/docs/study/arms/00-matrix.md +20 -0
- package/docs/study/arms/01-system-prompt.md +211 -0
- package/docs/study/arms/02-tools.md +79 -0
- package/docs/study/arms/03-subagents.md +90 -0
- package/docs/study/arms/04-skills.md +81 -0
- package/docs/study/arms/05-context-management.md +90 -0
- package/docs/study/arms/06-memory.md +90 -0
- package/docs/study/arms/07-governance.md +71 -0
- package/docs/study/arms/08-execution.md +69 -0
- package/docs/study/arms/09-observability.md +60 -0
- package/docs/study/arms/10-refinement.md +110 -0
- package/docs/study/autonomous-engineering-sources.md +277 -0
- package/docs/study/autonomy-sources.md +147 -0
- package/docs/study/btw-comparison.md +37 -0
- package/docs/study/feature-gap-review.md +42 -0
- package/docs/study/insights.md +123 -0
- package/docs/study/proactive-autonomy.md +408 -0
- package/docs/study/roadmap.md +72 -0
- package/docs/study/sources/claude-code.md +56 -0
- package/docs/study/sources/deepseek-harness.md +102 -0
- package/docs/study/sources/harness2.md +50 -0
- package/docs/study/sources/kimi-cli.md +42 -0
- package/docs/study/sources/omp.md +93 -0
- package/docs/study/sources/opencode.md +43 -0
- package/docs/study/sources/openhands.md +46 -0
- package/docs/study/sources/smolagents.md +40 -0
- package/docs/study/sources/swe-agent.md +34 -0
- package/docs/study/tui-resource-browser.md +78 -0
- package/docs/system-prompt-design.md +196 -0
- package/docs/terminal-tui.md +887 -109
- package/package.json +46 -13
- package/src/accounts/accounts.test.ts +0 -419
- package/src/accounts/accounts.ts +0 -760
- package/src/accounts/env.test.ts +0 -95
- package/src/accounts/env.ts +0 -338
- package/src/accounts/secrets.ts +0 -50
- package/src/accounts/store.ts +0 -338
- package/src/capabilities/api.ts +0 -75
- package/src/capabilities/runSnapshot.ts +0 -59
- package/src/capabilities/types.ts +0 -34
- package/src/cli.ts +0 -118
- package/src/core/bus.test.ts +0 -22
- package/src/core/bus.ts +0 -49
- package/src/core/changes.ts +0 -33
- package/src/core/env.ts +0 -27
- package/src/core/errors.ts +0 -32
- package/src/core/frontmatter.ts +0 -47
- package/src/core/fs.test.ts +0 -38
- package/src/core/fs.ts +0 -92
- package/src/core/index.ts +0 -193
- package/src/core/path.test.ts +0 -14
- package/src/core/path.ts +0 -79
- package/src/core/projects.ts +0 -90
- package/src/core/text.ts +0 -39
- package/src/harness.ts +0 -322
- package/src/hub/catalog.json +0 -123
- package/src/hub/cli.ts +0 -59
- package/src/hub/hub.test.ts +0 -205
- package/src/hub/hub.ts +0 -256
- package/src/hub/schema.ts +0 -81
- package/src/index.ts +0 -80
- package/src/mcp/connections.ts +0 -641
- package/src/mcp/manager.ts +0 -130
- package/src/mcp/oauth.ts +0 -195
- package/src/mcp/scopeMigration.test.ts +0 -79
- package/src/mcp/scopeMigration.ts +0 -204
- package/src/mcp/service.test.ts +0 -422
- package/src/mcp/service.ts +0 -560
- package/src/mcp/types.ts +0 -118
- package/src/memory/api.test.ts +0 -82
- package/src/memory/api.ts +0 -303
- package/src/memory/blocks.test.ts +0 -78
- package/src/memory/blocks.ts +0 -408
- package/src/memory/caller.ts +0 -69
- package/src/memory/curation.test.ts +0 -206
- package/src/memory/curation.ts +0 -64
- package/src/memory/dispatch.ts +0 -64
- package/src/memory/facts.test.ts +0 -41
- package/src/memory/facts.ts +0 -248
- package/src/memory/graph.ts +0 -103
- package/src/memory/health.test.ts +0 -130
- package/src/memory/health.ts +0 -74
- package/src/memory/maintainer.ts +0 -272
- package/src/memory/maintenance.test.ts +0 -192
- package/src/memory/maintenance.ts +0 -679
- package/src/memory/migrate.ts +0 -79
- package/src/memory/operations.ts +0 -150
- package/src/memory/proposals.test.ts +0 -168
- package/src/memory/proposals.ts +0 -584
- package/src/memory/recall.test.ts +0 -115
- package/src/memory/recall.ts +0 -279
- package/src/memory/references.ts +0 -77
- package/src/memory/runContext.ts +0 -93
- package/src/memory/secrets.ts +0 -6
- package/src/memory/store.test.ts +0 -66
- package/src/memory/store.ts +0 -385
- package/src/memory/trajectory.test.ts +0 -178
- package/src/memory/trajectory.ts +0 -220
- package/src/memory/wiki.test.ts +0 -47
- package/src/memory/wiki.ts +0 -423
- package/src/memory/wikiIndex.test.ts +0 -88
- package/src/memory/wikiIndex.ts +0 -117
- package/src/plugins/api.ts +0 -181
- package/src/plugins/attachments.test.ts +0 -84
- package/src/plugins/attachments.ts +0 -141
- package/src/plugins/builtin.ts +0 -84
- package/src/plugins/catalogue.test.ts +0 -254
- package/src/plugins/catalogue.ts +0 -251
- package/src/plugins/cli.ts +0 -184
- package/src/plugins/discover.ts +0 -151
- package/src/plugins/firstParty.test.ts +0 -143
- package/src/plugins/firstParty.ts +0 -129
- package/src/plugins/hooks.test.ts +0 -250
- package/src/plugins/hooks.ts +0 -239
- package/src/plugins/identity.ts +0 -37
- package/src/plugins/install.test.ts +0 -107
- package/src/plugins/install.ts +0 -106
- package/src/plugins/inventory.ts +0 -123
- package/src/plugins/manifest.ts +0 -76
- package/src/plugins/plugins.test.ts +0 -205
- package/src/plugins/plugins.ts +0 -189
- package/src/plugins/proposal.ts +0 -121
- package/src/plugins/runtime.test.ts +0 -40
- package/src/plugins/runtime.ts +0 -82
- package/src/plugins/trust.ts +0 -142
- package/src/plugins/types.ts +0 -149
- package/src/prompt/compile.test.ts +0 -261
- package/src/prompt/compile.ts +0 -732
- package/src/server/methods.ts +0 -355
- package/src/server/remote.ts +0 -77
- package/src/server/rpc.ts +0 -116
- package/src/server/serve.ts +0 -28
- package/src/server/server.test.ts +0 -193
- package/src/sessions/approvals.test.ts +0 -49
- package/src/sessions/approvals.ts +0 -140
- package/src/sessions/contracts.ts +0 -336
- package/src/sessions/conversation.test.ts +0 -233
- package/src/sessions/extensionSession.test.ts +0 -74
- package/src/sessions/extensionUi.test.ts +0 -65
- package/src/sessions/extensionUi.ts +0 -102
- package/src/sessions/history.ts +0 -51
- package/src/sessions/lineageJoin.ts +0 -75
- package/src/sessions/policy.ts +0 -36
- package/src/sessions/pricing.ts +0 -60
- package/src/sessions/questionBatches.test.ts +0 -110
- package/src/sessions/reasoningSummaries.ts +0 -59
- package/src/sessions/registry.ts +0 -412
- package/src/sessions/runIndex.ts +0 -99
- package/src/sessions/runStore.test.ts +0 -152
- package/src/sessions/runStore.ts +0 -346
- package/src/sessions/runner.ts +0 -610
- package/src/sessions/runtimeResources.test.ts +0 -61
- package/src/sessions/sessions.test.ts +0 -588
- package/src/sessions/sessions.ts +0 -331
- package/src/sessions/subagentService.test.ts +0 -159
- package/src/sessions/subagentService.ts +0 -236
- package/src/sessions/subagents.ts +0 -97
- package/src/skills/registry.test.ts +0 -104
- package/src/skills/registry.ts +0 -413
- package/src/terminal/accountsMenu.test.ts +0 -225
- package/src/terminal/accountsMenu.ts +0 -382
- package/src/terminal/cli.ts +0 -149
- package/src/terminal/client.ts +0 -74
- package/src/terminal/control.test.ts +0 -23
- package/src/terminal/control.ts +0 -23
- package/src/terminal/controller.ts +0 -354
- package/src/terminal/hubMenu.ts +0 -24
- package/src/terminal/launch.test.ts +0 -25
- package/src/terminal/launch.ts +0 -48
- package/src/terminal/piExtension.lifecycle.test.ts +0 -55
- package/src/terminal/piExtension.ts +0 -295
- package/src/terminal/pluginControl.test.ts +0 -146
- package/src/terminal/pluginMenu.ts +0 -112
- package/src/terminal/socket.test.ts +0 -94
- package/src/terminal/socket.ts +0 -256
- package/src/terminal/standalone.test.ts +0 -167
- package/src/terminal/standalone.ts +0 -165
- package/src/terminal/terminal.test.ts +0 -534
- package/src/terminal/terminals.ts +0 -661
- package/src/terminal/trajectory.test.ts +0 -66
- package/src/terminal/trajectory.ts +0 -44
- package/src/terminal/tui/application.test.ts +0 -290
- package/src/terminal/tui/application.ts +0 -653
- package/src/terminal/tui/commands.test.ts +0 -278
- package/src/terminal/tui/commands.ts +0 -443
- package/src/terminal/tui/dialogs.ts +0 -301
- package/src/terminal/tui/editor.test.ts +0 -113
- package/src/terminal/tui/editor.ts +0 -109
- package/src/terminal/tui/keybindings.test.ts +0 -30
- package/src/terminal/tui/keybindings.ts +0 -59
- package/src/terminal/tui/piAdapter.ts +0 -62
- package/src/terminal/tui/planMode.test.ts +0 -10
- package/src/terminal/tui/planMode.ts +0 -12
- package/src/terminal/tui/presentation.test.ts +0 -79
- package/src/terminal/tui/questions.test.ts +0 -41
- package/src/terminal/tui/questions.ts +0 -47
- package/src/terminal/tui/runtime.socket.test.ts +0 -178
- package/src/terminal/tui/runtime.test.ts +0 -225
- package/src/terminal/tui/runtime.ts +0 -403
- package/src/terminal/tui/screen.test.ts +0 -143
- package/src/terminal/tui/screen.ts +0 -121
- package/src/terminal/tui/sessionUi.ts +0 -24
- package/src/terminal/tui/settings.test.ts +0 -150
- package/src/terminal/tui/settings.ts +0 -188
- package/src/terminal/tui/skillInvocation.test.ts +0 -71
- package/src/terminal/tui/skillInvocation.ts +0 -51
- package/src/terminal/tui/status.test.ts +0 -48
- package/src/terminal/tui/status.ts +0 -82
- package/src/terminal/tui/theme.ts +0 -185
- package/src/terminal/tui/tools.test.ts +0 -145
- package/src/terminal/tui/tools.ts +0 -142
- package/src/terminal/tui/trajectoryPanel.test.ts +0 -99
- package/src/terminal/tui/trajectoryPanel.ts +0 -226
- package/src/terminal/tui/transcript.test.ts +0 -39
- package/src/terminal/tui/transcript.ts +0 -135
- package/src/terminal/tui/ui.test.ts +0 -313
- package/src/terminal/tui/ui.ts +0 -166
- package/src/terminal/tui/welcome.ts +0 -102
- package/src/terminal/tui/workingStatus.test.ts +0 -44
- package/src/terminal/tui/workingStatus.ts +0 -238
- package/src/tools/askUser.test.ts +0 -69
- package/src/tools/askUser.ts +0 -59
- package/src/tools/definitions.ts +0 -228
- package/src/tools/maintenance.ts +0 -29
- package/src/tools/memoryTools.ts +0 -22
- package/src/tools/pluginPropose.ts +0 -41
- package/src/tools/registryWrite.test.ts +0 -101
- package/src/tools/registryWrite.ts +0 -182
- package/src/tools/spawnSubagent.ts +0 -47
- package/src/tools/types.ts +0 -41
- package/src/web/safeRequest.ts +0 -171
- package/src/web/text.ts +0 -53
- package/src/web/tools.ts +0 -134
- package/src/web/web.test.ts +0 -141
|
@@ -0,0 +1,923 @@
|
|
|
1
|
+
// Starting a session turn: the account, the run record, the compiled prompt, the tools and
|
|
2
|
+
// their gate, then Pi. Everything before Pi answers is synchronous with the caller; the reply
|
|
3
|
+
// itself streams as run events.
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
import { existsSync, mkdirSync } from 'node:fs';
|
|
6
|
+
import { isAbsolute, join } from 'node:path';
|
|
7
|
+
import { log } from "../core/bus.js";
|
|
8
|
+
import { HarnessError, invalid } from "../core/errors.js";
|
|
9
|
+
import { formatBashCommandForApproval } from "../core/workspaceBashTool.js";
|
|
10
|
+
import { capabilitySet as parseCapabilitySet, freezeRun } from "../capabilities/runSnapshot.js";
|
|
11
|
+
import { now, writeJson } from "../core/fs.js";
|
|
12
|
+
import { resolveWorkspaceRoot, verifyWorkspaceRoot } from "../core/workspace.js";
|
|
13
|
+
import { takeChars } from "../core/text.js";
|
|
14
|
+
import { BUILTIN_PLUGIN_REGISTRY } from "../plugins/builtin.js";
|
|
15
|
+
import { sessionLaunch } from "../prompt/compile.js";
|
|
16
|
+
import * as attachments from "../plugins/attachments.js";
|
|
17
|
+
import { FIRST_PARTY_PLUGINS, firstPartyExtensions } from "../plugins/firstParty.js";
|
|
18
|
+
import { imagePruning } from "../world/images.js";
|
|
19
|
+
import { materialise } from "../variant/materialise.js";
|
|
20
|
+
import { snapshotWorkingTree } from "../worktrees/snapshot.js";
|
|
21
|
+
import { ASK_USER } from "../tools/askUser.js";
|
|
22
|
+
import { defaultSkillPaths } from "../tools/defaultSkills.js";
|
|
23
|
+
import { TODO_WRITE } from "../tools/todo.js";
|
|
24
|
+
import { checkpointOf } from "./checkpoint.js";
|
|
25
|
+
import { launchSwitchOff, sessionCheckModel } from "./completionCheck.js";
|
|
26
|
+
import { GOAL_TOOLS, GoalController, GoalError, continuationPrompt, goalTools, provenanceText } from "./goal.js";
|
|
27
|
+
import { GOAL_EXTENSION, goalLoop, goalNotice } from "./goalLoop.js";
|
|
28
|
+
import { SESSION_NAME, deriveSessionName, sessionNameTool } from "../tools/sessionName.js";
|
|
29
|
+
import { DEFAULT_TOOL_NAMES } from "../tools/definitions.js";
|
|
30
|
+
import { GET_CAPABILITIES, getCapabilitiesTool } from "../tools/getCapabilities.js";
|
|
31
|
+
import { isActiveStatus, stopCodeOf } from "./contracts.js";
|
|
32
|
+
import { SPAWN_SUBAGENT, WAIT_SUBAGENTS, subagentDepth, subagentHistory, subagentNesting } from "./subagents.js";
|
|
33
|
+
import { selectHistory } from "./history.js";
|
|
34
|
+
import { runLineageJoin } from "./lineageJoin.js";
|
|
35
|
+
import { latestSessionName } from "./sessionState.js";
|
|
36
|
+
import { compactionCheckpoint, COMPACTION_CHECKPOINT_EXTENSION } from "./compactionCheckpoint.js";
|
|
37
|
+
import { createSliceState, parseWorkSlice, sliceOf, workSliceGuard, WorkSliceError, WORK_SLICE_EXTENSION } from "./workSlice.js";
|
|
38
|
+
import { piSessionFactory, runTurn, summarize } from "./runner.js";
|
|
39
|
+
import { loadRun, readEvents, runDir, saveRun, updateRun } from "./runStore.js";
|
|
40
|
+
import { livePin, LiveSessions } from "./live.js";
|
|
41
|
+
import { combineWorkspaceScope, inspectRunWorkspaceWrite } from "./workspaceBoundary.js";
|
|
42
|
+
import { PLAN_INSTRUCTIONS, PLAN_RESEARCH_SUBAGENT_INSTRUCTIONS, planModeTools, planRefusal, planSection } from "./planMode.js";
|
|
43
|
+
import { CONTINUATION_SECTION_ID, continuationOf, continuationSection } from "./continuation.js";
|
|
44
|
+
import { deliveredSnapshot } from "../prompt/compile.js";
|
|
45
|
+
import { profileSection } from "../agents/profiles.js";
|
|
46
|
+
/** A session command acts on a saved conversation and is never combined with a request of its own. */
|
|
47
|
+
function checkCommand(command, historyFile, input) {
|
|
48
|
+
if (!historyFile)
|
|
49
|
+
throw invalid('There is no saved conversation for this command yet.');
|
|
50
|
+
if (input.plan || input.continueFrom || input.automatic || input.initialBashCommand != null || input.images?.length) {
|
|
51
|
+
throw invalid('A session command runs on its own, without plan mode, a continuation, Bash or images.');
|
|
52
|
+
}
|
|
53
|
+
switch (command?.name) {
|
|
54
|
+
case 'compact': return;
|
|
55
|
+
case 'navigate':
|
|
56
|
+
if (typeof command.entryId !== 'string' || !command.entryId)
|
|
57
|
+
throw invalid('navigate needs the entry to go to.');
|
|
58
|
+
return;
|
|
59
|
+
case 'export':
|
|
60
|
+
if (typeof command.path !== 'string' || !isAbsolute(command.path) || !command.path.endsWith('.html'))
|
|
61
|
+
throw invalid('export needs an absolute .html path.');
|
|
62
|
+
return;
|
|
63
|
+
default: throw invalid('Unknown session command.');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const CONTINUE_TEXT = 'Continue from where you stopped.';
|
|
67
|
+
/** Fills a continuing run's input from the run it continues, refusing anything that would differ. */
|
|
68
|
+
function continueInput(root, input) {
|
|
69
|
+
const continuation = continuationOf(root, input.continueFrom, input.sessionDir);
|
|
70
|
+
if (!continuation.resumable || !continuation.resume)
|
|
71
|
+
throw new HarnessError('continuation_unavailable', `Run ${input.continueFrom} cannot be continued (${continuation.reason ?? 'history_missing'}).`);
|
|
72
|
+
const mismatch = (what) => new HarnessError('continuation_mismatch', `A continuation keeps the earlier run's ${what}.`);
|
|
73
|
+
if (continuation.capabilities?.tools.includes(ASK_USER)
|
|
74
|
+
&& (input.automatic || ['probe', 'improver', 'reflection'].includes(input.run.trigger ?? ''))) {
|
|
75
|
+
throw mismatch('attended question capability');
|
|
76
|
+
}
|
|
77
|
+
if (continuation.sessionId !== input.run.sessionId)
|
|
78
|
+
throw mismatch('session');
|
|
79
|
+
if (input.resume?.nativeSessionId && input.resume.nativeSessionId !== continuation.resume.nativeSessionId)
|
|
80
|
+
throw mismatch('history');
|
|
81
|
+
if (input.accountId && input.accountId !== continuation.accountId)
|
|
82
|
+
throw mismatch('account');
|
|
83
|
+
const pinned = continuation.variant;
|
|
84
|
+
const chosen = input.variant ?? null;
|
|
85
|
+
if (chosen && (!pinned || 'dir' in chosen || chosen.scope !== pinned.scope || (chosen.version && chosen.version !== pinned.version)))
|
|
86
|
+
throw mismatch('harness version');
|
|
87
|
+
input.resume = continuation.resume;
|
|
88
|
+
input.run.resumedFromRunId ??= continuation.runId;
|
|
89
|
+
input.accountId = continuation.accountId;
|
|
90
|
+
input.poolId = null;
|
|
91
|
+
if (pinned)
|
|
92
|
+
input.variant = { scope: pinned.scope, version: pinned.version };
|
|
93
|
+
if (!input.capabilities && continuation.capabilities)
|
|
94
|
+
input.capabilities = continuation.capabilities;
|
|
95
|
+
if (!input.text.trim())
|
|
96
|
+
input.text = CONTINUE_TEXT;
|
|
97
|
+
return continuation;
|
|
98
|
+
}
|
|
99
|
+
/** The harness's own plugins a person switched on for this caller, with the numbers they set. */
|
|
100
|
+
function firstPartyFor(root, contributions) {
|
|
101
|
+
const choices = attachments.load(root);
|
|
102
|
+
const allowed = new Set(contributions);
|
|
103
|
+
return firstPartyExtensions((id) => FIRST_PARTY_PLUGINS.find((plugin) => plugin.id === id)?.code?.some((code) => allowed.has(`${id}/code/${code.name}`)) ?? false, choices.settings);
|
|
104
|
+
}
|
|
105
|
+
export class Sessions {
|
|
106
|
+
options;
|
|
107
|
+
providers = [];
|
|
108
|
+
factory;
|
|
109
|
+
/** Pi sessions kept open between the runs of a conversation (ADR-0083). */
|
|
110
|
+
live;
|
|
111
|
+
/** The last live run's input per session, which a follow-up repeats with its own text. */
|
|
112
|
+
liveInputs = new Map();
|
|
113
|
+
constructor(options) {
|
|
114
|
+
this.options = options;
|
|
115
|
+
this.factory = options.factory ?? piSessionFactory;
|
|
116
|
+
this.live = new LiveSessions({
|
|
117
|
+
idleMs: options.liveIdleMs,
|
|
118
|
+
record: (runId) => {
|
|
119
|
+
try {
|
|
120
|
+
return loadRun(this.env.root, runId);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
followUp: async (sessionId, _lastRunId, text) => { await this.runFollowUp(sessionId, text); },
|
|
127
|
+
log: (message) => log(message)
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/** The live sessions open now. */
|
|
131
|
+
liveSessions() {
|
|
132
|
+
return this.live.list();
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Sends a message as the next run of a live session: now when it is idle, or after its active
|
|
136
|
+
* run settles. The run repeats the last live run's input with this text.
|
|
137
|
+
*/
|
|
138
|
+
async followUp(sessionId, text) {
|
|
139
|
+
if (typeof sessionId !== 'string' || !sessionId)
|
|
140
|
+
throw invalid('A follow-up needs a session id.');
|
|
141
|
+
if (typeof text !== 'string')
|
|
142
|
+
throw invalid('A follow-up needs text.');
|
|
143
|
+
const queued = this.live.queue(sessionId, text);
|
|
144
|
+
if ('queued' in queued)
|
|
145
|
+
return queued;
|
|
146
|
+
return { runId: await this.runFollowUp(sessionId, text) };
|
|
147
|
+
}
|
|
148
|
+
/** Closes a live session now, or as soon as its active run settles. */
|
|
149
|
+
closeLive(sessionId) {
|
|
150
|
+
const result = this.live.close(sessionId);
|
|
151
|
+
if (!result.afterRun)
|
|
152
|
+
this.liveInputs.delete(sessionId);
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
/** Closes every live session; the harness calls it when it shuts down. */
|
|
156
|
+
close() {
|
|
157
|
+
this.live.closeAll();
|
|
158
|
+
this.liveInputs.clear();
|
|
159
|
+
}
|
|
160
|
+
async runFollowUp(sessionId, text) {
|
|
161
|
+
const template = this.liveInputs.get(sessionId);
|
|
162
|
+
if (!template)
|
|
163
|
+
throw new HarnessError('not_found', 'This session has no live run to follow.');
|
|
164
|
+
const status = this.live.status(sessionId);
|
|
165
|
+
const next = {
|
|
166
|
+
...structuredClone(template),
|
|
167
|
+
run: { ...template.run, id: randomUUID(), resumedFromRunId: null },
|
|
168
|
+
text,
|
|
169
|
+
// The follow-up continues exactly the history the live session writes, once it has a file.
|
|
170
|
+
resume: status?.sessionFile ? { sessionFile: status.sessionFile, nativeSessionId: status.nativeSessionId } : template.resume ?? null,
|
|
171
|
+
live: true
|
|
172
|
+
};
|
|
173
|
+
next.initialBashCommand = undefined;
|
|
174
|
+
next.initialBashContext = undefined;
|
|
175
|
+
next.images = undefined;
|
|
176
|
+
next.command = undefined;
|
|
177
|
+
next.continueFrom = null;
|
|
178
|
+
next.goal = undefined;
|
|
179
|
+
next.workSlice = template.workSlice;
|
|
180
|
+
const { runId } = await this.run(next);
|
|
181
|
+
return runId;
|
|
182
|
+
}
|
|
183
|
+
get env() {
|
|
184
|
+
return this.options.env;
|
|
185
|
+
}
|
|
186
|
+
/** Adds tools an application provides. Providers are asked in the order they were added. */
|
|
187
|
+
provide(provider) {
|
|
188
|
+
this.providers.push(provider);
|
|
189
|
+
}
|
|
190
|
+
async diagnostics(context) {
|
|
191
|
+
const results = await Promise.allSettled(this.providers.map(provider => Promise.resolve().then(() => provider.diagnostics?.(context) ?? [])));
|
|
192
|
+
return results.flatMap((result, index) => result.status === 'fulfilled' ? result.value : [{
|
|
193
|
+
id: `provider.${index}`, category: 'tools', title: 'Provider diagnostics',
|
|
194
|
+
local: async () => ({ status: 'fail', evidence: 'This provider could not describe its readiness checks.', remedy: 'Review the provider configuration.' })
|
|
195
|
+
}]);
|
|
196
|
+
}
|
|
197
|
+
/** The same registered providers used by real runs; no native Pi session is constructed. */
|
|
198
|
+
async diagnosticTools(session) {
|
|
199
|
+
return (await Promise.all(this.providers.map(provider => provider(session)))).flat();
|
|
200
|
+
}
|
|
201
|
+
diagnosticGate(run, caller) {
|
|
202
|
+
return this.gate(run, caller, new Set(), true);
|
|
203
|
+
}
|
|
204
|
+
gate(run, caller, gated, diagnostic = false, automatic = false) {
|
|
205
|
+
const { policy } = this.options;
|
|
206
|
+
const gate = {
|
|
207
|
+
check: async (name, input) => (await gate.checkDetailed(name, input))?.reason ?? null,
|
|
208
|
+
ask: (names) => {
|
|
209
|
+
for (const name of names)
|
|
210
|
+
gated.add(name);
|
|
211
|
+
},
|
|
212
|
+
checkDetailed: async (tool, args) => {
|
|
213
|
+
let record;
|
|
214
|
+
let inspection;
|
|
215
|
+
try {
|
|
216
|
+
record = loadRun(this.env.root, run.runId);
|
|
217
|
+
inspection = inspectRunWorkspaceWrite(record, tool, args);
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
return { code: 'workspace', reason: error instanceof Error ? error.message : 'The active project workspace could not be verified.' };
|
|
221
|
+
}
|
|
222
|
+
const call = { run: record, caller, tool, args: inspection.input };
|
|
223
|
+
const hostScope = (await policy.scope?.(call)) ?? { allowed: true };
|
|
224
|
+
const scope = combineWorkspaceScope(hostScope, inspection);
|
|
225
|
+
if (!scope.allowed && (scope.automatic || (automatic && inspection.outside) || !scope.requiresApproval))
|
|
226
|
+
return { code: inspection.outside ? 'workspace' : 'scope', reason: scope.reason ?? 'Outside the approved work scope.' };
|
|
227
|
+
try {
|
|
228
|
+
await policy.authorize?.(call);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
return { code: 'policy', reason: error instanceof Error ? error.message : 'Tool unavailable in the app settings.' };
|
|
232
|
+
}
|
|
233
|
+
if (scope.allowed && !scope.humanOnly && (scope.automatic || !gated.has(tool)))
|
|
234
|
+
return null;
|
|
235
|
+
if (diagnostic)
|
|
236
|
+
return { code: 'unattended', reason: 'This diagnostic call requires a separate per-call approval.' };
|
|
237
|
+
// Refinement and reflection runs have nobody to ask: what would need a person is refused, never queued.
|
|
238
|
+
if (call.run.trigger === 'probe' || call.run.trigger === 'improver')
|
|
239
|
+
return { code: 'unattended', reason: scope.reason ? `Refused in a refinement run: ${scope.reason}` : 'Refused in a refinement run: this call needs a person to approve it.' };
|
|
240
|
+
if (call.run.trigger === 'reflection')
|
|
241
|
+
return { code: 'unattended', reason: scope.reason ? `Refused in a reflection run: ${scope.reason}` : 'Refused in a reflection run: this call needs a person to approve it.' };
|
|
242
|
+
if (automatic)
|
|
243
|
+
return { code: 'unattended', reason: scope.reason ?? 'Refused in an unattended run: this call needs a person to approve it.' };
|
|
244
|
+
const boundaryAction = inspection.outside ? `${inspection.reason} ${summarize(call.args, tool)}` : summarize(call.args);
|
|
245
|
+
const decision = await run.requestApproval({
|
|
246
|
+
target: tool,
|
|
247
|
+
action: boundaryAction,
|
|
248
|
+
operation: { tool, args: (call.args && typeof call.args === 'object' ? call.args : {}) },
|
|
249
|
+
rememberable: scope.allowed && !scope.humanOnly,
|
|
250
|
+
standing: scope.humanOnly ? (scope.allowGlobalApproval ? 'switch' : 'none') : undefined
|
|
251
|
+
});
|
|
252
|
+
if (decision !== 'approved')
|
|
253
|
+
return { code: 'approval_denied', reason: 'The user denied this action. Do not repeat it or ask for permission in a message; choose another approach or report what is blocked.' };
|
|
254
|
+
try {
|
|
255
|
+
await policy.authorize?.(call);
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
return { code: 'policy', reason: error instanceof Error ? error.message : 'Tool was disabled while waiting.' };
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
},
|
|
262
|
+
workspaceBoundaryBypass: async (tool, args) => {
|
|
263
|
+
if (diagnostic || automatic || tool.toLowerCase() !== 'bash')
|
|
264
|
+
return false;
|
|
265
|
+
const record = loadRun(this.env.root, run.runId);
|
|
266
|
+
if (record.trigger != null && record.trigger !== 'user')
|
|
267
|
+
return false;
|
|
268
|
+
if (!await this.options.fullPermission?.(record))
|
|
269
|
+
return false;
|
|
270
|
+
const call = { run: record, caller, tool, args };
|
|
271
|
+
const scope = (await policy.scope?.(call)) ?? { allowed: true };
|
|
272
|
+
if (scope.automatic || (!scope.allowed && !scope.requiresApproval) || (scope.humanOnly && !scope.allowGlobalApproval))
|
|
273
|
+
return false;
|
|
274
|
+
try {
|
|
275
|
+
await policy.authorize?.(call);
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
requestWorkspaceWriteScope: async (tool, args, reason) => {
|
|
283
|
+
if (diagnostic || automatic || tool.toLowerCase() !== 'bash')
|
|
284
|
+
return false;
|
|
285
|
+
const record = loadRun(this.env.root, run.runId);
|
|
286
|
+
if (!isActiveStatus(record.status) || (record.trigger != null && record.trigger !== 'user'))
|
|
287
|
+
return false;
|
|
288
|
+
const operationArgs = (args && typeof args === 'object' && !Array.isArray(args) ? args : {});
|
|
289
|
+
if (operationArgs.workspaceWriteScope !== 'outside' || typeof operationArgs.command !== 'string' || !operationArgs.command)
|
|
290
|
+
return false;
|
|
291
|
+
const call = { run: record, caller, tool, args: operationArgs };
|
|
292
|
+
const scope = (await policy.scope?.(call)) ?? { allowed: true };
|
|
293
|
+
if (scope.automatic || (!scope.allowed && !scope.requiresApproval))
|
|
294
|
+
return false;
|
|
295
|
+
try {
|
|
296
|
+
await policy.authorize?.(call);
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
const decision = await run.requestApproval({
|
|
302
|
+
target: 'workspace-write',
|
|
303
|
+
action: `${reason}\n\nCommand to be run once after approval:\n${formatBashCommandForApproval(operationArgs.command)}`,
|
|
304
|
+
operation: { tool, args: operationArgs },
|
|
305
|
+
rememberable: false,
|
|
306
|
+
standing: 'none'
|
|
307
|
+
});
|
|
308
|
+
if (decision !== 'approved')
|
|
309
|
+
return false;
|
|
310
|
+
const currentRecord = loadRun(this.env.root, run.runId);
|
|
311
|
+
if (!isActiveStatus(currentRecord.status) || (currentRecord.trigger != null && currentRecord.trigger !== 'user'))
|
|
312
|
+
return false;
|
|
313
|
+
const currentCall = { run: currentRecord, caller, tool, args: operationArgs };
|
|
314
|
+
const currentScope = (await policy.scope?.(currentCall)) ?? { allowed: true };
|
|
315
|
+
if (currentScope.automatic || (!currentScope.allowed && !currentScope.requiresApproval))
|
|
316
|
+
return false;
|
|
317
|
+
try {
|
|
318
|
+
await policy.authorize?.(currentCall);
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
return gate;
|
|
327
|
+
}
|
|
328
|
+
/** Compatibility alias for the shared native service. */
|
|
329
|
+
spawnSubagent(request) {
|
|
330
|
+
return this.options.subagents.spawn(request);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Starts one turn. Returns once the Pi session is open; the reply arrives as run events. A
|
|
334
|
+
* session that cannot be opened ends its run as failed and returns no native session id.
|
|
335
|
+
*/
|
|
336
|
+
async run(input) {
|
|
337
|
+
if (!input?.run?.id || !input.run.sessionId || typeof input.text !== 'string')
|
|
338
|
+
throw invalid('A session turn needs a run id, a session, and text.');
|
|
339
|
+
input = structuredClone(input);
|
|
340
|
+
const worktree = await this.enterWorktree(input);
|
|
341
|
+
try {
|
|
342
|
+
return await this.start(input);
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
await worktree?.release();
|
|
346
|
+
throw error;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* A run that names a worktree the harness manages works in that worktree's folder and holds it
|
|
351
|
+
* until the run settles. An id the harness does not know is kept as the caller's own field.
|
|
352
|
+
*/
|
|
353
|
+
async enterWorktree(input) {
|
|
354
|
+
const id = input.run.worktreeId;
|
|
355
|
+
const worktrees = this.options.worktrees;
|
|
356
|
+
if (!id || !worktrees)
|
|
357
|
+
return null;
|
|
358
|
+
const path = worktrees.pathOf(id);
|
|
359
|
+
if (!path)
|
|
360
|
+
return null;
|
|
361
|
+
const holder = input.run.sessionId;
|
|
362
|
+
await worktrees.acquire(id, holder);
|
|
363
|
+
input.cwd = path;
|
|
364
|
+
let released = false;
|
|
365
|
+
const release = async () => {
|
|
366
|
+
if (released)
|
|
367
|
+
return;
|
|
368
|
+
released = true;
|
|
369
|
+
stop();
|
|
370
|
+
await worktrees.release(id, holder).catch(() => undefined);
|
|
371
|
+
};
|
|
372
|
+
const stop = this.options.runs.listen((event) => {
|
|
373
|
+
if (event.runId !== input.run.id)
|
|
374
|
+
return;
|
|
375
|
+
const settled = event.type === 'completed' || event.type === 'failed' || (event.type === 'status.changed' && event.payload.status === 'interrupted');
|
|
376
|
+
if (settled)
|
|
377
|
+
void release();
|
|
378
|
+
});
|
|
379
|
+
return { release };
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Starts the next slice when a reply stopped at its work-slice boundary (PROP-0041). Never for
|
|
383
|
+
* unattended, plan, subagent, command or worktree runs, after a blocked or fruitless slice, or
|
|
384
|
+
* past the policy's slice cap. The earlier record is never reopened; this is a new run with the
|
|
385
|
+
* same pins, exactly as an application-asked continuation.
|
|
386
|
+
*/
|
|
387
|
+
async continueSlice(input) {
|
|
388
|
+
const { root, runId, source, policy } = input;
|
|
389
|
+
if (!policy.enabled || !policy.continue || policy.maxSlices <= 0)
|
|
390
|
+
return;
|
|
391
|
+
if (source.automatic || source.plan || source.command || source.run.relation || source.run.worktreeId)
|
|
392
|
+
return;
|
|
393
|
+
if ((source.depth ?? 0) > 0)
|
|
394
|
+
return;
|
|
395
|
+
const record = loadRun(root, runId);
|
|
396
|
+
if (record.terminalReason !== 'slice_complete')
|
|
397
|
+
return;
|
|
398
|
+
const events = readEvents(root, runId);
|
|
399
|
+
const checkpoint = checkpointOf(events);
|
|
400
|
+
if (checkpoint?.blocked)
|
|
401
|
+
return;
|
|
402
|
+
const progressed = events.some((event) => event.type === 'file.changed')
|
|
403
|
+
|| events.some((event) => {
|
|
404
|
+
const payload = event.payload;
|
|
405
|
+
return event.type === 'tool.completed' && payload.name === 'bash' && payload.ok === true;
|
|
406
|
+
})
|
|
407
|
+
|| (checkpoint?.done.length ?? 0) > 0;
|
|
408
|
+
if (!progressed)
|
|
409
|
+
return;
|
|
410
|
+
if (sliceOf(root, runId) >= policy.maxSlices)
|
|
411
|
+
return;
|
|
412
|
+
const next = {
|
|
413
|
+
...source,
|
|
414
|
+
run: { ...source.run, id: randomUUID(), resumedFromRunId: null, parentRunId: null, relation: null },
|
|
415
|
+
continueFrom: runId,
|
|
416
|
+
text: CONTINUE_TEXT
|
|
417
|
+
};
|
|
418
|
+
next.initialBashCommand = undefined;
|
|
419
|
+
next.initialBashContext = undefined;
|
|
420
|
+
next.images = undefined;
|
|
421
|
+
next.resume = null;
|
|
422
|
+
next.command = undefined;
|
|
423
|
+
await this.run(next).catch((error) => log(`the next work slice did not start: ${error instanceof Error ? error.message : String(error)}`));
|
|
424
|
+
}
|
|
425
|
+
async start(input) {
|
|
426
|
+
const { root } = this.env;
|
|
427
|
+
if (input.live) {
|
|
428
|
+
if (input.automatic || input.run.relation || (input.depth ?? 0) > 0 || (input.run.trigger != null && input.run.trigger !== 'user')) {
|
|
429
|
+
throw invalid('A live session is only for a person\'s own attended top-level runs.');
|
|
430
|
+
}
|
|
431
|
+
if (this.live.busy(input.run.sessionId))
|
|
432
|
+
throw new HarnessError('session_busy', 'This session is already replying. Steer it with runs.steer, or queue the message with sessions.followUp.');
|
|
433
|
+
}
|
|
434
|
+
// A run that opens its own session on this conversation's history reads and writes the file the
|
|
435
|
+
// live session holds in memory: the live session yields first (ADR-0083).
|
|
436
|
+
else if (input.run.relation == null && (input.depth ?? 0) === 0)
|
|
437
|
+
this.live.yieldHistory({ sessionId: input.run.sessionId, sessionDir: input.sessionDir });
|
|
438
|
+
// A new conversation never continues the open one.
|
|
439
|
+
if (input.live && input.newHistory)
|
|
440
|
+
this.live.yieldHistory({ sessionId: input.run.sessionId });
|
|
441
|
+
if ((input.initialBashCommand !== undefined && input.initialBashCommand !== null) || (input.initialBashContext !== undefined && input.initialBashContext !== null)) {
|
|
442
|
+
const request = input.text.trimStart();
|
|
443
|
+
const requestedCommand = /^!\s*([\s\S]+)$/u.exec(request)?.[1];
|
|
444
|
+
if (!requestedCommand?.trim())
|
|
445
|
+
throw invalid('An initial Bash command must match a non-empty leading ! command in the user text.');
|
|
446
|
+
if (input.initialBashCommand != null) {
|
|
447
|
+
const matchesRequest = requestedCommand === input.initialBashCommand || requestedCommand.startsWith(`${input.initialBashCommand}\n\nAttached saved file references:`);
|
|
448
|
+
if (!input.initialBashCommand.trim() || !matchesRequest)
|
|
449
|
+
throw invalid('An initial Bash command must match a non-empty leading ! command in the user text.');
|
|
450
|
+
}
|
|
451
|
+
if (input.initialBashContext != null && (input.initialBashCommand != null
|
|
452
|
+
|| typeof input.initialBashContext.runId !== 'string'
|
|
453
|
+
|| !input.initialBashContext.runId.trim()
|
|
454
|
+
|| input.initialBashContext.runId.length > 256
|
|
455
|
+
|| typeof input.initialBashContext.status !== 'string'
|
|
456
|
+
|| !['completed', 'incomplete', 'unknown'].includes(input.initialBashContext.status)
|
|
457
|
+
|| input.initialBashContext.output !== undefined && typeof input.initialBashContext.output !== 'string'
|
|
458
|
+
|| (input.initialBashContext.output?.length ?? 0) > 24_000
|
|
459
|
+
|| input.initialBashContext.ok !== undefined && typeof input.initialBashContext.ok !== 'boolean')) {
|
|
460
|
+
throw invalid('A prior Bash result must be bounded and must not be combined with a new initial Bash command.');
|
|
461
|
+
}
|
|
462
|
+
// A live session's turn is always a new turn on the saved history it resumes (ADR-0083); a
|
|
463
|
+
// host's retry of an earlier turn says so with initialBashContext instead.
|
|
464
|
+
if (input.automatic || input.plan || (input.resume && !input.live) || input.continueFrom || input.run.relation || input.run.trigger != null && input.run.trigger !== 'user') {
|
|
465
|
+
throw invalid('An initial Bash command is available only for a new interactive user turn.');
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
let slicePolicy;
|
|
469
|
+
try {
|
|
470
|
+
slicePolicy = parseWorkSlice(input.workSlice);
|
|
471
|
+
}
|
|
472
|
+
catch (error) {
|
|
473
|
+
if (error instanceof WorkSliceError)
|
|
474
|
+
throw invalid(error.message);
|
|
475
|
+
throw error;
|
|
476
|
+
}
|
|
477
|
+
const continuation = input.continueFrom ? continueInput(root, input) : null;
|
|
478
|
+
const previousRun = continuation ? loadRun(root, continuation.runId) : null;
|
|
479
|
+
const workspaceRoot = previousRun?.workspaceRoot
|
|
480
|
+
? verifyWorkspaceRoot(previousRun.workspaceRoot)
|
|
481
|
+
: resolveWorkspaceRoot(previousRun?.workingDirectory ?? input.cwd);
|
|
482
|
+
if (input.newHistory && (input.resume || input.continueFrom || input.command))
|
|
483
|
+
throw invalid('A new history cannot also resume, continue or run a command on a saved one.');
|
|
484
|
+
if (input.hiddenNotes !== undefined && (!Array.isArray(input.hiddenNotes) || input.hiddenNotes.length > 8 || input.hiddenNotes.some((note) => !note || typeof note.customType !== 'string' || !/^[a-z][a-z0-9-]{0,63}$/.test(note.customType) || typeof note.content !== 'string' || !note.content || note.content.length > 20_000))) {
|
|
485
|
+
throw invalid('Hidden notes are at most 8 messages, each with a lower-case type and up to 20,000 characters.');
|
|
486
|
+
}
|
|
487
|
+
const historyFile = input.newHistory ? null : selectHistory({ sessionDir: input.sessionDir, resume: input.resume });
|
|
488
|
+
if (input.command)
|
|
489
|
+
checkCommand(input.command, historyFile, input);
|
|
490
|
+
const account = this.options.accounts.resolve(input.accountId, input.poolId);
|
|
491
|
+
const context = this.options.accounts.context(account);
|
|
492
|
+
const runId = input.run.id;
|
|
493
|
+
const caller = { ...input.caller, runId, sessionId: input.caller.sessionId ?? input.run.sessionId };
|
|
494
|
+
const broker = input.connections ? this.options.broker : null;
|
|
495
|
+
const depth = input.depth ?? 0;
|
|
496
|
+
const canSpawn = input.subagents !== null && (!input.automatic || input.subagents !== undefined) && subagentNesting(root, input.run) < subagentDepth(input.subagents ?? undefined);
|
|
497
|
+
const pinnedAskUser = continuation?.capabilities?.tools.includes(ASK_USER) ?? false;
|
|
498
|
+
const interactivePlan = input.plan === true
|
|
499
|
+
&& !input.automatic
|
|
500
|
+
&& (input.run.trigger === undefined || input.run.trigger === null || input.run.trigger === 'user');
|
|
501
|
+
const harnessToolsEnabled = input.harnessTools !== false || pinnedAskUser;
|
|
502
|
+
// A goal (ADR-0072) belongs to a person's own top-level run, and to its continuations across slices.
|
|
503
|
+
const goalWanted = Boolean(input.goal) && harnessToolsEnabled && !input.plan && !input.command && !input.automatic && !input.run.relation && (input.depth ?? 0) === 0;
|
|
504
|
+
if (input.goal && !goalWanted)
|
|
505
|
+
throw invalid('A goal is available only for a person\'s own top-level run with the harness tools, not a plan, command, unattended or child run.');
|
|
506
|
+
const canAskUser = pinnedAskUser || (interactivePlan && harnessToolsEnabled);
|
|
507
|
+
const requestedTools = [...new Set([
|
|
508
|
+
...input.tools.allow.filter((name) => name !== SPAWN_SUBAGENT && name !== WAIT_SUBAGENTS && (name !== ASK_USER || canAskUser)),
|
|
509
|
+
...(harnessToolsEnabled ? [...(canAskUser ? [ASK_USER] : []), TODO_WRITE, SESSION_NAME, GET_CAPABILITIES, ...DEFAULT_TOOL_NAMES] : []),
|
|
510
|
+
...(goalWanted ? GOAL_TOOLS : []),
|
|
511
|
+
...(broker?.toolNames ?? []),
|
|
512
|
+
...(canSpawn ? [SPAWN_SUBAGENT, WAIT_SUBAGENTS] : [])
|
|
513
|
+
])];
|
|
514
|
+
const available = this.options.resolveCapabilities
|
|
515
|
+
? await this.options.resolveCapabilities(caller, requestedTools, input.cwd)
|
|
516
|
+
: { version: 1, tools: requestedTools, connectors: [], contributions: [] };
|
|
517
|
+
const requested = input.capabilities ? parseCapabilitySet(input.capabilities) : available;
|
|
518
|
+
const allowedTools = available.tools.filter((tool) => requested.tools.includes(tool));
|
|
519
|
+
const capabilities = {
|
|
520
|
+
version: 1,
|
|
521
|
+
tools: input.plan && input.planTools === 'active' ? planModeTools(allowedTools, [], [ASK_USER]) : allowedTools,
|
|
522
|
+
connectors: available.connectors.filter((id) => requested.connectors.includes(id)),
|
|
523
|
+
contributions: available.contributions.filter((id) => requested.contributions.includes(id))
|
|
524
|
+
};
|
|
525
|
+
freezeRun(root, runId, caller, capabilities);
|
|
526
|
+
// The harness is resolved once and pinned: a child run or a later turn of this run uses the
|
|
527
|
+
// same files even if the head moves meanwhile.
|
|
528
|
+
let variant = null;
|
|
529
|
+
if (input.variant) {
|
|
530
|
+
const scope = input.variant.scope ?? null;
|
|
531
|
+
const trust = this.options.trust ?? null;
|
|
532
|
+
variant = materialise(root, input.variant, { trust, probeCode: input.run.trigger === 'probe' && Boolean(scope && trust?.probeCode(scope)), subagents: capabilities.tools.includes(SPAWN_SUBAGENT) });
|
|
533
|
+
input.variant = { dir: variant.dir, scope: variant.scope };
|
|
534
|
+
}
|
|
535
|
+
saveRun(root, {
|
|
536
|
+
resumedFromRunId: input.run.resumedFromRunId ?? null,
|
|
537
|
+
parentRunId: input.run.parentRunId ?? null,
|
|
538
|
+
relation: input.run.relation ?? null,
|
|
539
|
+
terminalReason: null,
|
|
540
|
+
id: runId,
|
|
541
|
+
projectId: input.run.projectId ?? caller.projectId ?? null,
|
|
542
|
+
mode: input.run.mode ?? 'chat',
|
|
543
|
+
effectiveMode: input.plan ? 'plan' : 'normal',
|
|
544
|
+
harness: input.run.harness ?? 'pi',
|
|
545
|
+
sessionType: input.run.sessionType ?? 'structured',
|
|
546
|
+
sessionId: input.run.sessionId,
|
|
547
|
+
nativeSessionId: null,
|
|
548
|
+
workingDirectory: input.cwd,
|
|
549
|
+
workspaceRoot,
|
|
550
|
+
worktreeId: input.run.worktreeId ?? null,
|
|
551
|
+
goal: input.run.goal ?? takeChars(input.goal?.objective ?? input.text, 4000),
|
|
552
|
+
attachmentCount: input.run.attachmentCount ?? 0,
|
|
553
|
+
startedAt: now(),
|
|
554
|
+
endedAt: null,
|
|
555
|
+
status: 'queued',
|
|
556
|
+
loadedSkills: [],
|
|
557
|
+
exitCode: null,
|
|
558
|
+
handoffId: input.run.handoffId ?? null,
|
|
559
|
+
accountId: account.id,
|
|
560
|
+
agentId: input.run.agentId ?? caller.agentId ?? null,
|
|
561
|
+
trigger: input.run.trigger ?? null,
|
|
562
|
+
variantScope: variant?.scope ?? null,
|
|
563
|
+
variantVersion: variant?.fingerprint ?? null,
|
|
564
|
+
...(input.run.profile ? { profile: input.run.profile } : {}),
|
|
565
|
+
...(input.run.title ? { title: input.run.title } : {}),
|
|
566
|
+
...(input.model ? { model: input.model } : {}),
|
|
567
|
+
...(input.effort ? { effort: input.effort } : {})
|
|
568
|
+
});
|
|
569
|
+
// What the session is, kept with the run so later consolidation knows which memory it had.
|
|
570
|
+
try {
|
|
571
|
+
writeJson(join(runDir(root, runId), 'caller.json'), caller);
|
|
572
|
+
}
|
|
573
|
+
catch {
|
|
574
|
+
// Consolidation falls back to what the run record says.
|
|
575
|
+
}
|
|
576
|
+
const fail = (error, code = 'provider_unavailable') => {
|
|
577
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
578
|
+
updateRun(root, runId, (record) => Object.assign(record, { status: 'failed', endedAt: now(), terminalReason: message, terminalCode: stopCodeOf(code) }));
|
|
579
|
+
log(`session ${runId} did not start: ${message}`, code);
|
|
580
|
+
};
|
|
581
|
+
// Plugins are resolved once per run: for the profiles the prompt lists, then for what Pi loads.
|
|
582
|
+
const { plugins } = this.options;
|
|
583
|
+
let pluginLoading = null;
|
|
584
|
+
const loadPlugins = plugins
|
|
585
|
+
? () => (pluginLoading ??= plugins.loading({ cwd: input.cwd, agentDir: context.configDir, install: true, caller: { agentId: caller.agentId ?? null, projectId: caller.projectId ?? null }, contributions: capabilities.contributions }))
|
|
586
|
+
: null;
|
|
587
|
+
// A person's main session sees its current name and whether this run's todo is empty. A
|
|
588
|
+
// command, child, side question or unattended run has no such state to show.
|
|
589
|
+
const stateEligible = !input.command
|
|
590
|
+
&& !input.run.relation
|
|
591
|
+
&& (input.depth ?? 0) === 0
|
|
592
|
+
&& !input.automatic
|
|
593
|
+
&& (input.run.trigger == null || input.run.trigger === 'user');
|
|
594
|
+
// The working tree as the person's turn found it, so refinement can replay the request later.
|
|
595
|
+
if (stateEligible) {
|
|
596
|
+
const snapshot = await snapshotWorkingTree(input.cwd);
|
|
597
|
+
if (snapshot)
|
|
598
|
+
updateRun(root, runId, (record) => { record.workspaceSnapshot = snapshot; });
|
|
599
|
+
}
|
|
600
|
+
const existingName = stateEligible ? latestSessionName(historyFile) : null;
|
|
601
|
+
const sessionState = stateEligible
|
|
602
|
+
? {
|
|
603
|
+
name: existingName,
|
|
604
|
+
todo: [],
|
|
605
|
+
...(continuation?.todo.length ? { previousTodo: continuation.todo } : {}),
|
|
606
|
+
firstTurn: !historyFile
|
|
607
|
+
}
|
|
608
|
+
: undefined;
|
|
609
|
+
let system;
|
|
610
|
+
let update;
|
|
611
|
+
try {
|
|
612
|
+
if (!existsSync(input.sessionDir))
|
|
613
|
+
mkdirSync(input.sessionDir, { recursive: true });
|
|
614
|
+
const launch = input.launch ?? {};
|
|
615
|
+
const plan = planSection(input.plan === true, historyFile, input.run.relation === 'subagent');
|
|
616
|
+
const delivered = historyFile ? deliveredSnapshot(historyFile) : null;
|
|
617
|
+
const resumed = continuationSection(continuation, delivered?.some((entry) => entry.id === CONTINUATION_SECTION_ID) ?? false);
|
|
618
|
+
// The profiles replace the variant's own subagent list, which they include.
|
|
619
|
+
const researchContext = input.plan === true ? {
|
|
620
|
+
frozenTools: capabilities.tools,
|
|
621
|
+
contributions: capabilities.contributions,
|
|
622
|
+
descriptors: BUILTIN_PLUGIN_REGISTRY.descriptors()
|
|
623
|
+
} : undefined;
|
|
624
|
+
if (capabilities.tools.includes(SPAWN_SUBAGENT) && loadPlugins && !input.automatic)
|
|
625
|
+
input.packageProfiles = (await loadPlugins()).profilePaths;
|
|
626
|
+
const profiles = capabilities.tools.includes(SPAWN_SUBAGENT)
|
|
627
|
+
? profileSection(root, input.cwd, variant?.dir ?? null, input.plan === true, researchContext, input.packageProfiles ?? [])
|
|
628
|
+
: null;
|
|
629
|
+
if (profiles && variant)
|
|
630
|
+
variant = { ...variant, sections: variant.sections.filter((section) => section.id !== profiles.id) };
|
|
631
|
+
const own = [plan, resumed, profiles].filter((section) => section !== null);
|
|
632
|
+
const effectiveLaunch = {
|
|
633
|
+
...launch,
|
|
634
|
+
model: input.model ?? launch.model ?? null,
|
|
635
|
+
...(sessionState ? { sessionState } : {}),
|
|
636
|
+
sections: own.length ? [...(launch.sections ?? []).filter((section) => !own.some((entry) => entry.id === section.id)), ...own] : launch.sections,
|
|
637
|
+
tools: capabilities.tools,
|
|
638
|
+
connectionTools: (launch.connectionTools ?? []).filter((name) => capabilities.tools.includes(name)),
|
|
639
|
+
toolGroups: launch.toolGroups?.map((group) => ({ ...group, tools: group.tools.filter((name) => capabilities.tools.includes(name)) })).filter((group) => group.tools.length > 0)
|
|
640
|
+
};
|
|
641
|
+
({ system, update } = sessionLaunch(this.env, caller, effectiveLaunch, historyFile, variant));
|
|
642
|
+
}
|
|
643
|
+
catch (error) {
|
|
644
|
+
fail(error);
|
|
645
|
+
throw error;
|
|
646
|
+
}
|
|
647
|
+
// A top-level run with the harness's own tools is bounded; plan-research children are bounded too,
|
|
648
|
+
// though their read-only capability set omits those tools.
|
|
649
|
+
const harnessStateTools = harnessToolsEnabled && depth === 0 && capabilities.tools.includes(TODO_WRITE);
|
|
650
|
+
const planResearchChild = input.plan === true && input.run.relation === 'subagent';
|
|
651
|
+
const sliceEnabled = slicePolicy.enabled && (harnessStateTools || planResearchChild);
|
|
652
|
+
const sliceState = createSliceState(slicePolicy, sliceOf(root, runId));
|
|
653
|
+
// The stop gate stays gone (ADR-0075): a reply the model ends settles as it ends, and the todo
|
|
654
|
+
// list is progress, not a gate. The goal loop below is the only layer that continues a reply.
|
|
655
|
+
// The completion check judges the goal's claim, not "Continue from where you stopped."
|
|
656
|
+
// The goal: a continuation slice picks up the previous run's goal where it stopped.
|
|
657
|
+
let goalController = null;
|
|
658
|
+
if (goalWanted && input.goal) {
|
|
659
|
+
goalController = new GoalController({ onChange: (state) => updateRun(root, runId, (record) => { record.goalMode = state; }) });
|
|
660
|
+
const inherited = previousRun?.goalMode;
|
|
661
|
+
try {
|
|
662
|
+
if (inherited && inherited.status === 'active') {
|
|
663
|
+
goalController.restore(inherited);
|
|
664
|
+
updateRun(root, runId, (record) => { record.goalMode = inherited; });
|
|
665
|
+
}
|
|
666
|
+
else
|
|
667
|
+
goalController.set(input.goal.objective, { rounds: input.goal.rounds, hours: input.goal.hours });
|
|
668
|
+
}
|
|
669
|
+
catch (error) {
|
|
670
|
+
if (error instanceof GoalError)
|
|
671
|
+
throw invalid(error.message);
|
|
672
|
+
throw error;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
const goalState = goalController?.get() ?? null;
|
|
676
|
+
// The goal's first message: who set it, then the continuation prompt, as Codex starts a goal.
|
|
677
|
+
const goalStart = goalState ? `${provenanceText('set', goalState)}\n\n${continuationPrompt(goalState)}` : null;
|
|
678
|
+
const run = this.options.runs.start(input.run.sessionId, runId);
|
|
679
|
+
if (run.finished)
|
|
680
|
+
return { runId, nativeSessionId: null };
|
|
681
|
+
if (variant?.untrustedPlugins.length) {
|
|
682
|
+
run.emit('extension.notice', { kind: 'notify', level: 'warning', text: `Harness plugins not loaded until their code is trusted: ${variant.untrustedPlugins.join(', ')}.` });
|
|
683
|
+
}
|
|
684
|
+
// What every session has, after the tools the caller switched on and in a fixed order.
|
|
685
|
+
const allow = capabilities.tools;
|
|
686
|
+
const session = { run, caller, allow, depth, cwd: input.cwd, capabilities };
|
|
687
|
+
let pi;
|
|
688
|
+
const naming = sessionNameTool(() => {
|
|
689
|
+
const current = pi;
|
|
690
|
+
if (!current?.setSessionName)
|
|
691
|
+
return undefined;
|
|
692
|
+
return {
|
|
693
|
+
get sessionName() { return current.sessionName; },
|
|
694
|
+
setSessionName: name => current.setSessionName(name)
|
|
695
|
+
};
|
|
696
|
+
});
|
|
697
|
+
try {
|
|
698
|
+
const tools = [
|
|
699
|
+
...(harnessToolsEnabled && allow.includes(GET_CAPABILITIES) ? [getCapabilitiesTool(() => ({
|
|
700
|
+
capabilities,
|
|
701
|
+
active: pi?.getActiveToolNames?.() ?? [],
|
|
702
|
+
registered: pi?.getAllTools?.() ?? []
|
|
703
|
+
}))] : []),
|
|
704
|
+
...BUILTIN_PLUGIN_REGISTRY.tools({
|
|
705
|
+
env: this.options.env,
|
|
706
|
+
caller,
|
|
707
|
+
variantDir: variant?.dir ?? null,
|
|
708
|
+
run,
|
|
709
|
+
runId,
|
|
710
|
+
allowedTools: allow,
|
|
711
|
+
harnessTools: harnessToolsEnabled,
|
|
712
|
+
subagents: this.options.subagents,
|
|
713
|
+
sessionName: naming,
|
|
714
|
+
...(broker ? { connectionTools: () => broker.tools(session, { readOnly: typeof input.connections === 'object' && input.connections.readOnly === true }) } : {})
|
|
715
|
+
}),
|
|
716
|
+
...(goalController && allow.includes(GOAL_TOOLS[0]) ? goalTools(() => goalController) : [])
|
|
717
|
+
];
|
|
718
|
+
if (input.providers !== false) {
|
|
719
|
+
const named = new Set(tools.map((tool) => tool.name));
|
|
720
|
+
for (const provider of this.providers) {
|
|
721
|
+
for (const tool of await provider(session)) {
|
|
722
|
+
// The first tool of a name wins: the harness's own world tools are asked first.
|
|
723
|
+
if (named.has(tool.name))
|
|
724
|
+
continue;
|
|
725
|
+
named.add(tool.name);
|
|
726
|
+
tools.push(tool);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
const readOnly = new Set(tools.filter((tool) => tool.readOnly).map((tool) => tool.name));
|
|
731
|
+
const checkpointPlanInstructions = input.plan
|
|
732
|
+
? () => input.run.relation === 'subagent' ? PLAN_RESEARCH_SUBAGENT_INSTRUCTIONS : PLAN_INSTRUCTIONS
|
|
733
|
+
: undefined;
|
|
734
|
+
const planModeSafety = new Map();
|
|
735
|
+
for (const tool of tools)
|
|
736
|
+
if (tool.planModeSafe)
|
|
737
|
+
planModeSafety.set(tool.name, tool.planModeSafe);
|
|
738
|
+
const gate = (() => {
|
|
739
|
+
const baseGate = this.gate(run, caller, new Set((input.tools.gated ?? []).filter((name) => capabilities.tools.includes(name))), false, input.automatic === true);
|
|
740
|
+
const checkDetailed = (name, args) => {
|
|
741
|
+
if (input.run.relation === 'subagent' && !capabilities.tools.includes(name))
|
|
742
|
+
return Promise.resolve({ code: 'capability', reason: 'This tool is outside the child capability snapshot.' });
|
|
743
|
+
const refusal = input.plan ? planRefusal(name, readOnly, args, planModeSafety.get(name)) : null;
|
|
744
|
+
return refusal ? Promise.resolve({ code: 'plan_mode', reason: refusal }) : baseGate.checkDetailed(name, args);
|
|
745
|
+
};
|
|
746
|
+
return { ...baseGate, checkDetailed, check: async (name, args) => (await checkDetailed(name, args))?.reason ?? null };
|
|
747
|
+
})();
|
|
748
|
+
const goalHandle = goalController ? { controller: goalController } : undefined;
|
|
749
|
+
const goalParams = { goal: goalHandle };
|
|
750
|
+
const params = {
|
|
751
|
+
runId,
|
|
752
|
+
...(input.initialBashCommand !== undefined && input.initialBashCommand !== null ? { initialBashCommand: input.initialBashCommand, initialBashAvailable: capabilities.tools.includes('bash') } : {}),
|
|
753
|
+
...(input.initialBashContext !== undefined && input.initialBashContext !== null ? { initialBashContext: input.initialBashContext } : {}),
|
|
754
|
+
gate,
|
|
755
|
+
onRefusal: (toolCallId, name, refusal) => run.emit('tool.refused', { toolCallId, name, ...refusal, reason: refusal.reason.slice(0, 2000) }),
|
|
756
|
+
restrictTools: input.run.relation === 'subagent',
|
|
757
|
+
...(input.plan ? { plan: true } : {}),
|
|
758
|
+
...(stateEligible && input.plan ? { repairPlan: true } : {}),
|
|
759
|
+
cwd: input.cwd,
|
|
760
|
+
workspaceRoot,
|
|
761
|
+
sessionDir: input.sessionDir,
|
|
762
|
+
historyFile,
|
|
763
|
+
...(input.newHistory ? { newHistory: true } : {}),
|
|
764
|
+
model: input.model ?? null,
|
|
765
|
+
effort: input.effort ?? null,
|
|
766
|
+
text: goalStart ?? input.text,
|
|
767
|
+
images: input.images,
|
|
768
|
+
requiresImageInput: input.requiresImageInput,
|
|
769
|
+
preamble: input.preamble ?? null,
|
|
770
|
+
automatic: input.automatic,
|
|
771
|
+
account: context,
|
|
772
|
+
resources: { ids: [], skillPaths: [...(variant?.skillPaths ?? []), ...defaultSkillPaths(variant?.dir)], promptPaths: [] },
|
|
773
|
+
variantExtensions: variant?.extensionPaths ?? [],
|
|
774
|
+
inline: [
|
|
775
|
+
...firstPartyFor(root, capabilities.contributions),
|
|
776
|
+
runLineageJoin(root, runId),
|
|
777
|
+
this.options.subagents.extension(runId),
|
|
778
|
+
{ name: 'image-pruning', factory: imagePruning() },
|
|
779
|
+
{ name: COMPACTION_CHECKPOINT_EXTENSION, factory: compactionCheckpoint({ initialTodo: continuation?.todo, planInstructions: checkpointPlanInstructions }) },
|
|
780
|
+
...(sliceEnabled ? [{ name: WORK_SLICE_EXTENSION, factory: workSliceGuard({ policy: slicePolicy, state: sliceState, onRefuse: (event, reason) => { if (typeof event.toolCallId === 'string')
|
|
781
|
+
run.emit('tool.refused', { toolCallId: event.toolCallId, name: event.toolName, code: 'work_slice', reason: reason.slice(0, 2000) }); } }) }] : []),
|
|
782
|
+
// A goal continues a reply the model ended (ADR-0072).
|
|
783
|
+
...(goalController ? [{ name: GOAL_EXTENSION, factory: goalLoop({
|
|
784
|
+
controller: goalController,
|
|
785
|
+
check: launchSwitchOff('XINGULAR_COMPLETION_CHECK') ? null : sessionCheckModel,
|
|
786
|
+
sliceEnded: () => sliceEnabled && sliceState.endedBy !== null,
|
|
787
|
+
recordUsage: (message) => goalParams.goal?.recordUsage?.(message),
|
|
788
|
+
onEvent: (event) => run.emit('extension.notice', { kind: 'notify', level: 'info', extension: GOAL_EXTENSION, text: goalNotice(event) })
|
|
789
|
+
}) }] : [])
|
|
790
|
+
],
|
|
791
|
+
...(plugins && loadPlugins ? { plugins: { loading: loadPlugins, loaded: (extensions) => plugins.loaded(extensions) } } : {}),
|
|
792
|
+
activatedPlugins: (ids) => updateRun(root, runId, (record) => { record.activatedPlugins = ids; }),
|
|
793
|
+
system,
|
|
794
|
+
...(sliceEnabled ? { slice: { state: sliceState, maxToolCalls: slicePolicy.maxToolCalls } } : {}),
|
|
795
|
+
...(goalController ? { goal: goalHandle } : {}),
|
|
796
|
+
// A command sends no request of its own, so the context update waits for the next turn.
|
|
797
|
+
update: input.command ? null : update,
|
|
798
|
+
...(input.hiddenNotes?.length && !input.command ? { hiddenNotes: input.hiddenNotes } : {}),
|
|
799
|
+
...(input.command ? { command: input.command } : {})
|
|
800
|
+
};
|
|
801
|
+
const factoryInput = {
|
|
802
|
+
params,
|
|
803
|
+
allow,
|
|
804
|
+
gate,
|
|
805
|
+
tools,
|
|
806
|
+
runtime: () => this.options.accounts.runtime(context),
|
|
807
|
+
// An unattended run loads no extension, so it has nobody to relay for.
|
|
808
|
+
...(input.automatic ? {} : { extensions: { ask: (question) => run.requestAnswer(question), notice: (notice) => run.emit('extension.notice', notice) } })
|
|
809
|
+
};
|
|
810
|
+
// A live session serves this run only when everything the run pins is what it was opened with.
|
|
811
|
+
const liveId = input.live ? input.run.sessionId : null;
|
|
812
|
+
const pin = liveId ? livePin({
|
|
813
|
+
account: account.id,
|
|
814
|
+
configDir: context.configDir,
|
|
815
|
+
variantScope: variant?.scope ?? null,
|
|
816
|
+
variantVersion: variant?.fingerprint ?? null,
|
|
817
|
+
variantExtensions: params.variantExtensions,
|
|
818
|
+
resources: params.resources,
|
|
819
|
+
capabilities,
|
|
820
|
+
cwd: input.cwd,
|
|
821
|
+
workspaceRoot,
|
|
822
|
+
sessionDir: input.sessionDir,
|
|
823
|
+
plan: Boolean(input.plan),
|
|
824
|
+
repairPlan: Boolean(params.repairPlan),
|
|
825
|
+
allow,
|
|
826
|
+
tools: tools.map((tool) => tool.name),
|
|
827
|
+
gated: input.tools.gated ?? [],
|
|
828
|
+
system,
|
|
829
|
+
model: input.model ?? null,
|
|
830
|
+
effort: input.effort ?? null,
|
|
831
|
+
inline: (params.inline ?? []).map((extension) => extension.name),
|
|
832
|
+
providers: input.providers !== false
|
|
833
|
+
}) : null;
|
|
834
|
+
const reused = liveId && pin ? this.live.claim(liveId, pin, runId, historyFile, input.resume?.nativeSessionId) : null;
|
|
835
|
+
if (reused) {
|
|
836
|
+
pi = reused;
|
|
837
|
+
try {
|
|
838
|
+
await reused.rebind(factoryInput);
|
|
839
|
+
}
|
|
840
|
+
catch (error) {
|
|
841
|
+
this.live.discard(liveId, reused);
|
|
842
|
+
throw error;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
else {
|
|
846
|
+
pi = await this.factory(factoryInput);
|
|
847
|
+
if (liveId && pin && pi.rebind)
|
|
848
|
+
this.live.hold(liveId, pin, pi, runId, input.sessionDir);
|
|
849
|
+
}
|
|
850
|
+
const held = liveId && this.live.status(liveId)?.activeRunId === runId ? liveId : null;
|
|
851
|
+
const opened0 = pi;
|
|
852
|
+
const discard = () => {
|
|
853
|
+
if (held)
|
|
854
|
+
this.live.discard(held, opened0);
|
|
855
|
+
else
|
|
856
|
+
opened0.dispose();
|
|
857
|
+
};
|
|
858
|
+
if (run.finished) {
|
|
859
|
+
discard();
|
|
860
|
+
return { runId, nativeSessionId: null };
|
|
861
|
+
}
|
|
862
|
+
if ((input.requiresImageInput || input.images?.length) && !pi.model?.input.includes('image')) {
|
|
863
|
+
discard();
|
|
864
|
+
pi = undefined;
|
|
865
|
+
throw new HarnessError('image_input_unsupported', 'Choose a model that supports images, or remove the image attachments and send again.');
|
|
866
|
+
}
|
|
867
|
+
if (input.resume?.nativeSessionId && pi.sessionId !== input.resume.nativeSessionId) {
|
|
868
|
+
discard();
|
|
869
|
+
pi = undefined;
|
|
870
|
+
run.finish('failed', { code: 'native_resume_unavailable', message: 'The saved conversation could not be restored.' });
|
|
871
|
+
throw new HarnessError('native_resume_unavailable', 'The saved conversation could not be restored.');
|
|
872
|
+
}
|
|
873
|
+
// The fallback is a name, not a task step: a refused or failed name never fails the run.
|
|
874
|
+
if (stateEligible && input.autoName !== false && !existingName && !pi.sessionName
|
|
875
|
+
&& pi.setSessionName && capabilities.tools.includes(SESSION_NAME)) {
|
|
876
|
+
const name = deriveSessionName(input.text);
|
|
877
|
+
if (name) {
|
|
878
|
+
try {
|
|
879
|
+
if (await gate.check(SESSION_NAME, { name }) === null)
|
|
880
|
+
pi.setSessionName(name);
|
|
881
|
+
}
|
|
882
|
+
catch {
|
|
883
|
+
// Session naming is metadata; leave the session unnamed.
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
const opened = pi;
|
|
888
|
+
const openedModel = pi.model?.id && pi.model.provider ? `${pi.model.provider}/${pi.model.id}` : null;
|
|
889
|
+
updateRun(root, runId, (record) => {
|
|
890
|
+
record.nativeSessionId = opened.sessionId;
|
|
891
|
+
if (openedModel)
|
|
892
|
+
record.model = openedModel;
|
|
893
|
+
if (opened.thinkingLevel)
|
|
894
|
+
record.effort = opened.thinkingLevel;
|
|
895
|
+
});
|
|
896
|
+
this.options.subagents.register(input, account.id, capabilities, Boolean(pi.sessionManager));
|
|
897
|
+
if (openedModel)
|
|
898
|
+
this.options.subagents.resolvedModel(runId, openedModel, pi.thinkingLevel);
|
|
899
|
+
params.settle = () => this.options.subagents.verify(runId, opened.sessionManager ? subagentHistory(opened.sessionManager.getBranch()) : undefined);
|
|
900
|
+
if (held) {
|
|
901
|
+
this.live.started(held, runId);
|
|
902
|
+
this.liveInputs.set(held, structuredClone(input));
|
|
903
|
+
params.release = (close) => this.live.release(held, runId, close);
|
|
904
|
+
}
|
|
905
|
+
void runTurn(run, pi, params).then(() => (sliceEnabled && !input.command ? this.continueSlice({ root, runId, source: input, policy: slicePolicy }) : undefined));
|
|
906
|
+
return { runId, nativeSessionId: pi.sessionId };
|
|
907
|
+
}
|
|
908
|
+
catch (error) {
|
|
909
|
+
if (pi) {
|
|
910
|
+
if (input.live && this.live.status(input.run.sessionId)?.activeRunId === runId)
|
|
911
|
+
this.live.discard(input.run.sessionId, pi);
|
|
912
|
+
else
|
|
913
|
+
pi.dispose();
|
|
914
|
+
}
|
|
915
|
+
if (error instanceof HarnessError && error.code === 'native_resume_unavailable')
|
|
916
|
+
throw error;
|
|
917
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
918
|
+
log('session failed to start', message);
|
|
919
|
+
run.finish('failed', { code: error instanceof HarnessError ? error.code : 'provider_unavailable', message });
|
|
920
|
+
return { runId, nativeSessionId: null };
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
}
|