@cjhyy/code-shell 0.1.0-alpha.0 → 0.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +8 -0
  3. package/dist/anthropic-P5VETAFI.cjs +10 -0
  4. package/dist/{anthropic-NENYS535.js → anthropic-W2GU3D76.js} +3 -2
  5. package/dist/arena/context/context-tools.d.ts +1 -1
  6. package/dist/arena/index.cjs +4 -4
  7. package/dist/arena/index.js +3 -3
  8. package/dist/arena/providers/index.d.ts +19 -3
  9. package/dist/arena/strategies/utils.d.ts +6 -1
  10. package/dist/arena/types.d.ts +10 -1
  11. package/dist/{arena-46QQ6BZQ.js → arena-ENHBHB2W.js} +5 -7
  12. package/dist/{arena-HZZZ2GJH.cjs → arena-HHDYYVHJ.cjs} +19 -21
  13. package/dist/{chunk-BE6IPRDM.js → chunk-2EUAE7AY.js} +1 -1
  14. package/dist/{chunk-WFQF3RT4.cjs → chunk-3CAZIWUA.cjs} +11 -8
  15. package/dist/{chunk-J5XW6UYL.js → chunk-5C5HIOML.js} +63 -4
  16. package/dist/chunk-75E4BBFC.js +224 -0
  17. package/dist/{chunk-ZJV3YSY3.cjs → chunk-BUJ5KYCI.cjs} +53 -11
  18. package/dist/{chunk-BMH65OVB.cjs → chunk-C7C7ZZY4.cjs} +8 -8
  19. package/dist/{chunk-KO2FPF7G.js → chunk-F5BS3GUC.js} +20 -2
  20. package/dist/chunk-FA5KD34T.js +54 -0
  21. package/dist/chunk-FV2ARONZ.cjs +224 -0
  22. package/dist/chunk-G76E5FOB.cjs +54 -0
  23. package/dist/{chunk-DICG4AB7.cjs → chunk-GZBD6QRS.cjs} +42 -3
  24. package/dist/{chunk-FVP7XJGS.cjs → chunk-HOXQLX5R.cjs} +406 -196
  25. package/dist/{chunk-4PKZPFCD.js → chunk-I57ZD5IQ.js} +47 -14
  26. package/dist/{chunk-7RMAR2Y3.js → chunk-ID6EJUHP.js} +1959 -473
  27. package/dist/chunk-JHNCK7JP.cjs +202 -0
  28. package/dist/{chunk-R32DJSJE.cjs → chunk-JHXNOB5G.cjs} +8 -5
  29. package/dist/{chunk-UK2SU23S.cjs → chunk-KOGV6PDQ.cjs} +20 -2
  30. package/dist/{chunk-VKGNCYRL.js → chunk-LMEKCQX4.js} +95 -13
  31. package/dist/{chunk-3EAEC566.cjs → chunk-M2QI5X3X.cjs} +51 -18
  32. package/dist/{chunk-YZ25SSWJ.js → chunk-M2SVOKC6.js} +46 -4
  33. package/dist/chunk-OMRGA6TI.js +4753 -0
  34. package/dist/{chunk-NG73UR3L.cjs → chunk-OP57WUWQ.cjs} +23 -1
  35. package/dist/{chunk-ZXYDDJEJ.js → chunk-OUC2DFA7.js} +2 -2
  36. package/dist/{chunk-6JOOLG6F.js → chunk-REFCCVDM.js} +5 -2
  37. package/dist/{chunk-O6F2EF2Z.js → chunk-SCDKLTN3.js} +41 -2
  38. package/dist/{chunk-BHGIJ2DJ.js → chunk-SW3L7HIM.js} +6 -3
  39. package/dist/chunk-TATCTZSB.cjs +4753 -0
  40. package/dist/{chunk-QHDYFC5U.cjs → chunk-VWFET3MG.cjs} +2132 -646
  41. package/dist/{chunk-3EUDE77E.cjs → chunk-X2DNIMPC.cjs} +19 -19
  42. package/dist/{chunk-SQZHPD3S.js → chunk-Y7TSCDF6.js} +297 -87
  43. package/dist/{chunk-WHRTARDJ.cjs → chunk-YAFCN7ZW.cjs} +112 -30
  44. package/dist/{chunk-LRAY5IYC.cjs → chunk-YD7XTI7T.cjs} +65 -6
  45. package/dist/{chunk-S74VVJBF.js → chunk-ZLPJJZUW.js} +23 -1
  46. package/dist/chunk-ZRVPCXI7.js +202 -0
  47. package/dist/cli/commands/builtin/advanced-commands.d.ts +1 -1
  48. package/dist/cli/commands/builtin/extra-commands.d.ts +2 -2
  49. package/dist/cli/commands/builtin/more-commands.d.ts +1 -3
  50. package/dist/cli/commands/registry.d.ts +8 -0
  51. package/dist/cli/cost-tracker.d.ts +6 -0
  52. package/dist/cli/main.cjs +3576 -2036
  53. package/dist/cli/main.js +3613 -2073
  54. package/dist/cli/onboarding.d.ts +67 -14
  55. package/dist/client-base-TOVE25FA.js +9 -0
  56. package/dist/client-base-VDDIADAC.cjs +9 -0
  57. package/dist/compaction-D3KV2NWY.cjs +31 -0
  58. package/dist/{compaction-CCHWA4G6.js → compaction-YNWCEF7B.js} +1 -2
  59. package/dist/context/manager.d.ts +9 -0
  60. package/dist/data/openrouter-models.d.ts +35 -0
  61. package/dist/data/openrouter-sync.d.ts +16 -0
  62. package/dist/{devtools-KIY3LWQJ.js → devtools-IRQQPIRY.js} +1 -1
  63. package/dist/{devtools-LRP47DDV.cjs → devtools-WTC3NFNE.cjs} +1 -1
  64. package/dist/engine/engine.d.ts +39 -4
  65. package/dist/engine/turn-loop.d.ts +13 -4
  66. package/dist/engine/turn-state.d.ts +6 -0
  67. package/dist/index.cjs +19 -28
  68. package/dist/index.d.ts +1 -1
  69. package/dist/index.js +28 -37
  70. package/dist/llm/client-base.d.ts +7 -0
  71. package/dist/llm/model-pool.d.ts +4 -0
  72. package/dist/logging/logger.d.ts +69 -8
  73. package/dist/manager-FWLOVEEK.cjs +7 -0
  74. package/dist/manager-GEXJLOIS.js +7 -0
  75. package/dist/{mcp-manager-OKXHHWYR.js → mcp-manager-37GQLFGX.js} +2 -2
  76. package/dist/mcp-manager-U77NEXBY.cjs +8 -0
  77. package/dist/memory-ADGOWADP.cjs +9 -0
  78. package/dist/memory-EPFDBPII.js +9 -0
  79. package/dist/native-ts/yoga-layout/index.d.ts +2 -2
  80. package/dist/{openai-5HQGBL4L.js → openai-RXU5URYI.js} +3 -2
  81. package/dist/openai-SQW4H2K4.cjs +10 -0
  82. package/dist/openrouter-models-OL725CL6.js +15 -0
  83. package/dist/openrouter-models-UM3AOGZ4.cjs +15 -0
  84. package/dist/openrouter-sync-CWD5VNW2.js +11 -0
  85. package/dist/openrouter-sync-HYZZC6RX.cjs +11 -0
  86. package/dist/product/index.cjs +12 -16
  87. package/dist/product/index.js +11 -15
  88. package/dist/product/types.d.ts +2 -7
  89. package/dist/protocol/types.d.ts +11 -3
  90. package/dist/{ink → render}/hooks/use-input.d.ts +1 -1
  91. package/dist/run/EngineRunner.d.ts +3 -1
  92. package/dist/run/RunManager.d.ts +6 -0
  93. package/dist/run/factory.d.ts +7 -1
  94. package/dist/run/index.cjs +12 -16
  95. package/dist/run/index.js +11 -15
  96. package/dist/session/memory.d.ts +23 -3
  97. package/dist/session/session-manager.d.ts +4 -1
  98. package/dist/{session-manager-UQKB564H.cjs → session-manager-HRSKENKB.cjs} +2 -2
  99. package/dist/{session-manager-JIIBCFTC.js → session-manager-NEKFEHF3.js} +1 -1
  100. package/dist/settings/manager.d.ts +9 -0
  101. package/dist/settings/schema.d.ts +48 -39
  102. package/dist/{tool-summary-J2ICNMWP.js → tool-summary-2RUFL5QK.js} +1 -1
  103. package/dist/{tool-summary-5P2GKRA4.cjs → tool-summary-RYNR4DDB.cjs} +2 -2
  104. package/dist/tool-system/builtin/agent-registry.d.ts +36 -0
  105. package/dist/tool-system/builtin/agent.d.ts +7 -26
  106. package/dist/tool-system/builtin/apply-patch/applier.d.ts +26 -0
  107. package/dist/tool-system/builtin/apply-patch/index.d.ts +19 -0
  108. package/dist/tool-system/builtin/apply-patch/parser.d.ts +17 -0
  109. package/dist/tool-system/builtin/apply-patch/seek-sequence.d.ts +18 -0
  110. package/dist/tool-system/builtin/apply-patch/types.d.ts +49 -0
  111. package/dist/tool-system/builtin/arena.d.ts +18 -5
  112. package/dist/tool-system/builtin/ask-user.d.ts +6 -6
  113. package/dist/tool-system/builtin/index.d.ts +11 -1
  114. package/dist/tool-system/builtin/tool-search.d.ts +2 -3
  115. package/dist/tool-system/context.d.ts +74 -0
  116. package/dist/tool-system/executor.d.ts +16 -0
  117. package/dist/tool-system/permission.d.ts +40 -5
  118. package/dist/tool-system/registry.d.ts +8 -0
  119. package/dist/types.d.ts +34 -1
  120. package/dist/ui/App.d.ts +1 -1
  121. package/dist/ui/components/AgentBlock.d.ts +1 -1
  122. package/dist/ui/components/AskUserPrompt.d.ts +7 -0
  123. package/dist/ui/components/MessageContent.d.ts +7 -3
  124. package/dist/ui/components/ModelManager.d.ts +35 -0
  125. package/dist/ui/components/ModelSelector.d.ts +10 -0
  126. package/dist/ui/components/OnboardingPrompt.d.ts +7 -0
  127. package/dist/ui/components/PermissionPrompt.d.ts +5 -2
  128. package/dist/ui/components/SessionPicker.d.ts +14 -0
  129. package/dist/ui/components/StatusLine.d.ts +4 -2
  130. package/dist/ui/components/ThemedBox.d.ts +1 -1
  131. package/dist/ui/components/ToolCall.d.ts +8 -1
  132. package/dist/ui/components/WelcomeTips.d.ts +5 -0
  133. package/dist/ui/onboarding-runner.d.ts +2 -0
  134. package/dist/ui/store.d.ts +1 -0
  135. package/dist/{updater-URVNPDPW.cjs → updater-M7L42ASZ.cjs} +4 -4
  136. package/dist/{updater-AVD4LKTQ.js → updater-ZRTONIR4.js} +4 -4
  137. package/dist/utils/debug.d.ts +17 -33
  138. package/package.json +4 -4
  139. package/dist/anthropic-XMTTVNSH.cjs +0 -9
  140. package/dist/bridge-4ZRXVWBN.js +0 -98
  141. package/dist/bridge-W476QDFH.cjs +0 -98
  142. package/dist/chunk-4RRUP4MM.js +0 -86
  143. package/dist/chunk-4SFPFHMG.js +0 -132
  144. package/dist/chunk-5LHVI777.cjs +0 -246
  145. package/dist/chunk-6ZIROYXX.js +0 -207
  146. package/dist/chunk-C7JBCO5V.js +0 -80
  147. package/dist/chunk-CSO5EOEP.cjs +0 -132
  148. package/dist/chunk-FGZGCFJX.cjs +0 -207
  149. package/dist/chunk-HD7MT5XU.cjs +0 -86
  150. package/dist/chunk-IMMTBZ33.cjs +0 -63
  151. package/dist/chunk-JT2WSQSR.cjs +0 -335
  152. package/dist/chunk-NZ4DQ72D.cjs +0 -664
  153. package/dist/chunk-OG4MIQJ6.js +0 -335
  154. package/dist/chunk-WRZJUQ5Z.js +0 -664
  155. package/dist/chunk-X4HAERTQ.js +0 -63
  156. package/dist/chunk-XHC2JMEC.cjs +0 -80
  157. package/dist/chunk-ZRSSGYA5.js +0 -246
  158. package/dist/compaction-44I55TLI.cjs +0 -32
  159. package/dist/coordinator-5HY7ALO2.js +0 -7
  160. package/dist/coordinator-INDLPVMF.cjs +0 -7
  161. package/dist/cost-tracker-IWYAUPXH.js +0 -9
  162. package/dist/cost-tracker-JXTJQQWE.cjs +0 -9
  163. package/dist/loader-DXFSUB4R.cjs +0 -91
  164. package/dist/loader-J5UID6CV.js +0 -91
  165. package/dist/manager-ETWDOCHN.cjs +0 -9
  166. package/dist/manager-HGMQNEJB.cjs +0 -11
  167. package/dist/manager-HUAQOORS.js +0 -9
  168. package/dist/manager-VJIZ2CQC.js +0 -11
  169. package/dist/mcp-manager-G4G2QASE.cjs +0 -8
  170. package/dist/memory-AP747G5H.js +0 -7
  171. package/dist/memory-BH3BYUN5.cjs +0 -7
  172. package/dist/onboarding-6WEPV7C2.js +0 -11
  173. package/dist/onboarding-QM5DY2TU.cjs +0 -11
  174. package/dist/openai-656VWUQW.cjs +0 -9
  175. package/dist/skills-63RBYQRX.js +0 -13
  176. package/dist/skills-V3BPLW3D.cjs +0 -13
  177. package/dist/token-counter-CHAXW5O7.cjs +0 -13
  178. package/dist/token-counter-DSOZGZ5Q.js +0 -13
  179. package/dist/utils/log.d.ts +0 -56
  180. package/dist/voice-KTZ7PAGO.js +0 -80
  181. package/dist/voice-KZE25GKB.cjs +0 -80
  182. /package/dist/{ink → render}/Ansi.d.ts +0 -0
  183. /package/dist/{ink → render}/bidi.d.ts +0 -0
  184. /package/dist/{ink → render}/clearTerminal.d.ts +0 -0
  185. /package/dist/{ink → render}/colorize.d.ts +0 -0
  186. /package/dist/{ink → render}/components/AlternateScreen.d.ts +0 -0
  187. /package/dist/{ink → render}/components/App.d.ts +0 -0
  188. /package/dist/{ink → render}/components/AppContext.d.ts +0 -0
  189. /package/dist/{ink → render}/components/Box.d.ts +0 -0
  190. /package/dist/{ink → render}/components/Button.d.ts +0 -0
  191. /package/dist/{ink → render}/components/ClockContext.d.ts +0 -0
  192. /package/dist/{ink → render}/components/CursorDeclarationContext.d.ts +0 -0
  193. /package/dist/{ink → render}/components/ErrorOverview.d.ts +0 -0
  194. /package/dist/{ink → render}/components/Link.d.ts +0 -0
  195. /package/dist/{ink → render}/components/Newline.d.ts +0 -0
  196. /package/dist/{ink → render}/components/NoSelect.d.ts +0 -0
  197. /package/dist/{ink → render}/components/RawAnsi.d.ts +0 -0
  198. /package/dist/{ink → render}/components/ScrollBox.d.ts +0 -0
  199. /package/dist/{ink → render}/components/Spacer.d.ts +0 -0
  200. /package/dist/{ink → render}/components/StdinContext.d.ts +0 -0
  201. /package/dist/{ink → render}/components/TerminalFocusContext.d.ts +0 -0
  202. /package/dist/{ink → render}/components/TerminalSizeContext.d.ts +0 -0
  203. /package/dist/{ink → render}/components/Text.d.ts +0 -0
  204. /package/dist/{ink → render}/constants.d.ts +0 -0
  205. /package/dist/{ink → render}/cursor.d.ts +0 -0
  206. /package/dist/{ink → render}/devtools.d.ts +0 -0
  207. /package/dist/{ink → render}/dom.d.ts +0 -0
  208. /package/dist/{ink → render}/events/click-event.d.ts +0 -0
  209. /package/dist/{ink → render}/events/dispatcher.d.ts +0 -0
  210. /package/dist/{ink → render}/events/emitter.d.ts +0 -0
  211. /package/dist/{ink → render}/events/event-handlers.d.ts +0 -0
  212. /package/dist/{ink → render}/events/event.d.ts +0 -0
  213. /package/dist/{ink → render}/events/focus-event.d.ts +0 -0
  214. /package/dist/{ink → render}/events/input-event.d.ts +0 -0
  215. /package/dist/{ink → render}/events/keyboard-event.d.ts +0 -0
  216. /package/dist/{ink → render}/events/paste-event.d.ts +0 -0
  217. /package/dist/{ink → render}/events/resize-event.d.ts +0 -0
  218. /package/dist/{ink → render}/events/terminal-event.d.ts +0 -0
  219. /package/dist/{ink → render}/events/terminal-focus-event.d.ts +0 -0
  220. /package/dist/{ink → render}/focus.d.ts +0 -0
  221. /package/dist/{ink → render}/frame.d.ts +0 -0
  222. /package/dist/{ink → render}/get-max-width.d.ts +0 -0
  223. /package/dist/{ink → render}/hit-test.d.ts +0 -0
  224. /package/dist/{ink → render}/hooks/use-animation-frame.d.ts +0 -0
  225. /package/dist/{ink → render}/hooks/use-app.d.ts +0 -0
  226. /package/dist/{ink → render}/hooks/use-declared-cursor.d.ts +0 -0
  227. /package/dist/{ink → render}/hooks/use-interval.d.ts +0 -0
  228. /package/dist/{ink → render}/hooks/use-search-highlight.d.ts +0 -0
  229. /package/dist/{ink → render}/hooks/use-selection.d.ts +0 -0
  230. /package/dist/{ink → render}/hooks/use-stdin.d.ts +0 -0
  231. /package/dist/{ink → render}/hooks/use-tab-status.d.ts +0 -0
  232. /package/dist/{ink → render}/hooks/use-terminal-focus.d.ts +0 -0
  233. /package/dist/{ink → render}/hooks/use-terminal-title.d.ts +0 -0
  234. /package/dist/{ink → render}/hooks/use-terminal-viewport.d.ts +0 -0
  235. /package/dist/{ink → render}/index.d.ts +0 -0
  236. /package/dist/{ink → render}/ink.d.ts +0 -0
  237. /package/dist/{ink → render}/instances.d.ts +0 -0
  238. /package/dist/{ink → render}/layout/engine.d.ts +0 -0
  239. /package/dist/{ink → render}/layout/geometry.d.ts +0 -0
  240. /package/dist/{ink → render}/layout/node.d.ts +0 -0
  241. /package/dist/{ink → render}/layout/yoga.d.ts +0 -0
  242. /package/dist/{ink → render}/line-width-cache.d.ts +0 -0
  243. /package/dist/{ink → render}/log-update.d.ts +0 -0
  244. /package/dist/{ink → render}/measure-element.d.ts +0 -0
  245. /package/dist/{ink → render}/measure-text.d.ts +0 -0
  246. /package/dist/{ink → render}/node-cache.d.ts +0 -0
  247. /package/dist/{ink → render}/optimizer.d.ts +0 -0
  248. /package/dist/{ink → render}/output.d.ts +0 -0
  249. /package/dist/{ink → render}/parse-keypress.d.ts +0 -0
  250. /package/dist/{ink → render}/reconciler.d.ts +0 -0
  251. /package/dist/{ink → render}/render-border.d.ts +0 -0
  252. /package/dist/{ink → render}/render-node-to-output.d.ts +0 -0
  253. /package/dist/{ink → render}/render-to-screen.d.ts +0 -0
  254. /package/dist/{ink → render}/renderer.d.ts +0 -0
  255. /package/dist/{ink → render}/root.d.ts +0 -0
  256. /package/dist/{ink → render}/screen.d.ts +0 -0
  257. /package/dist/{ink → render}/searchHighlight.d.ts +0 -0
  258. /package/dist/{ink → render}/selection.d.ts +0 -0
  259. /package/dist/{ink → render}/squash-text-nodes.d.ts +0 -0
  260. /package/dist/{ink → render}/stringWidth.d.ts +0 -0
  261. /package/dist/{ink → render}/styles.d.ts +0 -0
  262. /package/dist/{ink → render}/supports-hyperlinks.d.ts +0 -0
  263. /package/dist/{ink → render}/tabstops.d.ts +0 -0
  264. /package/dist/{ink → render}/terminal-focus-state.d.ts +0 -0
  265. /package/dist/{ink → render}/terminal-querier.d.ts +0 -0
  266. /package/dist/{ink → render}/terminal.d.ts +0 -0
  267. /package/dist/{ink → render}/termio/ansi.d.ts +0 -0
  268. /package/dist/{ink → render}/termio/csi.d.ts +0 -0
  269. /package/dist/{ink → render}/termio/dec.d.ts +0 -0
  270. /package/dist/{ink → render}/termio/esc.d.ts +0 -0
  271. /package/dist/{ink → render}/termio/osc.d.ts +0 -0
  272. /package/dist/{ink → render}/termio/parser.d.ts +0 -0
  273. /package/dist/{ink → render}/termio/sgr.d.ts +0 -0
  274. /package/dist/{ink → render}/termio/tokenize.d.ts +0 -0
  275. /package/dist/{ink → render}/termio/types.d.ts +0 -0
  276. /package/dist/{ink → render}/termio.d.ts +0 -0
  277. /package/dist/{ink → render}/useTerminalNotification.d.ts +0 -0
  278. /package/dist/{ink → render}/warn.d.ts +0 -0
  279. /package/dist/{ink → render}/widest-line.d.ts +0 -0
  280. /package/dist/{ink → render}/wrap-text.d.ts +0 -0
  281. /package/dist/{ink → render}/wrapAnsi.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -8,6 +8,45 @@ breaking.
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [0.1.0-alpha.1] - 2026-04-30
12
+
13
+ ### Changed (breaking)
14
+ - **Tool timeout system rewritten.** Removed the hardcoded
15
+ `LEGACY_LONG_TIMEOUT_TOOLS = {Agent, Arena}` whitelist in
16
+ `tool-system/registry.ts`. Tools now declare their own timeout via
17
+ `RegisteredTool.timeoutMs` at registration time. Precedence:
18
+ `executeTool(opts.timeoutMs)` > `tool.timeoutMs` > `DEFAULT_TOOL_TIMEOUT_MS`
19
+ (120s). Custom long-running tools registered via `engine.registerCustomTool`
20
+ can now set a higher timeout instead of being silently capped at 120s.
21
+ - **Bash internal 600s cap removed.** `bash.ts` no longer clamps the
22
+ user-supplied `timeout` argument. The outer registry caps via the tool's
23
+ declared `timeoutMs` (default 1h for Bash). Long-running shell loops
24
+ (`until cond; do ...; done`) are now feasible.
25
+ - **Agent `max_turns` upper bound (30) removed.** Sub-agents that need to do
26
+ more turns (deep research, large refactors) are no longer artificially
27
+ capped. Default remains 15.
28
+ - **Sub-agent LLM call timeout (60s) removed.** `agent.ts` no longer clamps
29
+ `subAgentConfig.llm.timeout` to 60s, which was breaking slow models
30
+ (e.g. extended thinking).
31
+
32
+ ### Added
33
+ - **`Agent(run_in_background: true)`** — fire-and-forget sub-agents. Returns
34
+ an `agent_id` immediately instead of blocking the parent turn. The agent
35
+ runs detached in the same process; restarting loses its state.
36
+ - **`AgentStatus(agent_id?)`** — query background agent state
37
+ (running / completed / failed / cancelled), or list all when `agent_id` is
38
+ omitted. Returns the result text once completed.
39
+ - **`AgentCancel(agent_id)`** — abort a running background agent.
40
+ - New module `src/tool-system/builtin/agent-registry.ts` — in-process
41
+ registry for async agent handles.
42
+
43
+ ### Notes
44
+ - Cross-process / restart-survivable long tasks still belong to `RunManager`
45
+ in `@cjhyy/code-shell/run`, not to `Agent(run_in_background)`. The split
46
+ mirrors Claude Code's REPL/Agent-tool/Routines architecture.
47
+
48
+ ## [0.1.0-alpha.0] - 2026-04-28
49
+
11
50
  ### Added
