@orion-agents/orion-code 0.3.66 → 0.4.3

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 (370) hide show
  1. package/CHANGELOG.md +81 -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 +34 -0
  6. package/dist/acp/session-updates.js +162 -0
  7. package/dist/acp/sessions.d.ts +32 -0
  8. package/dist/acp/sessions.js +315 -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 +5 -1
  15. package/dist/commands/diagnostic-command-handlers.js +20 -6
  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 +0 -18
  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/tool-commands.js +1 -1
  28. package/dist/commands/types.d.ts +4 -10
  29. package/dist/commands/types.js +1 -21
  30. package/dist/commands/workflow-command-handlers.js +13 -4
  31. package/dist/framework/loop-budget-contract.d.ts +7 -2
  32. package/dist/framework/loop-budget-contract.js +4 -1
  33. package/dist/framework/loop-progress.d.ts +22 -0
  34. package/dist/framework/loop-progress.js +79 -0
  35. package/dist/framework/prompt.d.ts +0 -2
  36. package/dist/framework/prompt.js +9 -27
  37. package/dist/framework/query.d.ts +27 -20
  38. package/dist/framework/query.js +453 -153
  39. package/dist/framework/store.d.ts +6 -10
  40. package/dist/framework/store.js +2 -21
  41. package/dist/framework/tool-call-orchestrator.d.ts +7 -0
  42. package/dist/framework/tool-call-orchestrator.js +8 -3
  43. package/dist/framework/tool-state.d.ts +2 -0
  44. package/dist/framework/tool.d.ts +0 -23
  45. package/dist/framework/verification-command.d.ts +15 -0
  46. package/dist/framework/verification-command.js +32 -0
  47. package/dist/harness/assembler.d.ts +1 -0
  48. package/dist/harness/assembler.js +24 -0
  49. package/dist/harness/capsule.d.ts +1 -1
  50. package/dist/harness/capsule.js +33 -14
  51. package/dist/harness/context-harness.d.ts +31 -12
  52. package/dist/harness/context-harness.js +491 -35
  53. package/dist/harness/contract.js +1 -1
  54. package/dist/harness/drift-guard.d.ts +4 -0
  55. package/dist/harness/drift-guard.js +68 -16
  56. package/dist/harness/intent.js +21 -0
  57. package/dist/harness/ledger.d.ts +6 -11
  58. package/dist/harness/ledger.js +39 -9
  59. package/dist/harness/progress-controller.d.ts +12 -7
  60. package/dist/harness/progress-controller.js +66 -21
  61. package/dist/harness/state.js +9 -1
  62. package/dist/harness/task-checklist.d.ts +16 -0
  63. package/dist/harness/task-checklist.js +95 -0
  64. package/dist/harness/types.d.ts +73 -1
  65. package/dist/harness/verification.d.ts +19 -1
  66. package/dist/harness/verification.js +116 -29
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.js +1 -3
  69. package/dist/print-ui/event-stream.d.ts +38 -0
  70. package/dist/print-ui/event-stream.js +187 -0
  71. package/dist/print-ui/launch.d.ts +12 -1
  72. package/dist/print-ui/launch.js +173 -11
  73. package/dist/product/environment.d.ts +1 -1
  74. package/dist/product/environment.js +1 -1
  75. package/dist/product/identity.d.ts +1 -1
  76. package/dist/product/identity.js +1 -1
  77. package/dist/product/paths.d.ts +3 -2
  78. package/dist/product/paths.js +6 -2
  79. package/dist/runtime/agent-loop.d.ts +11 -2
  80. package/dist/runtime/agent-loop.js +165 -25
  81. package/dist/runtime/agent-runtime-controller.d.ts +13 -3
  82. package/dist/runtime/agent-runtime-controller.js +347 -183
  83. package/dist/runtime/agent-runtime-protocol.d.ts +10 -18
  84. package/dist/runtime/agent-runtime-runner.d.ts +10 -0
  85. package/dist/runtime/builtin-tool-provider.js +5 -1
  86. package/dist/runtime/capability-receipt-journal.js +1 -0
  87. package/dist/runtime/durable-tool-receipt-reader.js +2 -1
  88. package/dist/runtime/first-party-tool-services.d.ts +1 -0
  89. package/dist/runtime/first-party-tool-services.js +2 -12
  90. package/dist/runtime/first-party-tool-universe.d.ts +1 -0
  91. package/dist/runtime/first-party-tool-universe.js +1 -1
  92. package/dist/runtime/followup-queue-store.d.ts +16 -0
  93. package/dist/runtime/followup-queue-store.js +75 -0
  94. package/dist/runtime/goal-lifecycle-v2.d.ts +11 -1
  95. package/dist/runtime/goal-lifecycle-v2.js +85 -15
  96. package/dist/runtime/goal-runtime-coordinator.d.ts +10 -1
  97. package/dist/runtime/goal-runtime-coordinator.js +81 -24
  98. package/dist/runtime/loop-budget.js +7 -5
  99. package/dist/runtime/mcp/first-party-mcp-adapter.d.ts +2 -0
  100. package/dist/runtime/mcp/first-party-mcp-adapter.js +23 -19
  101. package/dist/runtime/model-coordinator.js +2 -5
  102. package/dist/runtime/orion-runtime-v1.d.ts +18 -2
  103. package/dist/runtime/orion-runtime-v1.js +135 -39
  104. package/dist/runtime/orion-session-runner.d.ts +7 -0
  105. package/dist/runtime/orion-session-runner.js +82 -0
  106. package/dist/runtime/plan-review.d.ts +1 -0
  107. package/dist/runtime/plan-review.js +8 -4
  108. package/dist/runtime/product-bootstrap.d.ts +6 -0
  109. package/dist/runtime/product-bootstrap.js +41 -51
  110. package/dist/runtime/product-orion-runtime.js +128 -52
  111. package/dist/runtime/release-receipts.d.ts +24 -133
  112. package/dist/runtime/release-receipts.js +129 -693
  113. package/dist/runtime/rich-text/layout.js +108 -65
  114. package/dist/runtime/rsi/contracts.d.ts +50 -0
  115. package/dist/runtime/rsi/contracts.js +17 -0
  116. package/dist/runtime/rsi/diagnosis.d.ts +46 -0
  117. package/dist/runtime/rsi/diagnosis.js +98 -0
  118. package/dist/runtime/rsi/evaluation-suite.d.ts +25 -0
  119. package/dist/runtime/rsi/evaluation-suite.js +141 -0
  120. package/dist/runtime/rsi/evaluation-worker.d.ts +19 -0
  121. package/dist/runtime/rsi/evaluation-worker.js +64 -0
  122. package/dist/runtime/rsi/evaluation.d.ts +49 -0
  123. package/dist/runtime/rsi/evaluation.js +351 -0
  124. package/dist/runtime/rsi/lifecycle.d.ts +54 -0
  125. package/dist/runtime/rsi/lifecycle.js +279 -0
  126. package/dist/runtime/rsi/proposal.d.ts +39 -0
  127. package/dist/runtime/rsi/proposal.js +312 -0
  128. package/dist/runtime/rsi/receipt.d.ts +28 -0
  129. package/dist/runtime/rsi/receipt.js +138 -0
  130. package/dist/runtime/rsi/skill-state.d.ts +7 -0
  131. package/dist/runtime/rsi/skill-state.js +50 -0
  132. package/dist/runtime/rsi/trajectory.d.ts +19 -0
  133. package/dist/runtime/rsi/trajectory.js +314 -0
  134. package/dist/runtime/rsi/triage.d.ts +274 -0
  135. package/dist/runtime/rsi/triage.js +58 -0
  136. package/dist/runtime/session-composer-control.d.ts +5 -24
  137. package/dist/runtime/session-composer-control.js +27 -189
  138. package/dist/runtime/step-snapshot.d.ts +1 -0
  139. package/dist/runtime/subagents/policy.js +0 -1
  140. package/dist/runtime/subagents/production.js +1 -1
  141. package/dist/runtime/subagents/runtime-integration.js +2 -4
  142. package/dist/runtime/subagents/types.d.ts +0 -5
  143. package/dist/runtime/subagents/types.js +0 -2
  144. package/dist/runtime/task-context-recovery.d.ts +55 -0
  145. package/dist/runtime/task-context-recovery.js +342 -0
  146. package/dist/runtime/task-context-service.d.ts +16 -10
  147. package/dist/runtime/task-context-service.js +35 -4
  148. package/dist/runtime/thread-admission.d.ts +1 -1
  149. package/dist/runtime/thread-admission.js +12 -6
  150. package/dist/runtime/thread-event-store.d.ts +2 -2
  151. package/dist/runtime/thread-event-store.js +7 -2
  152. package/dist/runtime/thread-projection.js +4 -2
  153. package/dist/runtime/thread-runtime.d.ts +7 -0
  154. package/dist/runtime/thread-runtime.js +43 -0
  155. package/dist/runtime/thread-session-index.d.ts +8 -0
  156. package/dist/runtime/thread-session-index.js +50 -1
  157. package/dist/runtime/thread-session-view.d.ts +2 -1
  158. package/dist/runtime/thread-session-view.js +4 -0
  159. package/dist/runtime/thread-tool-journal.d.ts +1 -0
  160. package/dist/runtime/thread-tool-journal.js +6 -2
  161. package/dist/runtime/thread-ui-adapter.d.ts +1 -0
  162. package/dist/runtime/thread-ui-adapter.js +88 -11
  163. package/dist/runtime/tool-gateway.d.ts +7 -0
  164. package/dist/runtime/tool-gateway.js +20 -0
  165. package/dist/runtime/tool-transcript-entry.d.ts +16 -0
  166. package/dist/runtime/tool-transcript-entry.js +73 -0
  167. package/dist/runtime/turn-commit.d.ts +4 -1
  168. package/dist/runtime/turn-commit.js +19 -15
  169. package/dist/runtime/ui-events.d.ts +12 -0
  170. package/dist/runtime/ui-view-model.d.ts +6 -5
  171. package/dist/runtime/ui-view-model.js +33 -19
  172. package/dist/runtime/workspace-runtime-kernel.js +0 -1
  173. package/dist/services/atomic-write.d.ts +2 -0
  174. package/dist/services/atomic-write.js +12 -1
  175. package/dist/services/code-review/format.d.ts +4 -1
  176. package/dist/services/code-review/format.js +5 -1
  177. package/dist/services/code-review/runner.d.ts +2 -2
  178. package/dist/services/code-review/runner.js +86 -64
  179. package/dist/services/code-review/snapshot.d.ts +9 -9
  180. package/dist/services/code-review/snapshot.js +182 -166
  181. package/dist/services/compact/auto-compact.d.ts +21 -6
  182. package/dist/services/compact/auto-compact.js +148 -22
  183. package/dist/services/compact/background-candidate.d.ts +33 -0
  184. package/dist/services/compact/background-candidate.js +184 -0
  185. package/dist/services/compact/compact.d.ts +4 -1
  186. package/dist/services/compact/compact.js +30 -3
  187. package/dist/services/compact/coordinator.d.ts +10 -4
  188. package/dist/services/compact/coordinator.js +17 -7
  189. package/dist/services/compact/summary-generator.d.ts +4 -2
  190. package/dist/services/compact/summary-generator.js +17 -3
  191. package/dist/services/config.d.ts +5 -5
  192. package/dist/services/config.js +30 -45
  193. package/dist/services/doctor.js +85 -13
  194. package/dist/services/effort.d.ts +5 -5
  195. package/dist/services/effort.js +5 -11
  196. package/dist/services/file-lock.d.ts +9 -3
  197. package/dist/services/file-lock.js +92 -26
  198. package/dist/services/global-config.d.ts +26 -56
  199. package/dist/services/global-config.js +213 -183
  200. package/dist/services/llm.d.ts +40 -4
  201. package/dist/services/llm.js +164 -45
  202. package/dist/services/model-client-pool.d.ts +15 -9
  203. package/dist/services/model-client-pool.js +62 -33
  204. package/dist/services/model-context.d.ts +2 -1
  205. package/dist/services/model-context.js +15 -9
  206. package/dist/services/model-registry.d.ts +4 -15
  207. package/dist/services/model-registry.js +32 -101
  208. package/dist/services/provider-diagnostics.d.ts +7 -0
  209. package/dist/services/provider-diagnostics.js +9 -10
  210. package/dist/services/provider-resilience/coordinator.d.ts +1 -1
  211. package/dist/services/provider-resilience/coordinator.js +10 -6
  212. package/dist/services/provider-resilience/request-gate.d.ts +3 -0
  213. package/dist/services/provider-resilience/request-gate.js +29 -18
  214. package/dist/services/provider-resilience/types.d.ts +2 -0
  215. package/dist/services/session-storage.d.ts +7 -10
  216. package/dist/services/session-storage.js +57 -30
  217. package/dist/services/settings-coordinator.d.ts +0 -6
  218. package/dist/services/settings-coordinator.js +19 -56
  219. package/dist/services/settings-document-repository.d.ts +3 -10
  220. package/dist/services/settings-document-repository.js +7 -85
  221. package/dist/services/usage-state.d.ts +3 -3
  222. package/dist/services/usage-state.js +11 -42
  223. package/dist/terminal-ui/answer-format.d.ts +14 -0
  224. package/dist/terminal-ui/answer-format.js +119 -0
  225. package/dist/terminal-ui/launch.d.ts +7 -6
  226. package/dist/terminal-ui/launch.js +160 -70
  227. package/dist/terminal-ui/output-queue.d.ts +2 -1
  228. package/dist/terminal-ui/output-queue.js +1 -1
  229. package/dist/terminal-ui/raw-editor.d.ts +2 -1
  230. package/dist/terminal-ui/raw-editor.js +56 -15
  231. package/dist/tools/core/edit-file.js +2 -0
  232. package/dist/tools/core/write-file.js +5 -0
  233. package/dist/tools/lsp.d.ts +16 -1
  234. package/dist/tools/lsp.js +60 -19
  235. package/dist/tools/sandbox.d.ts +1 -1
  236. package/dist/tools/sandbox.js +3 -16
  237. package/dist/tools/todo.d.ts +4 -2
  238. package/dist/tools/todo.js +76 -31
  239. package/dist/tui-core/input-parser.d.ts +1 -0
  240. package/dist/tui-core/input-parser.js +6 -0
  241. package/dist/tui-core/style.d.ts +1 -8
  242. package/dist/tui-core/style.js +3 -110
  243. package/dist/tui-ui/chrome-view-model.d.ts +1 -1
  244. package/dist/tui-ui/chrome-view-model.js +22 -27
  245. package/dist/tui-ui/launch.js +14 -14
  246. package/dist/tui-ui/layout.d.ts +5 -7
  247. package/dist/tui-ui/layout.js +129 -124
  248. package/dist/tui-ui/runner.d.ts +11 -12
  249. package/dist/tui-ui/runner.js +88 -67
  250. package/dist/tui-ui/state.d.ts +0 -11
  251. package/dist/tui-ui/state.js +22 -33
  252. package/dist/tui-ui/terminal-image.js +22 -4
  253. package/dist/tui-ui/transcript-inspector-layout.js +6 -3
  254. package/dist/tui-ui/transcript-inspector.d.ts +1 -0
  255. package/dist/tui-ui/transcript-inspector.js +7 -1
  256. package/dist/tui-ui/transcript-layout.js +42 -6
  257. package/dist/utils/terminal-text.d.ts +11 -0
  258. package/dist/utils/terminal-text.js +114 -0
  259. package/docs/cli-guide.md +562 -0
  260. package/docs/orion.example.yaml +42 -0
  261. package/docs/readme.md +12 -57
  262. package/npm-shrinkwrap.json +484 -1855
  263. package/package.json +13 -63
  264. package/dist/migration/command.d.ts +0 -9
  265. package/dist/migration/command.js +0 -100
  266. package/dist/migration/index.d.ts +0 -7
  267. package/dist/migration/index.js +0 -14
  268. package/dist/migration/migrate.d.ts +0 -19
  269. package/dist/migration/migrate.js +0 -406
  270. package/dist/migration/types.d.ts +0 -55
  271. package/dist/migration/types.js +0 -6
  272. package/dist/services/tool-allowlist.d.ts +0 -110
  273. package/dist/services/tool-allowlist.js +0 -299
  274. package/dist/services/yaml-config.d.ts +0 -57
  275. package/dist/services/yaml-config.js +0 -178
  276. package/dist/web/cli-options.d.ts +0 -17
  277. package/dist/web/cli-options.js +0 -51
  278. package/dist/web/code-review-run-service.d.ts +0 -68
  279. package/dist/web/code-review-run-service.js +0 -228
  280. package/dist/web/context-text.d.ts +0 -17
  281. package/dist/web/context-text.js +0 -40
  282. package/dist/web/errors.d.ts +0 -6
  283. package/dist/web/errors.js +0 -13
  284. package/dist/web/event-hub.d.ts +0 -45
  285. package/dist/web/event-hub.js +0 -370
  286. package/dist/web/file-read-service.d.ts +0 -101
  287. package/dist/web/file-read-service.js +0 -593
  288. package/dist/web/file-write-service.d.ts +0 -16
  289. package/dist/web/file-write-service.js +0 -103
  290. package/dist/web/git-compare-service.d.ts +0 -45
  291. package/dist/web/git-compare-service.js +0 -160
  292. package/dist/web/git-diff-document.d.ts +0 -102
  293. package/dist/web/git-diff-document.js +0 -258
  294. package/dist/web/git-file-source.d.ts +0 -25
  295. package/dist/web/git-file-source.js +0 -21
  296. package/dist/web/git-history-service.d.ts +0 -151
  297. package/dist/web/git-history-service.js +0 -619
  298. package/dist/web/git-index-transaction.d.ts +0 -45
  299. package/dist/web/git-index-transaction.js +0 -174
  300. package/dist/web/git-patch-builder.d.ts +0 -30
  301. package/dist/web/git-patch-builder.js +0 -138
  302. package/dist/web/git-read-model-service.d.ts +0 -452
  303. package/dist/web/git-read-model-service.js +0 -1833
  304. package/dist/web/git-version-service.d.ts +0 -79
  305. package/dist/web/git-version-service.js +0 -279
  306. package/dist/web/host-daemon.d.ts +0 -70
  307. package/dist/web/host-daemon.js +0 -237
  308. package/dist/web/index.d.ts +0 -6
  309. package/dist/web/index.js +0 -28
  310. package/dist/web/launch.d.ts +0 -12
  311. package/dist/web/launch.js +0 -89
  312. package/dist/web/native-directory-picker.d.ts +0 -63
  313. package/dist/web/native-directory-picker.js +0 -169
  314. package/dist/web/protocol.d.ts +0 -705
  315. package/dist/web/protocol.js +0 -639
  316. package/dist/web/review-service.d.ts +0 -22
  317. package/dist/web/review-service.js +0 -68
  318. package/dist/web/server.d.ts +0 -20
  319. package/dist/web/server.js +0 -1453
  320. package/dist/web/session-runtime-registry.d.ts +0 -138
  321. package/dist/web/session-runtime-registry.js +0 -471
  322. package/dist/web/terminal-manager.d.ts +0 -156
  323. package/dist/web/terminal-manager.js +0 -779
  324. package/dist/web/terminal-server.d.ts +0 -8
  325. package/dist/web/terminal-server.js +0 -304
  326. package/dist/web/workbench-controller.d.ts +0 -395
  327. package/dist/web/workbench-controller.js +0 -3077
  328. package/dist/web/workspace-discovery.d.ts +0 -92
  329. package/dist/web/workspace-discovery.js +0 -324
  330. package/dist/web/workspace-mutation-arbiter.d.ts +0 -54
  331. package/dist/web/workspace-mutation-arbiter.js +0 -267
  332. package/dist/web/workspace-open-telemetry.d.ts +0 -55
  333. package/dist/web/workspace-open-telemetry.js +0 -73
  334. package/dist/web-client/assets/FilesPanel-CPDovK_K.js +0 -1
  335. package/dist/web-client/assets/GitPanel-DtU_TD61.js +0 -4
  336. package/dist/web-client/assets/ReviewPanel-vMO7BEA3.js +0 -6
  337. package/dist/web-client/assets/TerminalPanel-C9vDTAlS.js +0 -23
  338. package/dist/web-client/assets/TerminalPanel-DLuoa74B.css +0 -1
  339. package/dist/web-client/assets/index-CABdwh4l.css +0 -1
  340. package/dist/web-client/assets/index-KvshfEbl.js +0 -20
  341. package/dist/web-client/assets/useAutoNotice-IE1g2wcb.js +0 -1
  342. package/dist/web-client/favicon.svg +0 -9
  343. package/dist/web-client/index.html +0 -17
  344. package/docs/architecture/agent-mode-permission-contract.md +0 -87
  345. package/docs/architecture/v0.3.0-web-api.yaml +0 -1340
  346. package/docs/architecture/v0.3.1-web-api.yaml +0 -2338
  347. package/docs/architecture/v0.3.2-web-api.yaml +0 -3029
  348. package/docs/architecture/v0.3.3-web-api.yaml +0 -3205
  349. package/docs/architecture/v0.3.4-stabilization-contract.md +0 -32
  350. package/docs/migration/v0.1.9-to-v0.2.0.md +0 -98
  351. package/docs/migration/v0.2.2-to-v0.3.0-settings.md +0 -114
  352. package/docs/migration/v0.2.2-to-v0.3.0.md +0 -55
  353. package/docs/migration/v0.3.0-to-v0.3.1.md +0 -88
  354. package/docs/migration/v0.3.1-to-v0.3.2.md +0 -94
  355. package/docs/migration/v0.3.2-to-v0.3.3.md +0 -62
  356. package/docs/migration/v0.3.3-to-v0.3.4.md +0 -36
  357. package/docs/orion.example.json +0 -86
  358. package/docs/plan/v0.2.0-dsh-harness-redesign-plan.md +0 -1234
  359. package/docs/plan/v0.2.0-release-checklist.md +0 -91
  360. package/docs/plan/v0.3.0-node-runtime-compatibility-plan.md +0 -57
  361. package/docs/plan/v0.3.0-settings-integration-plan.md +0 -740
  362. package/docs/plan/v0.3.0-web-workbench-plan.md +0 -376
  363. package/docs/plan/v0.3.1-web-workbench-professional-shell-plan.md +0 -848
  364. package/docs/plan/v0.3.2-web-workbench-layout-and-composer-plan.md +0 -869
  365. package/docs/plan/v0.3.3-plan.md +0 -1113
  366. package/docs/plan/v0.3.4-stabilization-plan.md +0 -89
  367. package/docs/test/v0.3.1-web-workbench-e2e-plan.md +0 -140
  368. package/docs/test/v0.3.2-web-workbench-e2e-plan.md +0 -100
  369. package/docs/test/v0.3.3-web-workbench-e2e-plan.md +0 -79
  370. package/docs/test/v0.3.4-stabilization-e2e-plan.md +0 -54
