@bastani/atomic 0.9.4-alpha.5 → 0.9.4-alpha.6

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 (155) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/builtin/cursor/CHANGELOG.md +6 -0
  3. package/dist/builtin/cursor/package.json +3 -3
  4. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  5. package/dist/builtin/intercom/package.json +2 -2
  6. package/dist/builtin/mcp/CHANGELOG.md +6 -0
  7. package/dist/builtin/mcp/package.json +3 -3
  8. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  9. package/dist/builtin/subagents/package.json +4 -4
  10. package/dist/builtin/web-access/CHANGELOG.md +6 -0
  11. package/dist/builtin/web-access/package.json +2 -2
  12. package/dist/builtin/workflows/CHANGELOG.md +6 -0
  13. package/dist/builtin/workflows/package.json +2 -2
  14. package/dist/cli/file-processor.d.ts.map +1 -1
  15. package/dist/cli/file-processor.js +13 -25
  16. package/dist/cli/file-processor.js.map +1 -1
  17. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  18. package/dist/core/agent-session-extension-bindings.js +1 -1
  19. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  20. package/dist/core/agent-session-methods.d.ts +2 -0
  21. package/dist/core/agent-session-methods.d.ts.map +1 -1
  22. package/dist/core/agent-session-methods.js.map +1 -1
  23. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  24. package/dist/core/agent-session-prompt.js +11 -4
  25. package/dist/core/agent-session-prompt.js.map +1 -1
  26. package/dist/core/agent-session-state.d.ts.map +1 -1
  27. package/dist/core/agent-session-state.js +2 -2
  28. package/dist/core/agent-session-state.js.map +1 -1
  29. package/dist/core/agent-session-tool-hooks.d.ts +7 -1
  30. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  31. package/dist/core/agent-session-tool-hooks.js +26 -4
  32. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  33. package/dist/core/agent-session-tree.d.ts.map +1 -1
  34. package/dist/core/agent-session-tree.js +3 -1
  35. package/dist/core/agent-session-tree.js.map +1 -1
  36. package/dist/core/agent-session.d.ts +1 -0
  37. package/dist/core/agent-session.d.ts.map +1 -1
  38. package/dist/core/agent-session.js +1 -0
  39. package/dist/core/agent-session.js.map +1 -1
  40. package/dist/core/extensions/api-types.d.ts +2 -1
  41. package/dist/core/extensions/api-types.d.ts.map +1 -1
  42. package/dist/core/extensions/api-types.js.map +1 -1
  43. package/dist/core/extensions/index.d.ts +1 -1
  44. package/dist/core/extensions/index.d.ts.map +1 -1
  45. package/dist/core/extensions/index.js.map +1 -1
  46. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  47. package/dist/core/extensions/loader-core.js +3 -3
  48. package/dist/core/extensions/loader-core.js.map +1 -1
  49. package/dist/core/extensions/session-events.d.ts +7 -1
  50. package/dist/core/extensions/session-events.d.ts.map +1 -1
  51. package/dist/core/extensions/session-events.js.map +1 -1
  52. package/dist/core/http-dispatcher.d.ts.map +1 -1
  53. package/dist/core/http-dispatcher.js +28 -1
  54. package/dist/core/http-dispatcher.js.map +1 -1
  55. package/dist/core/model-resolver-defaults.d.ts.map +1 -1
  56. package/dist/core/model-resolver-defaults.js +1 -1
  57. package/dist/core/model-resolver-defaults.js.map +1 -1
  58. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  59. package/dist/core/resource-loader-reload.js +2 -1
  60. package/dist/core/resource-loader-reload.js.map +1 -1
  61. package/dist/core/session-manager-core.d.ts +2 -12
  62. package/dist/core/session-manager-core.d.ts.map +1 -1
  63. package/dist/core/session-manager-core.js +8 -16
  64. package/dist/core/session-manager-core.js.map +1 -1
  65. package/dist/core/settings-manager-resource-accessors.d.ts +1 -0
  66. package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
  67. package/dist/core/settings-manager-resource-accessors.js +11 -0
  68. package/dist/core/settings-manager-resource-accessors.js.map +1 -1
  69. package/dist/core/settings-manager-ui-accessors.d.ts +2 -0
  70. package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
  71. package/dist/core/settings-manager-ui-accessors.js +9 -0
  72. package/dist/core/settings-manager-ui-accessors.js.map +1 -1
  73. package/dist/core/settings-types.d.ts +2 -0
  74. package/dist/core/settings-types.d.ts.map +1 -1
  75. package/dist/core/settings-types.js.map +1 -1
  76. package/dist/core/timings.d.ts +7 -5
  77. package/dist/core/timings.d.ts.map +1 -1
  78. package/dist/core/timings.js +42 -24
  79. package/dist/core/timings.js.map +1 -1
  80. package/dist/core/tools/read.d.ts.map +1 -1
  81. package/dist/core/tools/read.js +12 -23
  82. package/dist/core/tools/read.js.map +1 -1
  83. package/dist/index-extensions.d.ts +1 -1
  84. package/dist/index-extensions.d.ts.map +1 -1
  85. package/dist/index-extensions.js.map +1 -1
  86. package/dist/index.d.ts +1 -1
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js.map +1 -1
  89. package/dist/main-session.d.ts.map +1 -1
  90. package/dist/main-session.js +14 -5
  91. package/dist/main-session.js.map +1 -1
  92. package/dist/modes/interactive/components/assistant-message.d.ts +3 -1
  93. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  94. package/dist/modes/interactive/components/assistant-message.js +22 -15
  95. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  96. package/dist/modes/interactive/components/chat-message-renderer.d.ts +1 -0
  97. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  98. package/dist/modes/interactive/components/chat-message-renderer.js +5 -5
  99. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  100. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  101. package/dist/modes/interactive/components/chat-session-host-rendering.js +1 -0
  102. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  103. package/dist/modes/interactive/components/user-message.d.ts +6 -2
  104. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  105. package/dist/modes/interactive/components/user-message.js +16 -5
  106. package/dist/modes/interactive/components/user-message.js.map +1 -1
  107. package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
  108. package/dist/modes/interactive/interactive-agent-events.js +1 -1
  109. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  110. package/dist/modes/interactive/interactive-editor-actions.d.ts.map +1 -1
  111. package/dist/modes/interactive/interactive-editor-actions.js +1 -0
  112. package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
  113. package/dist/modes/interactive/interactive-extension-context.d.ts.map +1 -1
  114. package/dist/modes/interactive/interactive-extension-context.js +1 -0
  115. package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
  116. package/dist/modes/interactive/interactive-mode-base.d.ts +1 -0
  117. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  118. package/dist/modes/interactive/interactive-mode-base.js +2 -0
  119. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  120. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  121. package/dist/modes/interactive/interactive-render-chat.js +4 -3
  122. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  123. package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
  124. package/dist/modes/interactive/interactive-session-runtime.js +1 -0
  125. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  126. package/dist/modes/rpc/rpc-client.d.ts +28 -51
  127. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  128. package/dist/modes/rpc/rpc-client.js +27 -51
  129. package/dist/modes/rpc/rpc-client.js.map +1 -1
  130. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  131. package/dist/modes/rpc/rpc-command-handler.js +19 -0
  132. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  133. package/dist/modes/rpc/rpc-types.d.ts +26 -0
  134. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  135. package/dist/modes/rpc/rpc-types.js.map +1 -1
  136. package/dist/rpc-entry.d.ts +3 -0
  137. package/dist/rpc-entry.d.ts.map +1 -0
  138. package/dist/rpc-entry.js +12 -0
  139. package/dist/rpc-entry.js.map +1 -0
  140. package/dist/utils/image-convert.d.ts +1 -0
  141. package/dist/utils/image-convert.d.ts.map +1 -1
  142. package/dist/utils/image-convert.js +21 -15
  143. package/dist/utils/image-convert.js.map +1 -1
  144. package/dist/utils/image-process.d.ts +18 -0
  145. package/dist/utils/image-process.d.ts.map +1 -0
  146. package/dist/utils/image-process.js +83 -0
  147. package/dist/utils/image-process.js.map +1 -0
  148. package/dist/utils/mime.d.ts.map +1 -1
  149. package/dist/utils/mime.js +41 -0
  150. package/dist/utils/mime.js.map +1 -1
  151. package/docs/extensions.md +11 -0
  152. package/docs/rpc.md +58 -0
  153. package/docs/settings.md +2 -0
  154. package/npm-shrinkwrap.json +134 -136
  155. package/package.json +11 -6
