@bastani/atomic 0.9.20-alpha.6 → 0.9.20-alpha.8

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 (182) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/builtin/intercom/package.json +2 -2
  3. package/dist/builtin/mcp/package.json +2 -2
  4. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  5. package/dist/builtin/subagents/package.json +3 -3
  6. package/dist/builtin/subagents/src/extension/index.bundle.mjs +18 -8
  7. package/dist/builtin/web-access/package.json +2 -2
  8. package/dist/builtin/workflows/CHANGELOG.md +27 -0
  9. package/dist/builtin/workflows/README.md +5 -19
  10. package/dist/builtin/workflows/builtin/{chunk-deq63d9p.js → chunk-7bzcersz.js} +30 -19
  11. package/dist/builtin/workflows/builtin/goal.js +1 -1
  12. package/dist/builtin/workflows/builtin/index.js +1 -1
  13. package/dist/builtin/workflows/package.json +2 -2
  14. package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +10 -9
  15. package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +4 -4
  16. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +96 -23
  17. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +75 -27
  18. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +72 -26
  19. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +58 -22
  20. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +118 -0
  21. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +70 -29
  22. package/dist/builtin/workflows/skills/prompt-engineer/references/core_prompting.md +1 -1
  23. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +95 -32
  24. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +79 -30
  25. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +139 -0
  26. package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +4 -4
  27. package/dist/builtin/workflows/src/extension/index.bundle.mjs +389 -719
  28. package/dist/builtin/workflows/src/index.js +17 -7
  29. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  30. package/dist/core/agent-session-message-queue.js +3 -1
  31. package/dist/core/agent-session-message-queue.js.map +1 -1
  32. package/dist/core/agent-session-methods.d.ts +3 -0
  33. package/dist/core/agent-session-methods.d.ts.map +1 -1
  34. package/dist/core/agent-session-methods.js.map +1 -1
  35. package/dist/core/agent-session-runtime.d.ts +4 -0
  36. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  37. package/dist/core/agent-session-runtime.js +6 -0
  38. package/dist/core/agent-session-runtime.js.map +1 -1
  39. package/dist/core/agent-session-tasks.d.ts +9 -0
  40. package/dist/core/agent-session-tasks.d.ts.map +1 -1
  41. package/dist/core/agent-session-tasks.js +68 -16
  42. package/dist/core/agent-session-tasks.js.map +1 -1
  43. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  44. package/dist/core/agent-session-tool-registry.js +9 -21
  45. package/dist/core/agent-session-tool-registry.js.map +1 -1
  46. package/dist/core/agent-session-types.d.ts +2 -0
  47. package/dist/core/agent-session-types.d.ts.map +1 -1
  48. package/dist/core/agent-session-types.js.map +1 -1
  49. package/dist/core/agent-session.d.ts +3 -0
  50. package/dist/core/agent-session.d.ts.map +1 -1
  51. package/dist/core/agent-session.js +5 -2
  52. package/dist/core/agent-session.js.map +1 -1
  53. package/dist/core/execution-model-router.d.ts +14 -0
  54. package/dist/core/execution-model-router.d.ts.map +1 -1
  55. package/dist/core/execution-model-router.js +67 -21
  56. package/dist/core/execution-model-router.js.map +1 -1
  57. package/dist/core/fast-model-variants.d.ts +26 -0
  58. package/dist/core/fast-model-variants.d.ts.map +1 -1
  59. package/dist/core/fast-model-variants.js +40 -1
  60. package/dist/core/fast-model-variants.js.map +1 -1
  61. package/dist/core/model-runtime.d.ts +13 -1
  62. package/dist/core/model-runtime.d.ts.map +1 -1
  63. package/dist/core/model-runtime.js +16 -1
  64. package/dist/core/model-runtime.js.map +1 -1
  65. package/dist/core/sdk-types.d.ts +5 -0
  66. package/dist/core/sdk-types.d.ts.map +1 -1
  67. package/dist/core/sdk-types.js.map +1 -1
  68. package/dist/core/sdk.d.ts.map +1 -1
  69. package/dist/core/sdk.js +4 -0
  70. package/dist/core/sdk.js.map +1 -1
  71. package/dist/core/settings-types.js.map +1 -1
  72. package/dist/core/skill-catalog.d.ts.map +1 -1
  73. package/dist/core/skill-catalog.js +18 -6
  74. package/dist/core/skill-catalog.js.map +1 -1
  75. package/dist/core/structured-output/index.d.ts +1 -0
  76. package/dist/core/structured-output/index.d.ts.map +1 -1
  77. package/dist/core/structured-output/index.js +34 -26
  78. package/dist/core/structured-output/index.js.map +1 -1
  79. package/dist/core/structured-output/jev-client.d.ts +9 -0
  80. package/dist/core/structured-output/jev-client.d.ts.map +1 -1
  81. package/dist/core/structured-output/jev-client.js +57 -3
  82. package/dist/core/structured-output/jev-client.js.map +1 -1
  83. package/dist/core/structured-output/jev.d.ts.map +1 -1
  84. package/dist/core/structured-output/jev.js +35 -53
  85. package/dist/core/structured-output/jev.js.map +1 -1
  86. package/dist/core/structured-output/resolver.d.ts +32 -24
  87. package/dist/core/structured-output/resolver.d.ts.map +1 -1
  88. package/dist/core/structured-output/resolver.js +57 -9
  89. package/dist/core/structured-output/resolver.js.map +1 -1
  90. package/dist/core/structured-output/types.d.ts +8 -4
  91. package/dist/core/structured-output/types.d.ts.map +1 -1
  92. package/dist/core/structured-output/types.js.map +1 -1
  93. package/dist/core/tasks/child-command-owner.d.ts +34 -0
  94. package/dist/core/tasks/child-command-owner.d.ts.map +1 -0
  95. package/dist/core/tasks/child-command-owner.js +70 -0
  96. package/dist/core/tasks/child-command-owner.js.map +1 -0
  97. package/dist/core/tools/bash-pty-native.d.ts +5 -1
  98. package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
  99. package/dist/core/tools/bash-pty-native.js +15 -7
  100. package/dist/core/tools/bash-pty-native.js.map +1 -1
  101. package/dist/core/tools/bash.d.ts.map +1 -1
  102. package/dist/core/tools/bash.js +15 -13
  103. package/dist/core/tools/bash.js.map +1 -1
  104. package/dist/core/tools/kill.d.ts +2 -2
  105. package/dist/core/tools/kill.d.ts.map +1 -1
  106. package/dist/core/tools/kill.js +3 -4
  107. package/dist/core/tools/kill.js.map +1 -1
  108. package/dist/index.d.ts +3 -3
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +2 -2
  111. package/dist/index.js.map +1 -1
  112. package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
  113. package/dist/modes/interactive/components/atomic-banner.js +3 -2
  114. package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
  115. package/dist/modes/interactive/components/startup-identity.d.ts +3 -0
  116. package/dist/modes/interactive/components/startup-identity.d.ts.map +1 -1
  117. package/dist/modes/interactive/components/startup-identity.js +11 -2
  118. package/dist/modes/interactive/components/startup-identity.js.map +1 -1
  119. package/dist/modes/interactive/interactive-auth-login.js +2 -4
  120. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  121. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  122. package/dist/modes/interactive/interactive-tui.js +2 -0
  123. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  124. package/dist/modes/interactive/overlay-line-composite.d.ts +7 -0
  125. package/dist/modes/interactive/overlay-line-composite.d.ts.map +1 -0
  126. package/dist/modes/interactive/overlay-line-composite.js +24 -0
  127. package/dist/modes/interactive/overlay-line-composite.js.map +1 -0
  128. package/dist/modes/interactive-engine/isolated-auth.d.ts +16 -0
  129. package/dist/modes/interactive-engine/isolated-auth.d.ts.map +1 -1
  130. package/dist/modes/interactive-engine/isolated-auth.js +27 -0
  131. package/dist/modes/interactive-engine/isolated-auth.js.map +1 -1
  132. package/dist/modes/interactive-engine/isolated-runtime.d.ts +4 -0
  133. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  134. package/dist/modes/interactive-engine/isolated-runtime.js +4 -1
  135. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  136. package/dist/modes/rpc/rpc-client-api.d.ts +2 -1
  137. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  138. package/dist/modes/rpc/rpc-client-api.js +7 -2
  139. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  140. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  141. package/dist/modes/rpc/rpc-command-handler.js +3 -1
  142. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  143. package/dist/modes/rpc/rpc-provider-auth.d.ts +2 -1
  144. package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -1
  145. package/dist/modes/rpc/rpc-provider-auth.js +2 -2
  146. package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
  147. package/dist/modes/rpc/rpc-types.d.ts +2 -0
  148. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  149. package/dist/modes/rpc/rpc-types.js.map +1 -1
  150. package/dist/utils/child-process.d.ts +1 -0
  151. package/dist/utils/child-process.d.ts.map +1 -1
  152. package/dist/utils/child-process.js +7 -8
  153. package/dist/utils/child-process.js.map +1 -1
  154. package/dist/utils/shell.d.ts.map +1 -1
  155. package/dist/utils/shell.js +18 -1
  156. package/dist/utils/shell.js.map +1 -1
  157. package/docs/background-tasks.md +11 -2
  158. package/docs/environment-variables.md +1 -1
  159. package/docs/getting-started/first-session.md +2 -2
  160. package/docs/llama-cpp.md +2 -2
  161. package/docs/models/evals.md +47 -43
  162. package/docs/models/reference.md +1 -1
  163. package/docs/providers.md +14 -4
  164. package/docs/reference/cli.md +2 -2
  165. package/docs/rpc/examples.md +2 -0
  166. package/docs/sdk/reference.md +1 -1
  167. package/docs/sdk/structured-decisions.md +20 -14
  168. package/docs/settings.md +8 -8
  169. package/docs/skills.md +5 -1
  170. package/docs/subagents/reference.md +2 -2
  171. package/docs/subagents.md +1 -1
  172. package/docs/workflows/api-reference.md +5 -34
  173. package/docs/workflows/builtins.md +1 -1
  174. package/docs/workflows/operations.md +11 -77
  175. package/docs/workflows/reliable-design.md +14 -29
  176. package/docs/workflows.md +8 -7
  177. package/examples/rpc-client.ts +38 -0
  178. package/examples/rpc-extension-ui.ts +19 -5
  179. package/examples/sdk/README.md +1 -1
  180. package/npm-shrinkwrap.json +65 -65
  181. package/package.json +7 -7
  182. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_astra.md +0 -58
