@bastani/atomic 0.9.16-alpha.8 → 0.9.16

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 (212) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/README.md +4 -4
  3. package/dist/builtin/intercom/CHANGELOG.md +42 -0
  4. package/dist/builtin/intercom/README.md +18 -17
  5. package/dist/builtin/intercom/broker/broker.ts +43 -18
  6. package/dist/builtin/intercom/broker/client.ts +138 -7
  7. package/dist/builtin/intercom/broker/group-isolation.ts +3 -3
  8. package/dist/builtin/intercom/broker/group-membership.ts +55 -0
  9. package/dist/builtin/intercom/broker/presence-handler.ts +62 -50
  10. package/dist/builtin/intercom/broker/send-handler.ts +2 -3
  11. package/dist/builtin/intercom/group.ts +40 -0
  12. package/dist/builtin/intercom/index.bundle.mjs +556 -185
  13. package/dist/builtin/intercom/package.json +2 -2
  14. package/dist/builtin/intercom/skills/intercom/SKILL.md +16 -10
  15. package/dist/builtin/intercom/types.ts +24 -2
  16. package/dist/builtin/mcp/index.bundle.mjs +268 -54
  17. package/dist/builtin/mcp/package.json +2 -2
  18. package/dist/builtin/subagents/CHANGELOG.md +51 -0
  19. package/dist/builtin/subagents/README.md +3 -3
  20. package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
  21. package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
  22. package/dist/builtin/subagents/agents/codebase-locator.md +1 -1
  23. package/dist/builtin/subagents/agents/codebase-online-researcher.md +1 -1
  24. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +1 -1
  25. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
  26. package/dist/builtin/subagents/agents/codebase-research-locator.md +1 -1
  27. package/dist/builtin/subagents/agents/debugger.md +1 -1
  28. package/dist/builtin/subagents/agents/worker.md +1 -1
  29. package/dist/builtin/subagents/package.json +3 -3
  30. package/dist/builtin/subagents/src/extension/index.bundle.mjs +488 -142
  31. package/dist/builtin/web-access/index.bundle.mjs +268 -54
  32. package/dist/builtin/web-access/package.json +2 -2
  33. package/dist/builtin/workflows/CHANGELOG.md +70 -0
  34. package/dist/builtin/workflows/README.md +2 -2
  35. package/dist/builtin/workflows/builtin/{chunk-zf28603f.js → chunk-3y1hmzw6.js} +36 -6
  36. package/dist/builtin/workflows/builtin/{chunk-nqr34qp3.js → chunk-6rbajjf5.js} +7 -1
  37. package/dist/builtin/workflows/builtin/{chunk-v04c5qmd.js → chunk-bz1c9732.js} +15 -3
  38. package/dist/builtin/workflows/builtin/{chunk-cdtd3m3w.js → chunk-dattsgxg.js} +1 -1
  39. package/dist/builtin/workflows/builtin/{chunk-5n10x7j2.js → chunk-gdx0avpx.js} +421 -69
  40. package/dist/builtin/workflows/builtin/{chunk-hdpj1dkw.js → chunk-w9c7rkrk.js} +1 -1
  41. package/dist/builtin/workflows/builtin/goal.js +3 -3
  42. package/dist/builtin/workflows/builtin/index.js +5 -5
  43. package/dist/builtin/workflows/builtin/open-claude-design.js +2 -2
  44. package/dist/builtin/workflows/builtin/ralph.js +3 -3
  45. package/dist/builtin/workflows/package.json +2 -2
  46. package/dist/builtin/workflows/src/extension/index.bundle.mjs +597 -145
  47. package/dist/builtin/workflows/src/index.js +278 -74
  48. package/dist/cli/args.js +6 -6
  49. package/dist/cli/args.js.map +1 -1
  50. package/dist/cli/config-selector.d.ts.map +1 -1
  51. package/dist/cli/config-selector.js +2 -1
  52. package/dist/cli/config-selector.js.map +1 -1
  53. package/dist/cli/session-picker.d.ts +2 -1
  54. package/dist/cli/session-picker.d.ts.map +1 -1
  55. package/dist/cli/session-picker.js +3 -2
  56. package/dist/cli/session-picker.js.map +1 -1
  57. package/dist/cli/startup-ui.d.ts.map +1 -1
  58. package/dist/cli/startup-ui.js +2 -1
  59. package/dist/cli/startup-ui.js.map +1 -1
  60. package/dist/core/agent-session-methods.d.ts +1 -0
  61. package/dist/core/agent-session-methods.d.ts.map +1 -1
  62. package/dist/core/agent-session-methods.js.map +1 -1
  63. package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -1
  64. package/dist/core/agent-session-post-tool-compaction.js +3 -6
  65. package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
  66. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  67. package/dist/core/agent-session-prompt.js +3 -1
  68. package/dist/core/agent-session-prompt.js.map +1 -1
  69. package/dist/core/agent-session-services.d.ts.map +1 -1
  70. package/dist/core/agent-session-services.js +6 -3
  71. package/dist/core/agent-session-services.js.map +1 -1
  72. package/dist/core/agent-session-state.d.ts.map +1 -1
  73. package/dist/core/agent-session-state.js +7 -5
  74. package/dist/core/agent-session-state.js.map +1 -1
  75. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  76. package/dist/core/agent-session-tool-hooks.js +37 -23
  77. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  78. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  79. package/dist/core/agent-session-tool-registry.js +9 -2
  80. package/dist/core/agent-session-tool-registry.js.map +1 -1
  81. package/dist/core/agent-session.d.ts +2 -0
  82. package/dist/core/agent-session.d.ts.map +1 -1
  83. package/dist/core/agent-session.js +2 -0
  84. package/dist/core/agent-session.js.map +1 -1
  85. package/dist/core/builtin-packages.d.ts +4 -0
  86. package/dist/core/builtin-packages.d.ts.map +1 -1
  87. package/dist/core/builtin-packages.js +22 -1
  88. package/dist/core/builtin-packages.js.map +1 -1
  89. package/dist/core/callback-activity.d.ts.map +1 -1
  90. package/dist/core/callback-activity.js +6 -3
  91. package/dist/core/callback-activity.js.map +1 -1
  92. package/dist/core/extensions/agent-events.d.ts +15 -0
  93. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  94. package/dist/core/extensions/agent-events.js.map +1 -1
  95. package/dist/core/extensions/api-types.d.ts +3 -1
  96. package/dist/core/extensions/api-types.d.ts.map +1 -1
  97. package/dist/core/extensions/api-types.js.map +1 -1
  98. package/dist/core/extensions/event-types.d.ts +2 -2
  99. package/dist/core/extensions/event-types.d.ts.map +1 -1
  100. package/dist/core/extensions/event-types.js.map +1 -1
  101. package/dist/core/extensions/index.d.ts +1 -1
  102. package/dist/core/extensions/index.d.ts.map +1 -1
  103. package/dist/core/extensions/index.js.map +1 -1
  104. package/dist/core/extensions/loader-core.d.ts +1 -0
  105. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  106. package/dist/core/extensions/loader-core.js +11 -1
  107. package/dist/core/extensions/loader-core.js.map +1 -1
  108. package/dist/core/extensions/loader.d.ts +1 -1
  109. package/dist/core/extensions/loader.d.ts.map +1 -1
  110. package/dist/core/extensions/loader.js +1 -1
  111. package/dist/core/extensions/loader.js.map +1 -1
  112. package/dist/core/extensions/runner-registries.d.ts.map +1 -1
  113. package/dist/core/extensions/runner-registries.js +9 -4
  114. package/dist/core/extensions/runner-registries.js.map +1 -1
  115. package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -1
  116. package/dist/core/extensions/runner-shortcuts.js +1 -0
  117. package/dist/core/extensions/runner-shortcuts.js.map +1 -1
  118. package/dist/core/extensions/runner.d.ts +6 -0
  119. package/dist/core/extensions/runner.d.ts.map +1 -1
  120. package/dist/core/extensions/runner.js +65 -1
  121. package/dist/core/extensions/runner.js.map +1 -1
  122. package/dist/core/keybindings.d.ts +5 -0
  123. package/dist/core/keybindings.d.ts.map +1 -1
  124. package/dist/core/keybindings.js +4 -0
  125. package/dist/core/keybindings.js.map +1 -1
  126. package/dist/core/mandatory-resource-loader.d.ts +6 -0
  127. package/dist/core/mandatory-resource-loader.d.ts.map +1 -0
  128. package/dist/core/mandatory-resource-loader.js +94 -0
  129. package/dist/core/mandatory-resource-loader.js.map +1 -0
  130. package/dist/core/mandatory-runtime-tools.d.ts +10 -0
  131. package/dist/core/mandatory-runtime-tools.d.ts.map +1 -0
  132. package/dist/core/mandatory-runtime-tools.js +31 -0
  133. package/dist/core/mandatory-runtime-tools.js.map +1 -0
  134. package/dist/core/model-resolver-defaults.js +1 -1
  135. package/dist/core/model-resolver-defaults.js.map +1 -1
  136. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  137. package/dist/core/resource-loader-reload.js +24 -13
  138. package/dist/core/resource-loader-reload.js.map +1 -1
  139. package/dist/core/sdk.d.ts.map +1 -1
  140. package/dist/core/sdk.js +2 -0
  141. package/dist/core/sdk.js.map +1 -1
  142. package/dist/core/settings-manager-ui-accessors.d.ts +4 -1
  143. package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
  144. package/dist/core/settings-manager-ui-accessors.js +22 -0
  145. package/dist/core/settings-manager-ui-accessors.js.map +1 -1
  146. package/dist/core/settings-types.d.ts +4 -0
  147. package/dist/core/settings-types.d.ts.map +1 -1
  148. package/dist/core/settings-types.js.map +1 -1
  149. package/dist/core/slash-commands.js +1 -1
  150. package/dist/core/slash-commands.js.map +1 -1
  151. package/dist/index-extensions.d.ts +1 -1
  152. package/dist/index-extensions.d.ts.map +1 -1
  153. package/dist/index-extensions.js.map +1 -1
  154. package/dist/main-session.d.ts.map +1 -1
  155. package/dist/main-session.js +3 -2
  156. package/dist/main-session.js.map +1 -1
  157. package/dist/main.d.ts.map +1 -1
  158. package/dist/main.js +6 -0
  159. package/dist/main.js.map +1 -1
  160. package/dist/modes/interactive/components/fast-mode-selector.js +2 -2
  161. package/dist/modes/interactive/components/fast-mode-selector.js.map +1 -1
  162. package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
  163. package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
  164. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  165. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  166. package/dist/modes/interactive/components/settings-selector-items.js +7 -0
  167. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  168. package/dist/modes/interactive/components/settings-selector-types.d.ts +2 -0
  169. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  170. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  171. package/dist/modes/interactive/interactive-agent-events.js +2 -1
  172. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  173. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  174. package/dist/modes/interactive/interactive-deferred-startup.js +1 -0
  175. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  176. package/dist/modes/interactive/interactive-extension-runtime.js +1 -1
  177. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  178. package/dist/modes/interactive/interactive-input-handling.js +3 -0
  179. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  180. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  181. package/dist/modes/interactive/interactive-mode-base.js +15 -1
  182. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  183. package/dist/modes/interactive/interactive-mode-surface.d.ts +6 -1
  184. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  185. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  186. package/dist/modes/interactive/interactive-selectors.js +6 -1
  187. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  188. package/dist/modes/interactive/interactive-session-runtime.js +3 -0
  189. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  190. package/dist/modes/interactive/interactive-slash-commands.js +7 -12
  191. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  192. package/dist/modes/interactive/interactive-tui.d.ts +1 -0
  193. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  194. package/dist/modes/interactive/interactive-tui.js +16 -0
  195. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  196. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  197. package/dist/modes/rpc/rpc-session-binding.js +2 -0
  198. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  199. package/docs/compaction.md +1 -1
  200. package/docs/environment-variables.md +2 -0
  201. package/docs/extensions.md +20 -1
  202. package/docs/intercom.md +29 -24
  203. package/docs/keybindings.md +5 -2
  204. package/docs/packages.md +1 -1
  205. package/docs/providers.md +2 -2
  206. package/docs/sdk.md +9 -7
  207. package/docs/settings.md +9 -3
  208. package/docs/subagents.md +2 -2
  209. package/docs/usage.md +7 -6
  210. package/docs/workflows.md +11 -7
  211. package/npm-shrinkwrap.json +59 -77
  212. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-tui.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-tui.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,YAAY,EACZ,eAAe,EAGf,YAAY,EAEZ,aAAa,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AA0CzF,MAAM,UAAU,gBAAgB,CAAC,GAAQ,EAAE,SAAoB;IAC9D,MAAM,SAAS,GAAG,GAA8C,CAAC;IACjE,OAAO,CACN,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAC9G,CAAC;AACH,CAAC;AACD,MAAM,UAAU,iBAAiB,CAAC,GAAmB;IACpD,MAAM,OAAO,GAAG,GAAG,CAAC,mBAAmB,EAAE,CAAC;IAC1C,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,MAAM,SAAS,GAAG,GAA8C,CAAC;IACjE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,OAAO,SAAS,CAAC,gBAAgB,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IACjH,MAAM,KAAK,GAAG,SAAS,CAAC,YAAY,CAAC,IAAI,CAA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AC3D,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;KACtD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n\ttype Component,\n\tisKeyRelease,\n\tProcessTerminal,\n\ttype Terminal,\n\ttype TUI,\n\tTuiAltScreen,\n\ttype TuiInputListener,\n\tTuiMainScreen,\n} from \"@earendil-works/pi-tui\";\nimport { stripOverlayActiveRowMarker } from \"../../core/extensions/ui-types.ts\";\nimport { copyToClipboard } from \"../../utils/clipboard.ts\";\nimport { openBrowser } from \"../../utils/open-browser.ts\";\nimport { TRANSCRIPT_JUMP_TO_END_URL } from \"./components/transcript-follow-indicator.ts\";\n\ninterface TuiOverlayEntry {\n\tcomponent: Component;\n\tpreFocus: Component | null;\n}\n\ninterface InternalUiActionOverlay extends Component {\n\thandlesInternalUiAction?: boolean;\n}\n\ntype TuiOverlayFocusRestore =\n\t| { status: \"inactive\" }\n\t| { status: \"eligible\"; overlay: TuiOverlayEntry }\n\t| {\n\t\t\tstatus: \"blocked\";\n\t\t\toverlay: TuiOverlayEntry;\n\t\t\tblockedBy: Component;\n\t\t\tresume: { status: \"restore-overlay\" } | { status: \"focus-target\"; target: Component | null };\n\t };\n\ninterface TuiOverlayInternals {\n\toverlayStack: TuiOverlayEntry[];\n\tisOverlayVisible(entry: TuiOverlayEntry): boolean;\n\tgetTopmostVisibleOverlay(): TuiOverlayEntry | undefined;\n\tsetFocusInternal(options: { component: Component | null; overlayFocusRestore: \"preserve\" }): void;\n\tgetVisibleOverlayFocusRestore(): TuiOverlayFocusRestore;\n\tclearOverlayFocusRestore(): void;\n\trequestImmediateRender(): void;\n}\n/** pi-tui 0.84.2 keeps this canonical mouse predicate private (tui-alt-screen.d.ts:114). */\ninterface TuiAltScreenMouseInternals {\n\tisMouseSequence(data: string): boolean;\n}\n\n/** pi-tui 0.84.2 keeps its overlay-deferral predicate private (tui-alt-screen.d.ts:84). */\ninterface TuiAltScreenViewportDeferral {\n\tshouldDeferViewportInputToOverlay?(): boolean;\n}\n\nexport type InteractiveTui = TuiMainScreen | TuiAltScreen;\n\nexport function isOverlayMounted(tui: TUI, component: Component): boolean {\n\tconst internals = tui as unknown as Partial<TuiOverlayInternals>;\n\treturn (\n\t\tArray.isArray(internals.overlayStack) && internals.overlayStack.some((entry) => entry.component === component)\n\t);\n}\nexport function getFocusedOverlay(tui: InteractiveTui): Component | undefined {\n\tconst focused = tui.getFocusedComponent();\n\tif (!focused) return undefined;\n\tconst internals = tui as unknown as Partial<TuiOverlayInternals>;\n\tif (!Array.isArray(internals.overlayStack) || typeof internals.isOverlayVisible !== \"function\") return undefined;\n\tconst entry = internals.overlayStack.find((candidate) => candidate.component === focused);\n\treturn entry && internals.isOverlayVisible(entry) ? focused : undefined;\n}\n\nexport function handleFocusedOverlayInternalUiAction(tui: InteractiveTui, url: string): InternalUiActionResult {\n\tconst overlay = getFocusedOverlay(tui);\n\tif (!overlay || (overlay as InternalUiActionOverlay).handlesInternalUiAction !== true) return undefined;\n\tconst handleInput = overlay.handleInput as\n\t\t| ((data: string) => boolean | undefined | Promise<boolean | undefined>)\n\t\t| undefined;\n\treturn handleInput?.call(overlay, url);\n}\n\nexport type InternalUiActionResult = boolean | undefined | Promise<boolean | undefined>;\n\nexport interface InteractiveTuiOptions {\n\tshowHardwareCursor: boolean;\n\tlogDirectory: string;\n\tterminal?: Terminal;\n\tonRightClickPaste?: () => void;\n\tonOverlayInternalUiAction?: (url: string) => InternalUiActionResult;\n\tonInternalUiAction?: (url: string) => InternalUiActionResult;\n\t/**\n\t * Return false to let a focused overlay receive viewport input first.\n\t * Mouse input is deferred only while the focused component belongs to an\n\t * overlay; non-overlay focus keeps pi-tui's transcript selection path.\n\t */\n\tshouldHandleViewportInput?: (\n\t\tdata: string,\n\t\tisMouseInput: boolean,\n\t\tfocusedIsOverlay: boolean,\n\t\t_focusedIsViewportSearch: boolean,\n\t) => boolean;\n\t/** Handle an unconsumed overlay input before replaying it to the viewport. */\n\tonOverlayUnhandledInput?: (data: string) => boolean;\n\t/**\n\t * Copy selected text to the system clipboard; resolve false when the host\n\t * clipboard never received it. Defaults to Atomic's `copyToClipboard` with\n\t * its platform fallbacks, so pi-tui flashes \"Copy failed\" on a terminal\n\t * whose clipboard stayed untouched (upstream #8110) instead of the old\n\t * unconditional \"Copied!\". Injectable so hosts and tests observe the write.\n\t */\n\tcopySelection?: (text: string) => Promise<boolean>;\n}\n\n/** The default selection-copy route: Atomic's host clipboard write. */\nasync function copySelectionToHostClipboard(text: string): Promise<boolean> {\n\ttry {\n\t\tawait copyToClipboard(text);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport interface UrlActivationHandlers {\n\tonOverlayInternalUiAction?: (url: string) => InternalUiActionResult;\n\tonInternalUiAction?: (url: string) => InternalUiActionResult;\n\topenUrl: (url: string) => void;\n}\n\nfunction fallbackInternalUiAction(url: string, handlers: UrlActivationHandlers): void {\n\thandlers.onInternalUiAction?.(url);\n}\n\nfunction routeInternalUiAction(url: string, handlers: UrlActivationHandlers): void {\n\tlet result: InternalUiActionResult;\n\ttry {\n\t\tresult = handlers.onOverlayInternalUiAction?.(url);\n\t} catch {\n\t\tfallbackInternalUiAction(url, handlers);\n\t\treturn;\n\t}\n\tif (result instanceof Promise) {\n\t\tvoid result.then(\n\t\t\t(handled) => {\n\t\t\t\tif (handled !== true) fallbackInternalUiAction(url, handlers);\n\t\t\t},\n\t\t\t() => fallbackInternalUiAction(url, handlers),\n\t\t);\n\t\treturn;\n\t}\n\tif (result !== true) fallbackInternalUiAction(url, handlers);\n}\n\n/** Route OSC 8 activation without allowing unknown internal URLs to escape to a browser. */\nexport function handleUrlActivation(url: string, handlers: UrlActivationHandlers): void {\n\tconst internalUiScheme = \"atomic-ui:\";\n\tif (url.slice(0, internalUiScheme.length).toLowerCase() === internalUiScheme) {\n\t\tconst schemeEnd = url.indexOf(\":\");\n\t\tconst normalizedInternalUrl = `${url.slice(0, schemeEnd).toLowerCase()}${url.slice(schemeEnd)}`;\n\t\t// Forward the normalized URL: overlay-side matching is exact, so a\n\t\t// mixed-case scheme must not reach an overlay as an unrecognized string.\n\t\tif (normalizedInternalUrl === TRANSCRIPT_JUMP_TO_END_URL) routeInternalUiAction(normalizedInternalUrl, handlers);\n\t\treturn;\n\t}\n\n\thandlers.openUrl(url);\n}\n\nconst viewportInputListeners = new WeakSet<AtomicTuiAltScreen>();\n\ntype ViewportInputGate = (\n\tdata: string,\n\tisMouseInput: boolean,\n\tfocusedIsOverlay: boolean,\n\t_focusedIsViewportSearch: boolean,\n) => boolean;\n\nconst viewportInputGates = new WeakMap<AtomicTuiAltScreen, ViewportInputGate>();\nconst overlayUnhandledInputHandlers = new WeakMap<AtomicTuiAltScreen, (data: string) => boolean>();\n/** Instances currently replaying overlay-declined input into pi-tui's viewport listener. */\nconst viewportInputReplays = new WeakSet<AtomicTuiAltScreen>();\ninterface ViewportInputSubscription {\n\tviewportUnsubscribe: () => void;\n\trouteListener: TuiInputListener;\n\trouteUnsubscribe: () => void;\n}\n\nconst viewportInputSubscriptions = new WeakMap<AtomicTuiAltScreen, ViewportInputSubscription>();\n\n/** A complete SGR or X10 mouse report extracted from an input chunk. */\ninterface ParsedMouseSequence {\n\treadonly data: string;\n\treadonly button: number;\n\treadonly isRelease: boolean;\n}\n\nconst SGR_MOUSE_SEQUENCE = /^\\x1b\\[<(\\d+);\\d+;\\d+([Mm])/;\nconst LEFT_MOUSE_MODIFIER_MASK = 4 | 8 | 16;\n\nfunction parseMouseSequences(data: string): ParsedMouseSequence[] | undefined {\n\tif (data.length === 0) return undefined;\n\tconst sequences: ParsedMouseSequence[] = [];\n\tlet offset = 0;\n\twhile (offset < data.length) {\n\t\tconst remaining = data.slice(offset);\n\t\tconst sgr = SGR_MOUSE_SEQUENCE.exec(remaining);\n\t\tif (sgr) {\n\t\t\tconst sequence = sgr[0]!;\n\t\t\tsequences.push({ data: sequence, button: Number.parseInt(sgr[1]!, 10), isRelease: sgr[2] === \"m\" });\n\t\t\toffset += sequence.length;\n\t\t\tcontinue;\n\t\t}\n\t\tif (remaining.startsWith(\"\\x1b[M\") && remaining.length >= 6) {\n\t\t\tconst sequence = remaining.slice(0, 6);\n\t\t\tsequences.push({ data: sequence, button: sequence.charCodeAt(3) - 32, isRelease: false });\n\t\t\toffset += 6;\n\t\t\tcontinue;\n\t\t}\n\t\treturn undefined;\n\t}\n\treturn sequences;\n}\n\n/** Whether every report in a mouse chunk is a vertical wheel event. */\nexport function isMouseWheelInput(data: string): boolean {\n\tconst sequences = parseMouseSequences(data);\n\treturn (\n\t\tsequences !== undefined &&\n\t\tsequences.length > 0 &&\n\t\tsequences.every(({ button }) => {\n\t\t\tconst direction = button & 3;\n\t\t\treturn (button & 64) !== 0 && (direction === 0 || direction === 1);\n\t\t})\n\t);\n}\n\nfunction isLeftMouseButton(sequence: ParsedMouseSequence): boolean {\n\tconst { button } = sequence;\n\tif ((button & 64) !== 0) return false;\n\tconst held = button & 3;\n\t// A release carries no button identity on the terminals upstream #7963\n\t// describes: they report the generic SGR code 3 rather than 0. pi-tui 0.84.2\n\t// ends a selection on `release && (button & 3) === 3`\n\t// (`dist/tui-alt-screen.js:796`), so a release Atomic drops here leaves the\n\t// press it already forwarded open — the selection never closes and the OSC 8\n\t// link under the press never activates. Shift, Meta/Option, and Ctrl are\n\t// application-bypass gestures on press and motion, but a release can retain\n\t// those bits and still has to close a selection.\n\tif (sequence.isRelease) return held === 0 || held === 3;\n\treturn held === 0 && (button & LEFT_MOUSE_MODIFIER_MASK) === 0;\n}\n\n/** Whether a mouse chunk contains a left-button selection gesture. */\nfunction isLeftMouseSequence(data: string): boolean {\n\treturn parseMouseSequences(data)?.some((sequence) => isLeftMouseButton(sequence)) ?? false;\n}\n\n/**\n * Replay a chunk one report at a time because pi-tui parses one report per\n * call. Only a chunk whose every byte is a mouse report is split; anything else\n * is replayed verbatim.\n *\n * **Probe, pi 0.84.2 (upstream `2a95ef70`, `06ed8716`):** neither the\n * lone-ESC timeout scope nor the split-`Alt+Enter` reassembly is affected by\n * this replay. Both land in `StdinBuffer`/`ProcessTerminal`\n * (`dist/stdin-buffer.js:process`, `dist/terminal.js:48`), which assemble\n * complete sequences before any listener runs; Atomic builds pi-tui's own\n * `ProcessTerminal` in `createFullscreenTui`/`createInteractiveTui` below and\n * overrides neither the buffer nor its escape timeout. A reassembled `\\x1b` or\n * `\\x1b\\r` reaches this function as one chunk, fails `parseMouseSequences`, and\n * is handed on unsplit — so a viewport action bound to `escape` or `alt+enter`\n * still matches after a decline.\n * Outcome: no breakage, no fix needed — covered by the replay probes in\n * `test/pi-0.84.2-overlay-viewport-deferral.test.ts`.\n */\nfunction replayMouseInput(viewportListener: TuiInputListener, data: string): void {\n\tconst sequences = parseMouseSequences(data);\n\tif (!sequences) {\n\t\tviewportListener(data);\n\t\treturn;\n\t}\n\tfor (const sequence of sequences) viewportListener(sequence.data);\n}\n\n/**\n * The first `addInputListener` call is load-bearing: pi-tui 0.84.2 registers\n * its viewport listener from `TuiAltScreen`'s constructor\n * (`dist/tui-alt-screen.js:85`). Keep the viewport wrapper first so mouse,\n * selection, and focus cleanup retain pi-tui's ordering. Put the focused-input\n * route last so application listeners still receive deferred viewport keys.\n */\nclass AtomicTuiAltScreen extends TuiAltScreen {\n\tconstructor(\n\t\tterminal: Terminal,\n\t\tshowHardwareCursor: boolean,\n\t\tlogDirectory: string,\n\t\toptions: ConstructorParameters<typeof TuiAltScreen>[3],\n\t\tviewportInputGate?: ViewportInputGate,\n\t\tonOverlayUnhandledInput?: (data: string) => boolean,\n\t) {\n\t\tsuper(terminal, showHardwareCursor, logDirectory, options);\n\t\tif (viewportInputGate) viewportInputGates.set(this, viewportInputGate);\n\t\tif (onOverlayUnhandledInput) overlayUnhandledInputHandlers.set(this, onOverlayUnhandledInput);\n\t\t// pi-tui 0.84.2 added `shouldDeferViewportInputToOverlay()`, which drops\n\t\t// viewport keys and wheel reports while an overlay holds focus (upstream\n\t\t// #7894). Atomic's gate offers that input to the focused overlay first and\n\t\t// replays only what the overlay declined (#2378 / PR #2381); pi-tui then\n\t\t// defers the replay a second time and the transcript freezes behind an\n\t\t// open dialog. Suppress the native answer for the replay alone. Input the\n\t\t// gate never routed through the overlay keeps pi-tui's routing and its\n\t\t// own deferral.\n\t\tconst deferral = this as unknown as TuiAltScreenViewportDeferral;\n\t\tconst deferToOverlay = deferral.shouldDeferViewportInputToOverlay?.bind(this);\n\t\tdeferral.shouldDeferViewportInputToOverlay = () => !viewportInputReplays.has(this) && deferToOverlay?.() === true;\n\t}\n\n\t/**\n\t * Last stop before pi-tui turns the composited screen into bytes, and where\n\t * it already removes its own `CURSOR_MARKER`. Every component tree that this\n\t * renderer paints converges here, so one strip covers the overlay, inline,\n\t * widget, and workflows stage-chat mounts at once — including hosts that\n\t * never call `ReservedBottomOverlay.takeActiveRow`. The mark is zero-width,\n\t * so removing it after cursor extraction cannot move a column.\n\t */\n\tprotected override applyLineResets(lines: string[]): string[] {\n\t\treturn stripOverlayActiveRowMarker(super.applyLineResets(lines));\n\t}\n\n\t/**\n\t * Keep pi-tui's private predicate as the fallback for its single-report\n\t * grammar. Injected terminals can deliver coalesced reports, so parse those\n\t * chunks locally before asking pi-tui about an unparsed value.\n\t */\n\tprivate isPiTuiMouseSequence(data: string): boolean {\n\t\tif (parseMouseSequences(data)) return true;\n\t\tconst predicate = (this as unknown as Partial<TuiAltScreenMouseInternals>).isMouseSequence;\n\t\treturn typeof predicate === \"function\" ? predicate.call(this, data) : false;\n\t}\n\n\tprivate isFocusedOverlay(): boolean {\n\t\tconst tui = this as unknown as TuiOverlayInternals;\n\t\treturn tui.overlayStack.some((entry) => entry.component === this.getFocusedComponent());\n\t}\n\n\toverride addInputListener(listener: TuiInputListener): () => void {\n\t\tif (!viewportInputListeners.has(this)) {\n\t\t\tviewportInputListeners.add(this);\n\t\t\tconst subscription: ViewportInputSubscription = {\n\t\t\t\tviewportUnsubscribe: () => {},\n\t\t\t\trouteListener: (data) => this.routeViewportInput(listener, data),\n\t\t\t\trouteUnsubscribe: () => {},\n\t\t\t};\n\t\t\tviewportInputSubscriptions.set(this, subscription);\n\t\t\tsubscription.viewportUnsubscribe = super.addInputListener((data) => {\n\t\t\t\tconst gate = viewportInputGates.get(this);\n\t\t\t\tconst isMouseInput = gate ? this.isPiTuiMouseSequence(data) : false;\n\t\t\t\tif (gate && !gate(data, isMouseInput, this.isFocusedOverlay(), false)) return undefined;\n\t\t\t\treturn listener(data);\n\t\t\t});\n\t\t\tsubscription.routeUnsubscribe = super.addInputListener(subscription.routeListener);\n\t\t\treturn () => {\n\t\t\t\tsubscription.viewportUnsubscribe();\n\t\t\t\tsubscription.routeUnsubscribe();\n\t\t\t\tviewportInputSubscriptions.delete(this);\n\t\t\t\tviewportInputListeners.delete(this);\n\t\t\t};\n\t\t}\n\n\t\tconst subscription = viewportInputSubscriptions.get(this);\n\t\tif (!subscription) return super.addInputListener(listener);\n\t\tsubscription.routeUnsubscribe();\n\t\tconst unsubscribe = super.addInputListener(listener);\n\t\tsubscription.routeUnsubscribe = super.addInputListener(subscription.routeListener);\n\t\treturn unsubscribe;\n\t}\n\n\tprivate repairOverlayFocus(): void {\n\t\tconst tui = this as unknown as TuiOverlayInternals;\n\t\tconst focused = this.getFocusedComponent();\n\t\tconst focusedOverlay = tui.overlayStack.find((entry) => entry.component === focused);\n\t\tif (focusedOverlay && !tui.isOverlayVisible(focusedOverlay)) {\n\t\t\tconst topVisible = tui.getTopmostVisibleOverlay();\n\t\t\tif (topVisible) {\n\t\t\t\tthis.setFocus(topVisible.component);\n\t\t\t} else {\n\t\t\t\ttui.setFocusInternal({ component: focusedOverlay.preFocus, overlayFocusRestore: \"preserve\" });\n\t\t\t}\n\t\t}\n\n\t\tconst focusIsOverlay = tui.overlayStack.some((entry) => entry.component === this.getFocusedComponent());\n\t\tif (focusIsOverlay) return;\n\n\t\tconst restoreState = tui.getVisibleOverlayFocusRestore();\n\t\tif (restoreState.status === \"eligible\") {\n\t\t\tthis.setFocus(restoreState.overlay.component);\n\t\t} else if (restoreState.status === \"blocked\" && restoreState.blockedBy !== this.getFocusedComponent()) {\n\t\t\tif (restoreState.resume.status === \"restore-overlay\") {\n\t\t\t\tthis.setFocus(restoreState.overlay.component);\n\t\t\t} else {\n\t\t\t\ttui.clearOverlayFocusRestore();\n\t\t\t\tthis.setFocus(restoreState.resume.target);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Keep pi-tui's selection state in sync while an overlay handles a left gesture. */\n\tprivate forwardSelectionMouseInput(viewportListener: TuiInputListener, data: string, focused: Component): void {\n\t\tif (this.getFocusedComponent() !== focused || !isLeftMouseSequence(data)) return;\n\t\tfor (const sequence of parseMouseSequences(data) ?? []) {\n\t\t\tif (isLeftMouseButton(sequence)) viewportListener(sequence.data);\n\t\t}\n\t}\n\t/**\n\t * Replay input the focused overlay declined. pi-tui's native overlay\n\t * deferral is suppressed for the duration, because this chunk has already\n\t * been offered to the overlay it would defer to.\n\t */\n\tprivate replayViewportInput(viewportListener: TuiInputListener, data: string): void {\n\t\tviewportInputReplays.add(this);\n\t\ttry {\n\t\t\treplayMouseInput(viewportListener, data);\n\t\t} finally {\n\t\t\tviewportInputReplays.delete(this);\n\t\t}\n\t}\n\t/** Dispatch a declined chunk to the host action the gated route owns. */\n\tprivate handleOverlayUnhandledInput(data: string, focused: Component | null): boolean {\n\t\tif (this.getFocusedComponent() !== focused || !this.isFocusedOverlay()) return false;\n\t\treturn overlayUnhandledInputHandlers.get(this)?.(data) === true;\n\t}\n\n\t/**\n\t * Finish a chunk a focused overlay's asynchronous handler declined.\n\t *\n\t * Every settled result other than `true` is a decline. The component\n\t * contract is `boolean | undefined | Promise<boolean | undefined>`\n\t * (`ExtensionCustomComponent`), and both `docs/tui.md` and\n\t * `docs/extensions.md` document `false` *and* `undefined` as viewport\n\t * fallthrough, so a promise resolving `undefined` has to replay exactly like\n\t * one resolving `false` — matching only literal `false` consumed the key and\n\t * froze the transcript. A rejection is a decline for the same reason: the\n\t * overlay produced no answer.\n\t *\n\t * The focus guard stays: input that moved focus while the promise was\n\t * pending belongs to whatever holds focus now, not to the transcript.\n\t */\n\tprivate declineAsyncViewportInput(viewportListener: TuiInputListener, data: string, focused: Component): void {\n\t\tif (this.getFocusedComponent() !== focused) return;\n\t\tif (this.handleOverlayUnhandledInput(data, focused)) {\n\t\t\t(this as unknown as TuiOverlayInternals).requestImmediateRender();\n\t\t\treturn;\n\t\t}\n\t\tthis.replayViewportInput(viewportListener, data);\n\t}\n\n\tprivate routeViewportInput(viewportListener: TuiInputListener, data: string): ReturnType<TuiInputListener> {\n\t\tconst gate = viewportInputGates.get(this);\n\t\tconst isMouseInput = gate ? this.isPiTuiMouseSequence(data) : false;\n\t\tif (!gate || gate(data, isMouseInput, this.isFocusedOverlay(), false)) return undefined;\n\n\t\t// Returning `consume` below skips pi-tui's post-listener phase. Mirror its\n\t\t// overlay-focus repair before reading the focused component so a resize\n\t\t// cannot send a gated key to an invisible overlay.\n\t\tthis.repairOverlayFocus();\n\t\tconst focused = this.getFocusedComponent();\n\t\tconst tui = this as unknown as TuiOverlayInternals;\n\t\tif (focused?.handleInput && (!isKeyRelease(data) || focused.wantsKeyRelease === true)) {\n\t\t\tconst handleInput = focused.handleInput as (\n\t\t\t\tdata: string,\n\t\t\t) => boolean | undefined | Promise<boolean | undefined>;\n\t\t\tconst result = handleInput.call(focused, data);\n\t\t\tif (result instanceof Promise) {\n\t\t\t\tvoid result.then(\n\t\t\t\t\t(handled) => {\n\t\t\t\t\t\tif (handled === true) {\n\t\t\t\t\t\t\tthis.forwardSelectionMouseInput(viewportListener, data, focused);\n\t\t\t\t\t\t\ttui.requestImmediateRender();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.declineAsyncViewportInput(viewportListener, data, focused);\n\t\t\t\t\t},\n\t\t\t\t\t() => this.declineAsyncViewportInput(viewportListener, data, focused),\n\t\t\t\t);\n\t\t\t\treturn { consume: true };\n\t\t\t}\n\t\t\tif (result === true) {\n\t\t\t\tthis.forwardSelectionMouseInput(viewportListener, data, focused);\n\t\t\t\ttui.requestImmediateRender();\n\t\t\t\treturn { consume: true };\n\t\t\t}\n\t\t}\n\n\t\tif (this.handleOverlayUnhandledInput(data, focused)) {\n\t\t\ttui.requestImmediateRender();\n\t\t\treturn { consume: true };\n\t\t}\n\t\tthis.replayViewportInput(viewportListener, data);\n\t\treturn { consume: true };\n\t}\n}\n\n/**\n * CI detection follows the convention CI providers actually use: the variable\n * is SET AND NONEMPTY, with any value. GitHub Actions sets `CI=true`, but\n * other providers and users export arbitrary values (`CI=github-actions`,\n * `CI=circleci`); an allowlist of truthy spellings let those reach the\n * alternate screen and write escape sequences into CI logs (Greptile P1 on\n * PR #2308). Only explicit opt-outs (`0`, `false`, empty) read as not-CI.\n */\nfunction isCiEnvironment(value: string | undefined): boolean {\n\tif (value === undefined) return false;\n\tconst normalized = value.trim().toLowerCase();\n\treturn normalized !== \"\" && normalized !== \"0\" && normalized !== \"false\";\n}\n\nfunction shouldUseFullscreenTui(usesInjectedTerminal: boolean): boolean {\n\tif (process.env.TERM?.toLowerCase() === \"dumb\") return false;\n\tif (usesInjectedTerminal) return true;\n\treturn process.stdin.isTTY === true && process.stdout.isTTY === true && !isCiEnvironment(process.env.CI);\n}\n\n/**\n * Build Atomic's fullscreen renderer, `viewportInputGate` included, without\n * consulting the environment. `createInteractiveTui` calls this whenever\n * fullscreen applies; fixtures that assert fullscreen behavior call it\n * directly, because `shouldUseFullscreenTui` returns the main-screen fallback\n * under `TERM=dumb` even for an injected terminal and would otherwise hand\n * those tests a renderer with no layout and no gate.\n */\nexport function createFullscreenTui(options: InteractiveTuiOptions): TuiAltScreen {\n\treturn new AtomicTuiAltScreen(\n\t\toptions.terminal ?? new ProcessTerminal(),\n\t\toptions.showHardwareCursor,\n\t\toptions.logDirectory,\n\t\t{\n\t\t\topenUrl: (url) =>\n\t\t\t\thandleUrlActivation(url, {\n\t\t\t\t\tonOverlayInternalUiAction: options.onOverlayInternalUiAction,\n\t\t\t\t\tonInternalUiAction: options.onInternalUiAction,\n\t\t\t\t\topenUrl: openBrowser,\n\t\t\t\t}),\n\t\t\tonRightClickPaste: options.onRightClickPaste,\n\t\t\tcopySelection: options.copySelection ?? copySelectionToHostClipboard,\n\t\t},\n\t\toptions.shouldHandleViewportInput,\n\t\toptions.onOverlayUnhandledInput,\n\t);\n}\n\n/** Main-screen fallback renderer, carrying the same central mark strip as the fullscreen one. */\nclass AtomicTuiMainScreen extends TuiMainScreen {\n\tprotected override applyLineResets(lines: string[]): string[] {\n\t\treturn stripOverlayActiveRowMarker(super.applyLineResets(lines));\n\t}\n}\n\n/** Creates the fullscreen renderer for interactive TTY sessions. */\nexport function createInteractiveTui(options: InteractiveTuiOptions): InteractiveTui {\n\tconst usesInjectedTerminal = options.terminal !== undefined;\n\tconst terminal = options.terminal ?? new ProcessTerminal();\n\tif (!shouldUseFullscreenTui(usesInjectedTerminal)) {\n\t\t// The normal CLI never reaches the interactive mode without a TTY. Keep a\n\t\t// main-screen renderer for internal harnesses and guarded fallback paths.\n\t\treturn new AtomicTuiMainScreen(terminal, options.showHardwareCursor, options.logDirectory);\n\t}\n\treturn createFullscreenTui({ ...options, terminal });\n}\n\n/** Keeps existing components pointed at the renderer selected at runtime. */\nexport function createInteractiveTuiReference(getTui: () => TUI): TUI {\n\treturn new Proxy({} as TUI, {\n\t\tget: (_target, property) => {\n\t\t\tconst tui = getTui();\n\t\t\tconst value = Reflect.get(tui, property, tui);\n\t\t\tif (typeof value !== \"function\") return value;\n\t\t\tlet methodTui = tui;\n\t\t\tlet method = value;\n\t\t\treturn (...args: unknown[]) => {\n\t\t\t\tconst currentTui = getTui();\n\t\t\t\tif (currentTui !== methodTui) {\n\t\t\t\t\tconst currentMethod = Reflect.get(currentTui, property, currentTui);\n\t\t\t\t\tif (typeof currentMethod !== \"function\") {\n\t\t\t\t\t\tthrow new TypeError(`TUI property ${String(property)} is not callable`);\n\t\t\t\t\t}\n\t\t\t\t\tmethodTui = currentTui;\n\t\t\t\t\tmethod = currentMethod;\n\t\t\t\t}\n\t\t\t\treturn Reflect.apply(method, methodTui, args);\n\t\t\t};\n\t\t},\n\t\tset: (_target, property, value) => {\n\t\t\tconst tui = getTui();\n\t\t\treturn Reflect.set(tui, property, value, tui);\n\t\t},\n\t\thas: (_target, property) => Reflect.has(getTui(), property),\n\t\tgetPrototypeOf: () => Reflect.getPrototypeOf(getTui()),\n\t});\n}\n"]}