@@ -48,6 +48,7 @@ export class InteractiveModeBase {
48
48
  this.toolOutputExpanded = false;
49
49
  // Thinking block visibility state
50
50
  this.hideThinkingBlock = false;
51
+ this.outputPad = 1;
51
52
  // Skill commands: command name -> skill file path
52
53
  this.skillCommands = new Map();
53
54
  this.signalCleanupHandlers = [];
@@ -125,6 +126,7 @@ export class InteractiveModeBase {
125
126
  this.usageMeter.setAutoCompactEnabled(this.session.autoCompactionEnabled);
126
127
  // Load hide thinking block setting
127
128
  this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();
129
+ this.outputPad = this.settingsManager.getOutputPad();
128
130
  // Register themes from resource loader and initialize
129
131
  setRegisteredThemes(this.session.resourceLoader.getThemes().themes);
130
132
  this.themeController = new InteractiveThemeController(this.ui, this.settingsManager, (message) => this.showError(message), () => this.updateEditorBorderColor());
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-mode-base.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-mode-base.ts"],"names":[],"mappings":"AAKA,OAAO,EAA0P,SAAS,EAAU,eAAe,EAAU,cAAc,EAAQ,GAAG,EAAE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAqE,YAAY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CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EACpC,GAAG,EAAE,CAAC,IAAI,CAAC,uBAAuB,EAAE,CACrC,CAAC;IACJ,CAAC;IAID,0DAA0D;aAC1C,qBAAgB,GAAG,EAAE,AAAL,CAAM;CAUvC","sourcesContent":["/**\n * Shared state and constructor wiring for interactive mode.\n * Responsibility-specific behavior is installed by sibling modules.\n */\nimport type {} from \"./interactive-mode-surface.ts\";\nimport { type AssistantMessage, type AutocompleteProvider, type EditorComponent, type Component, type LoaderIndicatorOptions, type AgentSession, type AgentSessionRuntime, type AutocompleteProviderFactory, type EditorFactory, type HostCustomUiStateListener, Container, Loader, ProcessTerminal, Spacer, setKeybindings, Text, TUI, VERSION, FooterDataProvider, KeybindingsManager, AssistantMessageComponent, BashExecutionComponent, CountdownTimer, CustomEditor, ExtensionEditorComponent, ExtensionInputComponent, ExtensionSelectorComponent, FooterComponent, UsageMeterComponent, ToolExecutionComponent, getEditorTheme, setRegisteredThemes, InteractiveThemeController } from \"./interactive-mode-deps.ts\";\nimport type { CompactionQueuedMessage, InteractiveModeOptions } from \"./interactive-mode-types.ts\";\n\nexport class InteractiveModeBase {\n\n runtimeHost: AgentSessionRuntime;\n\n\n ui: TUI;\n\n\n chatContainer: Container;\n\n\n pendingMessagesContainer: Container;\n\n\n statusContainer: Container;\n\n\n defaultEditor: CustomEditor;\n\n\n editor: EditorComponent;\n\n\n editorComponentFactory: EditorFactory | undefined;\n\n\n autocompleteProvider: AutocompleteProvider | undefined;\n\n\n autocompleteProviderWrappers: AutocompleteProviderFactory[] = [];\n\n\n fdPath: string | undefined;\n\n\n editorContainer: Container;\n\n\n footer: FooterComponent;\n\n\n usageMeter: UsageMeterComponent;\n\n\n footerDataProvider: FooterDataProvider;\n\n\n // Stored so the same manager can be injected into custom editors, selectors, and extension UI.\n keybindings: KeybindingsManager;\n\n\n version: string;\n\n\n isInitialized = false;\n\n\n // GitHub Copilot CAPI context-window catalog load state (gated on the Copilot provider).\n copilotCatalogApplied = false;\n\n\n copilotCatalogInFlight?: Promise<void>;\n\n\n onInputCallback?: (text: string) => void;\n\n\n pendingUserInputs: string[] = [];\n\n\n loadingAnimation: Loader | undefined = undefined;\n\n\n workingMessage: string | undefined = undefined;\n\n\n workingVisible = true;\n\n\n workingIndicatorOptions: LoaderIndicatorOptions | undefined =\n undefined;\n\n\n readonly defaultWorkingMessage = \"Working...\";\n\n\n readonly defaultHiddenThinkingLabel = \"Thinking...\";\n\n\n hiddenThinkingLabel = this.defaultHiddenThinkingLabel;\n\n\n\n lastSigintTime = 0;\n\n\n lastEscapeTime = 0;\n\n\n changelogMarkdown: string | undefined = undefined;\n\n\n startupNoticesShown = false;\n\n\n anthropicSubscriptionWarningShown = false;\n\n\n firstRunOnboardingActive = false;\n\n\n firstRunOnboardingSeedInFlight = false;\n\n\n pendingFirstRunOnboardingSeed: string | undefined = undefined;\n\n\n hadLastChangelogVersionAtStartup = false;\n\n\n firstRunOnboardingHeaderComponents: Component[] = [];\n\n\n autoTrustOnReloadCwd: string | undefined;\n\n\n\n // Status line tracking (for mutating immediately-sequential status updates)\n lastStatusSpacer: Spacer | undefined = undefined;\n\n\n lastStatusText: Text | undefined = undefined;\n\n\n\n // Streaming message tracking\n streamingComponent: AssistantMessageComponent | undefined = undefined;\n\n\n streamingMessage: AssistantMessage | undefined = undefined;\n\n\n\n // Tool execution tracking: toolCallId -> component\n pendingTools = new Map<string, ToolExecutionComponent>();\n\n\n\n // Tool output expansion state\n toolOutputExpanded = false;\n\n\n\n // Thinking block visibility state\n hideThinkingBlock = false;\n\n\n\n // Skill commands: command name -> skill file path\n skillCommands = new Map<string, string>();\n\n\n\n // Agent subscription unsubscribe function\n unsubscribe?: () => void;\n\n\n signalCleanupHandlers: Array<() => void> = [];\n\n\n\n // Track if editor is in bash mode (text starts with !)\n isBashMode = false;\n\n\n\n // Track current bash execution component\n bashComponent: BashExecutionComponent | undefined = undefined;\n\n\n\n // Track pending bash components (shown in pending area, moved to chat on submit)\n pendingBashComponents: BashExecutionComponent[] = [];\n\n\n\n // Auto-compaction state\n autoCompactionLoader: Loader | undefined = undefined;\n\n\n autoCompactionEscapeHandler?: () => void;\n\n\n\n // Auto-retry state\n retryLoader: Loader | undefined = undefined;\n\n\n retryCountdown: CountdownTimer | undefined = undefined;\n\n\n retryEscapeHandler?: () => void;\n\n\n\n // Messages queued while compaction is running\n compactionQueuedMessages: CompactionQueuedMessage[] = [];\n\n\n\n // Shutdown state\n shutdownRequested = false;\n\n\n\n // Extension UI state\n extensionSelector: ExtensionSelectorComponent | undefined = undefined;\n\n\n extensionInput: ExtensionInputComponent | undefined = undefined;\n\n\n extensionEditor: ExtensionEditorComponent | undefined = undefined;\n\n\n extensionTerminalInputUnsubscribers = new Set<() => void>();\n\n\n blockingInlineCustomUiDepth = 0;\n\n\n deferredInlineCustomUiFocusDepth = 0;\n\n\n pendingInlineCustomUiFocus: Component | undefined = undefined;\n\n\n hostCustomUiStateListeners = new Set<HostCustomUiStateListener>();\n\n\n themeController: InteractiveThemeController;\n\n\n\n // Extension widgets (components rendered above/below the editor)\n extensionWidgetsAbove = new Map<\n string,\n Component & { dispose?(): void }\n >();\n\n\n extensionWidgetsBelow = new Map<\n string,\n Component & { dispose?(): void }\n >();\n\n\n widgetContainerAbove!: Container;\n\n\n widgetContainerBelow!: Container;\n\n\n\n // Custom footer from extension (undefined = use built-in footer)\n customFooter: (Component & { dispose?(): void }) | undefined =\n undefined;\n\n\n\n // Header container that holds the built-in or custom header\n headerContainer: Container;\n\n\n\n // Built-in header (logo + keybinding hints + changelog)\n builtInHeader: Component | undefined = undefined;\n\n\n\n // Custom header from extension (undefined = use built-in header)\n customHeader: (Component & { dispose?(): void }) | undefined =\n undefined;\n\n\n\n // Convenience accessors\n get session(): AgentSession {\n return this.runtimeHost.session;\n }\n\n\n get agent() {\n return this.session.agent;\n }\n\n\n get sessionManager() {\n return this.session.sessionManager;\n }\n\n\n get settingsManager() {\n return this.session.settingsManager;\n }\n\n\n\n declare options: InteractiveModeOptions;\n\n\n\n constructor(\n runtimeHost: AgentSessionRuntime,\n options: InteractiveModeOptions = {},\n ) {\n this.options = options;\n this.autoTrustOnReloadCwd = options.autoTrustOnReloadCwd;\n this.runtimeHost = runtimeHost;\n this.runtimeHost.setBeforeSessionInvalidate(() => {\n this.resetExtensionUI();\n });\n this.runtimeHost.setRebindSession(async () => {\n await this.rebindCurrentSession();\n });\n this.version = VERSION;\n this.ui = new TUI(\n new ProcessTerminal(),\n this.settingsManager.getShowHardwareCursor(),\n );\n this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());\n this.headerContainer = new Container();\n this.chatContainer = new Container();\n this.pendingMessagesContainer = new Container();\n this.statusContainer = new Container();\n this.widgetContainerAbove = new Container();\n this.widgetContainerBelow = new Container();\n this.keybindings = KeybindingsManager.create();\n setKeybindings(this.keybindings);\n const editorPaddingX = this.settingsManager.getEditorPaddingX();\n const autocompleteMaxVisible =\n this.settingsManager.getAutocompleteMaxVisible();\n this.defaultEditor = new CustomEditor(\n this.ui,\n getEditorTheme(),\n this.keybindings,\n {\n paddingX: editorPaddingX,\n autocompleteMaxVisible,\n },\n );\n this.editor = this.defaultEditor;\n this.editorContainer = new Container();\n this.editorContainer.addChild(this.editor as Component);\n this.footerDataProvider = new FooterDataProvider(\n this.sessionManager.getCwd(),\n );\n this.footer = new FooterComponent(this.session, this.footerDataProvider);\n this.usageMeter = new UsageMeterComponent(this.session);\n this.usageMeter.setAutoCompactEnabled(this.session.autoCompactionEnabled);\n\n // Load hide thinking block setting\n this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();\n\n // Register themes from resource loader and initialize\n setRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n this.themeController = new InteractiveThemeController(\n this.ui,\n this.settingsManager,\n (message) => this.showError(message),\n () => this.updateEditorBorderColor(),\n );\n }\n\n\n\n // Maximum total widget lines to prevent viewport overflow\n static readonly MAX_WIDGET_LINES = 10;\n\n\n\n /**\n * Gracefully shutdown the agent.\n * Stops the TUI before emitting shutdown events so extension UI cleanup cannot\n * repaint the final frame while the process is exiting.\n */\n isShuttingDown = false;\n}\n"]}
1
+ {"version":3,"file":"interactive-mode-base.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-mode-base.ts"],"names":[],"mappings":"AAKA,OAAO,EAA0P,SAAS,EAAU,eAAe,EAAU,cAAc,EAAQ,GAAG,EAAE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAqE,YAAY,EAAiF,eAAe,EAAE,mBAAmB,EAA0B,cAAc,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAG3rB,MAAM,OAAO,mBAAmB;IA+R9B,wBAAwB;IACxB,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;IAClC,CAAC;IAGD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC5B,CAAC;IAGD,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;IACrC,CAAC;IAGD,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;IACtC,CAAC;IAQD,YACE,WAAgC,EAChC,OAAO,GAA2B,EAAE;QA9RtC,iCAA4B,GAAkC,EAAE,CAAC;QAyBjE,kBAAa,GAAG,KAAK,CAAC;QAGtB,yFAAyF;QACzF,0BAAqB,GAAG,KAAK,CAAC;QAS9B,sBAAiB,GAAa,EAAE,CAAC;QAGjC,qBAAgB,GAAuB,SAAS,CAAC;QAGjD,mBAAc,GAAuB,SAAS,CAAC;QAG/C,mBAAc,GAAG,IAAI,CAAC;QAGtB,4BAAuB,GACrB,SAAS,CAAC;QAGH,0BAAqB,GAAG,YAAY,CAAC;QAGrC,+BAA0B,GAAG,aAAa,CAAC;QAGpD,wBAAmB,GAAG,IAAI,CAAC,0BAA0B,CAAC;QAItD,mBAAc,GAAG,CAAC,CAAC;QAGnB,mB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C;QAE1E,mCAAmC;QACnC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,oBAAoB,EAAE,CAAC;QACrE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE,CAAC;QAErD,sDAAsD;QACtD,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC;QACpE,IAAI,CAAC,eAAe,GAAG,IAAI,0BAA0B,CACnD,IAAI,CAAC,EAAE,EACP,IAAI,CAAC,eAAe,EACpB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EACpC,GAAG,EAAE,CAAC,IAAI,CAAC,uBAAuB,EAAE,CACrC,CAAC;IACJ,CAAC;IAID,0DAA0D;aAC1C,qBAAgB,GAAG,EAAE,AAAL,CAAM;CAUvC","sourcesContent":["/**\n * Shared state and constructor wiring for interactive mode.\n * Responsibility-specific behavior is installed by sibling modules.\n */\nimport type {} from \"./interactive-mode-surface.ts\";\nimport { type AssistantMessage, type AutocompleteProvider, type EditorComponent, type Component, type LoaderIndicatorOptions, type AgentSession, type AgentSessionRuntime, type AutocompleteProviderFactory, type EditorFactory, type HostCustomUiStateListener, Container, Loader, ProcessTerminal, Spacer, setKeybindings, Text, TUI, VERSION, FooterDataProvider, KeybindingsManager, AssistantMessageComponent, BashExecutionComponent, CountdownTimer, CustomEditor, ExtensionEditorComponent, ExtensionInputComponent, ExtensionSelectorComponent, FooterComponent, UsageMeterComponent, ToolExecutionComponent, getEditorTheme, setRegisteredThemes, InteractiveThemeController } from \"./interactive-mode-deps.ts\";\nimport type { CompactionQueuedMessage, InteractiveModeOptions } from \"./interactive-mode-types.ts\";\n\nexport class InteractiveModeBase {\n\n runtimeHost: AgentSessionRuntime;\n\n\n ui: TUI;\n\n\n chatContainer: Container;\n\n\n pendingMessagesContainer: Container;\n\n\n statusContainer: Container;\n\n\n defaultEditor: CustomEditor;\n\n\n editor: EditorComponent;\n\n\n editorComponentFactory: EditorFactory | undefined;\n\n\n autocompleteProvider: AutocompleteProvider | undefined;\n\n\n autocompleteProviderWrappers: AutocompleteProviderFactory[] = [];\n\n\n fdPath: string | undefined;\n\n\n editorContainer: Container;\n\n\n footer: FooterComponent;\n\n\n usageMeter: UsageMeterComponent;\n\n\n footerDataProvider: FooterDataProvider;\n\n\n // Stored so the same manager can be injected into custom editors, selectors, and extension UI.\n keybindings: KeybindingsManager;\n\n\n version: string;\n\n\n isInitialized = false;\n\n\n // GitHub Copilot CAPI context-window catalog load state (gated on the Copilot provider).\n copilotCatalogApplied = false;\n\n\n copilotCatalogInFlight?: Promise<void>;\n\n\n onInputCallback?: (text: string) => void;\n\n\n pendingUserInputs: string[] = [];\n\n\n loadingAnimation: Loader | undefined = undefined;\n\n\n workingMessage: string | undefined = undefined;\n\n\n workingVisible = true;\n\n\n workingIndicatorOptions: LoaderIndicatorOptions | undefined =\n undefined;\n\n\n readonly defaultWorkingMessage = \"Working...\";\n\n\n readonly defaultHiddenThinkingLabel = \"Thinking...\";\n\n\n hiddenThinkingLabel = this.defaultHiddenThinkingLabel;\n\n\n\n lastSigintTime = 0;\n\n\n lastEscapeTime = 0;\n\n\n changelogMarkdown: string | undefined = undefined;\n\n\n startupNoticesShown = false;\n\n\n anthropicSubscriptionWarningShown = false;\n\n\n firstRunOnboardingActive = false;\n\n\n firstRunOnboardingSeedInFlight = false;\n\n\n pendingFirstRunOnboardingSeed: string | undefined = undefined;\n\n\n hadLastChangelogVersionAtStartup = false;\n\n\n firstRunOnboardingHeaderComponents: Component[] = [];\n\n\n autoTrustOnReloadCwd: string | undefined;\n\n\n\n // Status line tracking (for mutating immediately-sequential status updates)\n lastStatusSpacer: Spacer | undefined = undefined;\n\n\n lastStatusText: Text | undefined = undefined;\n\n\n\n // Streaming message tracking\n streamingComponent: AssistantMessageComponent | undefined = undefined;\n\n\n streamingMessage: AssistantMessage | undefined = undefined;\n\n\n\n // Tool execution tracking: toolCallId -> component\n pendingTools = new Map<string, ToolExecutionComponent>();\n\n\n\n // Tool output expansion state\n toolOutputExpanded = false;\n\n\n\n // Thinking block visibility state\n hideThinkingBlock = false;\n outputPad: 0 | 1 = 1;\n\n\n\n // Skill commands: command name -> skill file path\n skillCommands = new Map<string, string>();\n\n\n\n // Agent subscription unsubscribe function\n unsubscribe?: () => void;\n\n\n signalCleanupHandlers: Array<() => void> = [];\n\n\n\n // Track if editor is in bash mode (text starts with !)\n isBashMode = false;\n\n\n\n // Track current bash execution component\n bashComponent: BashExecutionComponent | undefined = undefined;\n\n\n\n // Track pending bash components (shown in pending area, moved to chat on submit)\n pendingBashComponents: BashExecutionComponent[] = [];\n\n\n\n // Auto-compaction state\n autoCompactionLoader: Loader | undefined = undefined;\n\n\n autoCompactionEscapeHandler?: () => void;\n\n\n\n // Auto-retry state\n retryLoader: Loader | undefined = undefined;\n\n\n retryCountdown: CountdownTimer | undefined = undefined;\n\n\n retryEscapeHandler?: () => void;\n\n\n\n // Messages queued while compaction is running\n compactionQueuedMessages: CompactionQueuedMessage[] = [];\n\n\n\n // Shutdown state\n shutdownRequested = false;\n\n\n\n // Extension UI state\n extensionSelector: ExtensionSelectorComponent | undefined = undefined;\n\n\n extensionInput: ExtensionInputComponent | undefined = undefined;\n\n\n extensionEditor: ExtensionEditorComponent | undefined = undefined;\n\n\n extensionTerminalInputUnsubscribers = new Set<() => void>();\n\n\n blockingInlineCustomUiDepth = 0;\n\n\n deferredInlineCustomUiFocusDepth = 0;\n\n\n pendingInlineCustomUiFocus: Component | undefined = undefined;\n\n\n hostCustomUiStateListeners = new Set<HostCustomUiStateListener>();\n\n\n themeController: InteractiveThemeController;\n\n\n\n // Extension widgets (components rendered above/below the editor)\n extensionWidgetsAbove = new Map<\n string,\n Component & { dispose?(): void }\n >();\n\n\n extensionWidgetsBelow = new Map<\n string,\n Component & { dispose?(): void }\n >();\n\n\n widgetContainerAbove!: Container;\n\n\n widgetContainerBelow!: Container;\n\n\n\n // Custom footer from extension (undefined = use built-in footer)\n customFooter: (Component & { dispose?(): void }) | undefined =\n undefined;\n\n\n\n // Header container that holds the built-in or custom header\n headerContainer: Container;\n\n\n\n // Built-in header (logo + keybinding hints + changelog)\n builtInHeader: Component | undefined = undefined;\n\n\n\n // Custom header from extension (undefined = use built-in header)\n customHeader: (Component & { dispose?(): void }) | undefined =\n undefined;\n\n\n\n // Convenience accessors\n get session(): AgentSession {\n return this.runtimeHost.session;\n }\n\n\n get agent() {\n return this.session.agent;\n }\n\n\n get sessionManager() {\n return this.session.sessionManager;\n }\n\n\n get settingsManager() {\n return this.session.settingsManager;\n }\n\n\n\n declare options: InteractiveModeOptions;\n\n\n\n constructor(\n runtimeHost: AgentSessionRuntime,\n options: InteractiveModeOptions = {},\n ) {\n this.options = options;\n this.autoTrustOnReloadCwd = options.autoTrustOnReloadCwd;\n this.runtimeHost = runtimeHost;\n this.runtimeHost.setBeforeSessionInvalidate(() => {\n this.resetExtensionUI();\n });\n this.runtimeHost.setRebindSession(async () => {\n await this.rebindCurrentSession();\n });\n this.version = VERSION;\n this.ui = new TUI(\n new ProcessTerminal(),\n this.settingsManager.getShowHardwareCursor(),\n );\n this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());\n this.headerContainer = new Container();\n this.chatContainer = new Container();\n this.pendingMessagesContainer = new Container();\n this.statusContainer = new Container();\n this.widgetContainerAbove = new Container();\n this.widgetContainerBelow = new Container();\n this.keybindings = KeybindingsManager.create();\n setKeybindings(this.keybindings);\n const editorPaddingX = this.settingsManager.getEditorPaddingX();\n const autocompleteMaxVisible =\n this.settingsManager.getAutocompleteMaxVisible();\n this.defaultEditor = new CustomEditor(\n this.ui,\n getEditorTheme(),\n this.keybindings,\n {\n paddingX: editorPaddingX,\n autocompleteMaxVisible,\n },\n );\n this.editor = this.defaultEditor;\n this.editorContainer = new Container();\n this.editorContainer.addChild(this.editor as Component);\n this.footerDataProvider = new FooterDataProvider(\n this.sessionManager.getCwd(),\n );\n this.footer = new FooterComponent(this.session, this.footerDataProvider);\n this.usageMeter = new UsageMeterComponent(this.session);\n this.usageMeter.setAutoCompactEnabled(this.session.autoCompactionEnabled);\n\n // Load hide thinking block setting\n this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();\n this.outputPad = this.settingsManager.getOutputPad();\n\n // Register themes from resource loader and initialize\n setRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n this.themeController = new InteractiveThemeController(\n this.ui,\n this.settingsManager,\n (message) => this.showError(message),\n () => this.updateEditorBorderColor(),\n );\n }\n\n\n\n // Maximum total widget lines to prevent viewport overflow\n static readonly MAX_WIDGET_LINES = 10;\n\n\n\n /**\n * Gracefully shutdown the agent.\n * Stops the TUI before emitting shutdown events so extension UI cleanup cannot\n * repaint the final frame while the process is exiting.\n */\n isShuttingDown = false;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-render-chat.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentMessage, type Component, type ContextCompactionResult, type SessionContext, type TruncationResult, type ChatMessageEntry, type ChatMessageRenderOptions, Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.showStatus = function(this: InteractiveModeBase, message: string): void {\n const children = this.chatContainer.children;\n const last =\n children.length > 0 ? children[children.length - 1] : undefined;\n const secondLast =\n children.length > 1 ? children[children.length - 2] : undefined;\n\n if (\n last &&\n secondLast &&\n last === this.lastStatusText &&\n secondLast === this.lastStatusSpacer\n ) {\n this.lastStatusText.setText(theme.fg(\"dim\", message));\n this.ui.requestRender();\n return;\n }\n\n const spacer = new Spacer(1);\n const text = new Text(theme.fg(\"dim\", message), 1, 0);\n this.chatContainer.addChild(spacer);\n this.chatContainer.addChild(text);\n this.lastStatusSpacer = spacer;\n this.lastStatusText = text;\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function(this: InteractiveModeBase): ChatMessageRenderOptions {\n return {\n ui: this.ui,\n cwd: this.sessionManager.getCwd(),\n markdownTheme: this.getMarkdownThemeWithSettings(),\n hideThinkingBlock: this.hideThinkingBlock,\n hiddenThinkingLabel: this.hiddenThinkingLabel,\n toolOutputExpanded: this.toolOutputExpanded,\n showImages: this.settingsManager.getShowImages(),\n imageWidthCells: this.settingsManager.getImageWidthCells(),\n getToolDefinition: (toolName) => this.getRegisteredToolDefinition(toolName),\n getCustomMessageRenderer: (customType) =>\n this.session.extensionRunner.getMessageRenderer(customType),\n };\n };\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function(this: InteractiveModeBase, entry: ChatMessageEntry): Component {\n const component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n addChatTranscriptEntry(this.chatContainer, component, entry.role);\n return component;\n };\n\nInteractiveModeBase.prototype.addContextCompactionSummaryToChat = function(this: InteractiveModeBase, result: ContextCompactionResult): void {\n this.chatContainer.addChild(new Spacer(1));\n const component = new ContextCompactionSummaryMessageComponent(\n result,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n };\n\nInteractiveModeBase.prototype.addMessageToChat = function(this: InteractiveModeBase, message: AgentMessage, options?: { populateHistory?: boolean }): void {\n switch (message.role) {\n case \"bashExecution\": {\n const component = new BashExecutionComponent(\n message.command,\n this.ui,\n message.excludeFromContext,\n );\n if (message.output) {\n component.appendOutput(message.output);\n }\n component.setComplete(\n message.exitCode,\n message.cancelled,\n message.truncated\n ? ({ truncated: true } as TruncationResult)\n : undefined,\n message.fullOutputPath,\n );\n this.chatContainer.addChild(component);\n break;\n }\n case \"custom\": {\n if (message.display) {\n const renderer = this.session.extensionRunner.getMessageRenderer(\n message.customType,\n );\n const component = new CustomMessageComponent(\n message,\n renderer,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n }\n break;\n }\n case \"branchSummary\": {\n this.chatContainer.addChild(new Spacer(1));\n const component = new BranchSummaryMessageComponent(\n message,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n break;\n }\n case \"user\": {\n const textContent = this.getUserMessageText(message);\n if (textContent) {\n if (this.chatContainer.children.length > 0) {\n this.chatContainer.addChild(new Spacer(1));\n }\n const skillBlock = parseSkillBlock(textContent);\n if (skillBlock) {\n // Render skill block (collapsible)\n const component = new SkillInvocationMessageComponent(\n skillBlock,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n // Render user message separately if present\n if (skillBlock.userMessage) {\n const userComponent = new UserMessageComponent(\n skillBlock.userMessage,\n this.getMarkdownThemeWithSettings(),\n );\n this.chatContainer.addChild(userComponent);\n }\n } else {\n const userComponent = new UserMessageComponent(\n textContent,\n this.getMarkdownThemeWithSettings(),\n );\n this.chatContainer.addChild(userComponent);\n }\n if (options?.populateHistory) {\n this.editor.addToHistory?.(textContent);\n }\n }\n break;\n }\n case \"assistant\": {\n const assistantComponent = new AssistantMessageComponent(\n message,\n this.hideThinkingBlock,\n this.getMarkdownThemeWithSettings(),\n this.hiddenThinkingLabel,\n );\n this.chatContainer.addChild(assistantComponent);\n break;\n }\n case \"toolResult\": {\n // Tool results are rendered inline with tool calls, handled separately\n break;\n }\n default:\n break;\n }\n };\n\nInteractiveModeBase.prototype.renderSessionContext = function(this: InteractiveModeBase, sessionContext: SessionContext, options: { updateFooter?: boolean; populateHistory?: boolean } = {}): void {\n this.pendingTools.clear();\n\n if (options.updateFooter) {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n }\n\n const entries = chatEntriesFromAgentMessages(sessionContext.messages);\n for (const entry of entries) {\n const component = this.addRenderedChatEntry(entry);\n if (\n entry.kind === \"tool\" &&\n entry.isPartial !== false &&\n component instanceof ToolExecutionComponent\n ) {\n this.pendingTools.set(entry.toolCallId, component);\n }\n if (options.populateHistory && entry.kind === \"user\") {\n this.editor.addToHistory?.(entry.text);\n }\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.renderInitialMessages = function(this: InteractiveModeBase): void {\n // Get aligned messages and entries from session context\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context, {\n updateFooter: true,\n populateHistory: true,\n });\n\n // Show compaction info if session was compacted\n const allEntries = this.sessionManager.getEntries();\n const compactionCount = allEntries.filter(\n (e) => e.type === \"compaction\",\n ).length;\n if (compactionCount > 0) {\n const times =\n compactionCount === 1 ? \"1 time\" : `${compactionCount} times`;\n this.showStatus(`Session compacted ${times}`);\n }\n };\n\nInteractiveModeBase.prototype.getUserInput = async function(this: InteractiveModeBase): Promise<string> {\n const queuedInput = this.pendingUserInputs.shift();\n if (queuedInput !== undefined) {\n return queuedInput;\n }\n\n return new Promise((resolve) => {\n this.onInputCallback = (text: string) => {\n this.onInputCallback = undefined;\n resolve(text);\n };\n });\n };\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context);\n };\n"]}
1
+ {"version":3,"file":"interactive-render-chat.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentMessage, type Component, type ContextCompactionResult, type SessionContext, type TruncationResult, type ChatMessageEntry, type ChatMessageRenderOptions, Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.showStatus = function(this: InteractiveModeBase, message: string): void {\n const children = this.chatContainer.children;\n const last =\n children.length > 0 ? children[children.length - 1] : undefined;\n const secondLast =\n children.length > 1 ? children[children.length - 2] : undefined;\n\n if (\n last &&\n secondLast &&\n last === this.lastStatusText &&\n secondLast === this.lastStatusSpacer\n ) {\n this.lastStatusText.setText(theme.fg(\"dim\", message));\n this.ui.requestRender();\n return;\n }\n\n const spacer = new Spacer(1);\n const text = new Text(theme.fg(\"dim\", message), 1, 0);\n this.chatContainer.addChild(spacer);\n this.chatContainer.addChild(text);\n this.lastStatusSpacer = spacer;\n this.lastStatusText = text;\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function(this: InteractiveModeBase): ChatMessageRenderOptions {\n return {\n ui: this.ui,\n cwd: this.sessionManager.getCwd(),\n markdownTheme: this.getMarkdownThemeWithSettings(),\n hideThinkingBlock: this.hideThinkingBlock,\n hiddenThinkingLabel: this.hiddenThinkingLabel,\n toolOutputExpanded: this.toolOutputExpanded,\n showImages: this.settingsManager.getShowImages(),\n imageWidthCells: this.settingsManager.getImageWidthCells(),\n outputPad: this.outputPad,\n getToolDefinition: (toolName) => this.getRegisteredToolDefinition(toolName),\n getCustomMessageRenderer: (customType) =>\n this.session.extensionRunner.getMessageRenderer(customType),\n };\n };\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function(this: InteractiveModeBase, entry: ChatMessageEntry): Component {\n const component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n addChatTranscriptEntry(this.chatContainer, component, entry.role);\n return component;\n };\n\nInteractiveModeBase.prototype.addContextCompactionSummaryToChat = function(this: InteractiveModeBase, result: ContextCompactionResult): void {\n this.chatContainer.addChild(new Spacer(1));\n const component = new ContextCompactionSummaryMessageComponent(\n result,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n };\n\nInteractiveModeBase.prototype.addMessageToChat = function(this: InteractiveModeBase, message: AgentMessage, options?: { populateHistory?: boolean }): void {\n switch (message.role) {\n case \"bashExecution\": {\n const component = new BashExecutionComponent(\n message.command,\n this.ui,\n message.excludeFromContext,\n );\n if (message.output) {\n component.appendOutput(message.output);\n }\n component.setComplete(\n message.exitCode,\n message.cancelled,\n message.truncated\n ? ({ truncated: true } as TruncationResult)\n : undefined,\n message.fullOutputPath,\n );\n this.chatContainer.addChild(component);\n break;\n }\n case \"custom\": {\n if (message.display) {\n const renderer = this.session.extensionRunner.getMessageRenderer(\n message.customType,\n );\n const component = new CustomMessageComponent(\n message,\n renderer,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n }\n break;\n }\n case \"branchSummary\": {\n this.chatContainer.addChild(new Spacer(1));\n const component = new BranchSummaryMessageComponent(\n message,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n break;\n }\n case \"user\": {\n const textContent = this.getUserMessageText(message);\n if (textContent) {\n if (this.chatContainer.children.length > 0) {\n this.chatContainer.addChild(new Spacer(1));\n }\n const skillBlock = parseSkillBlock(textContent);\n if (skillBlock) {\n // Render skill block (collapsible)\n const component = new SkillInvocationMessageComponent(\n skillBlock,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n // Render user message separately if present\n if (skillBlock.userMessage) {\n const userComponent = new UserMessageComponent(\n skillBlock.userMessage,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n } else {\n const userComponent = new UserMessageComponent(\n textContent,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n if (options?.populateHistory) {\n this.editor.addToHistory?.(textContent);\n }\n }\n break;\n }\n case \"assistant\": {\n const assistantComponent = new AssistantMessageComponent(\n message,\n this.hideThinkingBlock,\n this.getMarkdownThemeWithSettings(),\n this.hiddenThinkingLabel,\n this.outputPad,\n );\n this.chatContainer.addChild(assistantComponent);\n break;\n }\n case \"toolResult\": {\n // Tool results are rendered inline with tool calls, handled separately\n break;\n }\n default:\n break;\n }\n };\n\nInteractiveModeBase.prototype.renderSessionContext = function(this: InteractiveModeBase, sessionContext: SessionContext, options: { updateFooter?: boolean; populateHistory?: boolean } = {}): void {\n this.pendingTools.clear();\n\n if (options.updateFooter) {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n }\n\n const entries = chatEntriesFromAgentMessages(sessionContext.messages);\n for (const entry of entries) {\n const component = this.addRenderedChatEntry(entry);\n if (\n entry.kind === \"tool\" &&\n entry.isPartial !== false &&\n component instanceof ToolExecutionComponent\n ) {\n this.pendingTools.set(entry.toolCallId, component);\n }\n if (options.populateHistory && entry.kind === \"user\") {\n this.editor.addToHistory?.(entry.text);\n }\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.renderInitialMessages = function(this: InteractiveModeBase): void {\n // Get aligned messages and entries from session context\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context, {\n updateFooter: true,\n populateHistory: true,\n });\n\n // Show compaction info if session was compacted\n const allEntries = this.sessionManager.getEntries();\n const compactionCount = allEntries.filter(\n (e) => e.type === \"compaction\",\n ).length;\n if (compactionCount > 0) {\n const times =\n compactionCount === 1 ? \"1 time\" : `${compactionCount} times`;\n this.showStatus(`Session compacted ${times}`);\n }\n };\n\nInteractiveModeBase.prototype.getUserInput = async function(this: InteractiveModeBase): Promise<string> {\n const queuedInput = this.pendingUserInputs.shift();\n if (queuedInput !== undefined) {\n return queuedInput;\n }\n\n return new Promise((resolve) => {\n this.onInputCallback = (text: string) => {\n this.onInputCallback = undefined;\n resolve(text);\n };\n });\n };\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context);\n };\n"]}
@@ -30,6 +30,7 @@ InteractiveModeBase.prototype.chatMessageRenderOptions = function () {
30
30
  toolOutputExpanded: this.toolOutputExpanded,
31
31
  showImages: this.settingsManager.getShowImages(),
32
32
  imageWidthCells: this.settingsManager.getImageWidthCells(),
33
+ outputPad: this.outputPad,
33
34
  getToolDefinition: (toolName) => this.getRegisteredToolDefinition(toolName),
34
35
  getCustomMessageRenderer: (customType) => this.session.extensionRunner.getMessageRenderer(customType),
35
36
  };