@@ -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,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AA4DzC,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,G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E,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.js\";\nimport { isLifecycleTimingEnabled, markLifecycleTiming } from \"../../core/lifecycle-timings.ts\";\nimport { copyToClipboard } from \"../../utils/clipboard.ts\";\nimport { openBrowser } from \"../../utils/open-browser.ts\";\nimport { keyDisplayText } from \"./components/keybinding-hints.js\";\nimport { TRANSCRIPT_JUMP_TO_END_URL } from \"./components/transcript-follow-indicator.ts\";\nimport { theme } from \"./theme/theme.js\";\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 TuiAltScreenScrollToEndIndicatorInternals {\n\thandleScrollToEndIndicatorMouseEvent(event: unknown): boolean;\n}\n\n/** pi-tui 0.85.1's private copy route only understands boolean callbacks. */\ninterface TuiAltScreenClipboardInternals {\n\tcopyTextToClipboard(text: string): Promise<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; return true on success, false or a diagnostic on failure.\n\t * Defaults to Atomic's clipboard implementation and platform diagnostics.\n\t */\n\tcopySelection?: (text: string) => Promise<boolean | string>;\n}\n\n/** The default selection-copy route: Atomic's host clipboard write. */\nasync function copySelectionToHostClipboard(text: string): Promise<boolean | string> {\n\ttry {\n\t\tawait copyToClipboard(text);\n\t\treturn true;\n\t} catch (error) {\n\t\treturn error instanceof Error ? error.message : String(error);\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\ninterface ParsedMouseSequence {\n\treadonly data: string;\n\treadonly button: number;\n\treadonly x: number;\n\treadonly y: 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({\n\t\t\t\tdata: sequence,\n\t\t\t\tbutton: Number.parseInt(sgr[1]!, 10),\n\t\t\t\tx: Number.parseInt(sgr[2]!, 10) - 1,\n\t\t\t\ty: Number.parseInt(sgr[3]!, 10) - 1,\n\t\t\t\tisRelease: sgr[4] === \"m\",\n\t\t\t});\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({\n\t\t\t\tdata: sequence,\n\t\t\t\tbutton: sequence.charCodeAt(3) - 32,\n\t\t\t\tx: sequence.charCodeAt(4) - 33,\n\t\t\t\ty: sequence.charCodeAt(5) - 33,\n\t\t\t\tisRelease: false,\n\t\t\t});\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\tcopySelection: NonNullable<InteractiveTuiOptions[\"copySelection\"]> = copySelectionToHostClipboard,\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// Adapt the private route rather than returning a truthy error string to\n\t\t// pi-tui 0.85.1. Both keyboard and mouse selection use this same door.\n\t\tconst clipboardRoute = this as unknown as TuiAltScreenClipboardInternals;\n\t\tclipboardRoute.copyTextToClipboard = async (text) => {\n\t\t\tconst result = await copySelection(text);\n\t\t\tconst copied = result === true;\n\t\t\tthis.flash(\n\t\t\t\tcopied ? \"Copied!\" : typeof result === \"string\" ? result : \"Copy failed\",\n\t\t\t\tcopied ? undefined : 5000,\n\t\t\t);\n\t\t\treturn copied;\n\t\t};\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\n\t\t// pi-tui 0.85 owns the jump-to-end indicator, but its hit test runs before Atomic's\n\t\t// focused-overlay input gate. Let the gate offer that press to the overlay first.\n\t\tconst indicator = this as unknown as TuiAltScreenScrollToEndIndicatorInternals;\n\t\tconst handleScrollToEndIndicator = indicator.handleScrollToEndIndicatorMouseEvent.bind(this);\n\t\tindicator.handleScrollToEndIndicatorMouseEvent = (event) =>\n\t\t\tthis.isFocusedOverlay() ? false : handleScrollToEndIndicator(event);\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\nclass LifecycleTimingTerminal extends ProcessTerminal {\n\toverride write(data: string): void {\n\t\tmarkLifecycleTiming(\"first-terminal-write\");\n\t\tsuper.write(data);\n\t}\n}\n\nfunction createProcessTerminal(): ProcessTerminal {\n\treturn isLifecycleTimingEnabled() ? new LifecycleTimingTerminal() : new ProcessTerminal();\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 ?? createProcessTerminal(),\n\t\toptions.showHardwareCursor,\n\t\toptions.logDirectory,\n\t\t{\n\t\t\tscrollToEndIndicator: () => {\n\t\t\t\tconst shortcut = keyDisplayText(\"tui.altScreen.bottom\");\n\t\t\t\tconst label = ` ↓ Jump to latest message${shortcut ? ` · ${shortcut}` : \"\"} `;\n\t\t\t\treturn theme.bg(\"selectedBg\", theme.fg(\"text\", label));\n\t\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},\n\t\toptions.shouldHandleViewportInput,\n\t\toptions.onOverlayUnhandledInput,\n\t\toptions.copySelection,\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 ?? createProcessTerminal();\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,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAsEzC,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,KAA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AkB,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.js\";\nimport { isLifecycleTimingEnabled, markLifecycleTiming } from \"../../core/lifecycle-timings.ts\";\nimport { copyToClipboard } from \"../../utils/clipboard.ts\";\nimport { openBrowser } from \"../../utils/open-browser.ts\";\nimport { keyDisplayText } from \"./components/keybinding-hints.js\";\nimport { TRANSCRIPT_JUMP_TO_END_URL } from \"./components/transcript-follow-indicator.ts\";\nimport { compositeOverlayLine } from \"./overlay-line-composite.ts\";\nimport { theme } from \"./theme/theme.js\";\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 TuiAltScreenScrollToEndIndicatorInternals {\n\thandleScrollToEndIndicatorMouseEvent(event: unknown): boolean;\n}\n\ninterface TuiOverlayCompositingInternals {\n\tcompositeLineAt(\n\t\tbaseLine: string,\n\t\toverlayLine: string,\n\t\tstartCol: number,\n\t\toverlayWidth: number,\n\t\ttotalWidth: number,\n\t): string;\n}\n\n/** pi-tui 0.85.1's private copy route only understands boolean callbacks. */\ninterface TuiAltScreenClipboardInternals {\n\tcopyTextToClipboard(text: string): Promise<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; return true on success, false or a diagnostic on failure.\n\t * Defaults to Atomic's clipboard implementation and platform diagnostics.\n\t */\n\tcopySelection?: (text: string) => Promise<boolean | string>;\n}\n\n/** The default selection-copy route: Atomic's host clipboard write. */\nasync function copySelectionToHostClipboard(text: string): Promise<boolean | string> {\n\ttry {\n\t\tawait copyToClipboard(text);\n\t\treturn true;\n\t} catch (error) {\n\t\treturn error instanceof Error ? error.message : String(error);\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\ninterface ParsedMouseSequence {\n\treadonly data: string;\n\treadonly button: number;\n\treadonly x: number;\n\treadonly y: 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({\n\t\t\t\tdata: sequence,\n\t\t\t\tbutton: Number.parseInt(sgr[1]!, 10),\n\t\t\t\tx: Number.parseInt(sgr[2]!, 10) - 1,\n\t\t\t\ty: Number.parseInt(sgr[3]!, 10) - 1,\n\t\t\t\tisRelease: sgr[4] === \"m\",\n\t\t\t});\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({\n\t\t\t\tdata: sequence,\n\t\t\t\tbutton: sequence.charCodeAt(3) - 32,\n\t\t\t\tx: sequence.charCodeAt(4) - 33,\n\t\t\t\ty: sequence.charCodeAt(5) - 33,\n\t\t\t\tisRelease: false,\n\t\t\t});\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\tcopySelection: NonNullable<InteractiveTuiOptions[\"copySelection\"]> = copySelectionToHostClipboard,\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// Adapt the private route rather than returning a truthy error string to\n\t\t// pi-tui 0.85.1. Both keyboard and mouse selection use this same door.\n\t\tconst clipboardRoute = this as unknown as TuiAltScreenClipboardInternals;\n\t\tclipboardRoute.copyTextToClipboard = async (text) => {\n\t\t\tconst result = await copySelection(text);\n\t\t\tconst copied = result === true;\n\t\t\tthis.flash(\n\t\t\t\tcopied ? \"Copied!\" : typeof result === \"string\" ? result : \"Copy failed\",\n\t\t\t\tcopied ? undefined : 5000,\n\t\t\t);\n\t\t\treturn copied;\n\t\t};\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\n\t\t// pi-tui 0.85 owns the jump-to-end indicator, but its hit test runs before Atomic's\n\t\t// focused-overlay input gate. Let the gate offer that press to the overlay first.\n\t\tconst indicator = this as unknown as TuiAltScreenScrollToEndIndicatorInternals;\n\t\tconst handleScrollToEndIndicator = indicator.handleScrollToEndIndicatorMouseEvent.bind(this);\n\t\tindicator.handleScrollToEndIndicatorMouseEvent = (event) =>\n\t\t\tthis.isFocusedOverlay() ? false : handleScrollToEndIndicator(event);\n\n\t\t(this as unknown as TuiOverlayCompositingInternals).compositeLineAt = compositeOverlayLine;\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\nclass LifecycleTimingTerminal extends ProcessTerminal {\n\toverride write(data: string): void {\n\t\tmarkLifecycleTiming(\"first-terminal-write\");\n\t\tsuper.write(data);\n\t}\n}\n\nfunction createProcessTerminal(): ProcessTerminal {\n\treturn isLifecycleTimingEnabled() ? new LifecycleTimingTerminal() : new ProcessTerminal();\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 ?? createProcessTerminal(),\n\t\toptions.showHardwareCursor,\n\t\toptions.logDirectory,\n\t\t{\n\t\t\tscrollToEndIndicator: () => {\n\t\t\t\tconst shortcut = keyDisplayText(\"tui.altScreen.bottom\");\n\t\t\t\tconst label = ` ↓ Jump to latest message${shortcut ? ` · ${shortcut}` : \"\"} `;\n\t\t\t\treturn theme.bg(\"selectedBg\", theme.fg(\"text\", label));\n\t\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},\n\t\toptions.shouldHandleViewportInput,\n\t\toptions.onOverlayUnhandledInput,\n\t\toptions.copySelection,\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 ?? createProcessTerminal();\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"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Composite an overlay row onto a base row. A row that spans the whole
3
+ * terminal hides the base entirely, so it skips the grapheme scan of the base
4
+ * line that `compositeTuiLine` performs for partial overlays.
5
+ */
6
+ export declare function compositeOverlayLine(baseLine: string, overlayLine: string, startCol: number, overlayWidth: number, totalWidth: number): string;
7
+ //# sourceMappingURL=overlay-line-composite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay-line-composite.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/overlay-line-composite.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GAChB,MAAM,CAUR"}
@@ -0,0 +1,24 @@
1
+ import { compositeTuiLine, visibleWidth } from "@earendil-works/pi-tui";
2
+ const SEGMENT_RESET = "\x1b[0m\x1b]8;;\x07";
3
+ const KITTY_IMAGE_PREFIX = "\x1b_G";
4
+ const ITERM2_IMAGE_PREFIX = "\x1b]1337;File=";
5
+ function containsImageSequence(line) {
6
+ return line.includes(KITTY_IMAGE_PREFIX) || line.includes(ITERM2_IMAGE_PREFIX);
7
+ }
8
+ /**
9
+ * Composite an overlay row onto a base row. A row that spans the whole
10
+ * terminal hides the base entirely, so it skips the grapheme scan of the base
11
+ * line that `compositeTuiLine` performs for partial overlays.
12
+ */
13
+ export function compositeOverlayLine(baseLine, overlayLine, startCol, overlayWidth, totalWidth) {
14
+ const coversRow = startCol === 0 && overlayWidth === totalWidth;
15
+ if (!coversRow || containsImageSequence(baseLine) || containsImageSequence(overlayLine)) {
16
+ return compositeTuiLine(baseLine, overlayLine, startCol, overlayWidth, totalWidth);
17
+ }
18
+ const overlayVisibleWidth = visibleWidth(overlayLine);
19
+ if (overlayVisibleWidth > overlayWidth) {
20
+ return compositeTuiLine(baseLine, overlayLine, startCol, overlayWidth, totalWidth);
21
+ }
22
+ return `${SEGMENT_RESET}${overlayLine}${" ".repeat(overlayWidth - overlayVisibleWidth)}${SEGMENT_RESET}`;
23
+ }
24
+ //# sourceMappingURL=overlay-line-composite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay-line-composite.js","sourceRoot":"","sources":["../../../src/modes/interactive/overlay-line-composite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAExE,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAC5C,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AACpC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAE9C,SAAS,qBAAqB,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;AAChF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CACnC,QAAgB,EAChB,WAAmB,EACnB,QAAgB,EAChB,YAAoB,EACpB,UAAkB;IAElB,MAAM,SAAS,GAAG,QAAQ,KAAK,CAAC,IAAI,YAAY,KAAK,UAAU,CAAC;IAChE,IAAI,CAAC,SAAS,IAAI,qBAAqB,CAAC,QAAQ,CAAC,IAAI,qBAAqB,CAAC,WAAW,CAAC,EAAE,CAAC;QACzF,OAAO,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,mBAAmB,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IACtD,IAAI,mBAAmB,GAAG,YAAY,EAAE,CAAC;QACxC,OAAO,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,GAAG,aAAa,GAAG,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,GAAG,mBAAmB,CAAC,GAAG,aAAa,EAAE,CAAC;AAC1G,CAAC","sourcesContent":["import { compositeTuiLine, visibleWidth } from \"@earendil-works/pi-tui\";\n\nconst SEGMENT_RESET = \"\\x1b[0m\\x1b]8;;\\x07\";\nconst KITTY_IMAGE_PREFIX = \"\\x1b_G\";\nconst ITERM2_IMAGE_PREFIX = \"\\x1b]1337;File=\";\n\nfunction containsImageSequence(line: string): boolean {\n\treturn line.includes(KITTY_IMAGE_PREFIX) || line.includes(ITERM2_IMAGE_PREFIX);\n}\n\n/**\n * Composite an overlay row onto a base row. A row that spans the whole\n * terminal hides the base entirely, so it skips the grapheme scan of the base\n * line that `compositeTuiLine` performs for partial overlays.\n */\nexport function compositeOverlayLine(\n\tbaseLine: string,\n\toverlayLine: string,\n\tstartCol: number,\n\toverlayWidth: number,\n\ttotalWidth: number,\n): string {\n\tconst coversRow = startCol === 0 && overlayWidth === totalWidth;\n\tif (!coversRow || containsImageSequence(baseLine) || containsImageSequence(overlayLine)) {\n\t\treturn compositeTuiLine(baseLine, overlayLine, startCol, overlayWidth, totalWidth);\n\t}\n\tconst overlayVisibleWidth = visibleWidth(overlayLine);\n\tif (overlayVisibleWidth > overlayWidth) {\n\t\treturn compositeTuiLine(baseLine, overlayLine, startCol, overlayWidth, totalWidth);\n\t}\n\treturn `${SEGMENT_RESET}${overlayLine}${\" \".repeat(overlayWidth - overlayVisibleWidth)}${SEGMENT_RESET}`;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { AuthInteraction } from "@bastani/pi-ai";
1
2
  import type { AgentSession } from "../../core/agent-session.js";
