orkeon-code 0.0.0-stage → 1.0.0-rc.1

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 (423) hide show
  1. package/.orkeon-version +1 -0
  2. package/LICENSE.md +21 -0
  3. package/NOTICE.md +17 -0
  4. package/README.fr.md +169 -0
  5. package/README.md +162 -2
  6. package/config/appsettings.anthropic.example.json +77 -0
  7. package/config/appsettings.example.json +71 -0
  8. package/config/appsettings.jev.example.json +128 -0
  9. package/config/appsettings.kev.example.json +130 -0
  10. package/config/appsettings.liquid.example.json +129 -0
  11. package/config/appsettings.ollama-whisper.example.json +92 -0
  12. package/config/appsettings.ollama.example.json +70 -0
  13. package/config/appsettings.whisper.example.json +31 -0
  14. package/mcp/whisper/README.md +293 -0
  15. package/mcp/whisper/pyproject.toml +32 -0
  16. package/mcp/whisper/uv.lock +1641 -0
  17. package/mcp/whisper/whisper_mcp.py +1053 -0
  18. package/orkeon-code +897 -0
  19. package/orkeon-code.mjs +71 -0
  20. package/orkeon-code.ps1 +837 -0
  21. package/package.json +57 -4
  22. package/scripts/install.ps1 +156 -0
  23. package/scripts/install.sh +148 -0
  24. package/scripts/session-start.ork.ts +90 -0
  25. package/scripts/session-start.sh +74 -0
  26. package/scripts/setup-fixture.sh +88 -0
  27. package/src/commands/.orkeon/orkeon-cli.d.ts +562 -0
  28. package/src/commands/_lib/args.ts +193 -0
  29. package/src/commands/_lib/dev/dev-batches.ts +368 -0
  30. package/src/commands/_lib/dev/dev-implement.ts +188 -0
  31. package/src/commands/_lib/dev/dev-source.ts +65 -0
  32. package/src/commands/_lib/dev/dev.ts +344 -0
  33. package/src/commands/_lib/dev-step.ts +142 -0
  34. package/src/commands/_lib/dispatch.ts +231 -0
  35. package/src/commands/_lib/effort.ts +15 -0
  36. package/src/commands/_lib/git/branch.ts +95 -0
  37. package/src/commands/_lib/git/commit.ts +94 -0
  38. package/src/commands/_lib/git/diff.ts +97 -0
  39. package/src/commands/_lib/git/review.ts +109 -0
  40. package/src/commands/_lib/memory/memory-admit.ts +150 -0
  41. package/src/commands/_lib/memory/memory.ts +51 -0
  42. package/src/commands/_lib/pr-context.ts +32 -0
  43. package/src/commands/_lib/project/analyze.ts +24 -0
  44. package/src/commands/_lib/session/export.ts +104 -0
  45. package/src/commands/_lib/session/resume.ts +160 -0
  46. package/src/commands/_lib/session/tasks.ts +184 -0
  47. package/src/commands/_lib/settings/advisor.ts +80 -0
  48. package/src/commands/_lib/settings/agents.ts +147 -0
  49. package/src/commands/_lib/settings/config.ts +141 -0
  50. package/src/commands/_lib/settings/hooks.ts +58 -0
  51. package/src/commands/_lib/settings/mode.ts +91 -0
  52. package/src/commands/_lib/settings/model.ts +146 -0
  53. package/src/commands/_lib/settings/permissions.ts +309 -0
  54. package/src/commands/_lib/settings/session-config.ts +49 -0
  55. package/src/commands/_lib/settings/skills.ts +51 -0
  56. package/src/commands/_lib/speech/say.ts +96 -0
  57. package/src/commands/_lib/speech/transcribe.ts +130 -0
  58. package/src/commands/_lib/speech/voice.ts +146 -0
  59. package/src/commands/_lib/status/cache.ts +31 -0
  60. package/src/commands/_lib/status/context.ts +57 -0
  61. package/src/commands/_lib/status/doctor.ts +186 -0
  62. package/src/commands/_lib/status/meta.ts +45 -0
  63. package/src/commands/_lib/status/status.ts +129 -0
  64. package/src/commands/_lib/status/usage-tools.ts +49 -0
  65. package/src/commands/_lib/status/usage.ts +139 -0
  66. package/src/commands/_lib/view.ts +29 -0
  67. package/src/commands/dev/dev-batches.cmd.ts +108 -0
  68. package/src/commands/dev/dev-learn.cmd.ts +29 -0
  69. package/src/commands/dev/dev-plan.cmd.ts +52 -0
  70. package/src/commands/dev/dev-spec.cmd.ts +55 -0
  71. package/src/commands/dev/dev-status.cmd.ts +16 -0
  72. package/src/commands/git/branch.cmd.ts +27 -0
  73. package/src/commands/git/commit.cmd.ts +48 -0
  74. package/src/commands/git/diff.cmd.ts +26 -0
  75. package/src/commands/git/review.cmd.ts +36 -0
  76. package/src/commands/memory/memory.cmd.ts +48 -0
  77. package/src/commands/project/analyze.cmd.ts +32 -0
  78. package/src/commands/project/debug-tool-call.cmd.ts +67 -0
  79. package/src/commands/project/files.cmd.ts +22 -0
  80. package/src/commands/project/init-verifiers.cmd.ts +14 -0
  81. package/src/commands/project/init.cmd.ts +14 -0
  82. package/src/commands/project/verify.cmd.ts +27 -0
  83. package/src/commands/session/assistant.cmd.ts +40 -0
  84. package/src/commands/session/btw.cmd.ts +18 -0
  85. package/src/commands/session/clear.cmd.ts +19 -0
  86. package/src/commands/session/compact.cmd.ts +16 -0
  87. package/src/commands/session/copy.cmd.ts +44 -0
  88. package/src/commands/session/exit.cmd.ts +9 -0
  89. package/src/commands/session/export.cmd.ts +28 -0
  90. package/src/commands/session/rename.cmd.ts +17 -0
  91. package/src/commands/session/resume.cmd.ts +19 -0
  92. package/src/commands/session/rewind.cmd.ts +26 -0
  93. package/src/commands/session/summary.cmd.ts +27 -0
  94. package/src/commands/session/tasks.cmd.ts +44 -0
  95. package/src/commands/settings/advisor.cmd.ts +38 -0
  96. package/src/commands/settings/agents.cmd.ts +19 -0
  97. package/src/commands/settings/config.cmd.ts +17 -0
  98. package/src/commands/settings/effort.cmd.ts +40 -0
  99. package/src/commands/settings/fast.cmd.ts +17 -0
  100. package/src/commands/settings/hooks.cmd.ts +17 -0
  101. package/src/commands/settings/mode.cmd.ts +20 -0
  102. package/src/commands/settings/model.cmd.ts +20 -0
  103. package/src/commands/settings/output-style.cmd.ts +48 -0
  104. package/src/commands/settings/permissions.cmd.ts +25 -0
  105. package/src/commands/settings/proactive.cmd.ts +15 -0
  106. package/src/commands/settings/skills.cmd.ts +17 -0
  107. package/src/commands/speech/say.cmd.ts +24 -0
  108. package/src/commands/speech/transcribe.cmd.ts +29 -0
  109. package/src/commands/speech/voice.cmd.ts +30 -0
  110. package/src/commands/status/context.cmd.ts +18 -0
  111. package/src/commands/status/doctor.cmd.ts +27 -0
  112. package/src/commands/status/release-notes.cmd.ts +9 -0
  113. package/src/commands/status/status.cmd.ts +25 -0
  114. package/src/commands/status/usage.cmd.ts +21 -0
  115. package/src/crews/.orkeon/orkeon.d.ts +3946 -0
  116. package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +183 -0
  117. package/src/crews/_probe-shared-memory/probe.ork.ts +98 -0
  118. package/src/crews/advisor/application/run-advisor.ts +40 -0
  119. package/src/crews/advisor/crew.ork.ts +43 -0
  120. package/src/crews/advisor/domain/advice.ts +135 -0
  121. package/src/crews/agent-run/application/run-agent-run.ts +42 -0
  122. package/src/crews/agent-run/crew.ork.ts +67 -0
  123. package/src/crews/analyze/application/run-analyze.ts +118 -0
  124. package/src/crews/analyze/crew.ork.ts +40 -0
  125. package/src/crews/analyze/domain/harvest.ts +301 -0
  126. package/src/crews/code-review/application/prompts.ts +133 -0
  127. package/src/crews/code-review/application/review.ts +71 -0
  128. package/src/crews/code-review/application/run-code-review.ts +123 -0
  129. package/src/crews/code-review/crew.ork.ts +51 -0
  130. package/src/crews/code-review/domain/lenses.ts +193 -0
  131. package/src/crews/code-review/domain/report.ts +59 -0
  132. package/src/crews/code-review/domain/scope.ts +112 -0
  133. package/src/crews/dev-batches/application/plan-close.ts +181 -0
  134. package/src/crews/dev-batches/application/run-dev-batches.ts +669 -0
  135. package/src/crews/dev-batches/application/run-wave.ts +450 -0
  136. package/src/crews/dev-batches/application/seed-harvest.ts +162 -0
  137. package/src/crews/dev-batches/crew.ork.ts +143 -0
  138. package/src/crews/dev-batches/domain/batch-waves.ts +70 -0
  139. package/src/crews/dev-batches/domain/batches-budget.ts +52 -0
  140. package/src/crews/dev-batches/domain/batches-log.ts +54 -0
  141. package/src/crews/dev-batches/domain/wave-order.ts +43 -0
  142. package/src/crews/dev-change/application/change-prompt.ts +104 -0
  143. package/src/crews/dev-change/application/evidence.ts +169 -0
  144. package/src/crews/dev-change/application/run-dev-change.ts +315 -0
  145. package/src/crews/dev-change/crew.ork.ts +112 -0
  146. package/src/crews/dev-change/domain/change-answer.ts +159 -0
  147. package/src/crews/dev-change/domain/change-render.ts +79 -0
  148. package/src/crews/dev-implement/application/close.ts +183 -0
  149. package/src/crews/dev-implement/application/count-open-steps.ts +24 -0
  150. package/src/crews/dev-implement/application/locate-sheet.ts +80 -0
  151. package/src/crews/dev-implement/application/observe.ts +50 -0
  152. package/src/crews/dev-implement/application/report-writes.ts +41 -0
  153. package/src/crews/dev-implement/application/run-dev-implement.ts +811 -0
  154. package/src/crews/dev-implement/application/run-role.ts +27 -0
  155. package/src/crews/dev-implement/application/suite-job.ts +118 -0
  156. package/src/crews/dev-implement/application/touched.ts +74 -0
  157. package/src/crews/dev-implement/crew.ork.ts +68 -0
  158. package/src/crews/dev-implement/domain/contracts.ts +256 -0
  159. package/src/crews/dev-implement/domain/correction.ts +102 -0
  160. package/src/crews/dev-implement/domain/cycles.ts +35 -0
  161. package/src/crews/dev-implement/domain/implement-budget.ts +29 -0
  162. package/src/crews/dev-implement/domain/roles.ts +53 -0
  163. package/src/crews/dev-implement/domain/sheet-edits.ts +75 -0
  164. package/src/crews/dev-implement/domain/sheet-ticks.ts +22 -0
  165. package/src/crews/dev-implement/domain/step-checks.ts +136 -0
  166. package/src/crews/dev-implement/domain/step-section.ts +127 -0
  167. package/src/crews/dev-learn/application/learn-backlog.ts +58 -0
  168. package/src/crews/dev-learn/application/learn-prompt.ts +140 -0
  169. package/src/crews/dev-learn/application/run-dev-learn.ts +553 -0
  170. package/src/crews/dev-learn/crew.ork.ts +52 -0
  171. package/src/crews/dev-learn/domain/learn-answer.ts +235 -0
  172. package/src/crews/dev-learn/domain/owner-lines.ts +86 -0
  173. package/src/crews/dev-learn/domain/proposals-render.ts +96 -0
  174. package/src/crews/dev-plan/application/anchor-paths.ts +76 -0
  175. package/src/crews/dev-plan/application/inventory.ts +170 -0
  176. package/src/crews/dev-plan/application/plan-prompt.ts +159 -0
  177. package/src/crews/dev-plan/application/run-dev-plan.ts +455 -0
  178. package/src/crews/dev-plan/crew.ork.ts +109 -0
  179. package/src/crews/dev-plan/domain/inventory-model.ts +95 -0
  180. package/src/crews/dev-plan/domain/plan-answer.ts +738 -0
  181. package/src/crews/dev-plan/domain/plan-render.ts +307 -0
  182. package/src/crews/dev-spec/application/run-dev-spec.ts +206 -0
  183. package/src/crews/dev-spec/application/spec-prompt.ts +98 -0
  184. package/src/crews/dev-spec/crew.ork.ts +108 -0
  185. package/src/crews/dev-spec/domain/spec-answer.ts +253 -0
  186. package/src/crews/dev-spec/domain/spec-render.ts +76 -0
  187. package/src/crews/dev-verify/application/audit.ts +259 -0
  188. package/src/crews/dev-verify/application/auditor-prompt.ts +323 -0
  189. package/src/crews/dev-verify/application/capture.ts +303 -0
  190. package/src/crews/dev-verify/application/run-dev-verify.ts +409 -0
  191. package/src/crews/dev-verify/application/run-gate.ts +202 -0
  192. package/src/crews/dev-verify/crew.ork.ts +103 -0
  193. package/src/crews/dev-verify/domain/audit-answer.ts +150 -0
  194. package/src/crews/dev-verify/domain/auditor-charter.ts +21 -0
  195. package/src/crews/dev-verify/domain/capture-sections.ts +137 -0
  196. package/src/crews/dev-verify/domain/commands.ts +103 -0
  197. package/src/crews/dev-verify/domain/gate.ts +126 -0
  198. package/src/crews/dev-verify/domain/mechanical-table.ts +163 -0
  199. package/src/crews/dev-verify/domain/runtime-cut.ts +13 -0
  200. package/src/crews/dev-verify/domain/sheet-facts.ts +4 -0
  201. package/src/crews/dev-verify/domain/text.ts +20 -0
  202. package/src/crews/dev-verify/domain/verdict.ts +127 -0
  203. package/src/crews/git-commit/application/draft.ts +154 -0
  204. package/src/crews/git-commit/application/run-git-commit.ts +116 -0
  205. package/src/crews/git-commit/crew.ork.ts +52 -0
  206. package/src/crews/git-commit/domain/commit.ts +220 -0
  207. package/src/crews/init-verifiers/application/authoring.ts +89 -0
  208. package/src/crews/init-verifiers/application/prompts.ts +103 -0
  209. package/src/crews/init-verifiers/application/run-init-verifiers.ts +25 -0
  210. package/src/crews/init-verifiers/crew.ork.ts +34 -0
  211. package/src/crews/init-verifiers/domain/commands-section.ts +36 -0
  212. package/src/crews/init-verifiers/domain/readiness.ts +23 -0
  213. package/src/crews/main-loop/application/auto-compact.ts +77 -0
  214. package/src/crews/main-loop/application/context-gather.ts +133 -0
  215. package/src/crews/main-loop/application/run-main-loop.ts +350 -0
  216. package/src/crews/main-loop/application/turn-prompt.ts +112 -0
  217. package/src/crews/main-loop/crew.ork.ts +119 -0
  218. package/src/crews/main-loop/domain/autocompact.ts +27 -0
  219. package/src/crews/main-loop/domain/prompt-assembly.ts +521 -0
  220. package/src/crews/main-loop/domain/turn-chains.ts +129 -0
  221. package/src/crews/project-init/application/detect.ts +122 -0
  222. package/src/crews/project-init/application/prompts.ts +101 -0
  223. package/src/crews/project-init/application/run-project-init.ts +31 -0
  224. package/src/crews/project-init/crew.ork.ts +35 -0
  225. package/src/crews/project-init/domain/conventions.ts +36 -0
  226. package/src/crews/project-init/domain/existing-files.ts +63 -0
  227. package/src/crews/project-init/domain/package-map.ts +73 -0
  228. package/src/crews/session-compact/crew.ork.ts +55 -0
  229. package/src/crews/shared-memory-admit/crew.ork.ts +48 -0
  230. package/src/crews/speech/application/run-speech.ts +25 -0
  231. package/src/crews/speech/crew.ork.ts +37 -0
  232. package/src/shared/application/agents/child-agent.ts +255 -0
  233. package/src/shared/application/agents/run-sub-agent.ts +96 -0
  234. package/src/shared/application/answer-language.ts +14 -0
  235. package/src/shared/application/attached-skills.ts +36 -0
  236. package/src/shared/application/compaction/compact-session.ts +237 -0
  237. package/src/shared/application/compaction/extract-memories.ts +38 -0
  238. package/src/shared/application/compaction/restore-context.ts +78 -0
  239. package/src/shared/application/config-store.ts +123 -0
  240. package/src/shared/application/dev/brief-inventory.ts +113 -0
  241. package/src/shared/application/dev/close-batch.ts +83 -0
  242. package/src/shared/application/dev/find-repo-pack.ts +77 -0
  243. package/src/shared/application/dev/learn-decision.ts +252 -0
  244. package/src/shared/application/dev/load-dev-context.ts +266 -0
  245. package/src/shared/application/dev/measure-access-cost.ts +68 -0
  246. package/src/shared/application/dev/plan-source.ts +112 -0
  247. package/src/shared/application/dev/preflight.ts +71 -0
  248. package/src/shared/application/dev/project-files.ts +17 -0
  249. package/src/shared/application/dev/question-round.ts +52 -0
  250. package/src/shared/application/dev/resolve-work-folder.ts +133 -0
  251. package/src/shared/application/dev/script-tool-slot.ts +27 -0
  252. package/src/shared/application/dev/settle-questions.ts +55 -0
  253. package/src/shared/application/dev/source-review.ts +63 -0
  254. package/src/shared/application/dev/source-step.ts +150 -0
  255. package/src/shared/application/dev/spend.ts +42 -0
  256. package/src/shared/application/dev/step-precedents.ts +89 -0
  257. package/src/shared/application/dev/tool-call-policy.ts +89 -0
  258. package/src/shared/application/dev/tool-callbacks.ts +215 -0
  259. package/src/shared/application/dev/tool-trace-recorder.ts +45 -0
  260. package/src/shared/application/dev/verdict-sources.ts +48 -0
  261. package/src/shared/application/dev/wrapped-tools.ts +145 -0
  262. package/src/shared/application/extra-tools.ts +70 -0
  263. package/src/shared/application/git/batch-worktree.ts +97 -0
  264. package/src/shared/application/git/commit-files.ts +186 -0
  265. package/src/shared/application/git/merge-batch.ts +63 -0
  266. package/src/shared/application/git/open-pull-request.ts +51 -0
  267. package/src/shared/application/instructions-file.ts +19 -0
  268. package/src/shared/application/json-file.ts +34 -0
  269. package/src/shared/application/llm-profile.ts +35 -0
  270. package/src/shared/application/permission-rules.ts +159 -0
  271. package/src/shared/application/ports/approvals.ts +20 -0
  272. package/src/shared/application/ports/clock.ts +5 -0
  273. package/src/shared/application/ports/code-index.ts +93 -0
  274. package/src/shared/application/ports/crew.ts +60 -0
  275. package/src/shared/application/ports/files.ts +21 -0
  276. package/src/shared/application/ports/human.ts +13 -0
  277. package/src/shared/application/ports/llm.ts +54 -0
  278. package/src/shared/application/ports/memory.ts +30 -0
  279. package/src/shared/application/ports/progress.ts +23 -0
  280. package/src/shared/application/ports/runtime.ts +15 -0
  281. package/src/shared/application/ports/session.ts +74 -0
  282. package/src/shared/application/ports/shared-memory.ts +26 -0
  283. package/src/shared/application/ports/shell.ts +40 -0
  284. package/src/shared/application/ports/telemetry.ts +45 -0
  285. package/src/shared/application/ports/tools.ts +46 -0
  286. package/src/shared/application/ports/usage.ts +45 -0
  287. package/src/shared/application/ports.ts +27 -0
  288. package/src/shared/application/project-manifests.ts +106 -0
  289. package/src/shared/application/session-io.ts +84 -0
  290. package/src/shared/application/session-state.ts +36 -0
  291. package/src/shared/application/shared-memory/admit-entries.ts +177 -0
  292. package/src/shared/application/shared-memory/harvest-after-gaps.ts +72 -0
  293. package/src/shared/application/shared-memory/harvest-mistakes.ts +44 -0
  294. package/src/shared/application/shared-memory/import-agent-memory.ts +117 -0
  295. package/src/shared/application/shared-memory/memory-files.ts +110 -0
  296. package/src/shared/application/shared-memory/memory-settings.ts +93 -0
  297. package/src/shared/application/shared-memory/push-candidate.ts +146 -0
  298. package/src/shared/application/shared-memory/recall-precedents.ts +69 -0
  299. package/src/shared/application/state-snapshot.ts +38 -0
  300. package/src/shared/application/workflow/workflow-state.ts +135 -0
  301. package/src/shared/domain/agent-policy/behavior-flags.ts +168 -0
  302. package/src/shared/domain/agent-policy/extra-tools.ts +69 -0
  303. package/src/shared/domain/agent-policy/memory-categories.ts +6 -0
  304. package/src/shared/domain/agent-policy/mode-policy.ts +51 -0
  305. package/src/shared/domain/agent-policy/output-styles.ts +11 -0
  306. package/src/shared/domain/agent-policy/permission.ts +623 -0
  307. package/src/shared/domain/agent-policy/rule-sets.ts +412 -0
  308. package/src/shared/domain/agent-policy/tool-access.ts +77 -0
  309. package/src/shared/domain/agent-registry.ts +142 -0
  310. package/src/shared/domain/agents/built-in-charters.ts +43 -0
  311. package/src/shared/domain/agents/chain.ts +30 -0
  312. package/src/shared/domain/agents/charter.ts +61 -0
  313. package/src/shared/domain/agents/exclusive.ts +24 -0
  314. package/src/shared/domain/agents/instances.ts +249 -0
  315. package/src/shared/domain/code-intel-contract.ts +356 -0
  316. package/src/shared/domain/code-intel-routing.ts +113 -0
  317. package/src/shared/domain/compact-outcome.ts +44 -0
  318. package/src/shared/domain/compaction-thresholds.ts +161 -0
  319. package/src/shared/domain/compaction.ts +379 -0
  320. package/src/shared/domain/config-schema.ts +421 -0
  321. package/src/shared/domain/dev/access-cost.ts +226 -0
  322. package/src/shared/domain/dev/artefacts.ts +50 -0
  323. package/src/shared/domain/dev/batches-concurrency.ts +36 -0
  324. package/src/shared/domain/dev/batches-state.ts +49 -0
  325. package/src/shared/domain/dev/build-commands.ts +44 -0
  326. package/src/shared/domain/dev/call-guard.ts +341 -0
  327. package/src/shared/domain/dev/carried-text.ts +49 -0
  328. package/src/shared/domain/dev/design-rules.ts +100 -0
  329. package/src/shared/domain/dev/learn-proposals.ts +175 -0
  330. package/src/shared/domain/dev/learn-state.ts +93 -0
  331. package/src/shared/domain/dev/path-args.ts +42 -0
  332. package/src/shared/domain/dev/path-rebase.ts +93 -0
  333. package/src/shared/domain/dev/plan-checks.ts +190 -0
  334. package/src/shared/domain/dev/plan-format.ts +180 -0
  335. package/src/shared/domain/dev/project-files.ts +43 -0
  336. package/src/shared/domain/dev/questions.ts +249 -0
  337. package/src/shared/domain/dev/reading-rule.ts +41 -0
  338. package/src/shared/domain/dev/repo-pack.ts +237 -0
  339. package/src/shared/domain/dev/review-answer.ts +150 -0
  340. package/src/shared/domain/dev/review-prompt.ts +221 -0
  341. package/src/shared/domain/dev/reviewer-charter.ts +31 -0
  342. package/src/shared/domain/dev/sheet-facts.ts +83 -0
  343. package/src/shared/domain/dev/spec-format.ts +183 -0
  344. package/src/shared/domain/dev/step-budget.ts +72 -0
  345. package/src/shared/domain/dev/step-rules.ts +110 -0
  346. package/src/shared/domain/dev/test-commands.ts +90 -0
  347. package/src/shared/domain/dev/test-output.ts +33 -0
  348. package/src/shared/domain/dev/test-paths.ts +40 -0
  349. package/src/shared/domain/dev/tool-guards.ts +64 -0
  350. package/src/shared/domain/dev/trait-pattern.ts +83 -0
  351. package/src/shared/domain/dev/verdict-format.ts +169 -0
  352. package/src/shared/domain/dev/whitespace.ts +34 -0
  353. package/src/shared/domain/dev/work-folder.ts +67 -0
  354. package/src/shared/domain/dev/yaml-subset.ts +403 -0
  355. package/src/shared/domain/git/close.ts +273 -0
  356. package/src/shared/domain/git/pull-request.ts +96 -0
  357. package/src/shared/domain/git/worktree.ts +46 -0
  358. package/src/shared/domain/index-languages.ts +16 -0
  359. package/src/shared/domain/instructions-file.ts +18 -0
  360. package/src/shared/domain/iso-day.ts +4 -0
  361. package/src/shared/domain/llm-failure.ts +106 -0
  362. package/src/shared/domain/llm-profile.ts +25 -0
  363. package/src/shared/domain/marked-message.ts +33 -0
  364. package/src/shared/domain/model-catalog.ts +86 -0
  365. package/src/shared/domain/permission-modes.ts +103 -0
  366. package/src/shared/domain/prelude.ts +92 -0
  367. package/src/shared/domain/project-manifests.ts +83 -0
  368. package/src/shared/domain/search-routing.ts +85 -0
  369. package/src/shared/domain/secret-patterns.ts +45 -0
  370. package/src/shared/domain/session-keys.ts +85 -0
  371. package/src/shared/domain/session-start.ts +60 -0
  372. package/src/shared/domain/session-summary.ts +13 -0
  373. package/src/shared/domain/severity.ts +72 -0
  374. package/src/shared/domain/sha1.ts +61 -0
  375. package/src/shared/domain/shared-memory/agent-memory-import.ts +143 -0
  376. package/src/shared/domain/shared-memory/candidates.ts +41 -0
  377. package/src/shared/domain/shared-memory/entry.ts +145 -0
  378. package/src/shared/domain/shared-memory/front-matter.ts +183 -0
  379. package/src/shared/domain/shared-memory/gate.ts +44 -0
  380. package/src/shared/domain/shared-memory/harvest.ts +61 -0
  381. package/src/shared/domain/shared-memory/layout.ts +187 -0
  382. package/src/shared/domain/shared-memory/precedents-block.ts +93 -0
  383. package/src/shared/domain/shared-memory/refused.ts +84 -0
  384. package/src/shared/domain/shared-memory/verdict-rows.ts +134 -0
  385. package/src/shared/domain/snip-turns.ts +45 -0
  386. package/src/shared/domain/speech.ts +20 -0
  387. package/src/shared/domain/strip.ts +88 -0
  388. package/src/shared/domain/tool-trace.ts +122 -0
  389. package/src/shared/domain/types.ts +67 -0
  390. package/src/shared/domain/verifiers.ts +37 -0
  391. package/src/shared/domain/vfs.ts +9 -0
  392. package/src/shared/domain/workflow/state-file.ts +140 -0
  393. package/src/shared/infrastructure/globals.ts +52 -0
  394. package/src/shared/infrastructure/orkeon/approvals.ts +24 -0
  395. package/src/shared/infrastructure/orkeon/child-agents.ts +127 -0
  396. package/src/shared/infrastructure/orkeon/code-index.ts +120 -0
  397. package/src/shared/infrastructure/orkeon/crew-host.ts +27 -0
  398. package/src/shared/infrastructure/orkeon/crew-memory.ts +12 -0
  399. package/src/shared/infrastructure/orkeon/dev-deps.ts +172 -0
  400. package/src/shared/infrastructure/orkeon/files.ts +40 -0
  401. package/src/shared/infrastructure/orkeon/github-pull-requests.ts +29 -0
  402. package/src/shared/infrastructure/orkeon/host-provider.ts +22 -0
  403. package/src/shared/infrastructure/orkeon/human-input.ts +59 -0
  404. package/src/shared/infrastructure/orkeon/llm-profile.ts +38 -0
  405. package/src/shared/infrastructure/orkeon/llm.ts +109 -0
  406. package/src/shared/infrastructure/orkeon/memory-store.ts +41 -0
  407. package/src/shared/infrastructure/orkeon/memory-tools.ts +131 -0
  408. package/src/shared/infrastructure/orkeon/permission-rules.ts +42 -0
  409. package/src/shared/infrastructure/orkeon/progress.ts +24 -0
  410. package/src/shared/infrastructure/orkeon/run-state.ts +17 -0
  411. package/src/shared/infrastructure/orkeon/runtime-info.ts +30 -0
  412. package/src/shared/infrastructure/orkeon/runtime-tools.ts +60 -0
  413. package/src/shared/infrastructure/orkeon/script-tools.ts +134 -0
  414. package/src/shared/infrastructure/orkeon/session-store.ts +138 -0
  415. package/src/shared/infrastructure/orkeon/session-switch.ts +23 -0
  416. package/src/shared/infrastructure/orkeon/shared-memory.ts +61 -0
  417. package/src/shared/infrastructure/orkeon/shell-jobs.ts +75 -0
  418. package/src/shared/infrastructure/orkeon/shell.ts +31 -0
  419. package/src/shared/infrastructure/orkeon/telemetry.ts +63 -0
  420. package/src/shared/infrastructure/orkeon/tool-catalogue.ts +75 -0
  421. package/src/shared/infrastructure/orkeon/tool-results.ts +120 -0
  422. package/src/shared/infrastructure/orkeon/usage.ts +74 -0
  423. package/src/shared/infrastructure/orkeon/wiring.ts +118 -0
