@orion-agents/orion-code 0.3.66 → 0.4.4

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 (384) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +78 -361
  3. package/README.zh-CN.md +71 -262
  4. package/bin/orion +4 -1
  5. package/dist/acp/session-updates.d.ts +35 -0
  6. package/dist/acp/session-updates.js +183 -0
  7. package/dist/acp/sessions.d.ts +32 -0
  8. package/dist/acp/sessions.js +328 -0
  9. package/dist/acp/stdio.d.ts +3 -0
  10. package/dist/acp/stdio.js +59 -0
  11. package/dist/cli.js +136 -185
  12. package/dist/commands/context-tool-command-handlers.d.ts +1 -1
  13. package/dist/commands/context-tool-command-handlers.js +24 -3
  14. package/dist/commands/core-command-handlers.js +10 -18
  15. package/dist/commands/diagnostic-command-handlers.js +58 -48
  16. package/dist/commands/diagnostic-commands.js +0 -12
  17. package/dist/commands/init-command.d.ts +3 -0
  18. package/dist/commands/init-command.js +131 -0
  19. package/dist/commands/model-command-handlers.d.ts +1 -2
  20. package/dist/commands/model-command-handlers.js +15 -100
  21. package/dist/commands/model-commands.js +0 -11
  22. package/dist/commands/registry.js +1 -19
  23. package/dist/commands/rsi-command.d.ts +2 -0
  24. package/dist/commands/rsi-command.js +180 -0
  25. package/dist/commands/session-command-handlers.js +28 -19
  26. package/dist/commands/system-commands.js +0 -1
  27. package/dist/commands/target-command.js +49 -6
  28. package/dist/commands/tool-commands.js +1 -1
  29. package/dist/commands/types.d.ts +4 -10
  30. package/dist/commands/types.js +1 -21
  31. package/dist/commands/workflow-command-handlers.js +13 -4
  32. package/dist/commands/workflow-commands.js +2 -2
  33. package/dist/framework/loop-budget-contract.d.ts +2 -8
  34. package/dist/framework/loop-budget-contract.js +0 -3
  35. package/dist/framework/loop-progress.d.ts +18 -0
  36. package/dist/framework/loop-progress.js +63 -0
  37. package/dist/framework/prompt.d.ts +0 -2
  38. package/dist/framework/prompt.js +9 -27
  39. package/dist/framework/query.d.ts +26 -31
  40. package/dist/framework/query.js +451 -292
  41. package/dist/framework/store.d.ts +6 -10
  42. package/dist/framework/store.js +2 -21
  43. package/dist/framework/tool-call-orchestrator.d.ts +7 -0
  44. package/dist/framework/tool-call-orchestrator.js +8 -3
  45. package/dist/framework/tool-state.d.ts +2 -0
  46. package/dist/framework/tool.d.ts +0 -23
  47. package/dist/framework/verification-command.d.ts +15 -0
  48. package/dist/framework/verification-command.js +32 -0
  49. package/dist/harness/assembler.d.ts +1 -0
  50. package/dist/harness/assembler.js +24 -0
  51. package/dist/harness/capsule.d.ts +1 -1
  52. package/dist/harness/capsule.js +33 -14
  53. package/dist/harness/context-harness.d.ts +37 -12
  54. package/dist/harness/context-harness.js +545 -35
  55. package/dist/harness/contract.js +1 -1
  56. package/dist/harness/drift-guard.d.ts +4 -0
  57. package/dist/harness/drift-guard.js +68 -16
  58. package/dist/harness/index.d.ts +1 -1
  59. package/dist/harness/intent.js +21 -0
  60. package/dist/harness/ledger.d.ts +7 -11
  61. package/dist/harness/ledger.js +50 -9
  62. package/dist/harness/progress-controller.d.ts +12 -7
  63. package/dist/harness/progress-controller.js +96 -29
  64. package/dist/harness/state.js +10 -1
  65. package/dist/harness/stop-controller.d.ts +0 -5
  66. package/dist/harness/stop-controller.js +11 -31
  67. package/dist/harness/task-checklist.d.ts +16 -0
  68. package/dist/harness/task-checklist.js +92 -0
  69. package/dist/harness/types.d.ts +78 -1
  70. package/dist/harness/verification.d.ts +19 -1
  71. package/dist/harness/verification.js +116 -29
  72. package/dist/index.d.ts +1 -1
  73. package/dist/index.js +1 -3
  74. package/dist/print-ui/event-stream.d.ts +43 -0
  75. package/dist/print-ui/event-stream.js +204 -0
  76. package/dist/print-ui/launch.d.ts +12 -1
  77. package/dist/print-ui/launch.js +173 -11
  78. package/dist/product/environment.d.ts +1 -1
  79. package/dist/product/environment.js +1 -1
  80. package/dist/product/identity.d.ts +1 -1
  81. package/dist/product/identity.js +1 -1
  82. package/dist/product/paths.d.ts +3 -2
  83. package/dist/product/paths.js +6 -2
  84. package/dist/runtime/agent-loop.d.ts +12 -2
  85. package/dist/runtime/agent-loop.js +172 -29
  86. package/dist/runtime/agent-runtime-controller.d.ts +14 -4
  87. package/dist/runtime/agent-runtime-controller.js +366 -192
  88. package/dist/runtime/agent-runtime-protocol.d.ts +10 -18
  89. package/dist/runtime/agent-runtime-runner.d.ts +10 -0
  90. package/dist/runtime/builtin-tool-provider.js +5 -1
  91. package/dist/runtime/capability-receipt-journal.js +1 -0
  92. package/dist/runtime/durable-tool-receipt-reader.js +2 -1
  93. package/dist/runtime/first-party-tool-services.d.ts +1 -0
  94. package/dist/runtime/first-party-tool-services.js +2 -12
  95. package/dist/runtime/first-party-tool-universe.d.ts +1 -0
  96. package/dist/runtime/first-party-tool-universe.js +1 -1
  97. package/dist/runtime/followup-queue-store.d.ts +16 -0
  98. package/dist/runtime/followup-queue-store.js +75 -0
  99. package/dist/runtime/goal-lifecycle-v2.d.ts +16 -4
  100. package/dist/runtime/goal-lifecycle-v2.js +217 -39
  101. package/dist/runtime/goal-runtime-coordinator.d.ts +14 -2
  102. package/dist/runtime/goal-runtime-coordinator.js +147 -36
  103. package/dist/runtime/goals/presentation.js +3 -1
  104. package/dist/runtime/goals/types.d.ts +1 -3
  105. package/dist/runtime/goals/types.js +0 -3
  106. package/dist/runtime/loop-budget.d.ts +0 -7
  107. package/dist/runtime/loop-budget.js +8 -52
  108. package/dist/runtime/mcp/first-party-mcp-adapter.d.ts +2 -0
  109. package/dist/runtime/mcp/first-party-mcp-adapter.js +23 -19
  110. package/dist/runtime/model-coordinator.js +2 -5
  111. package/dist/runtime/orion-runtime-v1.d.ts +18 -2
  112. package/dist/runtime/orion-runtime-v1.js +183 -46
  113. package/dist/runtime/orion-session-runner.d.ts +7 -0
  114. package/dist/runtime/orion-session-runner.js +82 -0
  115. package/dist/runtime/plan-review.d.ts +1 -0
  116. package/dist/runtime/plan-review.js +8 -4
  117. package/dist/runtime/product-bootstrap.d.ts +6 -0
  118. package/dist/runtime/product-bootstrap.js +41 -51
  119. package/dist/runtime/product-orion-runtime.js +129 -58
  120. package/dist/runtime/release-receipts.d.ts +24 -133
  121. package/dist/runtime/release-receipts.js +129 -693
  122. package/dist/runtime/rich-text/layout.js +108 -65
  123. package/dist/runtime/rsi/contracts.d.ts +50 -0
  124. package/dist/runtime/rsi/contracts.js +17 -0
  125. package/dist/runtime/rsi/diagnosis.d.ts +46 -0
  126. package/dist/runtime/rsi/diagnosis.js +98 -0
  127. package/dist/runtime/rsi/evaluation-suite.d.ts +25 -0
  128. package/dist/runtime/rsi/evaluation-suite.js +141 -0
  129. package/dist/runtime/rsi/evaluation-worker.d.ts +19 -0
  130. package/dist/runtime/rsi/evaluation-worker.js +64 -0
  131. package/dist/runtime/rsi/evaluation.d.ts +49 -0
  132. package/dist/runtime/rsi/evaluation.js +345 -0
  133. package/dist/runtime/rsi/lifecycle.d.ts +54 -0
  134. package/dist/runtime/rsi/lifecycle.js +279 -0
  135. package/dist/runtime/rsi/proposal.d.ts +39 -0
  136. package/dist/runtime/rsi/proposal.js +312 -0
  137. package/dist/runtime/rsi/receipt.d.ts +28 -0
  138. package/dist/runtime/rsi/receipt.js +138 -0
  139. package/dist/runtime/rsi/skill-state.d.ts +7 -0
  140. package/dist/runtime/rsi/skill-state.js +50 -0
  141. package/dist/runtime/rsi/trajectory.d.ts +19 -0
  142. package/dist/runtime/rsi/trajectory.js +314 -0
  143. package/dist/runtime/rsi/triage.d.ts +274 -0
  144. package/dist/runtime/rsi/triage.js +58 -0
  145. package/dist/runtime/session-composer-control.d.ts +5 -24
  146. package/dist/runtime/session-composer-control.js +27 -189
  147. package/dist/runtime/step-snapshot.d.ts +4 -1
  148. package/dist/runtime/step-snapshot.js +11 -1
  149. package/dist/runtime/subagent-thread-runtime.js +27 -5
  150. package/dist/runtime/subagents/policy.js +0 -1
  151. package/dist/runtime/subagents/production.js +1 -5
  152. package/dist/runtime/subagents/runtime-integration.js +2 -4
  153. package/dist/runtime/subagents/types.d.ts +0 -5
  154. package/dist/runtime/subagents/types.js +0 -2
  155. package/dist/runtime/task-context-recovery.d.ts +55 -0
  156. package/dist/runtime/task-context-recovery.js +349 -0
  157. package/dist/runtime/task-context-service.d.ts +20 -10
  158. package/dist/runtime/task-context-service.js +69 -9
  159. package/dist/runtime/thread-admission.d.ts +3 -1
  160. package/dist/runtime/thread-admission.js +21 -7
  161. package/dist/runtime/thread-event-store.d.ts +2 -2
  162. package/dist/runtime/thread-event-store.js +7 -2
  163. package/dist/runtime/thread-projection.js +4 -2
  164. package/dist/runtime/thread-runtime.d.ts +10 -0
  165. package/dist/runtime/thread-runtime.js +85 -3
  166. package/dist/runtime/thread-session-index.d.ts +8 -0
  167. package/dist/runtime/thread-session-index.js +50 -1
  168. package/dist/runtime/thread-session-view.d.ts +2 -1
  169. package/dist/runtime/thread-session-view.js +4 -0
  170. package/dist/runtime/thread-tool-journal.d.ts +1 -0
  171. package/dist/runtime/thread-tool-journal.js +6 -2
  172. package/dist/runtime/thread-ui-adapter.d.ts +1 -0
  173. package/dist/runtime/thread-ui-adapter.js +89 -22
  174. package/dist/runtime/tool-gateway.d.ts +9 -0
  175. package/dist/runtime/tool-gateway.js +24 -0
  176. package/dist/runtime/tool-receipt-validator.js +4 -0
  177. package/dist/runtime/tool-transcript-entry.d.ts +16 -0
  178. package/dist/runtime/tool-transcript-entry.js +73 -0
  179. package/dist/runtime/turn-commit.d.ts +4 -1
  180. package/dist/runtime/turn-commit.js +19 -15
  181. package/dist/runtime/ui-events.d.ts +15 -1
  182. package/dist/runtime/ui-view-model.d.ts +6 -5
  183. package/dist/runtime/ui-view-model.js +78 -61
  184. package/dist/runtime/workspace-runtime-kernel.js +0 -1
  185. package/dist/runtime/workspace-verification.d.ts +7 -0
  186. package/dist/runtime/workspace-verification.js +83 -0
  187. package/dist/services/atomic-write.d.ts +2 -0
  188. package/dist/services/atomic-write.js +12 -1
  189. package/dist/services/code-review/format.d.ts +4 -1
  190. package/dist/services/code-review/format.js +5 -1
  191. package/dist/services/code-review/runner.d.ts +2 -2
  192. package/dist/services/code-review/runner.js +86 -64
  193. package/dist/services/code-review/snapshot.d.ts +9 -9
  194. package/dist/services/code-review/snapshot.js +182 -166
  195. package/dist/services/compact/auto-compact.d.ts +21 -6
  196. package/dist/services/compact/auto-compact.js +148 -22
  197. package/dist/services/compact/background-candidate.d.ts +33 -0
  198. package/dist/services/compact/background-candidate.js +184 -0
  199. package/dist/services/compact/compact.d.ts +4 -1
  200. package/dist/services/compact/compact.js +30 -3
  201. package/dist/services/compact/coordinator.d.ts +10 -4
  202. package/dist/services/compact/coordinator.js +17 -7
  203. package/dist/services/compact/summary-generator.d.ts +4 -2
  204. package/dist/services/compact/summary-generator.js +17 -3
  205. package/dist/services/config.d.ts +5 -5
  206. package/dist/services/config.js +29 -48
  207. package/dist/services/doctor.js +85 -13
  208. package/dist/services/effort.d.ts +5 -5
  209. package/dist/services/effort.js +5 -11
  210. package/dist/services/file-lock.d.ts +9 -3
  211. package/dist/services/file-lock.js +92 -26
  212. package/dist/services/global-config.d.ts +26 -64
  213. package/dist/services/global-config.js +233 -193
  214. package/dist/services/llm.d.ts +42 -4
  215. package/dist/services/llm.js +177 -45
  216. package/dist/services/model-client-pool.d.ts +15 -9
  217. package/dist/services/model-client-pool.js +62 -33
  218. package/dist/services/model-context.d.ts +2 -1
  219. package/dist/services/model-context.js +15 -9
  220. package/dist/services/model-registry.d.ts +4 -15
  221. package/dist/services/model-registry.js +32 -101
  222. package/dist/services/provider-diagnostics.d.ts +8 -0
  223. package/dist/services/provider-diagnostics.js +17 -12
  224. package/dist/services/provider-resilience/coordinator.d.ts +1 -1
  225. package/dist/services/provider-resilience/coordinator.js +10 -6
  226. package/dist/services/provider-resilience/request-gate.d.ts +3 -0
  227. package/dist/services/provider-resilience/request-gate.js +29 -18
  228. package/dist/services/provider-resilience/types.d.ts +2 -0
  229. package/dist/services/session-storage.d.ts +7 -10
  230. package/dist/services/session-storage.js +57 -30
  231. package/dist/services/settings-coordinator.d.ts +0 -6
  232. package/dist/services/settings-coordinator.js +19 -56
  233. package/dist/services/settings-document-repository.d.ts +3 -10
  234. package/dist/services/settings-document-repository.js +7 -85
  235. package/dist/services/usage-state.d.ts +3 -3
  236. package/dist/services/usage-state.js +11 -42
  237. package/dist/terminal-ui/answer-format.d.ts +14 -0
  238. package/dist/terminal-ui/answer-format.js +119 -0
  239. package/dist/terminal-ui/launch.d.ts +7 -6
  240. package/dist/terminal-ui/launch.js +160 -70
  241. package/dist/terminal-ui/output-queue.d.ts +2 -1
  242. package/dist/terminal-ui/output-queue.js +1 -1
  243. package/dist/terminal-ui/raw-editor.d.ts +2 -1
  244. package/dist/terminal-ui/raw-editor.js +56 -15
  245. package/dist/tools/core/edit-file.js +6 -2
  246. package/dist/tools/core/write-file.js +9 -2
  247. package/dist/tools/lsp.d.ts +16 -1
  248. package/dist/tools/lsp.js +60 -19
  249. package/dist/tools/sandbox.d.ts +1 -1
  250. package/dist/tools/sandbox.js +3 -16
  251. package/dist/tools/todo.d.ts +4 -2
  252. package/dist/tools/todo.js +91 -30
  253. package/dist/tui-core/input-parser.d.ts +1 -0
  254. package/dist/tui-core/input-parser.js +6 -0
  255. package/dist/tui-core/style.d.ts +1 -8
  256. package/dist/tui-core/style.js +3 -110
  257. package/dist/tui-ui/chrome-view-model.d.ts +1 -1
  258. package/dist/tui-ui/chrome-view-model.js +36 -32
  259. package/dist/tui-ui/launch.js +14 -14
  260. package/dist/tui-ui/layout.d.ts +5 -7
  261. package/dist/tui-ui/layout.js +129 -124
  262. package/dist/tui-ui/runner.d.ts +11 -12
  263. package/dist/tui-ui/runner.js +88 -67
  264. package/dist/tui-ui/state.d.ts +0 -11
  265. package/dist/tui-ui/state.js +22 -33
  266. package/dist/tui-ui/terminal-image.js +22 -4
  267. package/dist/tui-ui/transcript-inspector-layout.js +6 -3
  268. package/dist/tui-ui/transcript-inspector.d.ts +1 -0
  269. package/dist/tui-ui/transcript-inspector.js +7 -1
  270. package/dist/tui-ui/transcript-layout.js +42 -6
  271. package/dist/utils/terminal-text.d.ts +11 -0
  272. package/dist/utils/terminal-text.js +114 -0
  273. package/docs/cli-guide.md +575 -0
  274. package/docs/orion.example.yaml +43 -0
  275. package/docs/readme.md +12 -57
  276. package/npm-shrinkwrap.json +484 -1855
  277. package/package.json +13 -63
  278. package/dist/migration/command.d.ts +0 -9
  279. package/dist/migration/command.js +0 -100
  280. package/dist/migration/index.d.ts +0 -7
  281. package/dist/migration/index.js +0 -14
  282. package/dist/migration/migrate.d.ts +0 -19
  283. package/dist/migration/migrate.js +0 -406
  284. package/dist/migration/types.d.ts +0 -55
  285. package/dist/migration/types.js +0 -6
  286. package/dist/services/tool-allowlist.d.ts +0 -110
  287. package/dist/services/tool-allowlist.js +0 -299
  288. package/dist/services/yaml-config.d.ts +0 -57
  289. package/dist/services/yaml-config.js +0 -178
  290. package/dist/web/cli-options.d.ts +0 -17
  291. package/dist/web/cli-options.js +0 -51
  292. package/dist/web/code-review-run-service.d.ts +0 -68
  293. package/dist/web/code-review-run-service.js +0 -228
  294. package/dist/web/context-text.d.ts +0 -17
  295. package/dist/web/context-text.js +0 -40
  296. package/dist/web/errors.d.ts +0 -6
  297. package/dist/web/errors.js +0 -13
  298. package/dist/web/event-hub.d.ts +0 -45
  299. package/dist/web/event-hub.js +0 -370
  300. package/dist/web/file-read-service.d.ts +0 -101
  301. package/dist/web/file-read-service.js +0 -593
  302. package/dist/web/file-write-service.d.ts +0 -16
  303. package/dist/web/file-write-service.js +0 -103
  304. package/dist/web/git-compare-service.d.ts +0 -45
  305. package/dist/web/git-compare-service.js +0 -160
  306. package/dist/web/git-diff-document.d.ts +0 -102
  307. package/dist/web/git-diff-document.js +0 -258
  308. package/dist/web/git-file-source.d.ts +0 -25
  309. package/dist/web/git-file-source.js +0 -21
  310. package/dist/web/git-history-service.d.ts +0 -151
  311. package/dist/web/git-history-service.js +0 -619
  312. package/dist/web/git-index-transaction.d.ts +0 -45
  313. package/dist/web/git-index-transaction.js +0 -174
  314. package/dist/web/git-patch-builder.d.ts +0 -30
  315. package/dist/web/git-patch-builder.js +0 -138
  316. package/dist/web/git-read-model-service.d.ts +0 -452
  317. package/dist/web/git-read-model-service.js +0 -1833
  318. package/dist/web/git-version-service.d.ts +0 -79
  319. package/dist/web/git-version-service.js +0 -279
  320. package/dist/web/host-daemon.d.ts +0 -70
  321. package/dist/web/host-daemon.js +0 -237
  322. package/dist/web/index.d.ts +0 -6
  323. package/dist/web/index.js +0 -28
  324. package/dist/web/launch.d.ts +0 -12
  325. package/dist/web/launch.js +0 -89
  326. package/dist/web/native-directory-picker.d.ts +0 -63
  327. package/dist/web/native-directory-picker.js +0 -169
  328. package/dist/web/protocol.d.ts +0 -705
  329. package/dist/web/protocol.js +0 -639
  330. package/dist/web/review-service.d.ts +0 -22
  331. package/dist/web/review-service.js +0 -68
  332. package/dist/web/server.d.ts +0 -20
  333. package/dist/web/server.js +0 -1453
  334. package/dist/web/session-runtime-registry.d.ts +0 -138
  335. package/dist/web/session-runtime-registry.js +0 -471
  336. package/dist/web/terminal-manager.d.ts +0 -156
  337. package/dist/web/terminal-manager.js +0 -779
  338. package/dist/web/terminal-server.d.ts +0 -8
  339. package/dist/web/terminal-server.js +0 -304
  340. package/dist/web/workbench-controller.d.ts +0 -395
  341. package/dist/web/workbench-controller.js +0 -3077
  342. package/dist/web/workspace-discovery.d.ts +0 -92
  343. package/dist/web/workspace-discovery.js +0 -324
  344. package/dist/web/workspace-mutation-arbiter.d.ts +0 -54
  345. package/dist/web/workspace-mutation-arbiter.js +0 -267
  346. package/dist/web/workspace-open-telemetry.d.ts +0 -55
  347. package/dist/web/workspace-open-telemetry.js +0 -73
  348. package/dist/web-client/assets/FilesPanel-CPDovK_K.js +0 -1
  349. package/dist/web-client/assets/GitPanel-DtU_TD61.js +0 -4
  350. package/dist/web-client/assets/ReviewPanel-vMO7BEA3.js +0 -6
  351. package/dist/web-client/assets/TerminalPanel-C9vDTAlS.js +0 -23
  352. package/dist/web-client/assets/TerminalPanel-DLuoa74B.css +0 -1
  353. package/dist/web-client/assets/index-CABdwh4l.css +0 -1
  354. package/dist/web-client/assets/index-KvshfEbl.js +0 -20
  355. package/dist/web-client/assets/useAutoNotice-IE1g2wcb.js +0 -1
  356. package/dist/web-client/favicon.svg +0 -9
  357. package/dist/web-client/index.html +0 -17
  358. package/docs/architecture/agent-mode-permission-contract.md +0 -87
  359. package/docs/architecture/v0.3.0-web-api.yaml +0 -1340
  360. package/docs/architecture/v0.3.1-web-api.yaml +0 -2338
  361. package/docs/architecture/v0.3.2-web-api.yaml +0 -3029
  362. package/docs/architecture/v0.3.3-web-api.yaml +0 -3205
  363. package/docs/architecture/v0.3.4-stabilization-contract.md +0 -32
  364. package/docs/migration/v0.1.9-to-v0.2.0.md +0 -98
  365. package/docs/migration/v0.2.2-to-v0.3.0-settings.md +0 -114
  366. package/docs/migration/v0.2.2-to-v0.3.0.md +0 -55
  367. package/docs/migration/v0.3.0-to-v0.3.1.md +0 -88
  368. package/docs/migration/v0.3.1-to-v0.3.2.md +0 -94
  369. package/docs/migration/v0.3.2-to-v0.3.3.md +0 -62
  370. package/docs/migration/v0.3.3-to-v0.3.4.md +0 -36
  371. package/docs/orion.example.json +0 -86
  372. package/docs/plan/v0.2.0-dsh-harness-redesign-plan.md +0 -1234
  373. package/docs/plan/v0.2.0-release-checklist.md +0 -91
  374. package/docs/plan/v0.3.0-node-runtime-compatibility-plan.md +0 -57
  375. package/docs/plan/v0.3.0-settings-integration-plan.md +0 -740
  376. package/docs/plan/v0.3.0-web-workbench-plan.md +0 -376
  377. package/docs/plan/v0.3.1-web-workbench-professional-shell-plan.md +0 -848
  378. package/docs/plan/v0.3.2-web-workbench-layout-and-composer-plan.md +0 -869
  379. package/docs/plan/v0.3.3-plan.md +0 -1113
  380. package/docs/plan/v0.3.4-stabilization-plan.md +0 -89
  381. package/docs/test/v0.3.1-web-workbench-e2e-plan.md +0 -140
  382. package/docs/test/v0.3.2-web-workbench-e2e-plan.md +0 -100
  383. package/docs/test/v0.3.3-web-workbench-e2e-plan.md +0 -79
  384. package/docs/test/v0.3.4-stabilization-e2e-plan.md +0 -54