1
+ {"version":3,"file":"interactive-tui.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-tui.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,YAAY,EACZ,eAAe,EAGf,YAAY,EAEZ,aAAa,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AAmDzF,MAAM,UAAU,gBAAgB,CAAC,GAAQ,EAAE,SAAoB;IAC9D,MAAM,SAAS,GAAG,GAA8C,CAAC;IACjE,OAAO,CACN,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAC9G,CAAC;AACH,CAAC;AACD,MAAM,UAAU,iBAAiB,CAAC,GAAmB;IACpD,MAAM,OAAO,GAAG,GAAG,CAAC,mBAAmB,EAAE,CAAC;IAC1C,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,MAAM,SAAS,GAAG,GAA8C,CAAC;IACjE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,OAAO,S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AAS,EAAE,CAAC;oBAC9B,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;oBACpE,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE,CAAC;wBACzC,MAAM,IAAI,SAAS,CAAC,gBAAgB,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;oBACzE,CAAC;oBACD,SAAS,GAAG,UAAU,CAAC;oBACvB,MAAM,GAAG,aAAa,CAAC;gBACxB,CAAC;gBACD,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;YAC/C,CAAC,CAAC;QACH,CAAC;QACD,GAAG,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;YACjC,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;YACrB,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QAC/C,CAAC;QACD,GAAG,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC;QAC3D,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;KACtD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n\ttype Component,\n\tisKeyRelease,\n\tProcessTerminal,\n\ttype Terminal,\n\ttype TUI,\n\tTuiAltScreen,\n\ttype TuiInputListener,\n\tTuiMainScreen,\n} from \"@earendil-works/pi-tui\";\nimport { stripOverlayActiveRowMarker } from \"../../core/extensions/ui-types.ts\";\nimport { copyToClipboard } from \"../../utils/clipboard.ts\";\nimport { openBrowser } from \"../../utils/open-browser.ts\";\nimport { TRANSCRIPT_JUMP_TO_END_URL } from \"./components/transcript-follow-indicator.ts\";\n\ninterface TuiOverlayEntry {\n\tcomponent: Component;\n\tpreFocus: Component | null;\n}\n\ninterface InternalUiActionOverlay extends Component {\n\thandlesInternalUiAction?: boolean;\n}\n\ntype TuiOverlayFocusRestore =\n\t| { status: \"inactive\" }\n\t| { status: \"eligible\"; overlay: TuiOverlayEntry }\n\t| {\n\t\t\tstatus: \"blocked\";\n\t\t\toverlay: TuiOverlayEntry;\n\t\t\tblockedBy: Component;\n\t\t\tresume: { status: \"restore-overlay\" } | { status: \"focus-target\"; target: Component | null };\n\t };\n\ninterface TuiOverlayInternals {\n\toverlayStack: TuiOverlayEntry[];\n\tisOverlayVisible(entry: TuiOverlayEntry): boolean;\n\tgetTopmostVisibleOverlay(): TuiOverlayEntry | undefined;\n\tsetFocusInternal(options: { component: Component | null; overlayFocusRestore: \"preserve\" }): void;\n\tgetVisibleOverlayFocusRestore(): TuiOverlayFocusRestore;\n\tclearOverlayFocusRestore(): void;\n\trequestImmediateRender(): void;\n}\n/** pi-tui 0.84.2 keeps this canonical mouse predicate private (tui-alt-screen.d.ts:114). */\ninterface TuiAltScreenMouseInternals {\n\tisMouseSequence(data: string): boolean;\n}\n\n/** pi-tui 0.84.2 keeps its overlay-deferral predicate private (tui-alt-screen.d.ts:84). */\ninterface TuiAltScreenViewportDeferral {\n\tshouldDeferViewportInputToOverlay?(): boolean;\n}\n\ninterface TuiAltScreenSelectionInternals {\n\tselectionAnchor?: unknown;\n\tselectionFocus?: unknown;\n\tselectionInitialRange?: unknown;\n\tselectionPressActive: boolean;\n\tselectionDragged: boolean;\n\tlastClick?: unknown;\n}\n\nexport type InteractiveTui = TuiMainScreen | TuiAltScreen;\n\nexport function isOverlayMounted(tui: TUI, component: Component): boolean {\n\tconst internals = tui as unknown as Partial<TuiOverlayInternals>;\n\treturn (\n\t\tArray.isArray(internals.overlayStack) && internals.overlayStack.some((entry) => entry.component === component)\n\t);\n}\nexport function getFocusedOverlay(tui: InteractiveTui): Component | undefined {\n\tconst focused = tui.getFocusedComponent();\n\tif (!focused) return undefined;\n\tconst internals = tui as unknown as Partial<TuiOverlayInternals>;\n\tif (!Array.isArray(internals.overlayStack) || typeof internals.isOverlayVisible !== \"function\") return undefined;\n\tconst entry = internals.overlayStack.find((candidate) => candidate.component === focused);\n\treturn entry && internals.isOverlayVisible(entry) ? focused : undefined;\n}\n\nexport function handleFocusedOverlayInternalUiAction(tui: InteractiveTui, url: string): InternalUiActionResult {\n\tconst overlay = getFocusedOverlay(tui);\n\tif (!overlay || (overlay as InternalUiActionOverlay).handlesInternalUiAction !== true) return undefined;\n\tconst handleInput = overlay.handleInput as\n\t\t| ((data: string) => boolean | undefined | Promise<boolean | undefined>)\n\t\t| undefined;\n\treturn handleInput?.call(overlay, url);\n}\n\nexport type InternalUiActionResult = boolean | undefined | Promise<boolean | undefined>;\n\nexport interface InteractiveTuiOptions {\n\tshowHardwareCursor: boolean;\n\tlogDirectory: string;\n\tterminal?: Terminal;\n\tcopyOnSelect?: boolean;\n\tonRightClickPaste?: () => void;\n\tonOverlayInternalUiAction?: (url: string) => InternalUiActionResult;\n\tonInternalUiAction?: (url: string) => InternalUiActionResult;\n\t/**\n\t * Return false to let a focused overlay receive viewport input first.\n\t * Mouse input is deferred only while the focused component belongs to an\n\t * overlay; non-overlay focus keeps pi-tui's transcript selection path.\n\t */\n\tshouldHandleViewportInput?: (\n\t\tdata: string,\n\t\tisMouseInput: boolean,\n\t\tfocusedIsOverlay: boolean,\n\t\t_focusedIsViewportSearch: boolean,\n\t) => boolean;\n\t/** Handle an unconsumed overlay input before replaying it to the viewport. */\n\tonOverlayUnhandledInput?: (data: string) => boolean;\n\t/**\n\t * Copy selected text to the system clipboard; resolve false when the host\n\t * clipboard never received it. Defaults to Atomic's `copyToClipboard` with\n\t * its platform fallbacks, so pi-tui flashes \"Copy failed\" on a terminal\n\t * whose clipboard stayed untouched (upstream #8110) instead of the old\n\t * unconditional \"Copied!\". Injectable so hosts and tests observe the write.\n\t */\n\tcopySelection?: (text: string) => Promise<boolean>;\n}\n\n/** The default selection-copy route: Atomic's host clipboard write. */\nasync function copySelectionToHostClipboard(text: string): Promise<boolean> {\n\ttry {\n\t\tawait copyToClipboard(text);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport interface UrlActivationHandlers {\n\tonOverlayInternalUiAction?: (url: string) => InternalUiActionResult;\n\tonInternalUiAction?: (url: string) => InternalUiActionResult;\n\topenUrl: (url: string) => void;\n}\n\nfunction fallbackInternalUiAction(url: string, handlers: UrlActivationHandlers): void {\n\thandlers.onInternalUiAction?.(url);\n}\n\nfunction routeInternalUiAction(url: string, handlers: UrlActivationHandlers): void {\n\tlet result: InternalUiActionResult;\n\ttry {\n\t\tresult = handlers.onOverlayInternalUiAction?.(url);\n\t} catch {\n\t\tfallbackInternalUiAction(url, handlers);\n\t\treturn;\n\t}\n\tif (result instanceof Promise) {\n\t\tvoid result.then(\n\t\t\t(handled) => {\n\t\t\t\tif (handled !== true) fallbackInternalUiAction(url, handlers);\n\t\t\t},\n\t\t\t() => fallbackInternalUiAction(url, handlers),\n\t\t);\n\t\treturn;\n\t}\n\tif (result !== true) fallbackInternalUiAction(url, handlers);\n}\n\n/** Route OSC 8 activation without allowing unknown internal URLs to escape to a browser. */\nexport function handleUrlActivation(url: string, handlers: UrlActivationHandlers): void {\n\tconst internalUiScheme = \"atomic-ui:\";\n\tif (url.slice(0, internalUiScheme.length).toLowerCase() === internalUiScheme) {\n\t\tconst schemeEnd = url.indexOf(\":\");\n\t\tconst normalizedInternalUrl = `${url.slice(0, schemeEnd).toLowerCase()}${url.slice(schemeEnd)}`;\n\t\t// Forward the normalized URL: overlay-side matching is exact, so a\n\t\t// mixed-case scheme must not reach an overlay as an unrecognized string.\n\t\tif (normalizedInternalUrl === TRANSCRIPT_JUMP_TO_END_URL) routeInternalUiAction(normalizedInternalUrl, handlers);\n\t\treturn;\n\t}\n\n\thandlers.openUrl(url);\n}\n\nconst viewportInputListeners = new WeakSet<AtomicTuiAltScreen>();\n\ntype ViewportInputGate = (\n\tdata: string,\n\tisMouseInput: boolean,\n\tfocusedIsOverlay: boolean,\n\t_focusedIsViewportSearch: boolean,\n) => boolean;\n\nconst viewportInputGates = new WeakMap<AtomicTuiAltScreen, ViewportInputGate>();\nconst overlayUnhandledInputHandlers = new WeakMap<AtomicTuiAltScreen, (data: string) => boolean>();\n/** Instances currently replaying overlay-declined input into pi-tui's viewport listener. */\nconst viewportInputReplays = new WeakSet<AtomicTuiAltScreen>();\n/** Selections begun over Atomic overlays must never trigger or survive into main-chat clipboard actions. */\nconst overlayOwnedSelections = new WeakSet<AtomicTuiAltScreen>();\ninterface ViewportInputSubscription {\n\tviewportUnsubscribe: () => void;\n\trouteListener: TuiInputListener;\n\trouteUnsubscribe: () => void;\n}\n\nconst viewportInputSubscriptions = new WeakMap<AtomicTuiAltScreen, ViewportInputSubscription>();\n\n/** A complete SGR or X10 mouse report extracted from an input chunk. */\ninterface ParsedMouseSequence {\n\treadonly data: string;\n\treadonly button: number;\n\treadonly isRelease: boolean;\n}\n\nconst SGR_MOUSE_SEQUENCE = /^\\x1b\\[<(\\d+);\\d+;\\d+([Mm])/;\nconst LEFT_MOUSE_MODIFIER_MASK = 4 | 8 | 16;\n\nfunction parseMouseSequences(data: string): ParsedMouseSequence[] | undefined {\n\tif (data.length === 0) return undefined;\n\tconst sequences: ParsedMouseSequence[] = [];\n\tlet offset = 0;\n\twhile (offset < data.length) {\n\t\tconst remaining = data.slice(offset);\n\t\tconst sgr = SGR_MOUSE_SEQUENCE.exec(remaining);\n\t\tif (sgr) {\n\t\t\tconst sequence = sgr[0]!;\n\t\t\tsequences.push({ data: sequence, button: Number.parseInt(sgr[1]!, 10), isRelease: sgr[2] === \"m\" });\n\t\t\toffset += sequence.length;\n\t\t\tcontinue;\n\t\t}\n\t\tif (remaining.startsWith(\"\\x1b[M\") && remaining.length >= 6) {\n\t\t\tconst sequence = remaining.slice(0, 6);\n\t\t\tsequences.push({ data: sequence, button: sequence.charCodeAt(3) - 32, isRelease: false });\n\t\t\toffset += 6;\n\t\t\tcontinue;\n\t\t}\n\t\treturn undefined;\n\t}\n\treturn sequences;\n}\n\n/** Whether every report in a mouse chunk is a vertical wheel event. */\nexport function isMouseWheelInput(data: string): boolean {\n\tconst sequences = parseMouseSequences(data);\n\treturn (\n\t\tsequences !== undefined &&\n\t\tsequences.length > 0 &&\n\t\tsequences.every(({ button }) => {\n\t\t\tconst direction = button & 3;\n\t\t\treturn (button & 64) !== 0 && (direction === 0 || direction === 1);\n\t\t})\n\t);\n}\n\nfunction isLeftMouseButton(sequence: ParsedMouseSequence): boolean {\n\tconst { button } = sequence;\n\tif ((button & 64) !== 0) return false;\n\tconst held = button & 3;\n\t// A release carries no button identity on the terminals upstream #7963\n\t// describes: they report the generic SGR code 3 rather than 0. pi-tui 0.84.2\n\t// ends a selection on `release && (button & 3) === 3`\n\t// (`dist/tui-alt-screen.js:796`), so a release Atomic drops here leaves the\n\t// press it already forwarded open — the selection never closes and the OSC 8\n\t// link under the press never activates. Shift, Meta/Option, and Ctrl are\n\t// application-bypass gestures on press and motion, but a release can retain\n\t// those bits and still has to close a selection.\n\tif (sequence.isRelease) return held === 0 || held === 3;\n\treturn held === 0 && (button & LEFT_MOUSE_MODIFIER_MASK) === 0;\n}\n\n/** Whether a mouse chunk contains a left-button selection gesture. */\nfunction isLeftMouseSequence(data: string): boolean {\n\treturn parseMouseSequences(data)?.some((sequence) => isLeftMouseButton(sequence)) ?? false;\n}\n\n/**\n * Replay a chunk one report at a time because pi-tui parses one report per\n * call. Only a chunk whose every byte is a mouse report is split; anything else\n * is replayed verbatim.\n *\n * **Probe, pi 0.84.2 (upstream `2a95ef70`, `06ed8716`):** neither the\n * lone-ESC timeout scope nor the split-`Alt+Enter` reassembly is affected by\n * this replay. Both land in `StdinBuffer`/`ProcessTerminal`\n * (`dist/stdin-buffer.js:process`, `dist/terminal.js:48`), which assemble\n * complete sequences before any listener runs; Atomic builds pi-tui's own\n * `ProcessTerminal` in `createFullscreenTui`/`createInteractiveTui` below and\n * overrides neither the buffer nor its escape timeout. A reassembled `\\x1b` or\n * `\\x1b\\r` reaches this function as one chunk, fails `parseMouseSequences`, and\n * is handed on unsplit — so a viewport action bound to `escape` or `alt+enter`\n * still matches after a decline.\n * Outcome: no breakage, no fix needed — covered by the replay probes in\n * `test/pi-0.84.2-overlay-viewport-deferral.test.ts`.\n */\nfunction replayMouseInput(viewportListener: TuiInputListener, data: string): void {\n\tconst sequences = parseMouseSequences(data);\n\tif (!sequences) {\n\t\tviewportListener(data);\n\t\treturn;\n\t}\n\tfor (const sequence of sequences) viewportListener(sequence.data);\n}\n\n/**\n * The first `addInputListener` call is load-bearing: pi-tui 0.84.2 registers\n * its viewport listener from `TuiAltScreen`'s constructor\n * (`dist/tui-alt-screen.js:85`). Keep the viewport wrapper first so mouse,\n * selection, and focus cleanup retain pi-tui's ordering. Put the focused-input\n * route last so application listeners still receive deferred viewport keys.\n */\nclass AtomicTuiAltScreen extends TuiAltScreen {\n\tconstructor(\n\t\tterminal: Terminal,\n\t\tshowHardwareCursor: boolean,\n\t\tlogDirectory: string,\n\t\toptions: ConstructorParameters<typeof TuiAltScreen>[3],\n\t\tviewportInputGate?: ViewportInputGate,\n\t\tonOverlayUnhandledInput?: (data: string) => boolean,\n\t) {\n\t\tsuper(terminal, showHardwareCursor, logDirectory, options);\n\t\tif (viewportInputGate) viewportInputGates.set(this, viewportInputGate);\n\t\tif (onOverlayUnhandledInput) overlayUnhandledInputHandlers.set(this, onOverlayUnhandledInput);\n\t\t// pi-tui 0.84.2 added `shouldDeferViewportInputToOverlay()`, which drops\n\t\t// viewport keys and wheel reports while an overlay holds focus (upstream\n\t\t// #7894). Atomic's gate offers that input to the focused overlay first and\n\t\t// replays only what the overlay declined (#2378 / PR #2381); pi-tui then\n\t\t// defers the replay a second time and the transcript freezes behind an\n\t\t// open dialog. Suppress the native answer for the replay alone. Input the\n\t\t// gate never routed through the overlay keeps pi-tui's routing and its\n\t\t// own deferral.\n\t\tconst deferral = this as unknown as TuiAltScreenViewportDeferral;\n\t\tconst deferToOverlay = deferral.shouldDeferViewportInputToOverlay?.bind(this);\n\t\tdeferral.shouldDeferViewportInputToOverlay = () => !viewportInputReplays.has(this) && deferToOverlay?.() === true;\n\t}\n\n\t/**\n\t * Last stop before pi-tui turns the composited screen into bytes, and where\n\t * it already removes its own `CURSOR_MARKER`. Every component tree that this\n\t * renderer paints converges here, so one strip covers the overlay, inline,\n\t * widget, and workflows stage-chat mounts at once — including hosts that\n\t * never call `ReservedBottomOverlay.takeActiveRow`. The mark is zero-width,\n\t * so removing it after cursor extraction cannot move a column.\n\t */\n\tprotected override applyLineResets(lines: string[]): string[] {\n\t\tif (overlayOwnedSelections.has(this) && !this.isFocusedOverlay()) this.clearOverlayOwnedSelection();\n\t\treturn stripOverlayActiveRowMarker(super.applyLineResets(lines));\n\t}\n\n\tprivate clearOverlayOwnedSelection(): void {\n\t\tconst selection = this as unknown as TuiAltScreenSelectionInternals;\n\t\tselection.selectionAnchor = undefined;\n\t\tselection.selectionFocus = undefined;\n\t\tselection.selectionInitialRange = undefined;\n\t\tselection.selectionPressActive = false;\n\t\tselection.selectionDragged = false;\n\t\tselection.lastClick = undefined;\n\t\toverlayOwnedSelections.delete(this);\n\t}\n\n\t/**\n\t * Keep pi-tui's private predicate as the fallback for its single-report\n\t * grammar. Injected terminals can deliver coalesced reports, so parse those\n\t * chunks locally before asking pi-tui about an unparsed value.\n\t */\n\tprivate isPiTuiMouseSequence(data: string): boolean {\n\t\tif (parseMouseSequences(data)) return true;\n\t\tconst predicate = (this as unknown as Partial<TuiAltScreenMouseInternals>).isMouseSequence;\n\t\treturn typeof predicate === \"function\" ? predicate.call(this, data) : false;\n\t}\n\n\tprivate isFocusedOverlay(): boolean {\n\t\tconst tui = this as unknown as TuiOverlayInternals;\n\t\treturn tui.overlayStack.some((entry) => entry.component === this.getFocusedComponent());\n\t}\n\n\toverride addInputListener(listener: TuiInputListener): () => void {\n\t\tif (!viewportInputListeners.has(this)) {\n\t\t\tviewportInputListeners.add(this);\n\t\t\tconst subscription: ViewportInputSubscription = {\n\t\t\t\tviewportUnsubscribe: () => {},\n\t\t\t\trouteListener: (data) => this.routeViewportInput(listener, data),\n\t\t\t\trouteUnsubscribe: () => {},\n\t\t\t};\n\t\t\tviewportInputSubscriptions.set(this, subscription);\n\t\t\tsubscription.viewportUnsubscribe = super.addInputListener((data) => {\n\t\t\t\tconst gate = viewportInputGates.get(this);\n\t\t\t\tconst isMouseInput = gate ? this.isPiTuiMouseSequence(data) : false;\n\t\t\t\tif (gate && !gate(data, isMouseInput, this.isFocusedOverlay(), false)) return undefined;\n\t\t\t\treturn listener(data);\n\t\t\t});\n\t\t\tsubscription.routeUnsubscribe = super.addInputListener(subscription.routeListener);\n\t\t\treturn () => {\n\t\t\t\tsubscription.viewportUnsubscribe();\n\t\t\t\tsubscription.routeUnsubscribe();\n\t\t\t\tviewportInputSubscriptions.delete(this);\n\t\t\t\tviewportInputListeners.delete(this);\n\t\t\t};\n\t\t}\n\n\t\tconst subscription = viewportInputSubscriptions.get(this);\n\t\tif (!subscription) return super.addInputListener(listener);\n\t\tsubscription.routeUnsubscribe();\n\t\tconst unsubscribe = super.addInputListener(listener);\n\t\tsubscription.routeUnsubscribe = super.addInputListener(subscription.routeListener);\n\t\treturn unsubscribe;\n\t}\n\n\tprivate repairOverlayFocus(): void {\n\t\tconst tui = this as unknown as TuiOverlayInternals;\n\t\tconst focused = this.getFocusedComponent();\n\t\tconst focusedOverlay = tui.overlayStack.find((entry) => entry.component === focused);\n\t\tif (focusedOverlay && !tui.isOverlayVisible(focusedOverlay)) {\n\t\t\tconst topVisible = tui.getTopmostVisibleOverlay();\n\t\t\tif (topVisible) {\n\t\t\t\tthis.setFocus(topVisible.component);\n\t\t\t} else {\n\t\t\t\ttui.setFocusInternal({ component: focusedOverlay.preFocus, overlayFocusRestore: \"preserve\" });\n\t\t\t}\n\t\t}\n\n\t\tconst focusIsOverlay = tui.overlayStack.some((entry) => entry.component === this.getFocusedComponent());\n\t\tif (focusIsOverlay) return;\n\n\t\tconst restoreState = tui.getVisibleOverlayFocusRestore();\n\t\tif (restoreState.status === \"eligible\") {\n\t\t\tthis.setFocus(restoreState.overlay.component);\n\t\t} else if (restoreState.status === \"blocked\" && restoreState.blockedBy !== this.getFocusedComponent()) {\n\t\t\tif (restoreState.resume.status === \"restore-overlay\") {\n\t\t\t\tthis.setFocus(restoreState.overlay.component);\n\t\t\t} else {\n\t\t\t\ttui.clearOverlayFocusRestore();\n\t\t\t\tthis.setFocus(restoreState.resume.target);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Keep pi-tui's selection state in sync while an overlay handles a left gesture. */\n\tprivate forwardSelectionMouseInput(viewportListener: TuiInputListener, data: string, focused: Component): void {\n\t\tif (this.getFocusedComponent() !== focused || !isLeftMouseSequence(data)) return;\n\t\tfor (const sequence of parseMouseSequences(data) ?? []) {\n\t\t\tif (isLeftMouseButton(sequence)) viewportListener(sequence.data);\n\t\t}\n\t\toverlayOwnedSelections.add(this);\n\t}\n\t/**\n\t * Replay input the focused overlay declined. pi-tui's native overlay\n\t * deferral is suppressed for the duration, because this chunk has already\n\t * been offered to the overlay it would defer to.\n\t */\n\tprivate replayViewportInput(viewportListener: TuiInputListener, data: string): void {\n\t\tviewportInputReplays.add(this);\n\t\ttry {\n\t\t\treplayMouseInput(viewportListener, data);\n\t\t} finally {\n\t\t\tviewportInputReplays.delete(this);\n\t\t}\n\t}\n\t/** Dispatch a declined chunk to the host action the gated route owns. */\n\tprivate handleOverlayUnhandledInput(data: string, focused: Component | null): boolean {\n\t\tif (this.getFocusedComponent() !== focused || !this.isFocusedOverlay()) return false;\n\t\treturn overlayUnhandledInputHandlers.get(this)?.(data) === true;\n\t}\n\n\t/**\n\t * Finish a chunk a focused overlay's asynchronous handler declined.\n\t *\n\t * Every settled result other than `true` is a decline. The component\n\t * contract is `boolean | undefined | Promise<boolean | undefined>`\n\t * (`ExtensionCustomComponent`), and both `docs/tui.md` and\n\t * `docs/extensions.md` document `false` *and* `undefined` as viewport\n\t * fallthrough, so a promise resolving `undefined` has to replay exactly like\n\t * one resolving `false` — matching only literal `false` consumed the key and\n\t * froze the transcript. A rejection is a decline for the same reason: the\n\t * overlay produced no answer.\n\t *\n\t * The focus guard stays: input that moved focus while the promise was\n\t * pending belongs to whatever holds focus now, not to the transcript.\n\t */\n\tprivate declineAsyncViewportInput(viewportListener: TuiInputListener, data: string, focused: Component): void {\n\t\tif (this.getFocusedComponent() !== focused) return;\n\t\tif (this.handleOverlayUnhandledInput(data, focused)) {\n\t\t\t(this as unknown as TuiOverlayInternals).requestImmediateRender();\n\t\t\treturn;\n\t\t}\n\t\tthis.replayViewportInput(viewportListener, data);\n\t}\n\n\tprivate routeViewportInput(viewportListener: TuiInputListener, data: string): ReturnType<TuiInputListener> {\n\t\tconst gate = viewportInputGates.get(this);\n\t\tconst isMouseInput = gate ? this.isPiTuiMouseSequence(data) : false;\n\t\tif (!gate || gate(data, isMouseInput, this.isFocusedOverlay(), false)) return undefined;\n\n\t\t// Returning `consume` below skips pi-tui's post-listener phase. Mirror its\n\t\t// overlay-focus repair before reading the focused component so a resize\n\t\t// cannot send a gated key to an invisible overlay.\n\t\tthis.repairOverlayFocus();\n\t\tconst focused = this.getFocusedComponent();\n\t\tconst tui = this as unknown as TuiOverlayInternals;\n\t\tif (focused?.handleInput && (!isKeyRelease(data) || focused.wantsKeyRelease === true)) {\n\t\t\tconst handleInput = focused.handleInput as (\n\t\t\t\tdata: string,\n\t\t\t) => boolean | undefined | Promise<boolean | undefined>;\n\t\t\tconst result = handleInput.call(focused, data);\n\t\t\tif (result instanceof Promise) {\n\t\t\t\tvoid result.then(\n\t\t\t\t\t(handled) => {\n\t\t\t\t\t\tif (handled === true) {\n\t\t\t\t\t\t\tthis.forwardSelectionMouseInput(viewportListener, data, focused);\n\t\t\t\t\t\t\ttui.requestImmediateRender();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.declineAsyncViewportInput(viewportListener, data, focused);\n\t\t\t\t\t},\n\t\t\t\t\t() => this.declineAsyncViewportInput(viewportListener, data, focused),\n\t\t\t\t);\n\t\t\t\treturn { consume: true };\n\t\t\t}\n\t\t\tif (result === true) {\n\t\t\t\tthis.forwardSelectionMouseInput(viewportListener, data, focused);\n\t\t\t\ttui.requestImmediateRender();\n\t\t\t\treturn { consume: true };\n\t\t\t}\n\t\t}\n\n\t\tif (this.handleOverlayUnhandledInput(data, focused)) {\n\t\t\ttui.requestImmediateRender();\n\t\t\treturn { consume: true };\n\t\t}\n\t\tthis.replayViewportInput(viewportListener, data);\n\t\treturn { consume: true };\n\t}\n}\n\n/**\n * CI detection follows the convention CI providers actually use: the variable\n * is SET AND NONEMPTY, with any value. GitHub Actions sets `CI=true`, but\n * other providers and users export arbitrary values (`CI=github-actions`,\n * `CI=circleci`); an allowlist of truthy spellings let those reach the\n * alternate screen and write escape sequences into CI logs (Greptile P1 on\n * PR #2308). Only explicit opt-outs (`0`, `false`, empty) read as not-CI.\n */\nfunction isCiEnvironment(value: string | undefined): boolean {\n\tif (value === undefined) return false;\n\tconst normalized = value.trim().toLowerCase();\n\treturn normalized !== \"\" && normalized !== \"0\" && normalized !== \"false\";\n}\n\nfunction shouldUseFullscreenTui(usesInjectedTerminal: boolean): boolean {\n\tif (process.env.TERM?.toLowerCase() === \"dumb\") return false;\n\tif (usesInjectedTerminal) return true;\n\treturn process.stdin.isTTY === true && process.stdout.isTTY === true && !isCiEnvironment(process.env.CI);\n}\n\n/**\n * Build Atomic's fullscreen renderer, `viewportInputGate` included, without\n * consulting the environment. `createInteractiveTui` calls this whenever\n * fullscreen applies; fixtures that assert fullscreen behavior call it\n * directly, because `shouldUseFullscreenTui` returns the main-screen fallback\n * under `TERM=dumb` even for an injected terminal and would otherwise hand\n * those tests a renderer with no layout and no gate.\n */\nexport function createFullscreenTui(options: InteractiveTuiOptions): TuiAltScreen {\n\treturn new AtomicTuiAltScreen(\n\t\toptions.terminal ?? new ProcessTerminal(),\n\t\toptions.showHardwareCursor,\n\t\toptions.logDirectory,\n\t\t{\n\t\t\topenUrl: (url) =>\n\t\t\t\thandleUrlActivation(url, {\n\t\t\t\t\tonOverlayInternalUiAction: options.onOverlayInternalUiAction,\n\t\t\t\t\tonInternalUiAction: options.onInternalUiAction,\n\t\t\t\t\topenUrl: openBrowser,\n\t\t\t\t}),\n\t\t\tonRightClickPaste: options.onRightClickPaste,\n\t\t\tcopyOnSelect: options.copyOnSelect,\n\t\t\tcopySelection: options.copySelection ?? copySelectionToHostClipboard,\n\t\t},\n\t\toptions.shouldHandleViewportInput,\n\t\toptions.onOverlayUnhandledInput,\n\t);\n}\n\n/** Main-screen fallback renderer, carrying the same central mark strip as the fullscreen one. */\nclass AtomicTuiMainScreen extends TuiMainScreen {\n\tprotected override applyLineResets(lines: string[]): string[] {\n\t\treturn stripOverlayActiveRowMarker(super.applyLineResets(lines));\n\t}\n}\n\n/** Creates the fullscreen renderer for interactive TTY sessions. */\nexport function createInteractiveTui(options: InteractiveTuiOptions): InteractiveTui {\n\tconst usesInjectedTerminal = options.terminal !== undefined;\n\tconst terminal = options.terminal ?? new ProcessTerminal();\n\tif (!shouldUseFullscreenTui(usesInjectedTerminal)) {\n\t\t// The normal CLI never reaches the interactive mode without a TTY. Keep a\n\t\t// main-screen renderer for internal harnesses and guarded fallback paths.\n\t\treturn new AtomicTuiMainScreen(terminal, options.showHardwareCursor, options.logDirectory);\n\t}\n\treturn createFullscreenTui({ ...options, terminal });\n}\n\n/** Keeps existing components pointed at the renderer selected at runtime. */\nexport function createInteractiveTuiReference(getTui: () => TUI): TUI {\n\treturn new Proxy({} as TUI, {\n\t\tget: (_target, property) => {\n\t\t\tconst tui = getTui();\n\t\t\tconst value = Reflect.get(tui, property, tui);\n\t\t\tif (typeof value !== \"function\") return value;\n\t\t\tlet methodTui = tui;\n\t\t\tlet method = value;\n\t\t\treturn (...args: unknown[]) => {\n\t\t\t\tconst currentTui = getTui();\n\t\t\t\tif (currentTui !== methodTui) {\n\t\t\t\t\tconst currentMethod = Reflect.get(currentTui, property, currentTui);\n\t\t\t\t\tif (typeof currentMethod !== \"function\") {\n\t\t\t\t\t\tthrow new TypeError(`TUI property ${String(property)} is not callable`);\n\t\t\t\t\t}\n\t\t\t\t\tmethodTui = currentTui;\n\t\t\t\t\tmethod = currentMethod;\n\t\t\t\t}\n\t\t\t\treturn Reflect.apply(method, methodTui, args);\n\t\t\t};\n\t\t},\n\t\tset: (_target, property, value) => {\n\t\t\tconst tui = getTui();\n\t\t\treturn Reflect.set(tui, property, value, tui);\n\t\t},\n\t\thas: (_target, property) => Reflect.has(getTui(), property),\n\t\tgetPrototypeOf: () => Reflect.getPrototypeOf(getTui()),\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-session-binding.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-session-binding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAG/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAEjG,OAAO,EAA+B,KAAK,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACtG,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,UAAU,wBAAwB;IACjC,WAAW,EAAE,mBAAmB,CAAC;IACjC,MAAM,EAAE,SAAS,CAAC;IAClB,wBAAwB,EAAE,2BAA2B,CAAC;IACtD,QAAQ,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QAAQ,CAAC,aAAa,CAAyC;IACvE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqC;IAC/D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAa;IAC7C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAyD;IAE3F,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,YAAY,EACX,WAAW,EACX,MAAM,EACN,wBAAwB,EACxB,eAAe,EACf,QAAQ,EACR,aAAa,EACb,aAAa,EACb,SAAS,EACT,iBAAiB,GACjB,EAAE,wBAAwB,EAW1B;IAED,IAAI,cAAc,IAAI,YAAY,CAEjC;IAEK,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAkFnC;IAED,oBAAoB,IAAI,IAAI,CAO3B;CACD"}
@@ -1,3 +1,4 @@
1
+ import { setCapabilityOverrides } from "@earendil-works/pi-tui";
1
2
  import { FooterDataProvider } from "../../core/footer-data-provider.js";
