@wrongstack/core 0.287.0 → 0.291.0

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 (339) hide show
  1. package/dist/agent-status-tracker.d.ts +13 -0
  2. package/dist/agent-status-tracker.d.ts.map +1 -1
  3. package/dist/boot.d.ts.map +1 -1
  4. package/dist/chronicle/context.d.ts +13 -0
  5. package/dist/chronicle/context.d.ts.map +1 -0
  6. package/dist/chronicle/decision-adapter.d.ts +13 -0
  7. package/dist/chronicle/decision-adapter.d.ts.map +1 -0
  8. package/dist/chronicle/domain-adapter.d.ts +13 -0
  9. package/dist/chronicle/domain-adapter.d.ts.map +1 -0
  10. package/dist/chronicle/file-observer.d.ts +20 -0
  11. package/dist/chronicle/file-observer.d.ts.map +1 -0
  12. package/dist/chronicle/health-monitor.d.ts +11 -0
  13. package/dist/chronicle/health-monitor.d.ts.map +1 -0
  14. package/dist/chronicle/identity.d.ts +18 -0
  15. package/dist/chronicle/identity.d.ts.map +1 -0
  16. package/dist/chronicle/index.d.ts +16 -0
  17. package/dist/chronicle/index.d.ts.map +1 -0
  18. package/dist/chronicle/index.js +2555 -0
  19. package/dist/chronicle/index.js.map +7 -0
  20. package/dist/chronicle/journal.d.ts +81 -0
  21. package/dist/chronicle/journal.d.ts.map +1 -0
  22. package/dist/chronicle/process-adapter.d.ts +14 -0
  23. package/dist/chronicle/process-adapter.d.ts.map +1 -0
  24. package/dist/chronicle/prompt-manifest.d.ts +34 -0
  25. package/dist/chronicle/prompt-manifest.d.ts.map +1 -0
  26. package/dist/chronicle/provider-adapter.d.ts +13 -0
  27. package/dist/chronicle/provider-adapter.d.ts.map +1 -0
  28. package/dist/chronicle/query.d.ts +108 -0
  29. package/dist/chronicle/query.d.ts.map +1 -0
  30. package/dist/chronicle/rollup-adapter.d.ts +14 -0
  31. package/dist/chronicle/rollup-adapter.d.ts.map +1 -0
  32. package/dist/chronicle/stream-adapter.d.ts +13 -0
  33. package/dist/chronicle/stream-adapter.d.ts.map +1 -0
  34. package/dist/chronicle/tool-adapter.d.ts +15 -0
  35. package/dist/chronicle/tool-adapter.d.ts.map +1 -0
  36. package/dist/chronicle/types.d.ts +82 -0
  37. package/dist/chronicle/types.d.ts.map +1 -0
  38. package/dist/coordination/agent-monitor.d.ts +40 -0
  39. package/dist/coordination/agent-monitor.d.ts.map +1 -1
  40. package/dist/coordination/agent-subagent-runner.d.ts +7 -1
  41. package/dist/coordination/agent-subagent-runner.d.ts.map +1 -1
  42. package/dist/coordination/agents/phase6-domain.d.ts.map +1 -1
  43. package/dist/coordination/autonomous-coordinator.d.ts +2 -0
  44. package/dist/coordination/autonomous-coordinator.d.ts.map +1 -1
  45. package/dist/coordination/brain-monitor.d.ts +1 -1
  46. package/dist/coordination/brain.d.ts +3 -2
  47. package/dist/coordination/brain.d.ts.map +1 -1
  48. package/dist/coordination/collab-debug.d.ts +0 -9
  49. package/dist/coordination/collab-debug.d.ts.map +1 -1
  50. package/dist/coordination/coordinator/error-classifier.d.ts.map +1 -1
  51. package/dist/coordination/dep-watcher.d.ts +2 -1
  52. package/dist/coordination/dep-watcher.d.ts.map +1 -1
  53. package/dist/coordination/director/director-collab.d.ts +1 -1
  54. package/dist/coordination/director/director-collab.d.ts.map +1 -1
  55. package/dist/coordination/director-tools.d.ts.map +1 -1
  56. package/dist/coordination/director.d.ts +10 -1
  57. package/dist/coordination/director.d.ts.map +1 -1
  58. package/dist/coordination/file-author-tracker.d.ts.map +1 -1
  59. package/dist/coordination/fleet-bus.d.ts.map +1 -1
  60. package/dist/coordination/fleet-event-validation.d.ts +0 -7
  61. package/dist/coordination/fleet-event-validation.d.ts.map +1 -1
  62. package/dist/coordination/fleet-spawn.d.ts.map +1 -1
  63. package/dist/coordination/fleet-supervisor.d.ts +1 -1
  64. package/dist/coordination/fleet-supervisor.d.ts.map +1 -1
  65. package/dist/coordination/fleet.d.ts +0 -44
  66. package/dist/coordination/fleet.d.ts.map +1 -1
  67. package/dist/coordination/global-mailbox.d.ts +7 -1
  68. package/dist/coordination/global-mailbox.d.ts.map +1 -1
  69. package/dist/coordination/index.d.ts +5 -3
  70. package/dist/coordination/index.d.ts.map +1 -1
  71. package/dist/coordination/index.js +2426 -299
  72. package/dist/coordination/index.js.map +4 -4
  73. package/dist/coordination/knowledge-graph.d.ts +2 -1
  74. package/dist/coordination/knowledge-graph.d.ts.map +1 -1
  75. package/dist/coordination/large-answer-store.d.ts +0 -6
  76. package/dist/coordination/large-answer-store.d.ts.map +1 -1
  77. package/dist/coordination/mail-tools.d.ts +2 -2
  78. package/dist/coordination/mail-tools.d.ts.map +1 -1
  79. package/dist/coordination/mailbox-hooks.d.ts +2 -0
  80. package/dist/coordination/mailbox-hooks.d.ts.map +1 -1
  81. package/dist/coordination/mailbox-http-router.d.ts +43 -0
  82. package/dist/coordination/mailbox-http-router.d.ts.map +1 -0
  83. package/dist/coordination/mailbox-message-codec.d.ts +35 -0
  84. package/dist/coordination/mailbox-message-codec.d.ts.map +1 -1
  85. package/dist/coordination/mailbox-tool.d.ts +1 -1
  86. package/dist/coordination/mailbox-tool.d.ts.map +1 -1
  87. package/dist/coordination/mailbox-types.d.ts +170 -10
  88. package/dist/coordination/mailbox-types.d.ts.map +1 -1
  89. package/dist/coordination/mailbox.d.ts +1 -1
  90. package/dist/coordination/mailbox.d.ts.map +1 -1
  91. package/dist/coordination/package-author-tracker.d.ts.map +1 -1
  92. package/dist/coordination/provider-status-tracker.d.ts +236 -0
  93. package/dist/coordination/provider-status-tracker.d.ts.map +1 -0
  94. package/dist/coordination/subagent-budget.d.ts +2 -1
  95. package/dist/coordination/subagent-budget.d.ts.map +1 -1
  96. package/dist/core/agent-loop.d.ts +8 -3
  97. package/dist/core/agent-loop.d.ts.map +1 -1
  98. package/dist/core/agent-response.d.ts +5 -4
  99. package/dist/core/agent-response.d.ts.map +1 -1
  100. package/dist/core/agent-tools.d.ts +1 -1
  101. package/dist/core/agent-tools.d.ts.map +1 -1
  102. package/dist/core/agent.d.ts +4 -2
  103. package/dist/core/agent.d.ts.map +1 -1
  104. package/dist/core/context.d.ts +55 -1
  105. package/dist/core/context.d.ts.map +1 -1
  106. package/dist/core/fallback-model.d.ts +14 -8
  107. package/dist/core/fallback-model.d.ts.map +1 -1
  108. package/dist/core/fallback-profile-manager.d.ts +118 -0
  109. package/dist/core/fallback-profile-manager.d.ts.map +1 -0
  110. package/dist/core/fleet-pulse.d.ts +2 -1
  111. package/dist/core/fleet-pulse.d.ts.map +1 -1
  112. package/dist/core/iteration-limit.d.ts +2 -1
  113. package/dist/core/iteration-limit.d.ts.map +1 -1
  114. package/dist/core/mailbox-loop.d.ts +16 -1
  115. package/dist/core/mailbox-loop.d.ts.map +1 -1
  116. package/dist/core/model-availability-calendar.d.ts +27 -0
  117. package/dist/core/model-availability-calendar.d.ts.map +1 -0
  118. package/dist/core/provider-runner.d.ts.map +1 -1
  119. package/dist/core/system-prompt-builder.d.ts +2 -1
  120. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  121. package/dist/defaults/index.js +1920 -598
  122. package/dist/defaults/index.js.map +4 -4
  123. package/dist/execution/auto-compaction-middleware.d.ts +3 -2
  124. package/dist/execution/auto-compaction-middleware.d.ts.map +1 -1
  125. package/dist/execution/compaction-core.d.ts.map +1 -1
  126. package/dist/execution/council-brain.d.ts +28 -49
  127. package/dist/execution/council-brain.d.ts.map +1 -1
  128. package/dist/execution/council-orchestrator.d.ts +30 -0
  129. package/dist/execution/council-orchestrator.d.ts.map +1 -1
  130. package/dist/execution/enhance-recovery.d.ts +8 -0
  131. package/dist/execution/enhance-recovery.d.ts.map +1 -1
  132. package/dist/execution/error-handler.d.ts +2 -2
  133. package/dist/execution/error-handler.d.ts.map +1 -1
  134. package/dist/execution/eternal-autonomy.d.ts.map +1 -1
  135. package/dist/execution/index.js +2600 -1903
  136. package/dist/execution/index.js.map +4 -4
  137. package/dist/execution/intelligent-compactor.d.ts +0 -16
  138. package/dist/execution/intelligent-compactor.d.ts.map +1 -1
  139. package/dist/execution/model-runtime.d.ts.map +1 -1
  140. package/dist/execution/one-shot-llm.d.ts +9 -1
  141. package/dist/execution/one-shot-llm.d.ts.map +1 -1
  142. package/dist/execution/prompt-enhancer.d.ts +36 -0
  143. package/dist/execution/prompt-enhancer.d.ts.map +1 -1
  144. package/dist/execution/prompt-enhancer.js +158 -10
  145. package/dist/execution/prompt-enhancer.js.map +2 -2
  146. package/dist/execution/retry-policy.d.ts +0 -13
  147. package/dist/execution/retry-policy.d.ts.map +1 -1
  148. package/dist/execution/skill-loader.d.ts.map +1 -1
  149. package/dist/execution/tool-executor.d.ts.map +1 -1
  150. package/dist/goal/checkpoint.d.ts.map +1 -0
  151. package/dist/{autophase/auto-phase-planner.d.ts → goal/goal-planner.d.ts} +8 -8
  152. package/dist/goal/goal-planner.d.ts.map +1 -0
  153. package/dist/{autophase/auto-phase-runner.d.ts → goal/goal-runner.d.ts} +10 -10
  154. package/dist/goal/goal-runner.d.ts.map +1 -0
  155. package/dist/{autophase → goal}/index.d.ts +3 -3
  156. package/dist/goal/index.d.ts.map +1 -0
  157. package/dist/goal/phase-graph-builder.d.ts.map +1 -0
  158. package/dist/{autophase → goal}/phase-orchestrator.d.ts +2 -2
  159. package/dist/goal/phase-orchestrator.d.ts.map +1 -0
  160. package/dist/goal/phase-store.d.ts.map +1 -0
  161. package/dist/{autophase → goal}/types.d.ts +2 -2
  162. package/dist/goal/types.d.ts.map +1 -0
  163. package/dist/hq/auth-store.d.ts.map +1 -1
  164. package/dist/hq/commands.d.ts +2 -1
  165. package/dist/hq/commands.d.ts.map +1 -1
  166. package/dist/hq/exposure.d.ts +66 -0
  167. package/dist/hq/exposure.d.ts.map +1 -0
  168. package/dist/hq/index.d.ts +1 -0
  169. package/dist/hq/index.d.ts.map +1 -1
  170. package/dist/hq/index.js +190 -21
  171. package/dist/hq/index.js.map +4 -4
  172. package/dist/hq/mailbox-mapper.d.ts +13 -1
  173. package/dist/hq/mailbox-mapper.d.ts.map +1 -1
  174. package/dist/hq/protocol/browser.d.ts +9 -1
  175. package/dist/hq/protocol/browser.d.ts.map +1 -1
  176. package/dist/hq/protocol/client.d.ts +2 -2
  177. package/dist/hq/protocol/client.d.ts.map +1 -1
  178. package/dist/hq/protocol/core.d.ts.map +1 -1
  179. package/dist/hq/protocol/mailbox.d.ts +6 -0
  180. package/dist/hq/protocol/mailbox.d.ts.map +1 -1
  181. package/dist/hq/protocol/session.d.ts +4 -0
  182. package/dist/hq/protocol/session.d.ts.map +1 -1
  183. package/dist/hq/publisher.d.ts.map +1 -1
  184. package/dist/index.d.ts +34 -25
  185. package/dist/index.d.ts.map +1 -1
  186. package/dist/index.js +30287 -22214
  187. package/dist/index.js.map +4 -4
  188. package/dist/infrastructure/index.js +60 -5
  189. package/dist/infrastructure/index.js.map +2 -2
  190. package/dist/kernel/events/agent-events.d.ts +33 -1
  191. package/dist/kernel/events/agent-events.d.ts.map +1 -1
  192. package/dist/kernel/events/file-events.d.ts +65 -0
  193. package/dist/kernel/events/file-events.d.ts.map +1 -0
  194. package/dist/kernel/events/memory-events.d.ts +36 -0
  195. package/dist/kernel/events/memory-events.d.ts.map +1 -1
  196. package/dist/kernel/events/network-events.d.ts +60 -0
  197. package/dist/kernel/events/network-events.d.ts.map +1 -0
  198. package/dist/kernel/events/process-events.d.ts +44 -0
  199. package/dist/kernel/events/process-events.d.ts.map +1 -0
  200. package/dist/kernel/events/provider-events.d.ts +89 -0
  201. package/dist/kernel/events/provider-events.d.ts.map +1 -1
  202. package/dist/kernel/events/tool-events.d.ts +10 -0
  203. package/dist/kernel/events/tool-events.d.ts.map +1 -1
  204. package/dist/kernel/events/worktree-events.d.ts +1 -1
  205. package/dist/kernel/events.d.ts +14 -1
  206. package/dist/kernel/events.d.ts.map +1 -1
  207. package/dist/kernel/index.js +2 -1
  208. package/dist/kernel/index.js.map +2 -2
  209. package/dist/kernel/tokens.d.ts +3 -1
  210. package/dist/kernel/tokens.d.ts.map +1 -1
  211. package/dist/mailbox-attach.d.ts.map +1 -1
  212. package/dist/models/index.js.map +2 -2
  213. package/dist/observability/index.d.ts +3 -0
  214. package/dist/observability/index.d.ts.map +1 -1
  215. package/dist/observability/index.js +278 -0
  216. package/dist/observability/index.js.map +4 -4
  217. package/dist/observability/network-telemetry.d.ts +15 -0
  218. package/dist/observability/network-telemetry.d.ts.map +1 -0
  219. package/dist/observability/process-telemetry.d.ts +18 -0
  220. package/dist/observability/process-telemetry.d.ts.map +1 -0
  221. package/dist/observability/redact-command.d.ts +20 -0
  222. package/dist/observability/redact-command.d.ts.map +1 -0
  223. package/dist/plugins/auto-review-plugin.d.ts +56 -3
  224. package/dist/plugins/auto-review-plugin.d.ts.map +1 -1
  225. package/dist/plugins/chimera-plugin.d.ts +164 -5
  226. package/dist/plugins/chimera-plugin.d.ts.map +1 -1
  227. package/dist/plugins/review-context-builder.d.ts +52 -0
  228. package/dist/plugins/review-context-builder.d.ts.map +1 -0
  229. package/dist/security/index.d.ts +1 -0
  230. package/dist/security/index.d.ts.map +1 -1
  231. package/dist/security/index.js +186 -9
  232. package/dist/security/index.js.map +4 -4
  233. package/dist/security/kanban-boundary.d.ts +10 -0
  234. package/dist/security/kanban-boundary.d.ts.map +1 -0
  235. package/dist/security/permission-policy.d.ts +1 -0
  236. package/dist/security/permission-policy.d.ts.map +1 -1
  237. package/dist/session-registry.d.ts +80 -0
  238. package/dist/session-registry.d.ts.map +1 -1
  239. package/dist/skills/index.js.map +2 -2
  240. package/dist/storage/config-loader.d.ts +7 -0
  241. package/dist/storage/config-loader.d.ts.map +1 -1
  242. package/dist/storage/file-session-writer.d.ts +20 -7
  243. package/dist/storage/file-session-writer.d.ts.map +1 -1
  244. package/dist/storage/goal-coordination.d.ts +40 -0
  245. package/dist/storage/goal-coordination.d.ts.map +1 -0
  246. package/dist/storage/goal-store.d.ts +9 -5
  247. package/dist/storage/goal-store.d.ts.map +1 -1
  248. package/dist/storage/index.d.ts +4 -2
  249. package/dist/storage/index.d.ts.map +1 -1
  250. package/dist/storage/index.js +1066 -226
  251. package/dist/storage/index.js.map +4 -4
  252. package/dist/storage/memory-consolidator.d.ts +49 -4
  253. package/dist/storage/memory-consolidator.d.ts.map +1 -1
  254. package/dist/storage/memory-graph-backend.d.ts +11 -0
  255. package/dist/storage/memory-graph-backend.d.ts.map +1 -1
  256. package/dist/storage/provider-config-watcher.d.ts +19 -0
  257. package/dist/storage/provider-config-watcher.d.ts.map +1 -1
  258. package/dist/storage/session-event-bridge.d.ts +2 -2
  259. package/dist/storage/session-event-bridge.d.ts.map +1 -1
  260. package/dist/storage/session-resume-validation.d.ts +10 -0
  261. package/dist/storage/session-resume-validation.d.ts.map +1 -1
  262. package/dist/storage/session-rewind-apply.d.ts +53 -0
  263. package/dist/storage/session-rewind-apply.d.ts.map +1 -0
  264. package/dist/storage/session-rewinder.d.ts.map +1 -1
  265. package/dist/storage/session-store.d.ts.map +1 -1
  266. package/dist/tasking/index.js.map +1 -1
  267. package/dist/tasking/task-store.d.ts +1 -1
  268. package/dist/tools/council-tool.d.ts +3 -0
  269. package/dist/tools/council-tool.d.ts.map +1 -1
  270. package/dist/tools/fallback-manage-tools.d.ts +82 -0
  271. package/dist/tools/fallback-manage-tools.d.ts.map +1 -0
  272. package/dist/tools/index.d.ts +1 -0
  273. package/dist/tools/index.d.ts.map +1 -1
  274. package/dist/tools/index.js +3423 -192
  275. package/dist/tools/index.js.map +4 -4
  276. package/dist/tools/one-shot-llm-tool.d.ts +2 -0
  277. package/dist/tools/one-shot-llm-tool.d.ts.map +1 -1
  278. package/dist/types/config.d.ts +76 -7
  279. package/dist/types/config.d.ts.map +1 -1
  280. package/dist/types/file-event-record.d.ts +68 -0
  281. package/dist/types/file-event-record.d.ts.map +1 -0
  282. package/dist/types/index.d.ts +1 -0
  283. package/dist/types/index.d.ts.map +1 -1
  284. package/dist/types/index.js +13 -8
  285. package/dist/types/index.js.map +3 -3
  286. package/dist/types/memory.d.ts +12 -0
  287. package/dist/types/memory.d.ts.map +1 -1
  288. package/dist/types/multi-agent.d.ts +12 -1
  289. package/dist/types/multi-agent.d.ts.map +1 -1
  290. package/dist/types/one-shot-llm.d.ts +16 -7
  291. package/dist/types/one-shot-llm.d.ts.map +1 -1
  292. package/dist/types/provider.d.ts +1 -1
  293. package/dist/types/provider.d.ts.map +1 -1
  294. package/dist/types/session.d.ts +68 -2
  295. package/dist/types/session.d.ts.map +1 -1
  296. package/dist/types/tool-executor.d.ts +2 -0
  297. package/dist/types/tool-executor.d.ts.map +1 -1
  298. package/dist/types/tool.d.ts +5 -0
  299. package/dist/types/tool.d.ts.map +1 -1
  300. package/dist/utils/atomic-write.d.ts.map +1 -1
  301. package/dist/utils/index.d.ts +10 -10
  302. package/dist/utils/index.d.ts.map +1 -1
  303. package/dist/utils/index.js +497 -254
  304. package/dist/utils/index.js.map +4 -4
  305. package/dist/utils/message-invariants.d.ts +9 -0
  306. package/dist/utils/message-invariants.d.ts.map +1 -1
  307. package/dist/utils/safe-json.d.ts +1 -1
  308. package/dist/utils/safe-json.d.ts.map +1 -1
  309. package/dist/utils/term.d.ts +279 -0
  310. package/dist/utils/term.d.ts.map +1 -1
  311. package/dist/utils/tool-wire-compact.d.ts +9 -0
  312. package/dist/utils/tool-wire-compact.d.ts.map +1 -1
  313. package/dist/utils/wstack-paths.d.ts +12 -2
  314. package/dist/utils/wstack-paths.d.ts.map +1 -1
  315. package/dist/worktree/worktree-manager.d.ts +1 -1
  316. package/dist/worktree/worktree-manager.d.ts.map +1 -1
  317. package/instructions/agents/ios.md +113 -0
  318. package/instructions/agents/search.md +1 -1
  319. package/instructions/llm/chimera-review.md +66 -9
  320. package/instructions/llm/memory-consolidator.md +4 -12
  321. package/instructions/llm/prompt-enhancer.md +3 -1
  322. package/instructions/sections/tool/common-patterns.md +3 -3
  323. package/instructions/system.md +40 -5
  324. package/package.json +7 -3
  325. package/skills/auto-review/SKILL.md +176 -0
  326. package/skills/mnemosyne/SKILL.md +156 -0
  327. package/skills/mnemosyne/instructions/agent-prompt.md +200 -0
  328. package/dist/autophase/auto-phase-planner.d.ts.map +0 -1
  329. package/dist/autophase/auto-phase-runner.d.ts.map +0 -1
  330. package/dist/autophase/checkpoint.d.ts.map +0 -1
  331. package/dist/autophase/index.d.ts.map +0 -1
  332. package/dist/autophase/phase-graph-builder.d.ts.map +0 -1
  333. package/dist/autophase/phase-orchestrator.d.ts.map +0 -1
  334. package/dist/autophase/phase-store.d.ts.map +0 -1
  335. package/dist/autophase/types.d.ts.map +0 -1
  336. /package/dist/{autophase → goal}/checkpoint.d.ts +0 -0
  337. /package/dist/{autophase → goal}/phase-graph-builder.d.ts +0 -0
  338. /package/dist/{autophase → goal}/phase-store.d.ts +0 -0
  339. /package/instructions/{autophase → goal}/phase-planner.md +0 -0
