@wrongstack/core 0.313.0 → 0.316.1

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 (343) hide show
  1. package/dist/chronicle/index.js +84 -6391
  2. package/dist/chronicle/legacy-journal-import.d.ts +0 -6
  3. package/dist/chronicle/metrics-ingest.d.ts +14 -0
  4. package/dist/chronicle/metrics-schema.d.ts +10 -1
  5. package/dist/chronicle/metrics-store.d.ts +20 -2
  6. package/dist/chronicle/project-server.js +98 -4874
  7. package/dist/chronicle/sink.d.ts +13 -0
  8. package/dist/chronicle/sqlite-journal.d.ts +20 -2
  9. package/dist/chunk-25LSLC3G.js +334 -0
  10. package/dist/chunk-27QIURLN.js +1073 -0
  11. package/dist/chunk-2FK4WTFF.js +207 -0
  12. package/dist/chunk-2YU4WVBW.js +134 -0
  13. package/dist/chunk-3AGWVSS7.js +4608 -0
  14. package/dist/chunk-3BDV7RL3.js +211 -0
  15. package/dist/chunk-3ECENVHL.js +325 -0
  16. package/dist/chunk-3XPVB7BA.js +135 -0
  17. package/dist/chunk-45WI72ZB.js +16884 -0
  18. package/dist/chunk-4BMVPOHO.js +3748 -0
  19. package/dist/chunk-4I7HGVVA.js +363 -0
  20. package/dist/chunk-4LCZVJVF.js +317 -0
  21. package/dist/chunk-4SJNS7OB.js +217 -0
  22. package/dist/chunk-4VWO3ZXL.js +342 -0
  23. package/dist/chunk-57GEWK5X.js +26 -0
  24. package/dist/chunk-5BMIE7QG.js +46 -0
  25. package/dist/chunk-5S437PRC.js +50 -0
  26. package/dist/chunk-5XDUGTKN.js +511 -0
  27. package/dist/chunk-5YPSXQXM.js +1443 -0
  28. package/dist/chunk-6FHWXLPT.js +10 -0
  29. package/dist/chunk-6H5GEOET.js +2406 -0
  30. package/dist/chunk-6NWEVFEL.js +151 -0
  31. package/dist/chunk-AYW5YINX.js +58 -0
  32. package/dist/chunk-B4AMLZPB.js +9 -0
  33. package/dist/chunk-B7F4WVP4.js +65 -0
  34. package/dist/chunk-BJHVULHO.js +55 -0
  35. package/dist/chunk-BPBKKBUK.js +2085 -0
  36. package/dist/chunk-BYD345OX.js +589 -0
  37. package/dist/chunk-C27KDLOX.js +279 -0
  38. package/dist/chunk-CU546ESW.js +597 -0
  39. package/dist/chunk-DLHHXUAM.js +172 -0
  40. package/dist/chunk-DOTHQSJ2.js +429 -0
  41. package/dist/chunk-DYLPMV4Q.js +711 -0
  42. package/dist/chunk-EODDVJBM.js +82 -0
  43. package/dist/chunk-F3JWNST7.js +361 -0
  44. package/dist/chunk-FC2ZGRF3.js +140 -0
  45. package/dist/chunk-FCBTO76Z.js +5786 -0
  46. package/dist/chunk-FHZVFYSL.js +396 -0
  47. package/dist/chunk-FNXVT7HF.js +52 -0
  48. package/dist/chunk-FWNLEZYG.js +259 -0
  49. package/dist/chunk-FXQLIX3K.js +211 -0
  50. package/dist/chunk-G5S3S5ZN.js +38 -0
  51. package/dist/chunk-GDQ7CZRQ.js +116 -0
  52. package/dist/chunk-GJJGJB2R.js +1374 -0
  53. package/dist/chunk-GTCU6DZ3.js +1 -0
  54. package/dist/chunk-HA4ZYA6T.js +178 -0
  55. package/dist/chunk-HI3JGZR2.js +188 -0
  56. package/dist/chunk-HMLIGAU7.js +395 -0
  57. package/dist/chunk-HXKZ7OBQ.js +303 -0
  58. package/dist/chunk-I7DALG7J.js +292 -0
  59. package/dist/chunk-IRUTEHCE.js +960 -0
  60. package/dist/chunk-IYFBFX34.js +86 -0
  61. package/dist/chunk-J2WRWR37.js +1104 -0
  62. package/dist/chunk-JFPJ6LLQ.js +129 -0
  63. package/dist/chunk-JMULFFLN.js +9 -0
  64. package/dist/chunk-JO4MGB6Z.js +1264 -0
  65. package/dist/chunk-JVKB2TBL.js +48 -0
  66. package/dist/chunk-JX7VBZDK.js +31 -0
  67. package/dist/chunk-K6BXGITA.js +931 -0
  68. package/dist/chunk-KDQJCT2J.js +45 -0
  69. package/dist/chunk-KJ2ZTQSL.js +47 -0
  70. package/dist/chunk-KZMSZV32.js +187 -0
  71. package/dist/chunk-LA7CLDRW.js +129 -0
  72. package/dist/chunk-LHOA5DWA.js +28 -0
  73. package/dist/chunk-LSMMOS2Z.js +119 -0
  74. package/dist/chunk-LX5QWLBL.js +27 -0
  75. package/dist/chunk-LXWCMQNJ.js +789 -0
  76. package/dist/chunk-M27LIEKV.js +2829 -0
  77. package/dist/chunk-MJPHJRAL.js +663 -0
  78. package/dist/chunk-MTL4O5YR.js +228 -0
  79. package/dist/chunk-NDBIPFNY.js +102 -0
  80. package/dist/chunk-NEMIWEXC.js +1199 -0
  81. package/dist/chunk-NHJ75HXY.js +1 -0
  82. package/dist/chunk-NIOAGFPB.js +1510 -0
  83. package/dist/chunk-NS52ISWS.js +355 -0
  84. package/dist/chunk-NSOFPKGT.js +5352 -0
  85. package/dist/chunk-NVIZG63R.js +757 -0
  86. package/dist/chunk-O37BQ65S.js +21 -0
  87. package/dist/chunk-OOYZPOXM.js +308 -0
  88. package/dist/chunk-OSGLYW5J.js +28 -0
  89. package/dist/chunk-PFCMSSUF.js +1640 -0
  90. package/dist/chunk-PFZO3C6H.js +14 -0
  91. package/dist/chunk-PGRVXIMY.js +158 -0
  92. package/dist/chunk-PHH7LD45.js +113 -0
  93. package/dist/chunk-PISBFBJN.js +109 -0
  94. package/dist/chunk-POOOIWE5.js +9 -0
  95. package/dist/chunk-PQNS3U7Z.js +1240 -0
  96. package/dist/chunk-QSTSJOCK.js +402 -0
  97. package/dist/chunk-RFQMOKWK.js +282 -0
  98. package/dist/chunk-RJIZEJ42.js +30 -0
  99. package/dist/chunk-RTOTNK3P.js +484 -0
  100. package/dist/chunk-RXKSDUAU.js +1172 -0
  101. package/dist/chunk-S45JPKQN.js +3317 -0
  102. package/dist/chunk-SAFHACFA.js +152 -0
  103. package/dist/chunk-SQJVFEBV.js +41 -0
  104. package/dist/chunk-SVT4RNTR.js +49 -0
  105. package/dist/chunk-SWUFN7XM.js +43 -0
  106. package/dist/chunk-SXMVYC5H.js +174 -0
  107. package/dist/chunk-SZ6AYUIZ.js +23 -0
  108. package/dist/chunk-TBRL2RCC.js +9 -0
  109. package/dist/chunk-TCCHINEF.js +655 -0
  110. package/dist/chunk-THEGTRAG.js +316 -0
  111. package/dist/chunk-TR4LQE7L.js +2256 -0
  112. package/dist/chunk-TRT2HRWZ.js +18 -0
  113. package/dist/chunk-TWJMGXCI.js +900 -0
  114. package/dist/chunk-U45AXT5D.js +1023 -0
  115. package/dist/chunk-U4FWBSO3.js +509 -0
  116. package/dist/chunk-UBGDX6FI.js +147 -0
  117. package/dist/chunk-UJILKYES.js +75 -0
  118. package/dist/chunk-ULMAQV3T.js +234 -0
  119. package/dist/chunk-VVBP6KGT.js +9 -0
  120. package/dist/chunk-W5VITDM2.js +168 -0
  121. package/dist/chunk-WAHQVNWT.js +194 -0
  122. package/dist/chunk-WBPVKEEE.js +227 -0
  123. package/dist/chunk-WGGYRBXH.js +5434 -0
  124. package/dist/chunk-WLYKU45P.js +5770 -0
  125. package/dist/chunk-WP7BVANJ.js +53 -0
  126. package/dist/chunk-WQQON3SV.js +473 -0
  127. package/dist/chunk-WQTOVMGV.js +119 -0
  128. package/dist/chunk-XBDP4QPW.js +7 -0
  129. package/dist/chunk-XEBHSJLT.js +103 -0
  130. package/dist/chunk-XF4VUMKW.js +231 -0
  131. package/dist/chunk-XQ2ECNK3.js +1 -0
  132. package/dist/chunk-Y5YXDM7D.js +74 -0
  133. package/dist/chunk-YOPAUVU4.js +2588 -0
  134. package/dist/chunk-YPT4A46F.js +362 -0
  135. package/dist/chunk-YWXT3JNM.js +425 -0
  136. package/dist/chunk-YY6APYUM.js +49 -0
  137. package/dist/chunk-Z2IJUO45.js +691 -0
  138. package/dist/chunk-ZHZ2Y2DH.js +1643 -0
  139. package/dist/chunk-ZT7JNIGX.js +152 -0
  140. package/dist/coordination/agent-monitor.d.ts +9 -1
  141. package/dist/coordination/agent-subagent-runner.d.ts +1 -1
  142. package/dist/coordination/agents/agent-prompts.d.ts +8 -0
  143. package/dist/coordination/agents/index.d.ts +33 -1
  144. package/dist/coordination/agents/index.js +184 -6269
  145. package/dist/coordination/agents/phase3-wave1-platform.d.ts +1 -3
  146. package/dist/coordination/agents/phase3-wave2-meta.d.ts +1 -3
  147. package/dist/coordination/agents/phase8-wave3-products.d.ts +1 -3
  148. package/dist/coordination/agents/phase9-wave4-platform-meta.d.ts +1 -3
  149. package/dist/coordination/agents/project-agent-identity.d.ts +11 -11
  150. package/dist/coordination/agents/types.d.ts +13 -2
  151. package/dist/coordination/brain-monitor.d.ts +30 -7
  152. package/dist/coordination/collab-debug.d.ts +1 -1
  153. package/dist/coordination/collab-pause.d.ts +1 -1
  154. package/dist/coordination/delegate-tool.d.ts +7 -5
  155. package/dist/coordination/director-kanban-queue-helpers.d.ts +1 -0
  156. package/dist/coordination/director-options.d.ts +7 -0
  157. package/dist/coordination/director-spawn-model.d.ts +17 -0
  158. package/dist/coordination/director-tools.d.ts +2 -2
  159. package/dist/coordination/director.d.ts +12 -0
  160. package/dist/coordination/dispatcher.d.ts +8 -0
  161. package/dist/coordination/fleet-bus.d.ts +35 -4
  162. package/dist/coordination/fleet-supervisor.d.ts +10 -2
  163. package/dist/coordination/fleet.d.ts +16 -7
  164. package/dist/coordination/index.d.ts +4 -0
  165. package/dist/coordination/index.js +402 -34324
  166. package/dist/coordination/kanban-dispatch-port.d.ts +2 -2
  167. package/dist/coordination/mailbox-http-router.d.ts +4 -3
  168. package/dist/coordination/mailbox-http-validation.d.ts +1 -1
  169. package/dist/coordination/mailbox-project-server.js +48 -3276
  170. package/dist/coordination/mailbox-types.d.ts +24 -6
  171. package/dist/coordination/model-tier-leader.d.ts +122 -0
  172. package/dist/coordination/model-tier.d.ts +122 -0
  173. package/dist/coordination/multi-agent-coordinator.d.ts +24 -0
  174. package/dist/coordination/origin-session.d.ts +16 -0
  175. package/dist/coordination/provider-status-tracker.d.ts +41 -5
  176. package/dist/coordination/session-note-hub.d.ts +44 -0
  177. package/dist/coordination/session-note-tool.d.ts +10 -0
  178. package/dist/core/agent.d.ts +15 -2
  179. package/dist/core/context.d.ts +22 -3
  180. package/dist/core/index.d.ts +2 -0
  181. package/dist/core/index.js +239 -12360
  182. package/dist/core/model-ref.js +5 -23
  183. package/dist/core/provider-runner.d.ts +36 -1
  184. package/dist/core/request-conversation-binding.d.ts +37 -0
  185. package/dist/core/session-notes.d.ts +25 -0
  186. package/dist/core/system-prompt-builder.d.ts +11 -2
  187. package/dist/core/system-prompt-variants.d.ts +78 -0
  188. package/dist/design/index.js +50 -1087
  189. package/dist/execution/auto-compaction-middleware.d.ts +11 -0
  190. package/dist/execution/autonomy-brain.d.ts +2 -1
  191. package/dist/execution/autonomy-prompt-contributor.d.ts +7 -2
  192. package/dist/execution/compaction-core.d.ts +4 -4
  193. package/dist/execution/eternal-autonomy.d.ts +1 -1
  194. package/dist/execution/index.d.ts +1 -1
  195. package/dist/execution/index.js +1615 -21895
  196. package/dist/execution/model-runtime.d.ts +0 -7
  197. package/dist/execution/parallel-eternal-engine.d.ts +7 -7
  198. package/dist/execution/prompt-enhancer.js +16 -535
  199. package/dist/execution/retry-policy.d.ts +31 -1
  200. package/dist/extension/index.js +7 -311
  201. package/dist/goal/index.js +33 -3435
  202. package/dist/hooks/index.js +14 -1138
  203. package/dist/hq/index.js +114 -5139
  204. package/dist/hq/persistence/event-log.d.ts +0 -1
  205. package/dist/hq/persistence.d.ts +4 -4
  206. package/dist/hq/protocol.js +21 -668
  207. package/dist/hq/publisher.d.ts +2 -0
  208. package/dist/index.d.ts +14 -11
  209. package/dist/index.js +1502 -92655
  210. package/dist/infrastructure/index.d.ts +4 -4
  211. package/dist/infrastructure/index.js +504 -5230
  212. package/dist/infrastructure/token-counter.d.ts +9 -0
  213. package/dist/kernel/events/agent-events.d.ts +77 -3
  214. package/dist/kernel/events/brain-events.d.ts +12 -0
  215. package/dist/kernel/events/provider-events.d.ts +22 -1
  216. package/dist/kernel/events/session-events.d.ts +14 -0
  217. package/dist/kernel/events/tool-events.d.ts +13 -0
  218. package/dist/kernel/index.js +14 -992
  219. package/dist/mailbox-attach.d.ts +1 -1
  220. package/dist/models/index.js +41 -1117
  221. package/dist/notifications/index.js +3 -108
  222. package/dist/observability/event-bridge.d.ts +25 -5
  223. package/dist/observability/index.d.ts +9 -8
  224. package/dist/observability/index.js +477 -631
  225. package/dist/observability/tool-usage-source.d.ts +65 -0
  226. package/dist/plugin/index.d.ts +5 -0
  227. package/dist/plugin/index.js +600 -14835
  228. package/dist/plugins/auto-review-plugin.d.ts +3 -2
  229. package/dist/plugins/review-finding-commands.d.ts +0 -8
  230. package/dist/plugins/review-finding-store.js +22 -0
  231. package/dist/plugins/review-finding-types.js +19 -0
  232. package/dist/plugins/review-report-integration.js +21 -0
  233. package/dist/plugins/review-report-store.js +20 -0
  234. package/dist/plugins/review-report-types.js +13 -0
  235. package/dist/prompts/index.js +14 -948
  236. package/dist/registry/index.js +9 -822
  237. package/dist/registry/tool-registry.d.ts +59 -9
  238. package/dist/registry-7N4O3E7W.js +14 -0
  239. package/dist/replay/index.js +6 -84
  240. package/dist/security/capabilities.d.ts +6 -0
  241. package/dist/security/file-permissions.d.ts +1 -1
  242. package/dist/security/index.js +161 -2235
  243. package/dist/security/permission-policy.d.ts +12 -1
  244. package/dist/security/secret-scrubber.d.ts +15 -0
  245. package/dist/session-catalog/index.d.ts +1 -0
  246. package/dist/session-catalog/index.js +41 -2103
  247. package/dist/session-catalog/project-server.js +59 -1435
  248. package/dist/session-catalog/protocol.d.ts +32 -1
  249. package/dist/session-catalog/registry.d.ts +17 -1
  250. package/dist/session-catalog/session-agents.d.ts +56 -0
  251. package/dist/session-catalog/store-rebuild.d.ts +14 -0
  252. package/dist/session-catalog/store-schema.d.ts +26 -0
  253. package/dist/session-catalog/store.d.ts +27 -1
  254. package/dist/session-note-attach.d.ts +9 -0
  255. package/dist/skills/index.js +35 -1578
  256. package/dist/statusline/index.d.ts +43 -0
  257. package/dist/statusline/index.js +102 -0
  258. package/dist/storage/board-store-port.d.ts +2 -2
  259. package/dist/storage/config-loader/in-project-policy.d.ts +29 -0
  260. package/dist/storage/config-loader.d.ts +3 -2
  261. package/dist/storage/file-session-writer.d.ts +4 -2
  262. package/dist/storage/goal-coordination.d.ts +6 -1
  263. package/dist/storage/goal-kanban.d.ts +4 -1
  264. package/dist/storage/index.d.ts +12 -4
  265. package/dist/storage/index.js +198 -15601
  266. package/dist/storage/input-history-store.d.ts +2 -4
  267. package/dist/storage/memory-curator.d.ts +133 -0
  268. package/dist/storage/session-agent-attribution.d.ts +39 -0
  269. package/dist/storage/session-doctor.d.ts +109 -0
  270. package/dist/storage/session-event-bridge.d.ts +5 -7
  271. package/dist/storage/session-outcome.d.ts +42 -0
  272. package/dist/storage/session-recovery.d.ts +55 -0
  273. package/dist/storage/session-store/load-session-data.d.ts +11 -0
  274. package/dist/storage/session-store/prune-helpers.d.ts +1 -1
  275. package/dist/storage/session-store/resume-session.d.ts +0 -2
  276. package/dist/storage/session-store/types.d.ts +8 -0
  277. package/dist/storage/session-store.d.ts +3 -3
  278. package/dist/storage/session-summary-tracker.d.ts +8 -1
  279. package/dist/storage/session-write-buffer.d.ts +18 -0
  280. package/dist/storage/session-writer-truncate.d.ts +2 -0
  281. package/dist/tasking/index.js +10 -676
  282. package/dist/tools/fallback-manage-tools.d.ts +6 -4
  283. package/dist/tools/index.js +52 -9590
  284. package/dist/tools/model-tier-set-tool.d.ts +66 -0
  285. package/dist/types/agent-bridge.d.ts +2 -1
  286. package/dist/types/config/autonomy.d.ts +5 -0
  287. package/dist/types/config/mcp-features.d.ts +7 -0
  288. package/dist/types/config/model-tiers.d.ts +148 -0
  289. package/dist/types/config/root.d.ts +9 -0
  290. package/dist/types/config/tools.d.ts +73 -0
  291. package/dist/types/config/ui.d.ts +1 -1
  292. package/dist/types/config.d.ts +1 -0
  293. package/dist/types/context.d.ts +2 -0
  294. package/dist/types/default-config.d.ts +6 -0
  295. package/dist/types/errors.d.ts +20 -1
  296. package/dist/types/index.d.ts +11 -9
  297. package/dist/types/index.js +131 -1342
  298. package/dist/types/multi-agent.d.ts +43 -0
  299. package/dist/types/plugin.d.ts +1 -1
  300. package/dist/types/provider-runner.d.ts +8 -0
  301. package/dist/types/provider.d.ts +15 -0
  302. package/dist/types/runtime-capability-manifest.d.ts +1 -1
  303. package/dist/types/secret-scrubber.d.ts +15 -0
  304. package/dist/types/session-markers.d.ts +37 -10
  305. package/dist/types/session-markers.js +8 -144
  306. package/dist/types/session-timeline.d.ts +197 -0
  307. package/dist/types/session-timeline.js +12 -0
  308. package/dist/types/session.d.ts +172 -11
  309. package/dist/types/system-prompt.d.ts +27 -0
  310. package/dist/utils/config-backup.d.ts +9 -1
  311. package/dist/utils/error.js +3 -4
  312. package/dist/utils/expect-defined.js +3 -9
  313. package/dist/utils/heap-watchdog.js +6 -706
  314. package/dist/utils/index.js +271 -5685
  315. package/dist/utils/message-invariants.d.ts +4 -1
  316. package/dist/utils/regex-guard.d.ts +1 -1
  317. package/dist/utils/sage-output-block.js +5 -42
  318. package/dist/utils/socket-path.d.ts +1 -1
  319. package/dist/utils/token-estimate.d.ts +6 -2
  320. package/dist/utils/wstack-paths.d.ts +2 -0
  321. package/dist/wiring/proxy-rewrite.d.ts +46 -0
  322. package/dist/wiring/proxy-rewrite.js +24 -121
  323. package/dist/worktree/index.js +6 -887
  324. package/instructions/agents/explore-companion.md +45 -18
  325. package/instructions/agents/memory-curator.md +34 -22
  326. package/instructions/coordination/director-preamble.md +12 -7
  327. package/instructions/coordination/subagent-baseline.md +26 -5
  328. package/instructions/leader-after-task.md +4 -1
  329. package/instructions/llm/chimera-review.md +30 -9
  330. package/instructions/llm/memory-curator.md +31 -0
  331. package/instructions/sections/tool/delegation-compact.md +2 -0
  332. package/instructions/sections/tool/delegation-full.md +5 -1
  333. package/instructions/sections/tool/mailbox-compact.md +5 -1
  334. package/instructions/sections/tool/mailbox-full.md +3 -0
  335. package/instructions/sections/tool/session-note-compact.md +3 -0
  336. package/instructions/sections/tool/session-note-full.md +15 -0
  337. package/instructions/system-lite.md +9 -4
  338. package/instructions/system-pro.md +66 -143
  339. package/instructions/system.md +73 -175
  340. package/package.json +32 -4
  341. package/dist/coordination/agents.d.ts +0 -8
  342. package/dist/coordination/transport.d.ts +0 -2
  343. package/dist/storage/session-writer/session-writer-summary-tracker.d.ts +0 -28