@@ -88,12 +89,12 @@ InteractiveModeBase.prototype.addMessageToChat = function (message, options) {
88
89
  this.chatContainer.addChild(component);
89
90
  // Render user message separately if present
90
91
  if (skillBlock.userMessage) {
91
- const userComponent = new UserMessageComponent(skillBlock.userMessage, this.getMarkdownThemeWithSettings());
92
+ const userComponent = new UserMessageComponent(skillBlock.userMessage, this.getMarkdownThemeWithSettings(), this.outputPad);
92
93
  this.chatContainer.addChild(userComponent);
93
94
  }
94
95
  }
95
96
  else {
96
- const userComponent = new UserMessageComponent(textContent, this.getMarkdownThemeWithSettings());
97
+ const userComponent = new UserMessageComponent(textContent, this.getMarkdownThemeWithSettings(), this.outputPad);
97
98
  this.chatContainer.addChild(userComponent);
98
99
  }
99
100
  if (options?.populateHistory) {
@@ -103,7 +104,7 @@ InteractiveModeBase.prototype.addMessageToChat = function (message, options) {
103
104
  break;
104
105
  }
105
106
  case "assistant": {
106
- const assistantComponent = new AssistantMessageComponent(message, this.hideThinkingBlock, this.getMarkdownThemeWithSettings(), this.hiddenThinkingLabel);
107
+ const assistantComponent = new AssistantMessageComponent(message, this.hideThinkingBlock, this.getMarkdownThemeWithSettings(), this.hiddenThinkingLabel, this.outputPad);
107
108
  this.chatContainer.addChild(assistantComponent);
108
109
  break;
109
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"inter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C;QACxB,MAAM,KAAK,GACT,eAAe,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,eAAe,QAAQ,CAAC;QAChE,IAAI,CAAC,UAAU,CAAC,qBAAqB,KAAK,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC,CAAC;AAEJ,mBAAmB,CAAC,SAAS,CAAC,YAAY,GAAG,KAAK;IAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IACnD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,CAAC,eAAe,GAAG,CAAC,IAAY,EAAE,EAAE;YACtC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEJ,mBAAmB,CAAC,SAAS,CAAC,uBAAuB,GAAG;IACpD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,mBAAmB,EAAE,CAAC;IAC1D,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentMessage, type Component, type ContextCompactionResult, type SessionContext, type TruncationResult, type ChatMessageEntry, type ChatMessageRenderOptions, Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.showStatus = function(this: InteractiveModeBase, message: string): void {\n const children = this.chatContainer.children;\n const last =\n children.length > 0 ? children[children.length - 1] : undefined;\n const secondLast =\n children.length > 1 ? children[children.length - 2] : undefined;\n\n if (\n last &&\n secondLast &&\n last === this.lastStatusText &&\n secondLast === this.lastStatusSpacer\n ) {\n this.lastStatusText.setText(theme.fg(\"dim\", message));\n this.ui.requestRender();\n return;\n }\n\n const spacer = new Spacer(1);\n const text = new Text(theme.fg(\"dim\", message), 1, 0);\n this.chatContainer.addChild(spacer);\n this.chatContainer.addChild(text);\n this.lastStatusSpacer = spacer;\n this.lastStatusText = text;\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function(this: InteractiveModeBase): ChatMessageRenderOptions {\n return {\n ui: this.ui,\n cwd: this.sessionManager.getCwd(),\n markdownTheme: this.getMarkdownThemeWithSettings(),\n hideThinkingBlock: this.hideThinkingBlock,\n hiddenThinkingLabel: this.hiddenThinkingLabel,\n toolOutputExpanded: this.toolOutputExpanded,\n showImages: this.settingsManager.getShowImages(),\n imageWidthCells: this.settingsManager.getImageWidthCells(),\n getToolDefinition: (toolName) => this.getRegisteredToolDefinition(toolName),\n getCustomMessageRenderer: (customType) =>\n this.session.extensionRunner.getMessageRenderer(customType),\n };\n };\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function(this: InteractiveModeBase, entry: ChatMessageEntry): Component {\n const component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n addChatTranscriptEntry(this.chatContainer, component, entry.role);\n return component;\n };\n\nInteractiveModeBase.prototype.addContextCompactionSummaryToChat = function(this: InteractiveModeBase, result: ContextCompactionResult): void {\n this.chatContainer.addChild(new Spacer(1));\n const component = new ContextCompactionSummaryMessageComponent(\n result,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n };\n\nInteractiveModeBase.prototype.addMessageToChat = function(this: InteractiveModeBase, message: AgentMessage, options?: { populateHistory?: boolean }): void {\n switch (message.role) {\n case \"bashExecution\": {\n const component = new BashExecutionComponent(\n message.command,\n this.ui,\n message.excludeFromContext,\n );\n if (message.output) {\n component.appendOutput(message.output);\n }\n component.setComplete(\n message.exitCode,\n message.cancelled,\n message.truncated\n ? ({ truncated: true } as TruncationResult)\n : undefined,\n message.fullOutputPath,\n );\n this.chatContainer.addChild(component);\n break;\n }\n case \"custom\": {\n if (message.display) {\n const renderer = this.session.extensionRunner.getMessageRenderer(\n message.customType,\n );\n const component = new CustomMessageComponent(\n message,\n renderer,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n }\n break;\n }\n case \"branchSummary\": {\n this.chatContainer.addChild(new Spacer(1));\n const component = new BranchSummaryMessageComponent(\n message,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n break;\n }\n case \"user\": {\n const textContent = this.getUserMessageText(message);\n if (textContent) {\n if (this.chatContainer.children.length > 0) {\n this.chatContainer.addChild(new Spacer(1));\n }\n const skillBlock = parseSkillBlock(textContent);\n if (skillBlock) {\n // Render skill block (collapsible)\n const component = new SkillInvocationMessageComponent(\n skillBlock,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n // Render user message separately if present\n if (skillBlock.userMessage) {\n const userComponent = new UserMessageComponent(\n skillBlock.userMessage,\n this.getMarkdownThemeWithSettings(),\n );\n this.chatContainer.addChild(userComponent);\n }\n } else {\n const userComponent = new UserMessageComponent(\n textContent,\n this.getMarkdownThemeWithSettings(),\n );\n this.chatContainer.addChild(userComponent);\n }\n if (options?.populateHistory) {\n this.editor.addToHistory?.(textContent);\n }\n }\n break;\n }\n case \"assistant\": {\n const assistantComponent = new AssistantMessageComponent(\n message,\n this.hideThinkingBlock,\n this.getMarkdownThemeWithSettings(),\n this.hiddenThinkingLabel,\n );\n this.chatContainer.addChild(assistantComponent);\n break;\n }\n case \"toolResult\": {\n // Tool results are rendered inline with tool calls, handled separately\n break;\n }\n default:\n break;\n }\n };\n\nInteractiveModeBase.prototype.renderSessionContext = function(this: InteractiveModeBase, sessionContext: SessionContext, options: { updateFooter?: boolean; populateHistory?: boolean } = {}): void {\n this.pendingTools.clear();\n\n if (options.updateFooter) {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n }\n\n const entries = chatEntriesFromAgentMessages(sessionContext.messages);\n for (const entry of entries) {\n const component = this.addRenderedChatEntry(entry);\n if (\n entry.kind === \"tool\" &&\n entry.isPartial !== false &&\n component instanceof ToolExecutionComponent\n ) {\n this.pendingTools.set(entry.toolCallId, component);\n }\n if (options.populateHistory && entry.kind === \"user\") {\n this.editor.addToHistory?.(entry.text);\n }\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.renderInitialMessages = function(this: InteractiveModeBase): void {\n // Get aligned messages and entries from session context\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context, {\n updateFooter: true,\n populateHistory: true,\n });\n\n // Show compaction info if session was compacted\n const allEntries = this.sessionManager.getEntries();\n const compactionCount = allEntries.filter(\n (e) => e.type === \"compaction\",\n ).length;\n if (compactionCount > 0) {\n const times =\n compactionCount === 1 ? \"1 time\" : `${compactionCount} times`;\n this.showStatus(`Session compacted ${times}`);\n }\n };\n\nInteractiveModeBase.prototype.getUserInput = async function(this: InteractiveModeBase): Promise<string> {\n const queuedInput = this.pendingUserInputs.shift();\n if (queuedInput !== undefined) {\n return queuedInput;\n }\n\n return new Promise((resolve) => {\n this.onInputCallback = (text: string) => {\n this.onInputCallback = undefined;\n resolve(text);\n };\n });\n };\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context);\n };\n"]}
1
+ {"version":3,"file":"interactive-render-chat.js","sourceRoot":"","sources":["../../../src/modes/interactive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CAC/B,CAAC,MAAM,CAAC;IACT,IAAI,eAAe,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,KAAK,GACT,eAAe,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,eAAe,QAAQ,CAAC;QAChE,IAAI,CAAC,UAAU,CAAC,qBAAqB,KAAK,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC,CAAC;AAEJ,mBAAmB,CAAC,SAAS,CAAC,YAAY,GAAG,KAAK;IAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IACnD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,CAAC,eAAe,GAAG,CAAC,IAAY,EAAE,EAAE;YACtC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEJ,mBAAmB,CAAC,SAAS,CAAC,uBAAuB,GAAG;IACpD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,mBAAmB,EAAE,CAAC;IAC1D,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentMessage, type Component, type ContextCompactionResult, type SessionContext, type TruncationResult, type ChatMessageEntry, type ChatMessageRenderOptions, Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.showStatus = function(this: InteractiveModeBase, message: string): void {\n const children = this.chatContainer.children;\n const last =\n children.length > 0 ? children[children.length - 1] : undefined;\n const secondLast =\n children.length > 1 ? children[children.length - 2] : undefined;\n\n if (\n last &&\n secondLast &&\n last === this.lastStatusText &&\n secondLast === this.lastStatusSpacer\n ) {\n this.lastStatusText.setText(theme.fg(\"dim\", message));\n this.ui.requestRender();\n return;\n }\n\n const spacer = new Spacer(1);\n const text = new Text(theme.fg(\"dim\", message), 1, 0);\n this.chatContainer.addChild(spacer);\n this.chatContainer.addChild(text);\n this.lastStatusSpacer = spacer;\n this.lastStatusText = text;\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function(this: InteractiveModeBase): ChatMessageRenderOptions {\n return {\n ui: this.ui,\n cwd: this.sessionManager.getCwd(),\n markdownTheme: this.getMarkdownThemeWithSettings(),\n hideThinkingBlock: this.hideThinkingBlock,\n hiddenThinkingLabel: this.hiddenThinkingLabel,\n toolOutputExpanded: this.toolOutputExpanded,\n showImages: this.settingsManager.getShowImages(),\n imageWidthCells: this.settingsManager.getImageWidthCells(),\n outputPad: this.outputPad,\n getToolDefinition: (toolName) => this.getRegisteredToolDefinition(toolName),\n getCustomMessageRenderer: (customType) =>\n this.session.extensionRunner.getMessageRenderer(customType),\n };\n };\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function(this: InteractiveModeBase, entry: ChatMessageEntry): Component {\n const component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n addChatTranscriptEntry(this.chatContainer, component, entry.role);\n return component;\n };\n\nInteractiveModeBase.prototype.addContextCompactionSummaryToChat = function(this: InteractiveModeBase, result: ContextCompactionResult): void {\n this.chatContainer.addChild(new Spacer(1));\n const component = new ContextCompactionSummaryMessageComponent(\n result,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n };\n\nInteractiveModeBase.prototype.addMessageToChat = function(this: InteractiveModeBase, message: AgentMessage, options?: { populateHistory?: boolean }): void {\n switch (message.role) {\n case \"bashExecution\": {\n const component = new BashExecutionComponent(\n message.command,\n this.ui,\n message.excludeFromContext,\n );\n if (message.output) {\n component.appendOutput(message.output);\n }\n component.setComplete(\n message.exitCode,\n message.cancelled,\n message.truncated\n ? ({ truncated: true } as TruncationResult)\n : undefined,\n message.fullOutputPath,\n );\n this.chatContainer.addChild(component);\n break;\n }\n case \"custom\": {\n if (message.display) {\n const renderer = this.session.extensionRunner.getMessageRenderer(\n message.customType,\n );\n const component = new CustomMessageComponent(\n message,\n renderer,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n }\n break;\n }\n case \"branchSummary\": {\n this.chatContainer.addChild(new Spacer(1));\n const component = new BranchSummaryMessageComponent(\n message,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n break;\n }\n case \"user\": {\n const textContent = this.getUserMessageText(message);\n if (textContent) {\n if (this.chatContainer.children.length > 0) {\n this.chatContainer.addChild(new Spacer(1));\n }\n const skillBlock = parseSkillBlock(textContent);\n if (skillBlock) {\n // Render skill block (collapsible)\n const component = new SkillInvocationMessageComponent(\n skillBlock,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n // Render user message separately if present\n if (skillBlock.userMessage) {\n const userComponent = new UserMessageComponent(\n skillBlock.userMessage,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n } else {\n const userComponent = new UserMessageComponent(\n textContent,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n if (options?.populateHistory) {\n this.editor.addToHistory?.(textContent);\n }\n }\n break;\n }\n case \"assistant\": {\n const assistantComponent = new AssistantMessageComponent(\n message,\n this.hideThinkingBlock,\n this.getMarkdownThemeWithSettings(),\n this.hiddenThinkingLabel,\n this.outputPad,\n );\n this.chatContainer.addChild(assistantComponent);\n break;\n }\n case \"toolResult\": {\n // Tool results are rendered inline with tool calls, handled separately\n break;\n }\n default:\n break;\n }\n };\n\nInteractiveModeBase.prototype.renderSessionContext = function(this: InteractiveModeBase, sessionContext: SessionContext, options: { updateFooter?: boolean; populateHistory?: boolean } = {}): void {\n this.pendingTools.clear();\n\n if (options.updateFooter) {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n }\n\n const entries = chatEntriesFromAgentMessages(sessionContext.messages);\n for (const entry of entries) {\n const component = this.addRenderedChatEntry(entry);\n if (\n entry.kind === \"tool\" &&\n entry.isPartial !== false &&\n component instanceof ToolExecutionComponent\n ) {\n this.pendingTools.set(entry.toolCallId, component);\n }\n if (options.populateHistory && entry.kind === \"user\") {\n this.editor.addToHistory?.(entry.text);\n }\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.renderInitialMessages = function(this: InteractiveModeBase): void {\n // Get aligned messages and entries from session context\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context, {\n updateFooter: true,\n populateHistory: true,\n });\n\n // Show compaction info if session was compacted\n const allEntries = this.sessionManager.getEntries();\n const compactionCount = allEntries.filter(\n (e) => e.type === \"compaction\",\n ).length;\n if (compactionCount > 0) {\n const times =\n compactionCount === 1 ? \"1 time\" : `${compactionCount} times`;\n this.showStatus(`Session compacted ${times}`);\n }\n };\n\nInteractiveModeBase.prototype.getUserInput = async function(this: InteractiveModeBase): Promise<string> {\n const queuedInput = this.pendingUserInputs.shift();\n if (queuedInput !== undefined) {\n return queuedInput;\n }\n\n return new Promise((resolve) => {\n this.onInputCallback = (text: string) => {\n this.onInputCallback = undefined;\n resolve(text);\n };\n });\n };\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context);\n };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-session-runtime.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-session-runtime.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentSession, setRegisteredThemes, stopThemeWatcher } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.bindCurrentSessionExtensions = async function(this: InteractiveModeBase): Promise<void> {\n const uiContext = this.createExtensionUIContext();\n await this.session.bindExtensions({\n uiContext,\n mode: \"tui\",\n commandContextActions: {\n waitForIdle: () => this.session.agent.waitForIdle(),\n newSession: async (options) => {\n if (this.loadingAnimation) {\n this.loadingAnimation.stop();\n this.loadingAnimation = undefined;\n }\n this.statusContainer.clear();\n try {\n const result = await this.runtimeHost.newSession(options);\n if (!result.cancelled) {\n this.renderCurrentSessionState();\n this.ui.requestRender();\n }\n return result;\n } catch (error: unknown) {\n return this.handleFatalRuntimeError(\n \"Failed to create session\",\n error,\n );\n }\n },\n fork: async (entryId, options) => {\n try {\n const result = await this.runtimeHost.fork(entryId, options);\n if (!result.cancelled) {\n this.renderCurrentSessionState();\n this.editor.setText(result.selectedText ?? \"\");\n this.showStatus(\"Forked to new session\");\n }\n return { cancelled: result.cancelled };\n } catch (error: unknown) {\n return this.handleFatalRuntimeError(\n \"Failed to fork session\",\n error,\n );\n }\n },\n navigateTree: async (targetId, options) => {\n const result = await this.session.navigateTree(targetId, {\n summarize: options?.summarize,\n customInstructions: options?.customInstructions,\n replaceInstructions: options?.replaceInstructions,\n label: options?.label,\n });\n if (result.cancelled) {\n return { cancelled: true };\n }\n\n this.chatContainer.clear();\n this.renderInitialMessages();\n if (result.editorText && !this.editor.getText().trim()) {\n this.editor.setText(result.editorText);\n }\n this.showStatus(\"Navigated to selected point\");\n void this.flushCompactionQueue({ willRetry: false });\n return { cancelled: false };\n },\n switchSession: async (sessionPath, options) => {\n return this.handleResumeSession(sessionPath, options);\n },\n reload: async () => {\n await this.handleReloadCommand();\n },\n },\n shutdownHandler: () => {\n this.shutdownRequested = true;\n if (!this.session.isStreaming) {\n void this.shutdown();\n }\n },\n onError: (error) => {\n this.showExtensionError(error.extensionPath, error.error, error.stack);\n },\n });\n\n setRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n this.setupAutocompleteProvider();\n\n const extensionRunner = this.session.extensionRunner;\n this.setupExtensionShortcuts(extensionRunner);\n this.showLoadedResources({ force: false, showDiagnosticsWhenQuiet: true });\n this.showStartupNoticesIfNeeded();\n };\n\nInteractiveModeBase.prototype.applyRuntimeSettings = function(this: InteractiveModeBase): void {\n this.footer.setSession(this.session);\n this.usageMeter.setSession(this.session);\n this.usageMeter.setAutoCompactEnabled(this.session.autoCompactionEnabled);\n this.footerDataProvider.setCwd(this.sessionManager.getCwd());\n this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();\n this.ui.setShowHardwareCursor(this.settingsManager.getShowHardwareCursor());\n this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());\n const editorPaddingX = this.settingsManager.getEditorPaddingX();\n const autocompleteMaxVisible =\n this.settingsManager.getAutocompleteMaxVisible();\n this.defaultEditor.setPaddingX(editorPaddingX);\n this.defaultEditor.setAutocompleteMaxVisible(autocompleteMaxVisible);\n if (this.editor !== this.defaultEditor) {\n this.editor.setPaddingX?.(editorPaddingX);\n this.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);\n }\n };\n\nInteractiveModeBase.prototype.rebindCurrentSession = async function(this: InteractiveModeBase): Promise<void> {\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n this.applyRuntimeSettings();\n await this.bindCurrentSessionExtensions();\n this.subscribeToAgent();\n await this.updateAvailableProviderCount();\n this.updateEditorBorderColor();\n this.updateTerminalTitle();\n };\n\nInteractiveModeBase.prototype.handleFatalRuntimeError = async function(this: InteractiveModeBase, prefix: string, error: unknown): Promise<never> {\n const message = error instanceof Error ? error.message : String(error);\n this.showError(`${prefix}: ${message}`);\n stopThemeWatcher();\n this.stop();\n process.exit(1);\n };\n\nInteractiveModeBase.prototype.renderCurrentSessionState = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n this.pendingMessagesContainer.clear();\n this.compactionQueuedMessages = [];\n this.streamingComponent = undefined;\n this.streamingMessage = undefined;\n this.pendingTools.clear();\n this.renderInitialMessages();\n };\n\nInteractiveModeBase.prototype.getRegisteredToolDefinition = function(this: InteractiveModeBase, toolName: string): ReturnType<AgentSession[\"getToolDefinition\"]> {\n return this.session.getToolDefinition(toolName);\n };\n"]}
1
+ {"version":3,"file":"interactive-session-runtime.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-session-runtime.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentSession, setRegisteredThemes, stopThemeWatcher } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.bindCurrentSessionExtensions = async function(this: InteractiveModeBase): Promise<void> {\n const uiContext = this.createExtensionUIContext();\n await this.session.bindExtensions({\n uiContext,\n mode: \"tui\",\n commandContextActions: {\n waitForIdle: () => this.session.agent.waitForIdle(),\n newSession: async (options) => {\n if (this.loadingAnimation) {\n this.loadingAnimation.stop();\n this.loadingAnimation = undefined;\n }\n this.statusContainer.clear();\n try {\n const result = await this.runtimeHost.newSession(options);\n if (!result.cancelled) {\n this.renderCurrentSessionState();\n this.ui.requestRender();\n }\n return result;\n } catch (error: unknown) {\n return this.handleFatalRuntimeError(\n \"Failed to create session\",\n error,\n );\n }\n },\n fork: async (entryId, options) => {\n try {\n const result = await this.runtimeHost.fork(entryId, options);\n if (!result.cancelled) {\n this.renderCurrentSessionState();\n this.editor.setText(result.selectedText ?? \"\");\n this.showStatus(\"Forked to new session\");\n }\n return { cancelled: result.cancelled };\n } catch (error: unknown) {\n return this.handleFatalRuntimeError(\n \"Failed to fork session\",\n error,\n );\n }\n },\n navigateTree: async (targetId, options) => {\n const result = await this.session.navigateTree(targetId, {\n summarize: options?.summarize,\n customInstructions: options?.customInstructions,\n replaceInstructions: options?.replaceInstructions,\n label: options?.label,\n });\n if (result.cancelled) {\n return { cancelled: true };\n }\n\n this.chatContainer.clear();\n this.renderInitialMessages();\n if (result.editorText && !this.editor.getText().trim()) {\n this.editor.setText(result.editorText);\n }\n this.showStatus(\"Navigated to selected point\");\n void this.flushCompactionQueue({ willRetry: false });\n return { cancelled: false };\n },\n switchSession: async (sessionPath, options) => {\n return this.handleResumeSession(sessionPath, options);\n },\n reload: async () => {\n await this.handleReloadCommand();\n },\n },\n shutdownHandler: () => {\n this.shutdownRequested = true;\n if (!this.session.isStreaming) {\n void this.shutdown();\n }\n },\n onError: (error) => {\n this.showExtensionError(error.extensionPath, error.error, error.stack);\n },\n });\n\n setRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n this.setupAutocompleteProvider();\n\n const extensionRunner = this.session.extensionRunner;\n this.setupExtensionShortcuts(extensionRunner);\n this.showLoadedResources({ force: false, showDiagnosticsWhenQuiet: true });\n this.showStartupNoticesIfNeeded();\n };\n\nInteractiveModeBase.prototype.applyRuntimeSettings = function(this: InteractiveModeBase): void {\n this.footer.setSession(this.session);\n this.usageMeter.setSession(this.session);\n this.usageMeter.setAutoCompactEnabled(this.session.autoCompactionEnabled);\n this.footerDataProvider.setCwd(this.sessionManager.getCwd());\n this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();\n this.outputPad = this.settingsManager.getOutputPad();\n this.ui.setShowHardwareCursor(this.settingsManager.getShowHardwareCursor());\n this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());\n const editorPaddingX = this.settingsManager.getEditorPaddingX();\n const autocompleteMaxVisible =\n this.settingsManager.getAutocompleteMaxVisible();\n this.defaultEditor.setPaddingX(editorPaddingX);\n this.defaultEditor.setAutocompleteMaxVisible(autocompleteMaxVisible);\n if (this.editor !== this.defaultEditor) {\n this.editor.setPaddingX?.(editorPaddingX);\n this.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);\n }\n };\n\nInteractiveModeBase.prototype.rebindCurrentSession = async function(this: InteractiveModeBase): Promise<void> {\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n this.applyRuntimeSettings();\n await this.bindCurrentSessionExtensions();\n this.subscribeToAgent();\n await this.updateAvailableProviderCount();\n this.updateEditorBorderColor();\n this.updateTerminalTitle();\n };\n\nInteractiveModeBase.prototype.handleFatalRuntimeError = async function(this: InteractiveModeBase, prefix: string, error: unknown): Promise<never> {\n const message = error instanceof Error ? error.message : String(error);\n this.showError(`${prefix}: ${message}`);\n stopThemeWatcher();\n this.stop();\n process.exit(1);\n };\n\nInteractiveModeBase.prototype.renderCurrentSessionState = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n this.pendingMessagesContainer.clear();\n this.compactionQueuedMessages = [];\n this.streamingComponent = undefined;\n this.streamingMessage = undefined;\n this.pendingTools.clear();\n this.renderInitialMessages();\n };\n\nInteractiveModeBase.prototype.getRegisteredToolDefinition = function(this: InteractiveModeBase, toolName: string): ReturnType<AgentSession[\"getToolDefinition\"]> {\n return this.session.getToolDefinition(toolName);\n };\n"]}
@@ -88,6 +88,7 @@ InteractiveModeBase.prototype.applyRuntimeSettings = function () {
88
88
  this.usageMeter.setAutoCompactEnabled(this.session.autoCompactionEnabled);
89
89
  this.footerDataProvider.setCwd(this.sessionManager.getCwd());
90
90
  this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();
91
+ this.outputPad = this.settingsManager.getOutputPad();
91
92
  this.ui.setShowHardwareCursor(this.settingsManager.getShowHardwareCursor());
92
93
  this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());
