@orion-agents/orion-code 0.1.9 → 0.2.2

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 (757) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +142 -323
  3. package/README.zh-CN.md +118 -578
  4. package/dist/cli.js +65 -84
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/context-commands.d.ts.map +1 -1
  7. package/dist/commands/context-commands.js +14 -7
  8. package/dist/commands/context-commands.js.map +1 -1
  9. package/dist/commands/context-tool-command-handlers.d.ts +4 -5
  10. package/dist/commands/context-tool-command-handlers.d.ts.map +1 -1
  11. package/dist/commands/context-tool-command-handlers.js +132 -208
  12. package/dist/commands/context-tool-command-handlers.js.map +1 -1
  13. package/dist/commands/core-command-handlers.d.ts +3 -6
  14. package/dist/commands/core-command-handlers.d.ts.map +1 -1
  15. package/dist/commands/core-command-handlers.js +66 -664
  16. package/dist/commands/core-command-handlers.js.map +1 -1
  17. package/dist/commands/diagnostic-command-handlers.d.ts +1 -2
  18. package/dist/commands/diagnostic-command-handlers.d.ts.map +1 -1
  19. package/dist/commands/diagnostic-command-handlers.js +3 -17
  20. package/dist/commands/diagnostic-command-handlers.js.map +1 -1
  21. package/dist/commands/diagnostic-commands.d.ts.map +1 -1
  22. package/dist/commands/diagnostic-commands.js +0 -45
  23. package/dist/commands/diagnostic-commands.js.map +1 -1
  24. package/dist/commands/index.d.ts +1 -1
  25. package/dist/commands/index.d.ts.map +1 -1
  26. package/dist/commands/index.js +2 -7
  27. package/dist/commands/index.js.map +1 -1
  28. package/dist/commands/model-command-handlers.d.ts +1 -1
  29. package/dist/commands/model-command-handlers.js +2 -2
  30. package/dist/commands/model-command-handlers.js.map +1 -1
  31. package/dist/commands/model-commands.d.ts.map +1 -1
  32. package/dist/commands/model-commands.js +0 -11
  33. package/dist/commands/model-commands.js.map +1 -1
  34. package/dist/commands/registry.d.ts.map +1 -1
  35. package/dist/commands/registry.js +1 -139
  36. package/dist/commands/registry.js.map +1 -1
  37. package/dist/commands/session-command-handlers.d.ts +1 -1
  38. package/dist/commands/session-command-handlers.d.ts.map +1 -1
  39. package/dist/commands/session-command-handlers.js +52 -214
  40. package/dist/commands/session-command-handlers.js.map +1 -1
  41. package/dist/commands/session-commands.d.ts.map +1 -1
  42. package/dist/commands/session-commands.js +0 -48
  43. package/dist/commands/session-commands.js.map +1 -1
  44. package/dist/commands/target-command.d.ts +9 -15
  45. package/dist/commands/target-command.d.ts.map +1 -1
  46. package/dist/commands/target-command.js +16 -130
  47. package/dist/commands/target-command.js.map +1 -1
  48. package/dist/commands/tool-commands.d.ts.map +1 -1
  49. package/dist/commands/tool-commands.js +0 -10
  50. package/dist/commands/tool-commands.js.map +1 -1
  51. package/dist/commands/types.d.ts +10 -14
  52. package/dist/commands/types.d.ts.map +1 -1
  53. package/dist/commands/types.js +1 -1
  54. package/dist/commands/types.js.map +1 -1
  55. package/dist/commands/workflow-command-handlers.d.ts.map +1 -1
  56. package/dist/commands/workflow-command-handlers.js +1 -3
  57. package/dist/commands/workflow-command-handlers.js.map +1 -1
  58. package/dist/commands/workflow-commands.d.ts.map +1 -1
  59. package/dist/commands/workflow-commands.js +2 -24
  60. package/dist/commands/workflow-commands.js.map +1 -1
  61. package/dist/framework/agent-mode.d.ts +2 -3
  62. package/dist/framework/agent-mode.d.ts.map +1 -1
  63. package/dist/framework/agent-mode.js +8 -31
  64. package/dist/framework/agent-mode.js.map +1 -1
  65. package/dist/framework/index.d.ts +3 -3
  66. package/dist/framework/index.d.ts.map +1 -1
  67. package/dist/framework/index.js +6 -9
  68. package/dist/framework/index.js.map +1 -1
  69. package/dist/framework/loop-budget-contract.d.ts +20 -0
  70. package/dist/framework/loop-budget-contract.d.ts.map +1 -0
  71. package/dist/framework/loop-budget-contract.js +13 -0
  72. package/dist/framework/loop-budget-contract.js.map +1 -0
  73. package/dist/framework/prompt.d.ts.map +1 -1
  74. package/dist/framework/prompt.js +5 -4
  75. package/dist/framework/prompt.js.map +1 -1
  76. package/dist/framework/query.d.ts +45 -22
  77. package/dist/framework/query.d.ts.map +1 -1
  78. package/dist/framework/query.js +64 -52
  79. package/dist/framework/query.js.map +1 -1
  80. package/dist/framework/store.d.ts +4 -2
  81. package/dist/framework/store.d.ts.map +1 -1
  82. package/dist/framework/store.js +1 -0
  83. package/dist/framework/store.js.map +1 -1
  84. package/dist/framework/tool-call-orchestrator.d.ts +80 -0
  85. package/dist/framework/tool-call-orchestrator.d.ts.map +1 -0
  86. package/dist/framework/tool-call-orchestrator.js +192 -0
  87. package/dist/framework/tool-call-orchestrator.js.map +1 -0
  88. package/dist/framework/tool-state.d.ts +12 -11
  89. package/dist/framework/tool-state.d.ts.map +1 -1
  90. package/dist/framework/tool-state.js +36 -28
  91. package/dist/framework/tool-state.js.map +1 -1
  92. package/dist/framework/tool.d.ts +0 -9
  93. package/dist/framework/tool.d.ts.map +1 -1
  94. package/dist/framework/tool.js.map +1 -1
  95. package/dist/index.d.ts +70 -26
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js +64 -65
  98. package/dist/index.js.map +1 -1
  99. package/dist/print-ui/launch.d.ts.map +1 -1
  100. package/dist/print-ui/launch.js +9 -2
  101. package/dist/print-ui/launch.js.map +1 -1
  102. package/dist/product/paths.d.ts +7 -0
  103. package/dist/product/paths.d.ts.map +1 -1
  104. package/dist/product/paths.js +19 -0
  105. package/dist/product/paths.js.map +1 -1
  106. package/dist/runtime/agent-loop.d.ts +80 -0
  107. package/dist/runtime/agent-loop.d.ts.map +1 -0
  108. package/dist/runtime/agent-loop.js +419 -0
  109. package/dist/runtime/agent-loop.js.map +1 -0
  110. package/dist/runtime/agent-runtime-controller.d.ts +10 -57
  111. package/dist/runtime/agent-runtime-controller.d.ts.map +1 -1
  112. package/dist/runtime/agent-runtime-controller.js +270 -1216
  113. package/dist/runtime/agent-runtime-controller.js.map +1 -1
  114. package/dist/runtime/agent-runtime-protocol.d.ts +4 -5
  115. package/dist/runtime/agent-runtime-protocol.d.ts.map +1 -1
  116. package/dist/runtime/agent-runtime-protocol.js.map +1 -1
  117. package/dist/runtime/agent-runtime-runner.d.ts +36 -0
  118. package/dist/runtime/agent-runtime-runner.d.ts.map +1 -0
  119. package/dist/runtime/agent-runtime-runner.js +3 -0
  120. package/dist/runtime/agent-runtime-runner.js.map +1 -0
  121. package/dist/runtime/batch-read-service.d.ts +29 -0
  122. package/dist/runtime/batch-read-service.d.ts.map +1 -0
  123. package/dist/runtime/batch-read-service.js +212 -0
  124. package/dist/runtime/batch-read-service.js.map +1 -0
  125. package/dist/runtime/builtin-tool-provider.d.ts +30 -0
  126. package/dist/runtime/builtin-tool-provider.d.ts.map +1 -0
  127. package/dist/runtime/builtin-tool-provider.js +233 -0
  128. package/dist/runtime/builtin-tool-provider.js.map +1 -0
  129. package/dist/runtime/capabilities/compiler.d.ts +11 -0
  130. package/dist/runtime/capabilities/compiler.d.ts.map +1 -0
  131. package/dist/runtime/capabilities/compiler.js +719 -0
  132. package/dist/runtime/capabilities/compiler.js.map +1 -0
  133. package/dist/runtime/capabilities/index.d.ts +3 -0
  134. package/dist/runtime/capabilities/index.d.ts.map +1 -0
  135. package/dist/runtime/capabilities/index.js +9 -0
  136. package/dist/runtime/capabilities/index.js.map +1 -0
  137. package/dist/runtime/capabilities/types.d.ts +175 -0
  138. package/dist/runtime/capabilities/types.d.ts.map +1 -0
  139. package/dist/runtime/capabilities/types.js +3 -0
  140. package/dist/runtime/capabilities/types.js.map +1 -0
  141. package/dist/runtime/capability-receipt-journal.d.ts +29 -0
  142. package/dist/runtime/capability-receipt-journal.d.ts.map +1 -0
  143. package/dist/runtime/capability-receipt-journal.js +264 -0
  144. package/dist/runtime/capability-receipt-journal.js.map +1 -0
  145. package/dist/runtime/capability-step-factory.d.ts +73 -0
  146. package/dist/runtime/capability-step-factory.d.ts.map +1 -0
  147. package/dist/runtime/capability-step-factory.js +302 -0
  148. package/dist/runtime/capability-step-factory.js.map +1 -0
  149. package/dist/runtime/compact-transaction.d.ts +225 -0
  150. package/dist/runtime/compact-transaction.d.ts.map +1 -0
  151. package/dist/runtime/compact-transaction.js +622 -0
  152. package/dist/runtime/compact-transaction.js.map +1 -0
  153. package/dist/runtime/composer/buffer.d.ts +3 -4
  154. package/dist/runtime/composer/buffer.d.ts.map +1 -1
  155. package/dist/runtime/composer/buffer.js +3 -4
  156. package/dist/runtime/composer/buffer.js.map +1 -1
  157. package/dist/runtime/composer/grapheme.d.ts +2 -4
  158. package/dist/runtime/composer/grapheme.d.ts.map +1 -1
  159. package/dist/runtime/composer/grapheme.js +2 -4
  160. package/dist/runtime/composer/grapheme.js.map +1 -1
  161. package/dist/runtime/composer/layout.d.ts +1 -3
  162. package/dist/runtime/composer/layout.d.ts.map +1 -1
  163. package/dist/runtime/composer/layout.js +1 -3
  164. package/dist/runtime/composer/layout.js.map +1 -1
  165. package/dist/runtime/core-tools/descriptors.d.ts +17 -0
  166. package/dist/runtime/core-tools/descriptors.d.ts.map +1 -0
  167. package/dist/runtime/core-tools/descriptors.js +185 -0
  168. package/dist/runtime/core-tools/descriptors.js.map +1 -0
  169. package/dist/runtime/first-party-core-provider.d.ts +55 -0
  170. package/dist/runtime/first-party-core-provider.d.ts.map +1 -0
  171. package/dist/runtime/first-party-core-provider.js +197 -0
  172. package/dist/runtime/first-party-core-provider.js.map +1 -0
  173. package/dist/runtime/first-party-long-tail-provider.d.ts +57 -0
  174. package/dist/runtime/first-party-long-tail-provider.d.ts.map +1 -0
  175. package/dist/runtime/first-party-long-tail-provider.js +238 -0
  176. package/dist/runtime/first-party-long-tail-provider.js.map +1 -0
  177. package/dist/runtime/first-party-tool-services.d.ts +43 -0
  178. package/dist/runtime/first-party-tool-services.d.ts.map +1 -0
  179. package/dist/runtime/first-party-tool-services.js +200 -0
  180. package/dist/runtime/first-party-tool-services.js.map +1 -0
  181. package/dist/runtime/first-party-tool-universe.d.ts +14 -0
  182. package/dist/runtime/first-party-tool-universe.d.ts.map +1 -0
  183. package/dist/runtime/first-party-tool-universe.js +20 -0
  184. package/dist/runtime/first-party-tool-universe.js.map +1 -0
  185. package/dist/runtime/goal-lifecycle-v2.d.ts +63 -0
  186. package/dist/runtime/goal-lifecycle-v2.d.ts.map +1 -0
  187. package/dist/runtime/goal-lifecycle-v2.js +253 -0
  188. package/dist/runtime/goal-lifecycle-v2.js.map +1 -0
  189. package/dist/runtime/goal-runtime-coordinator.d.ts +111 -0
  190. package/dist/runtime/goal-runtime-coordinator.d.ts.map +1 -0
  191. package/dist/runtime/goal-runtime-coordinator.js +511 -0
  192. package/dist/runtime/goal-runtime-coordinator.js.map +1 -0
  193. package/dist/runtime/harness-confluence.d.ts +165 -0
  194. package/dist/runtime/harness-confluence.d.ts.map +1 -0
  195. package/dist/runtime/harness-confluence.js +807 -0
  196. package/dist/runtime/harness-confluence.js.map +1 -0
  197. package/dist/runtime/harness-eval.d.ts +96 -0
  198. package/dist/runtime/harness-eval.d.ts.map +1 -0
  199. package/dist/runtime/harness-eval.js +181 -0
  200. package/dist/runtime/harness-eval.js.map +1 -0
  201. package/dist/runtime/harness-metrics.d.ts +202 -0
  202. package/dist/runtime/harness-metrics.d.ts.map +1 -0
  203. package/dist/runtime/harness-metrics.js +415 -0
  204. package/dist/runtime/harness-metrics.js.map +1 -0
  205. package/dist/runtime/legacy-session-importer.d.ts +99 -0
  206. package/dist/runtime/legacy-session-importer.d.ts.map +1 -0
  207. package/dist/runtime/legacy-session-importer.js +455 -0
  208. package/dist/runtime/legacy-session-importer.js.map +1 -0
  209. package/dist/runtime/legacy-thread-materializer.d.ts +72 -0
  210. package/dist/runtime/legacy-thread-materializer.d.ts.map +1 -0
  211. package/dist/runtime/legacy-thread-materializer.js +553 -0
  212. package/dist/runtime/legacy-thread-materializer.js.map +1 -0
  213. package/dist/runtime/long-tail-tools/descriptors.d.ts +23 -0
  214. package/dist/runtime/long-tail-tools/descriptors.d.ts.map +1 -0
  215. package/dist/runtime/long-tail-tools/descriptors.js +423 -0
  216. package/dist/runtime/long-tail-tools/descriptors.js.map +1 -0
  217. package/dist/runtime/loop-budget.d.ts +1 -1
  218. package/dist/runtime/loop-budget.d.ts.map +1 -1
  219. package/dist/runtime/loop-budget.js +2 -2
  220. package/dist/runtime/loop-budget.js.map +1 -1
  221. package/dist/runtime/mcp/first-party-mcp-adapter.d.ts +75 -0
  222. package/dist/runtime/mcp/first-party-mcp-adapter.d.ts.map +1 -0
  223. package/dist/runtime/mcp/first-party-mcp-adapter.js +484 -0
  224. package/dist/runtime/mcp/first-party-mcp-adapter.js.map +1 -0
  225. package/dist/runtime/mcp/first-party-mcp-config.d.ts +13 -0
  226. package/dist/runtime/mcp/first-party-mcp-config.d.ts.map +1 -0
  227. package/dist/runtime/mcp/first-party-mcp-config.js +139 -0
  228. package/dist/runtime/mcp/first-party-mcp-config.js.map +1 -0
  229. package/dist/runtime/mcp/index.d.ts +5 -0
  230. package/dist/runtime/mcp/index.d.ts.map +1 -0
  231. package/dist/{skills → runtime/mcp}/index.js +3 -9
  232. package/dist/runtime/mcp/index.js.map +1 -0
  233. package/dist/runtime/mcp/lazy-mcp-runtime.d.ts +95 -0
  234. package/dist/runtime/mcp/lazy-mcp-runtime.d.ts.map +1 -0
  235. package/dist/runtime/mcp/lazy-mcp-runtime.js +854 -0
  236. package/dist/runtime/mcp/lazy-mcp-runtime.js.map +1 -0
  237. package/dist/runtime/mcp/types.d.ts +128 -0
  238. package/dist/runtime/mcp/types.d.ts.map +1 -0
  239. package/dist/runtime/mcp/types.js +5 -0
  240. package/dist/runtime/mcp/types.js.map +1 -0
  241. package/dist/runtime/orion-runtime-v1.d.ts +322 -0
  242. package/dist/runtime/orion-runtime-v1.d.ts.map +1 -0
  243. package/dist/runtime/orion-runtime-v1.js +959 -0
  244. package/dist/runtime/orion-runtime-v1.js.map +1 -0
  245. package/dist/runtime/orion-session-runner.d.ts +38 -0
  246. package/dist/runtime/orion-session-runner.d.ts.map +1 -0
  247. package/dist/runtime/orion-session-runner.js +168 -0
  248. package/dist/runtime/orion-session-runner.js.map +1 -0
  249. package/dist/runtime/product-orion-runtime.d.ts +35 -0
  250. package/dist/runtime/product-orion-runtime.d.ts.map +1 -0
  251. package/dist/runtime/product-orion-runtime.js +1047 -0
  252. package/dist/runtime/product-orion-runtime.js.map +1 -0
  253. package/dist/runtime/prompts/index.d.ts +3 -0
  254. package/dist/runtime/prompts/index.d.ts.map +1 -0
  255. package/dist/{ink-ui/types.js → runtime/prompts/index.js} +3 -2
  256. package/dist/runtime/prompts/index.js.map +1 -0
  257. package/dist/runtime/prompts/prompt-registry.d.ts +22 -0
  258. package/dist/runtime/prompts/prompt-registry.d.ts.map +1 -0
  259. package/dist/runtime/prompts/prompt-registry.js +356 -0
  260. package/dist/runtime/prompts/prompt-registry.js.map +1 -0
  261. package/dist/runtime/prompts/types.d.ts +111 -0
  262. package/dist/runtime/prompts/types.d.ts.map +1 -0
  263. package/dist/runtime/prompts/types.js +5 -0
  264. package/dist/runtime/prompts/types.js.map +1 -0
  265. package/dist/runtime/protocol/canonical.d.ts +3 -0
  266. package/dist/runtime/protocol/canonical.d.ts.map +1 -0
  267. package/dist/runtime/protocol/canonical.js +21 -0
  268. package/dist/runtime/protocol/canonical.js.map +1 -0
  269. package/dist/runtime/protocol/index.d.ts +4 -0
  270. package/dist/runtime/protocol/index.d.ts.map +1 -0
  271. package/dist/runtime/protocol/index.js +16 -0
  272. package/dist/runtime/protocol/index.js.map +1 -0
  273. package/dist/runtime/protocol/runtime-protocol-v1.d.ts +671 -0
  274. package/dist/runtime/protocol/runtime-protocol-v1.d.ts.map +1 -0
  275. package/dist/runtime/protocol/runtime-protocol-v1.js +557 -0
  276. package/dist/runtime/protocol/runtime-protocol-v1.js.map +1 -0
  277. package/dist/runtime/release-receipts.d.ts +110 -0
  278. package/dist/runtime/release-receipts.d.ts.map +1 -0
  279. package/dist/runtime/release-receipts.js +305 -0
  280. package/dist/runtime/release-receipts.js.map +1 -0
  281. package/dist/runtime/resource-scope.d.ts +123 -0
  282. package/dist/runtime/resource-scope.d.ts.map +1 -0
  283. package/dist/runtime/resource-scope.js +363 -0
  284. package/dist/runtime/resource-scope.js.map +1 -0
  285. package/dist/runtime/runtime-event-buffer.d.ts +78 -0
  286. package/dist/runtime/runtime-event-buffer.d.ts.map +1 -0
  287. package/dist/runtime/runtime-event-buffer.js +237 -0
  288. package/dist/runtime/runtime-event-buffer.js.map +1 -0
  289. package/dist/runtime/runtime-services.d.ts +87 -0
  290. package/dist/runtime/runtime-services.d.ts.map +1 -0
  291. package/dist/runtime/runtime-services.js +180 -0
  292. package/dist/runtime/runtime-services.js.map +1 -0
  293. package/dist/runtime/session-history-recovery.d.ts +19 -0
  294. package/dist/runtime/session-history-recovery.d.ts.map +1 -0
  295. package/dist/runtime/session-history-recovery.js +45 -0
  296. package/dist/runtime/session-history-recovery.js.map +1 -0
  297. package/dist/runtime/skills/bounded-lru-cache.d.ts +34 -0
  298. package/dist/runtime/skills/bounded-lru-cache.d.ts.map +1 -0
  299. package/dist/runtime/skills/bounded-lru-cache.js +100 -0
  300. package/dist/runtime/skills/bounded-lru-cache.js.map +1 -0
  301. package/dist/runtime/skills/filesystem-skill-provider.d.ts +96 -0
  302. package/dist/runtime/skills/filesystem-skill-provider.d.ts.map +1 -0
  303. package/dist/runtime/skills/filesystem-skill-provider.js +829 -0
  304. package/dist/runtime/skills/filesystem-skill-provider.js.map +1 -0
  305. package/dist/runtime/skills/index.d.ts +5 -0
  306. package/dist/runtime/skills/index.d.ts.map +1 -0
  307. package/dist/{ink-ui/controllers/chat-controller.js → runtime/skills/index.js} +5 -2
  308. package/dist/runtime/skills/index.js.map +1 -0
  309. package/dist/runtime/skills/lazy-skill-runtime.d.ts +77 -0
  310. package/dist/runtime/skills/lazy-skill-runtime.d.ts.map +1 -0
  311. package/dist/runtime/skills/lazy-skill-runtime.js +673 -0
  312. package/dist/runtime/skills/lazy-skill-runtime.js.map +1 -0
  313. package/dist/runtime/skills/types.d.ts +137 -0
  314. package/dist/runtime/skills/types.d.ts.map +1 -0
  315. package/dist/runtime/skills/types.js +13 -0
  316. package/dist/runtime/skills/types.js.map +1 -0
  317. package/dist/runtime/step-snapshot.d.ts +183 -0
  318. package/dist/runtime/step-snapshot.d.ts.map +1 -0
  319. package/dist/runtime/step-snapshot.js +286 -0
  320. package/dist/runtime/step-snapshot.js.map +1 -0
  321. package/dist/runtime/subagent-thread-runtime.d.ts +239 -0
  322. package/dist/runtime/subagent-thread-runtime.d.ts.map +1 -0
  323. package/dist/runtime/subagent-thread-runtime.js +876 -0
  324. package/dist/runtime/subagent-thread-runtime.js.map +1 -0
  325. package/dist/runtime/subagents/index.d.ts +4 -1
  326. package/dist/runtime/subagents/index.d.ts.map +1 -1
  327. package/dist/runtime/subagents/index.js +10 -2
  328. package/dist/runtime/subagents/index.js.map +1 -1
  329. package/dist/runtime/subagents/parent-step-fork.d.ts +36 -0
  330. package/dist/runtime/subagents/parent-step-fork.d.ts.map +1 -0
  331. package/dist/runtime/subagents/parent-step-fork.js +83 -0
  332. package/dist/runtime/subagents/parent-step-fork.js.map +1 -0
  333. package/dist/runtime/subagents/production.d.ts +65 -46
  334. package/dist/runtime/subagents/production.d.ts.map +1 -1
  335. package/dist/runtime/subagents/production.js +494 -170
  336. package/dist/runtime/subagents/production.js.map +1 -1
  337. package/dist/runtime/subagents/receipt-journal.d.ts +20 -0
  338. package/dist/runtime/subagents/receipt-journal.d.ts.map +1 -0
  339. package/dist/runtime/subagents/receipt-journal.js +74 -0
  340. package/dist/runtime/subagents/receipt-journal.js.map +1 -0
  341. package/dist/runtime/subagents/runtime-contract.d.ts +29 -0
  342. package/dist/runtime/subagents/runtime-contract.d.ts.map +1 -0
  343. package/dist/runtime/subagents/runtime-contract.js +3 -0
  344. package/dist/runtime/subagents/runtime-contract.js.map +1 -0
  345. package/dist/runtime/subagents/runtime-integration.d.ts +41 -56
  346. package/dist/runtime/subagents/runtime-integration.d.ts.map +1 -1
  347. package/dist/runtime/subagents/runtime-integration.js +34 -198
  348. package/dist/runtime/subagents/runtime-integration.js.map +1 -1
  349. package/dist/runtime/subagents/supervisor.d.ts +19 -7
  350. package/dist/runtime/subagents/supervisor.d.ts.map +1 -1
  351. package/dist/runtime/subagents/supervisor.js +83 -40
  352. package/dist/runtime/subagents/supervisor.js.map +1 -1
  353. package/dist/runtime/subagents/types.d.ts +1 -1
  354. package/dist/runtime/subagents/types.js +1 -1
  355. package/dist/runtime/task-context-service.d.ts +91 -0
  356. package/dist/runtime/task-context-service.d.ts.map +1 -0
  357. package/dist/runtime/task-context-service.js +122 -0
  358. package/dist/runtime/task-context-service.js.map +1 -0
  359. package/dist/runtime/thread-admission.d.ts +130 -0
  360. package/dist/runtime/thread-admission.d.ts.map +1 -0
  361. package/dist/runtime/thread-admission.js +276 -0
  362. package/dist/runtime/thread-admission.js.map +1 -0
  363. package/dist/runtime/thread-compact-persistence.d.ts +50 -0
  364. package/dist/runtime/thread-compact-persistence.d.ts.map +1 -0
  365. package/dist/runtime/thread-compact-persistence.js +176 -0
  366. package/dist/runtime/thread-compact-persistence.js.map +1 -0
  367. package/dist/runtime/thread-event-store.d.ts +98 -0
  368. package/dist/runtime/thread-event-store.d.ts.map +1 -0
  369. package/dist/runtime/thread-event-store.js +737 -0
  370. package/dist/runtime/thread-event-store.js.map +1 -0
  371. package/dist/runtime/thread-projection.d.ts +91 -0
  372. package/dist/runtime/thread-projection.d.ts.map +1 -0
  373. package/dist/runtime/thread-projection.js +407 -0
  374. package/dist/runtime/thread-projection.js.map +1 -0
  375. package/dist/runtime/thread-runtime.d.ts +165 -0
  376. package/dist/runtime/thread-runtime.d.ts.map +1 -0
  377. package/dist/runtime/thread-runtime.js +704 -0
  378. package/dist/runtime/thread-runtime.js.map +1 -0
  379. package/dist/runtime/thread-session-view.d.ts +45 -0
  380. package/dist/runtime/thread-session-view.d.ts.map +1 -0
  381. package/dist/runtime/thread-session-view.js +264 -0
  382. package/dist/runtime/thread-session-view.js.map +1 -0
  383. package/dist/runtime/thread-tool-journal.d.ts +11 -0
  384. package/dist/runtime/thread-tool-journal.d.ts.map +1 -0
  385. package/dist/runtime/thread-tool-journal.js +131 -0
  386. package/dist/runtime/thread-tool-journal.js.map +1 -0
  387. package/dist/runtime/thread-ui-adapter.d.ts +87 -0
  388. package/dist/runtime/thread-ui-adapter.d.ts.map +1 -0
  389. package/dist/runtime/thread-ui-adapter.js +580 -0
  390. package/dist/runtime/thread-ui-adapter.js.map +1 -0
  391. package/dist/runtime/tool-gateway.d.ts +159 -0
  392. package/dist/runtime/tool-gateway.d.ts.map +1 -0
  393. package/dist/runtime/tool-gateway.js +311 -0
  394. package/dist/runtime/tool-gateway.js.map +1 -0
  395. package/dist/runtime/turn-commit.d.ts +103 -0
  396. package/dist/runtime/turn-commit.d.ts.map +1 -0
  397. package/dist/runtime/turn-commit.js +321 -0
  398. package/dist/runtime/turn-commit.js.map +1 -0
  399. package/dist/runtime/ui-events.d.ts +15 -5
  400. package/dist/runtime/ui-events.d.ts.map +1 -1
  401. package/dist/runtime/ui-events.js +0 -1
  402. package/dist/runtime/ui-events.js.map +1 -1
  403. package/dist/runtime/ui-view-model.d.ts +2 -1
  404. package/dist/runtime/ui-view-model.d.ts.map +1 -1
  405. package/dist/runtime/ui-view-model.js +6 -5
  406. package/dist/runtime/ui-view-model.js.map +1 -1
  407. package/dist/services/config-dir.d.ts +1 -1
  408. package/dist/services/config-dir.d.ts.map +1 -1
  409. package/dist/services/config-dir.js +2 -1
  410. package/dist/services/config-dir.js.map +1 -1
  411. package/dist/services/config.d.ts +2 -16
  412. package/dist/services/config.d.ts.map +1 -1
  413. package/dist/services/config.js +2 -29
  414. package/dist/services/config.js.map +1 -1
  415. package/dist/services/doctor.d.ts +0 -2
  416. package/dist/services/doctor.d.ts.map +1 -1
  417. package/dist/services/doctor.js +39 -64
  418. package/dist/services/doctor.js.map +1 -1
  419. package/dist/services/file-lock.d.ts.map +1 -1
  420. package/dist/services/file-lock.js +42 -17
  421. package/dist/services/file-lock.js.map +1 -1
  422. package/dist/services/global-config.d.ts +2 -2
  423. package/dist/services/global-config.d.ts.map +1 -1
  424. package/dist/services/session-storage.d.ts +8 -0
  425. package/dist/services/session-storage.d.ts.map +1 -1
  426. package/dist/services/session-storage.js +76 -12
  427. package/dist/services/session-storage.js.map +1 -1
  428. package/dist/skills/builtin/code-review/SKILL.md +51 -0
  429. package/dist/skills/builtin/security-check/SKILL.md +54 -0
  430. package/dist/skills/builtin/test-gen/SKILL.md +49 -0
  431. package/dist/terminal-ui/launch.d.ts +3 -1
  432. package/dist/terminal-ui/launch.d.ts.map +1 -1
  433. package/dist/terminal-ui/launch.js +21 -3
  434. package/dist/terminal-ui/launch.js.map +1 -1
  435. package/dist/tools/core/common.d.ts +34 -0
  436. package/dist/tools/core/common.d.ts.map +1 -0
  437. package/dist/tools/core/common.js +164 -0
  438. package/dist/tools/core/common.js.map +1 -0
  439. package/dist/tools/core/edit-file.d.ts +10 -0
  440. package/dist/tools/core/edit-file.d.ts.map +1 -0
  441. package/dist/tools/core/edit-file.js +301 -0
  442. package/dist/tools/core/edit-file.js.map +1 -0
  443. package/dist/tools/core/exec-command.d.ts +2 -0
  444. package/dist/tools/core/exec-command.d.ts.map +1 -0
  445. package/dist/tools/core/exec-command.js +347 -0
  446. package/dist/tools/core/exec-command.js.map +1 -0
  447. package/dist/tools/core/glob.d.ts +2 -0
  448. package/dist/tools/core/glob.d.ts.map +1 -0
  449. package/dist/tools/core/glob.js +133 -0
  450. package/dist/tools/core/glob.js.map +1 -0
  451. package/dist/tools/core/grep.d.ts +12 -0
  452. package/dist/tools/core/grep.d.ts.map +1 -0
  453. package/dist/tools/core/grep.js +223 -0
  454. package/dist/tools/core/grep.js.map +1 -0
  455. package/dist/tools/core/index.d.ts +15 -0
  456. package/dist/tools/core/index.d.ts.map +1 -0
  457. package/dist/tools/core/index.js +31 -0
  458. package/dist/tools/core/index.js.map +1 -0
  459. package/dist/tools/core/list-files.d.ts +2 -0
  460. package/dist/tools/core/list-files.d.ts.map +1 -0
  461. package/dist/tools/core/list-files.js +87 -0
  462. package/dist/tools/core/list-files.js.map +1 -0
  463. package/dist/tools/core/read-file.d.ts +2 -0
  464. package/dist/tools/core/read-file.d.ts.map +1 -0
  465. package/dist/tools/core/read-file.js +129 -0
  466. package/dist/tools/core/read-file.js.map +1 -0
  467. package/dist/tools/core/write-file.d.ts +2 -0
  468. package/dist/tools/core/write-file.d.ts.map +1 -0
  469. package/dist/tools/core/write-file.js +65 -0
  470. package/dist/tools/core/write-file.js.map +1 -0
  471. package/dist/tools/todo.d.ts +3 -4
  472. package/dist/tools/todo.d.ts.map +1 -1
  473. package/dist/tools/todo.js +80 -79
  474. package/dist/tools/todo.js.map +1 -1
  475. package/dist/tools/web.js +1 -1
  476. package/dist/tools/web.js.map +1 -1
  477. package/dist/tui-ui/chrome-view-model.d.ts.map +1 -1
  478. package/dist/tui-ui/chrome-view-model.js +22 -8
  479. package/dist/tui-ui/chrome-view-model.js.map +1 -1
  480. package/dist/tui-ui/launch.d.ts.map +1 -1
  481. package/dist/tui-ui/launch.js +13 -0
  482. package/dist/tui-ui/launch.js.map +1 -1
  483. package/dist/tui-ui/layout.js +1 -1
  484. package/dist/tui-ui/layout.js.map +1 -1
  485. package/dist/tui-ui/state.d.ts.map +1 -1
  486. package/dist/tui-ui/state.js +2 -0
  487. package/dist/tui-ui/state.js.map +1 -1
  488. package/docs/migration/v0.1.9-to-v0.2.0.md +98 -0
  489. package/docs/orion.example.json +79 -0
  490. package/docs/plan/v0.2.0-dsh-harness-redesign-plan.md +1234 -0
  491. package/docs/plan/v0.2.0-release-checklist.md +91 -0
  492. package/docs/readme.md +8 -8
  493. package/npm-shrinkwrap.json +45 -450
  494. package/package.json +17 -13
  495. package/dist/agents/coder.d.ts +0 -12
  496. package/dist/agents/coder.d.ts.map +0 -1
  497. package/dist/agents/coder.js +0 -48
  498. package/dist/agents/coder.js.map +0 -1
  499. package/dist/agents/coordinator.d.ts +0 -86
  500. package/dist/agents/coordinator.d.ts.map +0 -1
  501. package/dist/agents/coordinator.js +0 -291
  502. package/dist/agents/coordinator.js.map +0 -1
  503. package/dist/agents/fork.d.ts +0 -73
  504. package/dist/agents/fork.d.ts.map +0 -1
  505. package/dist/agents/fork.js +0 -163
  506. package/dist/agents/fork.js.map +0 -1
  507. package/dist/agents/leader.d.ts +0 -12
  508. package/dist/agents/leader.d.ts.map +0 -1
  509. package/dist/agents/leader.js +0 -49
  510. package/dist/agents/leader.js.map +0 -1
  511. package/dist/agents/router.d.ts +0 -59
  512. package/dist/agents/router.d.ts.map +0 -1
  513. package/dist/agents/router.js +0 -193
  514. package/dist/agents/router.js.map +0 -1
  515. package/dist/agents/worker-pool.d.ts +0 -72
  516. package/dist/agents/worker-pool.d.ts.map +0 -1
  517. package/dist/agents/worker-pool.js +0 -229
  518. package/dist/agents/worker-pool.js.map +0 -1
  519. package/dist/commands/legacy-commands.d.ts +0 -4
  520. package/dist/commands/legacy-commands.d.ts.map +0 -1
  521. package/dist/commands/legacy-commands.js +0 -44
  522. package/dist/commands/legacy-commands.js.map +0 -1
  523. package/dist/core/agent.d.ts +0 -84
  524. package/dist/core/agent.d.ts.map +0 -1
  525. package/dist/core/agent.js +0 -58
  526. package/dist/core/agent.js.map +0 -1
  527. package/dist/core/brain.d.ts +0 -50
  528. package/dist/core/brain.d.ts.map +0 -1
  529. package/dist/core/brain.js +0 -95
  530. package/dist/core/brain.js.map +0 -1
  531. package/dist/framework/tool-scheduler.d.ts +0 -191
  532. package/dist/framework/tool-scheduler.d.ts.map +0 -1
  533. package/dist/framework/tool-scheduler.js +0 -573
  534. package/dist/framework/tool-scheduler.js.map +0 -1
  535. package/dist/harness/harness.d.ts +0 -58
  536. package/dist/harness/harness.d.ts.map +0 -1
  537. package/dist/harness/harness.js +0 -195
  538. package/dist/harness/harness.js.map +0 -1
  539. package/dist/harness/safety.d.ts +0 -101
  540. package/dist/harness/safety.d.ts.map +0 -1
  541. package/dist/harness/safety.js +0 -322
  542. package/dist/harness/safety.js.map +0 -1
  543. package/dist/init.d.ts +0 -108
  544. package/dist/init.d.ts.map +0 -1
  545. package/dist/init.js +0 -393
  546. package/dist/init.js.map +0 -1
  547. package/dist/ink-ui/App.d.ts +0 -9
  548. package/dist/ink-ui/App.d.ts.map +0 -1
  549. package/dist/ink-ui/App.js +0 -12
  550. package/dist/ink-ui/App.js.map +0 -1
  551. package/dist/ink-ui/components/Markdown.d.ts +0 -10
  552. package/dist/ink-ui/components/Markdown.d.ts.map +0 -1
  553. package/dist/ink-ui/components/Markdown.js +0 -210
  554. package/dist/ink-ui/components/Markdown.js.map +0 -1
  555. package/dist/ink-ui/components/NativeCursor.d.ts +0 -12
  556. package/dist/ink-ui/components/NativeCursor.d.ts.map +0 -1
  557. package/dist/ink-ui/components/NativeCursor.js +0 -35
  558. package/dist/ink-ui/components/NativeCursor.js.map +0 -1
  559. package/dist/ink-ui/components/PixelHorseBanner.d.ts +0 -8
  560. package/dist/ink-ui/components/PixelHorseBanner.d.ts.map +0 -1
  561. package/dist/ink-ui/components/PixelHorseBanner.js +0 -97
  562. package/dist/ink-ui/components/PixelHorseBanner.js.map +0 -1
  563. package/dist/ink-ui/components/PromptInput.d.ts +0 -13
  564. package/dist/ink-ui/components/PromptInput.d.ts.map +0 -1
  565. package/dist/ink-ui/components/PromptInput.js +0 -30
  566. package/dist/ink-ui/components/PromptInput.js.map +0 -1
  567. package/dist/ink-ui/components/RunningHorseIndicator.d.ts +0 -13
  568. package/dist/ink-ui/components/RunningHorseIndicator.d.ts.map +0 -1
  569. package/dist/ink-ui/components/RunningHorseIndicator.js +0 -53
  570. package/dist/ink-ui/components/RunningHorseIndicator.js.map +0 -1
  571. package/dist/ink-ui/components/SelectList.d.ts +0 -16
  572. package/dist/ink-ui/components/SelectList.d.ts.map +0 -1
  573. package/dist/ink-ui/components/SelectList.js +0 -60
  574. package/dist/ink-ui/components/SelectList.js.map +0 -1
  575. package/dist/ink-ui/components/StatusLine.d.ts +0 -11
  576. package/dist/ink-ui/components/StatusLine.d.ts.map +0 -1
  577. package/dist/ink-ui/components/StatusLine.js +0 -70
  578. package/dist/ink-ui/components/StatusLine.js.map +0 -1
  579. package/dist/ink-ui/components/ToolActivity.d.ts +0 -19
  580. package/dist/ink-ui/components/ToolActivity.d.ts.map +0 -1
  581. package/dist/ink-ui/components/ToolActivity.js +0 -134
  582. package/dist/ink-ui/components/ToolActivity.js.map +0 -1
  583. package/dist/ink-ui/components/Transcript.d.ts +0 -14
  584. package/dist/ink-ui/components/Transcript.d.ts.map +0 -1
  585. package/dist/ink-ui/components/Transcript.js +0 -66
  586. package/dist/ink-ui/components/Transcript.js.map +0 -1
  587. package/dist/ink-ui/controllers/chat-controller.d.ts +0 -2
  588. package/dist/ink-ui/controllers/chat-controller.d.ts.map +0 -1
  589. package/dist/ink-ui/controllers/chat-controller.js.map +0 -1
  590. package/dist/ink-ui/hooks/use-raw-input-bridge.d.ts +0 -6
  591. package/dist/ink-ui/hooks/use-raw-input-bridge.d.ts.map +0 -1
  592. package/dist/ink-ui/hooks/use-raw-input-bridge.js +0 -27
  593. package/dist/ink-ui/hooks/use-raw-input-bridge.js.map +0 -1
  594. package/dist/ink-ui/hooks/use-terminal-size.d.ts +0 -7
  595. package/dist/ink-ui/hooks/use-terminal-size.d.ts.map +0 -1
  596. package/dist/ink-ui/hooks/use-terminal-size.js +0 -34
  597. package/dist/ink-ui/hooks/use-terminal-size.js.map +0 -1
  598. package/dist/ink-ui/launch.d.ts +0 -9
  599. package/dist/ink-ui/launch.d.ts.map +0 -1
  600. package/dist/ink-ui/launch.js +0 -101
  601. package/dist/ink-ui/launch.js.map +0 -1
  602. package/dist/ink-ui/runtime/grapheme.d.ts +0 -10
  603. package/dist/ink-ui/runtime/grapheme.d.ts.map +0 -1
  604. package/dist/ink-ui/runtime/grapheme.js +0 -17
  605. package/dist/ink-ui/runtime/grapheme.js.map +0 -1
  606. package/dist/ink-ui/runtime/input-buffer.d.ts +0 -10
  607. package/dist/ink-ui/runtime/input-buffer.d.ts.map +0 -1
  608. package/dist/ink-ui/runtime/input-buffer.js +0 -18
  609. package/dist/ink-ui/runtime/input-buffer.js.map +0 -1
  610. package/dist/ink-ui/runtime/layout-budget.d.ts +0 -13
  611. package/dist/ink-ui/runtime/layout-budget.d.ts.map +0 -1
  612. package/dist/ink-ui/runtime/layout-budget.js +0 -25
  613. package/dist/ink-ui/runtime/layout-budget.js.map +0 -1
  614. package/dist/ink-ui/runtime/native-cursor.d.ts +0 -62
  615. package/dist/ink-ui/runtime/native-cursor.d.ts.map +0 -1
  616. package/dist/ink-ui/runtime/native-cursor.js +0 -398
  617. package/dist/ink-ui/runtime/native-cursor.js.map +0 -1
  618. package/dist/ink-ui/runtime/prompt-layout.d.ts +0 -10
  619. package/dist/ink-ui/runtime/prompt-layout.d.ts.map +0 -1
  620. package/dist/ink-ui/runtime/prompt-layout.js +0 -21
  621. package/dist/ink-ui/runtime/prompt-layout.js.map +0 -1
  622. package/dist/ink-ui/runtime/raw-input.d.ts +0 -4
  623. package/dist/ink-ui/runtime/raw-input.d.ts.map +0 -1
  624. package/dist/ink-ui/runtime/raw-input.js +0 -15
  625. package/dist/ink-ui/runtime/raw-input.js.map +0 -1
  626. package/dist/ink-ui/runtime/transcript-state.d.ts +0 -37
  627. package/dist/ink-ui/runtime/transcript-state.d.ts.map +0 -1
  628. package/dist/ink-ui/runtime/transcript-state.js +0 -91
  629. package/dist/ink-ui/runtime/transcript-state.js.map +0 -1
  630. package/dist/ink-ui/screens/ReplScreen.d.ts +0 -27
  631. package/dist/ink-ui/screens/ReplScreen.d.ts.map +0 -1
  632. package/dist/ink-ui/screens/ReplScreen.js +0 -781
  633. package/dist/ink-ui/screens/ReplScreen.js.map +0 -1
  634. package/dist/ink-ui/types.d.ts +0 -2
  635. package/dist/ink-ui/types.d.ts.map +0 -1
  636. package/dist/ink-ui/types.js.map +0 -1
  637. package/dist/runtime/chat-checkpoint.d.ts +0 -17
  638. package/dist/runtime/chat-checkpoint.d.ts.map +0 -1
  639. package/dist/runtime/chat-checkpoint.js +0 -105
  640. package/dist/runtime/chat-checkpoint.js.map +0 -1
  641. package/dist/runtime/chat-command-scope.d.ts +0 -5
  642. package/dist/runtime/chat-command-scope.d.ts.map +0 -1
  643. package/dist/runtime/chat-command-scope.js +0 -22
  644. package/dist/runtime/chat-command-scope.js.map +0 -1
  645. package/dist/runtime/chat-compact.d.ts +0 -26
  646. package/dist/runtime/chat-compact.d.ts.map +0 -1
  647. package/dist/runtime/chat-compact.js +0 -132
  648. package/dist/runtime/chat-compact.js.map +0 -1
  649. package/dist/runtime/chat-controller.d.ts +0 -62
  650. package/dist/runtime/chat-controller.d.ts.map +0 -1
  651. package/dist/runtime/chat-controller.js +0 -1620
  652. package/dist/runtime/chat-controller.js.map +0 -1
  653. package/dist/runtime/chat-effort.d.ts +0 -5
  654. package/dist/runtime/chat-effort.d.ts.map +0 -1
  655. package/dist/runtime/chat-effort.js +0 -47
  656. package/dist/runtime/chat-effort.js.map +0 -1
  657. package/dist/runtime/chat-presentation.d.ts +0 -63
  658. package/dist/runtime/chat-presentation.d.ts.map +0 -1
  659. package/dist/runtime/chat-presentation.js +0 -561
  660. package/dist/runtime/chat-presentation.js.map +0 -1
  661. package/dist/runtime/chat-trace.d.ts +0 -52
  662. package/dist/runtime/chat-trace.d.ts.map +0 -1
  663. package/dist/runtime/chat-trace.js +0 -234
  664. package/dist/runtime/chat-trace.js.map +0 -1
  665. package/dist/runtime/chat-workspace.d.ts +0 -22
  666. package/dist/runtime/chat-workspace.d.ts.map +0 -1
  667. package/dist/runtime/chat-workspace.js +0 -154
  668. package/dist/runtime/chat-workspace.js.map +0 -1
  669. package/dist/runtime/goals/accounting.d.ts +0 -45
  670. package/dist/runtime/goals/accounting.d.ts.map +0 -1
  671. package/dist/runtime/goals/accounting.js +0 -114
  672. package/dist/runtime/goals/accounting.js.map +0 -1
  673. package/dist/runtime/goals/coordinator.d.ts +0 -92
  674. package/dist/runtime/goals/coordinator.d.ts.map +0 -1
  675. package/dist/runtime/goals/coordinator.js +0 -1471
  676. package/dist/runtime/goals/coordinator.js.map +0 -1
  677. package/dist/runtime/goals/lifecycle.d.ts +0 -13
  678. package/dist/runtime/goals/lifecycle.d.ts.map +0 -1
  679. package/dist/runtime/goals/lifecycle.js +0 -46
  680. package/dist/runtime/goals/lifecycle.js.map +0 -1
  681. package/dist/runtime/goals/prompt.d.ts +0 -16
  682. package/dist/runtime/goals/prompt.d.ts.map +0 -1
  683. package/dist/runtime/goals/prompt.js +0 -88
  684. package/dist/runtime/goals/prompt.js.map +0 -1
  685. package/dist/runtime/goals/stop-policy.d.ts +0 -9
  686. package/dist/runtime/goals/stop-policy.d.ts.map +0 -1
  687. package/dist/runtime/goals/stop-policy.js +0 -83
  688. package/dist/runtime/goals/stop-policy.js.map +0 -1
  689. package/dist/runtime/goals/tools.d.ts +0 -61
  690. package/dist/runtime/goals/tools.d.ts.map +0 -1
  691. package/dist/runtime/goals/tools.js +0 -568
  692. package/dist/runtime/goals/tools.js.map +0 -1
  693. package/dist/sdk/index.d.ts +0 -10
  694. package/dist/sdk/index.d.ts.map +0 -1
  695. package/dist/sdk/index.js +0 -23
  696. package/dist/sdk/index.js.map +0 -1
  697. package/dist/sdk/init.d.ts +0 -24
  698. package/dist/sdk/init.d.ts.map +0 -1
  699. package/dist/sdk/init.js +0 -48
  700. package/dist/sdk/init.js.map +0 -1
  701. package/dist/sdk/query.d.ts +0 -19
  702. package/dist/sdk/query.d.ts.map +0 -1
  703. package/dist/sdk/query.js +0 -42
  704. package/dist/sdk/query.js.map +0 -1
  705. package/dist/sdk/sessions.d.ts +0 -19
  706. package/dist/sdk/sessions.d.ts.map +0 -1
  707. package/dist/sdk/sessions.js +0 -57
  708. package/dist/sdk/sessions.js.map +0 -1
  709. package/dist/sdk/types.d.ts +0 -47
  710. package/dist/sdk/types.d.ts.map +0 -1
  711. package/dist/sdk/types.js +0 -8
  712. package/dist/sdk/types.js.map +0 -1
  713. package/dist/services/agent-runner.d.ts +0 -71
  714. package/dist/services/agent-runner.d.ts.map +0 -1
  715. package/dist/services/agent-runner.js +0 -185
  716. package/dist/services/agent-runner.js.map +0 -1
  717. package/dist/services/task-manager.d.ts +0 -161
  718. package/dist/services/task-manager.d.ts.map +0 -1
  719. package/dist/services/task-manager.js +0 -315
  720. package/dist/services/task-manager.js.map +0 -1
  721. package/dist/skills/discovery.d.ts +0 -22
  722. package/dist/skills/discovery.d.ts.map +0 -1
  723. package/dist/skills/discovery.js +0 -75
  724. package/dist/skills/discovery.js.map +0 -1
  725. package/dist/skills/index.d.ts +0 -11
  726. package/dist/skills/index.d.ts.map +0 -1
  727. package/dist/skills/index.js.map +0 -1
  728. package/dist/skills/loader.d.ts +0 -53
  729. package/dist/skills/loader.d.ts.map +0 -1
  730. package/dist/skills/loader.js +0 -421
  731. package/dist/skills/loader.js.map +0 -1
  732. package/dist/skills/registry.d.ts +0 -41
  733. package/dist/skills/registry.d.ts.map +0 -1
  734. package/dist/skills/registry.js +0 -157
  735. package/dist/skills/registry.js.map +0 -1
  736. package/dist/skills/runtime.d.ts +0 -46
  737. package/dist/skills/runtime.d.ts.map +0 -1
  738. package/dist/skills/runtime.js +0 -363
  739. package/dist/skills/runtime.js.map +0 -1
  740. package/dist/skills/types.d.ts +0 -112
  741. package/dist/skills/types.d.ts.map +0 -1
  742. package/dist/skills/types.js +0 -24
  743. package/dist/skills/types.js.map +0 -1
  744. package/dist/tools/index.d.ts +0 -52
  745. package/dist/tools/index.d.ts.map +0 -1
  746. package/dist/tools/index.js +0 -2268
  747. package/dist/tools/index.js.map +0 -1
  748. package/dist/tools/mcp.d.ts +0 -99
  749. package/dist/tools/mcp.d.ts.map +0 -1
  750. package/dist/tools/mcp.js +0 -695
  751. package/dist/tools/mcp.js.map +0 -1
  752. package/dist/tools/plan.d.ts +0 -17
  753. package/dist/tools/plan.d.ts.map +0 -1
  754. package/dist/tools/plan.js +0 -84
  755. package/dist/tools/plan.js.map +0 -1
  756. package/docs/migration/v0.1.8-to-v0.1.9.md +0 -60
  757. package/docs/plan/v0.1.9-release-checklist.md +0 -64