@@ -1,1347 +1,133 @@
1
- // src/types/blocks.ts
2
- function isTextBlock(b) {
3
- return b.type === "text";
4
- }
5
- function isToolUseBlock(b) {
6
- return b.type === "tool_use";
7
- }
8
- function isToolResultBlock(b) {
9
- return b.type === "tool_result";
10
- }
11
- function isImageBlock(b) {
12
- return b.type === "image";
13
- }
14
-
15
- // src/types/config/fleet-chat.ts
16
- var FLEET_CHAT_VERBOSITY_VALUES = ["off", "full"];
17
- function resolveFleetChatVerbosity(autonomy) {
18
- const explicit = autonomy?.fleetChatVerbosity;
19
- if (explicit && FLEET_CHAT_VERBOSITY_VALUES.includes(explicit)) {
20
- return explicit;
21
- }
22
- return "off";
23
- }
24
-
25
- // src/types/config/runtime.ts
26
- function normalizeTokenSavingTier(val) {
27
- if (val === void 0) return "off";
28
- if (typeof val === "boolean") return val ? "medium" : "off";
29
- if (val === "auto") return "medium";
30
- const validTiers = /* @__PURE__ */ new Set([
31
- "off",
32
- "minimal",
33
- "light",
34
- "medium",
35
- "aggressive"
36
- ]);
37
- return validTiers.has(val) ? val : "off";
38
- }
39
- function resolveTokenSavingTier(val, maxContext) {
40
- if (val === "auto") {
41
- if (typeof maxContext !== "number" || !Number.isFinite(maxContext) || maxContext <= 0) {
42
- return "off";
43
- }
44
- if (maxContext < 32e3) return "medium";
45
- if (maxContext < 128e3) return "light";
46
- return "minimal";
47
- }
48
- return normalizeTokenSavingTier(val);
49
- }
50
- var DEFAULT_TUI_THINKING_WORD = "thinking";
51
- var MAX_TUI_THINKING_WORD_LENGTH = 16;
52
- var MAX_WRONGPROXY_URL_LENGTH = 2048;
53
- function normalizeTuiThinkingWord(value) {
54
- if (typeof value !== "string") return DEFAULT_TUI_THINKING_WORD;
55
- const word = value.trim();
56
- if (word.length === 0 || word.length > MAX_TUI_THINKING_WORD_LENGTH) {
57
- return DEFAULT_TUI_THINKING_WORD;
58
- }
59
- if (!/^[\p{L}\p{N}_-]+$/u.test(word)) return DEFAULT_TUI_THINKING_WORD;
60
- return word;
61
- }
62
-
63
- // src/types/config/ui.ts
64
- var THEME_PRESET_IDS = [
65
- "catppuccin",
66
- "tokyo-night",
67
- "nord",
68
- "cyberpunk",
69
- "dracula",
70
- "gruvbox-dark",
71
- "solarized-dark",
72
- "one-dark",
73
- "monokai",
74
- "rose-pine",
75
- "kanagawa",
76
- "ayu-dark",
77
- "everforest",
78
- "night-owl",
79
- "synthwave",
80
- "github-dark",
81
- "material-ocean",
82
- "nightfox",
83
- "oxocarbon",
84
- "catppuccin-macchiato",
85
- "catppuccin-frappe",
86
- "gruvbox-material",
87
- "tokyo-night-storm",
88
- "rose-pine-moon",
89
- "zenburn",
90
- "palenight",
91
- "horizon",
92
- "sonokai",
93
- "edge-dark",
94
- "moonfly",
95
- "melange",
96
- "poimandres",
97
- "vitesse-dark",
98
- "aura",
99
- "dark-plus",
100
- "monochrome"
101
- ];
102
-
103
- // src/utils/expect-defined.ts
104
- function expectDefined(value, label) {
105
- if (value === null || value === void 0) {
106
- const err = new Error(label ? `Expected ${label} to be defined` : "Expected value to be defined");
107
- err.name = "ExpectDefinedError";
108
- throw err;
109
- }
110
- return value;
111
- }
112
-
113
- // src/types/context-window.ts
114
- var DEFAULT_CONTEXT_WINDOW_MODE_ID = "balanced";
115
- var LARGE_WINDOW_DEEP_MODE_THRESHOLD = 1e6;
116
- var CONTEXT_WINDOW_MODE_PINNED_META_KEY = "contextWindowModePinned";
117
- var DEPRECATED_CONTEXT_WINDOW_MODE_ALIASES = Object.freeze({
118
- archival: "balanced"
119
- });
120
- var CONTEXT_WINDOW_MODES = Object.freeze([
121
- {
122
- id: "balanced",
123
- name: "Balanced",
124
- description: "Default rolling compaction: recent work stays verbatim, old tool output is trimmed. Windows of 1M+ tokens default to Deep.",
125
- thresholds: { warn: 0.55, soft: 0.7, hard: 0.85 },
126
- aggressiveOn: "soft",
127
- preserveK: 8,
128
- eliseThreshold: 1200,
129
- targetLoad: 0.65
130
- },
131
- {
132
- id: "frugal",
133
- name: "Frugal",
134
- description: "Token-saver mode: compacts early and keeps a tight verbatim tail.",
135
- thresholds: { warn: 0.4, soft: 0.55, hard: 0.7 },
136
- aggressiveOn: "warn",
137
- preserveK: 4,
138
- eliseThreshold: 500,
139
- targetLoad: 0.45
140
- },
141
- {
142
- id: "deep",
143
- name: "Deep",
144
- description: "Long-reasoning mode: delays compaction and keeps more recent turns intact.",
145
- thresholds: { warn: 0.72, soft: 0.86, hard: 0.96 },
146
- aggressiveOn: "hard",
147
- preserveK: 18,
148
- eliseThreshold: 5e3,
149
- targetLoad: 0.82
150
- }
151
- ]);
152
- function listContextWindowModes() {
153
- return CONTEXT_WINDOW_MODES.map((m) => ({ ...m, thresholds: { ...m.thresholds } }));
154
- }
155
- function normalizeContextWindowModeId(id) {
156
- if (!id) return null;
157
- if (isContextWindowModeId(id)) return id;
158
- return DEPRECATED_CONTEXT_WINDOW_MODE_ALIASES[id] ?? null;
159
- }
160
- function isDeprecatedContextWindowModeId(id) {
161
- return Object.hasOwn(DEPRECATED_CONTEXT_WINDOW_MODE_ALIASES, id);
162
- }
163
- function isContextWindowModeSelectionId(id) {
164
- return isContextWindowModeId(id) || isDeprecatedContextWindowModeId(id);
165
- }
166
- function getContextWindowMode(id) {
167
- const normalized = normalizeContextWindowModeId(id);
168
- if (!normalized) return null;
169
- const mode = CONTEXT_WINDOW_MODES.find((m) => m.id === normalized);
170
- return mode ? { ...mode, thresholds: { ...mode.thresholds } } : null;
171
- }
172
- function isContextWindowModeId(id) {
173
- return CONTEXT_WINDOW_MODES.some((m) => m.id === id);
174
- }
175
- function resolveContextWindowPolicy(config = {}, overrideMode, maxContext) {
176
- const requested = overrideMode ?? config.mode ?? DEFAULT_CONTEXT_WINDOW_MODE_ID;
177
- const normalized = normalizeContextWindowModeId(requested) ?? DEFAULT_CONTEXT_WINDOW_MODE_ID;
178
- const baseId = normalized === DEFAULT_CONTEXT_WINDOW_MODE_ID && typeof maxContext === "number" && maxContext >= LARGE_WINDOW_DEEP_MODE_THRESHOLD ? "deep" : normalized;
179
- const mode = expectDefined(getContextWindowMode(baseId));
180
- return {
181
- ...mode,
182
- thresholds: {
183
- warn: config.warnThreshold ?? mode.thresholds.warn,
184
- soft: config.softThreshold ?? mode.thresholds.soft,
185
- hard: config.hardThreshold ?? mode.thresholds.hard
186
- },
187
- preserveK: config.preserveK ?? mode.preserveK,
188
- eliseThreshold: config.eliseThreshold ?? mode.eliseThreshold,
189
- targetLoad: config.targetLoad ?? mode.targetLoad
190
- };
191
- }
192
- function formatContextWindowModeList(activeId) {
193
- const active = normalizeContextWindowModeId(activeId);
194
- return CONTEXT_WINDOW_MODES.map((m) => {
195
- const marker = m.id === active ? "*" : " ";
196
- return `${marker} ${m.id.padEnd(9)} ${m.name} - ${m.description}`;
197
- }).join("\n");
198
- }
199
-
200
- // src/types/default-config.ts
201
- var DEFAULT_TOOLS_CONFIG = Object.freeze({
202
- defaultExecutionStrategy: "smart",
203
- maxIterations: 100,
204
- iterationTimeoutMs: 3e5,
205
- maxToolTimeoutMs: 3e5,
206
- sessionTimeoutMs: 18e5,
207
- perIterationOutputCapBytes: 1e5,
208
- descriptionMode: Object.freeze({}),
209
- disabledTools: Object.freeze([]),
210
- // Extension requires an explicit host/user policy. Without that boundary a
211
- // nominal maxIterations cap can grow forever in autonomous sessions.
212
- autoExtendLimit: false,
213
- restrictToProjectRoot: true,
214
- // Off by default: the board is a record of the work, not a permit for it.
215
- // See ToolsConfig.kanbanGovernance for what turning it on costs and gates.
216
- kanbanGovernance: false,
217
- loopDetection: Object.freeze({
218
- mode: "steer-then-cut",
219
- steerThreshold: 3,
220
- cutThreshold: 5,
221
- windowSize: 12,
222
- callRepeatThreshold: 4
223
- })
224
- });
225
- var DEFAULT_CONTEXT_CONFIG = Object.freeze({
226
- warnThreshold: 0.55,
227
- softThreshold: 0.7,
228
- hardThreshold: 0.85,
229
- targetLoad: 0.65,
230
- preserveK: 8,
231
- eliseThreshold: 1200
232
- });
233
- var DEFAULT_AUTONOMY_CONFIG = Object.freeze({
234
- autoProceedDelayMs: 45e3
235
- });
236
- var DEFAULT_CIRCUIT_BREAKER_CONFIG = Object.freeze({
237
- enabled: false,
238
- autoKillResetMs: 6e4
239
- });
240
- var DEFAULT_SESSION_LOGGING_CONFIG = Object.freeze({
241
- auditLevel: "standard",
242
- sampling: {
243
- toolProgress: {
244
- sampleRate: 8
245
- }
246
- }
247
- });
248
- var DEFAULT_SESSION_PRUNE_DAYS = 30;
249
-
250
- // src/types/design-kit.ts
251
- var DESIGN_STACKS = ["web", "react-native", "flutter", "swiftui", "compose"];
252
- function isDesignStack(v) {
253
- return DESIGN_STACKS.includes(v);
254
- }
255
- var KNOWN_TOKEN_GROUPS = {
256
- /** Corner radii. */
257
- radius: ["radius-none", "radius-sm", "radius-md", "radius-lg", "radius-xl", "radius-full"],
258
- /** Spacing scale (4/8px rhythm). */
259
- space: ["space-1", "space-2", "space-3", "space-4", "space-6", "space-8", "space-12"],
260
- /** Type sizes. */
261
- text: ["text-xs", "text-sm", "text-base", "text-lg", "text-xl", "text-2xl", "text-3xl"],
262
- /** Line-heights (unitless). */
263
- leading: ["leading-tight", "leading-normal", "leading-relaxed"],
264
- /** Font weights (unitless). */
265
- weight: ["weight-normal", "weight-medium", "weight-semibold", "weight-bold"],
266
- /** Letter-spacing. */
267
- tracking: ["tracking-tight", "tracking-normal", "tracking-wide"],
268
- /** Elevation / shadow ramp. */
269
- shadow: ["shadow-1", "shadow-2", "shadow-3", "shadow-4"],
270
- /** Border widths. */
271
- border: ["border-hairline", "border-thin", "border-thick"],
272
- /** Motion durations. */
273
- duration: ["duration-fast", "duration-base", "duration-slow"],
274
- /** Motion easings. */
275
- ease: ["ease-standard", "ease-emphasized"],
276
- /** Font families. */
277
- font: ["font-sans", "font-mono", "font-display"]
278
- };
279
- var KNOWN_TOKEN_NAMES = Object.values(KNOWN_TOKEN_GROUPS).flat();
280
-
281
- // src/utils/error.ts
282
- function toErrorMessage(err) {
283
- return err instanceof Error ? err.message : String(err);
284
- }
285
-
286
- // src/types/errors.ts
287
- var ERROR_CODES = {
288
- // Provider
289
- PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED",
290
- PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED",
291
- PROVIDER_OVERLOADED: "PROVIDER_OVERLOADED",
292
- PROVIDER_INVALID_REQUEST: "PROVIDER_INVALID_REQUEST",
293
- PROVIDER_SERVER_ERROR: "PROVIDER_SERVER_ERROR",
294
- PROVIDER_NETWORK_ERROR: "PROVIDER_NETWORK_ERROR",
295
- PROVIDER_CONTEXT_OVERFLOW: "PROVIDER_CONTEXT_OVERFLOW",
296
- // Tool
297
- TOOL_NOT_FOUND: "TOOL_NOT_FOUND",
298
- TOOL_PERMISSION_DENIED: "TOOL_PERMISSION_DENIED",
299
- TOOL_EXECUTION_FAILED: "TOOL_EXECUTION_FAILED",
300
- TOOL_TIMEOUT: "TOOL_TIMEOUT",
301
- TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID",
302
- // Config
303
- CONFIG_INVALID: "CONFIG_INVALID",
304
- CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
305
- CONFIG_PARSE_FAILED: "CONFIG_PARSE_FAILED",
306
- CONFIG_MIGRATION_NEEDED: "CONFIG_MIGRATION_NEEDED",
307
- // Plugin
308
- PLUGIN_LOAD_FAILED: "PLUGIN_LOAD_FAILED",
309
- PLUGIN_API_MISMATCH: "PLUGIN_API_MISMATCH",
310
- PLUGIN_MISSING_DEPENDENCY: "PLUGIN_MISSING_DEPENDENCY",
311
- // Agent
312
- AGENT_ITERATION_LIMIT: "AGENT_ITERATION_LIMIT",
313
- AGENT_CONTEXT_OVERFLOW: "AGENT_CONTEXT_OVERFLOW",
314
- AGENT_ABORTED: "AGENT_ABORTED",
315
- AGENT_RUN_FAILED: "AGENT_RUN_FAILED",
316
- // Session
317
- SESSION_NOT_FOUND: "SESSION_NOT_FOUND",
318
- SESSION_CORRUPTED: "SESSION_CORRUPTED",
319
- SESSION_WRITE_FAILED: "SESSION_WRITE_FAILED",
320
- // Container / Registry
321
- CONTAINER_TOKEN_ALREADY_BOUND: "CONTAINER_TOKEN_ALREADY_BOUND",
322
- CONTAINER_TOKEN_NOT_BOUND: "CONTAINER_TOKEN_NOT_BOUND",
323
- CONTAINER_CIRCULAR_DEPENDENCY: "CONTAINER_CIRCULAR_DEPENDENCY",
324
- REGISTRY_DUPLICATE: "REGISTRY_DUPLICATE",
325
- REGISTRY_NOT_FOUND: "REGISTRY_NOT_FOUND",
326
- REGISTRY_INVALID: "REGISTRY_INVALID",
327
- // File system
328
- FS_READ_FAILED: "FS_READ_FAILED",
329
- FS_WRITE_FAILED: "FS_WRITE_FAILED",
330
- FS_MKDIR_FAILED: "FS_MKDIR_FAILED",
331
- FS_DELETE_FAILED: "FS_DELETE_FAILED",
332
- FS_ATOMIC_WRITE_FAILED: "FS_ATOMIC_WRITE_FAILED",
333
- // SDD (Spec-Driven Development)
334
- SDD_VALIDATION_FAILED: "SDD_VALIDATION_FAILED",
335
- SDD_PARSE_FAILED: "SDD_PARSE_FAILED",
336
- SDD_INVALID_STATE: "SDD_INVALID_STATE",
337
- SDD_NOT_READY: "SDD_NOT_READY",
338
- // General
339
- VALIDATION_ERROR: "VALIDATION_ERROR",
340
- PARSE_FAILED: "PARSE_FAILED",
341
- UNKNOWN: "UNKNOWN"
342
- };
343
- var WrongStackError = class extends Error {
344
- code;
345
- subsystem;
346
- severity;
347
- recoverable;
348
- context;
349
- constructor(opts) {
350
- super(opts.message, { cause: opts.cause });
351
- this.name = "WrongStackError";
352
- this.code = opts.code;
353
- this.subsystem = opts.subsystem;
354
- this.severity = opts.severity ?? "error";
355
- this.recoverable = opts.recoverable ?? false;
356
- this.context = opts.context;
357
- }
358
- /**
359
- * Render a one-line user-facing description.
360
- * Subclasses should override for domain-specific formatting.
361
- */
362
- describe() {
363
- const ctx = this.context ? ` ${formatContext(this.context)}` : "";
364
- return `${this.code}: ${this.message}${ctx}`;
365
- }
366
- };
367
- function formatContext(ctx) {
368
- const parts = Object.entries(ctx).filter(([, v]) => v !== void 0).slice(0, 3).map(([k, v]) => `${k}=${String(v)}`);
369
- return parts.length > 0 ? `[${parts.join(" ")}]` : "";
370
- }
371
- var ToolError = class extends WrongStackError {
372
- toolName;
373
- constructor(opts) {
374
- super({
375
- message: opts.message,
376
- code: opts.code,
377
- subsystem: "tool",
378
- recoverable: opts.recoverable,
379
- context: { tool: opts.toolName, ...opts.context },
380
- cause: opts.cause
381
- });
382
- this.name = "ToolError";
383
- this.toolName = opts.toolName;
384
- }
385
- };
386
- var ConfigError = class extends WrongStackError {
387
- constructor(opts) {
388
- super({
389
- message: opts.message,
390
- code: opts.code,
391
- subsystem: "config",
392
- severity: "fatal",
393
- recoverable: false,
394
- context: opts.context,
395
- cause: opts.cause
396
- });
397
- this.name = "ConfigError";
398
- }
399
- };
400
- var PluginError = class extends WrongStackError {
401
- pluginName;
402
- constructor(opts) {
403
- super({
404
- message: opts.message,
405
- code: opts.code,
406
- subsystem: "plugin",
407
- severity: "error",
408
- recoverable: opts.code === ERROR_CODES.PLUGIN_MISSING_DEPENDENCY,
409
- context: { plugin: opts.pluginName, ...opts.context },
410
- cause: opts.cause
411
- });
412
- this.name = "PluginError";
413
- this.pluginName = opts.pluginName;
414
- }
415
- };
416
- var AgentError = class extends WrongStackError {
417
- constructor(opts) {
418
- super({
419
- message: opts.message,
420
- code: opts.code,
421
- subsystem: "agent",
422
- severity: opts.code === ERROR_CODES.AGENT_ABORTED ? "warning" : "error",
423
- recoverable: opts.recoverable ?? opts.code === ERROR_CODES.AGENT_ITERATION_LIMIT,
424
- context: opts.context,
425
- cause: opts.cause
426
- });
427
- this.name = "AgentError";
428
- }
429
- };
430
- function toWrongStackError(err, code = ERROR_CODES.AGENT_RUN_FAILED) {
431
- if (err instanceof WrongStackError) return err;
432
- const message = toErrorMessage(err);
433
- return new AgentError({
434
- message,
435
- code: code === "UNKNOWN" ? ERROR_CODES.AGENT_RUN_FAILED : code,
436
- cause: err
437
- });
438
- }
439
- var SessionError = class extends WrongStackError {
440
- sessionId;
441
- constructor(opts) {
442
- super({
443
- message: opts.message,
444
- code: opts.code,
445
- subsystem: "session",
446
- severity: opts.code === ERROR_CODES.SESSION_WRITE_FAILED ? "error" : "warning",
447
- recoverable: opts.code !== ERROR_CODES.SESSION_CORRUPTED,
448
- context: { sessionId: opts.sessionId, ...opts.context },
449
- cause: opts.cause
450
- });
451
- this.name = "SessionError";
452
- this.sessionId = opts.sessionId;
453
- }
454
- };
455
- var SddError = class extends WrongStackError {
456
- constructor(opts) {
457
- super({
458
- message: opts.message,
459
- code: opts.code,
460
- subsystem: "sdd",
461
- severity: opts.code === ERROR_CODES.SDD_PARSE_FAILED ? "warning" : "error",
462
- recoverable: opts.code === ERROR_CODES.SDD_NOT_READY,
463
- context: opts.context,
464
- cause: opts.cause
465
- });
466
- this.name = "SddError";
467
- }
468
- };
469
- var FsError = class extends WrongStackError {
470
- path;
471
- constructor(opts) {
472
- super({
473
- message: opts.message,
474
- code: opts.code,
475
- subsystem: "fs",
476
- severity: "error",
477
- recoverable: opts.code !== ERROR_CODES.FS_READ_FAILED,
478
- context: { path: opts.path, ...opts.context },
479
- cause: opts.cause
480
- });
481
- this.name = "FsError";
482
- this.path = opts.path;
483
- }
484
- };
485
- var FetchError = class extends WrongStackError {
486
- status;
487
- constructor(opts) {
488
- super({
489
- message: opts.message,
490
- code: ERROR_CODES.VALIDATION_ERROR,
491
- subsystem: "general",
492
- severity: "error",
493
- recoverable: opts.status === 429 || opts.status >= 500,
494
- context: { status: opts.status, ...opts.context },
495
- cause: opts.cause
496
- });
497
- this.name = "FetchError";
498
- this.status = opts.status;
499
- }
500
- };
501
- var ToolValidationError = class extends WrongStackError {
502
- constructor(opts) {
503
- super({
504
- message: opts.message,
505
- code: ERROR_CODES.VALIDATION_ERROR,
506
- subsystem: "general",
507
- severity: "error",
508
- recoverable: false,
509
- context: { field: opts.field, ...opts.context },
510
- cause: opts.cause
511
- });
512
- this.name = "ToolValidationError";
513
- }
514
- };
515
- var ParseError = class extends WrongStackError {
516
- source;
517
- constructor(opts) {
518
- super({
519
- message: opts.message,
520
- code: ERROR_CODES.PARSE_FAILED,
521
- subsystem: "general",
522
- severity: "error",
523
- recoverable: false,
524
- context: { source: opts.source, ...opts.context },
525
- cause: opts.cause
526
- });
527
- this.name = "ParseError";
528
- this.source = opts.source;
529
- }
530
- };
531
- function isWrongStackError(err) {
532
- return err instanceof WrongStackError;
533
- }
534
- function isToolError(err) {
535
- return err instanceof ToolError;
536
- }
537
- function isConfigError(err) {
538
- return err instanceof ConfigError;
539
- }
540
- function isPluginError(err) {
541
- return err instanceof PluginError;
542
- }
543
- function isSessionError(err) {
544
- return err instanceof SessionError;
545
- }
546
- function isAgentError(err) {
547
- return err instanceof AgentError;
548
- }
549
- function isFsError(err) {
550
- return err instanceof FsError;
551
- }
552
- function isToolValidationError(err) {
553
- return err instanceof ToolValidationError;
554
- }
555
- function isFetchError(err) {
556
- return err instanceof FetchError;
557
- }
558
- function isParseError(err) {
559
- return err instanceof ParseError;
560
- }
561
- function isSddError(err) {
562
- return err instanceof SddError;
563
- }
564
-
565
- // src/types/memory.ts
566
- var MEMORY_TYPE_LABELS = {
567
- fact: "Fact",
568
- decision: "Decision",
569
- convention: "Convention",
570
- preference: "Preference",
571
- reference: "Reference",
572
- anti_pattern: "Anti-pattern"
573
- };
574
- function defineMemoryCapability(id) {
575
- return Object.freeze({
576
- id,
577
- /** Identity function that makes the brand a real runtime value so
578
- * `defineMemoryCapability<A>('x')` and `defineMemoryCapability<B>('x')`
579
- * produce structurally distinct objects. Capability lookup is still
580
- * keyed by `id` only — the brand prevents accidental cross-type casts
581
- * at the type level. */
582
- __memoryCapabilityType: (v) => v
583
- });
584
- }
585
-
586
- // src/types/mode-prompts.ts
587
- import { readFileSync, statSync } from "node:fs";
588
- import * as path from "node:path";
589
- import { fileURLToPath } from "node:url";
590
- function modePrompt(id) {
591
- for (const dir of modePromptDirCandidates()) {
592
- try {
593
- return readFileSync(path.join(dir, `${id}.md`), "utf8").trimEnd();
594
- } catch {
595
- }
596
- }
597
- return "";
598
- }
599
- function modePromptDirCandidates() {
600
- const here = path.dirname(fileURLToPath(import.meta.url));
601
- const candidates = [
602
- path.resolve(here, "../../instructions/modes"),
603
- path.resolve(here, "../instructions/modes"),
604
- path.resolve(here, "instructions/modes")
605
- ];
606
- return candidates.sort((a, b) => Number(!isDirectory(a)) - Number(!isDirectory(b)));
607
- }
608
- function isDirectory(candidate) {
609
- try {
610
- return statSync(candidate).isDirectory();
611
- } catch {
612
- return false;
613
- }
614
- }
615
-
616
- // src/types/mode.ts
617
- var DEFAULT_MODES = [
618
- {
619
- id: "default",
620
- name: "Default",
621
- description: "Balanced general-purpose mode; use when no special token/coverage trade-off is needed",
622
- prompt: "",
623
- tags: ["general", "balanced"]
624
- },
625
- {
626
- id: "brief",
627
- name: "Brief",
628
- description: "Ultra-compact responses for low-context, high-speed work",
629
- prompt: modePrompt("brief"),
630
- tags: ["lite", "fast", "concise", "token-saving"],
631
- toolPreferences: ["read", "edit", "bash"],
632
- suggestedSkills: []
633
- },
634
- {
635
- id: "review-lite",
636
- name: "Review Lite",
637
- description: "Token-saving code review: changed files only, top correctness/security risks",
638
- prompt: modePrompt("review-lite"),
639
- tags: ["lite", "review", "quality", "token-saving"],
640
- toolPreferences: ["git", "diff", "read", "grep"],
641
- suggestedSkills: ["bug-hunter", "typescript-strict"]
642
- },
643
- {
644
- id: "audit-lite",
645
- name: "Audit Lite",
646
- description: "Token-saving security triage for a small diff or named file",
647
- prompt: modePrompt("audit-lite"),
648
- tags: ["lite", "security", "audit", "token-saving"],
649
- toolPreferences: ["grep", "read", "git"],
650
- suggestedSkills: ["security-scanner"]
651
- },
652
- {
653
- id: "plan-lite",
654
- name: "Plan Lite",
655
- description: "Token-saving planning: 3-6 actionable steps, minimal design debate",
656
- prompt: modePrompt("plan-lite"),
657
- tags: ["lite", "planning", "architecture", "token-saving"],
658
- toolPreferences: ["tree", "glob", "read", "grep"],
659
- suggestedSkills: ["refactor-planner"]
660
- },
661
- {
662
- id: "debug-lite",
663
- name: "Debug Lite",
664
- description: "Token-saving bug triage: one hypothesis, nearest evidence, narrow check",
665
- prompt: modePrompt("debug-lite"),
666
- tags: ["lite", "debug", "triage", "token-saving"],
667
- toolPreferences: ["read", "grep", "test", "logs"],
668
- suggestedSkills: ["bug-hunter"]
669
- },
670
- {
671
- id: "test-lite",
672
- name: "Test Lite",
673
- description: "Token-saving tests: one focused regression or narrow verification target",
674
- prompt: modePrompt("test-lite"),
675
- tags: ["lite", "testing", "qa", "token-saving"],
676
- toolPreferences: ["test", "read", "grep"],
677
- suggestedSkills: ["testing"]
678
- },
679
- {
680
- id: "refactor-lite",
681
- name: "Refactor Lite",
682
- description: "Token-saving cleanup: small scoped behavior-preserving changes",
683
- prompt: modePrompt("refactor-lite"),
684
- tags: ["lite", "refactor", "token-saving"],
685
- toolPreferences: ["read", "edit", "test"],
686
- suggestedSkills: ["typescript-strict"]
687
- },
688
- {
689
- id: "research-lite",
690
- name: "Research Lite",
691
- description: "Token-saving web research: one search, one authoritative fetch, short answer",
692
- prompt: modePrompt("research-lite"),
693
- tags: ["lite", "research", "web", "token-saving"],
694
- toolPreferences: ["search", "fetch"],
695
- suggestedSkills: ["research-web"]
696
- },
697
- {
698
- id: "code-reviewer",
699
- name: "Review Deep",
700
- description: "Comprehensive code review across contracts, edge cases, lifecycle, errors, concurrency",
701
- prompt: modePrompt("code-reviewer"),
702
- tags: ["deep", "review", "quality", "security"],
703
- toolPreferences: ["read", "grep", "git", "diff", "test"],
704
- suggestedSkills: ["bug-hunter", "security-scanner", "typescript-strict", "testing"]
705
- },
706
- {
707
- id: "code-auditor",
708
- name: "Audit Deep",
709
- description: "Comprehensive security audit with category coverage and exploitability notes",
710
- prompt: modePrompt("code-auditor"),
711
- tags: ["deep", "security", "audit", "compliance"],
712
- toolPreferences: ["grep", "read", "audit", "bash"],
713
- suggestedSkills: ["security-scanner", "bug-hunter", "audit-log"]
714
- },
715
- {
716
- id: "architect",
717
- name: "Architecture Deep",
718
- description: "Comprehensive architecture and cross-module contract analysis",
719
- prompt: modePrompt("architect"),
720
- tags: ["deep", "architecture", "design", "scalability"],
721
- toolPreferences: ["read", "glob", "tree", "diff"],
722
- suggestedSkills: ["api-design", "refactor-planner", "node-modern", "docker-deploy"]
723
- },
724
- {
725
- id: "debugger",
726
- name: "Debug Deep",
727
- description: "Comprehensive root-cause analysis with traces, logs, assumptions, and verification",
728
- prompt: modePrompt("debugger"),
729
- tags: ["deep", "debug", "investigation", "error-resolution"],
730
- toolPreferences: ["read", "grep", "bash", "logs", "test"],
731
- suggestedSkills: ["bug-hunter", "audit-log", "observability"]
732
- },
733
- {
734
- id: "tester",
735
- name: "Test Deep",
736
- description: "Comprehensive QA mode for coverage, boundaries, isolation, and integration gaps",
737
- prompt: modePrompt("tester"),
738
- tags: ["deep", "testing", "qa", "quality"],
739
- toolPreferences: ["read", "grep", "test", "bash"],
740
- suggestedSkills: ["testing", "bug-hunter", "typescript-strict"]
741
- },
742
- {
743
- id: "devops",
744
- name: "DevOps Deep",
745
- description: "Comprehensive infrastructure, deployment, observability, and operations review",
746
- prompt: modePrompt("devops"),
747
- tags: ["deep", "devops", "infrastructure", "operations"],
748
- toolPreferences: ["read", "bash", "grep", "logs", "git"],
749
- suggestedSkills: ["docker-deploy", "observability", "security-scanner"]
750
- },
751
- {
752
- id: "refactorer",
753
- name: "Refactor Deep",
754
- description: "Comprehensive modernization/refactor mode with contracts and verification discipline",
755
- prompt: modePrompt("refactorer"),
756
- tags: ["deep", "refactor", "modernization", "improvement"],
757
- toolPreferences: ["read", "edit", "test", "git", "grep"],
758
- suggestedSkills: ["refactor-planner", "typescript-strict", "node-modern", "testing"]
759
- },
760
- {
761
- id: "ui-design",
762
- name: "UI Design Deep",
763
- description: "Comprehensive design-first frontend/mobile UI work with kit, tokens, and accessibility",
764
- prompt: modePrompt("ui-design"),
765
- tags: ["deep", "ui", "frontend", "mobile", "design"],
766
- toolPreferences: ["design", "write", "edit", "read", "scaffold"],
767
- suggestedSkills: ["react-modern"]
768
- },
769
- {
770
- id: "teach",
771
- name: "Teach Deep",
772
- description: "Mentor mode with explanations, mental models, trade-offs, and takeaways",
773
- prompt: modePrompt("teach"),
774
- tags: ["deep", "teaching", "mentor", "learning"],
775
- toolPreferences: ["read", "edit", "explain"],
776
- suggestedSkills: ["prompt-engineering", "skill-creator", "node-modern", "typescript-strict"]
777
- },
778
- {
779
- id: "research-web",
780
- name: "Research Deep",
781
- description: "Comprehensive current-data research with cross-checking and reusable findings",
782
- prompt: modePrompt("research-web"),
783
- tags: ["deep", "research", "web", "current-data", "up-to-date"],
784
- toolPreferences: ["search", "fetch", "context_manager"],
785
- suggestedSkills: ["research-web", "tech-stack", "node-modern", "security-scanner", "react-modern"]
786
- }
787
- ];
788
-
789
- // src/types/prompt.ts
790
- var BUILTIN_PROMPT_CATEGORIES = [
791
- "coding",
792
- "debugging",
793
- "refactoring",
794
- "testing",
795
- "code-review",
796
- "architecture",
797
- "devops",
798
- "documentation",
799
- "data-analysis",
800
- "writing",
801
- "research",
802
- "product",
803
- "agentic-workflows",
804
- "meta-prompting",
805
- "uncategorized"
806
- ];
807
- var PROMPT_CATEGORY_LABELS = {
808
- coding: "Coding",
809
- debugging: "Debugging",
810
- refactoring: "Refactoring",
811
- testing: "Testing",
812
- "code-review": "Code Review",
813
- architecture: "Architecture",
814
- devops: "DevOps",
815
- documentation: "Documentation",
816
- "data-analysis": "Data Analysis",
817
- writing: "Writing",
818
- research: "Research",
819
- product: "Product",
820
- "agentic-workflows": "Agentic Workflows",
821
- "meta-prompting": "Meta-Prompting",
822
- uncategorized: "Uncategorized"
823
- };
824
- function isBuiltinCategory(value) {
825
- return BUILTIN_PROMPT_CATEGORIES.includes(value);
826
- }
827
-
828
- // src/types/prompt-registry.ts
829
- var SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
830
- var CHECKSUM_RE = /^[a-f0-9]{64}$/;
831
- var MAX_STR = 4096;
832
- function validateRegistryManifest(raw) {
833
- const errors = [];
834
- if (!raw || typeof raw !== "object") return { ok: false, errors: ["manifest is not an object"] };
835
- const m = raw;
836
- if (m["registryVersion"] !== 1) errors.push("registryVersion must be 1");
837
- if (typeof m["source"] !== "string" || !m["source"])
838
- errors.push("source must be a non-empty string");
839
- if (typeof m["generatedAt"] !== "string") errors.push("generatedAt must be a string");
840
- if (!Array.isArray(m["prompts"])) {
841
- errors.push("prompts must be an array");
842
- return { ok: false, errors };
843
- }
844
- const seen = /* @__PURE__ */ new Set();
845
- const refs = [];
846
- m["prompts"].forEach((p, i) => {
847
- if (!p || typeof p !== "object") {
848
- errors.push(`prompts[${i}] is not an object`);
849
- return;
850
- }
851
- const r = p;
852
- const slug = r["slug"];
853
- if (typeof slug !== "string" || !SLUG_RE.test(slug)) {
854
- errors.push(`prompts[${i}].slug invalid (must be kebab-case)`);
855
- return;
856
- }
857
- if (seen.has(slug)) {
858
- errors.push(`prompts[${i}].slug "${slug}" duplicated`);
859
- return;
860
- }
861
- seen.add(slug);
862
- if (typeof r["checksum"] !== "string" || !CHECKSUM_RE.test(r["checksum"])) {
863
- errors.push(`prompts[${i}].checksum must be a 64-char sha256 hex`);
864
- return;
865
- }
866
- for (const field of ["id", "title", "description", "category"]) {
867
- const v = r[field];
868
- if (typeof v !== "string" || v.length === 0 || v.length > MAX_STR) {
869
- errors.push(`prompts[${i}].${field} must be a non-empty string under ${MAX_STR} chars`);
870
- return;
871
- }
872
- }
873
- const tags = Array.isArray(r["tags"]) ? r["tags"].filter((t) => typeof t === "string") : [];
874
- refs.push({
875
- id: r["id"],
876
- slug,
877
- title: r["title"],
878
- description: r["description"],
879
- category: r["category"],
880
- tags,
881
- checksum: r["checksum"],
882
- version: typeof r["version"] === "string" ? r["version"] : void 0,
883
- license: typeof r["license"] === "string" ? r["license"] : void 0,
884
- url: typeof r["url"] === "string" ? r["url"] : void 0
885
- });
886
- });
887
- if (errors.length > 0) return { ok: false, errors };
888
- return {
889
- ok: true,
890
- manifest: {
891
- registryVersion: 1,
892
- source: m["source"],
893
- generatedAt: m["generatedAt"],
894
- prompts: refs
895
- }
896
- };
897
- }
898
- function diffRegistry(local, manifest) {
899
- const localBySlug = new Map(local.map((e) => [e.slug, e.checksum]));
900
- const diff = { added: [], updated: [], unchanged: [] };
901
- for (const ref of manifest.prompts) {
902
- if (!localBySlug.has(ref.slug)) diff.added.push(ref);
903
- else if (localBySlug.get(ref.slug) !== ref.checksum) diff.updated.push(ref);
904
- else diff.unchanged.push(ref);
905
- }
906
- return diff;
907
- }
908
-
909
- // src/utils/string.ts
910
- function truncate(s, max) {
911
- return s.length <= max ? s : `${s.slice(0, max - 1)}\u2026`;
912
- }
913
-
914
- // src/types/quota-regex.ts
915
- var QUOTA_EXHAUSTED_RE = /(?:insufficient|exhausted|depleted|exceeded|no|not enough)[-_\s]*(?:quota|credit|balance)|(?:quota|credit|balance)(?:\s+(?:has|have))?(?:\s+been)?[-_\s]*(?:exhausted|depleted|exceeded|insufficient)|billing[_\s-]*(?:hard[_\s-]*)?limit|payment required|spending limit|plan limit|(?:usage|credit)[-_\s]*(?:quota|limit)(?![-_\w])|usage[-_\s]*(?:limit|quota)[-_\s]*(?:reached|exceeded|for)/i;
916
-
917
- // src/types/provider.ts
918
- var REASONING_EFFORT_LEVELS = [
919
- "none",
920
- "minimal",
921
- "low",
922
- "medium",
923
- "high",
924
- "xhigh",
925
- "max"
926
- ];
927
- function isReasoningEffort(value) {
928
- return typeof value === "string" && REASONING_EFFORT_LEVELS.includes(value);
929
- }
930
- function effectiveInputTokens(usage) {
931
- return usage.input + (usage.cacheRead ?? 0) + (usage.cacheWrite ?? 0);
932
- }
933
- function freshInputTokens(usage) {
934
- return Math.max(0, effectiveInputTokens(usage) - (usage.cacheRead ?? 0));
935
- }
936
- function promptCacheHitRatio(usage) {
937
- const total = effectiveInputTokens(usage);
938
- if (!Number.isFinite(total) || total <= 0) return 0;
939
- const cached = Number.isFinite(usage.cacheRead) ? Math.max(0, usage.cacheRead ?? 0) : 0;
940
- return Math.min(1, cached / total);
941
- }
942
- var CONTEXT_OVERFLOW_RE = /context.length|context.window|maximum context|max.*tokens?.*exceeded|(?:prompt|request|input|messages?).{0,12}too (?:large|long)|exceeds the context|\btokens\b.*exceed|too many tokens|reduce the length|resulted in \d+ tokens|context_length_exceeded/i;
943
- var CONTENT_FILTER_RE = /content.(filter|policy|moderation)|safety (system|filter)/i;
944
- var RATE_LIMIT_EXCEEDED_RE = /rate[-_\s]*limit[-_\s]*exceeded/i;
945
- function classifyProviderError(status, body, message) {
946
- const type = body?.type;
947
- const text = [message, body?.message, type, body?.raw].filter(Boolean).join("\n");
948
- if (status === 0) return "network";
949
- if (status === 408) return "timeout";
950
- if (status === 599) return "stream_hang";
951
- if (QUOTA_EXHAUSTED_RE.test(text)) return "quota_exhausted";
952
- if (status === 402) return "quota_exhausted";
953
- if (status === 429 && body?.message && body.type !== "rate_limit_exceeded" && RATE_LIMIT_EXCEEDED_RE.test(body.message)) {
954
- return "quota_exhausted";
955
- }
956
- if (type === "rate_limit_error" || status === 429) return "rate_limit";
957
- if (type === "overloaded_error" || status === 529) return "overloaded";
958
- if (status >= 500) return "server";
959
- if (type === "authentication_error" || type === "permission_error" || status === 401 || status === 403) {
960
- return "auth";
961
- }
962
- if (type === "content_filter" || CONTENT_FILTER_RE.test(text)) return "content_filter";
963
- if (status === 413 || status >= 400 && CONTEXT_OVERFLOW_RE.test(text)) {
964
- return "context_overflow";
965
- }
966
- if (status >= 400) return "invalid_request";
967
- return "unknown";
968
- }
969
- var MAX_RESET_HINT_MS = 7 * 24 * 60 * 60 * 1e3;
970
- function isRetryableKind(kind) {
971
- return RETRYABLE_BY_KIND[kind];
972
- }
973
- var RETRYABLE_BY_KIND = {
974
- rate_limit: true,
975
- quota_exhausted: false,
976
- overloaded: true,
977
- server: true,
978
- timeout: true,
979
- network: true,
980
- stream_hang: true,
981
- auth: false,
982
- context_overflow: false,
983
- content_filter: false,
984
- invalid_request: false,
985
- unknown: false
986
- };
987
- function isFallbackWorthy(kind) {
988
- return FALLBACK_WORTHY_BY_KIND[kind];
989
- }
990
- var FALLBACK_WORTHY_BY_KIND = {
991
- rate_limit: true,
992
- quota_exhausted: true,
993
- overloaded: true,
994
- server: true,
995
- timeout: true,
996
- network: true,
997
- stream_hang: true,
998
- auth: false,
999
- context_overflow: false,
1000
- content_filter: false,
1001
- invalid_request: false,
1002
- unknown: false
1003
- };
1004
- var ProviderError = class extends WrongStackError {
1005
- status;
1006
- retryable;
1007
- providerId;
1008
- /** Canonical failure classification — see {@link ProviderErrorKind}. */
1009
- kind;
1010
- body;
1011
- /**
1012
- * Duck-type guard: checks whether an unknown value *looks like* a
1013
- * ProviderError by probing for its structural properties. Use this
1014
- * anywhere the constructor identity might cross a package boundary
1015
- * (e.g. `@wrongstack/providers` creates the error, but the runner in
1016
- * `@wrongstack/core` checks it). A plain `instanceof ProviderError`
1017
- * can fail when npm hoists duplicate copies of `@wrongstack/core`,
1018
- * each with its own class identity.
1019
- *
1020
- * The check tests for the four invariant properties defined in the
1021
- * constructor: `name === 'ProviderError'`, `status` (number),
1022
- * `retryable` (boolean), and `kind` (string). This tolerates both
1023
- * true `ProviderError` instances and cross-boundary copies.
1024
- */
1025
- static isProviderError(err) {
1026
- if (!err || typeof err !== "object") return false;
1027
- const e = err;
1028
- const name = e.name;
1029
- if (typeof name !== "string" || !name.endsWith("Error")) return false;
1030
- return typeof e.status === "number" && typeof e.retryable === "boolean" && typeof e.kind === "string" && typeof e.describe === "function";
1031
- }
1032
- constructor(message, status, retryable, providerId, opts = {}) {
1033
- const kind = opts.kind ?? classifyProviderError(status, opts.body, message);
1034
- super({
1035
- message,
1036
- code: kindToCode(kind),
1037
- subsystem: "provider",
1038
- severity: status >= 500 ? "error" : "warning",
1039
- recoverable: retryable,
1040
- context: { providerId, status },
1041
- cause: opts.cause
1042
- });
1043
- this.name = "ProviderError";
1044
- this.status = status;
1045
- this.retryable = retryable;
1046
- this.providerId = providerId;
1047
- this.kind = kind;
1048
- this.body = opts.body;
1049
- }
1050
- /**
1051
- * Render a one-line, user-facing description. Designed for the CLI/TUI
1052
- * status line and the agent's retry warning. Avoids dumping raw JSON
1053
- * (which is what users see today when a 529 lands and the log message
1054
- * includes the full `{"type":"error",...}` body).
1055
- *
1056
- * Examples:
1057
- * "minimax-coding-plan overloaded (529): High traffic detected. Upgrade for highspeed model. [req 06534785201de9c0…]"
1058
- * "openai rate limited (429): Retry after 12s"
1059
- * "anthropic invalid request (400): messages.0.role must be one of 'user'|'assistant'"
1060
- * "groq HTTP 500 (server error)"
1061
- */
1062
- describe() {
1063
- const kind = describeStatus(this.status, this.body?.type);
1064
- const head = `${this.providerId} ${kind}`;
1065
- const detail = this.body?.message?.trim();
1066
- const reqId = this.body?.requestId ? ` [req ${this.body.requestId.slice(0, 16)}${this.body.requestId.length > 16 ? "\u2026" : ""}]` : "";
1067
- if (detail && detail.length > 0) {
1068
- return `${head}: ${truncate(detail, 240)}${reqId}`;
1069
- }
1070
- return `${head}${reqId}`;
1071
- }
1072
- };
1073
- function isContextOverflowShaped(err) {
1074
- if (!(err instanceof ProviderError) && !ProviderError.isProviderError(err)) return false;
1075
- const providerErr = err;
1076
- if (providerErr.kind === "context_overflow" || providerErr.status === 413) return true;
1077
- if (providerErr.status < 400) return false;
1078
- const text = [
1079
- providerErr.message,
1080
- providerErr.body?.message,
1081
- providerErr.body?.type,
1082
- providerErr.body?.raw
1083
- ].filter(Boolean).join("\n");
1084
- return CONTEXT_OVERFLOW_RE.test(text);
1085
- }
1086
- function describeStatus(status, type) {
1087
- if (status === 0) return "network error";
1088
- if (status === 599) return `stream hang (${status})`;
1089
- if (type === "overloaded_error" || status === 529) return `overloaded (${status})`;
1090
- if (type === "rate_limit_error" || status === 429) return `rate limited (${status})`;
1091
- if (type === "authentication_error" || status === 401) return `auth failed (${status})`;
1092
- if (type === "permission_error" || status === 403) return `forbidden (${status})`;
1093
- if (type === "not_found_error" || status === 404) return `not found (${status})`;
1094
- if (type === "content_filter") return `content filtered (${status})`;
1095
- if (type === "invalid_request_error" || status === 400) return `invalid request (${status})`;
1096
- if (status === 408) return `timeout (${status})`;
1097
- if (status >= 500 && status < 600) return `HTTP ${status} (server error)`;
1098
- if (type) return `${type} (${status})`;
1099
- return `HTTP ${status}`;
1100
- }
1101
- var StreamHangError = class extends ProviderError {
1102
- /** Name of the provider that hung, e.g. "zai", "anthropic". */
1103
- hungProviderId;
1104
- /** Model that was being called when the hang occurred. */
1105
- hungModel;
1106
- /** How long (ms) we waited for the next chunk before declaring a hang. */
1107
- hangTimeoutMs;
1108
- /** How many bytes were received before the hang. */
1109
- bytesReceived;
1110
- /** Elapsed time (ms) from the start of the stream until the hang. */
1111
- elapsedMs;
1112
- constructor(opts) {
1113
- super(
1114
- `Stream hang: ${opts.providerId}/${opts.model} \u2014 no data for ${opts.hangTimeoutMs}ms after ${opts.bytesReceived} bytes (${opts.elapsedMs}ms elapsed)`,
1115
- 599,
1116
- true,
1117
- // always retryable
1118
- opts.providerId,
1119
- {
1120
- body: {
1121
- message: `Stream stalled after ${opts.elapsedMs}ms, ${opts.bytesReceived} bytes received`
1122
- },
1123
- cause: opts.cause
1124
- }
1125
- );
1126
- this.name = "StreamHangError";
1127
- this.hungProviderId = opts.providerId;
1128
- this.hungModel = opts.model;
1129
- this.hangTimeoutMs = opts.hangTimeoutMs;
1130
- this.bytesReceived = opts.bytesReceived;
1131
- this.elapsedMs = opts.elapsedMs;
1132
- }
1133
- };
1134
- var KIND_TO_CODE = {
1135
- network: ERROR_CODES.PROVIDER_NETWORK_ERROR,
1136
- timeout: ERROR_CODES.PROVIDER_NETWORK_ERROR,
1137
- rate_limit: ERROR_CODES.PROVIDER_RATE_LIMITED,
1138
- quota_exhausted: ERROR_CODES.PROVIDER_RATE_LIMITED,
1139
- auth: ERROR_CODES.PROVIDER_AUTH_FAILED,
1140
- overloaded: ERROR_CODES.PROVIDER_OVERLOADED,
1141
- context_overflow: ERROR_CODES.PROVIDER_CONTEXT_OVERFLOW,
1142
- server: ERROR_CODES.PROVIDER_SERVER_ERROR,
1143
- stream_hang: ERROR_CODES.PROVIDER_SERVER_ERROR,
1144
- content_filter: ERROR_CODES.PROVIDER_INVALID_REQUEST,
1145
- invalid_request: ERROR_CODES.PROVIDER_INVALID_REQUEST,
1146
- unknown: ERROR_CODES.PROVIDER_INVALID_REQUEST
1147
- };
1148
- function kindToCode(kind) {
1149
- return KIND_TO_CODE[kind];
1150
- }
1151
-
1152
- // src/types/session-markers.ts
1153
- var SESSION_MARKER_EVENT_TYPES = /* @__PURE__ */ new Set([
1154
- "mode_changed",
1155
- "compaction",
1156
- "checkpoint",
1157
- "skill_activated",
1158
- "skill_deactivated",
1159
- "agent_spawned",
1160
- "agent_stopped",
1161
- "agent_error",
1162
- "error",
1163
- "provider_retry",
1164
- "provider_error",
1165
- "message_truncated"
1166
- ]);
1167
- var CHAT_MARKER_SOURCES = new Set(
1168
- [...SESSION_MARKER_EVENT_TYPES].filter((type) => type !== "checkpoint")
1169
- );
1170
- function sessionEventToMarker(ev) {
1171
- switch (ev.type) {
1172
- case "compaction": {
1173
- const before = (ev.before / 1e3).toFixed(0);
1174
- const after = (ev.after / 1e3).toFixed(0);
1175
- const level = ev.level ? ` (${ev.level})` : "";
1176
- const reductions = ev.reductions && ev.reductions.length > 0 ? ` [${ev.reductions.map((r) => `${r.phase}: \u2212${r.saved}`).join(", ")}]` : "";
1177
- return {
1178
- ts: ev.ts,
1179
- source: ev.type,
1180
- level: "info",
1181
- text: `\u27F2 context compacted${level}: ${before}K \u2192 ${after}K tokens${reductions}`
1182
- };
1183
- }
1184
- case "error":
1185
- return {
1186
- ts: ev.ts,
1187
- source: ev.type,
1188
- level: "error",
1189
- text: ev.phase ? `[${ev.phase}] ${ev.message}` : ev.message
1190
- };
1191
- case "provider_retry": {
1192
- const secs = (ev.delayMs / 1e3).toFixed(ev.delayMs >= 1e3 ? 1 : 2);
1193
- return {
1194
- ts: ev.ts,
1195
- source: ev.type,
1196
- level: "warn",
1197
- text: ev.status ? `\u27F3 retry ${ev.attempt} (HTTP ${ev.status}) after ${secs}s \u2014 ${ev.description}` : `\u27F3 retry ${ev.attempt} after ${secs}s \u2014 ${ev.description}`
1198
- };
1199
- }
1200
- case "provider_error":
1201
- return {
1202
- ts: ev.ts,
1203
- source: ev.type,
1204
- level: "error",
1205
- text: ev.status ? `provider error (HTTP ${ev.status}, ${ev.retryable ? "retryable" : "fatal"}): ${ev.description}` : `provider error (${ev.retryable ? "retryable" : "fatal"}): ${ev.description}`
1206
- };
1207
- case "checkpoint":
1208
- return {
1209
- ts: ev.ts,
1210
- source: ev.type,
1211
- level: "info",
1212
- text: `\u2713 checkpoint #${ev.promptIndex}: "${ev.promptPreview.slice(0, 60)}"`
1213
- };
1214
- case "agent_spawned":
1215
- return {
1216
- ts: ev.ts,
1217
- source: ev.type,
1218
- level: "info",
1219
- text: `spawned as ${ev.role}`,
1220
- agentId: ev.agentId
1221
- };
1222
- case "agent_stopped":
1223
- return {
1224
- ts: ev.ts,
1225
- source: ev.type,
1226
- level: "info",
1227
- text: "stopped",
1228
- agentId: ev.agentId
1229
- };
1230
- case "agent_error":
1231
- return {
1232
- ts: ev.ts,
1233
- source: ev.type,
1234
- level: "error",
1235
- text: `error: ${ev.error.slice(0, 80)}`,
1236
- agentId: ev.agentId
1237
- };
1238
- case "mode_changed":
1239
- return {
1240
- ts: ev.ts,
1241
- source: ev.type,
1242
- level: "info",
1243
- text: `mode: ${ev.from} \u2192 ${ev.to}`
1244
- };
1245
- case "skill_activated":
1246
- return {
1247
- ts: ev.ts,
1248
- source: ev.type,
1249
- level: "info",
1250
- text: `skill activated: ${ev.skillName}`
1251
- };
1252
- case "skill_deactivated":
1253
- return {
1254
- ts: ev.ts,
1255
- source: ev.type,
1256
- level: "info",
1257
- text: `skill deactivated: ${ev.skillName}`
1258
- };
1259
- case "message_truncated":
1260
- return {
1261
- ts: ev.ts,
1262
- source: ev.type,
1263
- level: "warn",
1264
- text: ev.after < ev.before ? `message truncated: ${ev.before} \u2192 ${ev.after} tokens` : `message truncated at ${ev.after} tokens`
1265
- };
1266
- default:
1267
- return null;
1268
- }
1269
- }
1270
- function projectSessionMarkers(events, sources = SESSION_MARKER_EVENT_TYPES) {
1271
- const markers = [];
1272
- for (const ev of events) {
1273
- if (!sources.has(ev.type)) continue;
1274
- const marker = sessionEventToMarker(ev);
1275
- if (marker) markers.push(marker);
1276
- }
1277
- return markers;
1278
- }
1279
- var SYSTEM_INJECTION_PREFIXES = [
1280
- "[MAILBOX]",
1281
- "[MAILBOX BTW]",
1282
- "[BY THE WAY \u2014",
1283
- "[QUEUED MESSAGES \u2014",
1284
- "[FLEET PULSE]",
1285
- "[loop-detector]",
1286
- "[SESSION RESUME FILE VALIDATION]",
1287
- "[SESSION RESUME INTERRUPTED WORK]"
1288
- ];
1289
- function isSystemInjectedMessage(text) {
1290
- const trimmed = text.trimStart();
1291
- for (const prefix of SYSTEM_INJECTION_PREFIXES) {
1292
- if (trimmed.startsWith(prefix)) return true;
1293
- }
1294
- return false;
1295
- }
1296
-
1297
- // src/types/spec.ts
1298
- var DEFAULT_SPEC_TEMPLATE = {
1299
- id: "default",
1300
- name: "Default Feature Spec",
1301
- description: "Standard template for feature specifications",
1302
- sections: [
1303
- { type: "overview", title: "Overview", level: 1 },
1304
- { type: "requirements", title: "Requirements", level: 1 },
1305
- { type: "architecture", title: "Architecture", level: 1 },
1306
- { type: "api", title: "API Design", level: 1 },
1307
- { type: "data", title: "Data Model", level: 1 },
1308
- { type: "security", title: "Security", level: 1 },
1309
- { type: "acceptance", title: "Acceptance Criteria", level: 1 }
1310
- ],
1311
- defaultRequirements: [
1312
- { type: "functional", priority: "high", acceptanceCriteria: [], blockedBy: [], implements: [] },
1313
- {
1314
- type: "non-functional",
1315
- priority: "medium",
1316
- acceptanceCriteria: [],
1317
- blockedBy: [],
1318
- implements: []
1319
- }
1320
- ]
1321
- };
1322
-
1323
- // src/types/system-prompt.ts
1324
- function flattenSystemPromptRegions(regions) {
1325
- return [...regions.core, ...regions.session, ...regions.volatile];
1326
- }
1327
-
1328
- // src/types/tool.ts
1329
- var ToolErrorCategory = /* @__PURE__ */ ((ToolErrorCategory2) => {
1330
- ToolErrorCategory2["TRANSIENT"] = "transient";
1331
- ToolErrorCategory2["NOT_FOUND"] = "not_found";
1332
- ToolErrorCategory2["PERMISSION"] = "permission";
1333
- ToolErrorCategory2["VALIDATION"] = "validation";
1334
- ToolErrorCategory2["FATAL"] = "fatal";
1335
- return ToolErrorCategory2;
1336
- })(ToolErrorCategory || {});
1337
-
1338
- // src/types/tool-executor.ts
1339
- var GOVERNED_TOOL_EXECUTOR_META_KEY = "toolExecutor.executeGoverned";
1340
-
1341
- // src/types/tool-markers.ts
1342
- var MALFORMED_ARG_MARKERS = ["__raw", "__raw_arguments", "_raw"];
1
+ import {
2
+ BUILTIN_MODEL_TIER_IDS,
3
+ DEFAULT_SPEC_TEMPLATE,
4
+ FLEET_CHAT_VERBOSITY_VALUES,
5
+ MALFORMED_ARG_MARKERS,
6
+ THEME_PRESET_IDS,
7
+ ToolErrorCategory,
8
+ resolveFleetChatVerbosity
9
+ } from "../chunk-GDQ7CZRQ.js";
10
+ import {
11
+ diffRegistry,
12
+ validateRegistryManifest
13
+ } from "../chunk-IYFBFX34.js";
14
+ import {
15
+ MEMORY_TYPE_LABELS,
16
+ defineMemoryCapability
17
+ } from "../chunk-57GEWK5X.js";
18
+ import {
19
+ DEFAULT_MODES
20
+ } from "../chunk-2FK4WTFF.js";
21
+ import {
22
+ CONTEXT_WINDOW_MODES,
23
+ CONTEXT_WINDOW_MODE_PINNED_META_KEY,
24
+ DEFAULT_AUTONOMY_CONFIG,
25
+ DEFAULT_CIRCUIT_BREAKER_CONFIG,
26
+ DEFAULT_CONTEXT_CONFIG,
27
+ DEFAULT_CONTEXT_WINDOW_MODE_ID,
28
+ DEFAULT_SESSION_LOGGING_CONFIG,
29
+ DEFAULT_SESSION_PRUNE_DAYS,
30
+ DEFAULT_TOOLS_CONFIG,
31
+ DEPRECATED_CONTEXT_WINDOW_MODE_ALIASES,
32
+ LARGE_WINDOW_DEEP_MODE_THRESHOLD,
33
+ formatContextWindowModeList,
34
+ getContextWindowMode,
35
+ isContextWindowModeId,
36
+ isContextWindowModeSelectionId,
37
+ isDeprecatedContextWindowModeId,
38
+ listContextWindowModes,
39
+ normalizeContextWindowModeId,
40
+ resolveContextWindowPolicy
41
+ } from "../chunk-DLHHXUAM.js";
42
+ import {
43
+ GOVERNED_TOOL_EXECUTOR_META_KEY
44
+ } from "../chunk-XBDP4QPW.js";
45
+ import {
46
+ BUILTIN_PROMPT_CATEGORIES,
47
+ PROMPT_CATEGORY_LABELS,
48
+ isBuiltinCategory
49
+ } from "../chunk-KDQJCT2J.js";
50
+ import {
51
+ DESIGN_STACKS,
52
+ KNOWN_TOKEN_GROUPS,
53
+ KNOWN_TOKEN_NAMES,
54
+ isDesignStack
55
+ } from "../chunk-G5S3S5ZN.js";
56
+ import {
57
+ ProviderError,
58
+ REASONING_EFFORT_LEVELS,
59
+ StreamHangError,
60
+ classifyProviderError,
61
+ effectiveInputTokens,
62
+ freshInputTokens,
63
+ isContextOverflowShaped,
64
+ isFallbackWorthy,
65
+ isReasoningEffort,
66
+ isRetryableKind,
67
+ promptCacheHitRatio,
68
+ totalUsageTokens
69
+ } from "../chunk-3ECENVHL.js";
70
+ import {
71
+ flattenSystemPromptRegions
72
+ } from "../chunk-VVBP6KGT.js";
73
+ import {
74
+ DEFAULT_TUI_THINKING_WORD,
75
+ MAX_TUI_THINKING_WORD_LENGTH,
76
+ MAX_WRONGPROXY_URL_LENGTH,
77
+ normalizeTokenSavingTier,
78
+ normalizeTuiThinkingWord,
79
+ resolveTokenSavingTier
80
+ } from "../chunk-KJ2ZTQSL.js";
81
+ import "../chunk-B4AMLZPB.js";
82
+ import "../chunk-PFZO3C6H.js";
83
+ import {
84
+ isImageBlock,
85
+ isTextBlock,
86
+ isToolResultBlock,
87
+ isToolUseBlock
88
+ } from "../chunk-O37BQ65S.js";
89
+ import {
90
+ AgentError,
91
+ ConfigError,
92
+ ERROR_CODES,
93
+ FetchError,
94
+ FsError,
95
+ ParseError,
96
+ PluginError,
97
+ SddError,
98
+ SessionError,
99
+ ToolError,
100
+ ToolValidationError,
101
+ WrongStackError,
102
+ isAgentError,
103
+ isConfigError,
104
+ isFetchError,
105
+ isFsError,
106
+ isParseError,
107
+ isPluginError,
108
+ isSddError,
109
+ isSessionError,
110
+ isToolError,
111
+ isToolValidationError,
112
+ isWrongStackError,
113
+ toWrongStackError
114
+ } from "../chunk-25LSLC3G.js";
115
+ import "../chunk-TBRL2RCC.js";
116
+ import {
117
+ projectSessionTimeline,
118
+ projectSessionToolMeta
119
+ } from "../chunk-3BDV7RL3.js";
120
+ import {
121
+ CHAT_MARKER_SOURCES,
122
+ SESSION_MARKER_EVENT_TYPES,
123
+ SYSTEM_INJECTION_PREFIXES,
124
+ isSystemInjectedMessage,
125
+ projectSessionMarkers,
126
+ sessionEventToMarker
127
+ } from "../chunk-ULMAQV3T.js";
1343
128
  export {
1344
129
  AgentError,
130
+ BUILTIN_MODEL_TIER_IDS,
1345
131
  BUILTIN_PROMPT_CATEGORIES,
1346
132
  CHAT_MARKER_SOURCES,
1347
133
  CONTEXT_WINDOW_MODES,
@@ -1424,12 +210,15 @@ export {
1424
210
  normalizeTokenSavingTier,
1425
211
  normalizeTuiThinkingWord,
1426
212
  projectSessionMarkers,
213
+ projectSessionTimeline,
214
+ projectSessionToolMeta,
1427
215
  promptCacheHitRatio,
1428
216
  resolveContextWindowPolicy,
1429
217
  resolveFleetChatVerbosity,
1430
218
  resolveTokenSavingTier,
1431
219
  sessionEventToMarker,
1432
220
  toWrongStackError,
221
+ totalUsageTokens,
1433
222
  validateRegistryManifest
1434
223
  };
1435
224
  //# sourceMappingURL=index.js.map