12
51
  - **`IterativeArena` — multi-model authoring loop.** Pipeline: tournament v1
13
52
  (every participant writes a draft, the author merges anonymized drafts into
package/README.md CHANGED
@@ -175,3 +175,11 @@ bun run tsc --noEmit
175
175
  ```
176
176
 
177
177
  `bun run tsc --noEmit` currently reports many pre-existing repo-wide issues outside the preset/framework changes, so treat typecheck as a global health signal rather than a clean gate for just this slice.
178
+
179
+ ## Acknowledgments
180
+
181
+ The `ApplyPatch` tool (`src/tool-system/builtin/apply-patch/`) is adapted from
182
+ [OpenAI Codex `codex-rs/apply-patch`](https://github.com/openai/codex/tree/main/codex-rs/apply-patch),
183
+ licensed under the Apache License 2.0. See `NOTICE.md` and `LICENSE-codex` in
184
+ that directory for details, including the intentional behavioral divergence
185
+ where our applier rolls back partial writes on failure.
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkBUJ5KYCIcjs = require('./chunk-BUJ5KYCI.cjs');
4
+ require('./chunk-GZBD6QRS.cjs');
5
+ require('./chunk-EL2RL5DG.cjs');
6
+ require('./chunk-JHNCK7JP.cjs');
7
+ require('./chunk-IJSHQGMP.cjs');
8
+
9
+
10
+ exports.AnthropicClient = _chunkBUJ5KYCIcjs.AnthropicClient;
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  AnthropicClient
3
- } from "./chunk-YZ25SSWJ.js";
4
- import "./chunk-O6F2EF2Z.js";
3
+ } from "./chunk-M2SVOKC6.js";
4
+ import "./chunk-SCDKLTN3.js";
5
5
  import "./chunk-FUOKLKR2.js";
6
+ import "./chunk-ZRVPCXI7.js";
6
7
  import "./chunk-DI7RDLOS.js";
7
8
  export {
8
9
  AnthropicClient
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import type { ToolDefinition, ToolCall } from "../../types.js";
10
10
  export declare const MAX_TOOL_RESULT = 15000;
11
- export declare const MAX_TOOL_ROUNDS = 5;
11
+ export declare const MAX_TOOL_ROUNDS = 3;
12
12
  export declare const CONTEXT_TOOLS: ToolDefinition[];
13
13
  /**
14
14
  * Execute a context tool call and return the result string.
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunk3EUDE77Ecjs = require('../chunk-3EUDE77E.cjs');
8
+ var _chunkX2DNIMPCcjs = require('../chunk-X2DNIMPC.cjs');
9
9
 
10
10
 
11
11
 
@@ -48,9 +48,9 @@ var _chunk3EUDE77Ecjs = require('../chunk-3EUDE77E.cjs');
48
48
 
49
49
 
50
50
 
51
- var _chunkFVP7XJGScjs = require('../chunk-FVP7XJGS.cjs');
52
- require('../chunk-IMMTBZ33.cjs');
51
+ var _chunkHOXQLX5Rcjs = require('../chunk-HOXQLX5R.cjs');
53
52
  require('../chunk-EL2RL5DG.cjs');
53
+ require('../chunk-JHNCK7JP.cjs');
54
54
  require('../chunk-IJSHQGMP.cjs');
55
55
 
56
56
 
@@ -100,4 +100,4 @@ require('../chunk-IJSHQGMP.cjs');
100
100
 
101
101
 
102
102
 
103
- exports.Arena = _chunkFVP7XJGScjs.Arena; exports.ArenaLedger = _chunkFVP7XJGScjs.ArenaLedger; exports.DiscussionStrategy = _chunkFVP7XJGScjs.DiscussionStrategy; exports.IterativeArena = _chunk3EUDE77Ecjs.IterativeArena; exports.LENS_NAMES = _chunkFVP7XJGScjs.LENS_NAMES; exports.MODEL_PRESETS = _chunkFVP7XJGScjs.MODEL_PRESETS; exports.PlanningStrategy = _chunkFVP7XJGScjs.PlanningStrategy; exports.ReviewStrategy = _chunkFVP7XJGScjs.ReviewStrategy; exports.applyReviewResult = _chunkFVP7XJGScjs.applyReviewResult; exports.buildConsensus = _chunkFVP7XJGScjs.buildConsensus; exports.buildDigest = _chunkFVP7XJGScjs.buildDigest; exports.buildLensPrompt = _chunkFVP7XJGScjs.buildLensPrompt; exports.collectEvidence = _chunkFVP7XJGScjs.collectEvidence; exports.createProgressRenderer = _chunkFVP7XJGScjs.createProgressRenderer; exports.defaultIterateConvergence = _chunk3EUDE77Ecjs.defaultConvergence; exports.formatArenaResult = _chunkFVP7XJGScjs.formatArenaResult; exports.formatArenaResultForSession = _chunkFVP7XJGScjs.formatArenaResultForSession; exports.formatDigest = _chunkFVP7XJGScjs.formatDigest; exports.getIterateFormat = _chunk3EUDE77Ecjs.getFormat; exports.getLens = _chunkFVP7XJGScjs.getLens; exports.getMaxOutputTokens = _chunkFVP7XJGScjs.getMaxOutputTokens; exports.getStrategy = _chunkFVP7XJGScjs.getStrategy; exports.getStrategyForPlan = _chunkFVP7XJGScjs.getStrategyForPlan; exports.hasTools = _chunkFVP7XJGScjs.hasTools; exports.isStrategyV2 = _chunkFVP7XJGScjs.isStrategyV2; exports.isTerminal = _chunkFVP7XJGScjs.isTerminal; exports.iterateCodeFormat = _chunk3EUDE77Ecjs.codeFormat; exports.iterateDiffRatio = _chunk3EUDE77Ecjs.diffRatio; exports.iterateDocumentFormat = _chunk3EUDE77Ecjs.documentFormat; exports.markUnderReview = _chunkFVP7XJGScjs.markUnderReview; exports.markUnresolved = _chunkFVP7XJGScjs.markUnresolved; exports.planArena = _chunkFVP7XJGScjs.planArena; exports.printArenaResult = _chunkFVP7XJGScjs.printArenaResult; exports.registerClaims = _chunkFVP7XJGScjs.registerClaims; exports.renderProgress = _chunkFVP7XJGScjs.renderProgress; exports.resolveClaimStatus = _chunkFVP7XJGScjs.resolveClaimStatus; exports.resolveLenses = _chunkFVP7XJGScjs.resolveLenses; exports.runAdjudication = _chunkFVP7XJGScjs.runAdjudication; exports.runCrossReview = _chunkFVP7XJGScjs.runCrossReview; exports.runDebateRounds = _chunkFVP7XJGScjs.runDebateRounds; exports.runParticipantResearch = _chunkFVP7XJGScjs.runParticipantResearch; exports.runParticipantResearchWithDossiers = _chunkFVP7XJGScjs.runParticipantResearchWithDossiers; exports.runVerificationReview = _chunkFVP7XJGScjs.runVerificationReview; exports.selectClaimsForReview = _chunkFVP7XJGScjs.selectClaimsForReview; exports.selectTools = _chunkFVP7XJGScjs.selectTools; exports.transitionClaim = _chunkFVP7XJGScjs.transitionClaim; exports.validTransitions = _chunkFVP7XJGScjs.validTransitions;
103
+ exports.Arena = _chunkHOXQLX5Rcjs.Arena; exports.ArenaLedger = _chunkHOXQLX5Rcjs.ArenaLedger; exports.DiscussionStrategy = _chunkHOXQLX5Rcjs.DiscussionStrategy; exports.IterativeArena = _chunkX2DNIMPCcjs.IterativeArena; exports.LENS_NAMES = _chunkHOXQLX5Rcjs.LENS_NAMES; exports.MODEL_PRESETS = _chunkHOXQLX5Rcjs.MODEL_PRESETS; exports.PlanningStrategy = _chunkHOXQLX5Rcjs.PlanningStrategy; exports.ReviewStrategy = _chunkHOXQLX5Rcjs.ReviewStrategy; exports.applyReviewResult = _chunkHOXQLX5Rcjs.applyReviewResult; exports.buildConsensus = _chunkHOXQLX5Rcjs.buildConsensus; exports.buildDigest = _chunkHOXQLX5Rcjs.buildDigest; exports.buildLensPrompt = _chunkHOXQLX5Rcjs.buildLensPrompt; exports.collectEvidence = _chunkHOXQLX5Rcjs.collectEvidence; exports.createProgressRenderer = _chunkHOXQLX5Rcjs.createProgressRenderer; exports.defaultIterateConvergence = _chunkX2DNIMPCcjs.defaultConvergence; exports.formatArenaResult = _chunkHOXQLX5Rcjs.formatArenaResult; exports.formatArenaResultForSession = _chunkHOXQLX5Rcjs.formatArenaResultForSession; exports.formatDigest = _chunkHOXQLX5Rcjs.formatDigest; exports.getIterateFormat = _chunkX2DNIMPCcjs.getFormat; exports.getLens = _chunkHOXQLX5Rcjs.getLens; exports.getMaxOutputTokens = _chunkHOXQLX5Rcjs.getMaxOutputTokens; exports.getStrategy = _chunkHOXQLX5Rcjs.getStrategy; exports.getStrategyForPlan = _chunkHOXQLX5Rcjs.getStrategyForPlan; exports.hasTools = _chunkHOXQLX5Rcjs.hasTools; exports.isStrategyV2 = _chunkHOXQLX5Rcjs.isStrategyV2; exports.isTerminal = _chunkHOXQLX5Rcjs.isTerminal; exports.iterateCodeFormat = _chunkX2DNIMPCcjs.codeFormat; exports.iterateDiffRatio = _chunkX2DNIMPCcjs.diffRatio; exports.iterateDocumentFormat = _chunkX2DNIMPCcjs.documentFormat; exports.markUnderReview = _chunkHOXQLX5Rcjs.markUnderReview; exports.markUnresolved = _chunkHOXQLX5Rcjs.markUnresolved; exports.planArena = _chunkHOXQLX5Rcjs.planArena; exports.printArenaResult = _chunkHOXQLX5Rcjs.printArenaResult; exports.registerClaims = _chunkHOXQLX5Rcjs.registerClaims; exports.renderProgress = _chunkHOXQLX5Rcjs.renderProgress; exports.resolveClaimStatus = _chunkHOXQLX5Rcjs.resolveClaimStatus; exports.resolveLenses = _chunkHOXQLX5Rcjs.resolveLenses; exports.runAdjudication = _chunkHOXQLX5Rcjs.runAdjudication; exports.runCrossReview = _chunkHOXQLX5Rcjs.runCrossReview; exports.runDebateRounds = _chunkHOXQLX5Rcjs.runDebateRounds; exports.runParticipantResearch = _chunkHOXQLX5Rcjs.runParticipantResearch; exports.runParticipantResearchWithDossiers = _chunkHOXQLX5Rcjs.runParticipantResearchWithDossiers; exports.runVerificationReview = _chunkHOXQLX5Rcjs.runVerificationReview; exports.selectClaimsForReview = _chunkHOXQLX5Rcjs.selectClaimsForReview; exports.selectTools = _chunkHOXQLX5Rcjs.selectTools; exports.transitionClaim = _chunkHOXQLX5Rcjs.transitionClaim; exports.validTransitions = _chunkHOXQLX5Rcjs.validTransitions;
@@ -5,7 +5,7 @@ import {
5
5
  diffRatio,
6
6
  documentFormat,
7
7
  getFormat
8
- } from "../chunk-ZXYDDJEJ.js";
8
+ } from "../chunk-OUC2DFA7.js";
9
9
  import {
10
10
  Arena,
11
11
  ArenaLedger,
@@ -48,9 +48,9 @@ import {
48
48
  selectTools,
49
49
  transitionClaim,
50
50
  validTransitions
51
- } from "../chunk-SQZHPD3S.js";
52
- import "../chunk-X4HAERTQ.js";
51
+ } from "../chunk-Y7TSCDF6.js";
53
52
  import "../chunk-FUOKLKR2.js";
53
+ import "../chunk-ZRVPCXI7.js";
54
54
  import "../chunk-DI7RDLOS.js";
55
55
  export {
56
56
  Arena,
@@ -1,16 +1,32 @@
1
1
  /**
2
2
  * Provider registry — evidence collectors for Arena.
3
3
  */
4
- import type { ArenaPlan, ArenaArtifact, ArenaQuickFact } from "../types.js";
4
+ import type { ArenaPlan, ArenaArtifact, ArenaSourceKind, ArenaQuickFact } from "../types.js";
5
5
  export { gitProvider } from "./git.js";
6
6
  export { repoProvider } from "./repo.js";
7
7
  export { docsProvider } from "./docs.js";
8
8
  export { noneProvider } from "./none.js";
9
+ export interface CollectEvidenceOptions {
10
+ /** Heartbeat callback fired before/after each provider runs. */
11
+ onProgress?: (event: {
12
+ type: "evidence_started" | "evidence_collected";
13
+ source: ArenaSourceKind;
14
+ count?: number;
15
+ durationMs?: number;
16
+ timedOut?: boolean;
17
+ }) => void;
18
+ signal?: AbortSignal;
19
+ }
9
20
  /**
10
21
  * Collect all evidence according to the plan's sources.
11
22
  * Returns unified ArenaArtifact[] and quickFacts.
23
+ *
24
+ * Providers run in parallel (independent of one another) with a
25
+ * per-provider timeout, so a single slow source can't stall the
26
+ * whole arena. Heartbeats are emitted around each provider so the
27
+ * UI can show "collecting from repo..." instead of a blank pause.
12
28
  */
13
- export declare function collectEvidence(plan: ArenaPlan, topic: string): {
29
+ export declare function collectEvidence(plan: ArenaPlan, topic: string, options?: CollectEvidenceOptions): Promise<{
14
30
  artifacts: ArenaArtifact[];
15
31
  quickFacts: ArenaQuickFact[];
16
- };
32
+ }>;
@@ -10,7 +10,12 @@ export declare function formatBaseContext(ctx: ArenaBaseContext): string;
10
10
  export declare function formatReports(reports: ParticipantReport[]): string;
11
11
  /** Format finding reviews for consensus prompts */
12
12
  export declare function formatFindingReviews(reviews: FindingReview[]): string;
13
- /** Parse a ParticipantReport from LLM JSON output */
13
+ /**
14
+ * Parse a ParticipantReport. The research prompt now asks for an
15
+ * XML <report> element because thinking-mode models (DeepSeek V4)
16
+ * produced malformed JSON often enough to derail the loop. We try
17
+ * XML first, then JSON, then a free-text salvage.
18
+ */
14
19
  export declare function parseReport(participant: string, text: string): ParticipantReport;
15
20
  /** Parse FindingReview[] from LLM JSON output */
16
21
  export declare function parseReviews(reviewer: string, text: string): FindingReview[];
@@ -71,7 +71,7 @@ export interface ArenaToolPack {
71
71
  /** Context provider interface — collects evidence from a source */
72
72
  export interface ArenaContextProvider {
73
73
  kind: ArenaSourceKind;
74
- collect(plan: ArenaPlan, topic: string): ArenaArtifact[];
74
+ collect(plan: ArenaPlan, topic: string): ArenaArtifact[] | Promise<ArenaArtifact[]>;
75
75
  }
76
76
  /** Quick fact — high-signal summary entry */
77
77
  export interface ArenaQuickFact {
@@ -440,6 +440,15 @@ export interface ArenaConfig {
440
440
  export type ArenaProgressEvent = {
441
441
  type: "plan_resolved";
442
442
  plan: ArenaPlan;
443
+ } | {
444
+ type: "evidence_started";
445
+ source: ArenaSourceKind;
446
+ } | {
447
+ type: "evidence_source_done";
448
+ source: ArenaSourceKind;
449
+ count: number;
450
+ durationMs: number;
451
+ timedOut: boolean;
443
452
  } | {
444
453
  type: "evidence_collected";
445
454
  artifacts: ArenaArtifact[];
@@ -1,10 +1,9 @@
1
1
  import {
2
2
  ModelPool
3
- } from "./chunk-KO2FPF7G.js";
3
+ } from "./chunk-F5BS3GUC.js";
4
4
  import {
5
- SettingsManager,
6
- init_manager
7
- } from "./chunk-6ZIROYXX.js";
5
+ SettingsManager
6
+ } from "./chunk-75E4BBFC.js";
8
7
  import {
9
8
  Arena,
10
9
  MODEL_PRESETS,
@@ -13,9 +12,9 @@ import {
13
12
  getMaxOutputTokens,
14
13
  printArenaResult,
15
14
  renderProgress
16
- } from "./chunk-SQZHPD3S.js";
17
- import "./chunk-X4HAERTQ.js";
15
+ } from "./chunk-Y7TSCDF6.js";
18
16
  import "./chunk-FUOKLKR2.js";
17
+ import "./chunk-ZRVPCXI7.js";
19
18
  import {
20
19
  init_esm_shims
21
20
  } from "./chunk-DI7RDLOS.js";
@@ -23,7 +22,6 @@ import {
23
22
  // src/cli/commands/arena.ts
24
23
  init_esm_shims();
25
24
  import chalk from "chalk";
26
- init_manager();
27
25
  async function runArenaReview(arg, engineConfig, opts) {
28
26
  const { models: modelsFlag, mode: explicitMode, base, head, topic } = parseFlags(arg);
29
27
  const out = opts?.output ?? ((text) => console.log(text));
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkUK2SU23Scjs = require('./chunk-UK2SU23S.cjs');
3
+ var _chunkKOGV6PDQcjs = require('./chunk-KOGV6PDQ.cjs');
4
4
 
5
5
 
6
+ var _chunkFV2ARONZcjs = require('./chunk-FV2ARONZ.cjs');
6
7
 
7
- var _chunkFGZGCFJXcjs = require('./chunk-FGZGCFJX.cjs');
8
8
 
9
9
 
10
10
 
@@ -12,10 +12,9 @@ var _chunkFGZGCFJXcjs = require('./chunk-FGZGCFJX.cjs');
12
12
 
13
13
 
14
14
 
15
-
16
- var _chunkFVP7XJGScjs = require('./chunk-FVP7XJGS.cjs');
17
- require('./chunk-IMMTBZ33.cjs');
15
+ var _chunkHOXQLX5Rcjs = require('./chunk-HOXQLX5R.cjs');
18
16
  require('./chunk-EL2RL5DG.cjs');
17
+ require('./chunk-JHNCK7JP.cjs');
19
18
 
20
19
 
21
20
  var _chunkIJSHQGMPcjs = require('./chunk-IJSHQGMP.cjs');
@@ -23,7 +22,6 @@ var _chunkIJSHQGMPcjs = require('./chunk-IJSHQGMP.cjs');
23
22
  // src/cli/commands/arena.ts
24
23
  _chunkIJSHQGMPcjs.init_cjs_shims.call(void 0, );
25
24
  var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
26
- _chunkFGZGCFJXcjs.init_manager.call(void 0, );
27
25
  async function runArenaReview(arg, engineConfig, opts) {
28
26
  const { models: modelsFlag, mode: explicitMode, base, head, topic } = parseFlags(arg);
29
27
  const out = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _ => _.output]), () => ( ((text) => console.log(text))));
@@ -40,8 +38,8 @@ async function runArenaReview(arg, engineConfig, opts) {
40
38
  out(_chalk2.default.bold(`\u2550\u2550\u2550 Arena ${modeLabel} \u2550\u2550\u2550`));
41
39
  out(_chalk2.default.dim(`Topic: ${topic}`));
42
40
  out(_chalk2.default.dim(`Models: ${participants.map((p) => p.name).join(" vs ")}`));
43
- const progressRenderer = _optionalChain([opts, 'optionalAccess', _2 => _2.output]) ? _chunkFVP7XJGScjs.createProgressRenderer.call(void 0, opts.output) : _chunkFVP7XJGScjs.renderProgress;
44
- const arena = new (0, _chunkFVP7XJGScjs.Arena)({
41
+ const progressRenderer = _optionalChain([opts, 'optionalAccess', _2 => _2.output]) ? _chunkHOXQLX5Rcjs.createProgressRenderer.call(void 0, opts.output) : _chunkHOXQLX5Rcjs.renderProgress;
42
+ const arena = new (0, _chunkHOXQLX5Rcjs.Arena)({
45
43
  participants,
46
44
  mode: explicitMode,
47
45
  enableContextTools: true,
@@ -55,9 +53,9 @@ async function runArenaReview(arg, engineConfig, opts) {
55
53
  });
56
54
  const resultSink = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _3 => _3.outputMessage]), () => ( _optionalChain([opts, 'optionalAccess', _4 => _4.output])));
57
55
  if (resultSink) {
58
- resultSink(_chunkFVP7XJGScjs.formatArenaResultForSession.call(void 0, result));
56
+ resultSink(_chunkHOXQLX5Rcjs.formatArenaResultForSession.call(void 0, result));
59
57
  } else {
60
- _chunkFVP7XJGScjs.printArenaResult.call(void 0, result);
58
+ _chunkHOXQLX5Rcjs.printArenaResult.call(void 0, result);
61
59
  }
62
60
  return result;
63
61
  } catch (err) {
@@ -66,9 +64,9 @@ async function runArenaReview(arg, engineConfig, opts) {
66
64
  }
67
65
  }
68
66
  function buildModelPool(engineConfig) {
69
- const pool = new (0, _chunkUK2SU23Scjs.ModelPool)();
67
+ const pool = new (0, _chunkKOGV6PDQcjs.ModelPool)();
70
68
  try {
71
- const settings = new (0, _chunkFGZGCFJXcjs.SettingsManager)(process.cwd()).get();
69
+ const settings = new (0, _chunkFV2ARONZcjs.SettingsManager)(process.cwd()).get();
72
70
  if (_optionalChain([settings, 'access', _5 => _5.models, 'optionalAccess', _6 => _6.length])) {
73
71
  for (const m of settings.models) {
74
72
  pool.register({
@@ -98,7 +96,7 @@ function resolveOneParticipant(entry, pool, engineConfig) {
98
96
  apiKey: _nullishCoalesce(m.apiKey, () => ( engineConfig.llm.apiKey)),
99
97
  baseUrl: _nullishCoalesce(m.baseUrl, () => ( engineConfig.llm.baseUrl)),
100
98
  temperature: 0.3,
101
- maxTokens: _nullishCoalesce(m.maxOutputTokens, () => ( _chunkFVP7XJGScjs.getMaxOutputTokens.call(void 0, m.model))),
99
+ maxTokens: _nullishCoalesce(m.maxOutputTokens, () => ( _chunkHOXQLX5Rcjs.getMaxOutputTokens.call(void 0, m.model))),
102
100
  enableStreaming: false
103
101
  }
104
102
  };
@@ -111,7 +109,7 @@ function resolveOneParticipant(entry, pool, engineConfig) {
111
109
  apiKey: _nullishCoalesce(entry.apiKey, () => ( engineConfig.llm.apiKey)),
112
110
  baseUrl: _nullishCoalesce(entry.baseUrl, () => ( engineConfig.llm.baseUrl)),
113
111
  temperature: 0.3,
114
- maxTokens: _chunkFVP7XJGScjs.getMaxOutputTokens.call(void 0, entry.model),
112
+ maxTokens: _chunkHOXQLX5Rcjs.getMaxOutputTokens.call(void 0, entry.model),
115
113
  enableStreaming: false
116
114
  }
117
115
  };
@@ -131,12 +129,12 @@ function resolveParticipants(engineConfig, modelsFlag) {
131
129
  apiKey: _nullishCoalesce(fromPool.apiKey, () => ( engineConfig.llm.apiKey)),
132
130
  baseUrl: _nullishCoalesce(fromPool.baseUrl, () => ( engineConfig.llm.baseUrl)),
133
131
  temperature: 0.3,
134
- maxTokens: _nullishCoalesce(fromPool.maxOutputTokens, () => ( _chunkFVP7XJGScjs.getMaxOutputTokens.call(void 0, fromPool.model))),
132
+ maxTokens: _nullishCoalesce(fromPool.maxOutputTokens, () => ( _chunkHOXQLX5Rcjs.getMaxOutputTokens.call(void 0, fromPool.model))),
135
133
  enableStreaming: false
136
134
  }
137
135
  };
138
136
  }
139
- const preset = _chunkFVP7XJGScjs.MODEL_PRESETS[name];
137
+ const preset = _chunkHOXQLX5Rcjs.MODEL_PRESETS[name];
140
138
  if (preset) {
141
139
  return {
142
140
  name: modelDisplayName(preset.model),
@@ -157,7 +155,7 @@ function resolveParticipants(engineConfig, modelsFlag) {
157
155
  };
158
156
  });
159
157
  }
160
- const settings = new (0, _chunkFGZGCFJXcjs.SettingsManager)(process.cwd()).get();
158
+ const settings = new (0, _chunkFV2ARONZcjs.SettingsManager)(process.cwd()).get();
161
159
  if (_optionalChain([settings, 'access', _7 => _7.arena, 'optionalAccess', _8 => _8.participants, 'optionalAccess', _9 => _9.length]) >= 2) {
162
160
  const resolved = settings.arena.participants.map((p) => resolveOneParticipant(p, pool, engineConfig)).filter((p) => p !== void 0);
163
161
  if (resolved.length >= 2) return resolved;
@@ -167,7 +165,7 @@ function resolveParticipants(engineConfig, modelsFlag) {
167
165
  name: modelDisplayName(engineConfig.llm.model),
168
166
  llm: {
169
167
  ...engineConfig.llm,
170
- maxTokens: _chunkFVP7XJGScjs.getMaxOutputTokens.call(void 0, engineConfig.llm.model),
168
+ maxTokens: _chunkHOXQLX5Rcjs.getMaxOutputTokens.call(void 0, engineConfig.llm.model),
171
169
  enableStreaming: false
172
170
  }
173
171
  }
@@ -180,7 +178,7 @@ function resolveParticipants(engineConfig, modelsFlag) {
180
178
  llm: {
181
179
  ...engineConfig.llm,
182
180
  model: opponent,
183
- maxTokens: _chunkFVP7XJGScjs.getMaxOutputTokens.call(void 0, opponent),
181
+ maxTokens: _chunkHOXQLX5Rcjs.getMaxOutputTokens.call(void 0, opponent),
184
182
  enableStreaming: false
185
183
  }
186
184
  });
@@ -234,7 +232,7 @@ function formatUsage() {
234
232
  " --base <ref> Base branch/ref for comparison",
235
233
  " --head <ref> Head branch/ref (default: HEAD)",
236
234
  "",
237
- `${_chalk2.default.dim("Available model presets:")} ${Object.keys(_chunkFVP7XJGScjs.MODEL_PRESETS).join(", ")}`
235
+ `${_chalk2.default.dim("Available model presets:")} ${Object.keys(_chunkHOXQLX5Rcjs.MODEL_PRESETS).join(", ")}`
238
236
  ].join("\n");
239
237
  }
240
238
  function formatModelHelp(engineConfig) {
@@ -258,4 +256,4 @@ function modelDisplayName(model) {
258
256
 
259
257
 
260
258
 
261
- exports.formatArenaResultForSession = _chunkFVP7XJGScjs.formatArenaResultForSession; exports.runArenaReview = runArenaReview;
259
+ exports.formatArenaResultForSession = _chunkHOXQLX5Rcjs.formatArenaResultForSession; exports.runArenaReview = runArenaReview;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-X4HAERTQ.js";
3
+ } from "./chunk-ZRVPCXI7.js";
4
4
  import {
5
5
  init_esm_shims
6
6
  } from "./chunk-DI7RDLOS.js";
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkQHDYFC5Ucjs = require('./chunk-QHDYFC5U.cjs');
7
+ var _chunkVWFET3MGcjs = require('./chunk-VWFET3MG.cjs');
8
8
 
9
9
 
10
10
  var _chunkIJSHQGMPcjs = require('./chunk-IJSHQGMP.cjs');
@@ -61,12 +61,12 @@ function defineProduct(definition, runtime) {
61
61
  builtinTools: [...enabledSet],
62
62
  defaultPermissionRules: permissionRules
63
63
  };
64
- _chunkQHDYFC5Ucjs.registerPreset.call(void 0, agentPreset);
64
+ _chunkVWFET3MGcjs.registerPreset.call(void 0, agentPreset);
65
65
  let evaluator;
66
66
  if (!_optionalChain([contract, 'optionalAccess', _4 => _4.evaluator])) {
67
- evaluator = new (0, _chunkQHDYFC5Ucjs.NoopEvaluator)();
67
+ evaluator = new (0, _chunkVWFET3MGcjs.NoopEvaluator)();
68
68
  } else if (Array.isArray(contract.evaluator)) {
69
- evaluator = new (0, _chunkQHDYFC5Ucjs.CompositeEvaluator)(contract.evaluator);
69
+ evaluator = new (0, _chunkVWFET3MGcjs.CompositeEvaluator)(contract.evaluator);
70
70
  } else {
71
71
  evaluator = contract.evaluator;
72
72
  }
@@ -76,8 +76,8 @@ function defineProduct(definition, runtime) {
76
76
  execute: ct.execute
77
77
  }));
78
78
  const runsDir = _nullishCoalesce(runtime.runsDir, () => ( _path.join.call(void 0, _os.homedir.call(void 0, ), ".code-shell", "runs")));
79
- const store = new (0, _chunkQHDYFC5Ucjs.FileRunStore)(runsDir);
80
- const manager = new (0, _chunkQHDYFC5Ucjs.RunManager)({
79
+ const store = new (0, _chunkVWFET3MGcjs.FileRunStore)(runsDir);
80
+ const manager = new (0, _chunkVWFET3MGcjs.RunManager)({
81
81
  store,
82
82
  executor: {
83
83
  llm: runtime.llm,
@@ -90,11 +90,14 @@ function defineProduct(definition, runtime) {
90
90
  disabledBuiltinTools: _optionalChain([adapter, 'optionalAccess', _9 => _9.disableTools]),
91
91
  customSystemPrompt: presetDef.customPrompt,
92
92
  appendSystemPrompt: presetDef.appendPrompt,
93
+ hooks: _optionalChain([adapter, 'optionalAccess', _10 => _10.hooks]),
93
94
  customTools: customToolEntries.length > 0 ? customToolEntries : void 0
94
95
  },
95
- concurrency: _nullishCoalesce(_optionalChain([contract, 'optionalAccess', _10 => _10.concurrency]), () => ( 1)),
96
+ concurrency: _nullishCoalesce(_optionalChain([contract, 'optionalAccess', _11 => _11.concurrency]), () => ( 1)),
96
97
  runsDir,
97
- evaluator
98
+ evaluator,
99
+ defaultTags: _optionalChain([contract, 'optionalAccess', _12 => _12.defaultTags]),
100
+ defaultMetadata: _optionalChain([contract, 'optionalAccess', _13 => _13.defaultMetadata])
98
101
  });
99
102
  return { manager, preset: agentPreset, customTools };
100
103
  }
@@ -1,13 +1,72 @@
1
- import {
2
- estimateMessagesTokens,
3
- init_token_counter
4
- } from "./chunk-4RRUP4MM.js";
5
1
  import {
6
2
  __esm,
7
3
  __export,
8
4
  init_esm_shims
9
5
  } from "./chunk-DI7RDLOS.js";
10
6
 
7
+ // src/context/token-counter.ts
8
+ function estimateStringTokens(text) {
9
+ if (!text) return 0;
10
+ const cjkChars = (text.match(/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g) ?? []).length;
11
+ const cjkRatio = cjkChars / text.length;
12
+ if (cjkRatio > 0.3) {
13
+ const cjkTokens = cjkChars / RATIOS.cjk;
14
+ const otherChars = text.length - cjkChars;
15
+ const otherTokens = otherChars / RATIOS.english;
16
+ return Math.ceil(cjkTokens + otherTokens);
17
+ }
18
+ const codeIndicators = ["{", "}", "(", ")", ";", "=>", "import ", "function ", "class ", "const "];
19
+ const codeScore = codeIndicators.reduce((s, ind) => s + (text.includes(ind) ? 1 : 0), 0);
20
+ if (codeScore >= 3) return Math.ceil(text.length / RATIOS.code);
21
+ if (text.startsWith("{") || text.startsWith("[")) return Math.ceil(text.length / RATIOS.json);
22
+ return Math.ceil(text.length / RATIOS.english);
23
+ }
24
+ function estimateMessagesTokens(messages) {
25
+ let total = 0;
26
+ for (const msg of messages) {
27
+ total += 4;
28
+ if (typeof msg.content === "string") {
29
+ total += estimateStringTokens(msg.content);
30
+ } else if (Array.isArray(msg.content)) {
31
+ for (const block of msg.content) {
32
+ total += estimateBlockTokens(block);
33
+ }
34
+ }
35
+ }
36
+ return total;
37
+ }
38
+ function estimateBlockTokens(block) {
39
+ let tokens = 2;
40
+ if (block.text) tokens += estimateStringTokens(block.text);
41
+ if (block.content && typeof block.content === "string") {
42
+ tokens += estimateStringTokens(block.content);
43
+ }
44
+ if (block.input) {
45
+ tokens += estimateStringTokens(JSON.stringify(block.input));
46
+ }
47
+ if (block.name) tokens += estimateStringTokens(block.name);
48
+ return tokens;
49
+ }
50
+ var RATIOS;
51
+ var init_token_counter = __esm({
52
+ "src/context/token-counter.ts"() {
53
+ "use strict";
54
+ init_esm_shims();
55
+ RATIOS = {
56
+ english: 4,
57
+ // ~4 chars per token for English prose
58
+ code: 3.2,
59
+ // ~3.2 chars per token for code (more tokens per char)
60
+ json: 3.5,
61
+ // JSON structures
62
+ mixed: 3.6,
63
+ // Mixed content (typical for tool results)
64
+ cjk: 1.5
65
+ // CJK characters: ~1.5 chars per token
66
+ };
67
+ }
68
+ });
69
+
11
70
  // src/context/compaction.ts
12
71
  var compaction_exports = {};
13
72
  __export(compaction_exports, {