@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.
Files changed (567) hide show
  1. package/README.md +1 -1
  2. package/changelog.json +6 -2
  3. package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
  4. package/deploy/unraid/sanctuary.xml +1 -1
  5. package/desk.lock.json +8 -0
  6. package/dist/heart/identity.js +27 -1
  7. package/dist/mind/desk-section.js +33 -43
  8. package/dist/repertoire/desk-mcp.js +140 -0
  9. package/dist/repertoire/mcp-manager.js +22 -0
  10. package/dist/repertoire/mcp-tools.js +11 -7
  11. package/npm-shrinkwrap.json +2 -2
  12. package/package.json +4 -1
  13. package/vendor/desk/.claude-plugin/plugin.json +35 -0
  14. package/vendor/desk/.mcp.claude-codex.json +28 -0
  15. package/vendor/desk/.mcp.copilot.json +16 -0
  16. package/vendor/desk/.ouro-desk.json +6 -0
  17. package/vendor/desk/CHANGELOG.md +7004 -0
  18. package/vendor/desk/README.md +195 -0
  19. package/vendor/desk/activation/README.md +98 -0
  20. package/vendor/desk/activation/copilot-root.flattened-bundle.json +38 -0
  21. package/vendor/desk/activation/desk.activation.json +251 -0
  22. package/vendor/desk/activation/host-capability-evidence.md +46 -0
  23. package/vendor/desk/activation/support-matrix.json +84 -0
  24. package/vendor/desk/agency.json +20 -0
  25. package/vendor/desk/agents/observer.agent.md +26 -0
  26. package/vendor/desk/agents/observer.md +29 -0
  27. package/vendor/desk/agents/worker.agent.md +32 -0
  28. package/vendor/desk/agents/worker.md +40 -0
  29. package/vendor/desk/artifacts/tombstones/tombstone.schema.json +53 -0
  30. package/vendor/desk/artifacts/tombstones/tombstones.jsonl +1 -0
  31. package/vendor/desk/changelog.d/README.md +12 -0
  32. package/vendor/desk/docs/agent-files.md +104 -0
  33. package/vendor/desk/docs/agentic-engineering-v2-rfc.md +206 -0
  34. package/vendor/desk/docs/agentic-engineering-v3-rfc.md +109 -0
  35. package/vendor/desk/docs/browser-remote-desktops.md +69 -0
  36. package/vendor/desk/docs/dependency-activation-stories-and-criteria.md +500 -0
  37. package/vendor/desk/docs/evaluation-packet.md +363 -0
  38. package/vendor/desk/docs/factory-local-capture.md +651 -0
  39. package/vendor/desk/docs/factory-store-playbook.md +927 -0
  40. package/vendor/desk/docs/images/factory-site.png +0 -0
  41. package/vendor/desk/docs/issue-drains.md +79 -0
  42. package/vendor/desk/docs/lfs-inspection.md +55 -0
  43. package/vendor/desk/docs/preview-diagnostics.md +11 -0
  44. package/vendor/desk/docs/relays.md +88 -0
  45. package/vendor/desk/docs/schedules.md +69 -0
  46. package/vendor/desk/docs/search-recovery.md +22 -0
  47. package/vendor/desk/docs/session-labels.md +157 -0
  48. package/vendor/desk/docs/session-retention.md +125 -0
  49. package/vendor/desk/docs/sessions.md +17 -0
  50. package/vendor/desk/docs/stalled-nudges.md +54 -0
  51. package/vendor/desk/docs/webhooks.md +80 -0
  52. package/vendor/desk/docs/workspace-tidy.md +74 -0
  53. package/vendor/desk/hooks/boot-checks.cjs +7 -0
  54. package/vendor/desk/hooks/claude-session-start.cjs +123 -0
  55. package/vendor/desk/hooks/compatible-node.cjs +97 -0
  56. package/vendor/desk/hooks/copilot-boot-prompt.cjs +69 -0
  57. package/vendor/desk/hooks/copilot-durable-files.cjs +8 -0
  58. package/vendor/desk/hooks/copilot-hooks.json +61 -0
  59. package/vendor/desk/hooks/copilot-intake-context.cjs +5 -0
  60. package/vendor/desk/hooks/copilot-lane-model.cjs +8 -0
  61. package/vendor/desk/hooks/copilot-session-start.cjs +264 -0
  62. package/vendor/desk/hooks/copilot-skill-current.cjs +28 -0
  63. package/vendor/desk/hooks/factory-end.cjs +5 -0
  64. package/vendor/desk/hooks/factory-start.cjs +27 -0
  65. package/vendor/desk/hooks/hooks.json +40 -0
  66. package/vendor/desk/hooks/lib/boot-checks.cjs +643 -0
  67. package/vendor/desk/hooks/lib/child-agent.cjs +14 -0
  68. package/vendor/desk/hooks/lib/copilot-intake-context.cjs +73 -0
  69. package/vendor/desk/hooks/lib/current-release.cjs +162 -0
  70. package/vendor/desk/hooks/lib/delivery-stop.cjs +326 -0
  71. package/vendor/desk/hooks/lib/detach-worker.cjs +43 -0
  72. package/vendor/desk/hooks/lib/durable-files.cjs +102 -0
  73. package/vendor/desk/hooks/lib/factory-end.cjs +327 -0
  74. package/vendor/desk/hooks/lib/lane-model.cjs +82 -0
  75. package/vendor/desk/hooks/lib/node-required.cjs +56 -0
  76. package/vendor/desk/hooks/lib/orca-session-title.cjs +60 -0
  77. package/vendor/desk/hooks/lib/session-end.cjs +30 -0
  78. package/vendor/desk/hooks/lib/sync-end.cjs +89 -0
  79. package/vendor/desk/hooks/loop-start.cjs +105 -0
  80. package/vendor/desk/hooks/node-missing.sh +78 -0
  81. package/vendor/desk/hooks/orca-session-title.cjs +8 -0
  82. package/vendor/desk/hooks/session-end.cjs +8 -0
  83. package/vendor/desk/mcp/README.md +269 -0
  84. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  85. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  86. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  87. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  88. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  89. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  90. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  91. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  92. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  93. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  94. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  95. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  96. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  97. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  98. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  99. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/support-matrix.json +72 -0
  100. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  101. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  102. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  103. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  104. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  105. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  106. package/vendor/desk/mcp/artifacts/runtime-deps/README.md +25 -0
  107. package/vendor/desk/mcp/bootstrap.cjs +761 -0
  108. package/vendor/desk/mcp/docs/private-feedback.md +13 -0
  109. package/vendor/desk/mcp/idle-proxy.cjs +423 -0
  110. package/vendor/desk/mcp/index.js +813 -0
  111. package/vendor/desk/mcp/package-lock.json +3717 -0
  112. package/vendor/desk/mcp/package.json +44 -0
  113. package/vendor/desk/mcp/scripts/agency-desk-channel.js +7 -0
  114. package/vendor/desk/mcp/scripts/build-runtime-deps-pack.js +5 -0
  115. package/vendor/desk/mcp/scripts/crew.js +89 -0
  116. package/vendor/desk/mcp/scripts/drains-launcher.mjs +329 -0
  117. package/vendor/desk/mcp/scripts/drains.js +5 -0
  118. package/vendor/desk/mcp/scripts/factory.js +657 -0
  119. package/vendor/desk/mcp/scripts/file-desk-problem.js +9 -0
  120. package/vendor/desk/mcp/scripts/finish-commit.js +7 -0
  121. package/vendor/desk/mcp/scripts/lfs.js +37 -0
  122. package/vendor/desk/mcp/scripts/local-recovery.js +363 -0
  123. package/vendor/desk/mcp/scripts/migrations.js +11 -0
  124. package/vendor/desk/mcp/scripts/private-view.js +177 -0
  125. package/vendor/desk/mcp/scripts/resolve-desk-root.js +106 -0
  126. package/vendor/desk/mcp/scripts/session-boot.js +22 -0
  127. package/vendor/desk/mcp/scripts/session-retention.js +5 -0
  128. package/vendor/desk/mcp/scripts/session-sync.js +10 -0
  129. package/vendor/desk/mcp/scripts/sessions.js +5 -0
  130. package/vendor/desk/mcp/scripts/sync-push.js +13 -0
  131. package/vendor/desk/mcp/scripts/tidy-status.js +8 -0
  132. package/vendor/desk/mcp/scripts/verify-runtime-deps-pack.js +5 -0
  133. package/vendor/desk/mcp/src/actions/desk-read.actions.mts +73 -0
  134. package/vendor/desk/mcp/src/actions/desk-session.actions.mts +42 -0
  135. package/vendor/desk/mcp/src/actions/desk-web.actions.mts +52 -0
  136. package/vendor/desk/mcp/src/actions/desk.actions.mts +5 -0
  137. package/vendor/desk/mcp/src/actions/generated/desk/OuroActions.swift +649 -0
  138. package/vendor/desk/mcp/src/actions/generated/desk/OuroActionsReins.swift +61 -0
  139. package/vendor/desk/mcp/src/actions/generated/desk/actions.json +280 -0
  140. package/vendor/desk/mcp/src/actions/generated/desk/commands.json +145 -0
  141. package/vendor/desk/mcp/src/actions/generated/desk/mcp.json +256 -0
  142. package/vendor/desk/mcp/src/actions/generated/desk/web.ts +59 -0
  143. package/vendor/desk/mcp/src/actions/generated/desk/webmcp.json +250 -0
  144. package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActions.swift +241 -0
  145. package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActionsReins.swift +25 -0
  146. package/vendor/desk/mcp/src/actions/generated/desk-web/actions.json +73 -0
  147. package/vendor/desk/mcp/src/actions/generated/desk-web/commands.json +53 -0
  148. package/vendor/desk/mcp/src/actions/generated/desk-web/mcp.json +83 -0
  149. package/vendor/desk/mcp/src/actions/generated/desk-web/web.ts +47 -0
  150. package/vendor/desk/mcp/src/actions/generated/desk-web/webmcp.json +81 -0
  151. package/vendor/desk/mcp/src/actions/served.js +5 -0
  152. package/vendor/desk/mcp/src/activation/admit.js +77 -0
  153. package/vendor/desk/mcp/src/activation/failures.js +65 -0
  154. package/vendor/desk/mcp/src/activation/readiness-policy.js +102 -0
  155. package/vendor/desk/mcp/src/activation/schema.js +17 -0
  156. package/vendor/desk/mcp/src/activation/superpowers-context.js +265 -0
  157. package/vendor/desk/mcp/src/activation/validate.js +540 -0
  158. package/vendor/desk/mcp/src/artifacts/tombstones.js +61 -0
  159. package/vendor/desk/mcp/src/crew/initiative.js +287 -0
  160. package/vendor/desk/mcp/src/crew/workspace.js +1259 -0
  161. package/vendor/desk/mcp/src/db/init.js +75 -0
  162. package/vendor/desk/mcp/src/db/schema.sql +83 -0
  163. package/vendor/desk/mcp/src/desk/active-tasks.js +408 -0
  164. package/vendor/desk/mcp/src/desk/card-commit-guard.js +281 -0
  165. package/vendor/desk/mcp/src/desk/cleanup-index.js +53 -0
  166. package/vendor/desk/mcp/src/desk/content-home.js +246 -0
  167. package/vendor/desk/mcp/src/desk/crew-config.js +102 -0
  168. package/vendor/desk/mcp/src/desk/crew-member.js +196 -0
  169. package/vendor/desk/mcp/src/desk/crew-roster.js +151 -0
  170. package/vendor/desk/mcp/src/desk/frontmatter-lite.js +228 -0
  171. package/vendor/desk/mcp/src/desk/gh-logins.js +109 -0
  172. package/vendor/desk/mcp/src/desk/handles.js +123 -0
  173. package/vendor/desk/mcp/src/desk/handoff-reference.js +35 -0
  174. package/vendor/desk/mcp/src/desk/improvement-authority.js +3 -0
  175. package/vendor/desk/mcp/src/desk/improvement-cards.js +704 -0
  176. package/vendor/desk/mcp/src/desk/improvement-person.js +51 -0
  177. package/vendor/desk/mcp/src/desk/lifecycle.js +16 -0
  178. package/vendor/desk/mcp/src/desk/machine-desks.js +119 -0
  179. package/vendor/desk/mcp/src/desk/naming.js +333 -0
  180. package/vendor/desk/mcp/src/desk/organization.js +592 -0
  181. package/vendor/desk/mcp/src/desk/resources.js +274 -0
  182. package/vendor/desk/mcp/src/desk/runtime-resolver.js +30 -0
  183. package/vendor/desk/mcp/src/desk/scratch-paths.js +44 -0
  184. package/vendor/desk/mcp/src/desk/step-delivery.js +140 -0
  185. package/vendor/desk/mcp/src/desk/steps.js +263 -0
  186. package/vendor/desk/mcp/src/desk/tidy.js +930 -0
  187. package/vendor/desk/mcp/src/desk/unsigned-deliveries.js +359 -0
  188. package/vendor/desk/mcp/src/factory/agent-types.js +45 -0
  189. package/vendor/desk/mcp/src/factory/andon-watch.js +109 -0
  190. package/vendor/desk/mcp/src/factory/binding.js +612 -0
  191. package/vendor/desk/mcp/src/factory/boot-check.js +645 -0
  192. package/vendor/desk/mcp/src/factory/capture-classify.js +158 -0
  193. package/vendor/desk/mcp/src/factory/capture-count.js +183 -0
  194. package/vendor/desk/mcp/src/factory/capture-flush.js +268 -0
  195. package/vendor/desk/mcp/src/factory/capture-publish.js +141 -0
  196. package/vendor/desk/mcp/src/factory/capture-schema.js +193 -0
  197. package/vendor/desk/mcp/src/factory/capture-sweep.js +239 -0
  198. package/vendor/desk/mcp/src/factory/catch-point.js +60 -0
  199. package/vendor/desk/mcp/src/factory/commit-resolve.js +94 -0
  200. package/vendor/desk/mcp/src/factory/consent-answer.js +37 -0
  201. package/vendor/desk/mcp/src/factory/context-capability.js +15 -0
  202. package/vendor/desk/mcp/src/factory/context-outbox.js +885 -0
  203. package/vendor/desk/mcp/src/factory/context-run.js +386 -0
  204. package/vendor/desk/mcp/src/factory/context-schema.js +249 -0
  205. package/vendor/desk/mcp/src/factory/copilot-turn-index.js +93 -0
  206. package/vendor/desk/mcp/src/factory/copilot-usage.js +148 -0
  207. package/vendor/desk/mcp/src/factory/credential.js +45 -0
  208. package/vendor/desk/mcp/src/factory/derive-claude.js +960 -0
  209. package/vendor/desk/mcp/src/factory/derive-codex.js +734 -0
  210. package/vendor/desk/mcp/src/factory/derive-common.js +279 -0
  211. package/vendor/desk/mcp/src/factory/derive-copilot.js +1057 -0
  212. package/vendor/desk/mcp/src/factory/derive-run.js +807 -0
  213. package/vendor/desk/mcp/src/factory/desk-problem-file.js +310 -0
  214. package/vendor/desk/mcp/src/factory/desk-problem-fingerprint.js +70 -0
  215. package/vendor/desk/mcp/src/factory/desk-problem-known.js +246 -0
  216. package/vendor/desk/mcp/src/factory/desk-problem-template.js +107 -0
  217. package/vendor/desk/mcp/src/factory/desk-repo.js +1223 -0
  218. package/vendor/desk/mcp/src/factory/desk-task-line.js +28 -0
  219. package/vendor/desk/mcp/src/factory/desk-visibility.js +48 -0
  220. package/vendor/desk/mcp/src/factory/end-hook.js +14 -0
  221. package/vendor/desk/mcp/src/factory/evaluate-kick.js +164 -0
  222. package/vendor/desk/mcp/src/factory/evaluate-run.js +678 -0
  223. package/vendor/desk/mcp/src/factory/evaluator-step.js +484 -0
  224. package/vendor/desk/mcp/src/factory/filer-launch.js +79 -0
  225. package/vendor/desk/mcp/src/factory/flush-health.js +26 -0
  226. package/vendor/desk/mcp/src/factory/flush.js +1758 -0
  227. package/vendor/desk/mcp/src/factory/focus.js +326 -0
  228. package/vendor/desk/mcp/src/factory/headless-flag.cjs +32 -0
  229. package/vendor/desk/mcp/src/factory/headless-flag.js +25 -0
  230. package/vendor/desk/mcp/src/factory/headless-ledger.js +743 -0
  231. package/vendor/desk/mcp/src/factory/headless.js +567 -0
  232. package/vendor/desk/mcp/src/factory/held-route.js +93 -0
  233. package/vendor/desk/mcp/src/factory/host-flags.js +36 -0
  234. package/vendor/desk/mcp/src/factory/improvement-verify.js +429 -0
  235. package/vendor/desk/mcp/src/factory/kaizen-file.js +231 -0
  236. package/vendor/desk/mcp/src/factory/label-binding.js +90 -0
  237. package/vendor/desk/mcp/src/factory/label-schema.js +426 -0
  238. package/vendor/desk/mcp/src/factory/local-status.js +368 -0
  239. package/vendor/desk/mcp/src/factory/loop-conditions.js +121 -0
  240. package/vendor/desk/mcp/src/factory/loop-health.js +500 -0
  241. package/vendor/desk/mcp/src/factory/loop-slot.js +90 -0
  242. package/vendor/desk/mcp/src/factory/loop-status.js +100 -0
  243. package/vendor/desk/mcp/src/factory/loop-switch.cjs +14 -0
  244. package/vendor/desk/mcp/src/factory/loop-worker-state.js +96 -0
  245. package/vendor/desk/mcp/src/factory/loop-worker.js +290 -0
  246. package/vendor/desk/mcp/src/factory/marker.js +61 -0
  247. package/vendor/desk/mcp/src/factory/mirror-step.js +145 -0
  248. package/vendor/desk/mcp/src/factory/os-protect.js +243 -0
  249. package/vendor/desk/mcp/src/factory/outbox.js +2231 -0
  250. package/vendor/desk/mcp/src/factory/outcome.js +431 -0
  251. package/vendor/desk/mcp/src/factory/pipeline/andon.js +319 -0
  252. package/vendor/desk/mcp/src/factory/pipeline/attention-rollup.js +158 -0
  253. package/vendor/desk/mcp/src/factory/pipeline/attention.js +146 -0
  254. package/vendor/desk/mcp/src/factory/pipeline/build.js +299 -0
  255. package/vendor/desk/mcp/src/factory/pipeline/compare.js +148 -0
  256. package/vendor/desk/mcp/src/factory/pipeline/formulas.js +652 -0
  257. package/vendor/desk/mcp/src/factory/pipeline/kaizen.js +387 -0
  258. package/vendor/desk/mcp/src/factory/pipeline/lifecycle-clocks.js +345 -0
  259. package/vendor/desk/mcp/src/factory/pipeline/normalize.js +73 -0
  260. package/vendor/desk/mcp/src/factory/pipeline/number-states.js +154 -0
  261. package/vendor/desk/mcp/src/factory/pipeline/outcomes.js +268 -0
  262. package/vendor/desk/mcp/src/factory/pipeline/report.js +737 -0
  263. package/vendor/desk/mcp/src/factory/pipeline/rollups.js +883 -0
  264. package/vendor/desk/mcp/src/factory/pipeline/stretches.js +523 -0
  265. package/vendor/desk/mcp/src/factory/pipeline/timeline.js +199 -0
  266. package/vendor/desk/mcp/src/factory/pipeline/validate-pr.js +238 -0
  267. package/vendor/desk/mcp/src/factory/pipeline/versions.js +42 -0
  268. package/vendor/desk/mcp/src/factory/pipeline/walk.js +1177 -0
  269. package/vendor/desk/mcp/src/factory/plugin-registry.js +72 -0
  270. package/vendor/desk/mcp/src/factory/plugin-sources.cjs +249 -0
  271. package/vendor/desk/mcp/src/factory/pr-green.js +77 -0
  272. package/vendor/desk/mcp/src/factory/process-lock.js +142 -0
  273. package/vendor/desk/mcp/src/factory/proof-session.js +75 -0
  274. package/vendor/desk/mcp/src/factory/publish.js +637 -0
  275. package/vendor/desk/mcp/src/factory/published-schema.js +648 -0
  276. package/vendor/desk/mcp/src/factory/reconcile-reasons.js +22 -0
  277. package/vendor/desk/mcp/src/factory/reconcile-step.js +251 -0
  278. package/vendor/desk/mcp/src/factory/reconcile.js +808 -0
  279. package/vendor/desk/mcp/src/factory/release-version.js +134 -0
  280. package/vendor/desk/mcp/src/factory/repo-name.js +13 -0
  281. package/vendor/desk/mcp/src/factory/retention.js +60 -0
  282. package/vendor/desk/mcp/src/factory/route-desk.js +40 -0
  283. package/vendor/desk/mcp/src/factory/route-issues.js +251 -0
  284. package/vendor/desk/mcp/src/factory/route-local.js +264 -0
  285. package/vendor/desk/mcp/src/factory/schema.js +957 -0
  286. package/vendor/desk/mcp/src/factory/session-kind.js +16 -0
  287. package/vendor/desk/mcp/src/factory/session-lifetime.js +56 -0
  288. package/vendor/desk/mcp/src/factory/session-route.js +183 -0
  289. package/vendor/desk/mcp/src/factory/shell-git.js +500 -0
  290. package/vendor/desk/mcp/src/factory/store-issues.js +143 -0
  291. package/vendor/desk/mcp/src/factory/store-route.js +208 -0
  292. package/vendor/desk/mcp/src/factory/test-state-guard.js +103 -0
  293. package/vendor/desk/mcp/src/factory/time.js +36 -0
  294. package/vendor/desk/mcp/src/factory/tool-issue-file.js +84 -0
  295. package/vendor/desk/mcp/src/factory/tool-kinds.js +87 -0
  296. package/vendor/desk/mcp/src/factory/triage-schema.js +233 -0
  297. package/vendor/desk/mcp/src/factory/windows-acl.js +679 -0
  298. package/vendor/desk/mcp/src/indexer/chunk.js +232 -0
  299. package/vendor/desk/mcp/src/indexer/discover.js +434 -0
  300. package/vendor/desk/mcp/src/indexer/exclusions.js +247 -0
  301. package/vendor/desk/mcp/src/indexer/index.js +167 -0
  302. package/vendor/desk/mcp/src/indexer/refs.js +0 -0
  303. package/vendor/desk/mcp/src/indexer/text-hash.js +18 -0
  304. package/vendor/desk/mcp/src/lib/ouro-actions/actions.claims.json +75 -0
  305. package/vendor/desk/mcp/src/lib/ouro-actions/dist-manifest.json +70 -0
  306. package/vendor/desk/mcp/src/lib/ouro-actions/ouro-actions.mts +1416 -0
  307. package/vendor/desk/mcp/src/lib/ouro-ui/LICENSE +21 -0
  308. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-claims.ts +190 -0
  309. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-command.ts +1020 -0
  310. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/checks.ts +343 -0
  311. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/cli.ts +240 -0
  312. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/component.ts +430 -0
  313. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/dev-commands.ts +204 -0
  314. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/doctor.ts +126 -0
  315. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/effects.ts +68 -0
  316. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/exit-codes.ts +75 -0
  317. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/help.ts +220 -0
  318. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/mcp.ts +268 -0
  319. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/outcome.ts +265 -0
  320. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/output.ts +67 -0
  321. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/precise-copy.ts +235 -0
  322. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/problem.ts +124 -0
  323. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.kit.mts +8 -0
  324. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.ts +568 -0
  325. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/terminal.ts +245 -0
  326. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/voice.ts +136 -0
  327. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/wait.ts +226 -0
  328. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/work-event.ts +181 -0
  329. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.kit.mts +18 -0
  330. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.ts +2072 -0
  331. package/vendor/desk/mcp/src/package-metadata.js +20 -0
  332. package/vendor/desk/mcp/src/protected/legacy-ledger.js +55 -0
  333. package/vendor/desk/mcp/src/readiness/leftovers.js +75 -0
  334. package/vendor/desk/mcp/src/readiness/process-start.js +149 -0
  335. package/vendor/desk/mcp/src/runtime/admission-worker.js +194 -0
  336. package/vendor/desk/mcp/src/runtime/admission.js +177 -0
  337. package/vendor/desk/mcp/src/runtime/agency-desk-channel.js +342 -0
  338. package/vendor/desk/mcp/src/runtime/agents-md.js +62 -0
  339. package/vendor/desk/mcp/src/runtime/append-lane.js +68 -0
  340. package/vendor/desk/mcp/src/runtime/argv-safe-reason.js +55 -0
  341. package/vendor/desk/mcp/src/runtime/boot-dependencies.js +75 -0
  342. package/vendor/desk/mcp/src/runtime/boot-text.js +504 -0
  343. package/vendor/desk/mcp/src/runtime/boot.js +1677 -0
  344. package/vendor/desk/mcp/src/runtime/bootstrap.js +1455 -0
  345. package/vendor/desk/mcp/src/runtime/chunked-import.js +102 -0
  346. package/vendor/desk/mcp/src/runtime/copilot-commit-trailer.js +133 -0
  347. package/vendor/desk/mcp/src/runtime/copilot-session.js +155 -0
  348. package/vendor/desk/mcp/src/runtime/deliver.js +469 -0
  349. package/vendor/desk/mcp/src/runtime/desk-channel.js +86 -0
  350. package/vendor/desk/mcp/src/runtime/desk-failure.js +26 -0
  351. package/vendor/desk/mcp/src/runtime/desk-health.js +168 -0
  352. package/vendor/desk/mcp/src/runtime/desk-session.js +1451 -0
  353. package/vendor/desk/mcp/src/runtime/diagnostic-server.js +72 -0
  354. package/vendor/desk/mcp/src/runtime/diagnostics.js +241 -0
  355. package/vendor/desk/mcp/src/runtime/drains-cli.js +187 -0
  356. package/vendor/desk/mcp/src/runtime/drains.js +781 -0
  357. package/vendor/desk/mcp/src/runtime/elsewhere-note.js +9 -0
  358. package/vendor/desk/mcp/src/runtime/failure-evidence.js +21 -0
  359. package/vendor/desk/mcp/src/runtime/fast-refs.js +209 -0
  360. package/vendor/desk/mcp/src/runtime/filer-throttle.js +66 -0
  361. package/vendor/desk/mcp/src/runtime/focused-card.js +147 -0
  362. package/vendor/desk/mcp/src/runtime/front-door.js +204 -0
  363. package/vendor/desk/mcp/src/runtime/gate-wait.js +2 -0
  364. package/vendor/desk/mcp/src/runtime/git-inspection.js +201 -0
  365. package/vendor/desk/mcp/src/runtime/git-read-worker.js +157 -0
  366. package/vendor/desk/mcp/src/runtime/health.js +50 -0
  367. package/vendor/desk/mcp/src/runtime/hooks.js +353 -0
  368. package/vendor/desk/mcp/src/runtime/hosted.js +163 -0
  369. package/vendor/desk/mcp/src/runtime/inbox.js +102 -0
  370. package/vendor/desk/mcp/src/runtime/index-drift.js +118 -0
  371. package/vendor/desk/mcp/src/runtime/last-start.js +133 -0
  372. package/vendor/desk/mcp/src/runtime/lesson-section.js +92 -0
  373. package/vendor/desk/mcp/src/runtime/lessons-shelf.js +100 -0
  374. package/vendor/desk/mcp/src/runtime/lfs.js +319 -0
  375. package/vendor/desk/mcp/src/runtime/native-path.js +12 -0
  376. package/vendor/desk/mcp/src/runtime/newest-release.js +197 -0
  377. package/vendor/desk/mcp/src/runtime/node-selection.js +233 -0
  378. package/vendor/desk/mcp/src/runtime/orca-session-title.js +225 -0
  379. package/vendor/desk/mcp/src/runtime/other-sessions.js +183 -0
  380. package/vendor/desk/mcp/src/runtime/pending-migrations.js +653 -0
  381. package/vendor/desk/mcp/src/runtime/plugin-update.js +215 -0
  382. package/vendor/desk/mcp/src/runtime/pluginless-runtimes.js +34 -0
  383. package/vendor/desk/mcp/src/runtime/pr-publication.js +226 -0
  384. package/vendor/desk/mcp/src/runtime/preview-snapshot.js +23 -0
  385. package/vendor/desk/mcp/src/runtime/publication-mode.js +19 -0
  386. package/vendor/desk/mcp/src/runtime/relays.js +974 -0
  387. package/vendor/desk/mcp/src/runtime/release-alert.js +148 -0
  388. package/vendor/desk/mcp/src/runtime/remote-identity.js +140 -0
  389. package/vendor/desk/mcp/src/runtime/resolve-here.js +4 -0
  390. package/vendor/desk/mcp/src/runtime/runtime-deps-cli.js +65 -0
  391. package/vendor/desk/mcp/src/runtime/runtime-deps.js +1109 -0
  392. package/vendor/desk/mcp/src/runtime/runtime-identity.js +22 -0
  393. package/vendor/desk/mcp/src/runtime/runtime-swap.js +101 -0
  394. package/vendor/desk/mcp/src/runtime/schedules.js +235 -0
  395. package/vendor/desk/mcp/src/runtime/session-activity.js +190 -0
  396. package/vendor/desk/mcp/src/runtime/session-label.js +30 -0
  397. package/vendor/desk/mcp/src/runtime/session-retention.js +662 -0
  398. package/vendor/desk/mcp/src/runtime/session-sync.js +333 -0
  399. package/vendor/desk/mcp/src/runtime/session-trailer.js +126 -0
  400. package/vendor/desk/mcp/src/runtime/sessions-cli.js +301 -0
  401. package/vendor/desk/mcp/src/runtime/signoff-listed.js +81 -0
  402. package/vendor/desk/mcp/src/runtime/skills.js +76 -0
  403. package/vendor/desk/mcp/src/runtime/stale-card-lead.js +52 -0
  404. package/vendor/desk/mcp/src/runtime/stale-desk-refresh.js +198 -0
  405. package/vendor/desk/mcp/src/runtime/stale-desk.js +219 -0
  406. package/vendor/desk/mcp/src/runtime/stalled.js +255 -0
  407. package/vendor/desk/mcp/src/runtime/standing-authority.js +79 -0
  408. package/vendor/desk/mcp/src/runtime/startup-boot.js +341 -0
  409. package/vendor/desk/mcp/src/runtime/startup-resolve.js +140 -0
  410. package/vendor/desk/mcp/src/runtime/state-branch.js +203 -0
  411. package/vendor/desk/mcp/src/runtime/status-compact.js +165 -0
  412. package/vendor/desk/mcp/src/runtime/status-inspection-child.js +26 -0
  413. package/vendor/desk/mcp/src/runtime/status-inspection.js +147 -0
  414. package/vendor/desk/mcp/src/runtime/status-root.js +39 -0
  415. package/vendor/desk/mcp/src/runtime/sync-worker.js +911 -0
  416. package/vendor/desk/mcp/src/runtime/test-state-guard.js +107 -0
  417. package/vendor/desk/mcp/src/runtime/unmerged-saves.js +247 -0
  418. package/vendor/desk/mcp/src/runtime/workspace-claim.js +53 -0
  419. package/vendor/desk/mcp/src/runtime/workspace-evidence.js +96 -0
  420. package/vendor/desk/mcp/src/runtime/workspace-tidy.js +509 -0
  421. package/vendor/desk/mcp/src/search/direct-lexical.js +54 -0
  422. package/vendor/desk/mcp/src/search/embedder.js +108 -0
  423. package/vendor/desk/mcp/src/search/engine.js +406 -0
  424. package/vendor/desk/mcp/src/search/files-router.js +22 -0
  425. package/vendor/desk/mcp/src/search/old-index.js +46 -0
  426. package/vendor/desk/mcp/src/search/vectors.js +60 -0
  427. package/vendor/desk/mcp/src/server.js +389 -0
  428. package/vendor/desk/mcp/src/tool-names.js +73 -0
  429. package/vendor/desk/mcp/src/tool-refusal.cjs +35 -0
  430. package/vendor/desk/mcp/src/tool-schema-parts.js +12 -0
  431. package/vendor/desk/mcp/src/tool-schemas.js +325 -0
  432. package/vendor/desk/mcp/src/tools/_card-commit.js +148 -0
  433. package/vendor/desk/mcp/src/tools/archive-links.js +185 -0
  434. package/vendor/desk/mcp/src/tools/archive-move.js +18 -0
  435. package/vendor/desk/mcp/src/tools/archive-native-session.js +728 -0
  436. package/vendor/desk/mcp/src/tools/archive-state.js +513 -0
  437. package/vendor/desk/mcp/src/tools/delivery-gate.js +251 -0
  438. package/vendor/desk/mcp/src/tools/desk-save.js +444 -0
  439. package/vendor/desk/mcp/src/tools/doctor.js +122 -0
  440. package/vendor/desk/mcp/src/tools/done-evidence.js +260 -0
  441. package/vendor/desk/mcp/src/tools/factory-context.js +204 -0
  442. package/vendor/desk/mcp/src/tools/friction.js +332 -0
  443. package/vendor/desk/mcp/src/tools/improvement.js +156 -0
  444. package/vendor/desk/mcp/src/tools/lesson-lines.js +22 -0
  445. package/vendor/desk/mcp/src/tools/lesson-owners.js +137 -0
  446. package/vendor/desk/mcp/src/tools/lesson-team.js +169 -0
  447. package/vendor/desk/mcp/src/tools/lesson.js +254 -0
  448. package/vendor/desk/mcp/src/tools/local-only.js +151 -0
  449. package/vendor/desk/mcp/src/tools/move.js +794 -0
  450. package/vendor/desk/mcp/src/tools/native-stage-context.js +32 -0
  451. package/vendor/desk/mcp/src/tools/note.js +267 -0
  452. package/vendor/desk/mcp/src/tools/search.js +634 -0
  453. package/vendor/desk/mcp/src/tools/shared-write.js +196 -0
  454. package/vendor/desk/mcp/src/tools/sibling-desk.js +37 -0
  455. package/vendor/desk/mcp/src/tools/status.js +233 -0
  456. package/vendor/desk/mcp/src/tools/task-archive-due.js +9 -0
  457. package/vendor/desk/mcp/src/tools/task-archived-resource.js +53 -0
  458. package/vendor/desk/mcp/src/tools/task-body.js +141 -0
  459. package/vendor/desk/mcp/src/tools/task-focus.js +164 -0
  460. package/vendor/desk/mcp/src/tools/task-log.js +76 -0
  461. package/vendor/desk/mcp/src/tools/task-signoff.js +155 -0
  462. package/vendor/desk/mcp/src/tools/task.js +1768 -0
  463. package/vendor/desk/mcp/src/tools/track-row.js +89 -0
  464. package/vendor/desk/mcp/src/tools/track.js +240 -0
  465. package/vendor/desk/mcp/src/util/agency-session.cjs +29 -0
  466. package/vendor/desk/mcp/src/util/archive-links.js +105 -0
  467. package/vendor/desk/mcp/src/util/bash.js +36 -0
  468. package/vendor/desk/mcp/src/util/capture-record.js +73 -0
  469. package/vendor/desk/mcp/src/util/cas-commit.js +252 -0
  470. package/vendor/desk/mcp/src/util/created-dirs.js +71 -0
  471. package/vendor/desk/mcp/src/util/deferred-tools.js +51 -0
  472. package/vendor/desk/mcp/src/util/desk-owner.js +99 -0
  473. package/vendor/desk/mcp/src/util/env-value.js +13 -0
  474. package/vendor/desk/mcp/src/util/file-identity.js +40 -0
  475. package/vendor/desk/mcp/src/util/finish-commit.js +145 -0
  476. package/vendor/desk/mcp/src/util/fm.js +410 -0
  477. package/vendor/desk/mcp/src/util/git-config-file.js +85 -0
  478. package/vendor/desk/mcp/src/util/git-stage.js +440 -0
  479. package/vendor/desk/mcp/src/util/main-publish.js +240 -0
  480. package/vendor/desk/mcp/src/util/markdown-links.cjs +555 -0
  481. package/vendor/desk/mcp/src/util/object-input.js +59 -0
  482. package/vendor/desk/mcp/src/util/paths.js +647 -0
  483. package/vendor/desk/mcp/src/util/rank.js +189 -0
  484. package/vendor/desk/mcp/src/util/redact.js +92 -0
  485. package/vendor/desk/mcp/src/util/remove-retry.js +35 -0
  486. package/vendor/desk/mcp/src/util/rename-retry.js +73 -0
  487. package/vendor/desk/mcp/src/util/route-around.js +265 -0
  488. package/vendor/desk/mcp/src/util/shell-quote.js +18 -0
  489. package/vendor/desk/mcp/src/util/startup-direction.js +124 -0
  490. package/vendor/desk/mcp/src/util/state-ignore.js +33 -0
  491. package/vendor/desk/mcp/src/util/tool-commits.js +64 -0
  492. package/vendor/desk/mcp/src/util/unicode-16/LICENSE-MIT.txt +7 -0
  493. package/vendor/desk/mcp/src/util/unicode-16/README.md +9 -0
  494. package/vendor/desk/mcp/src/util/unicode-16/letter.cjs +1 -0
  495. package/vendor/desk/mcp/src/util/unicode-16/mark.cjs +1 -0
  496. package/vendor/desk/mcp/src/util/unicode-16/number.cjs +1 -0
  497. package/vendor/desk/mcp/web-auth.cjs +1897 -0
  498. package/vendor/desk/mcp/web-browser-discovery.cjs +53 -0
  499. package/vendor/desk/mcp/web-catalog.json +34 -0
  500. package/vendor/desk/mcp/web-launch.cjs +101 -0
  501. package/vendor/desk/mcp/web.cjs +1239 -0
  502. package/vendor/desk/migrations/01-move-to-ourostack-desk.md +188 -0
  503. package/vendor/desk/migrations/02-tidy-desk.md +87 -0
  504. package/vendor/desk/migrations/03-desk-release-channel.md +38 -0
  505. package/vendor/desk/optional/session-label/consumer.mjs +237 -0
  506. package/vendor/desk/optional/session-label/extension.mjs +32 -0
  507. package/vendor/desk/plugin.json +54 -0
  508. package/vendor/desk/settings.json +3 -0
  509. package/vendor/desk/skills/add-workspace-mcp/SKILL.md +180 -0
  510. package/vendor/desk/skills/adopt-inflight-work/SKILL.md +212 -0
  511. package/vendor/desk/skills/archive-workflow/SKILL.md +132 -0
  512. package/vendor/desk/skills/content-routing/SKILL.md +95 -0
  513. package/vendor/desk/skills/core-meeting-capture/SKILL.md +47 -0
  514. package/vendor/desk/skills/core-meeting-capture/references/capture-contract.md +175 -0
  515. package/vendor/desk/skills/curator/SKILL.md +103 -0
  516. package/vendor/desk/skills/delightful-decks/SKILL.md +67 -0
  517. package/vendor/desk/skills/desk-problem/SKILL.md +87 -0
  518. package/vendor/desk/skills/directory-structure/SKILL.md +169 -0
  519. package/vendor/desk/skills/doc-review-rigor/SKILL.md +63 -0
  520. package/vendor/desk/skills/draining-issues/SKILL.md +62 -0
  521. package/vendor/desk/skills/evaluate-release/SKILL.md +96 -0
  522. package/vendor/desk/skills/evidence-discipline/SKILL.md +150 -0
  523. package/vendor/desk/skills/factory-evaluator/SKILL.md +122 -0
  524. package/vendor/desk/skills/factory-task-context/SKILL.md +116 -0
  525. package/vendor/desk/skills/factory-work/SKILL.md +16 -0
  526. package/vendor/desk/skills/fast-honest-ci/SKILL.md +70 -0
  527. package/vendor/desk/skills/fast-honest-ci/examples.md +49 -0
  528. package/vendor/desk/skills/first-run-bootstrap/SKILL.md +95 -0
  529. package/vendor/desk/skills/friction-management/SKILL.md +98 -0
  530. package/vendor/desk/skills/git-hygiene/SKILL.md +253 -0
  531. package/vendor/desk/skills/independent-review/SKILL.md +34 -0
  532. package/vendor/desk/skills/interaction-style/SKILL.md +239 -0
  533. package/vendor/desk/skills/lesson-capture/SKILL.md +85 -0
  534. package/vendor/desk/skills/lesson-capture/agents-md-budget.mjs +61 -0
  535. package/vendor/desk/skills/online-evaluation/SKILL.md +81 -0
  536. package/vendor/desk/skills/operator-voice-comments/LICENSE-humanize +21 -0
  537. package/vendor/desk/skills/operator-voice-comments/SKILL.md +90 -0
  538. package/vendor/desk/skills/operator-voice-comments/human-voice.md +43 -0
  539. package/vendor/desk/skills/peer-pr-review/SKILL.md +104 -0
  540. package/vendor/desk/skills/pr-feedback-on-own-pr/SKILL.md +145 -0
  541. package/vendor/desk/skills/pr-review-interrogation/SKILL.md +121 -0
  542. package/vendor/desk/skills/pr-reviewer-audit/SKILL.md +68 -0
  543. package/vendor/desk/skills/pr-reviewer-audit/helpers/audit.py +335 -0
  544. package/vendor/desk/skills/pr-reviewer-audit/helpers/test_audit.py +486 -0
  545. package/vendor/desk/skills/pr-self-review/SKILL.md +86 -0
  546. package/vendor/desk/skills/pr-surface-hygiene/SKILL.md +105 -0
  547. package/vendor/desk/skills/pr-surface-hygiene/check-visual-proof.cjs +99 -0
  548. package/vendor/desk/skills/pr-surface-hygiene/repository-setup.md +19 -0
  549. package/vendor/desk/skills/pr-surface-hygiene/resources/pr-visual-proof.yml +29 -0
  550. package/vendor/desk/skills/pr-surface-hygiene/resources/pull-request-template.md +5 -0
  551. package/vendor/desk/skills/preflight-actions/SKILL.md +60 -0
  552. package/vendor/desk/skills/preview-feedback/SKILL.md +70 -0
  553. package/vendor/desk/skills/repo-handling/SKILL.md +67 -0
  554. package/vendor/desk/skills/rnd-lab/SKILL.md +52 -0
  555. package/vendor/desk/skills/runtime-symptom-investigation/SKILL.md +106 -0
  556. package/vendor/desk/skills/session-resumption/SKILL.md +126 -0
  557. package/vendor/desk/skills/session-start/SKILL.md +54 -0
  558. package/vendor/desk/skills/session-start/details.md +150 -0
  559. package/vendor/desk/skills/session-start-migrations/README.md +71 -0
  560. package/vendor/desk/skills/session-start-migrations/SKILL.md +108 -0
  561. package/vendor/desk/skills/start-task/SKILL.md +88 -0
  562. package/vendor/desk/skills/task-card-format/SKILL.md +198 -0
  563. package/vendor/desk/skills/task-lifecycle/SKILL.md +217 -0
  564. package/vendor/desk/skills/track-card-format/SKILL.md +90 -0
  565. package/vendor/desk/skills/using-desk/SKILL.md +58 -0
  566. package/vendor/desk/skills/using-superpowers-with-desk/SKILL.md +156 -0
  567. package/vendor/desk/skills/work-orchestration/SKILL.md +162 -0