@@ -14,6 +14,7 @@ const chalk_1 = __importDefault(require("chalk"));
14
14
  const ui_view_model_1 = require("../runtime/ui-view-model");
15
15
  const legacy_thread_materializer_1 = require("../runtime/legacy-thread-materializer");
16
16
  const thread_session_view_1 = require("../runtime/thread-session-view");
17
+ const thread_session_index_1 = require("../runtime/thread-session-index");
17
18
  const format_1 = require("../services/format");
18
19
  const session_storage_1 = require("../services/session-storage");
19
20
  const session_index_1 = require("../services/session-index");
@@ -27,7 +28,6 @@ const ERROR = chalk_1.default.red;
27
28
  const WARN = chalk_1.default.yellow;
28
29
  const SUCCESS = chalk_1.default.green;
29
30
  const HEADER = chalk_1.default.cyan.bold;
30
- const RESUME_TRANSCRIPT_WINDOW_MESSAGES = 50;
31
31
  const RESUME_TRANSCRIPT_WINDOW_BYTES = 256 * 1024;
32
32
  const RESUME_TRANSCRIPT_ENTRY_BYTES = 64 * 1024;
33
33
  const RESUME_TRANSCRIPT_ENTRY_OVERHEAD_BYTES = 128;
@@ -37,29 +37,31 @@ const RESUME_TRANSCRIPT_ENTRY_OVERHEAD_BYTES = 128;
37
37
  * intentional: one very large tool result must not turn /resume back into an