2
3
  import { waitForRawStdoutBackpressure } from "../../core/output-guard.js";
3
4
  import { toJsonEvent } from "../json-event.js";
@@ -22,6 +23,7 @@ export class RpcSessionBinding {
22
23
  this.session = this.runtimeHost.session;
23
24
  this.disposeSubscriptions();
24
25
  const session = this.session;
26
+ setCapabilityOverrides(session.settingsManager.getTerminalCapabilityOverrides());
25
27
  this.renderService?.bindSession(session);
26
28
  this.footerDataProvider = new FooterDataProvider(session.sessionManager.getCwd());
27
29
  // Seed the provider count from the current catalog snapshot, mirroring
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-session-binding.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-session-binding.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAK1E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAoC,MAAM,uBAAuB,CAAC;AAgBtG,MAAM,OAAO,iBA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,EAAE,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,kEAAkE;YAClE,mDAAmD;YACnD,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;YAClC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;YACpC,MAAM,KAAK,CAAC;QACb,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;YAC9C,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;YACjE,MAAM,4BAA4B,EAAE,CAAC;QACtC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,oBAAoB;QACnB,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QACrB,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC;QACjC,IAAI,CAAC,kBAAkB,EAAE,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,uBAAuB,GAAG,SAAS,CAAC;QACzC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;IACrC,CAAC;CACD","sourcesContent":["import type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport { FooterDataProvider } from \"../../core/footer-data-provider.ts\";\nimport { waitForRawStdoutBackpressure } from \"../../core/output-guard.ts\";\nimport type { EngineCustomUiService } from \"../interactive-engine/engine-custom-ui.ts\";\nimport type { EngineInputFormService } from \"../interactive-engine/engine-input-form.ts\";\nimport type { EngineRenderService } from \"../interactive-engine/engine-render-service.ts\";\nimport type { EngineSessionPickerService } from \"../interactive-engine/engine-session-picker.ts\";\nimport { toJsonEvent } from \"../json-event.ts\";\nimport { createRpcExtensionUIContext, type RpcPendingExtensionRequests } from \"./rpc-extension-ui.ts\";\nimport type { KeybindingsReloadCoordinator } from \"./rpc-keybindings-reload.ts\";\nimport type { RpcOutput } from \"./rpc-responses.ts\";\n\ninterface RpcSessionBindingOptions {\n\truntimeHost: AgentSessionRuntime;\n\toutput: RpcOutput;\n\tpendingExtensionRequests: RpcPendingExtensionRequests;\n\tcustomUi?: EngineCustomUiService;\n\trenderService?: EngineRenderService;\n\tsessionPicker?: EngineSessionPickerService;\n\tinputForm?: EngineInputFormService;\n\trequestShutdown: () => void;\n\treloadCoordinator?: KeybindingsReloadCoordinator<AgentSession>;\n}\n\nexport class RpcSessionBinding {\n\tprivate session: AgentSession;\n\tprivate unsubscribe?: () => void;\n\tprivate unsubscribeBackpressure?: () => void;\n\tprivate readonly runtimeHost: AgentSessionRuntime;\n\tprivate readonly output: RpcOutput;\n\tprivate readonly pendingExtensionRequests: RpcPendingExtensionRequests;\n\tprivate readonly customUi: EngineCustomUiService | undefined;\n\tprivate readonly renderService: EngineRenderService | undefined;\n\tprivate readonly sessionPicker: EngineSessionPickerService | undefined;\n\tprivate readonly inputForm: EngineInputFormService | undefined;\n\tprivate readonly requestShutdown: () => void;\n\tprivate readonly reloadCoordinator: KeybindingsReloadCoordinator<AgentSession> | undefined;\n\n\tprivate footerDataProvider: FooterDataProvider | undefined;\n\tconstructor({\n\t\truntimeHost,\n\t\toutput,\n\t\tpendingExtensionRequests,\n\t\trequestShutdown,\n\t\tcustomUi,\n\t\trenderService,\n\t\tsessionPicker,\n\t\tinputForm,\n\t\treloadCoordinator,\n\t}: RpcSessionBindingOptions) {\n\t\tthis.runtimeHost = runtimeHost;\n\t\tthis.output = output;\n\t\tthis.pendingExtensionRequests = pendingExtensionRequests;\n\t\tthis.requestShutdown = requestShutdown;\n\t\tthis.customUi = customUi;\n\t\tthis.renderService = renderService;\n\t\tthis.sessionPicker = sessionPicker;\n\t\tthis.inputForm = inputForm;\n\t\tthis.reloadCoordinator = reloadCoordinator;\n\t\tthis.session = runtimeHost.session;\n\t}\n\n\tget currentSession(): AgentSession {\n\t\treturn this.session;\n\t}\n\n\tasync rebindSession(): Promise<void> {\n\t\tthis.session = this.runtimeHost.session;\n\t\tthis.disposeSubscriptions();\n\t\tconst session = this.session;\n\t\tthis.renderService?.bindSession(session);\n\t\tthis.footerDataProvider = new FooterDataProvider(session.sessionManager.getCwd());\n\t\t// Seed the provider count from the current catalog snapshot, mirroring\n\t\t// updateProviderCountFromSnapshot() in interactive startup, so the\n\t\t// embedded footer shows the (provider) model prefix in multi-provider\n\t\t// sessions instead of defaulting to 0.\n\t\tconst models =\n\t\t\tsession.scopedModels.length > 0\n\t\t\t\t? session.scopedModels.map((scoped) => scoped.model)\n\t\t\t\t: session.modelRuntime.getAvailableSnapshot();\n\t\tthis.footerDataProvider.setAvailableProviderCount(new Set(models.map((model) => model.provider)).size);\n\n\t\ttry {\n\t\t\tawait session.bindExtensions({\n\t\t\t\tuiContext: createRpcExtensionUIContext({\n\t\t\t\t\toutput: this.output,\n\t\t\t\t\tpendingExtensionRequests: this.pendingExtensionRequests,\n\t\t\t\t\tcustomUi: this.customUi,\n\t\t\t\t\tsessionPicker: this.sessionPicker,\n\t\t\t\t\tinputForm: this.inputForm,\n\t\t\t\t\tfooterDataProvider: this.footerDataProvider,\n\t\t\t\t}),\n\t\t\t\tmode: this.customUi ? \"tui\" : \"rpc\",\n\t\t\t\tcommandContextActions: {\n\t\t\t\t\twaitForIdle: () => this.session.agent.waitForIdle(),\n\t\t\t\t\tnewSession: async (options) => this.runtimeHost.newSession(options),\n\t\t\t\t\tfork: async (entryId, forkOptions) => {\n\t\t\t\t\t\tconst result = await this.runtimeHost.fork(entryId, forkOptions);\n\t\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t\t},\n\t\t\t\t\tnavigateTree: async (targetId, options) => {\n\t\t\t\t\t\tconst result = await this.session.navigateTree(targetId, {\n\t\t\t\t\t\t\tsummarize: options?.summarize,\n\t\t\t\t\t\t\tcustomInstructions: options?.customInstructions,\n\t\t\t\t\t\t\treplaceInstructions: options?.replaceInstructions,\n\t\t\t\t\t\t\tlabel: options?.label,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t\t},\n\t\t\t\t\tswitchSession: async (sessionPath, options) => {\n\t\t\t\t\t\treturn this.runtimeHost.switchSession(sessionPath, options);\n\t\t\t\t\t},\n\t\t\t\t\treload: async () => {\n\t\t\t\t\t\tconst steeringMode = this.session.steeringMode;\n\t\t\t\t\t\tconst followUpMode = this.session.followUpMode;\n\t\t\t\t\t\tif (this.reloadCoordinator) await this.reloadCoordinator.reload(this.session);\n\t\t\t\t\t\telse await this.session.reload();\n\t\t\t\t\t\tthis.session.setSteeringMode(steeringMode);\n\t\t\t\t\t\tthis.session.setFollowUpMode(followUpMode);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tshutdownHandler: this.requestShutdown,\n\t\t\t\tonError: (err) => {\n\t\t\t\t\tthis.output({\n\t\t\t\t\t\ttype: \"extension_error\",\n\t\t\t\t\t\textensionPath: err.extensionPath,\n\t\t\t\t\t\tevent: err.event,\n\t\t\t\t\t\terror: err.error,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t});\n\t\t\tthis.footerDataProvider.startGitWatcher();\n\t\t} catch (error) {\n\t\t\t// Leave no partially-initialized footer state behind if extension\n\t\t\t// binding fails; dispose the provider and rethrow.\n\t\t\tthis.footerDataProvider.dispose();\n\t\t\tthis.footerDataProvider = undefined;\n\t\t\tthrow error;\n\t\t}\n\n\t\tthis.unsubscribe = session.subscribe((event) => {\n\t\t\tthis.output(toJsonEvent(event));\n\t\t});\n\t\tthis.unsubscribeBackpressure = session.agent.subscribe(async () => {\n\t\t\tawait waitForRawStdoutBackpressure();\n\t\t});\n\t\tthis.reloadCoordinator?.publishCurrentState(session);\n\t}\n\n\tdisposeSubscriptions(): void {\n\t\tthis.unsubscribe?.();\n\t\tthis.unsubscribeBackpressure?.();\n\t\tthis.footerDataProvider?.dispose();\n\t\tthis.unsubscribe = undefined;\n\t\tthis.unsubscribeBackpressure = undefined;\n\t\tthis.footerDataProvider = undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"rpc-session-binding.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-session-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAK1E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAoC,MAAM,uBAAuB,CAAC;AAgBtG,MAAM,OAAO,iBAAiB;IAe7B,YAAY,EACX,WAAW,EACX,MAAM,EACN,wBAAwB,EACxB,eAAe,EACf,QAAQ,EACR,aAAa,EACb,aAAa,EACb,SAAS,EACT,iBAAiB,GACS;QAC1B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;QACzD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;IACpC,CAAC;IAED,IAAI,cAAc;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAED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C;IACtD,CAAC;IAED,oBAAoB;QACnB,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QACrB,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC;QACjC,IAAI,CAAC,kBAAkB,EAAE,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,uBAAuB,GAAG,SAAS,CAAC;QACzC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;IACrC,CAAC;CACD","sourcesContent":["import { setCapabilityOverrides } from \"@earendil-works/pi-tui\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport { FooterDataProvider } from \"../../core/footer-data-provider.ts\";\nimport { waitForRawStdoutBackpressure } from \"../../core/output-guard.ts\";\nimport type { EngineCustomUiService } from \"../interactive-engine/engine-custom-ui.ts\";\nimport type { EngineInputFormService } from \"../interactive-engine/engine-input-form.ts\";\nimport type { EngineRenderService } from \"../interactive-engine/engine-render-service.ts\";\nimport type { EngineSessionPickerService } from \"../interactive-engine/engine-session-picker.ts\";\nimport { toJsonEvent } from \"../json-event.ts\";\nimport { createRpcExtensionUIContext, type RpcPendingExtensionRequests } from \"./rpc-extension-ui.ts\";\nimport type { KeybindingsReloadCoordinator } from \"./rpc-keybindings-reload.ts\";\nimport type { RpcOutput } from \"./rpc-responses.ts\";\n\ninterface RpcSessionBindingOptions {\n\truntimeHost: AgentSessionRuntime;\n\toutput: RpcOutput;\n\tpendingExtensionRequests: RpcPendingExtensionRequests;\n\tcustomUi?: EngineCustomUiService;\n\trenderService?: EngineRenderService;\n\tsessionPicker?: EngineSessionPickerService;\n\tinputForm?: EngineInputFormService;\n\trequestShutdown: () => void;\n\treloadCoordinator?: KeybindingsReloadCoordinator<AgentSession>;\n}\n\nexport class RpcSessionBinding {\n\tprivate session: AgentSession;\n\tprivate unsubscribe?: () => void;\n\tprivate unsubscribeBackpressure?: () => void;\n\tprivate readonly runtimeHost: AgentSessionRuntime;\n\tprivate readonly output: RpcOutput;\n\tprivate readonly pendingExtensionRequests: RpcPendingExtensionRequests;\n\tprivate readonly customUi: EngineCustomUiService | undefined;\n\tprivate readonly renderService: EngineRenderService | undefined;\n\tprivate readonly sessionPicker: EngineSessionPickerService | undefined;\n\tprivate readonly inputForm: EngineInputFormService | undefined;\n\tprivate readonly requestShutdown: () => void;\n\tprivate readonly reloadCoordinator: KeybindingsReloadCoordinator<AgentSession> | undefined;\n\n\tprivate footerDataProvider: FooterDataProvider | undefined;\n\tconstructor({\n\t\truntimeHost,\n\t\toutput,\n\t\tpendingExtensionRequests,\n\t\trequestShutdown,\n\t\tcustomUi,\n\t\trenderService,\n\t\tsessionPicker,\n\t\tinputForm,\n\t\treloadCoordinator,\n\t}: RpcSessionBindingOptions) {\n\t\tthis.runtimeHost = runtimeHost;\n\t\tthis.output = output;\n\t\tthis.pendingExtensionRequests = pendingExtensionRequests;\n\t\tthis.requestShutdown = requestShutdown;\n\t\tthis.customUi = customUi;\n\t\tthis.renderService = renderService;\n\t\tthis.sessionPicker = sessionPicker;\n\t\tthis.inputForm = inputForm;\n\t\tthis.reloadCoordinator = reloadCoordinator;\n\t\tthis.session = runtimeHost.session;\n\t}\n\n\tget currentSession(): AgentSession {\n\t\treturn this.session;\n\t}\n\n\tasync rebindSession(): Promise<void> {\n\t\tthis.session = this.runtimeHost.session;\n\t\tthis.disposeSubscriptions();\n\t\tconst session = this.session;\n\t\tsetCapabilityOverrides(session.settingsManager.getTerminalCapabilityOverrides());\n\t\tthis.renderService?.bindSession(session);\n\t\tthis.footerDataProvider = new FooterDataProvider(session.sessionManager.getCwd());\n\t\t// Seed the provider count from the current catalog snapshot, mirroring\n\t\t// updateProviderCountFromSnapshot() in interactive startup, so the\n\t\t// embedded footer shows the (provider) model prefix in multi-provider\n\t\t// sessions instead of defaulting to 0.\n\t\tconst models =\n\t\t\tsession.scopedModels.length > 0\n\t\t\t\t? session.scopedModels.map((scoped) => scoped.model)\n\t\t\t\t: session.modelRuntime.getAvailableSnapshot();\n\t\tthis.footerDataProvider.setAvailableProviderCount(new Set(models.map((model) => model.provider)).size);\n\n\t\ttry {\n\t\t\tawait session.bindExtensions({\n\t\t\t\tuiContext: createRpcExtensionUIContext({\n\t\t\t\t\toutput: this.output,\n\t\t\t\t\tpendingExtensionRequests: this.pendingExtensionRequests,\n\t\t\t\t\tcustomUi: this.customUi,\n\t\t\t\t\tsessionPicker: this.sessionPicker,\n\t\t\t\t\tinputForm: this.inputForm,\n\t\t\t\t\tfooterDataProvider: this.footerDataProvider,\n\t\t\t\t}),\n\t\t\t\tmode: this.customUi ? \"tui\" : \"rpc\",\n\t\t\t\tcommandContextActions: {\n\t\t\t\t\twaitForIdle: () => this.session.agent.waitForIdle(),\n\t\t\t\t\tnewSession: async (options) => this.runtimeHost.newSession(options),\n\t\t\t\t\tfork: async (entryId, forkOptions) => {\n\t\t\t\t\t\tconst result = await this.runtimeHost.fork(entryId, forkOptions);\n\t\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t\t},\n\t\t\t\t\tnavigateTree: async (targetId, options) => {\n\t\t\t\t\t\tconst result = await this.session.navigateTree(targetId, {\n\t\t\t\t\t\t\tsummarize: options?.summarize,\n\t\t\t\t\t\t\tcustomInstructions: options?.customInstructions,\n\t\t\t\t\t\t\treplaceInstructions: options?.replaceInstructions,\n\t\t\t\t\t\t\tlabel: options?.label,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t\t},\n\t\t\t\t\tswitchSession: async (sessionPath, options) => {\n\t\t\t\t\t\treturn this.runtimeHost.switchSession(sessionPath, options);\n\t\t\t\t\t},\n\t\t\t\t\treload: async () => {\n\t\t\t\t\t\tconst steeringMode = this.session.steeringMode;\n\t\t\t\t\t\tconst followUpMode = this.session.followUpMode;\n\t\t\t\t\t\tif (this.reloadCoordinator) await this.reloadCoordinator.reload(this.session);\n\t\t\t\t\t\telse await this.session.reload();\n\t\t\t\t\t\tthis.session.setSteeringMode(steeringMode);\n\t\t\t\t\t\tthis.session.setFollowUpMode(followUpMode);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tshutdownHandler: this.requestShutdown,\n\t\t\t\tonError: (err) => {\n\t\t\t\t\tthis.output({\n\t\t\t\t\t\ttype: \"extension_error\",\n\t\t\t\t\t\textensionPath: err.extensionPath,\n\t\t\t\t\t\tevent: err.event,\n\t\t\t\t\t\terror: err.error,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t});\n\t\t\tthis.footerDataProvider.startGitWatcher();\n\t\t} catch (error) {\n\t\t\t// Leave no partially-initialized footer state behind if extension\n\t\t\t// binding fails; dispose the provider and rethrow.\n\t\t\tthis.footerDataProvider.dispose();\n\t\t\tthis.footerDataProvider = undefined;\n\t\t\tthrow error;\n\t\t}\n\n\t\tthis.unsubscribe = session.subscribe((event) => {\n\t\t\tthis.output(toJsonEvent(event));\n\t\t});\n\t\tthis.unsubscribeBackpressure = session.agent.subscribe(async () => {\n\t\t\tawait waitForRawStdoutBackpressure();\n\t\t});\n\t\tthis.reloadCoordinator?.publishCurrentState(session);\n\t}\n\n\tdisposeSubscriptions(): void {\n\t\tthis.unsubscribe?.();\n\t\tthis.unsubscribeBackpressure?.();\n\t\tthis.footerDataProvider?.dispose();\n\t\tthis.unsubscribe = undefined;\n\t\tthis.unsubscribeBackpressure = undefined;\n\t\tthis.footerDataProvider = undefined;\n\t}\n}\n"]}
@@ -117,7 +117,7 @@ Exactly the configured recent-message tail is outside the compactable region; At
117
117
 