@@ -0,0 +1,1047 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createProductOrionRuntimeV1 = createProductOrionRuntimeV1;
4
+ const path_1 = require("path");
5
+ const prompt_1 = require("../framework/prompt");
6
+ const stop_decision_1 = require("../framework/stop-decision");
7
+ const prompt_context_1 = require("../memory/prompt-context");
8
+ const file_context_1 = require("../services/file-context");
9
+ const goal_storage_1 = require("../services/goal-storage");
10
+ const llm_1 = require("../services/llm");
11
+ const session_storage_1 = require("../services/session-storage");
12
+ const token_estimate_1 = require("../utils/token-estimate");
13
+ const paths_1 = require("../product/paths");
14
+ const builtin_tool_provider_1 = require("./builtin-tool-provider");
15
+ const legacy_thread_materializer_1 = require("./legacy-thread-materializer");
16
+ const thread_event_store_1 = require("./thread-event-store");
17
+ const orion_runtime_v1_1 = require("./orion-runtime-v1");
18
+ const prompts_1 = require("./prompts");
19
+ const canonical_1 = require("./protocol/canonical");
20
+ const session_history_recovery_1 = require("./session-history-recovery");
21
+ const step_snapshot_1 = require("./step-snapshot");
22
+ const production_1 = require("./subagents/production");
23
+ const runtime_integration_1 = require("./subagents/runtime-integration");
24
+ const policy_1 = require("./subagents/policy");
25
+ const parent_step_fork_1 = require("./subagents/parent-step-fork");
26
+ const presets_1 = require("./subagents/presets");
27
+ const types_1 = require("./subagents/types");
28
+ const turn_commit_1 = require("./turn-commit");
29
+ /** Build one explicit OrionRuntime owner for a legacy Session/v2 Thread identity. */
30
+ function createProductOrionRuntimeV1(options, sessionId) {
31
+ let promptState;
32
+ const scheduledPlanReceipts = new Set();
33
+ let storage = (0, legacy_thread_materializer_1.resolveSessionStorageV1)(options.cwd, sessionId);
34
+ if (storage.kind === 'legacy') {
35
+ (0, legacy_thread_materializer_1.materializeLegacyThreadV1)({ projectPath: options.cwd, sessionId });
36
+ storage = (0, legacy_thread_materializer_1.resolveSessionStorageV1)(options.cwd, sessionId);
37
+ }
38
+ if (storage.kind !== 'thread') {
39
+ throw new Error(`Session ${sessionId} did not cut over to a v2 Thread.`);
40
+ }
41
+ const existingProjection = new thread_event_store_1.ThreadEventStore((0, paths_1.getProjectThreadsV2Dir)(options.cwd), storage.threadId).loadProjection();
42
+ const hasDurableTurnCommit = Object.values(existingProjection.turns).some(turn => turn.commit);
43
+ const profile = options.config.modelRegistry?.defaultProfile;
44
+ const provider = profile
45
+ ? options.config.modelRegistry?.providers.get(profile.provider)
46
+ : undefined;
47
+ const modelId = profile?.model ?? options.llm.getModel();
48
+ const contextWindow = profile?.contextWindow ?? 128000;
49
+ // Legacy sidecars are migration seeds only. Once a TurnCommit exists, its
50
+ // TaskContext and Goal state are the sole durable authority on restart.
51
+ const taskState = hasDurableTurnCommit
52
+ ? undefined
53
+ : ((0, session_storage_1.loadSessionHarnessState)(sessionId) ?? undefined);
54
+ const goalSeed = hasDurableTurnCommit ? undefined : loadProductGoalSeed(options.cwd, sessionId);
55
+ const executionPolicy = (0, step_snapshot_1.createExecutionPolicySnapshotV1)({
56
+ policyId: 'orion-product-policy-v1',
57
+ approvalMode: options.config.toolConfirmation === 'ask' ? 'interactive' : 'never',
58
+ // Workspace file tools provide path containment. Shell sandboxing remains
59
+ // explicitly recorded by FirstPartySandboxService; a project grant may
60
+ // execute with enforcement=none without pretending a sandbox exists.
61
+ sandboxRequired: false,
62
+ sandboxBackend: 'configured-first-party',
63
+ timeoutMs: 120000,
64
+ });
65
+ const subagents = createProductSubagentCompositionV1(options, {
66
+ modelId,
67
+ providerId: profile?.provider ?? 'configured-provider',
68
+ protocol: provider?.protocol ?? 'openai-compatible',
69
+ providerProtocol: provider?.protocol,
70
+ contextWindow,
71
+ });
72
+ const runtime = (0, orion_runtime_v1_1.createOrionRuntimeV1)({
73
+ modelExecutor: options.llm,
74
+ toolCatalog: options.toolCatalog,
75
+ toolContext: {
76
+ cwd: options.cwd,
77
+ config: { name: options.config.name, mode: options.config.mode },
78
+ },
79
+ eventStore: {
80
+ rootDir: (0, paths_1.getProjectThreadsV2Dir)(options.cwd),
81
+ threadId: storage.threadId,
82
+ },
83
+ projectPath: options.cwd,
84
+ taskContext: {
85
+ cwd: options.cwd,
86
+ modelId,
87
+ ...(taskState ? { state: taskState } : {}),
88
+ },
89
+ ...(goalSeed ? { goal: goalSeed } : {}),
90
+ skills: { providers: [...(options.skillProviders ?? [])] },
91
+ mcp: {
92
+ descriptors: [...(options.mcpDescriptors ?? [])],
93
+ connector: options.mcpConnector ?? INERT_MCP_CONNECTOR,
94
+ },
95
+ approvalHandler: options.approvalHandler,
96
+ ...(subagents ? { subagents } : {}),
97
+ resolveCapabilityConfiguration: async (input, context) => {
98
+ if (!promptState || promptState.turnId !== input.turnId) {
99
+ throw new Error(`Prompt receipt is missing for active turn ${input.turnId}.`);
100
+ }
101
+ const dynamicTools = await resolveMcpToolsForStep(input, context.mcp, context.mcpCatalog);
102
+ return capabilityConfiguration({
103
+ options,
104
+ input,
105
+ modelId,
106
+ contextWindow,
107
+ providerId: profile?.provider ?? 'configured-provider',
108
+ protocol: provider?.protocol ?? 'openai-compatible',
109
+ executionPolicy,
110
+ skillCatalog: promptState.skillCatalog,
111
+ loadedSkills: promptState.loadedSkills,
112
+ explicitSkillIds: promptState.explicitSkillIds,
113
+ promptReceipt: promptState.receipt,
114
+ dynamicTools,
115
+ });
116
+ },
117
+ loadBaseMessages: async (store, context, prompts, composition) => {
118
+ const assembled = await buildProductMessages(options, sessionId, store, prompts, composition, context.input, context.mode, contextWindow);
119
+ promptState = {
120
+ turnId: context.turnId,
121
+ mode: context.mode,
122
+ planReturnMode: productPlanReturnMode(options.store),
123
+ receipt: assembled.receipt,
124
+ skillCatalog: assembled.skillCatalog,
125
+ loadedSkills: assembled.loadedSkills,
126
+ explicitSkillIds: assembled.explicitSkillIds,
127
+ };
128
+ return assembled.messages;
129
+ },
130
+ loop: {
131
+ ...(options.compactCoordinator ? { compactCoordinator: options.compactCoordinator } : {}),
132
+ onContextUsage: usage => options.store.setContextUsage(usage),
133
+ prepareTurnCommit: commit => {
134
+ const active = promptState;
135
+ if (!active || active.turnId !== commit.turnId || active.mode !== 'plan')
136
+ return {};
137
+ const plan = extractDecisionCompletePlan(commit);
138
+ return {
139
+ stopDecision: createPlanStopDecision(commit, active.receipt.digest),
140
+ plan: {
141
+ plan,
142
+ returnMode: active.planReturnMode,
143
+ promptReceiptDigest: active.receipt.digest,
144
+ },
145
+ };
146
+ },
147
+ onTurnCommitted: (commit, durableCommit) => {
148
+ if (promptState?.turnId === commit.turnId)
149
+ promptState = undefined;
150
+ if (commit.queryComplete.stats)
151
+ options.store.setLastLoopStats(commit.queryComplete.stats);
152
+ options.store.setState({
153
+ harnessState: commit.taskContextState,
154
+ conversationHistory: commit.history.map(message => ({ ...message })),
155
+ });
156
+ const planReceipt = planReceiptFromCommit(durableCommit);
157
+ if (planReceipt) {
158
+ projectPlanReceipt(options.store, planReceipt);
159
+ schedulePlanExecution(runtime, planReceipt, scheduledPlanReceipts);
160
+ }
161
+ },
162
+ onRuntimeStarted: ({ restoredCommit, thread }) => {
163
+ if (restoredCommit)
164
+ projectRestoredTurnCommit(options.store, restoredCommit);
165
+ const planReceipt = restoredCommit ? planReceiptFromCommit(restoredCommit) : undefined;
166
+ if (!planReceipt)
167
+ return;
168
+ projectPlanReceipt(options.store, planReceipt);
169
+ if (thread.getProjection().queue.length === 0) {
170
+ schedulePlanExecution(runtime, planReceipt, scheduledPlanReceipts);
171
+ }
172
+ },
173
+ },
174
+ });
175
+ return runtime;
176
+ }
177
+ function createProductSubagentCompositionV1(options, model) {
178
+ const config = (0, policy_1.clampSubagentConfig)(options.config.subagents ?? types_1.DEFAULT_SUBAGENT_CONFIG);
179
+ const rootLlmConfig = (0, runtime_integration_1.deriveRootLlmConfig)(options.config);
180
+ if (config.mode === 'off' || !rootLlmConfig.apiKey)
181
+ return undefined;
182
+ const allowedNames = new Set(presets_1.READ_ONLY_INVESTIGATION_TOOLS);
183
+ const childTools = options.toolCatalog.entries
184
+ .filter(entry => allowedNames.has(entry.candidate.descriptor.name) &&
185
+ entry.candidate.descriptor.risk.readOnly &&
186
+ !entry.candidate.descriptor.risk.destructive &&
187
+ entry.candidate.descriptor.risk.network === 'none')
188
+ .map(entry => entry.tool);
189
+ const toolContext = {
190
+ cwd: options.cwd,
191
+ config: { name: options.config.name, mode: options.config.mode },
192
+ };
193
+ const childCatalog = (0, builtin_tool_provider_1.createBuiltinToolCatalogV1)(childTools, { context: toolContext });
194
+ const childExecutionPolicy = (0, step_snapshot_1.createExecutionPolicySnapshotV1)({
195
+ policyId: 'orion-product-subagent-readonly-v1',
196
+ approvalMode: 'never',
197
+ sandboxRequired: false,
198
+ sandboxBackend: 'workspace-path-containment',
199
+ timeoutMs: config.timeoutMs,
200
+ });
201
+ const rolePolicies = createProductSubagentRolePolicies(options, config);
202
+ const issuedModels = new WeakSet();
203
+ const childRuntimeServicesDigest = (0, canonical_1.digestRuntimeValue)({
204
+ version: 1,
205
+ owner: 'product-subagent-composition-v1',
206
+ loop: 'agent-loop-v1',
207
+ gateway: 'tool-gateway-v1',
208
+ toolCatalog: childCatalog.digest,
209
+ });
210
+ const emptySkillCatalogDigest = (0, canonical_1.digestRuntimeValue)({ version: 1, skills: [] });
211
+ const emptyMcpCatalogDigest = (0, canonical_1.digestRuntimeValue)({ version: 1, servers: [] });
212
+ return Object.freeze({
213
+ serviceId: 'product-subagent-composition-v1',
214
+ createTurn: async (input) => {
215
+ if (input.abortSignal.aborted)
216
+ return null;
217
+ const parentForkSource = new parent_step_fork_1.ParentThreadStepForkSourceV1({
218
+ store: input.store,
219
+ flush: input.flush,
220
+ });
221
+ let productionRuntime;
222
+ try {
223
+ productionRuntime = (0, production_1.createProductionSubagentRuntimeV1)({
224
+ childStoreRootDir: (0, path_1.join)((0, paths_1.getProjectThreadsV2Dir)(options.cwd), 'subagents'),
225
+ receiptRootDir: (0, path_1.join)((0, paths_1.getProjectThreadsV2Dir)(options.cwd), 'subagent-receipts'),
226
+ toolCatalog: childCatalog,
227
+ treeLimits: {
228
+ maxConcurrent: config.maxParallel,
229
+ maxQueued: config.maxTasksPerTurn,
230
+ maxModelRequests: config.maxModelRequestsPerTurn,
231
+ maxToolCalls: config.maxToolCallsPerTask * config.maxTasksPerTurn,
232
+ },
233
+ rolePolicies,
234
+ createModelExecutor: childInput => {
235
+ const executor = options.createSubagentModelExecutor
236
+ ? options.createSubagentModelExecutor(childInput)
237
+ : createProductChildModelExecutor(options, rootLlmConfig, model.providerProtocol);
238
+ if (executor === options.llm || issuedModels.has(executor)) {
239
+ throw new Error('Subagent model factory must return a distinct LLMService for every child request.');
240
+ }
241
+ issuedModels.add(executor);
242
+ return executor;
243
+ },
244
+ resolveCapabilityConfiguration: (step, context) => ({
245
+ taskEpoch: 1,
246
+ model: {
247
+ providerId: model.providerId,
248
+ modelId: context.modelId,
249
+ protocol: model.protocol,
250
+ contextWindow: model.contextWindow,
251
+ },
252
+ executionPolicy: childExecutionPolicy,
253
+ environment: {
254
+ cwd: context.authority.projectRoot,
255
+ platform: process.platform,
256
+ arch: process.arch,
257
+ environmentDigest: (0, canonical_1.digestRuntimeValue)({
258
+ cwd: context.authority.projectRoot,
259
+ platform: process.platform,
260
+ arch: process.arch,
261
+ }),
262
+ },
263
+ compiler: {
264
+ task: { objective: context.objective },
265
+ model: { toolCalling: true },
266
+ authority: context.authority,
267
+ budgets: {
268
+ maxDirectTools: Math.max(1, childCatalog.candidates.length),
269
+ maxToolSchemaBytes: Math.max(1, childCatalog.toolSchemaBytes),
270
+ maxDeferredTools: 0,
271
+ maxExpansionTools: 0,
272
+ },
273
+ tools: childCatalog.candidates,
274
+ runtimeServicesDigest: childRuntimeServicesDigest,
275
+ executionPolicyDigest: childExecutionPolicy.digest,
276
+ skillCatalogDigest: emptySkillCatalogDigest,
277
+ mcpCatalogDigest: emptyMcpCatalogDigest,
278
+ estimatedInputTokens: (0, token_estimate_1.estimateTokens)(step.input),
279
+ },
280
+ }),
281
+ toolContext: (_request, authority) => ({
282
+ ...toolContext,
283
+ cwd: authority.projectRoot,
284
+ }),
285
+ runtimeServicesDigest: childRuntimeServicesDigest,
286
+ onReceipt: options.onSubagentReceipt,
287
+ parentAbortSignal: input.abortSignal,
288
+ });
289
+ const bundle = (0, runtime_integration_1.createSubagentBundleForTurn)({
290
+ config,
291
+ cwd: options.cwd,
292
+ rootLlmConfig,
293
+ productionRuntime,
294
+ parentForkSource,
295
+ parentAuthority: input.authority,
296
+ modelLabel: model.modelId,
297
+ rootObjectiveSummary: input.input,
298
+ abortSignal: input.abortSignal,
299
+ });
300
+ if (!bundle) {
301
+ productionRuntime.close('subagent_turn_unavailable');
302
+ parentForkSource.close('subagent_turn_unavailable');
303
+ return null;
304
+ }
305
+ const catalog = (0, builtin_tool_provider_1.createBuiltinToolCatalogV1)([bundle.tool], { context: toolContext });
306
+ const capability = {
307
+ serviceId: `product-subagent-turn-v1:${input.turnId}`,
308
+ turnId: input.turnId,
309
+ catalog,
310
+ publishCommitted: (stepBundle, commit) => {
311
+ parentForkSource.publishCommitted(stepBundle, commit);
312
+ },
313
+ close: (reason) => bundle.close(reason),
314
+ };
315
+ return Object.freeze(capability);
316
+ }
317
+ catch (error) {
318
+ productionRuntime?.close('subagent_turn_start_failed');
319
+ parentForkSource.close('subagent_turn_start_failed');
320
+ throw error;
321
+ }
322
+ },
323
+ });
324
+ }
325
+ function createProductSubagentRolePolicies(options, config) {
326
+ const entries = config.roles.map(role => [
327
+ role,
328
+ (0, step_snapshot_1.createAuthoritySnapshotV1)({
329
+ authorityId: `subagent-role:${role}:${(0, canonical_1.digestRuntimeValue)(options.cwd).slice(0, 16)}`,
330
+ projectRoot: options.cwd,
331
+ confirmation: 'allow',
332
+ filesystem: 'workspace',
333
+ network: 'deny',
334
+ }),
335
+ ]);
336
+ return Object.freeze(Object.fromEntries(entries));
337
+ }
338
+ function createProductChildModelExecutor(options, rootConfig, providerProtocol) {
339
+ const executor = new llm_1.LLMService({
340
+ ...(0, production_1.createChildLlmConfig)(rootConfig),
341
+ providerProtocol,
342
+ reasoningCapability: options.config.modelRegistry?.defaultProfile?.reasoningCapability,
343
+ fallbackReasoningCapability: options.config.modelRegistry?.fallbackProfile?.reasoningCapability,
344
+ effortPreference: options.config.defaultEffort,
345
+ });
346
+ executor.resilience = options.llm.resilience;
347
+ return executor;
348
+ }
349
+ function capabilityConfiguration(input) {
350
+ const authority = createProductAuthority(input.options, input.input.mode);
351
+ const loadedSkillIds = new Set(input.loadedSkills.map(skill => skill.definition.id));
352
+ return {
353
+ taskEpoch: 1,
354
+ model: {
355
+ providerId: input.providerId,
356
+ modelId: input.modelId,
357
+ protocol: input.protocol,
358
+ contextWindow: input.contextWindow,
359
+ },
360
+ executionPolicy: input.executionPolicy,
361
+ environment: {
362
+ cwd: input.options.cwd,
363
+ platform: process.platform,
364
+ arch: process.arch,
365
+ environmentDigest: (0, canonical_1.digestRuntimeValue)({
366
+ cwd: input.options.cwd,
367
+ platform: process.platform,
368
+ arch: process.arch,
369
+ }),
370
+ },
371
+ compiler: {
372
+ task: {
373
+ objective: input.input.input,
374
+ ...(input.explicitSkillIds.length > 0 ? { explicitSkillIds: input.explicitSkillIds } : {}),
375
+ ...(input.dynamicTools?.candidates.length
376
+ ? {
377
+ explicitMcpToolIds: input.dynamicTools.candidates.map(candidate => candidate.descriptor.name),
378
+ }
379
+ : {}),
380
+ },
381
+ model: { toolCalling: true },
382
+ authority,
383
+ budgets: {
384
+ maxDirectTools: 12,
385
+ maxToolSchemaBytes: 16384,
386
+ maxDeferredTools: 32,
387
+ maxExpansionTools: 4,
388
+ },
389
+ skills: input.skillCatalog.descriptors.map(skill => ({
390
+ id: skill.id,
391
+ digest: skill.digest,
392
+ description: skill.description,
393
+ keywords: [skill.name],
394
+ requestedCapabilities: skill.requestedCapabilities,
395
+ loaded: loadedSkillIds.has(skill.id),
396
+ })),
397
+ executionPolicyDigest: input.executionPolicy.digest,
398
+ skillCatalogDigest: input.skillCatalog.digest,
399
+ promptManifest: input.promptReceipt.sections.map(section => ({
400
+ id: section.id,
401
+ digest: section.contentDigest,
402
+ selected: section.selected,
403
+ reason: section.reason,
404
+ })),
405
+ estimatedInputTokens: (0, token_estimate_1.estimateTokens)(input.input.input),
406
+ },
407
+ ...(input.dynamicTools ? { dynamicTools: input.dynamicTools } : {}),
408
+ };
409
+ }
410
+ function loadProductGoalSeed(projectPath, sessionId) {
411
+ const loaded = (0, goal_storage_1.loadGoal)(projectPath, sessionId);
412
+ if (!loaded.ok) {
413
+ if (loaded.error === 'not_found')
414
+ return undefined;
415
+ throw new Error(`Cannot start Goal runtime: ${loaded.message}`);
416
+ }
417
+ const legacy = loaded.value;
418
+ const status = legacy.status === 'active' ? 'active' : legacy.status === 'complete' ? 'completed' : 'paused';
419
+ const budget = {
420
+ maxTokens: legacy.tokenBudget ?? Number.MAX_SAFE_INTEGER,
421
+ maxElapsedMs: Number.MAX_SAFE_INTEGER,
422
+ };
423
+ const content = {
424
+ version: 2,
425
+ goalId: legacy.goalId,
426
+ objective: legacy.objective,
427
+ status,
428
+ generation: Math.max(1, legacy.revision + 1),
429
+ continuationCount: legacy.continuationCount,
430
+ noProgressCount: legacy.noProgressCount,
431
+ blockedCount: legacy.blocker?.consecutiveTurns ?? 0,
432
+ tokensUsed: legacy.tokensUsed,
433
+ elapsedMs: legacy.timeUsedMs,
434
+ budget,
435
+ createdAt: legacy.createdAt,
436
+ updatedAt: Math.max(legacy.createdAt, legacy.updatedAt),
437
+ };
438
+ const state = Object.freeze({
439
+ ...content,
440
+ digest: (0, canonical_1.digestRuntimeValue)(content),
441
+ });
442
+ return Object.freeze({
443
+ goalId: state.goalId,
444
+ objective: state.objective,
445
+ budget: state.budget,
446
+ state,
447
+ });
448
+ }
449
+ function buildGoalRuntimeContext(state) {
450
+ if (!state)
451
+ return undefined;
452
+ return [
453
+ 'Durable Goal lifecycle (v2):',
454
+ `- Goal ID: ${state.goalId}`,
455
+ `- Objective: ${state.objective}`,
456
+ `- Status: ${state.status}`,
457
+ `- Generation: ${state.generation}`,
458
+ `- Continuations: ${state.continuationCount}`,
459
+ `- Tokens: ${state.tokensUsed}/${state.budget.maxTokens}`,
460
+ `- Elapsed ms: ${state.elapsedMs}/${state.budget.maxElapsedMs}`,
461
+ state.status === 'active'
462
+ ? '- Continue autonomously; only TaskContext may verify completion.'
463
+ : '- Do not autonomously continue this Goal unless the user explicitly resumes it.',
464
+ ].join('\n');
465
+ }
466
+ async function buildProductMessages(options, sessionId, eventStore, prompts, composition, input, mode, contextWindow) {
467
+ const durable = latestDurableHistory(eventStore);
468
+ const history = durable ?? legacyHistory(sessionId);
469
+ const withoutOldSystem = history.filter(message => message.role !== 'system');
470
+ const snapshot = options.store.getSnapshot();
471
+ const goalContent = buildGoalRuntimeContext(composition.goal.state);
472
+ const planReceipt = mode === 'plan' ? undefined : latestDurablePlanReceipt(eventStore);
473
+ const memory = (0, prompt_context_1.buildMemoryPromptContext)(input, options.cwd).content;
474
+ const skillCatalog = await composition.skills.observe({ id: `project:${(0, canonical_1.digestRuntimeValue)(options.cwd)}` }, undefined);
475
+ const skillSelection = await loadSelectedSkills(input, skillCatalog, composition, createProductAuthority(options, mode));
476
+ const basePrompt = (0, prompt_1.buildSystemPrompt)({
477
+ cwd: options.cwd,
478
+ platform: process.platform,
479
+ nodeVersion: process.version,
480
+ tools: options.toolCatalog.entries
481
+ .filter(entry => entry.candidate.tier === 'core')
482
+ .map(entry => entry.tool),
483
+ planMode: mode === 'plan',
484
+ agentMode: mode === 'goal'
485
+ ? snapshot.agentMode
486
+ : mode === 'build'
487
+ ? 'interactive'
488
+ : mode === 'maintenance'
489
+ ? snapshot.agentMode
490
+ : mode,
491
+ });
492
+ const referencedFiles = (0, file_context_1.buildReferencedFilesPrompt)(input, options.cwd);
493
+ const sections = productPromptSections({
494
+ basePrompt,
495
+ memory,
496
+ projectInstructions: snapshot.projectInstructionsContent,
497
+ referencedFiles,
498
+ goal: goalContent,
499
+ plan: planReceipt,
500
+ skills: skillSelection.loaded,
501
+ });
502
+ const assembly = prompts.assemble({
503
+ hardTokenBudget: Math.min(32000, Math.max(8000, Math.floor(contextWindow * 0.25))),
504
+ contributors: sections,
505
+ });
506
+ const cacheable = assembly.sections
507
+ .filter(section => section.cacheablePrefix)
508
+ .map(section => section.content)
509
+ .join('\n\n');
510
+ const dynamic = assembly.sections
511
+ .filter(section => !section.cacheablePrefix)
512
+ .map(section => section.content)
513
+ .join('\n\n');
514
+ return {
515
+ messages: [
516
+ ...(cacheable
517
+ ? [
518
+ {
519
+ role: 'system',
520
+ content: cacheable,
521
+ cacheControl: { type: 'ephemeral' },
522
+ },
523
+ ]
524
+ : []),
525
+ ...(dynamic ? [{ role: 'system', content: dynamic }] : []),
526
+ ...withoutOldSystem,
527
+ ],
528
+ receipt: assembly.receipt,
529
+ skillCatalog,
530
+ loadedSkills: skillSelection.loaded,
531
+ explicitSkillIds: skillSelection.explicitSkillIds,
532
+ };
533
+ }
534
+ function productPromptSections(input) {
535
+ const section = (value) => ({
536
+ ...value,
537
+ source: { id: value.sourceId, digest: (0, prompts_1.digestPromptSource)(value.content) },
538
+ });
539
+ return {
540
+ taskContext: [
541
+ section({
542
+ id: 'core.instructions',
543
+ sourceId: 'orion.core.v020',
544
+ authority: 'system',
545
+ priority: 1000,
546
+ tokenBudget: 12000,
547
+ mandatory: true,
548
+ atomic: true,
549
+ dynamic: false,
550
+ cacheability: 'cacheable',
551
+ redaction: 'none',
552
+ content: input.basePrompt.static,
553
+ }),
554
+ ],
555
+ project: [
556
+ section({
557
+ id: 'project.instructions',
558
+ sourceId: 'project.instructions',
559
+ authority: 'project',
560
+ priority: 900,
561
+ tokenBudget: 8000,
562
+ mandatory: false,
563
+ atomic: true,
564
+ dynamic: false,
565
+ cacheability: 'cacheable',
566
+ redaction: 'secrets',
567
+ content: input.projectInstructions,
568
+ enabled: Boolean(input.projectInstructions.trim()),
569
+ omissionReason: input.projectInstructions.trim() ? undefined : 'source_unavailable',
570
+ }),
571
+ section({
572
+ id: 'project.referenced-files',
573
+ sourceId: 'turn.referenced-files',
574
+ authority: 'user',
575
+ priority: 850,
576
+ tokenBudget: 8000,
577
+ mandatory: false,
578
+ atomic: true,
579
+ dynamic: true,
580
+ cacheability: 'non_cacheable',
581
+ redaction: 'secrets',
582
+ content: input.referencedFiles,
583
+ enabled: Boolean(input.referencedFiles.trim()),
584
+ omissionReason: input.referencedFiles.trim() ? undefined : 'not_applicable',
585
+ }),
586
+ ],
587
+ memory: [
588
+ section({
589
+ id: 'memory.relevant',
590
+ sourceId: 'project.memory',
591
+ authority: 'session',
592
+ priority: 800,
593
+ tokenBudget: 6000,
594
+ mandatory: false,
595
+ atomic: true,
596
+ dynamic: true,
597
+ cacheability: 'non_cacheable',
598
+ redaction: 'secrets',
599
+ content: input.memory ? `Project memory:\n${input.memory}` : '',
600
+ enabled: Boolean(input.memory.trim()),
601
+ omissionReason: input.memory.trim() ? undefined : 'source_unavailable',
602
+ }),
603
+ ],
604
+ skill: input.skills.map((skill, index) => section({
605
+ id: `skill.selected-${index + 1}`,
606
+ sourceId: `skill.${skill.definition.digest.slice(0, 24)}`,
607
+ authority: skill.receipt.actor === 'user' ? 'user' : 'system',
608
+ priority: 920 - index,
609
+ tokenBudget: 16000,
610
+ mandatory: false,
611
+ atomic: true,
612
+ dynamic: true,
613
+ cacheability: 'non_cacheable',
614
+ redaction: 'secrets',
615
+ content: [
616
+ `Selected Skill: ${skill.definition.name}`,
617
+ `Granted capabilities: ${skill.receipt.grantedCapabilities.join(', ') || 'none'}`,
618
+ skill.definition.body,
619
+ ].join('\n\n'),
620
+ })),
621
+ goal: [
622
+ section({
623
+ id: 'goal.active',
624
+ sourceId: 'goal.active',
625
+ authority: 'session',
626
+ priority: 950,
627
+ tokenBudget: 8000,
628
+ mandatory: false,
629
+ atomic: true,
630
+ dynamic: true,
631
+ cacheability: 'non_cacheable',
632
+ redaction: 'secrets',
633
+ content: input.goal ?? '',
634
+ enabled: Boolean(input.goal?.trim()),
635
+ omissionReason: input.goal?.trim() ? undefined : 'not_applicable',
636
+ }),
637
+ ],
638
+ mode: [
639
+ section({
640
+ id: 'runtime.saved-plan',
641
+ sourceId: input.plan ? `plan.${input.plan.digest.slice(0, 24)}` : 'plan.none',
642
+ authority: 'runtime',
643
+ priority: 1010,
644
+ tokenBudget: 16000,
645
+ mandatory: false,
646
+ atomic: true,
647
+ dynamic: true,
648
+ cacheability: 'non_cacheable',
649
+ redaction: 'secrets',
650
+ content: input.plan
651
+ ? [
652
+ '[Durable PlanReceipt V1]',
653
+ `Receipt: ${input.plan.digest}`,
654
+ `Planning turn: ${input.plan.turnId}`,
655
+ `Execution mode: ${input.plan.returnMode.toUpperCase()}`,
656
+ 'Execute this saved plan now; do not return to planning unless new evidence invalidates it.',
657
+ '',
658
+ input.plan.plan,
659
+ ].join('\n')
660
+ : '',
661
+ enabled: Boolean(input.plan),
662
+ omissionReason: input.plan ? undefined : 'not_applicable',
663
+ }),
664
+ section({
665
+ id: 'runtime.environment-mode',
666
+ sourceId: 'runtime.environment-mode',
667
+ authority: 'runtime',
668
+ priority: 1000,
669
+ tokenBudget: 4000,
670
+ mandatory: true,
671
+ atomic: true,
672
+ dynamic: true,
673
+ cacheability: 'non_cacheable',
674
+ redaction: 'secrets',
675
+ content: input.basePrompt.dynamic,
676
+ }),
677
+ ],
678
+ };
679
+ }
680
+ function latestDurableHistory(store) {
681
+ const commits = Object.values(store.loadProjection().turns)
682
+ .map(turn => turn.commit)
683
+ .filter((commit) => Boolean(commit))
684
+ .sort((left, right) => left.seq - right.seq);
685
+ const latest = commits.at(-1);
686
+ if (!latest)
687
+ return undefined;
688
+ const parsed = (0, turn_commit_1.parseTurnCommitV1)(latest.receipt);
689
+ const history = JSON.parse(parsed.history);
690
+ if (!Array.isArray(history) || !history.every(isMessage)) {
691
+ throw new Error('Durable TurnCommit contains an invalid model history.');
692
+ }
693
+ return history.map(message => ({ ...message }));
694
+ }
695
+ function projectRestoredTurnCommit(store, commit) {
696
+ const history = JSON.parse(commit.history);
697
+ const harnessState = JSON.parse(commit.taskContext);
698
+ if (!Array.isArray(history) || !history.every(isMessage)) {
699
+ throw new Error('Durable TurnCommit contains an invalid model history.');
700
+ }
701
+ if (!harnessState || typeof harnessState !== 'object' || Array.isArray(harnessState)) {
702
+ throw new Error('Durable TurnCommit contains an invalid TaskContext state.');
703
+ }
704
+ if ((0, canonical_1.digestRuntimeValue)(harnessState) !== commit.taskContextDigest) {
705
+ throw new Error('Durable TurnCommit TaskContext digest does not match its state.');
706
+ }
707
+ store.setState({
708
+ conversationHistory: history.map(message => ({ ...message })),
709
+ harnessState: structuredClone(harnessState),
710
+ });
711
+ }
712
+ function latestDurablePlanReceipt(store) {
713
+ const latest = Object.values(store.loadProjection().turns)
714
+ .map(turn => turn.commit)
715
+ .filter((commit) => Boolean(commit))
716
+ .sort((left, right) => left.seq - right.seq)
717
+ .at(-1);
718
+ if (!latest)
719
+ return undefined;
720
+ return planReceiptFromCommit((0, turn_commit_1.parseTurnCommitV1)(latest.receipt));
721
+ }
722
+ function planReceiptFromCommit(commit) {
723
+ if (!commit.planReceipt)
724
+ return undefined;
725
+ const receipt = (0, turn_commit_1.parsePlanReceiptV1)(commit.planReceipt);
726
+ if (commit.planReceiptDigest !== receipt.digest) {
727
+ throw new Error('Durable PlanReceipt digest differs from its TurnCommit binding.');
728
+ }
729
+ return receipt;
730
+ }
731
+ function extractDecisionCompletePlan(commit) {
732
+ const plan = commit.queryComplete.content.trim();
733
+ if (!plan)
734
+ throw new Error('PLAN finished without a decision-complete plan body.');
735
+ const persistedInHistory = [...commit.history]
736
+ .reverse()
737
+ .some(message => message.role === 'assistant' && message.content.trim() === plan);
738
+ if (!persistedInHistory) {
739
+ throw new Error('PLAN output is not present in the authoritative model history.');
740
+ }
741
+ return plan;
742
+ }
743
+ function createPlanStopDecision(commit, promptReceiptDigest) {
744
+ const stats = commit.queryComplete.stats;
745
+ const completion = commit.taskContextCompletion;
746
+ const tokenCount = (commit.queryComplete.usage?.promptTokens ?? 0) +
747
+ (commit.queryComplete.usage?.completionTokens ?? 0);
748
+ return (0, stop_decision_1.createStopDecision)({
749
+ scope: 'request',
750
+ status: 'completed',
751
+ disposition: 'finish_scope',
752
+ reason: {
753
+ code: 'plan_ready',
754
+ message: 'The planning phase produced a durable decision-complete plan.',
755
+ },
756
+ evidence: [
757
+ {
758
+ kind: 'runtime',
759
+ source: 'task-context',
760
+ detail: `revision=${commit.taskContextRevision};digest=${(0, canonical_1.digestRuntimeValue)(commit.taskContextState)}`,
761
+ },
762
+ {
763
+ kind: 'runtime',
764
+ source: 'prompt-registry',
765
+ detail: `receipt=${promptReceiptDigest}`,
766
+ },
767
+ ],
768
+ nextActions: [
769
+ {
770
+ kind: 'continue',
771
+ label: 'Execute the saved plan in the next logical turn.',
772
+ },
773
+ ],
774
+ resources: {
775
+ turns: { used: safeCounter(stats?.turnsStarted) },
776
+ llmRequests: { used: safeCounter(stats?.llmRequests) },
777
+ toolCalls: { used: safeCounter(stats?.toolCalls) },
778
+ tokens: { used: safeCounter(tokenCount) },
779
+ },
780
+ ...(completion?.criterionResults
781
+ ? {
782
+ criterionStates: completion.criterionResults.map(result => ({
783
+ id: result.criterionId,
784
+ status: result.status,
785
+ })),
786
+ }
787
+ : {}),
788
+ ...(completion?.progressDelta
789
+ ? {
790
+ progressDelta: structuredClone(completion.progressDelta),
791
+ }
792
+ : {}),
793
+ ...(completion?.stopDecision?.evidenceRefs
794
+ ? { evidenceRefs: [...completion.stopDecision.evidenceRefs] }
795
+ : {}),
796
+ resumable: false,
797
+ });
798
+ }
799
+ function safeCounter(value) {
800
+ return Number.isSafeInteger(value) && (value ?? -1) >= 0 ? value : 0;
801
+ }
802
+ function productPlanReturnMode(store) {
803
+ const snapshot = store.getSnapshot();
804
+ return snapshot.agentMode === 'auto' || snapshot.planReturnMode === 'auto' ? 'auto' : 'build';
805
+ }
806
+ function projectPlanReceipt(store, receipt) {
807
+ const agentMode = receipt.returnMode === 'auto' ? 'auto' : 'interactive';
808
+ store.setState({
809
+ agentMode,
810
+ planMode: false,
811
+ planReturnMode: agentMode,
812
+ currentPlan: receipt.plan,
813
+ });
814
+ }
815
+ function schedulePlanExecution(runtime, receipt, scheduled) {
816
+ if (scheduled.has(receipt.digest))
817
+ return;
818
+ const admission = runtime.thread.dispatch({
819
+ type: 'turn.start',
820
+ data: {
821
+ input: [
822
+ `Execute durable PlanReceipt ${receipt.digest}.`,
823
+ 'Continue autonomously from the saved plan and verify the implementation before finishing.',
824
+ ].join(' '),
825
+ mode: receipt.returnMode,
826
+ },
827
+ });
828
+ if (admission.status === 'rejected') {
829
+ throw new Error(`Saved plan execution was not admitted: ${admission.reason}.`);
830
+ }
831
+ if (admission.status !== 'started' && admission.status !== 'queued') {
832
+ throw new Error(`Saved plan execution returned unexpected admission: ${admission.status}.`);
833
+ }
834
+ scheduled.add(receipt.digest);
835
+ }
836
+ function legacyHistory(sessionId) {
837
+ return (0, session_history_recovery_1.normalizeSessionModelHistoryV1)((0, session_storage_1.readSessionMessages)(sessionId).map(message => ({
838
+ role: message.role,
839
+ content: message.modelVisibleContent ?? message.content,
840
+ ...(message.toolCallId ? { tool_call_id: message.toolCallId } : {}),
841
+ ...(message.tool_calls ? { tool_calls: structuredClone(message.tool_calls) } : {}),
842
+ })), 'legacy').messages.map(message => ({ ...message }));
843
+ }
844
+ function isMessage(value) {
845
+ if (!value || typeof value !== 'object')
846
+ return false;
847
+ const message = value;
848
+ return (['system', 'user', 'assistant', 'tool'].includes(message.role ?? '') &&
849
+ typeof message.content === 'string');
850
+ }
851
+ function createProductAuthority(options, mode) {
852
+ // AUTO is an explicit full-action consent mode. It bypasses interactive
853
+ // approval only; capability, containment, hard policy and sandbox checks
854
+ // remain unchanged and still precede execution.
855
+ const confirmation = mode === 'auto' ? 'allow' : options.config.toolConfirmation;
856
+ return (0, step_snapshot_1.createAuthoritySnapshotV1)({
857
+ authorityId: `project:${(0, canonical_1.digestRuntimeValue)(options.cwd).slice(0, 16)}:${mode ?? 'base'}`,
858
+ projectRoot: options.cwd,
859
+ confirmation,
860
+ filesystem: 'workspace',
861
+ network: confirmation === 'deny' ? 'deny' : 'write',
862
+ });
863
+ }
864
+ async function loadSelectedSkills(input, catalog, composition, authority) {
865
+ const explicit = parseExplicitSkillSelector(input);
866
+ const selected = selectSkillDescriptors(input, catalog.descriptors, explicit);
867
+ const allowedCapabilities = skillAuthorityCapabilities(authority);
868
+ const skillAuthority = Object.freeze({
869
+ authorityId: authority.authorityId,
870
+ digest: (0, canonical_1.digestRuntimeValue)({
871
+ authorityDigest: authority.digest,
872
+ allowedCapabilities,
873
+ }),
874
+ allowedCapabilities,
875
+ deniedCapabilityReasons: authority.network === 'deny'
876
+ ? Object.freeze({ network: 'Project Authority denies network access.' })
877
+ : undefined,
878
+ });
879
+ const loaded = [];
880
+ for (const descriptor of selected.slice(0, 3)) {
881
+ loaded.push(await composition.skills.getDefinition({
882
+ catalog,
883
+ skillId: descriptor.id,
884
+ actor: explicit ? 'user' : 'model',
885
+ reason: explicit ? `Explicit Skill selection: ${explicit}` : 'Matched current task intent.',
886
+ authority: skillAuthority,
887
+ }));
888
+ }
889
+ const explicitSkillIds = explicit
890
+ ? [
891
+ catalog.descriptors.find(descriptor => normalizeLookup(descriptor.id) === normalizeLookup(explicit) ||
892
+ normalizeLookup(descriptor.name) === normalizeLookup(explicit))?.id ?? explicit,
893
+ ]
894
+ : loaded.map(skill => skill.definition.id);
895
+ return Object.freeze({ loaded: Object.freeze(loaded), explicitSkillIds });
896
+ }
897
+ function parseExplicitSkillSelector(input) {
898
+ const command = input.trim().match(/^\/(?:skill|use-skill|activate-skill)\s+([^\s]+)/iu);
899
+ const dollar = input.trim().match(/^\$([A-Za-z\p{L}][\w\p{L}-]*)\b/u);
900
+ const value = command?.[1] ?? dollar?.[1];
901
+ if (!value)
902
+ return undefined;
903
+ return value.replace(/^[$@#]+/u, '').trim();
904
+ }
905
+ function selectSkillDescriptors(input, descriptors, explicit) {
906
+ if (explicit) {
907
+ const key = normalizeLookup(explicit);
908
+ return descriptors.filter(descriptor => normalizeLookup(descriptor.id) === key || normalizeLookup(descriptor.name) === key);
909
+ }
910
+ const task = normalizeLookup(input);
911
+ return descriptors.filter(descriptor => descriptor.modelInvocable &&
912
+ normalizeLookup(descriptor.name).length >= 3 &&
913
+ task.includes(normalizeLookup(descriptor.name)));
914
+ }
915
+ function skillAuthorityCapabilities(authority) {
916
+ const values = new Set(['read', 'workspace_read', 'read_file', 'list_files', 'glob', 'grep']);
917
+ if (authority.confirmation !== 'deny') {
918
+ for (const value of ['write', 'workspace_write', 'write_file', 'edit_file', 'exec_command']) {
919
+ values.add(value);
920
+ }
921
+ }
922
+ if (authority.network !== 'deny') {
923
+ for (const value of ['network', 'web', 'web_search', 'web_fetch'])
924
+ values.add(value);
925
+ }
926
+ return Object.freeze([...values].sort());
927
+ }
928
+ async function resolveMcpToolsForStep(input, runtime, catalog) {
929
+ const server = selectMcpServer(input.input, catalog);
930
+ if (!server)
931
+ return undefined;
932
+ const ownerId = input.turnId;
933
+ const existing = runtime
934
+ .bindingSnapshotForOwner(ownerId)
935
+ .servers.some(binding => binding.serverId === server.id);
936
+ if (!existing) {
937
+ await runtime.acquire({
938
+ catalog,
939
+ serverId: server.id,
940
+ ownerId,
941
+ reason: 'explicit',
942
+ signal: input.abortSignal,
943
+ });
944
+ }
945
+ const bindings = chooseMcpBindings(input.input, runtime.toolBindingsForOwner(ownerId));
946
+ const candidates = [];
947
+ const registry = new Map();
948
+ for (const binding of bindings) {
949
+ const bindingId = `mcp:${binding.descriptor.bindingDigest}`;
950
+ const risk = Object.freeze({
951
+ readOnly: false,
952
+ destructive: true,
953
+ fileEdit: false,
954
+ effect: 'external_write',
955
+ network: 'write',
956
+ });
957
+ const descriptor = Object.freeze({
958
+ name: binding.descriptor.qualifiedName,
959
+ aliases: Object.freeze([]),
960
+ description: binding.descriptor.description,
961
+ inputSchema: binding.descriptor.inputSchema,
962
+ schemaDigest: binding.descriptor.schemaDigest,
963
+ executorId: bindingId,
964
+ risk,
965
+ });
966
+ candidates.push(Object.freeze({
967
+ bindingId,
968
+ descriptor,
969
+ tier: 'long_tail',
970
+ source: 'mcp',
971
+ keywords: Object.freeze([
972
+ binding.descriptor.serverId,
973
+ binding.descriptor.name,
974
+ binding.descriptor.qualifiedName,
975
+ ]),
976
+ mcp: Object.freeze({
977
+ serverId: binding.descriptor.serverId,
978
+ bindingDigest: binding.descriptor.bindingDigest,
979
+ }),
980
+ }));
981
+ registry.set(bindingId, Object.freeze({
982
+ descriptor,
983
+ execute: async (args, context) => {
984
+ try {
985
+ const result = await binding.invoke(args, context.abortSignal);
986
+ return { success: true, output: renderMcpResult(result) };
987
+ }
988
+ catch (error) {
989
+ const message = error instanceof Error ? error.message : String(error);
990
+ return { success: false, output: '', error: message };
991
+ }
992
+ },
993
+ }));
994
+ }
995
+ return candidates.length === 0
996
+ ? undefined
997
+ : Object.freeze({ candidates: Object.freeze(candidates), bindings: registry });
998
+ }
999
+ function selectMcpServer(input, catalog) {
1000
+ const task = normalizeLookup(input);
1001
+ const explicit = input.trim().match(/^\/mcp\s+([^\s]+)/iu)?.[1];
1002
+ const explicitKey = explicit ? normalizeLookup(explicit) : undefined;
1003
+ return catalog.descriptors.find(descriptor => {
1004
+ if (descriptor.disabled)
1005
+ return false;
1006
+ const identities = [descriptor.id, descriptor.name, ...descriptor.tags]
1007
+ .map(normalizeLookup)
1008
+ .filter(value => value.length >= 2);
1009
+ return explicitKey
1010
+ ? identities.includes(explicitKey)
1011
+ : identities.some(identity => task.includes(identity));
1012
+ });
1013
+ }
1014
+ function chooseMcpBindings(input, bindings) {
1015
+ const task = normalizeLookup(input);
1016
+ const ranked = [...bindings].sort((left, right) => {
1017
+ const leftRelevant = task.includes(normalizeLookup(left.descriptor.name)) ? 1 : 0;
1018
+ const rightRelevant = task.includes(normalizeLookup(right.descriptor.name)) ? 1 : 0;
1019
+ return (rightRelevant - leftRelevant ||
1020
+ left.descriptor.qualifiedName.localeCompare(right.descriptor.qualifiedName));
1021
+ });
1022
+ const relevant = ranked.filter(binding => task.includes(normalizeLookup(binding.descriptor.name)));
1023
+ return Object.freeze((relevant.length > 0 ? relevant : ranked).slice(0, 4));
1024
+ }
1025
+ function normalizeLookup(value) {
1026
+ return value
1027
+ .normalize('NFKC')
1028
+ .toLocaleLowerCase('en-US')
1029
+ .replace(/[^\p{L}\p{N}]+/gu, ' ')
1030
+ .trim();
1031
+ }
1032
+ function renderMcpResult(value) {
1033
+ if (typeof value === 'string')
1034
+ return value;
1035
+ try {
1036
+ return JSON.stringify(value);
1037
+ }
1038
+ catch {
1039
+ return String(value);
1040
+ }
1041
+ }
1042
+ const INERT_MCP_CONNECTOR = Object.freeze({
1043
+ connect: async () => {
1044
+ throw new Error('No MCP connector is configured for this OrionRuntime.');
1045
+ },
1046
+ });
1047
+ //# sourceMappingURL=product-orion-runtime.js.map