@@ -0,0 +1,100 @@
1
+ // Step bookkeeping for the factory loop. Each automatic step records when it last ran, when it last
2
+ // succeeded and a stable result code in `status.json` under `loop.steps.<name>`. A step that never ran has
3
+ // no record, and a step that ran and failed keeps `last_ok_at` as it was (null if it never succeeded), so a
4
+ // step that did not run never looks like one that ran and found nothing. No free text enters the record.
5
+
6
+ import { updateStatus } from "./outbox.js"
7
+
8
+ export const STEPS = Object.freeze(["evaluate", "route", "mirror", "reconcile", "verify", "measure", "deliver"])
9
+
10
+ /**
11
+ * The shortest time between two runs of a step, in hours; 0 means the step runs every time it is asked.
12
+ */
13
+ export const MIN_GAP_HOURS = Object.freeze({ evaluate: 1, route: 6, mirror: 6, reconcile: 24, verify: 24, measure: 0, deliver: 0 })
14
+
15
+ const STALE_AFTER_HOURS = 72
16
+ const STALE_FAILURES_IN_A_ROW = 3
17
+ const HOUR_MS = 3600 * 1000
18
+ const RESULT_CODE = /^[a-z0-9][a-z0-9_:-]{0,63}$/
19
+
20
+ const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value)
21
+
22
+ function requireStep(name) {
23
+ if (!STEPS.includes(name)) throw Object.assign(new TypeError("step: Pass a known step"), { code: "step_pass_a_known_step" })
24
+ }
25
+
26
+ function toTime(value) {
27
+ if (value === null) throw Object.assign(new TypeError("Pass now as a valid time"), { code: "loop_status_pass_now_as_a_valid_2" })
28
+ const time = new Date(value).getTime()
29
+ if (Number.isNaN(time)) throw Object.assign(new TypeError("Pass now as a valid time"), { code: "loop_status_pass_now_as_a_valid" })
30
+ return time
31
+ }
32
+
33
+ function timeOrNull(value) {
34
+ const time = typeof value === "string" ? Date.parse(value) : Number.NaN
35
+ return Number.isNaN(time) ? null : time
36
+ }
37
+
38
+ /** A stored counter that is not a non-negative safe integer is damaged and counts as 0. */
39
+ const counter = (value) => (Number.isSafeInteger(value) && value >= 0 ? value : 0)
40
+
41
+ function stepsOf(status) {
42
+ return isObject(status?.loop) && isObject(status.loop.steps) ? status.loop.steps : {}
43
+ }
44
+
45
+ /**
46
+ * `recordStep(env, name, { ok, result, now }) -> step record`: counts one run of `name` in `status.loop.steps.<name>`. `result` is a
47
+ * lowercase code of at most 64 characters.
48
+ */
49
+ export async function recordStep(env, name, { ok, result, now = new Date() } = {}) {
50
+ requireStep(name)
51
+ if (typeof ok !== "boolean") throw Object.assign(new TypeError("Pass ok as a boolean"), { code: "loop_status_pass_ok_as_a_boolean" })
52
+ if (typeof result !== "string" || !RESULT_CODE.test(result)) throw Object.assign(new TypeError("Pass result as a lowercase code of at most 64 characters"), { code: "loop_status_pass_result_as_a_lowercase" })
53
+ const at = new Date(toTime(now)).toISOString()
54
+ let record
55
+ await updateStatus(env, (current) => {
56
+ const loop = isObject(current.loop) ? current.loop : {}
57
+ const steps = isObject(loop.steps) ? loop.steps : {}
58
+ const before = isObject(steps[name]) ? steps[name] : {}
59
+ record = {
60
+ last_ran_at: at,
61
+ last_ok_at: ok ? at : (before.last_ok_at ?? null),
62
+ last_result: result,
63
+ runs: counter(before.runs) + 1,
64
+ failures: counter(before.failures) + (ok ? 0 : 1),
65
+ failures_in_a_row: ok ? 0 : counter(before.failures_in_a_row) + 1,
66
+ }
67
+ return { ...current, loop: { ...loop, steps: { ...steps, [name]: record } } }
68
+ })
69
+ return record
70
+ }
71
+
72
+ /**
73
+ * `dueStep(status, name, now, { newWorkAt }) -> boolean`: true for a step that never ran, or whose last run is at least `MIN_GAP_HOURS[name]`
74
+ * old, or that last ran before `newWorkAt` (milliseconds, or null): work that arrived after the step last ran makes it due at once, whatever
75
+ * the gap. The evaluator step passes its newest evaluation request, so a finished job never waits out the gap.
76
+ */
77
+ export function dueStep(status, name, now, { newWorkAt = null } = {}) {
78
+ requireStep(name)
79
+ const nowMs = toTime(now)
80
+ const ranAt = timeOrNull(stepsOf(status)[name]?.last_ran_at)
81
+ if (ranAt === null) return true
82
+ if (Number.isFinite(newWorkAt) && newWorkAt > ranAt) return true
83
+ const elapsed = nowMs - ranAt
84
+ return elapsed < 0 || elapsed >= MIN_GAP_HOURS[name] * HOUR_MS
85
+ }
86
+
87
+ /** `staleSteps(status, now, attemptedNames) -> string[]`: the steps attempted in this run whose last success is over 72 hours old (or over 72 hours ahead of the clock), or that failed 3 times in a row. An unreadable non-null `last_ok_at` counts as stale; a null one has no age. A step not attempted is never reported. */
88
+ export function staleSteps(status, now, attemptedNames) {
89
+ const steps = stepsOf(status)
90
+ const nowMs = toTime(now)
91
+ return attemptedNames.filter((name) => {
92
+ const record = steps[name]
93
+ if (!STEPS.includes(name) || !isObject(record)) return false
94
+ if (counter(record.failures_in_a_row) >= STALE_FAILURES_IN_A_ROW) return true
95
+ if (record.last_ok_at === null || record.last_ok_at === undefined) return false
96
+ const okAt = timeOrNull(record.last_ok_at)
97
+ // A success dated more than the stale window ahead of the clock (a clock that moved back) has no knowable age, so it reads stale rather than fresh for days.
98
+ return okAt === null || Math.abs(nowMs - okAt) > STALE_AFTER_HOURS * HOUR_MS
99
+ })
100
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ // The one off switch for the whole improvement loop: `DESK_FACTORY_LOOP` set to anything but 1, true, on or yes
4
+ // (padded or in capitals) turns it off, the same rule as the evaluator's `DESK_FACTORY_HEADLESS_EVALUATOR`.
5
+ // Unset means on. The loop worker (loop-worker.js) and the launcher hook (hooks/loop-start.cjs) both read it here.
6
+
7
+ const ON = new Set(["1", "true", "on", "yes"]);
8
+
9
+ function isLoopEnabled(env) {
10
+ const value = env?.DESK_FACTORY_LOOP;
11
+ return value === undefined || ON.has(String(value).trim().toLowerCase());
12
+ }
13
+
14
+ module.exports = { isLoopEnabled };
@@ -0,0 +1,96 @@
1
+ // What the loop worker leaves behind about itself, and the mark a reset status file leaves.
2
+ //
3
+ // The worker's own outcome of every run is `status.json.loop.worker = { at, result, since }` (`since` is when the current result
4
+ // started, so a lock held for hours shows its age). When the status file cannot be written, the same three fields go to
5
+ // `locks/loop-worker.state.json`. Both hold a code and two times, nothing else. The session-start line and the health record read them here.
6
+ //
7
+ // A damaged `status.json` is moved aside by the reader as `status.json.corrupt-json-<n>` and read as empty, which would reset the
8
+ // evaluator's daily cap. The moved-aside file is the durable mark: a UTC day on which one was set aside is a spent day for the evaluator.
9
+ // `ctime` is the time of the rename, which is when the status was reset; the later of it and `mtime` is used.
10
+
11
+ import { readdirSync, statSync, readFileSync } from "node:fs"
12
+ import { promises as fsp } from "node:fs"
13
+ import { randomBytes } from "node:crypto"
14
+ import * as path from "node:path"
15
+
16
+ export const WORKER_STATE_FILE = "loop-worker.state.json"
17
+ const ASIDE_NAME = /^status\.json\.corrupt-json-[0-9]+$/u
18
+ const RESULT_CODE = /^[a-z0-9][a-z0-9_:-]{0,63}$/u
19
+ const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value)
20
+ const isTime = (value) => typeof value === "string" && !Number.isNaN(Date.parse(value))
21
+
22
+ /** The names of the status files that were moved aside, or `[]` when the folder cannot be listed. */
23
+ export function listStatusAside(root) {
24
+ try {
25
+ return readdirSync(root).filter((name) => ASIDE_NAME.test(name))
26
+ } catch {
27
+ return []
28
+ }
29
+ }
30
+
31
+ /** The latest UTC day (`YYYY-MM-DD`) on which a status file was set aside, or `null`. */
32
+ export function statusResetDay(root) {
33
+ let latest = null
34
+ for (const name of listStatusAside(root)) {
35
+ try {
36
+ const info = statSync(path.join(root, name))
37
+ const ms = Math.max(info.mtimeMs, info.ctimeMs)
38
+ latest = Math.max(latest ?? ms, ms)
39
+ } catch {
40
+ // Gone since the listing.
41
+ }
42
+ }
43
+ return latest === null ? null : new Date(latest).toISOString().slice(0, 10)
44
+ }
45
+
46
+ /** A stored `{ at, result, since }` that is well formed, or `null`. */
47
+ export function validWorker(value) {
48
+ return isObject(value) && isTime(value.at) && isTime(value.since) && typeof value.result === "string" && RESULT_CODE.test(value.result)
49
+ ? { at: value.at, result: value.result, since: value.since }
50
+ : null
51
+ }
52
+
53
+ /** The record for a run that ended with `result` at `at` (ISO): `since` stays while the result stays the same. */
54
+ function nextWorker(previous, result, at) {
55
+ const before = validWorker(previous)
56
+ return { at, result, since: before !== null && before.result === result && Date.parse(before.since) <= Date.parse(at) ? before.since : at }
57
+ }
58
+
59
+ function readFallback(root) {
60
+ try {
61
+ return validWorker(JSON.parse(readFileSync(path.join(root, "locks", WORKER_STATE_FILE), "utf8")))
62
+ } catch {
63
+ return null
64
+ }
65
+ }
66
+
67
+ /** The newer of the status file's record and the fallback file's (`status` may be `null`), or `null` when neither is well formed. */
68
+ export function readWorker(status, root) {
69
+ const stored = validWorker(isObject(status?.loop) ? status.loop.worker : undefined)
70
+ const fallback = readFallback(root)
71
+ if (stored === null) return fallback
72
+ return fallback !== null && Date.parse(fallback.at) > Date.parse(stored.at) ? fallback : stored
73
+ }
74
+
75
+ /** Writes the worker's outcome: into the status through `updateStatusImpl`, else into the small file beside the lock. Never throws. */
76
+ export async function recordWorker(env, root, result, at, updateStatusImpl) {
77
+ try {
78
+ await updateStatusImpl(env, (current) => {
79
+ const loop = isObject(current.loop) ? current.loop : {}
80
+ return { ...current, loop: { ...loop, worker: nextWorker(loop.worker, result, at) } }
81
+ })
82
+ return
83
+ } catch {
84
+ // Fall through to the file beside the lock.
85
+ }
86
+ try {
87
+ const dir = path.join(root, "locks")
88
+ await fsp.mkdir(dir, { recursive: true, mode: 0o700 })
89
+ const file = path.join(dir, WORKER_STATE_FILE)
90
+ const temporary = `${file}.${randomBytes(4).toString("hex")}.tmp`
91
+ await fsp.writeFile(temporary, JSON.stringify(nextWorker(readFallback(root), result, at)), { mode: 0o600 })
92
+ await fsp.rename(temporary, file)
93
+ } catch {
94
+ // Nowhere to write: the printed line is all there is.
95
+ }
96
+ }
@@ -0,0 +1,290 @@
1
+ // The loop worker: one detached run of the improvement cycle, started by the session-start hook (hooks/loop-start.cjs)
2
+ // through `factory.js loop`. It runs the steps in order (the list `STEPS` below is data, so a step added later is
3
+ // one more entry), one at a time and each inside its own try, so one failing step never stops the next. A step that
4
+ // is not due (`dueStep`, inside its minimum gap with no newer work for it) is skipped and leaves no record. Besides the
5
+ // session-start hook, the end of a turn and a finalize run start the worker when the evaluator step is due (`evaluate-kick.js`),
6
+ // and a worker whose evaluator step labeled a job starts the next one as it ends, so the queue drains back to back.
7
+ //
8
+ // The order is route, evaluate, mirror, reconcile, verify, measure. Findings are routed first, so the later steps read current cards.
9
+ // The evaluator step starts at most one run (`maxRuns: 1`). An evaluation continuation an earlier Desk's triage step left in the status
10
+ // (`status.loop.evaluation_continuation`) is consumed under the lock before the evaluator step is asked whether it is due
11
+ // (`consumeEvaluationContinuation`): a consumed token makes the evaluator due; a refused one changes nothing.
12
+ //
13
+ // Safe and detached:
14
+ // - One worker at a time per machine, under one lock file in the factory state folder (`process-lock.js`: the
15
+ // worker's process id, start time, a random token and the child ids it started, which `onChild` and
16
+ // `onChildExit` of the evaluator step keep). A second worker answers `busy`. A lock is taken over only when
17
+ // its recorded process is not alive or it is older than 6 hours. Nothing is ever matched by name or signalled.
18
+ // - A fixed time budget: no step starts after `LOOP_BUDGET_MS` (20 minutes); the evaluator step gets a deadline
19
+ // that leaves `LATER_STEPS_RESERVE_MS` for the later steps; and the process ends itself at the budget plus
20
+ // `CEILING_GRACE_MS` if a step hangs. The evaluator's facts scan is left out of that budget: the step asks
21
+ // `extendDeadline(scanMs)` once its scan ends, and the worker grants the scan's time (at most
22
+ // `MAX_SCAN_ALLOWANCE_MS` in all), moves the budget, and with it the later steps' reserve, and the ceiling by
23
+ // the grant, tells its launcher (`hooks/loop-start.cjs`, over the message channel it opened, only while it is
24
+ // open) so the hard stop moves too, and rewrites its lock so the end-of-turn kick still reads it as running.
25
+ // A scan that ends before the first ceiling (21 minutes after the start) therefore never leaves less than one
26
+ // run's time; a longer scan is still ended by that ceiling or the launcher's 22-minute hard stop, as before.
27
+ // - A headless factory session (`DESK_FACTORY_HEADLESS`) starts nothing and writes nothing. `DESK_FACTORY_LOOP`
28
+ // set to anything but 1, true, on or yes turns the loop off (`disabled`). No state folder, no consenting store
29
+ // and no desk root each start nothing. Every outcome but a headless session or a missing state folder is recorded
30
+ // (`loop-worker-state.js`) so the session-start line and the health record can say what the loop last did.
31
+ //
32
+ // The result holds codes and integers only: `{ result, ran, skipped, failed, steps: { <step>: <code> } }`, where
33
+ // `result` is `completed`, `budget_spent`, `status_unavailable`, `status_reset` (the status file was damaged and moved aside during this run: nothing more runs, and that UTC day is a spent day for the evaluator), `busy`, `headless_session`, `disabled`,
34
+ // `no_factory_state`, `no_consenting_store`, `no_desk` or `stale_release` (the Desk that started this worker is older than the newest release on this machine, as in a session that outlived its Desk: it claims nothing, the code is recorded as the skip reason, and the newest release's own hooks run the loop), and a step's code is its own result code, `skipped`
35
+ // (not due), `not_started` (the budget was spent, or the status unreadable or reset), `step_error` (it threw) or
36
+ // `invalid_result`. The `route` step is the two route collectors as one: `routed`, `issues_failed`, `local_failed`
37
+ // or `both_failed`. `route` and `measure` answer `not_own_desk` (not run and not recorded) in a desk that is not the person's own (`route-desk.js`).
38
+ // Every other step records itself; the worker records `route`, and records `step_error` for a step that threw. The measure step runs last and is told which steps ran.
39
+
40
+ import { createRequire } from "node:module"
41
+ import { existsSync, readdirSync } from "node:fs"
42
+ import * as os from "node:os"
43
+ import * as path from "node:path"
44
+
45
+ import { checkPersonPrefix } from "./binding.js"
46
+ import { hasContributingStore } from "./boot-check.js"
47
+ import { isHeadlessFactorySession } from "./headless-flag.js"
48
+ import { runMeasureStep } from "./loop-health.js"
49
+ import { dueStep, recordStep } from "./loop-status.js"
50
+ import { runMirrorStep } from "./mirror-step.js"
51
+ import { listStatusAside, recordWorker } from "./loop-worker-state.js"
52
+ import { factoryStateRoot, readStatus, updateStatus } from "./outbox.js"
53
+ import { processAlive, releaseLock, takeLock, touchLock, trackChild } from "./process-lock.js"
54
+ import { runReconcileStep } from "./reconcile-step.js"
55
+ import { runRouteIssuesStep } from "./route-issues.js"
56
+ import { runRouteLocalStep } from "./route-local.js"
57
+ import { isOwnDesk } from "./route-desk.js"
58
+ import { runEvaluatorStep } from "./evaluator-step.js"
59
+ import { contextEvaluationDue } from "./context-run.js"
60
+ import { LOOP_LOCK_NAME, evaluateDue, kickLoop, newestRequestAt } from "./evaluate-kick.js"
61
+ import { consumeEvaluationContinuation } from "./headless-ledger.js"
62
+ import { runVerifyStep } from "./improvement-verify.js"
63
+ import { compareVersions, isVersion } from "./pipeline/versions.js"
64
+
65
+ const { isLoopEnabled } = createRequire(import.meta.url)("./loop-switch.cjs")
66
+
67
+ export const LOOP_BUDGET_MS = 20 * 60 * 1000
68
+ // What the evaluator step leaves for the steps after it: it starts no run that could end later than this before the budget.
69
+ export const LATER_STEPS_RESERVE_MS = 3 * 60 * 1000
70
+ // The process ends itself this long after the budget if a step is still running.
71
+ const CEILING_GRACE_MS = 60 * 1000
72
+ // The most facts-scan time the worker leaves out of its budget, in all. With the budget and the grace it keeps a worker well inside the
73
+ // lock's 6-hour outer age (`LOCK_OUTER_AGE_MS`), so no second worker ever takes over a live one. `hooks/loop-start.cjs` holds the same number.
74
+ export const MAX_SCAN_ALLOWANCE_MS = 5 * 60 * 60 * 1000
75
+ const LOCK_NAME = LOOP_LOCK_NAME
76
+ const CODE = /^[a-z0-9][a-z0-9_:-]{0,63}$/u
77
+
78
+ const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value)
79
+ /** The newest complete Desk release copy on this machine (`runtime/newest-release.js` keeps them), or null. */
80
+ function newestInstalledRelease(env) {
81
+ const cacheHome = typeof env.XDG_CACHE_HOME === "string" && env.XDG_CACHE_HOME.trim() !== "" ? env.XDG_CACHE_HOME : path.join(env.HOME || os.homedir(), ".cache")
82
+ const copies = path.join(cacheHome, "ouroboros-skills", "desk", "release-copies")
83
+ try {
84
+ return readdirSync(copies).filter((name) => isVersion(name) && existsSync(path.join(copies, name, ".complete.json"))).sort(compareVersions).at(-1) ?? null
85
+ } catch {
86
+ return null
87
+ }
88
+ }
89
+
90
+ const answer = (result, extra = {}) => ({ result, ran: 0, skipped: 0, failed: 0, steps: {}, ...extra })
91
+
92
+ // A step's answer, or null when it is not `{ ok: boolean, result: <code> }`.
93
+ const readAnswer = (value) => (isObject(value) && typeof value.ok === "boolean" && typeof value.result === "string" && CODE.test(value.result) ? { ok: value.ok, result: value.result } : null)
94
+
95
+ /**
96
+ * The default notice to the launcher: a message on the channel it opened, only while that channel is open. The callback takes any error
97
+ * (a launcher that ended between the check and the write), which Node would otherwise raise as an `error` event and end this worker with.
98
+ */
99
+ export function notifyLauncher(message) {
100
+ if (typeof process.send === "function" && process.connected) process.send(message, () => {})
101
+ }
102
+
103
+ const swallow = async (fn) => {
104
+ try {
105
+ return await fn()
106
+ } catch {
107
+ return undefined
108
+ }
109
+ }
110
+
111
+ const NOT_OWN_DESK = Object.freeze({ ok: true, result: "not_own_desk" })
112
+
113
+ // The two route collectors count as one step, recorded once by the worker. They write this machine's findings, so they run only in the
114
+ // person's own desk (`route-desk.js`); in any other desk the step is not recorded, so the own desk's next run is not held by the step's gap.
115
+ async function routeStep(env, ctx, impls) {
116
+ if (!ctx.ownDesk) return NOT_OWN_DESK
117
+ const half = async (fn) => readAnswer(await swallow(() => fn(env, { deskRoot: ctx.deskRoot, personPrefix: ctx.personPrefix, now: ctx.now }))) ?? { ok: false, result: "step_error" }
118
+ const issues = await half(impls.routeIssues)
119
+ const local = await half(impls.routeLocal)
120
+ if (issues.result === "headless_session" || local.result === "headless_session") return { ok: false, result: "headless_session" }
121
+ const result = issues.ok && local.ok ? "routed" : !issues.ok && !local.ok ? "both_failed" : !issues.ok ? "issues_failed" : "local_failed"
122
+ const outcome = { ok: result === "routed", result }
123
+ await swallow(() => recordStep(env, "route", { ...outcome, now: ctx.now }))
124
+ return outcome
125
+ }
126
+
127
+ // The pending evaluation continuation an earlier Desk's triage step left (`status.loop.evaluation_continuation`), or null.
128
+ const pendingContinuation = (status) => (isObject(status?.loop) && isObject(status.loop.evaluation_continuation) ? status.loop.evaluation_continuation : null)
129
+
130
+ // Consumes a pending continuation under this worker's lock and removes it from the status, whatever the ledger answers: a token is
131
+ // offered once. Answers whether it was consumed.
132
+ async function consumeContinuation(env, ctx, status, impls) {
133
+ const token = pendingContinuation(status)
134
+ if (token === null) return false
135
+ const consumed = await swallow(() => impls.consumeContinuation(env, { token, now: ctx.now, status }))
136
+ await swallow(() => ctx.updateStatus(env, (current) => {
137
+ // Another token, or none: it is not this worker's to remove.
138
+ if (JSON.stringify(pendingContinuation(current)) !== JSON.stringify(token)) return current
139
+ const { evaluation_continuation: _gone, ...rest } = current.loop
140
+ return { ...current, loop: rest }
141
+ }))
142
+ return consumed?.state === "consumed"
143
+ }
144
+
145
+ // The ordered steps. Each `run(env, ctx, impls)` answers `{ ok, result }`; a step that records itself needs nothing more. A step with
146
+ // `newWorkAt(env)` is due as soon as work newer than its last run arrives: an evaluation request makes the evaluator step due at once, and so
147
+ // does a queue still draining (`evaluateDue`).
148
+ const STEPS = Object.freeze([
149
+ { name: "route", run: routeStep },
150
+ {
151
+ name: "evaluate", newWorkAt: newestRequestAt,
152
+ due: async (status, now, newWorkAt, env, ctx, impls) => {
153
+ const consumed = await consumeContinuation(env, ctx, status, impls)
154
+ return consumed || evaluateDue(status, now, { newWorkAt }) || await contextEvaluationDue(env, status, now)
155
+ },
156
+ run: (env, ctx, impls) => impls.evaluate(env, { pluginVersion: ctx.pluginVersion, now: ctx.now, deadline: ctx.agentDeadline(), deskRoot: ctx.deskRoot, maxRuns: 1, onChild: ctx.onChild, onChildExit: ctx.onChildExit, extendDeadline: ctx.extendDeadline }),
157
+ },
158
+ { name: "mirror", run: (env, ctx, impls) => impls.mirror(env, { deskRoot: ctx.deskRoot, personPrefix: ctx.personPrefix, now: ctx.now }) },
159
+ { name: "reconcile", run: (env, ctx, impls) => impls.reconcile(env, { now: ctx.now, desks: [ctx.deskRoot], personPrefix: ctx.personPrefix }) },
160
+ { name: "verify", run: (env, ctx, impls) => impls.verify(env, { deskRoot: ctx.deskRoot, personPrefix: ctx.personPrefix, now: ctx.now }) },
161
+ // The machine's health record and its loop alarms describe the person's own desk: measured anywhere else, they would report that desk's
162
+ // cards as the machine's and its missing alarms as cleared, and the verify step would close the person's alarm cards.
163
+ { name: "measure", run: (env, ctx, impls) => (ctx.ownDesk ? impls.measure(env, { deskRoot: ctx.deskRoot, personPrefix: ctx.personPrefix, now: ctx.now, attempted: [...ctx.attempted] }) : NOT_OWN_DESK) },
164
+ ])
165
+
166
+ export const LOOP_STEP_NAMES = Object.freeze(STEPS.map(({ name }) => name))
167
+
168
+ const DEFAULT_IMPLS = { evaluate: runEvaluatorStep, consumeContinuation: consumeEvaluationContinuation, routeIssues: runRouteIssuesStep, routeLocal: runRouteLocalStep, mirror: runMirrorStep, reconcile: runReconcileStep, verify: runVerifyStep, measure: runMeasureStep, kick: kickLoop }
169
+
170
+ /**
171
+ * `runLoopWorker(env, { deskRoot, personPrefix, pluginVersion, clock, alive, budgetMs, ceilingMs, exit, notify, readStatusImpl, impls }) -> result`
172
+ * (see the header). `clock` (milliseconds), `alive`, `exit`, `notify` (the notice to the launcher), `readStatusImpl` and `impls` (the step functions) are seams for tests.
173
+ * Throws a `TypeError` for a `deskRoot` that is neither null nor absolute or a `personPrefix` that is not `""` or `desks/<alias>`.
174
+ */
175
+ export async function runLoopWorker(env, {
176
+ deskRoot, personPrefix = "", pluginVersion, clock = Date.now, alive = processAlive, budgetMs = LOOP_BUDGET_MS,
177
+ ceilingMs = budgetMs + CEILING_GRACE_MS, exit = process.exit, notify = notifyLauncher, readStatusImpl = readStatus, updateStatusImpl = updateStatus, impls = {},
178
+ ownDesk = isOwnDesk, newestRelease = newestInstalledRelease,
179
+ }) {
180
+ if (deskRoot !== null && !path.isAbsolute(deskRoot)) throw Object.assign(new TypeError("Pass deskRoot as an absolute path"), { code: "loop_worker_pass_deskroot_as_an_absolute" })
181
+ checkPersonPrefix(personPrefix, "runLoopWorker")
182
+ if (isHeadlessFactorySession(env)) return answer("headless_session")
183
+ const root = await factoryStateRoot(env, { create: false })
184
+ // Every run's outcome is recorded where the health record and the session-start line can read it; nothing when there is no state folder.
185
+ const ended = async (outcome) => {
186
+ if (root !== null) await recordWorker(env, root, outcome.result, new Date(clock()).toISOString(), updateStatusImpl)
187
+ return outcome
188
+ }
189
+ if (!isLoopEnabled(env)) return ended(answer("disabled"))
190
+ if (deskRoot === null) return ended(answer("no_desk"))
191
+ // A worker the old turn-end hook of a long-running session started must not claim work that belongs to the current release.
192
+ const newest = newestRelease(env)
193
+ if (isVersion(pluginVersion) && isVersion(newest) && compareVersions(newest, pluginVersion) > 0) return ended(answer("stale_release", { running: pluginVersion, newest }))
194
+ if (root === null) return answer("no_factory_state")
195
+ // A desk that has not opted in stays silent: nothing is recorded, so no health line or card follows from it.
196
+ if (!hasContributingStore(env)) return answer("no_consenting_store")
197
+ const lock = await takeLock(root, { name: LOCK_NAME, alive, clock, record: { children: [] } })
198
+ if (lock === null) return ended(answer("busy"))
199
+
200
+ const started = clock()
201
+ let ceiling = setTimeout(() => exit(0), ceilingMs)
202
+ ceiling.unref()
203
+ const functions = { ...DEFAULT_IMPLS, ...impls }
204
+ // The facts-scan time granted so far: the budget, the evaluator's limit and the ceiling all move by it.
205
+ let extension = 0
206
+ // Child ids go into the lock file one write at a time, in the order they were reported.
207
+ let pending = Promise.resolve()
208
+ const track = (pid, on) => { pending = pending.then(() => trackChild(lock, pid, on)) }
209
+ const extendDeadline = async (scanMs) => {
210
+ const asked = typeof scanMs === "number" && !Number.isNaN(scanMs) ? Math.floor(scanMs) : 0
211
+ const granted = Math.min(Math.max(0, asked), MAX_SCAN_ALLOWANCE_MS - extension)
212
+ if (granted === 0) return 0
213
+ extension += granted
214
+ clearTimeout(ceiling)
215
+ ceiling = setTimeout(() => exit(0), Math.max(0, started + ceilingMs + extension - clock()))
216
+ ceiling.unref()
217
+ notify({ desk_loop_extend_ms: extension })
218
+ // The kick reads a lock younger than its 22 minutes as a live worker (`KICK_LOCK_AGE_MS`); what is left of this worker after the scan
219
+ // is shorter than that, so a lock rewritten now keeps the kick from starting a second worker that would only record `busy`.
220
+ pending = pending.then(() => touchLock(lock))
221
+ await pending
222
+ return granted
223
+ }
224
+ const ctx = {
225
+ deskRoot, personPrefix, pluginVersion, attempted: [], updateStatus: updateStatusImpl,
226
+ ownDesk: ownDesk(env, deskRoot),
227
+ // The agent steps' deadline: the budget, moved by any facts-scan time granted so far, less the later steps' reserve.
228
+ agentDeadline: () => new Date(started + budgetMs + extension - LATER_STEPS_RESERVE_MS),
229
+ onChild: (pid) => track(pid, true),
230
+ onChildExit: (pid) => track(pid, false),
231
+ extendDeadline,
232
+ }
233
+ const outcome = answer("completed")
234
+ // A status file that the reader moves aside and reads as empty must not look like a machine that never ran: it would restart the evaluator's daily cap.
235
+ const known = new Set(listStatusAside(root))
236
+ try {
237
+ let stopped = null
238
+ for (const step of STEPS) {
239
+ if (stopped === null && clock() >= started + budgetMs + extension) stopped = "budget_spent"
240
+ let status
241
+ if (stopped === null) {
242
+ try {
243
+ status = await readStatusImpl(env)
244
+ if (listStatusAside(root).some((name) => !known.has(name))) stopped = "status_reset"
245
+ } catch {
246
+ stopped = "status_unavailable"
247
+ }
248
+ }
249
+ // New work that cannot be read makes nothing due early; the gap still applies.
250
+ const newWorkAt = stopped === null && step.newWorkAt !== undefined ? ((await swallow(() => step.newWorkAt(env))) ?? null) : null
251
+ const due = step.due ?? ((stored, now, work) => dueStep(stored, step.name, now, { newWorkAt: work }))
252
+ if (stopped === null && !(await due(status, new Date(clock()), newWorkAt, env, { ...ctx, now: new Date(clock()) }, functions))) {
253
+ outcome.steps[step.name] = "skipped"
254
+ outcome.skipped += 1
255
+ continue
256
+ }
257
+ if (stopped !== null) {
258
+ outcome.steps[step.name] = "not_started"
259
+ continue
260
+ }
261
+ ctx.now = new Date(clock())
262
+ let result
263
+ try {
264
+ result = await step.run(env, ctx, functions)
265
+ } catch {
266
+ result = { ok: false, result: "step_error" }
267
+ await swallow(() => recordStep(env, step.name, { ok: false, result: "step_error", now: ctx.now }))
268
+ }
269
+ const read = readAnswer(result) ?? { ok: false, result: "invalid_result" }
270
+ ctx.attempted.push(step.name)
271
+ outcome.ran += 1
272
+ if (!read.ok) outcome.failed += 1
273
+ outcome.steps[step.name] = read.result
274
+ }
275
+ if (stopped !== null) outcome.result = stopped
276
+ await ended(outcome)
277
+ } finally {
278
+ clearTimeout(ceiling)
279
+ await pending
280
+ await releaseLock(lock)
281
+ }
282
+ // A worker whose evaluator step accepted a job's labels (`evaluator.accepted_last_step`) starts the next one once its lock is free, so the queue drains back to back. The kick starts
283
+ // one only while a job the runner can run today is left within the day's ceiling (`evaluateDue`); a kick that fails changes nothing here.
284
+ if (outcome.steps.evaluate === "ran" && (await swallow(async () => (await readStatusImpl(env))?.evaluator?.accepted_last_step > 0)) === true) await swallow(() => functions.kick(env, { scope: { deskRoot, personPrefix } }))
285
+ else if (outcome.steps.evaluate === "context_ran" && (await swallow(async () => {
286
+ const context = (await readStatusImpl(env))?.context_evaluation
287
+ return context?.accepted > 0 && context.refused === 0
288
+ })) === true) await swallow(() => functions.kick(env, { scope: { deskRoot, personPrefix } }))
289
+ return outcome
290
+ }
@@ -0,0 +1,61 @@
1
+ import fs from "node:fs"
2
+ import * as path from "node:path"
3
+ import { EXACT, sameFile } from "../util/file-identity.js"
4
+ import { ENUMS, LIMITS, PATTERNS, isPlainObject, validPluginSource } from "./schema.js"
5
+
6
+ export const MAX_MARKER_BYTES = 64 * 1024
7
+ const REQUIRED = ["schema_version", "host", "session_id", "log_path", "cwd", "desk_root", "end_reason", "ended_at", "plugins", "updated_at"]
8
+ const OPTIONAL = ["entrypoint", "person_prefix", "routing", "proof"]
9
+ const time = (value) => typeof value === "string" && PATTERNS.timestamp.test(value) && Number.isFinite(Date.parse(value))
10
+ const unchangedFile = (left, right) => ["dev", "ino", "size", "mtimeNs", "ctimeNs"].every((key) => left[key] === right[key])
11
+ export const absolutePath = (value) => typeof value === "string" && value.length <= 4096 && !/[\x00-\x1f\x7f]/u.test(value) && path.isAbsolute(value)
12
+
13
+ export function validRouting(value) {
14
+ return isPlainObject(value) && Object.keys(value).sort().join(",") === "source,store,warnings"
15
+ && ["desk", "overlay", "default", "invalid_declaration"].includes(value.source)
16
+ && (value.source === "invalid_declaration" ? value.store === null : typeof value.store === "string" && PATTERNS.prRepo.test(value.store))
17
+ && Array.isArray(value.warnings) && value.warnings.length <= 192
18
+ && value.warnings.every((warning) => isPlainObject(warning) && Object.keys(warning).sort().join(",") === "code,manifest"
19
+ && ["manifest_unreadable", "manifest_unparseable"].includes(warning.code) && absolutePath(warning.manifest))
20
+ }
21
+
22
+ export function validMarker(marker) {
23
+ if (!isPlainObject(marker) || REQUIRED.some((key) => !Object.hasOwn(marker, key))
24
+ || Object.keys(marker).some((key) => !REQUIRED.includes(key) && !OPTIONAL.includes(key))) return false
25
+ return marker.schema_version === 1 && ENUMS.host.includes(marker.host)
26
+ && typeof marker.session_id === "string" && PATTERNS.sessionId.test(marker.session_id)
27
+ && absolutePath(marker.log_path) && absolutePath(marker.cwd)
28
+ && (marker.desk_root === null || absolutePath(marker.desk_root))
29
+ && (marker.end_reason === null || ENUMS.endReason.includes(marker.end_reason))
30
+ && (marker.ended_at === null || time(marker.ended_at)) && time(marker.updated_at)
31
+ && Array.isArray(marker.plugins) && marker.plugins.length <= LIMITS.plugins
32
+ && marker.plugins.every((plugin) => isPlainObject(plugin) && ["name,version", "name,source,version"].includes(Object.keys(plugin).sort().join(","))
33
+ && typeof plugin.name === "string" && PATTERNS.pluginName.test(plugin.name)
34
+ && typeof plugin.version === "string" && PATTERNS.semver.test(plugin.version)
35
+ && validPluginSource(plugin))
36
+ && (!Object.hasOwn(marker, "entrypoint") || ENUMS.entrypoint.includes(marker.entrypoint))
37
+ && (!Object.hasOwn(marker, "person_prefix") || (typeof marker.person_prefix === "string" && /^(?:desks\/[A-Za-z0-9][A-Za-z0-9_-]{0,63})?$/u.test(marker.person_prefix)))
38
+ && (!Object.hasOwn(marker, "routing") || validRouting(marker.routing))
39
+ // `proof: true` is written only for a controlled proof session (`DESK_FACTORY_PROOF`, issue #578); any other value makes the marker invalid.
40
+ && (!Object.hasOwn(marker, "proof") || marker.proof === true)
41
+ }
42
+
43
+ // Metadata only: never block on a pipe or read an unbounded manifest.
44
+ export function readSmallText(file, limit = MAX_MARKER_BYTES) {
45
+ const before = fs.lstatSync(file, EXACT)
46
+ if (!before.isFile() || before.nlink !== 1n || before.size > limit) throw new Error("metadata_unreadable")
47
+ const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NONBLOCK | fs.constants.O_NOFOLLOW)
48
+ try {
49
+ const stat = fs.fstatSync(fd, EXACT)
50
+ if (!stat.isFile() || stat.nlink !== 1n || stat.size > limit || !sameFile(stat, before)) throw new Error("metadata_unreadable")
51
+ const bytes = Buffer.alloc(limit + 1)
52
+ const size = fs.readSync(fd, bytes, 0, bytes.length, 0)
53
+ if (size > limit) throw new Error("metadata_unreadable")
54
+ const after = fs.fstatSync(fd, EXACT)
55
+ const atPath = fs.lstatSync(file, EXACT)
56
+ if (!atPath.isFile() || atPath.nlink !== 1n || !unchangedFile(stat, after) || !unchangedFile(after, atPath)) throw new Error("metadata_unreadable")
57
+ return bytes.toString("utf8", 0, size)
58
+ } finally {
59
+ fs.closeSync(fd)
60
+ }
61
+ }