118
118
  Manual compaction is single-flight. A manual request made while another manual compaction is still in flight joins that run and receives its result instead of starting a second model call, so it emits no extra `compaction_start`/`compaction_end` pair and appends no extra boundary; `abortCompaction()` (Escape) still cancels the single owning run for every waiter. A manual request made while automatic compaction is active takes ownership: it cancels unfinished automatic work, abandons any pending automatic continuation, waits for the active turn and automatic state to settle, then runs the requested manual compaction. If the automatic boundary committed first, the manual request runs after it rather than reusing that result or writing concurrently. In the interactive TUI, `/compact` uses this takeover only for automatic compaction; a second manual compaction or branch summary is still refused. Ordinary text typed during compaction remains queued and flushes after its non-mid-turn completion, including cancellation or failure.
119
119
 
120
- The post-tool check stays inside the active Pi loop: it runs the rung ladder once for that completed tool turn, returns the rebuilt context to the loop, and never calls or schedules `agent.continue()`. Normal context reconstruction preserves provider tool-call/result protocol validity. Below-threshold tool turns follow the unchanged request path. Because the same active run resumes without emitting another `agent_start`, the interactive TUI replaces the compaction loader with its working spinner as soon as successful mid-turn compaction ends; streaming feedback therefore resumes immediately without waiting for another user interaction.
120
+ The post-tool check stays inside the active Pi loop: it runs the rung ladder once for that completed tool turn, returns the rebuilt context to the loop, and never calls or schedules `agent.continue()`. If the caller installed `prepareNextTurn` or `prepareNextTurnWithContext`, Atomic invokes it after compaction with that rebuilt context and sends the caller's complete replacement context through the normal context transform to the next provider request. A `shouldStopAfterTurn` result of `true` takes precedence over queued steering and follow-up messages, including messages queued while the callback is running: Atomic leaves that work pending until a later explicit prompt or continuation instead of starting another provider request. Normal context reconstruction preserves provider tool-call/result protocol validity. Below-threshold tool turns follow the unchanged request path. Because the same active run resumes without emitting another `agent_start`, the interactive TUI replaces the compaction loader with its working spinner and keeps terminal progress active as soon as successful mid-turn compaction ends; streaming feedback therefore resumes immediately without waiting for another user interaction.
121
121
 
