@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,431 @@
|
|
|
1
|
+
// The outcome record a task card carries, and the rules for writing it. Three
|
|
2
|
+
// keys, written only by the task tools: `signoff` (the human's answer to a
|
|
3
|
+
// delivery), `flow` (where the card has been) and `returns` (one line per
|
|
4
|
+
// time work went backwards). Every function here is pure: it returns a new
|
|
5
|
+
// record and never changes its input. Times are ISO strings, as the card
|
|
6
|
+
// holds them. A malformed part of a record reads as absent (`null`), never
|
|
7
|
+
// as a guess.
|
|
8
|
+
|
|
9
|
+
export const SIGNOFF_STATES = ["delivered_unsigned", "accepted", "refused"]
|
|
10
|
+
export const OUTCOME_STATES = ["not_delivered", "not_recorded", "delivered_unsigned", "accepted", "refused", "reopened"]
|
|
11
|
+
export const REFUSAL_REASONS = ["not_what_was_asked", "defect", "changed_ask", "incomplete", "other"]
|
|
12
|
+
export const RETURN_REASONS = ["agent_error", "changed_ask", "new_information", "external"]
|
|
13
|
+
export const CATCH_POINTS = ["in_task", "at_review", "after_delivery"]
|
|
14
|
+
export const WAIT_CLASSES = ["lt_1h", "lt_1d", "lt_7d", "ge_7d"]
|
|
15
|
+
export const SIGNOFF_ALARM_DAYS = 7
|
|
16
|
+
|
|
17
|
+
const FLOW_SINCE = ["created", "adopted"]
|
|
18
|
+
const REACHED = ["drafting", "processing", "validating", "done"]
|
|
19
|
+
const HOUR_MS = 3_600_000
|
|
20
|
+
const DAY_MS = 86_400_000
|
|
21
|
+
|
|
22
|
+
// The class of a wait in milliseconds. An edge value belongs to the higher
|
|
23
|
+
// class. A wait that is negative or not a finite number is a bug upstream, so
|
|
24
|
+
// it throws rather than being filed under a class.
|
|
25
|
+
export function waitClass(ms) {
|
|
26
|
+
if (typeof ms !== "number" || !Number.isFinite(ms) || ms < 0) throw Object.assign(new RangeError("Pass a wait as a finite, non-negative number of milliseconds"), { code: "outcome_pass_a_wait_as_a" })
|
|
27
|
+
if (ms < HOUR_MS) return "lt_1h"
|
|
28
|
+
if (ms < DAY_MS) return "lt_1d"
|
|
29
|
+
if (ms < 7 * DAY_MS) return "lt_7d"
|
|
30
|
+
return "ge_7d"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date)
|
|
34
|
+
const oneOf = (list, value) => (list.includes(value) ? value : null)
|
|
35
|
+
const count = (value) => (Number.isInteger(value) && value >= 0 ? value : null)
|
|
36
|
+
|
|
37
|
+
// The ISO string for a time the card holds (a string) or a YAML reader made
|
|
38
|
+
// (a Date); null for anything else.
|
|
39
|
+
function timeOf(value) {
|
|
40
|
+
if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : value.toISOString()
|
|
41
|
+
if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}T/u.test(value) && Number.isFinite(Date.parse(value))) return value
|
|
42
|
+
return null
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function requireTime(value) {
|
|
46
|
+
const iso = value instanceof Date || typeof value === "string" ? timeOf(value) : null
|
|
47
|
+
if (iso === null) throw Object.assign(new Error("Pass the time as an ISO time"), { code: "invalid_time" })
|
|
48
|
+
return iso
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function readSignoff(value) {
|
|
52
|
+
if (!isObject(value)) return null
|
|
53
|
+
const state = oneOf(SIGNOFF_STATES, value.state)
|
|
54
|
+
if (state === null) return null
|
|
55
|
+
const signoff = { state, at: timeOf(value.at), reason: oneOf(REFUSAL_REASONS, value.reason) }
|
|
56
|
+
// Desk no longer writes `verified`; a card written before that keeps its flag.
|
|
57
|
+
if (value.verified === true || value.verified === false) signoff.verified = value.verified
|
|
58
|
+
return signoff
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function readFlow(value) {
|
|
62
|
+
if (!isObject(value)) return null
|
|
63
|
+
return {
|
|
64
|
+
since: oneOf(FLOW_SINCE, value.since),
|
|
65
|
+
rev: count(value.rev),
|
|
66
|
+
reached: oneOf(REACHED, value.reached),
|
|
67
|
+
first_validating_at: timeOf(value.first_validating_at),
|
|
68
|
+
first_delivered_at: timeOf(value.first_delivered_at),
|
|
69
|
+
delivered_at: timeOf(value.delivered_at),
|
|
70
|
+
deliveries: count(value.deliveries),
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const keptLine = (line) => typeof line === "string" && line.trim() !== ""
|
|
75
|
+
|
|
76
|
+
// The readable return lines and a count of what was dropped: a blank or non-string entry, or a value that is present but not a list, counts as one.
|
|
77
|
+
function readReturns(value) {
|
|
78
|
+
if (Array.isArray(value)) {
|
|
79
|
+
const lines = value.filter(keptLine)
|
|
80
|
+
return { lines, damaged: value.length - lines.length }
|
|
81
|
+
}
|
|
82
|
+
return { lines: [], damaged: value === undefined || value === null ? 0 : 1 }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// `{ signoff, flow, returns, returns_damaged }` from parsed frontmatter. `returns_damaged` counts the `returns` entries that had to be dropped, so a damaged list is never read as an empty one; it adds to the count a record already carries.
|
|
86
|
+
export function readRecord(data) {
|
|
87
|
+
const source = isObject(data) ? data : {}
|
|
88
|
+
const { lines, damaged } = readReturns(source.returns)
|
|
89
|
+
return { signoff: readSignoff(source.signoff), flow: readFlow(source.flow), returns: lines, returns_damaged: damaged + (count(source.returns_damaged) ?? 0) }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function scalar(raw) {
|
|
93
|
+
const text = raw.trim()
|
|
94
|
+
const quoted = /^(["'])(.*)\1(?:\s+#.*)?$/u.exec(text)
|
|
95
|
+
if (quoted) return quoted[2]
|
|
96
|
+
const bare = text.replace(/\s+#.*$/u, "").trim()
|
|
97
|
+
if (bare === "" || bare === "null" || bare === "~") return null
|
|
98
|
+
if (bare === "true") return true
|
|
99
|
+
if (bare === "false") return false
|
|
100
|
+
if (/^-?\d+$/u.test(bare)) return Number(bare)
|
|
101
|
+
return bare
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Splits flow-form text on commas that are not inside quotes.
|
|
105
|
+
function splitFlow(text) {
|
|
106
|
+
const parts = []
|
|
107
|
+
let quote = null
|
|
108
|
+
let current = ""
|
|
109
|
+
for (const char of text) {
|
|
110
|
+
if (quote !== null) {
|
|
111
|
+
if (char === quote) quote = null
|
|
112
|
+
} else if (char === '"' || char === "'") {
|
|
113
|
+
quote = char
|
|
114
|
+
} else if (char === ",") {
|
|
115
|
+
parts.push(current)
|
|
116
|
+
current = ""
|
|
117
|
+
continue
|
|
118
|
+
}
|
|
119
|
+
current += char
|
|
120
|
+
}
|
|
121
|
+
parts.push(current)
|
|
122
|
+
return parts.filter((part) => part.trim() !== "")
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function mapEntry(text) {
|
|
126
|
+
const at = text.indexOf(":")
|
|
127
|
+
return at === -1 ? null : [text.slice(0, at).trim(), scalar(text.slice(at + 1))]
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function flowMap(text) {
|
|
131
|
+
if (!text.endsWith("}")) return text
|
|
132
|
+
return Object.fromEntries(splitFlow(text.slice(1, -1)).map(mapEntry).filter(Boolean))
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function blockMap(lines) {
|
|
136
|
+
const out = {}
|
|
137
|
+
let indent = null
|
|
138
|
+
for (const line of lines) {
|
|
139
|
+
const match = /^(\s+)(\S.*)$/u.exec(line)
|
|
140
|
+
if (!match || match[2].startsWith("#")) continue
|
|
141
|
+
indent ??= match[1].length
|
|
142
|
+
if (match[1].length !== indent) continue
|
|
143
|
+
const entry = mapEntry(match[2])
|
|
144
|
+
if (entry) out[entry[0]] = entry[1]
|
|
145
|
+
}
|
|
146
|
+
return out
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function flowList(text) {
|
|
150
|
+
if (!text.endsWith("]")) return text
|
|
151
|
+
return splitFlow(text.slice(1, -1)).map((part) => scalar(part))
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function blockList(lines) {
|
|
155
|
+
const out = []
|
|
156
|
+
for (const line of lines) {
|
|
157
|
+
const match = /^\s*-\s*(.*)$/u.exec(line)
|
|
158
|
+
if (match) out.push(scalar(match[1]))
|
|
159
|
+
else if (line.trim() !== "" && !line.trim().startsWith("#")) out.push(null)
|
|
160
|
+
}
|
|
161
|
+
return out
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// One top-level key from raw frontmatter lines, in the forms the card writer
|
|
165
|
+
// and a person's editor produce. Only the first copy of a key is read, as the
|
|
166
|
+
// factory's card reader does. A value in any other shape comes back as the
|
|
167
|
+
// bare text, which `readRecord` reads as absent.
|
|
168
|
+
function topLevel(lines, key, block, flow) {
|
|
169
|
+
const pattern = new RegExp(`^${key}:(.*)$`, "u")
|
|
170
|
+
const at = lines.findIndex((line) => pattern.test(line))
|
|
171
|
+
if (at === -1) return undefined
|
|
172
|
+
const rest = pattern.exec(lines[at])[1].trim().replace(/^#.*$|(?<=[}\]])\s+#.*$/u, "")
|
|
173
|
+
if (rest.startsWith("{") || rest.startsWith("[")) return rest.startsWith("{") ? flowMap(rest) : flowList(rest)
|
|
174
|
+
if (rest !== "") return rest
|
|
175
|
+
const following = []
|
|
176
|
+
for (const line of lines.slice(at + 1)) {
|
|
177
|
+
if (/^[A-Za-z_]/u.test(line)) break
|
|
178
|
+
following.push(line)
|
|
179
|
+
}
|
|
180
|
+
return key === "returns" ? block(following) : flow(following)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// `{ signoff, flow, returns, returns_damaged }` from raw frontmatter lines (the text between the two `---` lines), block or flow form. A line under `returns:` that is not a list item counts as damaged.
|
|
184
|
+
export function recordFromLines(lines) {
|
|
185
|
+
const rows = Array.isArray(lines) ? lines : []
|
|
186
|
+
return readRecord({
|
|
187
|
+
signoff: topLevel(rows, "signoff", blockList, blockMap),
|
|
188
|
+
flow: topLevel(rows, "flow", blockList, blockMap),
|
|
189
|
+
returns: topLevel(rows, "returns", blockList, blockMap),
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// The frontmatter keys a card should carry: only those that exist, in the
|
|
194
|
+
// card's order. `returns` is left out when empty.
|
|
195
|
+
export function toFrontmatter(record) {
|
|
196
|
+
const out = {}
|
|
197
|
+
const { signoff, flow, returns } = readRecord(record)
|
|
198
|
+
if (signoff) out.signoff = signoff
|
|
199
|
+
if (flow) out.flow = flow
|
|
200
|
+
if (returns.length > 0) out.returns = returns
|
|
201
|
+
return out
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const startFlow = (reached, deliveries = 0) => ({
|
|
205
|
+
since: "adopted",
|
|
206
|
+
rev: 0,
|
|
207
|
+
reached,
|
|
208
|
+
first_validating_at: null,
|
|
209
|
+
first_delivered_at: null,
|
|
210
|
+
delivered_at: null,
|
|
211
|
+
deliveries,
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
// A card is delivered: it now waits for the human's answer.
|
|
215
|
+
export function deliver(record, { at }) {
|
|
216
|
+
const when = requireTime(at)
|
|
217
|
+
const { flow, returns } = readRecord(record)
|
|
218
|
+
const base = flow ?? startFlow("done")
|
|
219
|
+
return {
|
|
220
|
+
signoff: { state: "delivered_unsigned", at: null, reason: null },
|
|
221
|
+
flow: {
|
|
222
|
+
...base,
|
|
223
|
+
rev: (base.rev ?? 0) + 1,
|
|
224
|
+
reached: "done",
|
|
225
|
+
first_validating_at: base.first_validating_at ?? when,
|
|
226
|
+
first_delivered_at: base.first_delivered_at ?? when,
|
|
227
|
+
delivered_at: when,
|
|
228
|
+
deliveries: (base.deliveries ?? 0) + 1,
|
|
229
|
+
},
|
|
230
|
+
returns,
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const fail = (code, message) => Object.assign(new Error(message), { code })
|
|
235
|
+
|
|
236
|
+
function checkReasons(outcome, reason, returnReason) {
|
|
237
|
+
const given = (value) => value !== undefined && value !== null
|
|
238
|
+
if (outcome === "accepted") {
|
|
239
|
+
if (given(reason)) throw fail("reason_not_allowed", "an acceptance carries no reason")
|
|
240
|
+
if (given(returnReason)) throw fail("reason_not_allowed", "an acceptance carries no return reason")
|
|
241
|
+
return
|
|
242
|
+
}
|
|
243
|
+
if (!given(reason)) throw fail("reason_required", "a refusal needs the human's reason")
|
|
244
|
+
if (!REFUSAL_REASONS.includes(reason)) throw fail("unknown_reason", "the reason is not one of the listed reasons")
|
|
245
|
+
if (!given(returnReason)) throw fail("return_reason_required", "a refusal needs your own reading of the cause")
|
|
246
|
+
if (!RETURN_REASONS.includes(returnReason)) throw fail("unknown_return_reason", "the return reason is not one of the listed reasons")
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// The human's answer to a delivery. Saying the same thing again changes nothing; a different answer replaces the one held. The record carries no `verified` flag: a call is the answer. A card written before that still carries the flag, and readSignoff reads it.
|
|
250
|
+
export function sign(record, { status, outcome, reason, returnReason, at }) {
|
|
251
|
+
if (status !== "done") throw fail("not_delivered", "only a delivered task can be signed")
|
|
252
|
+
if (outcome !== "accepted" && outcome !== "refused") throw fail("unknown_outcome", "the outcome is accepted or refused")
|
|
253
|
+
checkReasons(outcome, reason, returnReason)
|
|
254
|
+
const when = requireTime(at)
|
|
255
|
+
const current = readRecord(record)
|
|
256
|
+
const held = current.signoff
|
|
257
|
+
if (held && held.state !== "delivered_unsigned" && held.state === outcome) return { record: { signoff: current.signoff, flow: current.flow, returns: current.returns }, changed: false }
|
|
258
|
+
const flow = current.flow ?? startFlow("done", 1)
|
|
259
|
+
return {
|
|
260
|
+
record: {
|
|
261
|
+
signoff: { state: outcome, at: when, reason: outcome === "refused" ? reason : null },
|
|
262
|
+
flow: { ...flow, rev: (flow.rev ?? 0) + 1 },
|
|
263
|
+
returns: current.returns,
|
|
264
|
+
},
|
|
265
|
+
changed: true,
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Where the card's outcome stands. A `done` card with no record is delivered
|
|
270
|
+
// before the record existed: never unsigned and never accepted.
|
|
271
|
+
export function outcomeState(record, status) {
|
|
272
|
+
const { signoff, flow } = readRecord(record)
|
|
273
|
+
if (status === "done") return signoff ? signoff.state : "not_recorded"
|
|
274
|
+
if ((flow?.deliveries ?? 0) > 0) return signoff?.state === "refused" ? "refused" : "reopened"
|
|
275
|
+
return "not_delivered"
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Package F: returns. A return is any status move that sends work back. The rules live in this file so `task_update` and `task_signoff` cannot differ.
|
|
279
|
+
|
|
280
|
+
export const MAIN_LINE = { drafting: 0, processing: 1, validating: 2, done: 3 }
|
|
281
|
+
export const STATUSES = ["drafting", "processing", "validating", "collaborating", "paused", "blocked", "done", "cancelled"]
|
|
282
|
+
|
|
283
|
+
const isMainLine = (status) => Object.hasOwn(MAIN_LINE, status)
|
|
284
|
+
|
|
285
|
+
// A move needs a reason when it leaves `done`, or when it lands on a main-line status below the highest one reached since the last return. Side states (`collaborating`, `paused`, `blocked`, `cancelled`) have no rank, so a move into one is never a return unless the card was at `done`. A missing `reached` is read as the status the card is at.
|
|
286
|
+
export function needsReturnReason({ from, to, reached }) {
|
|
287
|
+
if (from === to) return false
|
|
288
|
+
if (from === "done") return true
|
|
289
|
+
const held = isMainLine(reached) ? reached : from
|
|
290
|
+
return isMainLine(to) && isMainLine(held) && MAIN_LINE[held] > MAIN_LINE[to]
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export function catchPoint({ from, reached }) {
|
|
294
|
+
if (from === "done") return "after_delivery"
|
|
295
|
+
return reached === "validating" ? "at_review" : "in_task"
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const HUMAN_VERIFIED = { verified: true, unverified: false }
|
|
299
|
+
|
|
300
|
+
// One line of the `returns` list: `<time> <from> <to> <agent reason> <catch point>`, then ` refused=<human reason>` for a human refusal. A line written before Desk dropped the witness ends with ` verified` or ` unverified` after the refusal, and still reads. Throws `invalid_return` for an entry that would not read back.
|
|
301
|
+
export function formatReturn(entry) {
|
|
302
|
+
const e = isObject(entry) ? entry : {}
|
|
303
|
+
const base = `${e.at} ${e.from} ${e.to} ${e.reason} ${e.caught}`
|
|
304
|
+
const line = e.refusal === null || e.refusal === undefined ? base : `${base} refused=${e.refusal}`
|
|
305
|
+
if (parseReturn(line) === null) throw fail("invalid_return", "the return entry is not in the listed form")
|
|
306
|
+
return line
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// The entry a line holds, or null for any line that cannot be read in full.
|
|
310
|
+
export function parseReturn(line) {
|
|
311
|
+
if (typeof line !== "string") return null
|
|
312
|
+
const parts = line.split(" ")
|
|
313
|
+
if (parts.length < 5 || parts.length > 7 || (parts.length === 6 && !parts[5].startsWith("refused="))) return null
|
|
314
|
+
const [at, from, to, reason, caught, refused, verdict] = parts
|
|
315
|
+
if (typeof timeOf(at) !== "string" || !STATUSES.includes(from) || !STATUSES.includes(to)) return null
|
|
316
|
+
if (!RETURN_REASONS.includes(reason) || !CATCH_POINTS.includes(caught)) return null
|
|
317
|
+
if (from === to || to === "done" || (caught === "after_delivery") !== (from === "done")) return null
|
|
318
|
+
const entry = { at, from, to, reason, caught, refusal: null, refusal_verified: null }
|
|
319
|
+
if (parts.length === 5) return entry
|
|
320
|
+
const human = /^refused=(\S+)$/u.exec(refused)?.[1]
|
|
321
|
+
if (!REFUSAL_REASONS.includes(human) || (verdict !== undefined && !Object.hasOwn(HUMAN_VERIFIED, verdict)) || from !== "done" || to !== "processing") return null
|
|
322
|
+
return { ...entry, refusal: human, refusal_verified: verdict === undefined ? null : HUMAN_VERIFIED[verdict] }
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const knownStatus = (status) => {
|
|
326
|
+
if (!STATUSES.includes(status)) throw fail("unknown_status", "the status is not one of the listed statuses")
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// A status change. Returns a new record; the input is never changed. Without a status change, or when nothing in the record would change, the input itself comes back. A card with no `flow` gets one, as `adopted`, with `reached` at the status it is at (`drafting` for a side state).
|
|
330
|
+
export function move(record, { from, to, at, returnReason }) {
|
|
331
|
+
knownStatus(from)
|
|
332
|
+
knownStatus(to)
|
|
333
|
+
const current = readRecord(record)
|
|
334
|
+
const given = returnReason !== undefined && returnReason !== null
|
|
335
|
+
const flow = current.flow ?? startFlow(isMainLine(from) ? from : "drafting", from === "done" ? 1 : 0)
|
|
336
|
+
const reached = flow.reached ?? (isMainLine(from) ? from : "drafting")
|
|
337
|
+
const needs = needsReturnReason({ from, to, reached })
|
|
338
|
+
if (given && !needs) throw fail("return_reason_not_needed", "this move is not a return and takes no return reason")
|
|
339
|
+
if (from === to) return record
|
|
340
|
+
if (needs && !given) throw fail("return_reason_required", "this move sends work back and needs a return reason")
|
|
341
|
+
if (needs && !RETURN_REASONS.includes(returnReason)) throw fail("unknown_return_reason", "the return reason is not one of the listed reasons")
|
|
342
|
+
const when = requireTime(at)
|
|
343
|
+
const reviewed = to === "validating" || to === "done"
|
|
344
|
+
const marked = { ...flow, reached, first_validating_at: flow.first_validating_at ?? (reviewed ? when : null) }
|
|
345
|
+
if (needs) {
|
|
346
|
+
const line = formatReturn({ at: when, from, to, reason: returnReason, caught: catchPoint({ from, reached }), refusal: null, refusal_verified: null })
|
|
347
|
+
return {
|
|
348
|
+
signoff: from === "done" ? null : current.signoff,
|
|
349
|
+
flow: { ...marked, rev: (flow.rev ?? 0) + 1, reached: isMainLine(to) ? to : "drafting" },
|
|
350
|
+
returns: [...current.returns, line],
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (to === "done") {
|
|
354
|
+
return deliver({ signoff: current.signoff, flow: marked, returns: current.returns }, { at: when })
|
|
355
|
+
}
|
|
356
|
+
const next = { ...marked, reached: isMainLine(to) && MAIN_LINE[to] > MAIN_LINE[reached] ? to : reached }
|
|
357
|
+
if (current.flow && JSON.stringify(next) === JSON.stringify(flow)) return record
|
|
358
|
+
return { signoff: current.signoff, flow: { ...next, rev: (flow.rev ?? 0) + 1 }, returns: current.returns }
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// The return a human refusal makes. `task_signoff` calls it after `sign` has written the refusal (without one it throws `not_refused`); `signoff` stays as `sign` left it.
|
|
362
|
+
export function refuse(record, { at, reason, returnReason }) {
|
|
363
|
+
checkReasons("refused", reason, returnReason)
|
|
364
|
+
const when = requireTime(at)
|
|
365
|
+
const current = readRecord(record)
|
|
366
|
+
if (current.signoff?.state !== "refused") throw fail("not_refused", "no refusal is recorded on this card")
|
|
367
|
+
const flow = current.flow ?? startFlow("done", 1)
|
|
368
|
+
const line = formatReturn({ at: when, from: "done", to: "processing", reason: returnReason, caught: "after_delivery", refusal: reason, refusal_verified: null })
|
|
369
|
+
return {
|
|
370
|
+
signoff: current.signoff,
|
|
371
|
+
flow: { ...flow, rev: (flow.rev ?? 0) + 1, reached: "processing" },
|
|
372
|
+
returns: [...current.returns, line],
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// Whether a return counts against first-pass yield: the deciding reason (the human's when a refusal recorded one, else the agent's; a `verified` flag plays no part) is not `changed_ask`, and the return came at review or after delivery, or in the task at or after the first review. The catch point is a recorded fact and needs no milestone; an in-task return with no known first review does not count.
|
|
377
|
+
export function returnCounts(entry, firstValidatingAt) {
|
|
378
|
+
const decided = entry.refusal !== null ? entry.refusal : entry.reason
|
|
379
|
+
if (decided === "changed_ask") return false
|
|
380
|
+
if (entry.caught !== "in_task") return true
|
|
381
|
+
const first = timeOf(firstValidatingAt)
|
|
382
|
+
return first !== null && Date.parse(entry.at) >= Date.parse(first)
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const REASON_CLASS = {
|
|
386
|
+
not_what_was_asked: "ours",
|
|
387
|
+
defect: "ours",
|
|
388
|
+
incomplete: "ours",
|
|
389
|
+
agent_error: "ours",
|
|
390
|
+
changed_ask: "changed",
|
|
391
|
+
new_information: "outside",
|
|
392
|
+
external: "outside",
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Do the human's reason and the agent's name the same kind of cause? `null` when either is not comparable (`other`, or off both lists).
|
|
396
|
+
export function reasonsAgree(humanReason, agentReason) {
|
|
397
|
+
const human = REASON_CLASS[humanReason]
|
|
398
|
+
const agent = REASON_CLASS[agentReason]
|
|
399
|
+
if (human === undefined || agent === undefined) return null
|
|
400
|
+
return human === agent
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// The record as the facts carry it. The times are the card's own strings; `delivered_at` falls back to the evidence time only for a card that has been delivered. `returns` lists each readable return as codes and a flag, and `returns_unreadable` counts the lines skipped, so a damaged card never reads as having no returns. A card with no `flow` has no returns recorded.
|
|
404
|
+
export function outcomeSnapshot(record, { status, now, evidenceAt }) {
|
|
405
|
+
const read = readRecord(record)
|
|
406
|
+
const state = outcomeState(read, status)
|
|
407
|
+
const flow = read.flow
|
|
408
|
+
const parsed = flow ? read.returns.map(parseReturn) : []
|
|
409
|
+
const entries = parsed.filter(Boolean)
|
|
410
|
+
return {
|
|
411
|
+
rev: flow?.rev ?? 0,
|
|
412
|
+
state,
|
|
413
|
+
verified: read.signoff?.verified ?? null,
|
|
414
|
+
reason: read.signoff?.reason ?? null,
|
|
415
|
+
deliveries: flow?.deliveries ?? 0,
|
|
416
|
+
delivered_at: flow?.delivered_at ?? (state === "not_delivered" ? null : timeOf(evidenceAt)),
|
|
417
|
+
signed_at: read.signoff?.at ?? null,
|
|
418
|
+
observed_at: timeOf(typeof now === "number" && Number.isFinite(now) ? new Date(now) : now),
|
|
419
|
+
since: flow?.since ?? null,
|
|
420
|
+
first_validating_at: flow?.first_validating_at ?? null,
|
|
421
|
+
first_delivered_at: flow?.first_delivered_at ?? null,
|
|
422
|
+
returns: entries.map((entry) => ({
|
|
423
|
+
reason: entry.reason,
|
|
424
|
+
caught: entry.caught,
|
|
425
|
+
counts: returnCounts(entry, flow.first_validating_at),
|
|
426
|
+
refusal: entry.refusal,
|
|
427
|
+
refusal_verified: entry.refusal_verified,
|
|
428
|
+
})),
|
|
429
|
+
returns_unreadable: parsed.length - entries.length + read.returns_damaged,
|
|
430
|
+
}
|
|
431
|
+
}
|