93
94
  const editorPaddingX = this.settingsManager.getEditorPaddingX();
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-session-runtime.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-session-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,M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ts\";\nimport { type AgentSession, setRegisteredThemes, stopThemeWatcher } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.bindCurrentSessionExtensions = async function(this: InteractiveModeBase): Promise<void> {\n const uiContext = this.createExtensionUIContext();\n await this.session.bindExtensions({\n uiContext,\n mode: \"tui\",\n commandContextActions: {\n waitForIdle: () => this.session.agent.waitForIdle(),\n newSession: async (options) => {\n if (this.loadingAnimation) {\n this.loadingAnimation.stop();\n this.loadingAnimation = undefined;\n }\n this.statusContainer.clear();\n try {\n const result = await this.runtimeHost.newSession(options);\n if (!result.cancelled) {\n this.renderCurrentSessionState();\n this.ui.requestRender();\n }\n return result;\n } catch (error: unknown) {\n return this.handleFatalRuntimeError(\n \"Failed to create session\",\n error,\n );\n }\n },\n fork: async (entryId, options) => {\n try {\n const result = await this.runtimeHost.fork(entryId, options);\n if (!result.cancelled) {\n this.renderCurrentSessionState();\n this.editor.setText(result.selectedText ?? \"\");\n this.showStatus(\"Forked to new session\");\n }\n return { cancelled: result.cancelled };\n } catch (error: unknown) {\n return this.handleFatalRuntimeError(\n \"Failed to fork session\",\n error,\n );\n }\n },\n navigateTree: async (targetId, options) => {\n const result = await this.session.navigateTree(targetId, {\n summarize: options?.summarize,\n customInstructions: options?.customInstructions,\n replaceInstructions: options?.replaceInstructions,\n label: options?.label,\n });\n if (result.cancelled) {\n return { cancelled: true };\n }\n\n this.chatContainer.clear();\n this.renderInitialMessages();\n if (result.editorText && !this.editor.getText().trim()) {\n this.editor.setText(result.editorText);\n }\n this.showStatus(\"Navigated to selected point\");\n void this.flushCompactionQueue({ willRetry: false });\n return { cancelled: false };\n },\n switchSession: async (sessionPath, options) => {\n return this.handleResumeSession(sessionPath, options);\n },\n reload: async () => {\n await this.handleReloadCommand();\n },\n },\n shutdownHandler: () => {\n this.shutdownRequested = true;\n if (!this.session.isStreaming) {\n void this.shutdown();\n }\n },\n onError: (error) => {\n this.showExtensionError(error.extensionPath, error.error, error.stack);\n },\n });\n\n setRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n this.setupAutocompleteProvider();\n\n const extensionRunner = this.session.extensionRunner;\n this.setupExtensionShortcuts(extensionRunner);\n this.showLoadedResources({ force: false, showDiagnosticsWhenQuiet: true });\n this.showStartupNoticesIfNeeded();\n };\n\nInteractiveModeBase.prototype.applyRuntimeSettings = function(this: InteractiveModeBase): void {\n this.footer.setSession(this.session);\n this.usageMeter.setSession(this.session);\n this.usageMeter.setAutoCompactEnabled(this.session.autoCompactionEnabled);\n this.footerDataProvider.setCwd(this.sessionManager.getCwd());\n this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();\n this.ui.setShowHardwareCursor(this.settingsManager.getShowHardwareCursor());\n this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());\n const editorPaddingX = this.settingsManager.getEditorPaddingX();\n const autocompleteMaxVisible =\n this.settingsManager.getAutocompleteMaxVisible();\n this.defaultEditor.setPaddingX(editorPaddingX);\n this.defaultEditor.setAutocompleteMaxVisible(autocompleteMaxVisible);\n if (this.editor !== this.defaultEditor) {\n this.editor.setPaddingX?.(editorPaddingX);\n this.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);\n }\n };\n\nInteractiveModeBase.prototype.rebindCurrentSession = async function(this: InteractiveModeBase): Promise<void> {\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n this.applyRuntimeSettings();\n await this.bindCurrentSessionExtensions();\n this.subscribeToAgent();\n await this.updateAvailableProviderCount();\n this.updateEditorBorderColor();\n this.updateTerminalTitle();\n };\n\nInteractiveModeBase.prototype.handleFatalRuntimeError = async function(this: InteractiveModeBase, prefix: string, error: unknown): Promise<never> {\n const message = error instanceof Error ? error.message : String(error);\n this.showError(`${prefix}: ${message}`);\n stopThemeWatcher();\n this.stop();\n process.exit(1);\n };\n\nInteractiveModeBase.prototype.renderCurrentSessionState = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n this.pendingMessagesContainer.clear();\n this.compactionQueuedMessages = [];\n this.streamingComponent = undefined;\n this.streamingMessage = undefined;\n this.pendingTools.clear();\n this.renderInitialMessages();\n };\n\nInteractiveModeBase.prototype.getRegisteredToolDefinition = function(this: InteractiveModeBase, toolName: string): ReturnType<AgentSession[\"getToolDefinition\"]> {\n return this.session.getToolDefinition(toolName);\n };\n"]}
1
+ {"version":3,"file":"interactive-session-runtime.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-session-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAqB,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEtG,mBAAmB,CAAC,SAAS,CAAC,4BAA4B,GAAG,KAAK;IAC9D,MAAM,SAAS,GAAG,IAAI,CAAC,wBAAwB,EAAE,CAAC;IAClD,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAChC,SAAS;QACT,IAAI,EAAE,KAAK;QACX,qBAAqB,EAAE;YACrB,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE;YACnD,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;gBAC5B,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;oBAC1B,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;oBAC7B,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;gBACpC,CAAC;gBACD,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;gBAC7B,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBAC1D,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;wBACtB,IAAI,CAAC,yBAAyB,EAAE,CAAC;wBACjC,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;oBAC1B,CAAC;oBACD,OAAO,MAAM,CA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,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;IACpC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAClC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC1B,IAAI,CAAC,qBAAqB,EAAE,CAAC;AAC/B,CAAC,CAAC;AAEJ,mBAAmB,CAAC,SAAS,CAAC,2BAA2B,GAAG,UAAoC,QAAgB;IAC5G,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAClD,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentSession, setRegisteredThemes, stopThemeWatcher } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.bindCurrentSessionExtensions = async function(this: InteractiveModeBase): Promise<void> {\n const uiContext = this.createExtensionUIContext();\n await this.session.bindExtensions({\n uiContext,\n mode: \"tui\",\n commandContextActions: {\n waitForIdle: () => this.session.agent.waitForIdle(),\n newSession: async (options) => {\n if (this.loadingAnimation) {\n this.loadingAnimation.stop();\n this.loadingAnimation = undefined;\n }\n this.statusContainer.clear();\n try {\n const result = await this.runtimeHost.newSession(options);\n if (!result.cancelled) {\n this.renderCurrentSessionState();\n this.ui.requestRender();\n }\n return result;\n } catch (error: unknown) {\n return this.handleFatalRuntimeError(\n \"Failed to create session\",\n error,\n );\n }\n },\n fork: async (entryId, options) => {\n try {\n const result = await this.runtimeHost.fork(entryId, options);\n if (!result.cancelled) {\n this.renderCurrentSessionState();\n this.editor.setText(result.selectedText ?? \"\");\n this.showStatus(\"Forked to new session\");\n }\n return { cancelled: result.cancelled };\n } catch (error: unknown) {\n return this.handleFatalRuntimeError(\n \"Failed to fork session\",\n error,\n );\n }\n },\n navigateTree: async (targetId, options) => {\n const result = await this.session.navigateTree(targetId, {\n summarize: options?.summarize,\n customInstructions: options?.customInstructions,\n replaceInstructions: options?.replaceInstructions,\n label: options?.label,\n });\n if (result.cancelled) {\n return { cancelled: true };\n }\n\n this.chatContainer.clear();\n this.renderInitialMessages();\n if (result.editorText && !this.editor.getText().trim()) {\n this.editor.setText(result.editorText);\n }\n this.showStatus(\"Navigated to selected point\");\n void this.flushCompactionQueue({ willRetry: false });\n return { cancelled: false };\n },\n switchSession: async (sessionPath, options) => {\n return this.handleResumeSession(sessionPath, options);\n },\n reload: async () => {\n await this.handleReloadCommand();\n },\n },\n shutdownHandler: () => {\n this.shutdownRequested = true;\n if (!this.session.isStreaming) {\n void this.shutdown();\n }\n },\n onError: (error) => {\n this.showExtensionError(error.extensionPath, error.error, error.stack);\n },\n });\n\n setRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n this.setupAutocompleteProvider();\n\n const extensionRunner = this.session.extensionRunner;\n this.setupExtensionShortcuts(extensionRunner);\n this.showLoadedResources({ force: false, showDiagnosticsWhenQuiet: true });\n this.showStartupNoticesIfNeeded();\n };\n\nInteractiveModeBase.prototype.applyRuntimeSettings = function(this: InteractiveModeBase): void {\n this.footer.setSession(this.session);\n this.usageMeter.setSession(this.session);\n this.usageMeter.setAutoCompactEnabled(this.session.autoCompactionEnabled);\n this.footerDataProvider.setCwd(this.sessionManager.getCwd());\n this.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();\n this.outputPad = this.settingsManager.getOutputPad();\n this.ui.setShowHardwareCursor(this.settingsManager.getShowHardwareCursor());\n this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());\n const editorPaddingX = this.settingsManager.getEditorPaddingX();\n const autocompleteMaxVisible =\n this.settingsManager.getAutocompleteMaxVisible();\n this.defaultEditor.setPaddingX(editorPaddingX);\n this.defaultEditor.setAutocompleteMaxVisible(autocompleteMaxVisible);\n if (this.editor !== this.defaultEditor) {\n this.editor.setPaddingX?.(editorPaddingX);\n this.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);\n }\n };\n\nInteractiveModeBase.prototype.rebindCurrentSession = async function(this: InteractiveModeBase): Promise<void> {\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n this.applyRuntimeSettings();\n await this.bindCurrentSessionExtensions();\n this.subscribeToAgent();\n await this.updateAvailableProviderCount();\n this.updateEditorBorderColor();\n this.updateTerminalTitle();\n };\n\nInteractiveModeBase.prototype.handleFatalRuntimeError = async function(this: InteractiveModeBase, prefix: string, error: unknown): Promise<never> {\n const message = error instanceof Error ? error.message : String(error);\n this.showError(`${prefix}: ${message}`);\n stopThemeWatcher();\n this.stop();\n process.exit(1);\n };\n\nInteractiveModeBase.prototype.renderCurrentSessionState = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n this.pendingMessagesContainer.clear();\n this.compactionQueuedMessages = [];\n this.streamingComponent = undefined;\n this.streamingMessage = undefined;\n this.pendingTools.clear();\n this.renderInitialMessages();\n };\n\nInteractiveModeBase.prototype.getRegisteredToolDefinition = function(this: InteractiveModeBase, toolName: string): ReturnType<AgentSession[\"getToolDefinition\"]> {\n return this.session.getToolDefinition(toolName);\n };\n"]}
@@ -8,6 +8,7 @@ import type { ImageContent } from "@earendil-works/pi-ai/compat";
8
8
  import type { SessionStats } from "../../core/agent-session.ts";