122
122
  ## Planning rungs and failure behavior
123
123
 
@@ -19,6 +19,8 @@ Atomic accepts environment variables for configuration, provider credentials, an
19
19
 
20
20
  `PI_TUI_ESC_TIMEOUT` belongs to the installed pi-tui renderer and also keeps its upstream name: it sets how long the renderer waits after a lone `ESC` before treating it as the Escape key, in milliseconds. The default is `100` over SSH and `10` otherwise; increase it if Alt-key input is misread as Escape.
21
21
 
22
+ The renderer also owns `PI_HYPERLINKS`, `PI_IMAGE_PROTOCOL`, and `PI_TRUE_COLOR`. `PI_HYPERLINKS=1|0|auto` and `PI_TRUE_COLOR=1|0|auto` override or preserve detection; `PI_IMAGE_PROTOCOL=kitty|iterm2|none|auto` selects, disables, or preserves image-protocol detection. Explicit JSON values under `terminal.hyperlinks`, `terminal.images`, and `terminal.trueColor` take precedence. These renderer-owned names intentionally have no `ATOMIC_*` aliases.
23
+
22
24
  ## Subprocess attribution
23
25
 
24
26
  `AI_AGENT=atomic` is set by the CLI, RPC, and compiled binary entry points and forced into every Atomic-owned child-process environment, including bash/tool commands, isolated RPC children, subagent and workflow runners, MCP servers, web-access subprocesses, and the intercom broker. This follows upstream's overwrite policy: a caller-supplied `AI_AGENT` is replaced in the Atomic process and child environment, but the caller's environment object is never mutated.
