@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,301 @@
|
|
|
1
|
+
// The `sessions` command line: what a session on this machine last said, which session is this one, and a message to another
|
|
2
|
+
// session that is judged delivered only when it shows in that session's own history. It covers this machine only; reach another
|
|
3
|
+
// machine's sessions by running the same command there. Output is one JSON value on stdout; a usage error is one line on stderr
|
|
4
|
+
// (exit 2) and a failure is a Desk failure line on stderr (exit 1).
|
|
5
|
+
//
|
|
6
|
+
// Sessions live in `<COPILOT_HOME>/session-state/<id>/` (`events.jsonl` holds the history, `inuse.<pid>.lock` marks a live host
|
|
7
|
+
// process, `workspace.yaml` holds the name). A send goes through the Copilot app's local WebSocket (`<COPILOT_HOME>/run/ws.port`
|
|
8
|
+
// and `ws.token`), which loads a session that is not in memory before it answers.
|
|
9
|
+
import { randomBytes } from "node:crypto"
|
|
10
|
+
import { closeSync, fstatSync, openSync, readFileSync, readSync, readdirSync, existsSync } from "node:fs"
|
|
11
|
+
import { spawnSync } from "node:child_process"
|
|
12
|
+
import * as os from "node:os"
|
|
13
|
+
import * as path from "node:path"
|
|
14
|
+
import { AxError } from "../lib/ouro-ui/registry/ouro/ax/problem.ts"
|
|
15
|
+
import { defineCli, defineCommand } from "../lib/ouro-ui/registry/ouro/ax/ax-command.ts"
|
|
16
|
+
import { runCli } from "../lib/ouro-ui/registry/ouro/ax/cli.ts"
|
|
17
|
+
import { deskFailure } from "./desk-failure.js"
|
|
18
|
+
|
|
19
|
+
const UUID = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/iu
|
|
20
|
+
const SEND_WAIT_MS = 120000
|
|
21
|
+
const TAIL_BYTES = 2 << 20
|
|
22
|
+
const MESSAGE_CHARS = 2000
|
|
23
|
+
|
|
24
|
+
const failure = (code, thing, probably, look, fix) => new Error(deskFailure({ code, thing, probably, look, keepWorking: "read the session's history with tail, or message it with the app's send_session_message tool", fix }))
|
|
25
|
+
|
|
26
|
+
const copilotHome = ({ env, home }) => env.COPILOT_HOME || path.join(home, ".copilot")
|
|
27
|
+
|
|
28
|
+
/** The folder every session's state lives in. */
|
|
29
|
+
const sessionStateDir = (where) => path.join(copilotHome(where), "session-state")
|
|
30
|
+
|
|
31
|
+
const yamlField = (text, key) => {
|
|
32
|
+
const match = new RegExp(`^${key}:[ \\t]*(.*)$`, "mu").exec(String(text))
|
|
33
|
+
return match === null ? null : match[1].replace(/^['"]|['"]$/gu, "").trim()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The last `bytes` of a session's history and when it was last written, or null when it has none. */
|
|
37
|
+
function readHistoryTail(stateDir, id, bytes = TAIL_BYTES) {
|
|
38
|
+
try {
|
|
39
|
+
const fd = openSync(path.join(stateDir, id, "events.jsonl"), "r")
|
|
40
|
+
try {
|
|
41
|
+
const { size, mtime } = fstatSync(fd)
|
|
42
|
+
const length = Math.min(size, bytes)
|
|
43
|
+
const buffer = Buffer.alloc(length)
|
|
44
|
+
readSync(fd, buffer, 0, length, size - length)
|
|
45
|
+
return { text: buffer.toString("utf8"), mtime: mtime.toISOString() }
|
|
46
|
+
} finally {
|
|
47
|
+
closeSync(fd)
|
|
48
|
+
}
|
|
49
|
+
} catch {
|
|
50
|
+
return null
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The last `count` user and assistant messages in a history's text, oldest first. */
|
|
55
|
+
export function tailMessages(text, count) {
|
|
56
|
+
const messages = []
|
|
57
|
+
for (const line of String(text).split("\n")) {
|
|
58
|
+
if (!line.startsWith("{")) continue
|
|
59
|
+
let event
|
|
60
|
+
try {
|
|
61
|
+
event = JSON.parse(line)
|
|
62
|
+
} catch {
|
|
63
|
+
continue
|
|
64
|
+
}
|
|
65
|
+
const content = String(event.data?.content ?? "")
|
|
66
|
+
if (event.type === "user.message") messages.push({ at: event.timestamp, role: "user", text: content.slice(0, MESSAGE_CHARS) })
|
|
67
|
+
else if (event.type === "assistant.message" && content.trim() !== "") messages.push({ at: event.timestamp, role: "assistant", text: content.slice(0, MESSAGE_CHARS) })
|
|
68
|
+
}
|
|
69
|
+
return messages.slice(-count)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The name the app gave a session, or null. */
|
|
73
|
+
export function nameOf(stateDir, id) {
|
|
74
|
+
try {
|
|
75
|
+
return yamlField(readFileSync(path.join(stateDir, id, "workspace.yaml"), "utf8"), "name") || null
|
|
76
|
+
} catch {
|
|
77
|
+
return null
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The one session `ref` names: a full id, a unique id prefix or an exact name. Returns `{ id }` or `{ reason }` saying what matched instead. */
|
|
82
|
+
export function resolveSession(stateDir, ref) {
|
|
83
|
+
if (UUID.test(ref)) return { id: ref.toLowerCase() }
|
|
84
|
+
let ids
|
|
85
|
+
try {
|
|
86
|
+
ids = readdirSync(stateDir).filter((entry) => UUID.test(entry))
|
|
87
|
+
} catch {
|
|
88
|
+
return { reason: `there is no session-state folder at ${stateDir}` }
|
|
89
|
+
}
|
|
90
|
+
const prefixed = /^[0-9a-f-]{6,}$/iu.test(ref) ? ids.filter((id) => id.startsWith(ref.toLowerCase())) : []
|
|
91
|
+
const hits = prefixed.length > 0 ? prefixed : ids.filter((id) => nameOf(stateDir, id)?.toLowerCase() === ref.toLowerCase())
|
|
92
|
+
if (hits.length === 1) return { id: hits[0] }
|
|
93
|
+
if (hits.length === 0) return { reason: `no session on this machine has the id prefix or exact name ${JSON.stringify(ref)}` }
|
|
94
|
+
return { reason: `${JSON.stringify(ref)} matches ${hits.length} sessions: ${hits.map((id) => `${nameOf(stateDir, id) ?? "unnamed"} (${id.slice(0, 8)})`).join(", ")}` }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The sessions whose live host process is `pid` or one of its ancestors. `parentOf(pid)` is the parent process id, or 0; `exists` and `list` read the file system. */
|
|
98
|
+
export function selfSessions(stateDir, { pid, parentOf, exists, list }) {
|
|
99
|
+
let ids = []
|
|
100
|
+
try {
|
|
101
|
+
ids = list(stateDir).filter((entry) => UUID.test(entry))
|
|
102
|
+
} catch {
|
|
103
|
+
return []
|
|
104
|
+
}
|
|
105
|
+
const found = new Set()
|
|
106
|
+
for (let current = pid, hops = 0; current > 1 && hops < 12 && found.size === 0; current = parentOf(current), hops += 1) {
|
|
107
|
+
for (const id of ids) if (exists(path.join(stateDir, id, `inuse.${current}.lock`))) found.add(id)
|
|
108
|
+
}
|
|
109
|
+
return [...found].sort()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** This session: the only candidate, or the one whose recent history holds `hint` (the agent's own command line is in it). */
|
|
113
|
+
export function whoAmI(stateDir, hint, self) {
|
|
114
|
+
const ids = selfSessions(stateDir, self)
|
|
115
|
+
if (ids.length === 1) return { ids, id: ids[0] }
|
|
116
|
+
if (ids.length === 0 || hint === null) return { ids, id: null }
|
|
117
|
+
const hits = ids.filter((id) => (readHistoryTail(stateDir, id, 512 * 1024)?.text ?? "").includes(hint))
|
|
118
|
+
return { ids, id: hits.length === 1 ? hits[0] : null }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** The parent process id of `pid`, or 0 when `ps` cannot say. */
|
|
122
|
+
export const parentOfProcess = (pid, run = spawnSync) => Number(String(run("ps", ["-o", "ppid=", "-p", String(pid)], { encoding: "utf8", windowsHide: true }).stdout ?? "").trim())
|
|
123
|
+
|
|
124
|
+
/** The message with a header naming the sender and how to reply. The nonce is how the send finds it again in the target's history. */
|
|
125
|
+
export function envelope({ nonce, from, name, host, text, script }) {
|
|
126
|
+
const sender = from === null ? "an unidentified session" : `${from} (${String(name ?? "unnamed session").replace(/[()\n]/gu, " ").slice(0, 80)})`
|
|
127
|
+
const reply = from === null
|
|
128
|
+
? "The sender gave no session id, so there is no reply address."
|
|
129
|
+
: `Reply only if it needs an answer, never to acknowledge an acknowledgement. To reply, call the app's send_session_message with session_id ${from}, or run: node "${script}" send ${from} "<your reply>"`
|
|
130
|
+
return `[Message ${nonce} from ${sender} on ${host}, sent with sessions.js send.]\n\n${text}\n\n[${reply}]`
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const alive = (pid) => {
|
|
134
|
+
try {
|
|
135
|
+
process.kill(pid, 0)
|
|
136
|
+
return true
|
|
137
|
+
} catch (error) {
|
|
138
|
+
return error.code === "EPERM"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** The app's local WebSocket address and token as `{ port, token }`, or `{ reason }` in a plain sentence when the app is not running. */
|
|
143
|
+
export function appSocket(where) {
|
|
144
|
+
const run = path.join(copilotHome(where), "run")
|
|
145
|
+
let port
|
|
146
|
+
let owner
|
|
147
|
+
let token
|
|
148
|
+
try {
|
|
149
|
+
;[port, owner] = readFileSync(path.join(run, "ws.port"), "utf8").trim().split(/\r?\n/u)
|
|
150
|
+
;[token] = readFileSync(path.join(run, "ws.token"), "utf8").trim().split(/\r?\n/u)
|
|
151
|
+
} catch {
|
|
152
|
+
return { reason: "the app has not written its local socket files, so it is not running" }
|
|
153
|
+
}
|
|
154
|
+
if (owner && !alive(Number(owner))) return { reason: "the app that wrote its local socket is not running" }
|
|
155
|
+
return { port, token }
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Sends `messages` to the app and collects the replies `keep` accepts until `done` says stop or `waitMs` passes. */
|
|
159
|
+
export function exchange(socket, messages, { done, keep, waitMs }, WebSocketImpl = globalThis.WebSocket) {
|
|
160
|
+
return new Promise((resolve) => {
|
|
161
|
+
const got = []
|
|
162
|
+
const ws = new WebSocketImpl(`ws://127.0.0.1:${socket.port}/?token=${encodeURIComponent(socket.token)}&observer=1`)
|
|
163
|
+
const finish = () => {
|
|
164
|
+
clearTimeout(timer)
|
|
165
|
+
try {
|
|
166
|
+
ws.close()
|
|
167
|
+
} catch {
|
|
168
|
+
// Already closed.
|
|
169
|
+
}
|
|
170
|
+
resolve(got)
|
|
171
|
+
}
|
|
172
|
+
const timer = setTimeout(finish, waitMs)
|
|
173
|
+
ws.addEventListener("open", () => {
|
|
174
|
+
for (const message of messages) ws.send(JSON.stringify(message))
|
|
175
|
+
})
|
|
176
|
+
ws.addEventListener("message", (event) => {
|
|
177
|
+
let reply
|
|
178
|
+
try {
|
|
179
|
+
reply = JSON.parse(String(event.data))
|
|
180
|
+
} catch {
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
if (!keep(reply)) return
|
|
184
|
+
got.push(reply)
|
|
185
|
+
if (done(reply)) finish()
|
|
186
|
+
})
|
|
187
|
+
ws.addEventListener("error", () => {
|
|
188
|
+
got.push({ type: "socket_error" })
|
|
189
|
+
finish()
|
|
190
|
+
})
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Asks the app to deliver `prompt` to session `id` and reports what it answered. It always waits for the answer: closing the socket first cancels a send to a session the app is still loading. */
|
|
195
|
+
export async function sendThroughApp({ id, prompt, socket, send = exchange, newRequestId = () => randomBytes(8).toString("hex") }) {
|
|
196
|
+
const request_id = newRequestId()
|
|
197
|
+
const got = await send(socket, [{ type: "send_message", session_id: id, prompt, delivery_mode: "immediate", request_id }], {
|
|
198
|
+
keep: (reply) => reply.request_id === request_id || (reply.session_id === id && /message_(?:sent|queued|delivery)/u.test(reply.type)) || reply.type === "socket_error",
|
|
199
|
+
done: (reply) => /^(?:session_message_sent|session_message_queued|session_message_delivery_unknown|error|socket_error)$/u.test(reply.type),
|
|
200
|
+
waitMs: SEND_WAIT_MS,
|
|
201
|
+
})
|
|
202
|
+
const last = got.at(-1)
|
|
203
|
+
return { accepted: Boolean(last && /^session_message_(?:sent|queued)$/u.test(last.type)), reply: last?.type ?? "no reply", error: last?.type === "error" ? String(last.message).slice(0, 300) : null }
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const defaults = (env) => ({
|
|
207
|
+
stateDir: sessionStateDir({ env, home: os.homedir() }),
|
|
208
|
+
self: { pid: process.pid, parentOf: parentOfProcess, exists: existsSync, list: readdirSync },
|
|
209
|
+
socket: () => appSocket({ env, home: os.homedir() }),
|
|
210
|
+
send: sendThroughApp,
|
|
211
|
+
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
212
|
+
now: () => Date.now(),
|
|
213
|
+
platform: process.platform,
|
|
214
|
+
host: os.hostname().split(".")[0].toLowerCase(),
|
|
215
|
+
nonce: () => randomBytes(4).toString("hex"),
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
/** Waits for `seen()` to turn true, looking every 1.5 s, for at most `waitMs`. */
|
|
219
|
+
async function seenWithin(seen, waitMs, { sleep, now }) {
|
|
220
|
+
const end = now() + waitMs
|
|
221
|
+
let found = seen()
|
|
222
|
+
while (!found && now() < end) {
|
|
223
|
+
await sleep(1500)
|
|
224
|
+
found = seen()
|
|
225
|
+
}
|
|
226
|
+
return found
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async function runSend({ ref, message, from: fromFlag, asUser, waitMs, script, deps }) {
|
|
230
|
+
const target = resolveSession(deps.stateDir, ref)
|
|
231
|
+
if (target.reason !== undefined) {
|
|
232
|
+
throw failure("sessions_target", `cannot send to ${JSON.stringify(ref)}`, target.reason, "run sessions.js tail <id or name> to check the session, or ask the person which one is meant", "pass the full session id")
|
|
233
|
+
}
|
|
234
|
+
const nonce = deps.nonce()
|
|
235
|
+
let prompt = message
|
|
236
|
+
let sender = null
|
|
237
|
+
if (!asUser) {
|
|
238
|
+
// The first words of the command are in the sender's own history, which picks it out of several sessions in one runtime.
|
|
239
|
+
const hint = (/^[A-Za-z0-9 ,.:;_!?-]{8,60}/u.exec(message) ?? [])[0] ?? null
|
|
240
|
+
const from = fromFlag === "none" ? null : fromFlag ?? whoAmI(deps.stateDir, hint, deps.self).id
|
|
241
|
+
sender = from
|
|
242
|
+
prompt = envelope({ nonce, from, name: from === null ? null : nameOf(deps.stateDir, from), host: deps.host, text: message, script })
|
|
243
|
+
}
|
|
244
|
+
const before = new Set(tailMessages(readHistoryTail(deps.stateDir, target.id)?.text ?? "", 20).map((entry) => entry.at))
|
|
245
|
+
const socket = deps.socket()
|
|
246
|
+
if (socket.reason !== undefined) {
|
|
247
|
+
throw failure("sessions_app_socket", "cannot reach the GitHub Copilot app", socket.reason, "check that the app is open, then run sessions.js tail on the target to see whether the message arrived another way", "start the app and run the same command again")
|
|
248
|
+
}
|
|
249
|
+
const result = await deps.send({ id: target.id, prompt, socket })
|
|
250
|
+
const matches = (entry) => entry.role === "user" && (asUser ? entry.text.trim() === message.trim().slice(0, MESSAGE_CHARS) && !before.has(entry.at) : entry.text.includes(`[Message ${nonce} `))
|
|
251
|
+
const delivered = result.accepted && (await seenWithin(() => tailMessages(readHistoryTail(deps.stateDir, target.id)?.text ?? "", 20).some(matches), waitMs, deps))
|
|
252
|
+
if (!result.accepted) {
|
|
253
|
+
throw failure("sessions_send_refused", `the app did not accept the message for ${target.id}`, result.error ?? `the app answered ${result.reply}; the session may be archived or not a Copilot app session`, `run sessions.js tail ${target.id} to see the session`, "pass the id of a session that is open in the app")
|
|
254
|
+
}
|
|
255
|
+
const note = delivered ? undefined : `The app accepted the message but it was not in the history after ${waitMs / 1000} s. Read it with sessions.js tail ${target.id} before sending again, so it is not sent twice.`
|
|
256
|
+
return { to: target.id, from: sender, nonce: asUser ? null : nonce, accepted: true, delivered, reply: result.reply, ...(note === undefined ? {} : { note }) }
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const SESSION = { name: "session", required: true, description: "A full id, an id prefix or an exact name of a session on this machine." }
|
|
260
|
+
const text = (result) => JSON.stringify(result, null, 1)
|
|
261
|
+
|
|
262
|
+
function sessionsCli({ script, deps, overrides }) {
|
|
263
|
+
const command = (name, def, run) => defineCommand({ name, output: "one JSON value", text, effect: "private", ...def, run })
|
|
264
|
+
return defineCli({
|
|
265
|
+
name: "sessions",
|
|
266
|
+
about: ["Reads and messages the agent sessions on this machine; reach another machine's sessions by running the same command there."],
|
|
267
|
+
commands: [
|
|
268
|
+
command("whoami", { readOnly: true, summary: "Print the session this command runs in. With several sessions in one runtime, --hint <text from your own command> picks yours.", flags: { hint: { type: "string", description: "Text from your own command line, which is in your session's history." } } }, (input) => {
|
|
269
|
+
if (deps.platform === "win32" && overrides.self === undefined) {
|
|
270
|
+
throw failure("sessions_whoami_platform", "whoami cannot walk process parents here", "this command reads the process tree with ps, which Windows does not have", "read your own session id from the session folder name or the app", "pass --from <your session id> to send instead")
|
|
271
|
+
}
|
|
272
|
+
return whoAmI(deps.stateDir, input.hint ?? null, deps.self)
|
|
273
|
+
}),
|
|
274
|
+
command("tail", { readOnly: true, summary: "Print the last <count> (default 6) user and assistant messages of a session.", args: [SESSION, { name: "count", description: "How many messages, a positive whole number." }] }, (input) => {
|
|
275
|
+
const count = input.count === undefined ? 6 : Number(input.count)
|
|
276
|
+
if (!Number.isInteger(count) || count < 1) throw new AxError({ code: "sessions_tail_count", exit: 2, thing: "tail", problem: `the count must be a positive whole number, not ${JSON.stringify(input.count)}`, fix: "run sessions tail <session> [<count>]" })
|
|
277
|
+
const target = resolveSession(deps.stateDir, input.session)
|
|
278
|
+
const history = target.reason !== undefined ? null : readHistoryTail(deps.stateDir, target.id)
|
|
279
|
+
if (target.reason !== undefined || history === null) {
|
|
280
|
+
throw failure("sessions_tail_target", `cannot read ${JSON.stringify(input.session)}`, target.reason ?? `session ${target.id} has no events.jsonl here, so it is on another machine or has been removed`, "check the id or name, or run the command on the machine that hosts the session", "pass the full session id")
|
|
281
|
+
}
|
|
282
|
+
return { id: target.id, name: nameOf(deps.stateDir, target.id), last_written: history.mtime, messages: tailMessages(history.text, count) }
|
|
283
|
+
}),
|
|
284
|
+
command("send", {
|
|
285
|
+
summary: "Deliver a message with a header naming the sender and how to reply, then wait (--wait, default 20) for it to show in the target's history. A send that was accepted but not yet seen is not failed: read the target with tail before sending again.",
|
|
286
|
+
args: [SESSION, { name: "message", required: true, rest: true, description: "The message text." }],
|
|
287
|
+
flags: {
|
|
288
|
+
from: { type: "string", placeholder: "<session id>|none", description: "The sender's session id, or none; by default this session." },
|
|
289
|
+
"as-user": { type: "boolean", description: "Send the text alone, as the person's own message; use it only for words the person authorized in their voice." },
|
|
290
|
+
wait: { type: "number", min: 0, description: "Seconds to wait for the message to show in the target's history (default 20)." },
|
|
291
|
+
},
|
|
292
|
+
}, (input) => runSend({ ref: input.session, message: input.message, from: input.from, asUser: input["as-user"] === true, waitMs: (input.wait ?? 20) * 1000, script, deps })),
|
|
293
|
+
],
|
|
294
|
+
})
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** Runs the command line; returns the exit code. */
|
|
298
|
+
export async function runSessionsCli({ argv, script = "sessions.js", env = process.env, io = process, deps: overrides = {} }) {
|
|
299
|
+
// A failure from the code underneath is already a whole line of its own; the kit's tool-name prefix would say it twice.
|
|
300
|
+
return runCli(sessionsCli({ script, deps: { ...defaults(env), ...overrides }, overrides }), argv, { stdout: io.stdout, stderr: io.stderr })
|
|
301
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Which unsigned deliveries an earlier boot of this same session already listed.
|
|
2
|
+
//
|
|
3
|
+
// Boot runs again when a session resumes or is compacted, and each run listed the same unsigned deliveries with "raise them, once": an
|
|
4
|
+
// agent that lost the earlier turn in compaction raised them a second time, and the operator was asked twice for one answer. The host
|
|
5
|
+
// gives the boot script its session id in the environment (Claude Code's `CLAUDE_CODE_SESSION_ID`, Copilot's
|
|
6
|
+
// `COPILOT_AGENT_SESSION_ID`), so boot keeps a small session-scoped record of the deliveries it has listed, and a later boot of the same
|
|
7
|
+
// session says they were listed already instead of asking for them again. A host with no session id in the environment gets the plain
|
|
8
|
+
// line, as before.
|
|
9
|
+
//
|
|
10
|
+
// Fails open: an unreadable or unwritable record means "not known", never "listed".
|
|
11
|
+
|
|
12
|
+
import { createHash } from "node:crypto"
|
|
13
|
+
import { mkdirSync, readdirSync, readFileSync, statSync, unlinkSync, writeFileSync } from "node:fs"
|
|
14
|
+
import * as path from "node:path"
|
|
15
|
+
import { assertNotRealStateUnderTest } from "./test-state-guard.js"
|
|
16
|
+
import { renameWithRetry } from "../util/rename-retry.js"
|
|
17
|
+
|
|
18
|
+
export const SIGNOFF_LISTED_DIR = "signoff-listed"
|
|
19
|
+
const STALE_MS = 7 * 24 * 60 * 60 * 1000
|
|
20
|
+
const MAX_KEYS = 200
|
|
21
|
+
|
|
22
|
+
const hasText = (value) => typeof value === "string" && value.trim() !== ""
|
|
23
|
+
|
|
24
|
+
/** The host's id for this session from the environment, or null when the host gives none. */
|
|
25
|
+
export function hostSessionId(env) {
|
|
26
|
+
for (const name of ["CLAUDE_CODE_SESSION_ID", "COPILOT_AGENT_SESSION_ID"]) if (hasText(env?.[name])) return env[name].trim()
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The record for one session: a digest of its id, so no id can name another path. */
|
|
31
|
+
export function listedFile(stateDir, sessionId) {
|
|
32
|
+
return path.join(stateDir, SIGNOFF_LISTED_DIR, `${createHash("sha256").update(String(sessionId)).digest("hex").slice(0, 32)}.json`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function readKeys(file) {
|
|
36
|
+
try {
|
|
37
|
+
const parsed = JSON.parse(readFileSync(file, "utf8"))
|
|
38
|
+
return Array.isArray(parsed?.tasks) ? parsed.tasks.filter((key) => typeof key === "string") : []
|
|
39
|
+
} catch {
|
|
40
|
+
return []
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// A record may vanish between the listing and the check (another session pruning it): each one is judged on its own.
|
|
45
|
+
function pruneStale(dir, now) {
|
|
46
|
+
for (const name of readdirSync(dir)) {
|
|
47
|
+
try {
|
|
48
|
+
const file = path.join(dir, name)
|
|
49
|
+
if (now - statSync(file).mtimeMs > STALE_MS) unlinkSync(file)
|
|
50
|
+
} catch {
|
|
51
|
+
// Gone already, or not ours to remove.
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Notes the deliveries `found` lists (the `recordUnsigned` result) as listed in this session, and answers whether an earlier boot of the
|
|
58
|
+
* same session had listed every one of them already: `true` (listed before), `false` (at least one is new) or `undefined` (nothing to
|
|
59
|
+
* list, no session id, or the record could not be read or written).
|
|
60
|
+
*/
|
|
61
|
+
export function noteSignoffListed(env, found, { stateDir, now = Date.now } = {}) {
|
|
62
|
+
const sessionId = hostSessionId(env)
|
|
63
|
+
const tasks = Array.isArray(found?.tasks) ? found.tasks.filter((task) => hasText(task?.track) && hasText(task?.slug)).map((task) => `${task.track}/${task.slug}`) : []
|
|
64
|
+
if (sessionId === null || tasks.length === 0 || !hasText(stateDir)) return undefined
|
|
65
|
+
try {
|
|
66
|
+
assertNotRealStateUnderTest(stateDir)
|
|
67
|
+
const file = listedFile(stateDir, sessionId)
|
|
68
|
+
const before = readKeys(file)
|
|
69
|
+
const seen = tasks.every((key) => before.includes(key))
|
|
70
|
+
if (!seen) {
|
|
71
|
+
mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 })
|
|
72
|
+
const temp = `${file}.${process.pid}.tmp`
|
|
73
|
+
writeFileSync(temp, `${JSON.stringify({ tasks: [...new Set([...before, ...tasks])].slice(-MAX_KEYS) })}\n`, { mode: 0o600 })
|
|
74
|
+
renameWithRetry(temp, file)
|
|
75
|
+
pruneStale(path.dirname(file), now())
|
|
76
|
+
}
|
|
77
|
+
return seen
|
|
78
|
+
} catch {
|
|
79
|
+
return undefined
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// desk_skill: reads Desk's own skills through the MCP server, for a client that cannot load them as plugin skills (claude.ai, ChatGPT and other hosted chats).
|
|
2
|
+
//
|
|
3
|
+
// It needs no desk and no admission: the skills ship in the plugin, next to this server. Read-only, built from file reads only.
|
|
4
|
+
|
|
5
|
+
import { readdirSync, readFileSync } from "node:fs"
|
|
6
|
+
import * as path from "node:path"
|
|
7
|
+
import { fileURLToPath } from "node:url"
|
|
8
|
+
import { parseFrontmatterLite } from "../desk/frontmatter-lite.js"
|
|
9
|
+
import { HOSTED_SHELL_SKILLS, isHosted } from "./hosted.js"
|
|
10
|
+
|
|
11
|
+
/** The plugin's skills folder: `<plugin>/skills`, three levels above this file (`<plugin>/mcp/src/runtime`). */
|
|
12
|
+
export const SKILLS_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "skills")
|
|
13
|
+
|
|
14
|
+
/** The input fields desk_skill reads; the schema parity test holds tool-schemas.js to it. */
|
|
15
|
+
export const DESK_SKILL_FIELDS = Object.freeze(["name"])
|
|
16
|
+
|
|
17
|
+
const NAME = /^[a-z0-9][a-z0-9-]{0,63}$/u
|
|
18
|
+
const FRONTMATTER = /^---\r?\n([\s\S]*?)\r?\n---\r?\n/u
|
|
19
|
+
|
|
20
|
+
function readSkillFile(skillsRoot, name) {
|
|
21
|
+
try {
|
|
22
|
+
return readFileSync(path.join(skillsRoot, name, "SKILL.md"), "utf8")
|
|
23
|
+
} catch {
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function description(text) {
|
|
29
|
+
try {
|
|
30
|
+
const value = parseFrontmatterLite(text).data.description
|
|
31
|
+
return typeof value === "string" ? value.trim() : ""
|
|
32
|
+
} catch {
|
|
33
|
+
return ""
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function json(value, isError = false) {
|
|
38
|
+
return { content: [{ type: "text", text: JSON.stringify(value) }], ...(isError ? { isError: true } : {}) }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Without `name`: lists every skill as { name, description }, and on a hosted Desk marks the ones that need a shell with `hosted_unavailable`.
|
|
43
|
+
* With `name`: returns that skill's SKILL.md without its frontmatter, as plain text. A hosted Desk refuses a skill that needs a shell, with the reason.
|
|
44
|
+
*/
|
|
45
|
+
export function deskSkill(input = {}, { env = process.env, skillsRoot = SKILLS_ROOT } = {}) {
|
|
46
|
+
const hosted = isHosted(env)
|
|
47
|
+
const name = input?.name
|
|
48
|
+
if (name === undefined || name === null || name === "") {
|
|
49
|
+
let entries = []
|
|
50
|
+
try {
|
|
51
|
+
entries = readdirSync(skillsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort()
|
|
52
|
+
} catch {
|
|
53
|
+
entries = []
|
|
54
|
+
}
|
|
55
|
+
const skills = []
|
|
56
|
+
for (const entry of entries) {
|
|
57
|
+
const text = readSkillFile(skillsRoot, entry)
|
|
58
|
+
if (text === null) continue
|
|
59
|
+
const row = { name: entry, description: description(text) }
|
|
60
|
+
if (hosted && Object.hasOwn(HOSTED_SHELL_SKILLS, entry)) row.hosted_unavailable = HOSTED_SHELL_SKILLS[entry]
|
|
61
|
+
skills.push(row)
|
|
62
|
+
}
|
|
63
|
+
return json({ status: "listed", skills, next: "Call desk_skill with a name to read that skill, then follow it." })
|
|
64
|
+
}
|
|
65
|
+
if (typeof name !== "string" || !NAME.test(name)) {
|
|
66
|
+
return json({ status: "refused", code: "invalid_name", fix: "Pass a skill name from desk_skill's list: lowercase letters, digits and hyphens." }, true)
|
|
67
|
+
}
|
|
68
|
+
if (hosted && Object.hasOwn(HOSTED_SHELL_SKILLS, name)) {
|
|
69
|
+
return json({ status: "refused", code: "hosted_unavailable", skill: name, reason: HOSTED_SHELL_SKILLS[name] }, true)
|
|
70
|
+
}
|
|
71
|
+
const text = readSkillFile(skillsRoot, name)
|
|
72
|
+
if (text === null) {
|
|
73
|
+
return json({ status: "refused", code: "unknown_skill", fix: "Call desk_skill with no name for the list of skills." }, true)
|
|
74
|
+
}
|
|
75
|
+
return { content: [{ type: "text", text: `# Desk skill: ${name}\n\n${text.replace(FRONTMATTER, "").trim()}\n` }] }
|
|
76
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Desk's own fallback for a session an always-on runtime does not watch (docs/stalled-nudges.md): a desk_status call made while the
|
|
2
|
+
// session's focused task card is unfinished and has gone quiet leads with the nudge, once per session. The session's focus is the one it
|
|
3
|
+
// declared in this process, else the last `task_focus` in its own history (a session resumed after an app restart has declared nothing
|
|
4
|
+
// yet). Each call starts the check in the background and reads the answer of the one before it, so desk_status never waits for a
|
|
5
|
+
// history that can run to hundreds of MB.
|
|
6
|
+
import * as path from "node:path"
|
|
7
|
+
import { personPrefix } from "../util/paths.js"
|
|
8
|
+
import { staleCardLead } from "./focused-card.js"
|
|
9
|
+
import { findFocus, sessionStateDir } from "./session-activity.js"
|
|
10
|
+
|
|
11
|
+
/** `{ lead() }`: the nudge text the first time a finished check had one, else null. `context` is the session's (`context.root.root` is its desk, `context.person` who it writes as). */
|
|
12
|
+
export function createStaleCardLead({ env, focus, context, now = Date.now }) {
|
|
13
|
+
let running = false
|
|
14
|
+
let delivered = false
|
|
15
|
+
let text = null
|
|
16
|
+
let history = null
|
|
17
|
+
const declared = async () => {
|
|
18
|
+
const held = focus.get()
|
|
19
|
+
if (held !== null || focus.declared()) return held
|
|
20
|
+
const id = env.COPILOT_AGENT_SESSION_ID
|
|
21
|
+
if (typeof id !== "string" || id === "") return null
|
|
22
|
+
history ??= findFocus(path.join(sessionStateDir(env), id, "events.jsonl")).then((found) => found.focus)
|
|
23
|
+
return history
|
|
24
|
+
}
|
|
25
|
+
const check = async () => {
|
|
26
|
+
const task = await declared()
|
|
27
|
+
if (task === null) return null
|
|
28
|
+
const desk = context.root.root
|
|
29
|
+
return staleCardLead({ bases: [...new Set([personPrefix(desk, context.person), desk])], focus: task, now: now() })
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
lead() {
|
|
33
|
+
if (delivered) return null
|
|
34
|
+
if (!running) {
|
|
35
|
+
running = true
|
|
36
|
+
check().then((found) => {
|
|
37
|
+
text = found
|
|
38
|
+
}, () => {
|
|
39
|
+
text = null
|
|
40
|
+
}).finally(() => {
|
|
41
|
+
running = false
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
if (text === null) return null
|
|
45
|
+
delivered = true
|
|
46
|
+
return text
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The status answer with the nudge first, when there is one. */
|
|
52
|
+
export const withStaleCardLead = (answer, lead) => (lead === null ? answer : { nudge: lead, ...answer })
|