@@ -0,0 +1,120 @@
1
+ // CodeIndex adapter over index_status, index_codebase, codebase_map,
2
+ // dependency_graph, package_summary, codebase_search, symbol_source and
3
+ // impact_analysis. The payloads are read once, here,
4
+ // through the readers of shared/domain/code-intel-contract.ts, which pin the
5
+ // field names of the live tools. The AnchorIndex adapter over batch_anchors
6
+ // reads its result through tool-results.ts; the CostIndex adapter over
7
+ // index_status, incremental_reindex and access_cost reads the report through
8
+ // shared/domain/dev/access-cost.ts, and asks affected_tests when the host has it.
9
+
10
+ import type { AnchorIndex, CodeIndex, CostIndex } from "../../application/ports.ts";
11
+ import { readAccessCostReport } from "../../domain/dev/access-cost.ts";
12
+ import { INDEXED_LANGUAGES } from "../../domain/index-languages.ts";
13
+ import type { BatchAnchorsClosureInput } from "./runtime-tools.ts";
14
+ import { asArray, pick } from "./tool-results.ts";
15
+ import {
16
+ readGraph, readImpact, readIndexSummary, readMapEntries, readMapSymbolCount, readPackageSummary,
17
+ readSearchHitsWithOrigin, readSymbolLocation,
18
+ } from "../../domain/code-intel-contract.ts";
19
+
20
+ type CodeIndexTools = "indexStatus" | "indexCodebase" | "codebaseMap" | "dependencyGraph" | "packageSummary"
21
+ | "codebaseSearch" | "symbolSource" | "impactAnalysis";
22
+
23
+ /** Lines of source `symbol_source` returns: only the first one is kept, so the payload stays small. */
24
+ const SOURCE_LINES = 20;
25
+
26
+ export function createCodeIndex(tools: Pick<OrkeonTools, CodeIndexTools>): CodeIndex {
27
+ return {
28
+ async rootCount() {
29
+ const status = (await tools.indexStatus({})) as { roots?: unknown } | null | undefined;
30
+ return Array.isArray(status?.roots) ? status.roots.length : 0;
31
+ },
32
+ async index(root, opts) {
33
+ // The languages named: every grammar of the runtime's registry (index-languages.ts); a file the runtime still
34
+ // refuses to read is skipped by the discovery, not fatal (Orkeon #215).
35
+ return readIndexSummary(await tools.indexCodebase({
36
+ root_path: root,
37
+ languages: INDEXED_LANGUAGES,
38
+ ...(opts?.parallel === undefined ? {} : { max_parallelism: opts.parallel }),
39
+ ...(opts?.rebuild === true ? { use_cache: false } : {}),
40
+ }));
41
+ },
42
+ async map(level, withMetrics, maxEntries) {
43
+ const raw = await tools.codebaseMap({
44
+ level,
45
+ ...(withMetrics ? { include_metrics: true } : {}),
46
+ ...(maxEntries === undefined ? {} : { max_entries: maxEntries }),
47
+ });
48
+ return { entries: readMapEntries(raw), symbolCount: readMapSymbolCount(raw) };
49
+ },
50
+ async dependencyGraph(scope, maxNodes) {
51
+ return readGraph(await tools.dependencyGraph({ scope, max_nodes: maxNodes, include_mermaid: false }));
52
+ },
53
+ async packageSummary(fqn) {
54
+ return readPackageSummary(await tools.packageSummary({ fqn }));
55
+ },
56
+ async search(query, topK) {
57
+ // No `mode`: the tool's default is the hybrid search.
58
+ return readSearchHitsWithOrigin(await tools.codebaseSearch({ query, top_k: topK }));
59
+ },
60
+ async symbolSource(fqn) {
61
+ return readSymbolLocation(await tools.symbolSource({ fqn, max_lines: SOURCE_LINES }), fqn);
62
+ },
63
+ async impact(target, maxDepth) {
64
+ return readImpact(await tools.impactAnalysis({ target, direction: "Backward", max_depth: maxDepth }));
65
+ },
66
+ };
67
+ }
68
+
69
+ /** The closure of `fqns` by batch_anchors: its nodes, the anchors it did not find, and whether it was cut. */
70
+ export function createAnchorIndex(tools: Pick<OrkeonTools, "batchAnchors">): AnchorIndex {
71
+ return {
72
+ async closure(fqns) {
73
+ const input: BatchAnchorsClosureInput = { action: "closure", fqns };
74
+ const raw = await tools.batchAnchors(input);
75
+ return {
76
+ nodes: asArray(pick(raw, "nodes", "Nodes")).map(String),
77
+ unresolved: asArray(pick(raw, "unresolved", "Unresolved")).map(String),
78
+ truncated: pick(raw, "truncated", "Truncated") === true,
79
+ };
80
+ },
81
+ };
82
+ }
83
+
84
+ /** The access cost of dev-verify and dev-implement: the indexed roots, the refresh of the changed files, the
85
+ * report; and the tests the graph reaches from them (affected_tests), when the tools hold it. */
86
+ export function createCostIndex(
87
+ tools: Pick<OrkeonTools, "indexStatus" | "incrementalReindex" | "accessCost"> & Partial<Pick<OrkeonTools, "affectedTests">>,
88
+ ): CostIndex {
89
+ return {
90
+ ...(tools.affectedTests === undefined ? {} : {
91
+ async affected(files: readonly string[]) {
92
+ // Called on `tools`, never detached from it.
93
+ const raw = await (tools as Pick<OrkeonTools, "affectedTests">).affectedTests({ changed_files: [...files] });
94
+ const strings = (v: unknown): string[] => asArray(v).map(String).filter((s) => s !== "");
95
+ return {
96
+ all: pick(raw, "all", "All") === true,
97
+ projects: strings(pick(raw, "test_projects", "TestProjects")),
98
+ classes: strings(pick(raw, "test_classes", "TestClasses")),
99
+ unresolved: strings(pick(raw, "unresolved", "Unresolved")),
100
+ };
101
+ },
102
+ }),
103
+ async roots() {
104
+ const status = (await tools.indexStatus({})) as { roots?: unknown } | null | undefined;
105
+ if (!Array.isArray(status?.roots)) return [];
106
+ return status.roots
107
+ .map((r) => (typeof r === "string" ? r : String(pick(r, "virtual_root", "VirtualRoot") ?? "")))
108
+ .filter((r) => r !== "");
109
+ },
110
+ async refresh(root, files) {
111
+ const result = await tools.incrementalReindex({ root_path: root, changed_files: [...files] });
112
+ return asArray(pick(result, "errors", "Errors")).map(String);
113
+ },
114
+ async accessCost(files, receivers) {
115
+ const raw = await tools.accessCost({ changed_files: [...files], ...(receivers === undefined ? {} : { receivers }) });
116
+ const report = pick(raw, "report", "Report");
117
+ return { report: report === undefined || report === null ? null : readAccessCostReport(report), errors: asArray(pick(raw, "errors", "Errors")).map(String) };
118
+ },
119
+ };
120
+ }
@@ -0,0 +1,27 @@
1
+ // CrewHost adapter over the runtime's script-host service. The service is reached
2
+ // through the command context the runtime hands each command (`ctx.services`),
3
+ // not through a global, so the adapter takes the context's service locator as a
4
+ // parameter rather than being bound in wiring.ts. A launch option (`chain: "continue"`,
5
+ // Orkeon #221) is handed to runCrewAsync as it is, and left out when the caller gives none.
6
+
7
+ import type { CrewHost } from "../../application/ports.ts";
8
+ import type { ScriptHostFacade, ServiceLocator } from "../../../commands/.orkeon/orkeon-cli.d.ts";
9
+
10
+ /** The service name; the host registers it only when it can run crews. */
11
+ const SCRIPT_HOST = "script-host";
12
+
13
+ export function createCrewHost(services: Pick<ServiceLocator, "get">): CrewHost {
14
+ const host = () => services.get<ScriptHostFacade | null | undefined>(SCRIPT_HOST);
15
+ return {
16
+ listCrews() {
17
+ try {
18
+ return [...(host()?.listCrews?.() ?? [])];
19
+ } catch {
20
+ return [];
21
+ }
22
+ },
23
+ launch(name, input, options) {
24
+ return options === undefined ? host()!.runCrewAsync(name, input) : host()!.runCrewAsync(name, input, options);
25
+ },
26
+ };
27
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference path="../../../crews/.orkeon/orkeon.d.ts" />
2
+ // CrewMemory adapter over the running agent's crew-scoped memory
3
+ // (`ctx.memory.crew`). Like the state, it belongs to the context each agent body
4
+ // receives, so the entry point builds it (`createCrewMemory(ctx)`).
5
+
6
+ import type { CrewMemory } from "../../application/ports.ts";
7
+
8
+ export function createCrewMemory(ctx: Pick<AgentContext, "memory">): CrewMemory {
9
+ return {
10
+ store: (key, value) => ctx.memory.crew.store(key, value),
11
+ };
12
+ }
@@ -0,0 +1,172 @@
1
+ /// <reference path="../../../crews/.orkeon/orkeon.d.ts" />
2
+ // The ports of dev-implement's and dev-verify's use cases, built from the agent body that runs them: its own
3
+ // `ctx.tools`, `ctx.llm` and `ctx.log`. The crews' bodies use them, and so does a parallel /dev-batches' batch
4
+ // agent, beside others under their own working roots - where the global `tools` refuses a call from code
5
+ // (temp/26 L8P-D3). Given a root (the batch's worktree), the ports keep naming the checkout `/workspace` and map
6
+ // it onto the root (path-rebase.ts): the files, the shell and its jobs, the config, the act's callbacks (a call's
7
+ // paths back to `/workspace` before the rules see them) and the model's briefs (prompts and system texts out with
8
+ // the root's paths). The cost index is left out under a root: it indexes the main checkout. A spend, given, bounds
9
+ // the batch's tool calls: the runtime gives a delegated agent no budget (L8P-D12).
10
+
11
+ import type { ActRequest, CompleteRequest, Llm, Logger } from "../../application/ports.ts";
12
+ import type { WorkFolder } from "../../application/dev/resolve-work-folder.ts";
13
+ import { stepPrecedents } from "../../application/dev/step-precedents.ts";
14
+ import { harvestAfterGaps } from "../../application/shared-memory/harvest-after-gaps.ts";
15
+ import { memoryDirOf } from "../../application/shared-memory/memory-settings.ts";
16
+ import { briefToRoot, mapStrings } from "../../domain/dev/path-rebase.ts";
17
+ import { parseSessionRules } from "../../domain/git/pull-request.ts";
18
+ import type { DevImplementDeps } from "../../../crews/dev-implement/application/run-dev-implement.ts";
19
+ import type { DevVerifyDeps } from "../../../crews/dev-verify/application/run-dev-verify.ts";
20
+ import { reportingWrites } from "../../../crews/dev-implement/application/report-writes.ts";
21
+ import { AUDITOR_CHARTER } from "../../../crews/dev-verify/domain/auditor-charter.ts";
22
+ import { charterCatalogue } from "../../domain/agents/charter.ts";
23
+ import { createLlm } from "./llm.ts";
24
+ import { memoryReadTools, memoryRecallTools } from "./memory-tools.ts";
25
+ import type { MemoryToolPorts } from "./memory-tools.ts";
26
+ import { RUN_VALIDATION, runBuildTool, runTestsTool, runValidationTool, scriptToolSlot } from "./script-tools.ts";
27
+ import type { ScriptToolSlot, ToolBuilderFactory, ValidationCalls } from "./script-tools.ts";
28
+ import type { WrappedTools } from "../../application/dev/wrapped-tools.ts";
29
+ import { shCode, shOut } from "./tool-results.ts";
30
+ import { devToolCallbacks, rootedCallbacks } from "../../application/dev/tool-callbacks.ts";
31
+ import type { ToolCallbacks } from "../../application/dev/tool-callbacks.ts";
32
+ import { createSpend, spendGuard } from "../../application/dev/spend.ts";
33
+ import type { Spend } from "../../application/dev/spend.ts";
34
+ import {
35
+ orkeonClock, orkeonConfigStore, orkeonCostIndex, orkeonFiles, orkeonMemoryToolPorts, orkeonPullRequestOpener,
36
+ orkeonSharedMemory, orkeonShell, orkeonShellJobs,
37
+ } from "./wiring.ts";
38
+
39
+ /** What an agent body hands its deps: its own tools, model and log. */
40
+ export interface BodyContext {
41
+ tools: OrkeonTools;
42
+ llm: Pick<LlmFacade, "act" | "complete" | "extract" | "chat"> & Partial<Pick<LlmFacade, "permissionGate">>;
43
+ log: Logger;
44
+ }
45
+
46
+ /** `llm` with the `/workspace` paths its prompts and system texts name on the root; `llm` itself without one. */
47
+ export function rootedLlm(llm: Llm, root: string | undefined): Llm {
48
+ if (root === undefined || root === "") return llm;
49
+ // A brief's own paths only: what it quotes of the files (a constant, a fenced diff) stays as the files hold it.
50
+ const out = (text: string) => briefToRoot(text, root);
51
+ return {
52
+ ...llm,
53
+ act: (prompt: string, request: ActRequest) => llm.act(out(prompt), mapStrings(request, out)),
54
+ complete: (prompt: string, request?: CompleteRequest) => llm.complete(out(prompt), request === undefined ? request : mapStrings(request, out)),
55
+ extract: (prompt: string, schema: object) => llm.extract(out(prompt), schema),
56
+ };
57
+ }
58
+
59
+ /** The tools of the agent body that runs, for the script tools built with its agent before any body runs. */
60
+ export function agentTools(): { bind(tools: OrkeonTools): void; memoryPorts(root?: string): () => MemoryToolPorts } {
61
+ let bound: OrkeonTools | undefined;
62
+ return {
63
+ bind: (tools) => { bound = tools; },
64
+ // Unbound (a host that calls the tool before the body), the global: the crews' own single agent.
65
+ memoryPorts: (root) => () => orkeonMemoryToolPorts(bound, root),
66
+ };
67
+ }
68
+
69
+ /** What one batch agent of a parallel /dev-batches is built with: its own script-tool slots, spend and body tools,
70
+ * never shared with another batch agent, and the script tools bound to them (rooted on its worktree). */
71
+ export interface BatchAgentParts {
72
+ spend: Spend;
73
+ toolSlot: ScriptToolSlot<WrappedTools>;
74
+ validationSlot: ScriptToolSlot<ValidationCalls>;
75
+ bodyTools: ReturnType<typeof agentTools>;
76
+ tools: Array<Tool<unknown, unknown>>;
77
+ }
78
+
79
+ export function batchAgentParts(builder: ToolBuilderFactory, opts: { root: string; toolCalls: number; memoryOn: boolean }): BatchAgentParts {
80
+ const spend = createSpend(opts.toolCalls);
81
+ const toolSlot = scriptToolSlot<WrappedTools>();
82
+ const validationSlot = scriptToolSlot<ValidationCalls>();
83
+ const bodyTools = agentTools();
84
+ const tools = [
85
+ runTestsTool(builder, toolSlot, opts.root), runBuildTool(builder, toolSlot, opts.root), runValidationTool(builder, validationSlot, opts.root),
86
+ ...memoryRecallTools(builder, bodyTools.memoryPorts(opts.root), opts.memoryOn, opts.root),
87
+ ];
88
+ return { spend, toolSlot, validationSlot, bodyTools, tools };
89
+ }
90
+
91
+ /** git's top as an agent under `root` sees it: the raw output, never mapped back to `/workspace`, so that a
92
+ * top other than the root shows (a parallel /dev-batches' probe, L8P-D11). A refused call throws. */
93
+ export async function gitTopUnder(tools: Pick<OrkeonTools, "shellCommand">, root: string): Promise<{ exitCode: number; top: string }> {
94
+ const r = await tools.shellCommand({ command: "git rev-parse --show-toplevel", working_directory: root });
95
+ return { exitCode: shCode(r), top: shOut(r).trim() };
96
+ }
97
+
98
+ interface DevOptions {
99
+ /** The /hooks registry the command passed. */
100
+ hooks: unknown;
101
+ effort: ActRequest["effort"] | undefined;
102
+ /** memory_recall is attached (no session rule denies it). */
103
+ memoryOn: boolean;
104
+ /** The batch's worktree, a parallel /dev-batches' working root; none: the checkout itself. */
105
+ root?: string;
106
+ spend?: Spend;
107
+ }
108
+
109
+ function portsOf(ctx: BodyContext, root: string | undefined) {
110
+ return {
111
+ shell: orkeonShell(ctx.tools, root), files: orkeonFiles(ctx.tools, root), config: orkeonConfigStore(ctx.tools, root),
112
+ };
113
+ }
114
+
115
+ /** dev-implement's deps over the body's context. */
116
+ export function implementDeps(
117
+ ctx: BodyContext, opts: DevOptions & { toolSlot: DevImplementDeps["toolSlot"] },
118
+ ): DevImplementDeps {
119
+ const ports = portsOf(ctx, opts.root);
120
+ const callbacks = (spec: Parameters<typeof devToolCallbacks>[0], wrote: (path: string) => void) =>
121
+ spendGuard(rootedCallbacks(reportingWrites(devToolCallbacks(spec, { shell: ports.shell, log: ctx.log, files: ports.files, memoryDir: memoryDirOf(ports.config) }), wrote), opts.root), opts.spend);
122
+ return {
123
+ ...ports, jobs: orkeonShellJobs(ctx.tools, opts.root), log: ctx.log, clock: orkeonClock(),
124
+ ...(opts.toolSlot !== undefined ? { toolSlot: opts.toolSlot } : {}),
125
+ ...(opts.root === undefined ? { costIndex: orkeonCostIndex(ctx.tools) } : {}),
126
+ precedents: stepPrecedents({ ...ports, memory: orkeonSharedMemory(ctx.tools), log: ctx.log }, { on: opts.memoryOn }),
127
+ // The close's opener, for the context read at the launch (the chained close reads it from the batch record).
128
+ openerFor: (pr) => orkeonPullRequestOpener({ mode: pr.permissionMode, rules: parseSessionRules(pr.permissionRules), asked: false }, ctx.tools),
129
+ // Each role's act runs under its own callbacks: the host's gate first, then the step's rule sets, the role's
130
+ // roots and the /hooks the command passed. `wrote` hears each write those callbacks let through; `writable`:
131
+ // the test author's stubs, which its own root denies leave open; `files`: the rewrite rule reads a write's path.
132
+ roleLlm: (role, layout, wrote, writable) => rootedLlm(createLlm(ctx.llm, callbacks(
133
+ { step: "dev-implement", role, layout, writable, hooks: opts.hooks, readTools: memoryReadTools(opts.memoryOn) }, wrote,
134
+ ), { effort: opts.effort }), opts.root),
135
+ };
136
+ }
137
+
138
+ /** dev-verify's callbacks over the body's context: the step's rule sets again and the /hooks the command passed;
139
+ * run_validation and memory_recall, declared `read`, let through on a host without a gate. */
140
+ export function verifyCallbacks(ctx: Pick<BodyContext, "tools" | "log">, opts: DevOptions): ToolCallbacks {
141
+ const ports = portsOf({ ...ctx, llm: undefined as never }, opts.root);
142
+ return spendGuard(rootedCallbacks(devToolCallbacks(
143
+ { step: "dev-verify", hooks: opts.hooks, readTools: [RUN_VALIDATION.name, ...memoryReadTools(opts.memoryOn)] },
144
+ { shell: ports.shell, log: ctx.log, memoryDir: memoryDirOf(ports.config) },
145
+ ), opts.root), opts.spend);
146
+ }
147
+
148
+ /** dev-verify's deps over the body's context. The audit acts on the plain Llm (inline) unless `wrapLlm` hands it
149
+ * to a background child (the crew's); the harvest after GAPS runs only when asked (never in a batch: the driver's). */
150
+ export function verifyDeps(
151
+ ctx: BodyContext,
152
+ opts: DevOptions & { validationSlot: DevVerifyDeps["validationSlot"]; wrapLlm?: (llm: Llm) => Llm; harvest?: boolean },
153
+ ): DevVerifyDeps {
154
+ const ports = portsOf(ctx, opts.root);
155
+ const clock = orkeonClock();
156
+ // The audit's act is offered the auditor's tools alone: a batch agent also holds the implementer's, which an act
157
+ // without a subset would offer too - write tools to a read-only auditor, their schemas resent at every turn.
158
+ const auditorTools = [...charterCatalogue(AUDITOR_CHARTER), RUN_VALIDATION.name, ...memoryReadTools(opts.memoryOn)];
159
+ const rooted = rootedLlm(createLlm(ctx.llm, verifyCallbacks(ctx, opts), { effort: opts.effort }), opts.root);
160
+ const plain: Llm = { ...rooted, act: (prompt, request = {}) => rooted.act(prompt, request.tools === undefined ? { ...request, tools: auditorTools } : request) };
161
+ return {
162
+ ...ports, log: ctx.log, clock, llm: opts.wrapLlm === undefined ? plain : opts.wrapLlm(plain),
163
+ ...(opts.validationSlot !== undefined ? { validationSlot: opts.validationSlot } : {}),
164
+ ...(opts.root === undefined ? { costIndex: orkeonCostIndex(ctx.tools) } : {}),
165
+ // T4: the shared memory's precedents in the auditor's brief, unless memory_recall is denied.
166
+ precedents: stepPrecedents({ ...ports, memory: orkeonSharedMemory(ctx.tools), log: ctx.log }, { on: opts.memoryOn }),
167
+ // M-7: after a GAPS verdict, the mistakes that recur become candidates.
168
+ ...(opts.harvest === true
169
+ ? { harvest: (work: Pick<WorkFolder, "folder" | "vfsPath">) => harvestAfterGaps({ ...ports, clock, log: ctx.log }, work) }
170
+ : {}),
171
+ };
172
+ }
@@ -0,0 +1,40 @@
1
+ // Files adapter over file_read, file_write, directory_read and list_mounts. A
2
+ // failed read is rethrown with the tool's own message, the runtime's wrapping gone
3
+ // (withToolMessage): callers tell an absent file from an unreadable one by it. Given a batch's working root, each
4
+ // `/workspace` path is read and written under it (shared/domain/dev/path-rebase.ts).
5
+
6
+ import type { Files } from "../../application/ports.ts";
7
+ import { toRoot } from "../../domain/dev/path-rebase.ts";
8
+ import { entryNames, fileContent, pick, withToolMessage } from "./tool-results.ts";
9
+
10
+ export function createFiles(
11
+ tools: Pick<OrkeonTools, "fileRead" | "fileWrite" | "directoryRead" | "listMounts">,
12
+ root?: string,
13
+ ): Files {
14
+ return {
15
+ async read(logical, maxLength) {
16
+ const path = toRoot(logical, root);
17
+ const input = maxLength === undefined ? { path } : { path, max_length: maxLength };
18
+ return fileContent(await withToolMessage(() => tools.fileRead(input)));
19
+ },
20
+ async write(path, content) {
21
+ await tools.fileWrite({ path: toRoot(path, root), content });
22
+ },
23
+ async list(logical, maxEntries) {
24
+ const path = toRoot(logical, root);
25
+ // DirectoryReadRequest.MaxResults, bound through the tools' snake_case naming
26
+ // (as file_read's MaxLength is `max_length`); an unknown field is ignored.
27
+ return entryNames(await tools.directoryRead({ path, max_results: maxEntries }));
28
+ },
29
+ async mounts() {
30
+ const list: any[] = pick(await tools.listMounts(), "mounts") ?? [];
31
+ // `{ mounts: [{ virtual_path, access, overrides }] }`, as the typings of the
32
+ // runtime declare it (tools.generated.d.ts, `listMounts`); `access` is `ro`, `rw`
33
+ // or `rwnd`, else the rights enum's own name.
34
+ return list.map((m) => ({
35
+ path: String(m.virtual_path ?? ""),
36
+ rights: m.access == null ? undefined : String(m.access),
37
+ }));
38
+ },
39
+ };
40
+ }
@@ -0,0 +1,29 @@
1
+ // GitHubPullRequests adapter over the runtime's `github` tool, action
2
+ // `create_pr`. The tool answers a failure as `success: false` with `error`
3
+ // (an HTTP refusal included), not a throw: this turns it into one, GitHub's
4
+ // first line as its message. The url is the pull request's page (`html_url`,
5
+ // read as `url`); without one, its number.
6
+
7
+ import type { GitHubPullRequests } from "../../application/git/open-pull-request.ts";
8
+ import { asArray, pick } from "./tool-results.ts";
9
+
10
+ function firstLine(text: unknown): string {
11
+ return String(text ?? "").split("\n").map((l) => l.trim()).find((l) => l.length > 0) ?? "";
12
+ }
13
+
14
+ export function createGitHubPullRequests(tools: Pick<OrkeonTools, "github">): GitHubPullRequests {
15
+ return {
16
+ async create(args) {
17
+ const r = await tools.github(args);
18
+ if (pick(r, "success", "Success") !== true) {
19
+ throw new Error(firstLine(pick(r, "error", "Error")) || "the github tool reported a failure without a reason");
20
+ }
21
+ const item = asArray(pick(r, "items", "Items"))[0];
22
+ const url = String(pick(item, "url", "Url") ?? "").trim();
23
+ if (url.length > 0) return { url };
24
+ const number = pick(item, "number", "Number");
25
+ if (number == null) throw new Error("the github tool answered success without the pull request");
26
+ return { url: `#${number}` };
27
+ },
28
+ };
29
+ }
@@ -0,0 +1,22 @@
1
+ // The name of the host's LLM provider, read from the command context's `llm`
2
+ // service (the host's ILlmProvider, optional: a host may wire none). Jint keeps
3
+ // the CLR member names, so the name is `Name`; `name` is read too. Like the
4
+ // script-host, the service comes from the context each command receives, so the
5
+ // reader takes the service locator as a parameter. Nothing here is offered to
6
+ // the model.
7
+
8
+ import type { ServiceLocator } from "../../../commands/.orkeon/orkeon-cli.d.ts";
9
+ import { pick } from "./tool-results.ts";
10
+
11
+ const LLM = "llm";
12
+
13
+ /** The provider's name (`deepseek`, `anthropic`, `OpenAI`...), undefined when the host wires none or the read fails. */
14
+ export function readHostProvider(services: Pick<ServiceLocator, "get" | "has">): string | undefined {
15
+ try {
16
+ if (!services.has(LLM)) return undefined;
17
+ const name = String(pick(services.get<unknown>(LLM), "Name", "name") ?? "").trim();
18
+ return name.length > 0 ? name : undefined;
19
+ } catch {
20
+ return undefined;
21
+ }
22
+ }
@@ -0,0 +1,59 @@
1
+ // HumanInput adapter: human_input (RT-08) as the dev steps ask it. No answer is ever made on the person's behalf:
2
+ // every `choice` and `text` carries a default value no option holds, so whichever unattended provider answers (the
3
+ // auto-approver returns the default, the observed runner returns it when nobody replies) is read as "nobody
4
+ // answered", `was_default` or not; a `multi` gets no recommended option and a first option meaning "decide later",
5
+ // which the auto-approver picks and nobody else needs to. A host without the tool, or a call that throws, is
6
+ // nobody answering too. In the REPL an empty answer to a `choice` takes the recommended option (the person pressed
7
+ // Enter); an empty `text` is no answer.
8
+ import type { HumanInput } from "../../application/ports.ts";
9
+ import { pick } from "./tool-results.ts";
10
+
11
+ /** The default value no option holds: an answer equal to it came from no person. */
12
+ export const NO_ANSWER = "(no answer)";
13
+ /** The first option of a `multi`: picked by the auto-approver, it decides nothing. */
14
+ export const DECIDE_LATER = "Decide later";
15
+
16
+ type HumanInputTools = Partial<Pick<OrkeonTools, "humanInput">>;
17
+ const NOBODY = { answered: false } as const;
18
+
19
+ function textOf(value: unknown): string {
20
+ return typeof value === "string" ? value : "";
21
+ }
22
+
23
+ function valuesOf(value: unknown): string[] {
24
+ return Array.isArray(value) ? value.filter((v): v is string => typeof v === "string") : [];
25
+ }
26
+
27
+ export function createHumanInput(tools: HumanInputTools): HumanInput {
28
+ const ask = async (input: Parameters<OrkeonTools["humanInput"]>[0]): Promise<unknown> => {
29
+ if (typeof tools.humanInput !== "function") return null;
30
+ try {
31
+ return await tools.humanInput(input);
32
+ } catch {
33
+ return null;
34
+ }
35
+ };
36
+ return {
37
+ async choice(prompt, options) {
38
+ const r = await ask({ prompt, input_type: "choice", choices: [...options], recommended: 0, default_value: NO_ANSWER });
39
+ if (r === null) return NOBODY;
40
+ const value = textOf(pick(r, "response", "Response"));
41
+ if (pick(r, "was_default", "WasDefault") === true || value === NO_ANSWER || !options.includes(value)) return NOBODY;
42
+ return { answered: true, value };
43
+ },
44
+ async text(prompt) {
45
+ const r = await ask({ prompt, input_type: "text", default_value: NO_ANSWER });
46
+ if (r === null) return NOBODY;
47
+ const value = textOf(pick(r, "response", "Response")).trim();
48
+ if (pick(r, "was_default", "WasDefault") === true || value === NO_ANSWER || value === "") return NOBODY;
49
+ return { answered: true, value };
50
+ },
51
+ async multi(prompt, options) {
52
+ const r = await ask({ prompt, input_type: "multi", choices: [DECIDE_LATER, ...options] });
53
+ if (r === null) return NOBODY;
54
+ const picked = valuesOf(pick(r, "values", "Values"));
55
+ if (picked.length === 0 || picked.includes(DECIDE_LATER)) return NOBODY;
56
+ return { answered: true, values: options.filter((o) => picked.includes(o)) };
57
+ },
58
+ };
59
+ }
@@ -0,0 +1,38 @@
1
+ // An agent builder on the host profile the crew input names: `llmProfile`, the session's `llm.profile` the
2
+ // command read (shared/domain/llm-profile.ts). Every composition root starts its agents at wiring.ts
3
+ // orkeonAgent(), which hands this the runtime's factories, child agents included: one session key moves every
4
+ // agent of every crew onto a decision profile (Jev in front of an LLM profile) or another LLM profile. An input
5
+ // naming none gives the plain builder, on the host's default model. A name the host does not declare throws at
6
+ // the crew's load, as `llm.profile` does, listing the profiles the host knows. Every agent asks the provider to cache
7
+ // its system prompt and its tool definitions (Orkeon #254): the prompts are assembled so that this prefix stays
8
+ // byte-identical turn after turn. Only a provider whose cache is explicit (Anthropic) needs the request; the others
9
+ // cache by their own rules. A runtime before Orkeon #256 (the rc.6 release, the tool and docker modes) has no `cache`
10
+ // on its builder: the agent is then built without the request rather than failing at the crew's load. The same
11
+ // absence tells a runtime whose act() does not read `context` (Orkeon #277, after #256): the main loop's adapter then
12
+ // sends the context in front of the request rather than have it dropped.
13
+
14
+ import { llmProfileOf } from "../../domain/llm-profile.ts";
15
+
16
+ /** What building a profiled agent needs of the runtime: the agent builder and `llm.profile`, absent where the host declares no `llm`. */
17
+ export interface AgentFactories {
18
+ agent: () => any;
19
+ profile: ((name: string) => LlmConfig) | undefined;
20
+ }
21
+
22
+ /** The prompt cache every agent requests: the system prompt and the tools, for the vendor's default lifetime. */
23
+ export const PROMPT_CACHE: LlmCacheOptions = { systemPrompt: true, tools: true };
24
+
25
+ /** Whether the runtime's act() reads `context`: the builder has `.cache`, which the rc.6 release (before #256, so before
26
+ * #277) lacks. A source checkout between #256 and #277 answers true; the launcher moves such a checkout to the pin. */
27
+ export function runtimeTakesActContext(factories: Pick<AgentFactories, "agent">): boolean {
28
+ return typeof factories.agent().cache === "function";
29
+ }
30
+
31
+ export function profiledAgent(input: Readonly<Record<string, unknown>>, factories: AgentFactories): any {
32
+ const plain = factories.agent();
33
+ const builder = typeof plain.cache === "function" ? plain.cache(PROMPT_CACHE) : plain;
34
+ const name = llmProfileOf(input);
35
+ if (name === null) return builder;
36
+ if (factories.profile === undefined) throw new Error(`llm.profile '${name}': this host declares no llm namespace, no profile can be applied`);
37
+ return builder.llm(factories.profile(name));
38
+ }
@@ -0,0 +1,109 @@
1
+ /// <reference path="../../../crews/.orkeon/orkeon.d.ts" />
2
+ // Llm adapter over the running agent's `ctx.llm` facade. The facade belongs to
3
+ // the context the runtime hands each agent body, not to a global, so the entry
4
+ // point passes it in (`createLlm(ctx.llm)`) rather than wiring.ts binding it.
5
+ // This is the one place that turns the port's settings into the runtime's call
6
+ // options, and the one place that reads an act() result. A call the provider
7
+ // failed comes back as the host's failure marker: it is thrown as an LlmFailure,
8
+ // never returned as an answer. An act whose token budget ran out resolves with
9
+ // `budgetExhausted: true` and the wrap-up the model made without tools (Orkeon #218):
10
+ // it is thrown as a BudgetExhaustedAnswer carrying that answer, never returned, so the
11
+ // port's `act` keeps resolving to a finished answer alone, every caller that reads a
12
+ // spent budget off a rejection (runSubAgent, the dev roles, the auditor) keeps doing
13
+ // so under the `tokens` dimension, and the one caller that shows the wrap-up (the
14
+ // main loop) reads it off the error. A crew that guards its tool calls hands its callbacks
15
+ // (shared/application/dev/tool-callbacks.ts) as the second argument: each act then carries the
16
+ // onToolCall/onToolResult built for its own mode. The request's `effort` is the runtime's
17
+ // `act({effort})` as it is; the crew's own level, when it has one, fills a request that names none.
18
+ // The request's `context` is the runtime's `act({context})` (Orkeon #276); a runtime that does not read
19
+ // that option (the rc.6 release, the tool and docker modes) would drop it without a word, so there the
20
+ // context is put back in front of the prompt, in one message, as it was before.
21
+
22
+ import type { ActRequest, CompleteRequest, Llm, ModelOverride } from "../../application/ports.ts";
23
+ import type { PermissionMode } from "../../domain/permission-modes.ts";
24
+ import { budgetExhaustedAnswer, llmFailureOf } from "../../domain/llm-failure.ts";
25
+ import type { ToolCallbacks } from "../../application/dev/tool-callbacks.ts";
26
+
27
+ /** The request as the callers fill it: its mode is one of PERMISSION_MODES, the
28
+ * five modes ActOptions names (`dontAsk` among them since Orkeon 1.0.0-rc.6). */
29
+ type ModeActRequest = Omit<ActRequest, "permissionMode"> & { permissionMode?: PermissionMode };
30
+
31
+ /** The runtime's per-call options for a model override; none without one. */
32
+ function callOptions(override: ModelOverride | undefined): LlmCallOptions | undefined {
33
+ return override?.model ? { llm: { model: override.model } } : undefined;
34
+ }
35
+
36
+ /** The runtime's act() options: the request as given (its `tools` subset copied), its model as the `llm` patch, and the crew's callbacks for
37
+ * the act's mode (`default` when the request names none, as the runtime reads it). */
38
+ function actOptions(request: ActRequest, callbacks: Pick<ToolCallbacks, "forAct"> | undefined, gateEnabled: boolean | undefined): ActOptions {
39
+ const { model, tools, ...given } = request as ModeActRequest;
40
+ const rest = tools === undefined ? given : { ...given, tools: [...tools] };
41
+ const options: ActOptions = model ? { ...rest, llm: { model } } : rest;
42
+ return callbacks === undefined
43
+ ? options
44
+ : { ...options, ...callbacks.forAct(request.permissionMode ?? "default", gateEnabled) };
45
+ }
46
+
47
+ /** The answer text of an act() result: its `output`; the result itself when it
48
+ * carries none (a host resolving to a bare string); empty when nothing came back.
49
+ * A result flagged `budgetExhausted` is thrown with its output as a BudgetExhaustedAnswer. */
50
+ function answerOf(result: unknown): string {
51
+ const r = result as { output?: unknown; budgetExhausted?: unknown } | null | undefined;
52
+ const text = String(r?.output ?? r ?? "");
53
+ if (r?.budgetExhausted === true) throw budgetExhaustedAnswer(text);
54
+ return text;
55
+ }
56
+
57
+ /** The model's text; the failure it stands for, thrown, when it is the host's marker. */
58
+ function answerOrThrow(text: string): string {
59
+ const failure = llmFailureOf(text);
60
+ if (failure) throw failure;
61
+ return text;
62
+ }
63
+
64
+ /** What the adapter adds to every act: the crew's effort, and whether the runtime reads `act({context})`. */
65
+ export interface LlmDefaults extends Pick<ActRequest, "effort"> {
66
+ /** False on a runtime before Orkeon #277: the context goes in front of the prompt. True when absent. */
67
+ contextApart?: boolean;
68
+ }
69
+
70
+ /** The prompt and request the runtime receives: the context apart when it reads it, else in front of the prompt. */
71
+ function withContext(prompt: string, request: ActRequest, contextApart: boolean): { prompt: string; request: ActRequest } {
72
+ const { context, ...rest } = request;
73
+ if (context === undefined || context.trim().length === 0) return { prompt, request: rest };
74
+ return contextApart ? { prompt, request } : { prompt: context + "\n\n" + prompt, request: rest };
75
+ }
76
+
77
+ export function createLlm(
78
+ llm: Pick<LlmFacade, "act" | "complete" | "extract" | "chat"> & Partial<Pick<LlmFacade, "permissionGate">>,
79
+ callbacks?: Pick<ToolCallbacks, "forAct">,
80
+ defaults: LlmDefaults = {},
81
+ ): Llm {
82
+ const permissionGateEnabled = (): boolean | undefined => {
83
+ // The runtime always sets it; a facade without it (a test's) cannot say.
84
+ const on = llm.permissionGate?.enabled;
85
+ return on === true || on === false ? on : undefined;
86
+ };
87
+ return {
88
+ permissionGateEnabled,
89
+ async act(prompt, request) {
90
+ // The crew's effort (/effort, handed as an input) when the request names none.
91
+ const effort = request.effort ?? defaults.effort;
92
+ const withEffort = effort === undefined ? request : { ...request, effort };
93
+ const sent = withContext(prompt, withEffort, defaults.contextApart ?? true);
94
+ return answerOrThrow(answerOf(await llm.act(sent.prompt, actOptions(sent.request, callbacks, permissionGateEnabled()))));
95
+ },
96
+ async complete(prompt, request?: CompleteRequest) {
97
+ // A system message needs the message-array call: `complete` takes a prompt only.
98
+ if (request?.system) {
99
+ const reply = await llm.chat(
100
+ [{ role: "system", content: request.system }, { role: "user", content: prompt }],
101
+ callOptions(request),
102
+ );
103
+ return answerOrThrow(String(reply?.content ?? ""));
104
+ }
105
+ return answerOrThrow(await llm.complete(prompt, callOptions(request)));
106
+ },
107
+ extract: (prompt, schema) => llm.extract<unknown>(prompt, schema as JsonSchema),
108
+ };
109
+ }