@@ -637,6 +637,25 @@ pi.on("agent_settled", async (_event, ctx) => {
637
637
  });
638
638
  ```
639
639
 
640
+ #### ui_prompt_start / ui_prompt_end
641
+
642
+ These notification-only events wrap blocking user-facing extension prompts opened through `ctx.ui.select()`, `ctx.ui.confirm()`, `ctx.ui.input()`, `ctx.ui.editor()`, and `ctx.ui.custom()`. Each event has `reason: "ui_prompt"`, the prompt `kind`, and the prompt `title` when that method accepts one. Host and status integrations can use the pair to report that Atomic is waiting for the user instead of still working.
643
+
644
+ Atomic coalesces nested or overlapping prompts into one outer span. The end event keeps the outer prompt's kind and title and fires after every prompt in that span settles, including rejected promises and synchronous failures. Rebinding the host UI context closes an active span before a prompt from the new context can begin.
645
+
646
+ Handlers run best-effort from the microtask queue. Atomic does not await them before opening or closing the prompt, so a slow handler cannot delay the UI.
647
+
648
+ ```typescript
649
+ pi.on("ui_prompt_start", (event) => {
650
+ // event.kind - "select" | "confirm" | "input" | "editor" | "custom"
651
+ // event.title - prompt title when available
652
+ });
653
+
654
+ pi.on("ui_prompt_end", (event) => {
655
+ // Atomic is no longer waiting on this outer prompt span.
656
+ });
657
+ ```
658
+
640
659
  #### turn_start / turn_end
641
660
 
642
661
  Fired for each turn (one LLM response + tool calls).
@@ -1471,7 +1490,7 @@ Register a custom tool callable by the LLM. See [Custom Tools](#custom-tools) fo
1471
1490
 
1472
1491
  `pi.registerTool()` works both during extension load and after startup. You can call it inside `session_start`, command handlers, or other event handlers. New tools are refreshed immediately in the same session, so they appear in `pi.getAllTools()` and are callable by the LLM without `/reload`.
1473
1492
 
1474
- Use `pi.setActiveTools()` to enable or disable tools (including dynamically added tools) at runtime.
1493
+ Use `pi.setActiveTools()` to enable or disable tools (including dynamically added tools) at runtime. Atomic always restores mandatory ordinary `intercom`; other tool behavior is unchanged.
1475
1494
 
1476
1495
  Use `promptSnippet` to opt a custom tool into a one-line entry in `Available tools`, and `promptGuidelines` to append tool-specific bullets to the default `Guidelines` section when the tool is active.
1477
1496
 
package/docs/intercom.md CHANGED
@@ -10,9 +10,9 @@ description: "Direct messaging between Atomic sessions on the same machine"
10
10
  Atomic bundles `@bastani/intercom`, a first-party extension for direct 1:1 messaging between Atomic sessions on the same machine. Send context, findings, or requests from one session to another — whether you're driving the conversation or letting agents coordinate. Connections are lazy and tool-driven: the extension registers its commands and tools at startup, but a session does not connect until you or the model actually invoke Intercom. No separate install is needed.
11
11
 
12
12
  **Key capabilities:**
13
- - **Session messaging** - `send`, `ask` (blocking, 10-minute timeout), `reply`, `pending`, `list`, and `status` via the `intercom` tool
14
- - **Runtime groups** - `join` or `leave` named groups without restarting; joined sessions keep their broker IDs and subagents inherit the joined group
15
- - **Session discovery** - List connected sessions with name, full session ID, working directory, model, and live status
13
+ - **Session messaging** - `send`, `ask` (blocking, 10-minute timeout), `reply`, `pending`, `list`, `groups`, and `status` via the `intercom` tool
14
+ - **Runtime groups** - Add or remove named memberships without restarting; joined sessions keep their broker IDs and later subagents inherit the most recently joined membership
15
+ - **Session and group discovery** - List connected sessions or every available group, including session counts and membership markers
16
16
  - **Keyboard overlay** - ALT+M or `/intercom` opens a session picker and compose overlay
17
17
  - **Attachments** - Share `file`, `snippet`, and `context` payloads between sessions
18
18
  - **Subagent escalation** - Delegated children get a `contact_supervisor` tool for decisions, structured interviews, and progress updates
@@ -119,14 +119,15 @@ See auth.ts:142-156.
119
119
 
120
120
  The reply hint (enabled by default) points to `intercom({ action: "reply", ... })`, so recipients never need raw sender or `replyTo` IDs. Idle recipients get a new turn immediately; busy interactive recipients receive the message once they go idle. Attachment content is included in the agent-visible body, and messages are rendered inline and stored in Atomic session history.
121
121
 
122
+ Atomic treats ordinary `intercom` as a mandatory runtime tool in main chat and every workflow model stage. Tool allowlists, exclusions, `noTools`, optional-extension restrictions, and reloads cannot unload or deactivate it. Restrictions on every other tool are unchanged, and `contact_supervisor` remains subagent-only. Tool registration is lightweight; broker connection and heavy initialization remain lazy until an Intercom surface is used.
123
+
122
124
  ## How Connection Works
123
125
 
124
- Intercom connections are normally tool-driven. Ordinary sessions and delegated children keep the lightweight wrapper unloaded until an Intercom tool, `/intercom`, or the ALT+M overlay is invoked. One exception is supervisor authorization: launching an Intercom-enabled subagent connects the parent runtime long enough to request a broker capability for that child; the child's own connection remains lazy until it invokes `contact_supervisor`. The parent restores issued capabilities across reconnects, and the child uses the broker-confirmed current supervisor ID. Concurrent callers share one import and connection attempt, and broker state is leased to the active session generation and cleaned up on shutdown or replacement.
126
+ Intercom connections are normally tool-driven. Ordinary sessions and delegated children load and register the lightweight wrapper at startup, while broker connection and heavy initialization wait until an Intercom tool, `/intercom`, or the ALT+M overlay is invoked. One exception is supervisor authorization: launching an Intercom-enabled subagent connects the parent runtime long enough to request a broker capability for that child; the child's own connection remains lazy until it invokes `contact_supervisor`. The parent restores issued capabilities across reconnects, and the child uses the broker-confirmed current supervisor ID. Concurrent callers share one import and connection attempt, and broker state is leased to the active session generation and cleaned up on shutdown or replacement.
125
127
 
126
128
  A session becomes intercom-connected when all of these are true:
127
129
 
128
- - the intercom extension is loaded in that session
129
- - `enabled` is not set to `false` in `~/.atomic/agent/intercom/config.json` (or the legacy `~/.pi/agent/intercom/config.json` fallback)
130
+ - the mandatory bundled Intercom extension is loaded in that Atomic model session
130
131
  - the model or user has invoked an Intercom surface in that session, **or** the parent runtime is authorizing an Intercom-enabled child supervisor relationship
131
132
  - the local broker is running or can be auto-started
132
133
 
@@ -138,33 +139,34 @@ Name sessions with `/name` so they can target each other (for example `/name pla
138
139
 