@@ -39,22 +39,6 @@ export interface IntelligentCompactorOptions {
39
39
  /**
40
40
  * An importance label for a message or message range.
41
41
  */
42
- export type Importance = 'critical' | 'high' | 'medium' | 'low';
43
- /**
44
- * Result of importance analysis.
45
- */
46
- export interface ImportanceAnalysis {
47
- messages: Array<{
48
- index: number;
49
- importance: Importance;
50
- reason: string;
51
- }>;
52
- criticalRanges: Array<{
53
- from: number;
54
- to: number;
55
- summary: string;
56
- }>;
57
- }
58
42
  /**
59
43
  * IntelligentCompactor uses an LLM to:
60
44
  * - Analyze message importance and preserve critical context
@@ -1 +1 @@
1
- {"version":3,"file":"intelligent-compactor.d.ts","sourceRoot":"","sources":["../../src/execution/intelligent-compactor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAW,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAY7D;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,gEAAgE;IAChE,QAAQ,EAAE,QAAQ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,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACrD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,6BAA6B,GAClC,OAAO,CAmBT"}
@@ -10,7 +10,7 @@ import type { OneShotLLMInput, OneShotLLMResult, OneShotOrchestratorOptions } fr
10
10
  * system: 'You are a helpful assistant.',
11
11
  * userPrompt: 'Summarize this conversation.',
12
12
  * model: 'deepseek-chat',
13
- * fallbackProfile: 'summary',
13
+ * fallbackModels: ['anthropic/claude-haiku'],
14
14
  * });
15
15
  * console.log(result.text);
16
16
  * ```
@@ -44,9 +44,17 @@ export declare class OneShotOrchestrator {
44
44
  private resolveSignal;
45
45
  /**
46
46
  * Build the fallback model chain from input + config + current target.
47
+ * The injected {@link OneShotOrchestratorOptions.fallbackProfileManager}
48
+ * is the only allowed manager — OneShot never owns a private snapshot
49
+ * so a live `ConfigStore` change reaches every call without rebuilding
50
+ * the manager.
47
51
  */
48
52
  private resolveFallbackChain;
49
53
  /** Attempt a provider call while preserving the actual failure for callers. */
50
54
  private tryCall;
55
+ /** Build a success result from a provider Response. */
56
+ private buildResult;
57
+ /** Build a total-failure error result. */
58
+ private buildErrorResult;
51
59
  }