@@ -12,7 +12,17 @@ const style_1 = require("../../tui-core/style");
12
12
  function layoutRichText(doc, options) {
13
13
  const width = normalizeWidth(options.width);
14
14
  const indent = normalizeIndent(options.indent ?? 0, width);
15
- return doc.blocks.flatMap(block => layoutBlock(block, width, options.theme, indent));
15
+ const rows = [];
16
+ for (const block of doc.blocks) {
17
+ const blockRows = layoutBlock(block, width, options.theme, indent);
18
+ if (blockRows.length === 0)
19
+ continue;
20
+ if (rows.length > 0)
21
+ rows.push([]);
22
+ for (const row of blockRows)
23
+ rows.push(row);
24
+ }
25
+ return rows;
16
26
  }
17
27
  function layoutBlock(block, width, theme, indent) {
18
28
  switch (block.type) {
@@ -47,7 +57,7 @@ function layoutInline(spans, width, theme, baseStyle, indent) {
47
57
  text: span.text,
48
58
  style: resolveSpanStyle(span, baseStyle, theme),
49
59
  }));
50
- return layoutPrefixedSpans(styled, width, prefix, prefix, true);
60
+ return layoutPrefixedSpans(styled, width, prefix, prefix, 'word');
51
61
  }
52
62
  function layoutList(block, width, theme, indent) {
53
63
  const rows = [];
@@ -69,7 +79,7 @@ function layoutList(block, width, theme, indent) {
69
79
  text: span.text,
70
80
  style: resolveSpanStyle(span, base, theme),
71
81
  }));