139
140
  | Parameter | Type | Description |
140
141
  |-----------|------|-------------|
141
- | `action` | string | `"list"`, `"join"`, `"leave"`, `"send"`, `"ask"`, `"reply"`, `"pending"`, or `"status"` |
142
+ | `action` | string | `"list"`, `"groups"`, `"join"`, `"leave"`, `"send"`, `"ask"`, `"reply"`, `"pending"`, or `"status"` |
142
143
  | `to` | string | Exact session name/full session ID, or `<runId>:<stageKey>` for `send` to a not-yet-started workflow stage (for send/ask, or targeted reply) |
143
144
  | `message` | string | Message text (for send/ask/reply) |
144
145
  | `attachments` | array | Optional `file`, `snippet`, or `context` attachments |
145
146
  | `replyTo` | string | Optional message ID for threading or replying to an `ask` |
146
- | `group` | string | Group name for `join`; read-only group filter for `list`/`status`. `send`/`ask` stay locked to the current group. |
147
+ | `group` | string | Group name for `join` or an optional targeted `leave`; read-only group filter for `list`/`status`. `send`/`ask` remain limited to shared memberships. |
147
148
 
148
149
  ### Actions
149
150
 
150
151
  | Action | Behavior |
151
152
  |--------|----------|
152
- | `join` | Moves the session into a trimmed named group and creates it if needed. The action waits for broker acknowledgement before changing local inheritance state. `default` is the shared group; `true` and `auto` are reserved for subagent auto-groups. |
153
- | `leave` | Returns the session to its resolved home group from startup. It takes no `group` parameter. |
154
- | `list` | Returns the current session plus other active intercom-connected sessions with name, full session ID, working directory, model, and live status (`idle`, `thinking`, or `tool:<name>`, derived from lifecycle events). Every displayed full session ID is a valid target. |
153
+ | `join` | Adds a trimmed named group membership and creates the group if needed. The action waits for broker acknowledgement and reports the complete resulting membership set. `default` is shared; `true` and `auto` are reserved for subagent auto-groups. |
154
+ | `leave` | With `group`, removes only that membership and keeps all others. Without `group`, resets the session to its resolved startup home group. Both forms report the resulting membership set. |
155
+ | `groups` | Lists every group represented by a connected session, with its session count and a marker for each group this session belongs to. Use it to discover names rather than guessing. |
156
+ | `list` | Keeps session-listing semantics: returns the current session plus every active session sharing at least one membership, with name, full session ID, working directory, model, and live status. Pass `group` for a read-only view of one group. |
155
157
  | `send` | Fire-and-forget delivery through ordinary Intercom. A live workflow-stage session receives the message immediately and returns `delivered`. A known workflow stage whose session has not initialized is addressed as `<runId>:<stageKey>`; Atomic persists the message and returns the distinct `queued` result with its FIFO position. Unknown stage identities retain the ordinary unknown-target failure. Requires `to` and `message`; cannot message the current session. |
156
158
  | `ask` | Sends a message and blocks until a live recipient replies (10-minute timeout). An ask to a known workflow stage whose session has not initialized is refused with `pending_stage_ask_unsupported` and recommends ordinary `send`; holding a waiter until a stage eventually starts would be unbounded. A live recipient disconnect fails promptly. From a foreground child to its launching parent, the existing fresh-subagent handoff path remains unchanged. |
157
159
  | `reply` | Replies to the intercom-triggered message of the current turn; otherwise falls back to the single unresolved inbound ask. With multiple pending asks, pass `to` or inspect with `pending` first. |
158
160
  | `pending` | Lists unresolved inbound asks with sender, message ID, elapsed time, and a short preview. |
159
- | `status` | Shows connection status, session ID, current group, and the count of active sessions in that group. A `group` filter remains a read-only peek. |
161
+ | `status` | Shows connection status, session ID, every group this session belongs to, and the count of active sessions visible through those memberships. A `group` filter remains a read-only peek. |
160
162
 
161
- To put two plain chat sessions in a private named group, have both call:
163
+ To give two plain chat sessions a private shared membership, have both call:
162
164
 
163
165
  ```typescript
164
166
  intercom({ action: "join", group: "api-review" })
165
167
  ```
166
168
 
167
- The broker updates presence in place and sends a `session_left` event to the old group and a `session_joined` event to the new one. Session IDs do not change. A session that stays in `default` cannot list, resolve, or message the joined peers. Use `intercom({ action: "leave" })` to return to the home group resolved at startup; rejected or unacknowledged changes leave the local membership state unchanged. Joining a group does not widen isolation; `contact_supervisor` remains the only capability-based cross-group path.
169
+ Joining is additive: existing memberships remain active, and the broker updates presence without changing the session ID. Use `intercom({ action: "groups" })` to discover all available names and membership markers. `intercom({ action: "leave", group: "api-review" })` removes only that membership; `intercom({ action: "leave" })` resets to the home group resolved at startup. Rejected or unacknowledged changes leave client and inheritance state unchanged. Ordinary delivery requires a shared membership, while `contact_supervisor` retains its capability-based cross-group path.
168
170
 
169
171
  Sent and received messages are recorded in session history as `intercom_sent` / `intercom_received` entries.
170
172
 
@@ -172,6 +174,8 @@ Sent and received messages are recorded in session history as `intercom_sent` /
172
174
 
