@ai-agent-forge/agent-forge 0.88.2 → 0.88.3

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 (453) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +1 -1
  3. package/bundled-plugins/agent-loop-policy/agent-forge.json +1 -1
  4. package/bundled-plugins/agent-loop-policy/plugin.json +1 -1
  5. package/bundled-plugins/coding-tools/agent-forge.json +1 -1
  6. package/bundled-plugins/coding-tools/plugin.json +1 -1
  7. package/bundled-plugins/compaction-policy/agent-forge.json +1 -1
  8. package/bundled-plugins/compaction-policy/plugin.json +1 -1
  9. package/bundled-plugins/overflow-policy/agent-forge.json +1 -1
  10. package/bundled-plugins/overflow-policy/plugin.json +1 -1
  11. package/bundled-plugins/provider-failover/agent-forge.json +1 -1
  12. package/bundled-plugins/provider-failover/plugin.json +1 -1
  13. package/bundled-plugins/retry-policy/agent-forge.json +1 -1
  14. package/bundled-plugins/retry-policy/plugin.json +1 -1
  15. package/dist/artifacts/paged-read.d.ts +6 -1
  16. package/dist/artifacts/paged-read.d.ts.map +1 -1
  17. package/dist/artifacts/paged-read.js.map +1 -1
  18. package/dist/bundle/.build-manifest.json +240 -230
  19. package/dist/bundle/chunks/{anthropic-messages-PLAKXR73.js → anthropic-messages-3FJHRAJL.js} +2 -2
  20. package/dist/bundle/chunks/anthropic.js +1 -1
  21. package/dist/bundle/chunks/{azure-openai-responses-OUWQ2AZD.js → azure-openai-responses-GCL47IDS.js} +1 -1
  22. package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
  23. package/dist/bundle/chunks/{chunk-6F5JWGKE.js → chunk-32YDZI4J.js} +1 -1
  24. package/dist/bundle/chunks/{chunk-LSP24WNH.js → chunk-755VNWIF.js} +12 -12
  25. package/dist/bundle/chunks/{chunk-HTC5K5SM.js → chunk-B42Y2VME.js} +94 -89
  26. package/dist/bundle/chunks/{chunk-DRQDKNXA.js → chunk-BVVSHK6W.js} +1 -1
  27. package/dist/bundle/chunks/{chunk-6R7UI4IY.js → chunk-QDLOMKF6.js} +1 -1
  28. package/dist/bundle/chunks/{chunk-44I47ACN.js → chunk-V3ACW7VD.js} +1 -1
  29. package/dist/bundle/chunks/{google-generative-ai-DLII6DAT.js → google-generative-ai-6BMXWA44.js} +1 -1
  30. package/dist/bundle/chunks/{google-vertex-G7BZL7GM.js → google-vertex-6H7NLRTK.js} +1 -1
  31. package/dist/bundle/chunks/image-resize-worker.js +1 -1
  32. package/dist/bundle/chunks/{mistral-conversations-JXUK24ID.js → mistral-conversations-IXUHSFSJ.js} +1 -1
  33. package/dist/bundle/chunks/{openai-codex-responses-5GSGFIPG.js → openai-codex-responses-YHUAEVCM.js} +1 -1
  34. package/dist/bundle/chunks/openai-codex.js +1 -1
  35. package/dist/bundle/chunks/{openai-completions-EI2I6DTG.js → openai-completions-ULQCFC72.js} +1 -1
  36. package/dist/bundle/chunks/openai-responses-NLLAJDPS.js +2 -0
  37. package/dist/bundle/chunks/{openrouter-images-G4GQRUSG.js → openrouter-images-GZZQZXMS.js} +1 -1
  38. package/dist/bundle/chunks/openrouter.js +1 -1
  39. package/dist/bundle/chunks/{pi-messages-PWU2VJMR.js → pi-messages-EJTI2EJ3.js} +1 -1
  40. package/dist/bundle/chunks/virtual-modules-TQWEGNNZ.js +5 -0
  41. package/dist/bundle/cli.js +1 -1
  42. package/dist/bundle/client.js +1 -1
  43. package/dist/bundle/index.js +1 -1
  44. package/dist/bundle/rpc-entry.js +1 -1
  45. package/dist/cli/args.d.ts +0 -1
  46. package/dist/cli/args.d.ts.map +1 -1
  47. package/dist/cli/args.js +1 -4
  48. package/dist/cli/args.js.map +1 -1
  49. package/dist/cli/config-selector.d.ts.map +1 -1
  50. package/dist/cli/config-selector.js +1 -1
  51. package/dist/cli/config-selector.js.map +1 -1
  52. package/dist/cli/experimental/cli.d.ts +3 -3
  53. package/dist/cli/experimental/cli.d.ts.map +1 -1
  54. package/dist/cli/experimental/cli.js +2 -2
  55. package/dist/cli/experimental/cli.js.map +1 -1
  56. package/dist/cli/experimental/commands/agent-forge.d.ts +15 -0
  57. package/dist/cli/experimental/commands/agent-forge.d.ts.map +1 -0
  58. package/dist/cli/experimental/commands/{pi.js → agent-forge.js} +4 -4
  59. package/dist/cli/experimental/commands/agent-forge.js.map +1 -0
  60. package/dist/cli/startup-ui.d.ts.map +1 -1
  61. package/dist/cli/startup-ui.js +1 -1
  62. package/dist/cli/startup-ui.js.map +1 -1
  63. package/dist/config.d.ts +4 -4
  64. package/dist/config.d.ts.map +1 -1
  65. package/dist/config.js +7 -7
  66. package/dist/config.js.map +1 -1
  67. package/dist/core/agent-forge-manifest.d.ts +7 -0
  68. package/dist/core/agent-forge-manifest.d.ts.map +1 -0
  69. package/dist/core/{pi-manifest.js → agent-forge-manifest.js} +4 -4
  70. package/dist/core/agent-forge-manifest.js.map +1 -0
  71. package/dist/core/agent-session-compaction.d.ts +1 -1
  72. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  73. package/dist/core/agent-session-compaction.js +3 -3
  74. package/dist/core/agent-session-compaction.js.map +1 -1
  75. package/dist/core/agent-session-lifecycle.d.ts.map +1 -1
  76. package/dist/core/agent-session-lifecycle.js +12 -1
  77. package/dist/core/agent-session-lifecycle.js.map +1 -1
  78. package/dist/core/agent-session-projection.d.ts.map +1 -1
  79. package/dist/core/agent-session-projection.js +3 -3
  80. package/dist/core/agent-session-projection.js.map +1 -1
  81. package/dist/core/agent-session-services.d.ts +1 -1
  82. package/dist/core/agent-session-services.d.ts.map +1 -1
  83. package/dist/core/agent-session-services.js +1 -1
  84. package/dist/core/agent-session-services.js.map +1 -1
  85. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  86. package/dist/core/compaction/branch-summarization.js +1 -1
  87. package/dist/core/compaction/branch-summarization.js.map +1 -1
  88. package/dist/core/experimental.d.ts.map +1 -1
  89. package/dist/core/experimental.js +1 -3
  90. package/dist/core/experimental.js.map +1 -1
  91. package/dist/core/extensions/capability-runtime-store.d.ts +20 -1
  92. package/dist/core/extensions/capability-runtime-store.d.ts.map +1 -1
  93. package/dist/core/extensions/capability-runtime-store.js +67 -0
  94. package/dist/core/extensions/capability-runtime-store.js.map +1 -1
  95. package/dist/core/extensions/capability-runtime-types.d.ts +14 -0
  96. package/dist/core/extensions/capability-runtime-types.d.ts.map +1 -1
  97. package/dist/core/extensions/capability-runtime-types.js +7 -1
  98. package/dist/core/extensions/capability-runtime-types.js.map +1 -1
  99. package/dist/core/extensions/capability-runtime.d.ts.map +1 -1
  100. package/dist/core/extensions/capability-runtime.js +144 -42
  101. package/dist/core/extensions/capability-runtime.js.map +1 -1
  102. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  103. package/dist/core/extensions/virtual-modules.js +6 -1
  104. package/dist/core/extensions/virtual-modules.js.map +1 -1
  105. package/dist/core/facade/coding-agent-facade.d.ts +1 -1
  106. package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
  107. package/dist/core/facade/coding-agent-facade.js +1 -1
  108. package/dist/core/facade/coding-agent-facade.js.map +1 -1
  109. package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts +1 -1
  110. package/dist/core/i18n/locales/zh-cn/core-contract-final.d.ts.map +1 -1
  111. package/dist/core/i18n/locales/zh-cn/core-contract-final.js +3 -3
  112. package/dist/core/i18n/locales/zh-cn/core-contract-final.js.map +1 -1
  113. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.d.ts.map +1 -1
  114. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js +1 -1
  115. package/dist/core/i18n/locales/zh-cn/core-contract-plugins.js.map +1 -1
  116. package/dist/core/i18n/locales/zh-cn/core-errors.d.ts.map +1 -1
  117. package/dist/core/i18n/locales/zh-cn/core-errors.js +1 -1
  118. package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -1
  119. package/dist/core/i18n/locales/zh-cn/tui-components-misc.d.ts.map +1 -1
  120. package/dist/core/i18n/locales/zh-cn/tui-components-misc.js +2 -0
  121. package/dist/core/i18n/locales/zh-cn/tui-components-misc.js.map +1 -1
  122. package/dist/core/model-resolver.d.ts +2 -0
  123. package/dist/core/model-resolver.d.ts.map +1 -1
  124. package/dist/core/model-resolver.js +4 -1
  125. package/dist/core/model-resolver.js.map +1 -1
  126. package/dist/core/package-resource-collection.d.ts.map +1 -1
  127. package/dist/core/package-resource-collection.js +5 -5
  128. package/dist/core/package-resource-collection.js.map +1 -1
  129. package/dist/core/provider-composer.d.ts.map +1 -1
  130. package/dist/core/provider-composer.js +3 -3
  131. package/dist/core/provider-composer.js.map +1 -1
  132. package/dist/core/resource-loader.d.ts.map +1 -1
  133. package/dist/core/resource-loader.js +1 -1
  134. package/dist/core/resource-loader.js.map +1 -1
  135. package/dist/core/sdk.d.ts +1 -1
  136. package/dist/core/sdk.d.ts.map +1 -1
  137. package/dist/core/sdk.js +6 -7
  138. package/dist/core/sdk.js.map +1 -1
  139. package/dist/core/session-manager.d.ts.map +1 -1
  140. package/dist/core/session-manager.js +4 -4
  141. package/dist/core/session-manager.js.map +1 -1
  142. package/dist/core/settings-manager.d.ts.map +1 -1
  143. package/dist/core/settings-manager.js +5 -10
  144. package/dist/core/settings-manager.js.map +1 -1
  145. package/dist/core/timings.d.ts.map +1 -1
  146. package/dist/core/timings.js +1 -3
  147. package/dist/core/timings.js.map +1 -1
  148. package/dist/core/tools/render-utils.d.ts +1 -1
  149. package/dist/core/tools/render-utils.d.ts.map +1 -1
  150. package/dist/core/tools/render-utils.js.map +1 -1
  151. package/dist/core/tools/tool-definition.d.ts +1 -1
  152. package/dist/core/tools/tool-definition.d.ts.map +1 -1
  153. package/dist/core/tools/tool-definition.js.map +1 -1
  154. package/dist/core/trace-retention.d.ts +16 -1
  155. package/dist/core/trace-retention.d.ts.map +1 -1
  156. package/dist/core/trace-retention.js +43 -20
  157. package/dist/core/trace-retention.js.map +1 -1
  158. package/dist/export-html/ansi-to-html.d.ts.map +1 -0
  159. package/dist/export-html/ansi-to-html.js.map +1 -0
  160. package/dist/{core/export-html → export-html}/index.d.ts +1 -1
  161. package/dist/export-html/index.d.ts.map +1 -0
  162. package/dist/{core/export-html → export-html}/index.js +5 -5
  163. package/dist/export-html/index.js.map +1 -0
  164. package/dist/{core/export-html → export-html}/tool-renderer.d.ts +2 -2
  165. package/dist/export-html/tool-renderer.d.ts.map +1 -0
  166. package/dist/export-html/tool-renderer.js.map +1 -0
  167. package/dist/{modes/interactive → host}/model-catalog-refresh.d.ts +1 -1
  168. package/dist/host/model-catalog-refresh.d.ts.map +1 -0
  169. package/dist/{modes/interactive → host}/model-catalog-refresh.js +1 -1
  170. package/dist/host/model-catalog-refresh.js.map +1 -0
  171. package/dist/index.d.ts +5 -5
  172. package/dist/index.d.ts.map +1 -1
  173. package/dist/index.js +12 -12
  174. package/dist/index.js.map +1 -1
  175. package/dist/main.d.ts.map +1 -1
  176. package/dist/main.js +25 -14
  177. package/dist/main.js.map +1 -1
  178. package/dist/modes/interactive/components/agents-view.d.ts.map +1 -1
  179. package/dist/modes/interactive/components/agents-view.js +1 -1
  180. package/dist/modes/interactive/components/agents-view.js.map +1 -1
  181. package/dist/modes/interactive/components/armin.d.ts.map +1 -1
  182. package/dist/modes/interactive/components/armin.js +1 -1
  183. package/dist/modes/interactive/components/armin.js.map +1 -1
  184. package/dist/modes/interactive/components/assistant-message.d.ts +3 -0
  185. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  186. package/dist/modes/interactive/components/assistant-message.js +83 -24
  187. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  188. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  189. package/dist/modes/interactive/components/bash-execution.js +1 -1
  190. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  191. package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
  192. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  193. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  194. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  195. package/dist/modes/interactive/components/branch-summary-message.js +1 -1
  196. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  197. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  198. package/dist/modes/interactive/components/compaction-summary-message.js +1 -1
  199. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  200. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  201. package/dist/modes/interactive/components/config-selector.js +1 -1
  202. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  203. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  204. package/dist/modes/interactive/components/custom-entry.js +1 -1
  205. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  206. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  207. package/dist/modes/interactive/components/custom-message.js +1 -1
  208. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  209. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  210. package/dist/modes/interactive/components/daxnuts.js +1 -1
  211. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  212. package/dist/modes/interactive/components/dialog-editor.d.ts.map +1 -1
  213. package/dist/modes/interactive/components/dialog-editor.js +1 -1
  214. package/dist/modes/interactive/components/dialog-editor.js.map +1 -1
  215. package/dist/modes/interactive/components/dialog-input.d.ts.map +1 -1
  216. package/dist/modes/interactive/components/dialog-input.js +1 -1
  217. package/dist/modes/interactive/components/dialog-input.js.map +1 -1
  218. package/dist/modes/interactive/components/dialog-selector.d.ts.map +1 -1
  219. package/dist/modes/interactive/components/dialog-selector.js +1 -1
  220. package/dist/modes/interactive/components/dialog-selector.js.map +1 -1
  221. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  222. package/dist/modes/interactive/components/diff.js +1 -1
  223. package/dist/modes/interactive/components/diff.js.map +1 -1
  224. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  225. package/dist/modes/interactive/components/dynamic-border.js +1 -1
  226. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  227. package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
  228. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  229. package/dist/modes/interactive/components/first-time-setup.js +1 -1
  230. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  231. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  232. package/dist/modes/interactive/components/footer.js +1 -1
  233. package/dist/modes/interactive/components/footer.js.map +1 -1
  234. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  235. package/dist/modes/interactive/components/keybinding-hints.js +1 -1
  236. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  237. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  238. package/dist/modes/interactive/components/login-dialog.js +1 -1
  239. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  240. package/dist/modes/interactive/components/mermaid.d.ts +1 -1
  241. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  242. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  243. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  244. package/dist/modes/interactive/components/model-selector.js +2 -2
  245. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  246. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  247. package/dist/modes/interactive/components/oauth-selector.js +1 -1
  248. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  249. package/dist/modes/interactive/components/plugin-manager-entry.d.ts.map +1 -1
  250. package/dist/modes/interactive/components/plugin-manager-entry.js +1 -1
  251. package/dist/modes/interactive/components/plugin-manager-entry.js.map +1 -1
  252. package/dist/modes/interactive/components/plugin-selection-entry.d.ts.map +1 -1
  253. package/dist/modes/interactive/components/plugin-selection-entry.js +1 -1
  254. package/dist/modes/interactive/components/plugin-selection-entry.js.map +1 -1
  255. package/dist/modes/interactive/components/queue-manager-selector.d.ts.map +1 -1
  256. package/dist/modes/interactive/components/queue-manager-selector.js +1 -1
  257. package/dist/modes/interactive/components/queue-manager-selector.js.map +1 -1
  258. package/dist/modes/interactive/components/render-types.d.ts +1 -1
  259. package/dist/modes/interactive/components/render-types.d.ts.map +1 -1
  260. package/dist/modes/interactive/components/render-types.js.map +1 -1
  261. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  262. package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
  263. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  264. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  265. package/dist/modes/interactive/components/session-selector.js +2 -2
  266. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  267. package/dist/modes/interactive/components/settings-selector.d.ts +1 -1
  268. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  269. package/dist/modes/interactive/components/settings-selector.js +1 -1
  270. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  271. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  272. package/dist/modes/interactive/components/settings-submenu.js +1 -1
  273. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  274. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  275. package/dist/modes/interactive/components/show-images-selector.js +1 -1
  276. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  277. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  278. package/dist/modes/interactive/components/skill-invocation-message.js +1 -1
  279. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  280. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  281. package/dist/modes/interactive/components/status-indicator.js +1 -1
  282. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  283. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  284. package/dist/modes/interactive/components/theme-selector.js +1 -1
  285. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  286. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  287. package/dist/modes/interactive/components/thinking-selector.js +1 -1
  288. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  289. package/dist/modes/interactive/components/tool-execution.d.ts +2 -0
  290. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  291. package/dist/modes/interactive/components/tool-execution.js +96 -4
  292. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  293. package/dist/modes/interactive/components/tool-run-group.d.ts.map +1 -1
  294. package/dist/modes/interactive/components/tool-run-group.js +1 -1
  295. package/dist/modes/interactive/components/tool-run-group.js.map +1 -1
  296. package/dist/modes/interactive/components/tree-list.d.ts.map +1 -1
  297. package/dist/modes/interactive/components/tree-list.js +1 -1
  298. package/dist/modes/interactive/components/tree-list.js.map +1 -1
  299. package/dist/modes/interactive/components/tree-render.d.ts.map +1 -1
  300. package/dist/modes/interactive/components/tree-render.js +1 -1
  301. package/dist/modes/interactive/components/tree-render.js.map +1 -1
  302. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  303. package/dist/modes/interactive/components/tree-selector.js +1 -1
  304. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  305. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  306. package/dist/modes/interactive/components/user-message-selector.js +1 -1
  307. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  308. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  309. package/dist/modes/interactive/components/user-message.js +1 -1
  310. package/dist/modes/interactive/components/user-message.js.map +1 -1
  311. package/dist/modes/interactive/components/workflow-view.d.ts.map +1 -1
  312. package/dist/modes/interactive/components/workflow-view.js +1 -1
  313. package/dist/modes/interactive/components/workflow-view.js.map +1 -1
  314. package/dist/modes/interactive/interactive-auth.d.ts +1 -1
  315. package/dist/modes/interactive/interactive-auth.d.ts.map +1 -1
  316. package/dist/modes/interactive/interactive-auth.js +1 -1
  317. package/dist/modes/interactive/interactive-auth.js.map +1 -1
  318. package/dist/modes/interactive/interactive-commands.d.ts +123 -6
  319. package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
  320. package/dist/modes/interactive/interactive-commands.js +691 -4
  321. package/dist/modes/interactive/interactive-commands.js.map +1 -1
  322. package/dist/modes/interactive/interactive-events.d.ts +174 -0
  323. package/dist/modes/interactive/interactive-events.d.ts.map +1 -0
  324. package/dist/modes/interactive/interactive-events.js +704 -0
  325. package/dist/modes/interactive/interactive-events.js.map +1 -0
  326. package/dist/modes/interactive/interactive-format.d.ts.map +1 -1
  327. package/dist/modes/interactive/interactive-format.js +1 -1
  328. package/dist/modes/interactive/interactive-format.js.map +1 -1
  329. package/dist/modes/interactive/interactive-lifecycle.d.ts +94 -0
  330. package/dist/modes/interactive/interactive-lifecycle.d.ts.map +1 -0
  331. package/dist/modes/interactive/interactive-lifecycle.js +177 -0
  332. package/dist/modes/interactive/interactive-lifecycle.js.map +1 -0
  333. package/dist/modes/interactive/interactive-mode.d.ts +240 -133
  334. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  335. package/dist/modes/interactive/interactive-mode.js +251 -2159
  336. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  337. package/dist/modes/interactive/interactive-queues.d.ts +96 -0
  338. package/dist/modes/interactive/interactive-queues.d.ts.map +1 -0
  339. package/dist/modes/interactive/interactive-queues.js +183 -0
  340. package/dist/modes/interactive/interactive-queues.js.map +1 -0
  341. package/dist/modes/interactive/interactive-selectors.d.ts +95 -5
  342. package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
  343. package/dist/modes/interactive/interactive-selectors.js +517 -6
  344. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  345. package/dist/modes/interactive/startup-services.d.ts +31 -0
  346. package/dist/modes/interactive/startup-services.d.ts.map +1 -0
  347. package/dist/modes/interactive/startup-services.js +123 -0
  348. package/dist/modes/interactive/startup-services.js.map +1 -0
  349. package/dist/modes/memory-preheat.d.ts +11 -0
  350. package/dist/modes/memory-preheat.d.ts.map +1 -0
  351. package/dist/modes/memory-preheat.js +20 -0
  352. package/dist/modes/memory-preheat.js.map +1 -0
  353. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  354. package/dist/modes/rpc/rpc-mode.js +3 -1
  355. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  356. package/dist/remote/server-assembly.d.ts.map +1 -1
  357. package/dist/remote/server-assembly.js +7 -2
  358. package/dist/remote/server-assembly.js.map +1 -1
  359. package/dist/suites/builtin-suites.d.ts.map +1 -0
  360. package/dist/suites/builtin-suites.js.map +1 -0
  361. package/dist/suites/resolved-agent-profile.d.ts.map +1 -0
  362. package/dist/suites/resolved-agent-profile.js.map +1 -0
  363. package/dist/suites/suite-lifecycle.d.ts.map +1 -0
  364. package/dist/suites/suite-lifecycle.js.map +1 -0
  365. package/dist/suites/suite-loader.d.ts.map +1 -0
  366. package/dist/suites/suite-loader.js.map +1 -0
  367. package/dist/{modes/interactive/theme → theme}/dark.json +1 -1
  368. package/dist/{modes/interactive/theme → theme}/light.json +1 -1
  369. package/dist/{modes/interactive/theme → theme}/theme-controller.d.ts +1 -1
  370. package/dist/theme/theme-controller.d.ts.map +1 -0
  371. package/dist/{modes/interactive/theme → theme}/theme-controller.js +1 -1
  372. package/dist/theme/theme-controller.js.map +1 -0
  373. package/dist/{modes/interactive/theme → theme}/theme.d.ts +1 -1
  374. package/dist/theme/theme.d.ts.map +1 -0
  375. package/dist/{modes/interactive/theme → theme}/theme.js +5 -5
  376. package/dist/theme/theme.js.map +1 -0
  377. package/docs/compaction.md +7 -7
  378. package/docs/environment-variables.md +10 -4
  379. package/docs/keybindings.md +3 -3
  380. package/docs/models.md +17 -17
  381. package/docs/packages.md +1 -1
  382. package/docs/prompt-templates.md +1 -1
  383. package/docs/rpc.md +2 -2
  384. package/docs/sdk.md +5 -5
  385. package/docs/session-format.md +3 -3
  386. package/docs/settings.md +15 -1
  387. package/docs/shell-aliases.md +1 -1
  388. package/docs/skills.md +1 -1
  389. package/docs/terminal-setup.md +17 -17
  390. package/docs/themes.md +5 -5
  391. package/docs/tmux.md +4 -4
  392. package/docs/tui.md +1 -1
  393. package/docs/usage.md +292 -292
  394. package/docs/windows.md +1 -1
  395. package/examples/extensions/bash-spawn-hook/index.ts +1 -1
  396. package/examples/extensions/dynamic-resources/dynamic.json +1 -1
  397. package/examples/extensions/mcp-stdio/index.d.ts +64 -0
  398. package/examples/extensions/mcp-stdio/index.d.ts.map +1 -0
  399. package/examples/extensions/mcp-stdio/index.js +292 -0
  400. package/examples/extensions/mcp-stdio/index.js.map +1 -0
  401. package/examples/extensions/with-deps/package-lock.json +2 -2
  402. package/examples/extensions/with-deps/package.json +1 -6
  403. package/examples/extensions/with-deps/plugin.json +1 -1
  404. package/package.json +2 -2
  405. package/dist/bundle/chunks/openai-responses-AUJQ3NWT.js +0 -2
  406. package/dist/bundle/chunks/virtual-modules-MRXD3RWG.js +0 -5
  407. package/dist/cli/experimental/commands/pi.d.ts +0 -15
  408. package/dist/cli/experimental/commands/pi.d.ts.map +0 -1
  409. package/dist/cli/experimental/commands/pi.js.map +0 -1
  410. package/dist/core/export-html/ansi-to-html.d.ts.map +0 -1
  411. package/dist/core/export-html/ansi-to-html.js.map +0 -1
  412. package/dist/core/export-html/index.d.ts.map +0 -1
  413. package/dist/core/export-html/index.js.map +0 -1
  414. package/dist/core/export-html/tool-renderer.d.ts.map +0 -1
  415. package/dist/core/export-html/tool-renderer.js.map +0 -1
  416. package/dist/core/pi-manifest.d.ts +0 -7
  417. package/dist/core/pi-manifest.d.ts.map +0 -1
  418. package/dist/core/pi-manifest.js.map +0 -1
  419. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +0 -1
  420. package/dist/modes/interactive/model-catalog-refresh.js.map +0 -1
  421. package/dist/modes/interactive/theme/theme-controller.d.ts.map +0 -1
  422. package/dist/modes/interactive/theme/theme-controller.js.map +0 -1
  423. package/dist/modes/interactive/theme/theme.d.ts.map +0 -1
  424. package/dist/modes/interactive/theme/theme.js.map +0 -1
  425. package/dist/profiles/builtin-suites.d.ts.map +0 -1
  426. package/dist/profiles/builtin-suites.js.map +0 -1
  427. package/dist/profiles/resolved-agent-profile.d.ts.map +0 -1
  428. package/dist/profiles/resolved-agent-profile.js.map +0 -1
  429. package/dist/profiles/suite-lifecycle.d.ts.map +0 -1
  430. package/dist/profiles/suite-lifecycle.js.map +0 -1
  431. package/dist/profiles/suite-loader.d.ts.map +0 -1
  432. package/dist/profiles/suite-loader.js.map +0 -1
  433. package/dist/utils/deprecation.d.ts +0 -4
  434. package/dist/utils/deprecation.d.ts.map +0 -1
  435. package/dist/utils/deprecation.js +0 -13
  436. package/dist/utils/deprecation.js.map +0 -1
  437. /package/dist/{core/export-html → export-html}/ansi-to-html.d.ts +0 -0
  438. /package/dist/{core/export-html → export-html}/ansi-to-html.js +0 -0
  439. /package/dist/{core/export-html → export-html}/template.css +0 -0
  440. /package/dist/{core/export-html → export-html}/template.html +0 -0
  441. /package/dist/{core/export-html → export-html}/template.js +0 -0
  442. /package/dist/{core/export-html → export-html}/tool-renderer.js +0 -0
  443. /package/dist/{core/export-html → export-html}/vendor/highlight.min.js +0 -0
  444. /package/dist/{core/export-html → export-html}/vendor/marked.min.js +0 -0
  445. /package/dist/{profiles → suites}/builtin-suites.d.ts +0 -0
  446. /package/dist/{profiles → suites}/builtin-suites.js +0 -0
  447. /package/dist/{profiles → suites}/resolved-agent-profile.d.ts +0 -0
  448. /package/dist/{profiles → suites}/resolved-agent-profile.js +0 -0
  449. /package/dist/{profiles → suites}/suite-lifecycle.d.ts +0 -0
  450. /package/dist/{profiles → suites}/suite-lifecycle.js +0 -0
  451. /package/dist/{profiles → suites}/suite-loader.d.ts +0 -0
  452. /package/dist/{profiles → suites}/suite-loader.js +0 -0
  453. /package/dist/{modes/interactive/theme → theme}/theme-schema.json +0 -0