38
38
  * unbounded terminal or JSON operation.
39
39
  */
40
- function createResumeTranscriptWindow(sessionId, messages) {
40
+ function createResumeTranscriptWindow(sessionId, messages, totalEntries = messages.length) {
41
41
  const entries = [];
42
42
  let bytes = 0;
43
43
  let contentTruncated = false;
44
- for (let index = messages.length - 1; index >= 0 && entries.length < RESUME_TRANSCRIPT_WINDOW_MESSAGES; index -= 1) {
44
+ for (let index = messages.length - 1; index >= 0 && entries.length < thread_session_index_1.RESUME_TRANSCRIPT_WINDOW_MESSAGES; index -= 1) {
45
45
  const remaining = RESUME_TRANSCRIPT_WINDOW_BYTES - bytes - RESUME_TRANSCRIPT_ENTRY_OVERHEAD_BYTES;
46
46
  if (remaining < 256)
47
47
  break;
48
48
  const message = messages[index];
49
49
  const projected = truncateUtf8ForResume(message.content, Math.min(remaining, RESUME_TRANSCRIPT_ENTRY_BYTES));
50
50
  contentTruncated || (contentTruncated = projected.truncated);
51
+ const display = 'id' in message ? message : undefined;
51
52
  const entry = {
52
53
  id: `resume:${sessionId}:${index + 1}`,
53
54
  role: message.role,
54
55
  content: projected.value,
55
- ...(message.role === 'user' ? { title: 'you' } : {}),
56
+ title: display?.title ?? (message.role === 'user' ? 'you' : undefined),
57
+ ...(display?.toolActivity ? { toolActivity: display.toolActivity } : {}),
56
58
  };
57
59
  entries.unshift(entry);
58
60
  bytes += Buffer.byteLength(projected.value, 'utf8') + RESUME_TRANSCRIPT_ENTRY_OVERHEAD_BYTES;
59
61
  }
60
62
  return Object.freeze({
61
63
  entries: Object.freeze(entries),
62
- truncated: contentTruncated || entries.length < messages.length,
64
+ truncated: contentTruncated || entries.length < totalEntries,
63
65
  });
64
66
  }
65
67
  function truncateUtf8ForResume(value, maxBytes) {
@@ -361,7 +363,9 @@ async function handleResume(ctx, args) {
361
363
  : (0, session_storage_1.listProjectSessions)(scope.projectPath);
362
364
  const scopedSessions = (0, session_storage_1.filterSessionsWithRestorableHistory)(allScopedSessions);
363
365
  if (!sessionRef) {
364
- const lastSession = scopedSessions[0];
366
+ const lastSession = scope.last && !scope.allProjects
367
+ ? (0, session_storage_1.getLastSession)(scope.projectPath, scopedSessions)
368
+ : scopedSessions[0];
365
369
  if (!lastSession) {
366
370
  return {
367
371
  success: false,
@@ -421,14 +425,15 @@ async function restoreSession(ctx, session, isLast) {
421
425
  const history = historyResult.messages.map(message => structuredClone(message));
422
426
  const recoveryWarnings = historyResult.diagnostics.map(diagnostic => diagnostic.message);
423
427
  const transcriptMessages = restoredView.transcriptMessages;
424
- const transcriptWindow = createResumeTranscriptWindow(session.id, transcriptMessages);
428
+ const transcriptDisplayCount = restoredView.resumeDisplay?.totalEntries ?? transcriptMessages.length;
429
+ const transcriptWindow = createResumeTranscriptWindow(session.id, restoredView.resumeDisplay?.entries ?? transcriptMessages, restoredView.resumeDisplay?.totalEntries);
425
430
  const visibleTranscriptMessages = ctx.uiRenderer === 'web'
426
- ? Math.min(RESUME_TRANSCRIPT_WINDOW_MESSAGES, transcriptMessages.length)
431
+ ? Math.min(thread_session_index_1.RESUME_TRANSCRIPT_WINDOW_MESSAGES, transcriptMessages.length)
427
432
  : ctx.replaceTranscript
428
433
  ? transcriptWindow.entries.length
429
434
  : 0;
430
435
  const transcriptTruncated = ctx.uiRenderer === 'web'
431
- ? transcriptMessages.length > RESUME_TRANSCRIPT_WINDOW_MESSAGES
436
+ ? transcriptMessages.length > thread_session_index_1.RESUME_TRANSCRIPT_WINDOW_MESSAGES
432
437
  : ctx.replaceTranscript
433
438
  ? transcriptWindow.truncated
434
439
  : transcriptMessages.length > 0;
@@ -446,11 +451,11 @@ async function restoreSession(ctx, session, isLast) {
446
451
  throw new Error(`Session ${session.id} did not produce a verified Thread activation.`);
447
452
  }
448
453
  }
449
- const resumed = (0, session_storage_1.resumeSession)(session.id) ?? session;
454
+ const selected = (0, session_storage_1.loadSessionMeta)(session.id) ?? { ...session };
450
455
  // Swap in the resumed session's transcript BEFORE emitting any command output,
451
456
  // so the output is appended after the history rather than wiped by the
452
457
  // transcript replacement below.
453
- ctx.setSession?.(resumed);
458
+ ctx.setSession?.(selected);
454
459
  // Notify runtime/TUI consumers only after the target view is validated.
455
460
  const resumeGeneratedAt = Date.now();
456
461
  const summary = checkpoint?.summary.text ?? (history.length > 0 ? generateHistorySummary(history) : '');
@@ -461,10 +466,16 @@ async function restoreSession(ctx, session, isLast) {
461
466
  ctx.store.setState({ harnessState: restoredHarnessState });
462
467
  }
463
468
  if (history.length > 0) {
464
- const eventSummary = checkpoint?.summary.text ?? generateRestoredSessionEventSummary(history);
465
469
  ctx.store.setState({ conversationHistory: history });
466
- await ctx.restoreSessionRuntime?.(runtimeActivation);
467
- ctx.replaceTranscript?.(transcriptWindow.entries);
470
+ }
471
+ await ctx.restoreSessionRuntime?.(runtimeActivation);
472
+ // The runner needs the selected ID before it can acquire Thread ownership.
473
+ // A rejected activation leaves the saved session's lifecycle and recent hint intact.
474
+ const resumed = (0, session_storage_1.resumeSession)(selected.id) ?? selected;
475
+ Object.assign(selected, resumed);
476
+ ctx.replaceTranscript?.(transcriptWindow.entries);
477
+ if (history.length > 0) {
478
+ const eventSummary = checkpoint?.summary.text ?? generateRestoredSessionEventSummary(history);
468
479
  ctx.sessionRestored?.({
469
480
  sessionId: resumed.id,
470
481
  projectPath: resumed.projectPath,
@@ -476,15 +487,13 @@ async function restoreSession(ctx, session, isLast) {
476
487
  summarySource,
477
488
  summaryCoveredMessages,
478
489
  checkpointId: checkpoint?.checkpointId,
479
- transcriptMessages: transcriptMessages.length,
490
+ transcriptMessages: transcriptDisplayCount,
480
491
  visibleTranscriptMessages,
481
492
  transcriptTruncated,
482
493
  ...(recoveryWarnings.length > 0 ? { warnings: recoveryWarnings } : {}),
483
494
  });
484
495
  }
485
496
  else {
486
- await ctx.restoreSessionRuntime?.(runtimeActivation);
487
- ctx.replaceTranscript?.(transcriptWindow.entries);
488
497
  ctx.sessionRestored?.({
489
498
  sessionId: resumed.id,
490
499
  projectPath: resumed.projectPath,
@@ -495,7 +504,7 @@ async function restoreSession(ctx, session, isLast) {
495
504
  summarySource,
496
505
  summaryCoveredMessages,
497
506
  checkpointId: checkpoint?.checkpointId,
498
- transcriptMessages: transcriptMessages.length,
507
+ transcriptMessages: transcriptDisplayCount,
499
508
  visibleTranscriptMessages,
500
509
  transcriptTruncated,
501
510
  ...(recoveryWarnings.length > 0 ? { warnings: recoveryWarnings } : {}),
@@ -517,7 +526,7 @@ async function restoreSession(ctx, session, isLast) {
517
526
  bannerLines.push(` Summary: ${summary}`);
518
527
  bannerLines.push(` Generated: ${new Date(summaryGeneratedAt).toLocaleString()} (${checkpoint ? 'compact checkpoint' : 'generated on resume'})`);
519
528
  bannerLines.push(` Covers: ${summaryCoveredMessages} source messages`);
520
- bannerLines.push(`✔ Restored ${history.length} model-context messages / ${transcriptMessages.length} transcript messages`);
529
+ bannerLines.push(`✔ Restored ${history.length} model-context messages / ${transcriptDisplayCount} transcript messages`);
521
530
  if (transcriptTruncated) {
522
531
  bannerLines.push(visibleTranscriptMessages > 0
523
532
  ? ` Display: showing recent ${visibleTranscriptMessages}; older transcript remains durable`
@@ -97,7 +97,6 @@ function createSystemCommands(getVisibleCommands) {
97
97
  'model',
98
98
  'effort',
99
99
  'context',
100
- 'permission',
101
100
  'queue',
102
101
  'activity',
103
102
  ]).join(', ')}`,
@@ -33,7 +33,7 @@ exports.TOOL_COMMANDS = [
33
33
  type: 'builtin',
34
34
  execution: 'builtin',
35
35
  risk: 'read-only',
36
- execute: ctx => (0, context_tool_command_handlers_1.showSafety)(ctx),
36
+ execute: () => (0, context_tool_command_handlers_1.showSafety)(),
37
37
  },
38
38
  ];
39
39
  //# sourceMappingURL=tool-commands.js.map
@@ -26,7 +26,7 @@ export interface CommandContext {
26
26
  compactCoordinator?: CompactCoordinator;
27
27
  /** Transactional model/profile switch owner. */
28
28
  modelCoordinator?: ModelCoordinator;
29
- /** Shared Session-scoped model/effort/permission authority used by Web and slash commands. */
29
+ /** Shared session controls for model and effort selection. */
30
30
  sessionComposerControls?: SessionComposerControlServiceV1;
31
31
  /** 当前会话 ID(用于记录消息) */
32
32
  sessionId?: string;
@@ -64,6 +64,8 @@ export interface CommandContext {
64
64
  agentModeLifecycle?: import('../framework/agent-mode').AgentModeLifecycleController;
65
65
  /** Read-only v0.2 runtime diagnostics; does not activate lazy Skill or MCP providers. */
66
66
  getHarnessDiagnostics?: () => Promise<OrionRuntimeDiagnosticsV1 | undefined>;
67
+ /** Count durable conversation turns in the active Session. */
68
+ getConversationTurnCount?: () => number | undefined;
67
69
  /** Product-owned durable Settings authority; commands must never construct their own. */
68
70
  settingsCoordinator?: SettingsCoordinatorV1;
69
71
  /** Describe effective Settings with current Session overrides. */
@@ -104,16 +106,8 @@ export interface CommandParam {
104
106
  export type CommandType = 'builtin' | 'tool' | 'chat';
105
107
  /** Command category used by palettes and grouped help output. */
106
108
  export type CommandCategory = 'workflow' | 'session' | 'context' | 'tools' | 'model' | 'system' | 'diagnostics' | 'legacy';
107
- /** Permission Mode - controls how tools/edits are handled */
108
- export type PermissionMode = 'default' | 'acceptEdits' | 'plan' | 'auto';
109
- /** Agent working mode. This is deliberately independent from tool confirmation policy. */
109
+ /** Agent working mode. */
110
110
  export type AgentMode = 'interactive' | 'plan' | 'auto';
111
- /** Permission mode cycle order */
112
- export declare const PERMISSION_MODES: PermissionMode[];
113
- /** Get next permission mode in cycle order */
114
- export declare function getNextPermissionMode(current: PermissionMode): PermissionMode;
115
- /** Get the legacy renderer label for the current Agent mode. */
116
- export declare function getModeDisplayText(mode: AgentMode): string;
117
111
  /** Command execution classification. */
118
112
  export type CommandExecution = 'builtin' | 'agent-workflow' | 'renderer-local';
119
113
  /** Product audience used to keep compatibility and internal commands out of default surfaces. */
@@ -6,27 +6,7 @@
6
6
  * 非 `/` 前缀的输入直接作为 chat 消息处理。
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.DEFAULT_COMMAND_RISK = exports.ALL_RENDERER_SCOPES = exports.PERMISSION_MODES = void 0;
10
- exports.getNextPermissionMode = getNextPermissionMode;
11
- exports.getModeDisplayText = getModeDisplayText;
12
- /** Permission mode cycle order */
13
- exports.PERMISSION_MODES = ['default', 'acceptEdits', 'plan', 'auto'];
14
- /** Get next permission mode in cycle order */
15
- function getNextPermissionMode(current) {
16
- const idx = exports.PERMISSION_MODES.indexOf(current);
17
- return exports.PERMISSION_MODES[(idx + 1) % exports.PERMISSION_MODES.length];
18
- }
19
- /** Get the legacy renderer label for the current Agent mode. */
20
- function getModeDisplayText(mode) {
21
- switch (mode) {
22
- case 'plan':
23
- return 'plan mode on';
24
- case 'auto':
25
- return 'auto mode';
26
- default:
27
- return 'interactive mode';
28
- }
29
- }
9
+ exports.DEFAULT_COMMAND_RISK = exports.ALL_RENDERER_SCOPES = void 0;
30
10
  /** List of renderers that a command scope can apply to. */
31
11
  exports.ALL_RENDERER_SCOPES = ['tui', 'terminal', 'print', 'web'];
32
12
  /** Default risk when no explicit metadata is present on a command. */
@@ -28,7 +28,8 @@ async function handlePlan(ctx, args) {
28
28
  output: `Plan ${state.planDigest.slice(0, 12)} · ${state.status} · revision ${state.revision}`,
29
29
  };
30
30
  }
31
- if (state.status !== 'awaiting_review') {
31
+ if (state.status === 'cancelled' ||
32
+ (subcommand !== 'cancel' && state.status !== 'awaiting_review')) {
32
33
  return { success: false, error: `Plan review is already ${state.status}.` };
33
34
  }
34
35
  const feedback = tail.join(' ').trim();
@@ -41,6 +42,8 @@ async function handlePlan(ctx, args) {
41
42
  action,
42
43
  ...(feedback ? { feedback } : {}),
43
44
  });
45
+ if (action === 'cancel')
46
+ ctx.store.setState({ currentPlan: null });
44
47
  const nextMode = action === 'approve' ? 'interactive' : action === 'continue' ? 'plan' : null;
45
48
  if (nextMode) {
46
49
  if (ctx.agentModeLifecycle)
@@ -114,12 +117,13 @@ async function handleReview(ctx, args) {
114
117
  };
115
118
  }
116
119
  const llm = ctx.llm;
120
+ const fileLabels = new Map();
117
121
  const outcome = await (0, runner_1.runCodeReview)({
118
122
  cwd: ctx.cwd,
119
123
  selector: parsed.selector,
120
124
  adapter: {
121
- async complete(messages) {
122
- const response = await llm.chat(messages.map(message => ({ role: message.role, content: message.content })));
125
+ async complete(messages, abortSignal) {
126
+ const response = await llm.chat(messages.map(message => ({ role: message.role, content: message.content })), undefined, { abortSignal });
123
127
  return {
124
128
  content: response.content,
125
129
  model: response.model,
@@ -136,6 +140,11 @@ async function handleReview(ctx, args) {
136
140
  threadId: ctx.sessionId ?? 'pending-session',
137
141
  turnId: String(ctx.turnId ?? 'ad-hoc'),
138
142
  },
143
+ onSnapshotCaptured(snapshot) {
144
+ for (const file of snapshot.files) {
145
+ fileLabels.set(file.fileKey, { old: file.oldPath ?? file.path, new: file.path });
146
+ }
147
+ },
139
148
  ...(ctx.abortSignal ? { abortSignal: ctx.abortSignal } : {}),
140
149
  });
141
150
  if (!outcome.ok) {
@@ -156,6 +165,6 @@ async function handleReview(ctx, args) {
156
165
  }
157
166
  return { success: false, error: `Review output could not be parsed: ${failure.message}` };
158
167
  }
159
- return { success: true, output: (0, format_1.formatReviewReport)(outcome.result) };
168
+ return { success: true, output: (0, format_1.formatReviewReport)(outcome.result, fileLabels) };
160
169
  }
161
170
  //# sourceMappingURL=workflow-command-handlers.js.map
@@ -1,13 +1,18 @@
1
1
  export type LoopBudgetBaseProfile = 'default' | 'complex' | 'release';
2
2
  export type LoopBudgetSource = LoopBudgetBaseProfile | 'config';
3
+ export type RequestBudgetPolicy = 'adaptive' | 'fixed';
4
+ /** A last-resort foreground guard, independent of normal request checkpoints. */
5
+ export declare const ADAPTIVE_REQUEST_SAFETY_LIMIT = 256;
3
6
  export interface LoopBudget {
4
- /** Maximum LLM requests allowed for one user turn before stopping. */
7
+ /** Strict maximum in fixed mode, initial review checkpoint in adaptive mode. */
5
8
  maxLlmRequestsPerUserTurn: number;
9
+ /** Fixed for explicitly configured request caps and non-foreground owners. */
10
+ requestPolicy?: RequestBudgetPolicy;
6
11
  /** Maximum tool calls allowed for one user turn before stopping. */
7
12
  maxToolCallsPerUserTurn: number;
8
13
  /** Consecutive single read-only tool turns before injecting a batch_read hint. */
9
14
  maxReadOnlyFragmentation: number;
10
- /** Maximum aggregate tool-result bytes exposed to the model in one user turn. */
15
+ /** Shared compression allowance; each result retains up to 2 KiB recovery visibility after exhaustion. */
11
16
  maxModelVisibleToolBytes: number;
12
17
  /** Budget source after config overrides are applied. */
13
18
  profile?: LoopBudgetSource;
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_LOOP_BUDGET = void 0;
3
+ exports.DEFAULT_LOOP_BUDGET = exports.ADAPTIVE_REQUEST_SAFETY_LIMIT = void 0;
4
+ /** A last-resort foreground guard, independent of normal request checkpoints. */
5
+ exports.ADAPTIVE_REQUEST_SAFETY_LIMIT = 256;
4
6
  exports.DEFAULT_LOOP_BUDGET = Object.freeze({
5
7
  maxLlmRequestsPerUserTurn: 24,
8
+ requestPolicy: 'adaptive',
6
9
  maxToolCallsPerUserTurn: 120,
7
10
  maxReadOnlyFragmentation: 3,
8
11
  maxModelVisibleToolBytes: 64 * 1024,
@@ -0,0 +1,22 @@
1
+ import type { ToolExternalAssertion } from './external-assertion';
2
+ export declare const ADAPTIVE_CHECKPOINT_REQUESTS = 8;
3
+ interface LoopObservation {
4
+ readonly name: string;
5
+ readonly args: Readonly<Record<string, unknown>>;
6
+ readonly output: string;
7
+ readonly fileEdit?: boolean;
8
+ readonly assertion?: ToolExternalAssertion;
9
+ }
10
+ /** Request-scoped evidence. Assistant prose, failed actions and repeated probes earn no progress. */
11
+ export declare class LoopProgress {
12
+ private readonly cwd;
13
+ private readonly seen;
14
+ private lastProgress;
15
+ private recoveryAt;
16
+ constructor(cwd: string);
17
+ observe(observation: LoopObservation, requests: number): void;
18
+ checkpoint(requests: number): 'working' | 'recover' | 'stop';
19
+ recentlyAdvanced(requests: number): boolean;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=loop-progress.d.ts.map
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoopProgress = exports.ADAPTIVE_CHECKPOINT_REQUESTS = void 0;
4
+ const path_1 = require("path");
5
+ const canonical_1 = require("../runtime/protocol/canonical");
6
+ const verification_command_1 = require("./verification-command");
7
+ exports.ADAPTIVE_CHECKPOINT_REQUESTS = 8;
8
+ const DIRECT_REPOSITORY_READ = /^(?:(?:rg|grep|cat|head|tail|ls)|git\s+(?:grep|show|log|status|diff|ls-files))(?=\s|$)/u;
9
+ // Credit bounded line printing, without interpreting arbitrary sed programs as reads.
10
+ const SED_LINE_PRINT = /^sed\s+-n\s+(?:-e\s+)?(['"]?)\d+(?:,\d+)?p\1\s+(?:--\s+)?(?:'[^'-][^']*'|"[^"-][^"]*"|[^-\s'"<>][^\s'"<>]*)$/u;
11
+ const READ_TRUNCATION_NOTE = /\n\n\[\.\.\. truncated(?:, \d+ more lines; showing lines \d+-\d+ of \d+| at \d+B(?: of \d+B)?)\]$/u;
12
+ /** Request-scoped evidence. Assistant prose, failed actions and repeated probes earn no progress. */
13
+ class LoopProgress {
14
+ constructor(cwd) {
15
+ this.cwd = cwd;
16
+ this.seen = new Set();
17
+ this.lastProgress = 0;
18
+ }
19
+ observe(observation, requests) {
20
+ const { name, args, output, fileEdit, assertion } = observation;
21
+ if (name === 'todo_write')
22
+ return;
23
+ const verified = assertion?.status === 'passed' ? assertion : undefined;
24
+ const command = typeof args.command === 'string' ? args.command.trim() : '';
25
+ const direct = name === 'exec_command' && !verification_command_1.SHELL_CONTROL_OPERATOR.test(command);
26
+ const verificationCommand = name === 'exec_command' && (0, verification_command_1.classifyDirectVerificationCommand)(command) !== undefined;
27
+ const repositoryRead = direct && (DIRECT_REPOSITORY_READ.test(command) || SED_LINE_PRINT.test(command));
28
+ if (name === 'exec_command' && !verified && !verificationCommand && !repositoryRead)
29
+ return;
30
+ if (name === 'edit_file' &&
31
+ (args.preview === true ||
32
+ (typeof args.old_string === 'string' && args.old_string === args.new_string)))
33
+ return;
34
+ const observed = (name === 'read_file' ? output.replace(READ_TRUNCATION_NOTE, '') : output).trim();
35
+ if (!observed && !fileEdit && !verified && !verificationCommand)
36
+ return;
37
+ const path = typeof args.path === 'string' ? (0, path_1.resolve)(this.cwd, args.path) : undefined;
38
+ const commandCwd = (0, path_1.resolve)(this.cwd, typeof args.cwd === 'string' ? args.cwd : '.');
39
+ const identity = verified
40
+ ? [verified.provider, verified.action, verified.target, verified.observedValue]
41
+ : verificationCommand
42
+ ? [name, commandCwd, command]
43
+ : repositoryRead
44
+ ? [name, commandCwd, observed]
45
+ : fileEdit && path
46
+ ? [name, path, args.content, args.old_string, args.new_string]
47
+ : name === 'read_file' && path
48
+ ? // Reading different ranges of a file can be necessary. Credit stable,
49
+ // distinct content in that file, regardless of relative-path spelling.
50
+ [name, path, observed]
51
+ : name === 'grep' ||
52
+ name === 'glob' ||
53
+ name === 'list_files' ||
54
+ name === 'git_status' ||
55
+ name === 'git_diff'
56
+ ? [name, observed]
57
+ : [name, args];
58
+ const digest = (0, canonical_1.digestRuntimeValue)(identity);
59
+ if (this.seen.has(digest))
60
+ return;
61
+ this.seen.add(digest);
62
+ this.lastProgress = requests;
63
+ this.recoveryAt = undefined;
64
+ }
65
+ checkpoint(requests) {
66
+ if (requests - this.lastProgress < exports.ADAPTIVE_CHECKPOINT_REQUESTS)
67
+ return 'working';
68
+ if (this.recoveryAt !== undefined) {
69
+ return requests - this.recoveryAt < exports.ADAPTIVE_CHECKPOINT_REQUESTS ? 'working' : 'stop';
70
+ }
71
+ this.recoveryAt = requests;
72
+ return 'recover';
73
+ }
74
+ recentlyAdvanced(requests) {
75
+ return this.lastProgress > 0 && requests - this.lastProgress < exports.ADAPTIVE_CHECKPOINT_REQUESTS;
76
+ }
77
+ }
78
+ exports.LoopProgress = LoopProgress;
79
+ //# sourceMappingURL=loop-progress.js.map
@@ -24,8 +24,6 @@ export interface PromptContext {
24
24
  referencedFilesContent?: string;
25
25
  /** v0.2.24: Persistent goal context fragment (from GoalCoordinator). */
26
26
  goalContent?: string;
27
- /** Task-scoped planning lifecycle started by /plan. */
28
- planMode?: boolean;
29
27
  /** Active BUILD / PLAN / AUTO behavior contract. */
30
28
  agentMode?: AgentMode;
31
29
  }
@@ -16,8 +16,7 @@ const SECTIONS = [
16
16
  {
17
17
  name: 'intro',
18
18
  dynamic: false,
19
- render: () => `You are Orion Code, a universal AI agent powered by the Orion Code Framework.
20
- Your core mission is to solve the user's problem — be concise, direct, and action-oriented.`,
19
+ render: () => `You are Orion Code, a coding agent that works in the user's repository.`,
21
20
  },
22
21
  {
23
22
  name: 'capabilities',
@@ -25,10 +24,7 @@ Your core mission is to solve the user's problem — be concise, direct, and act
25
24
  render: () => `Guidelines:
26
25
  - Be brief — explain only what's necessary
27
26
  - Persist through failures — try alternative approaches, don't give up easily
28
- - When blocked, diagnose the root cause and attempt at least 2 different fixes before asking
29
27
  - Ask clarifying questions only when the user's intent is genuinely ambiguous or there are multiple equally-valid paths
30
- - Write code, don't describe it
31
- - Output plans/proposals as workspace markdown files, not just text
32
28
  - When summarizing repository changes, only name files verified by tool output such as git_status, git diff, or direct file reads
33
29
  - Keep responses structured and short
34
30
  - Respond in the same language as the user
@@ -50,6 +46,8 @@ Batched tool strategy:
50
46
  - When exploring, diagnosing, or reading code, call multiple independent read-only tools in the same assistant response instead of waiting for one result at a time.
51
47
  - Batch safe information gathering such as git_status, list_files, glob, grep, read_file, LSP read-only lookups, web_search/web_fetch, and read-only exec_command calls.
52
48
  - If the provider or model is likely to issue only one tool call at a time, use batch_read for up to 8 independent local exploration steps using only git_status, list_files, glob, grep, and read_file.
49
+ - Plan read batches by expected bytes too: model-visible tool output normally shares a 64 KiB allowance per turn (larger task profiles/config may raise it), with a 4 KiB per-result preview. Use narrow line ranges and output limits for large files.
50
+ - Tool-result metadata reports budgetRemainingBytes and budgetExhausted immediately before that result. After exhaustion only a bounded recovery excerpt remains; do not infer an empty file or failed command from a truncated preview. Use existing evidence/artifact references or a smaller targeted read.
53
51
  - Do not put web_search, web_fetch, exec_command, LSP tools, or write/edit tools inside batch_read; call those as normal tools.
54
52
  - Do not batch file edits, writes, pushes, destructive commands, or commands that require confirmation.
55
53
  - After batched tool results return, synthesize the findings and decide the next step.`;
@@ -145,30 +143,14 @@ Batched tool strategy:
145
143
  - Respect explicit user boundaries, protected paths, sandbox restrictions, hard deny rules, and destructive-action safeguards.`;
146
144
  }
147
145
  if (ctx.agentMode === 'plan') {
148
- return `[Plan-to-Execution Mode]
149
- - Produce a decision-complete plan for the current planning phase.
150
- - PLAN exposes the same tool registry as BUILD and uses the independently selected permission policy. Never reject a tool solely because PLAN is active.
151
- - Your final assistant response is the plan. The runtime atomically saves it with TaskContext, StopDecision, capability receipts, and history.
152
- - Do not call a mode-transition tool. After the PlanReceipt commits, the runtime restores BUILD/AUTO and starts implementation as a separate logical request.
153
- - Keep implementation of the completed plan in that separate execution request.`;
146
+ return `[Plan Mode]
147
+ - Inspect and validate assumptions with the shared tools.
148
+ - Return a decision-complete plan with scope, ordered changes, and verification.
149
+ - Include an "## Execution checklist" section with up to eight Markdown unchecked items. Name the target paths and the checks to run.
150
+ - The runtime commits a typed PlanReceipt and starts implementation as a separate logical request. Do not call a mode-transition tool.`;
154
151
  }
155
152
  return `[Build Mode]
156
- - Use the normal collaborative coding workflow.
157
- - Make reasonable progress autonomously, while using the configured permission policy for actions that require confirmation.`;
158
- },
159
- },
160
- {
161
- name: 'plan_mode',
162
- dynamic: true,
163
- render: ctx => {
164
- if (!ctx.planMode)
165
- return '';
166
- return `[Plan Mode]
167
- - Use any available tool needed to inspect, validate, or prepare the plan. Writes, commands, and external actions follow the current permission policy and durable grants; hard denials remain enforced.
168
- - Resolve material unknowns from repository evidence; ask the user only when a decision cannot be inferred safely.
169
- - Produce a decision-complete implementation plan with scope, ordered changes, tests, risks, and acceptance checks.
170
- - Return the final plan as your last assistant message. Do not call an exit or mode-transition tool.
171
- - The runtime commits a typed PlanReceipt, exits PLAN automatically, and starts implementation as a separate logical request.`;
153
+ - Carry out the requested coding work and verify the result.`;
172
154
  },
173
155
  },
174
156
  ];
@@ -11,25 +11,24 @@
11
11
  import type { LLMRequestDiagnostics, LLMService, Message, StreamCallbacks } from '../services/llm';
12
12
  import type { ProviderErrorType } from '../services/provider-diagnostics';
13
13
  import type { OrionCodeTool, ToolContext } from './tool';
14
- import type { PermissionMode } from '../commands/types';
15
14
  import type { CostTracker } from '../core/cost-tracker';
16
- import type { ToolConfirmationPolicy } from '../services/config';
17
- import type { ToolAllowlistEvaluator } from '../services/tool-allowlist';
18
15
  import { type StrategyTracker } from '../core/strategy-tracker';
19
16
  import { type CompactPauseFailure } from '../services/compact/auto-compact';
20
17
  import type { CompactResult } from '../services/compact/compact';
21
18
  import type { CompactCoordinator } from '../services/compact/coordinator';
22
19
  import type { CompactPrepareSourceReceipt } from '../services/session-storage';
23
20
  import type { ContextHarness, HarnessState } from '../harness';
24
- import type { PromptAssemblyStats } from '../harness/types';
21
+ import type { PromptAssemblyStats, TaskPlanStop } from '../harness/types';
25
22
  import { type AuthoritativeToolExecutor, type ToolPermissionDecision } from './tool-call-orchestrator';
26
23
  import { type ContextUsageSnapshot } from '../services/model-context';
27
24
  import type { ToolExternalAssertion } from './external-assertion';
28
25
  import { type StopDecision } from './stop-decision';
29
- import { type LoopBudget, type LoopBudgetBaseProfile, type LoopBudgetSource } from './loop-budget-contract';
26
+ import { type LoopBudget, type LoopBudgetBaseProfile, type LoopBudgetSource, type RequestBudgetPolicy } from './loop-budget-contract';
30
27
  export { DEFAULT_LOOP_BUDGET } from './loop-budget-contract';
31
28
  export type { LoopBudget, LoopBudgetBaseProfile, LoopBudgetSource } from './loop-budget-contract';
32
29
  export declare const DEFAULT_MAX_MODEL_VISIBLE_TOOL_RESULT_BYTES = 4096;
30
+ /** Bounded recovery visibility after the shared compression allowance is spent. */
31
+ export declare const MIN_MODEL_VISIBLE_TOOL_RESULT_BYTES = 2048;
33
32
  export type LoopFinishReason = 'completed' | 'cancelled' | 'failed' | 'blocked' | 'completion_gate' | 'budget_exceeded' | 'compact_paused' | 'running';
34
33
  export type LoopContinuationAction = 'reply_continue' | 'narrow_instruction' | 'inspect_loop_stats' | 'raise_budget';
35
34
  export interface LoopStats {
@@ -48,7 +47,18 @@ export interface LoopStats {
48
47
  /** Structured compact failure when the request pauses to protect context integrity. */
49
48
  compactFailure?: CompactPauseFailure;
50
49
  budgetExceededReason?: string;
50
+ budgetExhaustedWithoutProgress?: true;
51
+ budgetCompaction?: 'compacted' | 'disabled' | 'unavailable';
52
+ budgetCompactPending?: true;
53
+ loopBudgetBaseLlmRequests?: number;
54
+ missingAssistantOutput?: 'empty_output' | 'no_visible_output';
55
+ providerStop?: {
56
+ code: string;
57
+ message: string;
58
+ };
51
59
  loopBudgetSource?: LoopBudgetSource;
60
+ loopBudgetRequestPolicy?: RequestBudgetPolicy;
61
+ adaptiveStop?: 'no_progress_after_recovery' | 'request_safety_limit';
52
62
  loopBudgetBaseProfile?: LoopBudgetBaseProfile;
53
63
  loopBudgetMaxLlmRequests?: number;
54
64
  loopBudgetMaxToolCalls?: number;
@@ -110,6 +120,10 @@ export type QueryEvent = {
110
120
  type: 'request_start';
111
121
  model: string;
112
122
  turn: number;
123
+ } | {
124
+ type: 'budget_recovery';
125
+ additionalRequests: number;
126
+ reason: 'progress' | 'recovery';
113
127
  } | {
114
128
  type: 'prompt_assembly';
115
129
  modelId: string;
@@ -220,8 +234,6 @@ export interface QueryParams {
220
234
  * Existing callers may omit this and retain the turn-scoped registry.
221
235
  */
222
236
  resolveStep?: (input: QueryStepResolveInput) => QueryStepRuntime | Promise<QueryStepRuntime>;
223
- /** @deprecated Query always delegates authority to the injected executor. */
224
- executionBoundary?: 'legacy' | 'tool_gateway';
225
237
  /** LLM service instance */
226
238
  llm: LLMService;
227
239
  /** @deprecated Use loopBudget.maxLlmRequestsPerUserTurn. This alias is resource-only. */
@@ -230,19 +242,10 @@ export interface QueryParams {
230
242
  abortSignal?: AbortSignal;
231
243
  /** Streaming callbacks (onChunk writes to stdout, etc.) */
232
244
  streamCallbacks?: StreamCallbacks;
233
- /** Permission mode for tool execution */
234
- permissionMode?: PermissionMode;
235
- /** Fallback for permission checks that would need an interactive prompt. */
236
- toolConfirmation?: ToolConfirmationPolicy;
237
- /** Project-scoped allowlist rule engine applied on top of tool policy + mode. */
238
- toolAllowlist?: ToolAllowlistEvaluator;
239
- /** Optional UI confirmation hook for tools whose permission check returns ask. */
240
- confirmToolUse?: (request: {
241
- name: string;
242
- args: Record<string, unknown>;
243
- reason?: string;
244
- abortSignal?: AbortSignal;
245
- }) => Promise<boolean>;
245
+ /** Stage answer text for checklist-driven work until the completion gate passes. */
246
+ holdAssistantUntilCompletionCheck?: () => boolean;
247
+ /** Check a persisted checklist's step recovery or explicit deferral before sampling. */
248
+ checkTaskPlanStop?: () => TaskPlanStop | undefined;
246
249
  /** Tool execution context */
247
250
  toolContext?: ToolContext;
248
251
  /** Cost tracker for recording usage */
@@ -259,6 +262,10 @@ export interface QueryParams {
259
262
  maxModelVisibleToolResultBytes?: number;
260
263
  /** Per-user-turn budget guardrails for model requests, tools, and model-visible tool output. */
261
264
  loopBudget?: Partial<LoopBudget>;
265
+ /** Remaining reported tokens for an active Goal at turn admission. */
266
+ remainingGoalTokens?: number;
267
+ /** Allow same-turn compact recovery for root BUILD/AUTO work. */
268
+ allowBudgetRecovery?: boolean;
262
269
  /** Runtime observer for current context pressure. Renderers consume Store state instead. */
263
270
  onContextUsage?: (usage: ContextUsageSnapshot) => void;
264
271
  /** Runtime observer for autonomous core compaction. */