@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,957 @@
|
|
|
1
|
+
// Local facts (`desk.factory.local/2`; `/1` files are still read): schema, privacy gate and
|
|
2
|
+
// validator, plus the spec walker the published schema reuses.
|
|
3
|
+
//
|
|
4
|
+
// Local facts are what the derivers and binding write to the local outbox,
|
|
5
|
+
// one file per session per store. They keep exact times and never leave the
|
|
6
|
+
// machine as they are: `publish.js`'s `toPublished` is the only transform
|
|
7
|
+
// that produces what leaves it, and `published-schema.js` is the public gate
|
|
8
|
+
// for that form. Local facts carry no contributor.
|
|
9
|
+
//
|
|
10
|
+
// Every string in a local facts file matches an enum or a strict pattern —
|
|
11
|
+
// there is no free-text field, so there is nothing here a transcript, a
|
|
12
|
+
// prompt, a file path or a task title could hide inside.
|
|
13
|
+
// `validateLocalFacts` enforces that shape exactly: an unrecognized key is
|
|
14
|
+
// refused, not ignored. `validateLocalFactsBytes` additionally requires the
|
|
15
|
+
// raw bytes to be the canonical serialization of what they parse to, so a
|
|
16
|
+
// duplicate JSON key — which `JSON.parse` silently collapses to its last
|
|
17
|
+
// value — cannot let free text ride along in bytes that otherwise parse
|
|
18
|
+
// clean.
|
|
19
|
+
//
|
|
20
|
+
// The schema is a real declarative spec walker: one field-spec object per
|
|
21
|
+
// level (`SESSION_SPEC`, `MODEL_SPEC`, ...) is the *only* place that names a
|
|
22
|
+
// level's keys, and both the allowed-key check and the per-key validators are
|
|
23
|
+
// derived from that same object by `validateObject`. There is no second,
|
|
24
|
+
// hand-kept list to fall out of sync with it.
|
|
25
|
+
//
|
|
26
|
+
// Error reporting follows the same discipline. `{ code, path }` only, and
|
|
27
|
+
// `path` is built only from fixed schema field names and numeric array
|
|
28
|
+
// indices — never from a value the input supplied and never from a key name
|
|
29
|
+
// the input supplied (an "unknown key" names its containing object, not
|
|
30
|
+
// itself) — so a malformed or adversarial input cannot smuggle its own
|
|
31
|
+
// content out through an error report.
|
|
32
|
+
//
|
|
33
|
+
// `src/factory/**` imports only `node:` built-ins and other `src/factory/`
|
|
34
|
+
// files; this module needs no import at all — `Buffer` is a Node global, and
|
|
35
|
+
// every other check here is plain object/regex/Date arithmetic.
|
|
36
|
+
|
|
37
|
+
import { SLUG } from "./repo-name.js"
|
|
38
|
+
|
|
39
|
+
export const ENUMS = Object.freeze({
|
|
40
|
+
host: Object.freeze(["claude-code", "copilot-cli", "codex-cli"]),
|
|
41
|
+
entrypoint: Object.freeze(["cli", "desktop", "sdk", "launcher", "unknown"]),
|
|
42
|
+
endReason: Object.freeze([
|
|
43
|
+
"clear", "resume", "logout", "prompt_input_exit", "complete", "user_exit", "error", "other",
|
|
44
|
+
]),
|
|
45
|
+
toolKind: Object.freeze([
|
|
46
|
+
"read", "edit", "shell", "search", "web", "agent", "desk", "skill", "mcp", "plan", "other",
|
|
47
|
+
]),
|
|
48
|
+
intervalKind: Object.freeze([
|
|
49
|
+
"turn", "tool", "subagent", "human_wait", "permission_wait", "api_retry", "compaction",
|
|
50
|
+
]),
|
|
51
|
+
outcome: Object.freeze(["ok", "error", "denied", "interrupted", "timeout"]),
|
|
52
|
+
jobStatus: Object.freeze([
|
|
53
|
+
"drafting", "processing", "validating", "collaborating", "paused", "blocked", "done", "cancelled",
|
|
54
|
+
]),
|
|
55
|
+
jobBasis: Object.freeze(["desk_tool", "file_write", "desk_commit", "spawn_brief", "inherited"]),
|
|
56
|
+
// A field a file lists here was not recorded; its value in the file is not a measured zero.
|
|
57
|
+
unavailableField: Object.freeze([
|
|
58
|
+
"tokens", "requests", "models", "turns", "tool_durations", "permission_waits",
|
|
59
|
+
"human_waits", "api_retries", "commits", "ci_runs", "plugins", "ended_at",
|
|
60
|
+
"compaction_waits", "agents", "prs", "reasoning_tokens", "entrypoint", "tool_outcomes", "job_segments",
|
|
61
|
+
"human_turns", "outcomes",
|
|
62
|
+
]),
|
|
63
|
+
// The published form adds `job_offsets`: a job whose offsets could not be
|
|
64
|
+
// measured (no readable task-card creation time). `outcomes` with `capped`
|
|
65
|
+
// says a session touched more tasks than `LIMITS.outcomes` and the list
|
|
66
|
+
// was cut; a published file carries it only as `desk.factory.published/3`.
|
|
67
|
+
publishedUnavailableField: Object.freeze([
|
|
68
|
+
"tokens", "requests", "models", "turns", "tool_durations", "permission_waits",
|
|
69
|
+
"human_waits", "api_retries", "commits", "ci_runs", "plugins", "ended_at",
|
|
70
|
+
"compaction_waits", "agents", "prs", "reasoning_tokens", "entrypoint", "tool_outcomes", "job_segments",
|
|
71
|
+
"human_turns", "job_offsets", "outcomes",
|
|
72
|
+
]),
|
|
73
|
+
// `log_truncated` is a log that ends mid-record; `capped` is data a deriver
|
|
74
|
+
// trimmed to a schema limit; `desk_public` is job timing the transform
|
|
75
|
+
// withholds because the desk's own remote is (or may be) public.
|
|
76
|
+
// `interval_outside_session_clock` is an interval the publishing transform
|
|
77
|
+
// dropped because it ran outside the published session clock (a subagent
|
|
78
|
+
// still working after the main log's last line): the rest of the field's
|
|
79
|
+
// intervals are whole, so it only ever makes a figure partial.
|
|
80
|
+
unavailableReason: Object.freeze([
|
|
81
|
+
"host_does_not_record", "log_missing", "log_truncated", "session_open",
|
|
82
|
+
"not_collected_in_slice_1", "source_unreadable", "capped", "desk_public",
|
|
83
|
+
"field_absent", "host_records_partly", "withheld_public", "interval_outside_session_clock",
|
|
84
|
+
]),
|
|
85
|
+
// The size class of a character count (`sizeClass` in `derive-common.js`), and how a human turn relates to the agent's last stop.
|
|
86
|
+
sizeClass: Object.freeze(["none", "xs", "s", "m", "l", "xl"]),
|
|
87
|
+
turnBasis: Object.freeze(["first", "after_stop", "mid_turn"]),
|
|
88
|
+
// How the agent's turn ended before a human wait (`intervals[kind=human_wait].stop.end`): the root reply's stop reason, an API error or limit, the operator's interrupt, an open question or plan tool, or `not_recorded` when the host's log does not say.
|
|
89
|
+
stopEnd: Object.freeze([
|
|
90
|
+
"end_turn", "max_tokens", "rate_limit", "api_error", "refusal", "interrupted", "ask_question", "ask_plan", "not_recorded",
|
|
91
|
+
]),
|
|
92
|
+
// The source of a published job's finish day (`jobs[].finished_on`, `desk.factory.published/4`): the session's own last transition into the terminal status, or the card's `updated` time, which is an upper bound.
|
|
93
|
+
finishedBasis: Object.freeze(["transition", "card_updated"]),
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
export const LOCAL_SCHEMA = "desk.factory.local/2"
|
|
97
|
+
|
|
98
|
+
/** Every local schema value a reader accepts: the legacy `/1` and the current one. */
|
|
99
|
+
export const LOCAL_SCHEMAS = Object.freeze(["desk.factory.local/1", LOCAL_SCHEMA])
|
|
100
|
+
|
|
101
|
+
export const PATTERNS = Object.freeze({
|
|
102
|
+
schema: /^desk\.factory\.local\/[12]$/u,
|
|
103
|
+
sessionId: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u,
|
|
104
|
+
// The prerelease part is bounded (controller ruling, M1): unbounded free text there
|
|
105
|
+
// would let word-shaped strings ride through as a "version".
|
|
106
|
+
semver: /^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]{1,32})?$/u,
|
|
107
|
+
timestamp: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u,
|
|
108
|
+
pluginName: /^[a-z0-9][a-z0-9-]{0,63}$/u,
|
|
109
|
+
modelId: /^[A-Za-z0-9][A-Za-z0-9._:-]{0,79}$/u,
|
|
110
|
+
// The harness's own agent type (`general-purpose`, `plugin:name`). A requested model
|
|
111
|
+
// uses `modelId`: a short alias such as `sonnet` is a subset of that pattern.
|
|
112
|
+
agentType: /^[A-Za-z0-9][A-Za-z0-9:_.-]{0,63}$/u,
|
|
113
|
+
prRepo: SLUG,
|
|
114
|
+
commitSha: /^[0-9a-f]{40}$/u,
|
|
115
|
+
jobId: /^[0-9a-f]{32}$/u,
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
export const LIMITS = Object.freeze({
|
|
119
|
+
maxBytes: 16 * 1024 * 1024,
|
|
120
|
+
plugins: 64,
|
|
121
|
+
models: 32,
|
|
122
|
+
intervals: 100000,
|
|
123
|
+
prs: 500,
|
|
124
|
+
commits: 2000,
|
|
125
|
+
agents: 10000,
|
|
126
|
+
jobs: 1000,
|
|
127
|
+
jobTransitions: 1000,
|
|
128
|
+
jobSegments: 200,
|
|
129
|
+
// Every field with every reason once: no entry set can overflow when an enum grows.
|
|
130
|
+
unavailable: ENUMS.publishedUnavailableField.length * ENUMS.unavailableReason.length,
|
|
131
|
+
outcomes: 256,
|
|
132
|
+
returns: 32,
|
|
133
|
+
humanTurns: 1000,
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
export const isPlainObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value)
|
|
137
|
+
const isSafeNonNegInt = (value) => Number.isSafeInteger(value) && value >= 0
|
|
138
|
+
const isSafePositiveInt = (value) => Number.isSafeInteger(value) && value > 0
|
|
139
|
+
export const joinPath = (parent, segment) => (parent === "" ? String(segment) : `${parent}.${segment}`)
|
|
140
|
+
|
|
141
|
+
export function addError(errors, code, path) {
|
|
142
|
+
errors.push({ code, path })
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Every object here has an exact key set; anything else is `unknown_key`. */
|
|
146
|
+
function checkKnownKeys(value, path, allowedKeys, errors) {
|
|
147
|
+
const allowed = new Set(allowedKeys)
|
|
148
|
+
for (const key of Object.keys(value)) {
|
|
149
|
+
if (!allowed.has(key)) addError(errors, "unknown_key", path)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function checkPattern(value, path, pattern, errors) {
|
|
154
|
+
if (typeof value !== "string") {
|
|
155
|
+
addError(errors, "type", path)
|
|
156
|
+
return false
|
|
157
|
+
}
|
|
158
|
+
if (!pattern.test(value)) {
|
|
159
|
+
addError(errors, "pattern", path)
|
|
160
|
+
return false
|
|
161
|
+
}
|
|
162
|
+
return true
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function checkEnum(value, path, allowed, errors) {
|
|
166
|
+
if (typeof value !== "string") {
|
|
167
|
+
addError(errors, "type", path)
|
|
168
|
+
return false
|
|
169
|
+
}
|
|
170
|
+
if (!allowed.includes(value)) {
|
|
171
|
+
addError(errors, "enum", path)
|
|
172
|
+
return false
|
|
173
|
+
}
|
|
174
|
+
return true
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function checkSafeNonNegInt(value, path, errors) {
|
|
178
|
+
if (!isSafeNonNegInt(value)) {
|
|
179
|
+
addError(errors, "integer", path)
|
|
180
|
+
return false
|
|
181
|
+
}
|
|
182
|
+
return true
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function checkNullableSafeNonNegInt(value, path, errors) {
|
|
186
|
+
if (value === null) return true
|
|
187
|
+
return checkSafeNonNegInt(value, path, errors)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function checkRangeInt(value, path, min, max, errors) {
|
|
191
|
+
if (!Number.isSafeInteger(value) || value < min || value > max) {
|
|
192
|
+
addError(errors, "range", path)
|
|
193
|
+
return false
|
|
194
|
+
}
|
|
195
|
+
return true
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function checkNullableRangeInt(value, path, min, max, errors) {
|
|
199
|
+
if (value === null) return true
|
|
200
|
+
return checkRangeInt(value, path, min, max, errors)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// A timestamp must both match the strict pattern and be a real instant
|
|
204
|
+
// (controller ruling, M2): `2026-99-99T99:99:99.999Z` matches the pattern's
|
|
205
|
+
// shape but is not a date `Date.parse` can resolve, and reporting anything
|
|
206
|
+
// other than `pattern` for it would let a shape-only check stand in for a
|
|
207
|
+
// real one.
|
|
208
|
+
function checkTimestamp(value, path, errors) {
|
|
209
|
+
if (typeof value !== "string") {
|
|
210
|
+
addError(errors, "type", path)
|
|
211
|
+
return false
|
|
212
|
+
}
|
|
213
|
+
if (!PATTERNS.timestamp.test(value) || Number.isNaN(Date.parse(value))) {
|
|
214
|
+
addError(errors, "pattern", path)
|
|
215
|
+
return false
|
|
216
|
+
}
|
|
217
|
+
return true
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function checkNullableTimestamp(value, path, errors) {
|
|
221
|
+
if (value === null) return true
|
|
222
|
+
return checkTimestamp(value, path, errors)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function requireField(value, path, field, errors) {
|
|
226
|
+
if (!Object.hasOwn(value, field)) {
|
|
227
|
+
addError(errors, "missing", joinPath(path, field))
|
|
228
|
+
return false
|
|
229
|
+
}
|
|
230
|
+
return true
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// ---------------------------------------------------------------------------
|
|
234
|
+
// Spec primitives. Each returns `{ check(value, path, errors, ctx) }`. A
|
|
235
|
+
// level's spec is a plain object mapping its field names to one of these —
|
|
236
|
+
// that same object drives both `checkKnownKeys`'s allow-list and the actual
|
|
237
|
+
// per-key validation in `validateObject`, so the two can never disagree.
|
|
238
|
+
// They are exported for `published-schema.js`, which builds its own level
|
|
239
|
+
// specs from them and walks them with this same `validateObject`: there is
|
|
240
|
+
// one validator engine, not two.
|
|
241
|
+
// ---------------------------------------------------------------------------
|
|
242
|
+
|
|
243
|
+
export const leaf = (check) => ({ check })
|
|
244
|
+
|
|
245
|
+
export const patternField = (pattern) => leaf((value, path, errors) => checkPattern(value, path, pattern, errors))
|
|
246
|
+
export const enumField = (allowed) => leaf((value, path, errors) => checkEnum(value, path, allowed, errors))
|
|
247
|
+
export const nullableEnumField = (allowed) => leaf((value, path, errors) => (value === null ? true : checkEnum(value, path, allowed, errors)))
|
|
248
|
+
export const nonNegIntField = () => leaf(checkSafeNonNegInt)
|
|
249
|
+
const nullableNonNegIntField = () => leaf(checkNullableSafeNonNegInt)
|
|
250
|
+
export const booleanField = () => leaf((value, path, errors) => {
|
|
251
|
+
if (typeof value !== "boolean") {
|
|
252
|
+
addError(errors, "type", path)
|
|
253
|
+
return false
|
|
254
|
+
}
|
|
255
|
+
return true
|
|
256
|
+
})
|
|
257
|
+
const positiveIntField = () => leaf((value, path, errors) => {
|
|
258
|
+
if (!isSafePositiveInt(value)) {
|
|
259
|
+
addError(errors, "integer", path)
|
|
260
|
+
return false
|
|
261
|
+
}
|
|
262
|
+
return true
|
|
263
|
+
})
|
|
264
|
+
export const rangeIntField = (min, max) => leaf((value, path, errors) => checkRangeInt(value, path, min, max, errors))
|
|
265
|
+
const nullableRangeIntField = (min, max) => leaf((value, path, errors) => checkNullableRangeInt(value, path, min, max, errors))
|
|
266
|
+
const timestampField = () => leaf(checkTimestamp)
|
|
267
|
+
const nullableTimestampField = () => leaf(checkNullableTimestamp)
|
|
268
|
+
export const customField = (check) => leaf(check)
|
|
269
|
+
|
|
270
|
+
/** A nested fixed-shape object. `specOrFn` may compute the spec from the raw value (for a shape that depends on a sibling field, e.g. `intervals[].kind`). */
|
|
271
|
+
export function objectField(specOrFn, post) {
|
|
272
|
+
return leaf((value, path, errors, ctx) => {
|
|
273
|
+
const results = validateObject(value, path, specOrFn, errors, ctx)
|
|
274
|
+
if (results !== undefined && post) post(value, path, results, errors, ctx)
|
|
275
|
+
return results
|
|
276
|
+
})
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** Same shape, but `null` is also accepted. */
|
|
280
|
+
export function nullableObjectField(spec) {
|
|
281
|
+
return leaf((value, path, errors, ctx) => (value === null ? true : validateObject(value, path, spec, errors, ctx)))
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** An array of `itemField`-shaped entries, capped at `max` (every array in this schema has one — see `LIMITS`). Over cap fails fast with one `too_many`, items left unchecked. */
|
|
285
|
+
export function arrayField(itemField, max) {
|
|
286
|
+
return leaf((value, path, errors, ctx) => {
|
|
287
|
+
if (!Array.isArray(value)) {
|
|
288
|
+
addError(errors, "type", path)
|
|
289
|
+
return undefined
|
|
290
|
+
}
|
|
291
|
+
if (value.length > max) {
|
|
292
|
+
addError(errors, "too_many", path)
|
|
293
|
+
return undefined
|
|
294
|
+
}
|
|
295
|
+
return value.map((item, index) => itemField.check(item, joinPath(path, index), errors, ctx))
|
|
296
|
+
})
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** An open map keyed by members of `allowedKeys` (e.g. `counts.tool_calls`), each value shaped by `valueField`. An unrecognized key names the map itself, never the key. */
|
|
300
|
+
function mapOfField(allowedKeys, valueField) {
|
|
301
|
+
return leaf((value, path, errors) => {
|
|
302
|
+
if (!isPlainObject(value)) {
|
|
303
|
+
addError(errors, "type", path)
|
|
304
|
+
return undefined
|
|
305
|
+
}
|
|
306
|
+
let sawUnknownKey = false
|
|
307
|
+
for (const key of Object.keys(value)) {
|
|
308
|
+
if (!allowedKeys.includes(key)) sawUnknownKey = true
|
|
309
|
+
}
|
|
310
|
+
if (sawUnknownKey) addError(errors, "unknown_key", path)
|
|
311
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
312
|
+
if (!allowedKeys.includes(key)) continue
|
|
313
|
+
valueField.check(entry, joinPath(path, key), errors)
|
|
314
|
+
}
|
|
315
|
+
return true
|
|
316
|
+
})
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Validate `value` as an object shaped by `specOrFn` (a field-spec object, or
|
|
321
|
+
* a function of `value` and the caller's `ctx` returning one). A function
|
|
322
|
+
* spec always receives `ctx` as its second argument, so a spec function with
|
|
323
|
+
* another optional second parameter must be wrapped. Checks the key set exactly once
|
|
324
|
+
* against `Object.keys(spec)`, then runs each present field's own check —
|
|
325
|
+
* the single source of truth I2 (real declarative spec walker) asks for.
|
|
326
|
+
* Returns a map of field name -> that field's check result, or `undefined`
|
|
327
|
+
* when `value` isn't even a plain object.
|
|
328
|
+
*/
|
|
329
|
+
export function validateObject(value, path, specOrFn, errors, ctx) {
|
|
330
|
+
if (!isPlainObject(value)) {
|
|
331
|
+
addError(errors, "type", path)
|
|
332
|
+
return undefined
|
|
333
|
+
}
|
|
334
|
+
const spec = typeof specOrFn === "function" ? specOrFn(value, ctx) : specOrFn
|
|
335
|
+
checkKnownKeys(value, path, Object.keys(spec), errors)
|
|
336
|
+
const results = {}
|
|
337
|
+
for (const [key, field] of Object.entries(spec)) {
|
|
338
|
+
if (!requireField(value, path, key, errors)) continue
|
|
339
|
+
results[key] = field.check(value[key], joinPath(path, key), errors, ctx)
|
|
340
|
+
}
|
|
341
|
+
return results
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// ---------------------------------------------------------------------------
|
|
345
|
+
// Per-level specs.
|
|
346
|
+
// ---------------------------------------------------------------------------
|
|
347
|
+
|
|
348
|
+
// The levels whose shape is the same in the local and published forms are
|
|
349
|
+
// exported for `published-schema.js`.
|
|
350
|
+
|
|
351
|
+
const TOKEN_FIELDS = ["input", "output", "cache_read", "cache_write", "reasoning"]
|
|
352
|
+
const TOKENS_SPEC = Object.fromEntries(TOKEN_FIELDS.map((name) => [name, nullableNonNegIntField()]))
|
|
353
|
+
|
|
354
|
+
export const MODEL_SPEC = {
|
|
355
|
+
id: patternField(PATTERNS.modelId),
|
|
356
|
+
requests: nullableNonNegIntField(),
|
|
357
|
+
tokens: objectField(TOKENS_SPEC),
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const PLUGIN_SPEC = {
|
|
361
|
+
name: patternField(PATTERNS.pluginName),
|
|
362
|
+
version: patternField(PATTERNS.semver),
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// A local plugin may also say where it was installed from: the GitHub
|
|
366
|
+
// `owner/repo` of its marketplace or cache entry, or `null` when that is
|
|
367
|
+
// unknown. The key is optional, so older local facts stay valid and read as
|
|
368
|
+
// `null`; the transform names a plugin in a public store only when this
|
|
369
|
+
// repository is public, and it never publishes the source itself.
|
|
370
|
+
const nullableRepoField = () => leaf((value, path, errors) => (value === null ? true : checkPattern(value, path, PATTERNS.prRepo, errors)))
|
|
371
|
+
|
|
372
|
+
/** Whether a plugin entry's optional `source` is absent, `null` or an `owner/repo` name. */
|
|
373
|
+
export function validPluginSource(plugin) {
|
|
374
|
+
return !Object.hasOwn(plugin, "source") || plugin.source === null || (typeof plugin.source === "string" && PATTERNS.prRepo.test(plugin.source))
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function localPluginFields(value) {
|
|
378
|
+
return Object.hasOwn(value, "source") ? { ...PLUGIN_SPEC, source: nullableRepoField() } : PLUGIN_SPEC
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export const AGENT_SPEC = {
|
|
382
|
+
n: rangeIntField(0, 9999),
|
|
383
|
+
parent: nullableRangeIntField(0, 9999),
|
|
384
|
+
model: patternField(PATTERNS.modelId),
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** `base` plus the optional worker keys `agent_type` and `requested_model`, each only when the entry carries it, so files written before they existed stay valid. Local and published validation both build their agent spec here. */
|
|
388
|
+
export function agentFields(value, base, agentType, requestedModel) {
|
|
389
|
+
return {
|
|
390
|
+
...base,
|
|
391
|
+
...(Object.hasOwn(value, "agent_type") ? { agent_type: agentType } : {}),
|
|
392
|
+
...(Object.hasOwn(value, "requested_model") ? { requested_model: requestedModel } : {}),
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
const LOCAL_AGENT_TYPE = patternField(PATTERNS.agentType)
|
|
397
|
+
const localAgentFields = (value) => agentFields(value, AGENT_SPEC, LOCAL_AGENT_TYPE, patternField(PATTERNS.modelId))
|
|
398
|
+
|
|
399
|
+
export const PR_SPEC = {
|
|
400
|
+
repo: patternField(PATTERNS.prRepo),
|
|
401
|
+
number: positiveIntField(),
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// `agent` (the worker that opened the PR) is optional, so files written before
|
|
405
|
+
// workers were attributed stay valid. Whether it names a real worker is a
|
|
406
|
+
// cross-field check (`checkAgentReferences`).
|
|
407
|
+
// `at_ms` (when the creating tool result came, in milliseconds from session
|
|
408
|
+
// start) is optional too: files written before PRs were timed stay valid.
|
|
409
|
+
// So is `created`, whether this session's own call created the PR rather than
|
|
410
|
+
// only mentioning it; the published form requires it from `/4` on.
|
|
411
|
+
export function prFields(value) {
|
|
412
|
+
return {
|
|
413
|
+
...PR_SPEC,
|
|
414
|
+
...(Object.hasOwn(value, "agent") ? { agent: rangeIntField(0, 9999) } : {}),
|
|
415
|
+
...(Object.hasOwn(value, "at_ms") ? { at_ms: nonNegIntField() } : {}),
|
|
416
|
+
...(Object.hasOwn(value, "created") ? { created: booleanField() } : {}),
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// `true`, `false` or `null` (not known).
|
|
421
|
+
const nullableBooleanField = () => leaf((value, path, errors) => (value === null ? true : booleanField().check(value, path, errors)))
|
|
422
|
+
|
|
423
|
+
// `intervals[kind=human_wait].stop`: the mechanical facts of how the agent's
|
|
424
|
+
// turn ended before the wait. `asks` is whether the final reply ended in a
|
|
425
|
+
// question mark and `pending_agents` whether the agent's own background
|
|
426
|
+
// agents were still running; each is `null` when the host does not say. No
|
|
427
|
+
// text and no tool name. Shared by the local and published forms.
|
|
428
|
+
export const STOP_SPEC = {
|
|
429
|
+
end: enumField(ENUMS.stopEnd),
|
|
430
|
+
asks: nullableBooleanField(),
|
|
431
|
+
pending_agents: nullableBooleanField(),
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// `jobs[].agents`: the workers whose work belongs to the job. A non-empty,
|
|
435
|
+
// duplicate-free list of worker numbers; absent means every worker in the session.
|
|
436
|
+
function checkJobAgents(value, path, errors) {
|
|
437
|
+
if (!Array.isArray(value)) {
|
|
438
|
+
addError(errors, "type", path)
|
|
439
|
+
return false
|
|
440
|
+
}
|
|
441
|
+
if (value.length === 0) {
|
|
442
|
+
addError(errors, "empty", path)
|
|
443
|
+
return false
|
|
444
|
+
}
|
|
445
|
+
if (value.length > LIMITS.agents) {
|
|
446
|
+
addError(errors, "too_many", path)
|
|
447
|
+
return false
|
|
448
|
+
}
|
|
449
|
+
let ok = true
|
|
450
|
+
value.forEach((entry, index) => {
|
|
451
|
+
if (!rangeIntField(0, 9999).check(entry, joinPath(path, index), errors)) ok = false
|
|
452
|
+
})
|
|
453
|
+
if (ok && new Set(value).size !== value.length) {
|
|
454
|
+
addError(errors, "duplicate", path)
|
|
455
|
+
ok = false
|
|
456
|
+
}
|
|
457
|
+
// Canonical form: ascending, so one content gives one set of bytes.
|
|
458
|
+
if (ok && value.some((entry, index) => index > 0 && entry < value[index - 1])) {
|
|
459
|
+
addError(errors, "order", path)
|
|
460
|
+
ok = false
|
|
461
|
+
}
|
|
462
|
+
return ok
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// `jobs[].segments`: the spans of the session, in milliseconds from its start,
|
|
466
|
+
// that the controller's (worker 0's) evidence gives to the job. Each is
|
|
467
|
+
// half-open, `[start_ms, end_ms)`, and `shared: true` marks a span another job
|
|
468
|
+
// of the session holds too. Within a job they are ascending and never overlap.
|
|
469
|
+
const SEGMENT_SPEC = {
|
|
470
|
+
start_ms: nonNegIntField(),
|
|
471
|
+
end_ms: nonNegIntField(),
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const trueField = () => leaf((value, path, errors) => {
|
|
475
|
+
if (value !== true) {
|
|
476
|
+
addError(errors, "type", path)
|
|
477
|
+
return false
|
|
478
|
+
}
|
|
479
|
+
return true
|
|
480
|
+
})
|
|
481
|
+
|
|
482
|
+
const segmentFields = (value) => (Object.hasOwn(value, "shared") ? { ...SEGMENT_SPEC, shared: trueField() } : SEGMENT_SPEC)
|
|
483
|
+
|
|
484
|
+
function checkSegments(value, path, errors) {
|
|
485
|
+
if (!Array.isArray(value)) {
|
|
486
|
+
addError(errors, "type", path)
|
|
487
|
+
return false
|
|
488
|
+
}
|
|
489
|
+
// A job the controller holds no time in has no segments at all, never an empty list.
|
|
490
|
+
if (value.length === 0) {
|
|
491
|
+
addError(errors, "empty", path)
|
|
492
|
+
return false
|
|
493
|
+
}
|
|
494
|
+
if (value.length > LIMITS.jobSegments) {
|
|
495
|
+
addError(errors, "too_many", path)
|
|
496
|
+
return false
|
|
497
|
+
}
|
|
498
|
+
const before = errors.length
|
|
499
|
+
let previousEnd = null
|
|
500
|
+
value.forEach((segment, index) => {
|
|
501
|
+
const itemPath = joinPath(path, index)
|
|
502
|
+
const results = validateObject(segment, itemPath, segmentFields, errors)
|
|
503
|
+
if (results?.start_ms !== true || results.end_ms !== true) {
|
|
504
|
+
previousEnd = null
|
|
505
|
+
return
|
|
506
|
+
}
|
|
507
|
+
if (segment.end_ms <= segment.start_ms) addError(errors, "order", joinPath(itemPath, "end_ms"))
|
|
508
|
+
else if (previousEnd !== null && segment.start_ms < previousEnd) addError(errors, "order", joinPath(itemPath, "start_ms"))
|
|
509
|
+
previousEnd = segment.end_ms
|
|
510
|
+
})
|
|
511
|
+
return errors.length === before
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// Adds the optional `agents` and `segments` keys to a job spec when the job carries them.
|
|
515
|
+
export function jobFields(value, base) {
|
|
516
|
+
return {
|
|
517
|
+
...base,
|
|
518
|
+
...(Object.hasOwn(value, "agents") ? { agents: customField(checkJobAgents) } : {}),
|
|
519
|
+
...(Object.hasOwn(value, "segments") ? { segments: customField(checkSegments) } : {}),
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Segments split the controller's (worker 0's) time, so a job carries them
|
|
525
|
+
* only when its `agents` lists worker 0; anything else is `inconsistent`.
|
|
526
|
+
* Shared by the local and published validators.
|
|
527
|
+
*/
|
|
528
|
+
export function checkSegmentAgents(value, results, errors) {
|
|
529
|
+
results.jobs?.forEach((jobResult, index) => {
|
|
530
|
+
if (jobResult?.segments === undefined) return
|
|
531
|
+
const job = value.jobs[index]
|
|
532
|
+
if (!Array.isArray(job.agents) || !job.agents.includes(0)) addError(errors, "inconsistent", `jobs.${index}.segments`)
|
|
533
|
+
})
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* No job segment, PR time or commit time may run past the session's end
|
|
538
|
+
* (`durationMs`, or `null` when the session's own times are unsound, which
|
|
539
|
+
* skips the check so one bad time is one error). Shared by the local and
|
|
540
|
+
* published validators.
|
|
541
|
+
*/
|
|
542
|
+
export function checkSessionBounds(value, results, errors, durationMs) {
|
|
543
|
+
if (durationMs === null) return
|
|
544
|
+
results.jobs?.forEach((jobResult, index) => {
|
|
545
|
+
if (jobResult?.segments !== true) return
|
|
546
|
+
value.jobs[index].segments.forEach((segment, entry) => {
|
|
547
|
+
if (segment.end_ms > durationMs) addError(errors, "range", `jobs.${index}.segments.${entry}.end_ms`)
|
|
548
|
+
})
|
|
549
|
+
})
|
|
550
|
+
results.refs?.prs?.forEach((prResult, index) => {
|
|
551
|
+
if (prResult?.at_ms === true && value.refs.prs[index].at_ms > durationMs) addError(errors, "range", `refs.prs.${index}.at_ms`)
|
|
552
|
+
})
|
|
553
|
+
results.refs?.commits?.forEach((commitResult, index) => {
|
|
554
|
+
if (commitResult?.at_ms === true && value.refs.commits[index].at_ms > durationMs) addError(errors, "range", `refs.commits.${index}.at_ms`)
|
|
555
|
+
})
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// A commit's repository, when the deriver can attribute one; `null` when it
|
|
559
|
+
// cannot (the transform drops and counts those).
|
|
560
|
+
const COMMIT_SPEC = {
|
|
561
|
+
repo: nullableRepoField(),
|
|
562
|
+
sha: patternField(PATTERNS.commitSha),
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* A commit's keys: `COMMIT_SPEC` (or the published form's `base`), plus the
|
|
567
|
+
* optional `at_ms`, milliseconds from session start to when the session
|
|
568
|
+
* recorded the commit. Optional, so files written before commits were timed
|
|
569
|
+
* stay valid; it never runs past the session's end (`checkSessionBounds`).
|
|
570
|
+
*/
|
|
571
|
+
export function commitFields(value, base = COMMIT_SPEC) {
|
|
572
|
+
return Object.hasOwn(value, "at_ms") ? { ...base, at_ms: nonNegIntField() } : base
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// `unresolved` counts references the deriver saw but could not publish
|
|
576
|
+
// exactly: a bare PR number with no session repository, a short commit SHA
|
|
577
|
+
// that does not resolve locally. The transform adds them to `refs.private`.
|
|
578
|
+
const UNRESOLVED_SPEC = {
|
|
579
|
+
prs: nonNegIntField(),
|
|
580
|
+
commits: nonNegIntField(),
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
const REFS_SPEC = {
|
|
584
|
+
prs: arrayField(objectField(prFields), LIMITS.prs),
|
|
585
|
+
// Wrapped: a function spec also receives the walker's context, which `commitFields` would read as its `base`.
|
|
586
|
+
commits: arrayField(objectField((value) => commitFields(value)), LIMITS.commits),
|
|
587
|
+
unresolved: objectField(UNRESOLVED_SPEC),
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
const TRANSITION_SPEC = {
|
|
591
|
+
to: enumField(ENUMS.jobStatus),
|
|
592
|
+
at: timestampField(),
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// `at` is the card's `updated` for a terminal status, else `null` (M3-4).
|
|
596
|
+
const OBSERVED_SPEC = {
|
|
597
|
+
status: enumField(ENUMS.jobStatus),
|
|
598
|
+
at: nullableTimestampField(),
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// jobs[].basis: a non-empty, duplicate-free subset of ENUMS.jobBasis
|
|
602
|
+
// (controller ruling, M3: duplicates are their own `duplicate` error, not
|
|
603
|
+
// folded into `enum`).
|
|
604
|
+
export function checkBasis(value, path, errors) {
|
|
605
|
+
if (!Array.isArray(value)) {
|
|
606
|
+
addError(errors, "type", path)
|
|
607
|
+
return false
|
|
608
|
+
}
|
|
609
|
+
if (value.length === 0) {
|
|
610
|
+
addError(errors, "empty", path)
|
|
611
|
+
return false
|
|
612
|
+
}
|
|
613
|
+
let sawInvalid = false
|
|
614
|
+
for (const entry of value) {
|
|
615
|
+
if (typeof entry !== "string" || !ENUMS.jobBasis.includes(entry)) sawInvalid = true
|
|
616
|
+
}
|
|
617
|
+
if (sawInvalid) {
|
|
618
|
+
addError(errors, "enum", path)
|
|
619
|
+
return false
|
|
620
|
+
}
|
|
621
|
+
const seen = new Set()
|
|
622
|
+
let sawDuplicate = false
|
|
623
|
+
for (const entry of value) {
|
|
624
|
+
if (seen.has(entry)) sawDuplicate = true
|
|
625
|
+
seen.add(entry)
|
|
626
|
+
}
|
|
627
|
+
if (sawDuplicate) {
|
|
628
|
+
addError(errors, "duplicate", path)
|
|
629
|
+
return false
|
|
630
|
+
}
|
|
631
|
+
return true
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// M3-4's `LocalJob`.
|
|
635
|
+
const JOB_SPEC = {
|
|
636
|
+
job: patternField(PATTERNS.jobId),
|
|
637
|
+
basis: customField(checkBasis),
|
|
638
|
+
task_created_at: nullableTimestampField(),
|
|
639
|
+
transitions: arrayField(objectField(TRANSITION_SPEC), LIMITS.jobTransitions),
|
|
640
|
+
observed: nullableObjectField(OBSERVED_SPEC),
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
const UNAVAILABLE_SPEC = {
|
|
644
|
+
field: enumField(ENUMS.unavailableField),
|
|
645
|
+
reason: enumField(ENUMS.unavailableReason),
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// `outcomes[]`: the outcome record of one task the session touched (`derive-run.js` `outcomesFor`). These two lists are `OUTCOME_STATES` and `REFUSAL_REASONS` in `outcome.js`; a test compares them, because this module imports nothing.
|
|
649
|
+
const OUTCOME_STATE_CODES = ["not_delivered", "not_recorded", "delivered_unsigned", "accepted", "refused", "reopened"]
|
|
650
|
+
const REFUSAL_REASON_CODES = ["not_what_was_asked", "defect", "changed_ask", "incomplete", "other"]
|
|
651
|
+
const OUTCOME_SPEC = {
|
|
652
|
+
job: patternField(PATTERNS.jobId),
|
|
653
|
+
rev: nonNegIntField(),
|
|
654
|
+
state: enumField(OUTCOME_STATE_CODES),
|
|
655
|
+
verified: leaf((value, path, errors) => (value === null ? true : booleanField().check(value, path, errors))),
|
|
656
|
+
reason: nullableEnumField(REFUSAL_REASON_CODES),
|
|
657
|
+
deliveries: nonNegIntField(),
|
|
658
|
+
delivered_at: nullableTimestampField(),
|
|
659
|
+
signed_at: nullableTimestampField(),
|
|
660
|
+
observed_at: nullableTimestampField(),
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// The optional keys of an outcome entry: the record's start, the two milestone times (local only), the returns the record holds (newest `LIMITS.returns`), and the two flags that say a returns list is not the whole story. These lists are `RETURN_REASONS` and `CATCH_POINTS` in `outcome.js`; a test compares them.
|
|
664
|
+
const RETURN_REASON_CODES = ["agent_error", "changed_ask", "new_information", "external"]
|
|
665
|
+
const CATCH_POINT_CODES = ["in_task", "at_review", "after_delivery"]
|
|
666
|
+
const OUTCOME_SINCE_CODES = ["created", "adopted"]
|
|
667
|
+
const RETURN_SPEC = {
|
|
668
|
+
reason: enumField(RETURN_REASON_CODES),
|
|
669
|
+
caught: enumField(CATCH_POINT_CODES),
|
|
670
|
+
counts: booleanField(),
|
|
671
|
+
refusal: nullableEnumField(REFUSAL_REASON_CODES),
|
|
672
|
+
refusal_verified: OUTCOME_SPEC.verified,
|
|
673
|
+
}
|
|
674
|
+
const OUTCOME_OPTIONAL = {
|
|
675
|
+
since: nullableEnumField(OUTCOME_SINCE_CODES),
|
|
676
|
+
first_validating_at: nullableTimestampField(),
|
|
677
|
+
first_delivered_at: nullableTimestampField(),
|
|
678
|
+
returns: arrayField(objectField(RETURN_SPEC), LIMITS.returns),
|
|
679
|
+
returns_truncated: leaf((value, path, errors) => {
|
|
680
|
+
if (value === true) return true
|
|
681
|
+
addError(errors, "type", path)
|
|
682
|
+
return false
|
|
683
|
+
}),
|
|
684
|
+
returns_unreadable: positiveIntField(),
|
|
685
|
+
}
|
|
686
|
+
// An entry's spec: the required keys, and each optional key the entry carries.
|
|
687
|
+
const outcomeFields = (value) => ({ ...OUTCOME_SPEC, ...Object.fromEntries(Object.entries(OUTCOME_OPTIONAL).filter(([key]) => Object.hasOwn(value, key))) })
|
|
688
|
+
|
|
689
|
+
// A list capped at `LIMITS.outcomes` with one entry per job.
|
|
690
|
+
const outcomesField = () => {
|
|
691
|
+
const list = arrayField(objectField(outcomeFields), LIMITS.outcomes)
|
|
692
|
+
return leaf((value, path, errors, ctx) => {
|
|
693
|
+
const results = list.check(value, path, errors, ctx)
|
|
694
|
+
if (results === undefined) return results
|
|
695
|
+
const seen = new Set()
|
|
696
|
+
value.forEach((entry, index) => {
|
|
697
|
+
if (results[index]?.job !== true) return
|
|
698
|
+
if (seen.has(entry.job)) addError(errors, "duplicate", joinPath(path, `${index}.job`))
|
|
699
|
+
seen.add(entry.job)
|
|
700
|
+
})
|
|
701
|
+
return results
|
|
702
|
+
})
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// `ended_at` and `derived_through` never precede `started_at`: the published
|
|
706
|
+
// duration is `derived_through - started_at` and must not be negative.
|
|
707
|
+
function sessionOrderCheck(value, path, results, errors) {
|
|
708
|
+
if (!results.started_at) return
|
|
709
|
+
const started = Date.parse(value.started_at)
|
|
710
|
+
if (value.ended_at !== null && results.ended_at && Date.parse(value.ended_at) < started) {
|
|
711
|
+
addError(errors, "order", joinPath(path, "ended_at"))
|
|
712
|
+
}
|
|
713
|
+
if (results.derived_through && Date.parse(value.derived_through) < started) {
|
|
714
|
+
addError(errors, "order", joinPath(path, "derived_through"))
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const SESSION_SPEC = {
|
|
719
|
+
host: enumField(ENUMS.host),
|
|
720
|
+
id: patternField(PATTERNS.sessionId),
|
|
721
|
+
host_version: patternField(PATTERNS.semver),
|
|
722
|
+
entrypoint: enumField(ENUMS.entrypoint),
|
|
723
|
+
started_at: timestampField(),
|
|
724
|
+
ended_at: nullableTimestampField(),
|
|
725
|
+
end_reason: nullableEnumField(ENUMS.endReason),
|
|
726
|
+
derived_through: timestampField(),
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// intervals[].tool / outcome are required exactly when kind is "tool", and
|
|
730
|
+
// forbidden otherwise. Because the object walker derives its allow-list from
|
|
731
|
+
// the very same spec it validates against, "forbidden" is not a separate
|
|
732
|
+
// error path: when kind isn't "tool" those two keys are simply absent from
|
|
733
|
+
// the computed spec, so their presence is already an `unknown_key`.
|
|
734
|
+
function intervalFields(value) {
|
|
735
|
+
const fields = {
|
|
736
|
+
kind: enumField(ENUMS.intervalKind),
|
|
737
|
+
agent: rangeIntField(0, 9999),
|
|
738
|
+
start: timestampField(),
|
|
739
|
+
end: timestampField(),
|
|
740
|
+
}
|
|
741
|
+
// `validateObject` only ever calls this after confirming `value` is a
|
|
742
|
+
// plain object, so no further type guard is needed here.
|
|
743
|
+
if (value.kind === "tool") {
|
|
744
|
+
fields.tool = enumField(ENUMS.toolKind)
|
|
745
|
+
fields.outcome = enumField(ENUMS.outcome)
|
|
746
|
+
}
|
|
747
|
+
// `stop` exists only on a human wait, and is optional here so local files written before it stay valid.
|
|
748
|
+
if (value.kind === "human_wait" && Object.hasOwn(value, "stop")) fields.stop = objectField(STOP_SPEC)
|
|
749
|
+
return fields
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
function intervalOrderCheck(value, path, results, errors) {
|
|
753
|
+
if (results.start && results.end && Date.parse(value.end) < Date.parse(value.start)) {
|
|
754
|
+
addError(errors, "order", joinPath(path, "end"))
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
const INTERVAL_FIELD = objectField(intervalFields, intervalOrderCheck)
|
|
759
|
+
|
|
760
|
+
export const COUNTS_SPEC = {
|
|
761
|
+
tool_calls: mapOfField(ENUMS.toolKind, nonNegIntField()),
|
|
762
|
+
tool_failures: mapOfField(ENUMS.toolKind, nonNegIntField()),
|
|
763
|
+
tool_retries: nonNegIntField(),
|
|
764
|
+
api_retries: nonNegIntField(),
|
|
765
|
+
compactions: nonNegIntField(),
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
const TOP_SPEC = {
|
|
769
|
+
schema: patternField(PATTERNS.schema),
|
|
770
|
+
session: objectField(SESSION_SPEC, sessionOrderCheck),
|
|
771
|
+
plugins: arrayField(objectField(localPluginFields), LIMITS.plugins),
|
|
772
|
+
models: arrayField(objectField(MODEL_SPEC), LIMITS.models),
|
|
773
|
+
agents: arrayField(objectField(localAgentFields), LIMITS.agents),
|
|
774
|
+
intervals: arrayField(INTERVAL_FIELD, LIMITS.intervals),
|
|
775
|
+
counts: objectField(COUNTS_SPEC),
|
|
776
|
+
refs: objectField(REFS_SPEC),
|
|
777
|
+
jobs: arrayField(objectField((value) => jobFields(value, JOB_SPEC)), LIMITS.jobs),
|
|
778
|
+
unavailable: arrayField(objectField(UNAVAILABLE_SPEC), LIMITS.unavailable),
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// `human_turns[]`: one human prompt, as sizes and times only. `at` is the prompt's time in the form local intervals use; `window_ms` is null exactly for the first prompt.
|
|
782
|
+
const HUMAN_TURN_SPEC = {
|
|
783
|
+
at: timestampField(),
|
|
784
|
+
basis: enumField(ENUMS.turnBasis),
|
|
785
|
+
window_ms: nullableNonNegIntField(),
|
|
786
|
+
prompt_class: enumField(ENUMS.sizeClass),
|
|
787
|
+
output_class: enumField(ENUMS.sizeClass),
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// A list capped at `LIMITS.humanTurns`, in time order, where `window_ms` is null exactly for a `first` turn (the estimator throws on a mismatch, so the gate catches it first).
|
|
791
|
+
const humanTurnsField = () => {
|
|
792
|
+
const list = arrayField(objectField(HUMAN_TURN_SPEC), LIMITS.humanTurns)
|
|
793
|
+
return leaf((value, path, errors, ctx) => {
|
|
794
|
+
const results = list.check(value, path, errors, ctx)
|
|
795
|
+
if (results === undefined) return results
|
|
796
|
+
let previous = null
|
|
797
|
+
value.forEach((entry, index) => {
|
|
798
|
+
const own = results[index]
|
|
799
|
+
if (own?.basis === true && own.window_ms === true && (entry.basis === "first") !== (entry.window_ms === null)) {
|
|
800
|
+
addError(errors, "inconsistent", joinPath(path, `${index}.window_ms`))
|
|
801
|
+
}
|
|
802
|
+
if (own?.at !== true) return
|
|
803
|
+
const ms = Date.parse(entry.at)
|
|
804
|
+
if (previous !== null && ms < previous) addError(errors, "order", joinPath(path, `${index}.at`))
|
|
805
|
+
previous = ms
|
|
806
|
+
})
|
|
807
|
+
return results
|
|
808
|
+
})
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// The optional top-level keys, added only when the file carries them (as `agents` and `segments` are on a job).
|
|
812
|
+
const topFields = (value) => {
|
|
813
|
+
const withOutcomes = Object.hasOwn(value, "outcomes") ? { ...TOP_SPEC, outcomes: outcomesField() } : TOP_SPEC
|
|
814
|
+
return Object.hasOwn(value, "human_turns") ? { ...withOutcomes, human_turns: humanTurnsField() } : withOutcomes
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// Every spec object above, keyed for the structural regression test that
|
|
818
|
+
// walks each one and asserts every allowed key carries a real validator
|
|
819
|
+
// (I2): with this architecture that's true by construction, but the test
|
|
820
|
+
// still guards against a future edit that adds a bare value instead of a
|
|
821
|
+
// spec primitive.
|
|
822
|
+
export const __SPECS__ = Object.freeze({
|
|
823
|
+
top: TOP_SPEC,
|
|
824
|
+
session: SESSION_SPEC,
|
|
825
|
+
model: MODEL_SPEC,
|
|
826
|
+
tokens: TOKENS_SPEC,
|
|
827
|
+
plugin: localPluginFields({ source: null }),
|
|
828
|
+
agent: AGENT_SPEC,
|
|
829
|
+
pr: prFields({ agent: 0, at_ms: 0, created: true }),
|
|
830
|
+
stop: STOP_SPEC,
|
|
831
|
+
segment: segmentFields({ shared: true }),
|
|
832
|
+
commit: commitFields({ at_ms: 0 }),
|
|
833
|
+
refs: REFS_SPEC,
|
|
834
|
+
unresolved: UNRESOLVED_SPEC,
|
|
835
|
+
transition: TRANSITION_SPEC,
|
|
836
|
+
observed: OBSERVED_SPEC,
|
|
837
|
+
job: JOB_SPEC,
|
|
838
|
+
unavailable: UNAVAILABLE_SPEC,
|
|
839
|
+
outcome: OUTCOME_SPEC,
|
|
840
|
+
humanTurn: HUMAN_TURN_SPEC,
|
|
841
|
+
return: RETURN_SPEC,
|
|
842
|
+
outcomeOptional: OUTCOME_OPTIONAL,
|
|
843
|
+
counts: COUNTS_SPEC,
|
|
844
|
+
intervalTool: intervalFields({ kind: "tool" }),
|
|
845
|
+
intervalOther: intervalFields({ kind: "turn" }),
|
|
846
|
+
intervalWait: intervalFields({ kind: "human_wait", stop: null }),
|
|
847
|
+
})
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* Cross-field checks that no single field's own spec can express, shared by
|
|
851
|
+
* the local and published validators: an interval's agent must name a real
|
|
852
|
+
* entry in `agents`, an agent's own `n` must be unique, and an agent's
|
|
853
|
+
* `parent` must name a real agent (M3). Both gate on `results.agents` (not
|
|
854
|
+
* merely `Array.isArray(value.agents)`): when `agents` is over its cap the
|
|
855
|
+
* array's items are left unchecked, same as every other capped array, so
|
|
856
|
+
* nothing here can trust it enough to cross-reference against it either —
|
|
857
|
+
* that would cascade one `too_many` into a `ref`/`reference`/`duplicate`
|
|
858
|
+
* error per sibling item.
|
|
859
|
+
*/
|
|
860
|
+
export function checkAgentReferences(value, results, errors) {
|
|
861
|
+
if (!results.agents) return
|
|
862
|
+
const agentIds = new Set()
|
|
863
|
+
const validAgents = value.agents
|
|
864
|
+
.map((item, index) => ({ item, index, ok: results.agents[index]?.n === true }))
|
|
865
|
+
.filter((entry) => entry.ok)
|
|
866
|
+
const seenNs = new Set()
|
|
867
|
+
for (const { item, index } of validAgents) {
|
|
868
|
+
if (seenNs.has(item.n)) addError(errors, "duplicate", `agents.${index}.n`)
|
|
869
|
+
else seenNs.add(item.n)
|
|
870
|
+
agentIds.add(item.n)
|
|
871
|
+
}
|
|
872
|
+
value.agents.forEach((item, index) => {
|
|
873
|
+
if (!isPlainObject(item)) return
|
|
874
|
+
if (results.agents[index]?.parent === true && item.parent !== null && !agentIds.has(item.parent)) {
|
|
875
|
+
addError(errors, "reference", `agents.${index}.parent`)
|
|
876
|
+
}
|
|
877
|
+
})
|
|
878
|
+
|
|
879
|
+
// A job's or PR's worker must be a real worker of this session.
|
|
880
|
+
results.jobs?.forEach((jobResult, index) => {
|
|
881
|
+
if (jobResult?.agents !== true) return
|
|
882
|
+
value.jobs[index].agents.forEach((n, entry) => {
|
|
883
|
+
if (!agentIds.has(n)) addError(errors, "agent_unknown", `jobs.${index}.agents.${entry}`)
|
|
884
|
+
})
|
|
885
|
+
})
|
|
886
|
+
results.refs?.prs?.forEach((prResult, index) => {
|
|
887
|
+
if (prResult?.agent === true && !agentIds.has(value.refs.prs[index].agent)) {
|
|
888
|
+
addError(errors, "agent_unknown", `refs.prs.${index}.agent`)
|
|
889
|
+
}
|
|
890
|
+
})
|
|
891
|
+
|
|
892
|
+
if (results.intervals) {
|
|
893
|
+
value.intervals.forEach((item, index) => {
|
|
894
|
+
const itemResult = results.intervals[index]
|
|
895
|
+
if (itemResult && itemResult.agent === true && !agentIds.has(item.agent)) {
|
|
896
|
+
addError(errors, "ref", `intervals.${index}.agent`)
|
|
897
|
+
}
|
|
898
|
+
})
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* `validateLocalFacts(value) -> { ok, errors }`. Accepts an already-parsed
|
|
904
|
+
* value (use `validateLocalFactsBytes` for a raw buffer, which also enforces
|
|
905
|
+
* the byte cap and canonical-bytes check). Collects every violation rather
|
|
906
|
+
* than stopping at the first, but a single-violation input surfaces exactly
|
|
907
|
+
* one error.
|
|
908
|
+
*/
|
|
909
|
+
export function validateLocalFacts(value) {
|
|
910
|
+
const errors = []
|
|
911
|
+
const results = validateObject(value, "", topFields, errors)
|
|
912
|
+
if (results === undefined) return { ok: false, errors }
|
|
913
|
+
checkAgentReferences(value, results, errors)
|
|
914
|
+
checkSegmentAgents(value, results, errors)
|
|
915
|
+
const sessionSound = results.session?.started_at === true && results.session.derived_through === true
|
|
916
|
+
const durationMs = sessionSound ? Date.parse(value.session.derived_through) - Date.parse(value.session.started_at) : -1
|
|
917
|
+
checkSessionBounds(value, results, errors, durationMs >= 0 ? durationMs : null)
|
|
918
|
+
return { ok: errors.length === 0, errors }
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Parse and validate raw bytes (or a string) with `validate`. Enforces the
|
|
923
|
+
* 16 MiB cap first, measured with `Buffer.byteLength` so a multi-byte string
|
|
924
|
+
* can't undercount itself past the cap the way `.length` (UTF-16 code units)
|
|
925
|
+
* would. Then requires the text to be the exact canonical `JSON.stringify`
|
|
926
|
+
* of what it parses to (one trailing `\n` allowed) — `JSON.parse` silently
|
|
927
|
+
* keeps only the last of any duplicate key, so without this a file carrying
|
|
928
|
+
* `"schema": "<free text>", "schema": "<valid value>"` would validate clean
|
|
929
|
+
* while its raw bytes, which are what a store actually receives and commits,
|
|
930
|
+
* still carry the free text. Shared by the local and published gates.
|
|
931
|
+
*/
|
|
932
|
+
export function validateCanonicalBytes(buffer, validate) {
|
|
933
|
+
if (Buffer.byteLength(buffer) > LIMITS.maxBytes) {
|
|
934
|
+
return { ok: false, errors: [{ code: "too_large", path: "" }] }
|
|
935
|
+
}
|
|
936
|
+
const text = typeof buffer === "string" ? buffer : buffer.toString("utf8")
|
|
937
|
+
let parsed
|
|
938
|
+
try {
|
|
939
|
+
parsed = JSON.parse(text)
|
|
940
|
+
} catch {
|
|
941
|
+
return { ok: false, errors: [{ code: "json", path: "" }] }
|
|
942
|
+
}
|
|
943
|
+
const canonical = JSON.stringify(parsed)
|
|
944
|
+
if (text !== canonical && text !== `${canonical}\n`) {
|
|
945
|
+
return { ok: false, errors: [{ code: "canonical", path: "" }] }
|
|
946
|
+
}
|
|
947
|
+
return validate(parsed)
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
/** `validateLocalFactsBytes(buffer) -> { ok, errors }`: the canonical-bytes gate over `validateLocalFacts`. */
|
|
951
|
+
export function validateLocalFactsBytes(buffer) {
|
|
952
|
+
return validateCanonicalBytes(buffer, validateLocalFacts)
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
// The outcome entry's spec and enum lists, for the published form (`published-schema.js`), which shares them.
|
|
956
|
+
export { OUTCOME_SPEC, OUTCOME_STATE_CODES, REFUSAL_REASON_CODES }
|
|
957
|
+
export { OUTCOME_OPTIONAL, OUTCOME_SINCE_CODES, RETURN_SPEC }
|