2
3
  import { type AtomicOAuthLoginCallbacks } from "../../core/oauth-login.ts";
3
4
  import type { RpcClient } from "../rpc/rpc-client.ts";
@@ -7,4 +8,19 @@ export type { AtomicOAuthLoginCallbacks } from "../../core/oauth-login.ts";
7
8
  export declare function loginIsolatedOAuthProvider(session: AgentSession, client: RpcClient, catalog: RemoteModelCatalog, provider: string, callbacks: AtomicOAuthLoginCallbacks): Promise<{
8
9
  modelsRefreshed: true;
9
10
  }>;
11
+ /**
12
+ * Acquire an API key with the frontend's login dialog, then persist it in the engine.
13
+ *
14
+ * The engine owns credential storage for the isolated runtime, so the frontend
15
+ * only collects the key and adopts the engine's catalog and credential snapshot
16
+ * afterwards. A dialog cancelled before the engine save is sent persists nothing on
17
+ * either side; once the save is in flight it completes and the login is reported, the
18
+ * same commit point the local credential store uses. The engine save
19
+ * deliberately skips the remote catalog refresh: catalog freshness belongs to
20
+ * /model's bounded background refresh, and a failed fetch would otherwise leave the
21
+ * key persisted in the engine while the frontend took the error branch.
22
+ */
23
+ export declare function loginIsolatedApiKeyProvider(session: AgentSession, client: RpcClient, catalog: RemoteModelCatalog, provider: string, interaction: AuthInteraction): Promise<{
24
+ modelsRefreshed: true;
25
+ }>;
10
26
  //# sourceMappingURL=isolated-auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isolated-auth.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/isolated-auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,KAAK,yBAAyB,EAA4B,MAAM,2BAA2B,CAAC;AACrG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,YAAY,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE3E,6GAA6G;AAC7G,wBAAsB,0BAA0B,CAC/C,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,yBAAyB,GAClC,OAAO,CAAC;IAAE,eAAe,EAAE,IAAI,CAAA;CAAE,CAAC,CAUpC"}