72
- rows.push(...layoutPrefixedSpans(styled, width, firstPrefix, continuationPrefix, true));
82
+ rows.push(...layoutPrefixedSpans(styled, width, firstPrefix, continuationPrefix, 'word'));
73
83
  return;
74
84
  }
75
85
  if (blockIndex === 0) {
@@ -114,10 +124,14 @@ function layoutCode(lines, width, theme, indent, language) {
114
124
  rows.push(clampRow([...labelPrefix, ...padRow([{ text: label, style: labelStyle }], available, labelStyle)], width));
115
125
  }
116
126
  for (const line of lines.length > 0 ? lines : ['']) {
117
- const wrapped = wrapStyledSpans([{ text: line, style }], available, false);
118
- for (const row of wrapped) {
119
- rows.push(clampRow([...prefix, ...padRow(row, available, style)], width));
120
- }
127
+ const gutter = available >= 6 && (0, string_width_1.default)(line) > available ? 2 : 0;
128
+ const wrapped = wrapStyledSpans([{ text: line, style }], available - gutter, 'code');
129
+ wrapped.forEach((row, index) => {
130
+ const continuation = gutter > 0
131
+ ? [{ text: index === 0 ? ' ' : '↳ ', style: mergeStyles(style, theme('muted')) }]
132
+ : [];
133
+ rows.push([...prefix, ...padRow([...continuation, ...row], available, style)]);
134
+ });
121
135
  }
122
136
  return rows;
123
137
  }