9
9
  import type { BashResult } from "../../core/bash-executor.ts";
10
10
  import type { ContextCompactionResult } from "../../core/compaction/index.ts";
11
+ import type { SessionEntry, SessionTreeNode } from "../../core/session-manager.ts";
11
12
  import type { RpcContextWindowInfo, RpcEvent, RpcSessionState, RpcSlashCommand } from "./rpc-types.ts";
12
13
  export type { RpcContextWindowInfo, RpcEvent } from "./rpc-types.ts";
13
14
  export interface RpcClientOptions {
@@ -43,21 +44,13 @@ export declare class RpcClient {
43
44
  private exitError;
44
45
  private options;
45
46
  constructor(options?: RpcClientOptions);
46
- /**
47
- * Start the RPC agent process.
48
- */
47
+ /** Start the RPC agent process. */
49
48
  start(): Promise<void>;
50
- /**
51
- * Stop the RPC agent process.
52
- */
49
+ /** Stop the RPC agent process. */
53
50
  stop(): Promise<void>;
54
- /**
55
- * Subscribe to agent events.
56
- */
51
+ /** Subscribe to agent events. */
57
52
  onEvent(listener: RpcEventListener): () => void;
58
- /**
59
- * Get collected stderr output (useful for debugging).
60
- */
53
+ /** Get collected stderr output (useful for debugging). */
61
54
  getStderr(): string;
62
55
  /**
63
56
  * Send a prompt to the agent.
@@ -65,17 +58,11 @@ export declare class RpcClient {
65
58
  * Use waitForIdle() to wait for completion.
66
59
  */
67
60
  prompt(message: string, images?: ImageContent[]): Promise<void>;
68
- /**
69
- * Queue a steering message to interrupt the agent mid-run.
70
- */
61
+ /** Queue a steering message to interrupt the agent mid-run. */
71
62
  steer(message: string, images?: ImageContent[]): Promise<void>;
72
- /**
73
- * Queue a follow-up message to be processed after the agent finishes.
74
- */
63
+ /** Queue a follow-up message to be processed after the agent finishes. */
75
64
  followUp(message: string, images?: ImageContent[]): Promise<void>;
76
- /**
77
- * Abort current operation.
78
- */
65
+ /** Abort current operation. */
79
66
  abort(): Promise<void>;
80
67
  /**
81
68
  * Start a new session, optionally with parent tracking.
@@ -85,20 +72,14 @@ export declare class RpcClient {
85
72
  newSession(parentSession?: string): Promise<{
86
73
  cancelled: boolean;
87
74
  }>;
88
- /**
89
- * Get current session state.
90
- */
75
+ /** Get current session state. */
91
76
  getState(): Promise<RpcSessionState>;
92
- /**
93
- * Set model by provider and ID.
94
- */
77
+ /** Set model by provider and ID. */
95
78
  setModel(provider: string, modelId: string): Promise<{
96
79
  provider: string;
97
80
  id: string;
98
81
  }>;
99
- /**
100
- * Cycle to next model.
101
- */
82
+ /** Cycle to next model. */
102
83
  cycleModel(): Promise<{
103
84
  model: {
104
85
  provider: string;
@@ -107,17 +88,11 @@ export declare class RpcClient {
107
88
  thinkingLevel: ThinkingLevel;
108
89
  isScoped: boolean;
109
90
  } | null>;
110
- /**
111
- * Get list of available models.
112
- */
91
+ /** Get list of available models. */
113
92
  getAvailableModels(): Promise<ModelInfo[]>;
114
- /**
115
- * Set thinking level.
116
- */
93
+ /** Set thinking level. */
117
94
  setThinkingLevel(level: ThinkingLevel): Promise<void>;
118
- /**
119
- * Cycle thinking level.
120
- */
95
+ /** Cycle thinking level. */
121
96
  cycleThinkingLevel(): Promise<{
122
97
  level: ThinkingLevel;
123
98
  } | null>;
@@ -126,21 +101,13 @@ export declare class RpcClient {
126
101
  * This is a runtime selection and does not persist context-window defaults.
127
102
  */
128
103
  setContextWindow(contextWindow: number | string): Promise<void>;
129
- /**
130
- * Get selectable context-window token budgets for the current model.
131
- */
104
+ /** Get selectable context-window token budgets for the current model. */
132
105
  getAvailableContextWindows(): Promise<RpcContextWindowInfo>;
133
- /**
134
- * Set steering mode.
135
- */
106
+ /** Set steering mode. */
136
107
  setSteeringMode(mode: "all" | "one-at-a-time"): Promise<void>;
137
- /**
138
- * Set follow-up mode.
139
- */
108
+ /** Set follow-up mode. */
140
109
  setFollowUpMode(mode: "all" | "one-at-a-time"): Promise<void>;
141
- /**
142
- * Compact session context with deletion-only verbatim context compaction.
143
- */
110
+ /** Compact session context with deletion-only verbatim context compaction. */
144
111
  compact(): Promise<ContextCompactionResult>;
145
112
  /** @deprecated Use compact() instead. */
146
113
  contextCompact(): Promise<ContextCompactionResult>;
@@ -167,6 +134,16 @@ export declare class RpcClient {
167
134
  entryId: string;
168
135
  text: string;
169
136
  }>>;
137
+ /** Session entries in append order, optionally only those after the `since` entry id. */
138
+ getEntries(since?: string): Promise<{
139
+ entries: SessionEntry[];
140
+ leafId: string | null;
141
+ }>;
142
+ /** The session entry tree. */
143
+ getTree(): Promise<{
144
+ tree: SessionTreeNode[];
145
+ leafId: string | null;
146
+ }>;
170
147
  getLastAssistantText(): Promise<string | null>;
171
148
  setSessionName(name: string): Promise<void>;
172
149
  getMessages(): Promise<AgentMessage[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,Y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ic access to the coding agent.\n *\n * Spawns the agent in RPC mode and provides a typed API for all operations.\n */\n\nimport { type ChildProcess, spawn } from \"node:child_process\";\nimport type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent } from \"@earendil-works/pi-ai/compat\";\nimport type { SessionStats } from \"../../core/agent-session.ts\";\nimport type { BashResult } from \"../../core/bash-executor.ts\";\nimport type { ContextCompactionResult } from \"../../core/compaction/index.ts\";\nimport { attachJsonlLineReader, serializeJsonLine } from \"./jsonl.ts\";\nimport type {\n\tRpcCommand,\n\tRpcContextWindowInfo,\n\tRpcEvent,\n\tRpcResponse,\n\tRpcSessionState,\n\tRpcSlashCommand,\n} from \"./rpc-types.ts\";\nexport type { RpcContextWindowInfo, RpcEvent } from \"./rpc-types.ts\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/** Distributive Omit that works with union types */\ntype DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;\n\n/** RpcCommand without the id field (for internal send) */\ntype RpcCommandBody = DistributiveOmit<RpcCommand, \"id\">;\n\nexport interface RpcClientOptions {\n\t/** Path to the CLI entry point (default: searches for dist/cli.js) */\n\tcliPath?: string;\n\t/** Working directory for the agent */\n\tcwd?: string;\n\t/** Environment variables */\n\tenv?: Record<string, string>;\n\t/** Provider to use */\n\tprovider?: string;\n\t/** Model ID to use */\n\tmodel?: string;\n\t/** Startup context-window selection, as raw tokens or compact form like \"400k\"/\"1m\" */\n\tcontextWindow?: number | string;\n\t/** Additional CLI arguments */\n\targs?: string[];\n}\n\nexport interface ModelInfo {\n\tprovider: string;\n\tid: string;\n\tcontextWindow: number;\n\treasoning: boolean;\n}\n\nexport type RpcEventListener = (event: RpcEvent) => void;\n\n// ============================================================================\n// RPC Client\n// ============================================================================\n\nexport class RpcClient {\n\tprivate process: ChildProcess | null = null;\n\tprivate stopReadingStdout: (() => void) | null = null;\n\tprivate eventListeners: RpcEventListener[] = [];\n\tprivate pendingRequests: Map<string, { resolve: (response: RpcResponse) => void; reject: (error: Error) => void }> =\n\t\tnew Map();\n\tprivate requestId = 0;\n\tprivate stderr = \"\";\n\tprivate exitError: Error | null = null;\n\n\tdeclare private options: RpcClientOptions;\n\n\tconstructor(options: RpcClientOptions = {}) {\n\t\tthis.options = options;\n\t}\n\n\t/**\n\t * Start the RPC agent process.\n\t */\n\tasync start(): Promise<void> {\n\t\tif (this.process) {\n\t\t\tthrow new Error(\"Client already started\");\n\t\t}\n\n\t\tconst cliPath = this.options.cliPath ?? \"dist/cli.js\";\n\t\tconst args = [\"--mode\", \"rpc\"];\n\n\t\tif (this.options.provider) {\n\t\t\targs.push(\"--provider\", this.options.provider);\n\t\t}\n\t\tif (this.options.model) {\n\t\t\targs.push(\"--model\", this.options.model);\n\t\t}\n\t\tif (this.options.contextWindow !== undefined) {\n\t\t\targs.push(\"--context-window\", String(this.options.contextWindow));\n\t\t}\n\t\tif (this.options.args) {\n\t\t\targs.push(...this.options.args);\n\t\t}\n\n\t\tthis.exitError = null;\n\t\tconst childProcess = spawn(\"node\", [cliPath, ...args], {\n\t\t\tcwd: this.options.cwd,\n\t\t\tenv: { ...process.env, ...this.options.env },\n\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t});\n\t\tthis.process = childProcess;\n\n\t\tchildProcess.once(\"exit\", (code, signal) => {\n\t\t\tconst error = this.createProcessExitError(code, signal);\n\t\t\tthis.exitError = error;\n\t\t\tthis.rejectPendingRequests(error);\n\t\t});\n\t\tchildProcess.once(\"error\", (error) => {\n\t\t\tthis.exitError = error;\n\t\t\tthis.rejectPendingRequests(error);\n\t\t});\n\t\tchildProcess.stdin?.on(\"error\", (error) => {\n\t\t\tthis.exitError = error;\n\t\t\tthis.rejectPendingRequests(error);\n\t\t});\n\n\t\t// Collect stderr for debugging\n\t\tchildProcess.stderr?.on(\"data\", (data) => {\n\t\t\tthis.stderr += data.toString();\n\t\t\tprocess.stderr.write(data);\n\t\t});\n\n\t\t// Set up strict JSONL reader for stdout.\n\t\tthis.stopReadingStdout = attachJsonlLineReader(childProcess.stdout!, (line) => {\n\t\t\tthis.handleLine(line);\n\t\t});\n\n\t\t// Wait a moment for process to initialize\n\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\n\t\tif (this.process.exitCode !== null) {\n\t\t\tthrow new Error(`Agent process exited immediately with code ${this.process.exitCode}. Stderr: ${this.stderr}`);\n\t\t}\n\t}\n\n\t/**\n\t * Stop the RPC agent process.\n\t */\n\tasync stop(): Promise<void> {\n\t\tif (!this.process) return;\n\n\t\tthis.stopReadingStdout?.();\n\t\tthis.stopReadingStdout = null;\n\t\tthis.process.kill(\"SIGTERM\");\n\n\t\t// Wait for process to exit\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tthis.process?.kill(\"SIGKILL\");\n\t\t\t\tresolve();\n\t\t\t}, 1000);\n\n\t\t\tthis.process?.on(\"exit\", () => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\n\t\tthis.process = null;\n\t\tthis.pendingRequests.clear();\n\t}\n\n\t/**\n\t * Subscribe to agent events.\n\t */\n\tonEvent(listener: RpcEventListener): () => void {\n\t\tthis.eventListeners.push(listener);\n\t\treturn () => {\n\t\t\tconst index = this.eventListeners.indexOf(listener);\n\t\t\tif (index !== -1) {\n\t\t\t\tthis.eventListeners.splice(index, 1);\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Get collected stderr output (useful for debugging).\n\t */\n\tgetStderr(): string {\n\t\treturn this.stderr;\n\t}\n\n\t// =========================================================================\n\t// Command Methods\n\t// =========================================================================\n\n\t/**\n\t * Send a prompt to the agent.\n\t * Returns immediately after sending; use onEvent() to receive streaming events.\n\t * Use waitForIdle() to wait for completion.\n\t */\n\tasync prompt(message: string, images?: ImageContent[]): Promise<void> {\n\t\tawait this.send({ type: \"prompt\", message, images });\n\t}\n\n\t/**\n\t * Queue a steering message to interrupt the agent mid-run.\n\t */\n\tasync steer(message: string, images?: ImageContent[]): Promise<void> {\n\t\tawait this.send({ type: \"steer\", message, images });\n\t}\n\n\t/**\n\t * Queue a follow-up message to be processed after the agent finishes.\n\t */\n\tasync followUp(message: string, images?: ImageContent[]): Promise<void> {\n\t\tawait this.send({ type: \"follow_up\", message, images });\n\t}\n\n\t/**\n\t * Abort current operation.\n\t */\n\tasync abort(): Promise<void> {\n\t\tawait this.send({ type: \"abort\" });\n\t}\n\n\t/**\n\t * Start a new session, optionally with parent tracking.\n\t * @param parentSession - Optional parent session path for lineage tracking\n\t * @returns Object with `cancelled: true` if an extension cancelled the new session\n\t */\n\tasync newSession(parentSession?: string): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"new_session\", parentSession });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Get current session state.\n\t */\n\tasync getState(): Promise<RpcSessionState> {\n\t\tconst response = await this.send({ type: \"get_state\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Set model by provider and ID.\n\t */\n\tasync setModel(provider: string, modelId: string): Promise<{ provider: string; id: string }> {\n\t\tconst response = await this.send({ type: \"set_model\", provider, modelId });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Cycle to next model.\n\t */\n\tasync cycleModel(): Promise<{\n\t\tmodel: { provider: string; id: string };\n\t\tthinkingLevel: ThinkingLevel;\n\t\tisScoped: boolean;\n\t} | null> {\n\t\tconst response = await this.send({ type: \"cycle_model\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Get list of available models.\n\t */\n\tasync getAvailableModels(): Promise<ModelInfo[]> {\n\t\tconst response = await this.send({ type: \"get_available_models\" });\n\t\treturn this.getData<{ models: ModelInfo[] }>(response).models;\n\t}\n\n\t/**\n\t * Set thinking level.\n\t */\n\tasync setThinkingLevel(level: ThinkingLevel): Promise<void> {\n\t\tawait this.send({ type: \"set_thinking_level\", level });\n\t}\n\n\t/**\n\t * Cycle thinking level.\n\t */\n\tasync cycleThinkingLevel(): Promise<{ level: ThinkingLevel } | null> {\n\t\tconst response = await this.send({ type: \"cycle_thinking_level\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Set the active context-window token budget for the current model.\n\t * This is a runtime selection and does not persist context-window defaults.\n\t */\n\tasync setContextWindow(contextWindow: number | string): Promise<void> {\n\t\tconst response = await this.send({ type: \"set_context_window\", contextWindow });\n\t\tthis.assertSuccess(response);\n\t}\n\n\t/**\n\t * Get selectable context-window token budgets for the current model.\n\t */\n\tasync getAvailableContextWindows(): Promise<RpcContextWindowInfo> {\n\t\tconst response = await this.send({ type: \"get_available_context_windows\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Set steering mode.\n\t */\n\tasync setSteeringMode(mode: \"all\" | \"one-at-a-time\"): Promise<void> {\n\t\tawait this.send({ type: \"set_steering_mode\", mode });\n\t}\n\n\t/**\n\t * Set follow-up mode.\n\t */\n\tasync setFollowUpMode(mode: \"all\" | \"one-at-a-time\"): Promise<void> {\n\t\tawait this.send({ type: \"set_follow_up_mode\", mode });\n\t}\n\n\t/**\n\t * Compact session context with deletion-only verbatim context compaction.\n\t */\n\tasync compact(): Promise<ContextCompactionResult> {\n\t\tconst response = await this.send({ type: \"compact\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/** @deprecated Use compact() instead. */\n\tasync contextCompact(): Promise<ContextCompactionResult> {\n\t\tconst response = await this.send({ type: \"context_compact\" });\n\t\treturn this.getData(response);\n\t}\n\tasync setAutoCompaction(enabled: boolean): Promise<void> {\n\t\tawait this.send({ type: \"set_auto_compaction\", enabled });\n\t}\n\tasync setAutoRetry(enabled: boolean): Promise<void> {\n\t\tawait this.send({ type: \"set_auto_retry\", enabled });\n\t}\n\tasync abortRetry(): Promise<void> {\n\t\tawait this.send({ type: \"abort_retry\" });\n\t}\n\tasync bash(command: string): Promise<BashResult> {\n\t\tconst response = await this.send({ type: \"bash\", command });\n\t\treturn this.getData(response);\n\t}\n\tasync abortBash(): Promise<void> {\n\t\tawait this.send({ type: \"abort_bash\" });\n\t}\n\tasync getSessionStats(): Promise<SessionStats> {\n\t\tconst response = await this.send({ type: \"get_session_stats\" });\n\t\treturn this.getData(response);\n\t}\n\tasync exportHtml(outputPath?: string): Promise<{ path: string }> {\n\t\tconst response = await this.send({ type: \"export_html\", outputPath });\n\t\treturn this.getData(response);\n\t}\n\tasync switchSession(sessionPath: string): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"switch_session\", sessionPath });\n\t\treturn this.getData(response);\n\t}\n\tasync fork(entryId: string): Promise<{ text: string; cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"fork\", entryId });\n\t\treturn this.getData(response);\n\t}\n\tasync clone(): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"clone\" });\n\t\treturn this.getData(response);\n\t}\n\tasync getForkMessages(): Promise<Array<{ entryId: string; text: string }>> {\n\t\tconst response = await this.send({ type: \"get_fork_messages\" });\n\t\treturn this.getData<{ messages: Array<{ entryId: string; text: string }> }>(response).messages;\n\t}\n\tasync getLastAssistantText(): Promise<string | null> {\n\t\tconst response = await this.send({ type: \"get_last_assistant_text\" });\n\t\treturn this.getData<{ text: string | null }>(response).text;\n\t}\n\tasync setSessionName(name: string): Promise<void> {\n\t\tawait this.send({ type: \"set_session_name\", name });\n\t}\n\tasync getMessages(): Promise<AgentMessage[]> {\n\t\tconst response = await this.send({ type: \"get_messages\" });\n\t\treturn this.getData<{ messages: AgentMessage[] }>(response).messages;\n\t}\n\tasync getCommands(): Promise<RpcSlashCommand[]> {\n\t\tconst response = await this.send({ type: \"get_commands\" });\n\t\treturn this.getData<{ commands: RpcSlashCommand[] }>(response).commands;\n\t}\n\twaitForIdle(timeout = 60000): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tunsubscribe();\n\t\t\t\treject(new Error(`Timeout waiting for agent to become idle. Stderr: ${this.stderr}`));\n\t\t\t}, timeout);\n\t\t\tconst unsubscribe = this.onEvent((event) => {\n\t\t\t\tif (event.type === \"agent_end\") {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tunsubscribe();\n\t\t\t\t\tresolve();\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\tcollectEvents(timeout = 60000): Promise<RpcEvent[]> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst events: RpcEvent[] = [];\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tunsubscribe();\n\t\t\t\treject(new Error(`Timeout collecting events. Stderr: ${this.stderr}`));\n\t\t\t}, timeout);\n\t\t\tconst unsubscribe = this.onEvent((event) => {\n\t\t\t\tevents.push(event);\n\t\t\t\tif (event.type === \"agent_end\") {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tunsubscribe();\n\t\t\t\t\tresolve(events);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\tasync promptAndWait(message: string, images?: ImageContent[], timeout = 60000): Promise<RpcEvent[]> {\n\t\tconst eventsPromise = this.collectEvents(timeout);\n\t\tawait this.prompt(message, images);\n\t\treturn eventsPromise;\n\t}\n\tprivate handleLine(line: string): void {\n\t\ttry {\n\t\t\tconst data = JSON.parse(line);\n\t\t\tif (data.type === \"response\" && data.id && this.pendingRequests.has(data.id)) {\n\t\t\t\tconst pending = this.pendingRequests.get(data.id)!;\n\t\t\t\tthis.pendingRequests.delete(data.id);\n\t\t\t\tpending.resolve(data as RpcResponse);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (const listener of this.eventListeners) {\n\t\t\t\tlistener(data as RpcEvent);\n\t\t\t}\n\t\t} catch {\n\t\t}\n\t}\n\tprivate createProcessExitError(code: number | null, signal: NodeJS.Signals | null): Error {\n\t\treturn new Error(`Agent process exited (code=${code} signal=${signal}). Stderr: ${this.stderr}`);\n\t}\n\tprivate rejectPendingRequests(error: Error): void {\n\t\tfor (const { reject } of this.pendingRequests.values()) {\n\t\t\treject(error);\n\t\t}\n\t\tthis.pendingRequests.clear();\n\t}\n\tprivate async send(command: RpcCommandBody): Promise<RpcResponse> {\n\t\tconst childProcess = this.process;\n\t\tconst stdin = childProcess?.stdin;\n\t\tif (!childProcess || !stdin) {\n\t\t\tthrow new Error(\"Client not started\");\n\t\t}\n\t\tif (this.exitError) {\n\t\t\tthrow this.exitError;\n\t\t}\n\t\tif (childProcess.exitCode !== null) {\n\t\t\tconst error = this.createProcessExitError(childProcess.exitCode, childProcess.signalCode);\n\t\t\tthis.exitError = error;\n\t\t\tthrow error;\n\t\t}\n\t\tif (stdin.destroyed || !stdin.writable) {\n\t\t\tthrow new Error(\"Agent process stdin is not writable\");\n\t\t}\n\t\tconst id = `req_${++this.requestId}`;\n\t\tconst fullCommand = { ...command, id } as RpcCommand;\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tthis.pendingRequests.delete(id);\n\t\t\t\treject(new Error(`Timeout waiting for response to ${command.type}. Stderr: ${this.stderr}`));\n\t\t\t}, 30000);\n\t\t\tthis.pendingRequests.set(id, {\n\t\t\t\tresolve: (response) => {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tresolve(response);\n\t\t\t\t},\n\t\t\t\treject: (error) => {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\treject(error);\n\t\t\t\t},\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tstdin.write(serializeJsonLine(fullCommand));\n\t\t\t} catch (error) {\n\t\t\t\tthis.pendingRequests.delete(id);\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\treject(error instanceof Error ? error : new Error(String(error)));\n\t\t\t}\n\t\t});\n\t}\n\tprivate assertSuccess(response: RpcResponse): void {\n\t\tif (!response.success) {\n\t\t\tthrow new Error(response.error);\n\t\t}\n\t}\n\tprivate getData<T>(response: RpcResponse): T {\n\t\tthis.assertSuccess(response);\n\t\tconst successResponse = response as Extract<RpcResponse, { success: true; data: unknown }>;\n\t\treturn successResponse.data as T;\n\t}\n}\n"]}
1
+ {"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEnF,OAAO,KAAK,EAEX,oBAAoB,EACpB,QAAQ,EAER,eAAe,EACf,eAAe,EACf,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAYrE,MAAM,WAAW,gBAAgB;IAChC,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uFAAuF;IACvF,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,E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MAAM,GAAG,IAAI,CAAC,CAGnD;IACK,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhD;IACK,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAG3C;IACK,WAAW,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAG9C;IACD,WAAW,CAAC,OAAO,SAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAc1C;IACD,aAAa,CAAC,OAAO,SAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAgBlD;IACK,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,EAAE,OAAO,SAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAIlG;IACD,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,sBAAsB;IAG9B,OAAO,CAAC,qBAAqB;YAMf,IAAI;IA2ClB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,OAAO;CAKf","sourcesContent":["/**\n * RPC Client for programmatic access to the coding agent.\n *\n * Spawns the agent in RPC mode and provides a typed API for all operations.\n */\n\nimport { type ChildProcess, spawn } from \"node:child_process\";\nimport type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent } from \"@earendil-works/pi-ai/compat\";\nimport type { SessionStats } from \"../../core/agent-session.ts\";\nimport type { BashResult } from \"../../core/bash-executor.ts\";\nimport type { ContextCompactionResult } from \"../../core/compaction/index.ts\";\nimport type { SessionEntry, SessionTreeNode } from \"../../core/session-manager.ts\";\nimport { attachJsonlLineReader, serializeJsonLine } from \"./jsonl.ts\";\nimport type {\n\tRpcCommand,\n\tRpcContextWindowInfo,\n\tRpcEvent,\n\tRpcResponse,\n\tRpcSessionState,\n\tRpcSlashCommand,\n} from \"./rpc-types.ts\";\nexport type { RpcContextWindowInfo, RpcEvent } from \"./rpc-types.ts\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/** Distributive Omit that works with union types */\ntype DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;\n\n/** RpcCommand without the id field (for internal send) */\ntype RpcCommandBody = DistributiveOmit<RpcCommand, \"id\">;\n\nexport interface RpcClientOptions {\n\t/** Path to the CLI entry point (default: searches for dist/cli.js) */\n\tcliPath?: string;\n\t/** Working directory for the agent */\n\tcwd?: string;\n\t/** Environment variables */\n\tenv?: Record<string, string>;\n\t/** Provider to use */\n\tprovider?: string;\n\t/** Model ID to use */\n\tmodel?: string;\n\t/** Startup context-window selection, as raw tokens or compact form like \"400k\"/\"1m\" */\n\tcontextWindow?: number | string;\n\t/** Additional CLI arguments */\n\targs?: string[];\n}\n\nexport interface ModelInfo {\n\tprovider: string;\n\tid: string;\n\tcontextWindow: number;\n\treasoning: boolean;\n}\n\nexport type RpcEventListener = (event: RpcEvent) => void;\n\n// ============================================================================\n// RPC Client\n// ============================================================================\n\nexport class RpcClient {\n\tprivate process: ChildProcess | null = null;\n\tprivate stopReadingStdout: (() => void) | null = null;\n\tprivate eventListeners: RpcEventListener[] = [];\n\tprivate pendingRequests: Map<string, { resolve: (response: RpcResponse) => void; reject: (error: Error) => void }> =\n\t\tnew Map();\n\tprivate requestId = 0;\n\tprivate stderr = \"\";\n\tprivate exitError: Error | null = null;\n\n\tdeclare private options: RpcClientOptions;\n\n\tconstructor(options: RpcClientOptions = {}) {\n\t\tthis.options = options;\n\t}\n\n\t/** Start the RPC agent process. */\n\tasync start(): Promise<void> {\n\t\tif (this.process) {\n\t\t\tthrow new Error(\"Client already started\");\n\t\t}\n\n\t\tconst cliPath = this.options.cliPath ?? \"dist/cli.js\";\n\t\tconst args = [\"--mode\", \"rpc\"];\n\n\t\tif (this.options.provider) {\n\t\t\targs.push(\"--provider\", this.options.provider);\n\t\t}\n\t\tif (this.options.model) {\n\t\t\targs.push(\"--model\", this.options.model);\n\t\t}\n\t\tif (this.options.contextWindow !== undefined) {\n\t\t\targs.push(\"--context-window\", String(this.options.contextWindow));\n\t\t}\n\t\tif (this.options.args) {\n\t\t\targs.push(...this.options.args);\n\t\t}\n\n\t\tthis.exitError = null;\n\t\tconst childProcess = spawn(\"node\", [cliPath, ...args], {\n\t\t\tcwd: this.options.cwd,\n\t\t\tenv: { ...process.env, ...this.options.env },\n\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t});\n\t\tthis.process = childProcess;\n\n\t\tchildProcess.once(\"exit\", (code, signal) => {\n\t\t\tconst error = this.createProcessExitError(code, signal);\n\t\t\tthis.exitError = error;\n\t\t\tthis.rejectPendingRequests(error);\n\t\t});\n\t\tchildProcess.once(\"error\", (error) => {\n\t\t\tthis.exitError = error;\n\t\t\tthis.rejectPendingRequests(error);\n\t\t});\n\t\tchildProcess.stdin?.on(\"error\", (error) => {\n\t\t\tthis.exitError = error;\n\t\t\tthis.rejectPendingRequests(error);\n\t\t});\n\n\t\t// Collect stderr for debugging\n\t\tchildProcess.stderr?.on(\"data\", (data) => {\n\t\t\tthis.stderr += data.toString();\n\t\t\tprocess.stderr.write(data);\n\t\t});\n\n\t\t// Set up strict JSONL reader for stdout.\n\t\tthis.stopReadingStdout = attachJsonlLineReader(childProcess.stdout!, (line) => {\n\t\t\tthis.handleLine(line);\n\t\t});\n\n\t\t// Wait a moment for process to initialize\n\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\n\t\tif (this.process.exitCode !== null) {\n\t\t\tthrow new Error(`Agent process exited immediately with code ${this.process.exitCode}. Stderr: ${this.stderr}`);\n\t\t}\n\t}\n\n\t/** Stop the RPC agent process. */\n\tasync stop(): Promise<void> {\n\t\tif (!this.process) return;\n\n\t\tthis.stopReadingStdout?.();\n\t\tthis.stopReadingStdout = null;\n\t\tthis.process.kill(\"SIGTERM\");\n\n\t\t// Wait for process to exit\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tthis.process?.kill(\"SIGKILL\");\n\t\t\t\tresolve();\n\t\t\t}, 1000);\n\n\t\t\tthis.process?.on(\"exit\", () => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\n\t\tthis.process = null;\n\t\tthis.pendingRequests.clear();\n\t}\n\n\t/** Subscribe to agent events. */\n\tonEvent(listener: RpcEventListener): () => void {\n\t\tthis.eventListeners.push(listener);\n\t\treturn () => {\n\t\t\tconst index = this.eventListeners.indexOf(listener);\n\t\t\tif (index !== -1) {\n\t\t\t\tthis.eventListeners.splice(index, 1);\n\t\t\t}\n\t\t};\n\t}\n\n\t/** Get collected stderr output (useful for debugging). */\n\tgetStderr(): string {\n\t\treturn this.stderr;\n\t}\n\n\t// =========================================================================\n\t// Command Methods\n\t// =========================================================================\n\n\t/**\n\t * Send a prompt to the agent.\n\t * Returns immediately after sending; use onEvent() to receive streaming events.\n\t * Use waitForIdle() to wait for completion.\n\t */\n\tasync prompt(message: string, images?: ImageContent[]): Promise<void> {\n\t\tawait this.send({ type: \"prompt\", message, images });\n\t}\n\n\t/** Queue a steering message to interrupt the agent mid-run. */\n\tasync steer(message: string, images?: ImageContent[]): Promise<void> {\n\t\tawait this.send({ type: \"steer\", message, images });\n\t}\n\n\t/** Queue a follow-up message to be processed after the agent finishes. */\n\tasync followUp(message: string, images?: ImageContent[]): Promise<void> {\n\t\tawait this.send({ type: \"follow_up\", message, images });\n\t}\n\n\t/** Abort current operation. */\n\tasync abort(): Promise<void> {\n\t\tawait this.send({ type: \"abort\" });\n\t}\n\n\t/**\n\t * Start a new session, optionally with parent tracking.\n\t * @param parentSession - Optional parent session path for lineage tracking\n\t * @returns Object with `cancelled: true` if an extension cancelled the new session\n\t */\n\tasync newSession(parentSession?: string): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"new_session\", parentSession });\n\t\treturn this.getData(response);\n\t}\n\n\t/** Get current session state. */\n\tasync getState(): Promise<RpcSessionState> {\n\t\tconst response = await this.send({ type: \"get_state\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/** Set model by provider and ID. */\n\tasync setModel(provider: string, modelId: string): Promise<{ provider: string; id: string }> {\n\t\tconst response = await this.send({ type: \"set_model\", provider, modelId });\n\t\treturn this.getData(response);\n\t}\n\n\t/** Cycle to next model. */\n\tasync cycleModel(): Promise<{\n\t\tmodel: { provider: string; id: string };\n\t\tthinkingLevel: ThinkingLevel;\n\t\tisScoped: boolean;\n\t} | null> {\n\t\tconst response = await this.send({ type: \"cycle_model\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/** Get list of available models. */\n\tasync getAvailableModels(): Promise<ModelInfo[]> {\n\t\tconst response = await this.send({ type: \"get_available_models\" });\n\t\treturn this.getData<{ models: ModelInfo[] }>(response).models;\n\t}\n\n\t/** Set thinking level. */\n\tasync setThinkingLevel(level: ThinkingLevel): Promise<void> {\n\t\tawait this.send({ type: \"set_thinking_level\", level });\n\t}\n\n\t/** Cycle thinking level. */\n\tasync cycleThinkingLevel(): Promise<{ level: ThinkingLevel } | null> {\n\t\tconst response = await this.send({ type: \"cycle_thinking_level\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/**\n\t * Set the active context-window token budget for the current model.\n\t * This is a runtime selection and does not persist context-window defaults.\n\t */\n\tasync setContextWindow(contextWindow: number | string): Promise<void> {\n\t\tconst response = await this.send({ type: \"set_context_window\", contextWindow });\n\t\tthis.assertSuccess(response);\n\t}\n\n\t/** Get selectable context-window token budgets for the current model. */\n\tasync getAvailableContextWindows(): Promise<RpcContextWindowInfo> {\n\t\tconst response = await this.send({ type: \"get_available_context_windows\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/** Set steering mode. */\n\tasync setSteeringMode(mode: \"all\" | \"one-at-a-time\"): Promise<void> {\n\t\tawait this.send({ type: \"set_steering_mode\", mode });\n\t}\n\n\t/** Set follow-up mode. */\n\tasync setFollowUpMode(mode: \"all\" | \"one-at-a-time\"): Promise<void> {\n\t\tawait this.send({ type: \"set_follow_up_mode\", mode });\n\t}\n\n\t/** Compact session context with deletion-only verbatim context compaction. */\n\tasync compact(): Promise<ContextCompactionResult> {\n\t\tconst response = await this.send({ type: \"compact\" });\n\t\treturn this.getData(response);\n\t}\n\n\t/** @deprecated Use compact() instead. */\n\tasync contextCompact(): Promise<ContextCompactionResult> {\n\t\tconst response = await this.send({ type: \"context_compact\" });\n\t\treturn this.getData(response);\n\t}\n\tasync setAutoCompaction(enabled: boolean): Promise<void> {\n\t\tawait this.send({ type: \"set_auto_compaction\", enabled });\n\t}\n\tasync setAutoRetry(enabled: boolean): Promise<void> {\n\t\tawait this.send({ type: \"set_auto_retry\", enabled });\n\t}\n\tasync abortRetry(): Promise<void> {\n\t\tawait this.send({ type: \"abort_retry\" });\n\t}\n\tasync bash(command: string): Promise<BashResult> {\n\t\tconst response = await this.send({ type: \"bash\", command });\n\t\treturn this.getData(response);\n\t}\n\tasync abortBash(): Promise<void> {\n\t\tawait this.send({ type: \"abort_bash\" });\n\t}\n\tasync getSessionStats(): Promise<SessionStats> {\n\t\tconst response = await this.send({ type: \"get_session_stats\" });\n\t\treturn this.getData(response);\n\t}\n\tasync exportHtml(outputPath?: string): Promise<{ path: string }> {\n\t\tconst response = await this.send({ type: \"export_html\", outputPath });\n\t\treturn this.getData(response);\n\t}\n\tasync switchSession(sessionPath: string): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"switch_session\", sessionPath });\n\t\treturn this.getData(response);\n\t}\n\tasync fork(entryId: string): Promise<{ text: string; cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"fork\", entryId });\n\t\treturn this.getData(response);\n\t}\n\tasync clone(): Promise<{ cancelled: boolean }> {\n\t\tconst response = await this.send({ type: \"clone\" });\n\t\treturn this.getData(response);\n\t}\n\tasync getForkMessages(): Promise<Array<{ entryId: string; text: string }>> {\n\t\tconst response = await this.send({ type: \"get_fork_messages\" });\n\t\treturn this.getData<{ messages: Array<{ entryId: string; text: string }> }>(response).messages;\n\t}\n\n\t/** Session entries in append order, optionally only those after the `since` entry id. */\n\tasync getEntries(since?: string): Promise<{ entries: SessionEntry[]; leafId: string | null }> {\n\t\tconst response = await this.send({ type: \"get_entries\", since });\n\t\treturn this.getData<{ entries: SessionEntry[]; leafId: string | null }>(response);\n\t}\n\n\t/** The session entry tree. */\n\tasync getTree(): Promise<{ tree: SessionTreeNode[]; leafId: string | null }> {\n\t\tconst response = await this.send({ type: \"get_tree\" });\n\t\treturn this.getData<{ tree: SessionTreeNode[]; leafId: string | null }>(response);\n\t}\n\tasync getLastAssistantText(): Promise<string | null> {\n\t\tconst response = await this.send({ type: \"get_last_assistant_text\" });\n\t\treturn this.getData<{ text: string | null }>(response).text;\n\t}\n\tasync setSessionName(name: string): Promise<void> {\n\t\tawait this.send({ type: \"set_session_name\", name });\n\t}\n\tasync getMessages(): Promise<AgentMessage[]> {\n\t\tconst response = await this.send({ type: \"get_messages\" });\n\t\treturn this.getData<{ messages: AgentMessage[] }>(response).messages;\n\t}\n\tasync getCommands(): Promise<RpcSlashCommand[]> {\n\t\tconst response = await this.send({ type: \"get_commands\" });\n\t\treturn this.getData<{ commands: RpcSlashCommand[] }>(response).commands;\n\t}\n\twaitForIdle(timeout = 60000): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tunsubscribe();\n\t\t\t\treject(new Error(`Timeout waiting for agent to become idle. Stderr: ${this.stderr}`));\n\t\t\t}, timeout);\n\t\t\tconst unsubscribe = this.onEvent((event) => {\n\t\t\t\tif (event.type === \"agent_end\") {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tunsubscribe();\n\t\t\t\t\tresolve();\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\tcollectEvents(timeout = 60000): Promise<RpcEvent[]> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst events: RpcEvent[] = [];\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tunsubscribe();\n\t\t\t\treject(new Error(`Timeout collecting events. Stderr: ${this.stderr}`));\n\t\t\t}, timeout);\n\t\t\tconst unsubscribe = this.onEvent((event) => {\n\t\t\t\tevents.push(event);\n\t\t\t\tif (event.type === \"agent_end\") {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tunsubscribe();\n\t\t\t\t\tresolve(events);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\tasync promptAndWait(message: string, images?: ImageContent[], timeout = 60000): Promise<RpcEvent[]> {\n\t\tconst eventsPromise = this.collectEvents(timeout);\n\t\tawait this.prompt(message, images);\n\t\treturn eventsPromise;\n\t}\n\tprivate handleLine(line: string): void {\n\t\ttry {\n\t\t\tconst data = JSON.parse(line);\n\t\t\tif (data.type === \"response\" && data.id && this.pendingRequests.has(data.id)) {\n\t\t\t\tconst pending = this.pendingRequests.get(data.id)!;\n\t\t\t\tthis.pendingRequests.delete(data.id);\n\t\t\t\tpending.resolve(data as RpcResponse);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (const listener of this.eventListeners) {\n\t\t\t\tlistener(data as RpcEvent);\n\t\t\t}\n\t\t} catch {\n\t\t}\n\t}\n\tprivate createProcessExitError(code: number | null, signal: NodeJS.Signals | null): Error {\n\t\treturn new Error(`Agent process exited (code=${code} signal=${signal}). Stderr: ${this.stderr}`);\n\t}\n\tprivate rejectPendingRequests(error: Error): void {\n\t\tfor (const { reject } of this.pendingRequests.values()) {\n\t\t\treject(error);\n\t\t}\n\t\tthis.pendingRequests.clear();\n\t}\n\tprivate async send(command: RpcCommandBody): Promise<RpcResponse> {\n\t\tconst childProcess = this.process;\n\t\tconst stdin = childProcess?.stdin;\n\t\tif (!childProcess || !stdin) {\n\t\t\tthrow new Error(\"Client not started\");\n\t\t}\n\t\tif (this.exitError) {\n\t\t\tthrow this.exitError;\n\t\t}\n\t\tif (childProcess.exitCode !== null) {\n\t\t\tconst error = this.createProcessExitError(childProcess.exitCode, childProcess.signalCode);\n\t\t\tthis.exitError = error;\n\t\t\tthrow error;\n\t\t}\n\t\tif (stdin.destroyed || !stdin.writable) {\n\t\t\tthrow new Error(\"Agent process stdin is not writable\");\n\t\t}\n\t\tconst id = `req_${++this.requestId}`;\n\t\tconst fullCommand = { ...command, id } as RpcCommand;\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tthis.pendingRequests.delete(id);\n\t\t\t\treject(new Error(`Timeout waiting for response to ${command.type}. Stderr: ${this.stderr}`));\n\t\t\t}, 30000);\n\t\t\tthis.pendingRequests.set(id, {\n\t\t\t\tresolve: (response) => {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tresolve(response);\n\t\t\t\t},\n\t\t\t\treject: (error) => {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\treject(error);\n\t\t\t\t},\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tstdin.write(serializeJsonLine(fullCommand));\n\t\t\t} catch (error) {\n\t\t\t\tthis.pendingRequests.delete(id);\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\treject(error instanceof Error ? error : new Error(String(error)));\n\t\t\t}\n\t\t});\n\t}\n\tprivate assertSuccess(response: RpcResponse): void {\n\t\tif (!response.success) {\n\t\t\tthrow new Error(response.error);\n\t\t}\n\t}\n\tprivate getData<T>(response: RpcResponse): T {\n\t\tthis.assertSuccess(response);\n\t\tconst successResponse = response as Extract<RpcResponse, { success: true; data: unknown }>;\n\t\treturn successResponse.data as T;\n\t}\n}\n"]}