@kenkaiiii/ggcoder 6.4.0 → 7.0.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 (1116) hide show
  1. package/README.md +9 -8
  2. package/dist/app-sidecar/app-settings.d.ts +1 -1
  3. package/dist/app-sidecar/app-settings.js +3 -4
  4. package/dist/app-sidecar/app-settings.js.map +1 -1
  5. package/dist/app-sidecar/attachments.js +1 -1
  6. package/dist/app-sidecar/attachments.js.map +1 -1
  7. package/dist/app-sidecar/auth-routes.js +2 -5
  8. package/dist/app-sidecar/auth-routes.js.map +1 -1
  9. package/dist/app-sidecar/autopilot-runner.d.ts +8 -8
  10. package/dist/app-sidecar/autopilot-runner.js +8 -8
  11. package/dist/app-sidecar/autopilot-runner.js.map +1 -1
  12. package/dist/app-sidecar/branch-routes.d.ts +8 -1
  13. package/dist/app-sidecar/branch-routes.js +154 -2
  14. package/dist/app-sidecar/branch-routes.js.map +1 -1
  15. package/dist/app-sidecar/detached-sessions.d.ts +2 -10
  16. package/dist/app-sidecar/detached-sessions.js.map +1 -1
  17. package/dist/app-sidecar/file-search.js +1 -1
  18. package/dist/app-sidecar/file-search.js.map +1 -1
  19. package/dist/app-sidecar/git-branches.d.ts +18 -1
  20. package/dist/app-sidecar/git-branches.js +24 -6
  21. package/dist/app-sidecar/git-branches.js.map +1 -1
  22. package/dist/app-sidecar/git-ship.d.ts +42 -0
  23. package/dist/app-sidecar/git-ship.js +349 -0
  24. package/dist/app-sidecar/git-ship.js.map +1 -0
  25. package/dist/app-sidecar/git-target.d.ts +2 -2
  26. package/dist/app-sidecar/git-target.js +2 -2
  27. package/dist/app-sidecar/git-target.js.map +1 -1
  28. package/dist/app-sidecar/goal-routes.d.ts +1 -1
  29. package/dist/app-sidecar/goal-routes.js +5 -6
  30. package/dist/app-sidecar/goal-routes.js.map +1 -1
  31. package/dist/app-sidecar/hf-pull-manager.d.ts +5 -4
  32. package/dist/app-sidecar/hf-pull-manager.js +1 -1
  33. package/dist/app-sidecar/hf-pull-manager.js.map +1 -1
  34. package/dist/app-sidecar/history-routes.js +6 -6
  35. package/dist/app-sidecar/history-routes.js.map +1 -1
  36. package/dist/app-sidecar/history.d.ts +2 -2
  37. package/dist/app-sidecar/integration-routes.js +4 -6
  38. package/dist/app-sidecar/integration-routes.js.map +1 -1
  39. package/dist/app-sidecar/keep-awake.d.ts +1 -1
  40. package/dist/app-sidecar/keep-awake.js +1 -1
  41. package/dist/app-sidecar/keep-awake.js.map +1 -1
  42. package/dist/app-sidecar/ken-context.d.ts +2 -2
  43. package/dist/app-sidecar/ken-context.js +1 -1
  44. package/dist/app-sidecar/ken-context.js.map +1 -1
  45. package/dist/app-sidecar/live-preview/dev-url.d.ts +1 -1
  46. package/dist/app-sidecar/live-preview/manager.d.ts +2 -14
  47. package/dist/app-sidecar/live-preview/manager.js.map +1 -1
  48. package/dist/app-sidecar/live-preview/routes.js +1 -1
  49. package/dist/app-sidecar/live-preview/routes.js.map +1 -1
  50. package/dist/app-sidecar/live-preview/servers.js +1 -1
  51. package/dist/app-sidecar/live-preview/servers.js.map +1 -1
  52. package/dist/app-sidecar/mcp-routes.js +2 -2
  53. package/dist/app-sidecar/mcp-routes.js.map +1 -1
  54. package/dist/app-sidecar/mcp-rows.d.ts +3 -15
  55. package/dist/app-sidecar/mcp-rows.js +7 -2
  56. package/dist/app-sidecar/mcp-rows.js.map +1 -1
  57. package/dist/app-sidecar/mcp-shell-command.d.ts +1 -1
  58. package/dist/app-sidecar/mcp-shell-command.js +3 -3
  59. package/dist/app-sidecar/mcp-shell-command.js.map +1 -1
  60. package/dist/app-sidecar/mcp-sync.d.ts +2 -2
  61. package/dist/app-sidecar/mcp-sync.js +3 -3
  62. package/dist/app-sidecar/mcp-sync.js.map +1 -1
  63. package/dist/app-sidecar/progress-manager.d.ts +1 -1
  64. package/dist/app-sidecar/progress-manager.js +6 -6
  65. package/dist/app-sidecar/progress-manager.js.map +1 -1
  66. package/dist/app-sidecar/prompt-routes.js +5 -5
  67. package/dist/app-sidecar/prompt-routes.js.map +1 -1
  68. package/dist/app-sidecar/repo-polls.d.ts +3 -3
  69. package/dist/app-sidecar/repo-polls.js +4 -4
  70. package/dist/app-sidecar/repo-polls.js.map +1 -1
  71. package/dist/app-sidecar/route-context.d.ts +17 -17
  72. package/dist/app-sidecar/run-control-routes.js +2 -5
  73. package/dist/app-sidecar/run-control-routes.js.map +1 -1
  74. package/dist/app-sidecar/session-file-routes.d.ts +1 -1
  75. package/dist/app-sidecar/session-file-routes.js +2 -2
  76. package/dist/app-sidecar/session-file-routes.js.map +1 -1
  77. package/dist/app-sidecar/session-routes.js +3 -4
  78. package/dist/app-sidecar/session-routes.js.map +1 -1
  79. package/dist/app-sidecar/session-types.d.ts +5 -13
  80. package/dist/app-sidecar/shell-routes.js +1 -1
  81. package/dist/app-sidecar/shell-routes.js.map +1 -1
  82. package/dist/app-sidecar/shell-runs.js +2 -2
  83. package/dist/app-sidecar/shell-runs.js.map +1 -1
  84. package/dist/app-sidecar/shell-suggestions.d.ts +2 -8
  85. package/dist/app-sidecar/shell-suggestions.js +1 -1
  86. package/dist/app-sidecar/shell-suggestions.js.map +1 -1
  87. package/dist/app-sidecar/task-routes.js +5 -5
  88. package/dist/app-sidecar/task-routes.js.map +1 -1
  89. package/dist/app-sidecar/trophy-manager.d.ts +2 -2
  90. package/dist/app-sidecar/trophy-manager.js +3 -3
  91. package/dist/app-sidecar/trophy-manager.js.map +1 -1
  92. package/dist/app-sidecar/usage.d.ts +1 -1
  93. package/dist/app-sidecar/usage.js +3 -2
  94. package/dist/app-sidecar/usage.js.map +1 -1
  95. package/dist/app-sidecar/workspace-routes.js +4 -4
  96. package/dist/app-sidecar/workspace-routes.js.map +1 -1
  97. package/dist/app-sidecar/worktrees.js +1 -1
  98. package/dist/app-sidecar/worktrees.js.map +1 -1
  99. package/dist/app-sidecar-sessions.d.ts +2 -5
  100. package/dist/app-sidecar-sessions.js +1 -1
  101. package/dist/app-sidecar-sessions.js.map +1 -1
  102. package/dist/app-sidecar.d.ts +1 -1
  103. package/dist/app-sidecar.js +47 -45
  104. package/dist/app-sidecar.js.map +1 -1
  105. package/dist/chat-agents/general.d.ts +1 -1
  106. package/dist/chat-agents/index.d.ts +1 -1
  107. package/dist/chat-agents/jiwa.d.ts +2 -9
  108. package/dist/chat-agents/jiwa.js +1 -0
  109. package/dist/chat-agents/jiwa.js.map +1 -1
  110. package/dist/chat-agents/memory.d.ts +2 -9
  111. package/dist/chat-agents/memory.js +1 -0
  112. package/dist/chat-agents/memory.js.map +1 -1
  113. package/dist/chat-agents/research.d.ts +1 -1
  114. package/dist/chat-agents/shared.d.ts +1 -1
  115. package/dist/chat-agents/shared.js +1 -1
  116. package/dist/chat-agents/shared.js.map +1 -1
  117. package/dist/chat-agents/therapist.d.ts +1 -1
  118. package/dist/chat-agents/types.d.ts +2 -1
  119. package/dist/chat-agents/types.js +6 -1
  120. package/dist/chat-agents/types.js.map +1 -1
  121. package/dist/cli/auth.js +3 -6
  122. package/dist/cli/auth.js.map +1 -1
  123. package/dist/cli/mcp.js +4 -3
  124. package/dist/cli/mcp.js.map +1 -1
  125. package/dist/cli.d.ts +1 -0
  126. package/dist/cli.js +26 -27
  127. package/dist/cli.js.map +1 -1
  128. package/dist/goals-agent/goal-team.d.ts +1 -1
  129. package/dist/goals-agent/goals-agent.d.ts +3 -3
  130. package/dist/goals-agent/goals-agent.js +5 -5
  131. package/dist/goals-agent/goals-agent.js.map +1 -1
  132. package/dist/hf-pull.d.ts +2 -1
  133. package/dist/hf-pull.js +0 -1
  134. package/dist/hf-pull.js.map +1 -1
  135. package/dist/index.d.ts +0 -8
  136. package/dist/index.js +1 -14
  137. package/dist/index.js.map +1 -1
  138. package/dist/modes/acp-autopilot.js +3 -3
  139. package/dist/modes/acp-autopilot.js.map +1 -1
  140. package/dist/modes/acp-goals.d.ts +2 -2
  141. package/dist/modes/acp-goals.js +3 -3
  142. package/dist/modes/acp-goals.js.map +1 -1
  143. package/dist/modes/acp-mode.d.ts +6 -6
  144. package/dist/modes/acp-mode.js +22 -23
  145. package/dist/modes/acp-mode.js.map +1 -1
  146. package/dist/modes/agent-home-mode.js +7 -8
  147. package/dist/modes/agent-home-mode.js.map +1 -1
  148. package/dist/modes/json-mode.js +4 -4
  149. package/dist/modes/json-mode.js.map +1 -1
  150. package/dist/modes/print-mode.js +4 -3
  151. package/dist/modes/print-mode.js.map +1 -1
  152. package/dist/modes/rpc-mode.js +2 -2
  153. package/dist/modes/rpc-mode.js.map +1 -1
  154. package/dist/modes/serve-mode.js +10 -11
  155. package/dist/modes/serve-mode.js.map +1 -1
  156. package/dist/modes/subagent-worker-mode.d.ts +1 -1
  157. package/dist/modes/subagent-worker-mode.js +8 -8
  158. package/dist/modes/subagent-worker-mode.js.map +1 -1
  159. package/dist/motion-agent/motion-agent.d.ts +3 -2
  160. package/dist/motion-agent/motion-agent.js +3 -2
  161. package/dist/motion-agent/motion-agent.js.map +1 -1
  162. package/dist/motion-agent/motion-bundle.d.ts +18 -0
  163. package/dist/motion-agent/motion-bundle.js +34 -0
  164. package/dist/motion-agent/motion-bundle.js.map +1 -0
  165. package/dist/subagent-entry-path.d.ts +1 -0
  166. package/dist/subagent-entry-path.js +13 -0
  167. package/dist/subagent-entry-path.js.map +1 -0
  168. package/dist/subagent-entry.d.ts +1 -1
  169. package/dist/subagent-entry.js +2 -1
  170. package/dist/subagent-entry.js.map +1 -1
  171. package/dist/ui/App.d.ts +8 -8
  172. package/dist/ui/App.js +20 -21
  173. package/dist/ui/App.js.map +1 -1
  174. package/dist/ui/app-items.d.ts +1 -1
  175. package/dist/ui/components/BackgroundTasksBar.d.ts +1 -1
  176. package/dist/ui/components/Banner.js +1 -1
  177. package/dist/ui/components/Banner.js.map +1 -1
  178. package/dist/ui/components/ChatFooterPane.d.ts +1 -1
  179. package/dist/ui/components/ChatScreen.d.ts +4 -4
  180. package/dist/ui/components/Footer.d.ts +1 -1
  181. package/dist/ui/components/Footer.js +1 -1
  182. package/dist/ui/components/Footer.js.map +1 -1
  183. package/dist/ui/components/FooterStatusRow.d.ts +1 -1
  184. package/dist/ui/components/InputArea.d.ts +2 -2
  185. package/dist/ui/components/InputArea.js +2 -2
  186. package/dist/ui/components/InputArea.js.map +1 -1
  187. package/dist/ui/components/ModelSelector.js +1 -1
  188. package/dist/ui/components/ModelSelector.js.map +1 -1
  189. package/dist/ui/components/RewindOverlay.d.ts +1 -1
  190. package/dist/ui/components/RewindOverlay.js.map +1 -1
  191. package/dist/ui/components/SessionSelector.d.ts +1 -1
  192. package/dist/ui/components/SettingsSelector.d.ts +1 -1
  193. package/dist/ui/components/SkillsOverlay.js +2 -2
  194. package/dist/ui/components/SkillsOverlay.js.map +1 -1
  195. package/dist/ui/components/StreamingArea.js +1 -1
  196. package/dist/ui/components/StreamingArea.js.map +1 -1
  197. package/dist/ui/components/TaskPickerMenu.d.ts +1 -1
  198. package/dist/ui/components/ToolExecution.js +1 -1
  199. package/dist/ui/components/ToolExecution.js.map +1 -1
  200. package/dist/ui/error-item.js +2 -2
  201. package/dist/ui/error-item.js.map +1 -1
  202. package/dist/ui/hooks/useAgentLoop.d.ts +2 -2
  203. package/dist/ui/hooks/useAgentLoop.js +8 -8
  204. package/dist/ui/hooks/useAgentLoop.js.map +1 -1
  205. package/dist/ui/hooks/useChatLayoutMeasurements.d.ts +1 -1
  206. package/dist/ui/hooks/useContextCompaction.d.ts +3 -3
  207. package/dist/ui/hooks/useContextCompaction.js +6 -7
  208. package/dist/ui/hooks/useContextCompaction.js.map +1 -1
  209. package/dist/ui/hooks/useModeState.d.ts +2 -2
  210. package/dist/ui/hooks/useModeState.js +2 -2
  211. package/dist/ui/hooks/useModeState.js.map +1 -1
  212. package/dist/ui/hooks/useSessionPersistence.d.ts +1 -1
  213. package/dist/ui/hooks/useSessionPersistence.js +3 -3
  214. package/dist/ui/hooks/useSessionPersistence.js.map +1 -1
  215. package/dist/ui/hooks/useTaskPickerController.d.ts +1 -1
  216. package/dist/ui/hooks/useTaskPickerController.js +1 -1
  217. package/dist/ui/hooks/useTaskPickerController.js.map +1 -1
  218. package/dist/ui/hooks/useTranscriptHistory.d.ts +1 -1
  219. package/dist/ui/item-helpers.js +1 -1
  220. package/dist/ui/item-helpers.js.map +1 -1
  221. package/dist/ui/language-pack-update.d.ts +1 -1
  222. package/dist/ui/language-pack-update.js +1 -1
  223. package/dist/ui/language-pack-update.js.map +1 -1
  224. package/dist/ui/login.js +1 -1
  225. package/dist/ui/login.js.map +1 -1
  226. package/dist/ui/mcp.d.ts +1 -1
  227. package/dist/ui/prompt-routing.d.ts +3 -3
  228. package/dist/ui/prompt-routing.js +3 -3
  229. package/dist/ui/prompt-routing.js.map +1 -1
  230. package/dist/ui/render.d.ts +8 -8
  231. package/dist/ui/sessions.js +1 -1
  232. package/dist/ui/sessions.js.map +1 -1
  233. package/dist/ui/stores/taskbar-store.d.ts +1 -1
  234. package/dist/ui/stores/taskbar-store.js.map +1 -1
  235. package/dist/ui/submit-prompt-command.d.ts +2 -2
  236. package/dist/ui/submit-prompt-command.js +2 -3
  237. package/dist/ui/submit-prompt-command.js.map +1 -1
  238. package/dist/ui/terminal-history-status-renderers.d.ts +1 -1
  239. package/dist/ui/terminal-history.js +2 -3
  240. package/dist/ui/terminal-history.js.map +1 -1
  241. package/dist/ui/theme/theme.d.ts +2 -1
  242. package/dist/ui/theme/theme.js.map +1 -1
  243. package/dist/ui/thinking-level.d.ts +1 -1
  244. package/dist/ui/thinking-level.js +1 -1
  245. package/dist/ui/thinking-level.js.map +1 -1
  246. package/dist/ui/tool-line-summary.js +1 -1
  247. package/dist/ui/tool-line-summary.js.map +1 -1
  248. package/dist/ui/transcript/presentation.js +1 -1
  249. package/dist/ui/transcript/presentation.js.map +1 -1
  250. package/dist/ui/utils/text-utils.js +1 -1
  251. package/dist/ui/utils/text-utils.js.map +1 -1
  252. package/dist/utils/git-overview.d.ts +2 -23
  253. package/dist/utils/git-overview.js +8 -1
  254. package/dist/utils/git-overview.js.map +1 -1
  255. package/package.json +13 -103
  256. package/assets/skills/bulletproof/SKILL.md +0 -132
  257. package/assets/skills/bulletproof/references/agent-surface.md +0 -113
  258. package/assets/skills/bulletproof/references/attack-classes.md +0 -226
  259. package/assets/skills/bulletproof/references/audit-protocol.md +0 -232
  260. package/assets/skills/bulletproof/references/platform-playbooks.md +0 -196
  261. package/assets/skills/bulletproof/references/provenance.md +0 -146
  262. package/assets/skills/bulletproof/references/secure-defaults.md +0 -137
  263. package/assets/skills/bulletproof/references/supply-chain.md +0 -84
  264. package/assets/skills/bulletproof/references/threat-landscape.md +0 -66
  265. package/assets/skills/bulletproof/references/verification.md +0 -74
  266. package/assets/skills/compliance-guard/SKILL.md +0 -115
  267. package/assets/skills/compliance-guard/references/artifacts.md +0 -199
  268. package/assets/skills/compliance-guard/references/eu-uk.md +0 -162
  269. package/assets/skills/compliance-guard/references/exposure-triage.md +0 -177
  270. package/assets/skills/compliance-guard/references/full-review.md +0 -155
  271. package/assets/skills/compliance-guard/references/lawsuit-vectors.md +0 -153
  272. package/assets/skills/compliance-guard/references/provenance.md +0 -135
  273. package/assets/skills/compliance-guard/references/sector-gates.md +0 -187
  274. package/assets/skills/compliance-guard/references/security-baseline.md +0 -117
  275. package/assets/skills/compliance-guard/references/trigger-map.md +0 -177
  276. package/assets/skills/compliance-guard/references/us.md +0 -194
  277. package/assets/skills/durable/SKILL.md +0 -114
  278. package/assets/skills/durable/references/agent-db-safety.md +0 -76
  279. package/assets/skills/durable/references/backups-and-runtime.md +0 -93
  280. package/assets/skills/durable/references/migrations-and-schema.md +0 -87
  281. package/assets/skills/gg-guide/SKILL.md +0 -43
  282. package/assets/skills/gg-guide/references/chat-motion-goals.md +0 -217
  283. package/assets/skills/gg-guide/references/checklist-and-safety.md +0 -177
  284. package/assets/skills/gg-guide/references/code-mode.md +0 -268
  285. package/assets/skills/gg-guide/references/getting-started.md +0 -290
  286. package/assets/skills/gg-guide/references/ken-and-autopilot.md +0 -172
  287. package/assets/skills/gg-guide/references/mcp-and-skills.md +0 -204
  288. package/assets/skills/gg-guide/references/models-and-sign-in.md +0 -200
  289. package/assets/skills/gg-guide/references/sessions-and-history.md +0 -213
  290. package/assets/skills/gg-guide/references/settings.md +0 -193
  291. package/assets/skills/gg-guide/references/troubleshooting-and-data.md +0 -186
  292. package/assets/skills/lean/SKILL.md +0 -117
  293. package/assets/skills/lean/references/memory-and-processes.md +0 -99
  294. package/assets/skills/lean/references/playbooks.md +0 -134
  295. package/dist/app-error.d.ts +0 -22
  296. package/dist/app-error.js +0 -41
  297. package/dist/app-error.js.map +0 -1
  298. package/dist/config.d.ts +0 -90
  299. package/dist/config.js +0 -240
  300. package/dist/config.js.map +0 -1
  301. package/dist/core/acceptance-checks.d.ts +0 -48
  302. package/dist/core/acceptance-checks.js +0 -151
  303. package/dist/core/acceptance-checks.js.map +0 -1
  304. package/dist/core/action-threats.d.ts +0 -68
  305. package/dist/core/action-threats.js +0 -894
  306. package/dist/core/action-threats.js.map +0 -1
  307. package/dist/core/agent-notifications.d.ts +0 -79
  308. package/dist/core/agent-notifications.js +0 -125
  309. package/dist/core/agent-notifications.js.map +0 -1
  310. package/dist/core/agent-session/helpers.d.ts +0 -26
  311. package/dist/core/agent-session/helpers.js +0 -47
  312. package/dist/core/agent-session/helpers.js.map +0 -1
  313. package/dist/core/agent-session/mcp-tools.d.ts +0 -87
  314. package/dist/core/agent-session/mcp-tools.js +0 -227
  315. package/dist/core/agent-session/mcp-tools.js.map +0 -1
  316. package/dist/core/agent-session/run-loop-monitor.d.ts +0 -63
  317. package/dist/core/agent-session/run-loop-monitor.js +0 -164
  318. package/dist/core/agent-session/run-loop-monitor.js.map +0 -1
  319. package/dist/core/agent-session/transcript-markers.d.ts +0 -57
  320. package/dist/core/agent-session/transcript-markers.js +0 -166
  321. package/dist/core/agent-session/transcript-markers.js.map +0 -1
  322. package/dist/core/agent-session/verification-tracker.d.ts +0 -71
  323. package/dist/core/agent-session/verification-tracker.js +0 -295
  324. package/dist/core/agent-session/verification-tracker.js.map +0 -1
  325. package/dist/core/agent-session.d.ts +0 -1398
  326. package/dist/core/agent-session.js +0 -5123
  327. package/dist/core/agent-session.js.map +0 -1
  328. package/dist/core/agents.d.ts +0 -63
  329. package/dist/core/agents.js +0 -160
  330. package/dist/core/agents.js.map +0 -1
  331. package/dist/core/ask-user.d.ts +0 -163
  332. package/dist/core/ask-user.js +0 -178
  333. package/dist/core/ask-user.js.map +0 -1
  334. package/dist/core/auth/index.d.ts +0 -11
  335. package/dist/core/auth/index.js +0 -11
  336. package/dist/core/auth/index.js.map +0 -1
  337. package/dist/core/auth-providers.d.ts +0 -2
  338. package/dist/core/auth-providers.js +0 -5
  339. package/dist/core/auth-providers.js.map +0 -1
  340. package/dist/core/auth-storage.d.ts +0 -1
  341. package/dist/core/auth-storage.js +0 -4
  342. package/dist/core/auth-storage.js.map +0 -1
  343. package/dist/core/auto-update.d.ts +0 -6
  344. package/dist/core/auto-update.js +0 -15
  345. package/dist/core/auto-update.js.map +0 -1
  346. package/dist/core/autopilot-cycle.d.ts +0 -127
  347. package/dist/core/autopilot-cycle.js +0 -182
  348. package/dist/core/autopilot-cycle.js.map +0 -1
  349. package/dist/core/autopilot-gate.d.ts +0 -106
  350. package/dist/core/autopilot-gate.js +0 -192
  351. package/dist/core/autopilot-gate.js.map +0 -1
  352. package/dist/core/autopilot-verdict.d.ts +0 -55
  353. package/dist/core/autopilot-verdict.js +0 -226
  354. package/dist/core/autopilot-verdict.js.map +0 -1
  355. package/dist/core/blocked-packages-file.d.ts +0 -33
  356. package/dist/core/blocked-packages-file.js +0 -274
  357. package/dist/core/blocked-packages-file.js.map +0 -1
  358. package/dist/core/bundled-agents.d.ts +0 -2
  359. package/dist/core/bundled-agents.js +0 -253
  360. package/dist/core/bundled-agents.js.map +0 -1
  361. package/dist/core/cache-diagnostics.d.ts +0 -72
  362. package/dist/core/cache-diagnostics.js +0 -200
  363. package/dist/core/cache-diagnostics.js.map +0 -1
  364. package/dist/core/cache-expiry.d.ts +0 -89
  365. package/dist/core/cache-expiry.js +0 -117
  366. package/dist/core/cache-expiry.js.map +0 -1
  367. package/dist/core/checklist-detection.d.ts +0 -11
  368. package/dist/core/checklist-detection.js +0 -238
  369. package/dist/core/checklist-detection.js.map +0 -1
  370. package/dist/core/checklist-git.d.ts +0 -19
  371. package/dist/core/checklist-git.js +0 -54
  372. package/dist/core/checklist-git.js.map +0 -1
  373. package/dist/core/checklist-items.d.ts +0 -181
  374. package/dist/core/checklist-items.js +0 -230
  375. package/dist/core/checklist-items.js.map +0 -1
  376. package/dist/core/checklist-prompt.d.ts +0 -14
  377. package/dist/core/checklist-prompt.js +0 -64
  378. package/dist/core/checklist-prompt.js.map +0 -1
  379. package/dist/core/checklist-snapshot.d.ts +0 -17
  380. package/dist/core/checklist-snapshot.js +0 -46
  381. package/dist/core/checklist-snapshot.js.map +0 -1
  382. package/dist/core/checklist-store.d.ts +0 -63
  383. package/dist/core/checklist-store.js +0 -273
  384. package/dist/core/checklist-store.js.map +0 -1
  385. package/dist/core/checkout-record.d.ts +0 -22
  386. package/dist/core/checkout-record.js +0 -68
  387. package/dist/core/checkout-record.js.map +0 -1
  388. package/dist/core/checkpoint-store.d.ts +0 -109
  389. package/dist/core/checkpoint-store.js +0 -260
  390. package/dist/core/checkpoint-store.js.map +0 -1
  391. package/dist/core/claude-code/complete.d.ts +0 -35
  392. package/dist/core/claude-code/complete.js +0 -125
  393. package/dist/core/claude-code/complete.js.map +0 -1
  394. package/dist/core/claude-code/events.d.ts +0 -67
  395. package/dist/core/claude-code/events.js +0 -460
  396. package/dist/core/claude-code/events.js.map +0 -1
  397. package/dist/core/claude-code/live-session.d.ts +0 -94
  398. package/dist/core/claude-code/live-session.js +0 -525
  399. package/dist/core/claude-code/live-session.js.map +0 -1
  400. package/dist/core/claude-code/loop.d.ts +0 -9
  401. package/dist/core/claude-code/loop.js +0 -15
  402. package/dist/core/claude-code/loop.js.map +0 -1
  403. package/dist/core/claude-code/session-sync.d.ts +0 -28
  404. package/dist/core/claude-code/session-sync.js +0 -53
  405. package/dist/core/claude-code/session-sync.js.map +0 -1
  406. package/dist/core/claude-code/tool-bridge.d.ts +0 -49
  407. package/dist/core/claude-code/tool-bridge.js +0 -352
  408. package/dist/core/claude-code/tool-bridge.js.map +0 -1
  409. package/dist/core/claude-code/transcripts.d.ts +0 -39
  410. package/dist/core/claude-code/transcripts.js +0 -195
  411. package/dist/core/claude-code/transcripts.js.map +0 -1
  412. package/dist/core/code-retrieval-chunkers.d.ts +0 -26
  413. package/dist/core/code-retrieval-chunkers.js +0 -264
  414. package/dist/core/code-retrieval-chunkers.js.map +0 -1
  415. package/dist/core/code-retrieval.d.ts +0 -18
  416. package/dist/core/code-retrieval.js +0 -124
  417. package/dist/core/code-retrieval.js.map +0 -1
  418. package/dist/core/codex-request-shape.d.ts +0 -7
  419. package/dist/core/codex-request-shape.js +0 -19
  420. package/dist/core/codex-request-shape.js.map +0 -1
  421. package/dist/core/compaction/active-context.d.ts +0 -16
  422. package/dist/core/compaction/active-context.js +0 -20
  423. package/dist/core/compaction/active-context.js.map +0 -1
  424. package/dist/core/compaction/compactor.d.ts +0 -281
  425. package/dist/core/compaction/compactor.js +0 -1452
  426. package/dist/core/compaction/compactor.js.map +0 -1
  427. package/dist/core/compaction/plan-step-policy.d.ts +0 -46
  428. package/dist/core/compaction/plan-step-policy.js +0 -57
  429. package/dist/core/compaction/plan-step-policy.js.map +0 -1
  430. package/dist/core/compaction/policy.d.ts +0 -36
  431. package/dist/core/compaction/policy.js +0 -144
  432. package/dist/core/compaction/policy.js.map +0 -1
  433. package/dist/core/compaction/query-aware-selector.d.ts +0 -32
  434. package/dist/core/compaction/query-aware-selector.js +0 -202
  435. package/dist/core/compaction/query-aware-selector.js.map +0 -1
  436. package/dist/core/compaction/token-estimator.d.ts +0 -36
  437. package/dist/core/compaction/token-estimator.js +0 -180
  438. package/dist/core/compaction/token-estimator.js.map +0 -1
  439. package/dist/core/compaction/tool-result-pruner.d.ts +0 -90
  440. package/dist/core/compaction/tool-result-pruner.js +0 -238
  441. package/dist/core/compaction/tool-result-pruner.js.map +0 -1
  442. package/dist/core/completion-review.d.ts +0 -24
  443. package/dist/core/completion-review.js +0 -2
  444. package/dist/core/completion-review.js.map +0 -1
  445. package/dist/core/context-files.d.ts +0 -8
  446. package/dist/core/context-files.js +0 -46
  447. package/dist/core/context-files.js.map +0 -1
  448. package/dist/core/context-limits.d.ts +0 -40
  449. package/dist/core/context-limits.js +0 -43
  450. package/dist/core/context-limits.js.map +0 -1
  451. package/dist/core/custom-commands.d.ts +0 -18
  452. package/dist/core/custom-commands.js +0 -57
  453. package/dist/core/custom-commands.js.map +0 -1
  454. package/dist/core/destructive-git-guard.d.ts +0 -113
  455. package/dist/core/destructive-git-guard.js +0 -874
  456. package/dist/core/destructive-git-guard.js.map +0 -1
  457. package/dist/core/encode-cwd.d.ts +0 -41
  458. package/dist/core/encode-cwd.js +0 -53
  459. package/dist/core/encode-cwd.js.map +0 -1
  460. package/dist/core/env-delta.d.ts +0 -34
  461. package/dist/core/env-delta.js +0 -84
  462. package/dist/core/env-delta.js.map +0 -1
  463. package/dist/core/event-bus.d.ts +0 -178
  464. package/dist/core/event-bus.js +0 -171
  465. package/dist/core/event-bus.js.map +0 -1
  466. package/dist/core/extensions/loader.d.ts +0 -7
  467. package/dist/core/extensions/loader.js +0 -68
  468. package/dist/core/extensions/loader.js.map +0 -1
  469. package/dist/core/extensions/plugin-bundles.d.ts +0 -13
  470. package/dist/core/extensions/plugin-bundles.js +0 -45
  471. package/dist/core/extensions/plugin-bundles.js.map +0 -1
  472. package/dist/core/extensions/types.d.ts +0 -18
  473. package/dist/core/extensions/types.js +0 -2
  474. package/dist/core/extensions/types.js.map +0 -1
  475. package/dist/core/foreign-session-import.d.ts +0 -119
  476. package/dist/core/foreign-session-import.js +0 -598
  477. package/dist/core/foreign-session-import.js.map +0 -1
  478. package/dist/core/foreign-transcript-blocks.d.ts +0 -50
  479. package/dist/core/foreign-transcript-blocks.js +0 -151
  480. package/dist/core/foreign-transcript-blocks.js.map +0 -1
  481. package/dist/core/frontmatter.d.ts +0 -22
  482. package/dist/core/frontmatter.js +0 -90
  483. package/dist/core/frontmatter.js.map +0 -1
  484. package/dist/core/goal-run-marker.d.ts +0 -32
  485. package/dist/core/goal-run-marker.js +0 -178
  486. package/dist/core/goal-run-marker.js.map +0 -1
  487. package/dist/core/goal-summary.d.ts +0 -32
  488. package/dist/core/goal-summary.js +0 -110
  489. package/dist/core/goal-summary.js.map +0 -1
  490. package/dist/core/goals-store.d.ts +0 -215
  491. package/dist/core/goals-store.js +0 -577
  492. package/dist/core/goals-store.js.map +0 -1
  493. package/dist/core/hashline.d.ts +0 -51
  494. package/dist/core/hashline.js +0 -76
  495. package/dist/core/hashline.js.map +0 -1
  496. package/dist/core/idle-wake.d.ts +0 -62
  497. package/dist/core/idle-wake.js +0 -103
  498. package/dist/core/idle-wake.js.map +0 -1
  499. package/dist/core/index.d.ts +0 -14
  500. package/dist/core/index.js +0 -14
  501. package/dist/core/index.js.map +0 -1
  502. package/dist/core/injection-detect.d.ts +0 -39
  503. package/dist/core/injection-detect.js +0 -241
  504. package/dist/core/injection-detect.js.map +0 -1
  505. package/dist/core/installed-threats.d.ts +0 -23
  506. package/dist/core/installed-threats.js +0 -71
  507. package/dist/core/installed-threats.js.map +0 -1
  508. package/dist/core/internal-diagnostics.d.ts +0 -159
  509. package/dist/core/internal-diagnostics.js +0 -495
  510. package/dist/core/internal-diagnostics.js.map +0 -1
  511. package/dist/core/keep-awake.d.ts +0 -88
  512. package/dist/core/keep-awake.js +0 -251
  513. package/dist/core/keep-awake.js.map +0 -1
  514. package/dist/core/ken-ask-answer.d.ts +0 -24
  515. package/dist/core/ken-ask-answer.js +0 -96
  516. package/dist/core/ken-ask-answer.js.map +0 -1
  517. package/dist/core/ken-context.d.ts +0 -119
  518. package/dist/core/ken-context.js +0 -447
  519. package/dist/core/ken-context.js.map +0 -1
  520. package/dist/core/ken-model.d.ts +0 -45
  521. package/dist/core/ken-model.js +0 -26
  522. package/dist/core/ken-model.js.map +0 -1
  523. package/dist/core/ken-prompt.d.ts +0 -21
  524. package/dist/core/ken-prompt.js +0 -370
  525. package/dist/core/ken-prompt.js.map +0 -1
  526. package/dist/core/language-detector.d.ts +0 -41
  527. package/dist/core/language-detector.js +0 -293
  528. package/dist/core/language-detector.js.map +0 -1
  529. package/dist/core/live-preview.d.ts +0 -26
  530. package/dist/core/live-preview.js +0 -80
  531. package/dist/core/live-preview.js.map +0 -1
  532. package/dist/core/local-endpoint-store.d.ts +0 -53
  533. package/dist/core/local-endpoint-store.js +0 -221
  534. package/dist/core/local-endpoint-store.js.map +0 -1
  535. package/dist/core/logger.d.ts +0 -22
  536. package/dist/core/logger.js +0 -95
  537. package/dist/core/logger.js.map +0 -1
  538. package/dist/core/loop-breaker.d.ts +0 -89
  539. package/dist/core/loop-breaker.js +0 -204
  540. package/dist/core/loop-breaker.js.map +0 -1
  541. package/dist/core/lsp/client.d.ts +0 -206
  542. package/dist/core/lsp/client.js +0 -685
  543. package/dist/core/lsp/client.js.map +0 -1
  544. package/dist/core/lsp/edit-telemetry.d.ts +0 -26
  545. package/dist/core/lsp/edit-telemetry.js +0 -52
  546. package/dist/core/lsp/edit-telemetry.js.map +0 -1
  547. package/dist/core/lsp/format.d.ts +0 -11
  548. package/dist/core/lsp/format.js +0 -30
  549. package/dist/core/lsp/format.js.map +0 -1
  550. package/dist/core/lsp/jsonrpc.d.ts +0 -68
  551. package/dist/core/lsp/jsonrpc.js +0 -153
  552. package/dist/core/lsp/jsonrpc.js.map +0 -1
  553. package/dist/core/lsp/manager.d.ts +0 -188
  554. package/dist/core/lsp/manager.js +0 -576
  555. package/dist/core/lsp/manager.js.map +0 -1
  556. package/dist/core/lsp/pool.d.ts +0 -114
  557. package/dist/core/lsp/pool.js +0 -259
  558. package/dist/core/lsp/pool.js.map +0 -1
  559. package/dist/core/lsp/project-root.d.ts +0 -9
  560. package/dist/core/lsp/project-root.js +0 -75
  561. package/dist/core/lsp/project-root.js.map +0 -1
  562. package/dist/core/lsp/reference-project.d.ts +0 -6
  563. package/dist/core/lsp/reference-project.js +0 -110
  564. package/dist/core/lsp/reference-project.js.map +0 -1
  565. package/dist/core/lsp/servers.d.ts +0 -44
  566. package/dist/core/lsp/servers.js +0 -289
  567. package/dist/core/lsp/servers.js.map +0 -1
  568. package/dist/core/lsp/test-support.d.ts +0 -17
  569. package/dist/core/lsp/test-support.js +0 -27
  570. package/dist/core/lsp/test-support.js.map +0 -1
  571. package/dist/core/mcp/catalog-cache.d.ts +0 -64
  572. package/dist/core/mcp/catalog-cache.js +0 -167
  573. package/dist/core/mcp/catalog-cache.js.map +0 -1
  574. package/dist/core/mcp/client.d.ts +0 -317
  575. package/dist/core/mcp/client.js +0 -1168
  576. package/dist/core/mcp/client.js.map +0 -1
  577. package/dist/core/mcp/content.d.ts +0 -23
  578. package/dist/core/mcp/content.js +0 -194
  579. package/dist/core/mcp/content.js.map +0 -1
  580. package/dist/core/mcp/defaults.d.ts +0 -26
  581. package/dist/core/mcp/defaults.js +0 -81
  582. package/dist/core/mcp/defaults.js.map +0 -1
  583. package/dist/core/mcp/deferred-catalog.d.ts +0 -53
  584. package/dist/core/mcp/deferred-catalog.js +0 -117
  585. package/dist/core/mcp/deferred-catalog.js.map +0 -1
  586. package/dist/core/mcp/elicitation-bridge.d.ts +0 -40
  587. package/dist/core/mcp/elicitation-bridge.js +0 -36
  588. package/dist/core/mcp/elicitation-bridge.js.map +0 -1
  589. package/dist/core/mcp/index.d.ts +0 -16
  590. package/dist/core/mcp/index.js +0 -10
  591. package/dist/core/mcp/index.js.map +0 -1
  592. package/dist/core/mcp/loopback.d.ts +0 -26
  593. package/dist/core/mcp/loopback.js +0 -66
  594. package/dist/core/mcp/loopback.js.map +0 -1
  595. package/dist/core/mcp/oauth-provider.d.ts +0 -55
  596. package/dist/core/mcp/oauth-provider.js +0 -106
  597. package/dist/core/mcp/oauth-provider.js.map +0 -1
  598. package/dist/core/mcp/oauth-store.d.ts +0 -44
  599. package/dist/core/mcp/oauth-store.js +0 -77
  600. package/dist/core/mcp/oauth-store.js.map +0 -1
  601. package/dist/core/mcp/parse-add-command.d.ts +0 -50
  602. package/dist/core/mcp/parse-add-command.js +0 -391
  603. package/dist/core/mcp/parse-add-command.js.map +0 -1
  604. package/dist/core/mcp/resolve-stdio.d.ts +0 -77
  605. package/dist/core/mcp/resolve-stdio.js +0 -359
  606. package/dist/core/mcp/resolve-stdio.js.map +0 -1
  607. package/dist/core/mcp/shared-pool.d.ts +0 -157
  608. package/dist/core/mcp/shared-pool.js +0 -236
  609. package/dist/core/mcp/shared-pool.js.map +0 -1
  610. package/dist/core/mcp/store.d.ts +0 -100
  611. package/dist/core/mcp/store.js +0 -202
  612. package/dist/core/mcp/store.js.map +0 -1
  613. package/dist/core/mcp/tool-guard.d.ts +0 -58
  614. package/dist/core/mcp/tool-guard.js +0 -215
  615. package/dist/core/mcp/tool-guard.js.map +0 -1
  616. package/dist/core/mcp/types.d.ts +0 -57
  617. package/dist/core/mcp/types.js +0 -2
  618. package/dist/core/mcp/types.js.map +0 -1
  619. package/dist/core/message-images.d.ts +0 -11
  620. package/dist/core/message-images.js +0 -52
  621. package/dist/core/message-images.js.map +0 -1
  622. package/dist/core/model-registry.d.ts +0 -1
  623. package/dist/core/model-registry.js +0 -5
  624. package/dist/core/model-registry.js.map +0 -1
  625. package/dist/core/model-unavailable.d.ts +0 -14
  626. package/dist/core/model-unavailable.js +0 -23
  627. package/dist/core/model-unavailable.js.map +0 -1
  628. package/dist/core/network-guard.d.ts +0 -28
  629. package/dist/core/network-guard.js +0 -251
  630. package/dist/core/network-guard.js.map +0 -1
  631. package/dist/core/node-debugger.d.ts +0 -148
  632. package/dist/core/node-debugger.js +0 -642
  633. package/dist/core/node-debugger.js.map +0 -1
  634. package/dist/core/oauth/openai.d.ts +0 -1
  635. package/dist/core/oauth/openai.js +0 -3
  636. package/dist/core/oauth/openai.js.map +0 -1
  637. package/dist/core/oauth/types.d.ts +0 -1
  638. package/dist/core/oauth/types.js +0 -2
  639. package/dist/core/oauth/types.js.map +0 -1
  640. package/dist/core/opencode-catalog-store.d.ts +0 -20
  641. package/dist/core/opencode-catalog-store.js +0 -82
  642. package/dist/core/opencode-catalog-store.js.map +0 -1
  643. package/dist/core/openrouter-catalog-store.d.ts +0 -24
  644. package/dist/core/openrouter-catalog-store.js +0 -140
  645. package/dist/core/openrouter-catalog-store.js.map +0 -1
  646. package/dist/core/package-cooldown.d.ts +0 -69
  647. package/dist/core/package-cooldown.js +0 -297
  648. package/dist/core/package-cooldown.js.map +0 -1
  649. package/dist/core/package-threats.d.ts +0 -92
  650. package/dist/core/package-threats.js +0 -1340
  651. package/dist/core/package-threats.js.map +0 -1
  652. package/dist/core/parked-requests.d.ts +0 -43
  653. package/dist/core/parked-requests.js +0 -34
  654. package/dist/core/parked-requests.js.map +0 -1
  655. package/dist/core/persistent-shell.d.ts +0 -81
  656. package/dist/core/persistent-shell.js +0 -452
  657. package/dist/core/persistent-shell.js.map +0 -1
  658. package/dist/core/plan-delta.d.ts +0 -23
  659. package/dist/core/plan-delta.js +0 -36
  660. package/dist/core/plan-delta.js.map +0 -1
  661. package/dist/core/plan-handoff.d.ts +0 -38
  662. package/dist/core/plan-handoff.js +0 -21
  663. package/dist/core/plan-handoff.js.map +0 -1
  664. package/dist/core/plan-submission-gate.d.ts +0 -28
  665. package/dist/core/plan-submission-gate.js +0 -27
  666. package/dist/core/plan-submission-gate.js.map +0 -1
  667. package/dist/core/platform-clis.d.ts +0 -15
  668. package/dist/core/platform-clis.js +0 -299
  669. package/dist/core/platform-clis.js.map +0 -1
  670. package/dist/core/process-gate.d.ts +0 -61
  671. package/dist/core/process-gate.js +0 -103
  672. package/dist/core/process-gate.js.map +0 -1
  673. package/dist/core/process-manager.d.ts +0 -242
  674. package/dist/core/process-manager.js +0 -902
  675. package/dist/core/process-manager.js.map +0 -1
  676. package/dist/core/progress/engine.d.ts +0 -22
  677. package/dist/core/progress/engine.js +0 -131
  678. package/dist/core/progress/engine.js.map +0 -1
  679. package/dist/core/progress/git-xp.d.ts +0 -15
  680. package/dist/core/progress/git-xp.js +0 -100
  681. package/dist/core/progress/git-xp.js.map +0 -1
  682. package/dist/core/progress/ranks.d.ts +0 -31
  683. package/dist/core/progress/ranks.js +0 -310
  684. package/dist/core/progress/ranks.js.map +0 -1
  685. package/dist/core/progress/rebuild.d.ts +0 -8
  686. package/dist/core/progress/rebuild.js +0 -125
  687. package/dist/core/progress/rebuild.js.map +0 -1
  688. package/dist/core/progress/store.d.ts +0 -34
  689. package/dist/core/progress/store.js +0 -200
  690. package/dist/core/progress/store.js.map +0 -1
  691. package/dist/core/progress/types.d.ts +0 -108
  692. package/dist/core/progress/types.js +0 -3
  693. package/dist/core/progress/types.js.map +0 -1
  694. package/dist/core/project-discovery.d.ts +0 -88
  695. package/dist/core/project-discovery.js +0 -907
  696. package/dist/core/project-discovery.js.map +0 -1
  697. package/dist/core/project-files.d.ts +0 -15
  698. package/dist/core/project-files.js +0 -37
  699. package/dist/core/project-files.js.map +0 -1
  700. package/dist/core/project-health-scan.d.ts +0 -109
  701. package/dist/core/project-health-scan.js +0 -673
  702. package/dist/core/project-health-scan.js.map +0 -1
  703. package/dist/core/project-health-score.d.ts +0 -41
  704. package/dist/core/project-health-score.js +0 -257
  705. package/dist/core/project-health-score.js.map +0 -1
  706. package/dist/core/prompt-command-expansion.d.ts +0 -13
  707. package/dist/core/prompt-command-expansion.js +0 -48
  708. package/dist/core/prompt-command-expansion.js.map +0 -1
  709. package/dist/core/prompt-commands.d.ts +0 -13
  710. package/dist/core/prompt-commands.js +0 -370
  711. package/dist/core/prompt-commands.js.map +0 -1
  712. package/dist/core/radio-players.d.ts +0 -28
  713. package/dist/core/radio-players.js +0 -133
  714. package/dist/core/radio-players.js.map +0 -1
  715. package/dist/core/radio.d.ts +0 -50
  716. package/dist/core/radio.js +0 -480
  717. package/dist/core/radio.js.map +0 -1
  718. package/dist/core/regrounding.d.ts +0 -37
  719. package/dist/core/regrounding.js +0 -89
  720. package/dist/core/regrounding.js.map +0 -1
  721. package/dist/core/resolve-start.d.ts +0 -28
  722. package/dist/core/resolve-start.js +0 -35
  723. package/dist/core/resolve-start.js.map +0 -1
  724. package/dist/core/run-claim.d.ts +0 -36
  725. package/dist/core/run-claim.js +0 -46
  726. package/dist/core/run-claim.js.map +0 -1
  727. package/dist/core/run-lifecycle.d.ts +0 -58
  728. package/dist/core/run-lifecycle.js +0 -104
  729. package/dist/core/run-lifecycle.js.map +0 -1
  730. package/dist/core/run-status.d.ts +0 -17
  731. package/dist/core/run-status.js +0 -28
  732. package/dist/core/run-status.js.map +0 -1
  733. package/dist/core/runtime-mode.d.ts +0 -21
  734. package/dist/core/runtime-mode.js +0 -43
  735. package/dist/core/runtime-mode.js.map +0 -1
  736. package/dist/core/sandbox-domains.d.ts +0 -13
  737. package/dist/core/sandbox-domains.js +0 -76
  738. package/dist/core/sandbox-domains.js.map +0 -1
  739. package/dist/core/sandbox-feedback.d.ts +0 -21
  740. package/dist/core/sandbox-feedback.js +0 -69
  741. package/dist/core/sandbox-feedback.js.map +0 -1
  742. package/dist/core/sandbox.d.ts +0 -106
  743. package/dist/core/sandbox.js +0 -383
  744. package/dist/core/sandbox.js.map +0 -1
  745. package/dist/core/semantic-loop-check.d.ts +0 -58
  746. package/dist/core/semantic-loop-check.js +0 -103
  747. package/dist/core/semantic-loop-check.js.map +0 -1
  748. package/dist/core/session-compaction.d.ts +0 -23
  749. package/dist/core/session-compaction.js +0 -54
  750. package/dist/core/session-compaction.js.map +0 -1
  751. package/dist/core/session-export.d.ts +0 -97
  752. package/dist/core/session-export.js +0 -368
  753. package/dist/core/session-export.js.map +0 -1
  754. package/dist/core/session-history.d.ts +0 -160
  755. package/dist/core/session-history.js +0 -467
  756. package/dist/core/session-history.js.map +0 -1
  757. package/dist/core/session-manager.d.ts +0 -509
  758. package/dist/core/session-manager.js +0 -1367
  759. package/dist/core/session-manager.js.map +0 -1
  760. package/dist/core/session-preview.d.ts +0 -12
  761. package/dist/core/session-preview.js +0 -58
  762. package/dist/core/session-preview.js.map +0 -1
  763. package/dist/core/session-storage.d.ts +0 -78
  764. package/dist/core/session-storage.js +0 -659
  765. package/dist/core/session-storage.js.map +0 -1
  766. package/dist/core/session-summary-index.d.ts +0 -51
  767. package/dist/core/session-summary-index.js +0 -192
  768. package/dist/core/session-summary-index.js.map +0 -1
  769. package/dist/core/settings-manager.d.ts +0 -113
  770. package/dist/core/settings-manager.js +0 -281
  771. package/dist/core/settings-manager.js.map +0 -1
  772. package/dist/core/shared-checkout-guard.d.ts +0 -78
  773. package/dist/core/shared-checkout-guard.js +0 -219
  774. package/dist/core/shared-checkout-guard.js.map +0 -1
  775. package/dist/core/shell-path.d.ts +0 -13
  776. package/dist/core/shell-path.js +0 -175
  777. package/dist/core/shell-path.js.map +0 -1
  778. package/dist/core/shell-threats-popular-packages.d.ts +0 -11
  779. package/dist/core/shell-threats-popular-packages.js +0 -675
  780. package/dist/core/shell-threats-popular-packages.js.map +0 -1
  781. package/dist/core/shell-threats.d.ts +0 -21
  782. package/dist/core/shell-threats.js +0 -235
  783. package/dist/core/shell-threats.js.map +0 -1
  784. package/dist/core/shell.d.ts +0 -54
  785. package/dist/core/shell.js +0 -99
  786. package/dist/core/shell.js.map +0 -1
  787. package/dist/core/shutdown.d.ts +0 -70
  788. package/dist/core/shutdown.js +0 -144
  789. package/dist/core/shutdown.js.map +0 -1
  790. package/dist/core/skill-scan.d.ts +0 -112
  791. package/dist/core/skill-scan.js +0 -781
  792. package/dist/core/skill-scan.js.map +0 -1
  793. package/dist/core/skills.d.ts +0 -100
  794. package/dist/core/skills.js +0 -299
  795. package/dist/core/skills.js.map +0 -1
  796. package/dist/core/slash-commands.d.ts +0 -58
  797. package/dist/core/slash-commands.js +0 -242
  798. package/dist/core/slash-commands.js.map +0 -1
  799. package/dist/core/steering.d.ts +0 -47
  800. package/dist/core/steering.js +0 -65
  801. package/dist/core/steering.js.map +0 -1
  802. package/dist/core/steroids.d.ts +0 -66
  803. package/dist/core/steroids.js +0 -243
  804. package/dist/core/steroids.js.map +0 -1
  805. package/dist/core/stream-diag-level.d.ts +0 -3
  806. package/dist/core/stream-diag-level.js +0 -24
  807. package/dist/core/stream-diag-level.js.map +0 -1
  808. package/dist/core/stream-rules.d.ts +0 -30
  809. package/dist/core/stream-rules.js +0 -151
  810. package/dist/core/stream-rules.js.map +0 -1
  811. package/dist/core/subagent-manager.d.ts +0 -239
  812. package/dist/core/subagent-manager.js +0 -1060
  813. package/dist/core/subagent-manager.js.map +0 -1
  814. package/dist/core/subagent-policy.d.ts +0 -9
  815. package/dist/core/subagent-policy.js +0 -41
  816. package/dist/core/subagent-policy.js.map +0 -1
  817. package/dist/core/subagent-receipt.d.ts +0 -54
  818. package/dist/core/subagent-receipt.js +0 -274
  819. package/dist/core/subagent-receipt.js.map +0 -1
  820. package/dist/core/subagent-store.d.ts +0 -41
  821. package/dist/core/subagent-store.js +0 -284
  822. package/dist/core/subagent-store.js.map +0 -1
  823. package/dist/core/subagent-turn-record.d.ts +0 -18
  824. package/dist/core/subagent-turn-record.js +0 -82
  825. package/dist/core/subagent-turn-record.js.map +0 -1
  826. package/dist/core/tasks-store.d.ts +0 -31
  827. package/dist/core/tasks-store.js +0 -97
  828. package/dist/core/tasks-store.js.map +0 -1
  829. package/dist/core/telegram-config.d.ts +0 -20
  830. package/dist/core/telegram-config.js +0 -52
  831. package/dist/core/telegram-config.js.map +0 -1
  832. package/dist/core/telegram.d.ts +0 -1
  833. package/dist/core/telegram.js +0 -3
  834. package/dist/core/telegram.js.map +0 -1
  835. package/dist/core/temp-paths.d.ts +0 -5
  836. package/dist/core/temp-paths.js +0 -50
  837. package/dist/core/temp-paths.js.map +0 -1
  838. package/dist/core/test-impact.d.ts +0 -73
  839. package/dist/core/test-impact.js +0 -467
  840. package/dist/core/test-impact.js.map +0 -1
  841. package/dist/core/thinking-level.d.ts +0 -1
  842. package/dist/core/thinking-level.js +0 -4
  843. package/dist/core/thinking-level.js.map +0 -1
  844. package/dist/core/threat-feed.d.ts +0 -65
  845. package/dist/core/threat-feed.js +0 -335
  846. package/dist/core/threat-feed.js.map +0 -1
  847. package/dist/core/trophies/catalog-more.d.ts +0 -2
  848. package/dist/core/trophies/catalog-more.js +0 -837
  849. package/dist/core/trophies/catalog-more.js.map +0 -1
  850. package/dist/core/trophies/catalog.d.ts +0 -4
  851. package/dist/core/trophies/catalog.js +0 -649
  852. package/dist/core/trophies/catalog.js.map +0 -1
  853. package/dist/core/trophies/engine.d.ts +0 -70
  854. package/dist/core/trophies/engine.js +0 -347
  855. package/dist/core/trophies/engine.js.map +0 -1
  856. package/dist/core/trophies/store.d.ts +0 -17
  857. package/dist/core/trophies/store.js +0 -113
  858. package/dist/core/trophies/store.js.map +0 -1
  859. package/dist/core/trophies/types.d.ts +0 -119
  860. package/dist/core/trophies/types.js +0 -76
  861. package/dist/core/trophies/types.js.map +0 -1
  862. package/dist/core/ui-adoption.d.ts +0 -32
  863. package/dist/core/ui-adoption.js +0 -302
  864. package/dist/core/ui-adoption.js.map +0 -1
  865. package/dist/core/ui-compatibility.d.ts +0 -10
  866. package/dist/core/ui-compatibility.js +0 -51
  867. package/dist/core/ui-compatibility.js.map +0 -1
  868. package/dist/core/ui-registry.d.ts +0 -101
  869. package/dist/core/ui-registry.js +0 -292
  870. package/dist/core/ui-registry.js.map +0 -1
  871. package/dist/core/user-shell-context.d.ts +0 -8
  872. package/dist/core/user-shell-context.js +0 -12
  873. package/dist/core/user-shell-context.js.map +0 -1
  874. package/dist/core/verification-evidence.d.ts +0 -49
  875. package/dist/core/verification-evidence.js +0 -816
  876. package/dist/core/verification-evidence.js.map +0 -1
  877. package/dist/core/verification-gate.d.ts +0 -77
  878. package/dist/core/verification-gate.js +0 -504
  879. package/dist/core/verification-gate.js.map +0 -1
  880. package/dist/core/verification-snapshot.d.ts +0 -7
  881. package/dist/core/verification-snapshot.js +0 -109
  882. package/dist/core/verification-snapshot.js.map +0 -1
  883. package/dist/core/verify-commands.d.ts +0 -34
  884. package/dist/core/verify-commands.js +0 -203
  885. package/dist/core/verify-commands.js.map +0 -1
  886. package/dist/core/voice-transcriber.d.ts +0 -1
  887. package/dist/core/voice-transcriber.js +0 -4
  888. package/dist/core/voice-transcriber.js.map +0 -1
  889. package/dist/core/workspace-guard.d.ts +0 -56
  890. package/dist/core/workspace-guard.js +0 -334
  891. package/dist/core/workspace-guard.js.map +0 -1
  892. package/dist/session.d.ts +0 -44
  893. package/dist/session.js +0 -105
  894. package/dist/session.js.map +0 -1
  895. package/dist/system-prompt.d.ts +0 -104
  896. package/dist/system-prompt.js +0 -480
  897. package/dist/system-prompt.js.map +0 -1
  898. package/dist/test-support/fake-home.d.ts +0 -19
  899. package/dist/test-support/fake-home.js +0 -37
  900. package/dist/test-support/fake-home.js.map +0 -1
  901. package/dist/test-support/keep-alive.d.ts +0 -14
  902. package/dist/test-support/keep-alive.js +0 -17
  903. package/dist/test-support/keep-alive.js.map +0 -1
  904. package/dist/test-support/slow-git.d.ts +0 -1
  905. package/dist/test-support/slow-git.js +0 -21
  906. package/dist/test-support/slow-git.js.map +0 -1
  907. package/dist/test-support/system-tools.d.ts +0 -6
  908. package/dist/test-support/system-tools.js +0 -36
  909. package/dist/test-support/system-tools.js.map +0 -1
  910. package/dist/tools/ask-user.d.ts +0 -34
  911. package/dist/tools/ask-user.js +0 -99
  912. package/dist/tools/ask-user.js.map +0 -1
  913. package/dist/tools/background-watch-lint.d.ts +0 -18
  914. package/dist/tools/background-watch-lint.js +0 -102
  915. package/dist/tools/background-watch-lint.js.map +0 -1
  916. package/dist/tools/bash-read-evidence.d.ts +0 -23
  917. package/dist/tools/bash-read-evidence.js +0 -180
  918. package/dist/tools/bash-read-evidence.js.map +0 -1
  919. package/dist/tools/bash.d.ts +0 -64
  920. package/dist/tools/bash.js +0 -552
  921. package/dist/tools/bash.js.map +0 -1
  922. package/dist/tools/browser-api.d.ts +0 -27
  923. package/dist/tools/browser-api.js +0 -449
  924. package/dist/tools/browser-api.js.map +0 -1
  925. package/dist/tools/browser-sandbox.d.ts +0 -16
  926. package/dist/tools/browser-sandbox.js +0 -158
  927. package/dist/tools/browser-sandbox.js.map +0 -1
  928. package/dist/tools/browser-session.d.ts +0 -84
  929. package/dist/tools/browser-session.js +0 -304
  930. package/dist/tools/browser-session.js.map +0 -1
  931. package/dist/tools/browser-snapshot.d.ts +0 -19
  932. package/dist/tools/browser-snapshot.js +0 -109
  933. package/dist/tools/browser-snapshot.js.map +0 -1
  934. package/dist/tools/browser.d.ts +0 -11
  935. package/dist/tools/browser.js +0 -106
  936. package/dist/tools/browser.js.map +0 -1
  937. package/dist/tools/checklist.d.ts +0 -49
  938. package/dist/tools/checklist.js +0 -154
  939. package/dist/tools/checklist.js.map +0 -1
  940. package/dist/tools/compress.d.ts +0 -56
  941. package/dist/tools/compress.js +0 -226
  942. package/dist/tools/compress.js.map +0 -1
  943. package/dist/tools/debug.d.ts +0 -54
  944. package/dist/tools/debug.js +0 -230
  945. package/dist/tools/debug.js.map +0 -1
  946. package/dist/tools/document-text.d.ts +0 -6
  947. package/dist/tools/document-text.js +0 -154
  948. package/dist/tools/document-text.js.map +0 -1
  949. package/dist/tools/edit-diff.d.ts +0 -123
  950. package/dist/tools/edit-diff.js +0 -476
  951. package/dist/tools/edit-diff.js.map +0 -1
  952. package/dist/tools/edit-targets.d.ts +0 -10
  953. package/dist/tools/edit-targets.js +0 -31
  954. package/dist/tools/edit-targets.js.map +0 -1
  955. package/dist/tools/edit.d.ts +0 -38
  956. package/dist/tools/edit.js +0 -695
  957. package/dist/tools/edit.js.map +0 -1
  958. package/dist/tools/enter-plan.d.ts +0 -7
  959. package/dist/tools/enter-plan.js +0 -20
  960. package/dist/tools/enter-plan.js.map +0 -1
  961. package/dist/tools/exit-plan.d.ts +0 -7
  962. package/dist/tools/exit-plan.js +0 -51
  963. package/dist/tools/exit-plan.js.map +0 -1
  964. package/dist/tools/find.d.ts +0 -17
  965. package/dist/tools/find.js +0 -100
  966. package/dist/tools/find.js.map +0 -1
  967. package/dist/tools/generate-image.d.ts +0 -83
  968. package/dist/tools/generate-image.js +0 -625
  969. package/dist/tools/generate-image.js.map +0 -1
  970. package/dist/tools/grep-scan.d.ts +0 -96
  971. package/dist/tools/grep-scan.js +0 -283
  972. package/dist/tools/grep-scan.js.map +0 -1
  973. package/dist/tools/grep.d.ts +0 -48
  974. package/dist/tools/grep.js +0 -1013
  975. package/dist/tools/grep.js.map +0 -1
  976. package/dist/tools/html-extract.d.ts +0 -57
  977. package/dist/tools/html-extract.js +0 -130
  978. package/dist/tools/html-extract.js.map +0 -1
  979. package/dist/tools/index.d.ts +0 -198
  980. package/dist/tools/index.js +0 -216
  981. package/dist/tools/index.js.map +0 -1
  982. package/dist/tools/live-preview.d.ts +0 -23
  983. package/dist/tools/live-preview.js +0 -41
  984. package/dist/tools/live-preview.js.map +0 -1
  985. package/dist/tools/ls.d.ts +0 -9
  986. package/dist/tools/ls.js +0 -59
  987. package/dist/tools/ls.js.map +0 -1
  988. package/dist/tools/operations.d.ts +0 -86
  989. package/dist/tools/operations.js +0 -117
  990. package/dist/tools/operations.js.map +0 -1
  991. package/dist/tools/overflow.d.ts +0 -17
  992. package/dist/tools/overflow.js +0 -68
  993. package/dist/tools/overflow.js.map +0 -1
  994. package/dist/tools/path-utils.d.ts +0 -30
  995. package/dist/tools/path-utils.js +0 -74
  996. package/dist/tools/path-utils.js.map +0 -1
  997. package/dist/tools/pdf-extract.d.ts +0 -17
  998. package/dist/tools/pdf-extract.js +0 -43
  999. package/dist/tools/pdf-extract.js.map +0 -1
  1000. package/dist/tools/prompt-hints.d.ts +0 -46
  1001. package/dist/tools/prompt-hints.js +0 -171
  1002. package/dist/tools/prompt-hints.js.map +0 -1
  1003. package/dist/tools/read-only-bash.d.ts +0 -31
  1004. package/dist/tools/read-only-bash.js +0 -338
  1005. package/dist/tools/read-only-bash.js.map +0 -1
  1006. package/dist/tools/read-tracker.d.ts +0 -43
  1007. package/dist/tools/read-tracker.js +0 -120
  1008. package/dist/tools/read-tracker.js.map +0 -1
  1009. package/dist/tools/read.d.ts +0 -18
  1010. package/dist/tools/read.js +0 -316
  1011. package/dist/tools/read.js.map +0 -1
  1012. package/dist/tools/redaction-guard.d.ts +0 -10
  1013. package/dist/tools/redaction-guard.js +0 -55
  1014. package/dist/tools/redaction-guard.js.map +0 -1
  1015. package/dist/tools/routine-output.d.ts +0 -39
  1016. package/dist/tools/routine-output.js +0 -281
  1017. package/dist/tools/routine-output.js.map +0 -1
  1018. package/dist/tools/safe-env.d.ts +0 -1
  1019. package/dist/tools/safe-env.js +0 -79
  1020. package/dist/tools/safe-env.js.map +0 -1
  1021. package/dist/tools/session-stats.d.ts +0 -26
  1022. package/dist/tools/session-stats.js +0 -51
  1023. package/dist/tools/session-stats.js.map +0 -1
  1024. package/dist/tools/side-web-search.d.ts +0 -34
  1025. package/dist/tools/side-web-search.js +0 -146
  1026. package/dist/tools/side-web-search.js.map +0 -1
  1027. package/dist/tools/skill.d.ts +0 -12
  1028. package/dist/tools/skill.js +0 -94
  1029. package/dist/tools/skill.js.map +0 -1
  1030. package/dist/tools/source-path.d.ts +0 -8
  1031. package/dist/tools/source-path.js +0 -128
  1032. package/dist/tools/source-path.js.map +0 -1
  1033. package/dist/tools/steroids.d.ts +0 -44
  1034. package/dist/tools/steroids.js +0 -356
  1035. package/dist/tools/steroids.js.map +0 -1
  1036. package/dist/tools/subagent-control.d.ts +0 -5
  1037. package/dist/tools/subagent-control.js +0 -211
  1038. package/dist/tools/subagent-control.js.map +0 -1
  1039. package/dist/tools/subagent-shared.d.ts +0 -110
  1040. package/dist/tools/subagent-shared.js +0 -180
  1041. package/dist/tools/subagent-shared.js.map +0 -1
  1042. package/dist/tools/subagent.d.ts +0 -37
  1043. package/dist/tools/subagent.js +0 -406
  1044. package/dist/tools/subagent.js.map +0 -1
  1045. package/dist/tools/task-output.d.ts +0 -10
  1046. package/dist/tools/task-output.js +0 -74
  1047. package/dist/tools/task-output.js.map +0 -1
  1048. package/dist/tools/task-send.d.ts +0 -11
  1049. package/dist/tools/task-send.js +0 -36
  1050. package/dist/tools/task-send.js.map +0 -1
  1051. package/dist/tools/task-stop.d.ts +0 -8
  1052. package/dist/tools/task-stop.js +0 -15
  1053. package/dist/tools/task-stop.js.map +0 -1
  1054. package/dist/tools/tasks.d.ts +0 -15
  1055. package/dist/tools/tasks.js +0 -94
  1056. package/dist/tools/tasks.js.map +0 -1
  1057. package/dist/tools/tool-search.d.ts +0 -26
  1058. package/dist/tools/tool-search.js +0 -81
  1059. package/dist/tools/tool-search.js.map +0 -1
  1060. package/dist/tools/tool-tiers.d.ts +0 -65
  1061. package/dist/tools/tool-tiers.js +0 -121
  1062. package/dist/tools/tool-tiers.js.map +0 -1
  1063. package/dist/tools/truncate.d.ts +0 -39
  1064. package/dist/tools/truncate.js +0 -242
  1065. package/dist/tools/truncate.js.map +0 -1
  1066. package/dist/tools/ui-adopt.d.ts +0 -16
  1067. package/dist/tools/ui-adopt.js +0 -66
  1068. package/dist/tools/ui-adopt.js.map +0 -1
  1069. package/dist/tools/ui-registry.d.ts +0 -15
  1070. package/dist/tools/ui-registry.js +0 -39
  1071. package/dist/tools/ui-registry.js.map +0 -1
  1072. package/dist/tools/verification-review.d.ts +0 -2
  1073. package/dist/tools/verification-review.js +0 -41
  1074. package/dist/tools/verification-review.js.map +0 -1
  1075. package/dist/tools/web-fetch.d.ts +0 -52
  1076. package/dist/tools/web-fetch.js +0 -986
  1077. package/dist/tools/web-fetch.js.map +0 -1
  1078. package/dist/tools/web-search.d.ts +0 -35
  1079. package/dist/tools/web-search.js +0 -926
  1080. package/dist/tools/web-search.js.map +0 -1
  1081. package/dist/tools/write.d.ts +0 -16
  1082. package/dist/tools/write.js +0 -196
  1083. package/dist/tools/write.js.map +0 -1
  1084. package/dist/types.d.ts +0 -44
  1085. package/dist/types.js +0 -2
  1086. package/dist/types.js.map +0 -1
  1087. package/dist/utils/git.d.ts +0 -102
  1088. package/dist/utils/git.js +0 -325
  1089. package/dist/utils/git.js.map +0 -1
  1090. package/dist/utils/github-ci.d.ts +0 -18
  1091. package/dist/utils/github-ci.js +0 -138
  1092. package/dist/utils/github-ci.js.map +0 -1
  1093. package/dist/utils/github.d.ts +0 -19
  1094. package/dist/utils/github.js +0 -67
  1095. package/dist/utils/github.js.map +0 -1
  1096. package/dist/utils/image.d.ts +0 -166
  1097. package/dist/utils/image.js +0 -673
  1098. package/dist/utils/image.js.map +0 -1
  1099. package/dist/utils/open-browser.d.ts +0 -13
  1100. package/dist/utils/open-browser.js +0 -31
  1101. package/dist/utils/open-browser.js.map +0 -1
  1102. package/dist/utils/plan-steps.d.ts +0 -90
  1103. package/dist/utils/plan-steps.js +0 -209
  1104. package/dist/utils/plan-steps.js.map +0 -1
  1105. package/dist/utils/process.d.ts +0 -48
  1106. package/dist/utils/process.js +0 -175
  1107. package/dist/utils/process.js.map +0 -1
  1108. package/dist/utils/prompt-enhancer.d.ts +0 -53
  1109. package/dist/utils/prompt-enhancer.js +0 -178
  1110. package/dist/utils/prompt-enhancer.js.map +0 -1
  1111. package/dist/utils/text.d.ts +0 -61
  1112. package/dist/utils/text.js +0 -68
  1113. package/dist/utils/text.js.map +0 -1
  1114. package/dist/web.d.ts +0 -5
  1115. package/dist/web.js +0 -5
  1116. package/dist/web.js.map +0 -1