1
+ {"version":3,"file":"isolated-auth.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/isolated-auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,KAAK,yBAAyB,EAA4B,MAAM,2BAA2B,CAAC;AAErG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,YAAY,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE3E,6GAA6G;AAC7G,wBAAsB,0BAA0B,CAC/C,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,yBAAyB,GAClC,OAAO,CAAC;IAAE,eAAe,EAAE,IAAI,CAAA;CAAE,CAAC,CAUpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,2BAA2B,CAChD,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,eAAe,GAC1B,OAAO,CAAC;IAAE,eAAe,EAAE,IAAI,CAAA;CAAE,CAAC,CAWpC"}
@@ -1,4 +1,5 @@
1
1
  import { normalizeOAuthLoginError } from "../../core/oauth-login.js";
2
+ import { operationSignal, raceWithAbortSignal } from "../../utils/abort.js";
2
3
  import { loginRpcOAuthProvider } from "../rpc/rpc-oauth-client.js";
3
4
  /** Acquire and persist OAuth entirely in the engine, transporting only UI callbacks and catalog metadata. */
4
5
  export async function loginIsolatedOAuthProvider(session, client, catalog, provider, callbacks) {
@@ -12,4 +13,30 @@ export async function loginIsolatedOAuthProvider(session, client, catalog, provi
12
13
  await session.modelRuntime.reloadCredentials({ refreshAvailability: false });
13
14
  return { modelsRefreshed: true };
14
15
  }
16
+ /**
17
+ * Acquire an API key with the frontend's login dialog, then persist it in the engine.
18
+ *
19
+ * The engine owns credential storage for the isolated runtime, so the frontend
20
+ * only collects the key and adopts the engine's catalog and credential snapshot
21
+ * afterwards. A dialog cancelled before the engine save is sent persists nothing on
22
+ * either side; once the save is in flight it completes and the login is reported, the
23
+ * same commit point the local credential store uses. The engine save
24
+ * deliberately skips the remote catalog refresh: catalog freshness belongs to
25
+ * /model's bounded background refresh, and a failed fetch would otherwise leave the
26
+ * key persisted in the engine while the frontend took the error branch.
27
+ */
28
+ export async function loginIsolatedApiKeyProvider(session, client, catalog, provider, interaction) {
29
+ const apiKeyAuth = session.modelRuntime.getProvider(provider)?.auth.apiKey;
30
+ if (!apiKeyAuth?.login)
31
+ throw new Error(`Provider does not support api_key login: ${provider}`);
32
+ const signal = operationSignal(interaction.signal);
33
+ signal.throwIfAborted();
34
+ const credential = await raceWithAbortSignal(apiKeyAuth.login({ ...interaction, signal }), signal);
35
+ if (signal.aborted)
36
+ throw normalizeOAuthLoginError(signal.reason ?? new Error("Login cancelled"), signal);
37
+ const remoteCatalog = await client.saveProviderCredential(provider, credential, { refreshCatalog: false });
38
+ catalog.apply(remoteCatalog);
39
+ await session.modelRuntime.reloadCredentials({ refreshAvailability: false });
40
+ return { modelsRefreshed: true };
41
+ }
15
42
  //# sourceMappingURL=isolated-auth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isolated-auth.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/isolated-auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAkC,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErG,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAKnE,6GAA6G;AAC7G,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC/C,OAAqB,EACrB,MAAiB,EACjB,OAA2B,EAC3B,QAAgB,EAChB,SAAoC;IAEpC,MAAM,aAAa,GAAG,MAAM,qBAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC/E,IAAI,aAAa,CAAC,SAAS,EAAE,CAAC;QAC7B,MAAM,wBAAwB,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,IAAI,IAAI,KAAK,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5G,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC7B,4EAA4E;IAC5E,yEAAyE;IACzE,MAAM,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;AAClC,CAAC","sourcesContent":["import type { AgentSession } from \"../../core/agent-session.js\";\nimport { type AtomicOAuthLoginCallbacks, normalizeOAuthLoginError } from \"../../core/oauth-login.ts\";\nimport type { RpcClient } from \"../rpc/rpc-client.ts\";\nimport { loginRpcOAuthProvider } from \"../rpc/rpc-oauth-client.ts\";\nimport type { RemoteModelCatalog } from \"./remote-model-catalog.ts\";\n\nexport type { AtomicOAuthLoginCallbacks } from \"../../core/oauth-login.ts\";\n\n/** Acquire and persist OAuth entirely in the engine, transporting only UI callbacks and catalog metadata. */\nexport async function loginIsolatedOAuthProvider(\n\tsession: AgentSession,\n\tclient: RpcClient,\n\tcatalog: RemoteModelCatalog,\n\tprovider: string,\n\tcallbacks: AtomicOAuthLoginCallbacks,\n): Promise<{ modelsRefreshed: true }> {\n\tconst remoteCatalog = await loginRpcOAuthProvider(client, provider, callbacks);\n\tif (remoteCatalog.cancelled) {\n\t\tthrow normalizeOAuthLoginError(callbacks.signal?.reason ?? new Error(\"Login cancelled\"), callbacks.signal);\n\t}\n\tcatalog.apply(remoteCatalog);\n\t// The engine owns persistence. Refresh the frontend snapshot only after its\n\t// credential transaction and catalog refresh both complete successfully.\n\tawait session.modelRuntime.reloadCredentials({ refreshAvailability: false });\n\treturn { modelsRefreshed: true };\n}\n"]}
1
+ {"version":3,"file":"isolated-auth.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/isolated-auth.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkC,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrG,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAKnE,6GAA6G;AAC7G,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC/C,OAAqB,EACrB,MAAiB,EACjB,OAA2B,EAC3B,QAAgB,EAChB,SAAoC;IAEpC,MAAM,aAAa,GAAG,MA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AC,sBAAsB,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3G,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC7B,MAAM,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;AAClC,CAAC","sourcesContent":["import type { AuthInteraction } from \"@bastani/pi-ai\";\nimport type { AgentSession } from \"../../core/agent-session.js\";\nimport { type AtomicOAuthLoginCallbacks, normalizeOAuthLoginError } from \"../../core/oauth-login.ts\";\nimport { operationSignal, raceWithAbortSignal } from \"../../utils/abort.js\";\nimport type { RpcClient } from \"../rpc/rpc-client.ts\";\nimport { loginRpcOAuthProvider } from \"../rpc/rpc-oauth-client.ts\";\nimport type { RemoteModelCatalog } from \"./remote-model-catalog.ts\";\n\nexport type { AtomicOAuthLoginCallbacks } from \"../../core/oauth-login.ts\";\n\n/** Acquire and persist OAuth entirely in the engine, transporting only UI callbacks and catalog metadata. */\nexport async function loginIsolatedOAuthProvider(\n\tsession: AgentSession,\n\tclient: RpcClient,\n\tcatalog: RemoteModelCatalog,\n\tprovider: string,\n\tcallbacks: AtomicOAuthLoginCallbacks,\n): Promise<{ modelsRefreshed: true }> {\n\tconst remoteCatalog = await loginRpcOAuthProvider(client, provider, callbacks);\n\tif (remoteCatalog.cancelled) {\n\t\tthrow normalizeOAuthLoginError(callbacks.signal?.reason ?? new Error(\"Login cancelled\"), callbacks.signal);\n\t}\n\tcatalog.apply(remoteCatalog);\n\t// The engine owns persistence. Refresh the frontend snapshot only after its\n\t// credential transaction and catalog refresh both complete successfully.\n\tawait session.modelRuntime.reloadCredentials({ refreshAvailability: false });\n\treturn { modelsRefreshed: true };\n}\n\n/**\n * Acquire an API key with the frontend's login dialog, then persist it in the engine.\n *\n * The engine owns credential storage for the isolated runtime, so the frontend\n * only collects the key and adopts the engine's catalog and credential snapshot\n * afterwards. A dialog cancelled before the engine save is sent persists nothing on\n * either side; once the save is in flight it completes and the login is reported, the\n * same commit point the local credential store uses. The engine save\n * deliberately skips the remote catalog refresh: catalog freshness belongs to\n * /model's bounded background refresh, and a failed fetch would otherwise leave the\n * key persisted in the engine while the frontend took the error branch.\n */\nexport async function loginIsolatedApiKeyProvider(\n\tsession: AgentSession,\n\tclient: RpcClient,\n\tcatalog: RemoteModelCatalog,\n\tprovider: string,\n\tinteraction: AuthInteraction,\n): Promise<{ modelsRefreshed: true }> {\n\tconst apiKeyAuth = session.modelRuntime.getProvider(provider)?.auth.apiKey;\n\tif (!apiKeyAuth?.login) throw new Error(`Provider does not support api_key login: ${provider}`);\n\tconst signal = operationSignal(interaction.signal);\n\tsignal.throwIfAborted();\n\tconst credential = await raceWithAbortSignal(apiKeyAuth.login({ ...interaction, signal }), signal);\n\tif (signal.aborted) throw normalizeOAuthLoginError(signal.reason ?? new Error(\"Login cancelled\"), signal);\n\tconst remoteCatalog = await client.saveProviderCredential(provider, credential, { refreshCatalog: false });\n\tcatalog.apply(remoteCatalog);\n\tawait session.modelRuntime.reloadCredentials({ refreshAvailability: false });\n\treturn { modelsRefreshed: true };\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { AuthInteraction } from "@bastani/pi-ai";
1
2
  import type { AgentSession } from "../../core/agent-session.js";
2
3
  import { AgentSessionRuntime, type CreateAgentSessionRuntimeFactory } from "../../core/agent-session-runtime.ts";
3
4
  import type { ResourceOverlap } from "../../core/diagnostics.ts";
@@ -61,6 +62,9 @@ export declare class IsolatedInteractiveRuntime extends AgentSessionRuntime {
61
62
  loginOAuthProvider(provider: string, callbacks: AtomicOAuthLoginCallbacks): Promise<{
62
63
  modelsRefreshed: true;
63
64
  }>;
65
+ loginApiKeyProvider(provider: string, interaction: AuthInteraction): Promise<{
66
+ modelsRefreshed: true;
67
+ }>;
64
68
  logoutProvider(provider: string): Promise<import("../rpc/rpc-types.ts").RpcLogoutProviderResult>;
65
69
  onDiagnostic(listener: EngineDiagnosticListener): () => void;
66
70
  onEngineMessage(listener: (message: InteractiveEngineMessage) => void): () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"isolated-runtime.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/isolated-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,KAAK,gCAAgC,EAAE,MAAM,qCAAqC,CAAC;AAEjH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAIjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EACX,mBAAmB,EAEnB,qBAAqB,EACrB,sBAAsB,EAEtB,oBAAoB,EACpB,eAAe,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,KAAK,wBAAwB,EAA0B,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,KAAK,yBAAyB,EAA8B,MAAM,oBAAoB,CAAC;AAChG,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC/G,OAAO,EAAwB,KAAK,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAKhG,KAAK,0BAA0B,GAAG,CAAC,UAAU,EAAE,SAAS,oBAAoB,EAAE,KAAK,IAAI,CAAC;AAuCxF;;;;;;GAMG;AACH,qBAAa,0BAA2B,SAAQ,mBAAmB;IAClE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA+B;IAC/D,OAAO,CAAC,SAAS,CAAS;IAC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C,CAYhC;IAED,OAAO,CAAC,YAAY;IA6OpB;;;;;OAKG;YACW,eAAe;IAY7B,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,2BAA2B;IAQnC,OAAO,CAAC,mBAAmB;YAcb,yBAAyB;IAavC,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,YAAY;CAoCpB"}
@@ -5,7 +5,7 @@ import { SessionManager } from "../../core/session-manager.js";
5
5
  import { sleep } from "../../utils/sleep.js";
6
6
  import { isRpcTransportFailure, markRpcTransportFailure, rpcTransportError } from "../rpc/rpc-transport-error.js";
7
7
  import { EngineHealthController } from "./engine-health.js";
8
- import { loginIsolatedOAuthProvider } from "./isolated-auth.js";
8
+ import { loginIsolatedApiKeyProvider, loginIsolatedOAuthProvider, } from "./isolated-auth.js";
9
9
  import { RemoteCommandCatalog } from "./remote-command-catalog.js";
10
10
  import { RemoteModelCatalog } from "./remote-model-catalog.js";
11
11
  import { RemoteQueuePause } from "./remote-queue-pause.js";
@@ -194,6 +194,9 @@ export class IsolatedInteractiveRuntime extends AgentSessionRuntime {
194
194
  async loginOAuthProvider(provider, callbacks) {
195
195
  return loginIsolatedOAuthProvider(super.session, this.client, this.remoteModelCatalog, provider, callbacks);
196
196
  }
197
+ async loginApiKeyProvider(provider, interaction) {
198
+ return loginIsolatedApiKeyProvider(super.session, this.client, this.remoteModelCatalog, provider, interaction);
199
+ }
197
200
  async logoutProvider(provider) {
198
201
  const result = await this.client.logoutProvider(provider);
199
202
  this.remoteModelCatalog.applyModels({ models: result.models, scopedModels: result.scopedModels ?? [] });