@cjhyy/code-shell 0.3.0 → 0.5.0-rc.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 (464) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/dist/cli.js +2 -0
  3. package/dist/index.d.ts +1 -68
  4. package/dist/index.js +1 -1
  5. package/package.json +25 -73
  6. package/dist/agent/coordinator.d.ts +0 -49
  7. package/dist/anthropic-DJXVKFMJ.js +0 -1
  8. package/dist/arena/arena.d.ts +0 -43
  9. package/dist/arena/context/context-tools.d.ts +0 -16
  10. package/dist/arena/detect-mode.d.ts +0 -20
  11. package/dist/arena/digest-builder.d.ts +0 -25
  12. package/dist/arena/index.d.ts +0 -29
  13. package/dist/arena/index.js +0 -1
  14. package/dist/arena/iterate/convergence.d.ts +0 -25
  15. package/dist/arena/iterate/formats/index.d.ts +0 -22
  16. package/dist/arena/iterate/index.d.ts +0 -11
  17. package/dist/arena/iterate/iterative-arena.d.ts +0 -23
  18. package/dist/arena/iterate/parse.d.ts +0 -42
  19. package/dist/arena/iterate/phases/argue.d.ts +0 -22
  20. package/dist/arena/iterate/phases/revise.d.ts +0 -16
  21. package/dist/arena/iterate/phases/tournament.d.ts +0 -34
  22. package/dist/arena/iterate/tools/web-tools.d.ts +0 -13
  23. package/dist/arena/iterate/types.d.ts +0 -152
  24. package/dist/arena/ledger.d.ts +0 -47
  25. package/dist/arena/lenses/architecture.d.ts +0 -5
  26. package/dist/arena/lenses/engineering.d.ts +0 -5
  27. package/dist/arena/lenses/general.d.ts +0 -5
  28. package/dist/arena/lenses/index.d.ts +0 -16
  29. package/dist/arena/lenses/product.d.ts +0 -5
  30. package/dist/arena/model-presets.d.ts +0 -23
  31. package/dist/arena/phases/adjudication.d.ts +0 -24
  32. package/dist/arena/phases/build-consensus.d.ts +0 -29
  33. package/dist/arena/phases/claim-registry.d.ts +0 -26
  34. package/dist/arena/phases/cross-review.d.ts +0 -45
  35. package/dist/arena/phases/debate-rounds.d.ts +0 -27
  36. package/dist/arena/phases/participant-research.d.ts +0 -38
  37. package/dist/arena/phases/planning-detail-expansion.d.ts +0 -38
  38. package/dist/arena/planner.d.ts +0 -27
  39. package/dist/arena/providers/docs.d.ts +0 -6
  40. package/dist/arena/providers/git.d.ts +0 -8
  41. package/dist/arena/providers/index.d.ts +0 -32
  42. package/dist/arena/providers/none.d.ts +0 -7
  43. package/dist/arena/providers/repo.d.ts +0 -6
  44. package/dist/arena/render/session.d.ts +0 -17
  45. package/dist/arena/render/terminal.d.ts +0 -33
  46. package/dist/arena/strategies/discussion.d.ts +0 -25
  47. package/dist/arena/strategies/index.d.ts +0 -15
  48. package/dist/arena/strategies/language-wrapper.d.ts +0 -17
  49. package/dist/arena/strategies/lens-wrapper.d.ts +0 -16
  50. package/dist/arena/strategies/planning.d.ts +0 -30
  51. package/dist/arena/strategies/review.d.ts +0 -26
  52. package/dist/arena/strategies/utils.d.ts +0 -39
  53. package/dist/arena/tools/selector.d.ts +0 -17
  54. package/dist/arena/transitions.d.ts +0 -48
  55. package/dist/arena/types.d.ts +0 -508
  56. package/dist/arena-MRBATZFD.js +0 -3
  57. package/dist/bootstrap/setup.d.ts +0 -14
  58. package/dist/bootstrap/state.d.ts +0 -160
  59. package/dist/bwrap-PVZMLHZR.js +0 -2
  60. package/dist/chunk-2OD6VR4N.js +0 -2
  61. package/dist/chunk-3QP5BQ3L.js +0 -1
  62. package/dist/chunk-5QIVXFCT.js +0 -1
  63. package/dist/chunk-AFMP73YP.js +0 -2
  64. package/dist/chunk-D3TVASD2.js +0 -4
  65. package/dist/chunk-DI26OUIU.js +0 -2
  66. package/dist/chunk-FU7AHZNN.js +0 -1
  67. package/dist/chunk-FZXY554D.js +0 -2
  68. package/dist/chunk-GGVAOPI7.js +0 -1
  69. package/dist/chunk-GKAQH2DG.js +0 -2
  70. package/dist/chunk-GYNO4R7R.js +0 -2
  71. package/dist/chunk-K4HILJ6G.js +0 -251
  72. package/dist/chunk-M7VU4YVY.js +0 -49
  73. package/dist/chunk-MLCTC53I.js +0 -1
  74. package/dist/chunk-O5HFCH2U.js +0 -1
  75. package/dist/chunk-OWBYLMDD.js +0 -1
  76. package/dist/chunk-P6JSTIFM.js +0 -1
  77. package/dist/chunk-QTWU7UNA.js +0 -5
  78. package/dist/chunk-SKIX2M5Z.js +0 -4
  79. package/dist/chunk-SNFAPSLA.js +0 -1
  80. package/dist/chunk-SV7H4FKT.js +0 -3
  81. package/dist/chunk-T222K6IV.js +0 -18
  82. package/dist/chunk-TKJA6W36.js +0 -3
  83. package/dist/chunk-WI6FSWGU.js +0 -1
  84. package/dist/chunk-WONQHE4P.js +0 -641
  85. package/dist/chunk-X2S7ASQ2.js +0 -1
  86. package/dist/chunk-Z5HKHAO7.js +0 -336
  87. package/dist/cli/commands/arena.d.ts +0 -29
  88. package/dist/cli/commands/builtin/advanced-commands.d.ts +0 -5
  89. package/dist/cli/commands/builtin/core-commands.d.ts +0 -5
  90. package/dist/cli/commands/builtin/export-md.d.ts +0 -19
  91. package/dist/cli/commands/builtin/extra-commands.d.ts +0 -6
  92. package/dist/cli/commands/builtin/git-commands.d.ts +0 -5
  93. package/dist/cli/commands/builtin/init/detect.d.ts +0 -25
  94. package/dist/cli/commands/builtin/init/index.d.ts +0 -19
  95. package/dist/cli/commands/builtin/more-commands.d.ts +0 -5
  96. package/dist/cli/commands/builtin/permissions-command.d.ts +0 -5
  97. package/dist/cli/commands/builtin/plugin-commands-registration.d.ts +0 -12
  98. package/dist/cli/commands/builtin/plugin-handler.d.ts +0 -6
  99. package/dist/cli/commands/builtin/utility-commands.d.ts +0 -5
  100. package/dist/cli/commands/registry.d.ts +0 -79
  101. package/dist/cli/commands/repl.d.ts +0 -21
  102. package/dist/cli/commands/run.d.ts +0 -21
  103. package/dist/cli/commands/runs.d.ts +0 -14
  104. package/dist/cli/cost-tracker.d.ts +0 -63
  105. package/dist/cli/exit.d.ts +0 -12
  106. package/dist/cli/input/ndjson-reader.d.ts +0 -31
  107. package/dist/cli/input-compiler.d.ts +0 -5
  108. package/dist/cli/main.d.ts +0 -5
  109. package/dist/cli/main.js +0 -415
  110. package/dist/cli/migrate-models.d.ts +0 -45
  111. package/dist/cli/onboarding.d.ts +0 -189
  112. package/dist/cli/output/renderer.d.ts +0 -28
  113. package/dist/cli/output/terminal-ui.d.ts +0 -50
  114. package/dist/cli/updater.d.ts +0 -65
  115. package/dist/client-base-GSFXPP2Y.js +0 -1
  116. package/dist/compaction-L3Y6NG4N.js +0 -1
  117. package/dist/context/compaction.d.ts +0 -116
  118. package/dist/context/manager.d.ts +0 -145
  119. package/dist/context/token-counter.d.ts +0 -27
  120. package/dist/context/tool-result-storage.d.ts +0 -96
  121. package/dist/cron/scheduler.d.ts +0 -34
  122. package/dist/data/openrouter-models.d.ts +0 -35
  123. package/dist/data/openrouter-sync.d.ts +0 -16
  124. package/dist/data/static-catalogs.d.ts +0 -25
  125. package/dist/devtools-FBX4HVVY.js +0 -1
  126. package/dist/engine/cost-store.d.ts +0 -22
  127. package/dist/engine/engine.d.ts +0 -236
  128. package/dist/engine/model-facade.d.ts +0 -24
  129. package/dist/engine/query.d.ts +0 -50
  130. package/dist/engine/streaming-tool-queue.d.ts +0 -34
  131. package/dist/engine/token-budget.d.ts +0 -22
  132. package/dist/engine/tool-summary.d.ts +0 -13
  133. package/dist/engine/turn-loop.d.ts +0 -122
  134. package/dist/engine/turn-state.d.ts +0 -20
  135. package/dist/exceptions.d.ts +0 -44
  136. package/dist/export-md-U72T7NW7.js +0 -22
  137. package/dist/file-history-7FQFEQOL.js +0 -1
  138. package/dist/git/utils.d.ts +0 -35
  139. package/dist/git/worktree.d.ts +0 -36
  140. package/dist/hooks/events.d.ts +0 -114
  141. package/dist/hooks/inject.d.ts +0 -19
  142. package/dist/hooks/registry.d.ts +0 -15
  143. package/dist/hooks/shell-runner.d.ts +0 -45
  144. package/dist/llm/api-key-sanitize.d.ts +0 -22
  145. package/dist/llm/capabilities/index.d.ts +0 -20
  146. package/dist/llm/capabilities/rules.d.ts +0 -26
  147. package/dist/llm/capabilities/types.d.ts +0 -108
  148. package/dist/llm/client-base.d.ts +0 -29
  149. package/dist/llm/client-factory.d.ts +0 -10
  150. package/dist/llm/model-cache.d.ts +0 -21
  151. package/dist/llm/model-fetcher.d.ts +0 -29
  152. package/dist/llm/model-pool.d.ts +0 -84
  153. package/dist/llm/provider-catalog.d.ts +0 -32
  154. package/dist/llm/provider-kinds.d.ts +0 -21
  155. package/dist/llm/providers/anthropic.d.ts +0 -19
  156. package/dist/llm/providers/openai.d.ts +0 -64
  157. package/dist/llm/retry.d.ts +0 -12
  158. package/dist/llm/stream-watchdog.d.ts +0 -42
  159. package/dist/llm/token-counter.d.ts +0 -17
  160. package/dist/llm/types.d.ts +0 -37
  161. package/dist/logging/logger.d.ts +0 -102
  162. package/dist/logging/session-recorder.d.ts +0 -90
  163. package/dist/lsp/client.d.ts +0 -41
  164. package/dist/lsp/manager.d.ts +0 -40
  165. package/dist/lsp/servers.d.ts +0 -16
  166. package/dist/manager-4XKLZHKE.js +0 -1
  167. package/dist/mcp-manager-3JGHEJO3.js +0 -1
  168. package/dist/memory-BNI4WEWL.js +0 -1
  169. package/dist/model-cache-HEDXI7UJ.js +0 -1
  170. package/dist/model-fetcher-X5W5EASG.js +0 -1
  171. package/dist/native-ts/yoga-layout/enums.d.ts +0 -117
  172. package/dist/native-ts/yoga-layout/index.d.ts +0 -270
  173. package/dist/off-7SDVMMXW.js +0 -1
  174. package/dist/openai-OQ6LLN5J.js +0 -1
  175. package/dist/openrouter-models-ZT4R2AE3.js +0 -1
  176. package/dist/openrouter-sync-ARMVWY7S.js +0 -1
  177. package/dist/plugin-handler-GJISMH5Q.js +0 -11
  178. package/dist/plugins/gitOps.d.ts +0 -23
  179. package/dist/plugins/installedPlugins.d.ts +0 -15
  180. package/dist/plugins/knownMarketplaces.d.ts +0 -10
  181. package/dist/plugins/loadPluginHooks.d.ts +0 -52
  182. package/dist/plugins/marketplaceManager.d.ts +0 -49
  183. package/dist/plugins/parseMarketplaceInput.d.ts +0 -16
  184. package/dist/plugins/pluginCommandHook.d.ts +0 -54
  185. package/dist/plugins/pluginCommandsLoader.d.ts +0 -25
  186. package/dist/plugins/pluginInstaller.d.ts +0 -36
  187. package/dist/plugins/schemas.d.ts +0 -9
  188. package/dist/plugins/types.d.ts +0 -75
  189. package/dist/plugins/varRewrite.d.ts +0 -42
  190. package/dist/preset/index.d.ts +0 -60
  191. package/dist/product/define.d.ts +0 -60
  192. package/dist/product/index.d.ts +0 -5
  193. package/dist/product/index.js +0 -1
  194. package/dist/product/types.d.ts +0 -111
  195. package/dist/prompt/composer.d.ts +0 -42
  196. package/dist/prompt/instruction-scanner.d.ts +0 -54
  197. package/dist/prompt/section-cache.d.ts +0 -15
  198. package/dist/prompt/section-loader.d.ts +0 -26
  199. package/dist/protocol/client.d.ts +0 -64
  200. package/dist/protocol/helpers.d.ts +0 -42
  201. package/dist/protocol/index.d.ts +0 -4
  202. package/dist/protocol/server.d.ts +0 -51
  203. package/dist/protocol/transport.d.ts +0 -36
  204. package/dist/protocol/types.d.ts +0 -192
  205. package/dist/react-compiler-runtime-shim.d.ts +0 -1
  206. package/dist/remote/bridge.d.ts +0 -37
  207. package/dist/render/Ansi.d.ts +0 -10
  208. package/dist/render/bidi.d.ts +0 -15
  209. package/dist/render/clearTerminal.d.ts +0 -19
  210. package/dist/render/colorize.d.ts +0 -16
  211. package/dist/render/components/AlternateScreen.d.ts +0 -21
  212. package/dist/render/components/App.d.ts +0 -71
  213. package/dist/render/components/AppContext.d.ts +0 -11
  214. package/dist/render/components/Box.d.ts +0 -49
  215. package/dist/render/components/Button.d.ts +0 -36
  216. package/dist/render/components/ClockContext.d.ts +0 -9
  217. package/dist/render/components/CursorDeclarationContext.d.ts +0 -22
  218. package/dist/render/components/ErrorOverview.d.ts +0 -5
  219. package/dist/render/components/Link.d.ts +0 -7
  220. package/dist/render/components/Newline.d.ts +0 -12
  221. package/dist/render/components/NoSelect.d.ts +0 -19
  222. package/dist/render/components/RawAnsi.d.ts +0 -16
  223. package/dist/render/components/ScrollBox.d.ts +0 -78
  224. package/dist/render/components/Spacer.d.ts +0 -5
  225. package/dist/render/components/Static.d.ts +0 -23
  226. package/dist/render/components/StdinContext.d.ts +0 -27
  227. package/dist/render/components/TerminalFocusContext.d.ts +0 -10
  228. package/dist/render/components/TerminalSizeContext.d.ts +0 -5
  229. package/dist/render/components/Text.d.ts +0 -55
  230. package/dist/render/constants.d.ts +0 -1
  231. package/dist/render/cursor.d.ts +0 -8
  232. package/dist/render/devtools.d.ts +0 -9
  233. package/dist/render/dom.d.ts +0 -77
  234. package/dist/render/events/click-event.d.ts +0 -31
  235. package/dist/render/events/dispatcher.d.ts +0 -40
  236. package/dist/render/events/emitter.d.ts +0 -5
  237. package/dist/render/events/event-handlers.d.ts +0 -46
  238. package/dist/render/events/event.d.ts +0 -5
  239. package/dist/render/events/focus-event.d.ts +0 -13
  240. package/dist/render/events/input-event.d.ts +0 -30
  241. package/dist/render/events/keyboard-event.d.ts +0 -19
  242. package/dist/render/events/paste-event.d.ts +0 -8
  243. package/dist/render/events/resize-event.d.ts +0 -9
  244. package/dist/render/events/terminal-event.d.ts +0 -54
  245. package/dist/render/events/terminal-focus-event.d.ts +0 -13
  246. package/dist/render/focus.d.ts +0 -43
  247. package/dist/render/frame.d.ts +0 -95
  248. package/dist/render/get-max-width.d.ts +0 -17
  249. package/dist/render/hit-test.d.ts +0 -33
  250. package/dist/render/hooks/use-animation-frame.d.ts +0 -26
  251. package/dist/render/hooks/use-app.d.ts +0 -5
  252. package/dist/render/hooks/use-declared-cursor.d.ts +0 -26
  253. package/dist/render/hooks/use-input.d.ts +0 -37
  254. package/dist/render/hooks/use-interval.d.ts +0 -18
  255. package/dist/render/hooks/use-search-highlight.d.ts +0 -30
  256. package/dist/render/hooks/use-selection.d.ts +0 -39
  257. package/dist/render/hooks/use-stdin.d.ts +0 -5
  258. package/dist/render/hooks/use-tab-status.d.ts +0 -13
  259. package/dist/render/hooks/use-terminal-focus.d.ts +0 -10
  260. package/dist/render/hooks/use-terminal-title.d.ts +0 -12
  261. package/dist/render/hooks/use-terminal-viewport.d.ts +0 -29
  262. package/dist/render/index.d.ts +0 -30
  263. package/dist/render/ink.d.ts +0 -391
  264. package/dist/render/instances.d.ts +0 -3
  265. package/dist/render/layout/engine.d.ts +0 -2
  266. package/dist/render/layout/geometry.d.ts +0 -30
  267. package/dist/render/layout/node.d.ts +0 -125
  268. package/dist/render/layout/yoga.d.ts +0 -56
  269. package/dist/render/line-width-cache.d.ts +0 -1
  270. package/dist/render/log-update.d.ts +0 -28
  271. package/dist/render/measure-element.d.ts +0 -16
  272. package/dist/render/measure-text.d.ts +0 -6
  273. package/dist/render/node-cache.d.ts +0 -20
  274. package/dist/render/optimizer.d.ts +0 -15
  275. package/dist/render/output.d.ts +0 -119
  276. package/dist/render/parse-keypress.d.ts +0 -111
  277. package/dist/render/reconciler.d.ts +0 -11
  278. package/dist/render/render-border.d.ts +0 -24
  279. package/dist/render/render-node-to-output.d.ts +0 -45
  280. package/dist/render/render-to-screen.d.ts +0 -46
  281. package/dist/render/renderer.d.ts +0 -14
  282. package/dist/render/root.d.ts +0 -74
  283. package/dist/render/screen.d.ts +0 -269
  284. package/dist/render/searchHighlight.d.ts +0 -20
  285. package/dist/render/selection.d.ts +0 -229
  286. package/dist/render/squash-text-nodes.d.ts +0 -22
  287. package/dist/render/stringWidth.d.ts +0 -1
  288. package/dist/render/styles.d.ts +0 -306
  289. package/dist/render/supports-hyperlinks.d.ts +0 -13
  290. package/dist/render/tabstops.d.ts +0 -1
  291. package/dist/render/terminal-focus-state.d.ts +0 -6
  292. package/dist/render/terminal-querier.d.ts +0 -129
  293. package/dist/render/terminal.d.ts +0 -46
  294. package/dist/render/termio/ansi.d.ts +0 -65
  295. package/dist/render/termio/csi.d.ts +0 -165
  296. package/dist/render/termio/dec.d.ts +0 -37
  297. package/dist/render/termio/esc.d.ts +0 -12
  298. package/dist/render/termio/osc.d.ts +0 -173
  299. package/dist/render/termio/parser.d.ts +0 -35
  300. package/dist/render/termio/sgr.d.ts +0 -8
  301. package/dist/render/termio/tokenize.d.ts +0 -45
  302. package/dist/render/termio/types.d.ts +0 -190
  303. package/dist/render/termio.d.ts +0 -24
  304. package/dist/render/useTerminalNotification.d.ts +0 -28
  305. package/dist/render/warn.d.ts +0 -1
  306. package/dist/render/widest-line.d.ts +0 -1
  307. package/dist/render/wrap-text.d.ts +0 -2
  308. package/dist/render/wrapAnsi.d.ts +0 -7
  309. package/dist/run/ArtifactTracker.d.ts +0 -38
  310. package/dist/run/CheckpointWriter.d.ts +0 -53
  311. package/dist/run/EngineRunner.d.ts +0 -72
  312. package/dist/run/Evaluator.d.ts +0 -56
  313. package/dist/run/FileRunStore.d.ts +0 -39
  314. package/dist/run/Heartbeat.d.ts +0 -54
  315. package/dist/run/RunApprovalBackend.d.ts +0 -53
  316. package/dist/run/RunLock.d.ts +0 -40
  317. package/dist/run/RunManager.d.ts +0 -82
  318. package/dist/run/RunQueue.d.ts +0 -27
  319. package/dist/run/RunStore.d.ts +0 -25
  320. package/dist/run/factory.d.ts +0 -63
  321. package/dist/run/index.d.ts +0 -17
  322. package/dist/run/index.js +0 -1
  323. package/dist/run/types.d.ts +0 -136
  324. package/dist/seatbelt-L54CNI2Y.js +0 -37
  325. package/dist/services/analytics.d.ts +0 -29
  326. package/dist/services/auto-dream.d.ts +0 -35
  327. package/dist/services/diagnostics.d.ts +0 -41
  328. package/dist/services/extract-memories.d.ts +0 -27
  329. package/dist/services/index.d.ts +0 -11
  330. package/dist/services/memory-orchestrator.d.ts +0 -39
  331. package/dist/services/notifier.d.ts +0 -25
  332. package/dist/services/oauth.d.ts +0 -27
  333. package/dist/services/session-memory.d.ts +0 -37
  334. package/dist/session/file-history.d.ts +0 -41
  335. package/dist/session/memory.d.ts +0 -65
  336. package/dist/session/session-manager.d.ts +0 -28
  337. package/dist/session/transcript.d.ts +0 -39
  338. package/dist/session-manager-AGWS5SMJ.js +0 -1
  339. package/dist/settings/manager.d.ts +0 -36
  340. package/dist/settings/schema.d.ts +0 -1123
  341. package/dist/skills/frontmatter.d.ts +0 -13
  342. package/dist/skills/index.d.ts +0 -7
  343. package/dist/skills/scanner.d.ts +0 -20
  344. package/dist/tool-summary-HJX6RHG4.js +0 -2
  345. package/dist/tool-system/builtin/agent-notifications.d.ts +0 -55
  346. package/dist/tool-system/builtin/agent-registry.d.ts +0 -67
  347. package/dist/tool-system/builtin/agent-transcript-translator.d.ts +0 -22
  348. package/dist/tool-system/builtin/agent.d.ts +0 -16
  349. package/dist/tool-system/builtin/apply-patch/applier.d.ts +0 -26
  350. package/dist/tool-system/builtin/apply-patch/index.d.ts +0 -19
  351. package/dist/tool-system/builtin/apply-patch/parser.d.ts +0 -17
  352. package/dist/tool-system/builtin/apply-patch/seek-sequence.d.ts +0 -18
  353. package/dist/tool-system/builtin/apply-patch/types.d.ts +0 -49
  354. package/dist/tool-system/builtin/arena.d.ts +0 -31
  355. package/dist/tool-system/builtin/ask-user.d.ts +0 -20
  356. package/dist/tool-system/builtin/bash.d.ts +0 -12
  357. package/dist/tool-system/builtin/brief.d.ts +0 -6
  358. package/dist/tool-system/builtin/config.d.ts +0 -6
  359. package/dist/tool-system/builtin/cron.d.ts +0 -10
  360. package/dist/tool-system/builtin/edit.d.ts +0 -6
  361. package/dist/tool-system/builtin/file-cache.d.ts +0 -11
  362. package/dist/tool-system/builtin/glob.d.ts +0 -6
  363. package/dist/tool-system/builtin/grep.d.ts +0 -6
  364. package/dist/tool-system/builtin/index.d.ts +0 -20
  365. package/dist/tool-system/builtin/lsp.d.ts +0 -6
  366. package/dist/tool-system/builtin/mcp-tools.d.ts +0 -10
  367. package/dist/tool-system/builtin/notebook-edit.d.ts +0 -6
  368. package/dist/tool-system/builtin/plan.d.ts +0 -18
  369. package/dist/tool-system/builtin/powershell.d.ts +0 -6
  370. package/dist/tool-system/builtin/read.d.ts +0 -6
  371. package/dist/tool-system/builtin/remote-trigger.d.ts +0 -6
  372. package/dist/tool-system/builtin/repl.d.ts +0 -6
  373. package/dist/tool-system/builtin/send-message.d.ts +0 -6
  374. package/dist/tool-system/builtin/skill-prompt.d.ts +0 -7
  375. package/dist/tool-system/builtin/skill.d.ts +0 -8
  376. package/dist/tool-system/builtin/sleep.d.ts +0 -6
  377. package/dist/tool-system/builtin/task.d.ts +0 -51
  378. package/dist/tool-system/builtin/tool-search.d.ts +0 -11
  379. package/dist/tool-system/builtin/web-fetch.d.ts +0 -6
  380. package/dist/tool-system/builtin/web-search.d.ts +0 -6
  381. package/dist/tool-system/builtin/worktree.d.ts +0 -10
  382. package/dist/tool-system/builtin/write.d.ts +0 -6
  383. package/dist/tool-system/context.d.ts +0 -133
  384. package/dist/tool-system/executor.d.ts +0 -49
  385. package/dist/tool-system/investigation-guard.d.ts +0 -46
  386. package/dist/tool-system/mcp-manager.d.ts +0 -50
  387. package/dist/tool-system/permission.d.ts +0 -104
  388. package/dist/tool-system/registry.d.ts +0 -32
  389. package/dist/tool-system/sandbox/bwrap.d.ts +0 -13
  390. package/dist/tool-system/sandbox/index.d.ts +0 -78
  391. package/dist/tool-system/sandbox/off.d.ts +0 -2
  392. package/dist/tool-system/sandbox/seatbelt.d.ts +0 -18
  393. package/dist/tool-system/task-guard.d.ts +0 -30
  394. package/dist/tool-system/validation.d.ts +0 -5
  395. package/dist/types.d.ts +0 -356
  396. package/dist/ui/App.d.ts +0 -14
  397. package/dist/ui/components/AgentBlock.d.ts +0 -35
  398. package/dist/ui/components/AgentDock.d.ts +0 -36
  399. package/dist/ui/components/AskUserPrompt.d.ts +0 -14
  400. package/dist/ui/components/BabyHand.d.ts +0 -1
  401. package/dist/ui/components/Banner.d.ts +0 -8
  402. package/dist/ui/components/CodeBlock.d.ts +0 -7
  403. package/dist/ui/components/CommandInput.d.ts +0 -24
  404. package/dist/ui/components/ContextUsageBar.d.ts +0 -7
  405. package/dist/ui/components/DiffLine.d.ts +0 -33
  406. package/dist/ui/components/DiffView.d.ts +0 -6
  407. package/dist/ui/components/DogLogo.d.ts +0 -1
  408. package/dist/ui/components/FullscreenLayout.d.ts +0 -51
  409. package/dist/ui/components/KunHead.d.ts +0 -1
  410. package/dist/ui/components/KunLogo.d.ts +0 -1
  411. package/dist/ui/components/MessageContent.d.ts +0 -26
  412. package/dist/ui/components/MessageRow.d.ts +0 -54
  413. package/dist/ui/components/ModelManager.d.ts +0 -68
  414. package/dist/ui/components/ModelSelector.d.ts +0 -10
  415. package/dist/ui/components/OnboardingPrompt.d.ts +0 -16
  416. package/dist/ui/components/PermissionDialog.d.ts +0 -8
  417. package/dist/ui/components/PermissionPrompt.d.ts +0 -11
  418. package/dist/ui/components/ProviderModelFlow.d.ts +0 -58
  419. package/dist/ui/components/ScrollView.d.ts +0 -34
  420. package/dist/ui/components/SessionPicker.d.ts +0 -16
  421. package/dist/ui/components/Spinner.d.ts +0 -8
  422. package/dist/ui/components/SpinnerWithVerb.d.ts +0 -19
  423. package/dist/ui/components/StatusLine.d.ts +0 -28
  424. package/dist/ui/components/StructuredDiff.d.ts +0 -8
  425. package/dist/ui/components/TaskList.d.ts +0 -6
  426. package/dist/ui/components/TextInput.d.ts +0 -17
  427. package/dist/ui/components/ThemedBox.d.ts +0 -19
  428. package/dist/ui/components/ThemedText.d.ts +0 -26
  429. package/dist/ui/components/ToolCall.d.ts +0 -28
  430. package/dist/ui/components/UpdateBanner.d.ts +0 -1
  431. package/dist/ui/components/VirtualMessageList.d.ts +0 -43
  432. package/dist/ui/components/WelcomeTips.d.ts +0 -5
  433. package/dist/ui/dev-seed.d.ts +0 -1
  434. package/dist/ui/fullscreen-mode.d.ts +0 -9
  435. package/dist/ui/hooks/useCostSummary.d.ts +0 -1
  436. package/dist/ui/hooks/useVirtualScroll.d.ts +0 -101
  437. package/dist/ui/index.d.ts +0 -12
  438. package/dist/ui/input-history.d.ts +0 -61
  439. package/dist/ui/onboarding-runner.d.ts +0 -2
  440. package/dist/ui/perf-probes.d.ts +0 -22
  441. package/dist/ui/query-guard.d.ts +0 -35
  442. package/dist/ui/slice-anchor.d.ts +0 -44
  443. package/dist/ui/store.d.ts +0 -108
  444. package/dist/ui/terminal-renderer.d.ts +0 -45
  445. package/dist/ui/theme.d.ts +0 -36
  446. package/dist/ui/vim-mode.d.ts +0 -25
  447. package/dist/updater-OCNU2K2Z.js +0 -1
  448. package/dist/utils/debug.d.ts +0 -41
  449. package/dist/utils/earlyInput.d.ts +0 -43
  450. package/dist/utils/env.d.ts +0 -24
  451. package/dist/utils/envUtils.d.ts +0 -51
  452. package/dist/utils/execFileNoThrow.d.ts +0 -39
  453. package/dist/utils/format.d.ts +0 -44
  454. package/dist/utils/fullscreen.d.ts +0 -47
  455. package/dist/utils/intl.d.ts +0 -22
  456. package/dist/utils/lockfile.d.ts +0 -15
  457. package/dist/utils/semver.d.ts +0 -6
  458. package/dist/utils/sliceAnsi.d.ts +0 -12
  459. package/dist/utils/systemTheme.d.ts +0 -40
  460. package/dist/utils/task-sanitizer.d.ts +0 -6
  461. package/dist/utils/theme.d.ts +0 -91
  462. package/dist/utils/toolDisplay.d.ts +0 -31
  463. package/dist/utils/truncate.d.ts +0 -40
  464. package/dist/voice/index.d.ts +0 -35
package/dist/cli/main.js DELETED
@@ -1,415 +0,0 @@
1
- #!/usr/bin/env node
2
- import {a as a$5}from'../chunk-AFMP73YP.js';import {a as a$2,b as b$2}from'../chunk-2OD6VR4N.js';import {b as b$6}from'../chunk-GYNO4R7R.js';import {e,b as b$1,a as a$1,d as d$2}from'../chunk-TKJA6W36.js';import {O,R,ea as ea$1,Q,h as h$2,a as a$3,e as e$1,b as b$4,c as c$3,d as d$5,l,da as da$1,ba as ba$1,ca as ca$1,T,ga as ga$1,P}from'../chunk-Z5HKHAO7.js';import {h as h$1,d as d$4,a as a$4,b as b$3,c as c$2}from'../chunk-SKIX2M5Z.js';import'../chunk-MLCTC53I.js';import'../chunk-WI6FSWGU.js';import {d as d$3}from'../chunk-P6JSTIFM.js';import'../chunk-SNFAPSLA.js';import'../chunk-D3TVASD2.js';import {c as c$1}from'../chunk-FZXY554D.js';import'../chunk-M7VU4YVY.js';import'../chunk-T222K6IV.js';import'../chunk-QTWU7UNA.js';import'../chunk-K4HILJ6G.js';import {O as O$1,K,L,Q as Q$1,R as R$1,M}from'../chunk-WONQHE4P.js';import {d as d$1,b as b$5}from'../chunk-GKAQH2DG.js';import'../chunk-FU7AHZNN.js';import {d,e as e$2}from'../chunk-DI26OUIU.js';import {h,a,b}from'../chunk-3QP5BQ3L.js';import {Command}from'commander';import te,{Chalk}from'chalk';import {join,sep}from'path';import {Stream}from'stream';import D0 from'auto-bind';import {appendFileSync,writeSync,openSync,constants,readSync,closeSync,existsSync,readFileSync,writeFileSync,mkdirSync,statSync,readdirSync}from'fs';import Uo from'lodash-es/noop.js';import F0 from'lodash-es/throttle.js';import {DefaultEventPriority,NoEventPriority,ContinuousEventPriority,ConcurrentRoot,DiscreteEventPriority,LegacyRoot}from'react-reconciler/constants.js';import {onExit}from'signal-exit';import {format}from'util';import Lg,{createContext,PureComponent,useContext,useLayoutEffect,useEffect,memo,forwardRef,useRef,useImperativeHandle,useMemo,useSyncExternalStore,useState,useInsertionEffect,useCallback,useDeferredValue,createElement}from'react';import {execSync,execFile}from'child_process';import {EventEmitter}from'events';import {Buffer as Buffer$1}from'buffer';import Lb from'react-reconciler';import tb from'emoji-regex';import {eastAsianWidth}from'get-east-asian-width';import nb from'strip-ansi';import db from'wrap-ansi';import {ansiCodesToString,diffAnsiCodes,styledCharsFromTokens,tokenize}from'@alcalzone/ansi-tokenize';import'semver';import {homedir}from'os';import {c}from'react/compiler-runtime';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import Wx from'code-excerpt';import Nm from'stack-utils';import t0 from'bidi-js';import y0 from'indent-string';import p0 from'cli-boxes';import {useEventCallback}from'usehooks-ts';import fS from'supports-hyperlinks';import {Marked,lexer}from'marked';import {markedTerminal}from'marked-terminal';import $T from'lodash-es/memoize.js';h();h();h();function _e(t,e){return {input:t,output:e,cacheRead:t*.1,cacheWrite:t*1.25}}a(_e,"pricing");var fd={"claude-opus-4.6":{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},"claude-opus-4-6":{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},"claude-opus-4.5":{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},"claude-opus-4.1":{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},"claude-opus-4":{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},"claude-sonnet-4.6":{input:3,output:15,cacheRead:.3,cacheWrite:3.75},"claude-sonnet-4-6":{input:3,output:15,cacheRead:.3,cacheWrite:3.75},"claude-sonnet-4.5":{input:3,output:15,cacheRead:.3,cacheWrite:3.75},"claude-sonnet-4":{input:3,output:15,cacheRead:.3,cacheWrite:3.75},"claude-3.7-sonnet":{input:3,output:15,cacheRead:.3,cacheWrite:3.75},"claude-3-7-sonnet":{input:3,output:15,cacheRead:.3,cacheWrite:3.75},"claude-3.5-haiku":{input:.8,output:4,cacheRead:.08,cacheWrite:1},"claude-haiku-4.5":{input:1,output:5,cacheRead:.1,cacheWrite:1.25},"claude-haiku-4-5":{input:1,output:5,cacheRead:.1,cacheWrite:1.25},"gpt-5.4":_e(5,20),"gpt-5.4-mini":_e(1.5,6),"gpt-5.4-pro":_e(10,40),"gpt-5":_e(5,20),"gpt-4o":_e(2.5,10),"gpt-4o-mini":_e(.15,.6),"gpt-4.1":_e(2,8),"gpt-4.1-mini":_e(.4,1.6),"o4-mini":_e(1.1,4.4),o3:_e(10,40),"o3-mini":_e(1.1,4.4),"gemini-2.5-pro":_e(1.25,10),"gemini-2.5-pro-preview":_e(1.25,10),"gemini-2.5-flash":_e(.15,.6),"gemini-3.1-pro-preview":_e(2,10),"gemini-3-flash-preview":_e(.15,.6),"gemini-2.0-flash":_e(.1,.4),"deepseek-v4-flash":_e(.126,.252),"deepseek-v4-pro":_e(.5,2),"deepseek-v3.2":_e(.14,.28),"deepseek-chat":_e(.14,.28),"deepseek-r1":_e(.55,2.19),"deepseek-reasoner":_e(.55,2.19),"qwen3-coder":_e(.3,.6),"qwen3-235b-a22b":_e(.3,1.2),"qwen3-30b-a3b":_e(.1,.3),"qwen3-max":_e(.5,2),"llama-4-maverick":_e(.2,.8),"llama-4-scout":_e(.15,.4),"devstral-medium":_e(.5,1.5),"mistral-large":_e(2,6),"devstral-small":_e(.1,.3)},ly=_e(3,15);function md(t){let e=t.inputPricePerMillion,n=t.outputPricePerMillion;return {pricing:{input:e,output:n,cacheRead:e*.1,cacheWrite:e*1.25},known:true}}a(md,"openRouterPricing");function hi(t){if(t.includes("/")){let o=d$1(t);if(o&&(o.inputPricePerMillion>0||o.outputPricePerMillion>0))return md(o)}let e=d$1(`deepseek/${t}`)??d$1(`openai/${t}`)??d$1(`anthropic/${t}`);if(e&&(e.inputPricePerMillion>0||e.outputPricePerMillion>0))return md(e);let n=pd(t),r=fd[n]??fd[t];return r?{pricing:r,known:true}:{pricing:ly,known:false}}a(hi,"lookupPricing");function pd(t){let e=t.lastIndexOf("/");return (e>=0?t.slice(e+1):t).replace(/-\d{8}$/,"")}a(pd,"getCanonicalName");var ol=class{static{a(this,"CostTracker");}records=[];sessionStart=Date.now();_hasUnknownModel=false;record(e,n,r,o=false,i=0,s=0){let l=pd(e);!hi(e).known&&!hi(l).known&&(this._hasUnknownModel=true),this.records.push({model:l,promptTokens:n,completionTokens:r,cacheReadTokens:i,cacheWriteTokens:s,totalTokens:n+r,timestamp:Date.now(),isSubAgent:o});}getTotalTokens(){let e=0,n=0;for(let r of this.records)e+=r.promptTokens,n+=r.completionTokens;return {prompt:e,completion:n,total:e+n}}getEstimatedCost(){let e=0;for(let n of this.records){let{pricing:r}=hi(n.model),o=Math.max(0,n.promptTokens-n.cacheReadTokens-n.cacheWriteTokens);e+=o/1e6*r.input,e+=n.completionTokens/1e6*r.output,e+=n.cacheReadTokens/1e6*r.cacheRead,e+=n.cacheWriteTokens/1e6*r.cacheWrite;}return e}getRequestCount(){return this.records.length}getSessionDuration(){return Date.now()-this.sessionStart}estimateForTokens(e,n,r,o=0,i=0){let{pricing:s}=hi(e);return Math.max(0,n-o-i)/1e6*s.input+r/1e6*s.output+o/1e6*s.cacheRead+i/1e6*s.cacheWrite}getCacheTokens(){let e=0,n=0;for(let r of this.records)e+=r.cacheReadTokens,n+=r.cacheWriteTokens;return {cacheRead:e,cacheWrite:n}}formatSummary(){let e=this.getTotalTokens(),n=this.getCacheTokens(),r=this.getEstimatedCost(),o=this.getRequestCount(),i=this.getSessionDuration(),s=[];s.push(` ${te.bold.cyan("Cost Summary")}`),s.push(te.dim(" \u2500".repeat(25))),s.push(` ${te.dim("Requests:")} ${te.white(String(o))}`),s.push(` ${te.dim("Input tokens:")} ${te.white(_r(e.prompt))}`),s.push(` ${te.dim("Output tokens:")} ${te.white(_r(e.completion))}`),(n.cacheRead>0||n.cacheWrite>0)&&(s.push(` ${te.dim("Cache read:")} ${te.white(_r(n.cacheRead))}`),s.push(` ${te.dim("Cache write:")} ${te.white(_r(n.cacheWrite))}`)),s.push(` ${te.dim("Total cost:")} ${te.green(rl(r))}`),s.push(` ${te.dim("Duration:")} ${te.white(cy(i))}`);let l=new Map;for(let c of this.records){let d=l.get(c.model)??{prompt:0,completion:0,cacheRead:0,cacheWrite:0,count:0};d.prompt+=c.promptTokens,d.completion+=c.completionTokens,d.cacheRead+=c.cacheReadTokens,d.cacheWrite+=c.cacheWriteTokens,d.count++,l.set(c.model,d);}if(l.size>=1){s.push(""),s.push(` ${te.dim("By model:")}`);for(let[c,d]of l){let{pricing:f}=hi(c),g=Math.max(0,d.prompt-d.cacheRead-d.cacheWrite)/1e6*f.input+d.completion/1e6*f.output+d.cacheRead/1e6*f.cacheRead+d.cacheWrite/1e6*f.cacheWrite,y=`${_r(d.prompt)} in, ${_r(d.completion)} out`+(d.cacheRead>0?`, ${_r(d.cacheRead)} cache`:"");s.push(` ${te.dim(c)} \u2014 ${y}, ${rl(g)} (${d.count} reqs)`);}}return this._hasUnknownModel&&(s.push(""),s.push(te.dim(" (costs may be inaccurate due to usage of unknown models)"))),s.join(`
3
- `)}formatCompact(){let e=this.getTotalTokens(),n=this.getEstimatedCost();return te.dim(`tokens: ${_r(e.total)} | cost: ${rl(n)}`)}reset(){this.records=[],this.sessionStart=Date.now();}serialize(){let e=this.getTotalTokens();return {records:this.records,sessionStart:this.sessionStart,totalPromptTokens:e.prompt,totalCompletionTokens:e.completion,estimatedCost:this.getEstimatedCost()}}restore(e){this.records=e.records??[],this.sessionStart=e.sessionStart??Date.now();}};function rl(t){return t>=.5?`$${Math.round(t*100)/100}`:t>=.01?`$${t.toFixed(4)}`:t>0?`$${t.toFixed(6)}`:"$0.00"}a(rl,"formatCost");function _r(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":String(t)}a(_r,"formatNumber");function cy(t){let e=Math.floor(t/1e3);if(e<60)return `${e}s`;let n=Math.floor(e/60),r=e%60;if(n<60)return `${n}m ${r}s`;let o=Math.floor(n/60),i=n%60;return `${o}h ${i}m`}a(cy,"formatDuration");var yt=new ol;async function gd(){let{LLMClientBase:t}=await import('../client-base-GSFXPP2Y.js');t.onUsage=(e,n)=>{yt.record(e,n.promptTokens,n.completionTokens,false,n.cacheReadTokens??0,n.cacheCreationTokens??0);};}a(gd,"installCostTracking");h();h();var Ss=88,uy=new Set(["file_path","path","directory","cwd"]);function dy(t){if(!t||!t.startsWith("/"))return t;let e=process.cwd(),n=e.endsWith(sep)?e:e+sep;return t===e?".":t.startsWith(n)?t.slice(n.length):t}a(dy,"relativizePath");var yd={Read:"ansi:blue",Write:"ansi:green",Edit:"ansi:yellow",Bash:"ansi:magenta",Glob:"ansi:blue",Grep:"ansi:blue",Agent:"ansi:cyan",WebSearch:"ansi:blue",WebFetch:"ansi:blue",LSP:"ansi:cyan",TaskCreate:"ansi:cyan",TaskUpdate:"ansi:cyan"},fy={Read:["file_path"],Write:["file_path"],Edit:["file_path"],Glob:["pattern"],Grep:["pattern","path"],Bash:["command"],WebSearch:["query"],WebFetch:["url"],Agent:["description"],TaskCreate:["subject"],TaskUpdate:["taskId","status"],Sleep:["seconds"],EnterWorktree:["slug"],SendMessage:["to"],CronCreate:["name","schedule"],LSP:["action","file_path"],NotebookEdit:["action","file_path"],Config:["action","key"]};function my(t){let e=t.match(/^\s*cd\s+(?:"[^"]*"|'[^']*'|\S+)\s*(?:&&|;)\s*(.+)$/s);return e?e[1].trim():t}a(my,"stripCdPrefix");function ws(t,e){let n=fy[t]??Object.keys(e).slice(0,2),r=[];for(let o of n){let i=e[o];if(i!==void 0&&!o.startsWith("__")){let s=String(i);t==="Bash"&&o==="command"?s=my(s):uy.has(o)&&(s=dy(s));let l=t==="Bash"&&o==="command"?Ss:60;r.push(Jt(s,l));}}if(t==="Read"){let o=typeof e.offset=="number"?e.offset:void 0,i=typeof e.limit=="number"?e.limit:void 0;if(o!==void 0||i!==void 0){let s=o??1,l=i!==void 0?s+i-1:void 0;r.push(l!==void 0?`:${s}-${l}`:`:${s}-`);}}return r.length>0?r.join(" "):Jt(JSON.stringify(e),80)}a(ws,"formatToolArgs");function Jt(t,e){return t.length>e?t.slice(0,e-1)+"\u2026":t}a(Jt,"truncate");function Cn(t){return t.replace(/\n/g," ").replace(/\s+/g," ").trim()}a(Cn,"singleLine");function vs(t){return t>=1024*1024?(t/(1024*1024)).toFixed(1)+"MB":t>=1024?(t/1024).toFixed(1)+"KB":t+"B"}a(vs,"formatBytes");var il=class{static{a(this,"TextRenderer");}activeAgents=new Set;onEvent(e){let n=e.agentId,r=n?" ":"",o=n?te.dim("\u2502 "):"";switch(e.type){case "text_delta":n||process.stdout.write(e.text);break;case "agent_start":{let i=e;this.activeAgents.add(i.agentId),process.stderr.write(`
4
- ${r}${te.magenta("\u25B8")} ${te.bold("Agent")} ${te.dim(i.description)}
5
- `);break}case "agent_end":{let i=e;this.activeAgents.delete(i.agentId),i.error?process.stderr.write(`${r}${te.red("\u2717")} ${te.dim(`Agent ${i.description}: ${i.error}`)}
6
- `):process.stderr.write(`${r}${te.green("\u2713")} ${te.dim(`Agent ${i.description}`)}
7
- `);break}case "tool_use_start":{let i=e.toolCall,s=ws(i.toolName,i.args);process.stderr.write(`${r}${o}${te.cyan("\u25CF")} ${te.bold(i.toolName)} ${te.dim(s)}
8
- `);break}case "tool_result":{let i=e.result;if(i.error)process.stderr.write(`${r}${o}${te.red("\u2717")} ${te.bold(i.toolName)} ${te.red(Jt(Cn(i.error),80))}
9
- `);else {let s=i.result??"",l=py(i.toolName,s);process.stderr.write(`${r}${o}${te.green("\u2713")} ${te.bold(i.toolName)} ${te.dim(l)}
10
- `);}break}case "error":process.stderr.write(`${r}${o}${te.red("\u2717")} ${e.error}
11
- `);break}}onComplete(e,n){n!=="completed"?process.stdout.write(`
12
- ${te.yellow(`[${n}]`)}
13
- `):process.stdout.write(`
14
- `);}},sl=class{static{a(this,"JsonRenderer");}text="";onEvent(e){e.type==="text_delta"&&(this.text+=e.text);}onComplete(e,n,r){process.stdout.write(JSON.stringify({result:e||this.text,reason:n,...r},null,2)+`
15
- `);}},al=class{static{a(this,"JsonlRenderer");}onEvent(e){process.stdout.write(JSON.stringify(e)+`
16
- `);}onComplete(e,n,r){process.stdout.write(JSON.stringify({type:"result",text:e,reason:n,...r})+`
17
- `);}},ll=class{static{a(this,"StreamJsonRenderer");}onEvent(e){process.stdout.write(JSON.stringify(e)+`
18
- `);}onComplete(e,n,r){process.stdout.write(JSON.stringify({type:"result",text:e,reason:n,...r})+`
19
- `);}};function bd(t){switch(t){case "json":return new sl;case "jsonl":return new al;case "stream-json":return new ll;default:return new il}}a(bd,"createRenderer");function py(t,e){let n=e.split(`
20
- `),r=n.length;switch(t){case "Read":return `${r} lines, ${vs(e.length)}`;case "Glob":return `${n.filter(o=>o.trim()).length} files`;case "Grep":return `${n.filter(o=>o.trim()).length} matches`;case "Write":case "Edit":return Jt(Cn(e),60);case "Bash":return r<=1?Jt(Cn(e),80):`${Jt(n[0],60)} (+${r-1} lines)`;default:return r<=1?Jt(e,80):`${Jt(n[0],60)} (+${r-1} lines)`}}a(py,"compactSummary");function gy(t){let e=t;if(!e.models?.length)return;if(e.activeKey){let r=e.models.find(o=>o.key===e.activeKey);if(r)return r}let n=e.model?.name;if(n)return e.models.find(r=>r.model===n||r.model?.endsWith(`/${n}`))}a(gy,"findActiveModelEntry");function hy(t,e){return e?t.providers?.find(r=>r.key===e)?.apiKey:void 0}a(hy,"findProviderApiKey");async function cl(t){let e=process.cwd(),r=new c$1(e).get(),o=gy(r),i=r.model?.apiKey??o?.apiKey??hy(r,o?.providerKey),s=O$1(t.apiKey,i);s||(console.error("Error: No API key provided. Use --api-key, set OPENROUTER_API_KEY env var, or add to settings."),process.exit(1));let l={provider:t.provider??o?.provider??r.model?.provider??"openai",model:t.model??o?.model??r.model?.name??"anthropic/claude-opus-4-6",apiKey:s,baseUrl:t.baseUrl??o?.baseUrl??r.model?.baseUrl??"https://openrouter.ai/api/v1",temperature:r.model?.temperature,maxTokens:o?.maxOutputTokens??r.model?.maxTokens??8192,enableStreaming:true},c=yy(r.sandbox,"auto"),d=new R({llm:l,cwd:e,preset:t.preset??r.agent.preset,enabledBuiltinTools:r.agent.enabledBuiltinTools,disabledBuiltinTools:r.agent.disabledBuiltinTools,permissionMode:t.permissionMode??"acceptEdits",customSystemPrompt:r.agent.customSystemPrompt,appendSystemPrompt:r.agent.appendSystemPrompt,maxTurns:t.maxTurns??30,maxContextTokens:r.context.maxTokens,sessionStorageDir:r.session.storageDir,costStore:yt,mcpServers:r.mcpServers,headless:true,sandbox:c}),f=t.output??r.output.format??"text",m=bd(f),{client:g,close:y}=ea$1(d,{onStream:a(w=>m.onEvent(w),"onStream")});try{let w=await g.run(t.task,t.resume);m.onComplete(w.text,w.reason,{sessionId:w.sessionId,turnCount:w.turnCount}),process.exit(w.reason==="completed"?0:1);}finally{y();}}a(cl,"runCommand");function yy(t,e){let n=Q(e);return t?{mode:t.mode??n.mode,writableRoots:t.writableRoots??n.writableRoots,deniedReads:t.deniedReads??n.deniedReads,network:t.network??n.network}:n}a(yy,"mergeSandboxConfig");h();h();h();h();function $e(t,e){let n=e?.level??"debug",r=n==="error"||n==="warn"||n==="info"?n:"debug",o=t.match(/^\s*\[([^\]]+)\]\s*(.*)$/),i=o?o[1].toLowerCase():void 0,s=o?o[2]:t,l={};switch(i&&(l.cat=i),r){case "error":d.error(s,l);break;case "warn":d.warn(s,l);break;case "info":d.info(s,l);break;default:d.debug(s,l);break}}a($e,"logForDebugging");h();h();h();var ue={Auto:0,FlexStart:1,Center:2,FlexEnd:3,Stretch:4,Baseline:5,SpaceBetween:6,SpaceAround:7,SpaceEvenly:8};var Ts={Inherit:0,LTR:1},sr={Flex:0,None:1,Contents:2},Ue={Left:0,Top:1,Right:2,Bottom:3,Start:4,End:5,Horizontal:6,Vertical:7,All:8},xd={None:0};var ut={Column:0,ColumnReverse:1,Row:2,RowReverse:3},Yn={Column:0,Row:1,All:2},At={FlexStart:0,Center:1,FlexEnd:2,SpaceBetween:3,SpaceAround:4,SpaceEvenly:5},de={Undefined:0,Exactly:1,AtMost:2},jr={Visible:0,Hidden:1,Scroll:2},Kr={Relative:1,Absolute:2},Et={Undefined:0,Point:1,Percent:2,Auto:3},ar={NoWrap:0,Wrap:1,WrapReverse:2};var sn={unit:Et.Undefined,value:NaN},lr={unit:Et.Auto,value:NaN};function _s(t){return {unit:Et.Point,value:t}}a(_s,"pointValue");function hn(t){return {unit:Et.Percent,value:t}}a(hn,"percentValue");function st(t,e){switch(t.unit){case Et.Point:return t.value;case Et.Percent:return isNaN(e)?NaN:t.value*e/100;default:return NaN}}a(st,"resolveValue");function oe(t){return !isNaN(t)}a(oe,"isDefined");function It(t,e){return t===e||t!==t&&e!==e}a(It,"sameFloat");function Sd(){return {direction:Ts.Inherit,flexDirection:ut.Column,justifyContent:At.FlexStart,alignItems:ue.Stretch,alignSelf:ue.Auto,alignContent:ue.FlexStart,flexWrap:ar.NoWrap,overflow:jr.Visible,display:sr.Flex,positionType:Kr.Relative,flexGrow:0,flexShrink:0,flexBasis:lr,margin:new Array(9).fill(sn),padding:new Array(9).fill(sn),border:new Array(9).fill(sn),position:new Array(9).fill(sn),gap:new Array(3).fill(sn),width:lr,height:lr,minWidth:sn,minHeight:sn,maxWidth:sn,maxHeight:sn}}a(Sd,"defaultStyle");var $t=0,Rn=1,yn=2,cr=3;function Rr(t,e,n,r=false){let o=t[e];return o.unit===Et.Undefined&&(e===$t||e===yn?o=t[Ue.Horizontal]:o=t[Ue.Vertical]),o.unit===Et.Undefined&&(o=t[Ue.All]),o.unit===Et.Undefined&&(e===$t&&(o=t[Ue.Start]),e===yn&&(o=t[Ue.End])),o.unit===Et.Undefined?0:o.unit===Et.Auto?r?NaN:0:st(o,n)}a(Rr,"resolveEdge");function Mn(t,e){let n=t[e];return n.unit===Et.Undefined&&(e===$t||e===yn?n=t[Ue.Horizontal]:n=t[Ue.Vertical]),n.unit===Et.Undefined&&(n=t[Ue.All]),n.unit===Et.Undefined&&(e===$t&&(n=t[Ue.Start]),e===yn&&(n=t[Ue.End])),n}a(Mn,"resolveEdgeRaw");function Vn(t,e){return Mn(t,e).unit===Et.Auto}a(Vn,"isMarginAuto");function wd(t){for(let e=0;e<9;e++)if(t[e].unit===3)return true;return false}a(wd,"hasAnyAutoEdge");function Es(t){for(let e=0;e<9;e++)if(t[e].unit!==0)return true;return false}a(Es,"hasAnyDefinedEdge");function ul(t,e,n){let r=t[6],o=t[7],i=t[8],s=t[4],l=t[5],c=isNaN(e)?NaN:e/100,d=t[0];d.unit===0&&(d=r),d.unit===0&&(d=i),d.unit===0&&(d=s),n[0]=d.unit===1?d.value:d.unit===2?d.value*c:0,d=t[1],d.unit===0&&(d=o),d.unit===0&&(d=i),n[1]=d.unit===1?d.value:d.unit===2?d.value*c:0,d=t[2],d.unit===0&&(d=r),d.unit===0&&(d=i),d.unit===0&&(d=l),n[2]=d.unit===1?d.value:d.unit===2?d.value*c:0,d=t[3],d.unit===0&&(d=o),d.unit===0&&(d=i),n[3]=d.unit===1?d.value:d.unit===2?d.value*c:0;}a(ul,"resolveEdges4Into");function Si(t){return t===ut.Row||t===ut.RowReverse}a(Si,"isRow");function kd(t){return t===ut.RowReverse||t===ut.ColumnReverse}a(kd,"isReverse");function by(t){return Si(t)?ut.Column:ut.Row}a(by,"crossAxis");function pl(t){switch(t){case ut.Row:return $t;case ut.RowReverse:return yn;case ut.Column:return Rn;case ut.ColumnReverse:return cr}}a(pl,"leadingEdge");function gl(t){switch(t){case ut.Row:return yn;case ut.RowReverse:return $t;case ut.Column:return cr;case ut.ColumnReverse:return Rn}}a(gl,"trailingEdge");function _d(){let t={pointScaleFactor:1,errata:xd.None,useWebDefaults:false,free(){},isExperimentalFeatureEnabled(){return false},setExperimentalFeatureEnabled(){},setPointScaleFactor(e){t.pointScaleFactor=e;},getErrata(){return t.errata},setErrata(e){t.errata=e;},setUseWebDefaults(e){t.useWebDefaults=e;}};return t}a(_d,"createConfig");var yi=class{static{a(this,"Node");}style;layout;parent;children;measureFunc;config;isDirty_;isReferenceBaseline_;_flexBasis=0;_mainSize=0;_crossSize=0;_lineIndex=0;_hasAutoMargin=false;_hasPosition=false;_hasPadding=false;_hasBorder=false;_hasMargin=false;_lW=NaN;_lH=NaN;_lWM=0;_lHM=0;_lOW=NaN;_lOH=NaN;_lFW=false;_lFH=false;_lOutW=NaN;_lOutH=NaN;_hasL=false;_mW=NaN;_mH=NaN;_mWM=0;_mHM=0;_mOW=NaN;_mOH=NaN;_mOutW=NaN;_mOutH=NaN;_hasM=false;_fbBasis=NaN;_fbOwnerW=NaN;_fbOwnerH=NaN;_fbAvailMain=NaN;_fbAvailCross=NaN;_fbCrossMode=0;_fbGen=-1;_cIn=null;_cOut=null;_cGen=-1;_cN=0;_cWr=0;constructor(e){this.style=Sd(),this.layout={left:0,top:0,width:0,height:0,border:[0,0,0,0],padding:[0,0,0,0],margin:[0,0,0,0]},this.parent=null,this.children=[],this.measureFunc=null,this.config=e??xy,this.isDirty_=true,this.isReferenceBaseline_=false,hl++;}insertChild(e,n){e.parent=this,this.children.splice(n,0,e),this.markDirty();}removeChild(e){let n=this.children.indexOf(e);n>=0&&(this.children.splice(n,1),e.parent=null,this.markDirty());}getChild(e){return this.children[e]}getChildCount(){return this.children.length}getParent(){return this.parent}free(){this.parent=null,this.children=[],this.measureFunc=null,this._cIn=null,this._cOut=null,hl--;}freeRecursive(){for(let e of this.children)e.freeRecursive();this.free();}reset(){this.style=Sd(),this.children=[],this.parent=null,this.measureFunc=null,this.isDirty_=true,this._hasAutoMargin=false,this._hasPosition=false,this._hasPadding=false,this._hasBorder=false,this._hasMargin=false,this._hasL=false,this._hasM=false,this._cN=0,this._cWr=0,this._fbBasis=NaN;}markDirty(){this.isDirty_=true,this.parent&&!this.parent.isDirty_&&this.parent.markDirty();}isDirty(){return this.isDirty_}hasNewLayout(){return true}markLayoutSeen(){}setMeasureFunc(e){this.measureFunc=e,this.markDirty();}unsetMeasureFunc(){this.measureFunc=null,this.markDirty();}getComputedLeft(){return this.layout.left}getComputedTop(){return this.layout.top}getComputedWidth(){return this.layout.width}getComputedHeight(){return this.layout.height}getComputedRight(){let e=this.parent;return e?e.layout.width-this.layout.left-this.layout.width:0}getComputedBottom(){let e=this.parent;return e?e.layout.height-this.layout.top-this.layout.height:0}getComputedLayout(){return {left:this.layout.left,top:this.layout.top,right:this.getComputedRight(),bottom:this.getComputedBottom(),width:this.layout.width,height:this.layout.height}}getComputedBorder(e){return this.layout.border[ml(e)]}getComputedPadding(e){return this.layout.padding[ml(e)]}getComputedMargin(e){return this.layout.margin[ml(e)]}setWidth(e){this.style.width=kn(e),this.markDirty();}setWidthPercent(e){this.style.width=hn(e),this.markDirty();}setWidthAuto(){this.style.width=lr,this.markDirty();}setHeight(e){this.style.height=kn(e),this.markDirty();}setHeightPercent(e){this.style.height=hn(e),this.markDirty();}setHeightAuto(){this.style.height=lr,this.markDirty();}setMinWidth(e){this.style.minWidth=kn(e),this.markDirty();}setMinWidthPercent(e){this.style.minWidth=hn(e),this.markDirty();}setMinHeight(e){this.style.minHeight=kn(e),this.markDirty();}setMinHeightPercent(e){this.style.minHeight=hn(e),this.markDirty();}setMaxWidth(e){this.style.maxWidth=kn(e),this.markDirty();}setMaxWidthPercent(e){this.style.maxWidth=hn(e),this.markDirty();}setMaxHeight(e){this.style.maxHeight=kn(e),this.markDirty();}setMaxHeightPercent(e){this.style.maxHeight=hn(e),this.markDirty();}setFlexDirection(e){this.style.flexDirection=e,this.markDirty();}setFlexGrow(e){this.style.flexGrow=e??0,this.markDirty();}setFlexShrink(e){this.style.flexShrink=e??0,this.markDirty();}setFlex(e){e===void 0||isNaN(e)?(this.style.flexGrow=0,this.style.flexShrink=0):e>0?(this.style.flexGrow=e,this.style.flexShrink=1,this.style.flexBasis=_s(0)):e<0?(this.style.flexGrow=0,this.style.flexShrink=-e):(this.style.flexGrow=0,this.style.flexShrink=0),this.markDirty();}setFlexBasis(e){this.style.flexBasis=kn(e),this.markDirty();}setFlexBasisPercent(e){this.style.flexBasis=hn(e),this.markDirty();}setFlexBasisAuto(){this.style.flexBasis=lr,this.markDirty();}setFlexWrap(e){this.style.flexWrap=e,this.markDirty();}setAlignItems(e){this.style.alignItems=e,this.markDirty();}setAlignSelf(e){this.style.alignSelf=e,this.markDirty();}setAlignContent(e){this.style.alignContent=e,this.markDirty();}setJustifyContent(e){this.style.justifyContent=e,this.markDirty();}setDisplay(e){this.style.display=e,this.markDirty();}getDisplay(){return this.style.display}setPositionType(e){this.style.positionType=e,this.markDirty();}setPosition(e,n){this.style.position[e]=kn(n),this._hasPosition=Es(this.style.position),this.markDirty();}setPositionPercent(e,n){this.style.position[e]=hn(n),this._hasPosition=true,this.markDirty();}setPositionAuto(e){this.style.position[e]=lr,this._hasPosition=true,this.markDirty();}setOverflow(e){this.style.overflow=e,this.markDirty();}setDirection(e){this.style.direction=e,this.markDirty();}setBoxSizing(e){}setMargin(e,n){let r=kn(n);this.style.margin[e]=r,r.unit===Et.Auto?this._hasAutoMargin=true:this._hasAutoMargin=wd(this.style.margin),this._hasMargin=this._hasAutoMargin||Es(this.style.margin),this.markDirty();}setMarginPercent(e,n){this.style.margin[e]=hn(n),this._hasAutoMargin=wd(this.style.margin),this._hasMargin=true,this.markDirty();}setMarginAuto(e){this.style.margin[e]=lr,this._hasAutoMargin=true,this._hasMargin=true,this.markDirty();}setPadding(e,n){this.style.padding[e]=kn(n),this._hasPadding=Es(this.style.padding),this.markDirty();}setPaddingPercent(e,n){this.style.padding[e]=hn(n),this._hasPadding=true,this.markDirty();}setBorder(e,n){this.style.border[e]=n===void 0?sn:_s(n),this._hasBorder=Es(this.style.border),this.markDirty();}setGap(e,n){this.style.gap[e]=kn(n),this.markDirty();}setGapPercent(e,n){this.style.gap[e]=hn(n),this.markDirty();}getFlexDirection(){return this.style.flexDirection}getJustifyContent(){return this.style.justifyContent}getAlignItems(){return this.style.alignItems}getAlignSelf(){return this.style.alignSelf}getAlignContent(){return this.style.alignContent}getFlexGrow(){return this.style.flexGrow}getFlexShrink(){return this.style.flexShrink}getFlexBasis(){return this.style.flexBasis}getFlexWrap(){return this.style.flexWrap}getWidth(){return this.style.width}getHeight(){return this.style.height}getOverflow(){return this.style.overflow}getPositionType(){return this.style.positionType}getDirection(){return this.style.direction}copyStyle(e){}setDirtiedFunc(e){}unsetDirtiedFunc(){}setIsReferenceBaseline(e){this.isReferenceBaseline_=e,this.markDirty();}isReferenceBaseline(){return this.isReferenceBaseline_}setAspectRatio(e){}getAspectRatio(){return NaN}setAlwaysFormsContainingBlock(e){}calculateLayout(e,n,r){bl=0,xl=0,bi=0,Mr++;let o=e===void 0?NaN:e,i=n===void 0?NaN:n;xi(this,o,i,oe(o)?de.Exactly:de.Undefined,oe(i)?de.Exactly:de.Undefined,o,i,true);let s=this.layout.margin,l=st(Mn(this.style.position,$t),oe(o)?o:0),c=st(Mn(this.style.position,Rn),oe(o)?o:0);this.layout.left=s[$t]+(oe(l)?l:0),this.layout.top=s[Rn]+(oe(c)?c:0),Od(this,this.config.pointScaleFactor,0,0);}},xy=_d(),Cs=4;function dl(t,e,n,r,o,i,s,l,c,d){t._cIn||(t._cIn=new Float64Array(Cs*8),t._cOut=new Float64Array(Cs*2)),d&&t._cGen!==Mr&&(t._cN=0,t._cWr=0);let f=t._cWr++%Cs;t._cN<Cs&&(t._cN=t._cWr);let m=f*8,g=t._cIn;g[m]=e,g[m+1]=n,g[m+2]=r,g[m+3]=o,g[m+4]=i,g[m+5]=s,g[m+6]=l?1:0,g[m+7]=c?1:0,t._cOut[f*2]=t.layout.width,t._cOut[f*2+1]=t.layout.height,t._cGen=Mr;}a(dl,"cacheWrite");function fl(t,e){e?(t._lOutW=t.layout.width,t._lOutH=t.layout.height):(t._mOutW=t.layout.width,t._mOutH=t.layout.height);}a(fl,"commitCacheOutputs");var Mr=0,bl=0,xl=0,bi=0,hl=0;function Rs(){return {visited:bl,measured:xl,cacheHits:bi,live:hl}}a(Rs,"getYogaCounters");function xi(t,e,n,r,o,i,s,l,c=false,d=false){bl++;let f=t.style,m=t.layout,g=t._cGen===Mr&&!l;if(!t.isDirty_||g){if(!t.isDirty_&&t._hasL&&t._lWM===r&&t._lHM===o&&t._lFW===c&&t._lFH===d&&It(t._lW,e)&&It(t._lH,n)&&It(t._lOW,i)&&It(t._lOH,s)){bi++,m.width=t._lOutW,m.height=t._lOutH;return}if(t._cN>0&&(g||!t.isDirty_)){let Q=t._cIn;for(let Ne=0;Ne<t._cN;Ne++){let xe=Ne*8;if(Q[xe+2]===r&&Q[xe+3]===o&&Q[xe+6]===(c?1:0)&&Q[xe+7]===(d?1:0)&&It(Q[xe],e)&&It(Q[xe+1],n)&&It(Q[xe+4],i)&&It(Q[xe+5],s)){m.width=t._cOut[Ne*2],m.height=t._cOut[Ne*2+1],bi++;return}}}if(!t.isDirty_&&!l&&t._hasM&&t._mWM===r&&t._mHM===o&&It(t._mW,e)&&It(t._mH,n)&&It(t._mOW,i)&&It(t._mOH,s)){m.width=t._mOutW,m.height=t._mOutH,bi++;return}}let y=t.isDirty_;l?(t._lW=e,t._lH=n,t._lWM=r,t._lHM=o,t._lOW=i,t._lOH=s,t._lFW=c,t._lFH=d,t._hasL=true,t.isDirty_=false,y&&(t._hasM=false)):(t._mW=e,t._mH=n,t._mWM=r,t._mHM=o,t._mOW=i,t._mOH=s,t._hasM=true,y&&(t._hasL=false));let w=m.padding,x=m.border,v=m.margin;t._hasPadding?ul(f.padding,i,w):w[0]=w[1]=w[2]=w[3]=0,t._hasBorder?ul(f.border,i,x):x[0]=x[1]=x[2]=x[3]=0,t._hasMargin?ul(f.margin,i,v):v[0]=v[1]=v[2]=v[3]=0;let b=w[0]+w[2]+x[0]+x[2],h=w[1]+w[3]+x[1]+x[3],T=c?NaN:st(f.width,i),A=d?NaN:st(f.height,s),M=e,D=n,N=r,R=o;if(oe(T)&&(M=T,N=de.Exactly),oe(A)&&(D=A,R=de.Exactly),M=_n(f,true,M,i,s),D=_n(f,false,D,i,s),t.measureFunc&&t.children.length===0){let Q=N===de.Undefined?NaN:Math.max(0,M-b),Ne=R===de.Undefined?NaN:Math.max(0,D-h);xl++;let xe=t.measureFunc(Q,N,Ne,R);t.layout.width=N===de.Exactly?M:_n(f,true,(xe.width??0)+b,i,s),t.layout.height=R===de.Exactly?D:_n(f,false,(xe.height??0)+h,i,s),fl(t,l),dl(t,e,n,r,o,i,s,c,d,y);return}if(t.children.length===0){t.layout.width=N===de.Exactly?M:_n(f,true,b,i,s),t.layout.height=R===de.Exactly?D:_n(f,false,h,i,s),fl(t,l),dl(t,e,n,r,o,i,s,c,d,y);return}let E=f.flexDirection,I=by(E),F=Si(E),O=F?M:D,L=F?D:M,J=F?N:R,le=F?R:N,Oe=F?b:h,Pe=F?h:b,Ye=oe(O)?Math.max(0,O-Oe):NaN,Z=oe(L)?Math.max(0,L-Pe):NaN,Se=Ed(f,F?Yn.Column:Yn.Row,Ye),W=[],me=[];Nd(t,W,me);let pe=oe(M)?M:NaN,Y=oe(D)?D:NaN,q=f.flexWrap!==ar.NoWrap,Te=Ed(f,F?Yn.Row:Yn.Column,Z);for(let Q of W)Q._flexBasis=wy(Q,E,Ye,Z,le,pe,Y);let Ce=[];if(!q||!oe(Ye)||W.length===0){for(let Q of W)Q._lineIndex=0;Ce.push(W);}else {let Q=0,Ne=0;for(let xe=0;xe<W.length;xe++){let pt=W[xe],ze=_n(pt.style,F,pt._flexBasis,pe,Y),Fe=Math.max(0,ze)+ks(pt,E,pe),tn=xe>Q?Se:0;xe>Q&&Ne+tn+Fe>Ye?(Ce.push(W.slice(Q,xe)),Q=xe,Ne=Fe):Ne+=tn+Fe,pt._lineIndex=Ce.length;}Ce.push(W.slice(Q));}let ge=Ce.length,se=Ey(t,W),lt=new Array(ge),Be=new Array(ge),He=se?new Array(ge).fill(0):[],re=0,rt=0;for(let Q=0;Q<ge;Q++){let Ne=Ce[Q],xe=Ne.length>1?Se*(Ne.length-1):0,pt=xe;for(let ce of Ne)pt+=ce._flexBasis+ks(ce,E,pe);let ze=Ye;if(!oe(ze)){let ce=F?i:s,it=st(F?f.minWidth:f.minHeight,ce),gt=st(F?f.maxWidth:f.maxHeight,ce);oe(gt)&&pt>gt-Oe?ze=Math.max(0,gt-Oe):oe(it)&&pt<it-Oe&&(ze=Math.max(0,it-Oe));}vy(Ne,ze,pt,F,pe,Y);let Fe=0;for(let ce of Ne){let it=ce.style,gt=it.alignSelf===ue.Auto?f.alignItems:it.alignSelf,Tt=ks(ce,I,pe),ae=NaN,Xe=de.Undefined,St=st(F?it.height:it.width,F?Y:pe),rn=F?Rn:$t,nr=F?cr:yn,on=ce._hasAutoMargin&&(Vn(it.margin,rn)||Vn(it.margin,nr));oe(St)?(ae=St,Xe=de.Exactly):gt===ue.Stretch&&!on&&!q&&oe(Z)&&le===de.Exactly?(ae=Math.max(0,Z-Tt),Xe=de.Exactly):!q&&oe(Z)&&(ae=Math.max(0,Z-Tt),Xe=de.AtMost);let qt=F?ce._mainSize:ae,zt=F?ae:ce._mainSize;xi(ce,qt,zt,F?de.Exactly:Xe,F?Xe:de.Exactly,pe,Y,l,F,!F),ce._crossSize=F?ce.layout.height:ce.layout.width,Fe=Math.max(Fe,ce._crossSize+Tt);}if(se){let ce=0,it=0;for(let gt of Ne){if(Md(t,gt)!==ue.Baseline)continue;let Tt=Rr(gt.style.margin,Rn,pe),ae=Rr(gt.style.margin,cr,pe),Xe=yl(gt)+Tt,St=gt.layout.height+Tt+ae-Xe;Xe>ce&&(ce=Xe),St>it&&(it=St);}He[Q]=ce,ce+it>Fe&&(Fe=ce+it);}let tn=pl(E),Je=gl(E),nn=xe;for(let ce of Ne){let it=ce.layout.margin;nn+=ce._mainSize+it[tn]+it[Je];}lt[Q]=nn,Be[Q]=Fe,re=Math.max(re,nn),rt+=Fe;}let xt=ge>1?Te*(ge-1):0;rt+=xt;let Zt=f.overflow===jr.Scroll,Mt=re+Oe,Vt=J===de.Exactly?O:J===de.AtMost&&Zt?Math.max(Math.min(O,Mt),Oe):q&&ge>1&&J===de.AtMost?O:Mt,Dt=rt+Pe,We=le===de.Exactly?L:le===de.AtMost&&Zt?Math.max(Math.min(L,Dt),Pe):Dt;if(t.layout.width=_n(f,true,F?Vt:We,i,s),t.layout.height=_n(f,false,F?We:Vt,i,s),fl(t,l),dl(t,e,n,r,o,i,s,c,d,y),!l)return;let ke=(F?t.layout.width:t.layout.height)-Oe,we=(F?t.layout.height:t.layout.width)-Pe,qe=pl(E),ot=gl(E),U=F?Rn:$t,$=F?cr:yn,V=kd(E),K=F?t.layout.width:t.layout.height,z=w[U]+x[U],he=Te,ct=we-rt;if(ge===1&&!q&&!se)Be[0]=we;else {let Q=Math.max(0,ct);switch(f.alignContent){case ue.FlexStart:break;case ue.Center:z+=ct/2;break;case ue.FlexEnd:z+=ct;break;case ue.Stretch:if(ge>0&&Q>0){let Ne=Q/ge;for(let xe=0;xe<ge;xe++)Be[xe]+=Ne;}break;case ue.SpaceBetween:ge>1&&(he+=Q/(ge-1));break;case ue.SpaceAround:ge>0&&(he+=Q/ge,z+=Q/ge/2);break;case ue.SpaceEvenly:ge>0&&(he+=Q/(ge+1),z+=Q/(ge+1));break;}}let mt=f.flexWrap===ar.WrapReverse,en=F?t.layout.height:t.layout.width,pn=z;for(let Q=0;Q<ge;Q++){let Ne=Ce[Q],xe=Be[Q],pt=lt[Q],ze=Ne.length;if(q||le!==de.Exactly)for(let ae of Ne){let Xe=ae.style,St=Xe.alignSelf===ue.Auto?f.alignItems:Xe.alignSelf,rn=oe(st(F?Xe.height:Xe.width,F?Y:pe)),nr=ae._hasAutoMargin&&(Vn(Xe.margin,U)||Vn(Xe.margin,$));if(St===ue.Stretch&&!rn&&!nr){let on=ks(ae,I,pe),qt=Math.max(0,xe-on);if(ae._crossSize!==qt){let zt=F?ae._mainSize:qt,Gn=F?qt:ae._mainSize;xi(ae,zt,Gn,de.Exactly,de.Exactly,pe,Y,l,F,!F),ae._crossSize=qt;}}}let Fe=w[qe]+x[qe],tn=Se,Je=0;for(let ae of Ne)ae._hasAutoMargin&&(Vn(ae.style.margin,qe)&&Je++,Vn(ae.style.margin,ot)&&Je++);let nn=ke-pt,ce=Math.max(0,nn),it=Je>0&&ce>0?ce/Je:0;if(Je===0)switch(f.justifyContent){case At.FlexStart:break;case At.Center:Fe+=nn/2;break;case At.FlexEnd:Fe+=nn;break;case At.SpaceBetween:ze>1&&(tn+=ce/(ze-1));break;case At.SpaceAround:ze>0&&(tn+=ce/ze,Fe+=ce/ze/2);break;case At.SpaceEvenly:ze>0&&(tn+=ce/(ze+1),Fe+=ce/(ze+1));break}let gt=mt?en-pn-xe:pn,Tt=Fe;for(let ae of Ne){let Xe=ae.style.margin,St=ae.layout.margin,rn=false,nr=false,on=false,qt=false,zt,Gn,Hr,ui;ae._hasAutoMargin?(rn=Vn(Xe,qe),nr=Vn(Xe,ot),on=Vn(Xe,U),qt=Vn(Xe,$),zt=rn?it:St[qe],Gn=nr?it:St[ot],Hr=on?0:St[U],ui=qt?0:St[$]):(zt=St[qe],Gn=St[ot],Hr=St[U],ui=St[$]);let di=V?K-(Tt+zt)-ae._mainSize:Tt+zt,rr=ae.style.alignSelf===ue.Auto?f.alignItems:ae.style.alignSelf,jn=gt+Hr,Wr=xe-ae._crossSize-Hr-ui;if(on&&qt)jn+=Math.max(0,Wr)/2;else if(on)jn+=Math.max(0,Wr);else if(!qt)switch(rr){case ue.FlexStart:case ue.Stretch:mt&&(jn+=Wr);break;case ue.Center:jn+=Wr/2;break;case ue.FlexEnd:mt||(jn+=Wr);break;case ue.Baseline:se&&(jn=gt+He[Q]-yl(ae));break;}let go=0,fi=0;if(ae._hasPosition){let ps=st(Mn(ae.style.position,$t),pe),gs=st(Mn(ae.style.position,yn),pe),hs=st(Mn(ae.style.position,Rn),pe),ys=st(Mn(ae.style.position,cr),pe);go=oe(ps)?ps:oe(gs)?-gs:0,fi=oe(hs)?hs:oe(ys)?-ys:0;}F?(ae.layout.left=di+go,ae.layout.top=jn+fi):(ae.layout.left=jn+go,ae.layout.top=di+fi),Tt+=ae._mainSize+zt+Gn+tn;}pn+=xe+he;}for(let Q of me)Sy(t,Q,t.layout.width,t.layout.height,w,x);}a(xi,"layoutNode");function Sy(t,e,n,r,o,i){let s=e.style,l=Mn(s.position,$t),c=Mn(s.position,yn),d=Mn(s.position,Rn),f=Mn(s.position,cr),m=st(l,n),g=st(c,n),y=st(d,r),w=st(f,r),x=n-i[0]-i[2],v=r-i[1]-i[3],b=st(s.width,x),h=st(s.height,v);!oe(b)&&oe(m)&&oe(g)&&(b=x-m-g),!oe(h)&&oe(y)&&oe(w)&&(h=v-y-w),xi(e,b,h,oe(b)?de.Exactly:de.Undefined,oe(h)?de.Exactly:de.Undefined,x,v,true);let T=Rr(s.margin,$t,n),A=Rr(s.margin,Rn,n),M=Rr(s.margin,yn,n),D=Rr(s.margin,cr,n),N=t.style.flexDirection,R=kd(N),E=Si(N),I=t.style.flexWrap===ar.WrapReverse,F=s.alignSelf===ue.Auto?t.style.alignItems:s.alignSelf,O;if(oe(m))O=i[0]+m+T;else if(oe(g))O=n-i[2]-g-e.layout.width-M;else if(E){let J=o[0]+i[0],le=n-o[2]-i[2];O=R?le-e.layout.width-M:vd(t.style.justifyContent,J,le,e.layout.width)+T;}else O=Td(F,o[0]+i[0],n-o[2]-i[2],e.layout.width,I)+T;let L;if(oe(y))L=i[1]+y+A;else if(oe(w))L=r-i[3]-w-e.layout.height-D;else if(E)L=Td(F,o[1]+i[1],r-o[3]-i[3],e.layout.height,I)+A;else {let J=o[1]+i[1],le=r-o[3]-i[3];L=R?le-e.layout.height-D:vd(t.style.justifyContent,J,le,e.layout.height)+A;}e.layout.left=O,e.layout.top=L;}a(Sy,"layoutAbsoluteChild");function vd(t,e,n,r){switch(t){case At.Center:return e+(n-e-r)/2;case At.FlexEnd:return n-r;default:return e}}a(vd,"justifyAbsolute");function Td(t,e,n,r,o){switch(t){case ue.Center:return e+(n-e-r)/2;case ue.FlexEnd:return o?e:n-r;default:return o?n-r:e}}a(Td,"alignAbsolute");function wy(t,e,n,r,o,i,s){if((t._fbGen===Mr||!t.isDirty_)&&t._fbCrossMode===o&&It(t._fbOwnerW,i)&&It(t._fbOwnerH,s)&&It(t._fbAvailMain,n)&&It(t._fbAvailCross,r))return t._fbBasis;let c=t.style,d=Si(e),f=st(c.flexBasis,n);if(oe(f)){let E=Math.max(0,f);return t._fbBasis=E,t._fbOwnerW=i,t._fbOwnerH=s,t._fbAvailMain=n,t._fbAvailCross=r,t._fbCrossMode=o,t._fbGen=Mr,E}let m=d?c.width:c.height,y=st(m,d?i:s);if(oe(y)){let E=Math.max(0,y);return t._fbBasis=E,t._fbOwnerW=i,t._fbOwnerH=s,t._fbAvailMain=n,t._fbAvailCross=r,t._fbCrossMode=o,t._fbGen=Mr,E}let w=d?c.height:c.width,v=st(w,d?s:i),b=oe(v)?de.Exactly:de.Undefined;!oe(v)&&oe(r)&&(v=r,b=o===de.Exactly&&Ty(t)?de.Exactly:de.AtMost);let h=NaN,T=de.Undefined;d&&oe(n)&&Rd(t)&&(h=n,T=de.AtMost),xi(t,d?h:v,d?v:h,d?T:b,d?b:T,i,s,false);let R=d?t.layout.width:t.layout.height;return t._fbBasis=R,t._fbOwnerW=i,t._fbOwnerH=s,t._fbAvailMain=n,t._fbAvailCross=r,t._fbCrossMode=o,t._fbGen=Mr,R}a(wy,"computeFlexBasis");function Rd(t){if(t.measureFunc)return true;for(let e of t.children)if(Rd(e))return true;return false}a(Rd,"hasMeasureFuncInSubtree");function vy(t,e,n,r,o,i){let s=t.length,l=new Array(s).fill(false),c=oe(e)?e-n:0;for(let f=0;f<s;f++){let m=t[f],g=_n(m.style,r,m._flexBasis,o,i);!oe(e)||(c>=0?m.style.flexGrow===0:m.style.flexShrink===0)?(m._mainSize=Math.max(0,g),l[f]=true):m._mainSize=m._flexBasis;}let d=new Array(s);for(let f=0;f<=s;f++){let m=0,g=0,y=0,w=0;for(let h=0;h<s;h++){let T=t[h];l[h]?m+=T._mainSize-T._flexBasis:(g+=T.style.flexGrow,y+=T.style.flexShrink*T._flexBasis,w++);}if(w===0)break;let x=c-m;if(x>0&&g>0&&g<1){let h=c*g;h<x&&(x=h);}else if(x<0&&y>0){let h=0;for(let T=0;T<s;T++)l[T]||(h+=t[T].style.flexShrink);if(h<1){let T=c*h;T>x&&(x=T);}}let v=0;for(let h=0;h<s;h++){if(l[h])continue;let T=t[h],A=T._flexBasis;x>0&&g>0?A+=x*T.style.flexGrow/g:x<0&&y>0&&(A+=x*(T.style.flexShrink*T._flexBasis)/y),d[h]=A;let M=Math.max(0,_n(T.style,r,A,o,i));T._mainSize=M,v+=M-A;}if(v===0)break;let b=false;for(let h=0;h<s;h++){if(l[h])continue;let T=t[h]._mainSize-d[h];(v>0&&T>0||v<0&&T<0)&&(l[h]=true,b=true);}if(!b)break}}a(vy,"resolveFlexibleLengths");function Ty(t){let e=t.parent;return e?(t.style.alignSelf===ue.Auto?e.style.alignItems:t.style.alignSelf)===ue.Stretch:false}a(Ty,"isStretchAlign");function Md(t,e){return e.style.alignSelf===ue.Auto?t.style.alignItems:e.style.alignSelf}a(Md,"resolveChildAlign");function yl(t){let e=null;for(let n of t.children){if(n._lineIndex>0)break;if(n.style.positionType!==Kr.Absolute&&n.style.display!==sr.None){if(Md(t,n)===ue.Baseline||n.isReferenceBaseline_){e=n;break}e===null&&(e=n);}}return e===null?t.layout.height:yl(e)+e.layout.top}a(yl,"calculateBaseline");function Ey(t,e){if(!Si(t.style.flexDirection))return false;if(t.style.alignItems===ue.Baseline)return true;for(let n of e)if(n.style.alignSelf===ue.Baseline)return true;return false}a(Ey,"isBaselineLayout");function ks(t,e,n){if(!t._hasMargin)return 0;let r=Rr(t.style.margin,pl(e),n),o=Rr(t.style.margin,gl(e),n);return r+o}a(ks,"childMarginForAxis");function Ed(t,e,n){let r=t.gap[e];r.unit===Et.Undefined&&(r=t.gap[Yn.All]);let o=st(r,n);return oe(o)?Math.max(0,o):0}a(Ed,"resolveGap");function _n(t,e,n,r,o){let i=e?t.minWidth:t.minHeight,s=e?t.maxWidth:t.maxHeight,l=i.unit,c=s.unit;if(l===0&&c===0)return n;let d=e?r:o,f=n;if(c===1)f>s.value&&(f=s.value);else if(c===2){let m=s.value*d/100;m===m&&f>m&&(f=m);}if(l===1)f<i.value&&(f=i.value);else if(l===2){let m=i.value*d/100;m===m&&f<m&&(f=m);}return f}a(_n,"boundAxis");function Ad(t){for(let e of t.children)e.layout.left=0,e.layout.top=0,e.layout.width=0,e.layout.height=0,e.isDirty_=true,e._hasL=false,e._hasM=false,Ad(e);}a(Ad,"zeroLayoutRecursive");function Nd(t,e,n){for(let r of t.children){let o=r.style.display;o===sr.None?(r.layout.left=0,r.layout.top=0,r.layout.width=0,r.layout.height=0,Ad(r)):o===sr.Contents?(r.layout.left=0,r.layout.top=0,r.layout.width=0,r.layout.height=0,Nd(r,e,n)):r.style.positionType===Kr.Absolute?n.push(r):e.push(r);}}a(Nd,"collectLayoutChildren");function Od(t,e,n,r){if(e===0)return;let o=t.layout,i=o.left,s=o.top,l=o.width,c=o.height,d=n+i,f=r+s,m=t.measureFunc!==null;o.left=yo(i,e,false,m),o.top=yo(s,e,false,m);let g=d+l,y=f+c,w=!Cd(l*e),x=!Cd(c*e);o.width=yo(g,e,m&&w,m&&!w)-yo(d,e,false,m),o.height=yo(y,e,m&&x,m&&!x)-yo(f,e,false,m);for(let v of t.children)Od(v,e,d,f);}a(Od,"roundLayout");function Cd(t){let e=t-Math.floor(t);return e<1e-4||e>.9999}a(Cd,"isWholeNumber");function yo(t,e,n,r){let o=t*e,i=o-Math.floor(o);return i<0&&(i+=1),i<1e-4?o=Math.floor(o):i>.9999||n?o=Math.ceil(o):r?o=Math.floor(o):o=Math.floor(o)+(i>=.4999?1:0),o/e}a(yo,"roundValue");function kn(t){if(t===void 0)return sn;if(t==="auto")return lr;if(typeof t=="number")return Number.isFinite(t)?_s(t):sn;if(typeof t=="string"&&t.endsWith("%"))return hn(parseFloat(t));let e=parseFloat(t);return isNaN(e)?sn:_s(e)}a(kn,"parseDimension");function ml(t){switch(t){case Ue.Left:case Ue.Start:return $t;case Ue.Top:return Rn;case Ue.Right:case Ue.End:return yn;case Ue.Bottom:return cr;default:return $t}}a(ml,"physicalEdge");var Cy={Node:{create:a(t=>new yi(t),"create"),createDefault:a(()=>new yi,"createDefault"),createWithConfig:a(t=>new yi(t),"createWithConfig"),destroy(){}}};var Pd=Cy;h();function ky(){return process.env.TERM_PROGRAM==="vscode"&&te.level===2?(te.level=3,true):false}a(ky,"boostChalkLevelForXtermJs");function _y(){return process.env.CLAUDE_CODE_TMUX_TRUECOLOR?false:process.env.TMUX&&te.level>2?(te.level=2,true):false}a(_y,"clampChalkLevelForTmux");ky();_y();var Ry=/^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/,My=/^ansi256\(\s?(\d+)\s?\)$/,wi=a((t,e,n)=>{if(!e)return t;if(e.startsWith("ansi:"))switch(e.substring(5)){case "black":return n==="foreground"?te.black(t):te.bgBlack(t);case "red":return n==="foreground"?te.red(t):te.bgRed(t);case "green":return n==="foreground"?te.green(t):te.bgGreen(t);case "yellow":return n==="foreground"?te.yellow(t):te.bgYellow(t);case "blue":return n==="foreground"?te.blue(t):te.bgBlue(t);case "magenta":return n==="foreground"?te.magenta(t):te.bgMagenta(t);case "cyan":return n==="foreground"?te.cyan(t):te.bgCyan(t);case "white":return n==="foreground"?te.white(t):te.bgWhite(t);case "blackBright":return n==="foreground"?te.blackBright(t):te.bgBlackBright(t);case "redBright":return n==="foreground"?te.redBright(t):te.bgRedBright(t);case "greenBright":return n==="foreground"?te.greenBright(t):te.bgGreenBright(t);case "yellowBright":return n==="foreground"?te.yellowBright(t):te.bgYellowBright(t);case "blueBright":return n==="foreground"?te.blueBright(t):te.bgBlueBright(t);case "magentaBright":return n==="foreground"?te.magentaBright(t):te.bgMagentaBright(t);case "cyanBright":return n==="foreground"?te.cyanBright(t):te.bgCyanBright(t);case "whiteBright":return n==="foreground"?te.whiteBright(t):te.bgWhiteBright(t)}if(e.startsWith("#"))return n==="foreground"?te.hex(e)(t):te.bgHex(e)(t);if(e.startsWith("ansi256")){let r=My.exec(e);if(!r)return t;let o=Number(r[1]);return n==="foreground"?te.ansi256(o)(t):te.bgAnsi256(o)(t)}if(e.startsWith("rgb")){let r=Ry.exec(e);if(!r)return t;let o=Number(r[1]),i=Number(r[2]),s=Number(r[3]);return n==="foreground"?te.rgb(o,i,s)(t):te.bgRgb(o,i,s)(t)}return t},"colorize");function bo(t,e){let n=t;return e.inverse&&(n=te.inverse(n)),e.strikethrough&&(n=te.strikethrough(n)),e.underline&&(n=te.underline(n)),e.italic&&(n=te.italic(n)),e.bold&&(n=te.bold(n)),e.dim&&(n=te.dim(n)),e.color&&(n=wi(n,e.color,"foreground")),e.backgroundColor&&(n=wi(n,e.backgroundColor,"background")),n}a(bo,"applyTextStyles");function Ms(t,e){return e?wi(t,e,"foreground"):t}a(Ms,"applyColor");h();h();h();var Sl=null;function Yr(){return Sl||(Sl=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Sl}a(Yr,"getGraphemeSegmenter");function Id(){}a(Id,"stopCapturingEarlyInput");h();function Vr(t){if(!t)return false;if(typeof t=="boolean")return t;let e=t.toLowerCase().trim();return ["1","true","yes","on"].includes(e)}a(Vr,"isEnvTruthy");h();h();function An(t,e,n){return new Promise(r=>{let o={timeout:n?.timeout??1e4,maxBuffer:10485760,encoding:"utf-8"};n?.cwd&&(o.cwd=n.cwd),n?.env&&(o.env={...process.env,...n.env}),n?.shell&&(o.shell=n.shell===true?void 0:n.shell);let i=execFile(t,e,o,(s,l,c)=>{if(s){let d=s;d.code==="ENOENT"||d.code==="EACCES"||d.code==="EPERM"?r({code:null,stdout:String(l??""),stderr:d.message}):r({code:s.code!=null&&typeof s.code=="number"?s.code:1,stdout:String(l??""),stderr:String(c??"")});}else r({code:0,stdout:String(l??""),stderr:String(c??"")});});n?.input&&i.stdin&&(i.stdin.write(n.input),i.stdin.end());})}a(An,"execFileNoThrow");function Ld(){return Vr(process.env.CLAUDE_CODE_DISABLE_MOUSE_CLICKS)}a(Ld,"isMouseClicksDisabled");h();h();var bn=class{static{a(this,"Event");}_didStopImmediatePropagation=false;didStopImmediatePropagation(){return this._didStopImmediatePropagation}stopImmediatePropagation(){this._didStopImmediatePropagation=true;}};var xo=class extends EventEmitter{static{a(this,"EventEmitter");}constructor(){super(),this.setMaxListeners(0);}emit(e,...n){if(e==="error")return super.emit(e,...n);let r=this.rawListeners(e);if(r.length===0)return false;let o=n[0]instanceof bn?n[0]:null;for(let i of r)if(i.apply(this,n),o?.didStopImmediatePropagation())break;return true}};h();h();h();h();var qn={BEL:7,ESC:27},an="\x1B",ur="\x07",Ar=";",Nn={CSI:91,OSC:93,DCS:80,APC:95,ST:92};function vl(t){return t>=48&&t<=126}a(vl,"isEscFinal");var Tl=an+String.fromCharCode(Nn.CSI),So={PARAM_START:48,PARAM_END:63,INTERMEDIATE_START:32,INTERMEDIATE_END:47,FINAL_START:64,FINAL_END:126};function Bd(t){return t>=So.PARAM_START&&t<=So.PARAM_END}a(Bd,"isCSIParam");function As(t){return t>=So.INTERMEDIATE_START&&t<=So.INTERMEDIATE_END}a(As,"isCSIIntermediate");function Fd(t){return t>=So.FINAL_START&&t<=So.FINAL_END}a(Fd,"isCSIFinal");function Re(...t){if(t.length===0)return Tl;if(t.length===1)return `${Tl}${t[0]}`;let e=t.slice(0,-1),n=t[t.length-1];return `${Tl}${e.join(Ar)}${n}`}a(Re,"csi");var tt={CUU:65,CUD:66,CUF:67,CUB:68,CNL:69,CPL:70,CHA:71,CUP:72,VPA:100,HVP:102,ED:74,EL:75,ECH:88,SU:83,SD:84,SM:104,RM:108,SGR:109,DECSCUSR:113,DECSTBM:114,SCOSC:115,SCORC:117},$d=["toEnd","toStart","all","scrollback"],Hd=["toEnd","toStart","all"],El=[{style:"block",blinking:true},{style:"block",blinking:true},{style:"block",blinking:false},{style:"underline",blinking:true},{style:"underline",blinking:false},{style:"bar",blinking:true},{style:"bar",blinking:false}];function Wd(t=1){return t===0?"":Re(t,"A")}a(Wd,"cursorUp");function Oy(t=1){return t===0?"":Re(t,"B")}a(Oy,"cursorDown");function Py(t=1){return t===0?"":Re(t,"C")}a(Py,"cursorForward");function Dy(t=1){return t===0?"":Re(t,"D")}a(Dy,"cursorBack");function Ud(t){return Re(t,"G")}a(Ud,"cursorTo");var Iy=Re("G");function Cl(t,e){return Re(t,e,"H")}a(Cl,"cursorPosition");var On=Re("H");function wo(t,e){let n="";return t<0?n+=Dy(-t):t>0&&(n+=Py(t)),e<0?n+=Wd(-e):e>0&&(n+=Oy(e)),n}a(wo,"cursorMove");Re("s");Re("u");var Ly=Re(2,"K");var dr=Re(2,"J"),vi=Re(3,"J");function Gd(t){if(t<=0)return "";let e="";for(let n=0;n<t;n++)e+=Ly,n<t-1&&(e+=Wd(1));return e+=Iy,e}a(Gd,"eraseLines");function jd(t=1){return t===0?"":Re(t,"S")}a(jd,"scrollUp");function Kd(t=1){return t===0?"":Re(t,"T")}a(Kd,"scrollDown");function Yd(t,e){return Re(t,e,"r")}a(Yd,"setScrollRegion");var Vd=Re("r"),qd=Re("200~"),zd=Re("201~"),Jd=Re("I"),Xd=Re("O"),Ti=Re(">1u"),qr=Re("<u"),Ei=Re(">4;2m"),Ci=Re(">4m");h();function vo(t){let e="ground",n="",r=t?.x10Mouse??false;return {feed(o){let i=Qd(o,e,n,false,r);return e=i.state.state,n=i.state.buffer,i.tokens},flush(){let o=Qd("",e,n,true,r);return e=o.state.state,n=o.state.buffer,o.tokens},reset(){e="ground",n="";},buffer(){return n}}}a(vo,"createTokenizer");function Qd(t,e,n,r,o){let i=[],s={state:e,buffer:""},l=n+t,c=0,d=0,f=0,m=a(()=>{if(c>d){let y=l.slice(d,c);y&&i.push({type:"text",value:y});}d=c;},"flushText"),g=a(y=>{y&&i.push({type:"sequence",value:y}),s.state="ground",d=c;},"emitSequence");for(;c<l.length;){let y=l.charCodeAt(c);switch(s.state){case "ground":y===qn.ESC&&(m(),f=c,s.state="escape"),c++;break;case "escape":y===Nn.CSI?(s.state="csi",c++):y===Nn.OSC?(s.state="osc",c++):y===Nn.DCS?(s.state="dcs",c++):y===Nn.APC?(s.state="apc",c++):y===79?(s.state="ss3",c++):As(y)?(s.state="escapeIntermediate",c++):vl(y)?(c++,g(l.slice(f,c))):y===qn.ESC?(g(l.slice(f,c)),f=c,s.state="escape",c++):(s.state="ground",d=f);break;case "escapeIntermediate":As(y)?c++:vl(y)?(c++,g(l.slice(f,c))):(s.state="ground",d=f);break;case "csi":if(o&&y===77&&c-f===2&&(c+1>=l.length||l.charCodeAt(c+1)>=32)&&(c+2>=l.length||l.charCodeAt(c+2)>=32)&&(c+3>=l.length||l.charCodeAt(c+3)>=32)){c+4<=l.length?(c+=4,g(l.slice(f,c))):c=l.length;break}Fd(y)?(c++,g(l.slice(f,c))):Bd(y)||As(y)?c++:(s.state="ground",d=f);break;case "ss3":y>=64&&y<=126?(c++,g(l.slice(f,c))):(s.state="ground",d=f);break;case "osc":y===qn.BEL?(c++,g(l.slice(f,c))):y===qn.ESC&&c+1<l.length&&l.charCodeAt(c+1)===Nn.ST?(c+=2,g(l.slice(f,c))):c++;break;case "dcs":case "apc":y===qn.BEL?(c++,g(l.slice(f,c))):y===qn.ESC&&c+1<l.length&&l.charCodeAt(c+1)===Nn.ST?(c+=2,g(l.slice(f,c))):c++;break}}if(s.state==="ground")m();else if(r){let y=l.slice(f);y&&i.push({type:"sequence",value:y}),s.state="ground";}else s.buffer=l.slice(f);return {tokens:i,state:s}}a(Qd,"tokenize");var Fy=/^(?:\x1b)([a-zA-Z0-9])$/,$y=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Hy=/^\x1b\[(\d+)(?:;(\d+))?u/,Wy=/^\x1b\[27;(\d+);(\d+)~/,Uy=/^\x1b\[\?(\d+);(\d+)\$y$/,Gy=/^\x1b\[\?([\d;]*)c$/,jy=/^\x1b\[>([\d;]*)c$/,Ky=/^\x1b\[\?(\d+)u$/,Yy=/^\x1b\[\?(\d+);(\d+)R$/,Vy=/^\x1b\](\d+);(.*?)(?:\x07|\x1b\\)$/s,qy=/^\x1bP>\|(.*?)(?:\x07|\x1b\\)$/s,of=/^\x1b\[<(\d+);(\d+);(\d+)([Mm])$/;function Zd(t){return {kind:"key",name:"",fn:false,ctrl:false,meta:false,shift:false,option:false,super:false,sequence:t,raw:t,isPasted:true}}a(Zd,"createPasteKey");function zy(t){if(t.startsWith("\x1B[")){let e;return (e=Uy.exec(t))?{type:"decrpm",mode:parseInt(e[1],10),status:parseInt(e[2],10)}:(e=Gy.exec(t))?{type:"da1",params:ef(e[1])}:(e=jy.exec(t))?{type:"da2",params:ef(e[1])}:(e=Ky.exec(t))?{type:"kittyKeyboard",flags:parseInt(e[1],10)}:(e=Yy.exec(t))?{type:"cursorPosition",row:parseInt(e[1],10),col:parseInt(e[2],10)}:null}if(t.startsWith("\x1B]")){let e=Vy.exec(t);if(e)return {type:"osc",code:parseInt(e[1],10),data:e[2]}}if(t.startsWith("\x1BP")){let e=qy.exec(t);if(e)return {type:"xtversion",name:e[1]}}return null}a(zy,"parseTerminalResponse");function ef(t){return t?t.split(";").map(e=>parseInt(e,10)):[]}a(ef,"splitNumericParams");var sf={mode:"NORMAL",incomplete:"",pasteBuffer:""};function Jy(t){return Buffer$1.isBuffer(t)?t[0]>127&&t[1]===void 0?(t[0]-=128,"\x1B"+String(t)):String(t):t!==void 0&&typeof t!="string"?String(t):t||""}a(Jy,"inputToString");function af(t,e=""){let n=e===null,r=n?"":Jy(e),o=t._tokenizer??vo({x10Mouse:true}),i=n?o.flush():o.feed(r),s=[],l=t.mode==="IN_PASTE",c=t.pasteBuffer;for(let f of i)if(f.type==="sequence")if(f.value===qd)l=true,c="";else if(f.value===zd)s.push(Zd(c)),l=false,c="";else if(l)c+=f.value;else {let m=zy(f.value);if(m)s.push({kind:"response",sequence:f.value,response:m});else {let g=rf(f.value);g?s.push(g):s.push(kl(f.value));}}else if(f.type==="text")if(l)c+=f.value;else if(/^\[<\d+;\d+;\d+[Mm]$/.test(f.value)||/^\[M[\x60-\x7f][\x20-\uffff]{2}$/.test(f.value)){let m="\x1B"+f.value,g=rf(m);s.push(g??kl(m));}else s.push(kl(f.value));n&&l&&c&&(s.push(Zd(c)),l=false,c="");let d={mode:l?"IN_PASTE":"NORMAL",incomplete:o.buffer(),pasteBuffer:c,_tokenizer:o};return [s,d]}a(af,"parseMultipleKeypresses");var lf={OP:"f1",OQ:"f2",OR:"f3",OS:"f4",Op:"0",Oq:"1",Or:"2",Os:"3",Ot:"4",Ou:"5",Ov:"6",Ow:"7",Ox:"8",Oy:"9",Oj:"*",Ok:"+",Ol:",",Om:"-",On:".",Oo:"/",OM:"return","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},cf=[...Object.values(lf).filter(t=>t.length>1),"escape","backspace","wheelup","wheeldown","mouse"],Xy=a(t=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(t),"isShiftKey"),Qy=a(t=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(t),"isCtrlKey");function tf(t){let e=t-1;return {shift:!!(e&1),meta:!!(e&2),ctrl:!!(e&4),super:!!(e&8)}}a(tf,"decodeModifier");function nf(t){switch(t){case 9:return "tab";case 13:return "return";case 27:return "escape";case 32:return "space";case 127:return "backspace";case 57399:return "0";case 57400:return "1";case 57401:return "2";case 57402:return "3";case 57403:return "4";case 57404:return "5";case 57405:return "6";case 57406:return "7";case 57407:return "8";case 57408:return "9";case 57409:return ".";case 57410:return "/";case 57411:return "*";case 57412:return "-";case 57413:return "+";case 57414:return "return";case 57415:return "=";default:return t>=32&&t<=126?String.fromCharCode(t).toLowerCase():void 0}}a(nf,"keycodeToName");function rf(t){let e=of.exec(t);if(!e)return null;let n=parseInt(e[1],10);return (n&64)!==0?null:{kind:"mouse",button:n,action:e[4]==="M"?"press":"release",col:parseInt(e[2],10),row:parseInt(e[3],10),sequence:t}}a(rf,"parseMouseEvent");function kl(t=""){let e,n={kind:"key",name:"",fn:false,ctrl:false,meta:false,shift:false,option:false,super:false,sequence:t,raw:t,isPasted:false};n.sequence=n.sequence||t||n.name;let r;if(r=Hy.exec(t)){let o=parseInt(r[1],10),i=r[2]?parseInt(r[2],10):1,s=tf(i);return {kind:"key",name:nf(o),fn:false,ctrl:s.ctrl,meta:s.meta,shift:s.shift,option:false,super:s.super,sequence:t,raw:t,isPasted:false}}if(r=Wy.exec(t)){let o=tf(parseInt(r[1],10));return {kind:"key",name:nf(parseInt(r[2],10)),fn:false,ctrl:o.ctrl,meta:o.meta,shift:o.shift,option:false,super:o.super,sequence:t,raw:t,isPasted:false}}if(r=of.exec(t)){let o=parseInt(r[1],10);return (o&67)===64?xn(t,"wheelup",false):(o&67)===65?xn(t,"wheeldown",false):xn(t,"mouse",false)}if(t.length===6&&t.startsWith("\x1B[M")){let o=t.charCodeAt(3)-32;return (o&67)===64?xn(t,"wheelup",false):(o&67)===65?xn(t,"wheeldown",false):xn(t,"mouse",false)}if(t==="\r")n.raw=void 0,n.name="return";else if(t===`
21
- `)n.name="enter";else if(t===" ")n.name="tab";else if(t==="\b"||t==="\x1B\b")n.name="backspace",n.meta=t.charAt(0)==="\x1B";else if(t==="\x7F"||t==="\x1B\x7F")n.name="backspace",n.meta=t.charAt(0)==="\x1B";else if(t==="\x1B"||t==="\x1B\x1B")n.name="escape",n.meta=t.length===2;else if(t===" "||t==="\x1B ")n.name="space",n.meta=t.length===2;else if(t==="")n.name="_",n.ctrl=true;else if(t<=""&&t.length===1)n.name=String.fromCharCode(t.charCodeAt(0)+97-1),n.ctrl=true;else if(t.length===1&&t>="0"&&t<="9")n.name="number";else if(t.length===1&&t>="a"&&t<="z")n.name=t;else if(t.length===1&&t>="A"&&t<="Z")n.name=t.toLowerCase(),n.shift=true;else if(e=Fy.exec(t))n.meta=true,n.shift=/^[A-Z]$/.test(e[1]);else if(e=$y.exec(t)){let o=[...t];o[0]==="\x1B"&&o[1]==="\x1B"&&(n.option=true);let i=[e[1],e[2],e[4],e[6]].filter(Boolean).join(""),s=(e[3]||e[5]||1)-1;n.ctrl=!!(s&4),n.meta=!!(s&2),n.super=!!(s&8),n.shift=!!(s&1),n.code=i,n.name=lf[i],n.shift=Xy(i)||n.shift,n.ctrl=Qy(i)||n.ctrl;}switch(n.raw==="\x1Bb"?(n.meta=true,n.name="left"):n.raw==="\x1Bf"&&(n.meta=true,n.name="right"),t){case "\x1B[1~":return xn(t,"home",false);case "\x1B[4~":return xn(t,"end",false);case "\x1B[5~":return xn(t,"pageup",false);case "\x1B[6~":return xn(t,"pagedown",false);case "\x1B[1;5D":return xn(t,"left",true);case "\x1B[1;5C":return xn(t,"right",true)}return n}a(kl,"parseKeypress");function xn(t,e,n){return {kind:"key",name:e,ctrl:n,meta:false,shift:false,option:false,super:false,fn:false,sequence:t,raw:t,isPasted:false}}a(xn,"createNavKey");function Zy(t){let e={upArrow:t.name==="up",downArrow:t.name==="down",leftArrow:t.name==="left",rightArrow:t.name==="right",pageDown:t.name==="pagedown",pageUp:t.name==="pageup",wheelUp:t.name==="wheelup",wheelDown:t.name==="wheeldown",home:t.name==="home",end:t.name==="end",return:t.name==="return",escape:t.name==="escape",fn:t.fn,ctrl:t.ctrl,shift:t.shift,tab:t.name==="tab",backspace:t.name==="backspace",delete:t.name==="delete",meta:t.meta||t.name==="escape"||t.option,super:t.super},n=t.ctrl?t.name:t.sequence;n===void 0&&(n=""),t.ctrl&&n==="space"&&(n=" "),t.code&&!t.name&&(n=""),!t.name&&/^\[<\d+;\d+;\d+[Mm]/.test(n)&&(n=""),n.startsWith("\x1B")&&(n=n.slice(1));let r=false;return /^\[\d/.test(n)&&n.endsWith("u")&&(t.name?n=t.name==="space"?" ":t.name==="escape"?"":t.name:n="",r=true),n.startsWith("[27;")&&n.endsWith("~")&&(t.name?n=t.name==="space"?" ":t.name==="escape"?"":t.name:n="",r=true),n.startsWith("O")&&n.length===2&&t.name&&t.name.length===1&&(n=t.name,r=true),!r&&t.name&&cf.includes(t.name)&&(n=""),n.length===1&&typeof n[0]=="string"&&n[0]>="A"&&n[0]<="Z"&&(e.shift=true),[e,n]}a(Zy,"parseKey");var Ns=class extends bn{static{a(this,"InputEvent");}keypress;key;input;constructor(e){super();let[n,r]=Zy(e);this.keypress=e,this.key=n,this.input=r;}};h();var ki=class extends bn{static{a(this,"TerminalFocusEvent");}type;constructor(e){super(),this.type=e;}};h();h();h();h();h();var ye={All:"all",Horizontal:"horizontal",Vertical:"vertical",Left:"left",Right:"right",Top:"top",Bottom:"bottom",Start:"start",End:"end"},Os={All:"all",Column:"column",Row:"row"},ln={Flex:"flex",None:"none"},_i={Row:"row",RowReverse:"row-reverse",Column:"column",ColumnReverse:"column-reverse"},fr={Auto:"auto",Stretch:"stretch",FlexStart:"flex-start",Center:"center",FlexEnd:"flex-end"},zr={FlexStart:"flex-start",Center:"center",FlexEnd:"flex-end",SpaceBetween:"space-between",SpaceAround:"space-around",SpaceEvenly:"space-evenly"},Ps={NoWrap:"nowrap",Wrap:"wrap",WrapReverse:"wrap-reverse"},_l={Relative:"relative",Absolute:"absolute"},Ds={Visible:"visible",Hidden:"hidden",Scroll:"scroll"},To={Undefined:"undefined",Exactly:"exactly",AtMost:"at-most"};var Jr={all:Ue.All,horizontal:Ue.Horizontal,vertical:Ue.Vertical,left:Ue.Left,right:Ue.Right,top:Ue.Top,bottom:Ue.Bottom,start:Ue.Start,end:Ue.End},eb={all:Yn.All,column:Yn.Column,row:Yn.Row},Rl=class t{static{a(this,"YogaLayoutNode");}yoga;constructor(e){this.yoga=e;}insertChild(e,n){this.yoga.insertChild(e.yoga,n);}removeChild(e){this.yoga.removeChild(e.yoga);}getChildCount(){return this.yoga.getChildCount()}getParent(){let e=this.yoga.getParent();return e?new t(e):null}calculateLayout(e,n){this.yoga.calculateLayout(e,void 0,Ts.LTR);}setMeasureFunc(e){this.yoga.setMeasureFunc((n,r)=>{let o=r===de.Exactly?To.Exactly:r===de.AtMost?To.AtMost:To.Undefined;return e(n,o)});}unsetMeasureFunc(){this.yoga.unsetMeasureFunc();}markDirty(){this.yoga.markDirty();}getComputedLeft(){return this.yoga.getComputedLeft()}getComputedTop(){return this.yoga.getComputedTop()}getComputedWidth(){return this.yoga.getComputedWidth()}getComputedHeight(){return this.yoga.getComputedHeight()}getComputedBorder(e){return this.yoga.getComputedBorder(Jr[e])}getComputedPadding(e){return this.yoga.getComputedPadding(Jr[e])}setWidth(e){this.yoga.setWidth(e);}setWidthPercent(e){this.yoga.setWidthPercent(e);}setWidthAuto(){this.yoga.setWidthAuto();}setHeight(e){this.yoga.setHeight(e);}setHeightPercent(e){this.yoga.setHeightPercent(e);}setHeightAuto(){this.yoga.setHeightAuto();}setMinWidth(e){this.yoga.setMinWidth(e);}setMinWidthPercent(e){this.yoga.setMinWidthPercent(e);}setMinHeight(e){this.yoga.setMinHeight(e);}setMinHeightPercent(e){this.yoga.setMinHeightPercent(e);}setMaxWidth(e){this.yoga.setMaxWidth(e);}setMaxWidthPercent(e){this.yoga.setMaxWidthPercent(e);}setMaxHeight(e){this.yoga.setMaxHeight(e);}setMaxHeightPercent(e){this.yoga.setMaxHeightPercent(e);}setFlexDirection(e){let n={row:ut.Row,"row-reverse":ut.RowReverse,column:ut.Column,"column-reverse":ut.ColumnReverse};this.yoga.setFlexDirection(n[e]);}setFlexGrow(e){this.yoga.setFlexGrow(e);}setFlexShrink(e){this.yoga.setFlexShrink(e);}setFlexBasis(e){this.yoga.setFlexBasis(e);}setFlexBasisPercent(e){this.yoga.setFlexBasisPercent(e);}setFlexWrap(e){let n={nowrap:ar.NoWrap,wrap:ar.Wrap,"wrap-reverse":ar.WrapReverse};this.yoga.setFlexWrap(n[e]);}setAlignItems(e){let n={auto:ue.Auto,stretch:ue.Stretch,"flex-start":ue.FlexStart,center:ue.Center,"flex-end":ue.FlexEnd};this.yoga.setAlignItems(n[e]);}setAlignSelf(e){let n={auto:ue.Auto,stretch:ue.Stretch,"flex-start":ue.FlexStart,center:ue.Center,"flex-end":ue.FlexEnd};this.yoga.setAlignSelf(n[e]);}setJustifyContent(e){let n={"flex-start":At.FlexStart,center:At.Center,"flex-end":At.FlexEnd,"space-between":At.SpaceBetween,"space-around":At.SpaceAround,"space-evenly":At.SpaceEvenly};this.yoga.setJustifyContent(n[e]);}setDisplay(e){this.yoga.setDisplay(e==="flex"?sr.Flex:sr.None);}getDisplay(){return this.yoga.getDisplay()===sr.None?ln.None:ln.Flex}setPositionType(e){this.yoga.setPositionType(e==="absolute"?Kr.Absolute:Kr.Relative);}setPosition(e,n){this.yoga.setPosition(Jr[e],n);}setPositionPercent(e,n){this.yoga.setPositionPercent(Jr[e],n);}setOverflow(e){let n={visible:jr.Visible,hidden:jr.Hidden,scroll:jr.Scroll};this.yoga.setOverflow(n[e]);}setMargin(e,n){this.yoga.setMargin(Jr[e],n);}setPadding(e,n){this.yoga.setPadding(Jr[e],n);}setBorder(e,n){this.yoga.setBorder(Jr[e],n);}setGap(e,n){this.yoga.setGap(eb[e],n);}free(){this.yoga.free();}freeRecursive(){this.yoga.freeRecursive();}};function uf(){return new Rl(Pd.Node.create())}a(uf,"createYogaLayoutNode");function df(){return uf()}a(df,"createLayoutNode");h();h();h();var mf=tb();function rb(t){if(typeof t!="string"||t.length===0)return 0;let e=true;for(let r=0;r<t.length;r++){let o=t.charCodeAt(r);if(o>=127||o===27){e=false;break}}if(e){let r=0;for(let o=0;o<t.length;o++)t.charCodeAt(o)>31&&r++;return r}if(t.includes("\x1B")&&(t=nb(t),t.length===0))return 0;if(!ob(t)){let r=0;for(let o of t){let i=o.codePointAt(0);pf(i)||(r+=eastAsianWidth(i,{ambiguousAsWide:false}));}return r}let n=0;for(let{segment:r}of Yr().segment(t)){if(mf.lastIndex=0,mf.test(r)){n+=ib(r);continue}for(let o of r){let i=o.codePointAt(0);if(!pf(i)){n+=eastAsianWidth(i,{ambiguousAsWide:false});break}}}return n}a(rb,"stringWidthJavaScript");function ob(t){for(let e of t){let n=e.codePointAt(0);if(n>=127744&&n<=129791||n>=9728&&n<=10175||n>=127462&&n<=127487||n>=65024&&n<=65039||n===8205)return true}return false}a(ob,"needsSegmentation");function ib(t){let e=t.codePointAt(0);if(e>=127462&&e<=127487){let n=0;for(let r of t)n++;return n===1?1:2}return t.length===2&&t.codePointAt(1)===65039&&(e>=48&&e<=57||e===35||e===42)?1:2}a(ib,"getEmojiWidth");function pf(t){if(t>=32&&t<127)return false;if(t>=160&&t<768)return t===173;if(t<=31||t>=127&&t<=159||t>=8203&&t<=8205||t===65279||t>=8288&&t<=8292||t>=65024&&t<=65039||t>=917760&&t<=917999||t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071)return true;if(t>=2304&&t<=3407){let e=t&127;if(e<=3||e>=58&&e<=79||e>=81&&e<=87||e>=98&&e<=99)return true}return t===3633||t>=3636&&t<=3642||t>=3655&&t<=3662||t===3761||t>=3764&&t<=3772||t>=3784&&t<=3789||t>=1536&&t<=1541||t===1757||t===1807||t===2274||t>=55296&&t<=57343||t>=917504&&t<=917631}a(pf,"isZeroWidth");var gf=typeof Bun<"u"&&typeof Bun.stringWidth=="function"?Bun.stringWidth:null,sb={ambiguousIsNarrow:true},Ht=gf?t=>gf(t,sb):rb;var Is=new Map,ab=4096;function Ls(t){let e=Is.get(t);if(e!==void 0)return e;let n=Ht(t);return Is.size>=ab&&Is.clear(),Is.set(t,n),n}a(Ls,"lineWidth");function lb(t,e){if(t.length===0)return {width:0,height:0};let n=e<=0||!Number.isFinite(e),r=0,o=0,i=0;for(;i<=t.length;){let s=t.indexOf(`
22
- `,i),l=s===-1?t.substring(i):t.substring(i,s),c=Ls(l);if(o=Math.max(o,c),n?r++:r+=c===0?1:Math.ceil(c/e),s===-1)break;i=s+1;}return {width:o,height:r}}a(lb,"measureText");var Bs=lb;h();var dt=new WeakMap,Ri=new WeakMap,Ml=false;function hf(t,e,n){let r=Ri.get(t);r?r.push(e):Ri.set(t,[e]),n&&(Ml=true);}a(hf,"addPendingClear");function yf(){let t=Ml;return Ml=false,t}a(yf,"consumeAbsoluteRemovedFlag");h();function Fs(t,e={},n,r=[]){let o=t.textStyles?{...e,...t.textStyles}:e;for(let i of t.childNodes)if(i!==void 0){if(i.nodeName==="#text")i.nodeValue.length>0&&r.push({text:i.nodeValue,styles:o,hyperlink:n});else if(i.nodeName==="ink-text"||i.nodeName==="ink-virtual-text")Fs(i,o,n,r);else if(i.nodeName==="ink-link"){let s=i.attributes.href;Fs(i,o,s||n,r);}}return r}a(Fs,"squashTextNodesToSegments");function Al(t){let e="";for(let n of t.childNodes)n!==void 0&&(n.nodeName==="#text"?e+=n.nodeValue:(n.nodeName==="ink-text"||n.nodeName==="ink-virtual-text"||n.nodeName==="ink-link")&&(e+=Al(n)));return e}a(Al,"squashTextNodes");var bf=Al;h();var cb=8;function xf(t,e=cb){if(!t.includes(" "))return t;let n=vo(),r=n.feed(t);r.push(...n.flush());let o="",i=0;for(let s of r)if(s.type==="sequence")o+=s.value;else {let l=s.value.split(/(\t|\n)/);for(let c of l)if(c===" "){let d=e-i%e;o+=" ".repeat(d),i+=d;}else c===`
23
- `?(o+=c,i=0):(o+=c,i+=Ht(c));}return o}a(xf,"expandTabs");h();h();var Sf=/\x1b\[[0-9;]*m/g;function Xr(t,e,n){if(!t.includes("\x1B"))return t.slice(e,n);let r=[],o=0;for(;o<t.length;){Sf.lastIndex=o;let d=Sf.exec(t);d&&d.index===o?(r.push({ch:d[0],visible:false}),o+=d[0].length):(r.push({ch:t[o],visible:true}),o++);}let i=n??nb(t).length,s=0,l="",c="";for(let{ch:d,visible:f}of r){if(!f){s>=e&&s<i?l+=d:c+=d;continue}if(s>=e&&s<i&&(c&&(l+=c,c=""),l+=d),s++,s>=i)break}return l}a(Xr,"sliceAnsi");h();var fb=typeof Bun<"u"&&typeof Bun.wrapAnsi=="function"?Bun.wrapAnsi:null,Nl=fb??db;var $s="\u2026";function Hs(t,e,n){let r=Xr(t,e,n);return Ht(r)>n-e?Xr(t,e,n-1):r}a(Hs,"sliceFit");function mb(t,e,n){if(e<1)return "";if(e===1)return $s;let r=Ht(t);if(r<=e)return t;if(n==="start")return $s+Hs(t,r-e+1,r);if(n==="middle"){let o=Math.floor(e/2);return Hs(t,0,o)+$s+Hs(t,r-(e-o)+1,r)}return Hs(t,0,e-1)+$s}a(mb,"truncate");function Eo(t,e,n){if(n==="wrap")return Nl(t,e,{trim:false,hard:true});if(n==="wrap-trim")return Nl(t,e,{trim:true,hard:true});if(n.startsWith("truncate")){let r="end";return n==="truncate-middle"&&(r="middle"),n==="truncate-start"&&(r="start"),mb(t,e,r)}return t}a(Eo,"wrapText");var Co=a(t=>{let n={nodeName:t,style:{},attributes:{},childNodes:[],parentNode:void 0,yogaNode:t!=="ink-virtual-text"&&t!=="ink-link"&&t!=="ink-progress"&&t!=="ink-static"?df():void 0,dirty:false};return t==="ink-text"?n.yogaNode?.setMeasureFunc(gb.bind(null,n)):t==="ink-raw-ansi"&&n.yogaNode?.setMeasureFunc(hb.bind(null,n)),n},"createNode"),Ws=a((t,e)=>{e.parentNode&&Qr(e.parentNode,e),e.parentNode=t,t.childNodes.push(e),e.yogaNode&&t.yogaNode?.insertChild(e.yogaNode,t.yogaNode.getChildCount()),Ct(t);},"appendChildNode"),Ol=a((t,e,n)=>{e.parentNode&&Qr(e.parentNode,e),e.parentNode=t;let r=t.childNodes.indexOf(n);if(r>=0){let o=0;if(e.yogaNode&&t.yogaNode)for(let i=0;i<r;i++)t.childNodes[i]?.yogaNode&&o++;t.childNodes.splice(r,0,e),e.yogaNode&&t.yogaNode&&t.yogaNode.insertChild(e.yogaNode,o),Ct(t);return}t.childNodes.push(e),e.yogaNode&&t.yogaNode?.insertChild(e.yogaNode,t.yogaNode.getChildCount()),Ct(t);},"insertBeforeNode"),Qr=a((t,e)=>{e.yogaNode&&e.parentNode?.yogaNode?.removeChild(e.yogaNode),wf(t,e),e.parentNode=void 0;let n=t.childNodes.indexOf(e);n>=0&&t.childNodes.splice(n,1),Ct(t);},"removeChildNode");function wf(t,e,n=false){if(e.nodeName==="#text")return;let r=e,o=n||r.style.position==="absolute",i=dt.get(r);i&&(hf(t,i,o),dt.delete(r));for(let s of r.childNodes)wf(t,s,o);}a(wf,"collectRemovedRects");var Pl=a((t,e,n)=>{e!=="children"&&t.attributes[e]!==n&&(t.attributes[e]=n,Ct(t));},"setAttribute"),Dl=a((t,e)=>{pb(t.style,e)||(t.style=e,Ct(t));},"setStyle"),vf=a((t,e)=>{Tf(t.textStyles,e)||(t.textStyles=e,Ct(t));},"setTextStyles");function pb(t,e){return Tf(t,e)}a(pb,"stylesEqual");function Tf(t,e){if(t===e)return true;if(t===void 0||e===void 0)return false;let n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return false;for(let o of n)if(t[o]!==e[o])return false;return true}a(Tf,"shallowEqual");var Ef=a(t=>{let e={nodeName:"#text",nodeValue:t,yogaNode:void 0,parentNode:void 0,style:{}};return Mi(e,t),e},"createTextNode"),gb=a(function(t,e,n){let r=t.nodeName==="#text"?t.nodeValue:bf(t),o=xf(r),i=Bs(o,e);if(i.width<=e||i.width>=1&&e>0&&e<1)return i;if(o.includes(`
24
- `)&&n===To.Undefined){let c=Math.max(e,i.width);return Bs(o,c)}let s=t.style?.textWrap??"wrap",l=Eo(o,e,s);return Bs(l,e)},"measureTextNode"),hb=a(function(t){return {width:t.attributes.rawWidth,height:t.attributes.rawHeight}},"measureRawAnsiNode"),Ct=a(t=>{let e=t,n=false;for(;e;)e.nodeName!=="#text"&&(e.dirty=true,!n&&(e.nodeName==="ink-text"||e.nodeName==="ink-raw-ansi")&&e.yogaNode&&(e.yogaNode.markDirty(),n=true)),e=e.parentNode;},"markDirty"),Cf=a(t=>{let e=t;for(;e?.parentNode;)e=e.parentNode;e&&e.nodeName!=="#text"&&e.onRender?.();},"scheduleRenderFrom"),Mi=a((t,e)=>{typeof e!="string"&&(e=String(e)),t.nodeValue!==e&&(t.nodeValue=e,Ct(t));},"setTextNodeValue");function yb(t){return t.nodeName!=="#text"}a(yb,"isDOMElement");var Il=a(t=>{if("childNodes"in t)for(let e of t.childNodes)Il(e);t.yogaNode=void 0;},"clearYogaNodeReferences");function kf(t,e){let n=[];return r(t,0),n;function r(o,i){let s=o.yogaNode;if(!s||s.getDisplay()===ln.None)return;let l=i+s.getComputedTop(),c=s.getComputedHeight();if(!(e<l||e>=l+c)){o.debugOwnerChain&&(n=o.debugOwnerChain);for(let d of o.childNodes)yb(d)&&r(d,l);}}}a(kf,"findOwnerChainAtRow");h();h();var _f={keydown:{bubble:"onKeyDown",capture:"onKeyDownCapture"},focus:{bubble:"onFocus",capture:"onFocusCapture"},blur:{bubble:"onBlur",capture:"onBlurCapture"},paste:{bubble:"onPaste",capture:"onPasteCapture"},resize:{bubble:"onResize"},click:{bubble:"onClick"}},Ll=new Set(["onKeyDown","onKeyDownCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onPaste","onPasteCapture","onResize","onClick","onMouseEnter","onMouseLeave"]);function Rf(t,e,n){let r=t._eventHandlers;if(!r)return;let o=_f[e];if(!o)return;let i=n?o.capture:o.bubble;if(i)return r[i]}a(Rf,"getHandler");function wb(t,e){let n=[],r=t;for(;r;){let o=r===t,i=Rf(r,e.type,true),s=Rf(r,e.type,false);i&&n.unshift({node:r,handler:i,phase:o?"at_target":"capturing"}),s&&(e.bubbles||o)&&n.push({node:r,handler:s,phase:o?"at_target":"bubbling"}),r=r.parentNode;}return n}a(wb,"collectListeners");function vb(t,e){let n;for(let{node:r,handler:o,phase:i}of t){if(e._isImmediatePropagationStopped()||e._isPropagationStopped()&&r!==n)break;e._setEventPhase(i),e._setCurrentTarget(r),e._prepareForTarget(r);try{o(e);}catch(s){d.error(s);}n=r;}}a(vb,"processDispatchQueue");function Tb(t){switch(t){case "keydown":case "keyup":case "click":case "focus":case "blur":case "paste":return DiscreteEventPriority;case "resize":case "scroll":case "mousemove":return ContinuousEventPriority;default:return DefaultEventPriority}}a(Tb,"getEventPriority");var Us=class{static{a(this,"Dispatcher");}currentEvent=null;currentUpdatePriority=DefaultEventPriority;discreteUpdates=null;resolveEventPriority(){return this.currentUpdatePriority!==NoEventPriority?this.currentUpdatePriority:this.currentEvent?Tb(this.currentEvent.type):DefaultEventPriority}dispatch(e,n){let r=this.currentEvent;this.currentEvent=n;try{n._setTarget(e);let o=wb(e,n);return vb(o,n),n._setEventPhase("none"),n._setCurrentTarget(null),!n.defaultPrevented}finally{this.currentEvent=r;}}dispatchDiscrete(e,n){return this.discreteUpdates?this.discreteUpdates((r,o)=>this.dispatch(r,o),e,n,void 0,void 0):this.dispatch(e,n)}dispatchContinuous(e,n){let r=this.currentUpdatePriority;try{return this.currentUpdatePriority=ContinuousEventPriority,this.dispatch(e,n)}finally{this.currentUpdatePriority=r;}}};h();h();h();var ko=class extends bn{static{a(this,"TerminalEvent");}type;timeStamp;bubbles;cancelable;_target=null;_currentTarget=null;_eventPhase="none";_propagationStopped=false;_defaultPrevented=false;constructor(e,n){super(),this.type=e,this.timeStamp=performance.now(),this.bubbles=n?.bubbles??true,this.cancelable=n?.cancelable??true;}get target(){return this._target}get currentTarget(){return this._currentTarget}get eventPhase(){return this._eventPhase}get defaultPrevented(){return this._defaultPrevented}stopPropagation(){this._propagationStopped=true;}stopImmediatePropagation(){super.stopImmediatePropagation(),this._propagationStopped=true;}preventDefault(){this.cancelable&&(this._defaultPrevented=true);}_setTarget(e){this._target=e;}_setCurrentTarget(e){this._currentTarget=e;}_setEventPhase(e){this._eventPhase=e;}_isPropagationStopped(){return this._propagationStopped}_isImmediatePropagationStopped(){return this.didStopImmediatePropagation()}_prepareForTarget(e){}};var Nr=class extends ko{static{a(this,"FocusEvent");}relatedTarget;constructor(e,n=null){super(e,{bubbles:true,cancelable:false}),this.relatedTarget=n;}};var Eb=32,_o=class{static{a(this,"FocusManager");}activeElement=null;dispatchFocusEvent;enabled=true;focusStack=[];constructor(e){this.dispatchFocusEvent=e;}focus(e){if(e===this.activeElement||!this.enabled)return;let n=this.activeElement;if(n){let r=this.focusStack.indexOf(n);r!==-1&&this.focusStack.splice(r,1),this.focusStack.push(n),this.focusStack.length>Eb&&this.focusStack.shift(),this.dispatchFocusEvent(n,new Nr("blur",e));}this.activeElement=e,this.dispatchFocusEvent(e,new Nr("focus",n));}blur(){if(!this.activeElement)return;let e=this.activeElement;this.activeElement=null,this.dispatchFocusEvent(e,new Nr("blur",null));}handleNodeRemoved(e,n){if(this.focusStack=this.focusStack.filter(o=>o!==e&&Fl(o,n)),!this.activeElement||this.activeElement!==e&&Fl(this.activeElement,n))return;let r=this.activeElement;for(this.activeElement=null,this.dispatchFocusEvent(r,new Nr("blur",null));this.focusStack.length>0;){let o=this.focusStack.pop();if(Fl(o,n)){this.activeElement=o,this.dispatchFocusEvent(o,new Nr("focus",r));return}}}handleAutoFocus(e){this.focus(e);}handleClickFocus(e){typeof e.attributes.tabIndex=="number"&&this.focus(e);}enable(){this.enabled=true;}disable(){this.enabled=false;}focusNext(e){this.moveFocus(1,e);}focusPrevious(e){this.moveFocus(-1,e);}moveFocus(e,n){if(!this.enabled)return;let r=Cb(n);if(r.length===0)return;let o=this.activeElement?r.indexOf(this.activeElement):-1,i=o===-1?e===1?0:r.length-1:(o+e+r.length)%r.length,s=r[i];s&&this.focus(s);}};function Cb(t){let e=[];return Af(t,e),e}a(Cb,"collectTabbable");function Af(t,e){let n=t.attributes.tabIndex;typeof n=="number"&&n>=0&&e.push(t);for(let r of t.childNodes)r.nodeName!=="#text"&&Af(r,e);}a(Af,"walkTree");function Fl(t,e){let n=t;for(;n;){if(n===e)return true;n=n.parentNode;}return false}a(Fl,"isInTree");function $l(t){let e=t;for(;e;){if(e.focusManager)return e;e=e.parentNode;}throw new Error("Node is not in a tree with a FocusManager")}a($l,"getRootNode");function Hl(t){return $l(t).focusManager}a(Hl,"getFocusManager");h();var kb=a((t,e)=>{"position"in e&&t.setPositionType(e.position==="absolute"?_l.Absolute:_l.Relative),"top"in e&&Gs(t,"top",e.top),"bottom"in e&&Gs(t,"bottom",e.bottom),"left"in e&&Gs(t,"left",e.left),"right"in e&&Gs(t,"right",e.right);},"applyPositionStyles");function Gs(t,e,n){typeof n=="string"?t.setPositionPercent(e,Number.parseInt(n,10)):typeof n=="number"?t.setPosition(e,n):t.setPosition(e,Number.NaN);}a(Gs,"applyPositionEdge");var _b=a((t,e)=>{let n=e.overflowY??e.overflow,r=e.overflowX??e.overflow;n==="scroll"||r==="scroll"?t.setOverflow(Ds.Scroll):n==="hidden"||r==="hidden"?t.setOverflow(Ds.Hidden):("overflow"in e||"overflowX"in e||"overflowY"in e)&&t.setOverflow(Ds.Visible);},"applyOverflowStyles"),Rb=a((t,e)=>{"margin"in e&&t.setMargin(ye.All,e.margin??0),"marginX"in e&&t.setMargin(ye.Horizontal,e.marginX??0),"marginY"in e&&t.setMargin(ye.Vertical,e.marginY??0),"marginLeft"in e&&t.setMargin(ye.Start,e.marginLeft||0),"marginRight"in e&&t.setMargin(ye.End,e.marginRight||0),"marginTop"in e&&t.setMargin(ye.Top,e.marginTop||0),"marginBottom"in e&&t.setMargin(ye.Bottom,e.marginBottom||0);},"applyMarginStyles"),Mb=a((t,e)=>{"padding"in e&&t.setPadding(ye.All,e.padding??0),"paddingX"in e&&t.setPadding(ye.Horizontal,e.paddingX??0),"paddingY"in e&&t.setPadding(ye.Vertical,e.paddingY??0),"paddingLeft"in e&&t.setPadding(ye.Left,e.paddingLeft||0),"paddingRight"in e&&t.setPadding(ye.Right,e.paddingRight||0),"paddingTop"in e&&t.setPadding(ye.Top,e.paddingTop||0),"paddingBottom"in e&&t.setPadding(ye.Bottom,e.paddingBottom||0);},"applyPaddingStyles"),Ab=a((t,e)=>{"flexGrow"in e&&t.setFlexGrow(e.flexGrow??0),"flexShrink"in e&&t.setFlexShrink(typeof e.flexShrink=="number"?e.flexShrink:1),"flexWrap"in e&&(e.flexWrap==="nowrap"&&t.setFlexWrap(Ps.NoWrap),e.flexWrap==="wrap"&&t.setFlexWrap(Ps.Wrap),e.flexWrap==="wrap-reverse"&&t.setFlexWrap(Ps.WrapReverse)),"flexDirection"in e&&(e.flexDirection==="row"&&t.setFlexDirection(_i.Row),e.flexDirection==="row-reverse"&&t.setFlexDirection(_i.RowReverse),e.flexDirection==="column"&&t.setFlexDirection(_i.Column),e.flexDirection==="column-reverse"&&t.setFlexDirection(_i.ColumnReverse)),"flexBasis"in e&&(typeof e.flexBasis=="number"?t.setFlexBasis(e.flexBasis):typeof e.flexBasis=="string"?t.setFlexBasisPercent(Number.parseInt(e.flexBasis,10)):t.setFlexBasis(Number.NaN)),"alignItems"in e&&((e.alignItems==="stretch"||!e.alignItems)&&t.setAlignItems(fr.Stretch),e.alignItems==="flex-start"&&t.setAlignItems(fr.FlexStart),e.alignItems==="center"&&t.setAlignItems(fr.Center),e.alignItems==="flex-end"&&t.setAlignItems(fr.FlexEnd)),"alignSelf"in e&&((e.alignSelf==="auto"||!e.alignSelf)&&t.setAlignSelf(fr.Auto),e.alignSelf==="flex-start"&&t.setAlignSelf(fr.FlexStart),e.alignSelf==="center"&&t.setAlignSelf(fr.Center),e.alignSelf==="flex-end"&&t.setAlignSelf(fr.FlexEnd)),"justifyContent"in e&&((e.justifyContent==="flex-start"||!e.justifyContent)&&t.setJustifyContent(zr.FlexStart),e.justifyContent==="center"&&t.setJustifyContent(zr.Center),e.justifyContent==="flex-end"&&t.setJustifyContent(zr.FlexEnd),e.justifyContent==="space-between"&&t.setJustifyContent(zr.SpaceBetween),e.justifyContent==="space-around"&&t.setJustifyContent(zr.SpaceAround),e.justifyContent==="space-evenly"&&t.setJustifyContent(zr.SpaceEvenly));},"applyFlexStyles"),Nb=a((t,e)=>{"width"in e&&(typeof e.width=="number"?t.setWidth(e.width):typeof e.width=="string"?t.setWidthPercent(Number.parseInt(e.width,10)):t.setWidthAuto()),"height"in e&&(typeof e.height=="number"?t.setHeight(e.height):typeof e.height=="string"?t.setHeightPercent(Number.parseInt(e.height,10)):t.setHeightAuto()),"minWidth"in e&&(typeof e.minWidth=="string"?t.setMinWidthPercent(Number.parseInt(e.minWidth,10)):t.setMinWidth(e.minWidth??0)),"minHeight"in e&&(typeof e.minHeight=="string"?t.setMinHeightPercent(Number.parseInt(e.minHeight,10)):t.setMinHeight(e.minHeight??0)),"maxWidth"in e&&(typeof e.maxWidth=="string"?t.setMaxWidthPercent(Number.parseInt(e.maxWidth,10)):t.setMaxWidth(e.maxWidth??0)),"maxHeight"in e&&(typeof e.maxHeight=="string"?t.setMaxHeightPercent(Number.parseInt(e.maxHeight,10)):t.setMaxHeight(e.maxHeight??0));},"applyDimensionStyles"),Ob=a((t,e)=>{"display"in e&&t.setDisplay(e.display==="flex"?ln.Flex:ln.None);},"applyDisplayStyles"),Pb=a((t,e,n)=>{let r=n??e;if("borderStyle"in e){let o=e.borderStyle?1:0;t.setBorder(ye.Top,r.borderTop!==false?o:0),t.setBorder(ye.Bottom,r.borderBottom!==false?o:0),t.setBorder(ye.Left,r.borderLeft!==false?o:0),t.setBorder(ye.Right,r.borderRight!==false?o:0);}else "borderTop"in e&&e.borderTop!==void 0&&t.setBorder(ye.Top,e.borderTop===false?0:1),"borderBottom"in e&&e.borderBottom!==void 0&&t.setBorder(ye.Bottom,e.borderBottom===false?0:1),"borderLeft"in e&&e.borderLeft!==void 0&&t.setBorder(ye.Left,e.borderLeft===false?0:1),"borderRight"in e&&e.borderRight!==void 0&&t.setBorder(ye.Right,e.borderRight===false?0:1);},"applyBorderStyles"),Db=a((t,e)=>{"gap"in e&&t.setGap(Os.All,e.gap??0),"columnGap"in e&&t.setGap(Os.Column,e.columnGap??0),"rowGap"in e&&t.setGap(Os.Row,e.rowGap??0);},"applyGapStyles"),Ib=a((t,e={},n)=>{kb(t,e),_b(t,e),Rb(t,e),Mb(t,e),Ab(t,e),Nb(t,e),Ob(t,e),Pb(t,e,n),Db(t,e);},"styles"),Wl=Ib;if(process.env.NODE_ENV==="development")try{import('../devtools-FBX4HVVY.js');}catch(t){if(t.code==="ERR_MODULE_NOT_FOUND")console.warn(`
25
- The environment variable DEV is set to true, so Ink tried to import \`react-devtools-core\`,
26
- but this failed as it was not installed. Debugging with React Devtools requires it.
27
-
28
- To install use this command:
29
-
30
- $ npm install --save-dev react-devtools-core
31
- `.trim()+`
32
- `);else throw t}var Nf=a((t,e)=>{if(t===e)return;if(!t)return e;let n={},r=false;for(let o of Object.keys(t))(!e||!Object.hasOwn(e,o))&&(n[o]=void 0,r=true);if(e)for(let o of Object.keys(e))e[o]!==t[o]&&(n[o]=e[o],r=true);return r?n:void 0},"diff"),Of=a(t=>{let e=t.yogaNode;e&&(e.unsetMeasureFunc(),Il(t),e.freeRecursive());},"cleanupYogaNode");function Df(t,e,n){t._eventHandlers||(t._eventHandlers={}),t._eventHandlers[e]=n;}a(Df,"setEventHandler");function Bb(t,e,n){if(e!=="children"){if(e==="style"){Dl(t,n),t.yogaNode&&Wl(t.yogaNode,n);return}if(e==="textStyles"){t.textStyles=n;return}if(e==="pendingStaticElement"){t.pendingStaticElement=n;return}if(Ll.has(e)){Df(t,e,n);return}Pl(t,e,n);}}a(Bb,"applyProp");function Fb(t){let e=[],n=new Set,r=t;for(let o=0;r&&o<50&&!n.has(r);o++){n.add(r);let i=r.elementType,s=typeof i=="function"?i.displayName||i.name:typeof i=="string"?void 0:i?.displayName||i?.name;s&&s!==e[e.length-1]&&e.push(s),r=r._debugOwner??r.return;}return e}a(Fb,"getOwnerChain");var Ul;function Vl(){return Ul===void 0&&(Ul=Vr(process.env.CLAUDE_CODE_DEBUG_REPAINTS)),Ul}a(Vl,"isDebugRepaintsEnabled");var mr=new Us,Pn=process.env.CLAUDE_CODE_COMMIT_LOG,Gl=0,Pf=0,jl=0,Ks=0,Ys=0,Kl=0,ql=0,zl=0,Ai=0;function If(t){ql=t;}a(If,"recordYogaMs");function Lf(){return ql}a(Lf,"getLastYogaMs");function Bf(){Ai=performance.now();}a(Bf,"markCommitStart");function Ff(){return zl}a(Ff,"getLastCommitMs");function $f(){ql=0,zl=0,Ai=0;}a($f,"resetProfileCounters");var Yl=Lb({getRootHostContext:a(()=>({isInsideText:false}),"getRootHostContext"),prepareForCommit:a(()=>(Pn&&(Kl=performance.now()),null),"prepareForCommit"),preparePortalMount:a(()=>null,"preparePortalMount"),clearContainer:a(()=>false,"clearContainer"),resetAfterCommit(t){if(zl=Ai>0?performance.now()-Ai:0,Ai=0,Pn){let r=performance.now();Gl++;let o=jl>0?r-jl:0;o>Ks&&(Ks=o),jl=r;let i=Kl>0?r-Kl:0;(o>30||i>20||Ys>50)&&appendFileSync(Pn,`${r.toFixed(1)} gap=${o.toFixed(1)}ms reconcile=${i.toFixed(1)}ms creates=${Ys}
33
- `),Ys=0,r-Pf>1e3&&(appendFileSync(Pn,`${r.toFixed(1)} commits=${Gl}/s maxGap=${Ks.toFixed(1)}ms
34
- `),Gl=0,Ks=0,Pf=r);}let e=Pn?performance.now():0;if(typeof t.onComputeLayout=="function"&&t.onComputeLayout(),Pn){let r=performance.now()-e;if(r>20){let o=Rs();appendFileSync(Pn,`${e.toFixed(1)} SLOW_YOGA ${r.toFixed(1)}ms visited=${o.visited} measured=${o.measured} hits=${o.cacheHits} live=${o.live}
35
- `);}}if(process.env.NODE_ENV==="test"){if(t.childNodes.length===0&&t.hasRenderedContent)return;t.childNodes.length>0&&(t.hasRenderedContent=true),t.onImmediateRender?.();return}let n=Pn?performance.now():0;if(t.onRender?.(),Pn){let r=performance.now()-n;r>10&&appendFileSync(Pn,`${n.toFixed(1)} SLOW_PAINT ${r.toFixed(1)}ms
36
- `);}},getChildHostContext(t,e){let n=t.isInsideText,r=e==="ink-text"||e==="ink-virtual-text"||e==="ink-link";return n===r?t:{isInsideText:r}},shouldSetTextContent:a(()=>false,"shouldSetTextContent"),createInstance(t,e,n,r,o){if(r.isInsideText&&t==="ink-box")throw new Error("<Box> can't be nested inside <Text> component");let i=t==="ink-text"&&r.isInsideText?"ink-virtual-text":t,s=Co(i);Pn&&Ys++;for(let[l,c]of Object.entries(e))Bb(s,l,c);return Vl()&&(s.debugOwnerChain=Fb(o)),s},createTextInstance(t,e,n){if(!n.isInsideText)throw new Error(`Text string "${t}" must be rendered inside <Text> component`);return Ef(t)},resetTextContent(){},hideTextInstance(t){Mi(t,"");},unhideTextInstance(t,e){Mi(t,e);},getPublicInstance:a(t=>t,"getPublicInstance"),hideInstance(t){t.isHidden=true,t.yogaNode?.setDisplay(ln.None),Ct(t);},unhideInstance(t){t.isHidden=false,t.yogaNode?.setDisplay(ln.Flex),Ct(t);},appendInitialChild:Ws,appendChild:Ws,insertBefore:Ol,finalizeInitialChildren(t,e,n){return n.autoFocus===true},commitMount(t){Hl(t).handleAutoFocus(t);},isPrimaryRenderer:true,supportsMutation:true,supportsPersistence:false,supportsHydration:false,scheduleTimeout:setTimeout,cancelTimeout:clearTimeout,noTimeout:-1,getCurrentUpdatePriority:a(()=>mr.currentUpdatePriority,"getCurrentUpdatePriority"),beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},getInstanceFromNode:a(()=>null,"getInstanceFromNode"),prepareScopeUpdate(){},getInstanceFromScope:a(()=>null,"getInstanceFromScope"),appendChildToContainer:Ws,insertInContainerBefore:Ol,removeChildFromContainer(t,e){Qr(t,e),Of(e),Hl(t).handleNodeRemoved(e,t);},commitUpdate(t,e,n,r){let o=Nf(n,r),i=Nf(n.style,r.style);if(o)for(let[s,l]of Object.entries(o)){if(s==="style"){Dl(t,l);continue}if(s==="textStyles"){vf(t,l);continue}if(s==="pendingStaticElement"){t.pendingStaticElement=l;continue}if(Ll.has(s)){Df(t,s,l);continue}Pl(t,s,l);}i&&t.yogaNode&&Wl(t.yogaNode,i,r.style);},commitTextUpdate(t,e,n){Mi(t,n);},removeChild(t,e){if(Qr(t,e),Of(e),e.nodeName!=="#text"){let n=$l(t);n.focusManager.handleNodeRemoved(e,n);}},maySuspendCommit(){return false},preloadInstance(){return true},startSuspendingCommit(){},suspendInstance(){},waitForCommitToBeReady(){return null},NotPendingTransition:null,HostTransitionContext:{$$typeof:Symbol.for("react.context"),_currentValue:null},setCurrentUpdatePriority(t){mr.currentUpdatePriority=t;},resolveUpdatePriority(){return mr.resolveEventPriority()},resetFormInstance(){},requestPostPaintCallback(){},shouldAttemptEagerTransition(){return false},trackSchedulerEvent(){},resolveEventType(){return mr.currentEvent?.type??null},resolveEventTimeStamp(){return mr.currentEvent?.timeStamp??-1.1}});mr.discreteUpdates=Yl.discreteUpdates.bind(Yl);var Wt=Yl;h();h();function Or(t,e){let n=Math.min(t.x,e.x),r=Math.min(t.y,e.y),o=Math.max(t.x+t.width,e.x+e.width),i=Math.max(t.y+t.height,e.y+e.height);return {x:n,y:r,width:o-n,height:i-r}}a(Or,"unionRect");function Vs(t,e,n){return e!==void 0&&t<e?e:n!==void 0&&t>n?n:t}a(Vs,"clamp");h();h();function at(t,e){t!==void 0&&(Number.isInteger(t)||$e(`${e} should be an integer, got ${t}`,{level:"warn"}));}a(at,"ifNotInteger");var Zr=class{static{a(this,"CharPool");}strings=[" ",""];stringMap=new Map([[" ",0],["",1]]);ascii=Yb();intern(e){if(e.length===1){let o=e.charCodeAt(0);if(o<128){let i=this.ascii[o];if(i!==-1)return i;let s=this.strings.length;return this.strings.push(e),this.ascii[o]=s,s}}let n=this.stringMap.get(e);if(n!==void 0)return n;let r=this.strings.length;return this.strings.push(e),this.stringMap.set(e,r),r}get(e){return this.strings[e]??" "}},eo=class{static{a(this,"HyperlinkPool");}strings=[""];stringMap=new Map;intern(e){if(!e)return 0;let n=this.stringMap.get(e);return n===void 0&&(n=this.strings.length,this.strings.push(e),this.stringMap.set(e,n)),n}get(e){return e===0?void 0:this.strings[e]}},Wf={type:"ansi",code:"\x1B[7m",endCode:"\x1B[27m"},Wb={type:"ansi",code:"\x1B[1m",endCode:"\x1B[22m"},Ub={type:"ansi",code:"\x1B[4m",endCode:"\x1B[24m"},Gb={type:"ansi",code:"\x1B[33m",endCode:"\x1B[39m"},Ro=class{static{a(this,"StylePool");}ids=new Map;styles=[];transitionCache=new Map;none;constructor(){this.none=this.intern([]);}intern(e){let n=e.length===0?"":e.map(o=>o.code).join("\0"),r=this.ids.get(n);if(r===void 0){let o=this.styles.length;this.styles.push(e.length===0?[]:e),r=o<<1|(e.length>0&&Kb(e)?1:0),this.ids.set(n,r);}return r}get(e){return this.styles[e>>>1]??[]}transition(e,n){if(e===n)return "";let r=e*1048576+n,o=this.transitionCache.get(r);return o===void 0&&(o=ansiCodesToString(diffAnsiCodes(this.get(e),this.get(n))),this.transitionCache.set(r,o)),o}inverseCache=new Map;withInverse(e){let n=this.inverseCache.get(e);if(n===void 0){let r=this.get(e);n=r.some(i=>i.endCode==="\x1B[27m")?e:this.intern([...r,Wf]),this.inverseCache.set(e,n);}return n}currentMatchCache=new Map;withCurrentMatch(e){let n=this.currentMatchCache.get(e);if(n===void 0){let r=this.get(e),o=r.filter(i=>i.endCode!=="\x1B[39m"&&i.endCode!=="\x1B[49m");o.push(Gb),r.some(i=>i.endCode==="\x1B[27m")||o.push(Wf),r.some(i=>i.endCode==="\x1B[22m")||o.push(Wb),r.some(i=>i.endCode==="\x1B[24m")||o.push(Ub),n=this.intern(o),this.currentMatchCache.set(e,n);}return n}selectionBgCode=null;selectionBgCache=new Map;setSelectionBg(e){this.selectionBgCode?.code!==e?.code&&(this.selectionBgCode=e,this.selectionBgCache.clear());}withSelectionBg(e){let n=this.selectionBgCode;if(n===null)return this.withInverse(e);let r=this.selectionBgCache.get(e);if(r===void 0){let o=this.get(e).filter(i=>i.endCode!=="\x1B[49m"&&i.endCode!=="\x1B[27m");o.push(n),r=this.intern(o),this.selectionBgCache.set(e,r);}return r}},jb=new Set(["\x1B[49m","\x1B[27m","\x1B[24m","\x1B[29m","\x1B[55m"]);function Kb(t){for(let e of t)if(jb.has(e.endCode))return true;return false}a(Kb,"hasVisibleSpaceEffect");var qs=0,Uf=1;function Yb(){let t=new Int32Array(128);return t.fill(-1),t[32]=qs,t}a(Yb,"initCharAscii");var Mo=17,Ao=2,Ni=32767,Dn=3;function Pr(t,e,n){return t<<Mo|e<<Ao|n}a(Pr,"packWord1");var zs=0n;function Vb(t,e){let n=e<<1;return t.cells[n]===0&&t.cells[n|1]===0}a(Vb,"isEmptyCellByIndex");function Js(t,e,n){return e<0||n<0||e>=t.width||n>=t.height?true:Vb(t,n*t.width+e)}a(Js,"isEmptyCellAt");function qb(t,e){return t.hyperlinkPool.intern(e)}a(qb,"internHyperlink");function zn(t,e,n,r,o){at(t,"createScreen width"),at(e,"createScreen height"),(!Number.isInteger(t)||t<0)&&(t=Math.max(0,Math.floor(t)||0)),(!Number.isInteger(e)||e<0)&&(e=Math.max(0,Math.floor(e)||0));let i=t*e,s=new ArrayBuffer(i<<3),l=new Int32Array(s),c=new BigInt64Array(s);return {width:t,height:e,cells:l,cells64:c,charPool:r,hyperlinkPool:o,emptyStyleId:n.none,damage:void 0,noSelect:new Uint8Array(i),softWrap:new Int32Array(e)}}a(zn,"createScreen");function Jl(t,e,n){at(e,"resetScreen width"),at(n,"resetScreen height"),(!Number.isInteger(e)||e<0)&&(e=Math.max(0,Math.floor(e)||0)),(!Number.isInteger(n)||n<0)&&(n=Math.max(0,Math.floor(n)||0));let r=e*n;if(t.cells64.length<r){let o=new ArrayBuffer(r<<3);t.cells=new Int32Array(o),t.cells64=new BigInt64Array(o),t.noSelect=new Uint8Array(r);}t.softWrap.length<n&&(t.softWrap=new Int32Array(n)),t.cells64.fill(zs,0,r),t.noSelect.fill(0,0,r),t.softWrap.fill(0,0,n),t.width=e,t.height=n,t.damage=void 0;}a(Jl,"resetScreen");function Gf(t,e,n){let r=t.charPool,o=t.hyperlinkPool;if(r===e&&o===n)return;let i=t.width*t.height,s=t.cells;for(let l=0;l<i<<1;l+=2){let c=s[l];s[l]=e.intern(r.get(c));let d=s[l+1],f=d>>>Ao&Ni;if(f!==0){let m=o.get(f),g=n.intern(m),y=d>>>Mo,w=d&Dn;s[l+1]=Pr(y,g,w);}}t.charPool=e,t.hyperlinkPool=n;}a(Gf,"migrateScreenPools");function vt(t,e,n){if(!(e<0||n<0||e>=t.width||n>=t.height))return pr(t,n*t.width+e)}a(vt,"cellAt");function pr(t,e){let n=e<<1,r=t.cells[n+1],o=r>>>Ao&Ni;return {char:t.charPool.get(t.cells[n]),styleId:r>>>Mo,width:r&Dn,hyperlink:o===0?void 0:t.hyperlinkPool.get(o)}}a(pr,"cellAtIndex");function jf(t,e,n,r,o){let i=r<<1,s=t[i];if(s===1)return;let l=t[i+1];if(s===0&&(l&262140)===0){let d=l>>>Mo;if(d===0||d===o)return}let c=l>>>Ao&Ni;return {char:e.get(s),styleId:l>>>Mo,width:l&Dn,hyperlink:c===0?void 0:n.get(c)}}a(jf,"visibleCellAtIndex");function Dr(t,e,n){let r=e|1,o=t.cells[r];n.char=t.charPool.get(t.cells[e]),n.styleId=o>>>Mo,n.width=o&Dn;let i=o>>>Ao&Ni;n.hyperlink=i===0?void 0:t.hyperlinkPool.get(i);}a(Dr,"cellAtCI");function Kf(t,e,n){if(e<0||n<0||e>=t.width||n>=t.height)return;let r=n*t.width+e<<1;return t.charPool.get(t.cells[r])}a(Kf,"charInCellAt");function Xs(t,e,n,r){if(e<0||n<0||e>=t.width||n>=t.height)return;let o=n*t.width+e<<1,i=t.cells,s=i[o+1]&Dn;if(s===1&&r.width!==1&&e+1<t.width){let m=o+2;(i[m+1]&Dn)===2&&(i[m]=qs,i[m+1]=Pr(t.emptyStyleId,0,0));}let l=-1;if(s===2&&r.width!==2&&e>0){let f=o-2;(i[f+1]&Dn)===1&&(i[f]=qs,i[f+1]=Pr(t.emptyStyleId,0,0),l=e-1);}i[o]=zb(t,r.char),i[o+1]=Pr(r.styleId,qb(t,r.hyperlink),r.width);let c=l>=0?Math.min(e,l):e,d=t.damage;if(d){let f=d.x+d.width,m=d.y+d.height;c<d.x?(d.width+=d.x-c,d.x=c):e>=f&&(d.width=e-d.x+1),n<d.y?(d.height+=d.y-n,d.y=n):n>=m&&(d.height=n-d.y+1);}else t.damage={x:c,y:n,width:e-c+1,height:1};if(r.width===1){let f=e+1;if(f<t.width){let m=o+2;if((i[m+1]&Dn)===1){let y=m+2;f+1<t.width&&(i[y+1]&Dn)===2&&(i[y]=qs,i[y+1]=Pr(t.emptyStyleId,0,0));}i[m]=Uf,i[m+1]=Pr(t.emptyStyleId,0,2);let g=t.damage;g&&f>=g.x+g.width&&(g.width=f-g.x+1);}}}a(Xs,"setCellAt");function No(t,e,n,r){if(e<0||n<0||e>=t.width||n>=t.height)return;let o=n*t.width+e<<1,i=t.cells,s=i[o+1],l=s&Dn;if(l===2||l===3)return;let c=s>>>Ao&Ni;i[o+1]=Pr(r,c,l);let d=t.damage;d?t.damage=Or(d,{x:e,y:n,width:1,height:1}):t.damage={x:e,y:n,width:1,height:1};}a(No,"setCellStyleId");function zb(t,e){return t.charPool.intern(e)}a(zb,"internCharString");function Xl(t,e,n,r,o,i){if(n=Math.max(0,n),r=Math.max(0,r),n>=o||r>=i)return;let s=o-n,l=e.width<<1,c=t.width<<1,d=s<<1,f=e.cells,m=t.cells,g=e.noSelect,y=t.noSelect;if(t.softWrap.set(e.softWrap.subarray(r,i),r),n===0&&o===e.width&&e.width===t.width){let x=r*l,v=(i-r)*l;m.set(f.subarray(x,x+v),x);let b=r*e.width,h=(i-r)*e.width;y.set(g.subarray(b,b+h),b);}else {let x=r*l+(n<<1),v=r*c+(n<<1),b=r*e.width+n,h=r*t.width+n;for(let T=r;T<i;T++)m.set(f.subarray(x,x+d),v),y.set(g.subarray(b,b+s),h),x+=l,v+=c,b+=e.width,h+=t.width;}let w={x:n,y:r,width:s,height:i-r};if(t.damage?t.damage=Or(t.damage,w):t.damage=w,o<t.width){let x=r*e.width+(o-1)<<1,v=r*t.width+o<<1,b=false;for(let h=r;h<i;h++)(f[x+1]&Dn)===1&&(m[v]=Uf,m[v+1]=Pr(t.emptyStyleId,0,2),b=true),x+=l,v+=c;b&&t.damage&&t.damage.x+t.damage.width===o&&(t.damage={...t.damage,width:t.damage.width+1});}}a(Xl,"blitRegion");function Qs(t,e,n,r){if(r===0||e<0||n>=t.height||e>n)return;let o=t.width,i=t.cells64,s=t.noSelect,l=t.softWrap;if(Math.abs(r)>n-e){i.fill(zs,e*o,(n+1)*o),s.fill(0,e*o,(n+1)*o),l.fill(0,e,n+1);return}r>0?(i.copyWithin(e*o,(e+r)*o,(n+1)*o),s.copyWithin(e*o,(e+r)*o,(n+1)*o),l.copyWithin(e,e+r,n+1),i.fill(zs,(n-r+1)*o,(n+1)*o),s.fill(0,(n-r+1)*o,(n+1)*o),l.fill(0,n-r+1,n+1)):(i.copyWithin((e-r)*o,e*o,(n+r+1)*o),s.copyWithin((e-r)*o,e*o,(n+r+1)*o),l.copyWithin(e-r,e,n+r+1),i.fill(zs,e*o,(e-r)*o),s.fill(0,e*o,(e-r)*o),l.fill(0,e,e-r));}a(Qs,"shiftRows");var Yf=new RegExp(`^${an}\\]8${Ar}${Ar}([^${ur}]*)${ur}$`),Oi=`${an}]8${Ar}`;function Vf(t){for(let e of t){let n=e.code;if(n.length<5||!n.startsWith(Oi))continue;let r=n.match(Yf);if(r)return r[1]||null}return null}a(Vf,"extractHyperlinkFromStyles");function qf(t){return t.filter(e=>!e.code.startsWith(Oi)||!Yf.test(e.code))}a(qf,"filterOutHyperlinkStyles");function Ql(t,e,n){let r=t.width,o=e.width,i=t.height,s=e.height,l;r===0&&i===0?l={x:0,y:0,width:o,height:s}:e.damage?(l=e.damage,t.damage&&(l=Or(l,t.damage))):t.damage?l=t.damage:l={x:0,y:0,width:0,height:0},i>s&&(l=Or(l,{x:0,y:s,width:r,height:i-s})),r>o&&(l=Or(l,{x:o,y:0,width:r-o,height:i}));let c=Math.max(i,s),d=Math.max(r,o),f=Math.min(l.y+l.height,c),m=Math.min(l.x+l.width,d);return r===o?ex(t,e,l.x,m,l.y,f,n):tx(t,e,l.x,m,l.y,f,n)}a(Ql,"diffEach");function Jb(t,e,n,r){for(let o=0;o<r;o++,n+=2){let i=n|1;if(t[n]!==e[n]||t[i]!==e[i])return o}return r}a(Jb,"findNextDiff");function Xb(t,e,n,r,o,i,s,l,c,d,f){let m=s;for(;m<l;){let g=Jb(t,e,o,l-m);if(m+=g,o+=g<<1,m>=l)break;if(Dr(n,o,c),Dr(r,o,d),f(m,i,c,d))return true;m++,o+=2;}return false}a(Xb,"diffRowBoth");function Qb(t,e,n,r,o,i,s){for(let l=r;l<o;l++,e+=2)if(Dr(t,e,i),s(l,n,i,void 0))return true;return false}a(Qb,"diffRowRemoved");function Zb(t,e,n,r,o,i,s,l){for(let c=o;c<i;c++,n+=2)if(!(t[n]===0&&t[n|1]===0)&&(Dr(e,n,s),l(c,r,void 0,s)))return true;return false}a(Zb,"diffRowAdded");function ex(t,e,n,r,o,i,s){let l=t.cells,c=e.cells,d=t.width,f=t.height,m=e.height,g=d<<1,y={char:" ",styleId:0,width:0,hyperlink:void 0},w={char:" ",styleId:0,width:0,hyperlink:void 0},x=Math.min(r,d),v=o*d+n<<1;for(let b=o;b<i;b++){let h=b<f,T=b<m;if(h&&T){if(Xb(l,c,t,e,v,b,n,x,y,w,s))return true}else if(h){if(Qb(t,v,b,n,x,y,s))return true}else if(T&&Zb(c,e,v,b,n,x,w,s))return true;v+=g;}return false}a(ex,"diffSameWidth");function tx(t,e,n,r,o,i,s){let l=t.width,c=e.width,d=t.cells,f=e.cells,m={char:" ",styleId:0,width:0,hyperlink:void 0},g={char:" ",styleId:0,width:0,hyperlink:void 0},y=l<<1,w=c<<1,x=o*l+n<<1,v=o*c+n<<1;for(let b=o;b<i;b++){let h=b<t.height,T=b<e.height,A=h?Math.min(r,l):n,M=T?Math.min(r,c):n,D=Math.min(A,M),N=x,R=v;for(let E=n;E<D;E++){if(d[N]===f[R]&&d[N+1]===f[R+1]){N+=2,R+=2;continue}if(Dr(t,N,m),Dr(e,R,g),N+=2,R+=2,s(E,b,m,g))return true}if(A>D){N=x+(D-n<<1);for(let E=D;E<A;E++)if(Dr(t,N,m),N+=2,s(E,b,m,void 0))return true}if(M>D){R=v+(D-n<<1);for(let E=D;E<M;E++){if(f[R]===0&&f[R|1]===0){R+=2;continue}if(Dr(e,R,g),R+=2,s(E,b,void 0,g))return true}}x+=y,v+=w;}return false}a(tx,"diffDifferentWidth");function zf(t,e,n,r,o){let i=Math.min(e+r,t.width),s=Math.min(n+o,t.height),l=t.noSelect,c=t.width;for(let d=Math.max(0,n);d<s;d++){let f=d*c;l.fill(1,f+Math.max(0,e),f+i);}}a(zf,"markNoSelectRegion");function Jf(){return {anchor:null,focus:null,isDragging:false,anchorSpan:null,scrolledOffAbove:[],scrolledOffBelow:[],scrolledOffAboveSW:[],scrolledOffBelowSW:[],lastPressHadAlt:false}}a(Jf,"createSelectionState");function ea(t,e,n){t.anchor={col:e,row:n},t.focus=null,t.isDragging=true,t.anchorSpan=null,t.scrolledOffAbove=[],t.scrolledOffBelow=[],t.scrolledOffAboveSW=[],t.scrolledOffBelowSW=[],t.virtualAnchorRow=void 0,t.virtualFocusRow=void 0,t.lastPressHadAlt=false;}a(ea,"startSelection");function Xf(t,e,n){t.isDragging&&(!t.focus&&t.anchor&&t.anchor.col===e&&t.anchor.row===n||(t.focus={col:e,row:n}));}a(Xf,"updateSelection");function Oo(t){t.isDragging=false;}a(Oo,"finishSelection");function ta(t){t.anchor=null,t.focus=null,t.isDragging=false,t.anchorSpan=null,t.scrolledOffAbove=[],t.scrolledOffBelow=[],t.scrolledOffAboveSW=[],t.scrolledOffBelowSW=[],t.virtualAnchorRow=void 0,t.virtualFocusRow=void 0,t.lastPressHadAlt=false;}a(ta,"clearSelection");var nx=/[\p{L}\p{N}_/.\-+~\\]/u;function Zs(t){return t===" "||t===""?0:nx.test(t)?1:2}a(Zs,"charClass");function Qf(t,e,n){if(n<0||n>=t.height)return null;let r=t.width,o=t.noSelect,i=n*r,s=e;if(s>0){let m=vt(t,s,n);m&&m.width===2&&(s-=1);}if(s<0||s>=r||o[i+s]===1)return null;let l=vt(t,s,n);if(!l)return null;let c=Zs(l.char),d=s;for(;d>0;){let m=d-1;if(o[i+m]===1)break;let g=vt(t,m,n);if(!g)break;if(g.width===2){if(m===0||o[i+m-1]===1)break;let y=vt(t,m-1,n);if(!y||Zs(y.char)!==c)break;d=m-1;continue}if(Zs(g.char)!==c)break;d=m;}let f=s;for(;f<r-1;){let m=f+1;if(o[i+m]===1)break;let g=vt(t,m,n);if(!g)break;if(g.width===2){f=m;continue}if(Zs(g.char)!==c)break;f=m;}return {lo:d,hi:f}}a(Qf,"wordBoundsAt");function tc(t,e){return t.row!==e.row?t.row<e.row?-1:1:t.col!==e.col?t.col<e.col?-1:1:0}a(tc,"comparePoints");function Zf(t,e,n,r){let o=Qf(e,n,r);if(!o)return;let i={col:o.lo,row:r},s={col:o.hi,row:r};t.anchor=i,t.focus=s,t.isDragging=true,t.anchorSpan={lo:i,hi:s,kind:"word"};}a(Zf,"selectWordAt");var rx=new Set([..."<>\"'` "]);function Zl(t){if(t.length!==1)return false;let e=t.charCodeAt(0);return e>=33&&e<=126&&!rx.has(t)}a(Zl,"isUrlChar");function em(t,e,n){if(n<0||n>=t.height)return;let r=t.width,o=t.noSelect,i=n*r,s=e;if(s>0){let b=vt(t,s,n);b&&b.width===2&&(s-=1);}if(s<0||s>=r||o[i+s]===1)return;let l=vt(t,s,n);if(!l||!Zl(l.char))return;let c=s;for(;c>0;){let b=c-1;if(o[i+b]===1)break;let h=vt(t,b,n);if(!h||h.width!==0||!Zl(h.char))break;c=b;}let d=s;for(;d<r-1;){let b=d+1;if(o[i+b]===1)break;let h=vt(t,b,n);if(!h||h.width!==0||!Zl(h.char))break;d=b;}let f="";for(let b=c;b<=d;b++)f+=vt(t,b,n).char;let m=s-c,g=/(?:https?|file):\/\//g,y=-1,w=f.length;for(let b;b=g.exec(f);){if(b.index>m){w=b.index;break}y=b.index;}if(y<0)return;let x=f.slice(y,w),v={")":"(","]":"[","}":"{"};for(;x.length>0;){let b=x.at(-1);if(".,;:!?".includes(b)){x=x.slice(0,-1);continue}let h=v[b];if(!h)break;let T=0,A=0;for(let M=0;M<x.length;M++){let D=x.charAt(M);D===h?T++:D===b&&A++;}if(A>T)x=x.slice(0,-1);else break}if(!(m>=y+x.length))return x}a(em,"findPlainTextUrlAt");function tm(t,e,n){if(n<0||n>=e.height)return;let r={col:0,row:n},o={col:e.width-1,row:n};t.anchor=r,t.focus=o,t.isDragging=true,t.anchorSpan={lo:r,hi:o,kind:"line"};}a(tm,"selectLineAt");function nm(t,e,n,r){if(!t.isDragging||!t.anchorSpan)return;let o=t.anchorSpan,i,s;if(o.kind==="word"){let l=Qf(e,n,r);i={col:l?l.lo:n,row:r},s={col:l?l.hi:n,row:r};}else {let l=Vs(r,0,e.height-1);i={col:0,row:l},s={col:e.width-1,row:l};}tc(s,o.lo)<0?(t.anchor=o.hi,t.focus=i):tc(i,o.hi)>0?(t.anchor=o.lo,t.focus=s):(t.anchor=o.lo,t.focus=o.hi);}a(nm,"extendSelection");function rm(t,e,n){t.focus&&(t.anchorSpan=null,t.focus={col:e,row:n},t.virtualFocusRow=void 0);}a(rm,"moveFocus");function nc(t,e,n,r,o,i=true){if(!t.anchor||!t.focus)return;let s=(t.virtualAnchorRow??t.anchor.row)+e,l=(t.virtualFocusRow??t.focus.row)+e;if(i&&(s<n&&l<n||s>r&&l>r)){ta(t);return}let c=Math.min(t.virtualAnchorRow??t.anchor.row,t.virtualFocusRow??t.focus.row),d=Math.max(t.virtualAnchorRow??t.anchor.row,t.virtualFocusRow??t.focus.row),f=Math.max(0,n-c),m=Math.max(0,d-r),g=Math.max(0,n-Math.min(s,l)),y=Math.max(0,Math.max(s,l)-r);if(g<f){let x=f-g;t.scrolledOffAbove.length-=x,t.scrolledOffAboveSW.length=t.scrolledOffAbove.length;}if(y<m){let x=m-y;t.scrolledOffBelow.splice(0,x),t.scrolledOffBelowSW.splice(0,x);}t.scrolledOffAbove.length>g&&(t.scrolledOffAbove=g>0?t.scrolledOffAbove.slice(-g):[],t.scrolledOffAboveSW=g>0?t.scrolledOffAboveSW.slice(-g):[]),t.scrolledOffBelow.length>y&&(t.scrolledOffBelow=t.scrolledOffBelow.slice(0,y),t.scrolledOffBelowSW=t.scrolledOffBelowSW.slice(0,y));let w=a((x,v)=>v<n?{col:0,row:n}:v>r?{col:o-1,row:r}:{col:x.col,row:v},"shift");if(t.anchor=w(t.anchor,s),t.focus=w(t.focus,l),t.virtualAnchorRow=s<n||s>r?s:void 0,t.virtualFocusRow=l<n||l>r?l:void 0,t.anchorSpan){let x=a(v=>{let b=v.row+e;return b<n?{col:0,row:n}:b>r?{col:o-1,row:r}:{col:v.col,row:b}},"sp");t.anchorSpan={lo:x(t.anchorSpan.lo),hi:x(t.anchorSpan.hi),kind:t.anchorSpan.kind};}}a(nc,"shiftSelection");function om(t,e,n,r){if(!t.anchor)return;let o=(t.virtualAnchorRow??t.anchor.row)+e;if(t.anchor={col:t.anchor.col,row:Vs(o,n,r)},t.virtualAnchorRow=o<n||o>r?o:void 0,t.anchorSpan){let i=a(s=>({col:s.col,row:Vs(s.row+e,n,r)}),"shift");t.anchorSpan={lo:i(t.anchorSpan.lo),hi:i(t.anchorSpan.hi),kind:t.anchorSpan.kind};}}a(om,"shiftAnchor");function cn(t){return t.anchor!==null&&t.focus!==null}a(cn,"hasSelection");function rc(t){return !t.anchor||!t.focus?null:tc(t.anchor,t.focus)<=0?{start:t.anchor,end:t.focus}:{start:t.focus,end:t.anchor}}a(rc,"selectionBounds");function im(t,e,n,r){let o=t.noSelect,i=e*t.width,s=e+1<t.height?t.softWrap[e+1]:0,l=s>0?Math.min(r,s-1):r,c="";for(let d=n;d<=l;d++){if(o[i+d]===1)continue;let f=vt(t,d,e);f&&(f.width===2||f.width===3||(c+=f.char));}return s>0?c:c.replace(/\s+$/,"")}a(im,"extractRowText");function ec(t,e,n){n&&t.length>0?t[t.length-1]+=e:t.push(e);}a(ec,"joinRows");function sm(t,e){let n=rc(t);if(!n)return "";let{start:r,end:o}=n,i=e.softWrap,s=[];for(let l=0;l<t.scrolledOffAbove.length;l++)ec(s,t.scrolledOffAbove[l],t.scrolledOffAboveSW[l]);for(let l=r.row;l<=o.row;l++){let c=l===r.row?r.col:0,d=l===o.row?o.col:e.width-1;ec(s,im(e,l,c,d),i[l]>0);}for(let l=0;l<t.scrolledOffBelow.length;l++)ec(s,t.scrolledOffBelow[l],t.scrolledOffBelowSW[l]);return s.join(`
37
- `)}a(sm,"getSelectedText");function Po(t,e,n,r,o){let i=rc(t);if(!i||n>r)return;let{start:s,end:l}=i,c=Math.max(n,s.row),d=Math.min(r,l.row);if(c>d)return;let f=e.width,m=e.softWrap,g=[],y=[];for(let w=c;w<=d;w++){let x=w===s.row?s.col:0,v=w===l.row?l.col:f-1;g.push(im(e,w,x,v)),y.push(m[w]>0);}o==="above"?(t.scrolledOffAbove.push(...g),t.scrolledOffAboveSW.push(...y),t.anchor&&t.anchor.row===s.row&&c===s.row&&(t.anchor={col:0,row:t.anchor.row},t.anchorSpan&&(t.anchorSpan={kind:t.anchorSpan.kind,lo:{col:0,row:t.anchorSpan.lo.row},hi:{col:f-1,row:t.anchorSpan.hi.row}}))):(t.scrolledOffBelow.unshift(...g),t.scrolledOffBelowSW.unshift(...y),t.anchor&&t.anchor.row===l.row&&d===l.row&&(t.anchor={col:f-1,row:t.anchor.row},t.anchorSpan&&(t.anchorSpan={kind:t.anchorSpan.kind,lo:{col:0,row:t.anchorSpan.lo.row},hi:{col:f-1,row:t.anchorSpan.hi.row}})));}a(Po,"captureScrolledRows");function am(t,e,n){let r=rc(e);if(!r)return;let{start:o,end:i}=r,s=t.width,l=t.noSelect;for(let c=o.row;c<=i.row&&c<t.height;c++){let d=c===o.row?o.col:0,f=c===i.row?Math.min(i.col,s-1):s-1,m=c*s;for(let g=d;g<=f;g++){let y=m+g;if(l[y]===1)continue;let w=pr(t,y);No(t,g,c,n.withSelectionBg(w.styleId));}}}a(am,"applySelectionOverlay");h();h();var Do={platform:process.platform,terminal:process.env.TERM_PROGRAM??process.env.TERM??"unknown",shell:process.env.SHELL??(process.platform==="win32"?"cmd.exe":"/bin/sh"),isCI:!!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.GITLAB_CI)};homedir();h();var ix=Re(0,"f");function sx(){return process.platform==="win32"&&!!process.env.WT_SESSION}a(sx,"isWindowsTerminal");function ax(){return !!(process.env.TERM_PROGRAM==="mintty"||process.platform==="win32"&&process.env.MSYSTEM)}a(ax,"isMintty");function lx(){return !!(sx()||process.platform==="win32"&&process.env.TERM_PROGRAM==="vscode"&&process.env.TERM_PROGRAM_VERSION||ax())}a(lx,"isModernWindowsTerminal");function oc(t={}){let e=t.preserveScrollback===true;return process.platform==="win32"?lx()?dr+(e?"":vi)+On:dr+ix:dr+(e?"":vi)+On}a(oc,"getClearTerminalSequence");oc();h();var Ge={CURSOR_VISIBLE:25,ALT_SCREEN:47,ALT_SCREEN_CLEAR:1049,MOUSE_NORMAL:1e3,MOUSE_BUTTON:1002,MOUSE_ANY:1003,MOUSE_SGR:1006,FOCUS_EVENTS:1004,BRACKETED_PASTE:2004,SYNCHRONIZED_UPDATE:2026};function gr(t){return Re(`?${t}h`)}a(gr,"decset");function hr(t){return Re(`?${t}l`)}a(hr,"decreset");var lm=gr(Ge.SYNCHRONIZED_UPDATE),cm=hr(Ge.SYNCHRONIZED_UPDATE),um=gr(Ge.BRACKETED_PASTE),na=hr(Ge.BRACKETED_PASTE),ic=gr(Ge.FOCUS_EVENTS),Di=hr(Ge.FOCUS_EVENTS),to=gr(Ge.CURSOR_VISIBLE),Ii=hr(Ge.CURSOR_VISIBLE),Li=gr(Ge.ALT_SCREEN_CLEAR),ra=hr(Ge.ALT_SCREEN_CLEAR),no=gr(Ge.MOUSE_NORMAL)+gr(Ge.MOUSE_BUTTON)+gr(Ge.MOUSE_ANY)+gr(Ge.MOUSE_SGR),ro=hr(Ge.MOUSE_SGR)+hr(Ge.MOUSE_ANY)+hr(Ge.MOUSE_BUTTON)+hr(Ge.MOUSE_NORMAL);h();var sc=an+String.fromCharCode(Nn.OSC),fm=an+"\\";function Io(...t){let e=Do.terminal==="kitty"?fm:ur;return `${sc}${t.join(Ar)}${e}`}a(Io,"osc");function ac(t){return process.env.TMUX?`\x1BPtmux;${t.replaceAll("\x1B","\x1B\x1B")}\x1B\\`:process.env.STY?`\x1BP${t}\x1B\\`:t}a(ac,"wrapForMultiplexer");function ux(t){return `${an}Ptmux;${t.replaceAll(an,an+an)}${fm}`}a(ux,"tmuxPassthrough");async function dx(t){if(!process.env.TMUX)return false;let e=process.env.LC_TERMINAL==="iTerm2"?["load-buffer","-"]:["load-buffer","-w","-"],{code:n}=await An("tmux",e,{input:t,timeout:2e3});return n===0}a(dx,"tmuxLoadBuffer");async function mm(t){let e=Buffer$1.from(t,"utf8").toString("base64"),n=Io(Sn.CLIPBOARD,"c",e);return process.env.SSH_CONNECTION||fx(t),await dx(t)?ux(`${an}]52;c;${e}${ur}`):n}a(mm,"setClipboard");var oo;function fx(t){let e={input:t,timeout:2e3};switch(process.platform){case "darwin":An("pbcopy",[],e);return;case "linux":{if(oo===null)return;if(oo==="wl-copy"){An("wl-copy",[],e);return}if(oo==="xclip"){An("xclip",["-selection","clipboard"],e);return}if(oo==="xsel"){An("xsel",["--clipboard","--input"],e);return}An("wl-copy",[],e).then(n=>{if(n.code===0){oo="wl-copy";return}An("xclip",["-selection","clipboard"],e).then(r=>{if(r.code===0){oo="xclip";return}An("xsel",["--clipboard","--input"],e).then(o=>{oo=o.code===0?"xsel":null;});});});return}case "win32":An("clip",[],e);return}}a(fx,"copyNative");var Sn={SET_TITLE_AND_ICON:0,SET_ICON:1,SET_TITLE:2,HYPERLINK:8,ITERM2:9,CLIPBOARD:52,TAB_STATUS:21337};function pm(t){let e=t.indexOf(";"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e+1):"",o=parseInt(n,10);if(o===Sn.SET_TITLE_AND_ICON)return {type:"title",action:{type:"both",title:r}};if(o===Sn.SET_ICON)return {type:"title",action:{type:"iconName",name:r}};if(o===Sn.SET_TITLE)return {type:"title",action:{type:"windowTitle",title:r}};if(o===Sn.HYPERLINK){let i=r.split(";"),s=i[0]??"",l=i.slice(1).join(";");if(l==="")return {type:"link",action:{type:"end"}};let c={};if(s)for(let d of s.split(":")){let f=d.indexOf("=");f>=0&&(c[d.slice(0,f)]=d.slice(f+1));}return {type:"link",action:{type:"start",url:l,params:Object.keys(c).length>0?c:void 0}}}return o===Sn.TAB_STATUS?{type:"tabStatus",action:mx(r)}:{type:"unknown",sequence:`\x1B]${t}`}}a(pm,"parseOSC");function dm(t){let e=t.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(e)return {type:"rgb",r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)};let n=t.match(/^rgb:([0-9a-f]{1,4})\/([0-9a-f]{1,4})\/([0-9a-f]{1,4})$/i);if(n){let r=a(o=>Math.round(parseInt(o,16)/(16**o.length-1)*255),"scale");return {type:"rgb",r:r(n[1]),g:r(n[2]),b:r(n[3])}}return null}a(dm,"parseOscColor");function mx(t){let e={};for(let[n,r]of px(t))switch(n){case "indicator":e.indicator=r===""?null:dm(r);break;case "status":e.status=r===""?null:r;break;case "status-color":e.statusColor=r===""?null:dm(r);break}return e}a(mx,"parseTabStatus");function*px(t){let e="",n="",r=false,o=false;for(let i of t)o?(r?n+=i:e+=i,o=false):i==="\\"?o=true:i===";"?(yield [e,n],e="",n="",r=false):i==="="&&!r?r=true:r?n+=i:e+=i;(e||r)&&(yield [e,n]);}a(px,"splitTabStatusPairs");function oa(t,e){if(!t)return ia;let n={id:gx(t),...e},r=Object.entries(n).map(([o,i])=>`${o}=${i}`).join(":");return Io(Sn.HYPERLINK,r,t)}a(oa,"link");function gx(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return (e>>>0).toString(36)}a(gx,"osc8Id");var ia=Io(Sn.HYPERLINK,"",""),gm={PROGRESS:4},hm={CLEAR:0},ym=`${sc}${Sn.ITERM2};${gm.PROGRESS};${hm.CLEAR};${ur}`,bm=Io(Sn.TAB_STATUS,"indicator=;status=;status-color=");function xm(){return process.env.USER_TYPE==="ant"}a(xm,"supportsTabStatus");function hx(){if(process.env.TMUX)return false;let t=process.env.TERM_PROGRAM,e=process.env.TERM;if(t==="iTerm.app"||t==="WezTerm"||t==="WarpTerminal"||t==="ghostty"||t==="contour"||t==="vscode"||t==="alacritty"||e?.includes("kitty")||process.env.KITTY_WINDOW_ID||e==="xterm-ghostty"||e?.startsWith("foot")||e?.includes("alacritty")||process.env.ZED_TERM||process.env.WT_SESSION)return true;let n=process.env.VTE_VERSION;return !!(n&&parseInt(n,10)>=6800)}a(hx,"isSynchronizedOutputSupported");var lc;function Sm(t){lc===void 0&&(lc=t);}a(Sm,"setXtversionName");function sa(){return process.env.TERM_PROGRAM==="vscode"?true:lc?.startsWith("xterm.js")??false}a(sa,"isXtermJs");var yx=["iTerm.app","kitty","WezTerm","ghostty","tmux","windows-terminal"];function Bi(){return yx.includes(Do.terminal??"")}a(Bi,"supportsExtendedKeys");var cc=hx();function uc(t,e,n=false){if(e.length===0)return;let r=!n,o=r?lm:"";for(let i of e)switch(i.type){case "stdout":o+=i.content;break;case "clear":i.count>0&&(o+=Gd(i.count));break;case "clearTerminal":o+=oc({preserveScrollback:i.preserveScrollback});break;case "cursorHide":o+=Ii;break;case "cursorShow":o+=to;break;case "cursorMove":o+=wo(i.x,i.y);break;case "cursorTo":o+=Ud(i.col);break;case "carriageReturn":o+="\r";break;case "hyperlink":o+=oa(i.uri);break;case "styleStr":o+=i.str;break}r&&(o+=cm),t.stdout.write(o);}a(uc,"writeDiffToTerminal");h();var fc="unknown",wm=new Set,dc=new Set;function mc(t){fc=t?"focused":"blurred";for(let e of dc)e();if(!t){for(let e of wm)e();wm.clear();}}a(mc,"setTerminalFocused");function aa(){return fc!=="blurred"}a(aa,"getTerminalFocused");function vm(){return fc}a(vm,"getTerminalFocusState");function pc(t){return dc.add(t),()=>{dc.delete(t);}}a(pc,"subscribeTerminalFocus");h();function Tm(){return {request:Re(">0q"),match:a(t=>t.type==="xtversion","match")}}a(Tm,"xtversion");var bx=Re("c"),la=class{constructor(e){this.stdout=e;}static{a(this,"TerminalQuerier");}queue=[];send(e){return new Promise(n=>{this.queue.push({kind:"query",match:e.match,resolve:a(r=>n(r),"resolve")}),this.stdout.write(e.request);})}flush(){return new Promise(e=>{this.queue.push({kind:"sentinel",resolve:e}),this.stdout.write(bx);})}onResponse(e){let n=this.queue.findIndex(r=>r.kind==="query"&&r.match(e));if(n!==-1){let[r]=this.queue.splice(n,1);r?.kind==="query"&&r.resolve(e);return}if(e.type==="da1"){let r=this.queue.findIndex(o=>o.kind==="sentinel");if(r===-1)return;for(let o of this.queue.splice(0,r+1))o.kind==="query"?o.resolve(void 0):o.resolve();}}};h();var Em=createContext({exit(){}});Em.displayName="InternalAppContext";var ca=Em;h();h();h();h();var gc=createContext({isTerminalFocused:true,terminalFocusState:"unknown"});gc.displayName="TerminalFocusContext";function km(t){let e=c(6),{children:n}=t,r=useSyncExternalStore(pc,aa),o=useSyncExternalStore(pc,vm),i;e[0]!==r||e[1]!==o?(i={isTerminalFocused:r,terminalFocusState:o},e[0]=r,e[1]=o,e[2]=i):i=e[2];let s=i,l;return e[3]!==n||e[4]!==s?(l=jsx(gc.Provider,{value:s,children:n}),e[3]=n,e[4]=s,e[5]=l):l=e[5],l}a(km,"TerminalFocusProvider");var _m=gc;function Rm(){let{isTerminalFocused:t}=useContext(_m);return t}a(Rm,"useTerminalFocus");function Rx(t){let e=new Map,n=null,r=t,o=0,i=0;function s(){i=Date.now()-o;for(let c of e.keys())c();}a(s,"tick");function l(){[...e.values()].some(Boolean)?(n&&(clearInterval(n),n=null),o===0&&(o=Date.now()),n=setInterval(s,r)):n&&(clearInterval(n),n=null);}return a(l,"updateInterval"),{subscribe(c,d){return e.set(c,d),l(),()=>{e.delete(c),l();}},now(){return o===0&&(o=Date.now()),n&&i?i:Date.now()-o},setTickInterval(c){c!==r&&(r=c,l());}}}a(Rx,"createClock");var Mx=createContext(null),Ax=32;function Mm(t){let e=c(7),{children:n}=t,[r]=useState(Nx),o=Rm(),i,s;e[0]!==r||e[1]!==o?(i=a(()=>{r.setTickInterval(o?16:Ax);},"t1"),s=[r,o],e[0]=r,e[1]=o,e[2]=i,e[3]=s):(i=e[2],s=e[3]),useEffect(i,s);let l;return e[4]!==n||e[5]!==r?(l=jsx(Mx.Provider,{value:r,children:n}),e[4]=n,e[5]=r,e[6]=l):l=e[6],l}a(Mm,"ClockProvider");function Nx(){return Rx(16)}a(Nx,"_temp");h();var Dx=createContext(()=>{}),Am=Dx;h();h();h();function Lx(t){let e=c(42),n,r,o,i,s,l,c$1,d,f,m,g,y,w,x,v,b,h,T;if(e[0]!==t){let{children:R,flexWrap:E,flexDirection:I,flexGrow:F,flexShrink:O,ref:L,tabIndex:J,autoFocus:le,onClick:Oe,onFocus:Pe,onFocusCapture:Ye,onBlur:Z,onBlurCapture:Se,onMouseEnter:W,onMouseLeave:me,onKeyDown:pe,onKeyDownCapture:Y,...q}=t;r=R,b=L,T=J,n=le,f=Oe,m=Pe,g=Ye,c$1=Z,d=Se,x=W,v=me,y=pe,w=Y,h=q,l=E===void 0?"nowrap":E,o=I===void 0?"row":I,i=F===void 0?0:F,s=O===void 0?1:O,at(h.margin,"margin"),at(h.marginX,"marginX"),at(h.marginY,"marginY"),at(h.marginTop,"marginTop"),at(h.marginBottom,"marginBottom"),at(h.marginLeft,"marginLeft"),at(h.marginRight,"marginRight"),at(h.padding,"padding"),at(h.paddingX,"paddingX"),at(h.paddingY,"paddingY"),at(h.paddingTop,"paddingTop"),at(h.paddingBottom,"paddingBottom"),at(h.paddingLeft,"paddingLeft"),at(h.paddingRight,"paddingRight"),at(h.gap,"gap"),at(h.columnGap,"columnGap"),at(h.rowGap,"rowGap"),e[0]=t,e[1]=n,e[2]=r,e[3]=o,e[4]=i,e[5]=s,e[6]=l,e[7]=c$1,e[8]=d,e[9]=f,e[10]=m,e[11]=g,e[12]=y,e[13]=w,e[14]=x,e[15]=v,e[16]=b,e[17]=h,e[18]=T;}else n=e[1],r=e[2],o=e[3],i=e[4],s=e[5],l=e[6],c$1=e[7],d=e[8],f=e[9],m=e[10],g=e[11],y=e[12],w=e[13],x=e[14],v=e[15],b=e[16],h=e[17],T=e[18];let A=h.overflowX??h.overflow??"visible",M=h.overflowY??h.overflow??"visible",D;e[19]!==o||e[20]!==i||e[21]!==s||e[22]!==l||e[23]!==h||e[24]!==A||e[25]!==M?(D={flexWrap:l,flexDirection:o,flexGrow:i,flexShrink:s,...h,overflowX:A,overflowY:M},e[19]=o,e[20]=i,e[21]=s,e[22]=l,e[23]=h,e[24]=A,e[25]=M,e[26]=D):D=e[26];let N;return e[27]!==n||e[28]!==r||e[29]!==c$1||e[30]!==d||e[31]!==f||e[32]!==m||e[33]!==g||e[34]!==y||e[35]!==w||e[36]!==x||e[37]!==v||e[38]!==b||e[39]!==D||e[40]!==T?(N=jsx("ink-box",{ref:b,tabIndex:T,autoFocus:n,onClick:f,onFocus:m,onFocusCapture:g,onBlur:c$1,onBlurCapture:d,onMouseEnter:x,onMouseLeave:v,onKeyDown:y,onKeyDownCapture:w,style:D,children:r}),e[27]=n,e[28]=r,e[29]=c$1,e[30]=d,e[31]=f,e[32]=m,e[33]=g,e[34]=y,e[35]=w,e[36]=x,e[37]=v,e[38]=b,e[39]=D,e[40]=T,e[41]=N):N=e[41],N}a(Lx,"Box");var S=Lx;h();var $x={wrap:{flexGrow:0,flexShrink:1,flexDirection:"row",textWrap:"wrap"},"wrap-trim":{flexGrow:0,flexShrink:1,flexDirection:"row",textWrap:"wrap-trim"},end:{flexGrow:0,flexShrink:1,flexDirection:"row",textWrap:"end"},middle:{flexGrow:0,flexShrink:1,flexDirection:"row",textWrap:"middle"},"truncate-end":{flexGrow:0,flexShrink:1,flexDirection:"row",textWrap:"truncate-end"},truncate:{flexGrow:0,flexShrink:1,flexDirection:"row",textWrap:"truncate"},"truncate-middle":{flexGrow:0,flexShrink:1,flexDirection:"row",textWrap:"truncate-middle"},"truncate-start":{flexGrow:0,flexShrink:1,flexDirection:"row",textWrap:"truncate-start"}};function u(t){let e=c(29),{color:n,backgroundColor:r,bold:o,dim:i,italic:s,underline:l,strikethrough:c$1,inverse:d,wrap:f,children:m}=t,g=s===void 0?false:s,y=l===void 0?false:l,w=c$1===void 0?false:c$1,x=d===void 0?false:d,v=f===void 0?"wrap":f;if(m==null)return null;let b;e[0]!==n?(b=n&&{color:n},e[0]=n,e[1]=b):b=e[1];let h;e[2]!==r?(h=r&&{backgroundColor:r},e[2]=r,e[3]=h):h=e[3];let T;e[4]!==i?(T=i&&{dim:i},e[4]=i,e[5]=T):T=e[5];let A;e[6]!==o?(A=o&&{bold:o},e[6]=o,e[7]=A):A=e[7];let M;e[8]!==g?(M=g&&{italic:g},e[8]=g,e[9]=M):M=e[9];let D;e[10]!==y?(D=y&&{underline:y},e[10]=y,e[11]=D):D=e[11];let N;e[12]!==w?(N=w&&{strikethrough:w},e[12]=w,e[13]=N):N=e[13];let R;e[14]!==x?(R=x&&{inverse:x},e[14]=x,e[15]=R):R=e[15];let E;e[16]!==M||e[17]!==D||e[18]!==N||e[19]!==R||e[20]!==b||e[21]!==h||e[22]!==T||e[23]!==A?(E={...b,...h,...T,...A,...M,...D,...N,...R},e[16]=M,e[17]=D,e[18]=N,e[19]=R,e[20]=b,e[21]=h,e[22]=T,e[23]=A,e[24]=E):E=e[24];let I=E,F=$x[v],O;return e[25]!==m||e[26]!==F||e[27]!==I?(O=jsx("ink-text",{style:F,textStyles:I,children:m}),e[25]=m,e[26]=F,e[27]=I,e[28]=O):O=e[28],O}a(u,"Text");var Om=a(t=>t?.replace(`file://${process.cwd()}/`,""),"cleanupPath"),Gx;function Pm(){return Gx??=new Nm({cwd:process.cwd(),internals:Nm.nodeInternals()})}a(Pm,"getStackUtils");function hc({error:t}){let e=t.stack?t.stack.split(`
38
- `).slice(1):void 0,n=e?Pm().parseLine(e[0]):void 0,r=Om(n?.file),o,i=0;if(r&&n?.line)try{let s=readFileSync(r,"utf8");if(o=Wx(s,n.line),o)for(let{line:l}of o)i=Math.max(i,String(l).length);}catch{}return jsxs(S,{flexDirection:"column",padding:1,children:[jsxs(S,{children:[jsxs(u,{backgroundColor:"ansi:red",color:"ansi:white",children:[" ","ERROR"," "]}),jsxs(u,{children:[" ",t.message]})]}),n&&r&&jsx(S,{marginTop:1,children:jsxs(u,{dim:true,children:[r,":",n.line,":",n.column]})}),n&&o&&jsx(S,{marginTop:1,flexDirection:"column",children:o.map(({line:s,value:l})=>jsxs(S,{children:[jsx(S,{width:i+1,children:jsxs(u,{dim:s!==n.line,backgroundColor:s===n.line?"ansi:red":void 0,color:s===n.line?"ansi:white":void 0,children:[String(s).padStart(i," "),":"]})}),jsx(u,{backgroundColor:s===n.line?"ansi:red":void 0,color:s===n.line?"ansi:white":void 0,children:" "+l},s)]},s))}),t.stack&&jsx(S,{marginTop:1,flexDirection:"column",children:t.stack.split(`
39
- `).slice(1).map(s=>{let l=Pm().parseLine(s);return l?jsxs(S,{children:[jsx(u,{dim:true,children:"- "}),jsx(u,{bold:true,children:l.function}),jsxs(u,{dim:true,children:[" ","(",Om(l.file)??"",":",l.line,":",l.column,")"]})]},s):jsxs(S,{children:[jsx(u,{dim:true,children:"- "}),jsx(u,{bold:true,children:s})]},s)})})]})}a(hc,"ErrorOverview");h();var Dm=createContext({stdin:process.stdin,internal_eventEmitter:new xo,setRawMode(){},isRawModeSupported:false,internal_exitOnCtrlC:true,internal_querier:null});Dm.displayName="InternalStdinContext";var ua=Dm;h();var da=createContext(null);var Vx=process.platform!=="win32",qx=5e3,Im=500,Lm=1,Fi=class extends PureComponent{static{a(this,"App");}static displayName="InternalApp";static getDerivedStateFromError(e){return {error:e}}state={error:void 0};rawModeEnabledCount=0;internal_eventEmitter=new xo;keyParseState=sf;incompleteEscapeTimer=null;NORMAL_TIMEOUT=50;PASTE_TIMEOUT=500;querier=new la(this.props.stdout);lastClickTime=0;lastClickCol=-1;lastClickRow=-1;clickCount=0;pendingHyperlinkTimer=null;lastHoverCol=-1;lastHoverRow=-1;lastStdinTime=Date.now();isRawModeSupported(){return this.props.stdin.isTTY}render(){return jsx(da.Provider,{value:{columns:this.props.terminalColumns,rows:this.props.terminalRows},children:jsx(ca.Provider,{value:{exit:this.handleExit},children:jsx(ua.Provider,{value:{stdin:this.props.stdin,setRawMode:this.handleSetRawMode,isRawModeSupported:this.isRawModeSupported(),internal_exitOnCtrlC:this.props.exitOnCtrlC,internal_eventEmitter:this.internal_eventEmitter,internal_querier:this.querier},children:jsx(km,{children:jsx(Mm,{children:jsx(Am.Provider,{value:this.props.onCursorDeclaration??(()=>{}),children:this.state.error?jsx(hc,{error:this.state.error}):this.props.children})})})})})})}componentDidMount(){this.props.stdout.isTTY&&!Vr(process.env.CLAUDE_CODE_ACCESSIBILITY)&&this.props.stdout.write(Ii);}componentWillUnmount(){this.props.stdout.isTTY&&this.props.stdout.write(to),this.incompleteEscapeTimer&&(clearTimeout(this.incompleteEscapeTimer),this.incompleteEscapeTimer=null),this.pendingHyperlinkTimer&&(clearTimeout(this.pendingHyperlinkTimer),this.pendingHyperlinkTimer=null),this.isRawModeSupported()&&this.handleSetRawMode(false);}componentDidCatch(e){this.handleExit(e);}handleSetRawMode=a(e=>{let{stdin:n}=this.props;if(!this.isRawModeSupported())throw n===process.stdin?new Error(`Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.
40
- Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`):new Error(`Raw mode is not supported on the stdin provided to Ink.
41
- Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(n.setEncoding("utf8"),e){this.rawModeEnabledCount===0&&(n.ref(),n.setRawMode(true),n.addListener("readable",this.handleReadable),this.props.stdout.write(um),this.props.stdout.write(ic),Bi()&&(this.props.stdout.write(Ti),this.props.stdout.write(Ei)),setImmediate(()=>{Promise.all([this.querier.send(Tm()),this.querier.flush()]).then(([r])=>{r?(Sm(r.name),$e(`XTVERSION: terminal identified as "${r.name}"`)):$e("XTVERSION: no reply (terminal ignored query)");});})),this.rawModeEnabledCount++;return}--this.rawModeEnabledCount===0&&(this.props.stdout.write(Ci),this.props.stdout.write(qr),this.props.stdout.write(Di),this.props.stdout.write(na),n.setRawMode(false),n.removeListener("readable",this.handleReadable),n.unref());},"handleSetRawMode");flushIncomplete=a(()=>{if(this.incompleteEscapeTimer=null,!!this.keyParseState.incomplete){if(this.props.stdin.readableLength>0){this.incompleteEscapeTimer=setTimeout(this.flushIncomplete,this.NORMAL_TIMEOUT);return}this.processInput(null);}},"flushIncomplete");processInput=a(e=>{let[n,r]=af(this.keyParseState,e);this.keyParseState=r,n.length>0&&Wt.discreteUpdates(zx,this,n,void 0,void 0),this.keyParseState.incomplete&&(this.incompleteEscapeTimer&&clearTimeout(this.incompleteEscapeTimer),this.incompleteEscapeTimer=setTimeout(this.flushIncomplete,this.keyParseState.mode==="IN_PASTE"?this.PASTE_TIMEOUT:this.NORMAL_TIMEOUT));},"processInput");handleReadable=a(()=>{let e=Date.now();e-this.lastStdinTime>qx&&this.props.onStdinResume?.(),this.lastStdinTime=e;try{let n;for(;(n=this.props.stdin.read())!==null;)this.processInput(n);}catch(n){d.error(n);let{stdin:r}=this.props;this.rawModeEnabledCount>0&&!r.listeners("readable").includes(this.handleReadable)&&($e("handleReadable: re-attaching stdin readable listener after error recovery",{level:"warn"}),r.addListener("readable",this.handleReadable));}},"handleReadable");handleInput=a(e=>{e===""&&this.props.exitOnCtrlC&&this.handleExit();},"handleInput");handleExit=a(e=>{this.isRawModeSupported()&&this.handleSetRawMode(false),this.props.onExit(e);},"handleExit");handleTerminalFocus=a(e=>{mc(e);},"handleTerminalFocus");handleSuspend=a(()=>{if(!this.isRawModeSupported())return;let e=this.rawModeEnabledCount;for(;this.rawModeEnabledCount>0;)this.handleSetRawMode(false);this.props.stdout.isTTY&&this.props.stdout.write(to+Di+ro),this.internal_eventEmitter.emit("suspend");let n=a(()=>{for(let r=0;r<e;r++)this.isRawModeSupported()&&this.handleSetRawMode(true);this.props.stdout.isTTY&&(Vr(process.env.CLAUDE_CODE_ACCESSIBILITY)||this.props.stdout.write(Ii),this.props.stdout.write(ic)),this.internal_eventEmitter.emit("resume"),process.removeListener("SIGCONT",n);},"resumeHandler");process.on("SIGCONT",n),process.kill(process.pid,"SIGSTOP");},"handleSuspend")};function zx(t,e,n,r){e.some(o=>o.kind==="key"||o.kind==="mouse"&&!((o.button&32)!==0&&(o.button&3)===3))&&O();for(let o of e){if(o.kind==="response"){t.querier.onResponse(o.response);continue}if(o.kind==="mouse"){Jx(t,o);continue}let i=o.sequence;if(i===Jd){t.handleTerminalFocus(true);let l=new ki("terminalfocus");t.internal_eventEmitter.emit("terminalfocus",l);continue}if(i===Xd){t.handleTerminalFocus(false),t.props.selection.isDragging&&(Oo(t.props.selection),t.props.onSelectionFinish());let l=new ki("terminalblur");t.internal_eventEmitter.emit("terminalblur",l);continue}if(aa()||mc(true),o.name==="z"&&o.ctrl&&Vx){t.handleSuspend();continue}t.handleInput(i);let s=new Ns(o);t.internal_eventEmitter.emit("input",s),t.props.dispatchKeyboardEvent(o);}}a(zx,"processKeysInBatch");function Jx(t,e){if(Ld())return;let n=t.props.selection,r=e.col-1,o=e.row-1,i=e.button&3;if(e.action==="press"){if((e.button&32)!==0&&i===3){if(n.isDragging&&(Oo(n),t.props.onSelectionChange()),r===t.lastHoverCol&&o===t.lastHoverRow)return;t.lastHoverCol=r,t.lastHoverRow=o,t.props.onHoverAt(r,o);return}if(i!==0){t.clickCount=0;return}if((e.button&32)!==0){t.props.onSelectionDrag(r,o);return}n.isDragging&&(Oo(n),t.props.onSelectionFinish());let s=Date.now(),l=s-t.lastClickTime<Im&&Math.abs(r-t.lastClickCol)<=Lm&&Math.abs(o-t.lastClickRow)<=Lm;if(t.clickCount=l?t.clickCount+1:1,t.lastClickTime=s,t.lastClickCol=r,t.lastClickRow=o,t.clickCount>=2){t.pendingHyperlinkTimer&&(clearTimeout(t.pendingHyperlinkTimer),t.pendingHyperlinkTimer=null);let c=t.clickCount===2?2:3;t.props.onMultiClick(r,o,c);return}ea(n,r,o),n.lastPressHadAlt=(e.button&8)!==0,t.props.onSelectionChange();return}if(i!==0){if(!n.isDragging)return;Oo(n),t.props.onSelectionFinish();return}if(Oo(n),!cn(n)&&n.anchor&&!t.props.onClickAt(r,o)){let s=t.props.getHyperlinkAt(r,o);s&&process.env.TERM_PROGRAM!=="vscode"&&!sa()&&(t.pendingHyperlinkTimer&&clearTimeout(t.pendingHyperlinkTimer),t.pendingHyperlinkTimer=setTimeout((l,c)=>{l.pendingHyperlinkTimer=null,l.props.onOpenHyperlink(c);},Im,t,s));}t.props.onSelectionFinish();}a(Jx,"handleMouseEvent");h();var fa=class extends ko{static{a(this,"KeyboardEvent");}key;ctrl;shift;meta;superKey;fn;constructor(e){super("keydown",{bubbles:true,cancelable:true}),this.key=Xx(e),this.ctrl=e.ctrl,this.shift=e.shift,this.meta=e.meta||e.option,this.superKey=e.super,this.fn=e.fn;}};function Xx(t){let e=t.sequence??"",n=t.name??"";if(t.ctrl)return n;if(e.length===1){let r=e.charCodeAt(0);if(r>=32&&r!==127)return e}return n||e}a(Xx,"keyFromParsed");h();function Xn(t,e,n,r,o){return {screen:zn(0,0,n,r,o),viewport:{width:e,height:t},cursor:{x:0,y:0,visible:true}}}a(Xn,"emptyFrame");h();h();var ma=class extends bn{static{a(this,"ClickEvent");}col;row;localCol=0;localRow=0;cellIsBlank;constructor(e,n,r){super(),this.col=e,this.row=n,this.cellIsBlank=r;}};function yc(t,e,n){let r=dt.get(t);if(!r||e<r.x||e>=r.x+r.width||n<r.y||n>=r.y+r.height)return null;for(let o=t.childNodes.length-1;o>=0;o--){let i=t.childNodes[o];if(i.nodeName==="#text")continue;let s=yc(i,e,n);if(s)return s}return t}a(yc,"hitTest");function Bm(t,e,n,r=false){let o=yc(t,e,n)??void 0;if(!o)return false;if(t.focusManager){let l=o;for(;l;){if(typeof l.attributes.tabIndex=="number"){t.focusManager.handleClickFocus(l);break}l=l.parentNode;}}let i=new ma(e,n,r),s=false;for(;o;){let l=o._eventHandlers?.onClick;if(l){s=true;let c=dt.get(o);if(c&&(i.localCol=e-c.x,i.localRow=n-c.y),l(i),i.didStopImmediatePropagation())return true}o=o.parentNode;}return s}a(Bm,"dispatchClick");function Fm(t,e,n,r){let o=new Set,i=yc(t,e,n)??void 0;for(;i;){let s=i._eventHandlers;(s?.onMouseEnter||s?.onMouseLeave)&&o.add(i),i=i.parentNode;}for(let s of r)o.has(s)||(r.delete(s),s.parentNode&&s._eventHandlers?.onMouseLeave?.());for(let s of o)r.has(s)||(r.add(s),s._eventHandlers?.onMouseEnter?.());}a(Fm,"dispatchHover");h();var Qx=new Map,Qn=Qx;h();var Fo={type:"carriageReturn"},ga={type:"stdout",content:`
42
- `},ha=class{constructor(e){this.options=e;this.state={previousOutput:""};}static{a(this,"LogUpdate");}state;renderPreviousOutput_DEPRECATED(e){return this.options.isTTY?this.getRenderOpsForDone(e):[ga]}reset(){this.state.previousOutput="";}renderFullFrame(e){let{screen:n}=e,r=[],o=[],i;for(let s=0;s<n.height;s++){let l="";for(let d=0;d<n.width;d++){let f=vt(n,d,s);if(f&&f.width!==2){f.hyperlink!==i&&(i!==void 0&&(l+=ia),f.hyperlink!==void 0&&(l+=oa(f.hyperlink)),i=f.hyperlink);let m=this.options.stylePool.get(f.styleId),g=diffAnsiCodes(o,m);g.length>0&&(l+=ansiCodesToString(g),o=m),l+=f.char;}}i!==void 0&&(l+=ia,i=void 0);let c=diffAnsiCodes(o,[]);c.length>0&&(l+=ansiCodesToString(c),o=[]),r.push(l.trimEnd());}return r.length===0?[]:[{type:"stdout",content:r.join(`
43
- `)}]}getRenderOpsForDone(e){return this.state.previousOutput="",e.cursor.visible?[]:[{type:"cursorShow"}]}render(e,n,r=false,o=true){if(!this.options.isTTY)return this.renderFullFrame(n);let i=performance.now(),s=this.options.stylePool,l=!r;if(n.viewport.height<e.viewport.height||e.viewport.width!==0&&n.viewport.width!==e.viewport.width)return $i(n,"resize",s,l);let c=[];if(r&&n.scrollHint&&o){let{top:E,bottom:I,delta:F}=n.scrollHint;E>=0&&I<e.screen.height&&I<n.screen.height&&(Qs(e.screen,E,I,F),c=[{type:"stdout",content:Yd(E+1,I+1)+(F>0?jd(F):Kd(-F))+Vd+On}]);}let d=e.cursor.y>=e.screen.height,f=n.screen.height>e.screen.height,m=d&&e.screen.height>=e.viewport.height,g=n.screen.height<e.screen.height,y=n.screen.height<=e.viewport.height;if(m&&y&&g&&!l)return $e(`Full reset (shrink->below): prevHeight=${e.screen.height}, nextHeight=${n.screen.height}, viewport=${e.viewport.height}`),$i(n,"offscreen",s,l);if(!l&&e.screen.height>=e.viewport.height&&e.screen.height>0&&d&&!f){let I=e.screen.height-e.viewport.height+1,F=-1;if(Ql(e.screen,n.screen,(O,L)=>{if(L<I)return F=L,true}),F>=0){let O=pa(e.screen,F),L=pa(n.screen,F);return $i(n,"offscreen",s,l,{triggerY:F,prevLine:O,nextLine:L})}}let w=new ba(e.cursor,n.viewport.width),x=Math.max(n.screen.height,1)-Math.max(e.screen.height,1),v=x<0,b=x>0;if(v){let E=e.screen.height-n.screen.height;if(E>e.viewport.height)return $i(n,"offscreen",this.options.stylePool,l);w.txn(I=>[[{type:"clear",count:E},{type:"cursorMove",x:0,y:-1}],{dx:-I.x,dy:-E}]);}let h=m?1:0,T=b?Math.max(0,e.screen.height-e.viewport.height+h):Math.max(e.screen.height,n.screen.height)-n.viewport.height+h,A=s.none,M,D=false,N=-1;if(Ql(e.screen,n.screen,(E,I,F,O)=>{if(!(b&&I>=e.screen.height)&&!(O&&(O.width===2||O.width===3))&&!(F&&(F.width===2||F.width===3)&&!O)&&!(O&&Js(n.screen,E,I)&&!F)){if(I<T)return l?void 0:(D=true,N=I,true);if(bc(w,E,I),O){let L=O.hyperlink;M=Bo(w.diff,M,L);let J=s.transition(A,O.styleId);Um(w,O,J)&&(A=O.styleId);}else if(F){let L=A,J=M;A=s.none,M=void 0,w.txn(()=>{let le=[];return ya(le,s,L,s.none),Bo(le,J,void 0),le.push({type:"stdout",content:" "}),[le,{dx:1,dy:0}]});}}}),D)return $i(n,"offscreen",s,l,{triggerY:N,prevLine:pa(e.screen,N),nextLine:pa(n.screen,N)});A=ya(w.diff,s,A,s.none),M=Bo(w.diff,M,void 0),b&&Wm(w,n,e.screen.height,n.screen.height,s),r||(n.cursor.y>=n.screen.height?w.txn(E=>{let I=n.cursor.y-E.y;if(I>0){let O=new Array(1+I);O[0]=Fo;for(let L=0;L<I;L++)O[1+L]=ga;return [O,{dx:-E.x,dy:I}]}let F=n.cursor.y-E.y;if(F!==0||E.x!==n.cursor.x){let O=[Fo];return O.push({type:"cursorMove",x:n.cursor.x,y:F}),[O,{dx:n.cursor.x-E.x,dy:F}]}return [[],{dx:0,dy:0}]}):bc(w,n.cursor.x,n.cursor.y));let R=performance.now()-i;if(R>50){let E=n.screen.damage,I=E?`${E.width}x${E.height} at (${E.x},${E.y})`:"none";$e(`Slow render: ${R.toFixed(1)}ms, screen: ${n.screen.height}x${n.screen.width}, damage: ${I}, changes: ${w.diff.length}`);}return c.length>0?[...c,...w.diff]:w.diff}};function Bo(t,e,n){return e!==n?(t.push({type:"hyperlink",uri:n??""}),n):e}a(Bo,"transitionHyperlink");function ya(t,e,n,r){let o=e.transition(n,r);return o.length>0&&t.push({type:"styleStr",str:o}),r}a(ya,"transitionStyle");function pa(t,e){let n="";for(let r=0;r<t.width;r++)n+=Kf(t,r,e)??" ";return n.trimEnd()}a(pa,"readLine");function $i(t,e,n,r,o){let i=new ba({x:0,y:0},t.viewport.width);return Zx(i,t,n),[{type:"clearTerminal",reason:e,debug:o,preserveScrollback:r},...i.diff]}a($i,"fullResetSequence_CAUSES_FLICKER");function Zx(t,e,n){Wm(t,e,0,e.screen.height,n);}a(Zx,"renderFrame");function Wm(t,e,n,r,o){let i=o.none,s,l=-1,{width:c,cells:d,charPool:f,hyperlinkPool:m}=e.screen,g=n*c;for(let y=n;y<r;y+=1){if(t.cursor.y<y){let w=y-t.cursor.y;t.txn(x=>{let v=new Array(1+w);v[0]=Fo;for(let b=0;b<w;b++)v[1+b]=ga;return [v,{dx:-x.x,dy:w}]});}l=-1;for(let w=0;w<c;w+=1,g+=1){let x=jf(d,f,m,g,l);if(!x)continue;bc(t,w,y);let v=x.hyperlink;s=Bo(t.diff,s,v);let b=o.transition(i,x.styleId);Um(t,x,b)&&(i=x.styleId,l=x.styleId);}i=ya(t.diff,o,i,o.none),s=Bo(t.diff,s,void 0),t.txn(w=>[[Fo,ga],{dx:-w.x,dy:1}]);}return ya(t.diff,o,i,o.none),Bo(t.diff,s,void 0),t}a(Wm,"renderFrameSlice");function Um(t,e,n){let r=e.width===1?2:1,o=t.cursor.x,i=t.viewportWidth;if(r===2&&o<i){let c=e.char.length>2?i:i+1;if(o+2>=c)return false}let s=t.diff;n.length>0&&s.push({type:"styleStr",str:n});let l=r===2&&e0(e.char);return l&&o+1<i&&(s.push({type:"cursorTo",col:o+2}),s.push({type:"stdout",content:" "}),s.push({type:"cursorTo",col:o+1})),s.push({type:"stdout",content:e.char}),l&&s.push({type:"cursorTo",col:o+r+1}),o>=i?(t.cursor.x=r,t.cursor.y++):t.cursor.x=o+r,true}a(Um,"writeCellWithStyleStr");function bc(t,e,n){t.txn(r=>{let o=e-r.x,i=n-r.y;return r.x>=t.viewportWidth?[[Fo,{type:"cursorMove",x:e,y:i}],{dx:o,dy:i}]:i!==0?[[Fo,{type:"cursorMove",x:e,y:i}],{dx:o,dy:i}]:[[{type:"cursorMove",x:o,y:i}],{dx:o,dy:i}]});}a(bc,"moveCursorTo");function e0(t){let e=t.codePointAt(0);if(e===void 0)return false;if(e>=129648&&e<=129791||e>=129792&&e<=130047)return true;if(t.length>=2){for(let n=0;n<t.length;n++)if(t.charCodeAt(n)===65039)return true}return false}a(e0,"needsWidthCompensation");function Gm(t,e){let{width:n,height:r}=t,o="";for(let i=0;i<r;i++){let s=-1;for(let d=n-1;d>=0;d--){let f=vt(t,d,i);if(!(!f||f.width===2||f.width===3)&&(f.char!==" "||(f.styleId&1)!==0)){s=d;break}}let l="",c=e.none;for(let d=0;d<=s;d++){let f=vt(t,d,i);if(!f||f.width===2||f.width===3)continue;let m=e.transition(c,f.styleId);l+=m+f.char,c=f.styleId;}l+=e.transition(c,e.none),o+=l+`\r
44
- `;}return o}a(Gm,"screenToAnsi");var ba=class{constructor(e,n){this.viewportWidth=n;this.cursor={...e};}static{a(this,"VirtualScreen");}cursor;diff=[];txn(e){let[n,r]=e(this.cursor);for(let o of n)this.diff.push(o);this.cursor.x+=r.dx,this.cursor.y+=r.dy;}};h();function xc(t){if(t.length<=1)return t;let e=[],n=0;for(let r of t){let o=r.type;if(o==="stdout"){if(r.content==="")continue}else if(o==="cursorMove"){if(r.x===0&&r.y===0)continue}else if(o==="clear"&&r.count===0)continue;if(n>0){let i=n-1,s=e[i],l=s.type;if(o==="cursorMove"&&l==="cursorMove"){e[i]={type:"cursorMove",x:s.x+r.x,y:s.y+r.y};continue}if(o==="cursorTo"&&l==="cursorTo"){e[i]=r;continue}if(o==="styleStr"&&l==="styleStr"){e[i]={type:"styleStr",str:s.str+r.str};continue}if(o==="hyperlink"&&l==="hyperlink"&&r.uri===s.uri)continue;if(o==="cursorShow"&&l==="cursorHide"||o==="cursorHide"&&l==="cursorShow"){e.pop(),n--;continue}}e.push(r),n++;}return e}a(xc,"optimize");h();h();var Sc,wc;function n0(){return wc===void 0&&(wc=process.platform==="win32"||typeof process.env.WT_SESSION=="string"||process.env.TERM_PROGRAM==="vscode"),wc}a(n0,"needsBidi");function r0(){return Sc||(Sc=t0()),Sc}a(r0,"getBidi");function jm(t){if(!n0()||t.length===0)return t;let e=t.map(c=>c.value).join("");if(!s0(e))return t;let n=r0(),{levels:r}=n.getEmbeddingLevels(e,"auto"),o=[],i=0;for(let c=0;c<t.length;c++)o.push(r[i]),i+=t[c].value.length;let s=[...t],l=Math.max(...o);for(let c=l;c>=1;c--){let d=0;for(;d<s.length;)if(o[d]>=c){let f=d+1;for(;f<s.length&&o[f]>=c;)f++;o0(s,d,f-1),i0(o,d,f-1),d=f;}else d++;}return s}a(jm,"reorderBidi");function o0(t,e,n){for(;e<n;){let r=t[e];t[e]=t[n],t[n]=r,e++,n--;}}a(o0,"reverseRange");function i0(t,e,n){for(;e<n;){let r=t[e];t[e]=t[n],t[n]=r,e++,n--;}}a(i0,"reverseRangeNumbers");function s0(t){return /[\u0590-\u05FF\uFB1D-\uFB4F\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF\u0780-\u07BF\u0700-\u074F]/u.test(t)}a(s0,"hasRTLCharacters");h();function xa(t){let e=0,n=0;for(;n<=t.length;){let r=t.indexOf(`
45
- `,n),o=r===-1?t.substring(n):t.substring(n,r);if(e=Math.max(e,Ls(o)),r===-1)break;n=r+1;}return e}a(xa,"widestLine");function c0(t,e){return t?{x1:Km(t.x1,e.x1),x2:Ym(t.x2,e.x2),y1:Km(t.y1,e.y1),y2:Ym(t.y2,e.y2)}:e}a(c0,"intersectClip");function Km(t,e){return t===void 0?e:e===void 0?t:Math.max(t,e)}a(Km,"maxDefined");function Ym(t,e){return t===void 0?e:e===void 0?t:Math.min(t,e)}a(Ym,"minDefined");var br=class{static{a(this,"Output");}width;height;stylePool;screen;operations=[];charCache=new Map;constructor(e){let{width:n,height:r,stylePool:o,screen:i}=e;this.width=n,this.height=r,this.stylePool=o,this.screen=i,Jl(i,n,r);}reset(e,n,r){this.width=e,this.height=n,this.screen=r,this.operations.length=0,Jl(r,e,n),this.charCache.size>16384&&this.charCache.clear();}blit(e,n,r,o,i){this.operations.push({type:"blit",src:e,x:n,y:r,width:o,height:i});}shift(e,n,r){this.operations.push({type:"shift",top:e,bottom:n,n:r});}clear(e,n){this.operations.push({type:"clear",region:e,fromAbsolute:n});}noSelect(e){this.operations.push({type:"noSelect",region:e});}write(e,n,r,o){r&&this.operations.push({type:"write",x:e,y:n,text:r,softWrap:o});}clip(e){this.operations.push({type:"clip",clip:e});}unclip(){this.operations.push({type:"unclip"});}get(){let e=this.screen,n=this.width,r=this.height,o=0,i=0,s=[];for(let d of this.operations){if(d.type!=="clear")continue;let{x:f,y:m,width:g,height:y}=d.region,w=Math.max(0,f),x=Math.max(0,m),v=Math.min(f+g,n),b=Math.min(m+y,r);if(w>=v||x>=b)continue;let h={x:w,y:x,width:v-w,height:b-x};e.damage=e.damage?Or(e.damage,h):h,d.fromAbsolute&&s.push(h);}let l=[];for(let d of this.operations)switch(d.type){case "clear":continue;case "clip":l.push(c0(l.at(-1),d.clip));continue;case "unclip":l.pop();continue;case "blit":{let{src:f,x:m,y:g,width:y,height:w}=d,x=l.at(-1),v=Math.max(m,x?.x1??0),b=Math.max(g,x?.y1??0),h=Math.min(g+w,r,f.height,x?.y2??1/0),T=Math.min(m+y,n,f.width,x?.x2??1/0);if(v>=T||b>=h)continue;if(s.length===0){Xl(e,f,v,b,T,h),o+=(h-b)*(T-v);continue}let A=b;for(let M=b;M<=h;M++)(M<h&&s.some(N=>M>=N.y&&M<N.y+N.height&&v>=N.x&&T<=N.x+N.width)||M===h)&&(M>A&&(Xl(e,f,v,A,T,M),o+=(M-A)*(T-v)),A=M+1);continue}case "shift":{Qs(e,d.top,d.bottom,d.n);continue}case "write":{let{text:f,softWrap:m}=d,{x:g,y}=d,w=f.split(`
46
- `),x=0,v=0,b=l.at(-1);if(b){let A=typeof b?.x1=="number"&&typeof b?.x2=="number",M=typeof b?.y1=="number"&&typeof b?.y2=="number";if(A){let D=xa(f);if(g+D<=b.x1||g>=b.x2)continue}if(M){let D=w.length;if(y+D<=b.y1||y>=b.y2)continue}if(A&&(w=w.map(D=>{let N=g<b.x1?b.x1-g:0,R=Ht(D),E=g+R>b.x2?b.x2-g:R,I=Xr(D,N,E);return Ht(I)>E-N&&(I=Xr(D,N,E-1)),I}),g<b.x1&&(g=b.x1)),M){let D=y<b.y1?b.y1-y:0,N=w.length,R=y+N>b.y2?b.y2-y:N;m&&D>0&&m[D]===true&&(v=g+Ht(w[D-1])),w=w.slice(D,R),x=D,y<b.y1&&(y=b.y1);}}let h=e.softWrap,T=0;for(let A of w){let M=y+T;if(M>=r)break;let D=f0(e,A,g,M,n,this.stylePool,this.charCache);if(i+=D-g,m){let N=m[x+T]===true;h[M]=N?v:0,v=D;}T++;}continue}}for(let d of this.operations)if(d.type==="noSelect"){let{x:f,y:m,width:g,height:y}=d.region;zf(e,f,m,g,y);}let c=o+i;return c>1e3&&i>o&&$e(`[ink] High write ratio: blit=${o}, write=${i} (${(i/c*100).toFixed(1)}% writes), screen=${r}x${n}`),e}};function u0(t,e){if(t===e)return true;let n=t.length;if(n!==e.length)return false;if(n===0)return true;for(let r=0;r<n;r++)if(t[r].code!==e[r].code)return false;return true}a(u0,"stylesEqual");function d0(t,e){let n=t.length;if(n===0)return [];let r=[],o=[],i=t[0].styles;for(let s=0;s<n;s++){let l=t[s],c=l.styles;o.length>0&&!u0(c,i)&&(Vm(o.join(""),i,e,r),o.length=0),o.push(l.value),i=c;}return o.length>0&&Vm(o.join(""),i,e,r),r}a(d0,"styledCharsWithGraphemeClustering");function Vm(t,e,n,r){let o=Vf(e)??void 0,s=o!==void 0||e.some(c=>c.code.length>=Oi.length&&c.code.startsWith(Oi))?qf(e):e,l=n.intern(s);for(let{segment:c}of Yr().segment(t))r.push({value:c,width:Ht(c),styleId:l,hyperlink:o});}a(Vm,"flushBuffer");function f0(t,e,n,r,o,i,s){let l=s.get(e);l||(l=jm(d0(styledCharsFromTokens(tokenize(e)),i)),s.set(e,l));let c=n;for(let d=0;d<l.length;d++){let f=l[d],m=f.value.codePointAt(0);if(m!==void 0&&m<=31){if(m===9){let x=8-c%8;for(let v=0;v<x&&c<o;v++)Xs(t,c,r,{char:" ",styleId:i.none,width:0,hyperlink:void 0}),c++;}else if(m===27){let w=l[d+1]?.value,x=w?.codePointAt(0);if(w==="("||w===")"||w==="*"||w==="+")d+=2;else if(w==="[")for(d++;d<l.length-1;){d++;let v=l[d]?.value.codePointAt(0);if(v!==void 0&&v>=64&&v<=126)break}else if(w==="]"||w==="P"||w==="_"||w==="^"||w==="X")for(d++;d<l.length-1;){d++;let v=l[d]?.value;if(v==="\x07")break;if(v==="\x1B"&&l[d+1]?.value==="\\"){d++;break}}else x!==void 0&&x>=48&&x<=126&&d++;}continue}let g=f.width;if(g===0)continue;let y=g>=2;if(y&&c+2>o){Xs(t,c,r,{char:" ",styleId:i.none,width:3,hyperlink:void 0}),c++;continue}Xs(t,c,r,{char:f.value,styleId:f.styleId,width:y?1:0,hyperlink:f.hyperlink}),c+=y?2:1;}return c}a(f0,"writeLineToScreen");h();h();var m0=a(t=>t.getComputedWidth()-t.getComputedPadding(ye.Left)-t.getComputedPadding(ye.Right)-t.getComputedBorder(ye.Left)-t.getComputedBorder(ye.Right),"getMaxWidth"),qm=m0;h();var g0={dashed:{top:"\u254C",left:"\u254E",right:"\u254E",bottom:"\u254C",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}};function zm(t,e,n,r=0,o){let i=Ht(e),s=t.length;if(i>=s-2)return ["",e.substring(0,s),""];let l;n==="center"?l=Math.floor((s-i)/2):n==="start"?l=r+1:l=s-i-r-1,l=Math.max(1,Math.min(l,s-i-1));let c=t.substring(0,1)+o.repeat(l-1),d=o.repeat(s-l-i-1)+t.substring(s-1);return [c,e,d]}a(zm,"embedTextInBorder");function $o(t,e,n){let r=Ms(t,e);return n&&(r=te.dim(r)),r}a($o,"styleBorderLine");var h0=a((t,e,n,r)=>{if(n.style.borderStyle){let o=Math.floor(n.yogaNode.getComputedWidth()),i=Math.floor(n.yogaNode.getComputedHeight()),s=typeof n.style.borderStyle=="string"?g0[n.style.borderStyle]??p0[n.style.borderStyle]:n.style.borderStyle,l=n.style.borderTopColor??n.style.borderColor,c=n.style.borderBottomColor??n.style.borderColor,d=n.style.borderLeftColor??n.style.borderColor,f=n.style.borderRightColor??n.style.borderColor,m=n.style.borderTopDimColor??n.style.borderDimColor,g=n.style.borderBottomDimColor??n.style.borderDimColor,y=n.style.borderLeftDimColor??n.style.borderDimColor,w=n.style.borderRightDimColor??n.style.borderDimColor,x=n.style.borderTop!==false,v=n.style.borderBottom!==false,b=n.style.borderLeft!==false,h=n.style.borderRight!==false,T=Math.max(0,o-(b?1:0)-(h?1:0)),A=x?(b?s.topLeft:"")+s.top.repeat(T)+(h?s.topRight:""):"",M;if(x&&n.style.borderText?.position==="top"){let[O,L,J]=zm(A,n.style.borderText.content,n.style.borderText.align,n.style.borderText.offset,s.top);M=$o(O,l,m)+L+$o(J,l,m);}else x&&(M=$o(A,l,m));let D=i;x&&(D-=1),v&&(D-=1),D=Math.max(0,D);let N=(Ms(s.left,d)+`
47
- `).repeat(D);y&&(N=te.dim(N));let R=(Ms(s.right,f)+`
48
- `).repeat(D);w&&(R=te.dim(R));let E=v?(b?s.bottomLeft:"")+s.bottom.repeat(T)+(h?s.bottomRight:""):"",I;if(v&&n.style.borderText?.position==="bottom"){let[O,L,J]=zm(E,n.style.borderText.content,n.style.borderText.align,n.style.borderText.offset,s.bottom);I=$o(O,c,g)+L+$o(J,c,g);}else v&&(I=$o(E,c,g));let F=x?1:0;M&&r.write(t,e,M),b&&r.write(t,e+F,N),h&&r.write(t+o-1,e+F,R),I&&r.write(t,e+i-1,I);}},"renderBorder"),Jm=h0;function b0(){return process.env.TERM_PROGRAM==="vscode"||sa()}a(b0,"isXtermJsHost");var Ho=false;function va(){Ho=false;}a(va,"resetLayoutShifted");function tp(){return Ho}a(tp,"didLayoutShift");var Sa=null,Cc=[],Hi=[];function np(){Sa=null,Cc=Hi,Hi=[];}a(np,"resetScrollHint");function rp(){return Sa}a(rp,"getScrollHint");var _c=null;function Ta(){_c=null;}a(Ta,"resetScrollDrainNode");function Ea(){return _c}a(Ea,"getScrollDrainNode");var kc=null;function op(){let t=kc;return kc=null,t}a(op,"consumeFollowScroll");var x0=4,S0=5,w0=12,v0=2,T0=3,Tc=30;function E0(t,e,n){let r=e>0?1:-1,o=Math.abs(e),i=0;o>Tc&&(i+=r*(o-Tc),o=Tc);let s=o<=S0?o:o<w0?v0:T0;i+=r*s;let l=o-s,c=Math.max(1,n-1),d=Math.abs(i);if(d>c){let f=d-c;return t.pendingScrollDelta=r*(l+f),r*c}return t.pendingScrollDelta=l>0?r*l:void 0,i}a(E0,"drainAdaptive");function C0(t,e,n){let r=Math.abs(e),o=Math.max(1,n-1),i=Math.min(o,Math.max(x0,r*3>>2));if(r<=i)return t.pendingScrollDelta=void 0,e;let s=e>0?i:-i;return t.pendingScrollDelta=e-s,s}a(C0,"drainProportional");var Xm="\x1B]",Qm="\x07";function wa(t,e){return `${Xm}8;;${e}${Qm}${t}${Xm}8;;${Qm}`}a(wa,"wrapWithOsc8Link");function k0(t){let e=[];for(let n=0;n<t.length;n++){let r=t[n].text.length;for(let o=0;o<r;o++)e.push(n);}return e}a(k0,"buildCharToSegmentMap");function _0(t,e,n,r,o=false){let i=t.split(`
49
- `),s=[],l=0;for(let c=0;c<i.length;c++){let d=i[c];if(o&&d.length>0){let x=/\s/.test(d[0]);if(l<r.length&&/\s/.test(r[l])&&!x)for(;l<r.length&&/\s/.test(r[l]);)l++;}let f="",m=0,g=n[l]??0;for(let x=0;x<d.length;x++){let v=n[l]??g;if(v!==g){let b=d.slice(m,x),h=e[g];if(h){let T=bo(b,h.styles);h.hyperlink&&(T=wa(T,h.hyperlink)),f+=T;}else f+=b;m=x,g=v;}l++;}let y=d.slice(m),w=e[g];if(w){let x=bo(y,w.styles);w.hyperlink&&(x=wa(x,w.hyperlink)),f+=x;}else f+=y;if(s.push(f),l<r.length&&r[l]===`
50
- `&&l++,o&&c<i.length-1){let x=i[c+1],v=x.length>0?x[0]:null;for(;l<r.length&&/\s/.test(r[l])&&!(v!==null&&r[l]===v);)l++;}}return s.join(`
51
- `)}a(_0,"applyStylesToWrappedText");function Zm(t,e,n){if(n!=="wrap"&&n!=="wrap-trim")return {wrapped:Eo(t,e,n),softWrap:void 0};let r=t.split(`
52
- `),o=[],i=[];for(let s of r){let l=Eo(s,e,n).split(`
53
- `);for(let c=0;c<l.length;c++)o.push(l[c]),i.push(c>0);}return {wrapped:o.join(`
54
- `),softWrap:i}}a(Zm,"wrapWithSoftWrap");function R0(t,e,n){let r=t.childNodes[0]?.yogaNode;if(r){let o=r.getComputedLeft(),i=r.getComputedTop();e=`
55
- `.repeat(i)+y0(e,o),n&&i>0&&n.unshift(...Array(i).fill(false));}return e}a(R0,"applyPaddingToText");function Ca(t,e,{offsetX:n=0,offsetY:r=0,prevScreen:o,skipSelfBlit:i=false,inheritedBackgroundColor:s}){if(t.nodeName==="ink-static"){t.dirty=false;return}let{yogaNode:l}=t;if(l){if(l.getDisplay()===ln.None){if(t.dirty){let h=dt.get(t);h&&(e.clear({x:Math.floor(h.x),y:Math.floor(h.y),width:Math.floor(h.width),height:Math.floor(h.height)}),Rc(t),Ho=true);}return}let c=n+l.getComputedLeft(),d=l.getComputedTop(),f=r+d,m=l.getComputedWidth(),g=l.getComputedHeight();f<0&&t.style.position==="absolute"&&(f=0);let y=dt.get(t);if(!t.dirty&&!i&&t.pendingScrollDelta===void 0&&y&&y.x===c&&y.y===f&&y.width===m&&y.height===g&&o){let h=Math.floor(c),T=Math.floor(f),A=Math.floor(m),M=Math.floor(g);e.blit(o,h,T,A,M),t.style.position==="absolute"&&Hi.push(y),ip(t,e,o,h,T,A,M);return}let w=y!==void 0&&(y.x!==c||y.y!==f||y.width!==m||y.height!==g);w&&(Ho=true),y&&(t.dirty||w)&&e.clear({x:Math.floor(y.x),y:Math.floor(y.y),width:Math.floor(y.width),height:Math.floor(y.height)},t.style.position==="absolute");let x=Ri.get(t),v=x!==void 0;if(v){Ho=true;for(let h of x)e.clear({x:Math.floor(h.x),y:Math.floor(h.y),width:Math.floor(h.width),height:Math.floor(h.height)});Ri.delete(t);}if(g===0&&A0(t,l)){dt.set(t,{x:c,y:f,width:m,height:g,top:d}),t.dirty=false;return}if(t.nodeName==="ink-raw-ansi"){let h=t.attributes.rawText;h&&e.write(c,f,h);}else if(t.nodeName==="ink-text"){let h=Fs(t,s?{backgroundColor:s}:void 0),T=h.map(A=>A.text).join("");if(T.length>0){let A=Math.min(qm(l),e.width-c),M=t.style.textWrap??"wrap",D=xa(T)>A,N,R;if(D&&h.length===1){let E=h[0],I=Zm(T,A,M);R=I.softWrap,N=I.wrapped.split(`
56
- `).map(F=>{let O=bo(F,E.styles);return E.hyperlink&&(O=wa(O,E.hyperlink)),O}).join(`
57
- `);}else if(D){let E=Zm(T,A,M);R=E.softWrap;let I=k0(h);N=_0(E.wrapped,h,I,T,M==="wrap-trim");}else N=h.map(E=>{let I=bo(E.text,E.styles);return E.hyperlink&&(I=wa(I,E.hyperlink)),I}).join("");N=R0(t,N,R),e.write(c,f,N,R);}}else if(t.nodeName==="ink-box"){let h=t.style.backgroundColor??s;if(t.style.noSelect){let F=Math.floor(c),O=t.style.noSelect==="from-left-edge";e.noSelect({x:O?0:F,y:Math.floor(f),width:O?F+Math.floor(m):Math.floor(m),height:Math.floor(g)});}let T=t.style.overflowX??t.style.overflow,A=t.style.overflowY??t.style.overflow,M=T==="hidden"||T==="scroll",D=A==="hidden"||A==="scroll",N=A==="scroll",R=M||D,E,I;if(R){let F=M?c+l.getComputedBorder(ye.Left):void 0,O=M?c+l.getComputedWidth()-l.getComputedBorder(ye.Right):void 0;E=D?f+l.getComputedBorder(ye.Top):void 0,I=D?f+l.getComputedHeight()-l.getComputedBorder(ye.Bottom):void 0,e.clip({x1:F,x2:O,y1:E,y2:I});}if(N){let F=l.getComputedPadding(ye.Top),O=Math.max(0,(I??f+g)-(E??f)-F-l.getComputedPadding(ye.Bottom)),L=t.childNodes.find(He=>He.yogaNode),J=L?.yogaNode,le=J?.getComputedHeight()??0,Oe=t.scrollHeight??le,Pe=t.scrollViewportHeight??O;t.scrollHeight=le,t.scrollViewportHeight=O,t.scrollViewportTop=(E??f)+F;let Ye=Math.max(0,le-O);if(t.scrollAnchor){let He=t.scrollAnchor.el.yogaNode?.getComputedTop();He!=null&&(t.scrollTop=He+t.scrollAnchor.offset,t.pendingScrollDelta=void 0),t.scrollAnchor=void 0;}let Z=t.scrollTop??0,Se=t.stickyScroll??!!t.attributes.stickyScroll,W=Math.max(0,Oe-Pe),me=le>=Oe;(Se||me&&Z>=W)&&(t.pendingScrollDelta??0)>=0&&(t.scrollTop=Ye,t.pendingScrollDelta=void 0,t.stickyScroll===false&&Z>=W&&(t.stickyScroll=true));let Y=t.scrollTop??0,q=t.pendingScrollDelta,Te=t.scrollClampMin,Ce=t.scrollClampMax,ge=Te!==void 0&&Ce!==void 0;if(q!==void 0&&q!==0){let re=ge&&(q<0&&Y<Te||q>0&&Y>Ce)?Math.min(4,O>>3):O;Y+=b0()?E0(t,q,re):C0(t,q,re);}else q===0&&(t.pendingScrollDelta=void 0);let se=Math.max(0,Math.min(Y,Ye)),lt=ge?Math.max(Te,Math.min(se,Ce)):se;t.scrollTop=se,se!==Y&&(t.pendingScrollDelta=void 0),t.pendingScrollDelta!==void 0&&(_c=t);let Be=se-Z;if(Be!==0){let He=t.scrollViewportTop??0;kc={delta:Be,viewportTop:He,viewportBottom:He+O-1};}if(se=lt,L&&J){let He=c+J.getComputedLeft(),re=f+J.getComputedTop()-se,rt=dt.get(L),xt=null;if(rt&&rt.y!==re){let We=rt.y-re,ke=Math.floor(f+J.getComputedTop()),we=ke+O-1;y?.y===f&&y.height===g&&O>0&&Math.abs(We)<O?(xt={top:ke,bottom:we,delta:We},Sa=xt):Ho=true;}let Zt=J.getComputedHeight(),Mt=rt?.height??Zt,Vt=Zt-Mt,Dt=!xt||Vt===0||xt.delta>0&&Vt===xt.delta;if(Dt||(Sa=null),xt&&o&&Dt){let{top:We,bottom:ke,delta:we}=xt,qe=Math.floor(m);e.blit(o,Math.floor(c),We,qe,ke-We+1),e.shift(We,ke,we);let ot=we>0?ke-we+1:We,U=we>0?ke:We-we-1;e.clear({x:Math.floor(c),y:ot,width:qe,height:U-ot+1}),e.clip({x1:void 0,x2:void 0,y1:ot,y2:U+1});let $=L.dirty?new Set(L.childNodes.filter(K=>K.dirty)):null;if(Ec(L,e,He,re,v,void 0,ot-re,U+1-re,h,true),e.unclip(),$){let K=ot-re,ne=U+1-re,z=" ".repeat(qe),he=0;for(let ct of L.childNodes){let mt=ct,en=$.has(ct);if(!en&&he===0&&dt.has(mt))continue;let pn=mt.yogaNode;if(!pn)continue;let Q=pn.getComputedTop(),Ne=pn.getComputedHeight(),xe=Q+Ne;if(en){let Fe=dt.get(mt);he+=Ne-(Fe?Fe.height:0);}if(xe<=se||Q>=se+O||Q>=K&&xe<=ne)continue;let pt=Math.floor(re+Q);if(!en){let Fe=dt.get(mt);if(Fe&&Math.floor(Fe.y)-we===pt)continue}let ze=Math.min(Math.floor(re+xe),Math.floor((E??f)+F+O));if(pt<ze){let Fe=Array(ze-pt).fill(z).join(`
58
- `);e.write(Math.floor(c),pt,Fe),e.clip({x1:void 0,x2:void 0,y1:pt,y2:ze}),Ca(mt,e,{offsetX:He,offsetY:re,prevScreen:void 0,inheritedBackgroundColor:h}),e.unclip();}}}let V=Cc.length?" ".repeat(qe):"";for(let K of Cc){if(K.y>=ke+1||K.y+K.height<=We)continue;let ne=Math.max(We,Math.floor(K.y)-we),z=Math.min(ke+1,Math.floor(K.y+K.height)-we);if(ne>=ot&&z<=U+1||ne>=z)continue;let he=Array(z-ne).fill(V).join(`
59
- `);e.write(Math.floor(c),ne,he),e.clip({x1:void 0,x2:void 0,y1:ne,y2:z}),Ec(L,e,He,re,v,void 0,ne-re,z-re,h,true),e.unclip();}}else {let We=rt&&rt.y!==re;We&&E!==void 0&&I!==void 0&&e.clear({x:Math.floor(c),y:Math.floor(E),width:Math.floor(m),height:Math.floor(I-E)}),Ec(L,e,He,re,v,We||w?void 0:o,se,se+O,h);}dt.set(L,{x:He,y:re,width:J.getComputedWidth(),height:J.getComputedHeight()}),L.dirty=false;}}else {let F=t.style.backgroundColor;if(F||t.style.opaque){let O=l.getComputedBorder(ye.Left),L=l.getComputedBorder(ye.Right),J=l.getComputedBorder(ye.Top),le=l.getComputedBorder(ye.Bottom),Oe=Math.floor(m)-O-L,Pe=Math.floor(g)-J-le;if(Oe>0&&Pe>0){let Ye=" ".repeat(Oe),Z=F?bo(Ye,{backgroundColor:F}):Ye,Se=Array(Pe).fill(Z).join(`
60
- `);e.write(c+O,f+J,Se);}}ep(t,e,c,f,v,F||t.style.opaque?void 0:o,h);}R&&e.unclip(),Jm(c,f,t,e);}else t.nodeName==="ink-root"&&ep(t,e,c,f,v,o,s);let b={x:c,y:f,width:m,height:g,top:d};dt.set(t,b),t.style.position==="absolute"&&Hi.push(b),t.dirty=false;}}a(Ca,"renderNodeToOutput");function ep(t,e,n,r,o,i,s){let l=false,c=false;for(let d of t.childNodes){let f=d,m=f.dirty,g=f.style.position==="absolute";Ca(f,e,{offsetX:n,offsetY:r,prevScreen:o||l?void 0:i,skipSelfBlit:c&&g&&!f.style.opaque&&f.style.backgroundColor===void 0,inheritedBackgroundColor:s}),m&&!l&&(!M0(f)||g?l=true:c=true);}}a(ep,"renderChildren");function M0(t){let e=t.style.overflowX??t.style.overflow,n=t.style.overflowY??t.style.overflow;return (e==="hidden"||e==="scroll")&&(n==="hidden"||n==="scroll")}a(M0,"clipsBothAxes");function A0(t,e){let n=t.parentNode;if(!n)return false;let r=e.getComputedTop(),o=n.childNodes,i=o.indexOf(t);for(let s=i+1;s<o.length;s++){let l=o[s].yogaNode;if(l)return l.getComputedTop()===r}for(let s=i-1;s>=0;s--){let l=o[s].yogaNode;if(l)return l.getComputedTop()===r}return false}a(A0,"siblingSharesY");function ip(t,e,n,r,o,i,s){let l=r+i,c=o+s;for(let d of t.childNodes){if(d.nodeName==="#text")continue;let f=d;if(f.style.position==="absolute"){let m=dt.get(f);if(m){Hi.push(m);let g=Math.floor(m.x),y=Math.floor(m.y),w=Math.floor(m.width),x=Math.floor(m.height);(g<r||y<o||g+w>l||y+x>c)&&e.blit(n,g,y,w,x);}}ip(f,e,n,r,o,i,s);}}a(ip,"blitEscapingAbsoluteDescendants");function Ec(t,e,n,r,o,i,s,l,c,d=false){let f=false,m=0;for(let g of t.childNodes){let y=g,w=y.yogaNode;if(w){let v=dt.get(y),b,h;if(v?.top!==void 0&&!y.dirty&&m===0?(b=v.top,h=v.height):(b=w.getComputedTop(),h=w.getComputedHeight(),y.dirty&&(m+=h-(v?v.height:0)),v&&(v.top=b)),b+h<=s||b>=l){d||Rc(y);continue}}let x=y.dirty;Ca(y,e,{offsetX:n,offsetY:r,prevScreen:o||f?void 0:i,inheritedBackgroundColor:c}),x&&(f=true);}}a(Ec,"renderScrolledChildren");function Rc(t){dt.delete(t);for(let e of t.childNodes)e.nodeName!=="#text"&&Rc(e);}a(Rc,"dropSubtreeCache");var Wo=Ca;h();var Ir,Mc,Ac,sp,ap,Wi,Ut={reconcile:0,yoga:0,paint:0,scan:0,calls:0},O0=20;function lp(t,e){Ir||(Ir=Co("ink-root"),Ir.focusManager=new _o(()=>false),Ac=new Ro,sp=new Zr,ap=new eo,Mc=Wt.createContainer(Ir,LegacyRoot,null,false,null,"search-render",Uo,Uo,Uo,Uo));let n=performance.now();Wt.updateContainerSync(t,Mc,null,Uo),Wt.flushSyncWork();let r=performance.now();Ir.yogaNode?.setWidth(e),Ir.yogaNode?.calculateLayout(e);let o=Math.ceil(Ir.yogaNode?.getComputedHeight()??0),i=performance.now(),s=zn(e,Math.max(1,o),Ac,sp,ap);Wi?Wi.reset(e,o,s):Wi=new br({width:e,height:o,stylePool:Ac,screen:s}),va(),Wo(Ir,Wi,{prevScreen:void 0});let l=Wi.get(),c=performance.now();if(Wt.updateContainerSync(null,Mc,null,Uo),Wt.flushSyncWork(),Ut.reconcile+=r-n,Ut.yoga+=i-r,Ut.paint+=c-i,++Ut.calls%O0===0){let d=Ut.reconcile+Ut.yoga+Ut.paint+Ut.scan;$e(`renderToScreen: ${Ut.calls} calls \xB7 reconcile=${Ut.reconcile.toFixed(1)}ms yoga=${Ut.yoga.toFixed(1)}ms paint=${Ut.paint.toFixed(1)}ms scan=${Ut.scan.toFixed(1)}ms \xB7 total=${d.toFixed(1)}ms \xB7 avg ${(d/Ut.calls).toFixed(2)}ms/call`);}return {screen:l,height:o}}a(lp,"renderToScreen");function cp(t,e){let n=e.toLowerCase();if(!n)return [];let r=n.length,o=t.width,i=t.height,s=t.noSelect,l=[],c=performance.now();for(let d=0;d<i;d++){let f=d*o,m="",g=[],y=[];for(let x=0;x<o;x++){let v=f+x,b=pr(t,v);if(b.width===2||b.width===3||s[v]===1)continue;let h=b.char.toLowerCase(),T=g.length;for(let A=0;A<h.length;A++)y.push(T);m+=h,g.push(x);}let w=m.indexOf(n);for(;w>=0;){let x=y[w],v=y[w+r-1],b=g[x],h=g[v]+1;l.push({row:d,col:b,len:h-b}),w=m.indexOf(n,w+r);}}return Ut.scan+=performance.now()-c,l}a(cp,"scanPositions");function up(t,e,n,r,o){if(o<0||o>=n.length)return false;let i=n[o],s=i.row+r;if(s<0||s>=t.height)return false;let l=a(d=>e.withCurrentMatch(d),"transform"),c=s*t.width;for(let d=i.col;d<i.col+i.len;d++){if(d<0||d>=t.width)continue;let f=pr(t,c+d);No(t,d,s,l(f.styleId));}return true}a(up,"applyPositionedHighlight");h();function Nc(t,e){let n;return r=>{let{frontFrame:o,backFrame:i,isTTY:s,terminalWidth:l,terminalRows:c}=r,d=o.screen,f=i.screen,m=f.charPool,g=f.hyperlinkPool,y=t.yogaNode?.getComputedHeight(),w=t.yogaNode?.getComputedWidth(),x=y===void 0||!Number.isFinite(y)||y<0,v=w===void 0||!Number.isFinite(w)||w<0;if(!t.yogaNode||x||v)return t.yogaNode&&(x||v)&&$e(`Invalid yoga dimensions: width=${w}, height=${y}, childNodes=${t.childNodes.length}, terminalWidth=${l}, terminalRows=${c}`),{screen:zn(l,0,e,m,g),viewport:{width:l,height:c},cursor:{x:0,y:0,visible:true}};let b=Math.floor(t.yogaNode.getComputedWidth()),h=Math.floor(t.yogaNode.getComputedHeight()),T=r.altScreen?c:h;r.altScreen&&h>c&&$e(`alt-screen: yoga height ${h} > terminalRows ${c} \u2014 something is rendering outside <AlternateScreen>. Overflow clipped.`,{level:"warn"});let A=f??zn(b,T,e,m,g);n?n.reset(b,T,A):n=new br({width:b,height:T,stylePool:e,screen:A}),va(),np(),Ta();let M=yf();Wo(t,n,{prevScreen:M||r.prevFrameContaminated?void 0:d});let D=n.get(),N=Ea();return N&&Ct(N),{scrollHint:r.altScreen?rp():null,scrollDrainPending:N!==null,screen:D,viewport:{width:l,height:r.altScreen?c+1:c},cursor:{x:0,y:r.altScreen?Math.max(0,Math.min(A.height,c)-1):A.height,visible:!s||A.height===0}}}}a(Nc,"createRenderer");h();function dp(t,e,n){if(!e)return false;let r=e.toLowerCase(),o=r.length,i=t.width,s=t.noSelect,l=t.height,c=false;for(let d=0;d<l;d++){let f=d*i,m="",g=[],y=[];for(let x=0;x<i;x++){let v=f+x,b=pr(t,v);if(b.width===2||b.width===3||s[v]===1)continue;let h=b.char.toLowerCase(),T=g.length;for(let A=0;A<h.length;A++)y.push(T);m+=h,g.push(x);}let w=m.indexOf(r);for(;w>=0;){c=true;let x=y[w],v=y[w+o-1];for(let b=x;b<=v;b++){let h=g[b],T=pr(t,f+h);No(t,h,d,n.withInverse(T.styleId));}w=m.indexOf(r,w+o);}}return c}a(dp,"applySearchHighlight");h();var Oc=createContext(null),fp=Oc.Provider;var W0=Object.freeze({x:0,y:0,visible:false}),U0=Object.freeze({type:"stdout",content:On}),G0=Object.freeze({type:"stdout",content:dr+On});function gp(t){return Object.freeze({type:"stdout",content:Cl(t,1)})}a(gp,"makeAltScreenParkPatch");function yp(t,e){if(t.nodeName==="ink-static"){e(t);return}for(let n of t.childNodes)n.nodeName!=="#text"&&yp(n,e);}a(yp,"walkForStatic");var Ui=class{constructor(e){this.options=e;D0(this),this.options.patchConsole&&(this.restoreConsole=this.patchConsole(),this.restoreStderr=this.patchStderr()),this.terminal={stdout:e.stdout,stderr:e.stderr},this.terminalColumns=e.stdout.columns||80,this.terminalRows=e.stdout.rows||24,this.altScreenParkPatch=gp(this.terminalRows),this.stylePool=new Ro,this.charPool=new Zr,this.hyperlinkPool=new eo,this.frontFrame=Xn(this.terminalRows,this.terminalColumns,this.stylePool,this.charPool,this.hyperlinkPool),this.backFrame=Xn(this.terminalRows,this.terminalColumns,this.stylePool,this.charPool,this.hyperlinkPool),this.log=new ha({isTTY:e.stdout.isTTY||false,stylePool:this.stylePool});let n=a(()=>queueMicrotask(this.onRender),"deferredRender");this.scheduleRender=F0(n,16,{leading:true,trailing:true}),this.isUnmounted=false,this.unsubscribeExit=onExit(this.unmount,{alwaysLast:false}),e.stdout.isTTY&&(e.stdout.on("resize",this.handleResize),process.on("SIGCONT",this.handleResume),this.unsubscribeTTYHandlers=()=>{e.stdout.off("resize",this.handleResize),process.off("SIGCONT",this.handleResume);}),this.rootNode=Co("ink-root"),this.focusManager=new _o((r,o)=>mr.dispatchDiscrete(r,o)),this.rootNode.focusManager=this.focusManager,this.renderer=Nc(this.rootNode,this.stylePool),this.rootNode.onRender=this.scheduleRender,this.rootNode.onImmediateRender=()=>queueMicrotask(this.onRender),this.rootNode.onComputeLayout=()=>{if(!this.isUnmounted&&this.rootNode.yogaNode){let r=performance.now();this.rootNode.yogaNode.setWidth(this.terminalColumns),this.rootNode.yogaNode.calculateLayout(this.terminalColumns);let o=performance.now()-r;If(o);let i=Rs();this.lastYogaCounters={ms:o,...i};}},this.container=Wt.createContainer(this.rootNode,ConcurrentRoot,null,false,null,"id",Uo,Uo,Uo,Uo);}static{a(this,"Ink");}log;terminal;scheduleRender;isUnmounted=false;isPaused=false;container;rootNode;focusManager;renderer;stylePool;charPool;hyperlinkPool;exitPromise;restoreConsole;restoreStderr;unsubscribeTTYHandlers;terminalColumns;terminalRows;currentNode=null;frontFrame;backFrame;lastPoolResetTime=performance.now();drainTimer=null;drainConsecutive=0;drainTrace=[];lastYogaCounters={ms:0,visited:0,measured:0,cacheHits:0,live:0};altScreenParkPatch;selection=Jf();searchHighlightQuery="";searchPositions=null;selectionListeners=new Set;hoveredNodes=new Set;altScreenActive=false;altScreenMouseTracking=false;prevFrameContaminated=false;needsEraseBeforePaint=false;cursorDeclaration=null;displayCursor=null;handleResume=a(()=>{if(this.options.stdout.isTTY){if(this.altScreenActive){this.reenterAltScreen();return}this.frontFrame=Xn(this.frontFrame.viewport.height,this.frontFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.backFrame=Xn(this.backFrame.viewport.height,this.backFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.log.reset(),this.displayCursor=null;}},"handleResume");handleResize=a(()=>{let e=this.options.stdout.columns||80,n=this.options.stdout.rows||24;e===this.terminalColumns&&n===this.terminalRows||(this.terminalColumns=e,this.terminalRows=n,this.altScreenParkPatch=gp(this.terminalRows),this.altScreenActive&&!this.isPaused&&this.options.stdout.isTTY&&(this.altScreenMouseTracking&&this.options.stdout.write(no),this.resetFramesForAltScreen(),this.needsEraseBeforePaint=true),this.currentNode!==null&&this.render(this.currentNode));},"handleResize");resolveExitPromise=a(()=>{},"resolveExitPromise");rejectExitPromise=a(()=>{},"rejectExitPromise");unsubscribeExit=a(()=>{},"unsubscribeExit");enterAlternateScreen(){this.pause(),this.suspendStdin(),this.options.stdout.write(qr+Ci+(this.altScreenMouseTracking?ro:"")+(this.altScreenActive?"":"\x1B[?1049h")+"\x1B[?1004l\x1B[0m\x1B[?25h\x1B[2J\x1B[H");}exitAlternateScreen(){this.options.stdout.write((this.altScreenActive?Li:"")+"\x1B[2J\x1B[H"+(this.altScreenMouseTracking?no:"")+(this.altScreenActive?"":"\x1B[?1049l")+"\x1B[?25l"),this.resumeStdin(),this.altScreenActive?this.resetFramesForAltScreen():this.repaint(),this.resume(),this.options.stdout.write("\x1B[?1004h"+(Bi()?qr+Ti+Ei:""));}flushStaticNodes(){let e=this.options.stdout.columns||80,n=false;yp(this.rootNode,r=>{let o=r.pendingStaticElement;if(o){r.pendingStaticElement=void 0;try{let{screen:i}=lp(o,e);if(i.height>0){let s=Gm(i,this.stylePool);this.options.stdout.write(s),n=!0;}}catch(i){$e(`[Static] render error: ${i}`);}for(let i of [...r.childNodes])Qr(r,i);}}),n&&(this.frontFrame=Xn(this.frontFrame.viewport.height,this.frontFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.backFrame=Xn(this.backFrame.viewport.height,this.backFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.log.reset(),this.displayCursor=null,this.prevFrameContaminated=true);}onRender(){if(this.isUnmounted||this.isPaused)return;this.drainTimer!==null&&(clearTimeout(this.drainTimer),this.drainTimer=null),this.flushStaticNodes();let e=performance.now(),n=this.options.stdout.columns||80,r=this.options.stdout.rows||24,o=this.renderer({frontFrame:this.frontFrame,backFrame:this.backFrame,isTTY:this.options.stdout.isTTY,terminalWidth:n,terminalRows:r,altScreen:this.altScreenActive,prevFrameContaminated:this.prevFrameContaminated}),i=performance.now()-e,s=op();if(s&&this.selection.anchor&&this.selection.anchor.row>=s.viewportTop&&this.selection.anchor.row<=s.viewportBottom){let{delta:O,viewportTop:L,viewportBottom:J}=s;this.selection.isDragging?(cn(this.selection)&&(O>0?Po(this.selection,this.frontFrame.screen,L,L+O-1,"above"):Po(this.selection,this.frontFrame.screen,J+O+1,J,"below")),om(this.selection,-O,L,J)):(!this.selection.focus||this.selection.focus.row>=L&&this.selection.focus.row<=J)&&(cn(this.selection)&&(O>0?Po(this.selection,this.frontFrame.screen,L,L+O-1,"above"):Po(this.selection,this.frontFrame.screen,J+O+1,J,"below")),nc(this.selection,-O,L,J,this.frontFrame.screen.width,false));}let l=false,c=false;if(this.altScreenActive&&(l=cn(this.selection),l&&am(o.screen,this.selection,this.stylePool),c=dp(o.screen,this.searchHighlightQuery,this.stylePool),this.searchPositions)){let O=this.searchPositions,L=up(o.screen,this.stylePool,O.positions,O.rowOffset,O.currentIdx);c=c||L;}(tp()||l||c||this.prevFrameContaminated)&&(o.screen.damage={x:0,y:0,width:o.screen.width,height:o.screen.height});let d$1=this.frontFrame;this.altScreenActive&&(d$1={...this.frontFrame,cursor:W0});let f=performance.now(),m=this.log.render(d$1,o,this.altScreenActive,cc),g=performance.now()-f;this.backFrame=this.frontFrame,this.frontFrame=o,e-this.lastPoolResetTime>300*1e3&&(this.resetPools(),this.lastPoolResetTime=e);let y=[];for(let O of m)if(O.type==="clearTerminal"&&(y.push({desiredHeight:o.screen.height,availableHeight:o.viewport.height,reason:O.reason}),Vl()&&O.debug)){let L=kf(this.rootNode,O.debug.triggerY);$e(`[REPAINT] full reset \xB7 ${O.reason} \xB7 row ${O.debug.triggerY}
61
- prev: "${O.debug.prevLine}"
62
- next: "${O.debug.nextLine}"
63
- culprit: ${L.length?L.join(" < "):"(no owner chain captured)"}`,{level:"warn"});}let w=performance.now(),x=xc(m),v=performance.now()-w,b=x.length>0;this.altScreenActive&&b&&(this.needsEraseBeforePaint?(this.needsEraseBeforePaint=false,x.unshift(G0)):x.unshift(U0),x.push(this.altScreenParkPatch));let h=this.cursorDeclaration,T=h!==null?dt.get(h.node):void 0,A=h!==null&&T!==void 0?{x:T.x+h.relativeX,y:T.y+h.relativeY}:null,M=this.displayCursor,D=A!==null&&(M===null||M.x!==A.x||M.y!==A.y);if(b||D||A===null&&M!==null){if(M!==null&&!this.altScreenActive&&b){let O=d$1.cursor.x-M.x,L=d$1.cursor.y-M.y;(O!==0||L!==0)&&x.unshift({type:"stdout",content:wo(O,L)});}if(A!==null){if(this.altScreenActive){let O=Math.min(Math.max(A.y+1,1),r),L=Math.min(Math.max(A.x+1,1),n);x.push({type:"stdout",content:Cl(O,L)});}else {let O=!b&&M!==null?M:{x:o.cursor.x,y:o.cursor.y},L=A.x-O.x,J=A.y-O.y;(L!==0||J!==0)&&x.push({type:"stdout",content:wo(L,J)});}this.displayCursor=A;}else {if(M!==null&&!this.altScreenActive&&!b){let O=o.cursor.x-M.x,L=o.cursor.y-M.y;(O!==0||L!==0)&&x.push({type:"stdout",content:wo(O,L)});}this.displayCursor=null;}}let N=performance.now();uc(this.terminal,x,this.altScreenActive&&!cc);let R=performance.now()-N;if(this.prevFrameContaminated=l||c,o.scrollDrainPending){this.drainConsecutive++;let O=Ea();if(this.drainTrace.push(O?.pendingScrollDelta??null),this.drainTrace.length>20&&this.drainTrace.shift(),this.drainConsecutive>15){let L=O;d.warn("render.scroll_drain_runaway",{consecutive:this.drainConsecutive,pendingTrace:[...this.drainTrace],stuck:L?{pending:L.pendingScrollDelta,scrollTop:L.scrollTop,scrollHeight:L.scrollHeight,scrollViewportHeight:L.scrollViewportHeight,stickyScroll:L.stickyScroll,scrollClampMin:L.scrollClampMin,scrollClampMax:L.scrollClampMax,hasAnchor:L.scrollAnchor!==void 0}:null,isRunning:!this.isPaused}),L&&(L.pendingScrollDelta=void 0),Ta(),this.drainConsecutive=0,this.drainTrace.length=0;}else this.drainTimer=setTimeout(()=>this.onRender(),4);}else this.drainConsecutive=0,this.drainTrace.length=0;let E=Lf(),I=Ff(),F=this.lastYogaCounters;$f(),this.lastYogaCounters={ms:0,visited:0,measured:0,cacheHits:0,live:0},this.options.onFrame?.({durationMs:performance.now()-e,phases:{renderer:i,diff:g,optimize:v,write:R,patches:m.length,yoga:E,commit:I,yogaVisited:F.visited,yogaMeasured:F.measured,yogaCacheHits:F.cacheHits,yogaLive:F.live},flickers:y});}pause(){Wt.flushSyncFromReconciler(),this.onRender(),this.isPaused=true;}resume(){this.isPaused=false,this.onRender();}repaint(){this.frontFrame=Xn(this.frontFrame.viewport.height,this.frontFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.backFrame=Xn(this.backFrame.viewport.height,this.backFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.log.reset(),this.displayCursor=null;}forceRedraw(e={}){if(!this.options.stdout.isTTY||this.isUnmounted||this.isPaused)return;let n=e.clearScrollback?dr+vi+On:dr+On;this.options.stdout.write(n),this.altScreenActive?this.resetFramesForAltScreen():(this.repaint(),this.prevFrameContaminated=true),this.onRender();}invalidatePrevFrame(){this.prevFrameContaminated=true;}setAltScreenActive(e,n=false){this.altScreenActive!==e&&(this.altScreenActive=e,this.altScreenMouseTracking=e&&n,e?this.resetFramesForAltScreen():this.repaint());}get isAltScreenActive(){return this.altScreenActive}reassertTerminalModes=a((e=false)=>{this.options.stdout.isTTY&&(this.isPaused||(Bi()&&this.options.stdout.write(qr+Ti+Ei),this.altScreenActive&&(this.altScreenMouseTracking&&this.options.stdout.write(no),e&&this.reenterAltScreen())));},"reassertTerminalModes");detachForShutdown(){this.isUnmounted=true,this.scheduleRender.cancel?.();let e=this.options.stdin;this.drainStdin(),e.isTTY&&e.isRaw&&e.setRawMode&&e.setRawMode(false);}drainStdin(){j0(this.options.stdin);}reenterAltScreen(){this.options.stdout.write(Li+dr+On+(this.altScreenMouseTracking?no:"")),this.resetFramesForAltScreen();}resetFramesForAltScreen(){let e=this.terminalRows,n=this.terminalColumns,r=a(()=>({screen:zn(n,e,this.stylePool,this.charPool,this.hyperlinkPool),viewport:{width:n,height:e+1},cursor:{x:0,y:0,visible:true}}),"blank");this.frontFrame=r(),this.backFrame=r(),this.log.reset(),this.displayCursor=null,this.prevFrameContaminated=true;}copySelectionNoClear(){if(!cn(this.selection))return "";let e=sm(this.selection,this.frontFrame.screen);return e&&mm(e).then(n=>{n&&this.options.stdout.write(n);}),e}copySelection(){if(!cn(this.selection))return "";let e=this.copySelectionNoClear();return ta(this.selection),this.notifySelectionChange(),e}clearTextSelection(){cn(this.selection)&&(ta(this.selection),this.notifySelectionChange());}setSearchHighlight(e){this.searchHighlightQuery!==e&&(this.searchHighlightQuery=e,this.scheduleRender());}scanElementSubtree(e){if(!this.searchHighlightQuery||!e.yogaNode)return [];let n=Math.ceil(e.yogaNode.getComputedWidth()),r=Math.ceil(e.yogaNode.getComputedHeight());if(n<=0||r<=0)return [];let o=e.yogaNode.getComputedLeft(),i=e.yogaNode.getComputedTop(),s=zn(n,r,this.stylePool,this.charPool,this.hyperlinkPool),l=new br({width:n,height:r,stylePool:this.stylePool,screen:s});Wo(e,l,{offsetX:-o,offsetY:-i,prevScreen:void 0});let c=l.get();Ct(e);let d=cp(c,this.searchHighlightQuery);return $e(`scanElementSubtree: q='${this.searchHighlightQuery}' el=${n}x${r}@(${o},${i}) n=${d.length} [${d.slice(0,10).map(f=>`${f.row}:${f.col}`).join(",")}${d.length>10?",\u2026":""}]`),d}setSearchPositions(e){this.searchPositions=e,this.scheduleRender();}setSelectionBgColor(e){let n=wi("\0",e,"background"),r=n.indexOf("\0");if(r<=0||r===n.length-1){this.stylePool.setSelectionBg(null);return}this.stylePool.setSelectionBg({type:"ansi",code:n.slice(0,r),endCode:n.slice(r+1)});}captureScrolledRows(e,n,r){Po(this.selection,this.frontFrame.screen,e,n,r);}shiftSelectionForScroll(e,n,r){let o=cn(this.selection);nc(this.selection,e,n,r,this.frontFrame.screen.width),o&&!cn(this.selection)&&this.notifySelectionChange();}moveSelectionFocus(e){if(!this.altScreenActive)return;let{focus:n}=this.selection;if(!n)return;let{width:r,height:o}=this.frontFrame.screen,i=r-1,s=o-1,{col:l,row:c}=n;switch(e){case "left":l>0?l--:c>0&&(l=i,c--);break;case "right":l<i?l++:c<s&&(l=0,c++);break;case "up":c>0&&c--;break;case "down":c<s&&c++;break;case "lineStart":l=0;break;case "lineEnd":l=i;break}l===n.col&&c===n.row||(rm(this.selection,l,c),this.notifySelectionChange());}hasTextSelection(){return cn(this.selection)}subscribeToSelectionChange(e){return this.selectionListeners.add(e),()=>this.selectionListeners.delete(e)}notifySelectionChange(){this.onRender();for(let e of this.selectionListeners)e();}notifySelectionFinish(){cn(this.selection)&&this.copySelectionNoClear(),this.notifySelectionChange();}dispatchClick(e,n){if(!this.altScreenActive)return false;let r=Js(this.frontFrame.screen,e,n);return Bm(this.rootNode,e,n,r)}dispatchHover(e,n){this.altScreenActive&&Fm(this.rootNode,e,n,this.hoveredNodes);}dispatchKeyboardEvent(e){let n=this.focusManager.activeElement??this.rootNode,r=new fa(e);mr.dispatchDiscrete(n,r),!r.defaultPrevented&&e.name==="tab"&&!e.ctrl&&!e.meta&&(e.shift?this.focusManager.focusPrevious(this.rootNode):this.focusManager.focusNext(this.rootNode));}getHyperlinkAt(e,n){if(!this.altScreenActive)return;let r=this.frontFrame.screen,o=vt(r,e,n),i=o?.hyperlink;return !i&&o?.width===2&&e>0&&(i=vt(r,e-1,n)?.hyperlink),i??em(r,e,n)}onHyperlinkClick;openHyperlink(e){this.onHyperlinkClick?.(e);}handleMultiClick(e,n,r){if(!this.altScreenActive)return;let o=this.frontFrame.screen;ea(this.selection,e,n),r===2?Zf(this.selection,o,e,n):tm(this.selection,o,n),this.selection.focus||(this.selection.focus=this.selection.anchor),this.notifySelectionChange();}handleSelectionDrag(e,n){if(!this.altScreenActive)return;let r=this.selection;r.anchorSpan?nm(r,this.frontFrame.screen,e,n):Xf(r,e,n),this.notifySelectionChange();}stdinListeners=[];wasRawMode=false;suspendStdin(){let e=this.options.stdin;if(!e.isTTY)return;let n=e.listeners("readable");$e(`[stdin] suspendStdin: removing ${n.length} readable listener(s), wasRawMode=${e.isRaw??false}`),n.forEach(o=>{this.stdinListeners.push({event:"readable",listener:o}),e.removeListener("readable",o);});let r=e;r.isRaw&&r.setRawMode&&(r.setRawMode(false),this.wasRawMode=true);}resumeStdin(){let e=this.options.stdin;if(e.isTTY&&(this.stdinListeners.length===0&&!this.wasRawMode&&$e("[stdin] resumeStdin: called with no stored listeners and wasRawMode=false (possible desync)",{level:"warn"}),$e(`[stdin] resumeStdin: re-attaching ${this.stdinListeners.length} listener(s), wasRawMode=${this.wasRawMode}`),this.stdinListeners.forEach(({event:n,listener:r})=>{e.addListener(n,r);}),this.stdinListeners=[],this.wasRawMode)){let n=e;n.setRawMode&&n.setRawMode(true),this.wasRawMode=false;}}writeRaw(e){this.options.stdout.write(e);}setCursorDeclaration=a((e,n)=>{e===null&&n!==void 0&&this.cursorDeclaration?.node!==n||(this.cursorDeclaration=e);},"setCursorDeclaration");render(e){this.currentNode=e;let n=jsx(Fi,{stdin:this.options.stdin,stdout:this.options.stdout,stderr:this.options.stderr,exitOnCtrlC:this.options.exitOnCtrlC,onExit:this.unmount,terminalColumns:this.terminalColumns,terminalRows:this.terminalRows,selection:this.selection,onSelectionChange:this.notifySelectionChange,onSelectionFinish:this.notifySelectionFinish,onClickAt:this.dispatchClick,onHoverAt:this.dispatchHover,getHyperlinkAt:this.getHyperlinkAt,onOpenHyperlink:this.openHyperlink,onMultiClick:this.handleMultiClick,onSelectionDrag:this.handleSelectionDrag,onStdinResume:this.reassertTerminalModes,onCursorDeclaration:this.setCursorDeclaration,dispatchKeyboardEvent:this.dispatchKeyboardEvent,children:jsx(fp,{value:this.writeRaw,children:e})});Wt.updateContainerSync(n,this.container,null,Uo),Wt.flushSyncWork();}unmount(e){if(this.isUnmounted)return;this.onRender(),this.unsubscribeExit(),typeof this.restoreConsole=="function"&&this.restoreConsole(),this.restoreStderr?.(),this.unsubscribeTTYHandlers?.();let n=this.log.renderPreviousOutput_DEPRECATED(this.frontFrame);uc(this.terminal,xc(n)),this.options.stdout.isTTY&&(this.altScreenActive&&writeSync(1,ra),writeSync(1,ro),this.drainStdin(),writeSync(1,Ci),writeSync(1,qr),writeSync(1,Di),writeSync(1,na),writeSync(1,to),writeSync(1,ym),xm()&&writeSync(1,ac(bm))),this.isUnmounted=true,this.scheduleRender.cancel?.(),this.drainTimer!==null&&(clearTimeout(this.drainTimer),this.drainTimer=null),Wt.updateContainerSync(null,this.container,null,Uo),Wt.flushSyncWork(),Qn.delete(this.options.stdout),this.rootNode.yogaNode?.free(),this.rootNode.yogaNode=void 0,e instanceof Error?this.rejectExitPromise(e):this.resolveExitPromise();}async waitUntilExit(){return this.exitPromise||=new Promise((e,n)=>{this.resolveExitPromise=e,this.rejectExitPromise=n;}),this.exitPromise}resetLineCount(){this.options.stdout.isTTY&&(this.backFrame=this.frontFrame,this.frontFrame=Xn(this.frontFrame.viewport.height,this.frontFrame.viewport.width,this.stylePool,this.charPool,this.hyperlinkPool),this.log.reset(),this.displayCursor=null);}resetPools(){this.charPool=new Zr,this.hyperlinkPool=new eo,Gf(this.frontFrame.screen,this.charPool,this.hyperlinkPool),this.backFrame.screen.charPool=this.charPool,this.backFrame.screen.hyperlinkPool=this.hyperlinkPool;}patchConsole(){let e=console,n={},r=a((...i)=>$e(`console.log: ${format(...i)}`),"toDebug"),o=a((...i)=>d.error(new Error(`console.error: ${format(...i)}`)),"toError");for(let i of K0)n[i]=e[i],e[i]=r;for(let i of Y0)n[i]=e[i],e[i]=o;return n.assert=e.assert,e.assert=(i,...s)=>{i||o(...s);},()=>Object.assign(e,n)}patchStderr(){let e=process.stderr,n=e.write,r=false,o=a((i,s,l)=>{let c=typeof s=="function"?s:l;if(r){let d=typeof s=="string"?s:void 0;return n.call(e,i,d,c)}r=true;try{let d=typeof i=="string"?i:Buffer.from(i).toString("utf8");$e(`[stderr] ${d}`,{level:"warn"}),this.altScreenActive&&!this.isUnmounted&&!this.isPaused&&(this.prevFrameContaminated=!0,this.scheduleRender());}finally{r=false,c?.();}return true},"intercept");return e.write=o,()=>{e.write===o&&(e.write=n);}}};function j0(t=process.stdin){if(!t.isTTY)return;try{for(;t.read()!==null;);}catch{}if(process.platform==="win32")return;let e=t,n=e.isRaw===true,r=-1;try{n||e.setRawMode?.(!0),r=openSync("/dev/tty",constants.O_RDONLY|constants.O_NONBLOCK);let o=Buffer.alloc(1024);for(let i=0;i<64&&!(readSync(r,o,0,o.length,null)<=0);i++);}catch{}finally{if(r>=0)try{closeSync(r);}catch{}if(!n)try{e.setRawMode?.(!1);}catch{}}}a(j0,"drainStdin");var K0=["log","info","debug","dir","dirxml","count","countReset","group","groupCollapsed","groupEnd","table","time","timeEnd","timeLog"],Y0=["warn","error","trace"];var bp=a((t,e)=>{let n=z0(e),r={stdout:process.stdout,stdin:process.stdin,stderr:process.stderr,exitOnCtrlC:true,patchConsole:true,...n},o=J0(r.stdout,()=>new Ui(r));return o.render(t),{rerender:o.render,unmount(){o.unmount();},waitUntilExit:o.waitUntilExit,cleanup:a(()=>Qn.delete(r.stdout),"cleanup")}},"renderSync"),q0=a(async(t,e)=>{await Promise.resolve();let n=bp(t,e);return $e(`[render] first ink render: ${Math.round(process.uptime()*1e3)}ms since process start`),n},"wrappedRender"),Gi=q0;var z0=a((t={})=>t instanceof Stream?{stdout:t,stdin:process.stdin}:t,"getOptions"),J0=a((t,e)=>{let n=Qn.get(t);return n||(n=e(),Qn.set(t,n)),n},"getInstance");h();h();h();h();h();var Q0=a(()=>useContext(ca),"useApp"),Pc=Q0;h();h();var eS=a(()=>useContext(ua),"useStdin"),Dc=eS;var oS=a((t,e={})=>{let{setRawMode:n,internal_exitOnCtrlC:r,internal_eventEmitter:o}=Dc();useLayoutEffect(()=>{if(e.isActive!==false)return n(true),()=>{n(false);}},[e.isActive,n]);let i=useEventCallback(s=>{if(e.isActive===false)return;let{input:l,key:c}=s;(!(l==="c"&&c.ctrl)||!r)&&t(l,c,s);});useEffect(()=>(o?.on("input",i),()=>{o?.removeListener("input",i);}),[o,i]);},"useInput"),ft=oS;h();var aS=process.env.CODESHELL_RENDER_DEBUG==="verbose";function lS({children:t,ref:e,stickyScroll:n,...r}){let o=useRef(null),[,i]=useState(0),s=useRef(new Set),l=useRef(false),c=a(()=>{for(let f of s.current)f();},"notify");function d$1(f){P(),Ct(f),Bf(),c(),!l.current&&(l.current=true,queueMicrotask(()=>{l.current=false,Cf(f);}));}return a(d$1,"scrollMutated"),useImperativeHandle(e,()=>({scrollTo(f){let m=o.current;m&&(m.stickyScroll=false,m.pendingScrollDelta=void 0,m.scrollAnchor=void 0,m.scrollTop=Math.max(0,Math.floor(f)),d$1(m));},scrollToElement(f,m=0){let g=o.current;g&&(g.stickyScroll=false,g.pendingScrollDelta=void 0,g.scrollAnchor={el:f,offset:m},d$1(g));},scrollBy(f){let m=o.current;if(!m)return;m.stickyScroll=false,m.scrollAnchor=void 0;let g=m.pendingScrollDelta??0;if(m.pendingScrollDelta=g+Math.floor(f),aS){let y=new Error().stack?.split(`
64
- `).slice(2,7).join(`
65
- `);d.debug("render.scrollBy",{dy:f,before:g,after:m.pendingScrollDelta,scrollTop:m.scrollTop,stack:y});}d$1(m);},scrollToBottom(){let f=o.current;f&&(f.pendingScrollDelta=void 0,f.stickyScroll=true,Ct(f),c(),i(m=>m+1));},getScrollTop(){return o.current?.scrollTop??0},getPendingDelta(){return o.current?.pendingScrollDelta??0},getScrollHeight(){return o.current?.scrollHeight??0},getFreshScrollHeight(){return o.current?.childNodes[0]?.yogaNode?.getComputedHeight()??o.current?.scrollHeight??0},getViewportHeight(){return o.current?.scrollViewportHeight??0},getViewportTop(){return o.current?.scrollViewportTop??0},isSticky(){let f=o.current;return f?f.stickyScroll??!!f.attributes.stickyScroll:false},subscribe(f){return s.current.add(f),()=>s.current.delete(f)},setClampBounds(f,m){let g=o.current;g&&(g.scrollClampMin=f,g.scrollClampMax=m);}}),[]),jsx("ink-box",{ref:f=>{o.current=f,f&&(f.scrollTop??=0);},style:{flexWrap:"nowrap",flexDirection:r.flexDirection??"row",flexGrow:r.flexGrow??0,flexShrink:r.flexShrink??1,...r,overflowX:"scroll",overflowY:"scroll"},...n?{stickyScroll:true}:{},children:jsx(S,{flexDirection:"column",flexGrow:1,flexShrink:0,width:"100%",children:t})})}a(lS,"ScrollBox");var Lc=lS;h();function Bc(t){let e=c(7),{children:n,mouseTracking:r}=t,o=r===void 0?true:r,i=useContext(da),s=useContext(Oc),l,c$1;e[0]!==o||e[1]!==s?(l=a(()=>{let m=Qn.get(process.stdout);if(s)return s(Li+"\x1B[2J\x1B[H"+(o?no:"")),m?.setAltScreenActive(true,o),()=>{m?.setAltScreenActive(false),m?.clearTextSelection(),s((o?ro:"")+ra);}},"t2"),c$1=[s,o],e[0]=o,e[1]=s,e[2]=l,e[3]=c$1):(l=e[2],c$1=e[3]),useInsertionEffect(l,c$1);let d=i?.rows??24,f;return e[4]!==n||e[5]!==d?(f=jsx(S,{flexDirection:"column",height:d,width:"100%",flexShrink:0,children:n}),e[4]=n,e[5]=d,e[6]=f):f=e[6],f}a(Bc,"AlternateScreen");h();h();h();var wp=["ghostty","Hyper","kitty","alacritty","iTerm.app","iTerm2"];function vp(t){if(t?.stdoutSupported??fS.stdout)return true;let n=t?.env??process.env,r=n.TERM_PROGRAM;if(r&&wp.includes(r))return true;let o=n.LC_TERMINAL;return !!(o&&wp.includes(o)||n.TERM?.includes("kitty"))}a(vp,"supportsHyperlinks");function ji(t){let e=c(5),{children:n,url:r,fallback:o}=t,i=n??r;if(vp()){let c;return e[0]!==i||e[1]!==r?(c=jsx(u,{children:jsx("ink-link",{href:r,children:i})}),e[0]=i,e[1]=r,e[2]=c):c=e[2],c}let s=o??i,l;return e[3]!==s?(l=jsx(u,{children:s}),e[3]=s,e[4]=l):l=e[4],l}a(ji,"Link");h();h();h();function Tp(t){if(t.length===0)return null;let e=t[0];return e==="c"?{type:"reset"}:e==="7"?{type:"cursor",action:{type:"save"}}:e==="8"?{type:"cursor",action:{type:"restore"}}:e==="D"?{type:"cursor",action:{type:"move",direction:"down",count:1}}:e==="M"?{type:"cursor",action:{type:"move",direction:"up",count:1}}:e==="E"?{type:"cursor",action:{type:"nextLine",count:1}}:e==="H"||"()".includes(e)&&t.length>=2?null:{type:"unknown",sequence:`\x1B${t}`}}a(Tp,"parseEsc");h();h();function jo(){return {bold:false,dim:false,italic:false,underline:"none",blink:false,inverse:false,hidden:false,strikethrough:false,overline:false,fg:{type:"default"},bg:{type:"default"},underlineColor:{type:"default"}}}a(jo,"defaultStyle");var ka=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],pS=["none","single","double","curly","dotted","dashed"];function gS(t){if(t==="")return [{value:0,subparams:[],colon:false}];let e=[],n={value:null,subparams:[],colon:false},r="",o=false;for(let i=0;i<=t.length;i++){let s=t[i];if(s===";"||s===void 0){let l=r===""?null:parseInt(r,10);o?l!==null&&n.subparams.push(l):n.value=l,e.push(n),n={value:null,subparams:[],colon:false},r="",o=false;}else if(s===":"){let l=r===""?null:parseInt(r,10);o?l!==null&&n.subparams.push(l):(n.value=l,n.colon=true,o=true),r="";}else s>="0"&&s<="9"&&(r+=s);}return e}a(gS,"parseParams");function $c(t,e){let n=t[e];if(!n)return null;if(n.colon&&n.subparams.length>=1){if(n.subparams[0]===5&&n.subparams.length>=2)return {index:n.subparams[1]};if(n.subparams[0]===2&&n.subparams.length>=4){let o=n.subparams.length>=5?1:0;return {r:n.subparams[1+o],g:n.subparams[2+o],b:n.subparams[3+o]}}}let r=t[e+1];if(!r)return null;if(r.value===5&&t[e+2]?.value!==null&&t[e+2]?.value!==void 0)return {index:t[e+2].value};if(r.value===2){let o=t[e+2]?.value,i=t[e+3]?.value,s=t[e+4]?.value;if(o!=null&&i!==null&&i!==void 0&&s!==null&&s!==void 0)return {r:o,g:i,b:s}}return null}a($c,"parseExtendedColor");function Ep(t,e){let n=gS(t),r={...e},o=0;for(;o<n.length;){let i=n[o],s=i.value??0;if(s===0){r=jo(),o++;continue}if(s===1){r.bold=true,o++;continue}if(s===2){r.dim=true,o++;continue}if(s===3){r.italic=true,o++;continue}if(s===4){r.underline=i.colon?pS[i.subparams[0]]??"single":"single",o++;continue}if(s===5||s===6){r.blink=true,o++;continue}if(s===7){r.inverse=true,o++;continue}if(s===8){r.hidden=true,o++;continue}if(s===9){r.strikethrough=true,o++;continue}if(s===21){r.underline="double",o++;continue}if(s===22){r.bold=false,r.dim=false,o++;continue}if(s===23){r.italic=false,o++;continue}if(s===24){r.underline="none",o++;continue}if(s===25){r.blink=false,o++;continue}if(s===27){r.inverse=false,o++;continue}if(s===28){r.hidden=false,o++;continue}if(s===29){r.strikethrough=false,o++;continue}if(s===53){r.overline=true,o++;continue}if(s===55){r.overline=false,o++;continue}if(s>=30&&s<=37){r.fg={type:"named",name:ka[s-30]},o++;continue}if(s===39){r.fg={type:"default"},o++;continue}if(s>=40&&s<=47){r.bg={type:"named",name:ka[s-40]},o++;continue}if(s===49){r.bg={type:"default"},o++;continue}if(s>=90&&s<=97){r.fg={type:"named",name:ka[s-90+8]},o++;continue}if(s>=100&&s<=107){r.bg={type:"named",name:ka[s-100+8]},o++;continue}if(s===38){let l=$c(n,o);if(l){r.fg="index"in l?{type:"indexed",index:l.index}:{type:"rgb",...l},o+=i.colon?1:"index"in l?3:5;continue}}if(s===48){let l=$c(n,o);if(l){r.bg="index"in l?{type:"indexed",index:l.index}:{type:"rgb",...l},o+=i.colon?1:"index"in l?3:5;continue}}if(s===58){let l=$c(n,o);if(l){r.underlineColor="index"in l?{type:"indexed",index:l.index}:{type:"rgb",...l},o+=i.colon?1:"index"in l?3:5;continue}}if(s===59){r.underlineColor={type:"default"},o++;continue}o++;}return r}a(Ep,"applySGR");function hS(t){return t>=9728&&t<=9983||t>=9984&&t<=10175||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=127456&&t<=127487}a(hS,"isEmoji");function yS(t){return t>=4352&&t<=4447||t>=11904&&t<=40959||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65055||t>=65072&&t<=65135||t>=65280&&t<=65376||t>=65504&&t<=65510||t>=131072&&t<=196605||t>=196608&&t<=262141}a(yS,"isEastAsianWide");function bS(t){let e=0;for(let n of t)if(e++,e>1)return true;return false}a(bS,"hasMultipleCodepoints");function xS(t){if(bS(t))return 2;let e=t.codePointAt(0);return e===void 0?1:hS(e)||yS(e)?2:1}a(xS,"graphemeWidth");function*Cp(t){for(let{segment:e}of Yr().segment(t))yield {value:e,width:xS(e)};}a(Cp,"segmentGraphemes");function SS(t){return t===""?[]:t.split(/[;:]/).map(e=>e===""?0:parseInt(e,10))}a(SS,"parseCSIParams");function wS(t){let e=t.slice(2);if(e.length===0)return null;let n=e.charCodeAt(e.length-1),r=e.slice(0,-1),o="",i=r,s="";r.length>0&&"?>=".includes(r[0])&&(o=r[0],i=r.slice(1));let l=i.match(/([^0-9;:]+)$/);l&&(s=l[1],i=i.slice(0,-s.length));let c=SS(i),d=c[0]??1,f=c[1]??1;if(n===tt.SGR&&o==="")return {type:"sgr",params:i};if(n===tt.CUU)return {type:"cursor",action:{type:"move",direction:"up",count:d}};if(n===tt.CUD)return {type:"cursor",action:{type:"move",direction:"down",count:d}};if(n===tt.CUF)return {type:"cursor",action:{type:"move",direction:"forward",count:d}};if(n===tt.CUB)return {type:"cursor",action:{type:"move",direction:"back",count:d}};if(n===tt.CNL)return {type:"cursor",action:{type:"nextLine",count:d}};if(n===tt.CPL)return {type:"cursor",action:{type:"prevLine",count:d}};if(n===tt.CHA)return {type:"cursor",action:{type:"column",col:d}};if(n===tt.CUP||n===tt.HVP)return {type:"cursor",action:{type:"position",row:d,col:f}};if(n===tt.VPA)return {type:"cursor",action:{type:"row",row:d}};if(n===tt.ED)return {type:"erase",action:{type:"display",region:$d[c[0]??0]??"toEnd"}};if(n===tt.EL)return {type:"erase",action:{type:"line",region:Hd[c[0]??0]??"toEnd"}};if(n===tt.ECH)return {type:"erase",action:{type:"chars",count:d}};if(n===tt.SU)return {type:"scroll",action:{type:"up",count:d}};if(n===tt.SD)return {type:"scroll",action:{type:"down",count:d}};if(n===tt.DECSTBM)return {type:"scroll",action:{type:"setRegion",top:d,bottom:f}};if(n===tt.SCOSC)return {type:"cursor",action:{type:"save"}};if(n===tt.SCORC)return {type:"cursor",action:{type:"restore"}};if(n===tt.DECSCUSR&&s===" ")return {type:"cursor",action:{type:"style",...El[d]??El[0]}};if(o==="?"&&(n===tt.SM||n===tt.RM)){let m=n===tt.SM;if(d===Ge.CURSOR_VISIBLE)return {type:"cursor",action:m?{type:"show"}:{type:"hide"}};if(d===Ge.ALT_SCREEN_CLEAR||d===Ge.ALT_SCREEN)return {type:"mode",action:{type:"alternateScreen",enabled:m}};if(d===Ge.BRACKETED_PASTE)return {type:"mode",action:{type:"bracketedPaste",enabled:m}};if(d===Ge.MOUSE_NORMAL)return {type:"mode",action:{type:"mouseTracking",mode:m?"normal":"off"}};if(d===Ge.MOUSE_BUTTON)return {type:"mode",action:{type:"mouseTracking",mode:m?"button":"off"}};if(d===Ge.MOUSE_ANY)return {type:"mode",action:{type:"mouseTracking",mode:m?"any":"off"}};if(d===Ge.FOCUS_EVENTS)return {type:"mode",action:{type:"focusEvents",enabled:m}}}return {type:"unknown",sequence:t}}a(wS,"parseCSI");function vS(t){if(t.length<2||t.charCodeAt(0)!==qn.ESC)return "unknown";let e=t.charCodeAt(1);return e===91?"csi":e===93?"osc":e===79?"ss3":"esc"}a(vS,"identifySequence");var Ki=class{static{a(this,"Parser");}tokenizer=vo();style=jo();inLink=false;linkUrl;reset(){this.tokenizer.reset(),this.style=jo(),this.inLink=false,this.linkUrl=void 0;}feed(e){let n=this.tokenizer.feed(e),r=[];for(let o of n){let i=this.processToken(o);r.push(...i);}return r}processToken(e){switch(e.type){case "text":return this.processText(e.value);case "sequence":return this.processSequence(e.value)}}processText(e){let n=[],r="";for(let o of e)if(o.charCodeAt(0)===qn.BEL){if(r){let i=[...Cp(r)];i.length>0&&n.push({type:"text",graphemes:i,style:{...this.style}}),r="";}n.push({type:"bell"});}else r+=o;if(r){let o=[...Cp(r)];o.length>0&&n.push({type:"text",graphemes:o,style:{...this.style}});}return n}processSequence(e){switch(vS(e)){case "csi":{let r=wS(e);return r?r.type==="sgr"?(this.style=Ep(r.params,this.style),[]):[r]:[]}case "osc":{let r=e.slice(2);r.endsWith("\x07")?r=r.slice(0,-1):r.endsWith("\x1B\\")&&(r=r.slice(0,-2));let o=pm(r);return o?(o.type==="link"&&(o.action.type==="start"?(this.inLink=true,this.linkUrl=o.action.url):(this.inLink=false,this.linkUrl=void 0)),[o]):[]}case "esc":{let r=e.slice(1),o=Tp(r);return o?[o]:[]}case "ss3":return [{type:"unknown",sequence:e}];default:return [{type:"unknown",sequence:e}]}}};var dn=Lg.memo(a(function(e){let n=c(12),{children:r,dimColor:o}=e;if(typeof r!="string"){let d;return n[0]!==r||n[1]!==o?(d=o?jsx(u,{dim:true,children:String(r)}):jsx(u,{children:String(r)}),n[0]=r,n[1]=o,n[2]=d):d=n[2],d}if(r==="")return null;let i,s;if(n[3]!==r||n[4]!==o){s=Symbol.for("react.early_return_sentinel");e:{let d=ES(r);if(d.length===0){s=null;break e}if(d.length===1&&!RS(d[0].props)){s=o?jsx(u,{dim:true,children:d[0].text}):jsx(u,{children:d[0].text});break e}let f;n[7]!==o?(f=a((m,g)=>{let y=m.props.hyperlink;o&&(m.props.dim=true);let w=MS(m.props);return y?w?jsx(ji,{url:y,children:jsx(_p,{color:m.props.color,backgroundColor:m.props.backgroundColor,dim:m.props.dim,bold:m.props.bold,italic:m.props.italic,underline:m.props.underline,strikethrough:m.props.strikethrough,inverse:m.props.inverse,children:m.text})},g):jsx(ji,{url:y,children:m.text},g):w?jsx(_p,{color:m.props.color,backgroundColor:m.props.backgroundColor,dim:m.props.dim,bold:m.props.bold,italic:m.props.italic,underline:m.props.underline,strikethrough:m.props.strikethrough,inverse:m.props.inverse,children:m.text},g):m.text},"t3"),n[7]=o,n[8]=f):f=n[8],i=d.map(f);}n[3]=r,n[4]=o,n[5]=i,n[6]=s;}else i=n[5],s=n[6];if(s!==Symbol.for("react.early_return_sentinel"))return s;let l=i,c$1;return n[9]!==l||n[10]!==o?(c$1=o?jsx(u,{dim:true,children:l}):jsx(u,{children:l}),n[9]=l,n[10]=o,n[11]=c$1):c$1=n[11],c$1},"Ansi"));function ES(t){let n=new Ki().feed(t),r=[],o;for(let i of n){if(i.type==="link"){i.action.type==="start"?o=i.action.url:o=void 0;continue}if(i.type==="text"){let s=i.graphemes.map(d=>d.value).join("");if(!s)continue;let l=CS(i.style);o&&(l.hyperlink=o);let c=r[r.length-1];c&&_S(c.props,l)?c.text+=s:r.push({text:s,props:l});}}return r}a(ES,"parseToSpans");function CS(t){let e={};t.bold&&(e.bold=true),t.dim&&(e.dim=true),t.italic&&(e.italic=true),t.underline!=="none"&&(e.underline=true),t.strikethrough&&(e.strikethrough=true),t.inverse&&(e.inverse=true);let n=kp(t.fg);n&&(e.color=n);let r=kp(t.bg);return r&&(e.backgroundColor=r),e}a(CS,"textStyleToSpanProps");var kS={black:"ansi:black",red:"ansi:red",green:"ansi:green",yellow:"ansi:yellow",blue:"ansi:blue",magenta:"ansi:magenta",cyan:"ansi:cyan",white:"ansi:white",brightBlack:"ansi:blackBright",brightRed:"ansi:redBright",brightGreen:"ansi:greenBright",brightYellow:"ansi:yellowBright",brightBlue:"ansi:blueBright",brightMagenta:"ansi:magentaBright",brightCyan:"ansi:cyanBright",brightWhite:"ansi:whiteBright"};function kp(t){switch(t.type){case "named":return kS[t.name];case "indexed":return `ansi256(${t.index})`;case "rgb":return `rgb(${t.r},${t.g},${t.b})`;case "default":return}}a(kp,"colorToString");function _S(t,e){return t.color===e.color&&t.backgroundColor===e.backgroundColor&&t.bold===e.bold&&t.dim===e.dim&&t.italic===e.italic&&t.underline===e.underline&&t.strikethrough===e.strikethrough&&t.inverse===e.inverse&&t.hyperlink===e.hyperlink}a(_S,"propsEqual");function RS(t){return t.color!==void 0||t.backgroundColor!==void 0||t.dim===true||t.bold===true||t.italic===true||t.underline===true||t.strikethrough===true||t.inverse===true||t.hyperlink!==void 0}a(RS,"hasAnyProps");function MS(t){return t.color!==void 0||t.backgroundColor!==void 0||t.dim===true||t.bold===true||t.italic===true||t.underline===true||t.strikethrough===true||t.inverse===true}a(MS,"hasAnyTextProps");function _p(t){let e=c(14),n,r,o,i;if(e[0]!==t?({bold:n,dim:o,children:r,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=o,e[4]=i):(n=e[1],r=e[2],o=e[3],i=e[4]),o){let l;return e[5]!==r||e[6]!==i?(l=jsx(u,{...i,dim:true,children:r}),e[5]=r,e[6]=i,e[7]=l):l=e[7],l}if(n){let l;return e[8]!==r||e[9]!==i?(l=jsx(u,{...i,bold:true,children:r}),e[8]=r,e[9]=i,e[10]=l):l=e[10],l}let s;return e[11]!==r||e[12]!==i?(s=jsx(u,{...i,children:r}),e[11]=r,e[12]=i,e[13]=s):s=e[13],s}a(_p,"StyledText");h();h();h();h();function Mp(t={}){let e=t.stdout??process.stdout;Qn.get(e)?.forceRedraw({clearScrollback:t.clearScrollback});}a(Mp,"forceRedraw");h();h();var Lr="rgb(45,42,40)",Ko="rgb(250,247,240)",Hc="rgb(235,130,140)",AS="rgb(25,25,25)",Ap="rgb(60,40,20)",Np="rgb(250,247,240)";function Op(){return jsxs(S,{flexDirection:"column",children:[jsxs(u,{children:[jsx(u,{color:Lr,children:"\u259F"}),jsx(u,{color:Hc,children:"\u2596"}),jsx(u,{children:" "}),jsx(u,{color:Hc,children:"\u2597"}),jsx(u,{color:Lr,children:"\u2599"})]}),jsxs(u,{children:[jsx(u,{color:Lr,children:"\u2590\u2588"}),jsx(u,{color:Lr,children:"\u2599"}),jsx(u,{color:Ko,children:"\u2584"}),jsx(u,{color:Lr,children:"\u259F"}),jsx(u,{color:Lr,children:"\u2588\u258C"})]}),jsxs(u,{children:[jsx(u,{color:Lr,children:"\u259D"}),jsx(u,{color:Ap,backgroundColor:Np,children:"\u25CF"}),jsx(u,{color:Ko,children:"\u2584"}),jsx(u,{color:AS,children:"\u25BC"}),jsx(u,{color:Ko,children:"\u2584"}),jsx(u,{color:Ap,backgroundColor:Np,children:"\u25CF"}),jsx(u,{color:Lr,children:"\u2598"})]}),jsxs(u,{children:[jsx(u,{children:" "}),jsx(u,{color:Ko,children:"\u259C"}),jsx(u,{color:Hc,children:"\u2584"}),jsx(u,{color:Ko,children:"\u259B"}),jsx(u,{children:" "})]}),jsxs(u,{children:[jsx(u,{children:" "}),jsx(u,{color:Ko,children:"\u259D\u2580\u2580\u2580\u2598"}),jsx(u,{children:" "})]})]})}a(Op,"DogLogo");h();var Vo="rgb(40,30,25)",In="rgb(240,200,160)",wn="rgb(80,80,180)",qo="rgb(255,255,255)",kt="rgb(80,80,180)",Yi="rgb(255,140,30)",vn="rgb(255,255,255)",PS=6,DS=350;function Dp(){let[t,e]=useState(0);switch(useEffect(()=>{let n=setInterval(()=>{e(r=>(r+1)%PS);},DS);return ()=>clearInterval(n)},[]),t){case 0:return jsx(Pp,{});case 1:return jsx(IS,{});case 2:return jsx(LS,{});case 3:return jsx(BS,{});case 4:return jsx(FS,{});case 5:return jsx($S,{});default:return jsx(Pp,{})}}a(Dp,"KunLogo");function Pp(){return jsxs(S,{flexDirection:"column",children:[jsxs(u,{children:[" ",jsx(u,{color:Vo,children:"\u25D3"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:In,children:"\u2571"}),jsx(u,{color:qo,children:"\u2588"}),jsx(u,{color:In,children:"\u2572"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:wn,children:"\u257F"}),jsx(u,{color:kt,children:"\u2588"}),jsx(u,{color:wn,children:"\u257F"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:kt,children:"\u2502"})," ",jsx(u,{color:kt,children:"\u2502"}),jsx(u,{color:Yi,children:" \u25CE"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:vn,children:"\u2598"})," ",jsx(u,{color:vn,children:"\u2598"})," "]})]})}a(Pp,"F0");function IS(){return jsxs(S,{flexDirection:"column",children:[jsxs(u,{children:[" ",jsx(u,{color:Vo,children:"\u25D3"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:In,children:"\u2571"}),jsx(u,{color:qo,children:"\u2588"}),jsx(u,{color:In,children:"\u2572"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:wn,children:"\u257F"}),jsx(u,{color:kt,children:"\u2588"}),jsx(u,{color:wn,children:"\u257F"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:kt,children:"\u2571"})," ",jsx(u,{color:kt,children:"\u2572"})," "]}),jsxs(u,{children:[jsx(u,{color:vn,children:"\u259D"})," ",jsx(u,{color:vn,children:"\u2598"}),jsx(u,{color:Yi,children:"\u25CE"})," "]})]})}a(IS,"F1");function LS(){return jsxs(S,{flexDirection:"column",children:[jsxs(u,{children:[" ",jsx(u,{color:Vo,children:"\u25D3"})," ",jsx(u,{color:Yi,children:"\u25CE"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:In,children:"\u2571"}),jsx(u,{color:qo,children:"\u2588"}),jsx(u,{color:In,children:"\u2572"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:wn,children:"\u257F"}),jsx(u,{color:kt,children:"\u2588"}),jsx(u,{color:wn,children:"\u257F"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:kt,children:"\u2571"})," ",jsx(u,{color:kt,children:"\u2572"})," "]}),jsxs(u,{children:[jsx(u,{color:vn,children:"\u259D"})," ",jsx(u,{color:vn,children:"\u2598"})," "]})]})}a(LS,"F2");function BS(){return jsxs(S,{flexDirection:"column",children:[jsxs(u,{children:[" ",jsx(u,{color:Vo,children:"\u25D3"}),jsx(u,{color:Yi,children:"\u25CE"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:In,children:"\u2571"}),jsx(u,{color:qo,children:"\u2588"}),jsx(u,{color:In,children:"\u2500"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:wn,children:"\u257F"}),jsx(u,{color:kt,children:"\u2588"}),jsx(u,{color:wn,children:"\u257F"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:kt,children:"\u2571"})," ",jsx(u,{color:kt,children:"\u2572"})," "]}),jsxs(u,{children:[jsx(u,{color:vn,children:"\u259D"})," ",jsx(u,{color:vn,children:"\u2598"})," "]})]})}a(BS,"F3");function FS(){return jsxs(S,{flexDirection:"column",children:[jsxs(u,{children:[" ",jsx(u,{color:Yi,children:"\u25CE"}),jsx(u,{color:Vo,children:"\u25D3"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:qo,children:"\u2588"}),jsx(u,{color:In,children:"\u2572"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:wn,children:"\u257F"}),jsx(u,{color:kt,children:"\u2588"}),jsx(u,{color:wn,children:"\u257F"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:kt,children:"\u2571"})," ",jsx(u,{color:kt,children:"\u2572"})," "]}),jsxs(u,{children:[jsx(u,{color:vn,children:"\u259D"})," ",jsx(u,{color:vn,children:"\u2598"})," "]})]})}a(FS,"F4");function $S(){return jsxs(S,{flexDirection:"column",children:[jsxs(u,{children:[" ",jsx(u,{color:Vo,children:"\u25D3"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:In,children:"\u2571"}),jsx(u,{color:qo,children:"\u2588"}),jsx(u,{color:In,children:"\u2572"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:wn,children:"\u257F"}),jsx(u,{color:kt,children:"\u2588"}),jsx(u,{color:wn,children:"\u257F"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:kt,children:"\u2571"})," ",jsx(u,{color:kt,children:"\u2572"})," "]}),jsxs(u,{children:[jsx(u,{color:vn,children:"\u259D"})," ",jsx(u,{color:vn,children:"\u2598"})," "]})]})}a($S,"F5");h();var so="rgb(40,30,25)",ao="rgb(240,200,160)",HS="rgb(20,20,20)";function Ip(){return jsxs(S,{flexDirection:"column",children:[jsxs(u,{children:[jsx(u,{children:" "}),jsx(u,{color:so,children:"\u2584"}),jsx(u,{color:so,backgroundColor:ao,children:"\u2599\u259F"}),jsx(u,{color:so,children:"\u2584"})]}),jsxs(u,{children:[jsx(u,{color:so,children:"\u2588\u259B"}),jsx(u,{color:ao,children:" "}),jsx(u,{color:so,children:"\u259C\u2588"})]}),jsxs(u,{children:[jsx(u,{color:so,children:"\u259C"}),jsx(u,{color:ao,children:" "}),jsx(u,{color:HS,backgroundColor:ao,children:"\u25CF\u25CF"}),jsx(u,{color:ao,children:" "}),jsx(u,{color:so,children:"\u259B"})]}),jsxs(u,{children:[jsx(u,{children:" "}),jsx(u,{color:ao,children:"\u259C\u2584\u2584\u259B"})]}),jsxs(u,{children:[jsx(u,{children:" "}),jsx(u,{color:ao,children:"\u2580\u2580"})]})]})}a(Ip,"KunHead");h();var Wc="rgb(40,30,25)",Tn="rgb(240,200,160)",Jo="rgb(255,255,255)",Xo="rgb(80,80,180)",Sr="rgb(80,80,180)";var Uc="rgb(255,100,120)",GS=300,jS=12;function Lp(){let[t,e]=useState(0);useEffect(()=>{let i=setInterval(()=>{e(s=>(s+1)%jS);},GS);return ()=>clearInterval(i)},[]);let n=t,r=n<=1?"left":n<=3?"right":n<=5?"left":n<=7?"right":"center",o=n>=8&&n<=11;return r==="left"?jsx(KS,{showBubble:false}):r==="right"?jsx(YS,{showBubble:false}):jsx(VS,{showBubble:o})}a(Lp,"BabyHand");function KS({showBubble:t}){return jsxs(S,{flexDirection:"column",children:[jsxs(u,{children:[" ",jsx(u,{color:Wc,children:"\u25D3"})," ",t?jsx(u,{color:Uc,bold:true,children:"\u8D1D\u8D1D"}):" "]}),jsxs(u,{children:[jsx(u,{color:Tn,children:"\u2571"}),jsx(u,{color:Jo,children:"\u2588"}),jsx(u,{color:Tn,children:"\u2572"})," "]}),jsxs(u,{children:[jsx(u,{color:Tn,children:"\u2571"}),jsx(u,{color:Jo,children:"\u2588\u2588"}),jsx(u,{color:Tn,children:"\u2572"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:Xo,children:"\u257F"}),jsx(u,{color:Sr,children:"\u2588"}),jsx(u,{color:Xo,children:"\u257F"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:Sr,children:"\u2502"})," ",jsx(u,{color:Sr,children:"\u2502"})," "]})]})}a(KS,"PoseLeft");function YS({showBubble:t}){return jsxs(S,{flexDirection:"column",children:[jsxs(u,{children:[" ",jsx(u,{color:Wc,children:"\u25D3"})," ",t?jsx(u,{color:Uc,bold:true,children:"\u8D1D\u8D1D"}):" "]}),jsxs(u,{children:[" ",jsx(u,{color:Tn,children:"\u2571"}),jsx(u,{color:Jo,children:"\u2588"}),jsx(u,{color:Tn,children:"\u2572"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:Tn,children:"\u2571"}),jsx(u,{color:Jo,children:"\u2588\u2588"}),jsx(u,{color:Tn,children:"\u2572"})]}),jsxs(u,{children:[" ",jsx(u,{color:Xo,children:"\u257F"}),jsx(u,{color:Sr,children:"\u2588"}),jsx(u,{color:Xo,children:"\u257F"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:Sr,children:"\u2502"})," ",jsx(u,{color:Sr,children:"\u2502"})," "]})]})}a(YS,"PoseRight");function VS({showBubble:t}){return jsxs(S,{flexDirection:"column",children:[jsxs(u,{children:[" ",jsx(u,{color:Wc,children:"\u25D3"})," ",t?jsx(u,{color:Uc,bold:true,children:"\u8D1D\u8D1D"}):" "]}),jsxs(u,{children:[" ",jsx(u,{color:Tn,children:"\u2571"}),jsx(u,{color:Jo,children:"\u2588"}),jsx(u,{color:Tn,children:"\u2572"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:Tn,children:"\u2571"}),jsx(u,{color:Jo,children:"\u2588\u2588"}),jsx(u,{color:Tn,children:"\u2572"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:Xo,children:"\u257F"}),jsx(u,{color:Sr,children:"\u2588"}),jsx(u,{color:Xo,children:"\u257F"})," "]}),jsxs(u,{children:[" ",jsx(u,{color:Sr,children:"\u2502"})," ",jsx(u,{color:Sr,children:"\u2502"})," "]})]})}a(VS,"PoseCenter");function qS(){let t=process.env.CODESHELL_LOGO;if(t==="dog"||t==="kunhead"||t==="kunball"||t==="baby")return t;let e=Math.random();return e<.25?"dog":e<.5?"kunhead":e<.75?"kunball":"baby"}a(qS,"pickLogo");var Fp=qS(),zS={dog:Op,kunhead:Ip,kunball:Dp,baby:Lp},JS=zS[Fp],Bp=Fp==="kunhead";function $p({model:t,effort:e$1,cwd:n}){let r=XS(n),o=QS(t),i=e$1!=="high"?` (${e$1})`:"";return jsxs(S,{flexDirection:"column",marginBottom:0,children:[jsx(u,{children:" "}),Bp&&jsx(S,{paddingLeft:1,marginBottom:0,children:jsx(u,{color:"rgb(255,200,60)",bold:true,children:"\u5168\u6C11\u5236\u4F5C\u4EBA\u4EEC\u5927\u5BB6\u597D"})}),jsxs(S,{flexDirection:"row",gap:2,alignItems:"center",children:[jsx(JS,{}),jsxs(S,{flexDirection:"column",children:[jsxs(S,{children:[jsx(u,{bold:true,children:Bp?"iKun Shell":"Code Shell"}),jsx(u,{dim:true,children:" v"+e()})]}),jsxs(S,{children:[jsx(u,{children:o}),jsx(u,{dim:true,children:i})]}),jsx(S,{children:jsx(u,{dim:true,children:r})})]})]}),jsx(u,{children:" "})]})}a($p,"Banner");function XS(t){let e=process.env.HOME??"";return e&&t.startsWith(e)?"~"+t.slice(e.length):t}a(XS,"shortenPath");function QS(t){return (t.split("/").pop()??t).replace("claude-opus-4-6","Claude Opus 4.6").replace("claude-sonnet-4-6","Claude Sonnet 4.6").replace("claude-haiku-4-5","Claude Haiku 4.5").replace("claude-","Claude ")}a(QS,"formatModel");h();var tw=1800*1e3,nw="@cjhyy/code-shell";function Wp(){let[t,e$1]=useState(b$1());if(useEffect(()=>{let o=false,i=a(()=>{a$1(),setTimeout(()=>{if(o)return;let l=b$1();e$1(l),l?.canAutoInstall&&d$2();},6e3);},"refresh");i();let s=setInterval(i,tw);return ()=>{o=true,clearInterval(s);}},[]),!t)return null;let n=e(),r=t.canAutoInstall?null:`sudo npm install -g ${nw}@${t.latestVersion}`;return jsxs(S,{marginLeft:1,marginY:0,flexDirection:"column",children:[jsx(u,{color:"ansi:yellow",children:`\u2726 Update available: v${n} \u2192 v${t.latestVersion}`}),t.canAutoInstall?jsx(u,{dim:true,children:" Will install in the background when you exit."}):jsxs(u,{dim:true,children:[" Run: ",jsx(u,{bold:true,children:r})]})]})}a(Wp,"UpdateBanner");h();function iw(t){for(let e of ["CODESHELL.md","AGENTS.md","CLAUDE.md"])if(existsSync(join(t,e)))return e;return null}a(iw,"detectProjectDoc");function sw(t){let e=iw(t);return [{done:e!==null,text:e?`${e} \u5DF2\u5B58\u5728 \u2014 \u9879\u76EE\u8BF4\u660E\u4F1A\u81EA\u52A8\u52A0\u8F7D`:"\u8FD0\u884C /init \u751F\u6210 CODESHELL.md\uFF0C\u544A\u8BC9\u6A21\u578B\u5982\u4F55\u7406\u89E3\u672C\u9879\u76EE"},{done:false,text:"\u8BA9\u6A21\u578B\u5E2E\u4F60\u5206\u6790\u3001\u7F16\u8F91\u6587\u4EF6\uFF0C\u6216\u6267\u884C bash / git \u547D\u4EE4"},{done:false,text:"\u50CF\u8DDF\u540C\u4E8B\u6C9F\u901A\u4E00\u6837\u5199\u6E05\u695A\u9700\u6C42\uFF0C\u8D8A\u5177\u4F53\u6548\u679C\u8D8A\u597D"},{done:false,text:"\u968F\u65F6\u8F93\u5165 /status \u67E5\u770B\u5F53\u524D\u6A21\u578B\u3001\u7528\u91CF\u3001\u914D\u7F6E"}]}a(sw,"buildTips");function Gp({cwd:t}){let e=sw(t);return jsxs(S,{flexDirection:"column",marginBottom:1,paddingX:1,children:[jsx(S,{children:jsx(u,{color:"ansi:cyan",bold:true,children:"\u273B \u6B22\u8FCE\u4F7F\u7528 Code Shell"})}),jsx(S,{marginTop:0,children:jsx(u,{dim:true,children:" /help \u67E5\u770B\u5E2E\u52A9 \xB7 /status \u67E5\u770B\u5F53\u524D\u914D\u7F6E"})}),jsx(S,{marginTop:1,children:jsx(u,{dim:true,children:"\u2500".repeat(60)})}),jsx(S,{marginTop:1,children:jsx(u,{bold:true,children:" \u4E0A\u624B\u63D0\u793A\uFF1A"})}),e.map((n,r)=>jsxs(S,{children:[jsx(u,{children:" "}),n.done?jsx(u,{color:"ansi:green",children:"\u2714 "}):jsx(u,{dim:true,children:`${r+1}. `}),jsx(u,{dim:n.done,children:n.text})]},r)),jsx(S,{marginTop:1,children:jsx(u,{dim:true,children:"\u2500".repeat(60)})})]})}a(Gp,"WelcomeTips");h();h();var jc="\x1B[7m",Kc="\x1B[27m",Yc="\x1B[2m",Vc="\x1B[22m";function qc(t,e){let n=e;for(;n>0&&!/\w/.test(t[n-1]);)n--;for(;n>0&&/\w/.test(t[n-1]);)n--;return n}a(qc,"wordBoundaryLeft");function zc(t,e){let n=e;for(;n<t.length&&/\w/.test(t[n]);)n++;for(;n<t.length&&!/\w/.test(t[n]);)n++;return n}a(zc,"wordBoundaryRight");function Fr({value:t,onChange:e,onSubmit:n,placeholder:r,focus:o=true,hint:i,cursorResetCounter:s}){let[l,c]=useState(t.length),d=Math.min(Math.max(0,l),t.length);useEffect(()=>{s!==void 0&&c(t.length);},[s]);let f=t.includes(`
66
- `),m=f?t.split(`
67
- `).length:0;if(ft((v,b)=>{if(o){if(b.return){n?.(t);return}if(b.backspace||b.delete){if(d>0){let h=t.slice(0,d-1),T=t.slice(d);e(h+T),c(d-1);}return}if(b.leftArrow){b.meta||b.ctrl?c(qc(t,d)):c(Math.max(0,d-1));return}if(b.rightArrow){b.meta||b.ctrl?c(zc(t,d)):c(Math.min(t.length,d+1));return}if(b.ctrl&&v==="a"){c(0);return}if(b.ctrl&&v==="e"){c(t.length);return}if(b.ctrl&&v==="k"){e(t.slice(0,d));return}if(b.ctrl&&v==="u"){e(t.slice(d)),c(0);return}if(b.ctrl&&v==="w"){let h=qc(t,d),T=t.slice(0,h),A=t.slice(d);e(T+A),c(h);return}if(b.meta&&v==="b"){c(qc(t,d));return}if(b.meta&&v==="f"){c(zc(t,d));return}if(b.meta&&v==="d"){let h=zc(t,d),T=t.slice(0,d),A=t.slice(h);e(T+A);return}if(v&&!b.ctrl&&!b.meta){let T=v.replace(/\r\n?/g,`
68
- `).replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,"");if(!T)return;let A=t.slice(0,d),M=t.slice(d);e(A+T+M),c(d+T.length);}}}),!t&&r)return o?jsx(dn,{children:jc+" "+Kc+Yc+" "+r+Vc}):jsx(dn,{children:Yc+r+Vc});if(f){let v=t.split(`
69
- `),b=0;return jsxs(S,{flexDirection:"column",children:[v.map((h,T)=>{let A=b,M=A+h.length;b=M+1;let D=d>=A&&d<=M,N=d-A,R=T===0?"":" ";if(o&&D){let E=h.slice(0,N),I=h[N]??" ",F=h.slice(N+1);return jsxs(S,{children:[jsx(u,{dim:true,children:R}),jsx(dn,{children:E+jc+I+Kc+F})]},T)}return jsxs(S,{children:[jsx(u,{dim:true,children:R}),jsx(dn,{children:h})]},T)}),jsxs(u,{dim:true,children:[" (",m," lines)"]})]})}let g=t.slice(0,d),y=t[d]??" ",w=t.slice(d+1),x=o&&i&&d===t.length;return o?jsx(dn,{children:g+jc+y+Kc+w+(x?Yc+i+Vc:"")}):jsx(dn,{children:t})}a(Fr,"TextInput");h();var Jc=500,Na=join(homedir(),".code-shell"),Xc=join(Na,"history.jsonl"),Yp=join(Na,"history"),Ma="",Aa="",Bn=null,Qo=[],Ra=null,zp=new Set,Qc=false;function Jp(t,e){Ma=t,Aa=e;}a(Jp,"initHistory");function eu(){if(Bn!==null)return Bn;if(mkdirSync(Na,{recursive:true}),Bn=[],existsSync(Xc))try{let t=readFileSync(Xc,"utf-8");for(let e of t.split(`
70
- `))if(e.trim())try{let n=JSON.parse(e);n.display&&typeof n.display=="string"&&Bn.push(n);}catch{}}catch{}if(Bn.length===0&&existsSync(Yp))try{let e=readFileSync(Yp,"utf-8").split(`
71
- `).filter(n=>n.trim().length>0);for(let n of e)Bn.push({display:n,timestamp:0,project:"",sessionId:""});}catch{}return Bn.length>Jc&&(Bn=Bn.slice(Bn.length-Jc)),Bn}a(eu,"ensureLoaded");function Vp(){let t=eu(),e=[],n=[],r=new Set;for(let o=t.length-1;o>=0;o--){let i=t[o];if(!(i.sessionId===Ma&&zp.has(i.timestamp))&&!(Aa&&i.project&&i.project!==Aa)&&!r.has(i.display)&&(r.add(i.display),i.sessionId===Ma?e.push(i.display):n.push(i.display),r.size>=Jc))break}return [...e.reverse(),...n.reverse()]}a(Vp,"getProjectHistory");function Xp(){if(Qo.length!==0){try{mkdirSync(Na,{recursive:!0});let t=Qo.map(e=>JSON.stringify(e)).join(`
72
- `)+`
73
- `;appendFileSync(Xc,t,{encoding:"utf-8",mode:384});}catch{}Qo=[],Qc=false;}}a(Xp,"flushPendingEntries");function dw(){Qc||(Qc=true,process.nextTick(Xp));}a(dw,"scheduleFlush");function Qp(t){let e=t.trim();if(!e)return;let n=eu(),r={display:e,timestamp:Date.now(),project:Aa,sessionId:Ma};n.push(r),Ra=r,Qo.push(r),dw();}a(Qp,"addToHistory");function Zp(){if(!Ra)return;let t=Ra;Ra=null;let e=Qo.lastIndexOf(t);e!==-1?Qo.splice(e,1):zp.add(t.timestamp);let n=eu(),r=n.lastIndexOf(t);r!==-1&&n.splice(r,1);}a(Zp,"removeLastFromHistory");function eg(){Xp();}a(eg,"flushHistorySync");function tg(){let t=Vp(),e=t.length,n="";return {up(r){return e===t.length&&(n=r),e<=0?null:(e--,t[e]??null)},down(){return e>=t.length?null:(e++,e>=t.length?n:t[e]??null)},reset(){e=t.length,n="";},refresh(){t=Vp(),e=t.length,n="";}}}a(tg,"createHistoryNavigator");function gw(t,e){if(!e)return "";let n=e.trim();return n.startsWith(t)?n.slice(t.length).trim():""}a(gw,"extractUsageHint");var Oa=8;function ng({value:t,onChange:e,onSubmit:n,commands:r,placeholder:o,onArrowOut:i,disabled:s}){let[l,c]=useState(0),d=useRef(tg()),[f,m]=useState(false),[g,y]=useState(0),w=!f&&t.startsWith("/")&&!t.includes(" "),x=t.slice(1).toLowerCase(),v=useMemo(()=>w?x===""?r:r.filter(N=>N.name.slice(1).toLowerCase().includes(x)||N.description.toLowerCase().includes(x)):[],[w,x,r]);useEffect(()=>{v.length>0&&l>=v.length?c(v.length-1):v.length===0&&l!==0&&c(0);},[v.length,l]),ft((N,R)=>{if(!s){if(w&&v.length>0){if(R.upArrow){c(Math.max(0,l-1));return}else if(R.downArrow){c(Math.min(v.length-1,l+1));return}else if(R.tab){let E=v[l];E&&(e(E.name+" "),y(I=>I+1),c(0));return}else if(R.escape){e(""),c(0);return}}if(R.upArrow){let E=d.current.up(t);E!==null&&(m(true),e(E),y(I=>I+1));}else if(R.downArrow){let E=d.current.down();if(E!==null){m(true),e(E),y(I=>I+1);return}t.length===0&&i?.("down");}}});let b=a(N=>{d.current.reset(),m(false),e(N),c(0);},"handleChange"),h=a(N=>{if(w&&v.length>0&&x.length>0){let R=v[l];if(R&&N.trim()===t.trim()){if(v.find(I=>I.name===N.trim())){n(N),c(0),d.current.reset();return}e(R.name+" "),y(I=>I+1),c(0);return}}Qp(N),d.current.refresh(),m(false),n(N),c(0);},"handleSubmit"),T=Math.max(0,l-Oa+1),A=v.slice(T,T+Oa),M=T,D=(()=>{if(!t.startsWith("/")||!t.endsWith(" "))return;let N=t.trimEnd();if(t.length!==N.length+1)return;let R=r.find(I=>I.name===N);return R&&gw(R.name,R.usage)||void 0})();return jsxs(S,{flexDirection:"column",children:[w&&v.length>0&&jsxs(S,{flexDirection:"column",marginLeft:2,marginBottom:0,children:[T>0&&jsxs(u,{dim:true,children:[" \u2191 ",T," more"]}),A.map((N,R)=>{let I=M+R===l;return jsxs(S,{children:[jsx(u,{color:I?"cyanBright":void 0,bold:I,children:I?"\u25B8 ":" "}),jsx(u,{color:I?"cyanBright":"white",bold:I,children:N.name}),jsxs(u,{dim:true,children:[" ",N.description]})]},N.name)}),T+Oa<v.length&&jsxs(u,{dim:true,children:[" \u2193 ",v.length-T-Oa," more"]})]}),jsx(S,{flexDirection:"column",children:jsxs(S,{children:[jsx(u,{children:"\u276F "}),jsx(Fr,{value:t,onChange:b,onSubmit:h,placeholder:o??"Ask anything\u2026 (/ for commands, \u2191 for history)",focus:!s,hint:D,cursorResetCounter:g})]})})]})}a(ng,"CommandInput");h();h();var hw="ansi256(22)",yw="ansi256(52)",bw="ansi:greenBright",xw="ansi:redBright";function rg(t,e){let n=Math.min(200,Math.max(40,process.stdout.columns??80)),r=Math.max(0,n-e);return t.length>=r?t:t+" ".repeat(r-t.length)}a(rg,"padToWidth");function Zo({kind:t,text:e,indent:n=0,gutter:r}){let o=" ".repeat(n),i=r?r.length:0;return t==="add"?jsxs(S,{children:[r?jsx(u,{dim:true,children:r}):null,jsx(u,{backgroundColor:hw,color:bw,children:rg(`${o}+ ${e}`,i)})]}):t==="remove"?jsxs(S,{children:[r?jsx(u,{dim:true,children:r}):null,jsx(u,{backgroundColor:yw,color:xw,children:rg(`${o}- ${e}`,i)})]}):t==="hunk"?jsxs(S,{children:[r?jsx(u,{dim:true,children:r}):null,jsx(u,{color:"ansi:cyan",children:`${o}${e}`})]}):jsxs(S,{children:[r?jsx(u,{dim:true,children:r}):null,jsx(u,{dim:true,children:`${o} ${e}`})]})}a(Zo,"DiffLine");function og(t){let e=t.trimStart();return /^\+\s/.test(e)?{kind:"add",text:e.replace(/^\+\s/,"")}:/^-\s/.test(e)?{kind:"remove",text:e.replace(/^-\s/,"")}:e.startsWith("@@")?{kind:"hunk",text:e}:{kind:"context",text:t}}a(og,"classifyDiffLine");var Bt=3;function ig({toolName:t,args:e,nested:n}){let r=ws(t,e),o=yd[t]??"ansi:cyan";return jsxs(S,{marginLeft:n?3:0,marginTop:n?0:1,children:[jsx(u,{color:o,children:" \u25CF"}),jsxs(u,{bold:true,children:[" ",t]}),jsxs(u,{dim:true,children:[" ",r]})]})}a(ig,"ToolCallStart");function sg({toolName:t,nested:e}){return jsxs(S,{marginLeft:e?3:0,children:[jsx(u,{dim:true,children:" \u2502 "}),jsx(u,{color:"ansi:cyan",children:"\u2839 "}),jsxs(u,{dim:true,children:[t,"\u2026"]})]})}a(sg,"ToolCallRunning");function ag({toolName:t,result:e,error:n,nested:r,expanded:o,compact:i}){let[s,l]=useState(false),c=o||s,d=r?3:0;if(i){let g=Cn(e??n??"");return jsx(S,{marginLeft:d,children:jsxs(u,{dim:true,children:[" \xB7 ",t," retried \u2014 ",Jt(g,90)]})})}if(n)return jsxs(S,{marginLeft:d,children:[jsx(u,{color:"ansi:red",children:" \u2717 "}),jsxs(u,{dim:true,children:[t," "]}),jsx(u,{color:"ansi:red",children:Jt(Cn(n),72)})]});let f=e??"";if(!f)return jsxs(S,{marginLeft:d,children:[jsx(u,{color:"ansi:green",children:" \u2713 "}),jsx(u,{dim:true,children:t})]});let m=vw(t,f,c);return jsxs(S,{flexDirection:"column",marginLeft:d,children:[jsxs(S,{children:[jsx(u,{color:"ansi:green",children:" \u2713 "}),jsx(u,{dim:true,children:t}),m.summary?jsxs(u,{dim:true,children:[" ",m.summary]}):null]}),m.lines.length>0&&jsxs(S,{flexDirection:"column",children:[m.lines.map((g,y)=>jsx(Ew,{line:Tw(g)},y)),m.hiddenCount>0&&jsxs(S,{children:[jsx(u,{dim:true,children:" \u23BF "}),jsxs(u,{dim:true,children:["\u2026 +",m.hiddenCount," lines",o?"":" (ctrl+o to expand)"]})]})]})]})}a(ag,"ToolCallResult");function ww(t){return t.replace(/<system-reminder>[\s\S]*?<\/system-reminder>\s*/g,"")}a(ww,"stripSystemReminders");function vw(t,e,n){e=ww(e);let r=e.split(`
74
- `),o=r.length;switch(t){case "Read":return {summary:`${o} lines, ${vs(e.length)}`,lines:[],hiddenCount:0};case "Write":return {summary:Cn(r[0]??"").slice(0,80),lines:[],hiddenCount:0};case "Edit":{let[i,...s]=r,l=Cn(i??"").slice(0,80),c=s.filter(f=>f.length>0);if(n)return {summary:l,lines:c,hiddenCount:0};if(c.length===0)return {summary:l,lines:[],hiddenCount:0};let d=Math.min(c.length,Bt);return {summary:l,lines:c.slice(0,d),hiddenCount:Math.max(0,c.length-d)}}case "Glob":{let i=r.filter(l=>l.trim()).filter(l=>!/^\d+\s+files?\s+matched/i.test(l)),s=i.length;return n?{summary:`${s} files`,lines:i,hiddenCount:0}:s<=Bt?{summary:`${s} files`,lines:i,hiddenCount:0}:{summary:`${s} files`,lines:i.slice(0,Bt),hiddenCount:s-Bt}}case "Grep":{let i=new Set,s=[],l=0;for(let f of r){if(!f.trim())continue;l++;let m=f.match(/^(.+?)[:-]\d+(?:[:-]|$)/),g=m?m[1]:f;i.has(g)||(i.add(g),s.push(g));}let c=s.length,d=l===c?`${c} ${c===1?"file":"files"}`:`${l} matches in ${c} ${c===1?"file":"files"}`;return n||c<=Bt?{summary:d,lines:s,hiddenCount:0}:{summary:d,lines:s.slice(0,Bt),hiddenCount:c-Bt}}case "Bash":return o<=1&&r[0]?.trim()===""?{summary:"(no output)",lines:[],hiddenCount:0}:n?{summary:"",lines:r,hiddenCount:0}:o<=Bt+1?{summary:"",lines:r,hiddenCount:0}:{summary:`${o} lines`,lines:r.slice(0,Bt),hiddenCount:o-Bt};case "Agent":return {summary:Jt(Cn(e),80),lines:[],hiddenCount:0};case "TaskCreate":case "TaskUpdate":case "TaskList":case "TaskStop":case "TaskGet":case "TaskOutput":return {summary:Cn(e),lines:[],hiddenCount:0};case "WebSearch":case "WebFetch":return n?{summary:"",lines:r,hiddenCount:0}:o<=Bt+1?{summary:"",lines:r,hiddenCount:0}:{summary:`${o} lines`,lines:r.slice(0,Bt),hiddenCount:o-Bt};default:return o<=1?{summary:Jt(e,80),lines:[],hiddenCount:0}:n?{summary:"",lines:r,hiddenCount:0}:o<=Bt+1?{summary:"",lines:r,hiddenCount:0}:{summary:`${o} lines`,lines:r.slice(0,Bt),hiddenCount:o-Bt}}}a(vw,"renderToolOutput");function Tw(t){return t.length>Ss?t.slice(0,Ss-1)+"\u2026":t}a(Tw,"clampLine");function Ew({line:t}){let e=og(t);return e.kind==="add"||e.kind==="remove"?jsx(Zo,{kind:e.kind,text:e.text,gutter:" \u23BF "}):e.kind==="hunk"?jsxs(S,{children:[jsx(u,{dim:true,children:" \u23BF "}),jsx(u,{color:"ansi:cyan",children:e.text})]}):jsxs(S,{children:[jsx(u,{dim:true,children:" \u23BF "}),jsx(u,{children:t})]})}a(Ew,"DiffOrPlainRow");h();h();var lg=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Da({label:t,color:e="cyan",showElapsed:n=true,tokens:r}){let[o,i]=useState(0),s=useRef(Date.now());useEffect(()=>{let m=setInterval(()=>{i(g=>g+1);},1e3);return ()=>clearInterval(m)},[]);let l=lg[o%lg.length],c=Math.floor((Date.now()-s.current)/1e3),d=c>0?` ${c}s`:"",f=r&&r>0?` \xB7 ${Rw(r)}`:"";return jsxs(u,{children:[jsx(u,{color:e,children:l}),jsxs(u,{children:[" ",t??"Working\u2026"]}),n&&jsxs(u,{dim:true,children:[d,f]})]})}a(Da,"Spinner");function Rw(t){return t>=1e6?(t/1e6).toFixed(1)+"M tokens":t>=1e3?(t/1e3).toFixed(1)+"K tokens":`${t} tokens`}a(Rw,"formatTokens");function cg({name:t,description:e,running:n,isLast:r}){let o=r?"\u2514\u2500":"\u251C\u2500",i=r?" ":"\u2502 ";return jsxs(S,{flexDirection:"column",marginLeft:1,marginTop:1,children:[jsxs(S,{children:[jsxs(u,{dim:true,children:[o," "]}),n?jsxs(Fragment,{children:[jsx(Da,{label:"",color:"ansi:cyan"}),jsx(u,{children:" "})]}):null,t&&jsx(u,{bold:true,children:t+" "}),jsx(u,{bold:!t,dim:!!t,children:e})]}),n&&jsxs(S,{children:[jsxs(u,{dim:true,children:[i,"\u23BF "]}),jsx(u,{dim:true,children:"Initializing\u2026"})]})]})}a(cg,"AgentBlockStart");function ug({name:t,description:e,text:n,error:r,isLast:o}){let i=o?"\u2514\u2500":"\u251C\u2500",s=o?" ":"\u2502 ";return r?jsxs(S,{flexDirection:"column",marginLeft:1,children:[jsxs(S,{children:[jsxs(u,{dim:true,children:[i," "]}),t&&jsx(u,{color:"ansi:red",bold:true,children:t+" "}),jsx(u,{color:"ansi:red",dim:!!t,children:e}),jsx(u,{dim:true,children:" \xB7 "}),jsx(u,{color:"ansi:red",children:"Error"})]}),jsxs(S,{children:[jsxs(u,{dim:true,children:[s,"\u23BF "]}),jsx(u,{color:"ansi:red",children:r.slice(0,80)})]})]}):jsxs(S,{flexDirection:"column",marginLeft:1,children:[jsxs(S,{children:[jsxs(u,{dim:true,children:[i," "]}),t&&jsx(u,{bold:true,children:t+" "}),jsx(u,{dim:!!t,children:e}),jsx(u,{dim:true,children:" \xB7 "}),jsx(u,{color:"ansi:green",children:"Done"})]}),n&&n.trim().length>0&&jsxs(S,{children:[jsxs(u,{dim:true,children:[s,"\u23BF "]}),jsx(u,{children:n})]})]})}a(ug,"AgentBlockEnd");h();function dg({tasks:t}){return t.length===0?null:jsxs(S,{flexDirection:"column",marginLeft:1,marginTop:1,children:[jsx(u,{bold:true,color:"ansi:cyan",children:"Tasks"}),t.map(e=>jsx(Nw,{task:e,indent:true},e.id))]})}a(dg,"TaskList");function Nw({task:t,indent:e=true}){let n=e?2:0;switch(t.status){case "completed":return jsxs(S,{marginLeft:n,children:[jsx(u,{color:"ansi:green",children:"\u2713 "}),jsx(u,{strikethrough:true,dim:true,children:t.subject})]});case "in_progress":return jsxs(S,{marginLeft:n,children:[jsx(Da,{label:t.subject}),t.activeForm&&t.activeForm!==t.subject&&jsxs(u,{dim:true,children:[" \xB7 ",t.activeForm]})]});case "stopped":return jsxs(S,{marginLeft:n,children:[jsx(u,{color:"ansi:red",children:"\u2717 "}),jsx(u,{strikethrough:true,dim:true,children:t.subject})]});default:return jsxs(S,{marginLeft:n,children:[jsx(u,{dim:true,children:"\u25CB "}),jsx(u,{dim:true,children:t.subject})]})}}a(Nw,"TaskItem");h();function Iw(){return process.env.TERM==="xterm-ghostty"?["\xB7","\u2722","\u2733","\u2736","\u273B","*"]:process.platform==="darwin"?["\xB7","\u2722","\u2733","\u2736","\u273B","\u273D"]:["\xB7","\u2722","*","\u2736","\u273B","\u273D"]}a(Iw,"getDefaultCharacters");var mg=["\u7948\u6C42\u8005!","\u5728\u90A3\u9ED1\u8272\u7684\u65E0\u77E5\u4E4B\u6D77\u4E0A,\u543E\u4E43\u95EA\u8000\u7684\u77E5\u8BC6\u706F\u5854","music!","\u54CE\u5466,\u4F60\u5E72\u561B~","\u5C0F\u9ED1\u5B50,\u9732\u51FA\u9E21\u811A\u4E86\u5427","\u30AA\u30E9\u30AA\u30E9\u30AA\u30E9\u30AA\u30E9\u30C3!","\u30E0\u30C0\u30E0\u30C0\u30E0\u30C0\u30E0\u30C0\u30C3!","\u9EC4\u91D1\u306E\u7CBE\u795E","\u30B6\u30FB\u30EF\u30FC\u30EB\u30C9!\u6642\u3088\u6B62\u307E\u308C!","\u30AB\u30AB\u30ED\u30C3\u30C8!","\u304B\u2026\u2026\u3081\u2026\u2026\u306F\u2026\u2026\u3081\u2026\u2026\u6CE2\u30FC\u3063!","\u771F\u5B9F\u306F\u3044\u3064\u3082\u3072\u3068\u3064!","\u7121\u9650\u306E\u5263\u88FD(\u30A2\u30F3\u30EA\u30DF\u30C6\u30C3\u30C9\u30D6\u30EC\u30A4\u30C9\u30EF\u30FC\u30AF\u30B9)","\u554F\u304A\u3046\u3001\u8CB4\u65B9\u304C\u79C1\u306E\u30DE\u30B9\u30BF\u30FC\u304B","\u305F\u3060\u306E\u4EBA\u9593\u306B\u306F\u8208\u5473\u3042\u308A\u307E\u305B\u3093","SOS\u56E3\u3001\u7D50\u6210!","\u5168\u56FD\u5927\u4F1A\u3001\u884C\u304D\u305F\u3044\u3093\u3067\u3059!","\u4E45\u7F8E\u5B50\u3001\u597D\u304D\u3060!","\u3053\u306E\u7D20\u6674\u3089\u3057\u3044\u4E16\u754C\u306B\u795D\u798F\u3092!","\u308F\u305F\u3057\u3001\u3081\u3050\u307F\u3093\u3063!","\u30A8\u30AF\u30B9\u30D7\u30ED\u30FC\u30B8\u30E7\u30F3!","\u30A2\u30AF\u30B7\u30BA\u6559\u3078\u3088\u3046\u3053\u305D!","\u30B9\u30BF\u30FC\u30D0\u30FC\u30B9\u30C8\u30FB\u30B9\u30C8\u30EA\u30FC\u30E0!","\u30E6\u30A4\u3001\u30D1\u30D1\u3060\u3088","\u90AA\u738B\u771F\u773C\u3001\u89E3\u653E!","\u30D0\u30CB\u30C3\u30B7\u30E5\u30E1\u30F3\u30C8\u30FB\u30C7\u30A3\u30B9\u30FB\u30EF\u30FC\u30EB\u30C9!","\u3084\u308C\u3084\u308C\u2026\u2026","\u5B8C\u5168\u7121\u6B20\u306E\u8D85\u80FD\u529B\u8005","\u30D3\u30EA\u30D3\u30EA","\u672C\u5F53\u306E\u529B\u3001\u898B\u305B\u3066\u3042\u3052\u308B","\u4F60\u600E\u4E48\u8FD9\u4E48\u719F\u7EC3","\u3053\u308C\u306F\u3001\u904B\u547D\u77F3\u306E\u6249\u306E\u9078\u629E\u3060"],pg=Iw(),gg=[...pg,...[...pg].reverse()],Lw=["\u90AA\u738B\u771F\u773C\u767A\u52D5!","\u30B6\u30FB\u30EF\u30FC\u30EB\u30C9!","\u30A8\u30AF\u30B9\u30D7\u30ED\u30FC\u30B8\u30E7\u30F3!","\u534D\u89E3!"];function hg(t){return t[Math.floor(Math.random()*t.length)]}a(hg,"pickRandom");function Bw({mode:t,streamingTokensRef:e,runStartRef:n,thinkingContent:r}){let[o,i]=useState(0),s=useRef(hg(mg)),l=useRef(Date.now());if(useEffect(()=>{let w=setInterval(()=>i(x=>x+1),200);return ()=>clearInterval(w)},[]),Date.now()-l.current>8e3){let w=t==="tool-use"?Lw:mg;s.current=hg(w),l.current=Date.now();}let c=gg[o%gg.length],d=n?Math.floor((Date.now()-n.current)/1e3):0,f=e?.current??0,m=s.current,g=t==="thinking"?"ansi:magenta":"ansi:cyan",y=r?ou(r):"";return jsxs(S,{flexDirection:"column",marginLeft:2,marginY:1,children:[jsxs(S,{children:[jsx(u,{color:g,children:c}),jsxs(u,{children:[" ",m,"\u2026"]}),d>0&&jsxs(u,{dim:true,children:[" ",d,"s"]}),f>0&&jsxs(u,{dim:true,children:[" \xB7 ",$w(f)]})]}),r!==void 0&&jsx(S,{marginLeft:4,children:jsx(u,{dim:true,italic:true,children:y||" "})})]})}a(Bw,"SpinnerWithVerbImpl");function Fw(t,e){if(t.mode!==e.mode)return false;let n=t.thinkingContent?ou(t.thinkingContent):"",r=e.thinkingContent?ou(e.thinkingContent):"";return n===r}a(Fw,"spinnerPropsEqual");var yg=memo(Bw,Fw);function $w(t){return t>=1e6?(t/1e6).toFixed(1)+"M tokens":t>=1e3?(t/1e3).toFixed(1)+"K tokens":`${t} tokens`}a($w,"formatTokens");function ou(t){let e=t.replace(/\n/g," ").replace(/\s+/g," ").trim();return e.length>80?"\u2026"+e.slice(-79):e}a(ou,"truncateThinking");h();h();var Qi=d.child({cat:"ui"}),Pt=process.env.CODESHELL_UI_PERF==="1",ti=null;function Hw(t=250,e=50){!Pt||ti||(ti=setInterval(()=>{let n=performance.now();setImmediate(()=>{let r=performance.now()-n;r>e&&Qi.info("debug.ui.eventloop_lag",{lag_ms:Math.round(r)});});},t),ti.unref?.());}a(Hw,"startEventLoopMonitor");function Ww(){ti&&(clearInterval(ti),ti=null);}a(Ww,"stopEventLoopMonitor");var jt=null,ni=null;function Sg(t,e){if(!Pt)return;let n=performance.now();jt||(jt={count:0,byAgent:new Map,byType:new Map,firstAt:n}),jt.count++;let r=e??"(main)";jt.byAgent.set(r,(jt.byAgent.get(r)??0)+1),jt.byType.set(t,(jt.byType.get(t)??0)+1);}a(Sg,"recordStreamEvent");function Uw(t=1e3){!Pt||ni||(ni=setInterval(()=>{if(!jt||jt.count===0)return;let e=performance.now()-jt.firstAt;Qi.info("debug.ui.stream_rate",{count:jt.count,window_ms:Math.round(e),rate_per_s:Math.round(jt.count*1e3/Math.max(e,1)),byAgent:Object.fromEntries(jt.byAgent),byType:Object.fromEntries(jt.byType)}),jt=null;},t),ni.unref?.());}a(Uw,"startStreamRateReporter");function Gw(){ni&&(clearInterval(ni),ni=null);}a(Gw,"stopStreamRateReporter");var Ji=0,bg=performance.now(),xg=performance.now(),Ia=0,Xi=1/0,ri=null;function wg(){if(!Pt)return;let t=performance.now(),e=t-xg;e>Ia&&(Ia=e),e<Xi&&(Xi=e),xg=t,Ji++;}a(wg,"recordAppRender");function jw(t=1e3){!Pt||ri||(ri=setInterval(()=>{let e=performance.now(),n=e-bg;Ji>0&&Qi.info("debug.ui.app_renders",{count:Ji,window_ms:Math.round(n),rate_per_s:Math.round(Ji*1e3/Math.max(n,1)),maxInterval_ms:Math.round(Ia),minInterval_ms:Xi===1/0?null:Math.round(Xi)}),Ji=0,Ia=0,Xi=1/0,bg=e;},t),ri.unref?.());}a(jw,"startAppRenderReporter");function Kw(){ri&&(clearInterval(ri),ri=null);}a(Kw,"stopAppRenderReporter");var Ve=null,oi=null;function vg(t){if(!Pt)return;let e=performance.now();if(!Ve)Ve={count:0,totalDuration:0,maxDuration:0,totalDiff:0,totalWrite:0,totalYoga:0,totalPatches:0,firstAt:e,lastAt:e,maxGap:0};else {let n=e-Ve.lastAt;n>Ve.maxGap&&(Ve.maxGap=n);}Ve.count++,Ve.totalDuration+=t.durationMs,t.durationMs>Ve.maxDuration&&(Ve.maxDuration=t.durationMs),Ve.totalDiff+=t.phases.diff,Ve.totalWrite+=t.phases.write,Ve.totalYoga+=t.phases.yoga,Ve.totalPatches+=t.phases.patches,Ve.lastAt=e;}a(vg,"recordInkFrame");function Yw(t=1e3){!Pt||oi||(oi=setInterval(()=>{if(!Ve||Ve.count===0)return;let e=Ve.count;Qi.info("debug.ui.ink_frames",{count:e,window_ms:Math.round(performance.now()-Ve.firstAt),avgDuration_ms:Math.round(Ve.totalDuration/e),maxDuration_ms:Math.round(Ve.maxDuration),maxGap_ms:Math.round(Ve.maxGap),avgDiff_ms:Math.round(Ve.totalDiff/e),avgWrite_ms:Math.round(Ve.totalWrite/e),avgYoga_ms:Math.round(Ve.totalYoga/e),totalPatches:Ve.totalPatches}),Ve=null;},t),oi.unref?.());}a(Yw,"startInkFrameReporter");function Vw(){oi&&(clearInterval(oi),oi=null);}a(Vw,"stopInkFrameReporter");function Tg(){Pt&&(Hw(),Uw(),jw(),Yw(),Qi.info("debug.ui.perf_start",{enabled:true,probes:["eventloop","stream_rate","app_renders","ink_frames","statusline_tick"]}));}a(Tg,"startAllPerfProbes");function Eg(){Ww(),Gw(),Kw(),Vw();}a(Eg,"stopAllPerfProbes");var vr=d.child({cat:"ui"});function Cg({model:t,effort:e,tokens:n,cost:r,sessionId:o,baseContextTokens:i,maxContextTokens:s,gitBranch:l,isRunning:c,streamingTokensRef:d,runStartRef:f}){let m=zw(t),[g,y]=useState(0),w=useRef(performance.now()),x=useRef(performance.now()),v=useRef(0),b=useRef(0);if(useEffect(()=>(Pt&&vr.info("debug.statusline.mount",{isRunning:!!c}),()=>{Pt&&vr.info("debug.statusline.unmount",{});}),[]),useEffect(()=>{if(!c){y(0),Pt&&vr.info("debug.statusline.interval",{action:"skip_not_running"});return}Pt&&vr.info("debug.statusline.interval",{action:"start"});let E=setInterval(()=>{let I=performance.now(),F=I-w.current;w.current=I,v.current++,Pt&&vr.info("debug.statusline.tick_fire",{n:v.current,sinceLast_ms:Math.round(F),drift_ms:Math.round(F-1e3)}),y(O=>O+1);},1e3);return ()=>{Pt&&vr.info("debug.statusline.interval",{action:"clear"}),clearInterval(E);}},[c]),Pt&&c){let E=performance.now(),I=E-x.current;x.current=E,b.current++,b.current%5===0&&vr.info("debug.statusline.render_beat",{n:b.current,sinceLast_ms:Math.round(I),tickState:g,tickFires:v.current});}let h=c&&f?Math.floor((Date.now()-f.current)/1e3):0;Pt&&c&&b.current%10===0&&vr.info("debug.statusline.elapsed_inputs",{elapsed_s:h,runStartRef:f?.current??0,ageOfRunStart_ms:f?Date.now()-f.current:0});let T=c&&d?d.current:0,A=s&&s>0?Math.min((i??0)/s*100,100):0;useEffect(()=>{let E={baseContextTokens:i??0,maxContextTokens:s??0,pct:Math.round(A)};vr.info("debug.ctx.render",E),h$2(o,"ui.ctx.render",E);},[i,s,A,o]);let M=A>80?"ansi:red":A>60?"ansi:yellow":"ansi:green",D=8,N=Math.round(A/100*D),R="\u2588".repeat(N)+"\u2591".repeat(D-N);return jsxs(S,{children:[c&&jsxs(Fragment,{children:[jsx(u,{color:"ansi:cyan",children:"\u25CF "}),jsx(u,{color:"ansi:cyan",children:Jw(h)}),T>0&&jsxs(u,{dim:true,children:[" ",Xw(T)," tok"]}),jsx(u,{dim:true,children:" \u2502 "})]}),jsx(u,{dim:true,children:m}),(process.stdout.columns??80)>=100&&jsx(u,{dim:true,children:" (alt+m)"}),jsx(u,{dim:true,children:" \u2502 "}),jsx(u,{color:M,children:R}),jsxs(u,{dim:true,children:[" ",A.toFixed(0),"% ctx"]}),r>0&&jsxs(Fragment,{children:[jsx(u,{dim:true,children:" \u2502 "}),jsxs(u,{color:"ansi:green",children:["$",r.toFixed(2)]})]}),l&&jsxs(Fragment,{children:[jsx(u,{dim:true,children:" \u2502 "}),jsx(u,{color:"ansi:magenta",children:l})]})]})}a(Cg,"StatusLine");function zw(t){return (t.split("/").pop()??t).replace("claude-opus-4-6","opus").replace("claude-sonnet-4-6","sonnet").replace("claude-haiku-4-5","haiku").replace("claude-","").replace("gpt-4o","4o").replace("gpt-4","gpt4")}a(zw,"shortModel");function Jw(t){if(t<60)return `${t}s`;let e=Math.floor(t/60),n=t%60;return `${e}m${n.toString().padStart(2,"0")}s`}a(Jw,"formatElapsed");function Xw(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":String(t)}a(Xw,"formatNumber");h();h();function ev(){let t=process.env.CODESHELL_FULLSCREEN;if(t===void 0)return true;let e=t.trim().toLowerCase();return !(e==="0"||e==="false"||e==="off")}a(ev,"parseFullscreenEnv");var au=ev(),lu=createContext({fullscreen:au,setFullscreen:a(()=>{},"setFullscreen"),toggleFullscreen:a(()=>{},"toggleFullscreen")});function Ba(){return useContext(lu)}a(Ba,"useFullscreenMode");h();var tv=0;function ii(t){return {...t,id:`e${++tv}`}}a(ii,"createEntry");var cu=class{static{a(this,"ChatStore");}entries=[];listeners=new Set;getEntries(){return this.entries}setEntries(e){this.entries=e,this.notify();}append(e){this.entries=[...this.entries,ii(e)],this.notify();}update(e){let n=this.entries.length;this.entries=e(this.entries);let r=this.entries.length;process.env.CODE_SHELL_DEBUG_CHAT&&console.error(`[chatStore.update] ${n} -> ${r}, listeners=${this.listeners.size}`),this.notify();}commitInterruptedStreaming(e){this.entries=this.entries.filter(n=>n.type!=="thinking").map(n=>{if(n.type!=="assistant_text"||!n.streaming)return n;let r=n.text.trim().length>0;return {...n,streaming:false,text:r?n.text+e:n.text}}),this.notify();}clear(){this.entries=[],this.notify();}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){for(let e of this.listeners)e();}},be=new cu;function Ag({scrollable:t,bottom:e,overlay:n,newMessageCount:r=0,onJumpToNew:o,showPill:i=false}){let{fullscreen:s}=Ba(),l=useRef(s);useEffect(()=>{let d=l.current;if(l.current=s,d===true&&s===false){let f=be.getEntries();if(f.length===0)return;let m=[];for(let y of f)switch(y.type){case "user":m.push(`> ${y.text}`);break;case "assistant_text":m.push(y.text);break;case "tool_start":m.push(`[${y.toolName}] running\u2026`);break;case "tool_result":m.push(`[${y.toolName}] ${y.error?"\u2717 "+y.error:"\u2713"}`);break;case "status":m.push(`(${y.reason})`);break;case "system":m.push(y.text?`\u2500\u2500 ${y.text} \u2500\u2500`:"");break;case "error":m.push(`error: ${y.error}`);break;default:m.push("");}let g=m.filter(Boolean).join(`
75
- `)+`
76
- `;process.stdout.write(g);}},[s]);let c=jsxs(S,{flexDirection:"column",flexGrow:s?1:0,children:[jsxs(S,{flexDirection:"column",flexGrow:s?1:0,children:[t,!s&&n]}),s&&i&&r>0&&jsx(S,{justifyContent:"center",marginY:0,children:jsx(u,{color:"ansi:black",backgroundColor:"ansi:cyanBright",bold:true,children:` \u2193 ${r} new message${r>1?"s":""} `})}),s&&n&&jsx(S,{flexDirection:"column",flexShrink:0,children:n}),jsx(S,{flexDirection:"column",flexShrink:0,children:e})]});return s?jsx(Bc,{children:c}):c}a(Ag,"FullscreenLayout");function Ng(t){let[e,n]=useState(null),[r,o]=useState(false),i=useCallback(()=>{e===null&&n(t),o(true);},[e,t]),s=useCallback(()=>{n(null),o(false);},[]);useEffect(()=>{e!==null&&t<e&&(n(null),o(false));},[t,e]);let l=e!==null?t-e:0;return {dividerIndex:e,showPill:r&&l>0,unseenCount:l,onScrollAway:i,onScrollToBottom:s}}a(Ng,"useUnseenDivider");h();h();function ov({entry:t,render:e}){return jsx(Fragment,{children:e(t)})}a(ov,"MessageRowImpl");function iv(t,e){return !(t.entry!==e.entry||t.columns!==e.columns||t.isStreaming||e.isStreaming||t.isSelected!==e.isSelected||t.expanded!==e.expanded)}a(iv,"areMessageRowPropsEqual");var uu=Lg.memo(ov,iv);h();var uv=3,ai=80,dv=30,fv=ai>>1,du=1,es=300,ts=25,mv=a(()=>{},"NOOP_UNSUB");function Dg(t,e,n){let r=useRef(new Map),o=useRef(0),i=useRef(0),s=useRef({arr:new Float64Array(0),version:-1,n:-1}),l=useRef(new Map),c=useRef(new Map),d=useRef(n),f=useRef(false),m=useRef(null),g=useRef(0);if(d.current!==n){let Y=d.current/n;d.current=n;for(let[q,Te]of r.current)r.current.set(q,Math.max(1,Math.round(Te*Y)));o.current++,f.current=true,g.current=2;}let y=g.current>0?m.current:null,w=useRef(0),x=useRef(null),v=useCallback(Y=>t.current?.subscribe(Y)??mv,[t]);useSyncExternalStore(v,()=>{let Y=t.current;if(!Y)return NaN;let q=Y.getScrollTop()+Y.getPendingDelta(),Te=Math.floor(q/fv);return Y.isSticky()?~Te:Te});let b=t.current?.getScrollTop()??-1,h=t.current?.getPendingDelta()??0,T=t.current?.getViewportHeight()??0,A=t.current?.isSticky()??true;useMemo(()=>{let Y=new Set(e),q=false;for(let Te of r.current.keys())Y.has(Te)||(r.current.delete(Te),q=true);for(let Te of c.current.keys())Y.has(Te)||c.current.delete(Te);q&&o.current++;},[e]);let M=e.length;if(s.current.version!==o.current||s.current.n!==M){let Y=s.current.arr.length>=M+1?s.current.arr:new Float64Array(M+1);Y[0]=0;for(let q=0;q<M;q++)Y[q+1]=Y[q]+(r.current.get(e[q])??uv);s.current={arr:Y,version:o.current,n:M};}let D=s.current.arr,N=D[M],R,E;if(y)[R,E]=y,R=Math.min(R,M),E=Math.min(E,M);else if(T===0||b<0)R=Math.max(0,M-dv),E=M;else {if(A){let se=T+ai;for(R=M;R>0&&N-D[R-1]<se;)R--;E=M;}else {let se=w.current,lt=T*3,Be=Math.min(b,b+h),He=Math.max(b,b+h),re=He-Be,rt=re>lt&&h<0?He-lt:Be,xt=rt+Math.min(re,lt),Zt=Math.max(0,rt-se),Mt=xt-se,Vt=Zt-ai;{let we=0,qe=M;for(;we<qe;){let ot=we+qe>>1;D[ot+1]<=Vt?we=ot+1:qe=ot;}R=we;}{let we=m.current;if(we&&we[0]<R)for(let qe=we[0];qe<Math.min(R,we[1]);qe++){let ot=e[qe];if(l.current.has(ot)&&!r.current.has(ot)){R=qe;break}}}let Dt=T+2*ai,We=Math.min(M,R+es),ke=0;for(E=R;E<We&&(ke<Dt||D[E]<Mt+T+ai);)ke+=r.current.get(e[E])??du,E++;}let Y=T+2*ai,q=Math.max(0,E-es),Te=0;for(let se=R;se<E;se++)Te+=r.current.get(e[se])??du;for(;R>q&&Te<Y;)R--,Te+=r.current.get(e[R])??du;let Ce=m.current,ge=Math.abs(b-i.current)+Math.abs(h);if(Ce&&ge>T*2){let[se,lt]=Ce;R<se-ts&&(R=se-ts),E>lt+ts&&(E=lt+ts),R>E&&(E=Math.min(R+ts,M));}i.current=b;}g.current>0?g.current--:m.current=[R,E];let I=useDeferredValue(R),F=useDeferredValue(E),O=R<I?I:R,L=E>F?F:E;if((O>L||A)&&(O=R,L=E),h>0&&(L=E),L-O>es){let Y=(D[O]+D[L])/2;b-w.current<Y?L=O+es:O=L-es;}let J=w.current,le=D[O],Oe=O===0?0:le+J,Pe=L===M?1/0:Math.max(le,D[L]-T)+J;useLayoutEffect(()=>{A?t.current?.setClampBounds(void 0,void 0):t.current?.setClampBounds(Oe,Pe);}),useLayoutEffect(()=>{let Y=x.current?.yogaNode;if(Y&&Y.getComputedWidth()>0&&(w.current=Y.getComputedTop()),f.current){f.current=false;return}let q=false;for(let[Te,Ce]of l.current){let ge=Ce.yogaNode;if(!ge)continue;let se=ge.getComputedHeight(),lt=r.current.get(Te);se>0?lt!==se&&(r.current.set(Te,se),q=true):ge.getComputedWidth()>0&&lt!==0&&(r.current.set(Te,0),q=true);}q&&o.current++;});let Ye=useCallback(Y=>{let q=c.current.get(Y);return q||(q=a(Te=>{if(Te)l.current.set(Y,Te);else {let Ce=l.current.get(Y)?.yogaNode;if(Ce&&!f.current){let ge=Ce.getComputedHeight();(ge>0||Ce.getComputedWidth()>0)&&r.current.get(Y)!==ge&&(r.current.set(Y,ge),o.current++);}l.current.delete(Y);}},"fn"),c.current.set(Y,q)),q},[]),Z=useCallback(Y=>{let q=l.current.get(e[Y])?.yogaNode;return !q||q.getComputedWidth()===0?-1:q.getComputedTop()},[e]),Se=useCallback(Y=>l.current.get(e[Y])??null,[e]),W=useCallback(Y=>r.current.get(e[Y]),[e]),me=useCallback(Y=>{let q=s.current;Y<0||Y>=q.n||t.current?.scrollTo(q.arr[Y]+w.current);},[t]),pe=N-D[L];return {range:[O,L],topSpacer:le,bottomSpacer:pe,measureRef:Ye,spacerRef:x,offsets:D,getItemTop:Z,getItemElement:Se,getItemHeight:W,scrollToIndex:me}}a(Dg,"useVirtualScroll");h();function Ig(t,e,n=200,r=50){let o=e.current,i=o?t.findIndex(c=>c.id===o.id):-1,s=i>=0?i:o?Math.min(o.idx,Math.max(0,t.length-n)):0;t.length-s>n+r&&(s=t.length-n);let l=t[s];return l&&(o?.id!==l.id||o.idx!==s)?e.current={id:l.id,idx:s}:!l&&o&&(e.current=null),s}a(Ig,"computeSliceStart");function Fg({active:t,children:e}){return t?jsx(S,{borderStyle:"single",borderColor:"ansi:cyan",borderLeft:true,borderRight:false,borderTop:false,borderBottom:false,paddingLeft:1,children:e}):jsx(Fragment,{children:e})}a(Fg,"CursorOutline");var Hg=forwardRef(a(function({entries:e,renderEntry:n,columns:r,streamingEntryId:o=null,selectedEntryId:i=null,expanded:s=false,dividerIndex:l,unseenCount:c=0},d){let f=useRef(null),m=useRef(null);useImperativeHandle(d,()=>({scrollToBottom:a(()=>f.current?.scrollToBottom(),"scrollToBottom"),scrollBy:a(M=>f.current?.scrollBy(M),"scrollBy"),getViewportHeight:a(()=>f.current?.getViewportHeight()??0,"getViewportHeight")}));let g=useMemo(()=>e.map(M=>M.id),[e]),{range:y,topSpacer:w,bottomSpacer:x,measureRef:v,spacerRef:b}=Dg(f,g,r),{fullscreen:h}=Ba();if(!h){let M=Ig(e,m),D=M>0?e.slice(M):e,N=M,R=a((E,I)=>{let F=i===E.id;return jsxs(Lg.Fragment,{children:[l!==null&&l===I&&c>0&&jsx($g,{count:c}),jsx(S,{flexDirection:"column",flexShrink:0,children:jsx(Fg,{active:F,children:jsx(uu,{entry:E,columns:r,isStreaming:o===E.id,isSelected:F,expanded:s,render:O=>n(O,O.id,s)})})})]},E.id)},"renderRow");return jsx(S,{flexDirection:"column",children:D.map((E,I)=>R(E,N+I))})}let[T,A]=y;return jsxs(Lc,{ref:f,flexGrow:1,flexDirection:"column",stickyScroll:true,children:[jsx(S,{ref:b,height:w,flexShrink:0}),e.slice(T,A).map((M,D)=>{let N=T+D,R=i===M.id;return jsxs(Lg.Fragment,{children:[l!==null&&l===N&&c>0&&jsx($g,{count:c}),jsx(S,{ref:v(M.id),flexDirection:"column",flexShrink:0,children:jsx(Fg,{active:R,children:jsx(uu,{entry:M,columns:r,isStreaming:o===M.id,isSelected:R,expanded:s,render:E=>n(E,E.id,s)})})})]},M.id)}),jsx(S,{height:x,flexShrink:0})]})},"VirtualMessageList"));function $g({count:t}){return jsxs(S,{marginY:0,marginLeft:1,children:[jsx(u,{dim:true,children:"\u2500\u2500\u2500\u2500\u2500\u2500 "}),jsxs(u,{color:"ansi:cyanBright",bold:true,children:[t," new"]}),jsx(u,{dim:true,children:" \u2500\u2500\u2500\u2500\u2500\u2500"})]})}a($g,"UnseenDivider");h();var vv=500,uo=new Map;function fu(t,e){let n=uo.get(t);if(n!==void 0)return uo.delete(t),uo.set(t,n),n;let r=e(t);if(uo.size>=vv){let o=uo.keys().next().value;o!==void 0&&uo.delete(o);}return uo.set(t,r),r}a(fu,"cachedRender");var Tv=/[*_`~#\[|\->!]|^\s{0,3}\d+\.\s/m;function mu(t){return Tv.test(t)}a(mu,"hasMarkdownSyntax");te.level||(te.level=3);var Fa=null,Ug=false;function Ev(){if(Fa)return Fa;if(Ug)return null;try{let t=process.stdout.columns||80;return Fa=new Marked(markedTerminal({showSectionPrefix:!1,width:Math.min(t,100),reflowText:!0,tab:2,emoji:!1})),Fa}catch{return Ug=true,null}}a(Ev,"getMarkedInstance");function pu(t){let e=Ev();if(!e)return t;try{return e.parse(t,{async:!1}).replace(/\n+$/,"")}catch{return t}}a(pu,"renderMarkdown");var Cv=/^\|\s*[-:]+[-|\s:]*\|$/m;function kv(t){let e=t.split(`
77
- `),n=-1,r=-1,o=-1;for(let c=0;c<e.length;c++){let d=e[c].trim();if(d.startsWith("|")&&d.endsWith("|"))n===-1&&(n=c),Cv.test(d)&&(o=c),r=c;else if(n!==-1)break}if(n===-1||o===-1||r-n<2)return null;let i=a(c=>c.split("|").slice(1,-1).map(d=>d.trim()),"parseRow"),s=i(e[n]),l=[];for(let c=o+1;c<=r;c++)l.push(i(e[c]));return {before:e.slice(0,n).join(`
78
- `),table:{headers:s,rows:l},after:e.slice(r+1).join(`
79
- `)}}a(kv,"extractTable");function _v({data:t}){let e=t.headers.map((n,r)=>{let o=n.length;for(let i of t.rows)i[r]&&i[r].length>o&&(o=i[r].length);return Math.min(o+2,40)});return jsxs(S,{flexDirection:"column",marginLeft:1,marginY:0,children:[jsx(S,{children:t.headers.map((n,r)=>jsx(S,{width:e[r],children:jsx(u,{bold:true,children:n})},r))}),jsx(S,{children:e.map((n,r)=>jsx(S,{width:n,children:jsx(u,{dim:true,children:"\u2500".repeat(Math.max(n-1,1))})},r))}),t.rows.map((n,r)=>jsx(S,{children:t.headers.map((o,i)=>jsx(S,{width:e[i],children:jsx(u,{children:n[i]??""})},i))},r))]})}a(_v,"MarkdownTable");function jg(t){let e=[],n=t,r=0;for(;n;){let o=kv(n);if(!o){let i=mu(n)?fu(n,pu):n,s=i.trim()?i:n;e.push(jsx(S,{flexDirection:"column",children:jsx(dn,{children:s})},r++));break}if(o.before.trim()){let i=mu(o.before)?fu(o.before,pu):o.before;e.push(jsx(S,{flexDirection:"column",children:jsx(dn,{children:i})},r++));}e.push(jsx(_v,{data:o.table},r++)),n=o.after;}return e}a(jg,"renderHybrid");function Rv({text:t,nested:e}){let n=useRef({text:"",rendered:null}),r=n.current.text,o=t.slice(r.length);t.startsWith(r)||(n.current={text:"",rendered:null},r="",o=t);let i=0;try{let l=lexer(o),c=l.length-1;for(;c>=0&&l[c].type==="space";)c--;for(let d=0;d<c;d++)i+=l[d].raw.length;}catch{}if(i>0){let l=r+o.slice(0,i);n.current={text:l,rendered:jg(l)},r=l,o=t.slice(r.length);}let s=useMemo(()=>o?mu(o)?jsx(dn,{children:fu(o,pu)}):jsx(dn,{children:o}):null,[o]);return jsxs(S,{flexDirection:"column",marginLeft:1,marginTop:e?0:1,children:[n.current.rendered,s?jsx(S,{flexDirection:"column",children:s}):null,jsx(u,{dim:true,children:"\u258C"})]})}a(Rv,"StreamingMarkdown");function gu({text:t,streaming:e,nested:n}){return t?e?jsx(Rv,{text:t,nested:n}):jsx(Mv,{text:t,nested:n}):null}a(gu,"MessageContent");function Mv({text:t,nested:e}){let n=useMemo(()=>jg(t),[t]);return jsx(S,{flexDirection:"column",marginLeft:1,marginTop:e?0:1,children:n})}a(Mv,"FinalMarkdown");function Kg({text:t}){return jsxs(S,{marginTop:1,marginBottom:0,children:[jsx(u,{bold:true,children:"\u276F "}),jsx(u,{bold:true,children:t})]})}a(Kg,"UserMessage");function Yg({error:t,nested:e}){return jsxs(S,{marginLeft:1,marginTop:e?0:1,children:[jsx(u,{color:"ansi:red",bold:true,children:"\u2717 "}),jsx(u,{color:"ansi:red",children:t})]})}a(Yg,"ErrorMessage");function Vg({text:t}){return jsxs(S,{flexDirection:"column",marginLeft:1,marginTop:1,children:[jsxs(S,{children:[jsx(u,{color:"ansi:yellow",bold:true,children:"\u26A0 "}),jsx(u,{color:"ansi:yellow",children:"Rate limit reached"})]}),jsx(S,{marginLeft:2,children:jsx(u,{dim:true,children:t})}),jsxs(S,{marginLeft:2,children:[jsx(u,{dim:true,children:"Use "}),jsx(u,{bold:true,children:"/compact"}),jsx(u,{dim:true,children:" to reduce context or wait a moment."})]})]})}a(Vg,"RateLimitMessage");function qg(){return jsxs(S,{flexDirection:"column",marginLeft:1,marginTop:1,children:[jsxs(S,{children:[jsx(u,{color:"ansi:yellow",bold:true,children:"\u26A0 "}),jsx(u,{color:"ansi:yellow",children:"Context limit reached"})]}),jsxs(S,{marginLeft:2,children:[jsx(u,{dim:true,children:"Use "}),jsx(u,{bold:true,children:"/compact"}),jsx(u,{dim:true,children:" to summarize or "}),jsx(u,{bold:true,children:"/clear"}),jsx(u,{dim:true,children:" to start fresh."})]})]})}a(qg,"ContextLimitMessage");function zg({content:t,collapsed:e,nested:n}){let r=n?0:1;return e||!t?jsx(S,{marginLeft:1,marginTop:r,children:jsx(u,{dim:true,italic:true,children:"\u2234 Thinking"})}):jsxs(S,{flexDirection:"column",marginLeft:1,marginTop:r,children:[jsx(u,{dim:true,italic:true,children:"\u2234 Thinking\u2026"}),jsx(S,{marginLeft:2,children:jsx(u,{dim:true,children:t})})]})}a(zg,"ThinkingMessage");h();var rs=40;function Jg({toolName:t,description:e,riskLevel:n,args:r,cwd:o,onDecision:i}){let[s,l]=useState(0),c=Nv(t),d=c==="generic"?Iv(t,r):{body:[]},f=Lv(t,r),m=[{label:"Yes",scope:"once",approved:true},{label:`Yes, allow ${f} for this session`,scope:"session",approved:true},{label:`Yes, allow ${f} for this project (saved)`,scope:"project",approved:true},{label:"No (esc)",scope:"once",approved:false}];ft((v,b)=>{if(b.upArrow){l(T=>T>0?T-1:m.length-1);return}if(b.downArrow){l(T=>T<m.length-1?T+1:0);return}if(b.return){g(s);return}if(b.escape){i(false,"once");return}let h=v.toLowerCase();h==="1"||h==="y"?g(0):h==="2"||h==="a"?g(1):h==="3"||h==="p"?g(2):(h==="4"||h==="n")&&g(3);});function g(v){let b=m[v];i(b.approved,b.scope);}a(g,"decide");let y=n==="high"?"ansi:red":n==="medium"?"ansi:yellow":"ansi:cyan",w=Dv(t),x=Bv(o);return jsxs(S,{flexDirection:"column",borderStyle:"round",borderColor:y,paddingX:1,marginLeft:1,marginY:0,children:[jsxs(S,{children:[jsx(u,{color:y,bold:true,children:w}),n==="high"&&jsx(u,{color:"ansi:red",children:" \u26A0 high risk"})]}),jsxs(S,{marginTop:1,flexDirection:"column",marginLeft:1,children:[c==="write"?jsx(Ov,{filePath:String(r.file_path??""),content:String(r.content??"")}):c==="edit"?jsx(Pv,{filePath:String(r.file_path??""),oldString:String(r.old_string??""),newString:String(r.new_string??"")}):d.body.map((v,b)=>jsx(u,{children:v},b)),jsx(u,{dim:true,children:e}),jsxs(u,{dim:true,children:["cwd: ",x]})]}),jsx(S,{marginTop:1,children:jsx(u,{children:"Do you want to proceed?"})}),jsx(S,{flexDirection:"column",marginLeft:1,children:m.map((v,b)=>jsxs(S,{children:[jsx(u,{color:b===s?"ansi:cyan":void 0,children:b===s?"\u276F ":" "}),jsxs(u,{dim:true,children:[b+1,". "]}),jsx(u,{bold:b===s,children:v.label})]},b))})]})}a(Jg,"PermissionPrompt");function Nv(t){return t==="Write"?"write":t==="Edit"?"edit":"generic"}a(Nv,"previewKindFor");function Ov({filePath:t,content:e}){let n=e.split(`
80
- `),r=n.length>rs,o=r?n.slice(0,rs):n,i=homedir(),s=t.startsWith(i)?"~"+t.slice(i.length):t;return jsxs(S,{flexDirection:"column",children:[jsx(u,{bold:true,children:s}),jsxs(S,{marginTop:1,flexDirection:"column",children:[o.map((l,c)=>jsx(Zo,{kind:"add",text:l},c)),r&&jsx(u,{dim:true,children:` \u2026 ${n.length-rs} more lines`})]})]})}a(Ov,"WritePreview");function Pv({filePath:t,oldString:e,newString:n}){let r=e.split(`
81
- `),o=n.split(`
82
- `),i=r.length+o.length,s=homedir(),l=t.startsWith(s)?"~"+t.slice(s.length):t,c=r,d=o,f=0;if(i>rs){let m=Math.floor(rs/2);c=r.slice(0,m),d=o.slice(0,m),f=i-(c.length+d.length);}return jsxs(S,{flexDirection:"column",children:[jsx(u,{bold:true,children:l}),jsxs(S,{marginTop:1,flexDirection:"column",children:[c.map((m,g)=>jsx(Zo,{kind:"remove",text:m},`o${g}`)),d.map((m,g)=>jsx(Zo,{kind:"add",text:m},`n${g}`)),f>0&&jsx(u,{dim:true,children:` \u2026 ${f} more lines`})]})]})}a(Pv,"EditPreview");function Dv(t){switch(t){case "Bash":return "Bash command";case "Edit":return "Edit file";case "Write":return "Write file";case "Read":return "Read file";case "WebFetch":return "Fetch URL";case "Agent":return "Launch sub-agent";default:return t}}a(Dv,"toolTitle");function Iv(t,e){switch(t){case "Bash":return {body:String(e.command??"").split(`
83
- `)};case "Edit":case "Write":case "Read":return {body:[String(e.file_path??e.path??"")]};case "WebFetch":return {body:[String(e.url??"")]};default:return {body:JSON.stringify(e,null,2).split(`
84
- `).slice(0,8)}}}a(Iv,"describeArgs");function Lv(t,e){return t==="Bash"?`\`${String(e.command??"").trim().split(/\s+/)[0]??"Bash"}\``:t}a(Lv,"scopeLabel");function Bv(t){let e=homedir();return t.startsWith(e)?"~"+t.slice(e.length):t}a(Bv,"shortenPath");h();var Xg="Other...",Fv="Agent question",yu="ansi:yellow";function Qg({question:t,header:e,options:n,multiSelect:r,onAnswer:o,onCancel:i}){let s=!!n&&n.length>0,l=s?[...n,{label:Xg,description:"Type a custom answer"}]:[{label:Xg,description:"Type your answer"}],c=l.length-1,[d,f]=useState("pick"),[m,g]=useState(s?0:c),[y,w]=useState(new Set),[x,v]=useState(""),[b,h]=useState(0),T=m===c;function A(){if(r&&s){let N=[...y].sort((I,F)=>I-F).filter(I=>I!==c).map(I=>l[I].label),R=x.trim();return (R?[...N,`Other: ${R}`]:N).join(", ")}if(T){let N=x.trim();return N?s?`Other: ${N}`:N:s?"Other":""}return l[m].label}a(A,"buildAnswer");function M(){if(r&&s){let N=[...y].sort((E,I)=>E-I).filter(E=>E!==c).map(E=>l[E].label),R=x.trim();return R&&N.push(`Other: ${R}`),N.length>0?N:["(nothing selected)"]}if(T){let N=x.trim();return N?[s?`Other: ${N}`:N]:[s?"Other":"(empty)"]}return [l[m].label]}a(M,"reviewLines");function D(){if(r&&s){let N=[...y].some(E=>E!==c),R=x.trim().length>0;if(!N&&!R)return}else if(T&&!x.trim()&&!s)return;h(0),f("review");}return a(D,"advanceToReview"),ft((N,R)=>{if(d==="review"){if(R.escape){f("pick");return}if(R.upArrow){h(E=>E>0?E-1:1);return}if(R.downArrow){h(E=>E<1?E+1:0);return}if(N==="1"){h(0);return}if(N==="2"){h(1);return}R.return&&(b===0?o(A()):f("pick"));return}if(R.escape){i();return}if(R.upArrow){g(E=>E>0?E-1:l.length-1);return}if(R.downArrow){g(E=>E<l.length-1?E+1:0);return}if(R.return){T||D();return}if(r&&s&&N===" "&&!T){w(E=>{let I=new Set(E);return I.has(m)?I.delete(m):I.add(m),I});return}if(!T&&/^[1-9]$/.test(N)){let E=parseInt(N,10)-1;E>=0&&E<l.length&&g(E);return}}),jsx(Wv,{header:e,children:d==="pick"?jsx($v,{question:t,choices:l,cursor:m,selected:y,inputValue:x,setInputValue:v,onInputSubmit:()=>D(),multiSelect:!!r,hasOptions:s,inputIdx:c}):jsx(Hv,{lines:M(),reviewCursor:b})})}a(Qg,"AskUserPrompt");function $v({question:t,choices:e,cursor:n,selected:r,inputValue:o,setInputValue:i,onInputSubmit:s,multiSelect:l,hasOptions:c,inputIdx:d}){return jsxs(Fragment,{children:[jsx(S,{marginTop:1,marginLeft:1,children:jsx(u,{children:t})}),jsx(S,{flexDirection:"column",marginTop:1,marginLeft:1,children:e.map((f,m)=>{let g=m===n,y=r.has(m),w=m===d,x=`${m+1}.`,v=g?"ansi:cyan":void 0,b=g?"ansi:cyan":void 0,h=l&&c&&!w?y?"\u25C9":"\u25EF":null;return jsxs(S,{flexDirection:"column",marginTop:m===0?0:1,children:[jsxs(S,{children:[jsx(u,{color:v,children:`${g?"\u276F":" "} `}),h&&jsx(u,{color:v,children:`${h} `}),jsx(u,{color:v,bold:g,children:`${x} `}),w?g?jsx(Fr,{value:o,onChange:i,onSubmit:s,placeholder:c?"Type a custom answer here":"Type your answer"}):jsx(u,{dim:true,children:f.label}):jsx(u,{color:b,bold:g,children:f.label})]}),f.description&&(!w||!g)&&jsx(S,{marginLeft:h?7:5,children:jsx(u,{dim:true,children:f.description})})]},m)})}),jsx(S,{marginTop:1,marginLeft:1,children:jsx(u,{dim:true,children:l&&c?"\u2191\u2193 move \xB7 1-9 jump \xB7 Space toggle \xB7 Enter continue \xB7 Esc cancel":"\u2191\u2193 move \xB7 1-9 jump \xB7 Enter continue \xB7 Esc cancel"})})]})}a($v,"PickPhase");function Hv({lines:t,reviewCursor:e}){let n=[{label:"Submit answers",description:"Send your answer to the agent"},{label:"Cancel",description:"Go back and change your selection"}];return jsxs(Fragment,{children:[jsx(S,{marginTop:1,marginLeft:1,children:jsx(u,{bold:true,children:"Review your answers"})}),jsx(S,{flexDirection:"column",marginTop:1,marginLeft:3,children:t.map((r,o)=>jsxs(S,{children:[jsx(u,{color:"ansi:green",children:"\u25CF "}),jsx(u,{children:r})]},o))}),jsx(S,{marginTop:1,marginLeft:1,children:jsx(u,{children:"Ready to submit your answers?"})}),jsx(S,{flexDirection:"column",marginTop:1,marginLeft:1,children:n.map((r,o)=>{let i=o===e,s=i?"ansi:cyan":void 0;return jsxs(S,{flexDirection:"column",marginTop:o===0?0:1,children:[jsxs(S,{children:[jsx(u,{color:s,children:`${i?"\u276F":" "} `}),jsx(u,{color:s,bold:i,children:`${o+1}. ${r.label}`})]}),jsx(S,{marginLeft:5,children:jsx(u,{dim:true,children:r.description})})]},o)})}),jsx(S,{marginTop:1,marginLeft:1,children:jsx(u,{dim:true,children:"\u2191\u2193 move \xB7 1-2 jump \xB7 Enter select \xB7 Esc back"})})]})}a(Hv,"ReviewPhase");function Wv({header:t,children:e}){return jsxs(S,{flexDirection:"column",borderStyle:"round",borderColor:yu,paddingX:1,marginLeft:1,marginY:0,children:[jsxs(S,{children:[jsx(u,{color:yu,bold:true,children:"? "}),jsx(u,{color:yu,bold:true,children:t??Fv})]}),e]})}a(Wv,"Frame");h();h();function jv(t,e,n=""){let r=t.lastIndexOf("/"),o=r>=0?t.slice(r+1):t,i=n.toLowerCase(),s=i&&!o.toLowerCase().startsWith(`${i}-`)?`${i}-${o}`:o,l=new Set(e);if(!l.has(s))return s;for(let c=2;;c++){let d=`${s}-${c}`;if(!l.has(d))return d}}a(jv,"deriveModelAlias");function eh(t,e){let n=t;(/^https?:\/\//.test(t)||t.includes("."))&&(n=(t.replace(/^https?:\/\//,"").split("/")[0]??"custom").replace(/[^a-z0-9]+/gi,"-").toLowerCase().replace(/^-+|-+$/g,""));let r=new Set(e);if(!r.has(n))return n;for(let o=2;;o++){let i=`${n}-${o}`;if(!r.has(i))return i}}a(eh,"deriveProviderKey");function th(t,e){return t?/\s/.test(t)?"Alias must not contain whitespace":e.includes(t)?"Alias already used":null:"Alias cannot be empty"}a(th,"validateAlias");var Kv=["openrouter","anthropic","openai","deepseek","zai","xai","google","mistral","groq","ollama","custom"],nh={openrouter:"OpenRouter (\u63A8\u8350 \u2014 \u652F\u6301\u6240\u6709\u6A21\u578B)",anthropic:"Anthropic (\u76F4\u8FDE Claude API)",openai:"OpenAI",deepseek:"DeepSeek (\u5B98\u65B9\u76F4\u8FDE)",zai:"Z.AI (GLM \u5B98\u65B9)",xai:"xAI (Grok)",google:"Google Gemini",mistral:"Mistral",groq:"Groq",ollama:"Ollama (\u672C\u5730,\u65E0\u9700 key)",custom:"\u81EA\u5B9A\u4E49 (OpenAI-\u517C\u5BB9)"},Yv={openrouter:"https://openrouter.ai/keys",anthropic:"https://console.anthropic.com/settings/keys",openai:"https://platform.openai.com/api-keys",deepseek:"https://platform.deepseek.com/api_keys",zai:"https://z.ai/manage-apikey/apikey-list",xai:"https://console.x.ai",google:"https://aistudio.google.com/apikey",mistral:"https://console.mistral.ai/api-keys",groq:"https://console.groq.com/keys"};function Vv(t){return t.length<=8?"\u2022\u2022\u2022\u2022":`${t.slice(0,4)}\u2022\u2022\u2022\u2022${t.slice(-4)}`}a(Vv,"maskKey");function $a({existingProviders:t,existingModelKeys:e,existingModelIds:n=[],detectedEnvKeys:r=[],switchToNewModelOnFinish:o,onFinish:i,onCancel:s}){let l=new Set(n),c=Kv.map(U=>({type:"kind",label:nh[U]??a$2[U]?.label??U,kind:U})),d=t.map(U=>U.key),[f,m]=useState("kind"),[g,y]=useState(0),[w,x]=useState(),[v,b]=useState("openai"),[h,T]=useState(""),[A,M]=useState(null),D=useRef(false),[N,R]=useState(""),[E,I]=useState(0),[F,O]=useState(false),[L$1,J]=useState(),[le,Oe]=useState(false),[Pe,Ye]=useState(0),[Z,Se]=useState(new Set),[W,me]=useState([]),[pe,Y]=useState(false),[q,Te]=useState(""),[Ce,ge]=useState([]),[se,lt]=useState(0),[Be,He]=useState(0),[re,rt]=useState(false),xt=a(U=>r.find($=>$.kindHint===U),"envHintForKind"),Zt=a(U=>t.filter($=>$.kind===U),"matchingExistingProviders"),Mt=a(U=>{let $=Zt(U).map(K=>({type:"existing",provider:K})),V=xt(U);return V&&$.push({type:"env",hint:V}),$.push({type:"paste"}),$},"keyChoicesFor");useEffect(()=>{f==="fetch"&&(L$1||le||Vt(true));},[f]);async function Vt(U){Oe(true);let $=w?{key:w.key,kind:w.kind,baseUrl:w.baseUrl,apiKey:w.apiKey,...w.modelsPath?{modelsPath:w.modelsPath}:{}}:{key:eh(v==="custom"?N:v,d),kind:v,baseUrl:N,apiKey:h},V=await b$2($,{cacheDir:d$3(),refresh:U});J(V),Oe(false);}a(Vt,"runFetch");function Dt(U){let $=[],V=[...e],K=w?.kind??(v==="custom"?"":v);for(let ne of U){let z=jv(ne.id,V,K);$.push(z),V.push(z);}ge($),lt(0),He(0),rt(false),m("alias");}a(Dt,"enterAliasStep");function We(){if(!L$1)return [];let U=new Map(L$1.models.map($=>[$.id,$]));return W.map($=>U.get($)).filter($=>$!==void 0)}a(We,"getPickedModels");function ke(U){let $=Ce.filter((V,K)=>K!==U);return [...e,...$]}a(ke,"aliasUsedSet");function we(){return Ce.every((U,$)=>th(U,ke($))===null)}a(we,"allAliasesValid");function qe(){let U=We();if(U.length===0||!we())return;let $=w?void 0:{key:eh(v==="custom"?N:v,d),kind:v,baseUrl:N,apiKey:v==="ollama"?void 0:h,label:a$2[v].label},V=w?.key??$.key,K=w?.baseUrl??$.baseUrl,ne=w?.apiKey??$.apiKey,he=(w?.kind??v)==="anthropic"?"anthropic":"openai",ct=U.map((mt,en)=>({key:Ce[en],label:mt.id,providerKey:V,protocol:he,provider:he,model:mt.id,baseUrl:K,apiKey:ne,maxContextTokens:mt.contextLength&&mt.contextLength>0?mt.contextLength:void 0,maxOutputTokens:mt.maxOutputTokens&&mt.maxOutputTokens>0?mt.maxOutputTokens:void 0}));i({addedProvider:$,addedModels:ct,activeModelKey:o?Ce[Be]:void 0});}return a(qe,"commitFinish"),ft((U,$)=>{if($.escape){if(f==="kind"){s();return}if(f==="key"){F?(O(false),T("")):m("kind");return}if(f==="baseUrl"){m("key");return}if(f==="fetch"){if(pe){Y(false),Te("");return}w||v==="ollama"?(x(void 0),m("kind")):(O(false),m("key"));return}if(f==="alias"){m("fetch");return}return}if(f==="kind"){if($.upArrow)y(V=>Math.max(0,V-1));else if($.downArrow)y(V=>Math.min(c.length-1,V+1));else if($.return){let V=c[g];if(!V)return;let K=V.kind;if(b(K),R(a$2[K].defaultBaseUrl),I(0),K==="ollama"){T(""),x(void 0),m("fetch");return}let ne=Mt(K),z=ne.length===1&&ne[0]?.type==="paste";O(z),m("key");}return}if(f==="key"){if(!F){let V=Mt(v);if(V.length===0)return;if($.upArrow)I(K=>Math.max(0,K-1));else if($.downArrow)I(K=>Math.min(V.length-1,K+1));else if($.return){let K$1=V[E];if(!K$1)return;if(K$1.type==="existing")x(K$1.provider),m("fetch");else if(K$1.type==="env"){let{value:ne}=K(K$1.hint.apiKey);T(ne),m(v==="custom"?"baseUrl":"fetch");}else O(true);}}return}if(f!=="baseUrl"){if(f==="fetch"){if(pe){if($.backspace||$.delete)Te(V=>V.slice(0,-1));else if($.return&&q){let V={id:q,contextLength:0,maxOutputTokens:0};J(z=>({fetchedAt:z?.fetchedAt??new Date().toISOString(),providerKey:z?.providerKey??"",models:[...z?.models??[],V],...z?.error?{error:z.error}:{},...z?.fromCache?{fromCache:z.fromCache}:{}}));let K=new Set(Z);K.add(q),Se(K);let ne=[...W,q];me(ne),Dt([...We(),V]);}else U&&!$.ctrl&&Te(V=>V+U);return}if(U==="r"){J(void 0),Vt(true);return}if(U==="m"){Y(true);return}if(!L$1||le||L$1.models.length===0)return;if($.upArrow)Ye(V=>Math.max(0,V-1));else if($.downArrow)Ye(V=>Math.min(L$1.models.length-1,V+1));else if(U===" "){let V=L$1.models[Pe];if(!V||l.has(V.id))return;let K=new Set(Z);K.has(V.id)?(K.delete(V.id),me(ne=>ne.filter(z=>z!==V.id))):(K.add(V.id),me(ne=>[...ne,V.id])),Se(K);}else $.return&&Z.size>0&&Dt(We());return}if(f==="alias"){let V=Ce.length,K=o&&V>0,ne=V+(K?1:0);if($.tab){let z=(se+1)%ne;lt(z),rt(K&&z===V);return}if($.downArrow){if(re&&K)He(z=>Math.min(V-1,z+1));else {let z=Math.min(ne-1,se+1);lt(z),rt(K&&z===V);}return}if($.upArrow){if(re&&K)He(z=>Math.max(0,z-1));else {let z=Math.max(0,se-1);lt(z),rt(K&&z===V);}return}if(re){$.return&&we()&&qe();return}$.backspace||$.delete?ge(z=>{let he=[...z];return he[se]=(he[se]??"").slice(0,-1),he}):$.return?we()&&qe():U&&!$.ctrl&&ge(z=>{let he=[...z];return he[se]=(he[se]??"")+U,he});return}}}),jsxs(S,{flexDirection:"column",marginLeft:1,children:[jsxs(S,{children:[jsx(u,{color:"ansi:cyan",bold:true,children:w?"\u2726 \u6DFB\u52A0\u6A21\u578B":"\u2726 \u6DFB\u52A0 provider + \u6A21\u578B"}),jsx(u,{dim:true,children:" (Esc \u53D6\u6D88)"})]}),f==="kind"&&jsxs(S,{flexDirection:"column",marginTop:1,children:[jsx(u,{dim:true,children:"\u9009\u62E9 API \u63D0\u4F9B\u5546:"}),c.map((U,$)=>jsx(S,{children:jsxs(u,{color:$===g?"ansi:cyan":void 0,bold:$===g,children:[$===g?"\u276F ":" ",U.label]})},U.kind))]}),f==="key"&&(()=>{let U=nh[v]??a$2[v].label,$=Yv[v],V=Mt(v);return jsxs(S,{flexDirection:"column",marginTop:1,children:[jsx(u,{dim:true,children:U}),$&&jsxs(u,{dim:true,children:["\u83B7\u53D6 Key: ",$]}),!F?jsx(S,{flexDirection:"column",marginTop:1,children:V.map((ne,z)=>{let he=z===E,ct=he?"\u276F ":" ";return ne.type==="existing"?jsxs(S,{children:[jsxs(u,{color:he?"ansi:cyan":void 0,bold:he,children:[ct,"\u4F7F\u7528\u5DF2\u6709: ",ne.provider.label??ne.provider.key]}),jsx(u,{dim:true,children:` (${ne.provider.kind})`})]},`existing-${ne.provider.key}`):ne.type==="env"?jsxs(S,{children:[jsxs(u,{color:he?"ansi:cyan":void 0,bold:he,children:[ct,"\u4F7F\u7528\u73AF\u5883\u53D8\u91CF $",ne.hint.envKey]}),jsx(u,{dim:true,children:` (${Vv(ne.hint.apiKey)})`})]},`env-${ne.hint.envKey}`):jsx(S,{children:jsxs(u,{color:he?"ansi:cyan":void 0,bold:he,children:[ct,"\u7C98\u8D34\u65B0 key"]})},"paste")})}):jsxs(S,{marginTop:1,children:[jsx(u,{color:"ansi:cyan",children:"API Key: "}),jsx(Fr,{value:h,onChange:ne=>{T(ne),D.current=false,A&&M(null);},onSubmit:()=>{let{value:ne,changed:z,warnings:he}=K(h);if(!ne){M("API Key \u4E0D\u80FD\u4E3A\u7A7A");return}if(z){T(ne),M((he.length>0?`\u5DF2\u81EA\u52A8\u6E05\u7406\u7C98\u8D34\u5B57\u7B26: ${he.join("\u3001")}`:"\u5DF2\u81EA\u52A8\u6E05\u7406\u7C98\u8D34\u5B57\u7B26")+",\u518D\u6309 Enter \u786E\u8BA4");return}if(L(ne)&&!D.current){D.current=true,M("Key \u542B\u975E ASCII \u5B57\u7B26,\u53EF\u80FD\u7C98\u9519\u4E86\u3002\u518D\u6309 Enter \u5F3A\u5236\u4F7F\u7528");return}M(null),D.current=false,m(v==="custom"?"baseUrl":"fetch");},placeholder:"\u7C98\u8D34\u4F60\u7684 API Key, Enter \u786E\u8BA4",focus:true}),A&&jsx(S,{marginLeft:1,children:jsxs(u,{color:"ansi:yellow",children:["\u26A0 ",A]})})]})]})})(),f==="baseUrl"&&jsx(S,{flexDirection:"column",marginTop:1,children:jsxs(S,{children:[jsx(u,{color:"ansi:cyan",children:"Base URL: "}),jsx(Fr,{value:N,onChange:R,onSubmit:()=>m("fetch"),placeholder:"\u542B /v1, Enter \u786E\u8BA4",focus:true})]})}),f==="fetch"&&jsxs(S,{flexDirection:"column",marginTop:1,children:[le&&jsx(u,{dim:true,children:"Loading\u2026"}),!le&&L$1?.error&&L$1.models.length===0&&jsxs(S,{flexDirection:"column",children:[jsxs(u,{color:"red",children:["Error: ",L$1.error]}),jsx(u,{dim:true,children:"Press r to retry \xB7 m for manual id \xB7 Esc to cancel"})]}),!le&&L$1&&L$1.models.length>0&&!pe&&jsxs(S,{flexDirection:"column",children:[jsxs(u,{dim:true,children:["Pick models (Space to toggle, Enter when done) \u2014 ",Z.size," selected",n.length>0?` \xB7 ${n.length} \u5DF2\u6DFB\u52A0 (\u7070\u8272\u4E0D\u53EF\u9009)`:""]}),L$1.fromCache&&jsxs(u,{dim:true,children:["Cached at ",new Date(L$1.fetchedAt).toLocaleString()," \xB7 press r to refresh"]}),L$1.models.slice(Math.max(0,Pe-8),Pe+9).map((U,$)=>{let V=Math.max(0,Pe-8)+$,K=Z.has(U.id);return l.has(U.id)?jsx(S,{children:jsxs(u,{dim:true,children:[V===Pe?"\u203A ":" ","[\u2713] ",U.id,U.contextLength?` (${U.contextLength.toLocaleString()} ctx)`:""," (\u5DF2\u6DFB\u52A0)"]})},U.id):jsxs(u,{color:V===Pe?"ansi:cyan":void 0,children:[V===Pe?"\u203A ":" ","[",K?"x":" ","] ",U.id,U.contextLength?jsxs(u,{dim:true,children:[" (",U.contextLength.toLocaleString()," ctx)"]}):null]},U.id)})]}),pe&&jsxs(S,{flexDirection:"column",children:[jsx(u,{children:"Manual model id:"}),jsx(u,{color:"ansi:cyan",children:q}),jsx(u,{dim:true,children:"Enter when done."})]})]}),f==="alias"&&jsxs(S,{flexDirection:"column",marginTop:1,children:[jsx(u,{children:"Local alias for each model:"}),We().map((U,$)=>{let V=th(Ce[$]??"",ke($)),K=!re&&$===se;return jsxs(S,{flexDirection:"column",marginTop:1,children:[jsx(u,{dim:true,children:U.id}),jsxs(u,{color:K?"cyan":void 0,children:[K?"\u203A ":" ",Ce[$]??""]}),K&&V&&jsx(u,{color:"red",children:V}),!K&&V&&jsx(u,{color:"red",dim:true,children:V})]},U.id)}),o&&Ce.length>0&&jsxs(S,{flexDirection:"column",marginTop:1,children:[jsx(u,{children:"Which becomes active? \u2191\u2193"}),Ce.map((U,$)=>jsxs(u,{color:re&&$===Be?"cyan":void 0,children:[re&&$===Be?"\u203A ":" ",$===Be?"(\u2022) ":"( ) ",U]},`active-${$}`))]}),jsx(u,{dim:true,children:"Tab/\u2193 to next field \xB7 Enter to finish"})]})]})}a($a,"ProviderModelFlow");function Ua({onComplete:t,onCancel:e,existingProviders:n=[],existingModelKeys:r=[],existingModelIds:o=[]}){let[i,s]=useState("flow"),[l,c]=useState(null),[d,f]=useState(new Set),[m,g]=useState(0);ft((x,v)=>{if(i!=="arena"||!l)return;let b=l.addedModels.map(h=>h.key);if(v.escape){y(l,new Set);return}if(x==="s"||x==="S"){y(l,new Set);return}if(v.upArrow)g(h=>Math.max(0,h-1));else if(v.downArrow)g(h=>Math.min(b.length-1,h+1));else if(x===" "){let h=b[m];if(!h)return;f(T=>{let A=new Set(T);return A.has(h)?A.delete(h):A.add(h),A});}else v.return&&y(l,d);});function y(x,v){if(x.addedModels.length===0){e();return}let b=x.addedModels.find(T=>T.key===x.activeModelKey)??x.addedModels[0],h={key:b.key,provider:b.provider,model:b.model,apiKey:b.apiKey??"",baseUrl:b.baseUrl};Q$1({activeKey:b.key,activeMirror:{provider:h.provider,model:h.model,apiKey:h.apiKey,baseUrl:h.baseUrl},addedProvider:x.addedProvider?{key:x.addedProvider.key,label:x.addedProvider.label,kind:x.addedProvider.kind,baseUrl:x.addedProvider.baseUrl,apiKey:x.addedProvider.apiKey,protocol:x.addedProvider.protocol,modelsPath:x.addedProvider.modelsPath}:void 0,addedModels:x.addedModels}),v.size>=2&&R$1([...v]),t(h);}a(y,"finish");function w(x){if(c(x),x.addedModels.length===0){e();return}if(x.addedModels.length===1){y(x,new Set);return}s("arena");}if(a(w,"handleFlowFinish"),i==="flow")return jsx($a,{existingProviders:n,existingModelKeys:r,existingModelIds:o,detectedEnvKeys:M().map(x=>({envKey:x.envKey,apiKey:x.apiKey,kindHint:x.provider.id??"openai"})),switchToNewModelOnFinish:true,onFinish:w,onCancel:e});if(i==="arena"&&l){let x=l.addedModels;return jsxs(S,{flexDirection:"column",marginLeft:1,children:[jsx(S,{children:jsx(u,{color:"ansi:cyan",bold:true,children:"\u2726 Arena participants"})}),jsx(S,{marginTop:1,marginLeft:2,children:jsx(u,{dim:true,children:"Space toggles \xB7 Enter finishes \xB7 s skips \xB7 Esc cancels."})}),jsx(S,{marginLeft:2,children:jsx(u,{dim:true,children:"Pick at least 2 to enable /arena, or skip."})}),x.map((v,b)=>{let h=b===m,T=d.has(v.key);return jsxs(S,{marginLeft:2,children:[jsxs(u,{color:h?"ansi:cyan":void 0,bold:h,children:[h?"\u276F ":" ",`[${T?"x":" "}] ${v.key}`]}),jsxs(u,{dim:true,children:[" ",v.model]})]},v.key)})]})}return null}a(Ua,"OnboardingPrompt");h();function rh(t){return !t||t<=0?"?":t>=1e6?`${(t/1e6).toFixed(0)}M`:t>=1e3?`${(t/1e3).toFixed(0)}K`:`${t}`}a(rh,"fmtTokens");function zv(t,e){let n=[],r=`${t} ${e}`.toLowerCase();return /coder|code|devstral/i.test(r)&&n.push("coding"),/reason|think|r1|o3|o4|pro/i.test(r)&&n.push("reasoning"),/flash|mini|haiku|fast|small|nano/i.test(r)&&n.push("fast"),/cheap|free/i.test(r)&&n.push("cheap"),/large|max|ultra|opus|big/i.test(r)&&n.push("powerful"),n}a(zv,"modelTags");function oh({entries:t,onSelect:e,onCancel:n}){let r=Math.max(0,t.findIndex(c=>c.active)),[o,i]=useState(r);if(ft((c,d)=>{if(t.length===0){(d.escape||d.return)&&n();return}d.upArrow?i(f=>f>0?f-1:t.length-1):d.downArrow?i(f=>f<t.length-1?f+1:0):d.return?e(t[o].key):d.escape&&n();}),t.length===0)return jsxs(S,{flexDirection:"column",marginLeft:1,children:[jsx(S,{children:jsx(u,{color:"ansi:cyan",bold:true,children:"\u2726 \u5207\u6362\u6A21\u578B"})}),jsx(S,{marginLeft:2,children:jsx(u,{dim:true,children:'\u672A\u914D\u7F6E\u6A21\u578B\u6C60\u3002\u8BF7\u7528 /login \u91CD\u65B0\u914D\u7F6E\u6216\u7F16\u8F91 settings.json \u7684 "models" \u5B57\u6BB5\u3002'})}),jsx(S,{marginLeft:2,children:jsx(u,{dim:true,children:"\u6309\u4EFB\u610F\u952E\u5173\u95ED"})})]});let s=Math.min(Math.max(...t.map(c=>c.key.length)),20),l=Math.min(Math.max(...t.map(c=>rh(c.maxContextTokens).length)),8);return jsxs(S,{flexDirection:"column",marginLeft:1,children:[jsxs(S,{children:[jsx(u,{color:"ansi:cyan",bold:true,children:"\u2726 \u5207\u6362\u6A21\u578B"}),jsx(u,{dim:true,children:" (\u2191\u2193 \u9009\u62E9, Enter \u786E\u8BA4, Esc \u53D6\u6D88)"})]}),jsx(S,{marginLeft:2,marginBottom:0,children:jsxs(u,{dim:true,children:[" ".padEnd(s+2),"\u6A21\u578B\u8DEF\u5F84"," ".repeat(28),"\u4E0A\u4E0B\u6587"," ","\u6807\u7B7E"]})}),t.map((c,d)=>{let f=d===o,m=f?"\u276F ":" ",g=c.active?" \u2190 active":"",y=zv(c.key,c.model),w=y.length>0?y.join(", "):"";return jsxs(S,{marginLeft:2,children:[jsxs(u,{color:f?"ansi:cyan":void 0,bold:f,children:[m,c.key.padEnd(s)]}),jsxs(u,{children:[" ",c.model.padEnd(32)]}),jsx(u,{dim:true,children:rh(c.maxContextTokens).padStart(l)}),jsx(u,{children:" "}),jsx(u,{color:"ansi:green",children:w}),jsx(u,{dim:true,children:g})]},c.key)})]})}a(oh,"ModelSelector");h();function sh({entries:t,snapshot:e,arenaParticipants:n,providers:r,onSwitch:o,onSync:i,onSaveArena:s,onOpenFlow:l,onRefreshProvider:c,onDeleteProvider:d,onDeleteModel:f,onClose:m}){let g=r??[],[y,w]=useState("models"),[x,v]=useState(()=>Math.max(0,t.findIndex(Z=>Z.active))),[b,h]=useState(0),[T,A]=useState({kind:"idle"}),[M,D]=useState(n),[N,R]=useState(0),[E,I]=useState(null),[F,O]=useState(false),[L,J]=useState(false);ft(async(Z,Se)=>{if(T.kind==="busy")return;let W=Z&&Z.length===1&&/[A-Za-z]/.test(Z)?Z.toLowerCase():Z;if(L&&!Se.escape&&W!=="q"&&J(false),Se.tab){w(me=>me==="models"?"providers":me==="providers"?"arena":"models"),A({kind:"idle"});return}if(Se.escape||W==="q"){if(F&&!L){A({kind:"error",text:"\u672A\u4FDD\u5B58\u6539\u52A8 \u2014 \u6309 [w] \u4FDD\u5B58\u6216\u518D\u6B21\u6309 Esc \u653E\u5F03"}),J(true);return}m();return}if(y==="models"){await le(W,Se);return}if(y==="providers"){await Oe(W,Se);return}await Pe(W,Se);});async function le(Z,Se){if(Z==="a"){l&&l();return}if(t.length===0){Z==="s"&&await Ye();return}if(Se.upArrow){v(W=>W>0?W-1:t.length-1);return}if(Se.downArrow){v(W=>W<t.length-1?W+1:0);return}if(Se.return){let W=t[x];if(!W)return;A({kind:"busy",text:`\u5207\u6362\u5230 ${W.key}\u2026`});try{await o(W.key),m();}catch(me){A({kind:"error",text:`\u5207\u6362\u5931\u8D25: ${me.message}`});}return}if(Z==="x"){if(!f)return;let W=t[x];if(!W)return;A({kind:"busy",text:`\u5220\u9664 ${W.key}\u2026`});try{await f(W.key),A({kind:"info",text:`\u2713 \u5DF2\u5220\u9664 ${W.key}`});}catch(me){A({kind:"error",text:`\u5220\u9664\u5931\u8D25: ${me.message}`});}return}if(Z==="s"){await Ye();return}}a(le,"handleModelsInput");async function Oe(Z,Se){if(Z==="a"){l&&l();return}if(g.length!==0){if(Se.upArrow){h(W=>W>0?W-1:g.length-1);return}if(Se.downArrow){h(W=>W<g.length-1?W+1:0);return}if(Z==="r"){if(!c)return;let W=g[b];if(!W)return;A({kind:"busy",text:`\u5237\u65B0 ${W.key} \u6A21\u578B\u6E05\u5355\u2026`});try{let me=await c(W.key);me.error?A({kind:"error",text:`\u5237\u65B0\u5931\u8D25: ${me.error}`}):A({kind:"info",text:`\u2713 \u5DF2\u7F13\u5B58 ${me.count} \u4E2A\u6A21\u578B`});}catch(me){A({kind:"error",text:`\u5237\u65B0\u5931\u8D25: ${me.message}`});}return}if(Z==="d"){if(!d)return;let W=g[b];if(!W)return;if(W.modelCount>0){A({kind:"error",text:`\u65E0\u6CD5\u5220\u9664: \u4ECD\u6709 ${W.modelCount} \u4E2A\u6A21\u578B\u5F15\u7528 ${W.key}`});return}A({kind:"busy",text:`\u5220\u9664 ${W.key}\u2026`});try{let me=await d(W.key);me.ok?A({kind:"info",text:`\u2713 \u5DF2\u5220\u9664 ${W.key}`}):A({kind:"error",text:`\u5220\u9664\u5931\u8D25: ${me.error??"\u672A\u77E5\u9519\u8BEF"}`});}catch(me){A({kind:"error",text:`\u5220\u9664\u5931\u8D25: ${me.message}`});}return}}}a(Oe,"handleProvidersInput");async function Pe(Z,Se){if(E){if(Se.upArrow){I({idx:E.idx>0?E.idx-1:t.length-1});return}if(Se.downArrow){I({idx:E.idx<t.length-1?E.idx+1:0});return}if(Se.return){let W=t[E.idx];W&&(D(me=>[...me,{kind:"key",value:W.key}]),O(true),A({kind:"info",text:`\u5DF2\u52A0\u5165: ${W.key} (\u672A\u4FDD\u5B58)`})),I(null);return}I(null);return}if(Se.upArrow){R(W=>Math.max(0,W-1));return}if(Se.downArrow){R(W=>M.length===0?0:Math.min(M.length-1,W+1));return}if(Z==="a"){if(t.length===0){A({kind:"error",text:"\u6A21\u578B\u6C60\u4E3A\u7A7A \u2014 \u5148\u5728 Models tab \u540C\u6B65\u5FEB\u7167"});return}I({idx:0}),A({kind:"info",text:"\u9009\u4E00\u4E2A\u6A21\u578B\u52A0\u5165 (Enter \u786E\u8BA4, \u4EFB\u610F\u952E\u53D6\u6D88)"});return}if(Z==="d"){if(M.length===0)return;let W=M[N];D(pe=>pe.filter((Y,q)=>q!==N)),R(pe=>Math.max(0,Math.min(M.length-2,pe))),O(true);let me=W?.kind==="key"?W.value:W?.label??"";A({kind:"info",text:`\u5DF2\u79FB\u9664: ${me} (\u672A\u4FDD\u5B58)`});return}if(Z==="w"){let W=M.filter(pe=>pe.kind==="object");if(W.length>0){A({kind:"error",text:`\u5B58\u5728 ${W.length} \u4E2A\u5BF9\u8C61\u5F62\u5F0F\u6761\u76EE\uFF0C\u8BF7\u76F4\u63A5\u7F16\u8F91 settings.json \u540E\u91CD\u542F`});return}let me=M.map(pe=>pe.value);A({kind:"busy",text:"\u4FDD\u5B58\u4E2D\u2026"});try{await s(me),A({kind:"info",text:`\u2713 \u5DF2\u4FDD\u5B58 (${me.length} \u4E2A participant)`}),O(!1);}catch(pe){A({kind:"error",text:`\u4FDD\u5B58\u5931\u8D25: ${pe.message}`});}return}}a(Pe,"handleArenaInput");async function Ye(){A({kind:"busy",text:"\u6B63\u5728\u62C9\u53D6 OpenRouter \u6A21\u578B\u6E05\u5355\u2026"});try{let Z=await i();Z.ok?A({kind:"info",text:`\u2713 \u5DF2\u540C\u6B65 ${Z.count} \u4E2A\u6A21\u578B (\u672C\u8FDB\u7A0B\u5185\u751F\u6548)`}):A({kind:"error",text:`\u540C\u6B65\u5931\u8D25: ${Z.error??"\u672A\u77E5\u9519\u8BEF"}`});}catch(Z){A({kind:"error",text:`\u540C\u6B65\u5931\u8D25: ${Z.message}`});}}return a(Ye,"runSync"),jsxs(S,{flexDirection:"column",marginLeft:1,children:[jsxs(S,{children:[jsx(u,{color:"ansi:cyan",bold:true,children:"\u2726 \u6A21\u578B\u7BA1\u7406"}),jsx(u,{dim:true,children:" (Tab \u5207\u6362\u9762\u677F, q/Esc \u5173\u95ED)"})]}),jsxs(S,{marginLeft:2,marginTop:1,children:[jsx(u,{color:y==="models"?"ansi:cyan":void 0,bold:y==="models",children:y==="models"?"\u25CF Models":"\u25CB Models"}),jsx(u,{children:" "}),jsx(u,{color:y==="providers"?"ansi:cyan":void 0,bold:y==="providers",children:y==="providers"?"\u25CF Providers":"\u25CB Providers"}),jsx(u,{children:" "}),jsx(u,{color:y==="arena"?"ansi:cyan":void 0,bold:y==="arena",children:y==="arena"?"\u25CF Arena":"\u25CB Arena"})]}),y==="models"?jsx(Xv,{entries:t,cursor:x,snapshot:e}):y==="providers"?jsx(Qv,{providers:g,cursor:b}):jsx(Zv,{arena:M,cursor:N,picker:E,poolEntries:t,dirty:F}),T.kind!=="idle"&&jsx(S,{marginLeft:2,marginTop:1,children:jsx(u,{color:T.kind==="error"?"ansi:red":T.kind==="busy"?"ansi:yellow":"ansi:green",children:T.text})})]})}a(sh,"ModelManager");function ih(t){return !t||t<=0?"?":t>=1e6?`${(t/1e6).toFixed(0)}M`:t>=1e3?`${(t/1e3).toFixed(0)}K`:`${t}`}a(ih,"fmtTokens");function Jv(t,e){let n=[],r=`${t} ${e}`.toLowerCase();return /coder|code|devstral/i.test(r)&&n.push("coding"),/reason|think|r1|o3|o4|pro/i.test(r)&&n.push("reasoning"),/flash|mini|haiku|fast|small|nano/i.test(r)&&n.push("fast"),/cheap|free/i.test(r)&&n.push("cheap"),/large|max|ultra|opus|big/i.test(r)&&n.push("powerful"),n}a(Jv,"modelTags");function Xv({entries:t,cursor:e,snapshot:n}){let r=t.length?Math.min(Math.max(...t.map(i=>i.key.length)),16):0,o=t.length?Math.min(Math.max(...t.map(i=>ih(i.maxContextTokens).length)),8):0;return jsxs(Fragment,{children:[jsxs(S,{marginLeft:2,marginTop:1,children:[jsx(u,{dim:true,children:"\u5FEB\u7167: "}),jsx(u,{children:`${n.count} \u4E2A\u6A21\u578B`}),jsx(u,{dim:true,children:n.fetchedAt?` \xB7 ${ah(n.fetchedAt)}`:" \xB7 \u672A\u62C9\u53D6"})]}),jsx(S,{marginLeft:2,marginTop:1,children:jsx(u,{bold:true,children:`\u6A21\u578B\u6C60 (${t.length}):`})}),t.length===0?jsx(S,{marginLeft:4,children:jsx(u,{dim:true,children:"\u672A\u914D\u7F6E\u6A21\u578B\u6C60\u3002\u6309 [s] \u62C9\u53D6\u6700\u65B0\u6E05\u5355\uFF0C\u518D\u7528 /login \u9009\u62E9\u3002"})}):jsxs(Fragment,{children:[jsx(S,{marginLeft:2,children:jsxs(u,{dim:true,children:[" ".padEnd(r+2),"\u6A21\u578B\u8DEF\u5F84"," ".repeat(28),"\u4E0A\u4E0B\u6587"," ","\u6807\u7B7E"]})}),t.map((i,s)=>{let l=s===e,c=l?"\u276F ":" ",d=i.active?" \u2190 active":"",f=Jv(i.key,i.model),m=f.length>0?f.join(", "):"";return jsxs(S,{marginLeft:2,children:[jsxs(u,{color:l?"ansi:cyan":void 0,bold:l,children:[c,i.key.padEnd(r)]}),jsxs(u,{children:[" ",i.model.padEnd(32)]}),jsx(u,{dim:true,children:ih(i.maxContextTokens).padStart(o)}),jsx(u,{children:" "}),jsx(u,{color:"ansi:green",children:m}),jsx(u,{color:"ansi:green",children:d})]},i.key)})]}),jsx(S,{marginLeft:2,marginTop:1,children:jsxs(u,{dim:true,children:["\u64CD\u4F5C: ",jsx(u,{color:"ansi:cyan",children:"[Enter]"})," \u5207\u6362 ",jsx(u,{color:"ansi:cyan",children:"[a]"})," \u6DFB\u52A0 provider+\u6A21\u578B ",jsx(u,{color:"ansi:cyan",children:"[x]"})," \u5220\u9664 ",jsx(u,{color:"ansi:cyan",children:"[s]"})," \u540C\u6B65\u5FEB\u7167"]})})]})}a(Xv,"ModelsPane");function Qv({providers:t,cursor:e}){return jsxs(Fragment,{children:[jsx(S,{marginLeft:2,marginTop:1,children:jsx(u,{bold:true,children:`Providers (${t.length})`})}),t.length===0?jsx(S,{marginLeft:4,children:jsx(u,{dim:true,children:"\u5C1A\u672A\u914D\u7F6E\u4EFB\u4F55 provider\u3002\u6309 [a] \u6DFB\u52A0\u3002"})}):t.map((n,r)=>{let o=r===e,i=o?"\u276F ":" ",s=n.cachedModels!==void 0?`${n.cachedModels} \u7F13\u5B58${n.cachedAt?` \xB7 ${ah(n.cachedAt)}`:""}`:"\u672A\u62C9\u53D6";return jsxs(S,{marginLeft:2,children:[jsxs(u,{color:o?"ansi:cyan":void 0,bold:o,children:[i,n.label||n.key]}),jsx(u,{dim:true,children:` (${n.kind}) `}),jsx(u,{children:`${n.modelCount} \u6A21\u578B `}),jsx(u,{dim:true,children:s})]},n.key)}),jsx(S,{marginLeft:2,marginTop:1,children:jsxs(u,{dim:true,children:["\u64CD\u4F5C: ",jsx(u,{color:"ansi:cyan",children:"[a]"})," \u6DFB\u52A0 provider+\u6A21\u578B ",jsx(u,{color:"ansi:cyan",children:"[r]"})," \u5237\u65B0 ",jsx(u,{color:"ansi:cyan",children:"[d]"})," \u5220\u9664"]})})]})}a(Qv,"ProvidersPane");function Zv({arena:t,cursor:e,picker:n,poolEntries:r,dirty:o}){return jsxs(Fragment,{children:[jsxs(S,{marginLeft:2,marginTop:1,children:[jsx(u,{bold:true,children:`Arena \u53C2\u4E0E\u8005 (${t.length})`}),o&&jsx(u,{color:"ansi:yellow",children:" \u2022 \u672A\u4FDD\u5B58"})]}),t.length===0?jsx(S,{marginLeft:4,children:jsx(u,{dim:true,children:"\u672A\u914D\u7F6E \u2014 Arena \u5C06\u56DE\u9000\u5230\u9ED8\u8BA4\u53C2\u4E0E\u8005\u3002\u6309 [a] \u6DFB\u52A0\u3002"})}):t.map((i,s)=>{let l=s===e,c=l?"\u276F ":" ";if(i.kind==="key"){let d=r.find(f=>f.key===i.value);return jsxs(S,{marginLeft:2,children:[jsxs(u,{color:l?"ansi:cyan":void 0,bold:l,children:[c,i.value]}),d&&jsxs(u,{dim:true,children:[" ",d.model]}),!d&&jsx(u,{color:"ansi:yellow",children:" (\u4E0D\u5728\u5F53\u524D\u6A21\u578B\u6C60)"})]},`k-${s}`)}return jsxs(S,{marginLeft:2,children:[jsxs(u,{color:l?"ansi:cyan":void 0,bold:l,children:[c,i.label]}),jsx(u,{dim:true,children:" (\u5BF9\u8C61\u5F62\u5F0F \xB7 \u53EA\u8BFB)"})]},`o-${s}`)}),n&&jsxs(S,{flexDirection:"column",marginLeft:2,marginTop:1,children:[jsx(u,{bold:true,children:"\u4ECE\u6A21\u578B\u6C60\u9009\u62E9:"}),r.map((i,s)=>{let l=s===n.idx;return jsxs(S,{marginLeft:2,children:[jsxs(u,{color:l?"ansi:cyan":void 0,bold:l,children:[l?"\u276F ":" ",i.key]}),jsxs(u,{dim:true,children:[" ",i.model]})]},i.key)})]}),jsx(S,{marginLeft:2,marginTop:1,children:jsxs(u,{dim:true,children:["\u64CD\u4F5C: ",jsx(u,{color:"ansi:cyan",children:"[a]"})," \u6DFB\u52A0 ",jsx(u,{color:"ansi:cyan",children:"[d]"})," \u5220\u9664 ",jsx(u,{color:"ansi:cyan",children:"[w]"})," \u4FDD\u5B58"]})})]})}a(Zv,"ArenaPane");function ah(t){let e=new Date(t).getTime();if(Number.isNaN(e))return t;let n=Date.now()-e,r=Math.floor(n/36e5);if(r<1)return "\u51E0\u5206\u949F\u524D";if(r<24)return `${r} \u5C0F\u65F6\u524D`;let o=Math.floor(r/24);return o<7?`${o} \u5929\u524D`:new Date(t).toLocaleDateString()}a(ah,"formatFreshness");h();function ch({entries:t,onSelect:e,onCancel:n}){let[r,o]=useState(0);if(ft((c,d)=>{if(t.length===0){(d.escape||d.return)&&n();return}d.upArrow?o(f=>f>0?f-1:t.length-1):d.downArrow?o(f=>f<t.length-1?f+1:0):d.return?e(t[r].sessionId):d.escape&&n();}),t.length===0)return jsxs(S,{flexDirection:"column",marginLeft:1,children:[jsx(S,{children:jsx(u,{color:"ansi:cyan",bold:true,children:"\u2726 Resume session"})}),jsx(S,{marginLeft:2,children:jsx(u,{dim:true,children:"\u6CA1\u6709\u53EF\u6062\u590D\u7684\u4F1A\u8BDD\u3002"})}),jsx(S,{marginLeft:2,children:jsx(u,{dim:true,children:"\u6309\u4EFB\u610F\u952E\u5173\u95ED"})})]});let i=a(c=>c.lastActiveAt??c.startedAt,"timeOf"),s=Math.max(...t.map(c=>lh(i(c)).length)),l=Math.max(...t.map(c=>`${c.turnCount} turns`.length));return jsxs(S,{flexDirection:"column",marginLeft:1,children:[jsxs(S,{children:[jsx(u,{color:"ansi:cyan",bold:true,children:"\u2726 Resume session"}),jsx(u,{dim:true,children:" (\u2191\u2193 \u9009\u62E9, Enter \u52A0\u8F7D, Esc \u53D6\u6D88)"})]}),t.map((c,d)=>{let f=d===r,m=f?"\u276F ":" ",g=lh(i(c)).padEnd(s),y=`${c.turnCount} turns`.padEnd(l),w=c.preview?tT(c.preview,60):"(no messages)";return jsxs(S,{marginLeft:2,children:[jsx(u,{color:f?"ansi:cyan":void 0,bold:f,children:m}),jsxs(u,{dim:true,children:[g," "]}),jsxs(u,{dim:true,children:[y," "]}),jsx(u,{children:w})]},c.sessionId)})]})}a(ch,"SessionPicker");function lh(t){let e=Date.now()-t,n=Math.floor(e/1e3);if(n<60)return `${n}s ago`;let r=Math.floor(n/60);if(r<60)return `${r}m ago`;let o=Math.floor(r/60);if(o<24)return `${o}h ago`;let i=Math.floor(o/24);return i<7?`${i}d ago`:new Date(t).toLocaleDateString()}a(lh,"relativeTime");function tT(t,e){return t.length>e?t.slice(0,e-1)+"\u2026":t}a(tT,"truncate");h();var ja=class{static{a(this,"CommandRegistry");}commands=new Map;register(e){if(this.commands.set(e.name,e),e.aliases)for(let n of e.aliases)this.commands.set(n,e);}registerAll(e){for(let n of e)this.register(n);}get(e){return this.commands.get(e)}dispatch(e,n){let r=e.split(/\s+/),o=r[0].toLowerCase(),i=r.slice(1).join(" ").trim(),s=this.commands.get(o);if(!s){n.addStatus(`Unknown command: ${o}. Type /help for available commands.`);return}return s.execute(i,n)}helpText(){let e=new Set,n=new Map,r={core:"Core",git:"Git & Code Review",context:"Context & Memory",config:"Configuration",advanced:"Advanced"};for(let i of this.commands.values()){if(e.has(i.name))continue;e.add(i.name);let s=i.group??"core";n.has(s)||n.set(s,[]),n.get(s).push(i);}let o=["Available Commands:",""];for(let[i,s]of Object.entries(r)){let l=n.get(i);if(!(!l||l.length===0)){o.push(` ${s}:`);for(let c of l.sort((d,f)=>d.name.localeCompare(f.name))){let d=c.aliases?.length?` (${c.aliases.join(", ")})`:"";o.push(` ${c.name.padEnd(16)} ${c.description}${d}`);}o.push("");}}return o.push(" Shift+Tab to cycle permission mode \xB7 Ctrl+C to cancel/exit"),o.join(`
85
- `)}listNames(){let e=new Set;for(let n of this.commands.values())e.add(n.name);return [...e].sort()}listCommands(){let e=new Set,n=[];for(let r of this.commands.values())e.has(r.name)||(e.add(r.name),n.push({name:r.name,description:r.description,usage:r.usage}));return n.sort((r,o)=>r.name.localeCompare(o.name))}};h();var Ka=class{static{a(this,"QueryGuard");}state="idle";controller=null;listeners=new Set;subscribe=a(e=>(this.listeners.add(e),()=>{this.listeners.delete(e);}),"subscribe");getSnapshot=a(()=>this.state!=="idle","getSnapshot");notify(){for(let e of this.listeners)try{e();}catch{}}reserve(){return this.state!=="idle"?false:(this.state="reserved",this.notify(),true)}tryStart(e){return this.state!=="reserved"?false:(this.controller=e,this.state="running",this.notify(),true)}cancelReservation(){this.state==="reserved"&&(this.state="idle",this.notify());}end(){this.state!=="idle"&&(this.state="idle",this.controller=null,this.notify());}forceEnd(e="force-end"){if(this.state!=="idle"){if(this.state==="running"&&this.controller)try{this.controller.abort(e);}catch{}this.state="idle",this.controller=null,this.notify();}}getSignal(){return this.controller?.signal??null}};h();var is=5,iT=40;function uh({viewMode:t,focusedIndex:e}){let n=useSyncExternalStore(a$3.subscribe,a$3.getSnapshot),[,r]=useState(0),o=Date.now(),i=ss(n,o);if(useEffect(()=>{if(i.length===0)return;let c=setInterval(()=>r(d=>d+1),1e3);return ()=>clearInterval(c)},[i.length===0]),i.length===0)return null;let s=i.slice(0,is),l=i.length-s.length;return jsxs(S,{flexDirection:"column",paddingX:1,children:[jsx(u,{dim:true,children:"agents"}),jsx(aT,{focused:e===0,active:t.kind==="main"}),s.map((c,d)=>jsx(sT,{entry:c,focused:e===d+1,active:t.kind==="agent"&&t.agentId===c.agentId,now:o},c.agentId)),l>0&&jsx(u,{dim:true,children:`... +${l} more`})]})}a(uh,"AgentDock");function sT({entry:t,focused:e,active:n,now:r}){let o=e?">":" ",i=t.status==="running"?"ansi:cyan":t.status==="completed"?"ansi:green":t.status==="cancelled"?"ansi:yellow":"ansi:red",s=lT((t.finishedAt??r)-t.startedAt),l=cT(t.description,iT);return jsxs(S,{flexDirection:"row",children:[jsx(u,{color:e?"ansi:cyanBright":void 0,bold:e,children:o}),jsx(u,{color:i,children:" \u25CF "}),t.name&&jsx(u,{color:e?"ansi:cyanBright":n?"ansi:cyan":void 0,bold:e,children:t.name+" "}),jsx(u,{color:e?"ansi:cyanBright":n?"ansi:cyan":void 0,bold:e,dim:!e&&!n&&!!t.name,children:l}),jsx(S,{flexGrow:1}),jsx(u,{dim:true,children:s})]})}a(sT,"AgentDockRow");function aT({focused:t,active:e}){return jsxs(S,{flexDirection:"row",children:[jsx(u,{color:t?"ansi:cyanBright":void 0,bold:t,children:t?">":" "}),jsx(u,{color:"ansi:magenta",children:" \u25C6 "}),jsx(u,{color:t?"ansi:cyanBright":e?"ansi:magenta":void 0,bold:t,children:"main"}),t&&jsxs(Fragment,{children:[jsx(S,{flexGrow:1}),jsx(u,{dim:true,children:"\u2191/\u2193 to select \xB7 Enter to view"})]})]})}a(aT,"MainDockRow");function ss(t,e){return t.filter(n=>n.status==="running"?true:n.status==="completed"?false:n.finishedFadeAt!==void 0&&e<n.finishedFadeAt).sort((n,r)=>n.startedAt-r.startedAt)}a(ss,"getVisibleAgents");function lT(t){let e=Math.max(0,Math.floor(t/1e3));if(e<60)return `${e}s`;let n=Math.floor(e/60),r=e%60;return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m ${r}s`}a(lT,"formatElapsed");function cT(t,e){return t.length<=e?t:t.slice(0,e-1)+"\u2026"}a(cT,"truncate");h();h();h();var fT=["package.json","Cargo.toml","pyproject.toml","go.mod","pom.xml","build.gradle","build.gradle.kts","Gemfile","mix.exs","deno.json","deno.jsonc","bun.lockb"],mT=["README.md","README.rst","README.txt","README"],pT=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".go",".rs",".java",".kt",".rb",".ex",".exs",".c",".cpp",".cc",".h",".hpp",".swift",".scala",".clj",".cljs",".php"]),gT=new Set(["node_modules",".git","dist","build","target",".venv","venv","__pycache__",".next",".turbo","out","coverage",".cache"]),hT=50;function mh(t){let e=a(o=>existsSync(join(t,o)),"exists"),n=a(o=>{try{return statSync(join(t,o)).isDirectory()}catch{return false}},"isDir"),r=a(o=>{try{let i=readdirSync(t),s=new Set(i.map(l=>l.toLowerCase()));return o.some(l=>s.has(l.toLowerCase()))}catch{return false}},"existsCI");return {hasCodeshell:e("CODESHELL.md"),hasClaude:e("CLAUDE.md"),hasAgents:e("AGENTS.md"),hasCursorRules:e(".cursorrules"),hasCursorRulesDir:n(".cursor/rules"),hasWindsurfRules:e(".windsurfrules"),hasClinerules:e(".clinerules"),hasCopilotInstructions:e(".github/copilot-instructions.md"),hasCodeshellRulesDir:n(".codeshell/rules"),hasManifest:fT.some(o=>e(o)),hasSourceFiles:yT(t),hasReadme:r(mT)}}a(mh,"detect");function ph(t){return t.hasCodeshell?"improve":t.hasClaude||t.hasAgents||t.hasCursorRules||t.hasCursorRulesDir||t.hasWindsurfRules||t.hasClinerules||t.hasCopilotInstructions?"migrate":t.hasManifest||t.hasSourceFiles||t.hasReadme?"create":"empty"}a(ph,"pickIntent");function gh(t){let e=[];t.hasCodeshell&&e.push("CODESHELL.md"),t.hasClaude&&e.push("CLAUDE.md"),t.hasAgents&&e.push("AGENTS.md"),t.hasCursorRulesDir&&e.push(".cursor/rules/"),t.hasCursorRules&&e.push(".cursorrules"),t.hasWindsurfRules&&e.push(".windsurfrules"),t.hasClinerules&&e.push(".clinerules"),t.hasCopilotInstructions&&e.push(".github/copilot-instructions.md"),t.hasCodeshellRulesDir&&e.push(".codeshell/rules/");let n=[];if(t.hasManifest&&n.push("manifest"),t.hasSourceFiles&&n.push("source files"),t.hasReadme&&n.push("README"),e.length===0&&n.length===0)return "Detected: empty repository";let r=[];return e.length&&r.push(e.join(", ")),n.length&&r.push(n.join(" + ")),`Detected: ${r.join("; ")}`}a(gh,"summarize");function yT(t){let e=hT,n=a(o=>{let i;try{i=readdirSync(o);}catch{return false}for(let s of i){if(e--<=0)return false;if(gT.has(s)||s.startsWith("."))continue;let l=bT(s);if(l&&pT.has(l))return true}return false},"scanLevel");if(n(t))return true;let r=join(t,"src");try{if(statSync(r).isDirectory()&&n(r))return !0}catch{}return false}a(yT,"hasAnySourceFiles");function bT(t){let e=t.lastIndexOf(".");return e<0?"":t.slice(e)}a(bT,"extOf");var hh=`Create a new CODESHELL.md at \${targetPath}.
86
-
87
- ## Survey the codebase first
88
-
89
- Read whichever of these exist and are relevant: package.json, Cargo.toml, pyproject.toml, go.mod, pom.xml, README.md, Makefile, tsconfig.json, vite.config.*, webpack.config.*, .github/workflows/, .gitlab-ci.yml. Identify build/test/lint commands, languages, frameworks, package manager, and any non-obvious workflow quirks.
90
-
91
- ## What to do
92
-
93
- 1. Write a minimal CODESHELL.md at \${targetPath} based on what you discovered.
94
- 2. Lead the file with:
95
- \`\`\`
96
- # CODESHELL.md
97
-
98
- This file provides guidance to Code Shell when working with code in this repository.
99
- \`\`\`
100
-
101
- ## Writing rules
102
-
103
- CODESHELL.md is loaded into every Code Shell session, so it must be concise \u2014 every line must answer "would an agent likely miss this without help?".
104
-
105
- Include:
106
- - Build/test/lint commands the model can't guess (non-standard scripts, flags, sequences)
107
- - Code style that DIFFERS from language defaults
108
- - Testing quirks (e.g., how to run a single test)
109
- - Repo etiquette (branch naming, PR conventions, commit style)
110
- - Required env vars or setup steps
111
- - Non-obvious gotchas
112
-
113
- Exclude:
114
- - File-by-file structure (discoverable by reading code)
115
- - Standard language conventions the model already knows
116
- - Generic advice ("write clean code")
117
- - Commands obvious from manifest files
118
-
119
- Be specific. "Use 2-space indentation in TypeScript" beats "Format code properly."
120
- `;var yh=`Create CODESHELL.md at \${targetPath} by drawing on this repo's existing AI configs.
121
-
122
- Existing configs to investigate (read them first):
123
- \${existingConfigs}
124
-
125
- ## Survey the codebase first
126
-
127
- Read whichever of these exist and are relevant: package.json, Cargo.toml, pyproject.toml, go.mod, pom.xml, README.md, Makefile, tsconfig.json, vite.config.*, webpack.config.*, .github/workflows/, .gitlab-ci.yml. Identify build/test/lint commands, languages, frameworks, package manager, and any non-obvious workflow quirks.
128
-
129
- ## How to treat existing AI configs
130
-
131
- Treat them as **investigation sources, not text to copy**. Only carry forward statements you can verify against the codebase:
132
-
133
- - Commands (build/test/lint): run them with Bash to confirm they work.
134
- - File paths and directories: verify they exist with Read or ls.
135
- - Conventions and constraints: find a concrete example in the code before keeping the rule.
136
-
137
- Statements you cannot verify, that look stale, or that are too generic ("write clean code") \u2014 leave behind. When prose conflicts with config, trust config.
138
-
139
- ## What to do
140
-
141
- 1. Read every config listed above.
142
- 2. Survey the codebase to fill in any commands or conventions missing from those files.
143
- 3. Write a single CODESHELL.md at \${targetPath} that synthesizes only verified rules. Do not concatenate.
144
-
145
- ## Writing rules
146
-
147
- CODESHELL.md is loaded into every Code Shell session, so it must be concise \u2014 every line must answer "would an agent likely miss this without help?".
148
-
149
- Include:
150
- - Build/test/lint commands the model can't guess (non-standard scripts, flags, sequences)
151
- - Code style that DIFFERS from language defaults
152
- - Testing quirks (e.g., how to run a single test)
153
- - Repo etiquette (branch naming, PR conventions, commit style)
154
- - Required env vars or setup steps
155
- - Non-obvious gotchas
156
-
157
- Exclude:
158
- - File-by-file structure (discoverable by reading code)
159
- - Standard language conventions the model already knows
160
- - Generic advice ("write clean code")
161
- - Commands obvious from manifest files
162
- `;var bh=`Improve the existing CODESHELL.md at \${targetPath}.
163
-
164
- ## Survey the codebase first
165
-
166
- Read whichever of these exist and are relevant: package.json, Cargo.toml, pyproject.toml, go.mod, pom.xml, README.md, Makefile, tsconfig.json, vite.config.*, webpack.config.*, .github/workflows/, .gitlab-ci.yml. Identify build/test/lint commands, languages, frameworks, package manager, and any non-obvious workflow quirks.
167
-
168
- ## What to do
169
-
170
- 1. Read the current CODESHELL.md.
171
- 2. Identify concrete, specific improvements grounded in what you found in the codebase:
172
- - Missing build/test/lint commands
173
- - Generic advice that should be cut
174
- - Gotchas/conventions found in code but not documented
175
- 3. Apply the improvements using the **Edit** tool, one change at a time. Each Edit call must use a minimal, unique \`old_string\` and the replacement \`new_string\`, so the user sees a focused red/green diff per change. Do not use Write \u2014 Write replaces the entire file and hides what actually changed.
176
-
177
- ## Writing rules
178
-
179
- CODESHELL.md is loaded into every Code Shell session, so it must be concise \u2014 every line must answer "would an agent likely miss this without help?".
180
-
181
- Include:
182
- - Build/test/lint commands the model can't guess (non-standard scripts, flags, sequences)
183
- - Code style that DIFFERS from language defaults
184
- - Testing quirks (e.g., how to run a single test)
185
- - Repo etiquette (branch naming, PR conventions, commit style)
186
- - Required env vars or setup steps
187
- - Non-obvious gotchas
188
-
189
- Exclude:
190
- - File-by-file structure (discoverable by reading code)
191
- - Standard language conventions the model already knows
192
- - Generic advice ("write clean code")
193
- - Commands obvious from manifest files
194
-
195
- Be specific. "Use 2-space indentation in TypeScript" beats "Format code properly."
196
- `;var xh=`You are bootstrapping CODESHELL.md for an essentially empty git repository at \${cwd}.
197
-
198
- There is no source code, no manifest, and no README to read \u2014 the user has just started this project. You must ask them what they want to build before you can write anything useful.
199
-
200
- ## How to ask
201
-
202
- Use the **AskUserQuestion** tool. Prefer the multiple-choice form whenever the answer is one of a small known set \u2014 the user just arrow-keys + Enter, much faster than typing. Pass \`options\` (2-4 short entries with \`label\` + \`description\`), set \`header\` to a short chip (\u226412 chars), and put the recommended choice first with a recommendation marker appended to its label (e.g. "(Recommended)" for English, "(\u63A8\u8350)" for Chinese \u2014 match the user's language). The UI automatically appends an "Other..." entry, so you don't need to include one.
203
-
204
- **Language: write every \`question\`, \`header\`, option \`label\`, and option \`description\` in the SAME language the user has been writing in.** The sample option strings below are English placeholders showing *shape* \u2014 translate them. E.g. if the user is writing in Chinese, "CLI tool" becomes "\u547D\u4EE4\u884C\u5DE5\u5177", "Web service" becomes "Web \u670D\u52A1", "(Recommended)" becomes "(\u63A8\u8350)", and so on.
205
-
206
- Ask one question per AskUserQuestion call. **Hard limit: at most 4 AskUserQuestion calls total. After the 4th answer, write the file.** Stop earlier as soon as you have enough.
207
-
208
- Recommended questions to draw from, with concrete \`options\` shapes (translate into the user's language):
209
-
210
- 1. **What are you building?** \u2014 header: "Project", options: "CLI tool" / "Web service" / "Library / SDK" / "Mobile or desktop app". Pick whatever fits best as recommended, or omit a recommendation if it's genuinely a coin flip.
211
-
212
- 2. **Primary language and framework?** \u2014 header: "Stack", options: "TypeScript + Node" / "Python" / "Go" / "Rust". Recommend the one most aligned with the previous answer (e.g. CLI tool \u2192 Go or Rust if performance matters, TypeScript otherwise).
213
-
214
- 3. **Package manager / runtime?** \u2014 header: "Runtime", options shaped by the language answer (e.g. for TS: "Bun" / "pnpm" / "npm" / "Deno").
215
-
216
- 4. **Any non-obvious constraint up front?** \u2014 header: "Constraints", options: "Performance critical" / "Licensing matters" / "Compliance / privacy" / "None \u2014 defaults are fine". Recommend "None" unless the project type strongly suggests otherwise.
217
-
218
- If the user picks "Other..." on a question, treat the typed string as authoritative and move on.
219
-
220
- If a one-word answer (e.g. selecting "CLI tool") plus the language pick clearly covers what you need, do not pad with the remaining questions. Move on.
221
-
222
- ## When you have enough
223
-
224
- "Enough" means you can name:
225
- - The project's purpose (one phrase)
226
- - The technology stack (language + main framework/tool)
227
- - At least one non-obvious convention or constraint the user volunteered
228
-
229
- When you have these, **use the Write tool to create \${targetPath}**. Lead with:
230
-
231
- \`\`\`
232
- # CODESHELL.md
233
-
234
- This file provides guidance to Code Shell when working with code in this repository.
235
- \`\`\`
236
-
237
- Then a short section listing what the user told you, plus \`# TODO(user): \u2026\` placeholders for things the user explicitly didn't decide ("None" / "Other: not sure yet"). Do not invent build commands or test framework choices \u2014 leave them as TODOs if unstated.
238
-
239
- ## If the user cancels (AskUserQuestion returns "(user declined to answer)")
240
-
241
- Stop asking. Write a minimal CODESHELL.md with whatever you have plus TODO placeholders for everything missing. Don't loop.
242
-
243
- ## Writing rules
244
-
245
- CODESHELL.md is loaded into every Code Shell session, so it must be concise. For a fresh project the file will be short and full of TODOs \u2014 that's fine. Honesty beats fabrication.
246
-
247
- Do not include:
248
- - Standard language conventions the model already knows
249
- - Generic advice ("write clean code")
250
- - Guesses about how the user will deploy, test, or structure their code
251
- `;var Sh=`## After writing CODESHELL.md \u2014 optional rules split
252
-
253
- After CODESHELL.md exists, check whether it's substantial enough to benefit from splitting topic-specific guidance into \`.codeshell/rules/*.md\` files (Code Shell loads all of them in addition to the main file).
254
-
255
- Only offer the split when the file has at least two clearly different topics (e.g. "code style" AND "testing", or "build commands" AND "PR conventions"). For a short file with one focus, skip this step entirely.
256
-
257
- If a split would be useful, use **AskUserQuestion** once with these options (header: "Rules split"). **Translate the question, header, labels, and descriptions into the user's language** (e.g. Chinese if the user has been writing in Chinese \u2014 header becomes "\u89C4\u5219\u62C6\u5206", "(Recommended)" becomes "(\u63A8\u8350)", etc.). The English wording below is a shape guide:
258
-
259
- - "Keep single file (Recommended)" \u2014 concise, easy to scan; do nothing further.
260
- - "Split into topic files" \u2014 you will Edit CODESHELL.md to a short overview that points at \`.codeshell/rules/\`, and Write 2-4 topic files (e.g. \`code-style.md\`, \`testing.md\`, \`conventions.md\`) under that directory. Filenames must be lowercase kebab-case.
261
- - "Just scaffold empty files" \u2014 you will Write empty \`.codeshell/rules/{code-style,testing,conventions}.md\` placeholders (each with a single H1 header) so the user can fill them later.
262
-
263
- Act on whichever option they pick, then end the turn. If they pick "Keep single file" / "\u4FDD\u7559\u5355\u6587\u4EF6" or cancel, do nothing and end the turn.
264
- `;var xu=8e3;function kT(t,e,n){let r=join(n,"CODESHELL.md"),o=[];e.hasClaude&&o.push(join(n,"CLAUDE.md")),e.hasAgents&&o.push(join(n,"AGENTS.md")),e.hasCursorRulesDir&&o.push(join(n,".cursor/rules/")),e.hasCursorRules&&o.push(join(n,".cursorrules")),e.hasWindsurfRules&&o.push(join(n,".windsurfrules")),e.hasClinerules&&o.push(join(n,".clinerules")),e.hasCopilotInstructions&&o.push(join(n,".github/copilot-instructions.md"));let i=_T(t);return ((t==="create"||t==="migrate")&&!e.hasCodeshellRulesDir?`${i}
265
-
266
- ${Sh}`:i).replaceAll("${targetPath}",r).replaceAll("${cwd}",n).replaceAll("${existingConfigs}",o.map(c=>`- ${c}`).join(`
267
- `))}a(kT,"buildPrompt");function _T(t){switch(t){case "improve":return bh;case "migrate":return yh;case "create":return hh;case "empty":return xh}}a(_T,"pickTemplate");function RT(t){switch(t){case "improve":return "Improving existing CODESHELL.md\u2026";case "migrate":return "Migrating from existing AI configs into CODESHELL.md\u2026";case "create":return "Creating new CODESHELL.md\u2026";case "empty":return "Empty repo \u2014 asking you a few questions before writing CODESHELL.md\u2026"}}a(RT,"statusForIntent");var wh={name:"/init",group:"config",description:"Bootstrap or improve CODESHELL.md for this repo",execute:a(async(t,e)=>{let n=mh(e.cwd),r=ph(n);if(e.addStatus(gh(n)),e.addStatus(RT(r)),!e.queryGuard.reserve()){e.addStatus("Busy \u2014 wait for current turn to finish.");return}let o=new AbortController;e.queryGuard.tryStart(o);try{let i=await e.client.run(kT(r,n,e.cwd),e.sessionId);e.setSessionId(i.sessionId);let s=join(e.cwd,"CODESHELL.md");if(existsSync(s)){e.addStatus(r==="improve"?`Updated ${s}`:`Created ${s}`);try{let l=readFileSync(s,"utf-8"),c=l.length>xu?l.slice(0,xu)+`
268
-
269
- [truncated \u2014 ${l.length-xu} more chars in ${s}]`:l;await e.client.inject(i.sessionId,`CODESHELL.md was ${r==="improve"?"updated":"created"} by /init at ${s}:
270
-
271
- ${c}`),e.addStatus("CODESHELL.md injected into session context \u2014 the model will see it on every turn.");}catch{}}else e.addStatus("Init finished without writing a file \u2014 see the output above.");}catch(i){e.addStatus(`Init failed during ${r} phase: ${i.message}`);}finally{e.queryGuard.end();}},"execute")};var Th=[{name:"/exit",aliases:["/quit"],description:"Exit the REPL",execute:a((t,e)=>e.exit(),"execute")},{name:"/clear",description:"Clear chat history",execute:a((t,e)=>e.clearChat(),"execute")},{name:"/cost",description:"Show token usage and cost (/cost stats for summary, /cost detail for breakdown)",usage:"/cost [stats|detail]",execute:a((t,e)=>{if(yt.getRequestCount()===0){e.addStatus("No API requests yet.");return}let n=yt.getTotalTokens(),r=yt.getEstimatedCost(),o=yt.getRequestCount();if(t==="stats"||t==="summary")e.addStatus(yt.formatSummary());else if(t==="detail"||t==="usage"){let i=Math.round(n.total/o),s=(r/o).toFixed(4),l=a(c=>c.toLocaleString(),"fmt");e.addStatus(["API Usage:",` Requests: ${o}`,` Total tokens: ${l(n.total)}`,` Prompt: ${l(n.prompt)}`,` Completion: ${l(n.completion)}`,` Estimated cost: ${r.toFixed(4)}`,` Avg tokens/req: ${l(i)}`,` Avg cost/req: ${s}`,` Model: ${e.model}`].join(`
272
- `));}else e.addStatus(`Tokens: ${n.total} (in: ${n.prompt}, out: ${n.completion}) | Cost: ${r.toFixed(4)} | Requests: ${o}`),e.addStatus("Use /cost stats or /cost detail for more info.");},"execute")},{name:"/effort",description:"Set reasoning effort level",usage:"/effort <low|medium|high|max>",execute:a((t,e)=>{t&&["low","medium","high","max"].includes(t)?(e.setEffort(t),e.addStatus(`Effort set to: ${t}`)):e.addStatus(`Current effort: ${e.effort}. Use /effort <low|medium|high|max>`);},"execute")},{name:"/tasks",description:"Show task list",execute:a((t,e)=>{let n=e.tasks??[];if(n.length===0){e.addStatus("No active tasks. Tasks are created automatically when the agent begins multi-step work.");return}let r={in_progress:0,pending:1,completed:2,stopped:3},o=[...n].sort((i,s)=>(r[i.status]??9)-(r[s.status]??9));for(let i of o){let s=i.status==="completed"?"\u2713":i.status==="in_progress"?"\u25CF":i.status==="stopped"?"\u2717":"\u25CB";e.addStatus(` ${s} ${i.subject??i.id} (${i.status})`);}},"execute")},{name:"/model",aliases:["/m"],description:"Switch model (interactive picker if no key given)",usage:"/model [key] \u2014 opens picker when no key, or switches directly",execute:a(async(t,e)=>{let n=t.trim();if(!n){if(e.openModelSelector){e.openModelSelector();return}try{let o=(await e.client.query("models")).data??[];if(o.length===0){e.addStatus(`Model: ${e.model}
273
- (No model pool configured. Add "models" to settings.json)`);return}let i=o.map(s=>{let l=s.active?" \u2190 active":"";return ` ${s.key.padEnd(16)} ${s.model}${l}`});e.addStatus(`Model: ${e.model}
274
-
275
- Available models (/model <key> to switch):
276
- ${i.join(`
277
- `)}`);}catch{e.addStatus(`Model: ${e.model}`);}return}try{let r=await e.client.configure({model:n});if(!r?.ok||!r.model){e.addStatus("Failed to switch model: server did not confirm switch");return}e.setModel(r.model),e.addStatus(`Switched to: ${n} (${r.model})`);}catch(r){e.addStatus(`Failed to switch model: ${r.message}`);}},"execute")},{name:"/sid",group:"core",description:"Print the current session ID",execute:a((t,e)=>{e.sessionId?e.addStatus(`Session ID: ${e.sessionId}`):e.addStatus("No session yet (no run has started).");},"execute")},{name:"/session",description:"Session management: /session, /session list, /session tag <name>, /session resume <id>",usage:"/session [list|tag <name>|resume <id>]",aliases:["/sessions"],execute:a(async(t,e)=>{let n=t.trim().split(/\s+/),r=n[0]||"show",o=n.slice(1).join(" ");if(r==="show"||!t.trim())e.addStatus(`Session: ${e.sessionId??"none"}`);else if(r==="list")try{let s=(await e.client.query("sessions")).data??[];if(s.length===0)e.addStatus("No sessions.");else {let l=s.slice(0,10).map((c,d)=>{let f=new Date(c.startedAt).toLocaleString(),m=c.sessionId===e.sessionId?" \u2190 current":"",g=c.summary?` "${c.summary}"`:"";return ` ${d+1}. ${f} turns:${c.turnCount}${m}${g}`});e.addStatus(`Recent Sessions (use /resume <number> or /resume <query>):
278
- `+l.join(`
279
- `));}}catch(i){e.addStatus(`Error: ${i.message}`);}else if(r==="tag"){if(!o){e.addStatus("Usage: /session tag <name>");return}try{await e.client.run(`/tag ${o}`,e.sessionId),e.addStatus(`Session tagged: ${o}`);}catch{e.addStatus("Tagging not available. Use /tag command if registered.");}}else if(r==="resume"){if(!o){e.addStatus("Usage: /session resume <session-id>");return}e.addStatus(`Use /resume ${o} to resume that session.`);}else e.addStatus("Usage: /session [show|list|tag <name>|resume <id>]");},"execute")},{name:"/tools",description:"List available tools",execute:a(async(t,e)=>{try{let r=(await e.client.query("tools")).data??[];e.addStatus(`Available Tools (${r.length}):
280
- ${r.map(o=>o.name).join(", ")}`);}catch(n){e.addStatus(`Error: ${n.message}`);}},"execute")},{name:"/memory",group:"context",description:"Manage persistent memories",usage:"/memory [list | add <name> <content> | delete <name> | open]",execute:a(async(t,e)=>{let{MemoryManager:n}=await import('../memory-BNI4WEWL.js'),r=new n(e.cwd),o=t.trim().split(/\s+/),i=o[0]||"list";try{if(i==="list"||!t.trim()){let s=r.loadAll();if(s.length===0)e.addStatus("No memories stored. Use /memory add <name> <content> to create one.");else {let l=s.map((c,d)=>` ${d+1}. [${c.type}] ${c.name} \u2014 ${c.description}`);e.addStatus(`Memories:
281
- `+l.join(`
282
- `)+`
283
-
284
- Use /memory delete <name> to remove.`);}}else if(i==="add"){let s=o[1],l=o.slice(2).join(" ");if(!s||!l){e.addStatus(`Usage: /memory add <name> <content>
285
- Example: /memory add user_role I am a backend engineer`);return}r.save({name:s,description:l.slice(0,80),type:"user",content:l}),e.addStatus(`Memory "${s}" saved.`);}else if(i==="delete"||i==="rm"){let s=o[1];if(!s){e.addStatus("Usage: /memory delete <name>");return}let l=r.delete(s);e.addStatus(l?`Memory "${s}" deleted.`:`Memory "${s}" not found.`);}else if(i==="open"){let s=r.getMemoryDir(),l=process.env.EDITOR||process.env.VISUAL||"vi";e.addStatus(`Memory directory: ${s}
286
- Open with: ${l} ${s}`);}else e.addStatus("Usage: /memory [list | add <name> <content> | delete <name> | open]");}catch(s){e.addStatus(`Memory error: ${s.message}`);}},"execute")},{name:"/compact",group:"context",description:"Force context compaction now",execute:a(async(t,e)=>{e.addStatus("Compacting context...");try{let r=(await e.client.query("compact")).data;if(r.before===r.after)e.addStatus(`Context is already compact (${r.before} tokens). No compaction needed.`);else {let o=r.before-r.after,i=(o/r.before*100).toFixed(0);e.addStatus(`Compacted: ${r.before} \u2192 ${r.after} tokens (saved ${o} tokens, ${i}%)`);}}catch(n){e.addStatus(`Compaction failed: ${n.message}`);}},"execute")},{name:"/resume",description:"Resume a previous session",usage:"/resume [number|query]",execute:a(async(t,e)=>{if(!t){if(e.openSessionPicker){e.openSessionPicker();return}try{let r=(await e.client.query("sessions")).data??[];if(r.length===0){e.addStatus("No sessions to resume.");return}let o=r.slice(0,10).map((i,s)=>{let l=new Date(i.startedAt).toLocaleString(),c=i.preview?` "${i.preview.slice(0,60)}"`:"";return ` ${s+1}. ${l} turns:${i.turnCount}${c}`});e.addStatus(`Recent sessions (use /resume <number> or /resume <query>):
287
- `+o.join(`
288
- `));}catch(n){e.addStatus(`Error: ${n.message}`);}return}try{let n=t.trim(),o=(await e.client.query("sessions")).data??[],i=n,s=parseInt(n,10);if(!isNaN(s)&&s>=1&&s<=o.length)i=o[s-1].sessionId;else {let d=n.toLowerCase(),f=o.find(m=>m.preview&&m.preview.toLowerCase().includes(d)||m.sessionId.startsWith(n));f&&(i=f.sessionId);}let c=(await e.client.query("session_detail",i)).data;if(e.setSessionId(i),e.loadChatEntries&&c?.transcript){let d=c.transcript,f=[];for(let m of d)switch(m.type){case "message":{let g=m.data.role,y=m.data.content;if(g==="user"){let w=typeof y=="string"?y:Array.isArray(y)?y.filter(x=>x?.type==="text").map(x=>x.text??"").join(""):"";w&&f.push({type:"user",text:w});}else if(g==="assistant"){let w=[];if(typeof y=="string")y&&w.push(y);else if(Array.isArray(y))for(let v of y)v?.type==="reasoning"&&v.text?w.push(`[thinking]
289
- ${v.text}
290
- [/thinking]`):v?.type==="text"&&v.text&&w.push(v.text);let x=w.join(`
291
-
292
- `);x&&f.push({type:"assistant_text",text:x});}break}case "tool_use":{f.push({type:"tool_start",toolName:m.data.toolName,args:m.data.args??{}});break}case "tool_result":{f.push({type:"tool_result",toolName:m.data.toolName,result:m.data.result,error:m.data.error});break}}e.loadChatEntries(f);}e.addStatus(`Resumed session ${i.slice(0,8)}\u2026 (${c?.state?.turnCount??"?"} turns)`);}catch(n){e.addStatus(`Resume failed: ${n.message}`);}},"execute")},{name:"/diff",group:"git",description:"Show git diff",usage:"/diff [file]",execute:a((t,e)=>{try{let n=t||"",r=execSync(`git diff --stat HEAD ${n}`,{cwd:e.cwd,encoding:"utf-8",timeout:1e4}).trim();if(!r){e.addStatus("No changes.");return}let o=execSync(`git diff HEAD ${n} --no-color`,{cwd:e.cwd,encoding:"utf-8",timeout:1e4}).trim();e.addStatus(`${r}
293
-
294
- ${o.slice(0,5e3)}${o.length>5e3?`
295
- ... (truncated)`:""}`);}catch{e.addStatus("Not a git repository or git not available.");}},"execute")},{name:"/status",description:"Show system status; /status env for environment info, /status doctor for diagnostics",usage:"/status [env|doctor]",execute:a(async(t,e)=>{if(t==="env"||t==="environment")e.addStatus([`Runtime: ${process.version}`,`Platform: ${process.platform} ${process.arch}`,`CWD: ${e.cwd}`,`Shell: ${process.env.SHELL??"unknown"}`,`Session: ${e.sessionId??"none"}`].join(`
296
- `));else if(t==="doctor"||t==="diagnostic")try{let r=(await e.client.query("config")).data,o=[`Runtime: ${process.version} \u2014 OK`];try{let s=execSync("git --version",{encoding:"utf-8",timeout:5e3}).trim();o.push(`Git: ${s} \u2014 OK`);}catch{o.push("Git: NOT FOUND");}o.push(`Model: ${r.model??e.model}`),o.push(`CWD: ${r.cwd??e.cwd}`);try{let s=await e.client.query("tools");o.push(`Tools: ${(s.data??[]).length} registered`);}catch{o.push("Tools: unknown");}o.push(`Session: ${e.sessionId??"none"}`);try{execSync("gh --version",{encoding:"utf-8",timeout:5e3}),o.push("gh CLI: available");}catch{o.push("gh CLI: not found");}let i=O$1();o.push(`API key: ${i?"configured":"NOT SET"}`),e.addStatus(`Diagnostics:
297
- `+o.join(`
298
- `));}catch(n){e.addStatus(`Diagnostics error: ${n.message}`);}else try{let r=(await e.client.query("config")).data,i=(await e.client.query("tools")).data??[],s=[`Model: ${e.model}`,`Effort: ${e.effort}`,`Permission: ${r.permissionMode??"acceptEdits"}`,`Session: ${e.sessionId??"none"}`,`CWD: ${e.cwd}`,`Tools: ${i.length} registered`];try{let c=execSync("git branch --show-current",{cwd:e.cwd,encoding:"utf-8",timeout:5e3}).trim();s.push(`Git branch: ${c}`);}catch{}let l=yt.getTotalTokens();l.total>0&&(s.push(`Tokens: ${l.total} (in: ${l.prompt}, out: ${l.completion})`),s.push(`Cost: ${yt.getEstimatedCost().toFixed(4)}`)),e.addStatus(s.join(`
299
- `));}catch(n){e.addStatus(`Error: ${n.message}`);}},"execute")},{name:"/version",description:"Show version",execute:a((t,e)=>{try{let n=JSON.parse(execSync("cat package.json",{cwd:e.cwd,encoding:"utf-8",timeout:3e3}));e.addStatus(`code-shell v${n.version??"0.1.0"}`);}catch{e.addStatus("code-shell v0.1.0");}},"execute")},{name:"/export",description:"Export session transcript",usage:"/export [json|markdown]",execute:a(async(t,e)=>{if(!e.sessionId){e.addStatus("No active session to export.");return}let n=t==="json"?"json":"markdown";try{let i=(await e.client.query("session_detail",e.sessionId)).data?.transcript??[];if(n==="json"){let s=join(e.cwd,`session-${e.sessionId}.json`);writeFileSync(s,JSON.stringify(i,null,2),"utf-8"),e.addStatus(`Exported ${i.length} events to ${s}`);}else {let{renderSessionMarkdown:s}=await import('../export-md-U72T7NW7.js'),{md:l,sidecars:c}=s(e.sessionId,i,e.cwd),d=join(e.cwd,`session-${e.sessionId}.md`);if(writeFileSync(d,l,"utf-8"),c.length){let{mkdirSync:m}=await import('fs'),{dirname:g}=await import('path');m(g(c[0].path),{recursive:!0});for(let y of c)writeFileSync(y.path,y.content,"utf-8");}let f=c.length?` (+${c.length} sidecar files)`:"";e.addStatus(`Exported to ${d}${f}`);}}catch(r){e.addStatus(`Export failed: ${r.message}`);}},"execute")},{name:"/config",group:"config",description:"View or update settings",usage:"/config [show | set <key> <value> | get <key>]",execute:a(async(t,e)=>{let{SettingsManager:n}=await import('../manager-4XKLZHKE.js'),r=new n(e.cwd),o=t.trim().split(/\s+/),i=o[0]||"show";try{if(i==="show"||!t.trim()){let s=r.get();e.addStatus(JSON.stringify(s,null,2));}else if(i==="get"){let s=o[1];if(!s){e.addStatus("Usage: /config get <key> (e.g. model.name)");return}let l=r.get(),c=s.split(".").reduce((d,f)=>d?.[f],l);e.addStatus(`${s} = ${JSON.stringify(c)}`);}else if(i==="set"){let s=o[1],l=o.slice(2).join(" ");if(!s||!l){e.addStatus("Usage: /config set <key> <value> (e.g. model.name claude-opus-4-6)");return}let c=l;try{c=JSON.parse(l);}catch{}await e.client.query("config_set",s,c),e.addStatus(`Set ${s} = ${JSON.stringify(c)}`);}else e.addStatus("Usage: /config [show | set <key> <value> | get <key>]");}catch(s){e.addStatus(`Config error: ${s.message}`);}},"execute")},wh];h();h();function Va(t){try{return execSync("git rev-parse --is-inside-work-tree",{cwd:t,encoding:"utf-8",timeout:5e3}),!0}catch{return false}}a(Va,"isGitRepo");function Eh(t){let e=execSync("git status --porcelain",{cwd:t,encoding:"utf-8",timeout:1e4}).trim();return e?e.split(`
300
- `).map(n=>({status:n.slice(0,2).trim(),path:n.slice(3)})):[]}a(Eh,"getGitStatus");function qa(t,e){let n=["git","diff","--no-color"];return e?.staged&&n.push("--staged"),e?.file&&n.push("--",e.file),execSync(n.join(" "),{cwd:t,encoding:"utf-8",timeout:3e4}).trim()}a(qa,"getGitDiff");function Ch(t,e){let n=["git","diff","--stat","--no-color"];return e?.staged&&n.push("--staged"),e?.file&&n.push("--",e.file),execSync(n.join(" "),{cwd:t,encoding:"utf-8",timeout:1e4}).trim()}a(Ch,"getGitDiffStat");function kh(t,e=10){let n=execSync(`git log --oneline --format="%H|%s|%an|%ci" -${e}`,{cwd:t,encoding:"utf-8",timeout:1e4}).trim();return n?n.split(`
301
- `).map(r=>{let[o,i,s,l]=r.split("|");return {hash:o.slice(0,8),message:i,author:s,date:l}}):[]}a(kh,"getGitLog");function wu(t,e=["."]){let n=e.map(r=>`"${r}"`).join(" ");execSync(`git add ${n}`,{cwd:t,timeout:1e4});}a(wu,"gitAdd");function vu(t,e){return execSync(`git commit -m ${JSON.stringify(e)}`,{cwd:t,encoding:"utf-8",timeout:3e4}).trim()}a(vu,"gitCommit");function _h(t){let e=execSync("git branch --no-color",{cwd:t,encoding:"utf-8",timeout:5e3}).trim();return e?e.split(`
302
- `).map(n=>({current:n.startsWith("*"),name:n.replace(/^\*?\s+/,"").trim()})):[]}a(_h,"gitListBranches");function Rh(t,e,n=false){execSync(`git checkout ${n?"-b":""} ${e}`,{cwd:t,timeout:1e4});}a(Rh,"gitCheckout");function Tu(){try{return execSync("gh --version",{encoding:"utf-8",timeout:5e3}),!0}catch{return false}}a(Tu,"ghAvailable");function Eu(t,e){return execSync(`gh pr view ${e} --comments --json comments -q ".comments[].body"`,{cwd:t,encoding:"utf-8",timeout:3e4}).trim()}a(Eu,"ghPrComments");var Mh=[{name:"/commit",group:"git",description:"Generate commit message and commit",usage:"/commit [-m message]",execute:a(async(t,e)=>{if(!Va(e.cwd)){e.addStatus("Not a git repository.");return}if(Eh(e.cwd).length===0){e.addStatus("No changes to commit.");return}if(t.startsWith("-m ")){let o=t.slice(3).trim().replace(/^["']|["']$/g,"");if(!o){e.addStatus("Empty commit message.");return}try{wu(e.cwd);let i=vu(e.cwd,o);e.addStatus(i);}catch(i){e.addStatus(`Commit failed: ${i.message}`);}return}if(!e.queryGuard.reserve()){e.addStatus("Busy \u2014 wait for current turn to finish.");return}let r=new AbortController;e.queryGuard.tryStart(r);try{let o=Ch(e.cwd),i=qa(e.cwd),c=`Generate a concise git commit message for the following changes.
303
-
304
- ## Recent commit messages (follow this style):
305
- ${kh(e.cwd,5).map(m=>m.message).join(`
306
- `)}
307
-
308
- ## Diff stat:
309
- ${o}
310
-
311
- ## Diff (first 3000 chars):
312
- ${i.slice(0,3e3)}
313
-
314
- Respond with ONLY the commit message, nothing else. Use conventional commit format if the recent messages use it. Keep it under 72 characters for the first line.`,d=await e.client.run(c,e.sessionId);e.setSessionId(d.sessionId);let f=d.text.trim().replace(/^["'`]+|["'`]+$/g,"");if(f){wu(e.cwd);let m=vu(e.cwd,f);e.addStatus(`${m}`);}}catch(o){e.addStatus(`Commit failed: ${o.message}`);}finally{e.queryGuard.end();}},"execute")},{name:"/branch",group:"git",description:"List, create, or switch branches",usage:"/branch [name] [--create]",execute:a((t,e)=>{if(!Va(e.cwd)){e.addStatus("Not a git repository.");return}let n=t.trim();if(!n){let o=_h(e.cwd).map(i=>` ${i.current?"* ":" "}${i.name}`);e.addStatus(`Branches:
315
- `+o.join(`
316
- `));return}try{let r=n.includes("--create")||n.includes("-c"),o=n.replace(/--create|-c/g,"").trim();Rh(e.cwd,o,r),e.addStatus(`Switched to branch: ${o}${r?" (created)":""}`);}catch(r){e.addStatus(`Branch operation failed: ${r.message}`);}},"execute")},{name:"/review",group:"git",description:"Send code to model for review",usage:"/review [file]",execute:a(async(t,e)=>{if(!Va(e.cwd)){e.addStatus("Not a git repository.");return}if(!e.queryGuard.reserve()){e.addStatus("Busy \u2014 wait for current turn to finish.");return}let n=new AbortController;e.queryGuard.tryStart(n);try{let r=t?qa(e.cwd,{file:t}):qa(e.cwd);if(!r){e.addStatus("No changes to review.");return}let o=`Review the following code changes. Provide:
317
- 1. A brief summary of what changed
318
- 2. Potential issues or bugs
319
- 3. Suggestions for improvement
320
- 4. Security concerns if any
321
-
322
- \`\`\`diff
323
- ${r.slice(0,8e3)}
324
- \`\`\``,i=await e.client.run(o,e.sessionId);e.setSessionId(i.sessionId);}catch(r){e.addStatus(`Review failed: ${r.message}`);}finally{e.queryGuard.end();}},"execute")},{name:"/pr-comments",group:"git",description:"Fetch PR comments via gh CLI",usage:"/pr-comments <PR-url|number>",execute:a((t,e)=>{if(!Tu()){e.addStatus("gh CLI is not installed. Install it from https://cli.github.com/");return}if(!t){e.addStatus("Usage: /pr-comments <PR-url|number>");return}try{let n=Eu(e.cwd,t.trim());n?e.addStatus(n.slice(0,5e3)):e.addStatus("No comments found.");}catch(n){e.addStatus(`Failed to fetch PR comments: ${n.message}`);}},"execute")},{name:"/autofix-pr",group:"git",description:"Auto-fix based on PR review comments",usage:"/autofix-pr <PR-url|number>",execute:a(async(t,e)=>{if(!Tu()){e.addStatus("gh CLI is not installed.");return}if(!t){e.addStatus("Usage: /autofix-pr <PR-url|number>");return}if(!e.queryGuard.reserve()){e.addStatus("Busy \u2014 wait for current turn to finish.");return}let n=new AbortController;e.queryGuard.tryStart(n);try{let r=Eu(e.cwd,t.trim());if(!r){e.addStatus("No review comments found.");return}let o=`The following are review comments on a PR. Please read each comment, find the relevant code, and fix the issues mentioned.
325
-
326
- ## Review Comments:
327
- ${r.slice(0,5e3)}
328
-
329
- Fix all the issues in the codebase. Use the Edit and Read tools.`,i=await e.client.run(o,e.sessionId);e.setSessionId(i.sessionId);}catch(r){e.addStatus(`Autofix failed: ${r.message}`);}finally{e.queryGuard.end();}},"execute")}];h();var Ah=["default","acceptEdits","dontAsk","bypassPermissions","auto","plan"],Nh={name:"/permissions",aliases:["/perm"],group:"config",description:"Show or change permission mode",usage:"/permissions [mode]",execute:a(async(t,e)=>{let o=(await e.client.query("config")).data.permissionMode??"acceptEdits";if(!t){let s=[`Current mode: ${o}`,"","Available modes:"," default Ask for non-read tools"," acceptEdits Allow read + write, ask for bash"," dontAsk Deny all non-allowed tools"," bypassPermissions Allow everything"," auto Smart auto-approve safe operations"," plan Read-only planning mode","","Use /permissions <mode> to switch."];e.addStatus(s.join(`
330
- `));return}let i=t.trim();if(!Ah.includes(i)){e.addStatus(`Invalid mode: ${i}. Valid: ${Ah.join(", ")}`);return}try{await e.client.query("permission_set",i),e.addStatus(`Permission mode: ${o} \u2192 ${i} (live)`);}catch(s){e.addStatus(`Failed to switch mode: ${s.message}`);}},"execute")};h();var Oh=[{name:"/copy",description:"Copy last assistant response to clipboard",execute:a((t,e)=>{let n=[...e.chatLog].reverse().find(r=>r.type==="assistant_text");if(!n?.text){e.addStatus("No assistant response to copy.");return}try{let r=process.platform,o;r==="darwin"?o="pbcopy":r==="win32"?o="clip":o="xclip -selection clipboard",execSync(o,{input:n.text,timeout:5e3}),e.addStatus("Copied to clipboard.");}catch{e.addStatus("Failed to copy to clipboard. Command not available.");}},"execute")},{name:"/undo",description:"Revert the last file change",execute:a(async(t,e)=>{try{let{FileHistory:n}=await import('../file-history-7FQFEQOL.js'),{join:r}=await import('path'),{homedir:o}=await import('os');if(!e.sessionId){e.addStatus("No active session.");return}let s=(await e.client.query("config")).data,l=r(s.sessionStorageDir??r(o(),".code-shell","sessions"),e.sessionId),c=n.loadFromDir(l),d=c.getTrackedFiles();if(d.length===0){e.addStatus("No file changes to undo.");return}let f=d[d.length-1];c.restoreLatest(f)?e.addStatus(`Restored: ${f}`):e.addStatus("No file changes to undo.");}catch(n){e.addStatus(`Undo failed: ${n.message}`);}},"execute")},{name:"/hooks",description:"List registered hooks",execute:a((t,e)=>{e.addStatus("Hook listing is not yet available via the client protocol.");},"execute")},{name:"/fullscreen",description:"Toggle fullscreen UI mode (alt-screen + ScrollBox) vs flow mode (native terminal scrollback)",usage:"/fullscreen [on|off|toggle]",execute:a((t,e)=>{if(e.fullscreen===void 0||!e.setFullscreen){e.addStatus("Fullscreen toggle is not wired in this build.");return}let n=(t??"").trim().toLowerCase(),r;if(n==="on"||n==="1"||n==="true")r=true;else if(n==="off"||n==="0"||n==="false")r=false;else if(n===""||n==="toggle")r=!e.fullscreen;else {e.addStatus(`/fullscreen: unknown arg "${t}". Use on | off | toggle.`);return}if(r===e.fullscreen){e.addStatus(`Fullscreen is already ${r?"on":"off"}.`);return}e.setFullscreen(r);},"execute")},{name:"/update",description:"Check for and install updates",execute:a(async(t,e)=>{try{let{getCurrentVersion:n,getUpdateAvailable:r,getAutoUpdateDisabledReason:o}=await import('../updater-OCNU2K2Z.js'),i=n(),s=r(),l=o();if(!s){let d=l?`
331
- Auto-update is off: ${l}`:"";e.addStatus(`code-shell v${i} is up to date.${d}`);return}let c=`Update available: ${i} \u2192 ${s.latestVersion}`;s.canAutoInstall?e.addStatus(`${c}
332
- Will install on exit. (Or run now: npm install -g @cjhyy/code-shell@${s.latestVersion})`):e.addStatus(`${c}
333
- Run: sudo npm install -g @cjhyy/code-shell@${s.latestVersion}`);}catch(n){e.addStatus(`Update check failed: ${n.message}`);}},"execute")}];h();var Ph=[{name:"/voice",description:"Toggle voice input mode (reserved)",execute:a((t,e)=>{e.addStatus("Voice input is not yet implemented. When available, this will toggle speech-to-text input.");},"execute")}];h();var Ih=[{name:"/login",group:"config",description:"Reconfigure API key and provider interactively",usage:"/login [api-key]",execute:a(async(t,e)=>{let n=t.trim();if(n){let r=join(homedir(),".code-shell"),o=join(r,"settings.json");mkdirSync(r,{recursive:true});let i={};if(existsSync(o))try{i=JSON.parse(readFileSync(o,"utf-8"));}catch{}i.model||(i.model={}),i.model.apiKey=n,writeFileSync(o,JSON.stringify(i,null,2),"utf-8");try{await e.client.configure({reloadModels:!0}),e.addStatus("\u2713 API key saved and applied.");}catch(s){e.addStatus(`\u2713 API key saved. Hot-reload failed, please restart code-shell: ${s.message}`);}return}e.startOnboarding?e.startOnboarding():e.addStatus("Onboarding wizard only available in REPL mode. Restart code-shell.");},"execute")},{name:"/logout",group:"config",description:"Remove saved API key and configuration",execute:a((t,e)=>{let n=join(homedir(),".code-shell","settings.json");if(!existsSync(n)){e.addStatus("No saved config.");return}try{let r=JSON.parse(readFileSync(n,"utf-8")),o=[],i=["model","models","providers","arena","activeKey"];for(let d of i)r[d]!==void 0&&(delete r[d],o.push(d));let l=["ANTHROPIC_API_KEY","OPENAI_API_KEY","OPENROUTER_API_KEY","DEEPSEEK_API_KEY"].filter(d=>process.env[d]);if(o.length===0){let d=l.length?`
334
- Note: env var(s) still set: ${l.join(", ")} \u2014 unset to fully log out.`:"";e.addStatus(`No saved API key.${d}`);return}writeFileSync(n,JSON.stringify(r,null,2),"utf-8");let c=l.length?`
335
- \u26A0 Env var(s) still set: ${l.join(", ")} \u2014 unset to fully log out.`:"";e.addStatus(`\u2713 Cleared: ${o.join(", ")}. Restart to re-enter onboarding.${c}`);}catch(r){e.addStatus(`Failed: ${r.message}`);}},"execute")},{name:"/mcp",group:"config",description:"Show MCP server connection status",usage:"/mcp [list|status]",execute:a(async(t,e)=>{let o=(await e.client.query("config")).data.mcpServers??{},i=Object.keys(o);if(i.length===0){e.addStatus(`No MCP servers configured.
336
- Add to .code-shell/settings.json:
337
- "mcpServers": { "name": { "command": "...", "args": [...] } }`);return}let s=i.map(l=>{let c=o[l],d=c.transport??"stdio",f=c.command??c.url??"?";return ` ${l} [${d}] \u2014 ${f}`});e.addStatus(`MCP Servers (${i.length}):
338
- ${s.join(`
339
- `)}`);},"execute")},{name:"/models",group:"config",description:"Open the model management panel (list, switch, sync)",execute:a((t,e)=>{e.openModelManager?e.openModelManager():e.addStatus("Model manager only available in REPL mode. Use /model <key> to switch.");},"execute")},{name:"/skills",group:"config",description:"List skills available to the model",execute:a((t,e)=>{try{let n=h$1(e.cwd);if(n.length===0){e.addStatus(`No skills found.
340
- Create skills in:
341
- .code-shell/skills/<name>/SKILL.md (project)
342
- ~/.code-shell/skills/<name>/SKILL.md (user)`);return}let r=n.filter(l=>l.source==="project"),o=n.filter(l=>l.source==="user"),i=[];if(r.length>0){let l=r.map(c=>` ${c.name} \u2014 ${c.description||"(no description)"}`);i.push(`Project skills (${r.length}):
343
- ${l.join(`
344
- `)}`);}if(o.length>0){let l=o.map(c=>` ${c.name} \u2014 ${c.description||"(no description)"}`);i.push(`User skills (${o.length}):
345
- ${l.join(`
346
- `)}`);}let s=n.filter(l=>l.source==="plugin");if(s.length>0){let l=s.map(c=>` ${c.name} \u2014 ${c.description||"(no description)"}`);i.push(`Plugin skills (${s.length}):
347
- ${l.join(`
348
- `)}`);}e.addStatus(i.join(`
349
-
350
- `));}catch(n){e.addStatus(`Failed to scan skills: ${n.message}`);}},"execute")},{name:"/plugin",group:"config",description:"Manage plugin marketplaces and installed plugins",usage:"/plugin marketplace add|remove|list ... | /plugin install|uninstall <p>@<mkt> | /plugin list",execute:a(async(t,e)=>{try{let{runPluginCommand:n}=await import('../plugin-handler-GJISMH5Q.js'),r=await n(t??"");e.addStatus(r);}catch(n){e.addStatus(`/plugin failed: ${n.message}`);}},"execute")},{name:"/log",aliases:["/logs"],group:"config",description:"Show recent log entries; filter by sid / turn / cat",usage:"/log [n] | /log sid <id> [n] | /log turn <id> [n] | /log cat <name> [n]",execute:a((t,e)=>{let n=join(homedir(),".code-shell","logs"),r=new Date().toISOString().slice(0,10),o=join(n,`${r}.log`);if(!existsSync(o)){e.addStatus(`No logs found for today (${r}).`);return}let i=t.trim().split(/\s+/).filter(Boolean),s="tail",l=null,c;if(i[0]==="sid"||i[0]==="turn"||i[0]==="cat"){if(s=i[0],l=i[1]??null,c=i[2],!l){e.addStatus(`Usage: /log ${s} <value> [n]`);return}}else c=i[0];let d=s==="tail"?200:2e3,f=Math.max(1,Math.min(parseInt(c??"")||20,d));try{let g=readFileSync(o,"utf-8").trim().split(`
351
- `).filter(b=>b.trim()),y=[];for(let b of g){let h=null;try{h=JSON.parse(b);}catch{s==="tail"&&y.push({raw:b,e:null});continue}s==="sid"&&h.sid!==l||s==="turn"&&h.turnId!==l||s==="cat"&&h.cat!==l||y.push({raw:b,e:h});}let w=y.slice(-f),x=w.map(({raw:b,e:h})=>{if(!h)return ` ${b.slice(0,120)}`;let T=h.t?.split("T")[1]?.slice(0,12)??"",A=(h.l??"").toUpperCase().padEnd(5),M=h.msg??"",D=` ${T} ${A}`;s!=="turn"&&h.turnId&&(D+=` [t#${h.turn}/${h.turnId}]`),s==="tail"&&h.cat&&(D+=` ${h.cat}`);let N="",R=h.d;return R&&(R.duration_ms!==void 0?N+=` ${R.duration_ms}ms`:R.latencyMs!==void 0&&(N+=` ${R.latencyMs}ms`),R.ttft_ms!==void 0&&(N+=` ttft=${R.ttft_ms}ms`),R.usage?.totalTokens&&(N+=` ${R.usage.totalTokens}tok`),R.tool&&(N+=` tool=${R.tool}`),R.decision&&(N+=` decision=${R.decision}`),R.approved!==void 0&&(N+=` approved=${R.approved}`),R.stopReason&&(N+=` [${R.stopReason}]`),R.error&&(N+=` err=${R.error.slice(0,80)}`)),`${D} ${M}${N}`}),v=s==="tail"?`Recent logs (${w.length}/${g.length})`:`Logs filtered by ${s}=${l} (${w.length}/${y.length}, scanned ${g.length})`;e.addStatus(`${v}:
352
- ${x.join(`
353
- `)}`);}catch(m){e.addStatus(`Error reading logs: ${m.message}`);}},"execute")}];h();var Lh=[{name:"/files",description:"List files in the current working directory",usage:"/files [pattern]",execute:a((t,e)=>{try{let n=t.trim(),r;n?r=`find . -maxdepth 3 -name "${n}" -not -path '*/node_modules/*' -not -path '*/.git/*' | head -50`:r="find . -maxdepth 2 -type f -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/dist/*' | head -50";let o=execSync(r,{cwd:e.cwd,encoding:"utf-8",timeout:1e4}).trim();if(!o)e.addStatus("No files found.");else {let i=o.split(`
354
- `).length;e.addStatus(`Files (${i}, max 50 shown):
355
- ${o}`);}}catch(n){e.addStatus(`Error: ${n.message}`);}},"execute")},{name:"/release-notes",aliases:["/changelog","/whatsnew"],description:"Show recent changes and release notes",execute:a((t,e)=>{let n=[join(e.cwd,"CHANGELOG.md"),join(e.cwd,"CHANGES.md"),join(e.cwd,"HISTORY.md")];for(let r of n)if(existsSync(r)){let o=readFileSync(r,"utf-8");e.addStatus(o.slice(0,2e3)+(o.length>2e3?`
356
- ... (truncated)`:""));return}try{let r=execSync("git log --oneline -20",{cwd:e.cwd,encoding:"utf-8",timeout:5e3}).trim();e.addStatus(`Recent commits:
357
- ${r}`);}catch{e.addStatus("No changelog or git history found.");}},"execute")},{name:"/security-review",aliases:["/sec"],group:"git",description:"Run a security review of pending changes",execute:a(async(t,e)=>{try{let n=execSync("git status --short",{cwd:e.cwd,encoding:"utf-8",timeout:5e3}).trim(),r=execSync("git diff HEAD --no-color",{cwd:e.cwd,encoding:"utf-8",timeout:1e4}).trim(),o=execSync("git diff --cached --no-color",{cwd:e.cwd,encoding:"utf-8",timeout:1e4}).trim(),i=(r+`
358
- `+o).trim();if(!i){e.addStatus("No pending changes to review.");return}if(!e.queryGuard.reserve()){e.addStatus("Busy \u2014 wait for current turn to finish.");return}let s=new AbortController;e.queryGuard.tryStart(s);let l=`You are a senior security engineer. Review the pending diff for security issues.
359
-
360
- GIT STATUS:
361
- \`\`\`
362
- ${n}
363
- \`\`\`
364
-
365
- DIFF:
366
- \`\`\`diff
367
- ${i.slice(0,15e3)}
368
- \`\`\`
369
-
370
- Focus on: SQL/Command injection, auth bypass, hardcoded secrets, XSS, path traversal, unsafe deserialization, crypto issues.
371
- For each finding provide: file:line, severity (HIGH/MEDIUM), description, exploit scenario, fix.
372
- If no issues found, say so clearly.`;try{let c=await e.client.run(l,e.sessionId);e.setSessionId(c.sessionId);}catch(c){e.addStatus(`Security review failed: ${c.message}`);}finally{e.queryGuard.end();}}catch(n){e.addStatus(`Security review failed: ${n.message}`);}},"execute")},{name:"/feedback",aliases:["/bug"],description:"Report a bug or provide feedback",usage:"/feedback [description]",execute:a((t,e)=>{let n=t.trim();if(!n){e.addStatus(`Usage: /feedback <description>
373
- Include what you expected, what happened, steps to reproduce.`);return}let r=join(homedir(),".code-shell","feedback");try{let{mkdirSync:o,appendFileSync:i}=b("fs");o(r,{recursive:!0});let s={timestamp:new Date().toISOString(),model:e.model,sessionId:e.sessionId,description:n,platform:`${process.platform} ${process.arch}`};i(join(r,"feedback.jsonl"),JSON.stringify(s)+`
374
- `,"utf-8"),e.addStatus("Feedback saved. Thank you!");}catch{e.addStatus(`Feedback noted: "${n}". Could not save locally.`);}},"execute")}];h();h();function HT(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="ENOENT"}a(HT,"isENOENT");function Fh(t){if(typeof t!="object"||t===null||!("code"in t))return false;let e=t.code;return e==="EACCES"||e==="EPERM"||e==="EIO"}a(Fh,"isInaccessible");function WT(){return process.env.HOME??homedir()}a(WT,"userHome");function UT(t){try{return readFileSync(t,"utf-8")}catch(e){if(HT(e))return null;if(Fh(e))return console.warn(`[plugin-commands] cannot read ${t}: ${e.message}`),null;throw e}}a(UT,"readCommandFile");function GT(){let t=d$4(),e=[],n=new Set,r=Object.keys(t.plugins).sort();for(let o of r){let i=t.plugins[o]??[],s=o.lastIndexOf("@"),l=s>0?o.slice(0,s):o;for(let c of i){let d=join(c.installPath,"commands");if(!existsSync(d))continue;let f;try{f=readdirSync(d,{withFileTypes:!0});}catch(m){if(Fh(m)){console.warn(`[plugin-commands] cannot read ${d}: ${m.message}`);continue}throw m}for(let m of f){if(!m.isFile()&&!m.isSymbolicLink()||!m.name.endsWith(".md"))continue;let g=join(d,m.name),y=UT(g);if(y===null)continue;let w=m.name.slice(0,-3),x=`${l}:${w}`;if(n.has(x))continue;let{frontmatter:v,body:b}=a$4(y),h=b$3(v.description),T=typeof v["argument-hint"]=="string"?v["argument-hint"]:void 0;e.push({name:x,commandName:w,pluginName:l,description:h,argumentHint:T,body:b,filePath:g}),n.add(x);}}}return e}a(GT,"scanOnce");function jT(){let t=c$2();try{return statSync(t).mtimeMs.toString()}catch{return "0"}}a(jT,"installedPluginsMtime");var KT=$T(GT,()=>`${WT()}\0${jT()}`);function $h(){return KT()}a($h,"scanPluginCommands");function YT(t){let e=t.argumentHint?`/${t.name} ${t.argumentHint}`:`/${t.name}`;return {name:`/${t.name}`,description:t.description||`Plugin command from ${t.pluginName}`,usage:e,group:"advanced",execute:a((n,r)=>{let o=t.body.replace(/\$ARGUMENTS/g,n??"").replace(/\{args\}/g,n??"");r.setNextContext(o),r.addStatus(`Prompt staged from ${t.name}. Press Enter to submit (or edit your message first).`);},"execute")}}a(YT,"pluginCommandToSlash");function Hh(){return $h().map(YT)}a(Hh,"buildPluginSlashCommands");h();h();function Wh(t,e){if(t<6e4)return t===0?"0s":t<1?`${(t/1e3).toFixed(1)}s`:`${Math.floor(t/1e3).toString()}s`;let n=Math.floor(t/864e5),r=Math.floor(t%864e5/36e5),o=Math.floor(t%36e5/6e4),i=Math.round(t%6e4/1e3);i===60&&(i=0,o++),o===60&&(o=0,r++),r===24&&(r=0,n++);let s=e?.hideTrailingZeros;return e?.mostSignificantOnly?n>0?`${n}d`:r>0?`${r}h`:o>0?`${o}m`:`${i}s`:n>0?s&&r===0&&o===0?`${n}d`:s&&o===0?`${n}d ${r}h`:`${n}d ${r}h ${o}m`:r>0?s&&o===0&&i===0?`${r}h`:s&&i===0?`${r}h ${o}m`:`${r}h ${o}m ${i}s`:o>0?s&&i===0?`${o}m`:`${o}m ${i}s`:`${i}s`}a(Wh,"formatDuration");var Ru=null,Mu=null,VT=a(t=>t?(Ru||(Ru=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1,minimumFractionDigits:1})),Ru):(Mu||(Mu=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1,minimumFractionDigits:0})),Mu),"getNumberFormatter");function qT(t){let e=t>=1e3;return VT(e).format(t).toLowerCase()}a(qT,"formatNumber");function us(t){return qT(t).replace(".0","")}a(us,"formatTokens");var ms=d.child({cat:"ui"}),Un=new ja;Un.registerAll(Th);Un.registerAll(Mh);Un.register(Nh);Un.registerAll(Oh);Un.registerAll(Ph);Un.registerAll(Ih);Un.registerAll(Lh);Un.registerAll(Hh());var Le=ii;function jh({client:t,model:e,effort:n,maxTurns:r,cwd:o,maxContextTokens:i,sessionId:s,prefill:l}){wg();let{exit:c}=Pc(),[d,f]=useState(au),m=useMemo(()=>({fullscreen:d,setFullscreen:a(C=>f(C),"setFullscreen"),toggleFullscreen:a(()=>f(C=>!C),"toggleFullscreen")}),[d]),[g,y]=useState(l??""),w=useSyncExternalStore(be.subscribe.bind(be),be.getEntries.bind(be)),[x,v]=useState([]),b=useRef(null);useEffect(()=>(x.length>0&&x.every(C=>C.status==="completed"||C.status==="stopped")&&(b.current=setTimeout(()=>v([]),3e3)),()=>{b.current&&clearTimeout(b.current);}),[x]);let h=useRef(new Ka).current,T=useSyncExternalStore(h.subscribe,h.getSnapshot),A=useSyncExternalStore(a$3.subscribe,a$3.hasRunning),M=T||A,[D,N]=useState({kind:"main"}),[R,E]=useState(null),I=useSyncExternalStore(a$3.subscribe,a$3.getSnapshot);useEffect(()=>{if(D.kind!=="agent")return;let C=I.find(P=>P.agentId===D.agentId);(!C||C.status!=="running")&&N({kind:"main"});},[I,D]);let F=D.kind==="main"?"main":`agent:${D.agentId}`,O=useRef(false);useEffect(()=>{if(!O.current){O.current=true;return}Mp();},[F]),useEffect(()=>{if(R===null)return;let C=ss(I,Date.now()).length;if(C===0){E(null);return}let P=Math.min(is,C);R>P&&E(P);},[I,R]);let[L,J]=useState(s),le=useRef(s);useEffect(()=>{le.current=L;},[L]);let[Oe,Pe]=useState(e),Ye=useRef(null),[Z,Se]=useState(true),[W,me]=useState(0),[pe,Y]=useState(0),[q,Te]=useState(0),[Ce,ge]=useState(n),[se,lt]=useState("normal"),[Be,He]=useState(null),[re,rt]=useState(null),[xt,Zt]=useState(false),[Mt,Vt]=useState(null),[Dt,We]=useState(null),[ke,we]=useState(null),[qe,ot]=useState(null),U=useRef(0),$=useRef(0),[V,K]=useState("thinking"),[ne,z]=useState(null),he=useRef(false),[ct,mt]=useState("prompt"),[en,pn]=useState(null),{dividerIndex:Q,showPill:Ne,unseenCount:xe,onScrollToBottom:pt}=Ng(w.length),ze=useRef(null),Fe=useCallback(()=>{pt(),ze.current?.scrollToBottom();},[pt]);useEffect(()=>{M&&($.current=Date.now()),ms.info("debug.app.isRunning_change",{isRunning:M,runStartRef:$.current});},[M]),useEffect(()=>(Tg(),()=>Eg()),[]),useEffect(()=>{let C=a((P,j)=>{if(j.toolName==="__ask_user__"){let B=j.args??{},G=B.options,Qe=Array.isArray(G)&&G.every(ve=>typeof ve=="object"&&ve!==null&&typeof ve.label=="string"&&typeof ve.description=="string")?G:void 0;rt({requestId:P,question:j.description,header:typeof B.header=="string"?B.header:void 0,options:Qe,multiSelect:B.multiSelect===true});return}He({requestId:P,toolName:j.toolName,description:j.description,riskLevel:j.riskLevel,args:j.args});},"handleApproval");return t.onApprovalRequest(C),()=>t.offApprovalRequest(C)},[t]);let tn=useRef(new Map),Je=useRef(null),nn=useRef(""),ce=useRef(null),it=useCallback(()=>{if(ce.current=null,nn.current.length===0)return;let C=nn.current;nn.current="",z(P=>(P??"")+C);},[]),gt=useCallback(()=>{nn.current="",ce.current&&(clearTimeout(ce.current),ce.current=null);},[]),Tt=useCallback(()=>{Je.current=null;let C=tn.current;if(C.size===0)return;let P=new Map(C);C.clear(),be.update(j=>{let B=j;for(let[G,Qe]of P){let ve=JT(B,De=>De.type==="assistant_text"&&De.streaming&&De.agentId===G);if(ve>=0){let De=B[ve];B=[...B],B[ve]={...De,text:De.text+Qe};}else B=[...B.filter(De=>!(De.type==="thinking"&&De.agentId===G)),Le({type:"assistant_text",text:Qe,streaming:true,agentId:G})];}return B});},[]);useEffect(()=>()=>{Je.current&&clearTimeout(Je.current),ce.current&&clearTimeout(ce.current);},[]);let ae=useCallback(C=>{let P=C.agentId;ms.info("debug.stream.event",{type:C.type,agentId:P}),Sg(C.type,P);let j=C.type==="session_started"?C.sessionId:le.current;switch(h$2(j,"ui.stream_event",{type:C.type,agentId:P}),C.type){case "session_started":J(C.sessionId),C.promptTokens>0&&(ms.info("debug.ctx.set",{from:"session_started",value:C.promptTokens}),h$2(C.sessionId,"ui.ctx.set",{from:"session_started",value:C.promptTokens}),Te(C.promptTokens));break;case "stream_request_start":if(P!==void 0)break;K("thinking"),z(null),gt(),U.current=0,be.update(B=>[...B.filter(Qe=>!(Qe.type==="thinking"&&Qe.agentId===P)),Le({type:"thinking",agentId:P})]);break;case "thinking_delta":nn.current+=C.text,ce.current||(ce.current=setTimeout(it,50));break;case "text_delta":{if(P!==void 0)break;K("responding");let B=tn.current.get(P)??"";tn.current.set(P,B+C.text),U.current+=C.tokens??0,Je.current||(Je.current=setTimeout(Tt,50));break}case "tool_use_start":{if(K("tool-use"),Je.current&&(clearTimeout(Je.current),Je.current=null),Tt(),P!==void 0)break;let B=C.toolCall;be.update(G=>[...G.map(ve=>ve.type==="assistant_text"&&ve.streaming&&ve.agentId===P?{...ve,streaming:false}:ve).filter(ve=>!(ve.type==="thinking"&&ve.agentId===P)&&!(ve.type==="tool_running"&&ve.agentId===P)),Le({type:"tool_start",toolName:B.toolName,args:B.args,toolCallId:B.id,agentId:P}),Le({type:"tool_running",toolName:B.toolName,agentId:P})]);break}case "tool_use_args_delta":{if(P!==void 0)break;let{toolCallId:B,args:G}=C;be.update(Qe=>{let ve=Qe.findIndex(or=>or.type==="tool_start"&&or.toolCallId===B);if(ve<0)return Qe;let De=[...Qe];return De[ve]={...Qe[ve],args:G},De});break}case "tool_result":{if(P!==void 0)break;let B=C.result,G=B.toolName==="Arena"&&typeof B.result=="string"&&B.result.startsWith("Arena error:");be.update(Qe=>[...Qe.filter(De=>!(De.type==="tool_running"&&De.agentId===P)),Le({type:"tool_result",toolName:B.toolName,result:B.result,error:B.error,agentId:P,compact:G})]);break}case "agent_start":{let B=C;be.update(G=>[...G,Le({type:"agent_start",agentId:B.agentId,name:B.name,description:B.description})]);break}case "agent_end":{let B=C;be.update(G=>[...G.filter(ve=>!(ve.agentId===B.agentId&&(ve.type==="thinking"||ve.type==="tool_running"))),Le({type:"agent_end",agentId:B.agentId,name:B.name,description:B.description,text:B.text,error:B.error})]);break}case "task_update":{let B=C;B.tasks&&v(B.tasks);break}case "context_compact":{let B=C,G=B.before-B.after,Qe=B.before>0?Math.round(G/B.before*100):0,ve=`\u2500\u2500 context compacted (${B.strategy}, ${us(B.before)} \u2192 ${us(B.after)}, -${Qe}%) \u2500\u2500`;be.update(De=>[...De,Le({type:"system",subtype:"compact_boundary",text:ve})]),ms.info("debug.ctx.set",{from:"context_compact",value:B.after}),h$2(le.current,"ui.ctx.set",{from:"context_compact",value:B.after}),Te(B.after);break}case "usage_update":{ms.info("debug.ctx.usage_update",{promptTokens:C.promptTokens}),h$2(le.current,"ui.ctx.usage_update",{promptTokens:C.promptTokens}),C.promptTokens>0&&Te(C.promptTokens);break}case "error":{if(he.current||P!==void 0)break;let B=C.error,G=eE(B);be.update(Qe=>[...Qe.filter(De=>!(De.type==="thinking"&&De.agentId===P)&&!(De.type==="tool_running"&&De.agentId===P)),Le({type:"error",error:Uh(B),errorKind:G,agentId:P})]);break}}},[Tt]);useEffect(()=>(t.onStreamEvent(ae),()=>t.offStreamEvent(ae)),[t,ae]);let Xe=useCallback(async()=>{try{let P=(await t.query("models")).data??[];Vt(P);}catch(C){be.update(P=>[...P,Le({type:"status",reason:`Failed to load models: ${C.message}`})]);}},[t]),St=useCallback(async()=>{try{let j=((await t.query("sessions")).data??[]).filter(B=>(B.preview??"").trim().length>0);if(j.length===0){be.update(B=>[...B,Le({type:"status",reason:"No sessions to resume."})]);return}We(j);}catch(C){be.update(P=>[...P,Le({type:"status",reason:`Failed to load sessions: ${C.message}`})]);}},[t]),rn=useCallback(async()=>{let[C,P,j,B]=await Promise.all([t.query("models"),t.query("config_get","arena.participants"),t.query("providers"),import('../openrouter-models-ZT4R2AE3.js')]),G=C.data??[],Qe=B.getOpenRouterSnapshot(),ve=P.data?.value,De=Array.isArray(ve)?ve.map(Me=>{if(typeof Me=="string")return {kind:"key",value:Me};if(Me&&typeof Me=="object"){let mi=Me;return {kind:"object",label:mi.name??mi.model??"(\u672A\u547D\u540D)"}}return {kind:"object",label:String(Me)}}):[],ir=(Array.isArray(j.data)?j.data:[]).filter(Me=>!!Me&&typeof Me=="object").map(Me=>{let mi=typeof Me.key=="string"?Me.key:"",Lu=typeof Me.label=="string"?Me.label:mi,ny=typeof Me.kind=="string"?Me.kind:"unknown",ry=typeof Me.baseUrl=="string"?Me.baseUrl:void 0,oy=typeof Me.apiKey=="string"?Me.apiKey:void 0,iy=typeof Me.protocol=="string"?Me.protocol:void 0,sy=typeof Me.modelsPath=="string"?Me.modelsPath:void 0;return {key:mi,label:Lu,kind:ny,modelCount:typeof Me.modelCount=="number"?Me.modelCount:0,cachedModels:typeof Me.cachedModels=="number"?Me.cachedModels:void 0,cachedAt:typeof Me.cachedAt=="string"?Me.cachedAt:void 0,baseUrl:ry,apiKey:oy,protocol:iy,modelsPath:sy}}).filter(Me=>Me.key.length>0);return {entries:G,snapshot:{count:Qe.count,fetchedAt:Qe.fetchedAt},arenaParticipants:De,providers:ir}},[t]),nr=useCallback(async()=>{try{let C=await rn();we(C);}catch(C){be.update(P=>[...P,Le({type:"status",reason:`Failed to open model manager: ${C.message}`})]);}},[rn]),on=useCallback(async()=>{try{let C=await rn();we(C);}catch(C){be.update(P=>[...P,Le({type:"status",reason:`Failed to refresh model manager: ${C.message}`})]);}},[rn]),qt=useCallback(async()=>{try{let C=await rn();we(C);}catch(C){be.update(P=>[...P,Le({type:"status",reason:`Could not load existing config (continuing with empty list): ${C.message}`})]);}Zt(true);},[rn]);ft((C,P)=>{if(R!==null){let j=ss(a$3.getSnapshot(),Date.now()),B=Math.min(is,j.length);if(P.upArrow){E(G=>G===null?G:G===0?null:G-1);return}if(P.downArrow){E(G=>G===null?G:Math.min(B,G+1));return}if(P.return){if(R===0)N({kind:"main"});else {let G=j[R-1];G&&N({kind:"agent",agentId:G.agentId});}return}if(P.escape){E(null);return}}if(P.escape&&D.kind==="agent"&&!re&&!Be&&!xt&&!Mt&&!ke&&!Dt){N({kind:"main"});return}if(P.ctrl&&C==="c")if(M){Je.current&&(clearTimeout(Je.current),Je.current=null),Tt(),be.update(j=>j.filter(B=>B.type!=="tool_running")),be.commitInterruptedStreaming(`
375
-
376
- [Request interrupted by user]`),h.forceEnd("user-cancel"),t.cancel().catch(()=>{});for(let j of a$3.list())j.status==="running"&&a$3.cancel(j.agentId);he.current=true,K("thinking"),z(null),gt();}else c();if(P.shift&&P.tab&&!M&&lt(j=>{let B=["plan","normal","bypass"],G=B[(B.indexOf(j)+1)%B.length];return t.configure({planMode:G==="plan",bypassPermissions:G==="bypass"}).catch(()=>{}),G}),P.escape&&T&&!re&&!Be&&!xt&&!Mt&&!ke&&!Dt&&(Je.current&&(clearTimeout(Je.current),Je.current=null),Tt(),be.update(j=>j.filter(B=>B.type!=="tool_running")),be.commitInterruptedStreaming(`
377
-
378
- [Request interrupted by user]`),h.forceEnd("user-cancel"),t.cancel().catch(()=>{}),he.current=true,K("thinking"),z(null),gt(),Zp()),P.meta&&C==="m"&&!M&&!xt&&!Mt&&!ke){Xe();return}if(d&&!Gn&&(P.wheelUp||P.wheelDown)){ze.current?.scrollBy(P.wheelUp?-1:1);return}if(d&&!Gn&&(P.pageUp||P.pageDown)){let j=ze.current?.getViewportHeight()??0,B=Math.max(1,j-2);ze.current?.scrollBy(P.pageUp?-B:B);return}if(P.ctrl&&C==="o"){mt(j=>j==="transcript"?(pn(null),"prompt"):"transcript");return}if(ct==="transcript"){let j=w.filter(B=>B.type==="user"||B.type==="assistant_text"||B.type==="tool_result");P.upArrow?pn(B=>B===null?j.length-1:Math.max(0,B-1)):P.downArrow?pn(B=>B===null?0:Math.min(j.length-1,B+1)):P.escape&&pn(null);}});let zt=useCallback(async(C,P)=>{if(!h.reserve())return;U.current=0,he.current=false,e$1.reset();let j=new AbortController;if(!h.tryStart(j)){h.cancelReservation();return}P.asInjection?be.update(B=>[...B,Le({type:"system",subtype:"bg_agent_notification",text:P.chatSummary??""})]):be.update(B=>[...B,Le({type:"user",text:C})]);try{let B=C;!P.asInjection&&Ye.current&&(B=`<context>
379
- ${Ye.current}
380
- </context>
381
-
382
- ${C}`,Ye.current=null);let G=await t.run(B,L);if(he.current)return;Je.current&&(clearTimeout(Je.current),Je.current=null),Tt(),be.update(or=>or.filter(ir=>ir.type!=="thinking"&&ir.type!=="tool_running").map(ir=>ir.type==="assistant_text"&&ir.streaming?{...ir,streaming:!1}:ir)),J(G.sessionId),me(yt.getTotalTokens().total),Y(yt.getEstimatedCost());let Qe=Date.now()-$.current,ve=G.usage?yt.estimateForTokens(Oe,G.usage.promptTokens,G.usage.completionTokens):0,De=[Wh(Qe)];G.usage&&G.usage.totalTokens>0&&(De.push(`${us(G.usage.totalTokens)} tokens`),G.usage.cacheReadTokens&&De.push(`${us(G.usage.cacheReadTokens)} cached`)),ve>0&&De.push(`$${ve.toFixed(4)}`),be.update(or=>[...or,Le({type:"system",subtype:"turn_duration",text:De.join(" \xB7 ")})]),G.reason!=="completed"&&be.update(or=>[...or,Le({type:"status",reason:XT(G.reason)})]);}catch(B){he.current||be.update(G=>[...G,Le({type:"error",error:Uh(B.message)})]);}finally{h.end();}he.current||(K("thinking"),z(null),gt());},[t,L,Oe,Tt,gt]),Gn=re||Be||xt||Mt||ke||Dt,Hr=useSyncExternalStore(b$4.subscribe,b$4.getSnapshot);useEffect(()=>{if(Hr.length===0||T||g.trim()!==""||Gn)return;let C=b$4.drainAll();if(C.length===0)return;let P=c$3(C),j=d$5(C);zt(P,{asInjection:true,chatSummary:j});},[Hr,T,g,Gn,zt]);let ui=useCallback(async C=>{let P=C.trim();if(!P)return;let j=P.split(/\s+/)[0]?.toLowerCase();if(!(T&&!new Set(["/sid","/help"]).has(j??""))){if(T?y(""):(y(""),Se(false),Fe()),P.startsWith("/")){di(P);return}await zt(P,{asInjection:false});}},[T,zt,Fe]),di=useCallback(C=>{if(C.trim().toLowerCase()==="/help"){rr(Un.helpText());return}let P={client:t,cwd:o,model:Oe,setModel:Pe,sessionId:L,setSessionId:J,queryGuard:h,addStatus:rr,addMessage:jn,setNextContext:a(j=>{Ye.current=j;},"setNextContext"),exit:c,effort:Ce,setEffort:ge,tasks:x,clearChat:a(()=>{be.clear(),v([]),Se(true);},"clearChat"),chatLog:w,startOnboarding:qt,openModelSelector:Xe,openSessionPicker:St,openModelManager:nr,fullscreen:d,setFullscreen:m.setFullscreen,toggleFullscreen:m.toggleFullscreen,loadChatEntries:a(j=>{let B=j.map(G=>{switch(G.type){case "user":return Le({type:"user",text:G.text??""});case "assistant_text":return Le({type:"assistant_text",text:G.text??"",streaming:false});case "tool_start":return Le({type:"tool_start",toolName:G.toolName??"",args:G.args??{}});case "tool_result":return Le({type:"tool_result",toolName:G.toolName??"",result:G.result,error:G.error});case "status":return Le({type:"status",reason:G.text??""});default:return Le({type:"status",reason:""})}}).filter(G=>!(G.type==="status"&&G.reason===""));be.setEntries(B),v([]);},"loadChatEntries")};Un.dispatch(C,P);},[t,o,Oe,Pe,L,Ce,x,w,c,qt,Xe,St,nr]),rr=a(C=>{be.update(P=>[...P,Le({type:"status",reason:C})]);},"addStatus"),jn=a(C=>{be.update(P=>[...P,Le({type:"assistant_text",text:C,streaming:false})]);},"addMessage"),Wr=useMemo(()=>Un.listCommands(),[]),go=useMemo(()=>ct!=="transcript"?new Set:new Set(w.filter(C=>C.type==="user"||C.type==="assistant_text"||C.type==="tool_result").map(C=>C.id)),[ct,w]),fi=useMemo(()=>en===null||ct!=="transcript"?null:w.filter(P=>go.has(P.id))[en]?.id??null,[en,ct,w,go]),ps=ct==="transcript",gs=useMemo(()=>{for(let C=w.length-1;C>=0;C--){let P=w[C];if(P.type==="assistant_text"&&P.streaming)return P.id}return null},[w]),hs=D.kind==="main"?w:I.find(P=>P.agentId===D.agentId)?.transcript??[],ys=jsxs(Fragment,{children:[Z&&jsxs(Fragment,{children:[jsx($p,{model:Oe,effort:Ce,maxTurns:r,cwd:o}),jsx(Wp,{}),!s&&jsx(Gp,{cwd:o})]}),jsx(Hg,{ref:ze,entries:hs,renderEntry:zT,columns:process.stdout.columns??80,streamingEntryId:gs,selectedEntryId:fi,expanded:ps,dividerIndex:Q,unseenCount:xe}),M&&!re&&!Be&&jsx(yg,{mode:V,streamingTokensRef:U,runStartRef:$,thinkingContent:ne??void 0}),x.length>0&&D.kind==="main"&&jsx(dg,{tasks:x})]}),Zh=Be?jsx(Jg,{toolName:Be.toolName,description:Be.description,riskLevel:Be.riskLevel,args:Be.args,cwd:o,onDecision:(C,P)=>{let{requestId:j}=Be;He(null);let B=P!=="once";t.approve(j,C?{approved:true,always:B,scope:P}:{approved:false,always:B,scope:P}).catch(()=>{});}}):void 0,ey=process.stdout.columns??80,Iu="\u2500".repeat(ey),ty=jsxs(S,{flexDirection:"column",marginTop:0,children:[jsx(u,{dim:true,children:Iu}),ct==="transcript"?jsxs(S,{marginLeft:2,children:[jsx(u,{dim:true,children:"Transcript mode \xB7 ctrl+o to return \xB7 \u2191\u2193 navigate"}),en!==null&&jsxs(u,{dim:true,children:[" \xB7 selected: ",en+1]})]}):xt?jsx(Ua,{existingProviders:(ke?.providers??[]).map(C=>({key:C.key,label:C.label??C.key,kind:C.kind,baseUrl:C.baseUrl??"",apiKey:C.apiKey})),existingModelKeys:(ke?.entries??[]).map(C=>C.key),existingModelIds:(ke?.entries??[]).map(C=>C.model),onComplete:async C=>{Zt(false),we(null);try{let j=(await t.configure({reloadModels:!0,model:C.key}))?.model??C.model;Pe(j),rr(`\u2713 \u914D\u7F6E\u5DF2\u4FDD\u5B58,\u5DF2\u5207\u6362\u5230: ${C.key} (${j})`);}catch(P){rr(`\u2713 \u914D\u7F6E\u5DF2\u4FDD\u5B58 (${C.model})\u3002\u70ED\u52A0\u8F7D\u5931\u8D25,\u8BF7\u91CD\u542F code-shell: ${P.message}`);}},onCancel:()=>{Zt(false),we(null),rr("\u5DF2\u53D6\u6D88\u914D\u7F6E\u3002");}}):Mt?jsx(oh,{entries:Mt,onSelect:async C=>{Vt(null);try{let B=(await t.configure({model:C}))?.model??C;Pe(B),rr(`\u2713 \u5207\u6362\u5230: ${C} (${B})`);}catch(P){rr(`\u5207\u6362\u5931\u8D25: ${P.message}`);}},onCancel:()=>Vt(null)}):Dt?jsx(ch,{entries:Dt,onSelect:C=>{We(null),di(`/resume ${C}`);},onCancel:()=>We(null)}):qe==="flow"&&ke?jsx($a,{existingProviders:ke.providers.map(C=>({key:C.key,label:C.label??C.key,kind:C.kind,baseUrl:C.baseUrl??"",apiKey:C.apiKey,protocol:C.protocol,modelsPath:C.modelsPath})),existingModelKeys:ke.entries.map(C=>C.key),existingModelIds:ke.entries.map(C=>C.model),detectedEnvKeys:[],switchToNewModelOnFinish:false,onFinish:async C=>{let P=[];try{C.addedProvider&&await t.query("provider_add",{provider:C.addedProvider});}catch(j){P.push(`provider ${C.addedProvider?.key}: ${j.message}`);}for(let j of C.addedModels)try{await t.query("model_add",{model:j});}catch(B){P.push(`model ${j.key}: ${B.message}`);}ot(null);try{await t.configure({reloadModels:!0});}catch{}await on(),P.length>0&&be.update(j=>[...j,Le({type:"status",reason:`\u6DFB\u52A0\u90E8\u5206\u5931\u8D25: ${P.join("; ")}`})]);},onCancel:()=>ot(null)}):ke?jsx(sh,{entries:ke.entries,snapshot:ke.snapshot,arenaParticipants:ke.arenaParticipants,providers:ke.providers,onSaveArena:async C=>{await t.query("config_set","arena.participants",C),we(P=>P&&{...P,arenaParticipants:C.map(j=>({kind:"key",value:j}))});},onSwitch:async C=>{let j=(await t.configure({model:C}))?.model??C;Pe(j),we(B=>B&&{...B,entries:B.entries.map(G=>({...G,active:G.key===C}))});},onSync:async()=>{let P=await(await import('../openrouter-sync-ARMVWY7S.js')).syncOpenRouterCatalog(),B=(await import('../openrouter-models-ZT4R2AE3.js')).getOpenRouterSnapshot();return we(G=>G&&{...G,snapshot:{count:B.count,fetchedAt:B.fetchedAt}}),P},onOpenFlow:()=>ot("flow"),onRefreshProvider:async C=>{try{let P=await t.query("provider_refresh",{key:C});return await on(),{count:P?.count??0,...P?.error?{error:P.error}:{}}}catch(P){return {count:0,error:P.message}}},onDeleteProvider:async C=>{try{return await t.query("provider_delete",{key:C}),await on(),{ok:!0}}catch(P){return {ok:false,error:P.message}}},onDeleteModel:async C=>{await t.query("model_delete",{key:C}),await on();},onClose:()=>we(null)}):re?jsx(Qg,{question:re.question,header:re.header,options:re.options,multiSelect:re.multiSelect,onAnswer:C=>{let{requestId:P}=re;rt(null),t.approve(P,{approved:true,answer:C}).catch(()=>{});},onCancel:()=>{let{requestId:C}=re;rt(null),t.approve(C,{approved:false,reason:"(user declined to answer)"}).catch(()=>{});}}):!Be&&jsx(ng,{value:g,onChange:y,onSubmit:ui,commands:Wr,placeholder:M?"Interrupt\u2026 (Ctrl+C to cancel)":void 0,disabled:R!==null,onArrowOut:C=>{if(C!=="down")return;let P=ss(a$3.getSnapshot(),Date.now());if(P.length!==0){if(D.kind==="agent"){let j=P.findIndex(B=>B.agentId===D.agentId);if(j>=0&&j<is){E(j+1);return}}E(0);}}}),jsx(u,{dim:true,children:Iu}),jsxs(S,{wrap:"truncate",children:[jsx(ZT,{mode:se}),ct==="transcript"&&jsx(u,{color:"ansi:magenta",children:" TRANSCRIPT "}),jsx(S,{flexGrow:1}),jsx(Cg,{model:Oe,effort:Ce,tokens:W,cost:pe,sessionId:L,baseContextTokens:q,maxContextTokens:i,isRunning:M,streamingTokensRef:U,runStartRef:$})]}),jsx(uh,{viewMode:D,focusedIndex:R})]});return jsx(lu.Provider,{value:m,children:jsx(Ag,{scrollable:ys,bottom:ty,overlay:Zh,newMessageCount:xe,showPill:Ne,onJumpToNew:Fe})})}a(jh,"App");function zT(t,e,n=false){let r=!!t.agentId;switch(t.type){case "user":return jsx(Kg,{text:t.text},e);case "assistant_text":return r?jsxs(S,{marginLeft:1,children:[jsx(u,{dim:true,children:"\u2502 \u23BF "}),jsx(gu,{text:t.text,streaming:t.streaming,nested:true})]},e):jsx(gu,{text:t.text,streaming:t.streaming},e);case "thinking":return r?jsxs(S,{marginLeft:1,children:[jsx(u,{dim:true,children:"\u2502 \u23BF "}),jsx(zg,{content:t.content,collapsed:!n,nested:true})]},e):null;case "tool_start":return jsx(ig,{toolName:t.toolName,args:t.args,nested:r},e);case "tool_running":return jsx(sg,{toolName:t.toolName,nested:r},e);case "tool_result":return jsx(ag,{toolName:t.toolName,result:t.result,error:t.error,nested:r,expanded:n},e);case "agent_start":return jsx(cg,{name:t.name,description:t.description,running:true},e);case "agent_end":return jsx(ug,{name:t.name,description:t.description,text:t.text,error:t.error},e);case "error":{let o=t.errorKind;return o==="rate_limit"?jsx(Vg,{text:t.error},e):o==="context_limit"?jsx(qg,{},e):jsxs(S,{marginLeft:r?1:0,children:[r&&jsx(u,{dim:true,children:"\u2502 \u23BF "}),jsx(Yg,{error:t.error,nested:r})]},e)}case "system":{let o=t;if(o.subtype==="compact_boundary")return jsx(S,{marginLeft:1,marginTop:1,children:jsx(u,{dim:true,children:o.text??"\u2500\u2500 context compacted \u2500\u2500"})},e);if(o.subtype==="memory_saved")return jsxs(S,{marginLeft:1,marginTop:1,children:[jsx(u,{color:"ansi:magenta",children:"\u2726 "}),jsx(u,{dim:true,children:o.text??"Memory saved"})]},e);if(o.subtype==="turn_duration")return jsx(S,{marginLeft:1,marginTop:1,children:jsx(u,{dim:true,children:o.text})},e);if(o.subtype==="bg_agent_notification"){let i=(o.text??"").split(`
383
- `);return jsx(S,{flexDirection:"column",marginLeft:1,marginTop:1,children:i.map((s,l)=>jsx(u,{dim:true,children:s},l))},e)}return jsx(S,{marginLeft:1,marginTop:1,children:jsx(u,{dim:true,children:o.text??""})},e)}case "status":return jsx(S,{marginLeft:1,marginTop:1,children:jsx(u,{dim:true,children:t.reason})},e)}}a(zT,"renderEntry");function JT(t,e){for(let n=t.length-1;n>=0;n--)if(e(t[n]))return n;return -1}a(JT,"findLastIndex");function XT(t){switch(t){case "aborted_streaming":case "aborted_tools":return "\u5DF2\u4E2D\u65AD";case "model_error":return "\u6A21\u578B\u8C03\u7528\u5931\u8D25 \u2014 \u68C0\u67E5\u7F51\u7EDC / API key / \u914D\u989D\u540E\u91CD\u8BD5";case "prompt_too_long":return "\u4E0A\u4E0B\u6587\u8D85\u957F \u2014 \u7528 /compact \u538B\u7F29,\u6216\u5F00\u65B0\u4F1A\u8BDD";case "max_turns":return "\u8FBE\u5230\u6700\u5927\u56DE\u5408\u6570 \u2014 \u53EF\u7EE7\u7EED\u8F93\u5165\u63A8\u8FDB";case "hook_stopped":case "stop_hook_prevented":return "\u88AB hook \u62E6\u622A \u2014 \u68C0\u67E5 settings.json \u4E2D\u7684 hook \u914D\u7F6E";case "image_error":return "\u56FE\u7247\u5904\u7406\u5931\u8D25";case "completed":return "";default:return t}}a(XT,"friendlyReason");function Uh(t){let e=t.toLowerCase();return e.includes("aborted")||e.includes("abort")?"\u5DF2\u4E2D\u65AD":e.includes("401")||e.includes("unauthorized")||e.includes("invalid api key")?"API key \u65E0\u6548\u6216\u5DF2\u8FC7\u671F \u2014 \u68C0\u67E5 /providers":e.includes("429")||e.includes("rate limit")||e.includes("quota")?"\u89E6\u53D1\u9650\u6D41 / \u914D\u989D\u8017\u5C3D \u2014 \u7A0D\u540E\u518D\u8BD5,\u6216\u5207\u6362\u6A21\u578B":e.includes("timeout")||e.includes("etimedout")||e.includes("econnreset")?"\u7F51\u7EDC\u8D85\u65F6 \u2014 \u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5":e.includes("enotfound")||e.includes("getaddrinfo")?"\u65E0\u6CD5\u89E3\u6790\u6A21\u578B\u670D\u52A1\u5730\u5740 \u2014 \u68C0\u67E5 DNS / \u4EE3\u7406\u8BBE\u7F6E":e.includes("context length")||e.includes("maximum context")||e.includes("too long")?"\u4E0A\u4E0B\u6587\u8D85\u957F \u2014 \u7528 /compact \u538B\u7F29,\u6216\u5F00\u65B0\u4F1A\u8BDD":t}a(Uh,"friendlyError");var QT={plan:{symbol:"\u23F5 ",title:"plan read-only",color:"ansi:yellow"},normal:{symbol:"\u23F5\u23F5 ",title:"auto-accept edits",color:"ansi:cyan"},bypass:{symbol:"\u23F5\u23F5\u23F5",title:"bypass permissions",color:"ansi:red"}};function ZT({mode:t}){let e=QT[t];return jsxs(S,{children:[jsx(u,{color:e.color,children:e.symbol}),jsx(u,{dim:true,children:" "+e.title+" "}),jsx(u,{dim:true,children:"(shift+tab)"})]})}a(ZT,"ModeIndicator");function eE(t){let e=t.toLowerCase();return e.includes("rate limit")||e.includes("429")||e.includes("too many requests")?"rate_limit":e.includes("context")&&(e.includes("limit")||e.includes("too long")||e.includes("too many tokens"))?"context_limit":e.includes("invalid")&&(e.includes("api key")||e.includes("api_key")||e.includes("authentication"))?"invalid_api_key":e.includes("timeout")||e.includes("timed out")?"api_timeout":e.includes("credit")||e.includes("balance")||e.includes("billing")?"credit_balance":"generic"}a(eE,"classifyError");h();h();var oE={autoAccept:"rgb(135,0,255)",bashBorder:"rgb(255,0,135)",claude:"rgb(215,119,87)",claudeShimmer:"rgb(245,149,117)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(87,105,247)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(117,135,255)",permission:"rgb(87,105,247)",permissionShimmer:"rgb(137,155,255)",planMode:"rgb(0,102,102)",ide:"rgb(71,130,200)",promptBorder:"rgb(153,153,153)",promptBorderShimmer:"rgb(183,183,183)",text:"rgb(0,0,0)",inverseText:"rgb(255,255,255)",inactive:"rgb(102,102,102)",inactiveShimmer:"rgb(142,142,142)",subtle:"rgb(175,175,175)",suggestion:"rgb(87,105,247)",remember:"rgb(0,0,255)",background:"rgb(0,153,153)",success:"rgb(44,122,57)",error:"rgb(171,43,63)",warning:"rgb(150,108,30)",merged:"rgb(135,0,255)",warningShimmer:"rgb(200,158,80)",diffAdded:"rgb(105,219,124)",diffRemoved:"rgb(255,168,180)",diffAddedDimmed:"rgb(199,225,203)",diffRemovedDimmed:"rgb(253,210,216)",diffAddedWord:"rgb(47,157,68)",diffRemovedWord:"rgb(209,69,75)",red_FOR_SUBAGENTS_ONLY:"rgb(220,38,38)",blue_FOR_SUBAGENTS_ONLY:"rgb(37,99,235)",green_FOR_SUBAGENTS_ONLY:"rgb(22,163,74)",yellow_FOR_SUBAGENTS_ONLY:"rgb(202,138,4)",purple_FOR_SUBAGENTS_ONLY:"rgb(147,51,234)",orange_FOR_SUBAGENTS_ONLY:"rgb(234,88,12)",pink_FOR_SUBAGENTS_ONLY:"rgb(219,39,119)",cyan_FOR_SUBAGENTS_ONLY:"rgb(8,145,178)",professionalBlue:"rgb(106,155,204)",chromeYellow:"rgb(251,188,4)",clawd_body:"rgb(215,119,87)",clawd_background:"rgb(0,0,0)",userMessageBackground:"rgb(240, 240, 240)",userMessageBackgroundHover:"rgb(252, 252, 252)",messageActionsBackground:"rgb(232, 236, 244)",selectionBg:"rgb(180, 213, 255)",bashMessageBackgroundColor:"rgb(250, 245, 250)",memoryBackgroundColor:"rgb(230, 245, 250)",rate_limit_fill:"rgb(87,105,247)",rate_limit_empty:"rgb(39,47,111)",fastMode:"rgb(255,106,0)",fastModeShimmer:"rgb(255,150,50)",briefLabelYou:"rgb(37,99,235)",briefLabelClaude:"rgb(215,119,87)",rainbow_red:"rgb(235,95,87)",rainbow_orange:"rgb(245,139,87)",rainbow_yellow:"rgb(250,195,95)",rainbow_green:"rgb(145,200,130)",rainbow_blue:"rgb(130,170,220)",rainbow_indigo:"rgb(155,130,200)",rainbow_violet:"rgb(200,130,180)",rainbow_red_shimmer:"rgb(250,155,147)",rainbow_orange_shimmer:"rgb(255,185,137)",rainbow_yellow_shimmer:"rgb(255,225,155)",rainbow_green_shimmer:"rgb(185,230,180)",rainbow_blue_shimmer:"rgb(180,205,240)",rainbow_indigo_shimmer:"rgb(195,180,230)",rainbow_violet_shimmer:"rgb(230,180,210)"},iE={autoAccept:"ansi:magenta",bashBorder:"ansi:magenta",claude:"ansi:redBright",claudeShimmer:"ansi:yellowBright",claudeBlue_FOR_SYSTEM_SPINNER:"ansi:blue",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"ansi:blueBright",permission:"ansi:blue",permissionShimmer:"ansi:blueBright",planMode:"ansi:cyan",ide:"ansi:blueBright",promptBorder:"ansi:white",promptBorderShimmer:"ansi:whiteBright",text:"ansi:black",inverseText:"ansi:white",inactive:"ansi:blackBright",inactiveShimmer:"ansi:white",subtle:"ansi:blackBright",suggestion:"ansi:blue",remember:"ansi:blue",background:"ansi:cyan",success:"ansi:green",error:"ansi:red",warning:"ansi:yellow",merged:"ansi:magenta",warningShimmer:"ansi:yellowBright",diffAdded:"ansi:green",diffRemoved:"ansi:red",diffAddedDimmed:"ansi:green",diffRemovedDimmed:"ansi:red",diffAddedWord:"ansi:greenBright",diffRemovedWord:"ansi:redBright",red_FOR_SUBAGENTS_ONLY:"ansi:red",blue_FOR_SUBAGENTS_ONLY:"ansi:blue",green_FOR_SUBAGENTS_ONLY:"ansi:green",yellow_FOR_SUBAGENTS_ONLY:"ansi:yellow",purple_FOR_SUBAGENTS_ONLY:"ansi:magenta",orange_FOR_SUBAGENTS_ONLY:"ansi:redBright",pink_FOR_SUBAGENTS_ONLY:"ansi:magentaBright",cyan_FOR_SUBAGENTS_ONLY:"ansi:cyan",professionalBlue:"ansi:blueBright",chromeYellow:"ansi:yellow",clawd_body:"ansi:redBright",clawd_background:"ansi:black",userMessageBackground:"ansi:white",userMessageBackgroundHover:"ansi:whiteBright",messageActionsBackground:"ansi:white",selectionBg:"ansi:cyan",bashMessageBackgroundColor:"ansi:whiteBright",memoryBackgroundColor:"ansi:white",rate_limit_fill:"ansi:yellow",rate_limit_empty:"ansi:black",fastMode:"ansi:red",fastModeShimmer:"ansi:redBright",briefLabelYou:"ansi:blue",briefLabelClaude:"ansi:redBright",rainbow_red:"ansi:red",rainbow_orange:"ansi:redBright",rainbow_yellow:"ansi:yellow",rainbow_green:"ansi:green",rainbow_blue:"ansi:cyan",rainbow_indigo:"ansi:blue",rainbow_violet:"ansi:magenta",rainbow_red_shimmer:"ansi:redBright",rainbow_orange_shimmer:"ansi:yellow",rainbow_yellow_shimmer:"ansi:yellowBright",rainbow_green_shimmer:"ansi:greenBright",rainbow_blue_shimmer:"ansi:cyanBright",rainbow_indigo_shimmer:"ansi:blueBright",rainbow_violet_shimmer:"ansi:magentaBright"},sE={autoAccept:"ansi:magentaBright",bashBorder:"ansi:magentaBright",claude:"ansi:redBright",claudeShimmer:"ansi:yellowBright",claudeBlue_FOR_SYSTEM_SPINNER:"ansi:blueBright",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"ansi:blueBright",permission:"ansi:blueBright",permissionShimmer:"ansi:blueBright",planMode:"ansi:cyanBright",ide:"ansi:blue",promptBorder:"ansi:white",promptBorderShimmer:"ansi:whiteBright",text:"ansi:whiteBright",inverseText:"ansi:black",inactive:"ansi:white",inactiveShimmer:"ansi:whiteBright",subtle:"ansi:white",suggestion:"ansi:blueBright",remember:"ansi:blueBright",background:"ansi:cyanBright",success:"ansi:greenBright",error:"ansi:redBright",warning:"ansi:yellowBright",merged:"ansi:magentaBright",warningShimmer:"ansi:yellowBright",diffAdded:"ansi:green",diffRemoved:"ansi:red",diffAddedDimmed:"ansi:green",diffRemovedDimmed:"ansi:red",diffAddedWord:"ansi:greenBright",diffRemovedWord:"ansi:redBright",red_FOR_SUBAGENTS_ONLY:"ansi:redBright",blue_FOR_SUBAGENTS_ONLY:"ansi:blueBright",green_FOR_SUBAGENTS_ONLY:"ansi:greenBright",yellow_FOR_SUBAGENTS_ONLY:"ansi:yellowBright",purple_FOR_SUBAGENTS_ONLY:"ansi:magentaBright",orange_FOR_SUBAGENTS_ONLY:"ansi:redBright",pink_FOR_SUBAGENTS_ONLY:"ansi:magentaBright",cyan_FOR_SUBAGENTS_ONLY:"ansi:cyanBright",professionalBlue:"rgb(106,155,204)",chromeYellow:"ansi:yellowBright",clawd_body:"ansi:redBright",clawd_background:"ansi:black",userMessageBackground:"ansi:blackBright",userMessageBackgroundHover:"ansi:white",messageActionsBackground:"ansi:blackBright",selectionBg:"ansi:blue",bashMessageBackgroundColor:"ansi:black",memoryBackgroundColor:"ansi:blackBright",rate_limit_fill:"ansi:yellow",rate_limit_empty:"ansi:white",fastMode:"ansi:redBright",fastModeShimmer:"ansi:redBright",briefLabelYou:"ansi:blueBright",briefLabelClaude:"ansi:redBright",rainbow_red:"ansi:red",rainbow_orange:"ansi:redBright",rainbow_yellow:"ansi:yellow",rainbow_green:"ansi:green",rainbow_blue:"ansi:cyan",rainbow_indigo:"ansi:blue",rainbow_violet:"ansi:magenta",rainbow_red_shimmer:"ansi:redBright",rainbow_orange_shimmer:"ansi:yellow",rainbow_yellow_shimmer:"ansi:yellowBright",rainbow_green_shimmer:"ansi:greenBright",rainbow_blue_shimmer:"ansi:cyanBright",rainbow_indigo_shimmer:"ansi:blueBright",rainbow_violet_shimmer:"ansi:magentaBright"},aE={autoAccept:"rgb(135,0,255)",bashBorder:"rgb(0,102,204)",claude:"rgb(255,153,51)",claudeShimmer:"rgb(255,183,101)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(51,102,255)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(101,152,255)",permission:"rgb(51,102,255)",permissionShimmer:"rgb(101,152,255)",planMode:"rgb(51,102,102)",ide:"rgb(71,130,200)",promptBorder:"rgb(153,153,153)",promptBorderShimmer:"rgb(183,183,183)",text:"rgb(0,0,0)",inverseText:"rgb(255,255,255)",inactive:"rgb(102,102,102)",inactiveShimmer:"rgb(142,142,142)",subtle:"rgb(175,175,175)",suggestion:"rgb(51,102,255)",remember:"rgb(51,102,255)",background:"rgb(0,153,153)",success:"rgb(0,102,153)",error:"rgb(204,0,0)",warning:"rgb(255,153,0)",merged:"rgb(135,0,255)",warningShimmer:"rgb(255,183,50)",diffAdded:"rgb(153,204,255)",diffRemoved:"rgb(255,204,204)",diffAddedDimmed:"rgb(209,231,253)",diffRemovedDimmed:"rgb(255,233,233)",diffAddedWord:"rgb(51,102,204)",diffRemovedWord:"rgb(153,51,51)",red_FOR_SUBAGENTS_ONLY:"rgb(204,0,0)",blue_FOR_SUBAGENTS_ONLY:"rgb(0,102,204)",green_FOR_SUBAGENTS_ONLY:"rgb(0,204,0)",yellow_FOR_SUBAGENTS_ONLY:"rgb(255,204,0)",purple_FOR_SUBAGENTS_ONLY:"rgb(128,0,128)",orange_FOR_SUBAGENTS_ONLY:"rgb(255,128,0)",pink_FOR_SUBAGENTS_ONLY:"rgb(255,102,178)",cyan_FOR_SUBAGENTS_ONLY:"rgb(0,178,178)",professionalBlue:"rgb(106,155,204)",chromeYellow:"rgb(251,188,4)",clawd_body:"rgb(215,119,87)",clawd_background:"rgb(0,0,0)",userMessageBackground:"rgb(220, 220, 220)",userMessageBackgroundHover:"rgb(232, 232, 232)",messageActionsBackground:"rgb(210, 216, 226)",selectionBg:"rgb(180, 213, 255)",bashMessageBackgroundColor:"rgb(250, 245, 250)",memoryBackgroundColor:"rgb(230, 245, 250)",rate_limit_fill:"rgb(51,102,255)",rate_limit_empty:"rgb(23,46,114)",fastMode:"rgb(255,106,0)",fastModeShimmer:"rgb(255,150,50)",briefLabelYou:"rgb(37,99,235)",briefLabelClaude:"rgb(255,153,51)",rainbow_red:"rgb(235,95,87)",rainbow_orange:"rgb(245,139,87)",rainbow_yellow:"rgb(250,195,95)",rainbow_green:"rgb(145,200,130)",rainbow_blue:"rgb(130,170,220)",rainbow_indigo:"rgb(155,130,200)",rainbow_violet:"rgb(200,130,180)",rainbow_red_shimmer:"rgb(250,155,147)",rainbow_orange_shimmer:"rgb(255,185,137)",rainbow_yellow_shimmer:"rgb(255,225,155)",rainbow_green_shimmer:"rgb(185,230,180)",rainbow_blue_shimmer:"rgb(180,205,240)",rainbow_indigo_shimmer:"rgb(195,180,230)",rainbow_violet_shimmer:"rgb(230,180,210)"},lE={autoAccept:"rgb(175,135,255)",bashBorder:"rgb(253,93,177)",claude:"rgb(215,119,87)",claudeShimmer:"rgb(235,159,127)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(147,165,255)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(177,195,255)",permission:"rgb(177,185,249)",permissionShimmer:"rgb(207,215,255)",planMode:"rgb(72,150,140)",ide:"rgb(71,130,200)",promptBorder:"rgb(136,136,136)",promptBorderShimmer:"rgb(166,166,166)",text:"rgb(255,255,255)",inverseText:"rgb(0,0,0)",inactive:"rgb(153,153,153)",inactiveShimmer:"rgb(193,193,193)",subtle:"rgb(80,80,80)",suggestion:"rgb(177,185,249)",remember:"rgb(177,185,249)",background:"rgb(0,204,204)",success:"rgb(78,186,101)",error:"rgb(255,107,128)",warning:"rgb(255,193,7)",merged:"rgb(175,135,255)",warningShimmer:"rgb(255,223,57)",diffAdded:"rgb(34,92,43)",diffRemoved:"rgb(122,41,54)",diffAddedDimmed:"rgb(71,88,74)",diffRemovedDimmed:"rgb(105,72,77)",diffAddedWord:"rgb(56,166,96)",diffRemovedWord:"rgb(179,89,107)",red_FOR_SUBAGENTS_ONLY:"rgb(220,38,38)",blue_FOR_SUBAGENTS_ONLY:"rgb(37,99,235)",green_FOR_SUBAGENTS_ONLY:"rgb(22,163,74)",yellow_FOR_SUBAGENTS_ONLY:"rgb(202,138,4)",purple_FOR_SUBAGENTS_ONLY:"rgb(147,51,234)",orange_FOR_SUBAGENTS_ONLY:"rgb(234,88,12)",pink_FOR_SUBAGENTS_ONLY:"rgb(219,39,119)",cyan_FOR_SUBAGENTS_ONLY:"rgb(8,145,178)",professionalBlue:"rgb(106,155,204)",chromeYellow:"rgb(251,188,4)",clawd_body:"rgb(215,119,87)",clawd_background:"rgb(0,0,0)",userMessageBackground:"rgb(55, 55, 55)",userMessageBackgroundHover:"rgb(70, 70, 70)",messageActionsBackground:"rgb(44, 50, 62)",selectionBg:"rgb(38, 79, 120)",bashMessageBackgroundColor:"rgb(65, 60, 65)",memoryBackgroundColor:"rgb(55, 65, 70)",rate_limit_fill:"rgb(177,185,249)",rate_limit_empty:"rgb(80,83,112)",fastMode:"rgb(255,120,20)",fastModeShimmer:"rgb(255,165,70)",briefLabelYou:"rgb(122,180,232)",briefLabelClaude:"rgb(215,119,87)",rainbow_red:"rgb(235,95,87)",rainbow_orange:"rgb(245,139,87)",rainbow_yellow:"rgb(250,195,95)",rainbow_green:"rgb(145,200,130)",rainbow_blue:"rgb(130,170,220)",rainbow_indigo:"rgb(155,130,200)",rainbow_violet:"rgb(200,130,180)",rainbow_red_shimmer:"rgb(250,155,147)",rainbow_orange_shimmer:"rgb(255,185,137)",rainbow_yellow_shimmer:"rgb(255,225,155)",rainbow_green_shimmer:"rgb(185,230,180)",rainbow_blue_shimmer:"rgb(180,205,240)",rainbow_indigo_shimmer:"rgb(195,180,230)",rainbow_violet_shimmer:"rgb(230,180,210)"},cE={autoAccept:"rgb(175,135,255)",bashBorder:"rgb(51,153,255)",claude:"rgb(255,153,51)",claudeShimmer:"rgb(255,183,101)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(153,204,255)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(183,224,255)",permission:"rgb(153,204,255)",permissionShimmer:"rgb(183,224,255)",planMode:"rgb(102,153,153)",ide:"rgb(71,130,200)",promptBorder:"rgb(136,136,136)",promptBorderShimmer:"rgb(166,166,166)",text:"rgb(255,255,255)",inverseText:"rgb(0,0,0)",inactive:"rgb(153,153,153)",inactiveShimmer:"rgb(193,193,193)",subtle:"rgb(80,80,80)",suggestion:"rgb(153,204,255)",remember:"rgb(153,204,255)",background:"rgb(0,204,204)",success:"rgb(51,153,255)",error:"rgb(255,102,102)",warning:"rgb(255,204,0)",merged:"rgb(175,135,255)",warningShimmer:"rgb(255,234,50)",diffAdded:"rgb(0,68,102)",diffRemoved:"rgb(102,0,0)",diffAddedDimmed:"rgb(62,81,91)",diffRemovedDimmed:"rgb(62,44,44)",diffAddedWord:"rgb(0,119,179)",diffRemovedWord:"rgb(179,0,0)",red_FOR_SUBAGENTS_ONLY:"rgb(255,102,102)",blue_FOR_SUBAGENTS_ONLY:"rgb(102,178,255)",green_FOR_SUBAGENTS_ONLY:"rgb(102,255,102)",yellow_FOR_SUBAGENTS_ONLY:"rgb(255,255,102)",purple_FOR_SUBAGENTS_ONLY:"rgb(178,102,255)",orange_FOR_SUBAGENTS_ONLY:"rgb(255,178,102)",pink_FOR_SUBAGENTS_ONLY:"rgb(255,153,204)",cyan_FOR_SUBAGENTS_ONLY:"rgb(102,204,204)",professionalBlue:"rgb(106,155,204)",chromeYellow:"rgb(251,188,4)",clawd_body:"rgb(215,119,87)",clawd_background:"rgb(0,0,0)",userMessageBackground:"rgb(55, 55, 55)",userMessageBackgroundHover:"rgb(70, 70, 70)",messageActionsBackground:"rgb(44, 50, 62)",selectionBg:"rgb(38, 79, 120)",bashMessageBackgroundColor:"rgb(65, 60, 65)",memoryBackgroundColor:"rgb(55, 65, 70)",rate_limit_fill:"rgb(153,204,255)",rate_limit_empty:"rgb(69,92,115)",fastMode:"rgb(255,120,20)",fastModeShimmer:"rgb(255,165,70)",briefLabelYou:"rgb(122,180,232)",briefLabelClaude:"rgb(255,153,51)",rainbow_red:"rgb(235,95,87)",rainbow_orange:"rgb(245,139,87)",rainbow_yellow:"rgb(250,195,95)",rainbow_green:"rgb(145,200,130)",rainbow_blue:"rgb(130,170,220)",rainbow_indigo:"rgb(155,130,200)",rainbow_violet:"rgb(200,130,180)",rainbow_red_shimmer:"rgb(250,155,147)",rainbow_orange_shimmer:"rgb(255,185,137)",rainbow_yellow_shimmer:"rgb(255,225,155)",rainbow_green_shimmer:"rgb(185,230,180)",rainbow_blue_shimmer:"rgb(180,205,240)",rainbow_indigo_shimmer:"rgb(195,180,230)",rainbow_violet_shimmer:"rgb(230,180,210)"};function za(t){switch(t){case "light":return oE;case "light-ansi":return iE;case "dark-ansi":return sE;case "light-daltonized":return aE;case "dark-daltonized":return cE;default:return lE}}a(za,"getTheme");Do.terminal==="Apple_Terminal"?new Chalk({level:2}):te;h();var Au;function uE(){return Au===void 0&&(Au=dE()??"dark"),Au}a(uE,"getSystemThemeName");function Nu(t){return t==="auto"?uE():t}a(Nu,"resolveThemeSetting");function dE(){let t=process.env.COLORFGBG;if(!t)return;let e=t.split(";"),n=e[e.length-1];if(n===void 0||n==="")return;let r=Number(n);if(!(!Number.isInteger(r)||r<0||r>15))return r<=6||r===8?"dark":"light"}a(dE,"detectFromColorFgBg");var hE=createContext({themeName:"dark",theme:za("dark"),themeSetting:"auto",setThemeSetting:a(()=>{},"setThemeSetting")});function Ja({children:t,initialSetting:e="auto"}){let[n,r]=useState(e),o=Nu(n),i=za(o),s=useMemo(()=>({themeName:o,theme:i,themeSetting:n,setThemeSetting:r}),[o,i,n]);return createElement(hE.Provider,{value:s},t)}a(Ja,"ThemeProvider");h();function Kh(){let t=process.env.CODESHELL_DEV_SEED_TRANSCRIPT;if(!t)return;let e=Number(t);if(!Number.isFinite(e)||e<=0)return;let n=[];for(let r=0;r<e;r++)r%2===0?n.push(ii({type:"user",text:`[seed ${r}] ${"lorem ipsum ".repeat(r*7%5+1)}`})):n.push(ii({type:"assistant_text",text:`[seed ${r}] ${"lorem ipsum ".repeat(r*7%5+1)}`,streaming:false}));be.setEntries(n);}a(Kh,"applyDevSeed");async function Vh(t){let e=t.sessionId??`session-${Date.now()}`;if(Jp(e,t.cwd),Kh(),d.setSid(e),process.env.CODESHELL_NO_MODEL_SYNC!=="1"){let o=b$5();(o.fetchedAt?Date.now()-new Date(o.fetchedAt).getTime():1/0)>1440*60*1e3&&a$5().catch(()=>{});}let n=setInterval(()=>{},2147483647),r=await Gi(jsx(Ja,{children:jsx(jh,{client:t.client,model:t.model,effort:t.effort,maxTurns:t.maxTurns,cwd:t.cwd,maxContextTokens:t.maxContextTokens,sessionId:t.sessionId,prefill:t.prefill})}),{stdout:process.stdout,stdin:process.stdin,stderr:process.stderr,exitOnCtrlC:true,patchConsole:false,onFrame:a(o=>{let i=o.phases;vg({durationMs:o.durationMs,phases:{diff:i?.diff??0,write:i?.write??0,yoga:i?.yoga??0,patches:i?.patches??0}}),b$6.recordFrame(o);},"onFrame")});await r.waitUntilExit(),clearInterval(n),eg(),r.cleanup(),process.exit(0);}a(Vh,"startInkRepl");h();async function zh(){let t=setInterval(()=>{},2147483647);return new Promise(e=>{let n,r=false,o=a(i=>{if(!r){r=true,clearInterval(t);try{n.unmount();}catch{}try{n.cleanup();}catch{}e(i);}},"finish");Gi(jsx(Ja,{children:jsx(Ua,{onComplete:i=>o(i),onCancel:()=>o(null)})}),{stdout:process.stdout,stdin:process.stdin,stderr:process.stderr,exitOnCtrlC:true,patchConsole:false}).then(i=>{n=i;});})}a(zh,"runInkOnboarding");function yE(t){switch(t){case "low":return {temperature:.1,maxTokens:4096};case "medium":return {temperature:.3,maxTokens:8192};case "high":return {temperature:.5,maxTokens:16384};case "max":return {temperature:.7,maxTokens:32768}}}a(yE,"getEffortConfig");async function Ou(t){let e=process.cwd(),n=new c$1(e).get(),o=!!t.apiKey||!!n.model?.apiKey||Array.isArray(n.models)&&n.models.some(T=>T?.apiKey)||Array.isArray(n.providers)&&n.providers.some(T=>T?.apiKey)?O$1(t.apiKey,n.model.apiKey):void 0,i=t.model??n.model.name,s=t.provider??n.model.provider,l$1=t.baseUrl??n.model.baseUrl;if(!o){process.stdin.isTTY||(console.error(te.red("Error: No API key configured and stdin is not a TTY. Set --api-key, OPENROUTER_API_KEY, or run interactively to onboard.")),process.exit(1));let T=await zh();T||(console.error(te.yellow("Onboarding cancelled.")),process.exit(1)),o=T.apiKey,s=T.provider,i=T.model,l$1=T.baseUrl,n=new c$1(e).get();}i=i??"anthropic/claude-opus-4-6",s=s??"openai",l$1=l$1??"https://openrouter.ai/api/v1";let c=t.effort??"high",d=yE(c),f=t.maxTurns??100,m={provider:s,model:i,apiKey:o,baseUrl:l$1,temperature:d.temperature??n.model.temperature??.3,maxTokens:n.model.maxTokens??d.maxTokens??8192,enableStreaming:true},g=t.permissionMode??"acceptEdits",y=n.context.maxTokens??2e5,w=new R({llm:m,cwd:e,preset:t.preset??n.agent.preset,enabledBuiltinTools:n.agent.enabledBuiltinTools,disabledBuiltinTools:n.agent.disabledBuiltinTools,permissionMode:g,customSystemPrompt:n.agent.customSystemPrompt,appendSystemPrompt:n.agent.appendSystemPrompt,maxTurns:f,maxContextTokens:y,sessionStorageDir:n.session.storageDir,costStore:yt,mcpServers:n.mcpServers,approvalBackend:l()}),[x,v]=da$1();new ba$1({engine:w,transport:x});let h=new ca$1({transport:v});await Vh({client:h,model:i,effort:c,maxTurns:f,cwd:e,maxContextTokens:w.maxContextTokens,sessionId:t.resume,prefill:t.prefill});}a(Ou,"replCommand");h();async function Xh(t){let{cwd:e,permissionMode:n}=t;e$2(),d.info("setup.start",{cwd:e,permissionMode:n,level:d.getMinLevel()});let r=process.version.match(/^v(\d+)\./)?.[1];(!r||parseInt(r)<18)&&(console.error(te.bold.red("Error: Code Shell requires Node.js version 18 or higher.")),process.exit(1));try{let{statSync:o}=await import('fs');if(!o(e).isDirectory())throw new Error("not a directory")}catch{console.error(te.red(`Error: Working directory does not exist: ${e}`)),process.exit(1);}n==="bypassPermissions"&&process.platform!=="win32"&&typeof process.getuid=="function"&&process.getuid()===0&&process.env.IS_SANDBOX!=="1"&&(console.error(te.red("bypassPermissions cannot be used with root/sudo privileges for security reasons.")),process.exit(1)),process.cwd()!==e&&process.chdir(e);try{let{execSync:o}=await import('child_process');o("git rev-parse --is-inside-work-tree",{cwd:e,stdio:"ignore"});}catch{}}a(Xh,"setup");h();function po(){let t=process.cwd(),e=new c$1(t).get(),n=O$1(void 0,e.model.apiKey),r={provider:e.model.provider??"openai",model:e.model.name??"anthropic/claude-opus-4-6",apiKey:n,baseUrl:e.model.baseUrl??"https://openrouter.ai/api/v1",temperature:e.model.temperature,maxTokens:e.model.maxTokens??8192,enableStreaming:true},o=new T;return new ga$1({store:o,executor:{llm:r,maxTurns:30,maxContextTokens:e.context.maxTokens,sessionStorageDir:e.session.storageDir,permissionMode:e.permissions.defaultMode??"acceptEdits",mcpServers:e.mcpServers}})}a(po,"createRunManager");function Xa(t){return t?new Date(t).toLocaleString():"\u2014"}a(Xa,"formatDate");function Qa(t){return `${{queued:"[ ]",running:"[>]",waiting_input:"[?]",waiting_approval:"[!]",blocked:"[x]",completed:"[+]",failed:"[-]",cancelled:"[~]"}[t]} ${t}`}a(Qa,"formatStatus");function Qh(){let t=new Command("runs").description("Manage long-running agent tasks");return t.command("list").description("List recent runs").option("-n, --limit <n>","Number of runs to show","20").option("-s, --status <status>","Filter by status (queued, running, completed, etc.)").option("-t, --tag <tag>","Filter by tag").action(async e=>{let r=await po().list({limit:parseInt(e.limit),status:e.status,tag:e.tag});if(r.length===0){console.log("No runs found.");return}console.log(`
384
- ${"ID".padEnd(18)} ${"Status".padEnd(22)} ${"Created".padEnd(22)} Objective`),console.log(" "+"\u2500".repeat(90));for(let o of r){let i=o.runId.slice(0,16),s=Qa(o.status),l=Xa(o.createdAt),c=o.objective.slice(0,40).replace(/\n/g," ");console.log(` ${i.padEnd(18)} ${s.padEnd(22)} ${l.padEnd(22)} ${c}`);}console.log();}),t.command("get").description("Inspect a run").argument("<runId>","Run ID").action(async e=>{let r=await po().get(e);r||(console.error(`Run not found: ${e}`),process.exit(1)),console.log(`
385
- Run: ${r.runId}
386
- Status: ${Qa(r.status)}
387
- Objective: ${r.objective.slice(0,100)}
388
- Preset: ${r.preset}
389
- CWD: ${r.cwd}
390
- Created: ${Xa(r.createdAt)}
391
- Started: ${Xa(r.startedAt)}
392
- Finished: ${Xa(r.finishedAt)}
393
- Attempts: ${r.attemptCount}
394
- Session: ${r.sessionId??"\u2014"}
395
- Tags: ${r.tags.length>0?r.tags.join(", "):"\u2014"}
396
- Summary: ${r.summary??"\u2014"}
397
- Error: ${r.error??"\u2014"}
398
- `);}),t.command("submit").description("Submit a new managed run").argument("<objective>","Task objective").option("--preset <preset>","Agent preset").option("--tag <tags>","Comma-separated tags").action(async(e,n)=>{let r=po(),o=n.tag?n.tag.split(",").map(l=>l.trim()):[],i=await r.submit({objective:e,preset:n.preset,tags:o});console.log(`
399
- Run submitted: ${i.runId}`),console.log(` Status: ${Qa(i.status)}`),console.log(` Objective: ${i.objective.slice(0,80)}
400
- `),console.log(` Streaming output...
401
- `);let s=r.attach(i.runId,l=>{if(l.type==="engine_stream"){let c=l.event;c.type==="text_delta"?process.stdout.write(c.text):c.type==="tool_use_start"&&console.log(`
402
- [tool] ${c.toolCall.toolName}`);}else if(l.type==="run_status_changed"){let c=l.run.status;c==="completed"||c==="failed"||c==="cancelled"?(console.log(`
403
-
404
- Run ${c}: ${l.run.runId}`),l.run.error&&console.log(` Error: ${l.run.error}`),s()):(c==="waiting_input"||c==="waiting_approval")&&(console.log(`
405
-
406
- Run paused: ${c}`),console.log(` Use: code-shell runs resume ${l.run.runId}`),s());}});}),t.command("resume").description("Resume a waiting or blocked run").argument("<runId>","Run ID").option("--input <text>","User input to provide").option("--approve","Approve pending approval").option("--reject","Reject pending approval").action(async(e,n)=>{let r=po();await r.get(e)||(console.error(`Run not found: ${e}`),process.exit(1));let i=new T,s;if(n.approve||n.reject){let l=await i.getPendingApproval(e);l||(console.error("No pending approval found for this run."),process.exit(1)),s={approvalId:l.approvalId,approved:!!n.approve,reason:n.reject?"rejected by user":void 0};}await r.resume(e,{userInput:n.input,approvalDecision:s}),console.log(`
407
- Run resumed: ${e}
408
- `);}),t.command("cancel").description("Cancel a run").argument("<runId>","Run ID").option("--reason <text>","Cancellation reason").action(async(e,n)=>{let r=po();try{await r.cancel(e,n.reason),console.log(`
409
- Run cancelled: ${e}
410
- `);}catch(o){console.error(`Error: ${o.message}`),process.exit(1);}}),t.command("events").description("View run event log").argument("<runId>","Run ID").option("-n, --limit <n>","Number of events to show","50").action(async(e,n)=>{let o=await po().getEvents(e);if(o.length===0){console.log("No events found.");return}let i=parseInt(n.limit),s=o.slice(-i);console.log(`
411
- Events for run ${e} (showing last ${s.length} of ${o.length}):
412
- `);for(let l of s){let c=new Date(l.timestamp).toLocaleTimeString(),d=Object.keys(l.data).length>0?" "+JSON.stringify(l.data).slice(0,80):"";console.log(` ${c} ${l.type}${d}`);}console.log();}),t.command("recover").description("Recover crashed runs (run on startup)").action(async()=>{let e=po(),n=await e.recover();if(n.length===0)console.log("No crashed runs found.");else {console.log(`
413
- Recovered ${n.length} run(s):`);for(let r of n){let o=await e.get(r);console.log(` ${r} ${Qa(o?.status??"blocked")}`);}console.log();}}),t}a(Qh,"createRunsCommand");function SE(t){switch(t){case "completed":return "done";case "aborted_streaming":case "aborted_tools":return "aborted";case "prompt_too_long":return "ptl";case "model_error":case "image_error":return "error";case "stop_hook_prevented":case "hook_stopped":return "hook_stop";default:return t}}a(SE,"formatSessionStatus");var kr=new Command;kr.name("code-shell").description("Code Shell \u2014 general orchestration framework with a terminal coding assistant preset").version(e());function Du(t){return t.option("-m, --model <model>","Model name (e.g. anthropic/claude-opus-4-6)").option("-p, --provider <provider>","LLM provider (anthropic, openai)","openai").option("--preset <preset>","Agent preset (general, terminal-coding)").option("--base-url <url>","LLM API base URL (e.g. https://openrouter.ai/api/v1)").option("--api-key <key>","API key (or set OPENROUTER_API_KEY / ANTHROPIC_API_KEY env var)").option("--permission-mode <mode>","Permission mode (default, acceptEdits, bypassPermissions)").option("-o, --output <format>","Output format (text, json, jsonl, stream-json)","text").option("--max-turns <n>","Maximum turns","100").option("--effort <level>","Reasoning effort (low, medium, high, max)","high")}a(Du,"addCommonOptions");Du(kr.command("run").description("Execute a single task (headless mode)").argument("<task>","The task to execute")).option("--resume <sessionId>","Resume a previous session").action(async(t,e)=>{await cl({task:t,...Za(e)});});Du(kr.command("repl").description("Interactive REPL mode (default)")).action(async t=>{await Ou(Za(t));});kr.command("sessions").description("List recent sessions").option("-n, --limit <n>","Number of sessions to show","10").action(async t=>{let{SessionManager:e}=await import('../session-manager-AGWS5SMJ.js'),r=new e().list(parseInt(t.limit));if(r.length===0){console.log("No sessions found.");return}for(let o of r){let i=new Date(o.startedAt).toLocaleString(),s=SE(o.status);console.log(` ${o.sessionId} ${i} ${s} ${o.model} turns:${o.turnCount}`);}});Du(kr.command("arena").description("Multi-model review arena \u2014 agent gathers context, multiple models discuss").argument("<topic>","What to review (agent will find relevant code)").option("--models <models>","Models to use (e.g. claude,gpt4o,deepseek)").option("--mode <mode>","Arena mode: review, discussion, or planning (auto-detected if omitted)")).action(async(t,e)=>{let n=Za(e),{runArenaReview:r}=await import('../arena-MRBATZFD.js'),{SettingsManager:o}=await import('../manager-4XKLZHKE.js'),i=new o(process.cwd()).get(),s=O$1(n.apiKey,i.model.apiKey);s||(console.error("Error: No API key provided."),process.exit(1));let l=t;e.models&&(l=`--models ${e.models} ${l}`),e.mode&&(l=`--mode ${e.mode} ${l}`),await r(l,{llm:{provider:n.provider??i.model.provider??"openai",model:n.model??i.model.name??"anthropic/claude-opus-4-6",apiKey:s,baseUrl:n.baseUrl??i.model.baseUrl??"https://openrouter.ai/api/v1",temperature:.3,enableStreaming:false}});});kr.addCommand(Qh());kr.argument("[task]","Task to execute (or omit for REPL mode)").option("-m, --model <model>","Model name (e.g. anthropic/claude-opus-4-6)").option("-p, --provider <provider>","LLM provider (anthropic, openai)","openai").option("--preset <preset>","Agent preset (general, terminal-coding)").option("--base-url <url>","LLM API base URL (e.g. https://openrouter.ai/api/v1)").option("--api-key <key>","API key (or set OPENROUTER_API_KEY / ANTHROPIC_API_KEY env var)").option("--permission-mode <mode>","Permission mode (default, acceptEdits, bypassPermissions)").option("-o, --output <format>","Output format (text, json, jsonl, stream-json)","text").option("--max-turns <n>","Maximum turns","100").option("--effort <level>","Reasoning effort (low, medium, high, max)","high").option("--resume <sessionId>","Resume a previous session").option("--prefill <text>","Pre-fill the input box without submitting").passThroughOptions().action(async(t,e)=>{let n=Za(e);t?await cl({task:t,...n}):await Ou({...n,prefill:e.prefill});});function Za(t){return {model:t.model,provider:t.provider,preset:t.preset,baseUrl:t.baseUrl,apiKey:t.apiKey,permissionMode:t.permissionMode,output:t.output,maxTurns:t.maxTurns?parseInt(t.maxTurns):void 0,resume:t.resume,effort:t.effort}}a(Za,"resolveOpts");kr.hook("preAction",async t=>{let e=t.opts();await Xh({cwd:process.cwd(),permissionMode:e.permissionMode??"acceptEdits"});});process.on("exit",()=>{yt.getTotalTokens().total>0&&process.stdout.write(`
414
- `+yt.formatSummary()+`
415
- `);});await gd();kr.parse();