52
60
  //# sourceMappingURL=one-shot-llm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"one-shot-llm.d.ts","sourceRoot":"","sources":["../../src/execution/one-shot-llm.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAwB9G;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;IAElD,YAAY,IAAI,EAAE,0BAA0B,EAE3C;IAED;;;;;OAKG;IACG,IAAI,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAsH5D;IAID;;;OAGG;IACH,OAAO,CAAC,aAAa;IAmCrB;;OAEG;IACH,OAAO,CAAC,YAAY;IAkBpB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAKrB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA4B5B,+EAA+E;YACjE,OAAO;CAmBtB"}
1
+ {"version":3,"file":"one-shot-llm.d.ts","sourceRoot":"","sources":["../../src/execution/one-shot-llm.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,0BAA0B,CAAC;AAuBlC;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;IAElD,YAAY,IAAI,EAAE,0BAA0B,EAE3C;IAED;;;;;OAKG;IACG,IAAI,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAoI5D;IAID;;;OAGG;IACH,OAAO,CAAC,aAAa;IAmCrB;;OAEG;IACH,OAAO,CAAC,YAAY;IAkBpB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAKrB;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IA4B5B,+EAA+E;YACjE,OAAO;IAgCrB,uDAAuD;IACvD,OAAO,CAAC,WAAW;IA2BnB,0CAA0C;IAC1C,OAAO,CAAC,gBAAgB;CAiBzB"}
@@ -1,4 +1,5 @@
1
1
  import type { Message } from '../types/messages.js';
2
+ import type { MemoryStore } from '../types/memory.js';
2
3
  import type { Provider, ReasoningConfig, ReasoningRequest } from '../types/provider.js';
3
4
  import type { OneShotOrchestrator } from './one-shot-llm.js';
4
5
  /**
@@ -51,6 +52,24 @@ export interface ConversationTurn {
51
52
  role: 'user' | 'assistant';
52
53
  text: string;
53
54
  }
55
+ /** Additional context the refiner may use to resolve references. */
56
+ export interface RefinerContextSection {
57
+ title: string;
58
+ items: string[];
59
+ }
60
+ /**
61
+ * Minimal structural shape of the live agent context needed to enrich the
62
+ * refiner. Kept structural so browser/client bundles do not need the Context
63
+ * class and tests can pass plain objects.
64
+ */
65
+ export interface RefinerSessionContextLike {
66
+ projectRoot?: unknown;
67
+ cwd?: unknown;
68
+ workingDir?: unknown;
69
+ readFiles?: unknown;
70
+ writtenFiles?: unknown;
71
+ todos?: unknown;
72
+ }
54
73
  /**
55
74
  * Result of a successful prompt refinement. Carries the original-language and
56
75
  * English versions so the UI can offer both. When the input was already in
@@ -73,6 +92,7 @@ export interface EnhanceResult {
73
92
  * returns `null` with no `onError` call).
74
93
  */
75
94
  export type EnhanceFailureKind = 'timeout' | 'empty' | 'provider_error';
95
+ export declare const DEFAULT_REFINER_RETRY_FEEDBACK = "Make another pass that is sharper and more self-contained. Use the provided project memory, current session context, and recent conversation only to resolve references and preserve project vocabulary; keep the original scope unchanged.";
76
96
  export interface EnhanceUserPromptOptions {
77
97
  provider: Provider;
78
98
  model: string;
@@ -85,6 +105,17 @@ export interface EnhanceUserPromptOptions {
85
105
  * `recentTextTurns(ctx.messages)`.
86
106
  */
87
107
  history?: ConversationTurn[] | undefined;
108
+ /**
109
+ * Project/session context snippets, already filtered and compacted by the
110
+ * caller. They are context only: the refiner may use them to resolve
111
+ * references, names, files, conventions, and constraints, but must not turn
112
+ * them into extra requirements.
113
+ */
114
+ contextSections?: RefinerContextSection[] | undefined;
115
+ /** Previous refinement when the user asks for another pass. */
116
+ previousRefinement?: EnhanceResult | undefined;
117
+ /** Short instruction for a retry pass. Defaults to `DEFAULT_REFINER_RETRY_FEEDBACK`. */
118
+ retryFeedback?: string | undefined;
88
119
  /** Parent abort signal (e.g. the run controller / Esc). */
89
120
  signal?: AbortSignal | undefined;
90
121
  /** Hard cap on how long to wait for the refiner before giving up. Default 90s. */
@@ -116,6 +147,11 @@ export interface EnhanceUserPromptOptions {
116
147
  */
117
148
  oneShotOrchestrator?: OneShotOrchestrator | undefined;
118
149
  }
150
+ export declare function buildRefinerContextSections(opts: {
151
+ text: string;
152
+ memoryStore?: MemoryStore | undefined;
153
+ context?: RefinerSessionContextLike | undefined;
154
+ }): Promise<RefinerContextSection[]>;
119
155
  /**
120
156
  * Refine a raw user prompt. Returns the refined text, or `null` when the
121
157
  * caller should fall back to the original (refiner errored, timed out, was
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-enhancer.d.ts","sourceRoot":"","sources":["../../src/execution/prompt-enhancer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EAEf,gBAAgB,EAEjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,sBAAsB,QAAuD,CAAC;AAM3F;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAUnD;AAoBD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,eAAe,GAAG,SAAS,GAC9B,gBAAgB,GAAG,SAAS,CAU9B;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAG7D;AAED,oEAAoE;AACpE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,OAAO,GAAG,gBAAgB,CAAC;AAExE,MAAM,WAAW,wBAAwB;IACvC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AapB"}
@@ -83,25 +83,173 @@ function normalizedEqual(a, b) {
83
83
  const norm = (s) => s.trim().replace(/\s+/g, " ").toLowerCase();
84
84
  return norm(a) === norm(b);
85
85
  }
86
- function buildRefinerInput(text, history) {
87
- if (!history || history.length === 0) return text;
88
- const lines = history.map((t) => `${t.role === "user" ? "User" : "Assistant"}: ${t.text}`);
86
+ var DEFAULT_REFINER_RETRY_FEEDBACK = "Make another pass that is sharper and more self-contained. Use the provided project memory, current session context, and recent conversation only to resolve references and preserve project vocabulary; keep the original scope unchanged.";
87
+ function buildRefinerInput(text, history, contextSections, previousRefinement, retryFeedback) {
88
+ const parts = [];
89
+ const renderedContext = renderRefinerContextSections(contextSections);
90
+ if (renderedContext) parts.push(renderedContext);
91
+ if (previousRefinement || retryFeedback) {
92
+ const retryLines = [
93
+ "Retry context (context only - the user asked for another refinement pass):"
94
+ ];
95
+ if (previousRefinement?.refined) {
96
+ retryLines.push(`Previous refined version: ${compactText(previousRefinement.refined, 900)}`);
97
+ }
98
+ if (previousRefinement?.english && previousRefinement.english.trim() !== previousRefinement.refined.trim()) {
99
+ retryLines.push(`Previous English version: ${compactText(previousRefinement.english, 900)}`);
100
+ }
101
+ retryLines.push(`Retry instruction: ${retryFeedback ?? DEFAULT_REFINER_RETRY_FEEDBACK}`);
102
+ parts.push(retryLines.join("\n"));
103
+ }
104
+ if (history && history.length > 0) {
105
+ const lines = history.map((t) => `${t.role === "user" ? "User" : "Assistant"}: ${t.text}`);
106
+ parts.push(
107
+ [
108
+ "Recent conversation (context only - do not act on it):",
109
+ ...lines
110
+ ].join("\n")
111
+ );
112
+ }
113
+ if (parts.length === 0) return text;
89
114
  return [
90
- "Recent conversation (context only \u2014 do not act on it):",
91
- ...lines,
115
+ ...parts,
92
116
  "",
93
117
  "Latest message to refine:",
94
118
  text
95
- ].join("\n");
119
+ ].join("\n\n");
120
+ }
121
+ function renderRefinerContextSections(contextSections) {
122
+ const sections = (contextSections ?? []).map((section) => ({
123
+ title: section.title.trim(),
124
+ items: section.items.map((item) => compactText(item, 360)).filter(Boolean)
125
+ })).filter((section) => section.title && section.items.length > 0);
126
+ if (sections.length === 0) return void 0;
127
+ const lines = [
128
+ "Additional project/session context (context only - use to resolve references, conventions, and constraints; do not add new requirements):"
129
+ ];
130
+ for (const section of sections) {
131
+ lines.push("", `${section.title}:`);
132
+ for (const item of section.items) lines.push(`- ${item}`);
133
+ }
134
+ return lines.join("\n");
135
+ }
136
+ function compactText(text, maxChars) {
137
+ const compacted = text.replace(/\s+/g, " ").trim();
138
+ if (compacted.length <= maxChars) return compacted;
139
+ return `${compacted.slice(0, Math.max(0, maxChars - 3)).trimEnd()}...`;
140
+ }
141
+ function unknownString(value) {
142
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
143
+ }
144
+ function iterableStrings(value) {
145
+ if (!value || typeof value === "string") return [];
146
+ if (Array.isArray(value)) {
147
+ return value.flatMap((item) => {
148
+ const text = unknownString(item);
149
+ return text ? [text] : [];
150
+ });
151
+ }
152
+ if (value instanceof Set) {
153
+ return [...value].flatMap((item) => {
154
+ const text = unknownString(item);
155
+ return text ? [text] : [];
156
+ });
157
+ }
158
+ if (typeof value === "object" && typeof value[Symbol.iterator] === "function") {
159
+ try {
160
+ return Array.from(value).flatMap((item) => {
161
+ const text = unknownString(item);
162
+ return text ? [text] : [];
163
+ });
164
+ } catch {
165
+ return [];
166
+ }
167
+ }
168
+ return [];
169
+ }
170
+ function lastItems(values, maxItems) {
171
+ return values.slice(Math.max(0, values.length - maxItems));
172
+ }
173
+ function todoLines(value, maxItems) {
174
+ if (!Array.isArray(value)) return [];
175
+ const open = value.filter((item) => {
176
+ if (!item || typeof item !== "object") return false;
177
+ const status = item["status"];
178
+ return status === "pending" || status === "in_progress";
179
+ });
180
+ return open.slice(0, maxItems).flatMap((todo) => {
181
+ const content = unknownString(todo["activeForm"]) ?? unknownString(todo["content"]);
182
+ if (!content) return [];
183
+ return [`open todo (${String(todo["status"])}): ${compactText(content, 220)}`];
184
+ });
185
+ }
186
+ function buildRefinerSessionContextSection(context) {
187
+ if (!context) return void 0;
188
+ const items = [];
189
+ const projectRoot = unknownString(context.projectRoot);
190
+ const workingDir = unknownString(context.workingDir) ?? unknownString(context.cwd);
191
+ if (projectRoot) items.push(`project root: ${projectRoot}`);
192
+ if (workingDir && workingDir !== projectRoot) items.push(`working dir: ${workingDir}`);
193
+ for (const file of lastItems(iterableStrings(context.readFiles), 6)) {
194
+ items.push(`recently read file: ${file}`);
195
+ }
196
+ for (const file of lastItems(iterableStrings(context.writtenFiles), 6)) {
197
+ items.push(`recently written file: ${file}`);
198
+ }
199
+ items.push(...todoLines(context.todos, 6));
200
+ return items.length > 0 ? { title: "Current session state", items } : void 0;
201
+ }
202
+ function formatMemoryEntry(entry) {
203
+ const meta = [entry.scope, entry.type, entry.priority].filter(Boolean).join("/");
204
+ const tags = entry.tags && entry.tags.length > 0 ? ` tags: ${entry.tags.slice(0, 5).join(", ")}` : "";
205
+ return `${meta ? `[${meta}] ` : ""}${compactText(entry.text, 260)}${tags}`;
206
+ }
207
+ async function collectMemoryEntries(memoryStore, text, scope, limit) {
208
+ const scored = memoryStore.scoreRelevant ? await memoryStore.scoreRelevant({ currentTask: text }, scope, limit).catch(() => []) : [];
209
+ if (scored.length > 0) return scored;
210
+ return memoryStore.search(text || "prompt refinement", scope, limit).catch(() => []);
211
+ }
212
+ async function buildRefinerMemoryContextSection(memoryStore, text) {
213
+ if (!memoryStore) return void 0;
214
+ const seen = /* @__PURE__ */ new Set();
215
+ const entries = [];
216
+ for (const scope of ["project-memory", "user-memory"]) {
217
+ const remaining = Math.max(0, 6 - entries.length);
218
+ if (remaining === 0) break;
219
+ for (const entry of await collectMemoryEntries(memoryStore, text.trim(), scope, remaining)) {
220
+ const key = `${entry.scope}:${entry.text}`;
221
+ if (seen.has(key)) continue;
222
+ seen.add(key);
223
+ entries.push(entry);
224
+ if (entries.length >= 6) break;
225
+ }
226
+ }
227
+ if (entries.length === 0) return void 0;
228
+ return { title: "Relevant project memory", items: entries.map(formatMemoryEntry) };
229
+ }
230
+ async function buildRefinerContextSections(opts) {
231
+ const sections = [];
232
+ const memory = await buildRefinerMemoryContextSection(opts.memoryStore, opts.text);
233
+ if (memory) sections.push(memory);
234
+ const session = buildRefinerSessionContextSection(opts.context);
235
+ if (session) sections.push(session);
236
+ return sections;
96
237
  }
97
238
  async function enhanceUserPrompt(opts) {
98
239
  const { provider, model, text } = opts;
99
240
  const timeoutMs = opts.timeoutMs ?? 9e4;
100
241
  const maxTokens = opts.maxTokens ?? 2048;
242
+ const refinerInput = buildRefinerInput(
243
+ text,
244
+ opts.history,
245
+ opts.contextSections,
246
+ opts.previousRefinement,
247
+ opts.retryFeedback
248
+ );
101
249
  const req = {
102
250
  model,
103
251
  system: [{ type: "text", text: ENHANCER_SYSTEM_PROMPT }],
104
- messages: [{ role: "user", content: buildRefinerInput(text, opts.history) }],
252
+ messages: [{ role: "user", content: refinerInput }],
105
253
  maxTokens,
106
254
  // NOTE: deliberately NO `temperature`. The main agent loop never sets it,
107
255
  // and reasoning models (DeepSeek reasoner, o1/o3, …) return HTTP 400 when
@@ -122,9 +270,7 @@ async function enhanceUserPrompt(opts) {
122
270
  if (opts.oneShotOrchestrator) {
123
271
  const result = await opts.oneShotOrchestrator.call({
124
272
  system: ENHANCER_SYSTEM_PROMPT,
125
- messages: [
126
- { role: "user", content: buildRefinerInput(text, opts.history) }
127
- ],
273
+ messages: [{ role: "user", content: refinerInput }],
128
274
  maxTokens,
129
275
  timeoutMs,
130
276
  signal: opts.signal
@@ -185,7 +331,9 @@ function recentTextTurns(messages, maxTurns = 6, maxChars = 1500) {
185
331
  return turns;
186
332
  }
187
333
  export {
334
+ DEFAULT_REFINER_RETRY_FEEDBACK,
188
335
  ENHANCER_SYSTEM_PROMPT,
336
+ buildRefinerContextSections,
189
337
  enhanceUserPrompt,
190
338
  gatedEnhancerReasoning,
191
339
  normalizedEqual,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types/blocks.ts", "../../src/utils/error.ts", "../../src/utils/instruction-file.ts", "../../src/execution/prompt-enhancer.ts"],
4
- "sourcesContent": ["export interface TextBlock {\n type: 'text';\n text: string;\n cache_control?: { type: 'ephemeral' | undefined };\n}\n\nexport interface ToolUseBlock {\n type: 'tool_use';\n id: string;\n name: string;\n input: Record<string, unknown>;\n /**\n * Provider-specific opaque metadata captured from the wire response.\n * Echoed back verbatim in the next request so providers that bind\n * extra state to function calls keep working. Example: Gemini's\n * `thoughtSignature` \u2014 required for tool-use turns with thinking\n * models, otherwise the next request fails with 400 \"Function call\n * is missing a thought_signature in functionCall parts\".\n *\n * Keys are namespaced by intent so multiple wires can coexist:\n * - `google.thoughtSignature` \u2014 Gemini signed-thought blob\n * Other providers can add their own keys without colliding.\n */\n providerMeta?: Record<string, unknown>;\n}\n\nexport interface ToolResultBlock {\n type: 'tool_result';\n tool_use_id: string;\n /**\n * The original tool name. Useful for providers like Google Gemini that\n * need the tool name in `functionResponse.name` \u2014 the tool_use_id is\n * only a session-local identifier and is not stable across replays.\n * Always set by ToolExecutor; may be absent on manually-constructed blocks.\n */\n name?: string | undefined;\n content: string;\n is_error?: boolean | undefined;\n}\n\nexport interface ImageBlock {\n type: 'image';\n source: {\n type: 'base64' | 'url';\n media_type?: string | undefined;\n data?: string | undefined;\n url?: string | undefined;\n };\n}\n\n/**\n * Chain-of-thought / extended-thinking content emitted by the model.\n *\n * Both Anthropic extended thinking (`{type:'thinking', thinking, signature}`)\n * and DeepSeek reasoning mode (top-level `reasoning_content` on the assistant\n * message) require this content to be echoed back verbatim on the next\n * request, otherwise the provider returns 400:\n * - Anthropic: \"The `content[].thinking` in the thinking mode must be passed back\"\n * - DeepSeek: \"The `reasoning_content` in the thinking mode must be passed back\"\n *\n * `signature` is Anthropic-specific (an opaque integrity blob). DeepSeek\n * doesn't issue a signature \u2014 the field is absent for that provider.\n *\n * Per Anthropic, thinking blocks MUST appear before any text/tool_use blocks\n * in an assistant message. Stream builders preserve that order.\n */\nexport interface ThinkingBlock {\n type: 'thinking';\n thinking: string;\n signature?: string | undefined;\n providerMeta?: Record<string, unknown>;\n}\n\nexport type ContentBlock = TextBlock | ToolUseBlock | ToolResultBlock | ImageBlock | ThinkingBlock;\n\nexport function isTextBlock(b: ContentBlock): b is TextBlock {\n return b.type === 'text';\n}\nexport function isToolUseBlock(b: ContentBlock): b is ToolUseBlock {\n return b.type === 'tool_use';\n}\nexport function isToolResultBlock(b: ContentBlock): b is ToolResultBlock {\n return b.type === 'tool_result';\n}\nexport function isImageBlock(b: ContentBlock): b is ImageBlock {\n return b.type === 'image';\n}\n", "/**\n * Converts an unknown error value to a human-readable string.\n * Used in 40+ files across the codebase to normalize error messaging.\n */\nexport function toErrorMessage(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n", "import { readFileSync, statSync } from 'node:fs';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n/**\n * Cache of resolved instruction text, keyed by the relative path. Bundled\n * instruction files are immutable for the process lifetime, so re-reading them\n * on every call (some callers do so per LLM request) is wasted disk I/O.\n */\nconst textCache = new Map<string, string>();\n\n/** Resolved once \u2014 the candidate roots only depend on this module's location. */\nlet rootCandidates: string[] | undefined;\n\nexport function readBundledInstructionText(relativePath: string): string {\n const cached = textCache.get(relativePath);\n if (cached !== undefined) return cached;\n\n let resolved = '';\n for (const root of instructionRootCandidates()) {\n try {\n resolved = readFileSync(path.join(root, relativePath), 'utf8').trimEnd();\n break;\n } catch {\n // try next candidate\n }\n }\n textCache.set(relativePath, resolved);\n return resolved;\n}\n\nexport function renderInstructionTemplate(\n template: string,\n values: Record<string, string>,\n): string {\n return template.replace(/\\{\\{\\s*([a-zA-Z0-9_.-]+)\\s*\\}\\}/g, (match, key: string) =>\n Object.hasOwn(values, key) ? (values[key] ?? '') : match,\n );\n}\n\nfunction instructionRootCandidates(): string[] {\n if (rootCandidates !== undefined) return rootCandidates;\n const here = path.dirname(fileURLToPath(import.meta.url));\n const candidates = [\n path.resolve(here, '../../instructions'),\n path.resolve(here, '../instructions'),\n path.resolve(here, 'instructions'),\n ];\n rootCandidates = candidates.sort((a, b) => Number(!isDirectory(a)) - Number(!isDirectory(b)));\n return rootCandidates;\n}\n\nfunction isDirectory(candidate: string): boolean {\n try {\n return statSync(candidate).isDirectory();\n } catch {\n return false;\n }\n}\n", "import type { ContentBlock } from '../types/blocks.js';\nimport { isTextBlock } from '../types/blocks.js';\nimport type { Message } from '../types/messages.js';\nimport type {\n Provider,\n ReasoningConfig,\n ReasoningEffort,\n ReasoningRequest,\n Request,\n} from '../types/provider.js';\nimport { toErrorMessage } from '../utils/error.js';\nimport type { OneShotOrchestrator } from './one-shot-llm.js';\nimport { readBundledInstructionText } from '../utils/instruction-file.js';\n\n/**\n * Prompt refinement (\"did you mean this?\").\n *\n * Runs a one-shot LLM call in a SEPARATE context (its own system prompt, no\n * conversation history, no tools) that rewrites a raw user message into a\n * clearer, more complete instruction BEFORE the main agent sees it. The goal\n * is to make the main context start from a well-understood request rather than\n * guessing intent from terse input like \"fix the bug\".\n *\n * This mirrors `IntelligentCompactor.callSummarizer` \u2014 a plain\n * `provider.complete()` with a dedicated system prompt \u2014 and is deliberately\n * free of React / TUI dependencies so it can be unit-tested in isolation.\n */\n\nexport const ENHANCER_SYSTEM_PROMPT = readBundledInstructionText('llm/prompt-enhancer.md');\n\n/** Words/phrases that are control answers, not refinable requests. */\nconst AFFIRMATION_RE =\n /^(y|n|yes|no|yep|nope|ok|okay|sure|go|go ahead|continue|proceed|stop|cancel|done|next|skip|retry|again|please do|do it)\\b[.! ]*$/i;\n\n/**\n * Heuristic gate: should this raw input be sent through the refiner at all?\n * Pure + exported for unit testing. Returns false for inputs where refinement\n * is pointless or unwanted (slash commands, one-word affirmations, trivially\n * short text, bare numbers).\n */\nexport function shouldEnhance(text: string): boolean {\n const t = text.trim();\n if (!t) return false;\n if (t.startsWith('/')) return false; // slash command\n if (t.length < 12) return false; // too short to be worth refining\n if (AFFIRMATION_RE.test(t)) return false; // \"yes\" / \"continue\" / ...\n if (/^[\\d\\s.,]+$/.test(t)) return false; // bare numbers (menu picks, etc.)\n const words = t.split(/\\s+/).filter(Boolean);\n if (words.length < 3) return false; // 1\u20132 words rarely benefit\n return true;\n}\n\n/**\n * Preference order when picking an effort level: the cheapest level that still\n * does SOME reasoning first ('low', then 'minimal'), then up the ladder, with\n * fully-off ('none') last so it's only chosen when it's the sole advertised\n * option. This keeps the refiner cheap without dropping reasoning entirely when\n * a little still helps. 'low' leads because it's the most widely accepted low\n * level across adapters (e.g. OpenAI's reasoning_effort set).\n */\nconst EFFORT_PREFERENCE: ReasoningEffort[] = [\n 'low',\n 'minimal',\n 'medium',\n 'high',\n 'xhigh',\n 'max',\n 'none',\n];\n\n/**\n * Build a reasoning directive for the refiner that minimizes wasted thinking,\n * gated to what the model actually accepts. Refinement is a shallow rewrite\n * task \u2014 extended thinking adds latency and (hidden) token cost for little\n * gain \u2014 so we ask the model to spend as little reasoning as it safely can.\n *\n * The gating mirrors `resolveReasoningForRequest` so we never send a field the\n * model would reject:\n * - effort-capable model \u2192 its lowest advertised effort level;\n * - else disable-capable model \u2192 disable thinking (`enabled: false`);\n * - else (always-on / unknown) \u2192 `undefined` (leave the provider default).\n *\n * Returns `undefined` whenever nothing can be safely reduced. Callers forward\n * that verbatim to `enhanceUserPrompt`, which then sends no reasoning field \u2014\n * identical to the behavior before this hint existed. Pure + exported for unit\n * testing.\n */\nexport function gatedEnhancerReasoning(\n rc: ReasoningConfig | undefined,\n): ReasoningRequest | undefined {\n // Capabilities unknown \u2192 don't risk an unsupported field (matches the\n // conservative \"capabilities unknown\" branch in resolveReasoningForRequest).\n if (!rc) return undefined;\n if (rc.effortSupported && rc.effortLevels.length > 0) {\n const lowest = EFFORT_PREFERENCE.find((e) => rc.effortLevels.includes(e)) ?? rc.effortLevels[0];\n if (lowest) return { effort: lowest };\n }\n if (rc.disableSupported) return { enabled: false };\n return undefined;\n}\n\n/**\n * Normalize for \"did the refiner actually change anything?\" comparison \u2014\n * collapse whitespace and lowercase so trivial reformatting doesn't trigger\n * the confirmation panel.\n */\nexport function normalizedEqual(a: string, b: string): boolean {\n const norm = (s: string) => s.trim().replace(/\\s+/g, ' ').toLowerCase();\n return norm(a) === norm(b);\n}\n\n/** A single text-only conversation turn used as refiner context. */\nexport interface ConversationTurn {\n role: 'user' | 'assistant';\n text: string;\n}\n\n/**\n * Result of a successful prompt refinement. Carries the original-language and\n * English versions so the UI can offer both. When the input was already in\n * English the refiner emits a single version and both fields hold the same\n * text (the UI then offers two identical choices, which is correct).\n */\nexport interface EnhanceResult {\n /** Refined in the user's original language. */\n refined: string;\n /** Refined in English. Equals `refined` when the input was already English. */\n english: string;\n}\n\n/**\n * Why a refine attempt fell through. Callers use this to decide the recovery\n * path: `timeout` is a transient capacity/latency failure worth an automatic\n * retry with a longer window (the model was reachable, just slow); `empty` and\n * `provider_error` mean the attempt produced nothing useful, so the caller\n * should surface the recovery options (retry, switch model, send as-is) rather\n * than silently retry. User-initiated cancellation is NOT reported here (it\n * returns `null` with no `onError` call).\n */\nexport type EnhanceFailureKind = 'timeout' | 'empty' | 'provider_error';\n\nexport interface EnhanceUserPromptOptions {\n provider: Provider;\n model: string;\n text: string;\n /**\n * Recent conversation turns (oldest\u2192newest), text only, used purely as\n * CONTEXT so the refiner can resolve references in a follow-up message\n * (\"it\", \"the same\", \"that file\"). Without this, the refiner is blind to\n * the conversation and can only refine self-contained prompts. Build with\n * `recentTextTurns(ctx.messages)`.\n */\n history?: ConversationTurn[] | undefined;\n /** Parent abort signal (e.g. the run controller / Esc). */\n signal?: AbortSignal | undefined;\n /** Hard cap on how long to wait for the refiner before giving up. Default 90s. */\n timeoutMs?: number | undefined;\n /** Max tokens for the refined output. Default 2048. */\n maxTokens?: number | undefined;\n /**\n * Reasoning directive for the refiner call. Refinement is a shallow\n * restate-this-more-clearly task that does not benefit from extended\n * thinking, so callers pass a low-effort / thinking-disabled hint here to\n * cut latency and (hidden) reasoning-token cost \u2014 most impactful on slow\n * reasoning models. Build it with `gatedEnhancerReasoning(rc)` so the field\n * is gated to what the model accepts. Omit (undefined) to send no reasoning\n * directive at all (the provider's own default applies).\n */\n reasoning?: ReasoningRequest | undefined;\n /**\n * Called with a short reason and a machine-readable `kind` when refinement\n * fails (provider error, timeout, empty response). NOT called when the caller\n * cancels via `signal`. The `kind` lets the UI drive recovery: `timeout` is\n * eligible for an automatic longer-window retry; `empty` / `provider_error`\n * surface the recovery options instead. The second argument is optional so\n * existing callers that only read the reason keep compiling.\n */\n onError?: ((reason: string, kind?: EnhanceFailureKind) => void) | undefined;\n /**\n * OneShotOrchestrator for the refiner LLM call. When set, uses it instead\n * of direct provider.complete(), gaining fallback chain support.\n */\n oneShotOrchestrator?: OneShotOrchestrator | undefined;\n}\n\n/**\n * Compose the single user message sent to the refiner: the recent\n * conversation embedded as plain text (so we never trip provider\n * role-alternation rules) followed by the latest message to refine.\n */\nfunction buildRefinerInput(text: string, history?: ConversationTurn[]): string {\n if (!history || history.length === 0) return text;\n const lines = history.map((t) => `${t.role === 'user' ? 'User' : 'Assistant'}: ${t.text}`);\n return [\n 'Recent conversation (context only \u2014 do not act on it):',\n ...lines,\n '',\n 'Latest message to refine:',\n text,\n ].join('\\n');\n}\n\n/**\n * Refine a raw user prompt. Returns the refined text, or `null` when the\n * caller should fall back to the original (refiner errored, timed out, was\n * aborted, or returned nothing useful). NEVER throws \u2014 refinement is a\n * best-effort convenience and must never block the user from sending.\n */\nexport async function enhanceUserPrompt(\n opts: EnhanceUserPromptOptions,\n): Promise<EnhanceResult | null> {\n const { provider, model, text } = opts;\n // Reasoning models (\"thinking\" models like DeepSeek reasoner / o1) take\n // longer to first token, so give a generous default window.\n const timeoutMs = opts.timeoutMs ?? 90000;\n // Generous default: on some endpoints the model's hidden \"thinking\" tokens\n // count against this budget, so a small cap can leave NO room for the actual\n // refined text (\u2192 empty completion \u2192 null). 2048 keeps the output room ample.\n const maxTokens = opts.maxTokens ?? 2048;\n\n const req: Request = {\n model,\n system: [{ type: 'text', text: ENHANCER_SYSTEM_PROMPT }],\n messages: [{ role: 'user', content: buildRefinerInput(text, opts.history) }],\n maxTokens,\n // NOTE: deliberately NO `temperature`. The main agent loop never sets it,\n // and reasoning models (DeepSeek reasoner, o1/o3, \u2026) return HTTP 400 when\n // `temperature` is present \u2014 which would make every refine call fail and\n // silently fall back to the original (no panel shown).\n //\n // A reasoning hint is forwarded ONLY when the caller supplies one (it must\n // already be gated to the model's advertised support \u2014 see\n // `gatedEnhancerReasoning`). Absent it, no reasoning field is sent, which\n // is identical to the original behavior.\n ...(opts.reasoning ? { reasoning: opts.reasoning } : {}),\n };\n\n // Link a local timeout to the parent signal so a stuck provider call can't\n // hang the submit path. AbortSignal.any keeps both cancellation sources.\n const timer = new AbortController();\n const to = setTimeout(() => timer.abort(new Error('enhancer timeout')), timeoutMs);\n const signal = opts.signal ? AbortSignal.any([opts.signal, timer.signal]) : timer.signal;\n\n try {\n let raw: string;\n if (opts.oneShotOrchestrator) {\n const result = await opts.oneShotOrchestrator.call({\n system: ENHANCER_SYSTEM_PROMPT,\n messages: [\n { role: 'user', content: buildRefinerInput(text, opts.history) },\n ],\n maxTokens,\n timeoutMs,\n signal: opts.signal,\n });\n if (result.error) {\n opts.onError?.(result.error, 'provider_error');\n return null;\n }\n raw = result.text;\n } else {\n const res = await provider.complete(req, { signal });\n raw = res.content\n .filter(isTextBlock)\n .map((b) => b.text)\n .join('\\n')\n .trim();\n }\n if (!raw) {\n opts.onError?.('model returned no text', 'empty');\n return null;\n }\n\n // English input \u2192 ONE version (no \"---\"); other languages \u2192 two versions\n // separated by a line with only \"---\". Split on the first occurrence so the\n // delimiter can still appear inside the second version's text.\n const sepIdx = raw.indexOf('\\n---\\n');\n if (sepIdx === -1) {\n // Single version: the input was already English (or the model chose not\n // to translate). Use it for both fields \u2014 the UI offers identical\n // \"refined\" / \"english\" options, which is correct and saves the model\n // from generating a redundant second copy. NOT an error.\n return { refined: raw, english: raw };\n }\n const refined = raw.slice(0, sepIdx).trim();\n const english = raw.slice(sepIdx + 5).trim(); // skip \"\\n---\\n\"\n if (!refined || !english) {\n opts.onError?.('one or both versions empty', 'empty');\n return null;\n }\n return { refined, english };\n } catch (err) {\n // User-initiated cancel \u2192 stay silent (they chose to send the original).\n if (opts.signal?.aborted) return null;\n if (timer.signal.aborted) {\n opts.onError?.(`timed out after ${Math.round(timeoutMs / 1000)}s`, 'timeout');\n return null;\n }\n opts.onError?.(toErrorMessage(err), 'provider_error');\n return null;\n } finally {\n // Idempotent \u2014 abort() after signal already fired is a no-op, so this is\n // always safe regardless of whether the timeout fired first.\n timer.abort();\n clearTimeout(to);\n }\n}\n\n/** Pull the visible text out of a message's content (ignores tool blocks). */\nfunction messageText(content: string | ContentBlock[]): string {\n if (typeof content === 'string') return content;\n return content\n .filter(isTextBlock)\n .map((b) => b.text)\n .join('\\n')\n .trim();\n}\n\n/**\n * Extract the last few user/assistant TEXT turns from a conversation, newest\n * last, for use as refiner context. Skips system messages and tool-only turns\n * (tool_use / tool_result carry no useful natural-language context and bloat\n * the call). Each turn is truncated to `maxChars`; at most `maxTurns` are\n * returned. Pure + exported for unit testing.\n */\nexport function recentTextTurns(\n messages: Message[],\n maxTurns = 6,\n maxChars = 1500,\n): ConversationTurn[] {\n const turns: ConversationTurn[] = [];\n for (let i = messages.length - 1; i >= 0 && turns.length < maxTurns; i--) {\n const m = messages[i];\n if (!m || (m.role !== 'user' && m.role !== 'assistant')) continue;\n const text = messageText(m.content);\n if (!text) continue;\n turns.unshift({\n role: m.role,\n text: text.length > maxChars ? `${text.slice(0, maxChars - 1)}\u2026` : text,\n });\n }\n return turns;\n}\n"],
5
- "mappings": ";AA2EO,SAAS,YAAY,GAAiC;AAC3D,SAAO,EAAE,SAAS;AACpB;;;ACzEO,SAAS,eAAe,KAAsB;AACnD,SAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AACxD;;;ACNA,SAAS,cAAc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,UAAM,UAAU,IAAI,MAAM,SAAS,CAAC,EAAE,KAAK;AAC3C,QAAI,CAAC,WAAW,CAAC,SAAS;AACxB,WAAK,UAAU,8BAA8B,OAAO;AACpD,aAAO;AAAA,IACT;AACA,WAAO,EAAE,SAAS,QAAQ;AAAA,EAC5B,SAAS,KAAK;AAEZ,QAAI,KAAK,QAAQ,QAAS,QAAO;AACjC,QAAI,MAAM,OAAO,SAAS;AACxB,WAAK,UAAU,mBAAmB,KAAK,MAAM,YAAY,GAAI,CAAC,KAAK,SAAS;AAC5E,aAAO;AAAA,IACT;AACA,SAAK,UAAU,eAAe,GAAG,GAAG,gBAAgB;AACpD,WAAO;AAAA,EACT,UAAE;AAGA,UAAM,MAAM;AACZ,iBAAa,EAAE;AAAA,EACjB;AACF;AAGA,SAAS,YAAY,SAA0C;AAC7D,MAAI,OAAO,YAAY,SAAU,QAAO;AACxC,SAAO,QACJ,OAAO,WAAW,EAClB,IAAI,CAAC,MAAM,EAAE,IAAI,EACjB,KAAK,IAAI,EACT,KAAK;AACV;AASO,SAAS,gBACd,UACA,WAAW,GACX,WAAW,MACS;AACpB,QAAM,QAA4B,CAAC;AACnC,WAAS,IAAI,SAAS,SAAS,GAAG,KAAK,KAAK,MAAM,SAAS,UAAU,KAAK;AACxE,UAAM,IAAI,SAAS,CAAC;AACpB,QAAI,CAAC,KAAM,EAAE,SAAS,UAAU,EAAE,SAAS,YAAc;AACzD,UAAM,OAAO,YAAY,EAAE,OAAO;AAClC,QAAI,CAAC,KAAM;AACX,UAAM,QAAQ;AAAA,MACZ,MAAM,EAAE;AAAA,MACR,MAAM,KAAK,SAAS,WAAW,GAAG,KAAK,MAAM,GAAG,WAAW,CAAC,CAAC,WAAM;AAAA,IACrE,CAAC;AAAA,EACH;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["export interface TextBlock {\n type: 'text';\n text: string;\n cache_control?: { type: 'ephemeral' | undefined };\n}\n\nexport interface ToolUseBlock {\n type: 'tool_use';\n id: string;\n name: string;\n input: Record<string, unknown>;\n /**\n * Provider-specific opaque metadata captured from the wire response.\n * Echoed back verbatim in the next request so providers that bind\n * extra state to function calls keep working. Example: Gemini's\n * `thoughtSignature` \u2014 required for tool-use turns with thinking\n * models, otherwise the next request fails with 400 \"Function call\n * is missing a thought_signature in functionCall parts\".\n *\n * Keys are namespaced by intent so multiple wires can coexist:\n * - `google.thoughtSignature` \u2014 Gemini signed-thought blob\n * Other providers can add their own keys without colliding.\n */\n providerMeta?: Record<string, unknown>;\n}\n\nexport interface ToolResultBlock {\n type: 'tool_result';\n tool_use_id: string;\n /**\n * The original tool name. Useful for providers like Google Gemini that\n * need the tool name in `functionResponse.name` \u2014 the tool_use_id is\n * only a session-local identifier and is not stable across replays.\n * Always set by ToolExecutor; may be absent on manually-constructed blocks.\n */\n name?: string | undefined;\n content: string;\n is_error?: boolean | undefined;\n}\n\nexport interface ImageBlock {\n type: 'image';\n source: {\n type: 'base64' | 'url';\n media_type?: string | undefined;\n data?: string | undefined;\n url?: string | undefined;\n };\n}\n\n/**\n * Chain-of-thought / extended-thinking content emitted by the model.\n *\n * Both Anthropic extended thinking (`{type:'thinking', thinking, signature}`)\n * and DeepSeek reasoning mode (top-level `reasoning_content` on the assistant\n * message) require this content to be echoed back verbatim on the next\n * request, otherwise the provider returns 400:\n * - Anthropic: \"The `content[].thinking` in the thinking mode must be passed back\"\n * - DeepSeek: \"The `reasoning_content` in the thinking mode must be passed back\"\n *\n * `signature` is Anthropic-specific (an opaque integrity blob). DeepSeek\n * doesn't issue a signature \u2014 the field is absent for that provider.\n *\n * Per Anthropic, thinking blocks MUST appear before any text/tool_use blocks\n * in an assistant message. Stream builders preserve that order.\n */\nexport interface ThinkingBlock {\n type: 'thinking';\n thinking: string;\n signature?: string | undefined;\n providerMeta?: Record<string, unknown>;\n}\n\nexport type ContentBlock = TextBlock | ToolUseBlock | ToolResultBlock | ImageBlock | ThinkingBlock;\n\nexport function isTextBlock(b: ContentBlock): b is TextBlock {\n return b.type === 'text';\n}\nexport function isToolUseBlock(b: ContentBlock): b is ToolUseBlock {\n return b.type === 'tool_use';\n}\nexport function isToolResultBlock(b: ContentBlock): b is ToolResultBlock {\n return b.type === 'tool_result';\n}\nexport function isImageBlock(b: ContentBlock): b is ImageBlock {\n return b.type === 'image';\n}\n", "/**\n * Converts an unknown error value to a human-readable string.\n * Used in 40+ files across the codebase to normalize error messaging.\n */\nexport function toErrorMessage(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n", "import { readFileSync, statSync } from 'node:fs';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n/**\n * Cache of resolved instruction text, keyed by the relative path. Bundled\n * instruction files are immutable for the process lifetime, so re-reading them\n * on every call (some callers do so per LLM request) is wasted disk I/O.\n */\nconst textCache = new Map<string, string>();\n\n/** Resolved once \u2014 the candidate roots only depend on this module's location. */\nlet rootCandidates: string[] | undefined;\n\nexport function readBundledInstructionText(relativePath: string): string {\n const cached = textCache.get(relativePath);\n if (cached !== undefined) return cached;\n\n let resolved = '';\n for (const root of instructionRootCandidates()) {\n try {\n resolved = readFileSync(path.join(root, relativePath), 'utf8').trimEnd();\n break;\n } catch {\n // try next candidate\n }\n }\n textCache.set(relativePath, resolved);\n return resolved;\n}\n\nexport function renderInstructionTemplate(\n template: string,\n values: Record<string, string>,\n): string {\n return template.replace(/\\{\\{\\s*([a-zA-Z0-9_.-]+)\\s*\\}\\}/g, (match, key: string) =>\n Object.hasOwn(values, key) ? (values[key] ?? '') : match,\n );\n}\n\nfunction instructionRootCandidates(): string[] {\n if (rootCandidates !== undefined) return rootCandidates;\n const here = path.dirname(fileURLToPath(import.meta.url));\n const candidates = [\n path.resolve(here, '../../instructions'),\n path.resolve(here, '../instructions'),\n path.resolve(here, 'instructions'),\n ];\n rootCandidates = candidates.sort((a, b) => Number(!isDirectory(a)) - Number(!isDirectory(b)));\n return rootCandidates;\n}\n\nfunction isDirectory(candidate: string): boolean {\n try {\n return statSync(candidate).isDirectory();\n } catch {\n return false;\n }\n}\n", "import type { ContentBlock } from '../types/blocks.js';\nimport { isTextBlock } from '../types/blocks.js';\nimport type { Message } from '../types/messages.js';\nimport type { MemoryEntry, MemoryScope, MemoryStore } from '../types/memory.js';\nimport type {\n Provider,\n ReasoningConfig,\n ReasoningEffort,\n ReasoningRequest,\n Request,\n} from '../types/provider.js';\nimport { toErrorMessage } from '../utils/error.js';\nimport type { OneShotOrchestrator } from './one-shot-llm.js';\nimport { readBundledInstructionText } from '../utils/instruction-file.js';\n\n/**\n * Prompt refinement (\"did you mean this?\").\n *\n * Runs a one-shot LLM call in a SEPARATE context (its own system prompt, no\n * conversation history, no tools) that rewrites a raw user message into a\n * clearer, more complete instruction BEFORE the main agent sees it. The goal\n * is to make the main context start from a well-understood request rather than\n * guessing intent from terse input like \"fix the bug\".\n *\n * This mirrors `IntelligentCompactor.callSummarizer` \u2014 a plain\n * `provider.complete()` with a dedicated system prompt \u2014 and is deliberately\n * free of React / TUI dependencies so it can be unit-tested in isolation.\n */\n\nexport const ENHANCER_SYSTEM_PROMPT = readBundledInstructionText('llm/prompt-enhancer.md');\n\n/** Words/phrases that are control answers, not refinable requests. */\nconst AFFIRMATION_RE =\n /^(y|n|yes|no|yep|nope|ok|okay|sure|go|go ahead|continue|proceed|stop|cancel|done|next|skip|retry|again|please do|do it)\\b[.! ]*$/i;\n\n/**\n * Heuristic gate: should this raw input be sent through the refiner at all?\n * Pure + exported for unit testing. Returns false for inputs where refinement\n * is pointless or unwanted (slash commands, one-word affirmations, trivially\n * short text, bare numbers).\n */\nexport function shouldEnhance(text: string): boolean {\n const t = text.trim();\n if (!t) return false;\n if (t.startsWith('/')) return false; // slash command\n if (t.length < 12) return false; // too short to be worth refining\n if (AFFIRMATION_RE.test(t)) return false; // \"yes\" / \"continue\" / ...\n if (/^[\\d\\s.,]+$/.test(t)) return false; // bare numbers (menu picks, etc.)\n const words = t.split(/\\s+/).filter(Boolean);\n if (words.length < 3) return false; // 1\u20132 words rarely benefit\n return true;\n}\n\n/**\n * Preference order when picking an effort level: the cheapest level that still\n * does SOME reasoning first ('low', then 'minimal'), then up the ladder, with\n * fully-off ('none') last so it's only chosen when it's the sole advertised\n * option. This keeps the refiner cheap without dropping reasoning entirely when\n * a little still helps. 'low' leads because it's the most widely accepted low\n * level across adapters (e.g. OpenAI's reasoning_effort set).\n */\nconst EFFORT_PREFERENCE: ReasoningEffort[] = [\n 'low',\n 'minimal',\n 'medium',\n 'high',\n 'xhigh',\n 'max',\n 'none',\n];\n\n/**\n * Build a reasoning directive for the refiner that minimizes wasted thinking,\n * gated to what the model actually accepts. Refinement is a shallow rewrite\n * task \u2014 extended thinking adds latency and (hidden) token cost for little\n * gain \u2014 so we ask the model to spend as little reasoning as it safely can.\n *\n * The gating mirrors `resolveReasoningForRequest` so we never send a field the\n * model would reject:\n * - effort-capable model \u2192 its lowest advertised effort level;\n * - else disable-capable model \u2192 disable thinking (`enabled: false`);\n * - else (always-on / unknown) \u2192 `undefined` (leave the provider default).\n *\n * Returns `undefined` whenever nothing can be safely reduced. Callers forward\n * that verbatim to `enhanceUserPrompt`, which then sends no reasoning field \u2014\n * identical to the behavior before this hint existed. Pure + exported for unit\n * testing.\n */\nexport function gatedEnhancerReasoning(\n rc: ReasoningConfig | undefined,\n): ReasoningRequest | undefined {\n // Capabilities unknown \u2192 don't risk an unsupported field (matches the\n // conservative \"capabilities unknown\" branch in resolveReasoningForRequest).\n if (!rc) return undefined;\n if (rc.effortSupported && rc.effortLevels.length > 0) {\n const lowest = EFFORT_PREFERENCE.find((e) => rc.effortLevels.includes(e)) ?? rc.effortLevels[0];\n if (lowest) return { effort: lowest };\n }\n if (rc.disableSupported) return { enabled: false };\n return undefined;\n}\n\n/**\n * Normalize for \"did the refiner actually change anything?\" comparison \u2014\n * collapse whitespace and lowercase so trivial reformatting doesn't trigger\n * the confirmation panel.\n */\nexport function normalizedEqual(a: string, b: string): boolean {\n const norm = (s: string) => s.trim().replace(/\\s+/g, ' ').toLowerCase();\n return norm(a) === norm(b);\n}\n\n/** A single text-only conversation turn used as refiner context. */\nexport interface ConversationTurn {\n role: 'user' | 'assistant';\n text: string;\n}\n\n/** Additional context the refiner may use to resolve references. */\nexport interface RefinerContextSection {\n title: string;\n items: string[];\n}\n\n/**\n * Minimal structural shape of the live agent context needed to enrich the\n * refiner. Kept structural so browser/client bundles do not need the Context\n * class and tests can pass plain objects.\n */\nexport interface RefinerSessionContextLike {\n projectRoot?: unknown;\n cwd?: unknown;\n workingDir?: unknown;\n readFiles?: unknown;\n writtenFiles?: unknown;\n todos?: unknown;\n}\n\n/**\n * Result of a successful prompt refinement. Carries the original-language and\n * English versions so the UI can offer both. When the input was already in\n * English the refiner emits a single version and both fields hold the same\n * text (the UI then offers two identical choices, which is correct).\n */\nexport interface EnhanceResult {\n /** Refined in the user's original language. */\n refined: string;\n /** Refined in English. Equals `refined` when the input was already English. */\n english: string;\n}\n\n/**\n * Why a refine attempt fell through. Callers use this to decide the recovery\n * path: `timeout` is a transient capacity/latency failure worth an automatic\n * retry with a longer window (the model was reachable, just slow); `empty` and\n * `provider_error` mean the attempt produced nothing useful, so the caller\n * should surface the recovery options (retry, switch model, send as-is) rather\n * than silently retry. User-initiated cancellation is NOT reported here (it\n * returns `null` with no `onError` call).\n */\nexport type EnhanceFailureKind = 'timeout' | 'empty' | 'provider_error';\n\nexport const DEFAULT_REFINER_RETRY_FEEDBACK =\n 'Make another pass that is sharper and more self-contained. Use the provided project memory, current session context, and recent conversation only to resolve references and preserve project vocabulary; keep the original scope unchanged.';\n\nexport interface EnhanceUserPromptOptions {\n provider: Provider;\n model: string;\n text: string;\n /**\n * Recent conversation turns (oldest\u2192newest), text only, used purely as\n * CONTEXT so the refiner can resolve references in a follow-up message\n * (\"it\", \"the same\", \"that file\"). Without this, the refiner is blind to\n * the conversation and can only refine self-contained prompts. Build with\n * `recentTextTurns(ctx.messages)`.\n */\n history?: ConversationTurn[] | undefined;\n /**\n * Project/session context snippets, already filtered and compacted by the\n * caller. They are context only: the refiner may use them to resolve\n * references, names, files, conventions, and constraints, but must not turn\n * them into extra requirements.\n */\n contextSections?: RefinerContextSection[] | undefined;\n /** Previous refinement when the user asks for another pass. */\n previousRefinement?: EnhanceResult | undefined;\n /** Short instruction for a retry pass. Defaults to `DEFAULT_REFINER_RETRY_FEEDBACK`. */\n retryFeedback?: string | undefined;\n /** Parent abort signal (e.g. the run controller / Esc). */\n signal?: AbortSignal | undefined;\n /** Hard cap on how long to wait for the refiner before giving up. Default 90s. */\n timeoutMs?: number | undefined;\n /** Max tokens for the refined output. Default 2048. */\n maxTokens?: number | undefined;\n /**\n * Reasoning directive for the refiner call. Refinement is a shallow\n * restate-this-more-clearly task that does not benefit from extended\n * thinking, so callers pass a low-effort / thinking-disabled hint here to\n * cut latency and (hidden) reasoning-token cost \u2014 most impactful on slow\n * reasoning models. Build it with `gatedEnhancerReasoning(rc)` so the field\n * is gated to what the model accepts. Omit (undefined) to send no reasoning\n * directive at all (the provider's own default applies).\n */\n reasoning?: ReasoningRequest | undefined;\n /**\n * Called with a short reason and a machine-readable `kind` when refinement\n * fails (provider error, timeout, empty response). NOT called when the caller\n * cancels via `signal`. The `kind` lets the UI drive recovery: `timeout` is\n * eligible for an automatic longer-window retry; `empty` / `provider_error`\n * surface the recovery options instead. The second argument is optional so\n * existing callers that only read the reason keep compiling.\n */\n onError?: ((reason: string, kind?: EnhanceFailureKind) => void) | undefined;\n /**\n * OneShotOrchestrator for the refiner LLM call. When set, uses it instead\n * of direct provider.complete(), gaining fallback chain support.\n */\n oneShotOrchestrator?: OneShotOrchestrator | undefined;\n}\n\n/**\n * Compose the single user message sent to the refiner: the recent\n * conversation and project/session hints embedded as plain text (so we never\n * trip provider role-alternation rules) followed by the latest message to\n * refine.\n */\nfunction buildRefinerInput(\n text: string,\n history?: ConversationTurn[],\n contextSections?: RefinerContextSection[],\n previousRefinement?: EnhanceResult,\n retryFeedback?: string,\n): string {\n const parts: string[] = [];\n const renderedContext = renderRefinerContextSections(contextSections);\n if (renderedContext) parts.push(renderedContext);\n\n if (previousRefinement || retryFeedback) {\n const retryLines = [\n 'Retry context (context only - the user asked for another refinement pass):',\n ];\n if (previousRefinement?.refined) {\n retryLines.push(`Previous refined version: ${compactText(previousRefinement.refined, 900)}`);\n }\n if (\n previousRefinement?.english\n && previousRefinement.english.trim() !== previousRefinement.refined.trim()\n ) {\n retryLines.push(`Previous English version: ${compactText(previousRefinement.english, 900)}`);\n }\n retryLines.push(`Retry instruction: ${retryFeedback ?? DEFAULT_REFINER_RETRY_FEEDBACK}`);\n parts.push(retryLines.join('\\n'));\n }\n\n if (history && history.length > 0) {\n const lines = history.map((t) => `${t.role === 'user' ? 'User' : 'Assistant'}: ${t.text}`);\n parts.push(\n [\n 'Recent conversation (context only - do not act on it):',\n ...lines,\n ].join('\\n'),\n );\n }\n\n if (parts.length === 0) return text;\n return [\n ...parts,\n '',\n 'Latest message to refine:',\n text,\n ].join('\\n\\n');\n}\n\nfunction renderRefinerContextSections(\n contextSections?: RefinerContextSection[],\n): string | undefined {\n const sections = (contextSections ?? [])\n .map((section) => ({\n title: section.title.trim(),\n items: section.items.map((item) => compactText(item, 360)).filter(Boolean),\n }))\n .filter((section) => section.title && section.items.length > 0);\n if (sections.length === 0) return undefined;\n const lines = [\n 'Additional project/session context (context only - use to resolve references, conventions, and constraints; do not add new requirements):',\n ];\n for (const section of sections) {\n lines.push('', `${section.title}:`);\n for (const item of section.items) lines.push(`- ${item}`);\n }\n return lines.join('\\n');\n}\n\nfunction compactText(text: string, maxChars: number): string {\n const compacted = text.replace(/\\s+/g, ' ').trim();\n if (compacted.length <= maxChars) return compacted;\n return `${compacted.slice(0, Math.max(0, maxChars - 3)).trimEnd()}...`;\n}\n\nfunction unknownString(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() ? value.trim() : undefined;\n}\n\nfunction iterableStrings(value: unknown): string[] {\n if (!value || typeof value === 'string') return [];\n if (Array.isArray(value)) {\n return value.flatMap((item) => {\n const text = unknownString(item);\n return text ? [text] : [];\n });\n }\n if (value instanceof Set) {\n return [...value].flatMap((item) => {\n const text = unknownString(item);\n return text ? [text] : [];\n });\n }\n if (\n typeof value === 'object'\n && typeof (value as { [Symbol.iterator]?: unknown })[Symbol.iterator] === 'function'\n ) {\n try {\n return Array.from(value as Iterable<unknown>).flatMap((item) => {\n const text = unknownString(item);\n return text ? [text] : [];\n });\n } catch {\n return [];\n }\n }\n return [];\n}\n\nfunction lastItems(values: string[], maxItems: number): string[] {\n return values.slice(Math.max(0, values.length - maxItems));\n}\n\nfunction todoLines(value: unknown, maxItems: number): string[] {\n if (!Array.isArray(value)) return [];\n const open = value.filter((item): item is Record<string, unknown> => {\n if (!item || typeof item !== 'object') return false;\n const status = item['status'];\n return status === 'pending' || status === 'in_progress';\n });\n return open.slice(0, maxItems).flatMap((todo) => {\n const content = unknownString(todo['activeForm']) ?? unknownString(todo['content']);\n if (!content) return [];\n return [`open todo (${String(todo['status'])}): ${compactText(content, 220)}`];\n });\n}\n\nfunction buildRefinerSessionContextSection(\n context?: RefinerSessionContextLike,\n): RefinerContextSection | undefined {\n if (!context) return undefined;\n const items: string[] = [];\n const projectRoot = unknownString(context.projectRoot);\n const workingDir = unknownString(context.workingDir) ?? unknownString(context.cwd);\n if (projectRoot) items.push(`project root: ${projectRoot}`);\n if (workingDir && workingDir !== projectRoot) items.push(`working dir: ${workingDir}`);\n\n for (const file of lastItems(iterableStrings(context.readFiles), 6)) {\n items.push(`recently read file: ${file}`);\n }\n for (const file of lastItems(iterableStrings(context.writtenFiles), 6)) {\n items.push(`recently written file: ${file}`);\n }\n items.push(...todoLines(context.todos, 6));\n return items.length > 0 ? { title: 'Current session state', items } : undefined;\n}\n\nfunction formatMemoryEntry(entry: MemoryEntry): string {\n const meta = [entry.scope, entry.type, entry.priority].filter(Boolean).join('/');\n const tags = entry.tags && entry.tags.length > 0 ? ` tags: ${entry.tags.slice(0, 5).join(', ')}` : '';\n return `${meta ? `[${meta}] ` : ''}${compactText(entry.text, 260)}${tags}`;\n}\n\nasync function collectMemoryEntries(\n memoryStore: MemoryStore,\n text: string,\n scope: MemoryScope,\n limit: number,\n): Promise<MemoryEntry[]> {\n const scored = memoryStore.scoreRelevant\n ? await memoryStore\n .scoreRelevant({ currentTask: text }, scope, limit)\n .catch(() => [] as MemoryEntry[])\n : [];\n if (scored.length > 0) return scored;\n return memoryStore.search(text || 'prompt refinement', scope, limit).catch(() => []);\n}\n\nasync function buildRefinerMemoryContextSection(\n memoryStore: MemoryStore | undefined,\n text: string,\n): Promise<RefinerContextSection | undefined> {\n if (!memoryStore) return undefined;\n const seen = new Set<string>();\n const entries: MemoryEntry[] = [];\n for (const scope of ['project-memory', 'user-memory'] as const) {\n const remaining = Math.max(0, 6 - entries.length);\n if (remaining === 0) break;\n for (const entry of await collectMemoryEntries(memoryStore, text.trim(), scope, remaining)) {\n const key = `${entry.scope}:${entry.text}`;\n if (seen.has(key)) continue;\n seen.add(key);\n entries.push(entry);\n if (entries.length >= 6) break;\n }\n }\n if (entries.length === 0) return undefined;\n return { title: 'Relevant project memory', items: entries.map(formatMemoryEntry) };\n}\n\nexport async function buildRefinerContextSections(opts: {\n text: string;\n memoryStore?: MemoryStore | undefined;\n context?: RefinerSessionContextLike | undefined;\n}): Promise<RefinerContextSection[]> {\n const sections: RefinerContextSection[] = [];\n const memory = await buildRefinerMemoryContextSection(opts.memoryStore, opts.text);\n if (memory) sections.push(memory);\n const session = buildRefinerSessionContextSection(opts.context);\n if (session) sections.push(session);\n return sections;\n}\n\n/**\n * Refine a raw user prompt. Returns the refined text, or `null` when the\n * caller should fall back to the original (refiner errored, timed out, was\n * aborted, or returned nothing useful). NEVER throws \u2014 refinement is a\n * best-effort convenience and must never block the user from sending.\n */\nexport async function enhanceUserPrompt(\n opts: EnhanceUserPromptOptions,\n): Promise<EnhanceResult | null> {\n const { provider, model, text } = opts;\n // Reasoning models (\"thinking\" models like DeepSeek reasoner / o1) take\n // longer to first token, so give a generous default window.\n const timeoutMs = opts.timeoutMs ?? 90000;\n // Generous default: on some endpoints the model's hidden \"thinking\" tokens\n // count against this budget, so a small cap can leave NO room for the actual\n // refined text (\u2192 empty completion \u2192 null). 2048 keeps the output room ample.\n const maxTokens = opts.maxTokens ?? 2048;\n const refinerInput = buildRefinerInput(\n text,\n opts.history,\n opts.contextSections,\n opts.previousRefinement,\n opts.retryFeedback,\n );\n\n const req: Request = {\n model,\n system: [{ type: 'text', text: ENHANCER_SYSTEM_PROMPT }],\n messages: [{ role: 'user', content: refinerInput }],\n maxTokens,\n // NOTE: deliberately NO `temperature`. The main agent loop never sets it,\n // and reasoning models (DeepSeek reasoner, o1/o3, \u2026) return HTTP 400 when\n // `temperature` is present \u2014 which would make every refine call fail and\n // silently fall back to the original (no panel shown).\n //\n // A reasoning hint is forwarded ONLY when the caller supplies one (it must\n // already be gated to the model's advertised support \u2014 see\n // `gatedEnhancerReasoning`). Absent it, no reasoning field is sent, which\n // is identical to the original behavior.\n ...(opts.reasoning ? { reasoning: opts.reasoning } : {}),\n };\n\n // Link a local timeout to the parent signal so a stuck provider call can't\n // hang the submit path. AbortSignal.any keeps both cancellation sources.\n const timer = new AbortController();\n const to = setTimeout(() => timer.abort(new Error('enhancer timeout')), timeoutMs);\n const signal = opts.signal ? AbortSignal.any([opts.signal, timer.signal]) : timer.signal;\n\n try {\n let raw: string;\n if (opts.oneShotOrchestrator) {\n const result = await opts.oneShotOrchestrator.call({\n system: ENHANCER_SYSTEM_PROMPT,\n messages: [{ role: 'user', content: refinerInput }],\n maxTokens,\n timeoutMs,\n signal: opts.signal,\n });\n if (result.error) {\n opts.onError?.(result.error, 'provider_error');\n return null;\n }\n raw = result.text;\n } else {\n const res = await provider.complete(req, { signal });\n raw = res.content\n .filter(isTextBlock)\n .map((b) => b.text)\n .join('\\n')\n .trim();\n }\n if (!raw) {\n opts.onError?.('model returned no text', 'empty');\n return null;\n }\n\n // English input \u2192 ONE version (no \"---\"); other languages \u2192 two versions\n // separated by a line with only \"---\". Split on the first occurrence so the\n // delimiter can still appear inside the second version's text.\n const sepIdx = raw.indexOf('\\n---\\n');\n if (sepIdx === -1) {\n // Single version: the input was already English (or the model chose not\n // to translate). Use it for both fields \u2014 the UI offers identical\n // \"refined\" / \"english\" options, which is correct and saves the model\n // from generating a redundant second copy. NOT an error.\n return { refined: raw, english: raw };\n }\n const refined = raw.slice(0, sepIdx).trim();\n const english = raw.slice(sepIdx + 5).trim(); // skip \"\\n---\\n\"\n if (!refined || !english) {\n opts.onError?.('one or both versions empty', 'empty');\n return null;\n }\n return { refined, english };\n } catch (err) {\n // User-initiated cancel \u2192 stay silent (they chose to send the original).\n if (opts.signal?.aborted) return null;\n if (timer.signal.aborted) {\n opts.onError?.(`timed out after ${Math.round(timeoutMs / 1000)}s`, 'timeout');\n return null;\n }\n opts.onError?.(toErrorMessage(err), 'provider_error');\n return null;\n } finally {\n // Idempotent \u2014 abort() after signal already fired is a no-op, so this is\n // always safe regardless of whether the timeout fired first.\n timer.abort();\n clearTimeout(to);\n }\n}\n\n/** Pull the visible text out of a message's content (ignores tool blocks). */\nfunction messageText(content: string | ContentBlock[]): string {\n if (typeof content === 'string') return content;\n return content\n .filter(isTextBlock)\n .map((b) => b.text)\n .join('\\n')\n .trim();\n}\n\n/**\n * Extract the last few user/assistant TEXT turns from a conversation, newest\n * last, for use as refiner context. Skips system messages and tool-only turns\n * (tool_use / tool_result carry no useful natural-language context and bloat\n * the call). Each turn is truncated to `maxChars`; at most `maxTurns` are\n * returned. Pure + exported for unit testing.\n */\nexport function recentTextTurns(\n messages: Message[],\n maxTurns = 6,\n maxChars = 1500,\n): ConversationTurn[] {\n const turns: ConversationTurn[] = [];\n for (let i = messages.length - 1; i >= 0 && turns.length < maxTurns; i--) {\n const m = messages[i];\n if (!m || (m.role !== 'user' && m.role !== 'assistant')) continue;\n const text = messageText(m.content);\n if (!text) continue;\n turns.unshift({\n role: m.role,\n text: text.length > maxChars ? `${text.slice(0, maxChars - 1)}\u2026` : text,\n });\n }\n return tur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AC;AACpB,QAAI,CAAC,KAAM,EAAE,SAAS,UAAU,EAAE,SAAS,YAAc;AACzD,UAAM,OAAO,YAAY,EAAE,OAAO;AAClC,QAAI,CAAC,KAAM;AACX,UAAM,QAAQ;AAAA,MACZ,MAAM,EAAE;AAAA,MACR,MAAM,KAAK,SAAS,WAAW,GAAG,KAAK,MAAM,GAAG,WAAW,CAAC,CAAC,WAAM;AAAA,IACrE,CAAC;AAAA,EACH;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,18 +1,5 @@
1
1
  import { ProviderError } from '../types/provider.js';
2
2
  import type { RetryPolicy } from '../types/retry-policy.js';
3
- /**
4
- * Upper bound for any Retry-After hint surfaced by a provider.
5
- *
6
- * The HTTP `Retry-After` header can carry either a delta-seconds
7
- * integer or an absolute HTTP-date. The latter can legitimately be
8
- * far in the future if the provider is asking us to back off for
9
- * minutes or hours. We never want to be stuck waiting that long —
10
- * the agent kernel has its own pacing and a multi-minute single
11
- * retry would freeze the user. 60 seconds is the conventional cap
12
- * (it matches what most providers document as the practical upper
13
- * bound for a single rate-limit window).
14
- */
15
- export declare const MAX_RETRY_AFTER_MS = 60000;
16
3
  export declare class DefaultRetryPolicy implements RetryPolicy {
17
4
  shouldRetry(err: Error | ProviderError, attempt: number): boolean;
18
5
  maxAttempts(err: Error | ProviderError): number;
@@ -1 +1 @@
1
- {"version":3,"file":"retry-policy.d.ts","sourceRoot":"","sources":["../../src/execution/retry-policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAA0B,MAAM,sBAAsB,CAAC;AAE7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAuBzC,qBAAa,kBAAmB,YAAW,WAAW;IACpD,WAAW,CAAC,GAAG,EAAE,KAAK,GAAG,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAShE;IAED,WAAW,CAAC,GAAG,EAAE,KAAK,GAAG,aAAa,GAAG,MAAM,CAK9C;IAED;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,GAAG,aAAa,GAAG,MAAM,CAmB5D;CACF"}
1
+ {"version":3,"file":"retry-policy.d.ts","sourceRoot":"","sources":["../../src/execution/retry-policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAA0B,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAuC5D,qBAAa,kBAAmB,YAAW,WAAW;IACpD,WAAW,CAAC,GAAG,EAAE,KAAK,GAAG,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAShE;IAED,WAAW,CAAC,GAAG,EAAE,KAAK,GAAG,aAAa,GAAG,MAAM,CAK9C;IAED;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,GAAG,aAAa,GAAG,MAAM,CAmB5D;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"skill-loader.d.ts","sourceRoot":"","sources":["../../src/execution/skill-loader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AA+D5D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,WAAW,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,qIAAqI;IACrI,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IAChD,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,EAAE,GAA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AAO,CAAC,EAAE,MAAM,GAAG,UAAU,EAAE,CAI9C;IAEK,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQ7D;YAEa,UAAU;YAyBV,cAAc;YAkCd,YAAY;YAqCZ,gBAAgB;CA0B/B"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * AutoPhasePlanner - converts a goal into phases using a real LLM call,
2
+ * GoalPlanner - converts a goal into phases using a real LLM call,
3
3
  * producing a large task list with todos under each phase.
4
4
  *
5
5
  * Similar to SDD's spec-to-task flow, but different: the output is directly
@@ -11,7 +11,7 @@
11
11
  * (a subagent run in the CLI, or a deterministic stub in tests).
12
12
  */
13
13
  import type { PhaseTemplate } from './types.js';
14
- export interface AutoPhasePlannerOptions {
14
+ export interface GoalPlannerOptions {
15
15
  /**
16
16
  * One-shot LLM call: receives a prompt and returns the model text output.
17
17
  * In the CLI this wraps subagent.run; in tests it can be a deterministic stub.
@@ -34,7 +34,7 @@ export interface AutoPhasePlannerOptions {
34
34
  */
35
35
  maxTotalTasks?: number | undefined;
36
36
  }
37
- export interface AutoPhasePlanResult {
37
+ export interface GoalPlanResult {
38
38
  /** Phase templates passed to PhaseGraphBuilder. */
39
39
  phases: PhaseTemplate[];
40
40
  /** Raw model output for debugging and logs. */
@@ -52,13 +52,13 @@ export interface AutoPhasePlanResult {
52
52
  budgetExceeded?: boolean | undefined;
53
53
  }
54
54
  /**
55
- * AutoPhasePlanner drives the model through `plan()` and produces `PhaseTemplate[]`.
55
+ * GoalPlanner drives the model through `plan()` and produces `PhaseTemplate[]`.
56
56
  */
57
- export declare class AutoPhasePlanner {
57
+ export declare class GoalPlanner {
58
58
  private readonly opts;
59
- constructor(opts: AutoPhasePlannerOptions);
59
+ constructor(opts: GoalPlannerOptions);
60
60
  /** Convert the goal into a phase-and-todo plan. */
61
- plan(): Promise<AutoPhasePlanResult>;
61
+ plan(): Promise<GoalPlanResult>;
62
62
  /** Instruction prompt for the plan the model should produce. */
63
63
  buildPrompt(): string;
64
64
  /** Extract JSON from raw output, validate it, and convert it to PhaseTemplate[].
@@ -76,4 +76,4 @@ export declare class AutoPhasePlanner {
76
76
  * 2. The first balanced [ ... ] block in the text, aware of strings and escapes
77
77
  */
78
78
  export declare function extractJSONArray(text: string): string | null;
79
- //# sourceMappingURL=auto-phase-planner.d.ts.map
79
+ //# sourceMappingURL=goal-planner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goal-planner.d.ts","sourceRoot":"","sources":["../../src/goal/goal-planner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,KAAK,EAAa,aAAa,EAAE,MAAM,YAAY,CAAC;AAK3D,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,0EAA0E;IAC1E,WAAW,EAAE,OAAO,CAAC;IACrB,sFAAsF;IACtF,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,yDAAyD;IACzD,cAAc,CA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