@xingular/harness 0.1.7 → 1.0.0
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 +97 -1
- package/LICENSE +202 -0
- package/NOTICE.md +22 -0
- package/README.md +187 -85
- package/THIRD_PARTY_LICENSES.md +942 -0
- package/dist/cli.js +13701 -13498
- package/dist/sdk/accounts/accounts.d.ts +165 -0
- package/dist/sdk/accounts/accounts.js +730 -0
- package/dist/sdk/accounts/choices.d.ts +23 -0
- package/dist/sdk/accounts/choices.js +62 -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 +16 -0
- package/dist/sdk/accounts/secrets.js +40 -0
- package/dist/sdk/accounts/store.d.ts +114 -0
- package/dist/sdk/accounts/store.js +255 -0
- package/dist/sdk/browser/config.d.ts +16 -0
- package/dist/sdk/browser/config.js +22 -0
- package/dist/sdk/browser/diagnostics.d.ts +4 -0
- package/dist/sdk/browser/diagnostics.js +38 -0
- package/dist/sdk/browser/index.d.ts +17 -0
- package/dist/sdk/browser/index.js +65 -0
- package/dist/sdk/browser/network.d.ts +10 -0
- package/dist/sdk/browser/network.js +59 -0
- package/dist/sdk/browser/session.d.ts +84 -0
- package/dist/sdk/browser/session.js +192 -0
- package/dist/sdk/browser/tools.d.ts +8 -0
- package/dist/sdk/browser/tools.js +329 -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 +47 -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 +142 -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/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 +187 -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/text.d.ts +7 -0
- package/dist/sdk/core/text.js +40 -0
- package/dist/sdk/doctor/checks.d.ts +5 -0
- package/dist/sdk/doctor/checks.js +208 -0
- package/dist/sdk/doctor/probe.d.ts +4 -0
- package/dist/sdk/doctor/probe.js +92 -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 +133 -0
- package/dist/sdk/harness.js +299 -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/trajectory.d.ts +7 -0
- package/dist/sdk/history/trajectory.js +216 -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 +474 -0
- package/dist/sdk/hub/schema.d.ts +280 -0
- package/dist/sdk/hub/schema.js +78 -0
- package/dist/sdk/index.d.ts +63 -0
- package/dist/sdk/index.js +48 -0
- package/dist/sdk/mcp/connections.d.ts +83 -0
- package/dist/sdk/mcp/connections.js +669 -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/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/runtime.d.ts +13 -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 +6 -0
- package/dist/sdk/plugins/builtin.js +68 -0
- package/dist/sdk/plugins/catalogue.d.ts +29 -0
- package/dist/sdk/plugins/catalogue.js +196 -0
- package/dist/sdk/plugins/cli.d.ts +13 -0
- package/dist/sdk/plugins/cli.js +187 -0
- package/dist/sdk/plugins/discover.d.ts +42 -0
- package/dist/sdk/plugins/discover.js +115 -0
- package/dist/sdk/plugins/firstParty.d.ts +50 -0
- package/dist/sdk/plugins/firstParty.js +113 -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 +20 -0
- package/dist/sdk/plugins/install.js +110 -0
- package/dist/sdk/plugins/inventory.d.ts +22 -0
- package/dist/sdk/plugins/inventory.js +110 -0
- package/dist/sdk/plugins/manifest.d.ts +13 -0
- package/dist/sdk/plugins/manifest.js +56 -0
- package/dist/sdk/plugins/plugins.d.ts +104 -0
- package/dist/sdk/plugins/plugins.js +164 -0
- package/dist/sdk/plugins/runtime.d.ts +9 -0
- package/dist/sdk/plugins/runtime.js +95 -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 +159 -0
- package/dist/sdk/plugins/types.js +7 -0
- package/dist/sdk/prompt/compile.d.ts +174 -0
- package/dist/sdk/prompt/compile.js +396 -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 +51 -0
- package/dist/sdk/refine/host.js +76 -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 +45 -0
- package/dist/sdk/refine/prompts.js +390 -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 +81 -0
- package/dist/sdk/refine/runner.js +150 -0
- package/dist/sdk/refine/selection.d.ts +57 -0
- package/dist/sdk/refine/selection.js +251 -0
- package/dist/sdk/refine/service.d.ts +84 -0
- package/dist/sdk/refine/service.js +165 -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 +68 -0
- package/dist/sdk/refine/types.d.ts +77 -0
- package/dist/sdk/refine/types.js +10 -0
- package/dist/sdk/server/methods.d.ts +3 -0
- package/dist/sdk/server/methods.js +370 -0
- package/dist/sdk/server/remote.d.ts +19 -0
- package/dist/sdk/server/remote.js +84 -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 +10 -0
- package/dist/sdk/server/serve.js +18 -0
- package/dist/sdk/sessions/approvals.d.ts +47 -0
- package/dist/sdk/sessions/approvals.js +119 -0
- package/dist/sdk/sessions/continuation.d.ts +48 -0
- package/dist/sdk/sessions/continuation.js +85 -0
- package/dist/sdk/sessions/contracts.d.ts +534 -0
- package/dist/sdk/sessions/contracts.js +299 -0
- package/dist/sdk/sessions/extensionUi.d.ts +19 -0
- package/dist/sdk/sessions/extensionUi.js +64 -0
- package/dist/sdk/sessions/history.d.ts +16 -0
- package/dist/sdk/sessions/history.js +68 -0
- package/dist/sdk/sessions/lineageJoin.d.ts +2 -0
- package/dist/sdk/sessions/lineageJoin.js +61 -0
- package/dist/sdk/sessions/planMode.d.ts +36 -0
- package/dist/sdk/sessions/planMode.js +84 -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 +102 -0
- package/dist/sdk/sessions/registry.js +383 -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 +66 -0
- package/dist/sdk/sessions/runStore.js +335 -0
- package/dist/sdk/sessions/runner.d.ts +213 -0
- package/dist/sdk/sessions/runner.js +589 -0
- package/dist/sdk/sessions/sessions.d.ts +140 -0
- package/dist/sdk/sessions/sessions.js +394 -0
- package/dist/sdk/sessions/subagentService.d.ts +41 -0
- package/dist/sdk/sessions/subagentService.js +247 -0
- package/dist/sdk/sessions/subagents.d.ts +50 -0
- package/dist/sdk/sessions/subagents.js +68 -0
- package/dist/sdk/terminal/accountsMenu.d.ts +46 -0
- package/dist/sdk/terminal/accountsMenu.js +392 -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 +15 -0
- package/dist/sdk/terminal/client.js +126 -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 +72 -0
- package/dist/sdk/terminal/controller.js +351 -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/logs.d.ts +14 -0
- package/dist/sdk/terminal/logs.js +59 -0
- package/dist/sdk/terminal/piExtension.d.ts +6 -0
- package/dist/sdk/terminal/piExtension.js +392 -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 +70 -0
- package/dist/sdk/terminal/socket.js +256 -0
- package/dist/sdk/terminal/standalone.d.ts +18 -0
- package/dist/sdk/terminal/standalone.js +146 -0
- package/dist/sdk/terminal/terminals.d.ts +176 -0
- package/dist/sdk/terminal/terminals.js +767 -0
- package/dist/sdk/terminal/trajectory.d.ts +10 -0
- package/dist/sdk/terminal/trajectory.js +30 -0
- package/dist/sdk/terminal/tui/chrome.d.ts +64 -0
- package/dist/sdk/terminal/tui/chrome.js +169 -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 +7 -0
- package/dist/sdk/terminal/tui/commandPages.js +63 -0
- package/dist/sdk/terminal/tui/commands.d.ts +42 -0
- package/dist/sdk/terminal/tui/commands.js +276 -0
- package/dist/sdk/terminal/tui/dialogGeometry.d.ts +27 -0
- package/dist/sdk/terminal/tui/dialogGeometry.js +50 -0
- package/dist/sdk/terminal/tui/dialogs.d.ts +75 -0
- package/dist/sdk/terminal/tui/dialogs.js +363 -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 +73 -0
- package/dist/sdk/terminal/tui/list.js +196 -0
- package/dist/sdk/terminal/tui/modeChoices.d.ts +42 -0
- package/dist/sdk/terminal/tui/modeChoices.js +70 -0
- package/dist/sdk/terminal/tui/modelPicker.d.ts +55 -0
- package/dist/sdk/terminal/tui/modelPicker.js +155 -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/page.d.ts +14 -0
- package/dist/sdk/terminal/tui/page.js +1 -0
- package/dist/sdk/terminal/tui/pageOverlay.d.ts +27 -0
- package/dist/sdk/terminal/tui/pageOverlay.js +145 -0
- package/dist/sdk/terminal/tui/pages/accountsPage.d.ts +54 -0
- package/dist/sdk/terminal/tui/pages/accountsPage.js +181 -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/doctorPage.d.ts +37 -0
- package/dist/sdk/terminal/tui/pages/doctorPage.js +145 -0
- package/dist/sdk/terminal/tui/pages/hubPage.d.ts +39 -0
- package/dist/sdk/terminal/tui/pages/hubPage.js +128 -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 +57 -0
- package/dist/sdk/terminal/tui/pages/pluginsPage.js +243 -0
- package/dist/sdk/terminal/tui/pages/settingsPage.d.ts +55 -0
- package/dist/sdk/terminal/tui/pages/settingsPage.js +88 -0
- package/dist/sdk/terminal/tui/pages/trajectoryPage.d.ts +58 -0
- package/dist/sdk/terminal/tui/pages/trajectoryPage.js +377 -0
- package/dist/sdk/terminal/tui/piAdapter.d.ts +18 -0
- package/dist/sdk/terminal/tui/piAdapter.js +48 -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/questionPicker.d.ts +20 -0
- package/dist/sdk/terminal/tui/questionPicker.js +150 -0
- package/dist/sdk/terminal/tui/questions.d.ts +19 -0
- package/dist/sdk/terminal/tui/questions.js +42 -0
- package/dist/sdk/terminal/tui/runtime.d.ts +114 -0
- package/dist/sdk/terminal/tui/runtime.js +441 -0
- package/dist/sdk/terminal/tui/search.d.ts +22 -0
- package/dist/sdk/terminal/tui/search.js +60 -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/sessionUi.d.ts +3 -0
- package/dist/sdk/terminal/tui/sessionUi.js +30 -0
- package/dist/sdk/terminal/tui/settingsModel.d.ts +12 -0
- package/dist/sdk/terminal/tui/settingsModel.js +84 -0
- package/dist/sdk/terminal/tui/sideQuestion.d.ts +53 -0
- package/dist/sdk/terminal/tui/sideQuestion.js +197 -0
- package/dist/sdk/terminal/tui/skillInvocation.d.ts +9 -0
- package/dist/sdk/terminal/tui/skillInvocation.js +43 -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 +45 -0
- package/dist/sdk/terminal/tui/theme.js +176 -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 +47 -0
- package/dist/sdk/terminal/tui/ui.js +148 -0
- package/dist/sdk/terminal/tui/workingStatus.d.ts +9 -0
- package/dist/sdk/terminal/tui/workingStatus.js +229 -0
- package/dist/sdk/tools/askUser.d.ts +6 -0
- package/dist/sdk/tools/askUser.js +74 -0
- package/dist/sdk/tools/checklist.d.ts +9 -0
- package/dist/sdk/tools/checklist.js +54 -0
- package/dist/sdk/tools/definitions.d.ts +30 -0
- package/dist/sdk/tools/definitions.js +117 -0
- package/dist/sdk/tools/dispatch.d.ts +16 -0
- package/dist/sdk/tools/dispatch.js +67 -0
- package/dist/sdk/tools/harnessTools.d.ts +6 -0
- package/dist/sdk/tools/harnessTools.js +20 -0
- package/dist/sdk/tools/sessionName.d.ts +7 -0
- package/dist/sdk/tools/sessionName.js +31 -0
- package/dist/sdk/tools/spawnSubagent.d.ts +4 -0
- package/dist/sdk/tools/spawnSubagent.js +49 -0
- package/dist/sdk/tools/types.d.ts +48 -0
- package/dist/sdk/tools/types.js +1 -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 +82 -0
- package/dist/sdk/variant/store.js +151 -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/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/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/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 +65 -0
- package/dist/sdk/world/world.js +80 -0
- package/dist/terminal-opentui.js +13612 -0
- package/dist/terminal-pi.js +808 -151
- package/docs/README.md +22 -0
- package/docs/architecture/00-overview.md +159 -0
- package/docs/architecture/01-extension-points.md +78 -0
- package/docs/architecture/02-sessions-and-runs.md +146 -0
- package/docs/architecture/03-variants.md +95 -0
- package/docs/architecture/04-prompt.md +102 -0
- package/docs/architecture/05-refinement.md +107 -0
- package/docs/architecture/06-plugins-and-capabilities.md +93 -0
- package/docs/architecture/07-tools-and-gate.md +88 -0
- package/docs/architecture/08-memory-and-history.md +94 -0
- package/docs/architecture/09-accounts-and-connectors.md +90 -0
- package/docs/architecture/10-server-protocol.md +84 -0
- package/docs/architecture/11-terminal.md +81 -0
- package/docs/architecture/12-storage.md +61 -0
- package/docs/architecture/13-world-tools.md +23 -0
- package/docs/architecture/README.md +114 -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 +68 -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/README.md +76 -0
- package/docs/decisions/ADR-0002-native-subagent-lifecycle.md +49 -0
- package/docs/decisions/ADR-0003-shared-asynchronous-subagents.md +70 -0
- package/docs/decisions/ADR-0004-fullscreen-terminal-layout.md +50 -0
- package/docs/decisions/ADR-0005-app-provided-oauth-clients.md +54 -0
- 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 +38 -0
- package/docs/decisions/ADR-0009-xharness-command.md +38 -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 +21 -0
- package/docs/doctor.md +74 -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/features/README.md +20 -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/releases/1.0.0.md +40 -0
- package/docs/releases/README.md +36 -0
- package/docs/study/00-index.md +78 -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 +75 -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/btw-comparison.md +37 -0
- package/docs/study/feature-gap-review.md +42 -0
- package/docs/study/insights.md +123 -0
- package/docs/study/roadmap.md +72 -0
- package/docs/study/sources/claude-code.md +44 -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/system-prompt-design.md +196 -0
- package/docs/terminal-tui.md +473 -56
- package/package.json +43 -13
- package/docs/evidence/terminal-2026-10-17/120x40-completed-transcript.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17/40x20-settings-interaction.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17/40x20-settings-keyboard.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17/40x20-welcome.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17/80x24-approval-0.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17/80x24-question.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17/verification.json +0 -130
- package/docs/evidence/terminal-2026-10-17-followup/120x40-completed-transcript.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/40x20-settings-interaction.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/40x20-settings-keyboard.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/40x20-welcome.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/80x24-approval-0.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/80x24-plugin-light.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/80x24-question-batch.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/80x24-question.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/app-bundle/80x24-approval-0.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/app-bundle/80x24-plugin-light.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/app-bundle/80x24-question-batch.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/app-bundle/80x24-question.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/app-bundle/verification.json +0 -95
- package/docs/evidence/terminal-2026-10-17-followup/global-install/80x24-approval-0.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/global-install/80x24-plugin-light.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/global-install/80x24-question-batch.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/global-install/80x24-question.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/global-install/README.md +0 -27
- package/docs/evidence/terminal-2026-10-17-followup/global-install/shell-command-80x24.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/global-install/shell-command.json +0 -18
- package/docs/evidence/terminal-2026-10-17-followup/global-install/verification.json +0 -95
- package/docs/evidence/terminal-2026-10-17-followup/harness-reference-80x24.json.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/harness-reference-final-80x24.json.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/harness-reference-scenario.json +0 -60
- package/docs/evidence/terminal-2026-10-17-followup/live-codex/README.md +0 -24
- package/docs/evidence/terminal-2026-10-17-followup/live-codex/complete-80x24.ansi.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/live-codex/verification.json +0 -57
- package/docs/evidence/terminal-2026-10-17-followup/omp-reference-80x24-early.json.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/omp-reference-80x24.json.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/omp-reference-scenario.json +0 -58
- package/docs/evidence/terminal-2026-10-17-followup/omp-supplemental-static.json.gz +0 -0
- package/docs/evidence/terminal-2026-10-17-followup/rea-artifacts.json +0 -320
- package/docs/evidence/terminal-2026-10-17-followup/reference-comparison.json +0 -30
- package/docs/evidence/terminal-2026-10-17-followup/reference-comparison.md +0 -133
- package/docs/evidence/terminal-2026-10-17-followup/reference-source-observations.json +0 -20
- package/docs/evidence/terminal-2026-10-17-followup/verification.json +0 -207
- package/src/accounts/accounts.test.ts +0 -333
- package/src/accounts/accounts.ts +0 -658
- 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.ts +0 -34
- 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 -312
- 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 -75
- package/src/mcp/connections.ts +0 -614
- 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 -376
- package/src/mcp/service.ts +0 -549
- package/src/mcp/types.ts +0 -108
- 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 -163
- package/src/memory/curation.ts +0 -64
- package/src/memory/dispatch.ts +0 -59
- 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 -176
- package/src/memory/maintenance.ts +0 -518
- 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 -278
- 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/wiki.test.ts +0 -47
- package/src/memory/wiki.ts +0 -422
- package/src/memory/wikiIndex.test.ts +0 -88
- package/src/memory/wikiIndex.ts +0 -116
- 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 -82
- 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 -349
- 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 -174
- package/src/sessions/approvals.ts +0 -118
- package/src/sessions/contracts.ts +0 -336
- package/src/sessions/conversation.test.ts +0 -177
- 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 -381
- package/src/sessions/runIndex.ts +0 -99
- package/src/sessions/runStore.test.ts +0 -152
- package/src/sessions/runStore.ts +0 -332
- package/src/sessions/runner.ts +0 -604
- package/src/sessions/runtimeResources.test.ts +0 -61
- package/src/sessions/sessions.test.ts +0 -549
- package/src/sessions/sessions.ts +0 -339
- 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 -291
- 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 -259
- package/src/terminal/pluginControl.test.ts +0 -146
- package/src/terminal/pluginMenu.ts +0 -112
- package/src/terminal/socket.test.ts +0 -71
- package/src/terminal/socket.ts +0 -232
- package/src/terminal/standalone.test.ts +0 -167
- package/src/terminal/standalone.ts +0 -153
- package/src/terminal/terminal.test.ts +0 -399
- package/src/terminal/terminals.ts +0 -553
- package/src/terminal/tui/application.test.ts +0 -114
- package/src/terminal/tui/application.ts +0 -491
- package/src/terminal/tui/commands.test.ts +0 -218
- package/src/terminal/tui/commands.ts +0 -361
- package/src/terminal/tui/dialogs.ts +0 -301
- package/src/terminal/tui/editor.test.ts +0 -84
- package/src/terminal/tui/editor.ts +0 -79
- package/src/terminal/tui/keybindings.test.ts +0 -22
- package/src/terminal/tui/keybindings.ts +0 -50
- package/src/terminal/tui/piAdapter.ts +0 -62
- 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 -104
- package/src/terminal/tui/runtime.test.ts +0 -215
- package/src/terminal/tui/runtime.ts +0 -388
- 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/status.test.ts +0 -70
- package/src/terminal/tui/status.ts +0 -109
- package/src/terminal/tui/theme.ts +0 -174
- package/src/terminal/tui/tools.test.ts +0 -145
- package/src/terminal/tui/tools.ts +0 -142
- package/src/terminal/tui/transcript.test.ts +0 -25
- package/src/terminal/tui/transcript.ts +0 -124
- 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/tools/askUser.test.ts +0 -69
- package/src/tools/askUser.ts +0 -59
- package/src/tools/definitions.ts +0 -187
- package/src/tools/maintenance.ts +0 -24
- 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 -92
- package/src/tools/types.ts +0 -39
- 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,107 @@
|
|
|
1
|
+
# 05 Refinement
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Refinement improves a variant from evidence of how it ran, with model weights fixed
|
|
6
|
+
(Harness²). On one task it runs the current variant, lets improver sessions edit it, probes each
|
|
7
|
+
candidate, composes the best behaviours, and picks one final output without ever seeing a score.
|
|
8
|
+
A person adopts the result. Adopted variants and their lessons go to an experience library that the
|
|
9
|
+
next task's improvers read.
|
|
10
|
+
|
|
11
|
+
## Components
|
|
12
|
+
|
|
13
|
+
| Type / function | Module | Role |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| `Refinements` | `refine/service.ts` | `start`, `wait`, `get`, `list`, `cancel`, `candidates`, `adopt`, `library`, `libraryEntry`, `forget`. |
|
|
16
|
+
| `runRefinement` | `refine/runner.ts` | One refinement end to end; writes `summary.json`. |
|
|
17
|
+
| `runMatrix` | `refine/suite.ts` | Evaluates variant versions on a task set without refining: one probe execution per version × task, recorded as `matrix.json` with comparability keys. Reads with `readMatrix`. |
|
|
18
|
+
| recursion | `refine/recursion.ts` | Parallel (`agg`) and sequential (`seq`) modes; stages `INV`, `DOM`, `AGG`, `COMPOSE`. |
|
|
19
|
+
| `Ledger` | `refine/ledger.ts` | Budget identity: R = 4k rollouts, P = 3k improver sessions. |
|
|
20
|
+
| evidence | `refine/evidence.ts` | Builds the evidence folder and guards it against grader output. |
|
|
21
|
+
| selection | `refine/selection.ts` | Blind choice among anonymised outputs, then reflection. |
|
|
22
|
+
| `Library` | `refine/library.ts` | The experience library per scope and area. |
|
|
23
|
+
| `PiExecutor`, `PiImprover` | `refine/pi.ts` | Executions and improvers as ordinary harness runs, triggers `probe` and `improver`. |
|
|
24
|
+
| `RefineHost` | `refine/host.ts` | The application's part (page 01, surface 7). |
|
|
25
|
+
| prompts | `refine/prompts.ts` | Improver missions. |
|
|
26
|
+
|
|
27
|
+
## Method
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
base variant ──► k base executions (probe runs, isolated workspaces)
|
|
31
|
+
──► evidence folder (task, source, trajectories, deliverables, variant, library, pool)
|
|
32
|
+
──► improvers: k INV (how the agent works) + k DOM (what a practitioner knows)
|
|
33
|
+
──► probe each candidate ──► k compositions from behavioural contrasts ──► k finals
|
|
34
|
+
──► blind selection among anonymised outputs ──► reflection ──► candidate for adoption
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Parallel mode explores wider; sequential mode refines deeper. Both cost R = 4k executions and
|
|
38
|
+
P = 3k improver sessions. An invalid proposal gets one retry with the validator's message
|
|
39
|
+
(`STAGE_ATTEMPTS = 2`), then inherits the current variant.
|
|
40
|
+
|
|
41
|
+
An **evaluation matrix** is the measurement half on its own: `runMatrix` runs every
|
|
42
|
+
`{variant version × task}` pair through the same `Executor` contract — no improver, no selection,
|
|
43
|
+
no adoption, and an empty or failed execution is an honest row. Every row records
|
|
44
|
+
deliverability (`ok`, `delivered`) and cost, plus its comparability keys (task-prompt hash,
|
|
45
|
+
executor name, package version, variant fingerprint), so matrices taken across variant versions or
|
|
46
|
+
package commits are diffable directly. An evaluation never moves a head, and it inherits the
|
|
47
|
+
answer-free rule: a variant or record carrying grader output is refused before any execution
|
|
48
|
+
(`INV-REF-1`).
|
|
49
|
+
|
|
50
|
+
## Contracts
|
|
51
|
+
|
|
52
|
+
- `start({ task: { id, scope, prompt, ... }, k?, mode?: 'parallel' | 'sequential', baseVersion?, improver?, executor?, retainWorkspaces? })`
|
|
53
|
+
returns `{ id }` at once; progress arrives as `refine.changed` and `refine.event` notices.
|
|
54
|
+
- With `retainWorkspaces: true` (default `false`), each execution's workspace — base, candidate
|
|
55
|
+
and final — is copied whole to `rollouts/<label>/workspace/` after its run settles and before
|
|
56
|
+
the host's `cleanup`. Binary and hidden files are kept, and symbolic links are copied as links.
|
|
57
|
+
A failed copy is recorded as `workspaceError` in `rollout.json` and never fails the execution.
|
|
58
|
+
`candidates(id)` reports each execution's `workspace` path, or `null` (PROP-0002).
|
|
59
|
+
- `executor: { model?, effort?, accountId?, poolId? }` names how executions run. For each value
|
|
60
|
+
the host's `session(...)` wins, then `executor`, then the account default. `summary.json`
|
|
61
|
+
records `settings: { executor, improver }` as started; each probe run's record holds what it
|
|
62
|
+
resolved (PROP-0003).
|
|
63
|
+
- `adopt(id, { label? })` commits the chosen (or named) candidate as the scope's head with source
|
|
64
|
+
`refinement`. It refuses while any plugin code in it is untrusted.
|
|
65
|
+
- Executions run as `sessions.run` with `trigger: 'probe'`, `automatic: true`, in the host's
|
|
66
|
+
workspace. Improvers run with `trigger: 'improver'`, `automatic: true`, file tools only, no
|
|
67
|
+
providers, no connected apps, no harness tools, no variant, in a temporary copy of the evidence.
|
|
68
|
+
|
|
69
|
+
## Invariants
|
|
70
|
+
|
|
71
|
+
- **INV-REF-1** Refinement is answer-free. No rubric, score, grader output or reviewer verdict
|
|
72
|
+
reaches an improver, the selector or the library. `refine/evidence.ts` guards every evidence
|
|
73
|
+
folder (`GRADER_VERDICT_MARKERS` as a tripwire) and `assertTreeHasNoGraderVerdicts` guards the
|
|
74
|
+
library. Retained workspaces are output for measurement after the fact; evidence, selection,
|
|
75
|
+
reflection and the library never read them.
|
|
76
|
+
- **INV-REF-2** The selector sees only the request, the source and the outputs, shuffled under
|
|
77
|
+
arbitrary ids. It never sees a harness, a trajectory or a verdict.
|
|
78
|
+
- **INV-REF-3** The budget identity R = 4k, P = 3k holds in both modes (`Ledger.assertIdentity`).
|
|
79
|
+
A change to the method changes both modes and their tests together.
|
|
80
|
+
- **INV-REF-4** Refinement never acts in the world. Executions are unattended `probe` runs in a
|
|
81
|
+
folder the `RefineHost` prepared; anything that needs a person is refused at the gate, never
|
|
82
|
+
queued.
|
|
83
|
+
- **INV-REF-5** Improvers have file tools only and work on a copy of the evidence.
|
|
84
|
+
- **INV-REF-6** Refinement never moves a head by itself. Only `adopt`, a person's action, does, and
|
|
85
|
+
only with all plugin code trusted (`INV-VAR-5`).
|
|
86
|
+
- **INV-REF-7** The library carries whole adopted variants with an evidence-backed lesson, never a
|
|
87
|
+
summary in place of the variant.
|
|
88
|
+
- **INV-REF-8** Per-observation truncation of trajectories is never below `MIN_OBS_TRUNC`
|
|
89
|
+
(10,000 characters); lower values fabricate defects.
|
|
90
|
+
|
|
91
|
+
## Data
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
<data root>/refine/<id>/ summary.json, task.json, variants/<label>/, rollouts/<label>/,
|
|
95
|
+
sessions/<label>/, context/, selection/, reflection/, improver/
|
|
96
|
+
<data root>/refine/<id>/rollouts/<label>/workspace/ only with retainWorkspaces
|
|
97
|
+
<data root>/refine/<id>/ matrix.json, suite.json (evaluation matrices; see above)
|
|
98
|
+
<data root>/library/<scope>/<area>/INDEX.md
|
|
99
|
+
<data root>/library/<scope>/<area>/variants/<task>/{variant/, EXPERIENCE.md}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Source map
|
|
103
|
+
|
|
104
|
+
`src/refine/*.ts`. Method origin: Harness² (`harness2/core/{recursion,ledger,selection,library,context}.py`,
|
|
105
|
+
Apache-2.0). The evaluation matrix is this harness's addition (`refine/suite.ts`), shaped by the
|
|
106
|
+
same executor contract and demo executor. Try it with no model: `npm run build && node dist/cli.js refine demo --k 2`,
|
|
107
|
+
or evaluate a matrix with `node dist/cli.js refine matrix --demo [--data <root>] [--out <file.json>]`.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# 06 Plugins and capabilities
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
A *plugin* is a bundle with a title, a description and contributions: instructions, skills,
|
|
6
|
+
commands, tools, connections, code (a Pi extension) and themes. A Pi package is a plugin as it is;
|
|
7
|
+
so are the harness's own parts, the application's parts, a person's registry, the folder every
|
|
8
|
+
account shares, and what a working folder brings. This part decides what a session loads, who has
|
|
9
|
+
what switched on, which code may run, and what reaches one caller. A *capability set* is the
|
|
10
|
+
callable result for one run.
|
|
11
|
+
|
|
12
|
+
## Components
|
|
13
|
+
|
|
14
|
+
| Type / function | Module | Role |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| `Plugin`, `Contribution`, `PluginDescriptor`, `CONTRIBUTION_KINDS`, `PLUGIN_SOURCES` | `plugins/types.ts` | The model of a plugin and what it brings. |
|
|
17
|
+
| `Plugins` (`loading`, `loaded`) | `plugins/plugins.ts` | Chooses the paths a session or terminal loads; records what each extension registered. |
|
|
18
|
+
| discovery | `plugins/discover.ts` | Finds items with Pi's own resolver, which runs no extension code. |
|
|
19
|
+
| attachments (`load`, `save`, `attached`, `decided`, `set`) | `plugins/attachments.ts` | The one store of what is switched on, per scope. |
|
|
20
|
+
| `HARNESS_PLUGINS` | `plugins/builtin.ts` | Descriptors of the harness's own parts: `pi`, `harness`, `subagents`, `wiki`, `history`, `ask-user`, `checklist`, `connected-apps`. |
|
|
21
|
+
| `FIRST_PARTY_PLUGINS` | `plugins/firstParty.ts` | `output-trim`, `budget-guard`: inline extensions shipped switched off. `lessons`: switched off; its contribution turns on reflection after a run (page 08, PROP-0008) and loads no Pi code. |
|
|
22
|
+
| `Hooks` | `plugins/hooks.ts` | Runs a package's hooks file after a write. |
|
|
23
|
+
| install / trust | `plugins/install.ts`, `plugins/trust.ts` | Install through Pi's package manager with scripts off; trust code by hash. |
|
|
24
|
+
| inventory / api | `plugins/inventory.ts`, `plugins/api.ts` | `plugins.list`, `plugins.inventory`, attach, trust. |
|
|
25
|
+
| capability api | `capabilities/api.ts`, `capabilities/types.ts` | `list`, `resolve`, `toolIntersection`, `inventory`, `attach`. |
|
|
26
|
+
| run snapshot | `capabilities/runSnapshot.ts` | `freezeRun`, `loadRun`, `capabilitySet`. |
|
|
27
|
+
|
|
28
|
+
## Contracts
|
|
29
|
+
|
|
30
|
+
- **Loading.** `Plugins.loading({ cwd, agentDir, caller, contributions, install? })` returns
|
|
31
|
+
`extensionPaths`, `skillPaths`, `promptPaths`, `themePaths`, `builtins` (terminal only), `hooks`,
|
|
32
|
+
`found`, `detached`, `projectCode`, `packageCode`. A session opens Pi with its own discovery off
|
|
33
|
+
and only these paths; a terminal receives them as `--extension`, `--skill`,
|
|
34
|
+
`--prompt-template` and `--theme` after `--no-extensions --no-skills --no-prompt-templates
|
|
35
|
+
--no-themes`. Pi still reads `AGENTS.md` and `SYSTEM.md` itself.
|
|
36
|
+
- **Attachments.** `config/plugin-attachments.json` holds `global`, `agents`, `projects` (each
|
|
37
|
+
`{ on, off }`) and `settings` per plugin. The narrowest scope that says something wins: agent,
|
|
38
|
+
then project, then everywhere. With no entry an item keeps its default.
|
|
39
|
+
- **Hooks.** A package declares `"harness": { "extends": [...], "hooks": "./hooks.mjs" }`. Events:
|
|
40
|
+
`wiki.page.saved`, `history.run.ended`. A hook has 30 seconds; its errors are kept in
|
|
41
|
+
`plugin-hooks.json`. `ctx.call(connection, tool, args)` reaches only a connected app that is on
|
|
42
|
+
for everyone, and only a tool marked to run without asking.
|
|
43
|
+
- **Capability set** (`CapabilitySet`): `{ version: 1, tools, connectors, contributions }`.
|
|
44
|
+
`capabilities.resolve` returns the set available to a caller; `capabilities.intersect` /
|
|
45
|
+
`toolIntersection` narrows it for a child.
|
|
46
|
+
|
|
47
|
+
## Invariants
|
|
48
|
+
|
|
49
|
+
- **INV-PLG-1** The harness is the only loader. A session or terminal loads exactly what
|
|
50
|
+
`Plugins.loading` chose, with Pi's discovery switched off. Never pass a session a loader that
|
|
51
|
+
discovers on its own.
|
|
52
|
+
- **INV-PLG-2** Code waits for trust. A working folder's `.pi/extensions` and the packages its
|
|
53
|
+
settings name are trusted together; each installed package is trusted on its own. Trust is a
|
|
54
|
+
hash of the files; a changed file asks again. A loose file a person put in the shared
|
|
55
|
+
`extensions/` folder needs no trust. Text contributions always load.
|
|
56
|
+
- **INV-PLG-3** Installing runs no code (`npm_config_ignore_scripts`). A package arrives switched
|
|
57
|
+
off and, if it has code, untrusted. Installing grants no attachment, trust, credential or
|
|
58
|
+
permission.
|
|
59
|
+
- **INV-PLG-4** The approval gate is the last extension to see a tool call (page 07, `INV-GATE-2`).
|
|
60
|
+
A plugin that changes a call's input does so before the gate sees it.
|
|
61
|
+
- **INV-PLG-5** Everything model-visible belongs to a plugin. A new prompt section, tool group or
|
|
62
|
+
tool is declared by a `PluginDescriptor` (`plugins/builtin.ts` for the harness's own), or
|
|
63
|
+
`plugins.inventory` reports it as `unattributed`.
|
|
64
|
+
- **INV-PLG-6** One store says what is switched on: `plugins/attachments.ts`. A new kind of
|
|
65
|
+
switchable thing gets a default and is read with `attached`; no second enablement file.
|
|
66
|
+
- **INV-PLG-7** A hook is told, never asked. Hooks run after the write, in the background; a write
|
|
67
|
+
never waits for a hook and a hook's failure never reaches it. A new write point that should be
|
|
68
|
+
heard calls `noteChange` (`core/changes.ts`). No hook may stop or change a write.
|
|
69
|
+
- **INV-PLG-8** A hook runs only while its plugin is on for everyone and trusted, checked before
|
|
70
|
+
each delivery. A working folder's package cannot bring a hook.
|
|
71
|
+
- **INV-PLG-9** Unattended runs load no extension found on disk (`INV-RUN-5`). The harness's own
|
|
72
|
+
parts are required and refuse to be switched off; switching something on grants no permission.
|
|
73
|
+
- **INV-CAP-1** A capability set only narrows. `intersect` never adds access; a run's set is
|
|
74
|
+
frozen when it starts (`INV-RUN-2`).
|
|
75
|
+
- **INV-CAP-2** The capability contract is generic. It names no application task, role or UI
|
|
76
|
+
concept.
|
|
77
|
+
- **INV-CAP-3** A capability set says what may be called, not whether a call may run. The gate
|
|
78
|
+
still decides each call.
|
|
79
|
+
|
|
80
|
+
## Data
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
<data root>/config/plugin-attachments.json (registry-enabled.json read until the first change)
|
|
84
|
+
<data root>/plugins/<name>/ packages kept with the data; removal moves to trash/plugins/
|
|
85
|
+
<state dir>/plugin-trust.json trusted code, by hash
|
|
86
|
+
<state dir>/plugin-registered.json what each extension registered last time
|
|
87
|
+
<state dir>/plugin-hooks.json hooks and their last run
|
|
88
|
+
<state dir>/accounts/_shared/pi/ settings and packages shared by every account
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Source map
|
|
92
|
+
|
|
93
|
+
`src/plugins/*.ts`, `src/capabilities/*.ts`, `src/core/changes.ts`.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# 07 Tools and the gate
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
A run's tools come from four places: the harness's own tools, the connected-apps broker,
|
|
6
|
+
subagent tools, and the application's tool providers. Every call, whatever its source, passes one
|
|
7
|
+
per-call gate that asks the application's policy, then standing approvals, then the person.
|
|
8
|
+
|
|
9
|
+
## Components
|
|
10
|
+
|
|
11
|
+
| Type / function | Module | Role |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| `HarnessToolDefinition`, `RECALL_TOOLS`, `TRAJECTORY_TOOLS`, `WIKI_READ_TOOLS`, `WIKI_WRITE_TOOLS`, `SKILL_TOOLS`, `DEFAULT_TOOL_NAMES` | `tools/definitions.ts` | The harness's own tools, defined once. |
|
|
14
|
+
| `dispatch` | `tools/dispatch.ts` | One entry point for every History, Wiki and skill call, from a Pi tool, the server or a terminal. |
|
|
15
|
+
| `harnessTools` | `tools/harnessTools.ts` | The definitions as `ToolSpec`s for one session. |
|
|
16
|
+
| `askUserTool` (`ask_user`) | `tools/askUser.ts` | Stops the run and asks a question with choices. |
|
|
17
|
+
| `checklistTool` (`checklist_write`) | `tools/checklist.ts` | Writes the run's whole checklist as a `checklist.updated` event (PROP-0006). Read-only for the gate, so plan mode allows it. |
|
|
18
|
+
| `subagentTools` | `tools/spawnSubagent.ts` | `spawn_subagent`, `wait_subagents`. |
|
|
19
|
+
| `webTools` | `web/tools.ts` | `web_search` (Brave, key from the secret store), `web_fetch` (checked public reads). An application provides them as a provider. |
|
|
20
|
+
| gate | `sessions/sessions.ts::gate`, `sessions/runner.ts` | `ToolGate { ask, check }`, loaded as the last extension (`xagent-approvals`). |
|
|
21
|
+
| `Approvals`, `decide`, `grant`, `approvalKey` | `sessions/approvals.ts` | Standing approvals. |
|
|
22
|
+
|
|
23
|
+
Harness tools: `history_search`, `history_read`, `trajectory_search`, `trajectory_read`,
|
|
24
|
+
`wiki_search`, `wiki_read`, `wiki_list`, `wiki_write` (not in the default set), `skill_load`,
|
|
25
|
+
`ask_user`, `checklist_write`. Broker: `mcp_list_tools`, `mcp_call_tool`. Native Pi tools: `read`, `grep`, `find`,
|
|
26
|
+
`ls`, `edit`, `write`, `bash`.
|
|
27
|
+
|
|
28
|
+
## The gate, per call
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
child run and tool outside its snapshot ─► refuse
|
|
32
|
+
plan mode and tool not research-safe ─► refuse (before approvals)
|
|
33
|
+
policy.scope(call)
|
|
34
|
+
not allowed and (automatic or no approval possible) ─► refuse with reason
|
|
35
|
+
policy.authorize(call) throws ─► refuse
|
|
36
|
+
allowed, not humanOnly, (automatic or not gated) ─► run
|
|
37
|
+
trigger probe or improver ─► refuse (nobody to ask)
|
|
38
|
+
run.requestApproval(...) ─► standing approvals may answer, else the person
|
|
39
|
+
denied ─► refuse
|
|
40
|
+
policy.authorize(call) again ─► run or refuse
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Standing approvals (`approvals.json`): an always-approve switch per key (`chat`, or the run's
|
|
44
|
+
`harness`), tools allowed across the state directory per key, and targets remembered per
|
|
45
|
+
session. `humanOnly` calls are never answered by remembered tools, and by the switch only when
|
|
46
|
+
`allowGlobalApproval`. `ApprovalFacts.unattended` disables standing answers; `readOnly` disables
|
|
47
|
+
the switch and global tools.
|
|
48
|
+
|
|
49
|
+
## Invariants
|
|
50
|
+
|
|
51
|
+
- **INV-GATE-1** Every tool call of every run passes the gate. No tool source bypasses it,
|
|
52
|
+
including extension-registered tools (which ask before every call) and the initial Bash command.
|
|
53
|
+
- **INV-GATE-2** The gate is the last extension loaded, after disk, variant and inline extensions, so
|
|
54
|
+
it sees the final input of every call.
|
|
55
|
+
- **INV-GATE-3** Order is fixed: capability and plan-mode refusals, then the policy's scope and
|
|
56
|
+
authorize, then standing approvals, then the person, then authorize again.
|
|
57
|
+
- **INV-GATE-4** Refinement runs (`probe`, `improver`) never ask a person; what would need one is
|
|
58
|
+
refused, never queued (`INV-REF-4`).
|
|
59
|
+
- **INV-GATE-5** A tool is registered only if its name is in the run's frozen capability set, in
|
|
60
|
+
that order (`INV-CAP-1`).
|
|
61
|
+
- **INV-GATE-6** Tool attachment bytes never enter the run-event stream; only references are
|
|
62
|
+
recorded.
|
|
63
|
+
- **INV-GATE-7** Tool descriptions name the product with `{product}` (filled by `describeTool`),
|
|
64
|
+
never an application's name (`INV-BND-2`).
|
|
65
|
+
|
|
66
|
+
## Data
|
|
67
|
+
|
|
68
|
+
`<state dir>/approvals.json`.
|
|
69
|
+
|
|
70
|
+
## Source map
|
|
71
|
+
|
|
72
|
+
`src/tools/*.ts`, `src/web/*.ts`, `src/sessions/sessions.ts`, `src/sessions/runner.ts`,
|
|
73
|
+
`src/sessions/approvals.ts`, `src/sessions/policy.ts`.
|
|
74
|
+
|
|
75
|
+
## Session naming (PROP-0010)
|
|
76
|
+
|
|
77
|
+
`session_name` (`tools/sessionName.ts`) binds to the current native session. It maintains
|
|
78
|
+
only Pi session metadata and is explicitly plan-safe, while still subject to capability
|
|
79
|
+
selection and the host policy. The terminal registers the same definition through its Pi
|
|
80
|
+
bridge; standalone policy permits naming without approval. See page 02 for validation and
|
|
81
|
+
persistence. It is a foundation tool, not mutable variant data.
|
|
82
|
+
|
|
83
|
+
## Diagnostic probes
|
|
84
|
+
|
|
85
|
+
`/doctor` is a user command, never a model tool. Live diagnostics create separate real runs,
|
|
86
|
+
intersect current capabilities, and execute tool calls through the existing gate. Calls that
|
|
87
|
+
require an additional per-call approval report blocked; batch diagnostic consent does not grant
|
|
88
|
+
standing permission. No raw tool inputs, results, or screenshots enter diagnostic findings.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# 08 Memory and history
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Two kinds of memory sit outside the variant. The **Wiki** holds project notes: linked
|
|
6
|
+
Markdown that people and agents read and write as reference material, never as instructions.
|
|
7
|
+
**History** is the record of earlier runs: recall over what was said, and bounded reads of the
|
|
8
|
+
recorded trajectory. Both are served through harness tools (page 07) and kept searchable in a
|
|
9
|
+
rebuildable SQLite index.
|
|
10
|
+
|
|
11
|
+
## Components
|
|
12
|
+
|
|
13
|
+
| Type / function | Module | Role |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| `paths`, `list`, `read`, `write`, `remove`, `versions`, `version`, `search`, `graph`, `ensureLayout`, `moveLegacy` | `wiki/notes.ts` | The Wiki. Logical module (functions), not a class. |
|
|
16
|
+
| `noteChange` | `core/changes.ts` | Announces a completed write to listeners (hooks). |
|
|
17
|
+
| `indexRun`, `sync`, `search`, `read` | `history/recall.ts` | Recall passages from runs, scoped to the caller. |
|
|
18
|
+
| trajectory search and read | `history/trajectory.ts` | Paged, redacted reads of canonical run events. |
|
|
19
|
+
| `Lessons`, `keptLessons`, `lessonMission` | `history/lessons.ts`, `history/lessonPrompt.ts` | Reflection on finished runs when the `lessons` plugin is on; keeps general lessons as Wiki notes (PROP-0008). |
|
|
20
|
+
| `withIndex`, `migrate`, `MIGRATIONS` | `core/index.ts` | The shared `index.sqlite` connection and its migrations. |
|
|
21
|
+
|
|
22
|
+
## Contracts
|
|
23
|
+
|
|
24
|
+
- **Note paths.** A note's path is its file path under `wiki/` without `.md`. Links are
|
|
25
|
+
`[[path]]`, `[[path|label]]` or a relative Markdown link. Notes live in `home.md`, `library/`
|
|
26
|
+
(no project) and `projects/<slug>/` (a project the application named in `projects.json`).
|
|
27
|
+
- **Writes.** `write(root, path, body, { expectedUpdatedAt?, actor?, reason? })` refuses text over
|
|
28
|
+
400,000 characters, text that looks like a credential (`secret_refused`), an unknown project
|
|
29
|
+
slug, and a stale `expectedUpdatedAt` (`conflict`). The previous text is kept in `wiki-history/`.
|
|
30
|
+
- **Recall scope.** A `Code` caller (a session in a project) reads only session runs of its project,
|
|
31
|
+
or its own session. A `Chat` caller reads its agent's conversations. `recallExcludeAgents` hides
|
|
32
|
+
named agents' conversations. A caller never reads a run outside its scope.
|
|
33
|
+
- **Trajectory reads** return pages of canonical execution events, including active runs,
|
|
34
|
+
bounded and marked when truncated. They omit account identifiers, credential fields,
|
|
35
|
+
attachment bytes, native adapter payloads and provider reasoning text. They report evidence,
|
|
36
|
+
never a score.
|
|
37
|
+
- **Lessons** (PROP-0008, [ADR-0010](../decisions/ADR-0010-lessons-in-the-wiki.md)). When the
|
|
38
|
+
first-party `lessons` plugin is on for a run's caller (its contribution is in the run's
|
|
39
|
+
`capabilities.json`), a **completed, top-level** run that made at least `minToolCalls` tool calls
|
|
40
|
+
is queued after it ends. Subagent runs and runs with trigger `probe`, `improver` or `reflection`
|
|
41
|
+
are never queued. One reflection runs at a time, in the background, and the queue is not kept
|
|
42
|
+
across a restart.
|
|
43
|
+
- The reflection is a session with trigger `reflection` on the run's own account and model, file
|
|
44
|
+
tools `read`, `grep`, `find`, `ls` only, no providers, connections, harness tools or subagents,
|
|
45
|
+
`automatic: true`; anything needing a person is refused at the gate. Its evidence is a temporary
|
|
46
|
+
`context/` with `run.md` (the request and the rendered trajectory, observations kept to at least
|
|
47
|
+
10,000 characters) and `lessons.md` (the kept lessons' paths and cues), checked with the grader
|
|
48
|
+
tripwire.
|
|
49
|
+
- It replies `NO_ENTRY`, `SAME <path>`, or one `<experience>` block (`cue`, `lesson`, `evidence`,
|
|
50
|
+
`confidence`): refinement's lesson shape, which never carries the run's own facts.
|
|
51
|
+
- A new lesson is written with `notes.write` to `library/lessons/<slug of cue>` with actor
|
|
52
|
+
`reflection`, frontmatter `title`, `cue`, `confidence`, `sources: [runId]`. `SAME` adds the run
|
|
53
|
+
id to that note's `sources`. Nothing is written when the lesson is longer than `maxChars`,
|
|
54
|
+
looks like a credential, carries a grader marker, or the Wiki already keeps `maxLessons`
|
|
55
|
+
lessons; nothing is evicted.
|
|
56
|
+
- The `wiki` pointer section says how many lessons there are when there are any.
|
|
57
|
+
- **Index.** Every finished run is indexed when it ends; `open` and `rebuildIndex()` sync from
|
|
58
|
+
`runs/`.
|
|
59
|
+
|
|
60
|
+
## Invariants
|
|
61
|
+
|
|
62
|
+
- **INV-MEM-1** The Wiki is reference material, not instructions. Only the variant shapes an agent
|
|
63
|
+
(`INV-VAR-1`); the Wiki reaches a prompt only as the dynamic `wiki` pointer and selected
|
|
64
|
+
`references` (`INV-PRM-3`).
|
|
65
|
+
- **INV-MEM-2** The harness is the only writer of the Wiki and of run records. An application
|
|
66
|
+
reads them and writes notes only through harness methods (`wiki.*`). Inside the harness, the
|
|
67
|
+
Wiki is written by `wiki_write`, by `wiki.*` methods, and by `Lessons` (actor `reflection`, only
|
|
68
|
+
under `library/lessons/`, only while the `lessons` plugin is on for the run's caller).
|
|
69
|
+
- **INV-MEM-3** Every write point calls `noteChange` after the file is in place, and never waits
|
|
70
|
+
for listeners (`INV-PLG-7`). (Removal does not yet: drift D-7.)
|
|
71
|
+
- **INV-MEM-4** A note write keeps the previous text as a version. Nothing deletes history except
|
|
72
|
+
an explicit person's action.
|
|
73
|
+
- **INV-MEM-5** Files are the source of truth. `index.sqlite` is derived and can be deleted and
|
|
74
|
+
rebuilt (`harness.rebuildIndex()`).
|
|
75
|
+
- **INV-MEM-6** Index migrations are append-only once released. Each runs in one transaction
|
|
76
|
+
after the file is backed up; a failure restores the previous index.
|
|
77
|
+
- **INV-MEM-7** Recall and trajectory reads respect the caller's scope and redact secrets. They
|
|
78
|
+
never return another scope's runs.
|
|
79
|
+
- **INV-MEM-8** Wiki code is synchronous (`INV-BND-4`).
|
|
80
|
+
|
|
81
|
+
## Data
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
<data root>/wiki/ home.md, library/, projects/<slug>/
|
|
85
|
+
<data root>/wiki-history/ earlier versions of notes
|
|
86
|
+
<data root>/legacy/ an earlier Wiki's memory blocks, facts, revisions, Inbox (moved once)
|
|
87
|
+
<data root>/index.sqlite derived: pages, links, runs, recall passages (FTS5)
|
|
88
|
+
<data root>/projects.json read only: the application owns it
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Source map
|
|
92
|
+
|
|
93
|
+
`src/wiki/notes.ts`, `src/history/recall.ts`, `src/history/trajectory.ts`, `src/history/lessons.ts`, `src/core/index.ts`,
|
|
94
|
+
`src/core/changes.ts`, `src/core/projects.ts`, `src/core/secrets.ts`.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# 09 Accounts and connectors
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
**Accounts** are isolated Pi identities: each has its own agent folder, credentials, sessions and
|
|
6
|
+
history, so one person can use several providers and subscriptions without them mixing.
|
|
7
|
+
**Connectors** (connected apps) are MCP servers a session reaches through a broker, with scoped
|
|
8
|
+
access, approval of non-read calls, and redaction. The **Hub** installs exact catalog versions of
|
|
9
|
+
skills, prompts, rules and Pi packages.
|
|
10
|
+
|
|
11
|
+
## Components
|
|
12
|
+
|
|
13
|
+
| Type / function | Module | Role |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| `Accounts` | `accounts/accounts.ts` | Accounts and pools: `resolve`, `context`, `runtime`, `models`, `status`, sign-in (`loginStart`, `loginStatus`, `loginRespond`, `loginCancel`), `setApiKey`, `signOut`, terminal accounting. |
|
|
16
|
+
| `isolateProcess`, `ensureSharedDir`, `sharedDir` | `accounts/env.ts` | Isolated launch environments. |
|
|
17
|
+
| account store, audit | `accounts/store.ts` | The registry and audit log. |
|
|
18
|
+
| `SecretStore`, `secretKey`, `fileSecretStore`, `memorySecretStore` | `accounts/secrets.ts` | Where credentials live (page 01). |
|
|
19
|
+
| `ConnectedApps` | `mcp/service.ts` | The broker: `grant`, `session`, `expose`, `tools`, `revokeRun`, `callUnattended`, traces. |
|
|
20
|
+
| `Connections` | `mcp/connections.ts` | Saved connections, scopes, secrets, `redactEvent`, `scrub`. |
|
|
21
|
+
| `McpManager` | `mcp/manager.ts` | MCP clients. |
|
|
22
|
+
| OAuth | `mcp/oauth.ts` | Sign-in; an application's own registered clients (`AppOAuthClients`). |
|
|
23
|
+
| `Hub` | `hub/hub.ts`, `hub/schema.ts` | Catalog, preview, install, uninstall, receipts. |
|
|
24
|
+
|
|
25
|
+
## Contracts
|
|
26
|
+
|
|
27
|
+
- **Account folder.** Every Pi session gets its account's own agent folder
|
|
28
|
+
(`PI_CODING_AGENT_DIR`) under `<state dir>/accounts/`. Settings, skills, prompts and
|
|
29
|
+
instructions are shared through links to `_shared/pi/`; credentials, sessions and history stay
|
|
30
|
+
in the account's own folder.
|
|
31
|
+
- **Resolution.** A new session may name an account, a pool, or neither (the default). Once
|
|
32
|
+
started, it stays on that account.
|
|
33
|
+
- **Sign-in progress** lives in the running process only. `accounts.loginStatus` recovers the
|
|
34
|
+
current code or prompt with a revision; it is never written to account files.
|
|
35
|
+
- **Broker tools.** `mcp_list_tools` and `mcp_call_tool`. A connection reaches a session only if
|
|
36
|
+
its scope allows the caller and the policy's `connections` keeps it. Calls that are not reads
|
|
37
|
+
are approved through the gate. Each call's redacted result is traced in `mcp-context.json`.
|
|
38
|
+
- **`apps.expose(tools)`** offers the application's own tools through the broker, which is how a
|
|
39
|
+
terminal session reaches them.
|
|
40
|
+
- **Hub.** `hub.list`, `get`, `preview`, `install`, `uninstall`, `readDocument`. Pi packages need
|
|
41
|
+
an exact npm version or a full Git commit. Documents are saved as inert JSON.
|
|
42
|
+
|
|
43
|
+
## Invariants
|
|
44
|
+
|
|
45
|
+
- **INV-ACC-1** Accounts are isolated. A session runs in its account's own Pi folder, never in
|
|
46
|
+
`~/.pi`. The process drops inherited credential variables (`*_API_KEY`, `*_AUTH_TOKEN`,
|
|
47
|
+
`*_OAUTH_TOKEN`, `*_ACCESS_TOKEN`, `CODEX_HOME`, `CLAUDE_CONFIG_DIR`, `PI_CODING_AGENT_DIR`)
|
|
48
|
+
before any session starts.
|
|
49
|
+
- **INV-ACC-2** An account is never exchanged for another. A pinned session that cannot use its
|
|
50
|
+
account fails. Changing account for a terminal is an explicit person's action that restarts
|
|
51
|
+
the child.
|
|
52
|
+
- **INV-ACC-3** The harness never writes a secret to its own files; it asks the `SecretStore`.
|
|
53
|
+
The default file store is owner-only (`0600`).
|
|
54
|
+
- **INV-ACC-4** A terminal's `/accounts` goes through the session socket's `accounts.*` calls, and
|
|
55
|
+
every one needs the session's control key. A command the model runs in the shell cannot make
|
|
56
|
+
an account change.
|
|
57
|
+
- **INV-MCP-1** Connector secrets live in the `SecretStore`; `connections.json` holds no secret.
|
|
58
|
+
Run events and traces are redacted before they are stored or shown.
|
|
59
|
+
- **INV-MCP-2** A session reaches only the connections its scope and the policy allow, and loses
|
|
60
|
+
them when its run ends (`revokeRun`).
|
|
61
|
+
- **INV-MCP-3** An application's OAuth client is usable only by a catalog entry it lists, and
|
|
62
|
+
nothing of it is stored.
|
|
63
|
+
- **INV-MCP-4** Hub installation grants no attachment, trust, credential or permission. Writes
|
|
64
|
+
are serialized; existing registry files are never overwritten; uninstall removes only the exact
|
|
65
|
+
receipt's resources and revokes its attachment choices.
|
|
66
|
+
|
|
67
|
+
## Data
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
<state dir>/accounts/ registry, per-account Pi agent folders, _shared/pi/, audit log
|
|
71
|
+
<state dir>/secrets.json default SecretStore (owner-only)
|
|
72
|
+
<state dir>/connections.json connected apps, no secrets
|
|
73
|
+
<state dir>/hub/catalog.json catalog cache
|
|
74
|
+
<data root>/hub/ installed documents and provenance
|
|
75
|
+
<data root>/runs/<id>/mcp-context.json
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Source map
|
|
79
|
+
|
|
80
|
+
`src/accounts/*.ts`, `src/mcp/*.ts`, `src/hub/*.ts`. Decision:
|
|
81
|
+
[ADR-0005](../decisions/ADR-0005-app-provided-oauth-clients.md).
|
|
82
|
+
|
|
83
|
+
## Account and connector diagnostics
|
|
84
|
+
|
|
85
|
+
`Accounts.inspect` reads credentials and a non-refreshing Pi model catalogue through a read-only
|
|
86
|
+
credential store. It never refreshes OAuth tokens or verifies a key over the network. `/doctor`
|
|
87
|
+
labels this local readiness. A selected live model probe sends one synthetic request, caps output
|
|
88
|
+
at 64 tokens, and records usage through the normal run writer. It never substitutes an account.
|
|
89
|
+
MCP live diagnostics connect and list tools on the selected scoped connector, without calling
|
|
90
|
+
connector tools or starting sign-in. Disposable grants and clients are closed afterwards.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# 10 Server protocol
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
A host that is not a Node program embeds the harness as a child process and talks to it over
|
|
6
|
+
newline-delimited JSON on stdin and stdout. The protocol exposes the same in-process API a Node
|
|
7
|
+
application uses, run events as they are saved, state-change notices, and calls from the harness
|
|
8
|
+
to the host for the extension points the host supplies.
|
|
9
|
+
|
|
10
|
+
## Components
|
|
11
|
+
|
|
12
|
+
| Type / function | Module | Role |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| `RpcPeer`, `Transport`, `stdioTransport`, `PROTOCOL_VERSION` | `server/rpc.ts` | Framing, requests, replies, host calls. |
|
|
15
|
+
| `methods(harness)` | `server/methods.ts` | The method table. |
|
|
16
|
+
| `serve`, `attach` | `server/serve.ts` | Registers the table, forwards events and notices. |
|
|
17
|
+
| `remoteSecrets`, remote policy, directory, tools | `server/remote.ts` | Extension points supplied by the host over the protocol. |
|
|
18
|
+
| CLI `serve` | `src/cli.ts` | `serve --state <dir> --data <dir> --name <product> [--builtins <dir>] [--host-secrets] [--host-policy] [--host-tools] [--host-directory]`. |
|
|
19
|
+
|
|
20
|
+
## Contracts
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
host → harness { v: 1, id, method, params } harness → host { v: 1, id, result | error }
|
|
24
|
+
harness → host { v: 1, event } a run event, validated, after it is saved
|
|
25
|
+
harness → host { v: 1, notice } state changed: read it again
|
|
26
|
+
harness → host { v: 1, id, call, params } host → harness { v: 1, id, result | error }
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- stdout carries only protocol lines; diagnostics go to stderr.
|
|
30
|
+
- `harness.methods` lists every method. Groups in the table: `accounts`, `harnesses`, `runs`,
|
|
31
|
+
`connections`, `plugins`, `wiki`, `refine`, `capabilities`, `hub`, `terminal`, `approvals`,
|
|
32
|
+
`harness`, `subagents`, `sessions`, `library`, `recall`, `context`.
|
|
33
|
+
- Host calls (only with the matching `--host-*` flag): `secrets.get|set|delete`,
|
|
34
|
+
`policy.scope|authorize|approval|connections`, `tools.call`. The host registers tools with
|
|
35
|
+
`tools.register` and names with `directory.set`, and describes its parts with
|
|
36
|
+
`plugins.describe`.
|
|
37
|
+
- `refine.start` takes `{ task, k?, mode?, improver?, executor?, baseVersion?, retainWorkspaces?, id? }`;
|
|
38
|
+
`refine.candidates` returns each execution with `workspace: string | null` (page 05, PROP-0002, PROP-0003).
|
|
39
|
+
- `runs.checklist { runId }` returns the run's latest checklist, `[]` when it wrote none (PROP-0006).
|
|
40
|
+
- `runs.continuation { runId, sessionDir? }` returns a `Continuation`, and `sessions.run` accepts
|
|
41
|
+
`continueFrom` (page 02, PROP-0007). `harness.status` reports `recovery.interruptedRunIds`.
|
|
42
|
+
- Errors carry a stable `code`, a message and an optional hint (`core/errors.ts`).
|
|
43
|
+
|
|
44
|
+
## Invariants
|
|
45
|
+
|
|
46
|
+
- **INV-SRV-1** `src/server/methods.ts` is the contract for every non-Node host. Adding a method
|
|
47
|
+
to an existing group is an additive change (update this page). Renaming, removing, or changing
|
|
48
|
+
the params or result shape of a method is an architecture change.
|
|
49
|
+
- **INV-SRV-2** A method handler calls the same in-process API a Node application uses. The server
|
|
50
|
+
holds no logic of its own beyond parameter checking.
|
|
51
|
+
- **INV-SRV-3** Events reach the host only after they are persisted and redacted (`INV-RUN-3`).
|
|
52
|
+
- **INV-SRV-4** Changing the framing or `PROTOCOL_VERSION` is an architecture change.
|
|
53
|
+
- **INV-SRV-5** The harness works with none of the host calls supplied (`INV-EXT-2`).
|
|
54
|
+
- **INV-SRV-6** After a change to the server, the CLI or startup, `npm run prove` must pass: it
|
|
55
|
+
starts the server on a throwaway data root with no application present and exercises accounts,
|
|
56
|
+
variants, the Wiki, the prompt, connected apps, a recorded session, a plugin hook and the
|
|
57
|
+
refinement demo. The App's sidecar tests parse every reply with its schemas and must pass too.
|
|
58
|
+
|
|
59
|
+
## Source map
|
|
60
|
+
|
|
61
|
+
`src/server/*.ts`, `src/cli.ts`, `src/core/errors.ts`, `scripts/prove-standalone.mjs`.
|
|
62
|
+
|
|
63
|
+
## Doctor jobs (PROP-0011)
|
|
64
|
+
|
|
65
|
+
| Method | Input | Reply |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `doctor.start` | `{ context: { caller, cwd, accountId, model, tools, variant?, capabilities? }, mode?: "local" \| "live", checks?: string[], confirmed?: boolean }` | `DoctorReport` |
|
|
68
|
+
| `doctor.read` | `{ id }` | `DoctorReport` |
|
|
69
|
+
| `doctor.cancel` | `{ id }` | `DoctorReport` |
|
|
70
|
+
|
|
71
|
+
A trusted host attests confirmation for the exact selected live checks. Live mode requires both
|
|
72
|
+
`confirmed: true` and non-empty `checks`. Terminal equivalents are `terminal.doctor.*`; every call
|
|
73
|
+
requires the control key and each job belongs to its originating terminal. The terminal supplies
|
|
74
|
+
its account and pinned variant; the controlled frontend supplies its current model and tool list.
|
|
75
|
+
|
|
76
|
+
Reports carry job state (`running`, `completed`, `cancelled`), progress, timestamps, selected
|
|
77
|
+
account/model, findings, and available live-check notices. Findings distinguish `local` from
|
|
78
|
+
`live` and statuses `pass`, `warning`, `fail`, `disabled`, `blocked`, `unverified`. Schemas and
|
|
79
|
+
Node types are exported. Jobs are in-memory until shutdown; real live-run records remain.
|
|
80
|
+
|
|
81
|
+
Remote `tools.register` may include `diagnostics: [{ id, category, title, tools, probe?: { notice,
|
|
82
|
+
tool, input, contains } }]`. The host answers `tools.diagnose({ id, context })` with `{ status,
|
|
83
|
+
evidence, remedy? }` for local inspection. A probe is a declared registered tool call through
|
|
84
|
+
the gate, with an expected response marker; it cannot supply arbitrary executable code.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# 11 Terminal
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
The harness owns a generic interactive terminal application (`xharness`) over a
|
|
6
|
+
persistent Pi session on a variant. It is the standalone way to use the harness, and an
|
|
7
|
+
embedding application can host it in its own PTY. Detail, screen layout and verification evidence
|
|
8
|
+
are in [`../terminal-tui.md`](../terminal-tui.md); this page states the binding parts.
|
|
9
|
+
|
|
10
|
+
## Components
|
|
11
|
+
|
|
12
|
+
| Type / module | Role |
|
|
13
|
+
|---|---|
|
|
14
|
+
| `Terminals` (`terminal/terminals.ts`) | Parent side: `prepare` (account, compiled context, trusted resources, run writer) returns a launch specification; `send`, `state`, `input`, `dispose`. |
|
|
15
|
+
| `src/terminal/opentui/` (`app.ts`, `root.tsx`) | The OpenTUI/Solid frontend: lifecycle, submission, commands, decisions, composition, transcript, composer, dialogs. |
|
|
16
|
+
| `src/terminal/opentui/attachments.ts`, `composerMarks.ts` | Composer attachments: pasted images and collapsed large pastes, their atomic labels, and expansion into the prompt text and Pi image content on send. |
|
|
17
|
+
| `src/terminal/tui/runtime.ts` | `AgentSessionRuntime` over `createAgentSession`, `ModelRuntime`, `SessionManager`, `DefaultResourceLoader`. |
|
|
18
|
+
| `src/terminal/socket.ts`, `client.ts`, `control.ts`, `controller.ts` | The session socket, the private control key, and the run controller. |
|
|
19
|
+
| `src/terminal/piExtension.ts` | The bridge extension, loaded last as the trusted inline gate. |
|
|
20
|
+
| `src/terminal/cli.ts` | Wiki and connected-apps commands for the session's shell. |
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
Harness parent: account + compiled context + trusted resources + run writer
|
|
24
|
+
| launch specification / session socket
|
|
25
|
+
Harness terminal child (Bun): OpenTUI application + persistent Pi AgentSessionRuntime
|
|
26
|
+
| typed native events / plugin UI callbacks
|
|
27
|
+
Screen: transcript above the composer, centred page dialogs
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Contracts
|
|
31
|
+
|
|
32
|
+
- The published executable is `xharness`; with no command it starts the interactive terminal. `terminal` remains an explicit alias, and `serve` remains the host-facing RPC path.
|
|
33
|
+
- `TerminalAssets` is `{ node, cli, piExtension, openTui }`. The command is Bun with
|
|
34
|
+
`--conditions=browser` and `dist/terminal-opentui.js`; no global `pi` is needed.
|
|
35
|
+
- The `piExtension` path is the final prepared extension argument; the runtime loads it as the
|
|
36
|
+
final trusted inline factory.
|
|
37
|
+
- The terminal compiles its prompt once (`compile` + `render`) and keeps that pack; each run
|
|
38
|
+
records a copy (page 04).
|
|
39
|
+
- Standalone defaults: `~/.xingular-harness/{data,state}`; `npm run dev` uses
|
|
40
|
+
`~/.xingular-harness-dev/{data,state}`.
|
|
41
|
+
|
|
42
|
+
## Invariants
|
|
43
|
+
|
|
44
|
+
- **INV-TUI-1** OpenTUI is the only terminal frontend. Pi's `InteractiveMode` is never constructed
|
|
45
|
+
([ADR-0006](../decisions/ADR-0006-opentui-only-terminal.md)).
|
|
46
|
+
- **INV-TUI-2** The harness owns screen composition, input, scrolling, command routing and plugin
|
|
47
|
+
UI. Pi owns the execution runtime, native history and rich content components. A host owns the
|
|
48
|
+
PTY and process supervision ([ADR-0001](../decisions/ADR-0001-owned-terminal.md)).
|
|
49
|
+
- **INV-TUI-3** Execution, account isolation, trust, authorization and run recording stay behind
|
|
50
|
+
their existing layers. The terminal adds no second path for any of them; its runs are written
|
|
51
|
+
through the controller and the run store.
|
|
52
|
+
- **INV-TUI-4** Changes made through the session socket (`plugins.attach|detach|trust|untrust|configure`,
|
|
53
|
+
`accounts.*`, Hub installs) require the control key the trusted terminal process claimed once
|
|
54
|
+
(`control.claim`). The session's shell can read the session token, so the token alone is never
|
|
55
|
+
enough.
|
|
56
|
+
- **INV-TUI-5** Every resource reload revalidates the original trusted selection; changed or
|
|
57
|
+
revoked code needs review and a fresh terminal.
|
|
58
|
+
- **INV-TUI-6** `sessions.run` stays the embedding and unattended path. The terminal keeps a
|
|
59
|
+
persistent child instead of opening a session per turn.
|
|
60
|
+
|
|
61
|
+
## Source map
|
|
62
|
+
|
|
63
|
+
`src/terminal/**`. Decisions: ADR-0001, [ADR-0004](../decisions/ADR-0004-fullscreen-terminal-layout.md)
|
|
64
|
+
(superseded), ADR-0006. Experiments: EXP-0001, EXP-0002 in `../experiments/`.
|
|
65
|
+
|
|
66
|
+
## Session name in the working line (PROP-0010)
|
|
67
|
+
|
|
68
|
+
The bridge registers `session_name` against Pi's `getSessionName` / `setSessionName` APIs.
|
|
69
|
+
The native `session_info_changed` event invalidates the frontend's cached snapshot and
|
|
70
|
+
refreshes the working line. Both the active and retained completion line append
|
|
71
|
+
` – <name>` after duration and token rate, for example
|
|
72
|
+
`Working (2m, 50 tok/s) – Add web browser integrations`. Unnamed sessions omit the suffix.
|
|
73
|
+
Names use the existing terminal text sanitization, remain outside the verb shimmer, and
|
|
74
|
+
truncate at the right edge. Manual `/name` and existing long names remain supported.
|
|
75
|
+
|
|
76
|
+
## Doctor command
|
|
77
|
+
|
|
78
|
+
`/doctor` opens a command page and runs local readiness checks. Refresh and retry are local;
|
|
79
|
+
Live checks opens an explicit selection followed by account/model, destination, cost and isolation
|
|
80
|
+
confirmation. The page polls structured reports, retains findings after cancellation, and cancels
|
|
81
|
+
on close. No command text is sent to the conversation model. See [Doctor](../doctor.md).
|