@@ -1,902 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- import fs from "node:fs";
3
- import fsp from "node:fs/promises";
4
- import path from "node:path";
5
- import os from "node:os";
6
- import crypto from "node:crypto";
7
- import { killProcessTree } from "../utils/process.js";
8
- import { getSafeToolEnv } from "../tools/safe-env.js";
9
- import { resolveShell } from "./shell.js";
10
- const BG_DIR = path.join(os.homedir(), ".gg", "bg");
11
- /**
12
- * How long a background process log survives after its last write.
13
- *
14
- * Every `start()` opens a new `<id>.log` and nothing ever removed them, so the
15
- * directory grew without bound for the lifetime of the install — measured at
16
- * 14,358 files / 494MB on a single developer machine, with entries dating back
17
- * five months. These are debugging aids for a process the agent started; once
18
- * the run is long over, so is their value.
19
- */
20
- const BG_LOG_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
21
- /** Throttle between prune sweeps, so a burst of `start()` calls scans once. */
22
- const BG_PRUNE_INTERVAL_MS = 60 * 60 * 1000;
23
- /** Delay before a running process may first report progress. */
24
- const WATCH_INTERVAL_MS = 5_000;
25
- /** Tick for model-declared wake rules (match/silence). Cheap: one stat + a
26
- * bounded tail read, so a flat interval (no backoff) is fine. */
27
- const WAKE_INTERVAL_MS = 500;
28
- /** Ceiling on the progress interval as it backs off between reports. */
29
- const WATCH_INTERVAL_MAX_MS = 120_000;
30
- /**
31
- * How many progress checkpoints one background process may push, ever.
32
- *
33
- * A progress checkpoint is worth most early ("the build is underway", "it died
34
- * on startup") and approaches zero after that: a dev server the agent started
35
- * itself, still logging an hour on, tells it nothing it doesn't already know
36
- * and can always be inspected on demand with `task_output`.
37
- *
38
- * At a flat interval with no budget, such a server produced a fresh checkpoint
39
- * for essentially every loop step — measured here at ~2k tokens per minute of
40
- * overlap, i.e. a whole context window per hour spent restating "still
41
- * running".
42
- *
43
- * Anthropic reached the same conclusion the hard way: Claude Code shipped
44
- * periodic background status into the model's context as `task_progress` and
45
- * `background_task_status` attachments, then REMOVED both (they survive only in
46
- * a `LEGACY_ATTACHMENT_TYPES` list that drops them from resumed sessions).
47
- * Their progress is now a host-side stream event for the UI, and the only thing
48
- * pushed into context is the terminal completion notice.
49
- *
50
- * We keep a small early budget rather than going to zero: the first few reports
51
- * are what let the agent notice a build that died on startup without blocking
52
- * on it. Combined with the backoff those land at ~5s, ~15s and ~35s, after
53
- * which the watcher retires and only the exit notification remains.
54
- */
55
- const WATCH_MAX_REPORTS = 3;
56
- /** Chars of log tail carried in a progress checkpoint. */
57
- const CHECKPOINT_TAIL_CHARS = 320;
58
- /** Ceiling on a single blocking `waitForExitOrWake`, so one wedged process cannot
59
- * hold the agent loop indefinitely; callers re-wait if they still want to. */
60
- export const MAX_PROCESS_WAIT_MS = 300_000;
61
- /** Output a foreground command produced before {@link ProcessManager.adopt} that
62
- * is kept in its log; the rest was already shown to nobody and only costs disk. */
63
- const ADOPTED_PRIOR_OUTPUT_BYTES = 1024 * 1024;
64
- /** Chars of the matched log line carried in a pattern-wake notification. */
65
- const WAKE_LINE_CHARS = 200;
66
- /**
67
- * Most new log bytes one wake tick scans. A process that floods its log faster
68
- * than this between ticks only has its latest output checked — that is where a
69
- * fresh failure or readiness line is.
70
- */
71
- const WAKE_SCAN_MAX_BYTES = 1024 * 1024;
72
- /** ANSI escape sequences: SGR colours, cursor movement, OSC titles/links. */
73
- // eslint-disable-next-line no-control-regex -- matching terminal escapes is the point
74
- const ANSI_ESCAPE = /\u001b\[[0-?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g;
75
- /**
76
- * Remove terminal colour and cursor codes. Test runners and CLIs colour their
77
- * output, and a code can sit inside the very word a wake looks for:
78
- * `\e[31mFAIL\e[0mED` never matches /FAILED/ until it is stripped.
79
- */
80
- export function stripAnsi(text) {
81
- return text.replace(ANSI_ESCAPE, "");
82
- }
83
- /**
84
- * Lines that mean "something failed" in the tools agents actually run in the
85
- * background. Each one is anchored to a shape a tool prints, NOT a bare word:
86
- * "error" or "failed" alone shows up in plenty of healthy output (file names,
87
- * "0 failed", log levels), and a wake that cries wolf trains the agent to
88
- * ignore it.
89
- */
90
- const FAILURE_LINE_PATTERNS = [
91
- // vitest / jest file results, pytest FAILED lines, go "FAIL\tpkg".
92
- /^\s*FAIL(?:ED)?\b(?!\s*[:=]?\s*0\b)/,
93
- // go test.
94
- /^\s*--- FAIL:/,
95
- // Summaries: vitest "Tests 2 failed | 8 passed", jest "Tests: 2 failed",
96
- // pytest "==== 2 failed, 8 passed ====", mocha "2 failing".
97
- /^\s*(?:Tests?:?|Test Files|=+)\s.*\b[1-9]\d* failed\b/,
98
- /^\s*[1-9]\d* failing\b/,
99
- // vitest's failed-test marker, esbuild's "✘ [ERROR]", Playwright's list
100
- // reporter (" ✘ 5 e2e/a.spec.ts:9:5 › …", several spaces).
101
- /^\s*[✗✘×]\s+\S/,
102
- // TypeScript.
103
- /\berror TS\d{3,5}:/,
104
- // rustc / cargo.
105
- /^error(?:\[E\d{4}\])?: \S/,
106
- // npm / pnpm / yarn.
107
- /^npm ERR! /,
108
- /\bERR_PNPM_[A-Z_]+\b/,
109
- /\bELIFECYCLE\b.*\bfailed\b/i,
110
- // Python, Rust panics.
111
- /^Traceback \(most recent call last\):/,
112
- /\bpanicked at\b/,
113
- // Uncaught JS errors at the start of a line ("TypeError: x is undefined").
114
- /^\s*(?:Uncaught |Unhandled )?[A-Z][A-Za-z]*Error: \S/,
115
- // Bundlers and build tools.
116
- /^\s*BUILD FAILED\b/,
117
- /\bBuild failed with \d+ errors?\b/,
118
- // GitHub Actions log lines, and `gh run watch`'s failed-job row:
119
- // "X test (windows-latest) in 3m2s (ID 123)".
120
- /^##\[error\]/,
121
- /\bProcess completed with exit code [1-9]\d*\b/,
122
- /^X .+ \(ID \d+\)\s*$/,
123
- ];
124
- /**
125
- * The first line in `text` that looks like a tool reporting a failure, ANSI
126
- * codes stripped, or undefined. Exported for tests.
127
- */
128
- export function findFailureLine(text) {
129
- for (const raw of stripAnsi(text).split(/\r?\n|\r/)) {
130
- if (raw.length > 4096)
131
- continue; // A minified blob, not a status line.
132
- if (FAILURE_LINE_PATTERNS.some((pattern) => pattern.test(raw)))
133
- return raw;
134
- }
135
- return undefined;
136
- }
137
- /**
138
- * The line holding the first match of `pattern` that ends inside `fresh`, where
139
- * `seen` is overlap already scanned on an earlier tick. Matching across the
140
- * boundary still counts (a line split between ticks), but a match lying wholly
141
- * inside `seen` was already reported and must not fire again.
142
- */
143
- function findFreshMatchLine(pattern, seen, fresh) {
144
- const text = seen + fresh;
145
- const boundary = seen.length;
146
- const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
147
- for (const match of text.matchAll(new RegExp(pattern.source, flags))) {
148
- const end = match.index + match[0].length;
149
- if (end <= boundary && !(match[0].length === 0 && match.index >= boundary))
150
- continue;
151
- const lineStart = text.lastIndexOf("\n", match.index - 1) + 1;
152
- const lineEnd = text.indexOf("\n", match.index);
153
- return text.slice(lineStart, lineEnd === -1 ? undefined : lineEnd) || match[0];
154
- }
155
- return undefined;
156
- }
157
- /** One log line, whitespace-collapsed and tail-bounded — never the raw log. */
158
- function boundedLine(text) {
159
- const collapsed = text.replace(/\s+/g, " ").trim();
160
- if (!collapsed)
161
- return "";
162
- return collapsed.length <= WAKE_LINE_CHARS
163
- ? collapsed
164
- : `\u2026${collapsed.slice(collapsed.length - WAKE_LINE_CHARS)}`;
165
- }
166
- /** Last line(s) of the log, collapsed and bounded — never the raw log. */
167
- function tailDigest(text) {
168
- const collapsed = text.replace(/\s+/g, " ").trim();
169
- if (!collapsed)
170
- return "";
171
- return collapsed.length <= CHECKPOINT_TAIL_CHARS
172
- ? collapsed
173
- : `\u2026${collapsed.slice(collapsed.length - CHECKPOINT_TAIL_CHARS)}`;
174
- }
175
- function formatElapsed(ms) {
176
- return ms >= 60_000 ? `${Math.round(ms / 6_000) / 10}m` : `${Math.round(ms / 1_000)}s`;
177
- }
178
- function stopProcessTree(pid, ops = {}) {
179
- // pid 0 marks a child that never spawned. Signalling 0 (or -0) would hit
180
- // this host's own process group.
181
- if (pid <= 0)
182
- return;
183
- if (ops.killProcessTree) {
184
- ops.killProcessTree(pid);
185
- return;
186
- }
187
- // killProcessTree is itself platform-aware (taskkill /T /F on Windows).
188
- killProcessTree(pid, { platform: ops.platform, kill: ops.kill, spawnSync: ops.spawnSync });
189
- }
190
- export class ProcessManager {
191
- ops;
192
- processes = new Map();
193
- children = new Map();
194
- /** Per-process progress timers. Cleared on exit, stop and shutdown. */
195
- watchers = new Map();
196
- /** Per-process wake-rule timers (model-declared match/silence conditions). */
197
- wakeWatchers = new Map();
198
- wakeStates = new Map();
199
- /** Log size at the last emitted checkpoint, so a quiet process stays quiet. */
200
- watchedSizes = new Map();
201
- /** Processes the agent or host is deliberately stopping: their non-zero exit
202
- * is the stop working, not news, so it must not raise an urgent alert. */
203
- stopping = new Set();
204
- /** Timestamp of the last retention sweep; 0 means "never swept". */
205
- lastPruneAt = 0;
206
- constructor(ops = {}) {
207
- this.ops = ops;
208
- }
209
- get bgDir() {
210
- return this.ops.bgDir ?? BG_DIR;
211
- }
212
- /**
213
- * Delete background logs whose last write is older than the retention window.
214
- *
215
- * Deliberately best-effort and never awaited by `start()`: losing an old log
216
- * is harmless, but failing to launch the user's process because a stale log
217
- * couldn't be unlinked is not. Logs belonging to processes this manager still
218
- * tracks are skipped regardless of age — a quiet long-running dev server can
219
- * easily go a week without writing a line, and its log must stay readable.
220
- */
221
- async pruneOldLogs() {
222
- const now = Date.now();
223
- if (now - this.lastPruneAt < BG_PRUNE_INTERVAL_MS)
224
- return;
225
- this.lastPruneAt = now;
226
- let entries;
227
- try {
228
- entries = await fsp.readdir(this.bgDir);
229
- }
230
- catch {
231
- return; // Directory missing or unreadable; nothing to prune.
232
- }
233
- const live = new Set([...this.processes.keys()].map((id) => `${id}.log`));
234
- const cutoff = now - BG_LOG_RETENTION_MS;
235
- for (const entry of entries) {
236
- if (!entry.endsWith(".log") || live.has(entry))
237
- continue;
238
- const file = path.join(this.bgDir, entry);
239
- try {
240
- const stat = await fsp.stat(file);
241
- if (stat.mtimeMs >= cutoff)
242
- continue;
243
- await fsp.unlink(file);
244
- }
245
- catch {
246
- // Raced with another sweep or held open elsewhere; try again next time.
247
- }
248
- }
249
- }
250
- async start(command, cwd, launch, wake,
251
- /** Extra env for this process (e.g. the package release-age cooldown). */
252
- extraEnv = {}) {
253
- await fsp.mkdir(this.bgDir, { recursive: true });
254
- void this.pruneOldLogs();
255
- const id = crypto.randomUUID().slice(0, 8);
256
- const logFile = path.join(this.bgDir, `${id}.log`);
257
- const fd = fs.openSync(logFile, "w");
258
- // Cross-platform shell (see core/shell.ts): bash on POSIX, Git Bash on
259
- // Windows, cmd.exe fallback. Same resolution as the foreground bash tool.
260
- const shell = launch ?? resolveShell(command);
261
- const child = spawn(shell.file, shell.args, {
262
- cwd,
263
- detached: true,
264
- // stdin is a pipe so callers can drive interactive processes (REPLs,
265
- // scaffolders, [Y/n] prompts) via sendInput(); stdout/stderr go to the log.
266
- stdio: ["pipe", fd, fd],
267
- env: { ...getSafeToolEnv(), ...extraEnv },
268
- });
269
- fs.closeSync(fd);
270
- // Swallow EPIPE: writing to a process that has already exited would
271
- // otherwise emit an unhandled 'error' and crash the host.
272
- child.stdin?.on("error", () => { });
273
- // No pid means the spawn failed. 'error' then 'close' still fire, and track()
274
- // records the exit, so register it with pid 0, which every kill path skips.
275
- const pid = child.pid ?? 0;
276
- child.unref();
277
- const proc = {
278
- id,
279
- pid,
280
- command,
281
- logFile,
282
- startedAt: Date.now(),
283
- exitCode: null,
284
- lastReadOffset: 0,
285
- logSize: 0,
286
- };
287
- return this.track(child, proc, wake);
288
- }
289
- /**
290
- * Take over a foreground command that is still running, so the caller can
291
- * return without killing it. Output captured so far seeds the log (its last
292
- * {@link ADOPTED_PRIOR_OUTPUT_BYTES} only); later stdout/stderr is appended
293
- * as it arrives. The process keeps its cwd and environment because it is the
294
- * same process. Its stdin was never a pipe, so `sendInput` reports it closed.
295
- *
296
- * Synchronous on purpose: the caller hands over a live child whose 'close'
297
- * has not fired yet, and an `await` here could let it fire unobserved.
298
- */
299
- adopt(child, command, startedAt, priorOutput) {
300
- fs.mkdirSync(this.bgDir, { recursive: true });
301
- void this.pruneOldLogs();
302
- const id = crypto.randomUUID().slice(0, 8);
303
- const logFile = path.join(this.bgDir, `${id}.log`);
304
- const prior = priorOutput.length > ADOPTED_PRIOR_OUTPUT_BYTES
305
- ? Buffer.concat([
306
- Buffer.from(`[earlier output dropped; last ${ADOPTED_PRIOR_OUTPUT_BYTES / 1024 / 1024} MiB kept]\n`),
307
- priorOutput.subarray(priorOutput.length - ADOPTED_PRIOR_OUTPUT_BYTES),
308
- ])
309
- : priorOutput;
310
- const fd = fs.openSync(logFile, "w");
311
- fs.writeSync(fd, prior);
312
- // Synchronous appends keep the log ordered and complete by the time
313
- // 'close' fires, which the exit bookkeeping and waiters rely on.
314
- const append = (data) => {
315
- try {
316
- fs.writeSync(fd, data);
317
- }
318
- catch {
319
- // Disk full or log removed: drop output rather than crash the host.
320
- }
321
- };
322
- child.stdout?.on("data", append);
323
- child.stderr?.on("data", append);
324
- child.once("close", () => fs.closeSync(fd));
325
- // Never hold the host's event loop open for a process it no longer awaits.
326
- child.unref();
327
- for (const stream of [child.stdout, child.stderr]) {
328
- stream?.unref?.();
329
- }
330
- const proc = {
331
- id,
332
- pid: child.pid ?? 0,
333
- command,
334
- logFile,
335
- startedAt,
336
- exitCode: null,
337
- lastReadOffset: 0,
338
- logSize: prior.length,
339
- };
340
- return this.track(child, proc);
341
- }
342
- /** Register a running child and arm its exit bookkeeping and watchers. */
343
- track(child, proc, wake) {
344
- const { id, pid, logFile } = proc;
345
- this.processes.set(id, proc);
346
- this.children.set(id, child);
347
- // A child that fails to spawn emits 'error', and an 'error' with no listener
348
- // is thrown as an uncaught exception that takes the whole CLI down. 'close'
349
- // still fires afterwards (verified: ENOENT gives error then close -2), so
350
- // exit bookkeeping below stays the single source of truth and this handler
351
- // only has to keep the event from being fatal.
352
- child.on("error", () => { });
353
- child.on("close", (code) => {
354
- proc.exitCode = code ?? 1;
355
- this.children.delete(id);
356
- this.disposeWatcher(id);
357
- // Refresh unconditionally: the gate needs a final size even when no
358
- // notification queue is wired and notifyExit is a no-op.
359
- void this.refreshLogSize(proc).then(() => this.notifyExit(proc));
360
- });
361
- this.armWatcher(proc);
362
- // Always armed: the built-in failure detector runs on every task, so a
363
- // build or CI watcher that prints a failure but keeps running releases a
364
- // waiting agent at once instead of at exit or the wait cap.
365
- const wakeArmed = this.armWakeWatcher(proc, wake);
366
- return { id, pid, logFile, wakeArmed };
367
- }
368
- /**
369
- * Arm a backing-off, budgeted progress watcher for one background process.
370
- * Emits at most one latest-only checkpoint per interval, only when the log
371
- * actually grew, and at most {@link WATCH_MAX_REPORTS} times in total — so a
372
- * build reports itself early without the agent ever calling `task_output`,
373
- * while an idle or long-lived process stops costing context.
374
- *
375
- * Once the budget is spent the watcher retires completely (no timer, no
376
- * further injections). The terminal exit notification is unaffected: it is
377
- * produced by the exit handler, not this watcher, so "it finished" always
378
- * still reaches the agent.
379
- *
380
- * Self-rescheduling rather than `setInterval` because the delay changes; a
381
- * tick is only scheduled once the previous one has been handled.
382
- *
383
- * No-op when no notification queue is wired, so hosts that never drain
384
- * notifications pay nothing.
385
- */
386
- armWatcher(proc) {
387
- const queue = this.ops.notifications;
388
- if (!queue)
389
- return;
390
- this.watchedSizes.set(proc.id, 0);
391
- let delay = this.ops.watchIntervalMs ?? WATCH_INTERVAL_MS;
392
- let reports = 0;
393
- const schedule = () => {
394
- const timer = setTimeout(() => {
395
- // The process may have exited between ticks; the terminal checkpoint
396
- // owns that case and must not be overwritten by a stale progress line.
397
- if (proc.exitCode !== null) {
398
- this.disposeWatcher(proc.id);
399
- return;
400
- }
401
- void this.emitProgress(proc).then((emitted) => {
402
- // Re-check: the process can exit while the tail read is in flight,
403
- // and disposeWatcher may already have cleared this entry.
404
- if (proc.exitCode !== null || !this.watchers.has(proc.id))
405
- return;
406
- if (emitted && ++reports >= WATCH_MAX_REPORTS) {
407
- // Retire generic progress only; declared readiness must still fire
408
- // if a slow server finishes starting after this budget is spent.
409
- this.disposeProgressWatcher(proc.id);
410
- return;
411
- }
412
- // Back off only on an actual report. A process that goes quiet must
413
- // NOT drift towards the cap while emitting nothing — otherwise a dev
414
- // server that idles and then fails a recompile is heard about minutes
415
- // late. Silence is already free; only chattiness needs damping.
416
- if (emitted)
417
- delay = Math.min(delay * 2, WATCH_INTERVAL_MAX_MS);
418
- schedule();
419
- });
420
- }, delay);
421
- // Never hold the event loop open for a detached background process.
422
- timer.unref?.();
423
- this.watchers.set(proc.id, timer);
424
- };
425
- schedule();
426
- }
427
- /** Stat the log once and cache its size on the record. Returns 0 if unreadable. */
428
- async refreshLogSize(proc) {
429
- try {
430
- proc.logSize = (await fsp.stat(proc.logFile)).size;
431
- }
432
- catch {
433
- // Log may be gone (pruned, or never created); keep the last known size.
434
- }
435
- return proc.logSize;
436
- }
437
- /** Emit one progress checkpoint if the log grew. Returns whether it did. */
438
- async emitProgress(proc) {
439
- const queue = this.ops.notifications;
440
- if (!queue)
441
- return false;
442
- const size = await this.refreshLogSize(proc);
443
- const previous = this.watchedSizes.get(proc.id) ?? 0;
444
- if (size <= previous)
445
- return false;
446
- if (proc.exitCode !== null)
447
- return false;
448
- const tail = await this.readTail(proc.logFile, size);
449
- // The tail read can race a dispose: a wake rule firing (its declared
450
- // signal outranks generic progress) or the process exiting (the terminal
451
- // notification owns that case). An enqueue after that would supersede
452
- // that notification in the latest-only queue, so a disposed watcher
453
- // stays silent.
454
- if (!this.watchers.has(proc.id))
455
- return false;
456
- this.watchedSizes.set(proc.id, size);
457
- queue.enqueue("process", proc.id, `Background process ${proc.id} (${proc.command}) is still running after ` +
458
- `${formatElapsed(Date.now() - proc.startedAt)}, ${size} bytes logged` +
459
- `${tail ? `. Latest: ${tail}` : ""}`);
460
- return true;
461
- }
462
- notifyExit(proc) {
463
- const queue = this.ops.notifications;
464
- if (!queue)
465
- return;
466
- // A failed exit is news the agent must act on; a deliberate stop is not.
467
- const urgent = proc.exitCode !== 0 && !this.stopping.has(proc.id);
468
- void (async () => {
469
- const size = proc.logSize;
470
- const tail = size > 0 ? await this.readTail(proc.logFile, size) : "";
471
- queue.enqueue("process", proc.id, `Background process ${proc.id} (${proc.command}) exited with code ${proc.exitCode} ` +
472
- `after ${formatElapsed(Date.now() - proc.startedAt)}` +
473
- `${tail ? `. Last output: ${tail}` : ""}. ` +
474
- `Read it with task_output id="${proc.id}".`, { terminal: true, urgent });
475
- })();
476
- }
477
- /** Read the trailing bytes of a log without loading the whole file. */
478
- async readTail(logFile, size) {
479
- const start = Math.max(0, size - CHECKPOINT_TAIL_CHARS * 4);
480
- try {
481
- const fh = await fsp.open(logFile, "r");
482
- try {
483
- const buf = Buffer.alloc(size - start);
484
- const { bytesRead } = await fh.read(buf, 0, buf.length, start);
485
- return tailDigest(buf.subarray(0, bytesRead).toString("utf-8"));
486
- }
487
- finally {
488
- await fh.close();
489
- }
490
- }
491
- catch {
492
- return "";
493
- }
494
- }
495
- /** Read the bytes of a log in `[start, end)` without loading the file. */
496
- async readBytes(logFile, start, end) {
497
- try {
498
- const fh = await fsp.open(logFile, "r");
499
- try {
500
- const buf = Buffer.alloc(Math.max(0, end - start));
501
- const { bytesRead } = await fh.read(buf, 0, buf.length, start);
502
- return buf.subarray(0, bytesRead);
503
- }
504
- finally {
505
- await fh.close();
506
- }
507
- }
508
- catch {
509
- return Buffer.alloc(0);
510
- }
511
- }
512
- /**
513
- * Wake watcher, evaluated every {@link WAKE_INTERVAL_MS}. Always runs the
514
- * built-in failure detector (one-shot), plus the model's declared rules when
515
- * a notification queue can deliver them: `pattern` fires on every new match,
516
- * `silenceMs` once. It retires on exit, or once nothing is left that could
517
- * still fire. Unlike the progress watcher it never backs off — a late match
518
- * on a quiet dev server is precisely the point.
519
- *
520
- * Returns whether the model's declared rules were armed. Without a queue they
521
- * are not (nothing could deliver them), but failure detection still releases
522
- * a blocking `task_output` wait directly.
523
- */
524
- armWakeWatcher(proc, requested) {
525
- const wantsRules = Boolean(requested && (requested.pattern || requested.silenceMs));
526
- const rulesArmed = wantsRules && this.ops.notifications !== undefined;
527
- const state = {
528
- rules: rulesArmed && requested ? requested : {},
529
- scanOffset: 0,
530
- failureOffset: 0,
531
- lastSize: 0,
532
- lastGrowthAt: proc.startedAt,
533
- silenceFired: false,
534
- failureFired: false,
535
- };
536
- this.wakeStates.set(proc.id, state);
537
- const patternSource = state.rules.pattern?.source ?? "";
538
- // Re-scan a little before the last offset so a match straddling the tick
539
- // boundary is still seen; the offset only ever advances to full size.
540
- const overlap = Math.min(256, patternSource.length + 16);
541
- const tick = () => {
542
- const timer = setTimeout(() => {
543
- void this.evaluateWakeRules(proc, state, overlap).then(() => {
544
- if (proc.exitCode !== null || !this.wakeStates.has(proc.id)) {
545
- this.disposeWakeWatcher(proc.id);
546
- return;
547
- }
548
- // A pattern can always match again, so it keeps the watcher alive.
549
- const done = !state.rules.pattern &&
550
- (!state.rules.silenceMs || state.silenceFired) &&
551
- state.failureFired;
552
- if (done) {
553
- this.disposeWakeWatcher(proc.id);
554
- return;
555
- }
556
- tick();
557
- });
558
- }, WAKE_INTERVAL_MS);
559
- timer.unref?.();
560
- this.wakeWatchers.set(proc.id, timer);
561
- };
562
- tick();
563
- return rulesArmed;
564
- }
565
- /** Record a wake on the process and release anyone blocked waiting on it. */
566
- fireWake(proc, reason, offset) {
567
- proc.wakeReason = reason;
568
- proc.wakeOffset = offset;
569
- this.children.get(proc.id)?.emit("gg:wake", reason);
570
- }
571
- async evaluateWakeRules(proc, state, overlap) {
572
- const queue = this.ops.notifications;
573
- const size = await this.refreshLogSize(proc);
574
- const gone = () => proc.exitCode !== null || !this.wakeStates.has(proc.id);
575
- if (size > state.lastSize) {
576
- state.lastSize = size;
577
- state.lastGrowthAt = Date.now();
578
- }
579
- const { pattern, silenceMs } = state.rules;
580
- if (pattern && queue && size > state.scanOffset) {
581
- let start = Math.max(0, state.scanOffset - overlap);
582
- if (size - start > WAKE_SCAN_MAX_BYTES)
583
- start = size - WAKE_SCAN_MAX_BYTES;
584
- const buf = await this.readBytes(proc.logFile, start, size);
585
- if (gone())
586
- return;
587
- const boundary = Math.max(0, Math.min(buf.length, state.scanOffset - start));
588
- state.scanOffset = Math.max(state.scanOffset, start + buf.length);
589
- const line = findFreshMatchLine(pattern, stripAnsi(buf.subarray(0, boundary).toString("utf-8")), stripAnsi(buf.subarray(boundary).toString("utf-8")));
590
- if (line !== undefined) {
591
- state.lastPatternLine = boundedLine(line);
592
- // The declared signal outranks generic progress: retire the progress
593
- // watcher so its next tick cannot supersede this notification in the
594
- // latest-only queue. Exit notifications come from the exit handler.
595
- this.disposeProgressWatcher(proc.id);
596
- queue.enqueue("process", proc.id, `Background process ${proc.id} (${proc.command}) produced output matching your wake ` +
597
- `pattern /${pattern.source}/: ${boundedLine(line)}. Still running — ` +
598
- `task_output id="${proc.id}" for full context.`);
599
- this.fireWake(proc, "pattern", state.scanOffset);
600
- }
601
- }
602
- if (!state.failureFired && size > state.failureOffset) {
603
- let start = state.failureOffset;
604
- if (size - start > WAKE_SCAN_MAX_BYTES)
605
- start = size - WAKE_SCAN_MAX_BYTES;
606
- const buf = await this.readBytes(proc.logFile, start, size);
607
- if (gone())
608
- return;
609
- // Whole lines only: a line still being written is re-read next tick, so
610
- // "FAI" + "LED" across two writes is still one failure line.
611
- const lastNewline = buf.lastIndexOf(0x0a);
612
- if (lastNewline >= 0) {
613
- state.failureOffset = start + lastNewline + 1;
614
- // Lines the agent has already read (task_output ran while this tick
615
- // was reading) are not news; waking for them replays a seen failure.
616
- const readTo = proc.lastReadOffset - start;
617
- const unreadStart = readTo <= 0 ? 0 : buf.lastIndexOf(0x0a, readTo - 1) + 1;
618
- const line = unreadStart >= lastNewline
619
- ? undefined
620
- : findFailureLine(buf.subarray(unreadStart, lastNewline).toString("utf-8"));
621
- if (line !== undefined) {
622
- state.failureFired = true;
623
- this.disposeProgressWatcher(proc.id);
624
- // The queue keeps one entry per task, so this notice replaces any
625
- // pattern notice still pending. When both fired on the same line, say
626
- // both: the agent asked for that pattern by name.
627
- const shown = boundedLine(line);
628
- const what = pattern && state.lastPatternLine === shown
629
- ? `produced output matching your wake pattern /${pattern.source}/ that also looks like a failure`
630
- : "printed what looks like a failure";
631
- queue?.enqueue("process", proc.id, `Background process ${proc.id} (${proc.command}) ${what}: ` +
632
- `${shown}. Still running — read it with task_output id="${proc.id}", ` +
633
- `then fix the cause, stop it, or keep waiting if the failure is expected.`, { urgent: true });
634
- this.fireWake(proc, "failure", state.failureOffset);
635
- }
636
- }
637
- else if (buf.length >= WAKE_SCAN_MAX_BYTES) {
638
- // One enormous unterminated line (a progress bar redrawn with \r):
639
- // skip it rather than re-reading a megabyte every tick.
640
- state.failureOffset = start + buf.length;
641
- }
642
- }
643
- if (queue &&
644
- silenceMs &&
645
- !state.silenceFired &&
646
- proc.exitCode === null &&
647
- Date.now() - state.lastGrowthAt >= silenceMs) {
648
- state.silenceFired = true;
649
- this.disposeProgressWatcher(proc.id);
650
- const tail = await this.readTail(proc.logFile, size);
651
- if (gone())
652
- return;
653
- queue.enqueue("process", proc.id, `Background process ${proc.id} (${proc.command}) has produced no output for ` +
654
- `${Math.round((Date.now() - state.lastGrowthAt) / 1000)}s — it may be stalled` +
655
- `${tail ? `. Last output: ${tail}` : " (no output so far)"}. ` +
656
- `Check task_output id="${proc.id}" and decide whether to wait, send input, or stop it.`);
657
- this.fireWake(proc, "silence", size);
658
- }
659
- }
660
- /** Stop and forget a process's wake watcher. */
661
- disposeWakeWatcher(id) {
662
- const timer = this.wakeWatchers.get(id);
663
- if (timer)
664
- clearTimeout(timer);
665
- this.wakeWatchers.delete(id);
666
- this.wakeStates.delete(id);
667
- }
668
- /** Live wake-watcher ids. Exposed for leak assertions in tests. */
669
- activeWakeWatchers() {
670
- return [...this.wakeWatchers.keys()];
671
- }
672
- /** Stop and forget a process's watcher. A finished process keeps no timer. */
673
- disposeWatcher(id) {
674
- this.disposeProgressWatcher(id);
675
- this.disposeWakeWatcher(id);
676
- }
677
- /** Stop and forget a process's progress watcher only. */
678
- disposeProgressWatcher(id) {
679
- const timer = this.watchers.get(id);
680
- if (timer)
681
- clearTimeout(timer);
682
- this.watchers.delete(id);
683
- this.watchedSizes.delete(id);
684
- }
685
- /** Live watcher ids. Exposed for leak assertions in tests. */
686
- activeWatchers() {
687
- return [...this.watchers.keys()];
688
- }
689
- /**
690
- * Block until a process exits or a declared wake fires, bounded by `timeoutMs`.
691
- * Steering notifications cannot interrupt a tool call; the wake must also
692
- * release this wait directly so a ready dev server doesn't wait for shutdown.
693
- *
694
- * Without this, "wait for the build" can only be expressed as a guessed
695
- * `sleep N`: too short burns a turn, too long burns wall-clock, and neither
696
- * knows when the process actually finished. The wake/exit notifications
697
- * answer the same question but only on the steering path — they need a next
698
- * loop step to be delivered, which is exactly what an agent with nothing
699
- * else to do does not have.
700
- */
701
- async waitForExitOrWake(id, timeoutMs, signal) {
702
- return (await this.waitForActivity(id, timeoutMs, signal)).reason;
703
- }
704
- /**
705
- * {@link waitForExitOrWake}, plus what ended it. Besides this task exiting or
706
- * waking, the wait also ends when ANOTHER task raises an urgent notification
707
- * (a different build failed, a child agent finished): the agent blocked here
708
- * has no other way to learn that before its wait runs out.
709
- */
710
- async waitForActivity(id, timeoutMs, signal) {
711
- const proc = this.processes.get(id);
712
- if (!proc)
713
- return { reason: "unknown" };
714
- const child = this.children.get(id);
715
- // Already terminal (or no live child tracked): nothing to wait on.
716
- if (!child || proc.exitCode !== null)
717
- return { reason: "exited" };
718
- if (signal?.aborted)
719
- return { reason: "timeout" };
720
- if (proc.wakeReason)
721
- return { reason: proc.wakeReason };
722
- const bounded = Math.min(Math.max(timeoutMs, 0), MAX_PROCESS_WAIT_MS);
723
- return await new Promise((resolve) => {
724
- const settle = (result) => {
725
- clearTimeout(timer);
726
- child.off("close", onClose);
727
- child.off("gg:wake", onWake);
728
- signal?.removeEventListener("abort", onAbort);
729
- unsubscribe?.();
730
- resolve(result);
731
- };
732
- // Registered after start()'s own 'close' handler, so `exitCode` is
733
- // already set by the time this resolves.
734
- const onClose = () => settle({ reason: "exited" });
735
- const onWake = (reason) => settle({ reason });
736
- // Give up the wait when the caller is cancelled; the process itself is
737
- // left running — this only ends our observation of it.
738
- const onAbort = () => settle({ reason: "timeout" });
739
- const timer = setTimeout(() => settle({ reason: "timeout" }), bounded);
740
- timer.unref?.();
741
- child.once("close", onClose);
742
- child.once("gg:wake", onWake);
743
- signal?.addEventListener("abort", onAbort, { once: true });
744
- // This task's own alerts arrive above as exit/wake; only others count here.
745
- const unsubscribe = this.ops.notifications?.onUrgent((entry) => {
746
- if (entry.kind === "process" && entry.id === id)
747
- return;
748
- settle({ reason: "other", detail: entry.text });
749
- });
750
- });
751
- }
752
- async readOutput(id, fromStart) {
753
- const proc = this.processes.get(id);
754
- if (!proc) {
755
- return {
756
- id,
757
- isRunning: false,
758
- exitCode: null,
759
- output: `No background process with id "${id}"`,
760
- };
761
- }
762
- const offset = fromStart ? 0 : proc.lastReadOffset;
763
- let output = "";
764
- try {
765
- const stat = await fsp.stat(proc.logFile);
766
- proc.logSize = stat.size;
767
- if (stat.size > offset) {
768
- const buf = Buffer.alloc(stat.size - offset);
769
- const fh = await fsp.open(proc.logFile, "r");
770
- const { bytesRead } = await fh.read(buf, 0, buf.length, offset);
771
- await fh.close();
772
- output = buf.subarray(0, bytesRead).toString("utf-8");
773
- proc.lastReadOffset = offset + bytesRead;
774
- }
775
- // Consume the wake only once this read covers what it is about: a wake
776
- // that fired while the read was in flight, for output past it, stays.
777
- if ((proc.wakeOffset ?? 0) <= proc.lastReadOffset) {
778
- delete proc.wakeReason;
779
- delete proc.wakeOffset;
780
- }
781
- }
782
- catch {
783
- output = "(failed to read log file)";
784
- // Unreadable log: a wake that can never be consumed would make every
785
- // later wait return at once.
786
- delete proc.wakeReason;
787
- delete proc.wakeOffset;
788
- }
789
- const isRunning = this.children.has(id);
790
- return { id, isRunning, exitCode: proc.exitCode, output };
791
- }
792
- /**
793
- * Write input to a running background process's stdin, enabling interactive
794
- * control (answer prompts, drive a REPL, feed a scaffolder). By default a
795
- * newline is appended (as if the user pressed Enter). Set `eof` to close
796
- * stdin afterwards, signalling end-of-input (Ctrl-D) to the program.
797
- */
798
- async sendInput(id, input, opts = {}) {
799
- const proc = this.processes.get(id);
800
- if (!proc)
801
- return `No background process with id "${id}"`;
802
- const child = this.children.get(id);
803
- if (!child || proc.exitCode !== null) {
804
- return `Process ${id} already exited (code ${proc.exitCode})`;
805
- }
806
- const stdin = child.stdin;
807
- if (!stdin || stdin.destroyed || stdin.writableEnded) {
808
- return `Process ${id} is not accepting input (stdin is closed).`;
809
- }
810
- const enter = opts.enter ?? true;
811
- const text = input + (enter ? "\n" : "");
812
- try {
813
- if (text.length > 0) {
814
- await new Promise((resolve, reject) => {
815
- stdin.write(text, (err) => (err ? reject(err) : resolve()));
816
- });
817
- }
818
- if (opts.eof)
819
- stdin.end();
820
- }
821
- catch (err) {
822
- return `Failed to send input to ${id}: ${err.message}`;
823
- }
824
- const summary = opts.eof
825
- ? text.length > 0
826
- ? `Sent input and closed stdin (EOF) for ${id}.`
827
- : `Closed stdin (EOF) for ${id}.`
828
- : `Sent input to ${id}.`;
829
- return `${summary} Use task_output with id="${id}" to read the response.`;
830
- }
831
- async stop(id) {
832
- const proc = this.processes.get(id);
833
- if (!proc)
834
- return `No background process with id "${id}"`;
835
- const child = this.children.get(id);
836
- if (!child || proc.exitCode !== null) {
837
- return `Process ${id} already exited (code ${proc.exitCode})`;
838
- }
839
- if (proc.pid <= 0)
840
- return `Process ${id} failed to start`;
841
- this.stopping.add(id);
842
- const isWindows = (this.ops.platform ?? process.platform) === "win32";
843
- if (isWindows) {
844
- // Windows has no process groups and no real SIGTERM: signalling the
845
- // wrapper only orphans its descendants. Force-kill the PID tree up front.
846
- stopProcessTree(proc.pid, this.ops);
847
- }
848
- else {
849
- // SIGTERM the group first so POSIX children get a chance to clean up.
850
- try {
851
- (this.ops.kill ?? process.kill)(-proc.pid, "SIGTERM");
852
- }
853
- catch {
854
- try {
855
- (this.ops.kill ?? process.kill)(proc.pid, "SIGTERM");
856
- }
857
- catch {
858
- return `Process ${id} already exited`;
859
- }
860
- }
861
- }
862
- // Wait up to 5s, then hard-kill a surviving tree.
863
- const exited = await new Promise((resolve) => {
864
- const timeout = setTimeout(() => resolve(false), 5000);
865
- child.on("close", () => {
866
- clearTimeout(timeout);
867
- resolve(true);
868
- });
869
- });
870
- if (!exited) {
871
- if (isWindows) {
872
- return `Failed to stop process ${id}: it did not exit within 5 seconds and may still be running.`;
873
- }
874
- stopProcessTree(proc.pid, this.ops);
875
- }
876
- return `Process ${id} stopped`;
877
- }
878
- list() {
879
- // Prune completed processes older than 5 minutes to prevent Map growth
880
- const cutoff = Date.now() - 5 * 60 * 1000;
881
- for (const [id, proc] of this.processes) {
882
- if (proc.exitCode !== null && !this.children.has(id) && proc.startedAt < cutoff) {
883
- this.processes.delete(id);
884
- this.stopping.delete(id);
885
- this.disposeWatcher(id);
886
- }
887
- }
888
- return Array.from(this.processes.values());
889
- }
890
- shutdownAll() {
891
- for (const [id, proc] of this.processes) {
892
- if (this.children.has(id)) {
893
- this.stopping.add(id);
894
- stopProcessTree(proc.pid, this.ops);
895
- proc.exitCode = proc.exitCode ?? 1;
896
- this.children.delete(id);
897
- }
898
- this.disposeWatcher(id);
899
- }
900
- }
901
- }
902
- //# sourceMappingURL=process-manager.js.map