@@ -129,7 +143,7 @@ function layoutDiff(lines, width, theme, indent) {
129
143
  const style = diffLineStyle(line.kind, theme);
130
144
  const firstPrefix = [{ text: `${' '.repeat(safeIndent)}${prefix}`, style }];
131
145
  const continuationPrefix = [{ text: `${' '.repeat(safeIndent)}↳`, style }];
132
- rows.push(...layoutPrefixedSpans([{ text: line.content, style }], width, firstPrefix, continuationPrefix, false));
146
+ rows.push(...layoutPrefixedSpans([{ text: line.content, style }], width, firstPrefix, continuationPrefix, 'hard'));
133
147
  }
134
148
  return rows;
135
149
  }
@@ -152,44 +166,69 @@ function layoutTable(block, width, theme, indent) {
152
166
  const columnCount = Math.max(block.headers.length, ...block.rows.map(row => row.length));
153
167
  if (columnCount === 0)
154
168
  return [];
155
- const columnWidth = Math.floor(available / columnCount);
156
- if (columnWidth < 4)
169
+ const gap = 2;
170
+ const cellBudget = available - gap * (columnCount - 1);
171
+ const tableRows = [block.headers, ...block.rows];
172
+ const natural = Array.from({ length: columnCount }, (_, index) => Math.max(1, ...tableRows.map(row => cellWidth(row[index] ?? []))));
173
+ const widths = natural.map(cells => Math.min(4, cells));
174
+ let remaining = cellBudget - widths.reduce((sum, cells) => sum + cells, 0);
175
+ if (remaining < 0)
157
176
  return layoutTableAsKeyValue(block, width, theme, safeIndent);
158
- const rows = [];
159
- const indentSpan = safeIndent > 0 ? [{ text: ' '.repeat(safeIndent), style: theme('assistantText') }] : [];
160
- const header = [...indentSpan];
161
- for (let column = 0; column < columnCount; column++) {
162
- const text = block.headers[column]?.map(span => span.text).join('') ?? '';
163
- header.push({
164
- text: padText(truncateToWidth(text, columnWidth - 1), columnWidth),
165
- style: theme('heading'),
177
+ while (remaining > 0) {
178
+ const growable = widths.map((used, index) => natural[index] - used).filter(value => value > 0);
179
+ if (growable.length === 0)
180
+ break;
181
+ const share = Math.max(1, Math.floor(remaining / growable.length));
182
+ widths.forEach((used, index) => {
183
+ const growth = Math.min(share, remaining, natural[index] - used);
184
+ widths[index] += growth;
185
+ remaining -= growth;
166
186
  });
167
187
  }
168
- rows.push(clampRow(header, width));
169
- rows.push([
188
+ const indentSpan = safeIndent > 0 ? [{ text: ' '.repeat(safeIndent), style: theme('assistantText') }] : [];
189
+ const separator = [
170
190
  ...indentSpan,
171
- { text: '─'.repeat(columnWidth * columnCount), style: theme('muted') },
172
- ]);
173
- for (const sourceRow of block.rows) {
174
- const row = [...indentSpan];
175
- for (let column = 0; column < columnCount; column++) {
176
- const text = sourceRow[column]?.map(span => span.text).join('') ?? '';
177
- row.push({
178
- text: padText(truncateToWidth(text, columnWidth - 1), columnWidth),
179
- style: theme('assistantText'),
180
- });
181
- }
182
- rows.push(clampRow(row, width));
183
- }
184
- return rows;
191
+ { text: widths.map(cells => '─'.repeat(cells)).join(' '.repeat(gap)), style: theme('muted') },
192
+ ];
193
+ return tableRows.flatMap((row, index) => {
194
+ const baseStyle = theme(index === 0 ? 'heading' : 'assistantText');
195
+ const columns = widths.map((cells, column) => layoutInline(row[column] ?? [], cells, theme, baseStyle, 0));
196
+ const height = Math.max(...columns.map(column => column.length));
197
+ const rendered = Array.from({ length: height }, (_, line) => [
198
+ ...indentSpan,
199
+ ...columns.flatMap((column, cell) => {
200
+ const part = column[line] ?? [];
201
+ return cell === columnCount - 1 ? part : padRow(part, widths[cell] + gap, baseStyle);
202
+ }),
203
+ ]);
204
+ return index === 0 ? [...rendered, separator] : rendered;
205
+ });
206
+ }
207
+ function cellWidth(spans) {
208
+ return spans
209
+ .map(span => span.text)
210
+ .join('')
211
+ .split('\n')
212
+ .reduce((width, line) => Math.max(width, (0, string_width_1.default)(line)), 0);
185
213
  }
186
214
  function layoutTableAsKeyValue(block, width, theme, indent) {
187
215
  const rows = [];
188
216
  const prefixIndent = ' '.repeat(normalizeIndent(indent, width));
217
+ if (block.rows.length === 0) {
218
+ return block.headers.flatMap(cell => layoutInline(cell, width, theme, theme('heading'), indent));
219
+ }
189
220
  for (const sourceRow of block.rows) {
190
- for (let column = 0; column < block.headers.length; column++) {
221
+ const columnCount = Math.max(block.headers.length, sourceRow.length);
222
+ for (let column = 0; column < columnCount; column++) {
191
223
  const key = block.headers[column]?.map(span => span.text).join('') || `col${column + 1}`;
192
224
  const value = sourceRow[column] ?? [];
225
+ if (width - (0, string_width_1.default)(prefixIndent + key) < 5) {
226
+ const keyRows = layoutInline([{ text: `${key}:` }], width, theme, theme('heading'), indent);
227
+ const valueRows = layoutInline(value, width, theme, theme('assistantText'), indent);
228
+ for (const row of [...keyRows, ...valueRows])
229
+ rows.push(row);
230
+ continue;
231
+ }
193
232
  const prefix = [{ text: `${prefixIndent}${key}: `, style: theme('heading') }];
194
233
  const safePrefix = clampRow(prefix, Math.max(1, width - 1));
195
234
  const continuation = [
@@ -199,23 +238,25 @@ function layoutTableAsKeyValue(block, width, theme, indent) {
199
238
  text: span.text,
200
239
  style: resolveSpanStyle(span, theme('assistantText'), theme),
201
240
  }));
202
- rows.push(...layoutPrefixedSpans(styledValue, width, safePrefix, continuation, true));
241
+ for (const row of layoutPrefixedSpans(styledValue, width, safePrefix, continuation, 'word')) {
242
+ rows.push(row);
243
+ }
203
244
  }
204
245
  }
205
246
  return rows;
206
247
  }
207
- function layoutPrefixedSpans(spans, width, firstPrefix, continuationPrefix, softWrap) {
248
+ function layoutPrefixedSpans(spans, width, firstPrefix, continuationPrefix, mode) {
208
249
  const prefixWidth = Math.max(rowWidth(firstPrefix), rowWidth(continuationPrefix));
209
250
  if (prefixWidth >= width) {
210
251
  const prefixRow = clampRow(firstPrefix, width);
211
- const body = wrapStyledSpans(spans, width, softWrap);
252
+ const body = wrapStyledSpans(spans, width, mode);
212
253
  const hasContent = spans.some(span => span.text.length > 0);
213
254
  return hasContent ? [prefixRow, ...body.map(row => clampRow(row, width))] : [prefixRow];
214
255
  }
215
- const bodyRows = wrapStyledSpans(spans, width - prefixWidth, softWrap);
256
+ const bodyRows = wrapStyledSpans(spans, width - prefixWidth, mode);
216
257
  return bodyRows.map((row, index) => clampRow([...(index === 0 ? firstPrefix : continuationPrefix), ...row], width));
217
258
  }
218
- function wrapStyledSpans(spans, width, softWrap) {
259
+ function wrapStyledSpans(spans, width, mode) {
219
260
  const safeWidth = normalizeWidth(width);
220
261
  const lines = splitStyledUnitsIntoLines(spans);
221
262
  const rows = [];
@@ -224,35 +265,40 @@ function wrapStyledSpans(spans, width, softWrap) {
224
265
  rows.push([]);
225
266
  continue;
226
267
  }
227
- let remaining = units;
228
- while (remaining.length > 0) {
268
+ let start = 0;
269
+ while (start < units.length) {
229
270
  let used = 0;
230
- let take = 0;
231
- let lastWhitespace = -1;
232
- while (take < remaining.length && used + remaining[take].width <= safeWidth) {
233
- used += remaining[take].width;
234
- if (/^\s+$/u.test(remaining[take].text))
235
- lastWhitespace = take;
236
- take += 1;
271
+ let end = start;
272
+ let whitespace = -1;
273
+ let seenWord = false;
274
+ while (end < units.length && used + units[end].width <= safeWidth) {
275
+ used += units[end].width;
276
+ if (/^\s+$/u.test(units[end].text)) {
277
+ if (seenWord)
278
+ whitespace = end;
279
+ }
280
+ else {
281
+ seenWord = true;
282
+ }
283
+ end += 1;
237
284
  }
238
- if (take === remaining.length) {
239
- rows.push(unitsToRow(remaining));
285
+ if (end === units.length) {
286
+ rows.push(unitsToRow(units.slice(start)));
240
287
  break;
241
288
  }
242
- if (take === 0) {
243
- rows.push([{ text: '…', style: remaining[0].style }]);
244
- remaining = remaining.slice(1);
289
+ if (end === start) {
290
+ rows.push([{ text: '…', style: units[start].style }]);
291
+ start += 1;
245
292
  continue;
246
293
  }
247
- const breakAt = softWrap && lastWhitespace > 0 ? lastWhitespace : take;
248
- rows.push(unitsToRow(remaining.slice(0, breakAt)));
249
- let consumed = softWrap && lastWhitespace > 0 ? lastWhitespace + 1 : take;
250
- if (softWrap) {
251
- while (consumed < remaining.length && /^\s+$/u.test(remaining[consumed].text)) {
252
- consumed += 1;
253
- }
294
+ const wordBreak = mode !== 'hard' && whitespace !== -1;
295
+ const breakAt = wordBreak ? whitespace + Number(mode === 'code') : end;
296
+ rows.push(unitsToRow(units.slice(start, breakAt)));
297
+ start = breakAt;
298
+ if (mode === 'word') {
299
+ while (start < units.length && /^\s+$/u.test(units[start].text))
300
+ start += 1;
254
301
  }
255
- remaining = remaining.slice(consumed);
256
302
  }
257
303
  }
258
304
  return rows.length > 0 ? rows : [[]];
@@ -342,9 +388,6 @@ function truncateToWidth(text, maxWidth) {
342
388
  }
343
389
  return `${result}…`;
344
390
  }
345
- function padText(text, width) {
346
- return text + ' '.repeat(Math.max(0, width - (0, string_width_1.default)(text)));
347
- }
348
391
  function rowWidth(row) {
349
392
  return (0, string_width_1.default)(row.map(span => span.text).join(''));
350
393
  }
@@ -0,0 +1,50 @@
1
+ export declare const RSI_CATEGORIES: readonly ["cross_module_callers", "local_edit_cost", "missing_verification", "missing_tool"];
2
+ export type RsiCategory = (typeof RSI_CATEGORIES)[number];
3
+ export type RsiFeedbackResult = 'corrected' | 'failed' | 'accepted';
4
+ export type RsiDiagnosticCode = 'adaptive_no_progress' | 'request_safety_limit' | 'automatic_compaction_paused' | 'provider_empty_output' | 'request_budget_reached' | 'capability_not_exposed' | 'tool_gate_denied' | 'tool_execution_failed' | 'completion_needs_verification' | 'unclassified_failure';
5
+ export interface RsiSelectedTurnV1 {
6
+ readonly sessionId: string;
7
+ readonly turnId: string;
8
+ readonly category: RsiCategory;
9
+ readonly result: RsiFeedbackResult;
10
+ readonly skill?: string;
11
+ }
12
+ export interface RsiSelectionV1 {
13
+ readonly version: 1;
14
+ readonly repository: string;
15
+ readonly baseCommit: string;
16
+ readonly turns: readonly RsiSelectedTurnV1[];
17
+ }
18
+ /** Shareable metadata. Prompt text, tool arguments, and raw outputs are excluded. */
19
+ export interface RsiTurnEvidenceV1 extends RsiSelectedTurnV1 {
20
+ readonly threadId: string;
21
+ readonly turnCommitDigest: string;
22
+ readonly terminal: 'completed' | 'failed' | 'interrupted';
23
+ readonly toolReceipts: readonly {
24
+ readonly digest: string;
25
+ readonly name: string;
26
+ readonly success: boolean;
27
+ }[];
28
+ readonly loadedSkillDigests: readonly string[];
29
+ readonly diagnosis?: {
30
+ readonly code: RsiDiagnosticCode;
31
+ readonly at: number;
32
+ };
33
+ readonly skillProof?: {
34
+ readonly verified: boolean;
35
+ readonly startedAt: number;
36
+ readonly elapsedMs: number;
37
+ readonly descriptorDigest: string | null;
38
+ readonly capabilityReceiptDigests: readonly string[];
39
+ readonly promptDigests: readonly string[];
40
+ };
41
+ }
42
+ export declare const RSI_POLICY_PATH = ".orion-code/rsi-policy.json";
43
+ export interface RsiPolicyV1 {
44
+ readonly version: 1;
45
+ readonly callerScope: 'public-interface' | 'all-edits';
46
+ readonly priority: readonly RsiCategory[];
47
+ readonly minimumRepeat: number;
48
+ }
49
+ export declare const DEFAULT_RSI_POLICY: RsiPolicyV1;
50
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_RSI_POLICY = exports.RSI_POLICY_PATH = exports.RSI_CATEGORIES = void 0;
4
+ exports.RSI_CATEGORIES = [
5
+ 'cross_module_callers',
6
+ 'local_edit_cost',
7
+ 'missing_verification',
8
+ 'missing_tool',
9
+ ];
10
+ exports.RSI_POLICY_PATH = '.orion-code/rsi-policy.json';
11
+ exports.DEFAULT_RSI_POLICY = Object.freeze({
12
+ version: 1,
13
+ callerScope: 'public-interface',
14
+ priority: Object.freeze([...exports.RSI_CATEGORIES]),
15
+ minimumRepeat: 2,
16
+ });
17
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1,46 @@
1
+ import type { TurnCommitV1 } from '../turn-commit';
2
+ import type { RsiDiagnosticCode } from './contracts';
3
+ export declare const RSI_DIAGNOSES: {
4
+ readonly adaptive_no_progress: {
5
+ readonly route: "harness";
6
+ readonly verify: "Replay the stopped loop with its tool-result sequence. Verify useful progress resumes and a genuinely stagnant loop still stops.";
7
+ };
8
+ readonly request_safety_limit: {
9
+ readonly route: "harness";
10
+ readonly verify: "Replay the trajectory against the same task and inspect how many requests show measurable progress before deciding if the safety limit is appropriate.";
11
+ };
12
+ readonly automatic_compaction_paused: {
13
+ readonly route: "harness";
14
+ readonly verify: "Reproduce the pause with an equivalent context-pressure fixture. Verify compaction plus durable suffix preservation and resume.";
15
+ };
16
+ readonly capability_not_exposed: {
17
+ readonly route: "harness";
18
+ readonly verify: "Replay tool selection and verify whether the tool was registered, permitted, and exposed in the corresponding Step Snapshot.";
19
+ };
20
+ readonly provider_empty_output: {
21
+ readonly route: "operator";
22
+ readonly verify: "Replay a provider response with no visible answer and compare provider/Runtime outcomes before attributing the failure.";
23
+ };
24
+ readonly request_budget_reached: {
25
+ readonly route: "operator";
26
+ readonly verify: "Check whether this task had an explicit request or time budget before treating the stop as a harness regression.";
27
+ };
28
+ readonly tool_gate_denied: {
29
+ readonly route: "operator";
30
+ readonly verify: "Inspect the recorded policy, approval, or sandbox decision for this task.";
31
+ };
32
+ readonly tool_execution_failed: {
33
+ readonly route: "needs_feedback";
34
+ readonly verify: "Check whether the task recovered after the failed tool call; report the actual unmet outcome before proposing a change.";
35
+ };
36
+ readonly completion_needs_verification: {
37
+ readonly route: "needs_feedback";
38
+ readonly verify: "Confirm which completion criterion was unmet and whether a project Skill could have directed the agent to the missing check.";
39
+ };
40
+ readonly unclassified_failure: {
41
+ readonly route: "needs_feedback";
42
+ readonly verify: "Review the failed turn and record the expected outcome and independently reproduced cause.";
43
+ };
44
+ };
45
+ export declare function diagnoseRsiTurn(commit: Pick<TurnCommitV1, 'terminal' | 'outcome' | 'stopDecision'>, failures: ReadonlySet<string>): RsiDiagnosticCode | undefined;
46
+ //# sourceMappingURL=diagnosis.d.ts.map
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RSI_DIAGNOSES = void 0;
4
+ exports.diagnoseRsiTurn = diagnoseRsiTurn;
5
+ exports.RSI_DIAGNOSES = {
6
+ adaptive_no_progress: {
7
+ route: 'harness',
8
+ verify: 'Replay the stopped loop with its tool-result sequence. Verify useful progress resumes and a genuinely stagnant loop still stops.',
9
+ },
10
+ request_safety_limit: {
11
+ route: 'harness',
12
+ verify: 'Replay the trajectory against the same task and inspect how many requests show measurable progress before deciding if the safety limit is appropriate.',
13
+ },
14
+ automatic_compaction_paused: {
15
+ route: 'harness',
16
+ verify: 'Reproduce the pause with an equivalent context-pressure fixture. Verify compaction plus durable suffix preservation and resume.',
17
+ },
18
+ capability_not_exposed: {
19
+ route: 'harness',
20
+ verify: 'Replay tool selection and verify whether the tool was registered, permitted, and exposed in the corresponding Step Snapshot.',
21
+ },
22
+ provider_empty_output: {
23
+ route: 'operator',
24
+ verify: 'Replay a provider response with no visible answer and compare provider/Runtime outcomes before attributing the failure.',
25
+ },
26
+ request_budget_reached: {
27
+ route: 'operator',
28
+ verify: 'Check whether this task had an explicit request or time budget before treating the stop as a harness regression.',
29
+ },
30
+ tool_gate_denied: {
31
+ route: 'operator',
32
+ verify: 'Inspect the recorded policy, approval, or sandbox decision for this task.',
33
+ },
34
+ tool_execution_failed: {
35
+ route: 'needs_feedback',
36
+ verify: 'Check whether the task recovered after the failed tool call; report the actual unmet outcome before proposing a change.',
37
+ },
38
+ completion_needs_verification: {
39
+ route: 'needs_feedback',
40
+ verify: 'Confirm which completion criterion was unmet and whether a project Skill could have directed the agent to the missing check.',
41
+ },
42
+ unclassified_failure: {
43
+ route: 'needs_feedback',
44
+ verify: 'Review the failed turn and record the expected outcome and independently reproduced cause.',
45
+ },
46
+ };
47
+ const STOP_CODES = new Map([
48
+ ['no_progress_after_recovery', 'adaptive_no_progress'],
49
+ ['request_safety_limit', 'request_safety_limit'],
50
+ ['budget_paused_compact_pending', 'request_budget_reached'],
51
+ ['empty_output', 'provider_empty_output'],
52
+ ['no_visible_output', 'provider_empty_output'],
53
+ ['llm_request_budget', 'request_budget_reached'],
54
+ ['budget_exhausted_without_progress', 'request_budget_reached'],
55
+ ['user_hard_budget_reached', 'request_budget_reached'],
56
+ ]);
57
+ function parseObject(value) {
58
+ try {
59
+ const parsed = value ? JSON.parse(value) : undefined;
60
+ return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
61
+ ? parsed
62
+ : undefined;
63
+ }
64
+ catch {
65
+ // Legacy TurnCommit outcomes may be plain text. Only typed facts drive diagnosis.
66
+ return undefined;
67
+ }
68
+ }
69
+ function reasonCode(decision) {
70
+ const reason = decision?.reason;
71
+ return typeof reason?.code === 'string' ? reason.code : undefined;
72
+ }
73
+ function diagnoseRsiTurn(commit, failures) {
74
+ const outcome = parseObject(commit.outcome);
75
+ const reason = reasonCode(outcome?.stopDecision) ?? reasonCode(parseObject(commit.stopDecision));
76
+ const known = reason === undefined ? undefined : STOP_CODES.get(reason);
77
+ if (known)
78
+ return known;
79
+ if (outcome?.finishReason === 'compact_paused')
80
+ return 'automatic_compaction_paused';
81
+ if (outcome?.finishReason === 'budget_exceeded')
82
+ return 'request_budget_reached';
83
+ if (outcome?.finishReason === 'completion_gate' || reason === 'completion_gate') {
84
+ return 'completion_needs_verification';
85
+ }
86
+ // A tool can be denied or fail during an otherwise successful turn that recovered.
87
+ if (commit.terminal === 'completed' && outcome?.finishReason !== 'blocked')
88
+ return undefined;
89
+ if (failures.has('approval') || failures.has('policy') || failures.has('sandbox')) {
90
+ return 'tool_gate_denied';
91
+ }
92
+ if (failures.has('capability'))
93
+ return 'capability_not_exposed';
94
+ if (failures.has('execute'))
95
+ return 'tool_execution_failed';
96
+ return 'unclassified_failure';
97
+ }
98
+ //# sourceMappingURL=diagnosis.js.map
@@ -0,0 +1,25 @@
1
+ import { type RsiCategory } from './contracts';
2
+ export interface RsiEvaluationTask {
3
+ readonly id: string;
4
+ readonly split: 'development' | 'holdout';
5
+ readonly category: RsiCategory;
6
+ readonly prompt: string;
7
+ readonly files: Readonly<Record<string, string>>;
8
+ /** Exact expected bytes for permitted changes. All other fixture files stay unchanged. */
9
+ readonly expected: Readonly<Record<string, string>>;
10
+ }
11
+ export interface RsiEvaluationSuite {
12
+ readonly version: 1;
13
+ readonly model: string;
14
+ readonly endpoint: string;
15
+ readonly repeats: number;
16
+ readonly maxRequests: number;
17
+ readonly maxTools: number;
18
+ readonly maxTokens: number;
19
+ readonly timeoutMs: number;
20
+ readonly tasks: readonly RsiEvaluationTask[];
21
+ }
22
+ export declare const RSI_EVALUATION_TOOLS: readonly string[];
23
+ /** Fixtures and checks are supplied independently from proposal generation. */
24
+ export declare function parseRsiSuite(value: unknown): RsiEvaluationSuite;
25
+ //# sourceMappingURL=evaluation-suite.d.ts.map
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RSI_EVALUATION_TOOLS = void 0;
4
+ exports.parseRsiSuite = parseRsiSuite;
5
+ const contracts_1 = require("./contracts");
6
+ exports.RSI_EVALUATION_TOOLS = Object.freeze([
7
+ 'read_file',
8
+ 'list_files',
9
+ 'glob',
10
+ 'grep',
11
+ 'batch_read',
12
+ 'edit_file',
13
+ 'write_file',
14
+ ]);
15
+ function object(value, keys) {
16
+ if (!value ||
17
+ typeof value !== 'object' ||
18
+ Array.isArray(value) ||
19
+ (keys && Object.keys(value).some(key => !keys.includes(key)))) {
20
+ throw new Error('Invalid RSI suite object.');
21
+ }
22
+ return value;
23
+ }
24
+ function limit(value, min, max, field) {
25
+ if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < min || value > max) {
26
+ throw new Error(`RSI suite ${field} must be between ${min} and ${max}.`);
27
+ }
28
+ return value;
29
+ }
30
+ function fileMap(value) {
31
+ const files = object(value);
32
+ const entries = Object.entries(files);
33
+ if (entries.length > 24 ||
34
+ entries.some(([path, content]) => !/^[a-z0-9][a-z0-9_.-]*(?:\/[a-z0-9][a-z0-9_.-]*)*$/u.test(path) ||
35
+ path.length > 180 ||
36
+ path.split('/').length > 8 ||
37
+ path
38
+ .split('/')
39
+ .some(segment => ['node_modules', 'orion.md', 'agents.md'].includes(segment)) ||
40
+ typeof content !== 'string' ||
41
+ Buffer.byteLength(content) > 16384 ||
42
+ content.includes('\0'))) {
43
+ throw new Error('RSI fixture files must be small regular text paths without project configuration.');
44
+ }
45
+ return files;
46
+ }
47
+ function parseTask(value) {
48
+ const { id, split, category, prompt, files, expected } = object(value, [
49
+ 'id',
50
+ 'split',
51
+ 'category',
52
+ 'prompt',
53
+ 'files',
54
+ 'expected',
55
+ ]);
56
+ if (typeof id !== 'string' ||
57
+ !/^[a-z][a-z0-9-]{0,63}$/u.test(id) ||
58
+ (split !== 'development' && split !== 'holdout') ||
59
+ !contracts_1.RSI_CATEGORIES.includes(category) ||
60
+ typeof prompt !== 'string' ||
61
+ !prompt.trim() ||
62
+ Buffer.byteLength(prompt) > 4096 ||
63
+ prompt.includes('\0')) {
64
+ throw new Error('Invalid RSI task ID, split, category, or prompt.');
65
+ }
66
+ const initial = fileMap(files);
67
+ const checks = fileMap(expected);
68
+ if (Object.entries(checks).some(([path, content]) => initial[path] === content)) {
69
+ throw new Error('RSI expected changes must differ from the initial fixture.');
70
+ }
71
+ const paths = [...new Set([...Object.keys(initial), ...Object.keys(checks)])].sort();
72
+ if (paths.some((path, index) => paths.slice(index + 1).some(other => other.startsWith(`${path}/`)))) {
73
+ throw new Error('RSI fixture contains conflicting file paths.');
74
+ }
75
+ if ((category === 'cross_module_callers' && Object.keys(checks).length < 2) ||
76
+ (category === 'local_edit_cost' && Object.keys(checks).length !== 1) ||
77
+ ((category === 'missing_tool' || category === 'missing_verification') &&
78
+ Object.keys(checks).length)) {
79
+ throw new Error('RSI task checks must match its category.');
80
+ }
81
+ return {
82
+ id,
83
+ split,
84
+ category: category,
85
+ prompt: prompt.trim(),
86
+ files: initial,
87
+ expected: checks,
88
+ };
89
+ }
90
+ /** Fixtures and checks are supplied independently from proposal generation. */
91
+ function parseRsiSuite(value) {
92
+ const { version, model, endpoint, repeats, maxRequests, maxTools, maxTokens, timeoutMs, tasks } = object(value, [
93
+ 'version',
94
+ 'model',
95
+ 'endpoint',
96
+ 'repeats',
97
+ 'maxRequests',
98
+ 'maxTools',
99
+ 'maxTokens',
100
+ 'timeoutMs',
101
+ 'tasks',
102
+ ]);
103
+ if (version !== 1 ||
104
+ typeof model !== 'string' ||
105
+ !/^[a-z0-9][a-z0-9._:/-]{0,100}$/iu.test(model) ||
106
+ typeof endpoint !== 'string' ||
107
+ !/^http:\/\/127\.0\.0\.1:\d{1,5}\/v1\/?$/u.test(endpoint)) {
108
+ throw new Error('RSI needs one model and an explicitly selected local OpenAI-compatible endpoint.');
109
+ }
110
+ const url = new URL(endpoint);
111
+ if (!url.port)
112
+ throw new Error('RSI requires an explicit non-default endpoint port.');
113
+ if (!Array.isArray(tasks) || tasks.length < 5 || tasks.length > 12) {
114
+ throw new Error('RSI needs between five and twelve evaluation tasks.');
115
+ }
116
+ const parsed = tasks.map(parseTask);
117
+ if (new Set(parsed.map(task => task.id)).size !== parsed.length ||
118
+ !parsed.some(task => task.split === 'development') ||
119
+ !contracts_1.RSI_CATEGORIES.every(category => parsed.some(task => task.split === 'holdout' && task.category === category))) {
120
+ throw new Error('RSI needs distinct task IDs, development samples, and all four holdout categories.');
121
+ }
122
+ const dev = parsed.filter(task => task.split === 'development');
123
+ if (parsed.some(task => task.split === 'holdout' &&
124
+ dev.some(other => other.prompt === task.prompt ||
125
+ JSON.stringify(Object.entries(other.files).sort()) ===
126
+ JSON.stringify(Object.entries(task.files).sort())))) {
127
+ throw new Error('RSI development and holdout samples must use distinct prompts and fixtures.');
128
+ }
129
+ return {
130
+ version,
131
+ model,
132
+ endpoint: url.origin + '/v1',
133
+ repeats: limit(repeats, 1, 3, 'repeats'),
134
+ maxRequests: limit(maxRequests, 2, 12, 'maxRequests'),
135
+ maxTools: limit(maxTools, 1, 24, 'maxTools'),
136
+ maxTokens: limit(maxTokens, 128, 64000, 'maxTokens'),
137
+ timeoutMs: limit(timeoutMs, 1000, 120000, 'timeoutMs'),
138
+ tasks: [...dev, ...parsed.filter(task => task.split === 'holdout')],
139
+ };
140
+ }
141
+ //# sourceMappingURL=evaluation-suite.js.map