@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,567 @@
|
|
|
1
|
+
// The factory's bounded headless runner: it starts the agent CLI in print mode
|
|
2
|
+
// to label the waste in finished jobs' evaluator briefs, with no human in the
|
|
3
|
+
// loop. Its rules, in order of importance:
|
|
4
|
+
//
|
|
5
|
+
// - It never spends money by itself. The run starts only when the agent CLI
|
|
6
|
+
// reports a subscription sign-in (`probeSignIn`). A per-token credential
|
|
7
|
+
// in the environment, a per-token sign-in, no sign-in or an unreadable
|
|
8
|
+
// answer each give a stable state and start nothing, and the child's
|
|
9
|
+
// environment never carries a per-token variable.
|
|
10
|
+
// - A headless session never starts another headless run: with
|
|
11
|
+
// `DESK_FACTORY_HEADLESS` set in the caller's own environment nothing
|
|
12
|
+
// starts, not even the probe.
|
|
13
|
+
// - Only the exact child handle this module spawned is ever signalled. It
|
|
14
|
+
// never looks a process up by name.
|
|
15
|
+
// - Nothing records argv, stdout or stderr. What leaves this module is a
|
|
16
|
+
// stable state code, the cost number (`null` when the output carries none,
|
|
17
|
+
// never zero) and a stable detail code.
|
|
18
|
+
//
|
|
19
|
+
// The run is independent of the work it labels: a fresh process, a fixed
|
|
20
|
+
// prompt naming only the brief paths, a scratch working folder that is not a
|
|
21
|
+
// desk, and tools limited to read, search and write.
|
|
22
|
+
|
|
23
|
+
import { spawn as nodeSpawn } from "node:child_process"
|
|
24
|
+
import { accessSync, constants as fsConstants, readFileSync, realpathSync, statSync } from "node:fs"
|
|
25
|
+
import { homedir as osHomedir } from "node:os"
|
|
26
|
+
import * as path from "node:path"
|
|
27
|
+
|
|
28
|
+
import { deskPluginRoot } from "../package-metadata.js"
|
|
29
|
+
import { isHeadlessFactorySession } from "./headless-flag.js"
|
|
30
|
+
|
|
31
|
+
export const HEADLESS_BUDGET_USD = 1
|
|
32
|
+
/** A safety ceiling against a runaway, not a pace: the loop drains its queue back to back and stops here for the UTC day. */
|
|
33
|
+
export const MAX_HEADLESS_JOBS_PER_DAY = 30
|
|
34
|
+
export const HEADLESS_TIMEOUT_MS = 900000
|
|
35
|
+
|
|
36
|
+
const PROBE_TIMEOUT_MS = 15000
|
|
37
|
+
const PROBE_MAX_BYTES = 64 * 1024
|
|
38
|
+
const RUN_MAX_BYTES = 1024 * 1024
|
|
39
|
+
const AGENT_NAME = "desk:observer"
|
|
40
|
+
|
|
41
|
+
// The child (and the sign-in probe) get only what the CLI needs to find itself,
|
|
42
|
+
// its subscription sign-in and its network (proxy and certificate settings).
|
|
43
|
+
// Everything else, every provider switch and credential included, is left out.
|
|
44
|
+
export const CHILD_ENV_ALLOW = Object.freeze({
|
|
45
|
+
names: Object.freeze([
|
|
46
|
+
"PATH",
|
|
47
|
+
"HOME",
|
|
48
|
+
"USER",
|
|
49
|
+
"LOGNAME",
|
|
50
|
+
"SHELL",
|
|
51
|
+
"LANG",
|
|
52
|
+
"TMPDIR",
|
|
53
|
+
"TERM",
|
|
54
|
+
"CLAUDE_CONFIG_DIR",
|
|
55
|
+
"USERPROFILE",
|
|
56
|
+
"APPDATA",
|
|
57
|
+
"LOCALAPPDATA",
|
|
58
|
+
"SystemRoot",
|
|
59
|
+
"COMSPEC",
|
|
60
|
+
"PATHEXT",
|
|
61
|
+
"TEMP",
|
|
62
|
+
"TMP",
|
|
63
|
+
// A proxied or TLS-inspecting network: without these the CLI cannot reach its service and every run fails.
|
|
64
|
+
"HTTPS_PROXY",
|
|
65
|
+
"https_proxy",
|
|
66
|
+
"HTTP_PROXY",
|
|
67
|
+
"http_proxy",
|
|
68
|
+
"NO_PROXY",
|
|
69
|
+
"no_proxy",
|
|
70
|
+
"ALL_PROXY",
|
|
71
|
+
"all_proxy",
|
|
72
|
+
"NODE_EXTRA_CA_CERTS",
|
|
73
|
+
"NODE_USE_SYSTEM_CA",
|
|
74
|
+
"SSL_CERT_FILE",
|
|
75
|
+
"SSL_CERT_DIR",
|
|
76
|
+
]),
|
|
77
|
+
prefixes: Object.freeze(["LC_", "XDG_"]),
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
// `ANTHROPIC_*` names that are neither a key, a token nor a base URL. None is worth keeping today.
|
|
81
|
+
export const HARMLESS_ANTHROPIC_ENV = Object.freeze([])
|
|
82
|
+
|
|
83
|
+
const isSet = (value) => typeof value === "string" && value !== "" && value !== "0" && value !== "false"
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* `billingVariableBlocks(env) -> boolean`: true when the environment holds a
|
|
87
|
+
* provider switch or a credential that would make the CLI bill per token:
|
|
88
|
+
* any `CLAUDE_CODE_USE_*`, any `ANTHROPIC_*` (outside the harmless list),
|
|
89
|
+
* `CLAUDE_CODE_OAUTH_TOKEN` or `AWS_BEARER_TOKEN_BEDROCK`.
|
|
90
|
+
*/
|
|
91
|
+
export function billingVariableBlocks(env) {
|
|
92
|
+
return Object.entries(env).some(([name, value]) => {
|
|
93
|
+
if (!isSet(value)) {
|
|
94
|
+
return false
|
|
95
|
+
}
|
|
96
|
+
if (name.startsWith("CLAUDE_CODE_USE_") || name === "CLAUDE_CODE_OAUTH_TOKEN" || name === "AWS_BEARER_TOKEN_BEDROCK") {
|
|
97
|
+
return true
|
|
98
|
+
}
|
|
99
|
+
return name.startsWith("ANTHROPIC_") && !HARMLESS_ANTHROPIC_ENV.includes(name)
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const isHeadlessSession = isHeadlessFactorySession
|
|
104
|
+
|
|
105
|
+
export function childEnvironment(env) {
|
|
106
|
+
const out = {}
|
|
107
|
+
for (const [name, value] of Object.entries(env)) {
|
|
108
|
+
if (typeof value !== "string") {
|
|
109
|
+
continue
|
|
110
|
+
}
|
|
111
|
+
if (CHILD_ENV_ALLOW.names.includes(name) || CHILD_ENV_ALLOW.prefixes.some((prefix) => name.startsWith(prefix))) {
|
|
112
|
+
out[name] = value
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
out.DESK_FACTORY_HEADLESS = "1"
|
|
116
|
+
return out
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const isExecutableFile = (candidate) => {
|
|
120
|
+
try {
|
|
121
|
+
if (!statSync(candidate).isFile()) {
|
|
122
|
+
return false
|
|
123
|
+
}
|
|
124
|
+
accessSync(candidate, fsConstants.X_OK)
|
|
125
|
+
return true
|
|
126
|
+
} catch {
|
|
127
|
+
return false
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const isDirectory = (candidate) => {
|
|
132
|
+
try {
|
|
133
|
+
return statSync(candidate).isDirectory()
|
|
134
|
+
} catch {
|
|
135
|
+
return false
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** `hostSupported(host) -> boolean`: only Claude Code's print mode is supported. */
|
|
140
|
+
export function hostSupported(host) {
|
|
141
|
+
return host === "claude-code"
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* `HEADLESS_ARGV({ briefPaths, evaluationDir, logDirs }) -> string[]`: the
|
|
146
|
+
* pinned argument vector, one `--add-dir` for the evaluation folder and one per
|
|
147
|
+
* distinct log folder. The prompt names only the brief paths.
|
|
148
|
+
*/
|
|
149
|
+
export function HEADLESS_ARGV({ briefPaths, evaluationDir, logDirs, purpose = "labels", pluginRoot = deskPluginRoot() }) {
|
|
150
|
+
const prompts = {
|
|
151
|
+
labels: "Label the waste in these evaluator briefs with desk:factory-evaluator",
|
|
152
|
+
task_context: "Generate evidence-supported public task context using desk:factory-task-context, generation phase",
|
|
153
|
+
context_privacy: "Independently review public task context using desk:factory-task-context, privacy phase",
|
|
154
|
+
}
|
|
155
|
+
if (!Object.hasOwn(prompts, purpose)) throw Object.assign(new TypeError("HEADLESS_ARGV: Pass a valid purpose"), { code: "headless_headless_argv_pass_a_valid" })
|
|
156
|
+
const prompt = `${prompts[purpose]}: ${briefPaths.join(" ")}.`
|
|
157
|
+
const dirs = [evaluationDir, ...new Set(logDirs)]
|
|
158
|
+
return [
|
|
159
|
+
"-p",
|
|
160
|
+
prompt,
|
|
161
|
+
...(purpose === "labels" ? [] : ["--plugin-dir", pluginRoot]),
|
|
162
|
+
"--agent",
|
|
163
|
+
AGENT_NAME,
|
|
164
|
+
"--output-format",
|
|
165
|
+
"json",
|
|
166
|
+
"--max-budget-usd",
|
|
167
|
+
String(HEADLESS_BUDGET_USD),
|
|
168
|
+
"--no-session-persistence",
|
|
169
|
+
"--permission-mode",
|
|
170
|
+
"dontAsk",
|
|
171
|
+
"--allowedTools",
|
|
172
|
+
"Read",
|
|
173
|
+
"Grep",
|
|
174
|
+
"Glob",
|
|
175
|
+
"Write",
|
|
176
|
+
...dirs.flatMap((dir) => ["--add-dir", dir]),
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const isScriptShim = (cli) => /\.(cmd|bat)$/i.test(cli)
|
|
181
|
+
const isNodeScript = (file) => /\.(c|m)?js$/i.test(file)
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* `resolveLaunch({ cli, platform, readFile, execPath }) -> { cmd, prefix } | null`:
|
|
185
|
+
* how to start the agent CLI without a shell. Node refuses to start a `.cmd`
|
|
186
|
+
* or `.bat` without one (`EINVAL`), and a shell would parse the prompt's text,
|
|
187
|
+
* which carries file paths, as commands. So an npm shim is never run: on
|
|
188
|
+
* Windows its underlying program is found from the package the shim belongs to
|
|
189
|
+
* (`node_modules/@anthropic-ai/claude-code/package.json`, field `bin`) and
|
|
190
|
+
* started directly, through this process's own Node when it is a script.
|
|
191
|
+
* Anything else starts as itself. A shim whose program cannot be found gives
|
|
192
|
+
* `null`, and nothing is started.
|
|
193
|
+
*/
|
|
194
|
+
export function resolveLaunch({ cli, platform = process.platform, readFile = readFileSync, execPath = process.execPath }) {
|
|
195
|
+
if (platform !== "win32" || !isScriptShim(cli)) {
|
|
196
|
+
return { cmd: cli, prefix: [] }
|
|
197
|
+
}
|
|
198
|
+
const packageDir = path.win32.join(path.win32.dirname(cli), "node_modules", "@anthropic-ai", "claude-code")
|
|
199
|
+
let bin
|
|
200
|
+
try {
|
|
201
|
+
const manifest = JSON.parse(readFile(path.win32.join(packageDir, "package.json"), "utf8"))
|
|
202
|
+
bin = typeof manifest.bin === "string" ? manifest.bin : manifest.bin?.claude
|
|
203
|
+
} catch {
|
|
204
|
+
return null
|
|
205
|
+
}
|
|
206
|
+
if (typeof bin !== "string" || bin === "") {
|
|
207
|
+
return null
|
|
208
|
+
}
|
|
209
|
+
// A rooted path (`\x`, `\\server\share`) or a colon (a drive as in `C:x.exe`, or a stream) is not a file inside the package.
|
|
210
|
+
if (bin.includes(":") || path.win32.isAbsolute(bin)) {
|
|
211
|
+
return null
|
|
212
|
+
}
|
|
213
|
+
const target = path.win32.join(packageDir, bin)
|
|
214
|
+
// Only Windows reaches here, so the package folder is read in Windows spelling (backslashes, drive letters) on every host.
|
|
215
|
+
// A `bin` that climbs out of the package (or is an absolute path elsewhere) names a program the package does not own.
|
|
216
|
+
const within = path.win32.relative(packageDir, target)
|
|
217
|
+
if (within === "" || within.startsWith("..") || path.win32.isAbsolute(within)) {
|
|
218
|
+
return null
|
|
219
|
+
}
|
|
220
|
+
if (isScriptShim(target)) {
|
|
221
|
+
return null
|
|
222
|
+
}
|
|
223
|
+
return isNodeScript(target) ? { cmd: execPath, prefix: [target] } : { cmd: target, prefix: [] }
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* `findAgentCli({ env, exists, platform, homedir, readFile }) -> string | null`: `DESK_AGENT_CLI`, else
|
|
228
|
+
* `claude` on PATH, else `local/claude` in the Claude config directory (`CLAUDE_CONFIG_DIR`, else `~/.claude`), else `~/.local/bin/claude`.
|
|
229
|
+
* On Windows the names are `claude.exe`, then an npm `claude.cmd` (kept only
|
|
230
|
+
* when `resolveLaunch` can start its program), and the home folder is `HOME`,
|
|
231
|
+
* else `USERPROFILE`, else the operating system's answer, because `HOME` is
|
|
232
|
+
* normally unset there. Elsewhere only `HOME` counts.
|
|
233
|
+
*/
|
|
234
|
+
export function findAgentCli({ env, exists = isExecutableFile, platform = process.platform, homedir = osHomedir, readFile = readFileSync }) {
|
|
235
|
+
const windows = platform === "win32"
|
|
236
|
+
const p = windows ? path.win32 : path
|
|
237
|
+
const usable = (candidate) => exists(candidate) && (!isScriptShim(candidate) || resolveLaunch({ cli: candidate, platform, readFile }) !== null)
|
|
238
|
+
const explicit = env.DESK_AGENT_CLI
|
|
239
|
+
if (typeof explicit === "string" && explicit !== "" && usable(explicit)) {
|
|
240
|
+
return explicit
|
|
241
|
+
}
|
|
242
|
+
// The native Claude Code install is `claude.exe` on Windows, and the npm install is `claude.cmd`.
|
|
243
|
+
const names = windows ? ["claude.exe", "claude.cmd"] : ["claude"]
|
|
244
|
+
const dirs = typeof env.PATH === "string" ? env.PATH.split(p.delimiter).filter((dir) => dir !== "") : []
|
|
245
|
+
const candidates = dirs.flatMap((dir) => names.map((name) => p.join(dir, name)))
|
|
246
|
+
const home = [env.HOME, windows ? env.USERPROFILE : undefined, windows ? homedir() : undefined].find((value) => typeof value === "string" && value !== "")
|
|
247
|
+
if (home !== undefined) {
|
|
248
|
+
const configDir = env.CLAUDE_CONFIG_DIR || p.join(home, ".claude")
|
|
249
|
+
for (const name of names) {
|
|
250
|
+
candidates.push(p.join(configDir, "local", name), p.join(home, ".local", "bin", name))
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return candidates.find((candidate) => usable(candidate)) ?? null
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const EXIT_GRACE_MS = 2000
|
|
257
|
+
const noop = () => {}
|
|
258
|
+
|
|
259
|
+
// Runs one child to its end and answers with a small tagged record. The only
|
|
260
|
+
// signal sent goes to the handle returned by `spawn`. The timer and every
|
|
261
|
+
// listener are armed before any caller callback runs, and a callback that
|
|
262
|
+
// throws can neither leave the child unbounded nor escape. The outcome is
|
|
263
|
+
// decided when the child exits, after a short bounded wait for the rest of its
|
|
264
|
+
// output; the pipes are released on every path. Output beyond `maxBytes` is
|
|
265
|
+
// discarded, never buffered, and reported as `truncated`.
|
|
266
|
+
export function runChild({ spawn, cmd, args, opts, timeoutMs, maxBytes, graceMs = EXIT_GRACE_MS, onChild, onChildExit }) {
|
|
267
|
+
return new Promise((resolve) => {
|
|
268
|
+
let child
|
|
269
|
+
try {
|
|
270
|
+
child = spawn(cmd, args, { windowsHide: true, ...opts })
|
|
271
|
+
} catch (error) {
|
|
272
|
+
resolve({ kind: "error", code: error?.code })
|
|
273
|
+
return
|
|
274
|
+
}
|
|
275
|
+
const pid = typeof child.pid === "number" ? child.pid : null
|
|
276
|
+
let reported = false
|
|
277
|
+
let settled = false
|
|
278
|
+
let exitCode = null
|
|
279
|
+
let graceTimer
|
|
280
|
+
const chunks = []
|
|
281
|
+
let size = 0
|
|
282
|
+
let truncated = false
|
|
283
|
+
const settle = (result) => {
|
|
284
|
+
if (settled) {
|
|
285
|
+
return
|
|
286
|
+
}
|
|
287
|
+
settled = true
|
|
288
|
+
clearTimeout(timer)
|
|
289
|
+
clearTimeout(graceTimer)
|
|
290
|
+
child.stdout.destroy?.()
|
|
291
|
+
child.stderr.destroy?.()
|
|
292
|
+
if (reported) {
|
|
293
|
+
try {
|
|
294
|
+
onChildExit?.(pid)
|
|
295
|
+
} catch {
|
|
296
|
+
// A failing callback cannot change the outcome.
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
resolve(result)
|
|
300
|
+
}
|
|
301
|
+
const closed = (code) => settle({ kind: "closed", code, truncated, stdout: truncated ? "" : Buffer.concat(chunks).toString("utf8") })
|
|
302
|
+
const timer = setTimeout(() => {
|
|
303
|
+
child.kill("SIGKILL")
|
|
304
|
+
settle({ kind: "timeout" })
|
|
305
|
+
}, timeoutMs)
|
|
306
|
+
child.stdout.on("data", (chunk) => {
|
|
307
|
+
if (truncated) {
|
|
308
|
+
return
|
|
309
|
+
}
|
|
310
|
+
size += chunk.length
|
|
311
|
+
if (size > maxBytes) {
|
|
312
|
+
truncated = true
|
|
313
|
+
chunks.length = 0
|
|
314
|
+
return
|
|
315
|
+
}
|
|
316
|
+
chunks.push(chunk)
|
|
317
|
+
})
|
|
318
|
+
// Drained and dropped: stderr text is never kept.
|
|
319
|
+
child.stderr.on("data", noop)
|
|
320
|
+
child.stdout.on("error", noop)
|
|
321
|
+
child.stderr.on("error", noop)
|
|
322
|
+
child.on("error", (error) => settle({ kind: "error", code: error?.code }))
|
|
323
|
+
child.on("exit", (code) => {
|
|
324
|
+
exitCode = code
|
|
325
|
+
graceTimer = setTimeout(() => closed(exitCode), graceMs)
|
|
326
|
+
})
|
|
327
|
+
child.on("close", (code) => closed(code))
|
|
328
|
+
if (pid !== null) {
|
|
329
|
+
try {
|
|
330
|
+
onChild?.(pid)
|
|
331
|
+
reported = true
|
|
332
|
+
} catch {
|
|
333
|
+
child.kill("SIGKILL")
|
|
334
|
+
settle({ kind: "callback_failed" })
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
})
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function parseObject(text) {
|
|
341
|
+
try {
|
|
342
|
+
const value = JSON.parse(text)
|
|
343
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null
|
|
344
|
+
} catch {
|
|
345
|
+
return null
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const SIGN_IN_STATES = Object.freeze(["subscription", "no_credentials", "disabled_would_bill", "sign_in_unknown"])
|
|
350
|
+
const nonEmptyString = (value) => typeof value === "string" && value !== ""
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* `probeSignIn({ cli, env, spawn, timeoutMs, onChild, onChildExit }) ->
|
|
354
|
+
* Promise<{ state }>` with `state` one of `subscription`, `no_credentials`,
|
|
355
|
+
* `disabled_would_bill`, `sign_in_unknown`. A billing variable in `env` gives
|
|
356
|
+
* `disabled_would_bill` without starting anything. Otherwise it runs
|
|
357
|
+
* `<cli> auth status` with the same allowlisted environment as the run, and
|
|
358
|
+
* reads only `loggedIn`, `authMethod`, `apiProvider` and `subscriptionType`;
|
|
359
|
+
* nothing else of its output is kept or returned.
|
|
360
|
+
*/
|
|
361
|
+
export async function probeSignIn({ cli, env, spawn = nodeSpawn, timeoutMs = PROBE_TIMEOUT_MS, onChild, onChildExit, platform = process.platform, readFile = readFileSync, execPath = process.execPath }) {
|
|
362
|
+
if (billingVariableBlocks(env)) {
|
|
363
|
+
return { state: "disabled_would_bill" }
|
|
364
|
+
}
|
|
365
|
+
const launch = resolveLaunch({ cli, platform, readFile, execPath })
|
|
366
|
+
if (launch === null) {
|
|
367
|
+
return { state: "sign_in_unknown" }
|
|
368
|
+
}
|
|
369
|
+
const run = await runChild({
|
|
370
|
+
spawn,
|
|
371
|
+
cmd: launch.cmd,
|
|
372
|
+
args: [...launch.prefix, "auth", "status"],
|
|
373
|
+
opts: { env: childEnvironment(env), stdio: ["ignore", "pipe", "pipe"] },
|
|
374
|
+
timeoutMs,
|
|
375
|
+
maxBytes: PROBE_MAX_BYTES,
|
|
376
|
+
onChild,
|
|
377
|
+
onChildExit,
|
|
378
|
+
})
|
|
379
|
+
if (run.kind !== "closed") {
|
|
380
|
+
return { state: "sign_in_unknown" }
|
|
381
|
+
}
|
|
382
|
+
const parsed = parseObject(run.stdout)
|
|
383
|
+
if (parsed === null || typeof parsed.loggedIn !== "boolean") {
|
|
384
|
+
return { state: "sign_in_unknown" }
|
|
385
|
+
}
|
|
386
|
+
if (!parsed.loggedIn) {
|
|
387
|
+
return { state: "no_credentials" }
|
|
388
|
+
}
|
|
389
|
+
if (!nonEmptyString(parsed.authMethod) || !nonEmptyString(parsed.apiProvider)) {
|
|
390
|
+
return { state: "sign_in_unknown" }
|
|
391
|
+
}
|
|
392
|
+
if (parsed.apiProvider !== "firstParty" || parsed.authMethod !== "claude.ai") {
|
|
393
|
+
return { state: "disabled_would_bill" }
|
|
394
|
+
}
|
|
395
|
+
if (!nonEmptyString(parsed.subscriptionType)) {
|
|
396
|
+
return { state: "sign_in_unknown" }
|
|
397
|
+
}
|
|
398
|
+
return { state: "subscription" }
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function effectiveContextSource(text, version) {
|
|
402
|
+
const lines = text.replace(/\r\n/gu, "\n").trim().split("\n")
|
|
403
|
+
if (lines[0] !== `desk ${version}` || lines.filter((line) => /^desk(?:\s|$)/u.test(line.trim())).length !== 1) return false
|
|
404
|
+
const sources = lines.filter((line) => /^\s*Source:/u.test(line))
|
|
405
|
+
if (sources.length !== 1 || sources[0].trim() !== "Source: desk@inline") return false
|
|
406
|
+
const inventory = lines.indexOf("Component inventory")
|
|
407
|
+
const skills = lines.map((line, index) => ({ line, index })).filter(({ line }) => /^\s*Skills\b/u.test(line))
|
|
408
|
+
if (inventory < 0 || lines.lastIndexOf("Component inventory") !== inventory || skills.length !== 1 || skills[0].index <= inventory) return false
|
|
409
|
+
const match = /^ Skills \((\d+)\)(?: (.+))?$/u.exec(skills[0].line)
|
|
410
|
+
if (match === null) return false
|
|
411
|
+
const names = match[2]?.split(",").map((name) => name.trim()) ?? []
|
|
412
|
+
return names.length === Number(match[1]) && new Set(names).size === names.length && names.includes("factory-task-context")
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/** Model-free pre/post compatibility checks, not an attestation from the model's own process. */
|
|
416
|
+
export async function qualifyHeadlessSource({
|
|
417
|
+
cli, env, pluginRoot, pluginVersion, evaluationDir, logDirs, workDir,
|
|
418
|
+
spawn = nodeSpawn, timeoutMs = PROBE_TIMEOUT_MS, onChild, onChildExit,
|
|
419
|
+
platform = process.platform, readFile = readFileSync, execPath = process.execPath,
|
|
420
|
+
}) {
|
|
421
|
+
const refused = { state: "source_unqualified" }
|
|
422
|
+
if (!nonEmptyString(pluginRoot) || !nonEmptyString(pluginVersion) || isHeadlessSession(env) || billingVariableBlocks(env)) return refused
|
|
423
|
+
const launch = resolveLaunch({ cli, platform, readFile, execPath })
|
|
424
|
+
if (launch === null) return refused
|
|
425
|
+
const args = [
|
|
426
|
+
...launch.prefix, "--plugin-dir", pluginRoot,
|
|
427
|
+
...[evaluationDir, ...new Set(logDirs)].flatMap((dir) => ["--add-dir", dir]),
|
|
428
|
+
// --add-dir is variadic; this flag keeps the metadata command out of its values.
|
|
429
|
+
"--permission-mode", "dontAsk",
|
|
430
|
+
]
|
|
431
|
+
const started = Date.now()
|
|
432
|
+
const metadata = async (command) => {
|
|
433
|
+
const remaining = Math.min(timeoutMs, PROBE_TIMEOUT_MS) - (Date.now() - started)
|
|
434
|
+
if (remaining <= 0) return null
|
|
435
|
+
const run = await runChild({
|
|
436
|
+
spawn, cmd: launch.cmd, args: [...args, "plugin", ...command],
|
|
437
|
+
opts: { cwd: workDir, env: childEnvironment(env), stdio: ["ignore", "pipe", "pipe"] },
|
|
438
|
+
timeoutMs: remaining, maxBytes: PROBE_MAX_BYTES, onChild, onChildExit,
|
|
439
|
+
})
|
|
440
|
+
return run.kind === "closed" && run.code === 0 && !run.truncated ? run.stdout : null
|
|
441
|
+
}
|
|
442
|
+
const list = await metadata(["list", "--json"])
|
|
443
|
+
let rows
|
|
444
|
+
try {
|
|
445
|
+
rows = JSON.parse(list)
|
|
446
|
+
} catch {
|
|
447
|
+
return refused
|
|
448
|
+
}
|
|
449
|
+
if (!Array.isArray(rows)) return refused
|
|
450
|
+
const inline = rows.filter((row) => row?.id === "desk@inline")
|
|
451
|
+
if (inline.length !== 1 || inline[0].scope !== "session" || inline[0].enabled !== true ||
|
|
452
|
+
inline[0].version !== pluginVersion || !nonEmptyString(inline[0].installPath)) return refused
|
|
453
|
+
try {
|
|
454
|
+
if (realpathSync(inline[0].installPath) !== realpathSync(pluginRoot)) return refused
|
|
455
|
+
} catch {
|
|
456
|
+
return refused
|
|
457
|
+
}
|
|
458
|
+
const details = await metadata(["details", "desk"])
|
|
459
|
+
return details !== null && effectiveContextSource(details, pluginVersion) ? { state: "qualified" } : refused
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
const result = (state, cost_usd = null, detail = null) => ({ state, cost_usd, detail })
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* `runHeadless({ env, job, briefPaths, evaluationDir, logDirs, workDir, spawn,
|
|
466
|
+
* cli, signIn, exists, dirExists, timeoutMs, onChild, onChildExit }) ->
|
|
467
|
+
* Promise<{ state, cost_usd, detail }>`. `job.host` is required; a missing or
|
|
468
|
+
* unsupported host is `unsupported_host`. `state` is one of `ran`,
|
|
469
|
+
* `no_agent_cli`, `no_credentials`, `timeout`, `budget_exceeded`, `failed`,
|
|
470
|
+
* `unsupported_host`, `disabled_would_bill`, `sign_in_unknown`,
|
|
471
|
+
* `headless_session`. `workDir` is the scratch working folder and must exist
|
|
472
|
+
* (`failed` with detail `work_dir_missing` otherwise). `signIn` is an optional
|
|
473
|
+
* already-computed `probeSignIn` result; the environment is checked first
|
|
474
|
+
* whatever it says, and an unknown state counts as `sign_in_unknown`. Without
|
|
475
|
+
* it the runner probes. `onChild(pid)` and `onChildExit(pid)` report each
|
|
476
|
+
* child it starts (the probe's too), for the caller's lock file.
|
|
477
|
+
*/
|
|
478
|
+
export async function runHeadless({
|
|
479
|
+
env,
|
|
480
|
+
job,
|
|
481
|
+
briefPaths,
|
|
482
|
+
evaluationDir,
|
|
483
|
+
logDirs,
|
|
484
|
+
workDir,
|
|
485
|
+
spawn = nodeSpawn,
|
|
486
|
+
cli,
|
|
487
|
+
signIn,
|
|
488
|
+
exists = isExecutableFile,
|
|
489
|
+
dirExists = isDirectory,
|
|
490
|
+
timeoutMs = HEADLESS_TIMEOUT_MS,
|
|
491
|
+
onChild,
|
|
492
|
+
onChildExit,
|
|
493
|
+
platform = process.platform,
|
|
494
|
+
homedir = osHomedir,
|
|
495
|
+
readFile = readFileSync,
|
|
496
|
+
execPath = process.execPath,
|
|
497
|
+
purpose = "labels",
|
|
498
|
+
pluginRoot,
|
|
499
|
+
}) {
|
|
500
|
+
if (isHeadlessSession(env)) {
|
|
501
|
+
return result("headless_session")
|
|
502
|
+
}
|
|
503
|
+
if (!hostSupported(job?.host)) {
|
|
504
|
+
return result("unsupported_host")
|
|
505
|
+
}
|
|
506
|
+
if (billingVariableBlocks(env)) {
|
|
507
|
+
return result("disabled_would_bill")
|
|
508
|
+
}
|
|
509
|
+
const agentCli = cli ?? findAgentCli({ env, exists, platform, homedir, readFile })
|
|
510
|
+
if (agentCli === null) {
|
|
511
|
+
return result("no_agent_cli")
|
|
512
|
+
}
|
|
513
|
+
const launch = resolveLaunch({ cli: agentCli, platform, readFile, execPath })
|
|
514
|
+
if (launch === null) {
|
|
515
|
+
return result("no_agent_cli")
|
|
516
|
+
}
|
|
517
|
+
if (typeof workDir !== "string" || !dirExists(workDir)) {
|
|
518
|
+
return result("failed", null, "work_dir_missing")
|
|
519
|
+
}
|
|
520
|
+
const signedIn = signIn ?? (await probeSignIn({ cli: agentCli, env, spawn, onChild, onChildExit, platform, readFile, execPath }))
|
|
521
|
+
const signInState = SIGN_IN_STATES.includes(signedIn?.state) ? signedIn.state : "sign_in_unknown"
|
|
522
|
+
if (signInState !== "subscription") {
|
|
523
|
+
return result(signInState)
|
|
524
|
+
}
|
|
525
|
+
const run = await runChild({
|
|
526
|
+
spawn,
|
|
527
|
+
cmd: launch.cmd,
|
|
528
|
+
args: [...launch.prefix, ...HEADLESS_ARGV({
|
|
529
|
+
briefPaths, evaluationDir, logDirs, purpose, pluginRoot: purpose === "labels" ? undefined : pluginRoot ?? deskPluginRoot(env),
|
|
530
|
+
})],
|
|
531
|
+
opts: { cwd: workDir, env: childEnvironment(env), stdio: ["ignore", "pipe", "pipe"] },
|
|
532
|
+
timeoutMs,
|
|
533
|
+
maxBytes: RUN_MAX_BYTES,
|
|
534
|
+
onChild,
|
|
535
|
+
onChildExit,
|
|
536
|
+
})
|
|
537
|
+
if (run.kind === "timeout") {
|
|
538
|
+
return result("timeout")
|
|
539
|
+
}
|
|
540
|
+
if (run.kind === "callback_failed") {
|
|
541
|
+
return result("failed", null, "callback_failed")
|
|
542
|
+
}
|
|
543
|
+
if (run.kind === "error") {
|
|
544
|
+
return run.code === "ENOENT" ? result("no_agent_cli") : result("failed", null, "spawn_error")
|
|
545
|
+
}
|
|
546
|
+
if (run.truncated) {
|
|
547
|
+
return result("failed", null, "output_too_large")
|
|
548
|
+
}
|
|
549
|
+
const output = parseObject(run.stdout)
|
|
550
|
+
if (output === null) {
|
|
551
|
+
return result("failed", null, "output_unparsable")
|
|
552
|
+
}
|
|
553
|
+
const cost = Number.isFinite(output.total_cost_usd) && output.total_cost_usd >= 0 ? output.total_cost_usd : null
|
|
554
|
+
if (typeof output.subtype === "string" && output.subtype.includes("budget")) {
|
|
555
|
+
return result("budget_exceeded", cost)
|
|
556
|
+
}
|
|
557
|
+
if (output.is_error === true) {
|
|
558
|
+
return result("failed", cost, "agent_error")
|
|
559
|
+
}
|
|
560
|
+
if (run.code !== 0) {
|
|
561
|
+
return result("failed", cost, "exit_nonzero")
|
|
562
|
+
}
|
|
563
|
+
if (output.is_error !== false || output.subtype !== "success") {
|
|
564
|
+
return result("failed", cost, "output_unexpected")
|
|
565
|
+
}
|
|
566
|
+
return result("ran", cost)
|
|
567
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Held routes. A session hook that could not read the plugin set (a manifest or plugin folder it could not read, a registry that is missing
|
|
2
|
+
// or does not list Desk, too many plugins, a scan cut short) records a held route: no store, so the session is never derived or published.
|
|
3
|
+
// A hold is released only by something that positively declares a store for that session: every reader routes a desk that declares its
|
|
4
|
+
// store in `_meta/factory.json` to it, and reads the warned manifests again (`store-route.js` `recheckRoute`), so a manifest the session
|
|
5
|
+
// itself loaded that now declares a store other than the public one routes it there. Nothing infers the default store for a held session: another session's plugin
|
|
6
|
+
// scan says nothing about the plugins this one ran with (a `claude --plugin-dir` overlay, another config folder, an overlay uninstalled
|
|
7
|
+
// since), so a hold whose cause cleared without a declaration waits. A held marker is kept for 90 days (`outbox.js` `listMarkers`),
|
|
8
|
+
// counted with its reason by the sweep for `desk_doctor` and the boot line (`routeHolds`), and reported once pruned (`held_pruned`), so a
|
|
9
|
+
// hold is never silent.
|
|
10
|
+
//
|
|
11
|
+
// `src/factory/**` imports only `node:` built-ins and other `src/factory/` files.
|
|
12
|
+
|
|
13
|
+
import { lstatSync, statSync } from "node:fs"
|
|
14
|
+
import * as path from "node:path"
|
|
15
|
+
|
|
16
|
+
import { MAX_MARKER_BYTES, readSmallText } from "./marker.js"
|
|
17
|
+
import { markerRoute, recordedHeld } from "./session-route.js"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* `routeHolds(markers) -> { count, reasons }`: the markers whose route is held now (`session-route.js`), with each distinct reason: `{ code,
|
|
21
|
+
* path, sessions }`, `code` being the recorded warning's code and `path` its manifest or plugin folder, or `plugin_scan_incomplete` with no
|
|
22
|
+
* path when the hook named none. At most 8 reasons, the most common first.
|
|
23
|
+
*/
|
|
24
|
+
export function routeHolds(markers) {
|
|
25
|
+
const reasons = new Map()
|
|
26
|
+
let count = 0
|
|
27
|
+
for (const marker of markers) {
|
|
28
|
+
if (typeof marker.desk_root !== "string" || !recordedHeld(marker) || markerRoute(marker).store !== null) continue
|
|
29
|
+
count += 1
|
|
30
|
+
const { warnings } = marker.routing
|
|
31
|
+
const keys = warnings.length > 0 ? warnings.map(({ code, manifest }) => [code, manifest]) : [["plugin_scan_incomplete", null]]
|
|
32
|
+
for (const [code, file] of keys) {
|
|
33
|
+
const key = `${code}\0${file}`
|
|
34
|
+
reasons.set(key, { code, path: file, sessions: (reasons.get(key)?.sessions ?? 0) + 1 })
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { count, reasons: [...reasons.values()].sort((a, b) => b.sessions - a.sessions).slice(0, 8) }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const REMEDY_LINKS = "install the plugin without links (Desk reads only a plain manifest file), or declare the store in the desk's `_meta/factory.json`"
|
|
41
|
+
const REMEDY_PLUGIN = "fix, reinstall or remove that plugin, or declare the store in the desk's `_meta/factory.json`"
|
|
42
|
+
const REMEDY_SCAN = "start sessions from an installed Desk (not `claude --plugin-dir`) so the plugin list can be read, or declare the store in the desk's `_meta/factory.json`"
|
|
43
|
+
/** What the operator can do about each hold reason (`holdReason`). */
|
|
44
|
+
export const HOLD_REMEDIES = Object.freeze({
|
|
45
|
+
manifest_symlinked: REMEDY_LINKS,
|
|
46
|
+
manifest_hardlinked: REMEDY_LINKS,
|
|
47
|
+
manifest_too_large: REMEDY_PLUGIN,
|
|
48
|
+
manifest_missing: REMEDY_PLUGIN,
|
|
49
|
+
manifest_unreadable: REMEDY_PLUGIN,
|
|
50
|
+
manifest_unparseable: REMEDY_PLUGIN,
|
|
51
|
+
plugin_missing: REMEDY_PLUGIN,
|
|
52
|
+
plugin_unreadable: REMEDY_PLUGIN,
|
|
53
|
+
registry_missing: REMEDY_SCAN,
|
|
54
|
+
registry_unreadable: REMEDY_SCAN,
|
|
55
|
+
desk_not_in_registry: REMEDY_SCAN,
|
|
56
|
+
too_many_plugins: "remove plugins until at most 64 are installed, or declare the store in the desk's `_meta/factory.json`",
|
|
57
|
+
scan_deadline: "nothing; the next session reads the plugin list again",
|
|
58
|
+
plugin_scan_incomplete: REMEDY_SCAN,
|
|
59
|
+
needs_declaration: "the plugin reads now but declares no private store, and the plugins this session ran with cannot be read again; declare the store in the desk's `_meta/factory.json` to release it, or it is pruned after 90 days",
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Why `file` (a recorded warning's manifest or plugin folder, or `null` for a hold that named none) holds a route now, as a `HOLD_REMEDIES`
|
|
64
|
+
* key, read from the file as it is now: a link, a hard link, a file too large, a file or folder that is missing, or one that cannot be read
|
|
65
|
+
* or parsed; `needs_declaration` when it now reads (only a declaration releases the hold).
|
|
66
|
+
*/
|
|
67
|
+
export function holdReason(file, { code = "manifest_unreadable" } = {}) {
|
|
68
|
+
if (file === null) return "plugin_scan_incomplete"
|
|
69
|
+
const manifest = path.basename(file) === "plugin.json"
|
|
70
|
+
let info
|
|
71
|
+
try {
|
|
72
|
+
info = lstatSync(file)
|
|
73
|
+
} catch {
|
|
74
|
+
return path.basename(file) === "installed_plugins.json" ? "registry_missing" : manifest ? "manifest_missing" : "plugin_missing"
|
|
75
|
+
}
|
|
76
|
+
if (!manifest && !info.isFile()) {
|
|
77
|
+
// A plugin folder, or a link to one: held only while it does not resolve to a folder that reads.
|
|
78
|
+
try {
|
|
79
|
+
return statSync(file).isDirectory() ? "needs_declaration" : "plugin_unreadable"
|
|
80
|
+
} catch {
|
|
81
|
+
return "plugin_missing"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (info.isSymbolicLink()) return "manifest_symlinked"
|
|
85
|
+
if (info.nlink > 1) return "manifest_hardlinked"
|
|
86
|
+
if (info.size > MAX_MARKER_BYTES) return "manifest_too_large"
|
|
87
|
+
try {
|
|
88
|
+
JSON.parse(readSmallText(file))
|
|
89
|
+
return "needs_declaration"
|
|
90
|
+
} catch {
|
|
91
|
+
return code === "manifest_unparseable" ? "manifest_unparseable" : "manifest_unreadable"
|
|
92
|
+
}
|
|
93
|
+
}
|