@ouro.bot/cli 0.1.0-alpha.1469 → 0.1.0-alpha.1470
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/README.md +1 -1
- package/changelog.json +6 -2
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/desk.lock.json +8 -0
- package/dist/heart/identity.js +27 -1
- package/dist/mind/desk-section.js +33 -43
- package/dist/repertoire/desk-mcp.js +140 -0
- package/dist/repertoire/mcp-manager.js +22 -0
- package/dist/repertoire/mcp-tools.js +11 -7
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -1
- package/vendor/desk/.claude-plugin/plugin.json +35 -0
- package/vendor/desk/.mcp.claude-codex.json +28 -0
- package/vendor/desk/.mcp.copilot.json +16 -0
- package/vendor/desk/.ouro-desk.json +6 -0
- package/vendor/desk/CHANGELOG.md +7004 -0
- package/vendor/desk/README.md +195 -0
- package/vendor/desk/activation/README.md +98 -0
- package/vendor/desk/activation/copilot-root.flattened-bundle.json +38 -0
- package/vendor/desk/activation/desk.activation.json +251 -0
- package/vendor/desk/activation/host-capability-evidence.md +46 -0
- package/vendor/desk/activation/support-matrix.json +84 -0
- package/vendor/desk/agency.json +20 -0
- package/vendor/desk/agents/observer.agent.md +26 -0
- package/vendor/desk/agents/observer.md +29 -0
- package/vendor/desk/agents/worker.agent.md +32 -0
- package/vendor/desk/agents/worker.md +40 -0
- package/vendor/desk/artifacts/tombstones/tombstone.schema.json +53 -0
- package/vendor/desk/artifacts/tombstones/tombstones.jsonl +1 -0
- package/vendor/desk/changelog.d/README.md +12 -0
- package/vendor/desk/docs/agent-files.md +104 -0
- package/vendor/desk/docs/agentic-engineering-v2-rfc.md +206 -0
- package/vendor/desk/docs/agentic-engineering-v3-rfc.md +109 -0
- package/vendor/desk/docs/browser-remote-desktops.md +69 -0
- package/vendor/desk/docs/dependency-activation-stories-and-criteria.md +500 -0
- package/vendor/desk/docs/evaluation-packet.md +363 -0
- package/vendor/desk/docs/factory-local-capture.md +651 -0
- package/vendor/desk/docs/factory-store-playbook.md +927 -0
- package/vendor/desk/docs/images/factory-site.png +0 -0
- package/vendor/desk/docs/issue-drains.md +79 -0
- package/vendor/desk/docs/lfs-inspection.md +55 -0
- package/vendor/desk/docs/preview-diagnostics.md +11 -0
- package/vendor/desk/docs/relays.md +88 -0
- package/vendor/desk/docs/schedules.md +69 -0
- package/vendor/desk/docs/search-recovery.md +22 -0
- package/vendor/desk/docs/session-labels.md +157 -0
- package/vendor/desk/docs/session-retention.md +125 -0
- package/vendor/desk/docs/sessions.md +17 -0
- package/vendor/desk/docs/stalled-nudges.md +54 -0
- package/vendor/desk/docs/webhooks.md +80 -0
- package/vendor/desk/docs/workspace-tidy.md +74 -0
- package/vendor/desk/hooks/boot-checks.cjs +7 -0
- package/vendor/desk/hooks/claude-session-start.cjs +123 -0
- package/vendor/desk/hooks/compatible-node.cjs +97 -0
- package/vendor/desk/hooks/copilot-boot-prompt.cjs +69 -0
- package/vendor/desk/hooks/copilot-durable-files.cjs +8 -0
- package/vendor/desk/hooks/copilot-hooks.json +61 -0
- package/vendor/desk/hooks/copilot-intake-context.cjs +5 -0
- package/vendor/desk/hooks/copilot-lane-model.cjs +8 -0
- package/vendor/desk/hooks/copilot-session-start.cjs +264 -0
- package/vendor/desk/hooks/copilot-skill-current.cjs +28 -0
- package/vendor/desk/hooks/factory-end.cjs +5 -0
- package/vendor/desk/hooks/factory-start.cjs +27 -0
- package/vendor/desk/hooks/hooks.json +40 -0
- package/vendor/desk/hooks/lib/boot-checks.cjs +643 -0
- package/vendor/desk/hooks/lib/child-agent.cjs +14 -0
- package/vendor/desk/hooks/lib/copilot-intake-context.cjs +73 -0
- package/vendor/desk/hooks/lib/current-release.cjs +162 -0
- package/vendor/desk/hooks/lib/delivery-stop.cjs +326 -0
- package/vendor/desk/hooks/lib/detach-worker.cjs +43 -0
- package/vendor/desk/hooks/lib/durable-files.cjs +102 -0
- package/vendor/desk/hooks/lib/factory-end.cjs +327 -0
- package/vendor/desk/hooks/lib/lane-model.cjs +82 -0
- package/vendor/desk/hooks/lib/node-required.cjs +56 -0
- package/vendor/desk/hooks/lib/orca-session-title.cjs +60 -0
- package/vendor/desk/hooks/lib/session-end.cjs +30 -0
- package/vendor/desk/hooks/lib/sync-end.cjs +89 -0
- package/vendor/desk/hooks/loop-start.cjs +105 -0
- package/vendor/desk/hooks/node-missing.sh +78 -0
- package/vendor/desk/hooks/orca-session-title.cjs +8 -0
- package/vendor/desk/hooks/session-end.cjs +8 -0
- package/vendor/desk/mcp/README.md +269 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/support-matrix.json +72 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/README.md +25 -0
- package/vendor/desk/mcp/bootstrap.cjs +761 -0
- package/vendor/desk/mcp/docs/private-feedback.md +13 -0
- package/vendor/desk/mcp/idle-proxy.cjs +423 -0
- package/vendor/desk/mcp/index.js +813 -0
- package/vendor/desk/mcp/package-lock.json +3717 -0
- package/vendor/desk/mcp/package.json +44 -0
- package/vendor/desk/mcp/scripts/agency-desk-channel.js +7 -0
- package/vendor/desk/mcp/scripts/build-runtime-deps-pack.js +5 -0
- package/vendor/desk/mcp/scripts/crew.js +89 -0
- package/vendor/desk/mcp/scripts/drains-launcher.mjs +329 -0
- package/vendor/desk/mcp/scripts/drains.js +5 -0
- package/vendor/desk/mcp/scripts/factory.js +657 -0
- package/vendor/desk/mcp/scripts/file-desk-problem.js +9 -0
- package/vendor/desk/mcp/scripts/finish-commit.js +7 -0
- package/vendor/desk/mcp/scripts/lfs.js +37 -0
- package/vendor/desk/mcp/scripts/local-recovery.js +363 -0
- package/vendor/desk/mcp/scripts/migrations.js +11 -0
- package/vendor/desk/mcp/scripts/private-view.js +177 -0
- package/vendor/desk/mcp/scripts/resolve-desk-root.js +106 -0
- package/vendor/desk/mcp/scripts/session-boot.js +22 -0
- package/vendor/desk/mcp/scripts/session-retention.js +5 -0
- package/vendor/desk/mcp/scripts/session-sync.js +10 -0
- package/vendor/desk/mcp/scripts/sessions.js +5 -0
- package/vendor/desk/mcp/scripts/sync-push.js +13 -0
- package/vendor/desk/mcp/scripts/tidy-status.js +8 -0
- package/vendor/desk/mcp/scripts/verify-runtime-deps-pack.js +5 -0
- package/vendor/desk/mcp/src/actions/desk-read.actions.mts +73 -0
- package/vendor/desk/mcp/src/actions/desk-session.actions.mts +42 -0
- package/vendor/desk/mcp/src/actions/desk-web.actions.mts +52 -0
- package/vendor/desk/mcp/src/actions/desk.actions.mts +5 -0
- package/vendor/desk/mcp/src/actions/generated/desk/OuroActions.swift +649 -0
- package/vendor/desk/mcp/src/actions/generated/desk/OuroActionsReins.swift +61 -0
- package/vendor/desk/mcp/src/actions/generated/desk/actions.json +280 -0
- package/vendor/desk/mcp/src/actions/generated/desk/commands.json +145 -0
- package/vendor/desk/mcp/src/actions/generated/desk/mcp.json +256 -0
- package/vendor/desk/mcp/src/actions/generated/desk/web.ts +59 -0
- package/vendor/desk/mcp/src/actions/generated/desk/webmcp.json +250 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActions.swift +241 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActionsReins.swift +25 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/actions.json +73 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/commands.json +53 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/mcp.json +83 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/web.ts +47 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/webmcp.json +81 -0
- package/vendor/desk/mcp/src/actions/served.js +5 -0
- package/vendor/desk/mcp/src/activation/admit.js +77 -0
- package/vendor/desk/mcp/src/activation/failures.js +65 -0
- package/vendor/desk/mcp/src/activation/readiness-policy.js +102 -0
- package/vendor/desk/mcp/src/activation/schema.js +17 -0
- package/vendor/desk/mcp/src/activation/superpowers-context.js +265 -0
- package/vendor/desk/mcp/src/activation/validate.js +540 -0
- package/vendor/desk/mcp/src/artifacts/tombstones.js +61 -0
- package/vendor/desk/mcp/src/crew/initiative.js +287 -0
- package/vendor/desk/mcp/src/crew/workspace.js +1259 -0
- package/vendor/desk/mcp/src/db/init.js +75 -0
- package/vendor/desk/mcp/src/db/schema.sql +83 -0
- package/vendor/desk/mcp/src/desk/active-tasks.js +408 -0
- package/vendor/desk/mcp/src/desk/card-commit-guard.js +281 -0
- package/vendor/desk/mcp/src/desk/cleanup-index.js +53 -0
- package/vendor/desk/mcp/src/desk/content-home.js +246 -0
- package/vendor/desk/mcp/src/desk/crew-config.js +102 -0
- package/vendor/desk/mcp/src/desk/crew-member.js +196 -0
- package/vendor/desk/mcp/src/desk/crew-roster.js +151 -0
- package/vendor/desk/mcp/src/desk/frontmatter-lite.js +228 -0
- package/vendor/desk/mcp/src/desk/gh-logins.js +109 -0
- package/vendor/desk/mcp/src/desk/handles.js +123 -0
- package/vendor/desk/mcp/src/desk/handoff-reference.js +35 -0
- package/vendor/desk/mcp/src/desk/improvement-authority.js +3 -0
- package/vendor/desk/mcp/src/desk/improvement-cards.js +704 -0
- package/vendor/desk/mcp/src/desk/improvement-person.js +51 -0
- package/vendor/desk/mcp/src/desk/lifecycle.js +16 -0
- package/vendor/desk/mcp/src/desk/machine-desks.js +119 -0
- package/vendor/desk/mcp/src/desk/naming.js +333 -0
- package/vendor/desk/mcp/src/desk/organization.js +592 -0
- package/vendor/desk/mcp/src/desk/resources.js +274 -0
- package/vendor/desk/mcp/src/desk/runtime-resolver.js +30 -0
- package/vendor/desk/mcp/src/desk/scratch-paths.js +44 -0
- package/vendor/desk/mcp/src/desk/step-delivery.js +140 -0
- package/vendor/desk/mcp/src/desk/steps.js +263 -0
- package/vendor/desk/mcp/src/desk/tidy.js +930 -0
- package/vendor/desk/mcp/src/desk/unsigned-deliveries.js +359 -0
- package/vendor/desk/mcp/src/factory/agent-types.js +45 -0
- package/vendor/desk/mcp/src/factory/andon-watch.js +109 -0
- package/vendor/desk/mcp/src/factory/binding.js +612 -0
- package/vendor/desk/mcp/src/factory/boot-check.js +645 -0
- package/vendor/desk/mcp/src/factory/capture-classify.js +158 -0
- package/vendor/desk/mcp/src/factory/capture-count.js +183 -0
- package/vendor/desk/mcp/src/factory/capture-flush.js +268 -0
- package/vendor/desk/mcp/src/factory/capture-publish.js +141 -0
- package/vendor/desk/mcp/src/factory/capture-schema.js +193 -0
- package/vendor/desk/mcp/src/factory/capture-sweep.js +239 -0
- package/vendor/desk/mcp/src/factory/catch-point.js +60 -0
- package/vendor/desk/mcp/src/factory/commit-resolve.js +94 -0
- package/vendor/desk/mcp/src/factory/consent-answer.js +37 -0
- package/vendor/desk/mcp/src/factory/context-capability.js +15 -0
- package/vendor/desk/mcp/src/factory/context-outbox.js +885 -0
- package/vendor/desk/mcp/src/factory/context-run.js +386 -0
- package/vendor/desk/mcp/src/factory/context-schema.js +249 -0
- package/vendor/desk/mcp/src/factory/copilot-turn-index.js +93 -0
- package/vendor/desk/mcp/src/factory/copilot-usage.js +148 -0
- package/vendor/desk/mcp/src/factory/credential.js +45 -0
- package/vendor/desk/mcp/src/factory/derive-claude.js +960 -0
- package/vendor/desk/mcp/src/factory/derive-codex.js +734 -0
- package/vendor/desk/mcp/src/factory/derive-common.js +279 -0
- package/vendor/desk/mcp/src/factory/derive-copilot.js +1057 -0
- package/vendor/desk/mcp/src/factory/derive-run.js +807 -0
- package/vendor/desk/mcp/src/factory/desk-problem-file.js +310 -0
- package/vendor/desk/mcp/src/factory/desk-problem-fingerprint.js +70 -0
- package/vendor/desk/mcp/src/factory/desk-problem-known.js +246 -0
- package/vendor/desk/mcp/src/factory/desk-problem-template.js +107 -0
- package/vendor/desk/mcp/src/factory/desk-repo.js +1223 -0
- package/vendor/desk/mcp/src/factory/desk-task-line.js +28 -0
- package/vendor/desk/mcp/src/factory/desk-visibility.js +48 -0
- package/vendor/desk/mcp/src/factory/end-hook.js +14 -0
- package/vendor/desk/mcp/src/factory/evaluate-kick.js +164 -0
- package/vendor/desk/mcp/src/factory/evaluate-run.js +678 -0
- package/vendor/desk/mcp/src/factory/evaluator-step.js +484 -0
- package/vendor/desk/mcp/src/factory/filer-launch.js +79 -0
- package/vendor/desk/mcp/src/factory/flush-health.js +26 -0
- package/vendor/desk/mcp/src/factory/flush.js +1758 -0
- package/vendor/desk/mcp/src/factory/focus.js +326 -0
- package/vendor/desk/mcp/src/factory/headless-flag.cjs +32 -0
- package/vendor/desk/mcp/src/factory/headless-flag.js +25 -0
- package/vendor/desk/mcp/src/factory/headless-ledger.js +743 -0
- package/vendor/desk/mcp/src/factory/headless.js +567 -0
- package/vendor/desk/mcp/src/factory/held-route.js +93 -0
- package/vendor/desk/mcp/src/factory/host-flags.js +36 -0
- package/vendor/desk/mcp/src/factory/improvement-verify.js +429 -0
- package/vendor/desk/mcp/src/factory/kaizen-file.js +231 -0
- package/vendor/desk/mcp/src/factory/label-binding.js +90 -0
- package/vendor/desk/mcp/src/factory/label-schema.js +426 -0
- package/vendor/desk/mcp/src/factory/local-status.js +368 -0
- package/vendor/desk/mcp/src/factory/loop-conditions.js +121 -0
- package/vendor/desk/mcp/src/factory/loop-health.js +500 -0
- package/vendor/desk/mcp/src/factory/loop-slot.js +90 -0
- package/vendor/desk/mcp/src/factory/loop-status.js +100 -0
- package/vendor/desk/mcp/src/factory/loop-switch.cjs +14 -0
- package/vendor/desk/mcp/src/factory/loop-worker-state.js +96 -0
- package/vendor/desk/mcp/src/factory/loop-worker.js +290 -0
- package/vendor/desk/mcp/src/factory/marker.js +61 -0
- package/vendor/desk/mcp/src/factory/mirror-step.js +145 -0
- package/vendor/desk/mcp/src/factory/os-protect.js +243 -0
- package/vendor/desk/mcp/src/factory/outbox.js +2231 -0
- package/vendor/desk/mcp/src/factory/outcome.js +431 -0
- package/vendor/desk/mcp/src/factory/pipeline/andon.js +319 -0
- package/vendor/desk/mcp/src/factory/pipeline/attention-rollup.js +158 -0
- package/vendor/desk/mcp/src/factory/pipeline/attention.js +146 -0
- package/vendor/desk/mcp/src/factory/pipeline/build.js +299 -0
- package/vendor/desk/mcp/src/factory/pipeline/compare.js +148 -0
- package/vendor/desk/mcp/src/factory/pipeline/formulas.js +652 -0
- package/vendor/desk/mcp/src/factory/pipeline/kaizen.js +387 -0
- package/vendor/desk/mcp/src/factory/pipeline/lifecycle-clocks.js +345 -0
- package/vendor/desk/mcp/src/factory/pipeline/normalize.js +73 -0
- package/vendor/desk/mcp/src/factory/pipeline/number-states.js +154 -0
- package/vendor/desk/mcp/src/factory/pipeline/outcomes.js +268 -0
- package/vendor/desk/mcp/src/factory/pipeline/report.js +737 -0
- package/vendor/desk/mcp/src/factory/pipeline/rollups.js +883 -0
- package/vendor/desk/mcp/src/factory/pipeline/stretches.js +523 -0
- package/vendor/desk/mcp/src/factory/pipeline/timeline.js +199 -0
- package/vendor/desk/mcp/src/factory/pipeline/validate-pr.js +238 -0
- package/vendor/desk/mcp/src/factory/pipeline/versions.js +42 -0
- package/vendor/desk/mcp/src/factory/pipeline/walk.js +1177 -0
- package/vendor/desk/mcp/src/factory/plugin-registry.js +72 -0
- package/vendor/desk/mcp/src/factory/plugin-sources.cjs +249 -0
- package/vendor/desk/mcp/src/factory/pr-green.js +77 -0
- package/vendor/desk/mcp/src/factory/process-lock.js +142 -0
- package/vendor/desk/mcp/src/factory/proof-session.js +75 -0
- package/vendor/desk/mcp/src/factory/publish.js +637 -0
- package/vendor/desk/mcp/src/factory/published-schema.js +648 -0
- package/vendor/desk/mcp/src/factory/reconcile-reasons.js +22 -0
- package/vendor/desk/mcp/src/factory/reconcile-step.js +251 -0
- package/vendor/desk/mcp/src/factory/reconcile.js +808 -0
- package/vendor/desk/mcp/src/factory/release-version.js +134 -0
- package/vendor/desk/mcp/src/factory/repo-name.js +13 -0
- package/vendor/desk/mcp/src/factory/retention.js +60 -0
- package/vendor/desk/mcp/src/factory/route-desk.js +40 -0
- package/vendor/desk/mcp/src/factory/route-issues.js +251 -0
- package/vendor/desk/mcp/src/factory/route-local.js +264 -0
- package/vendor/desk/mcp/src/factory/schema.js +957 -0
- package/vendor/desk/mcp/src/factory/session-kind.js +16 -0
- package/vendor/desk/mcp/src/factory/session-lifetime.js +56 -0
- package/vendor/desk/mcp/src/factory/session-route.js +183 -0
- package/vendor/desk/mcp/src/factory/shell-git.js +500 -0
- package/vendor/desk/mcp/src/factory/store-issues.js +143 -0
- package/vendor/desk/mcp/src/factory/store-route.js +208 -0
- package/vendor/desk/mcp/src/factory/test-state-guard.js +103 -0
- package/vendor/desk/mcp/src/factory/time.js +36 -0
- package/vendor/desk/mcp/src/factory/tool-issue-file.js +84 -0
- package/vendor/desk/mcp/src/factory/tool-kinds.js +87 -0
- package/vendor/desk/mcp/src/factory/triage-schema.js +233 -0
- package/vendor/desk/mcp/src/factory/windows-acl.js +679 -0
- package/vendor/desk/mcp/src/indexer/chunk.js +232 -0
- package/vendor/desk/mcp/src/indexer/discover.js +434 -0
- package/vendor/desk/mcp/src/indexer/exclusions.js +247 -0
- package/vendor/desk/mcp/src/indexer/index.js +167 -0
- package/vendor/desk/mcp/src/indexer/refs.js +0 -0
- package/vendor/desk/mcp/src/indexer/text-hash.js +18 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/actions.claims.json +75 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/dist-manifest.json +70 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/ouro-actions.mts +1416 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/LICENSE +21 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-claims.ts +190 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-command.ts +1020 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/checks.ts +343 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/cli.ts +240 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/component.ts +430 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/dev-commands.ts +204 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/doctor.ts +126 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/effects.ts +68 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/exit-codes.ts +75 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/help.ts +220 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/mcp.ts +268 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/outcome.ts +265 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/output.ts +67 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/precise-copy.ts +235 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/problem.ts +124 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.kit.mts +8 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.ts +568 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/terminal.ts +245 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/voice.ts +136 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/wait.ts +226 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/work-event.ts +181 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.kit.mts +18 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.ts +2072 -0
- package/vendor/desk/mcp/src/package-metadata.js +20 -0
- package/vendor/desk/mcp/src/protected/legacy-ledger.js +55 -0
- package/vendor/desk/mcp/src/readiness/leftovers.js +75 -0
- package/vendor/desk/mcp/src/readiness/process-start.js +149 -0
- package/vendor/desk/mcp/src/runtime/admission-worker.js +194 -0
- package/vendor/desk/mcp/src/runtime/admission.js +177 -0
- package/vendor/desk/mcp/src/runtime/agency-desk-channel.js +342 -0
- package/vendor/desk/mcp/src/runtime/agents-md.js +62 -0
- package/vendor/desk/mcp/src/runtime/append-lane.js +68 -0
- package/vendor/desk/mcp/src/runtime/argv-safe-reason.js +55 -0
- package/vendor/desk/mcp/src/runtime/boot-dependencies.js +75 -0
- package/vendor/desk/mcp/src/runtime/boot-text.js +504 -0
- package/vendor/desk/mcp/src/runtime/boot.js +1677 -0
- package/vendor/desk/mcp/src/runtime/bootstrap.js +1455 -0
- package/vendor/desk/mcp/src/runtime/chunked-import.js +102 -0
- package/vendor/desk/mcp/src/runtime/copilot-commit-trailer.js +133 -0
- package/vendor/desk/mcp/src/runtime/copilot-session.js +155 -0
- package/vendor/desk/mcp/src/runtime/deliver.js +469 -0
- package/vendor/desk/mcp/src/runtime/desk-channel.js +86 -0
- package/vendor/desk/mcp/src/runtime/desk-failure.js +26 -0
- package/vendor/desk/mcp/src/runtime/desk-health.js +168 -0
- package/vendor/desk/mcp/src/runtime/desk-session.js +1451 -0
- package/vendor/desk/mcp/src/runtime/diagnostic-server.js +72 -0
- package/vendor/desk/mcp/src/runtime/diagnostics.js +241 -0
- package/vendor/desk/mcp/src/runtime/drains-cli.js +187 -0
- package/vendor/desk/mcp/src/runtime/drains.js +781 -0
- package/vendor/desk/mcp/src/runtime/elsewhere-note.js +9 -0
- package/vendor/desk/mcp/src/runtime/failure-evidence.js +21 -0
- package/vendor/desk/mcp/src/runtime/fast-refs.js +209 -0
- package/vendor/desk/mcp/src/runtime/filer-throttle.js +66 -0
- package/vendor/desk/mcp/src/runtime/focused-card.js +147 -0
- package/vendor/desk/mcp/src/runtime/front-door.js +204 -0
- package/vendor/desk/mcp/src/runtime/gate-wait.js +2 -0
- package/vendor/desk/mcp/src/runtime/git-inspection.js +201 -0
- package/vendor/desk/mcp/src/runtime/git-read-worker.js +157 -0
- package/vendor/desk/mcp/src/runtime/health.js +50 -0
- package/vendor/desk/mcp/src/runtime/hooks.js +353 -0
- package/vendor/desk/mcp/src/runtime/hosted.js +163 -0
- package/vendor/desk/mcp/src/runtime/inbox.js +102 -0
- package/vendor/desk/mcp/src/runtime/index-drift.js +118 -0
- package/vendor/desk/mcp/src/runtime/last-start.js +133 -0
- package/vendor/desk/mcp/src/runtime/lesson-section.js +92 -0
- package/vendor/desk/mcp/src/runtime/lessons-shelf.js +100 -0
- package/vendor/desk/mcp/src/runtime/lfs.js +319 -0
- package/vendor/desk/mcp/src/runtime/native-path.js +12 -0
- package/vendor/desk/mcp/src/runtime/newest-release.js +197 -0
- package/vendor/desk/mcp/src/runtime/node-selection.js +233 -0
- package/vendor/desk/mcp/src/runtime/orca-session-title.js +225 -0
- package/vendor/desk/mcp/src/runtime/other-sessions.js +183 -0
- package/vendor/desk/mcp/src/runtime/pending-migrations.js +653 -0
- package/vendor/desk/mcp/src/runtime/plugin-update.js +215 -0
- package/vendor/desk/mcp/src/runtime/pluginless-runtimes.js +34 -0
- package/vendor/desk/mcp/src/runtime/pr-publication.js +226 -0
- package/vendor/desk/mcp/src/runtime/preview-snapshot.js +23 -0
- package/vendor/desk/mcp/src/runtime/publication-mode.js +19 -0
- package/vendor/desk/mcp/src/runtime/relays.js +974 -0
- package/vendor/desk/mcp/src/runtime/release-alert.js +148 -0
- package/vendor/desk/mcp/src/runtime/remote-identity.js +140 -0
- package/vendor/desk/mcp/src/runtime/resolve-here.js +4 -0
- package/vendor/desk/mcp/src/runtime/runtime-deps-cli.js +65 -0
- package/vendor/desk/mcp/src/runtime/runtime-deps.js +1109 -0
- package/vendor/desk/mcp/src/runtime/runtime-identity.js +22 -0
- package/vendor/desk/mcp/src/runtime/runtime-swap.js +101 -0
- package/vendor/desk/mcp/src/runtime/schedules.js +235 -0
- package/vendor/desk/mcp/src/runtime/session-activity.js +190 -0
- package/vendor/desk/mcp/src/runtime/session-label.js +30 -0
- package/vendor/desk/mcp/src/runtime/session-retention.js +662 -0
- package/vendor/desk/mcp/src/runtime/session-sync.js +333 -0
- package/vendor/desk/mcp/src/runtime/session-trailer.js +126 -0
- package/vendor/desk/mcp/src/runtime/sessions-cli.js +301 -0
- package/vendor/desk/mcp/src/runtime/signoff-listed.js +81 -0
- package/vendor/desk/mcp/src/runtime/skills.js +76 -0
- package/vendor/desk/mcp/src/runtime/stale-card-lead.js +52 -0
- package/vendor/desk/mcp/src/runtime/stale-desk-refresh.js +198 -0
- package/vendor/desk/mcp/src/runtime/stale-desk.js +219 -0
- package/vendor/desk/mcp/src/runtime/stalled.js +255 -0
- package/vendor/desk/mcp/src/runtime/standing-authority.js +79 -0
- package/vendor/desk/mcp/src/runtime/startup-boot.js +341 -0
- package/vendor/desk/mcp/src/runtime/startup-resolve.js +140 -0
- package/vendor/desk/mcp/src/runtime/state-branch.js +203 -0
- package/vendor/desk/mcp/src/runtime/status-compact.js +165 -0
- package/vendor/desk/mcp/src/runtime/status-inspection-child.js +26 -0
- package/vendor/desk/mcp/src/runtime/status-inspection.js +147 -0
- package/vendor/desk/mcp/src/runtime/status-root.js +39 -0
- package/vendor/desk/mcp/src/runtime/sync-worker.js +911 -0
- package/vendor/desk/mcp/src/runtime/test-state-guard.js +107 -0
- package/vendor/desk/mcp/src/runtime/unmerged-saves.js +247 -0
- package/vendor/desk/mcp/src/runtime/workspace-claim.js +53 -0
- package/vendor/desk/mcp/src/runtime/workspace-evidence.js +96 -0
- package/vendor/desk/mcp/src/runtime/workspace-tidy.js +509 -0
- package/vendor/desk/mcp/src/search/direct-lexical.js +54 -0
- package/vendor/desk/mcp/src/search/embedder.js +108 -0
- package/vendor/desk/mcp/src/search/engine.js +406 -0
- package/vendor/desk/mcp/src/search/files-router.js +22 -0
- package/vendor/desk/mcp/src/search/old-index.js +46 -0
- package/vendor/desk/mcp/src/search/vectors.js +60 -0
- package/vendor/desk/mcp/src/server.js +389 -0
- package/vendor/desk/mcp/src/tool-names.js +73 -0
- package/vendor/desk/mcp/src/tool-refusal.cjs +35 -0
- package/vendor/desk/mcp/src/tool-schema-parts.js +12 -0
- package/vendor/desk/mcp/src/tool-schemas.js +325 -0
- package/vendor/desk/mcp/src/tools/_card-commit.js +148 -0
- package/vendor/desk/mcp/src/tools/archive-links.js +185 -0
- package/vendor/desk/mcp/src/tools/archive-move.js +18 -0
- package/vendor/desk/mcp/src/tools/archive-native-session.js +728 -0
- package/vendor/desk/mcp/src/tools/archive-state.js +513 -0
- package/vendor/desk/mcp/src/tools/delivery-gate.js +251 -0
- package/vendor/desk/mcp/src/tools/desk-save.js +444 -0
- package/vendor/desk/mcp/src/tools/doctor.js +122 -0
- package/vendor/desk/mcp/src/tools/done-evidence.js +260 -0
- package/vendor/desk/mcp/src/tools/factory-context.js +204 -0
- package/vendor/desk/mcp/src/tools/friction.js +332 -0
- package/vendor/desk/mcp/src/tools/improvement.js +156 -0
- package/vendor/desk/mcp/src/tools/lesson-lines.js +22 -0
- package/vendor/desk/mcp/src/tools/lesson-owners.js +137 -0
- package/vendor/desk/mcp/src/tools/lesson-team.js +169 -0
- package/vendor/desk/mcp/src/tools/lesson.js +254 -0
- package/vendor/desk/mcp/src/tools/local-only.js +151 -0
- package/vendor/desk/mcp/src/tools/move.js +794 -0
- package/vendor/desk/mcp/src/tools/native-stage-context.js +32 -0
- package/vendor/desk/mcp/src/tools/note.js +267 -0
- package/vendor/desk/mcp/src/tools/search.js +634 -0
- package/vendor/desk/mcp/src/tools/shared-write.js +196 -0
- package/vendor/desk/mcp/src/tools/sibling-desk.js +37 -0
- package/vendor/desk/mcp/src/tools/status.js +233 -0
- package/vendor/desk/mcp/src/tools/task-archive-due.js +9 -0
- package/vendor/desk/mcp/src/tools/task-archived-resource.js +53 -0
- package/vendor/desk/mcp/src/tools/task-body.js +141 -0
- package/vendor/desk/mcp/src/tools/task-focus.js +164 -0
- package/vendor/desk/mcp/src/tools/task-log.js +76 -0
- package/vendor/desk/mcp/src/tools/task-signoff.js +155 -0
- package/vendor/desk/mcp/src/tools/task.js +1768 -0
- package/vendor/desk/mcp/src/tools/track-row.js +89 -0
- package/vendor/desk/mcp/src/tools/track.js +240 -0
- package/vendor/desk/mcp/src/util/agency-session.cjs +29 -0
- package/vendor/desk/mcp/src/util/archive-links.js +105 -0
- package/vendor/desk/mcp/src/util/bash.js +36 -0
- package/vendor/desk/mcp/src/util/capture-record.js +73 -0
- package/vendor/desk/mcp/src/util/cas-commit.js +252 -0
- package/vendor/desk/mcp/src/util/created-dirs.js +71 -0
- package/vendor/desk/mcp/src/util/deferred-tools.js +51 -0
- package/vendor/desk/mcp/src/util/desk-owner.js +99 -0
- package/vendor/desk/mcp/src/util/env-value.js +13 -0
- package/vendor/desk/mcp/src/util/file-identity.js +40 -0
- package/vendor/desk/mcp/src/util/finish-commit.js +145 -0
- package/vendor/desk/mcp/src/util/fm.js +410 -0
- package/vendor/desk/mcp/src/util/git-config-file.js +85 -0
- package/vendor/desk/mcp/src/util/git-stage.js +440 -0
- package/vendor/desk/mcp/src/util/main-publish.js +240 -0
- package/vendor/desk/mcp/src/util/markdown-links.cjs +555 -0
- package/vendor/desk/mcp/src/util/object-input.js +59 -0
- package/vendor/desk/mcp/src/util/paths.js +647 -0
- package/vendor/desk/mcp/src/util/rank.js +189 -0
- package/vendor/desk/mcp/src/util/redact.js +92 -0
- package/vendor/desk/mcp/src/util/remove-retry.js +35 -0
- package/vendor/desk/mcp/src/util/rename-retry.js +73 -0
- package/vendor/desk/mcp/src/util/route-around.js +265 -0
- package/vendor/desk/mcp/src/util/shell-quote.js +18 -0
- package/vendor/desk/mcp/src/util/startup-direction.js +124 -0
- package/vendor/desk/mcp/src/util/state-ignore.js +33 -0
- package/vendor/desk/mcp/src/util/tool-commits.js +64 -0
- package/vendor/desk/mcp/src/util/unicode-16/LICENSE-MIT.txt +7 -0
- package/vendor/desk/mcp/src/util/unicode-16/README.md +9 -0
- package/vendor/desk/mcp/src/util/unicode-16/letter.cjs +1 -0
- package/vendor/desk/mcp/src/util/unicode-16/mark.cjs +1 -0
- package/vendor/desk/mcp/src/util/unicode-16/number.cjs +1 -0
- package/vendor/desk/mcp/web-auth.cjs +1897 -0
- package/vendor/desk/mcp/web-browser-discovery.cjs +53 -0
- package/vendor/desk/mcp/web-catalog.json +34 -0
- package/vendor/desk/mcp/web-launch.cjs +101 -0
- package/vendor/desk/mcp/web.cjs +1239 -0
- package/vendor/desk/migrations/01-move-to-ourostack-desk.md +188 -0
- package/vendor/desk/migrations/02-tidy-desk.md +87 -0
- package/vendor/desk/migrations/03-desk-release-channel.md +38 -0
- package/vendor/desk/optional/session-label/consumer.mjs +237 -0
- package/vendor/desk/optional/session-label/extension.mjs +32 -0
- package/vendor/desk/plugin.json +54 -0
- package/vendor/desk/settings.json +3 -0
- package/vendor/desk/skills/add-workspace-mcp/SKILL.md +180 -0
- package/vendor/desk/skills/adopt-inflight-work/SKILL.md +212 -0
- package/vendor/desk/skills/archive-workflow/SKILL.md +132 -0
- package/vendor/desk/skills/content-routing/SKILL.md +95 -0
- package/vendor/desk/skills/core-meeting-capture/SKILL.md +47 -0
- package/vendor/desk/skills/core-meeting-capture/references/capture-contract.md +175 -0
- package/vendor/desk/skills/curator/SKILL.md +103 -0
- package/vendor/desk/skills/delightful-decks/SKILL.md +67 -0
- package/vendor/desk/skills/desk-problem/SKILL.md +87 -0
- package/vendor/desk/skills/directory-structure/SKILL.md +169 -0
- package/vendor/desk/skills/doc-review-rigor/SKILL.md +63 -0
- package/vendor/desk/skills/draining-issues/SKILL.md +62 -0
- package/vendor/desk/skills/evaluate-release/SKILL.md +96 -0
- package/vendor/desk/skills/evidence-discipline/SKILL.md +150 -0
- package/vendor/desk/skills/factory-evaluator/SKILL.md +122 -0
- package/vendor/desk/skills/factory-task-context/SKILL.md +116 -0
- package/vendor/desk/skills/factory-work/SKILL.md +16 -0
- package/vendor/desk/skills/fast-honest-ci/SKILL.md +70 -0
- package/vendor/desk/skills/fast-honest-ci/examples.md +49 -0
- package/vendor/desk/skills/first-run-bootstrap/SKILL.md +95 -0
- package/vendor/desk/skills/friction-management/SKILL.md +98 -0
- package/vendor/desk/skills/git-hygiene/SKILL.md +253 -0
- package/vendor/desk/skills/independent-review/SKILL.md +34 -0
- package/vendor/desk/skills/interaction-style/SKILL.md +239 -0
- package/vendor/desk/skills/lesson-capture/SKILL.md +85 -0
- package/vendor/desk/skills/lesson-capture/agents-md-budget.mjs +61 -0
- package/vendor/desk/skills/online-evaluation/SKILL.md +81 -0
- package/vendor/desk/skills/operator-voice-comments/LICENSE-humanize +21 -0
- package/vendor/desk/skills/operator-voice-comments/SKILL.md +90 -0
- package/vendor/desk/skills/operator-voice-comments/human-voice.md +43 -0
- package/vendor/desk/skills/peer-pr-review/SKILL.md +104 -0
- package/vendor/desk/skills/pr-feedback-on-own-pr/SKILL.md +145 -0
- package/vendor/desk/skills/pr-review-interrogation/SKILL.md +121 -0
- package/vendor/desk/skills/pr-reviewer-audit/SKILL.md +68 -0
- package/vendor/desk/skills/pr-reviewer-audit/helpers/audit.py +335 -0
- package/vendor/desk/skills/pr-reviewer-audit/helpers/test_audit.py +486 -0
- package/vendor/desk/skills/pr-self-review/SKILL.md +86 -0
- package/vendor/desk/skills/pr-surface-hygiene/SKILL.md +105 -0
- package/vendor/desk/skills/pr-surface-hygiene/check-visual-proof.cjs +99 -0
- package/vendor/desk/skills/pr-surface-hygiene/repository-setup.md +19 -0
- package/vendor/desk/skills/pr-surface-hygiene/resources/pr-visual-proof.yml +29 -0
- package/vendor/desk/skills/pr-surface-hygiene/resources/pull-request-template.md +5 -0
- package/vendor/desk/skills/preflight-actions/SKILL.md +60 -0
- package/vendor/desk/skills/preview-feedback/SKILL.md +70 -0
- package/vendor/desk/skills/repo-handling/SKILL.md +67 -0
- package/vendor/desk/skills/rnd-lab/SKILL.md +52 -0
- package/vendor/desk/skills/runtime-symptom-investigation/SKILL.md +106 -0
- package/vendor/desk/skills/session-resumption/SKILL.md +126 -0
- package/vendor/desk/skills/session-start/SKILL.md +54 -0
- package/vendor/desk/skills/session-start/details.md +150 -0
- package/vendor/desk/skills/session-start-migrations/README.md +71 -0
- package/vendor/desk/skills/session-start-migrations/SKILL.md +108 -0
- package/vendor/desk/skills/start-task/SKILL.md +88 -0
- package/vendor/desk/skills/task-card-format/SKILL.md +198 -0
- package/vendor/desk/skills/task-lifecycle/SKILL.md +217 -0
- package/vendor/desk/skills/track-card-format/SKILL.md +90 -0
- package/vendor/desk/skills/using-desk/SKILL.md +58 -0
- package/vendor/desk/skills/using-superpowers-with-desk/SKILL.md +156 -0
- package/vendor/desk/skills/work-orchestration/SKILL.md +162 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Copilot preToolUse for the file-writing tools (create, edit, the image tools). The host's session `files/` and `images/` folders
|
|
4
|
+
// vanish with the session and nobody else can find them, so a report, an inventory, a screenshot or a generated image written there is
|
|
5
|
+
// lost to the person and to whoever continues. This never blocks: it allows the call and adds one note naming the focused task's
|
|
6
|
+
// desk folder, or telling the agent to start a task first. Fail-open: any problem leaves the call as it was.
|
|
7
|
+
|
|
8
|
+
const fs = require("node:fs");
|
|
9
|
+
const os = require("node:os");
|
|
10
|
+
const path = require("node:path");
|
|
11
|
+
const { pathToFileURL } = require("node:url");
|
|
12
|
+
|
|
13
|
+
const DURABLE = /\.(?:md|markdown|png|jpe?g|gif|webp|svg|pdf|csv|json|html)$/iu;
|
|
14
|
+
const SESSION_FOLDER = /^[^\\/]+[\\/](?:files|images)[\\/]/u;
|
|
15
|
+
const MAX_STDIN = 262144;
|
|
16
|
+
|
|
17
|
+
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
18
|
+
|
|
19
|
+
/** The durable files under a session's `files/` or `images/` folder that a tool call names, from any string argument. */
|
|
20
|
+
function durablePaths(args, { env = process.env, homeDir = os.homedir() } = {}) {
|
|
21
|
+
const home = env.COPILOT_HOME || path.join(homeDir, ".copilot");
|
|
22
|
+
const root = path.resolve(home, "session-state");
|
|
23
|
+
const found = [];
|
|
24
|
+
for (const value of Object.values(args)) {
|
|
25
|
+
if (typeof value !== "string" || value.length > 4096 || value.includes("\n")) continue;
|
|
26
|
+
const target = path.resolve(value);
|
|
27
|
+
if (target.startsWith(root + path.sep) && SESSION_FOLDER.test(target.slice(root.length + 1)) && DURABLE.test(target)) found.push(target);
|
|
28
|
+
}
|
|
29
|
+
return found;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The focused task's desk folder for this session, or null. Reads the session's own history through the runtime's focus finder. */
|
|
33
|
+
async function focusedFolder({ sessionId, cwd, env, homeDir }) {
|
|
34
|
+
if (typeof sessionId !== "string" || !/^[\w-]+$/u.test(sessionId)) return null;
|
|
35
|
+
const runtime = (name) => import(pathToFileURL(path.join(__dirname, "..", "..", "mcp", "src", "runtime", name)).href);
|
|
36
|
+
const activity = await runtime("session-activity.js");
|
|
37
|
+
const cards = await runtime("focused-card.js");
|
|
38
|
+
const dir = path.join(activity.sessionStateDir(env), sessionId);
|
|
39
|
+
const { focus } = await activity.findFocus(path.join(dir, "events.jsonl"));
|
|
40
|
+
if (focus === null) return null;
|
|
41
|
+
const workspace = activity.readWorkspaceFile(path.join(dir, "workspace.yaml"));
|
|
42
|
+
const bases = cards.cardBases({ cwd: workspace.cwd ?? cwd, gitRoot: workspace.gitRoot, extra: [], homeDir });
|
|
43
|
+
const card = cards.findFocusedCard(bases, focus);
|
|
44
|
+
return card === null ? `${focus.track}/${focus.slug}` : path.dirname(card.file);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function noteFor(files, folder) {
|
|
48
|
+
const name = path.basename(files[0]);
|
|
49
|
+
return folder === null
|
|
50
|
+
? `Desk: ${name} is in the host's session folder, which vanishes with the session and which nobody else can find. No task is focused: run start-task first (task_create with focus: true), then write it in that task's desk folder.`
|
|
51
|
+
: `Desk: ${name} is in the host's session folder, which vanishes with the session and which nobody else can find. If it is for anyone else to read, write it in the focused task's desk folder instead: ${folder}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The hook's answer for one payload: `{}` to leave the call alone, or an allow with the note. */
|
|
55
|
+
async function decide(payload, options = {}) {
|
|
56
|
+
try {
|
|
57
|
+
if (!isRecord(payload)) return {};
|
|
58
|
+
let args = payload.toolArgs;
|
|
59
|
+
if (typeof args === "string") args = JSON.parse(args);
|
|
60
|
+
if (!isRecord(args)) return {};
|
|
61
|
+
const env = options.env ?? process.env;
|
|
62
|
+
const homeDir = options.homeDir ?? os.homedir();
|
|
63
|
+
const files = durablePaths(args, { env, homeDir });
|
|
64
|
+
if (files.length === 0) return {};
|
|
65
|
+
let folder = null;
|
|
66
|
+
try {
|
|
67
|
+
folder = await focusedFolder({ sessionId: payload.sessionId, cwd: payload.cwd, env, homeDir });
|
|
68
|
+
} catch { /* no readable focus reads as no task */ }
|
|
69
|
+
return { permissionDecision: "allow", additionalContext: noteFor(files, folder) };
|
|
70
|
+
} catch {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function main(stdin = process.stdin, stdout = process.stdout, stderr = process.stderr) {
|
|
76
|
+
let input = "";
|
|
77
|
+
let bytes = 0;
|
|
78
|
+
let oversized = false;
|
|
79
|
+
stdin.setEncoding("utf8");
|
|
80
|
+
stdin.on("data", (chunk) => {
|
|
81
|
+
if (oversized) return;
|
|
82
|
+
bytes += Buffer.byteLength(chunk);
|
|
83
|
+
if (bytes > MAX_STDIN) {
|
|
84
|
+
oversized = true;
|
|
85
|
+
input = "";
|
|
86
|
+
const failure = {
|
|
87
|
+
code: "input_too_large",
|
|
88
|
+
message: `Send a smaller hook payload: Desk durable files limit ${MAX_STDIN} bytes. The call was left unchanged.`,
|
|
89
|
+
};
|
|
90
|
+
stderr.write(`${failure.code}: ${failure.message}\n`);
|
|
91
|
+
} else input += chunk;
|
|
92
|
+
});
|
|
93
|
+
stdin.on("end", async () => {
|
|
94
|
+
let payload = null;
|
|
95
|
+
if (!oversized) {
|
|
96
|
+
try { payload = JSON.parse(input); } catch { /* not a payload: leave the call alone */ }
|
|
97
|
+
}
|
|
98
|
+
stdout.write(`${JSON.stringify(await decide(payload))}\n`);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
module.exports = { main };
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const os = require("node:os");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const crypto = require("node:crypto");
|
|
7
|
+
const { spawn } = require("node:child_process");
|
|
8
|
+
// Loaded only when a worker starts: the Stop hook runs after every turn.
|
|
9
|
+
const compatibleNode = (options) => require("../compatible-node.cjs").compatibleNode(options);
|
|
10
|
+
const ownRoot = path.resolve(__dirname, "..", "..");
|
|
11
|
+
const headless = (env) => { try { return require("../../mcp/src/factory/headless-flag.cjs").isHeadlessFactorySession(env); } catch { const v = String(env?.DESK_FACTORY_HEADLESS ?? ""); return v !== "" && v !== "0"; } };
|
|
12
|
+
const proofRun = (env) => { try { return require("../../mcp/src/factory/headless-flag.cjs").isProofFactorySession(env); } catch { const v = String(env?.DESK_FACTORY_PROOF ?? ""); return v !== "" && v !== "0"; } };
|
|
13
|
+
const { limitWorker, startDetached } = require("./detach-worker.cjs");
|
|
14
|
+
const MAX_INPUT = 1024 * 1024;
|
|
15
|
+
|
|
16
|
+
async function readInput(stream, timeoutMs = 150) {
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
let bytes = 0;
|
|
19
|
+
const chunks = [];
|
|
20
|
+
const finish = (value) => {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
stream.removeAllListeners("data");
|
|
23
|
+
stream.removeAllListeners("end");
|
|
24
|
+
stream.removeAllListeners("error");
|
|
25
|
+
stream.pause();
|
|
26
|
+
resolve(value);
|
|
27
|
+
};
|
|
28
|
+
const timer = setTimeout(() => finish(null), timeoutMs);
|
|
29
|
+
stream.on("data", (chunk) => {
|
|
30
|
+
bytes += Buffer.byteLength(chunk);
|
|
31
|
+
if (bytes > MAX_INPUT) finish(null);
|
|
32
|
+
else chunks.push(Buffer.from(chunk));
|
|
33
|
+
});
|
|
34
|
+
stream.once("error", () => finish(null));
|
|
35
|
+
stream.once("end", () => {
|
|
36
|
+
try {
|
|
37
|
+
const value = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
38
|
+
finish(value !== null && typeof value === "object" && !Array.isArray(value) ? value : null);
|
|
39
|
+
} catch {
|
|
40
|
+
finish(null);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// factory.js loads Desk's MCP code, so it runs in a Node that satisfies the
|
|
47
|
+
// MCP's engines range, never simply in the hook's own Node. With none
|
|
48
|
+
// installed nothing starts, and the retained marker is the retry path.
|
|
49
|
+
async function launch(script, args, env, resolveNode = compatibleNode) {
|
|
50
|
+
const { node } = resolveNode({ env });
|
|
51
|
+
if (!node) return;
|
|
52
|
+
await new Promise((resolve, reject) => {
|
|
53
|
+
const child = spawn(node, [script, ...args], { detached: true, stdio: "ignore", windowsHide: true, env });
|
|
54
|
+
child.once("error", reject);
|
|
55
|
+
child.once("spawn", () => { child.unref(); resolve(); });
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// How long the Stop hook may spend finding install sources before it names none.
|
|
60
|
+
const SOURCE_BUDGET_MS = 400;
|
|
61
|
+
|
|
62
|
+
// A Codex thread spawned by another thread is not a session. SessionEnd never fires for one, but a payload or rollout that names a parent is refused anyway.
|
|
63
|
+
function childThread(payload, log) {
|
|
64
|
+
if (payload.parent_thread_id || payload.source?.subagent) return true;
|
|
65
|
+
try {
|
|
66
|
+
const fd = fs.openSync(log, "r");
|
|
67
|
+
try {
|
|
68
|
+
const buffer = Buffer.alloc(65536);
|
|
69
|
+
const text = buffer.toString("utf8", 0, fs.readSync(fd, buffer, 0, buffer.length, 0));
|
|
70
|
+
const meta = JSON.parse(text.split("\n")[0])?.payload;
|
|
71
|
+
return Boolean(meta?.parent_thread_id || meta?.source?.subagent);
|
|
72
|
+
} finally { fs.closeSync(fd); }
|
|
73
|
+
} catch { return false; }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Outbox counts a lock as abandoned only after 10 minutes, but its holder here is a capture that stops itself after 60 s
|
|
77
|
+
// (detach-worker.cjs) and holds the lock for milliseconds. A capture killed inside that section (its own time limit, which skips
|
|
78
|
+
// cleanup, a crash or a forced kill) would leave every later capture for the session waiting until it gives up, and a session
|
|
79
|
+
// end in that window would never be recorded. The lock file names its holder's process (outbox.js withLock), so while waiting
|
|
80
|
+
// this removes a lock whose holder is gone, or one still without a holder after far longer than writing it takes.
|
|
81
|
+
const LOCK_SWEEP_MS = 200;
|
|
82
|
+
// Outbox creates the lock and then writes the holder's process id. A holder whose event loop is blocked in between (the session-end
|
|
83
|
+
// worker runs Git synchronously, up to 10 s per call) still holds it, so only a lock unnamed for this long is abandoned.
|
|
84
|
+
const LOCK_UNNAMED_MS = 30_000;
|
|
85
|
+
|
|
86
|
+
function holderGone(text, stat) {
|
|
87
|
+
let pid;
|
|
88
|
+
try { pid = JSON.parse(text).pid; } catch { /* not written yet */ }
|
|
89
|
+
if (!Number.isSafeInteger(pid) || pid <= 0) return Date.now() - Number(stat.mtimeMs) > LOCK_UNNAMED_MS;
|
|
90
|
+
if (pid === process.pid) return false;
|
|
91
|
+
try {
|
|
92
|
+
process.kill(pid, 0);
|
|
93
|
+
return false;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
// EPERM: the process exists but is not ours to signal.
|
|
96
|
+
return error.code === "ESRCH";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const sameFile = (a, b) => a.dev === b.dev && a.ino === b.ino && a.mtimeNs === b.mtimeNs;
|
|
101
|
+
|
|
102
|
+
function clearAbandonedLock(lockFile) {
|
|
103
|
+
let before;
|
|
104
|
+
try {
|
|
105
|
+
before = fs.statSync(lockFile, { bigint: true });
|
|
106
|
+
if (!holderGone(fs.readFileSync(lockFile, "utf8"), before)) return;
|
|
107
|
+
} catch { return; /* gone already: outbox's own wait applies */ }
|
|
108
|
+
// Another waiter may judge the same lock, remove it and take its own in the instant before this one removes it. Moving the
|
|
109
|
+
// lock aside is atomic, so this waiter then holds exactly one file, and removes it only if it is the lock it judged.
|
|
110
|
+
const aside = `${lockFile}.${process.pid}-${crypto.randomBytes(6).toString("hex")}.stale`;
|
|
111
|
+
try { fs.renameSync(lockFile, aside); } catch { return; /* already moved or removed by another waiter */ }
|
|
112
|
+
try {
|
|
113
|
+
if (sameFile(fs.statSync(aside, { bigint: true }), before)) {
|
|
114
|
+
fs.unlinkSync(aside);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
// Another waiter's live lock: put it back without replacing anything created there since (a link never overwrites).
|
|
118
|
+
fs.linkSync(aside, lockFile);
|
|
119
|
+
fs.unlinkSync(aside);
|
|
120
|
+
} catch {
|
|
121
|
+
try { if (!fs.existsSync(lockFile)) fs.renameSync(aside, lockFile); } catch { /* cannot be put back without risking a newer lock */ }
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function withAbandonedLockCleared(lockFile, body) {
|
|
126
|
+
clearAbandonedLock(lockFile);
|
|
127
|
+
const sweep = setInterval(() => clearAbandonedLock(lockFile), LOCK_SWEEP_MS);
|
|
128
|
+
try {
|
|
129
|
+
return await body();
|
|
130
|
+
} finally {
|
|
131
|
+
clearInterval(sweep);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function runHook({ host, payload, env = process.env, pluginRoot = ownRoot, launch: start = launch, supportsFinalize } = {}) {
|
|
136
|
+
try {
|
|
137
|
+
// A headless evaluator session is never captured: no marker, no derive.
|
|
138
|
+
if (headless(env)) return "headless";
|
|
139
|
+
const [{ absolutePath, readSmallText, validMarker }, { ENUMS, PATTERNS, isPlainObject }] = await Promise.all([
|
|
140
|
+
import("../../mcp/src/factory/marker.js"), import("../../mcp/src/factory/schema.js"),
|
|
141
|
+
]);
|
|
142
|
+
if (!["claude", "copilot", "codex"].includes(host) || !isPlainObject(payload)) return "invalid";
|
|
143
|
+
const claude = host === "claude";
|
|
144
|
+
const codex = host === "codex";
|
|
145
|
+
// Codex fires only SessionEnd, root thread only (openai/codex 60947e2, codex-rs/core/src/hook_runtime.rs#L471-L499). Its stdin is session_id, transcript_path (the rollout, or null), cwd, hook_event_name and reason (codex-rs/hooks/src/schema.rs#L512-L523).
|
|
146
|
+
const event = claude || codex ? payload.hook_event_name : Object.hasOwn(payload, "stopReason") ? "agentStop" : Object.hasOwn(payload, "reason") ? "sessionEnd" : null;
|
|
147
|
+
if (!(codex ? ["SessionEnd"] : claude ? ["Stop", "SessionEnd"] : ["agentStop", "sessionEnd"]).includes(event)) return "invalid";
|
|
148
|
+
const id = claude || codex ? payload.session_id : payload.sessionId;
|
|
149
|
+
if (typeof id !== "string" || !PATTERNS.sessionId.test(id) || !absolutePath(payload.cwd)) return "invalid";
|
|
150
|
+
const home = env.HOME || os.homedir();
|
|
151
|
+
const log = claude || codex ? payload.transcript_path : path.join(env.COPILOT_HOME || path.join(home, ".copilot"), "session-state", id, "events.jsonl");
|
|
152
|
+
if (!absolutePath(log)) return "invalid";
|
|
153
|
+
if (codex && childThread(payload, log)) return "invalid";
|
|
154
|
+
const [{ resolveHookDeskRoot }, outbox, { resolveStore }, cli] = await Promise.all([
|
|
155
|
+
import("../../mcp/scripts/resolve-desk-root.js"), import("../../mcp/src/factory/outbox.js"), import("../../mcp/src/factory/store-route.js"), import("../../mcp/scripts/factory.js"),
|
|
156
|
+
]);
|
|
157
|
+
// On Copilot, the payload's cwd: the folder the server records for the session (copilot-session.js), so both pick the same desk.
|
|
158
|
+
// Copilot 1.0.12 and later also set CLAUDE_PROJECT_DIR for plugin hooks; older ones do not.
|
|
159
|
+
const { root: deskRoot } = resolveHookDeskRoot({ env, cwd: payload.cwd, hostProjectRoot: claude || codex ? env.CLAUDE_PROJECT_DIR : payload.cwd });
|
|
160
|
+
if (deskRoot === null) return "unavailable";
|
|
161
|
+
const { metadata } = require("../../mcp/src/factory/plugin-sources.cjs");
|
|
162
|
+
const { plugins, dirs, incomplete } = metadata({ host, pluginRoot, home, env, readSmallText, PATTERNS, sourceDeadline: performance.now() + SOURCE_BUDGET_MS });
|
|
163
|
+
const ended = event === "SessionEnd" || event === "sessionEnd";
|
|
164
|
+
const at = !claude && Number.isSafeInteger(payload.timestamp) && payload.timestamp >= 0 ? new Date(payload.timestamp).toISOString() : new Date().toISOString();
|
|
165
|
+
const agency = path.join(home, ".local", "agency", "plugins", "sessions") + path.sep;
|
|
166
|
+
let routing = resolveStore({ deskRoot, pluginDirs: dirs, read: (file) => readSmallText(file) });
|
|
167
|
+
const { improvementPerson } = await import("../../mcp/src/desk/improvement-person.js");
|
|
168
|
+
let person;
|
|
169
|
+
try { person = await improvementPerson({ deskRoot, env }); } catch { /* no positive person */ }
|
|
170
|
+
if (incomplete && routing.source !== "desk") routing = { store: null, source: "invalid_declaration", warnings: routing.warnings };
|
|
171
|
+
const marker = {
|
|
172
|
+
schema_version: 1, host: claude ? "claude-code" : codex ? "codex-cli" : "copilot-cli", session_id: id,
|
|
173
|
+
log_path: log, cwd: payload.cwd, desk_root: deskRoot,
|
|
174
|
+
end_reason: ended ? ENUMS.endReason.includes(payload.reason) ? payload.reason : "other" : null,
|
|
175
|
+
ended_at: ended ? at : null, plugins, updated_at: new Date().toISOString(),
|
|
176
|
+
entrypoint: claude || codex ? "unknown" : path.resolve(pluginRoot).startsWith(agency) ? "launcher" : "cli",
|
|
177
|
+
// DESK_PERSON as given (a value that is not an alias makes the marker invalid), else the person the tool server writes
|
|
178
|
+
// as (improvement-person.js uses its resolver), so derive reads this member's cards.
|
|
179
|
+
person_prefix: env.DESK_PERSON ? `desks/${env.DESK_PERSON.trim()}` : person?.status === "ok" && /^(?:desks\/[A-Za-z0-9][A-Za-z0-9_-]{0,63})?$/u.test(person.personPrefix) ? person.personPrefix : "",
|
|
180
|
+
routing,
|
|
181
|
+
};
|
|
182
|
+
if (!validMarker(marker)) return "invalid";
|
|
183
|
+
// A turn's capture runs detached, so it can land after the session's end is recorded (a session that ends right after a turn,
|
|
184
|
+
// as every `-p` run does). It must never undo that end: the read and the write share one lock per session, and a capture with
|
|
185
|
+
// no end keeps the end already recorded. Later activity in a resumed session still reopens it when derived (session-lifetime).
|
|
186
|
+
// Only a missing record has no end: a record that exists but cannot be read or checked (a failed Windows permission step, a file
|
|
187
|
+
// that changed under the read) may hold one, so that capture leaves it as it is.
|
|
188
|
+
const lockName = `marker-${marker.host}-${id}`;
|
|
189
|
+
const stateRoot = await outbox.factoryStateRoot(env);
|
|
190
|
+
const file = path.join(stateRoot, "markers", `${marker.host}-${id}.json`);
|
|
191
|
+
// A proof run marks its own session (`DESK_FACTORY_PROOF`). The mark is kept on the record, so a later write without the variable keeps it too.
|
|
192
|
+
let proof = proofRun(env);
|
|
193
|
+
if (proof) marker.proof = true;
|
|
194
|
+
let kept = false;
|
|
195
|
+
await withAbandonedLockCleared(path.join(stateRoot, "locks", `${lockName}.lock`), () => outbox.withNamedLock(env, lockName, async () => {
|
|
196
|
+
let recorded = null;
|
|
197
|
+
let readError = null;
|
|
198
|
+
try {
|
|
199
|
+
recorded = await outbox.readMarker(env, file);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
readError = error;
|
|
202
|
+
}
|
|
203
|
+
if (recorded?.proof === true) proof = true;
|
|
204
|
+
if (proof) marker.proof = true;
|
|
205
|
+
if (!ended) {
|
|
206
|
+
// Only the proof mark overrides a record that exists: an unreadable one may hold an end already recorded, so it stays as it is.
|
|
207
|
+
kept = !proof && (readError === null ? recorded === null : readError?.code !== "ENOENT");
|
|
208
|
+
if (kept) return;
|
|
209
|
+
if (recorded?.ended_at) Object.assign(marker, { end_reason: recorded.end_reason, ended_at: recorded.ended_at });
|
|
210
|
+
}
|
|
211
|
+
await outbox.writeMarker(env, marker);
|
|
212
|
+
}, { deskRoot }));
|
|
213
|
+
// A proof session is never derived, flushed or counted, so nothing else starts for it.
|
|
214
|
+
if (proof) return "proof";
|
|
215
|
+
// Codex gives SessionEnd at most 3 s (codex-rs/hooks/src/events/session_end.rs#L20-L24), so this hook only records the marker; the next session-start sweep derives it.
|
|
216
|
+
if (codex) return "written";
|
|
217
|
+
const scope = person?.status === "ok" ? { deskRoot, personPrefix: person.personPrefix } : null;
|
|
218
|
+
const workerEnv = { ...env };
|
|
219
|
+
if (scope === null) delete workerEnv.DESK_FACTORY_LOOP_SCOPE;
|
|
220
|
+
else workerEnv.DESK_FACTORY_LOOP_SCOPE = JSON.stringify(scope);
|
|
221
|
+
const script = path.join(ownRoot, "mcp", "scripts", "factory.js");
|
|
222
|
+
// One Node search per hook run, however many jobs it starts.
|
|
223
|
+
let resolved;
|
|
224
|
+
const resolveOnce = (options) => (resolved ??= compatibleNode(options));
|
|
225
|
+
if (ended) {
|
|
226
|
+
const root = await outbox.factoryStateRoot(env);
|
|
227
|
+
await start(script, ["derive", "--marker", path.join(root, "markers", `${marker.host}-${id}.json`), "--wait-quiet", "30000"], env, resolveOnce);
|
|
228
|
+
} else if (supportsFinalize ?? cli.SUPPORTED_COMMANDS.includes("finalize")) {
|
|
229
|
+
const jobs = await outbox.listFinalizeJobs(env);
|
|
230
|
+
for (const job of jobs) await start(script, ["finalize", "--job", job], workerEnv, resolveOnce);
|
|
231
|
+
// A finalize run starts the loop worker itself once it has derived the job's sessions; with none pending, the end of a turn
|
|
232
|
+
// starts it when the evaluator step is due (a request newer than its last run, or requests waiting past its gap), or when a task context evaluation is due.
|
|
233
|
+
if (jobs.length === 0) await kickAtTurnEnd(workerEnv, start, resolveOnce, scope);
|
|
234
|
+
}
|
|
235
|
+
return kept ? "kept" : "written";
|
|
236
|
+
} catch {
|
|
237
|
+
// Accounting remains fail-open. The separate wrapper reply check never changes these markers.
|
|
238
|
+
return "unavailable";
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Starts the loop launcher (hooks/loop-start.cjs) through the same detached launch as every other hook job, only when evaluate-kick.js says the evaluator step is due.
|
|
243
|
+
async function kickAtTurnEnd(env, start, resolveOnce, scope) {
|
|
244
|
+
const { kickLoop } = await import("../../mcp/src/factory/evaluate-kick.js");
|
|
245
|
+
await kickLoop(env, { scope, spawn: async (_node, args, options) => {
|
|
246
|
+
await start(args[0], args.slice(1), options.env, resolveOnce);
|
|
247
|
+
return {};
|
|
248
|
+
} });
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Session end needs no reply from the hook (the delivery check only answers a turn's stop), so its work runs detached and
|
|
252
|
+
// the hook exits at once: on a loaded machine it can take longer than the host's hook timeout (see detach-worker.cjs).
|
|
253
|
+
function sessionEnded(host, payload) {
|
|
254
|
+
return host === "copilot" ? !Object.hasOwn(payload, "stopReason") && Object.hasOwn(payload, "reason") : payload.hook_event_name === "SessionEnd";
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// How long a turn's end may wait for the delivery check, counted from the hook's own start.
|
|
258
|
+
const DEADLINE_MS = 1500;
|
|
259
|
+
|
|
260
|
+
// The capture (marker, finalize jobs, loop kick) never changes the hook's answer, and loading Desk's MCP modules for it was almost
|
|
261
|
+
// all of the bounded child's time (about 200 ms of 206 on macOS; Windows is several times slower and ran past the deadline on most
|
|
262
|
+
// turns). So it always runs detached, and at a turn's end the bounded child runs only the delivery check, whose answer the host uses.
|
|
263
|
+
async function runBoundedHook(host, input, entry, { deadlineMs = DEADLINE_MS, stdout = process.stdout, stderr = process.stderr, env = process.env } = {}) {
|
|
264
|
+
if (headless(env)) return;
|
|
265
|
+
const deadline = Date.now() + deadlineMs;
|
|
266
|
+
const payload = await readInput(input);
|
|
267
|
+
if (payload === null || Date.now() >= deadline) return;
|
|
268
|
+
const capture = startDetached(entry, [host, "--factory-worker", "--detached"], payload, { env });
|
|
269
|
+
if (sessionEnded(host, payload)) {
|
|
270
|
+
await capture;
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
// A separate process makes the deadline effective even during synchronous OS calls.
|
|
274
|
+
const check = new Promise((resolve) => {
|
|
275
|
+
const child = spawn(process.execPath, [entry, host, "--factory-worker"], {
|
|
276
|
+
stdio: ["pipe", "pipe", "pipe"], windowsHide: true, env,
|
|
277
|
+
});
|
|
278
|
+
let output = "", diagnostic = "", timedOut = false, spawnError = null;
|
|
279
|
+
child.stdout.on("data", chunk => { if (output.length < 16384) output += chunk; });
|
|
280
|
+
child.stderr.on("data", chunk => { if (diagnostic.length < 2048) diagnostic += chunk; });
|
|
281
|
+
const timer = setTimeout(() => { timedOut = true; child.kill("SIGKILL"); }, Math.max(0, deadline - Date.now()));
|
|
282
|
+
let finished = false;
|
|
283
|
+
const finish = (code, signal) => {
|
|
284
|
+
if (finished) return;
|
|
285
|
+
finished = true;
|
|
286
|
+
clearTimeout(timer);
|
|
287
|
+
if (code === 0 && !timedOut) {
|
|
288
|
+
if (diagnostic) stderr.write(diagnostic.slice(0, 2048));
|
|
289
|
+
try {
|
|
290
|
+
const value = JSON.parse(output);
|
|
291
|
+
if (value?.decision === "block" && typeof value.reason === "string" && value.reason.includes("[DESK_DELIVERY_CORRECTION]")) stdout.write(JSON.stringify(value));
|
|
292
|
+
} catch { /* Accounting produces no stdout when no correction is due. */ }
|
|
293
|
+
} else {
|
|
294
|
+
const why = timedOut ? "deadline" : spawnError ? `spawn ${spawnError.code ?? "error"}` : signal ? `signal ${signal}` : `exit ${code}`;
|
|
295
|
+
stderr.write(`[desk-delivery] unverified: hook_worker_unavailable (${why})\n`);
|
|
296
|
+
}
|
|
297
|
+
resolve();
|
|
298
|
+
};
|
|
299
|
+
child.once("error", (error) => { spawnError = error; finish(null, null); });
|
|
300
|
+
child.once("close", finish);
|
|
301
|
+
child.stdin.on("error", () => {});
|
|
302
|
+
child.stdin.end(JSON.stringify(payload));
|
|
303
|
+
});
|
|
304
|
+
await Promise.all([capture, check]);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// The command line of the entry file `hooks/factory-end.cjs`, which is the file hosts register and the worker process runs again.
|
|
308
|
+
// `--factory-worker --detached` is the capture, `--factory-worker` alone the bounded delivery check.
|
|
309
|
+
function main(entry, argv = process.argv, stdin = process.stdin) {
|
|
310
|
+
const detached = argv[4] === "--detached";
|
|
311
|
+
if (detached) limitWorker();
|
|
312
|
+
const work = argv[3] === "--factory-worker"
|
|
313
|
+
? readInput(stdin, detached ? 5000 : undefined).then(async (payload) => {
|
|
314
|
+
if (detached) {
|
|
315
|
+
await runHook({ host: argv[2], payload });
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const delivery = await checkDelivery({ host: argv[2], payload }).catch(() => ({ diagnostic: "guard_unavailable" }));
|
|
319
|
+
if (delivery.diagnostic) process.stderr.write(`[desk-delivery] unverified: ${delivery.diagnostic}\n`);
|
|
320
|
+
if (delivery.output) process.stdout.write(JSON.stringify(delivery.output));
|
|
321
|
+
})
|
|
322
|
+
: runBoundedHook(argv[2], stdin, entry);
|
|
323
|
+
work.then(() => process.exit(0), () => process.exit(0));
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const checkDelivery = options => require("./delivery-stop.cjs").checkDelivery(options);
|
|
327
|
+
module.exports = { readInput, runHook, runBoundedHook, launch, main };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Copilot preToolUse for the app's session-starting tools (create_session, open_issue_session, open_pr_session). Without
|
|
4
|
+
// `kickoff.model` the app starts the new session on the model of the session that asked, and coordinators run on the most
|
|
5
|
+
// expensive one, so every lane inherits it. When the call names no model, this adds Desk's lane default through `modifiedArgs`;
|
|
6
|
+
// the app also starts a kickoff in plan mode when `kickoff.mode` is absent, which leaves a lane waiting on a plan approval
|
|
7
|
+
// nobody sees, so a missing mode becomes autopilot. A model or mode the caller named is never touched.
|
|
8
|
+
// `execution_location: "cloud"` is dropped (the session runs locally), because the cloud sandbox loads no plugins. Fail-open: any problem leaves the call as it was.
|
|
9
|
+
|
|
10
|
+
const fs = require("node:fs");
|
|
11
|
+
const os = require("node:os");
|
|
12
|
+
const path = require("node:path");
|
|
13
|
+
|
|
14
|
+
const DEFAULT_LANE_MODEL = "claude-sonnet-5.5";
|
|
15
|
+
const DEFAULT_LANE_MODE = "autopilot";
|
|
16
|
+
const SESSION_TOOL = /(?:^|[^a-z_])(?:create_session|open_issue_session|open_pr_session)$/u;
|
|
17
|
+
|
|
18
|
+
const text = (value) => (typeof value === "string" && value.trim() !== "" ? value.trim() : null);
|
|
19
|
+
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
20
|
+
|
|
21
|
+
/** `create_session`, or the same tool under a server prefix (`app-create_session`, `app/create_session`). */
|
|
22
|
+
function isSessionTool(name) {
|
|
23
|
+
return typeof name === "string" && SESSION_TOOL.test(name);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Desk's state folder, where the drains config also lives. */
|
|
27
|
+
function configFile({ env = process.env, homeDir = os.homedir() } = {}) {
|
|
28
|
+
const configured = text(env.XDG_STATE_HOME);
|
|
29
|
+
const stateHome = configured !== null && path.isAbsolute(configured) ? configured : path.join(homeDir, ".local", "state");
|
|
30
|
+
return path.join(stateHome, "ouroboros-skills", "desk", "config.json");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The lane default: `DESK_LANE_MODEL`, else `laneModel` in Desk's `config.json`, else claude-sonnet-5.5. */
|
|
34
|
+
function laneModel({ env = process.env, homeDir = os.homedir() } = {}) {
|
|
35
|
+
const fromEnv = text(env.DESK_LANE_MODEL);
|
|
36
|
+
if (fromEnv !== null) return fromEnv;
|
|
37
|
+
try {
|
|
38
|
+
const config = JSON.parse(fs.readFileSync(configFile({ env, homeDir }), "utf8"));
|
|
39
|
+
return (isRecord(config) && text(config.laneModel)) || DEFAULT_LANE_MODEL;
|
|
40
|
+
} catch {
|
|
41
|
+
return DEFAULT_LANE_MODEL;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** `DESK_ALLOW_CLOUD_SESSIONS=1` keeps `execution_location: "cloud"` for a lane that really must run in the cloud. */
|
|
46
|
+
function allowCloud({ env = process.env } = {}) {
|
|
47
|
+
return text(env.DESK_ALLOW_CLOUD_SESSIONS) === "1";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The hook's answer for one payload: `{}` to leave the call alone, or an allow with the arguments plus the default model. */
|
|
51
|
+
function decide(payload, options = {}) {
|
|
52
|
+
try {
|
|
53
|
+
if (!isRecord(payload) || !isSessionTool(payload.toolName)) return {};
|
|
54
|
+
let args = payload.toolArgs;
|
|
55
|
+
if (typeof args === "string") args = JSON.parse(args);
|
|
56
|
+
if (!isRecord(args)) return {};
|
|
57
|
+
if (args.kickoff !== undefined && !isRecord(args.kickoff)) return {};
|
|
58
|
+
const kickoff = { ...(args.kickoff ?? {}) };
|
|
59
|
+
if (text(kickoff.model) === null) kickoff.model = laneModel(options);
|
|
60
|
+
if (text(kickoff.mode) === null) kickoff.mode = DEFAULT_LANE_MODE;
|
|
61
|
+
// A cloud session runs in a sandbox that never loads the Desk, MS Desk and Superpowers plugin bundle, so it is started locally.
|
|
62
|
+
const { execution_location: location, ...rest } = args;
|
|
63
|
+
const dropCloud = text(location) === "cloud" && !allowCloud(options);
|
|
64
|
+
if (!dropCloud && isRecord(args.kickoff) && kickoff.model === args.kickoff.model && kickoff.mode === args.kickoff.mode) return {};
|
|
65
|
+
return { permissionDecision: "allow", modifiedArgs: { ...(dropCloud ? rest : args), kickoff } };
|
|
66
|
+
} catch {
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function main(stdin = process.stdin, stdout = process.stdout) {
|
|
72
|
+
let input = "";
|
|
73
|
+
stdin.setEncoding("utf8");
|
|
74
|
+
stdin.on("data", (chunk) => { input += chunk; });
|
|
75
|
+
stdin.on("end", () => {
|
|
76
|
+
let payload = null;
|
|
77
|
+
try { payload = JSON.parse(input); } catch { /* not a payload: leave the call alone */ }
|
|
78
|
+
stdout.write(`${JSON.stringify(decide(payload))}\n`);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = { main };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// The session-start hooks' first check. With no `node` at all, the host's own shell gives the message (hooks/node-missing.sh and the
|
|
4
|
+
// PowerShell branch in copilot-hooks.json). This covers the next case: the hook runs in a Node older than Desk needs and no newer Node
|
|
5
|
+
// is installed, so the tool servers can only answer that Node is missing. The session then gets the same message, leading with the install
|
|
6
|
+
// command the MCP bootstrap's own desk_status fix names. On Windows the bootstrap's search also reads the registry's current PATH.
|
|
7
|
+
//
|
|
8
|
+
// It must never say Node is missing when the tool server would find one, so it searches exactly as mcp/bootstrap.cjs does: the same
|
|
9
|
+
// selectNode call, with the bootstrap's own probe and time budget. A search that runs out of time says nothing, because the server,
|
|
10
|
+
// starting later, may still find a Node. The running Node is checked first, without loading the bootstrap, so a session whose Node
|
|
11
|
+
// fits pays nothing. The hooks reach this check on Node 16 and newer; an older Node fails before it (the hooks use Node 16
|
|
12
|
+
// syntax and `node:` module names), and desk_status, whose bootstrap runs on Node 8, still names the fix.
|
|
13
|
+
|
|
14
|
+
const os = require("node:os");
|
|
15
|
+
const path = require("node:path");
|
|
16
|
+
const { atLeast, engineFloor } = require("../compatible-node.cjs");
|
|
17
|
+
|
|
18
|
+
const MCP_ROOT = path.join(__dirname, "..", "..", "mcp");
|
|
19
|
+
const RESTART = "Then the person must open a new terminal and start a new session, because tool servers load only when a session starts.";
|
|
20
|
+
const bootstrap = () => require("../../mcp/bootstrap.cjs");
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* nodeRequiredLine({ env?, platform?, current?, select?, now? }) -> string
|
|
24
|
+
*
|
|
25
|
+
* The message for a session whose Node is older than Desk's engines range when the bootstrap's own search finds no compatible Node,
|
|
26
|
+
* or "" when Desk can run, when the search ran out of time, or when the check itself fails: it must never block a session.
|
|
27
|
+
* `current`, `select` and `now` are test seams.
|
|
28
|
+
*/
|
|
29
|
+
function nodeRequiredLine({
|
|
30
|
+
env = process.env,
|
|
31
|
+
platform = process.platform,
|
|
32
|
+
current = { path: process.execPath, version: process.version, abi: process.versions.modules },
|
|
33
|
+
select = (options) => bootstrap().selectNode(options),
|
|
34
|
+
now = Date.now,
|
|
35
|
+
} = {}) {
|
|
36
|
+
try {
|
|
37
|
+
const plain = engineFloor(MCP_ROOT);
|
|
38
|
+
if (plain !== null && atLeast(current.version, plain.floor)) return "";
|
|
39
|
+
const homeDir = env.HOME || env.USERPROFILE || os.homedir();
|
|
40
|
+
const budget = bootstrap().PROBE_BUDGET_MS;
|
|
41
|
+
const started = now();
|
|
42
|
+
// The bootstrap's start(): the same options, and no probe or budget of the hook's own.
|
|
43
|
+
const { node, range } = select({
|
|
44
|
+
env, platform, arch: process.arch, homeDir, mcpRoot: MCP_ROOT, current, systemPrefix: env.DESK_NODE_SYSTEM_PREFIX || "", now,
|
|
45
|
+
});
|
|
46
|
+
if (node || now() - started >= budget) return "";
|
|
47
|
+
const command = bootstrap().installCommand({ platform, env, homeDir, major: null });
|
|
48
|
+
const floor = /^>=\s*v?(\d+)(?:\.([1-9]\d*))?\.0$/u.exec(String(range).trim());
|
|
49
|
+
const needed = floor ? `Node.js ${floor[1]}${floor[2] ? `.${floor[2]}` : ""} or newer` : `Node.js ${range}`;
|
|
50
|
+
return `To fix this, run \`${command}\` in a terminal. ${RESTART} Desk needs ${needed}, and the \`node\` on PATH is ${current.version} with no newer Node.js installed, so the Desk tool servers (desk, desk-web) cannot run and Desk tools do not work in this session.`;
|
|
51
|
+
} catch {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = { nodeRequiredLine };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Claude Code's PostToolUse hook for task_focus and task_create: hands the finished call to
|
|
4
|
+
// mcp/src/runtime/orca-session-title.js, which names this session's Orca tab after the focused task (desk#1478).
|
|
5
|
+
// It prints nothing and always exits 0, so it can never change or block the tool call; every outcome is logged by the
|
|
6
|
+
// module in Desk's state folder.
|
|
7
|
+
|
|
8
|
+
const { pathToFileURL } = require("node:url");
|
|
9
|
+
const path = require("node:path");
|
|
10
|
+
|
|
11
|
+
const MAX_INPUT = 1024 * 1024;
|
|
12
|
+
const MODULE = pathToFileURL(path.join(__dirname, "..", "..", "mcp", "src", "runtime", "orca-session-title.js")).href;
|
|
13
|
+
|
|
14
|
+
/** The hook's JSON input from `stream`, or null when it is missing, too large, not an object or slow to arrive. */
|
|
15
|
+
function readInput(stream, timeoutMs = 1000) {
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
|
+
let bytes = 0;
|
|
18
|
+
const chunks = [];
|
|
19
|
+
const finish = (value) => {
|
|
20
|
+
clearTimeout(timer);
|
|
21
|
+
stream.removeAllListeners("data");
|
|
22
|
+
stream.removeAllListeners("end");
|
|
23
|
+
stream.removeAllListeners("error");
|
|
24
|
+
stream.pause();
|
|
25
|
+
resolve(value);
|
|
26
|
+
};
|
|
27
|
+
const timer = setTimeout(() => finish(null), timeoutMs);
|
|
28
|
+
stream.on("data", (chunk) => {
|
|
29
|
+
bytes += Buffer.byteLength(chunk);
|
|
30
|
+
if (bytes > MAX_INPUT) finish(null);
|
|
31
|
+
else chunks.push(Buffer.from(chunk));
|
|
32
|
+
});
|
|
33
|
+
stream.once("error", () => finish(null));
|
|
34
|
+
stream.once("end", () => {
|
|
35
|
+
try {
|
|
36
|
+
const value = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
37
|
+
finish(value !== null && typeof value === "object" && !Array.isArray(value) ? value : null);
|
|
38
|
+
} catch {
|
|
39
|
+
finish(null);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Reads the hook input and names the session; resolves to the module's outcome code, or "unavailable" when it could not run. */
|
|
46
|
+
async function runHook({ stdin = process.stdin, env = process.env, load = () => import(MODULE) } = {}) {
|
|
47
|
+
try {
|
|
48
|
+
const hookInput = await readInput(stdin);
|
|
49
|
+
const { nameOrcaSession } = await load();
|
|
50
|
+
return (await nameOrcaSession({ hookInput, env })).code;
|
|
51
|
+
} catch {
|
|
52
|
+
return "unavailable";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function main() {
|
|
57
|
+
runHook().finally(() => { process.exitCode = 0; });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = { readInput, runHook, main };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Session end, the one command each host registers for it. On Windows every registered command is its own PowerShell process,
|
|
4
|
+
// about 0.75 s before any work, so the unpushed-commit check (sync-end.cjs) runs in a detached worker too.
|
|
5
|
+
// The hook reads the payload once and hands it to one detached worker (`--worker`) that runs the check, so it exits well inside the
|
|
6
|
+
// host's timeout however slow loading Desk or Git is (see detach-worker.cjs). Nothing the host does depends on it. The factory's
|
|
7
|
+
// capture (factory-end.cjs) is not registered: it runs only where someone registers it.
|
|
8
|
+
|
|
9
|
+
const path = require("node:path");
|
|
10
|
+
const { limitWorker, startDetached } = require("./detach-worker.cjs");
|
|
11
|
+
const syncEnd = require("./sync-end.cjs");
|
|
12
|
+
|
|
13
|
+
const ENTRY = path.join(__dirname, "..", "session-end.cjs");
|
|
14
|
+
const headless = (env) => { try { return require("../../mcp/src/factory/headless-flag.cjs").startupChangesNothing(env); } catch { return [env?.DESK_FACTORY_HEADLESS, env?.DESK_READ_ONLY_CHILD].some((v) => String(v ?? "") !== "" && String(v ?? "") !== "0"); } };
|
|
15
|
+
|
|
16
|
+
/** The session-end job for one payload. It is fail-open. */
|
|
17
|
+
function runJobs({ host, payload, env = process.env }) {
|
|
18
|
+
return syncEnd.runHook({ host, payload, env });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// The command line of the entry file `hooks/session-end.cjs`.
|
|
22
|
+
function main(argv = process.argv, stdin = process.stdin) {
|
|
23
|
+
const host = argv[2];
|
|
24
|
+
const work = argv[3] === "--worker"
|
|
25
|
+
? (limitWorker(), syncEnd.readInput(stdin, 5000).then((payload) => runJobs({ host, payload })))
|
|
26
|
+
: syncEnd.readInput(stdin).then((payload) => payload === null || headless(process.env) ? null : startDetached(ENTRY, [host, "--worker"], payload));
|
|
27
|
+
work.then(() => process.exit(0), () => process.exit(0));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = { main };
|