173
175
  Live-session lookup accepts only an exact full session ID or an exact case-insensitive session name. Ordinary `send` also accepts the exact `<runId>:<stageKey>` identity of a known workflow stage whose session has not initialized. The run ID is the full UUID, and the authored stage key is case-sensitive. Unknown runs and stages retain the ordinary unknown-target failure. Targeting is **group-scoped** — see [Groups](#groups) below.
174
176
 
177
+ Before steering a stage, join its invocation group. Use the Intercom `groups` action to discover it. Workflow invocation groups are named `workflow:<rootRunId>`.
178
+
175
179
  ### Deferred delivery to pending stages
176
180
 
177
181
  Send material updates through Intercom to every affected workflow stage, including stages that have not started. Atomic queues messages for known pending stages and delivers them when their sessions initialize. A deferred send returns `queued`, including its FIFO position, rather than claiming the message was `delivered`; live delivery remains immediate and returns `delivered`.
@@ -182,13 +186,16 @@ Only a session in the workflow run's Intercom group can queue a message; a cross
182
186
 
183
187
  ### Groups
184
188
 
185
- Every session belongs to exactly one intercom **group**. Sessions with no group configured share the implicit `"default"` group (so ungrouped sessions all see and message each other, exactly as before). A session in group G can **only** message sessions in group G cross-group sends are rejected by the broker, not merely hidden from discovery:
189
+ Every session belongs to a non-empty set of intercom **groups**. Sessions with no group configured retain exactly the legacy behavior: they belong only to the implicit `"default"` group and can see and message each other. A session can ordinarily discover, resolve, and message another session when their membership sets intersect; exact-ID sends with no shared membership are rejected by the broker.
190
+
191
+ - `list` still lists sessions. Without a filter it returns the union of sessions visible through any of your memberships; with `group`, it gives a read-only view of that one group.
192
+ - `groups` lists every currently available group, its connected-session count, and whether this session is a member.
193
+ - `join` adds one membership. `leave` removes the named membership, while bare `leave` resets the complete set to the startup home group.
194
+ - `status` reports the complete membership set. `session_joined`/`session_left`/`presence_update` events are delivered whenever a membership change affects visibility.
186
195
 
187
- - A cross-group target name is unresolvable (`list`/targeting only consider your own group), and a cross-group send by exact session ID is rejected with `"Target session is in a different intercom group"`.
188
- - `list`/`status` show your own group and only same-group peers. Pass `group: "name"` to `list`/`status` for a **read-only** peek at another group's membership. `send`/`ask` are always locked to your own group and error if you pass a different `group`.
189
- - `session_joined`/`session_left`/`presence_update` are group-scoped, so you never see peers outside your group appear or disappear.
196
+ A session's home group is resolved with this precedence: explicit stage/task/subagent group > runtime-owned workflow invocation group or inherited launching-session group > env `ATOMIC_INTERCOM_GROUP` (legacy `PI_INTERCOM_GROUP`) > Intercom `config.json` `"group"` > `"default"`. Each top-level workflow invocation gets a stable non-default group from its persistent run identity; Intercom-capable stages, nested workflows, and their delegated subagents inherit it without authors threading IDs. Explicit `group: "default"` opts into the shared group. Boolean `true` and the trimmed, case-insensitive strings `"true"`/`"auto"` request an automatically generated subgroup; those string names are reserved. Stages and children without Intercom access receive no group. See [workflows.md](/workflows) for workflow-stage rules. The subagent-only `contact_supervisor` path remains capability-based and can cross group boundaries; ordinary `send`, `ask`, and replies cannot use it as a bypass.
190
197
 
191
- A session's home group is resolved with this precedence: explicit stage/task/subagent group > runtime-owned workflow invocation group or inherited launching-session group > env `ATOMIC_INTERCOM_GROUP` (legacy `PI_INTERCOM_GROUP`) > Intercom `config.json` `"group"` > `"default"`. Each top-level workflow invocation gets a stable non-default group from its persistent run identity; Intercom-capable stages, nested workflows, and their delegated subagents inherit it without authors threading IDs. Explicit `group: "default"` opts back into the shared group. Boolean `true` and the trimmed, case-insensitive strings `"true"`/`"auto"` request an automatically generated subgroup; those string names are reserved. Stages and children without Intercom access receive no group. See [workflows.md](/workflows) for workflow-stage rules. The subagent-only `contact_supervisor` path can cross groups only after a broker capability binds the registered child socket to the issuing supervisor session. The broker, not the client, marks validated traffic as `supervisor`; ordinary `send` frames remain isolated even if a raw client forges that flag, and replies cross back only through an exact broker-recorded `replyTo` match. Parent-held authorization state is restored after broker reconnects. Before an Intercom-enabled foreground child first runs, the parent wrapper may lazy-load and connect the broker provider to mint that exact child's capability; queued children request no capability. The child still connects only when it uses an Intercom delivery path, and claimed decisions or interviews terminally hand off before child send or waiter admission. A claimed provider failure aborts launch, while runtimes with no provider omit supervisor metadata and do not expose a broken channel.
198
+ The broker, not the client, marks validated supervisor traffic. Ordinary `send` frames remain membership-isolated even if a raw client forges a supervisor marker, and replies cross back only through an exact broker-recorded `replyTo` match. Parent-held authorization state is restored after reconnects. Before an Intercom-enabled foreground child first runs, the parent wrapper may lazy-load and connect the broker provider to mint that exact child's capability; queued children request no capability. The child still connects only when it uses an Intercom delivery path, and claimed decisions or interviews terminally hand off before child send or waiter admission. A claimed provider failure aborts launch, while runtimes with no provider omit supervisor metadata and do not expose a broken channel.
192
199
 
193
200
  ### send vs ask vs reply
194
201
 
@@ -381,9 +388,9 @@ The `subagent` tool's `control` options select which control events notify the p
381
388
  - **`notifyOn`** — defaults to `["active_long_running", "needs_attention"]`
382
389
  - **`notifyChannels`** — defaults to `["event", "intercom"]` (all that are available)
383
390
 
384
- Detached subagent result delivery over Intercom is confirmation-based and preserves a successful delivery phase across watcher replacement. Each delegated child gets a deterministic Intercom target derived from its run/agent/index identity, and run results report those targets ("Run intercom target" / "Previous intercom target"; targets may be inactive after completion). `intercom({ action: "status" })` reports connection state and the resolved group for the current session.
391
+ Detached subagent result delivery over Intercom is confirmation-based and preserves a successful delivery phase across watcher replacement. Each delegated child gets a deterministic Intercom target derived from its run/agent/index identity, and run results report those targets ("Run intercom target" / "Previous intercom target"; targets may be inactive after completion). `intercom({ action: "status" })` reports connection state and every membership for the current session.
385
392
 
386
- If live peer coordination is needed, invoke `intercom({ action: "status" })` in the parent before launching; the child connects on its first ordinary Intercom call. A claimed `contact_supervisor` decision or interview can yield before child broker connection because typed admission already identifies the launching parent. Fresh child sessions receive the bundled Intercom wrapper through normal package discovery unless an explicit `extensions` allowlist excludes it.
393
+ If live peer coordination is needed, invoke `intercom({ action: "status" })` in the parent before launching; the child connects on its first ordinary Intercom call. A claimed `contact_supervisor` decision or interview can yield before child broker connection because typed admission already identifies the launching parent. Fresh child sessions always receive the mandatory bundled Intercom wrapper, including when an explicit `extensions` allowlist is empty or omits it.
387
394
 
388
395
  ### Delivery Ordering
389
396
 
@@ -400,7 +407,6 @@ Create `~/.atomic/agent/intercom/config.json`. The legacy `~/.pi/agent/intercom/
400
407
  "brokerCommand": "npx",
401
408
  "brokerArgs": ["--no-install", "tsx"],
402
409
  "confirmSend": false,
403
- "enabled": true,
404
410
  "replyHint": true,
405
411
  "status": "researching",
406
412
  "group": "default"
@@ -412,7 +418,6 @@ Create `~/.atomic/agent/intercom/config.json`. The legacy `~/.pi/agent/intercom/
412
418
  | `brokerCommand` | `"npx"` | Command used to start the local broker process; the default sentinel is hardened internally to avoid PATH lookup |
413
419
  | `brokerArgs` | `["--no-install", "tsx"]` | Arguments passed to `brokerCommand` before the broker script path |
414
420
  | `confirmSend` | `false` | Show a confirmation dialog before non-reply sends from an interactive session with UI |
415
- | `enabled` | `true` | Enable/disable intercom entirely |
416
421
  | `replyHint` | `true` | Include reply instruction in incoming messages |
417
422
  | `status` | — | Optional custom status suffix shown after the automatic lifecycle status, for example `thinking · researching` |
418
423
  | `group` | `"default"` | Home intercom group for this session (see [Groups](#groups)). Overridden by env `ATOMIC_INTERCOM_GROUP` / `PI_INTERCOM_GROUP` and by workflow/orchestrator per-session injection. |
@@ -465,7 +470,7 @@ graph TB
465
470
  B2 <-->|Local Socket/Pipe| B3
466
471
  ```
467
472
 
468
- The broker is a standalone process that manages session registration and message routing. It auto-spawns when the first intercom-enabled session needs it and exits 5 seconds after the last connected session disconnects; clients reconnect automatically if the broker restarts. A spawn lock keyed by PID and timestamp prevents duplicate brokers when multiple sessions start at once.
473
+ The broker is a standalone process that manages session registration and message routing. It auto-spawns when the first session that invokes Intercom needs it and exits 5 seconds after the last connected session disconnects; clients reconnect automatically if the broker restarts. A spawn lock keyed by PID and timestamp prevents duplicate brokers when multiple sessions start at once.
469
474
 
470
475
  Transport is local IPC only — a Unix domain socket on macOS/Linux or a named pipe on Windows — using length-prefixed JSON (4-byte length + payload) with request correlation for session listing, explicit delivery failures, and validation of malformed or out-of-order messages. `ask` stays client-side: the broker routes plain messages, and the client waits for the matching reply before returning it as the tool result.
471
476
 
@@ -84,10 +84,10 @@ The dedicated history actions always change history entries, regardless of the c
84
84
 
85
85
  ### TUI Fullscreen Viewport
86
86
 
87
- Interactive sessions always use this fullscreen viewport for the primary transcript scroll region. Mouse-wheel input scrolls the region under the pointer, falling back to the transcript over the fixed editor/status/footer dock. Clicking an OSC 8 hyperlink opens it in the default handler; the jump-to-bottom indicator's internal OSC 8 link returns the focused transcript surface to its live end, including an attached workflow stage chat. Dragging with the primary mouse button selects text and copies it to the clipboard. See [Terminal setup](/terminal-setup) for terminal-specific mouse and trackpad behavior.
87
+ Interactive sessions always use this fullscreen viewport for the primary transcript scroll region. Mouse-wheel input scrolls the region under the pointer, falling back to the transcript over the fixed editor/status/footer dock. Clicking an OSC 8 hyperlink opens it in the default handler; the jump-to-bottom indicator's internal OSC 8 link returns the focused transcript surface to its live end, including an attached workflow stage chat. Dragging with the primary mouse button selects text and, by default, copies it to the clipboard. Set `fullscreenCopyOnSelect` to `false` to retain selections for explicit Ctrl+X copying. See [Terminal setup](/terminal-setup) for terminal-specific mouse and trackpad behavior.
88
88
 
89
89
 
90
- Fullscreen text selection comes from the installed pi-tui 0.84.3 renderer. Drag with the primary button to select characters; double-click selects a word and triple-click selects a line. Focus changes and non-drag clicks clear transient selection state, preventing a stale highlight from appearing. A drag release reported with the generic SGR button code also ends the selection. The renderer also reduces mouse tracking in tmux, Zellij, and GNU Screen.
90
+ Fullscreen text selection comes from the installed pi-tui 0.84.4 renderer. Drag with the primary button to select characters; double-click selects a word, including complete slash-delimited paths and kebab-case names, and triple-click selects a line. Focus changes and non-drag clicks clear transient selection state, preventing a stale highlight from appearing. A drag release reported with the generic SGR button code also ends the selection. The renderer also reduces mouse tracking in tmux, Zellij, and GNU Screen.
91
91
  Fullscreen transcript bindings take precedence over editor bindings while the main editor has focus. The default unmodified navigation keys therefore control the transcript, while their `ctrl` variants continue to control the editor. When a fullscreen overlay or inline custom component has focus, Atomic sends matching viewport bindings to that component first. Returning `true` keeps the key local. For an in-process component, returning `false`, `undefined`, or `void` lets transcript scrolling handle it. A remote component's correlated reply falls through on `false`, failure, or timeout; `undefined` after disposal is dropped because that component no longer owns focus.
92
92
 
93
93
  | Key | Editor action | Fullscreen action |
@@ -128,6 +128,7 @@ On Windows, pressing the secondary mouse button in fullscreen pastes text from t
128
128
  | `app.suspend` | `ctrl+z` (none on Windows) | Suspend to background |
129
129
  | `app.editor.external` | `ctrl+g` | Open in external editor (`$VISUAL` or `$EDITOR`) |
130
130
  | `app.clipboard.pasteImage` | `ctrl+v` (`alt+v` on Windows) | Paste image or text from clipboard |
131
+ | `app.message.copy` | `ctrl+x` | When `fullscreenCopyOnSelect` is `false`, copy the active fullscreen selection; otherwise copy the last assistant message |
131
132
 
132
133
  When `app.clipboard.pasteImage` finds text rather than an image, Atomic inserts that clipboard text into the editor instead of reporting an image-paste failure.
133
134
 
@@ -137,6 +138,8 @@ Inside tmux on macOS, `Ctrl+V` is the reliable image-paste shortcut; native `Cmd
137
138
 
138
139
  When the clipboard has both text and an image, behavior depends on the terminal: empty-paste terminals may insert the text on `Cmd+V`, while Kitty-protocol terminals that deliver `super+v` go through the image path (same preference as `Ctrl+V`). `Ctrl+V` always prefers the image. Apple Terminal may send nothing for image-only paste; use Ghostty/iTerm/Kitty or `Ctrl+V` in that case.
139
140
 
141
+ Ctrl+X keeps Atomic's hierarchy precedence. A workflow tool-detail view closes to its graph; the scoped-model selector clears its local selection; an attached workflow stage chat returns to its graph; and a workflow graph returns to main chat. Only the main editor then runs `app.message.copy`. Workflow surfaces recognize the physical Ctrl+X chord directly, including CSI variants, rather than the configurable application action. `/copy` is separate and always copies the last assistant message.
142
+
140
143
  A held paused queue by itself is idle for Ctrl+C handling. After an interruption settles, the next Ctrl+C clears the editor without releasing or dequeuing the hold, and a second quick idle press exits normally.
141
144
 
142
145
  In interactive sessions the agent runs in a supervised engine child (see [Extensions](/extensions#interactive-callback-isolation)). Escape there requests the engine's cooperative cancellation and waits for it with no deadline; it never terminates or replaces the engine.
package/docs/packages.md CHANGED
@@ -177,7 +177,7 @@ If no app manifest (`atomic`, or legacy `pi`) is present, Atomic auto-discovers
177
177
  - `skills/` recursively finds `SKILL.md` folders and loads top-level `.md` files as skills
178
178
  - `prompts/` loads `.md` files
179
179
  - `themes/` loads `.json` files
180
- - `workflows/` loads workflow SDK files (`.ts`, `.js`, `.mjs`, `.cjs`); `workflow/` is also accepted as a singular alias. Workflow files import `workflow` from `@bastani/atomic/workflows`, import `Type` from `typebox`, and export the definition returned by `workflow({ ... })`. TypeScript resolves the published `@bastani/atomic/workflows` specifier through the `@bastani/atomic` package. Atomic resolves that workflow specifier to its in-memory SDK when it loads the workflow at runtime. See Programmatic Usage in the workflows guide.
180
+ - `workflows/` loads workflow SDK files (`.ts`, `.js`, `.mjs`, `.cjs`); `workflow/` is also accepted as a singular alias. Workflow files import `workflow` from `@bastani/atomic/workflows`, import `Type` from `typebox`, and export the definition returned by `workflow({ ... })`. TypeScript resolves the published `@bastani/atomic/workflows` specifier through the `@bastani/atomic` package. Atomic resolves that workflow specifier and the supported TypeBox root, `typebox/compile`, `typebox/value`, and legacy `@sinclair/typebox` aliases to in-memory host modules when it loads the workflow at runtime. See Programmatic Usage in the workflows guide.
181
181
 
182
182
  When a package manifest exists, declared resource arrays normally define what loads. Workflows are the exception: if `atomic.workflows` / legacy `pi.workflows` is omitted, Atomic still checks conventional `workflows/` and `workflow/` directories.
183
183
 
package/docs/providers.md CHANGED
@@ -56,7 +56,7 @@ Run `/fast` in interactive mode to configure fast mode separately for normal cha
56
56
  - OpenAI `openai/*` and `openai-codex/*` models use the priority service tier. A resolved provider alias also qualifies when it uses the shared `openai-codex-responses` transport.
57
57
  - GitHub Copilot models qualify when the OAuth model catalog for the signed-in account advertises a fast variant. Atomic uses that variant only for the outgoing request, so it does not appear as a separate choice in `/model`. Copilot fast mode requires the account catalog metadata obtained through `/login`; a raw `COPILOT_GITHUB_TOKEN` does not provide that metadata.
58
58
 
59
- Workflow stages, nested `ctx.workflow(...)` stages, and subagents launched by those stages use the workflow setting, not the chat setting. Atomic checks each fallback, retry, compaction-planner, and branch-summary request against its effective model. An eligible fallback uses fast mode, while an unsupported model keeps its normal request behavior. The UI appends `fast` after the model name in the chat footer, workflow stage model labels, and stage-launched subagent results. Fast mode does not apply to Azure OpenAI, OpenRouter, or generic OpenAI-compatible providers. Enable it deliberately for workflows because parallel fan-out can multiply provider usage.
59
+ Main-chat subagents use the chat setting; workflow stages, nested `ctx.workflow(...)` stages, and subagents launched by those stages use the workflow setting. Atomic checks each fallback, retry, compaction-planner, and branch-summary request against its effective model. An eligible fallback uses fast mode, while an unsupported model keeps its normal request behavior. The UI appends `fast` after the base model name in the chat footer, workflow stage model labels, and both main-chat and stage-launched subagent results. For an entitled Copilot child, that marker appears exactly when the outgoing request uses the account-advertised `<model-id>-fast` variant; OpenAI children instead use `service_tier: priority`. Fast mode does not apply to Azure OpenAI, OpenRouter, or generic OpenAI-compatible providers. Enable it deliberately for workflows because parallel fan-out can multiply provider usage.
60
60
 
61
61
  For the shared ChatGPT Codex transport, Atomic sends the fast routing contract only after the final request payload contains `service_tier: priority`: `originator: codex_cli_rs` plus `x-codex-routing-hint: model=<effective-model>;tier=priority` on both HTTP/SSE and WebSocket transports. The same rule covers the stock provider, renamed providers, credential-resolved endpoints, and monitoring proxies that retain `api: "openai-codex-responses"`. WebSocket fallback, reconnect, and HTTP retry attempts reuse that identity; a final model or tier change drops a cached socket before reuse. Requests to the standard OpenAI API send only the tier. When fast mode is off, or a request hook changes the final tier away from `priority`, Atomic keeps the normal `originator: pi` identity and sends no routing hint.
62
62
 
@@ -162,7 +162,7 @@ Remote pi.dev catalogs persist their ETag and are revalidated with `If-None-Matc
162
162
  | Xiaomi MiMo Token Plan (Amsterdam) | `XIAOMI_TOKEN_PLAN_AMS_API_KEY` | `xiaomi-token-plan-ams` |
163
163
  | Xiaomi MiMo Token Plan (Singapore) | `XIAOMI_TOKEN_PLAN_SGP_API_KEY` | `xiaomi-token-plan-sgp` |
164
164
 
165
- Z.AI and Z.AI Coding Plan (China) default to `glm-5.3` (`zai/glm-5.3` and `zai-coding-cn/glm-5.3`); the generated catalogs expose reasoning without a thinking-level map, so built-in chains use the supported `:high` suffix rather than inventing distinct `:xhigh` or `:max` tiers. OpenRouter currently exposes `z-ai/glm-5.2` but not `z-ai/glm-5.3`, so Atomic does not ship an unavailable OpenRouter GLM-5.3 fallback. Baseten also has no GLM-5.3 catalog entry, so its documented default remains `zai-org/GLM-5.2` and its catalog supplies the provider-specific thinking levels. Qwen Token Plan Individual defaults to `qwen3.8-max` and uses the international `QWEN_TOKEN_PLAN_API_KEY` shared with the existing Qwen Token Plan provider.
165
+ Z.AI and Z.AI Coding Plan (China) default to `glm-5.3` (`zai/glm-5.3` and `zai-coding-cn/glm-5.3`), and both direct providers also expose the multimodal `glm-5.3-flash`. Baseten defaults to its directly selectable `zai-org/GLM-5.3`; OpenRouter exposes `z-ai/glm-5.3`, and both mirrors expose the multimodal Flash variant (`zai-org/GLM-5.3-Flash` on Baseten and `z-ai/glm-5.3-flash` on OpenRouter). Every full and Flash entry supports `low`, `high`, and `max` reasoning, and built-in workflow and subagent chains include all four provider routes at `:high`. Use Baseten's `zai-org/GLM-5.2` when fully disabled reasoning is required. Qwen Token Plan Individual defaults to `qwen3.8-max` and uses the international `QWEN_TOKEN_PLAN_API_KEY` shared with the existing Qwen Token Plan provider.
166
166
 
167
167
  Reference for environment variables and `auth.json` keys: `findEnvKeys()` / `getEnvApiKey()` in the installed `@bastani/pi-ai` dependency (`node_modules/@bastani/pi-ai/dist/env-api-keys.d.ts`). The private provider map those functions use is in `node_modules/@bastani/pi-ai/dist/env-api-keys.js`; Atomic does not include a separate `packages/ai` source directory in this monorepo.
168
168