@@ -0,0 +1,177 @@
1
+ import chalk from "chalk";
2
+ import { APP_NAME } from "../../config.js";
3
+ import { t } from "../../core/i18n/index.js";
4
+ import { killTrackedDetachedChildren } from "../../utils/shell.js";
5
+ import { isDeadTerminalError } from "./interactive-helpers.js";
6
+ export function handleCtrlC(host) {
7
+ const now = Date.now();
8
+ if (now - host.lastSigintTime < 500) {
9
+ void host.shutdown();
10
+ }
11
+ else {
12
+ host.clearEditor();
13
+ host.lastSigintTime = now;
14
+ }
15
+ }
16
+ export function handleCtrlD(host) {
17
+ // Only called when editor is empty (enforced by CustomEditor)
18
+ void host.shutdown();
19
+ }
20
+ export async function shutdown(host, options) {
21
+ if (host.isShuttingDown)
22
+ return;
23
+ host.isShuttingDown = true;
24
+ // Keep signal handlers registered until terminal cleanup has completed.
25
+ // `signal-exit` checks the listener list during the same SIGTERM/SIGHUP
26
+ // dispatch and re-sends the signal if only its own listeners remain.
27
+ if (options?.fromSignal) {
28
+ // Signal-triggered shutdown (SIGTERM/SIGHUP). Emit extension cleanup
29
+ // (session_shutdown) BEFORE touching the terminal. Extension teardown
30
+ // such as removing sockets does not write to the tty, so it must not be
31
+ // skipped if a later terminal-restore write fails on a dead or stalled
32
+ // terminal. If the terminal is gone, the restore writes below emit EIO,
33
+ // which the stdout/stderr error handler turns into emergencyTerminalExit;
34
+ // the render loop is already idle, so this cannot hot-spin (see #4144).
35
+ await host.runtimeFacade.dispose();
36
+ host.themeController.disableAutoSync();
37
+ await host.ui.terminal.drainInput(1000);
38
+ host.stop();
39
+ process.exit(0);
40
+ }
41
+ // Interactive quit (Ctrl+D, Ctrl+C, /quit, extension shutdown()). Stop the
42
+ // TUI before emitting shutdown events so extension UI cleanup cannot repaint
43
+ // the final frame while the process is exiting.
44
+ // Drain any in-flight Kitty key release events before stopping.
45
+ // This prevents escape sequences from leaking to the parent shell over slow SSH.
46
+ host.themeController.disableAutoSync();
47
+ await host.ui.terminal.drainInput(1000);
48
+ host.stop();
49
+ await host.runtimeFacade.dispose();
50
+ const resumeCommand = host.formatResumeCommand(host.runtimeFacade);
51
+ if (resumeCommand) {
52
+ process.stdout.write(`${chalk.dim(t("To resume this session:"))} ${resumeCommand}\n`);
53
+ }
54
+ process.exit(0);
55
+ }
56
+ export function emergencyTerminalExit(host) {
57
+ host.isShuttingDown = true;
58
+ host.unregisterSignalHandlers();
59
+ killTrackedDetachedChildren();
60
+ // The terminal is gone. Do not run normal shutdown because TUI and
61
+ // extension cleanup can write restore sequences and re-trigger EIO.
62
+ process.exit(129);
63
+ }
64
+ /**
65
+ * Last-resort handler for uncaught exceptions. The TUI puts stdin into raw
66
+ * mode and hides the cursor; without this handler, an uncaught throw from
67
+ * anywhere (e.g. an extension's async `ChildProcess.on("exit")` callback)
68
+ * tears down the process while leaving the terminal in raw mode with no
69
+ * cursor, requiring `stty sane && reset` to recover.
70
+ *
71
+ * Unlike emergencyTerminalExit, the terminal is still alive here, so we
72
+ * call ui.stop() to restore cooked mode, the cursor, and disable bracketed
73
+ * paste / Kitty / modifyOtherKeys sequences.
74
+ */
75
+ export function uncaughtCrash(host, error) {
76
+ if (host.isShuttingDown) {
77
+ process.exit(1);
78
+ }
79
+ host.isShuttingDown = true;
80
+ try {
81
+ host.unregisterSignalHandlers();
82
+ }
83
+ catch { }
84
+ try {
85
+ killTrackedDetachedChildren();
86
+ }
87
+ catch { }
88
+ try {
89
+ host.ui.stop();
90
+ }
91
+ catch { }
92
+ console.error(t("{app} exiting due to uncaughtException:", { app: APP_NAME }));
93
+ console.error(error);
94
+ process.exit(1);
95
+ }
96
+ /**
97
+ * Check if shutdown was requested and perform shutdown if so.
98
+ */
99
+ export async function checkShutdownRequested(host) {
100
+ if (!host.shutdownRequested)
101
+ return;
102
+ await host.shutdown();
103
+ }
104
+ export function registerSignalHandlers(host) {
105
+ host.unregisterSignalHandlers();
106
+ const signals = ["SIGTERM"];
107
+ if (process.platform !== "win32") {
108
+ signals.push("SIGHUP");
109
+ }
110
+ for (const signal of signals) {
111
+ const handler = () => {
112
+ // SIGHUP no longer hard-exits: graceful shutdown emits session_shutdown
113
+ // first, then attempts terminal restore. A genuinely dead terminal
114
+ // surfaces as an EIO on the restore writes, which the stdout/stderr
115
+ // error handler converts into emergencyTerminalExit (see #4144, #5080).
116
+ killTrackedDetachedChildren();
117
+ void host.shutdown({ fromSignal: true });
118
+ };
119
+ process.prependListener(signal, handler);
120
+ host.signalCleanupHandlers.push(() => process.off(signal, handler));
121
+ }
122
+ const terminalErrorHandler = (error) => {
123
+ if (isDeadTerminalError(error)) {
124
+ host.emergencyTerminalExit();
125
+ }
126
+ throw error;
127
+ };
128
+ process.stdout.on("error", terminalErrorHandler);
129
+ process.stderr.on("error", terminalErrorHandler);
130
+ host.signalCleanupHandlers.push(() => process.stdout.off("error", terminalErrorHandler));
131
+ host.signalCleanupHandlers.push(() => process.stderr.off("error", terminalErrorHandler));
132
+ // Restore the terminal before the process dies on any uncaught throw.
133
+ // Without this, an unhandled exception from extension code (or anywhere
134
+ // in the application) leaves the terminal in raw mode with no cursor.
135
+ const uncaughtExceptionHandler = (error) => host.uncaughtCrash(error);
136
+ process.prependListener("uncaughtException", uncaughtExceptionHandler);
137
+ host.signalCleanupHandlers.push(() => process.off("uncaughtException", uncaughtExceptionHandler));
138
+ }
139
+ export function unregisterSignalHandlers(host) {
140
+ for (const cleanup of host.signalCleanupHandlers) {
141
+ cleanup();
142
+ }
143
+ host.signalCleanupHandlers = [];
144
+ }
145
+ export function handleCtrlZ(host) {
146
+ if (process.platform === "win32") {
147
+ host.showStatus(t("Suspend to background is not supported on Windows"));
148
+ return;
149
+ }
150
+ // Keep the event loop alive while suspended. Without this, stopping the TUI
151
+ // can leave Node with no ref'ed handles, causing the process to exit on fg
152
+ // before the SIGCONT handler gets a chance to restore the terminal.
153
+ const suspendKeepAlive = setInterval(() => { }, 2 ** 30);
154
+ // Ignore SIGINT while suspended so Ctrl+C in the terminal does not
155
+ // kill the backgrounded process. The handler is removed on resume.
156
+ const ignoreSigint = () => { };
157
+ process.on("SIGINT", ignoreSigint);
158
+ // Set up handler to restore TUI when resumed
159
+ process.once("SIGCONT", () => {
160
+ clearInterval(suspendKeepAlive);
161
+ process.removeListener("SIGINT", ignoreSigint);
162
+ host.ui.start();
163
+ host.ui.requestRender(true);
164
+ });
165
+ try {
166
+ // Stop the TUI (restore terminal to normal mode)
167
+ host.ui.stop();
168
+ // Send SIGTSTP to process group (pid=0 means all processes in group)
169
+ process.kill(0, "SIGTSTP");
170
+ }
171
+ catch (error) {
172
+ clearInterval(suspendKeepAlive);
173
+ process.removeListener("SIGINT", ignoreSigint);
174
+ throw error;
175
+ }
176
+ }
177
+ //# sourceMappingURL=interactive-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactive-lifecycle.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-lifecycle.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,CAAC,EAAE,MAAM,0BAA0B,CAAC;AAG7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAiD/D,MAAM,UAAU,WAAW,CAAC,IAAmB,EAAQ;IACtD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,IAAI,GAAG,GAAG,IAAI,CAAC,cAAc,GAAG,GAAG,EAAE,CAAC;QACrC,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;IACtB,CAAC;SAAM,CAAC;QACP,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC;IAC3B,CAAC;AAAA,CACD;AAED,MAAM,UAAU,WAAW,CAAC,IAAmB,EAAQ;IACtD,8DAA8D;IAC9D,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;AAAA,CACrB;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAmB,EAAE,OAAkC,EAAiB;IACtG,IAAI,IAAI,CAAC,cAAc;QAAE,OAAO;IAChC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC3B,wEAAwE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iD;QACjD,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;QAEf,qEAAqE;QACrE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,aAAa,CAAC,gBAAgB,CAAC,CAAC;QAChC,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC/C,MAAM,KAAK,CAAC;IACb,CAAC;AAAA,CACD","sourcesContent":["/**\n * Exit and signal lifecycle for interactive mode (拆分 slice 4,\n * docs/plans/interactive-mode拆分计划.md): the Ctrl+C / Ctrl+D / Ctrl+Z\n * handlers, graceful shutdown, the dead-terminal emergency exit, the uncaught\n * exception crash handler, and signal-handler registration/unregistration.\n *\n * InteractiveMode implements LifecycleHost and keeps same-name delegate methods\n * so prototype-level tests and the editor key wiring keep working; the\n * functions below receive the mode through LifecycleHost. The main loop\n * (run/init) and the TUI teardown (stop) stay on the mode; formatResumeCommand\n * also stays resident in interactive-mode.ts (D-041 §3.5: the resume hint is\n * host TUI behavior, not a facade contract) and is reached here through the\n * host method.\n *\n * Internal collaboration interface (same pattern as AuthUiHost): not a plugin\n * API and not exported from the package root.\n */\nimport type { TUI } from \"@agent-forge/tui\";\nimport chalk from \"chalk\";\nimport { APP_NAME } from \"../../config.ts\";\nimport type { CodingAgentRuntimeFacadeV1 } from \"../../core/facade/index.ts\";\nimport { t } from \"../../core/i18n/index.ts\";\nimport type { FullscreenExitOutput } from \"../../core/settings-manager.ts\";\nimport type { InteractiveThemeController } from \"../../theme/theme-controller.ts\";\nimport { killTrackedDetachedChildren } from \"../../utils/shell.ts\";\nimport { isDeadTerminalError } from \"./interactive-helpers.ts\";\n\n/**\n * Session read view the shutdown resume hint consumes (structural twin of the\n * reads formatResumeCommand takes; the real interface and function stay in\n * ./interactive-mode.ts, D-041 §3.5).\n */\ninterface ShutdownResumeSessionReads {\n\tisPersisted(): boolean;\n\tgetSessionFile(): string | undefined;\n\tusesDefaultSessionDir(): boolean;\n\tgetSessionDir(): string;\n\tgetSessionId(): string;\n}\n\n/**\n * Host surface InteractiveMode exposes to this module: the TUI, the runtime\n * facade (dispose), the theme controller, the shutdown state fields, and the\n * mode-owned surfaces shutdown drives (stop, editor clear, status line).\n *\n * Internal collaboration interface (same pattern as AuthUiHost): not a plugin\n * API and not exported from the package root.\n */\nexport interface LifecycleHost {\n\tui: TUI;\n\t/** Stable runtime facade (阶段 4 slice 3): dispose on shutdown. */\n\truntimeFacade: CodingAgentRuntimeFacadeV1;\n\tthemeController: InteractiveThemeController;\n\t/** Timestamp of the last Ctrl+C clear; a second press inside 500ms exits. */\n\tlastSigintTime: number;\n\t/** Reentrancy guard shared by shutdown / emergencyTerminalExit / uncaughtCrash. */\n\tisShuttingDown: boolean;\n\t/** Set when the session asks the UI to exit once the agent settles. */\n\tshutdownRequested: boolean;\n\t/** Cleanup closures for every process-level listener this module registers. */\n\tsignalCleanupHandlers: Array<() => void>;\n\n\t/** TUI teardown; stays on the mode (also the /quit-adjacent stop path). */\n\tstop(fullscreenExitOutput?: FullscreenExitOutput): void;\n\tclearEditor(): void;\n\tshowStatus(message: string): void;\n\tshutdown(options?: { fromSignal?: boolean }): Promise<void>;\n\temergencyTerminalExit(): never;\n\tuncaughtCrash(error: Error): never;\n\tunregisterSignalHandlers(): void;\n\t/** D-041 §3.5: the function stays resident in interactive-mode.ts. */\n\tformatResumeCommand(session: ShutdownResumeSessionReads): string | undefined;\n}\n\nexport function handleCtrlC(host: LifecycleHost): void {\n\tconst now = Date.now();\n\tif (now - host.lastSigintTime < 500) {\n\t\tvoid host.shutdown();\n\t} else {\n\t\thost.clearEditor();\n\t\thost.lastSigintTime = now;\n\t}\n}\n\nexport function handleCtrlD(host: LifecycleHost): void {\n\t// Only called when editor is empty (enforced by CustomEditor)\n\tvoid host.shutdown();\n}\n\nexport async function shutdown(host: LifecycleHost, options?: { fromSignal?: boolean }): Promise<void> {\n\tif (host.isShuttingDown) return;\n\thost.isShuttingDown = true;\n\t// Keep signal handlers registered until terminal cleanup has completed.\n\t// `signal-exit` checks the listener list during the same SIGTERM/SIGHUP\n\t// dispatch and re-sends the signal if only its own listeners remain.\n\n\tif (options?.fromSignal) {\n\t\t// Signal-triggered shutdown (SIGTERM/SIGHUP). Emit extension cleanup\n\t\t// (session_shutdown) BEFORE touching the terminal. Extension teardown\n\t\t// such as removing sockets does not write to the tty, so it must not be\n\t\t// skipped if a later terminal-restore write fails on a dead or stalled\n\t\t// terminal. If the terminal is gone, the restore writes below emit EIO,\n\t\t// which the stdout/stderr error handler turns into emergencyTerminalExit;\n\t\t// the render loop is already idle, so this cannot hot-spin (see #4144).\n\t\tawait host.runtimeFacade.dispose();\n\t\thost.themeController.disableAutoSync();\n\t\tawait host.ui.terminal.drainInput(1000);\n\t\thost.stop();\n\t\tprocess.exit(0);\n\t}\n\n\t// Interactive quit (Ctrl+D, Ctrl+C, /quit, extension shutdown()). Stop the\n\t// TUI before emitting shutdown events so extension UI cleanup cannot repaint\n\t// the final frame while the process is exiting.\n\t// Drain any in-flight Kitty key release events before stopping.\n\t// This prevents escape sequences from leaking to the parent shell over slow SSH.\n\thost.themeController.disableAutoSync();\n\tawait host.ui.terminal.drainInput(1000);\n\n\thost.stop();\n\tawait host.runtimeFacade.dispose();\n\n\tconst resumeCommand = host.formatResumeCommand(host.runtimeFacade);\n\tif (resumeCommand) {\n\t\tprocess.stdout.write(`${chalk.dim(t(\"To resume this session:\"))} ${resumeCommand}\\n`);\n\t}\n\n\tprocess.exit(0);\n}\n\nexport function emergencyTerminalExit(host: LifecycleHost): never {\n\thost.isShuttingDown = true;\n\thost.unregisterSignalHandlers();\n\tkillTrackedDetachedChildren();\n\t// The terminal is gone. Do not run normal shutdown because TUI and\n\t// extension cleanup can write restore sequences and re-trigger EIO.\n\tprocess.exit(129);\n}\n\n/**\n * Last-resort handler for uncaught exceptions. The TUI puts stdin into raw\n * mode and hides the cursor; without this handler, an uncaught throw from\n * anywhere (e.g. an extension's async `ChildProcess.on(\"exit\")` callback)\n * tears down the process while leaving the terminal in raw mode with no\n * cursor, requiring `stty sane && reset` to recover.\n *\n * Unlike emergencyTerminalExit, the terminal is still alive here, so we\n * call ui.stop() to restore cooked mode, the cursor, and disable bracketed\n * paste / Kitty / modifyOtherKeys sequences.\n */\nexport function uncaughtCrash(host: LifecycleHost, error: Error): never {\n\tif (host.isShuttingDown) {\n\t\tprocess.exit(1);\n\t}\n\thost.isShuttingDown = true;\n\ttry {\n\t\thost.unregisterSignalHandlers();\n\t} catch {}\n\ttry {\n\t\tkillTrackedDetachedChildren();\n\t} catch {}\n\ttry {\n\t\thost.ui.stop();\n\t} catch {}\n\tconsole.error(t(\"{app} exiting due to uncaughtException:\", { app: APP_NAME }));\n\tconsole.error(error);\n\tprocess.exit(1);\n}\n\n/**\n * Check if shutdown was requested and perform shutdown if so.\n */\nexport async function checkShutdownRequested(host: LifecycleHost): Promise<void> {\n\tif (!host.shutdownRequested) return;\n\tawait host.shutdown();\n}\n\nexport function registerSignalHandlers(host: LifecycleHost): void {\n\thost.unregisterSignalHandlers();\n\n\tconst signals: NodeJS.Signals[] = [\"SIGTERM\"];\n\tif (process.platform !== \"win32\") {\n\t\tsignals.push(\"SIGHUP\");\n\t}\n\n\tfor (const signal of signals) {\n\t\tconst handler = () => {\n\t\t\t// SIGHUP no longer hard-exits: graceful shutdown emits session_shutdown\n\t\t\t// first, then attempts terminal restore. A genuinely dead terminal\n\t\t\t// surfaces as an EIO on the restore writes, which the stdout/stderr\n\t\t\t// error handler converts into emergencyTerminalExit (see #4144, #5080).\n\t\t\tkillTrackedDetachedChildren();\n\t\t\tvoid host.shutdown({ fromSignal: true });\n\t\t};\n\t\tprocess.prependListener(signal, handler);\n\t\thost.signalCleanupHandlers.push(() => process.off(signal, handler));\n\t}\n\n\tconst terminalErrorHandler = (error: Error) => {\n\t\tif (isDeadTerminalError(error)) {\n\t\t\thost.emergencyTerminalExit();\n\t\t}\n\t\tthrow error;\n\t};\n\tprocess.stdout.on(\"error\", terminalErrorHandler);\n\tprocess.stderr.on(\"error\", terminalErrorHandler);\n\thost.signalCleanupHandlers.push(() => process.stdout.off(\"error\", terminalErrorHandler));\n\thost.signalCleanupHandlers.push(() => process.stderr.off(\"error\", terminalErrorHandler));\n\n\t// Restore the terminal before the process dies on any uncaught throw.\n\t// Without this, an unhandled exception from extension code (or anywhere\n\t// in the application) leaves the terminal in raw mode with no cursor.\n\tconst uncaughtExceptionHandler = (error: Error) => host.uncaughtCrash(error);\n\tprocess.prependListener(\"uncaughtException\", uncaughtExceptionHandler);\n\thost.signalCleanupHandlers.push(() => process.off(\"uncaughtException\", uncaughtExceptionHandler));\n}\n\nexport function unregisterSignalHandlers(host: LifecycleHost): void {\n\tfor (const cleanup of host.signalCleanupHandlers) {\n\t\tcleanup();\n\t}\n\thost.signalCleanupHandlers = [];\n}\n\nexport function handleCtrlZ(host: LifecycleHost): void {\n\tif (process.platform === \"win32\") {\n\t\thost.showStatus(t(\"Suspend to background is not supported on Windows\"));\n\t\treturn;\n\t}\n\n\t// Keep the event loop alive while suspended. Without this, stopping the TUI\n\t// can leave Node with no ref'ed handles, causing the process to exit on fg\n\t// before the SIGCONT handler gets a chance to restore the terminal.\n\tconst suspendKeepAlive = setInterval(() => {}, 2 ** 30);\n\n\t// Ignore SIGINT while suspended so Ctrl+C in the terminal does not\n\t// kill the backgrounded process. The handler is removed on resume.\n\tconst ignoreSigint = () => {};\n\tprocess.on(\"SIGINT\", ignoreSigint);\n\n\t// Set up handler to restore TUI when resumed\n\tprocess.once(\"SIGCONT\", () => {\n\t\tclearInterval(suspendKeepAlive);\n\t\tprocess.removeListener(\"SIGINT\", ignoreSigint);\n\t\thost.ui.start();\n\t\thost.ui.requestRender(true);\n\t});\n\n\ttry {\n\t\t// Stop the TUI (restore terminal to normal mode)\n\t\thost.ui.stop();\n\n\t\t// Send SIGTSTP to process group (pid=0 means all processes in group)\n\t\tprocess.kill(0, \"SIGTSTP\");\n\t} catch (error) {\n\t\tclearInterval(suspendKeepAlive);\n\t\tprocess.removeListener(\"SIGINT\", ignoreSigint);\n\t\tthrow error;\n\t}\n}\n"]}