@bastani/atomic 0.9.28-alpha.2 → 0.9.28-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/native-client-licenses/NOTICE +2 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +11 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +14733 -14704
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +8 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -2
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +3 -2
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +1 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +1 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +6 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +22 -4
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/child-session-options.d.ts.map +1 -1
- package/dist/core/child-session-options.js +17 -2
- package/dist/core/child-session-options.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts +3 -4
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +14 -9
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/tool-events.d.ts +1 -1
- package/dist/core/extensions/tool-events.js.map +1 -1
- package/dist/core/extensions/ts-source-specifiers.d.ts +18 -0
- package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -0
- package/dist/core/extensions/ts-source-specifiers.js +142 -0
- package/dist/core/extensions/ts-source-specifiers.js.map +1 -0
- package/dist/core/sdk-exports.d.ts +2 -2
- package/dist/core/sdk-exports.js.map +1 -1
- package/dist/core/sdk-types.d.ts +3 -0
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +17 -8
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-merge.d.ts +3 -0
- package/dist/core/settings-merge.d.ts.map +1 -1
- package/dist/core/settings-merge.js +18 -4
- package/dist/core/settings-merge.js.map +1 -1
- package/dist/core/settings-storage.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +14 -1
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/tool.js +2 -2
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +19 -8
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/mcp/cli.js +18 -24
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/client/auth-provider.d.ts +4 -0
- package/dist/extensions/mcp/client/auth-provider.d.ts.map +1 -1
- package/dist/extensions/mcp/client/auth-provider.js.map +1 -1
- package/dist/extensions/mcp/client/oauth/discovery.d.ts +3 -0
- package/dist/extensions/mcp/client/oauth/discovery.d.ts.map +1 -1
- package/dist/extensions/mcp/client/oauth/discovery.js +8 -5
- package/dist/extensions/mcp/client/oauth/discovery.js.map +1 -1
- package/dist/extensions/mcp/client/oauth/flow.d.ts +4 -0
- package/dist/extensions/mcp/client/oauth/flow.d.ts.map +1 -1
- package/dist/extensions/mcp/client/oauth/flow.js +12 -2
- package/dist/extensions/mcp/client/oauth/flow.js.map +1 -1
- package/dist/extensions/mcp/client/transports/streamable-http.d.ts +3 -0
- package/dist/extensions/mcp/client/transports/streamable-http.d.ts.map +1 -1
- package/dist/extensions/mcp/client/transports/streamable-http.js +17 -14
- package/dist/extensions/mcp/client/transports/streamable-http.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +150 -72
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/oauth.d.ts +5 -3
- package/dist/extensions/mcp/oauth.d.ts.map +1 -1
- package/dist/extensions/mcp/oauth.js +36 -10
- package/dist/extensions/mcp/oauth.js.map +1 -1
- package/dist/extensions/mcp/ui.d.ts +3 -3
- package/dist/extensions/mcp/ui.d.ts.map +1 -1
- package/dist/extensions/mcp/ui.js +10 -2
- package/dist/extensions/mcp/ui.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main-deferred-startup.d.ts +1 -0
- package/dist/main-deferred-startup.d.ts.map +1 -1
- package/dist/main-deferred-startup.js +9 -21
- package/dist/main-deferred-startup.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +8 -6
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +1 -47
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +0 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +0 -1
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +0 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-restore.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-prompt-restore.js +0 -5
- package/dist/modes/interactive/interactive-prompt-restore.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +0 -5
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +7 -0
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +20 -3
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-command-timeouts.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-timeouts.js +1 -0
- package/dist/modes/rpc/rpc-command-timeouts.js.map +1 -1
- package/dist/utils/ansi.d.ts +8 -0
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +29 -10
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +13 -3
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts +8 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +1 -0
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/image-resize-worker.js +3 -2
- package/dist/utils/image-resize-worker.js.map +1 -1
- package/dist/utils/image-resize.d.ts +2 -2
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +7 -10
- package/dist/utils/image-resize.js.map +1 -1
- package/docs/codemode.md +21 -1
- package/docs/llama-cpp.md +9 -2
- package/docs/mcp-servers.md +3 -3
- package/docs/models.md +10 -0
- package/docs/providers.md +27 -4
- package/docs/reference/cli.md +2 -2
- package/docs/sdk/reference.md +3 -3
- package/docs/settings.md +2 -2
- package/docs/tools.md +1 -1
- package/docs/workflows/operations.md +2 -2
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-render-chat.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAqB,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AACtH,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,4BAA4B,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACtH,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAEN,QAAQ,EACR,yBAAyB,EACzB,sBAAsB,EACtB,sBAAsB,EACtB,6BAA6B,EAG7B,kCAAkC,EAElC,sBAAsB,EACtB,4BAA4B,EAC5B,iCAAiC,EACjC,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EAEtB,+BAA+B,EAC/B,MAAM,EACN,IAAI,EACJ,sBAAs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,OAAO,CAAC,UAAU,KAAK,YAAY,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IACxG,MAAM,OAAO,GAAG,OAAO,CAAC,OAA4C,CAAC;IACrE,IAAI,OAAO,EAAE,QAAQ,KAAK,gBAAgB;QAAE,OAAO,KAAK,CAAC;IACzD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;QAC7C,CAAC,CAAC,OAAO,CAAC,OAAO;aACd,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC;aACxC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;aAC1B,IAAI,CAAC,IAAI,CAAC;QACb,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACnB,OAAO,OAAO,KAAK,0BAA0B,GAAG,MAAM,CAAC,aAAa,CAAC;AACtE,CAAC","sourcesContent":["import type { AssistantMessage, Usage } from \"@bastani/pi-ai/compat\";\nimport { CONFIG_DIR_NAME } from \"../../config.js\";\nimport { collectCacheMisses, createCacheMissModelSource, describeCacheMissCause } from \"../../core/cache-stats.ts\";\nimport { markLifecycleTiming } from \"../../core/lifecycle-timings.ts\";\nimport { VERBATIM_COMPACTION_PREFIX } from \"../../core/messages.ts\";\nimport type { CustomEntry } from \"../../core/session-manager.ts\";\nimport { buildContextEntries, type SessionEntry, sessionEntryToContextMessages } from \"../../core/session-manager.ts\";\nimport { yieldToEventLoop } from \"../../utils/event-loop.ts\";\nimport { IsolatedInteractiveRuntime } from \"../interactive-engine/isolated-runtime.js\";\nimport { RemoteCustomMessageComponent, RemoteToolExecutionComponent } from \"../interactive-engine/remote-renderer.ts\";\nimport { appendBoundedStderr } from \"../rpc/rpc-client-process.js\";\nimport { CustomEntryComponent } from \"./components/custom-entry.ts\";\nimport { createMermaidMarkdownTransformer } from \"./components/mermaid.ts\";\nimport { ThemedText } from \"./components/themed-text.js\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport {\n\ttype AgentMessage,\n\tAPP_NAME,\n\tAssistantMessageComponent,\n\taddChatTranscriptEntry,\n\tBashExecutionComponent,\n\tBranchSummaryMessageComponent,\n\ttype ChatMessageEntry,\n\ttype ChatMessageRenderOptions,\n\tCompactionBoundaryMessageComponent,\n\ttype Component,\n\tCustomMessageComponent,\n\tchatEntriesFromAgentMessages,\n\thasTrustRequiringProjectResources,\n\tparseSkillBlock,\n\trecordTimeSinceReset,\n\trenderChatMessageEntry,\n\ttype SessionContext,\n\tSkillInvocationMessageComponent,\n\tSpacer,\n\tText,\n\tToolExecutionComponent,\n\ttype TruncationResult,\n\ttheme,\n\tUserMessageComponent,\n\ttype VerbatimCompactionResult,\n} from \"./interactive-mode-deps.ts\";\nimport type { InteractiveSubmission } from \"./interactive-submission.ts\";\nimport { refreshInteractiveTasks } from \"./interactive-task-projection.js\";\n\nfunction countDroppedThinkingBlocks(message: AssistantMessage): number {\n\treturn (message.diagnostics ?? []).reduce((count, diagnostic) => {\n\t\tif (diagnostic.type !== \"anthropic_input_transformations\") return count;\n\t\tconst dropped = diagnostic.details?.droppedBlockCount;\n\t\treturn count + (typeof dropped === \"number\" && dropped > 0 ? dropped : 0);\n\t}, 0);\n}\n\nInteractiveModeBase.prototype.maybeShowAssistantDiagnostics = function (\n\tthis: InteractiveModeBase,\n\tmessage: AssistantMessage,\n): void {\n\tif (!this.settingsManager.getShowCacheMissNotices()) return;\n\n\tconst count = countDroppedThinkingBlocks(message);\n\tif (count === 0) return;\n\tlet previousCount = 0;\n\t// The live message_end notification precedes persistence of this response.\n\tconst branch = this.sessionManager.getBranch();\n\tfor (let i = branch.length - 1; i >= 0; i--) {\n\t\tconst entry = branch[i];\n\t\tif (entry.type === \"message\" && entry.message.role === \"assistant\") {\n\t\t\tpreviousCount = countDroppedThinkingBlocks(entry.message);\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (count <= previousCount) return;\n\tconst noun = count === 1 ? \"thinking block\" : \"thinking blocks\";\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(\n\t\tnew Text(theme.fg(\"warning\", `Anthropic dropped ${count} ${noun} (details in session)`), 1, 0),\n\t);\n};\n\n// Weak keys leave cleared/rebuilt transcripts collectible without separate lifecycle state.\n// Only persistent diagnostic statuses participate; ordinary chat/status is never evicted.\nconst diagnosticStatuses = new WeakMap<Component, { spacer: Spacer; bytes: number }>();\nconst MAX_DIAGNOSTIC_STATUSES = 64;\nconst MAX_DIAGNOSTIC_HISTORY_BYTES = 256 * 1024;\n\nInteractiveModeBase.prototype.showStatus = function (\n\tthis: InteractiveModeBase,\n\tmessage: string,\n\tpersist = false,\n): void {\n\tconst children = this.chatContainer.children;\n\tconst last = children.length > 0 ? children[children.length - 1] : undefined;\n\tconst secondLast = children.length > 1 ? children[children.length - 2] : undefined;\n\n\tif (!persist && last && secondLast && last === this.lastStatusText && secondLast === this.lastStatusSpacer) {\n\t\tthis.lastStatusText.setText(theme.fg(\"dim\", message));\n\t\tthis.ui.requestRender();\n\t\treturn;\n\t}\n\n\tif (persist) message = appendBoundedStderr(\"\", message);\n\tconst spacer = new Spacer(1);\n\tconst text = new Text(theme.fg(\"dim\", message), 1, 0);\n\tthis.chatContainer.addChild(spacer);\n\tthis.chatContainer.addChild(text);\n\tthis.lastStatusSpacer = persist ? undefined : spacer;\n\tthis.lastStatusText = persist ? undefined : text;\n\tif (persist) {\n\t\tdiagnosticStatuses.set(text, { spacer, bytes: Buffer.byteLength(message) });\n\t\tlet count = 0;\n\t\tlet bytes = 0;\n\t\tfor (const child of [...children].reverse()) {\n\t\t\tconst diagnostic = diagnosticStatuses.get(child);\n\t\t\tif (!diagnostic) continue;\n\t\t\tcount++;\n\t\t\tbytes += diagnostic.bytes;\n\t\t\tif (count > MAX_DIAGNOSTIC_STATUSES || bytes > MAX_DIAGNOSTIC_HISTORY_BYTES) {\n\t\t\t\tthis.chatContainer.removeChild(child);\n\t\t\t\tthis.chatContainer.removeChild(diagnostic.spacer);\n\t\t\t}\n\t\t}\n\t}\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.renderDeferredUserInput = function (this: InteractiveModeBase, text: string): void {\n\tthis.deferredRenderedUserInputs.push(text);\n\tconst startIndex = this.chatContainer.children.length;\n\tthis.addMessageToChat({ role: \"user\", content: text } as AgentMessage);\n\tconst renderedComponents = this.chatContainer.children.slice(startIndex);\n\tconst trackedComponents = this.deferredRenderedUserInputComponents.get(text) ?? [];\n\ttrackedComponents.push(renderedComponents);\n\tthis.deferredRenderedUserInputComponents.set(text, trackedComponents);\n\tthis.updatePendingMessagesDisplay();\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.consumeDeferredRenderedUserInput = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n): boolean {\n\tconst index = this.deferredRenderedUserInputs.indexOf(text);\n\tif (index === -1) return false;\n\tthis.deferredRenderedUserInputs.splice(index, 1);\n\tconst trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n\ttrackedComponents?.shift();\n\tif (trackedComponents && trackedComponents.length === 0) {\n\t\tthis.deferredRenderedUserInputComponents.delete(text);\n\t}\n\treturn true;\n};\n\nInteractiveModeBase.prototype.discardDeferredRenderedUserInput = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n): void {\n\tconst index = this.deferredRenderedUserInputs.indexOf(text);\n\tif (index !== -1) this.deferredRenderedUserInputs.splice(index, 1);\n\tconst trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n\tconst componentsToRemove = trackedComponents?.shift();\n\tif (trackedComponents && trackedComponents.length === 0) {\n\t\tthis.deferredRenderedUserInputComponents.delete(text);\n\t}\n\tif (!componentsToRemove) return;\n\tfor (const component of componentsToRemove) {\n\t\tthis.chatContainer.removeChild(component);\n\t}\n\tthis.updatePendingMessagesDisplay();\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.getMarkdownTransformers = function (this: InteractiveModeBase) {\n\tconst mode = this.settingsManager.getMermaidRenderingMode();\n\tif (this.mermaidMarkdownTransformerMode !== mode) {\n\t\tthis.mermaidMarkdownTransformerMode = mode;\n\t\tthis.mermaidMarkdownTransformer = createMermaidMarkdownTransformer({\n\t\t\tgetMode: () => this.settingsManager.getMermaidRenderingMode(),\n\t\t\ttheme,\n\t\t});\n\t}\n\tconst extensionTransformers =\n\t\tthis.runtimeHost instanceof IsolatedInteractiveRuntime\n\t\t\t? []\n\t\t\t: this.session.extensionRunner.getMarkdownTransformers();\n\treturn [this.mermaidMarkdownTransformer, ...extensionTransformers];\n};\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function (\n\tthis: InteractiveModeBase,\n): ChatMessageRenderOptions {\n\tconst isolated = this.runtimeHost instanceof IsolatedInteractiveRuntime;\n\treturn {\n\t\tui: this.ui,\n\t\tcwd: this.sessionManager.getCwd(),\n\t\tmarkdownTheme: this.getMarkdownThemeWithSettings(),\n\t\thideThinkingBlock: this.hideThinkingBlock,\n\t\thiddenThinkingLabel: this.hiddenThinkingLabel,\n\t\ttoolOutputExpanded: this.toolOutputExpanded,\n\t\tshowImages: this.settingsManager.getShowImages(),\n\t\timageWidthCells: this.settingsManager.getImageWidthCells(),\n\t\toutputPad: this.outputPad,\n\t\trenderLatex: this.settingsManager.getLatexRenderingEnabled(),\n\t\tmarkdownTransformers: this.getMarkdownTransformers(),\n\t\tgetToolDefinition: isolated ? undefined : (toolName) => this.getRegisteredToolDefinition(toolName),\n\t\tgetCustomMessageRenderer: isolated\n\t\t\t? undefined\n\t\t\t: (customType) => this.session.extensionRunner.getMessageRenderer(customType),\n\t\tcreateToolComponent: isolated\n\t\t\t? (entry) => {\n\t\t\t\t\tconst component = new RemoteToolExecutionComponent(\n\t\t\t\t\t\tentry.toolName,\n\t\t\t\t\t\tentry.toolCallId,\n\t\t\t\t\t\tentry.args,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tshowImages: this.settingsManager.getShowImages(),\n\t\t\t\t\t\t\timageWidthCells: this.settingsManager.getImageWidthCells(),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.runtimeHost as IsolatedInteractiveRuntime,\n\t\t\t\t\t\t() => this.ui.requestRender(),\n\t\t\t\t\t);\n\t\t\t\t\tcomponent.setExpanded(this.toolOutputExpanded);\n\t\t\t\t\tif (entry.result) component.updateResult(entry.result, entry.isPartial ?? false);\n\t\t\t\t\treturn component;\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tcreateCustomMessageComponent: isolated\n\t\t\t? (message) => {\n\t\t\t\t\tconst component = new RemoteCustomMessageComponent(\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tthis.runtimeHost as IsolatedInteractiveRuntime,\n\t\t\t\t\t\t() => this.ui.requestRender(),\n\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t);\n\t\t\t\t\tcomponent.setExpanded(this.toolOutputExpanded);\n\t\t\t\t\treturn component;\n\t\t\t\t}\n\t\t\t: undefined,\n\t};\n};\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function (\n\tthis: InteractiveModeBase,\n\tentry: ChatMessageEntry,\n): Component {\n\tconst component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n\taddChatTranscriptEntry(this.chatContainer, component, entry.role);\n\treturn component;\n};\n\nInteractiveModeBase.prototype.addCompactionBoundaryToChat = function (\n\tthis: InteractiveModeBase,\n\tresult: VerbatimCompactionResult,\n): void {\n\tthis.chatContainer.addChild(new Spacer(1));\n\tconst component = new CompactionBoundaryMessageComponent(result);\n\tcomponent.setExpanded(this.toolOutputExpanded);\n\tthis.chatContainer.addChild(component);\n};\n\nInteractiveModeBase.prototype.addCompactionCostNotice = function (\n\tthis: InteractiveModeBase,\n\tkind: \"compaction\" | \"branch_summary\",\n\tusage: Usage,\n): void {\n\tif (!this.settingsManager.getShowCacheMissNotices()) return;\n\tconst tokens = usage.input + usage.output + usage.cacheRead + usage.cacheWrite;\n\tconst cost = usage.cost.total >= 0.01 ? ` (~$${usage.cost.total.toFixed(2)})` : \"\";\n\tconst label = kind === \"compaction\" ? \"Compaction\" : \"Branch summary\";\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(\n\t\tnew Text(theme.fg(\"warning\", `${label}: ${tokens.toLocaleString()} tokens billed${cost}`), 1, 0),\n\t);\n};\n\nInteractiveModeBase.prototype.addCustomEntryToChat = function (this: InteractiveModeBase, entry: CustomEntry): void {\n\tconst renderer = this.session.extensionRunner.getEntryRenderer(entry.customType);\n\tif (!renderer) return;\n\tconst runner = this.session.extensionRunner;\n\tconst component = new CustomEntryComponent(entry, (...args) => runner.renderEntry(entry.customType, ...args));\n\tcomponent.setExpanded(this.toolOutputExpanded);\n\tif (!component.hasContent()) return;\n\tconst streamingIndex = this.streamingComponent ? this.chatContainer.children.indexOf(this.streamingComponent) : -1;\n\tif (streamingIndex >= 0) this.chatContainer.children.splice(streamingIndex, 0, component);\n\telse this.chatContainer.addChild(component);\n};\n\nInteractiveModeBase.prototype.addMessageToChat = function (\n\tthis: InteractiveModeBase,\n\tmessage: AgentMessage,\n\toptions?: { populateHistory?: boolean },\n): void {\n\tconst markdownTransformers = this.getMarkdownTransformers();\n\tswitch (message.role) {\n\t\tcase \"bashExecution\": {\n\t\t\tconst component = new BashExecutionComponent(message.command, this.ui, message.excludeFromContext);\n\t\t\tif (message.output) {\n\t\t\t\tcomponent.appendOutput(message.output);\n\t\t\t}\n\t\t\tcomponent.setComplete(\n\t\t\t\tmessage.exitCode,\n\t\t\t\tmessage.cancelled,\n\t\t\t\tmessage.truncated ? ({ truncated: true } as TruncationResult) : undefined,\n\t\t\t\tmessage.fullOutputPath,\n\t\t\t);\n\t\t\tthis.chatContainer.addChild(component);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"custom\": {\n\t\t\tif (message.display) {\n\t\t\t\tconst component =\n\t\t\t\t\tthis.runtimeHost instanceof IsolatedInteractiveRuntime\n\t\t\t\t\t\t? new RemoteCustomMessageComponent(\n\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\tthis.runtimeHost,\n\t\t\t\t\t\t\t\t() => this.ui.requestRender(),\n\t\t\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: new CustomMessageComponent(\n\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\tthis.session.extensionRunner.getMessageRenderer(message.customType),\n\t\t\t\t\t\t\t\tthis.getMarkdownThemeWithSettings(),\n\t\t\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t\t\t\tthis.settingsManager.getLatexRenderingEnabled(),\n\t\t\t\t\t\t\t);\n\t\t\t\tcomponent.setExpanded(this.toolOutputExpanded);\n\t\t\t\tthis.chatContainer.addChild(component);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"branchSummary\": {\n\t\t\tthis.chatContainer.addChild(new Spacer(1));\n\t\t\tconst component = new BranchSummaryMessageComponent(\n\t\t\t\tmessage,\n\t\t\t\tthis.getMarkdownThemeWithSettings(),\n\t\t\t\tthis.settingsManager.getLatexRenderingEnabled(),\n\t\t\t);\n\t\t\tcomponent.setExpanded(this.toolOutputExpanded);\n\t\t\tthis.chatContainer.addChild(component);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"user\": {\n\t\t\tconst textContent = this.getUserMessageText(message);\n\t\t\tif (textContent) {\n\t\t\t\tif (this.chatContainer.children.length > 0) {\n\t\t\t\t\tthis.chatContainer.addChild(new Spacer(1));\n\t\t\t\t}\n\t\t\t\tconst skillBlock = parseSkillBlock(textContent);\n\t\t\t\tif (skillBlock) {\n\t\t\t\t\t// Render skill block (collapsible)\n\t\t\t\t\tconst component = new SkillInvocationMessageComponent(\n\t\t\t\t\t\tskillBlock,\n\t\t\t\t\t\tthis.getMarkdownThemeWithSettings(),\n\t\t\t\t\t\tthis.settingsManager.getLatexRenderingEnabled(),\n\t\t\t\t\t);\n\t\t\t\t\tcomponent.setExpanded(this.toolOutputExpanded);\n\t\t\t\t\tthis.chatContainer.addChild(component);\n\t\t\t\t\t// Render user message separately if present\n\t\t\t\t\tif (skillBlock.userMessage) {\n\t\t\t\t\t\tconst userComponent = new UserMessageComponent(\n\t\t\t\t\t\t\tskillBlock.userMessage,\n\t\t\t\t\t\t\tthis.getMarkdownThemeWithSettings(),\n\t\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t\t\tmarkdownTransformers,\n\t\t\t\t\t\t\tthis.settingsManager.getLatexRenderingEnabled(),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.chatContainer.addChild(userComponent);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst userComponent = new UserMessageComponent(\n\t\t\t\t\t\ttextContent,\n\t\t\t\t\t\tthis.getMarkdownThemeWithSettings(),\n\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t\tmarkdownTransformers,\n\t\t\t\t\t\tthis.settingsManager.getLatexRenderingEnabled(),\n\t\t\t\t\t);\n\t\t\t\t\tthis.chatContainer.addChild(userComponent);\n\t\t\t\t}\n\t\t\t\tif (options?.populateHistory) {\n\t\t\t\t\tthis.editor.addToHistory?.(textContent);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"assistant\": {\n\t\t\tconst assistantComponent = new AssistantMessageComponent(\n\t\t\t\tmessage,\n\t\t\t\tthis.hideThinkingBlock,\n\t\t\t\tthis.getMarkdownThemeWithSettings(),\n\t\t\t\tthis.hiddenThinkingLabel,\n\t\t\t\tthis.outputPad,\n\t\t\t\tmarkdownTransformers,\n\t\t\t\tfalse,\n\t\t\t\tthis.settingsManager.getLatexRenderingEnabled(),\n\t\t\t);\n\t\t\tthis.chatContainer.addChild(assistantComponent);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"toolResult\": {\n\t\t\t// Tool results are rendered inline with tool calls, handled separately\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tbreak;\n\t}\n};\n\nInteractiveModeBase.prototype.renderSessionContext = function (\n\tthis: InteractiveModeBase,\n\tsessionContext: SessionContext,\n\toptions: { updateFooter?: boolean; populateHistory?: boolean } = {},\n): void {\n\tthis.pendingTools.clear();\n\tconst pendingDeferredInputs = [...this.deferredRenderedUserInputs];\n\tthis.deferredRenderedUserInputs = [];\n\tthis.deferredRenderedUserInputComponents.clear();\n\n\tif (options.updateFooter) {\n\t\tthis.footer.invalidate();\n\t\tthis.updateEditorBorderColor();\n\t}\n\n\tconst entries = chatEntriesFromAgentMessages(sessionContext.messages);\n\tfor (const entry of entries) {\n\t\tconst component = this.addRenderedChatEntry(entry);\n\t\tif (entry.kind === \"tool\" && entry.isPartial !== false && component instanceof ToolExecutionComponent) {\n\t\t\tthis.pendingTools.set(entry.toolCallId, component);\n\t\t}\n\t\tif (options.populateHistory && entry.kind === \"user\") {\n\t\t\tthis.editor.addToHistory?.(entry.text);\n\t\t}\n\t}\n\n\tfor (const input of pendingDeferredInputs) {\n\t\tthis.renderDeferredUserInput(input);\n\t}\n\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.renderSessionEntries = function (\n\tthis: InteractiveModeBase,\n\tsessionEntries: SessionEntry[],\n\toptions: {\n\t\tupdateFooter?: boolean;\n\t\tpopulateHistory?: boolean;\n\t\tsuppressCompactionBoundary?: VerbatimCompactionResult;\n\t} = {},\n): void {\n\tthis.pendingTools.clear();\n\tconst deferredInputs = [...this.deferredRenderedUserInputs];\n\tthis.deferredRenderedUserInputs = [];\n\tthis.deferredRenderedUserInputComponents.clear();\n\tif (options.updateFooter) {\n\t\tthis.footer.invalidate();\n\t\tthis.updateEditorBorderColor();\n\t}\n\tlet messageBuffer: AgentMessage[] = [];\n\tlet firstMessage = true;\n\tconst flushMessages = (): void => {\n\t\tif (\n\t\t\toptions.suppressCompactionBoundary &&\n\t\t\tfirstMessage &&\n\t\t\tisSynthesizedCompactionBoundary(messageBuffer[0], options.suppressCompactionBoundary)\n\t\t) {\n\t\t\tmessageBuffer = messageBuffer.slice(1);\n\t\t}\n\t\tfirstMessage = false;\n\t\tfor (const entry of chatEntriesFromAgentMessages(messageBuffer)) {\n\t\t\tconst component = this.addRenderedChatEntry(entry);\n\t\t\tif (entry.kind === \"tool\" && entry.isPartial !== false && component instanceof ToolExecutionComponent) {\n\t\t\t\tthis.pendingTools.set(entry.toolCallId, component);\n\t\t\t}\n\t\t\tif (options.populateHistory && entry.kind === \"user\") this.editor.addToHistory?.(entry.text);\n\t\t}\n\t\tmessageBuffer = [];\n\t};\n\tfor (const entry of sessionEntries) {\n\t\tif (entry.type === \"custom\") {\n\t\t\tflushMessages();\n\t\t\tthis.addCustomEntryToChat(entry);\n\t\t} else {\n\t\t\tmessageBuffer.push(...sessionEntryToContextMessages(entry));\n\t\t\tif ((entry.type === \"compaction\" || entry.type === \"branch_summary\") && entry.usage) {\n\t\t\t\tflushMessages();\n\t\t\t\tconst suppressedLiveBoundary =\n\t\t\t\t\tentry.type === \"compaction\" &&\n\t\t\t\t\toptions.suppressCompactionBoundary !== undefined &&\n\t\t\t\t\tentry.summary === options.suppressCompactionBoundary.compactedText &&\n\t\t\t\t\tentry.tokensBefore === options.suppressCompactionBoundary.tokensBefore;\n\t\t\t\tif (!suppressedLiveBoundary) this.addCompactionCostNotice(entry.type, entry.usage);\n\t\t\t}\n\t\t}\n\t}\n\tflushMessages();\n\tif (this.settingsManager.getShowCacheMissNotices()) {\n\t\tfor (const miss of collectCacheMisses(\n\t\t\tsessionEntries,\n\t\t\tcreateCacheMissModelSource(this.session.modelRuntime),\n\t\t).values()) {\n\t\t\tconst cause = describeCacheMissCause(miss);\n\t\t\tthis.chatContainer.addChild(\n\t\t\t\tnew Text(\n\t\t\t\t\ttheme.fg(\n\t\t\t\t\t\t\"warning\",\n\t\t\t\t\t\t`Prompt cache miss${cause}: ${miss.missedTokens.toLocaleString()} tokens re-billed ($${miss.missedCost.toFixed(3)})`,\n\t\t\t\t\t),\n\t\t\t\t\t1,\n\t\t\t\t\t0,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\tfor (const input of deferredInputs) this.renderDeferredUserInput(input);\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.attachStartupNoticesContainer = function (\n\tthis: InteractiveModeBase,\n\toptions: { resetDetached?: boolean } = {},\n): void {\n\tconst disclosureIndex = this.chatContainer.children.indexOf(this.resourceDisclosureContainer);\n\tconst noticesIndex = this.chatContainer.children.indexOf(this.startupNoticesContainer);\n\tif (disclosureIndex >= 0 && noticesIndex >= 0) return;\n\tif (disclosureIndex < 0) {\n\t\tif (options.resetDetached) this.resourceDisclosureContainer.clear();\n\t\tif (noticesIndex >= 0) this.chatContainer.children.splice(noticesIndex, 0, this.resourceDisclosureContainer);\n\t\telse this.chatContainer.addChild(this.resourceDisclosureContainer);\n\t}\n\tif (noticesIndex < 0) {\n\t\tif (options.resetDetached) this.startupNoticesContainer.clear();\n\t\tthis.chatContainer.addChild(this.startupNoticesContainer);\n\t}\n};\n\nInteractiveModeBase.prototype.renderInitialMessages = function (this: InteractiveModeBase): void {\n\tthis.attachStartupNoticesContainer({ resetDetached: true });\n\tconst entries = buildContextEntries(this.sessionManager.getEntries(), this.sessionManager.getLeafId());\n\tthis.renderSessionEntries(entries, { updateFooter: true, populateHistory: true });\n\trenderProjectTrustWarningIfNeeded(this);\n\trefreshInteractiveTasks(this);\n};\n\nfunction renderProjectTrustWarningIfNeeded(mode: InteractiveModeBase): void {\n\tif (mode.settingsManager.isProjectTrusted() || !hasTrustRequiringProjectResources(mode.sessionManager.getCwd())) {\n\t\treturn;\n\t}\n\tif (mode.chatContainer.children.length > 0) {\n\t\tmode.chatContainer.addChild(new Spacer(1));\n\t}\n\tmode.chatContainer.addChild(\n\t\tnew ThemedText(\n\t\t\t() =>\n\t\t\t\ttheme.fg(\n\t\t\t\t\t\"warning\",\n\t\t\t\t\t`This project is not trusted. Project ${CONFIG_DIR_NAME} resources and packages are ignored. Use /trust to save a trust decision, then restart ${APP_NAME}.`,\n\t\t\t\t),\n\t\t\t1,\n\t\t\t0,\n\t\t),\n\t);\n}\n\nInteractiveModeBase.prototype.getUserInput = async function (\n\tthis: InteractiveModeBase,\n): Promise<InteractiveSubmission> {\n\tfor (let attempt = 0; !this.startupCookedInputRecovered && attempt < 10; attempt += 1) {\n\t\tawait yieldToEventLoop();\n\t\tif (this.recoverCookedStartupInput?.()) break;\n\t}\n\twhile (true) {\n\t\tconst queuedInput = this.pendingUserInputs.shift();\n\t\tif (queuedInput !== undefined) {\n\t\t\treturn queuedInput;\n\t\t}\n\n\t\tif (this.startupReplayActiveInput) {\n\t\t\tawait this.drainStartupReplayCommands();\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn new Promise((resolve) => {\n\t\t\tthis.onInputCallback = (submission: InteractiveSubmission) => {\n\t\t\t\tthis.onInputCallback = undefined;\n\t\t\t\tresolve(submission);\n\t\t\t};\n\t\t\tif (!this.inputHandlerReadyRecorded) {\n\t\t\t\tthis.inputHandlerReadyRecorded = true;\n\t\t\t\trecordTimeSinceReset(\"interactive-input-handler-ready\");\n\t\t\t\tmarkLifecycleTiming(\"interactive-input-handler-ready\");\n\t\t\t\tvoid (async () => {\n\t\t\t\t\tawait yieldToEventLoop();\n\t\t\t\t\t// pi parity: the changelog/first-run notices need nothing from\n\t\t\t\t\t// extensions — render them right after the input handler is ready\n\t\t\t\t\t// instead of gating them behind the deferred extension reload (or,\n\t\t\t\t\t// when the user types immediately, behind the whole agent turn).\n\t\t\t\t\tthis.showStartupNoticesIfNeeded(this.startupNoticesContainer);\n\t\t\t\t\tthis.footerDataProvider.startGitWatcher();\n\t\t\t\t\tif (this.deferredStartupPending) {\n\t\t\t\t\t\tawait this.ensureDeferredStartupComplete();\n\t\t\t\t\t}\n\t\t\t\t})().catch((error) => {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tconsole.error(`Deferred input-readiness startup task failed: ${message}`);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n};\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function (\n\tthis: InteractiveModeBase,\n\toptions: {\n\t\tsuppressCompactionBoundary?: VerbatimCompactionResult;\n\t\tresetStartupDisclosure?: boolean;\n\t} = {},\n): void {\n\t// Generic rebuilds keep the same session: pending fd/rg callbacks still own\n\t// this transcript. Full session replacements invalidate their generation in\n\t// renderCurrentSessionState() before rebuilding the replacement transcript.\n\tthis.managedToolStatusStarted = false;\n\tthis.lastStatusSpacer = undefined;\n\tthis.lastStatusText = undefined;\n\tthis.chatContainer.clear();\n\tif (options.resetStartupDisclosure) this.resourceDisclosureContainer.clear();\n\tthis.attachStartupNoticesContainer();\n\tconst entries = buildContextEntries(this.sessionManager.getEntries(), this.sessionManager.getLeafId());\n\tthis.renderSessionEntries(entries, { suppressCompactionBoundary: options.suppressCompactionBoundary });\n};\n\nfunction isSynthesizedCompactionBoundary(message: AgentMessage | undefined, result: VerbatimCompactionResult): boolean {\n\tif (message?.role !== \"custom\" || message.customType !== \"compaction\" || !message.display) return false;\n\tconst details = message.details as { strategy?: string } | undefined;\n\tif (details?.strategy !== \"verbatim-lines\") return false;\n\tconst content = Array.isArray(message.content)\n\t\t? message.content\n\t\t\t\t.filter((block) => block.type === \"text\")\n\t\t\t\t.map((block) => block.text)\n\t\t\t\t.join(\"\\n\")\n\t\t: message.content;\n\treturn content === VERBATIM_COMPACTION_PREFIX + result.compactedText;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-render-chat.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EAAE,mBAA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AAK,EAAE,CAAC;IAC3B,IAAI,OAAO,CAAC,sBAAsB;QAAE,IAAI,CAAC,2BAA2B,CAAC,KAAK,EAAE,CAAC;IAC7E,IAAI,CAAC,6BAA6B,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,mBAAmB,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,CAAC;IACvG,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,EAAE,0BAA0B,EAAE,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAAC;AACxG,CAAC,CAAC;AAEF,SAAS,+BAA+B,CAAC,OAAiC,EAAE,MAAgC;IAC3G,IAAI,OAAO,EAAE,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC,UAAU,KAAK,YAAY,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IACxG,MAAM,OAAO,GAAG,OAAO,CAAC,OAA4C,CAAC;IACrE,IAAI,OAAO,EAAE,QAAQ,KAAK,gBAAgB;QAAE,OAAO,KAAK,CAAC;IACzD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;QAC7C,CAAC,CAAC,OAAO,CAAC,OAAO;aACd,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC;aACxC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;aAC1B,IAAI,CAAC,IAAI,CAAC;QACb,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACnB,OAAO,OAAO,KAAK,0BAA0B,GAAG,MAAM,CAAC,aAAa,CAAC;AACtE,CAAC","sourcesContent":["import type { AssistantMessage, Usage } from \"@bastani/pi-ai/compat\";\nimport { CONFIG_DIR_NAME } from \"../../config.js\";\nimport { collectCacheMisses, createCacheMissModelSource, describeCacheMissCause } from \"../../core/cache-stats.ts\";\nimport { markLifecycleTiming } from \"../../core/lifecycle-timings.ts\";\nimport { VERBATIM_COMPACTION_PREFIX } from \"../../core/messages.ts\";\nimport type { CustomEntry } from \"../../core/session-manager.ts\";\nimport { buildContextEntries, type SessionEntry, sessionEntryToContextMessages } from \"../../core/session-manager.ts\";\nimport { yieldToEventLoop } from \"../../utils/event-loop.ts\";\nimport { IsolatedInteractiveRuntime } from \"../interactive-engine/isolated-runtime.js\";\nimport { RemoteCustomMessageComponent, RemoteToolExecutionComponent } from \"../interactive-engine/remote-renderer.ts\";\nimport { appendBoundedStderr } from \"../rpc/rpc-client-process.js\";\nimport { CustomEntryComponent } from \"./components/custom-entry.ts\";\nimport { createMermaidMarkdownTransformer } from \"./components/mermaid.ts\";\nimport { ThemedText } from \"./components/themed-text.js\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport {\n\ttype AgentMessage,\n\tAPP_NAME,\n\tAssistantMessageComponent,\n\taddChatTranscriptEntry,\n\tBashExecutionComponent,\n\tBranchSummaryMessageComponent,\n\ttype ChatMessageEntry,\n\ttype ChatMessageRenderOptions,\n\tCompactionBoundaryMessageComponent,\n\ttype Component,\n\tCustomMessageComponent,\n\tchatEntriesFromAgentMessages,\n\thasTrustRequiringProjectResources,\n\tparseSkillBlock,\n\trecordTimeSinceReset,\n\trenderChatMessageEntry,\n\ttype SessionContext,\n\tSkillInvocationMessageComponent,\n\tSpacer,\n\tText,\n\tToolExecutionComponent,\n\ttype TruncationResult,\n\ttheme,\n\tUserMessageComponent,\n\ttype VerbatimCompactionResult,\n} from \"./interactive-mode-deps.ts\";\nimport type { InteractiveSubmission } from \"./interactive-submission.ts\";\nimport { refreshInteractiveTasks } from \"./interactive-task-projection.js\";\n\nfunction countDroppedThinkingBlocks(message: AssistantMessage): number {\n\treturn (message.diagnostics ?? []).reduce((count, diagnostic) => {\n\t\tif (diagnostic.type !== \"anthropic_input_transformations\") return count;\n\t\tconst dropped = diagnostic.details?.droppedBlockCount;\n\t\treturn count + (typeof dropped === \"number\" && dropped > 0 ? dropped : 0);\n\t}, 0);\n}\n\nInteractiveModeBase.prototype.maybeShowAssistantDiagnostics = function (\n\tthis: InteractiveModeBase,\n\tmessage: AssistantMessage,\n): void {\n\tif (!this.settingsManager.getShowCacheMissNotices()) return;\n\n\tconst count = countDroppedThinkingBlocks(message);\n\tif (count === 0) return;\n\tlet previousCount = 0;\n\t// The live message_end notification precedes persistence of this response.\n\tconst branch = this.sessionManager.getBranch();\n\tfor (let i = branch.length - 1; i >= 0; i--) {\n\t\tconst entry = branch[i];\n\t\tif (entry.type === \"message\" && entry.message.role === \"assistant\") {\n\t\t\tpreviousCount = countDroppedThinkingBlocks(entry.message);\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (count <= previousCount) return;\n\tconst noun = count === 1 ? \"thinking block\" : \"thinking blocks\";\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(\n\t\tnew Text(theme.fg(\"warning\", `Anthropic dropped ${count} ${noun} (details in session)`), 1, 0),\n\t);\n};\n\n// Weak keys leave cleared/rebuilt transcripts collectible without separate lifecycle state.\n// Only persistent diagnostic statuses participate; ordinary chat/status is never evicted.\nconst diagnosticStatuses = new WeakMap<Component, { spacer: Spacer; bytes: number }>();\nconst MAX_DIAGNOSTIC_STATUSES = 64;\nconst MAX_DIAGNOSTIC_HISTORY_BYTES = 256 * 1024;\n\nInteractiveModeBase.prototype.showStatus = function (\n\tthis: InteractiveModeBase,\n\tmessage: string,\n\tpersist = false,\n): void {\n\tconst children = this.chatContainer.children;\n\tconst last = children.length > 0 ? children[children.length - 1] : undefined;\n\tconst secondLast = children.length > 1 ? children[children.length - 2] : undefined;\n\n\tif (!persist && last && secondLast && last === this.lastStatusText && secondLast === this.lastStatusSpacer) {\n\t\tthis.lastStatusText.setText(theme.fg(\"dim\", message));\n\t\tthis.ui.requestRender();\n\t\treturn;\n\t}\n\n\tif (persist) message = appendBoundedStderr(\"\", message);\n\tconst spacer = new Spacer(1);\n\tconst text = new Text(theme.fg(\"dim\", message), 1, 0);\n\tthis.chatContainer.addChild(spacer);\n\tthis.chatContainer.addChild(text);\n\tthis.lastStatusSpacer = persist ? undefined : spacer;\n\tthis.lastStatusText = persist ? undefined : text;\n\tif (persist) {\n\t\tdiagnosticStatuses.set(text, { spacer, bytes: Buffer.byteLength(message) });\n\t\tlet count = 0;\n\t\tlet bytes = 0;\n\t\tfor (const child of [...children].reverse()) {\n\t\t\tconst diagnostic = diagnosticStatuses.get(child);\n\t\t\tif (!diagnostic) continue;\n\t\t\tcount++;\n\t\t\tbytes += diagnostic.bytes;\n\t\t\tif (count > MAX_DIAGNOSTIC_STATUSES || bytes > MAX_DIAGNOSTIC_HISTORY_BYTES) {\n\t\t\t\tthis.chatContainer.removeChild(child);\n\t\t\t\tthis.chatContainer.removeChild(diagnostic.spacer);\n\t\t\t}\n\t\t}\n\t}\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.renderDeferredUserInput = function (this: InteractiveModeBase, text: string): void {\n\tthis.deferredRenderedUserInputs.push(text);\n\tconst startIndex = this.chatContainer.children.length;\n\tthis.addMessageToChat({ role: \"user\", content: text } as AgentMessage);\n\tconst renderedComponents = this.chatContainer.children.slice(startIndex);\n\tconst trackedComponents = this.deferredRenderedUserInputComponents.get(text) ?? [];\n\ttrackedComponents.push(renderedComponents);\n\tthis.deferredRenderedUserInputComponents.set(text, trackedComponents);\n\tthis.updatePendingMessagesDisplay();\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.consumeDeferredRenderedUserInput = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n): boolean {\n\tconst index = this.deferredRenderedUserInputs.indexOf(text);\n\tif (index === -1) return false;\n\tthis.deferredRenderedUserInputs.splice(index, 1);\n\tconst trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n\ttrackedComponents?.shift();\n\tif (trackedComponents && trackedComponents.length === 0) {\n\t\tthis.deferredRenderedUserInputComponents.delete(text);\n\t}\n\treturn true;\n};\n\nInteractiveModeBase.prototype.discardDeferredRenderedUserInput = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n): void {\n\tconst index = this.deferredRenderedUserInputs.indexOf(text);\n\tif (index !== -1) this.deferredRenderedUserInputs.splice(index, 1);\n\tconst trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n\tconst componentsToRemove = trackedComponents?.shift();\n\tif (trackedComponents && trackedComponents.length === 0) {\n\t\tthis.deferredRenderedUserInputComponents.delete(text);\n\t}\n\tif (!componentsToRemove) return;\n\tfor (const component of componentsToRemove) {\n\t\tthis.chatContainer.removeChild(component);\n\t}\n\tthis.updatePendingMessagesDisplay();\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.getMarkdownTransformers = function (this: InteractiveModeBase) {\n\tconst mode = this.settingsManager.getMermaidRenderingMode();\n\tif (this.mermaidMarkdownTransformerMode !== mode) {\n\t\tthis.mermaidMarkdownTransformerMode = mode;\n\t\tthis.mermaidMarkdownTransformer = createMermaidMarkdownTransformer({\n\t\t\tgetMode: () => this.settingsManager.getMermaidRenderingMode(),\n\t\t\ttheme,\n\t\t});\n\t}\n\tconst extensionTransformers =\n\t\tthis.runtimeHost instanceof IsolatedInteractiveRuntime\n\t\t\t? []\n\t\t\t: this.session.extensionRunner.getMarkdownTransformers();\n\treturn [this.mermaidMarkdownTransformer, ...extensionTransformers];\n};\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function (\n\tthis: InteractiveModeBase,\n): ChatMessageRenderOptions {\n\tconst isolated = this.runtimeHost instanceof IsolatedInteractiveRuntime;\n\treturn {\n\t\tui: this.ui,\n\t\tcwd: this.sessionManager.getCwd(),\n\t\tmarkdownTheme: this.getMarkdownThemeWithSettings(),\n\t\thideThinkingBlock: this.hideThinkingBlock,\n\t\thiddenThinkingLabel: this.hiddenThinkingLabel,\n\t\ttoolOutputExpanded: this.toolOutputExpanded,\n\t\tshowImages: this.settingsManager.getShowImages(),\n\t\timageWidthCells: this.settingsManager.getImageWidthCells(),\n\t\toutputPad: this.outputPad,\n\t\trenderLatex: this.settingsManager.getLatexRenderingEnabled(),\n\t\tmarkdownTransformers: this.getMarkdownTransformers(),\n\t\tgetToolDefinition: isolated ? undefined : (toolName) => this.getRegisteredToolDefinition(toolName),\n\t\tgetCustomMessageRenderer: isolated\n\t\t\t? undefined\n\t\t\t: (customType) => this.session.extensionRunner.getMessageRenderer(customType),\n\t\tcreateToolComponent: isolated\n\t\t\t? (entry) => {\n\t\t\t\t\tconst component = new RemoteToolExecutionComponent(\n\t\t\t\t\t\tentry.toolName,\n\t\t\t\t\t\tentry.toolCallId,\n\t\t\t\t\t\tentry.args,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tshowImages: this.settingsManager.getShowImages(),\n\t\t\t\t\t\t\timageWidthCells: this.settingsManager.getImageWidthCells(),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.runtimeHost as IsolatedInteractiveRuntime,\n\t\t\t\t\t\t() => this.ui.requestRender(),\n\t\t\t\t\t);\n\t\t\t\t\tcomponent.setExpanded(this.toolOutputExpanded);\n\t\t\t\t\tif (entry.result) component.updateResult(entry.result, entry.isPartial ?? false);\n\t\t\t\t\treturn component;\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tcreateCustomMessageComponent: isolated\n\t\t\t? (message) => {\n\t\t\t\t\tconst component = new RemoteCustomMessageComponent(\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tthis.runtimeHost as IsolatedInteractiveRuntime,\n\t\t\t\t\t\t() => this.ui.requestRender(),\n\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t);\n\t\t\t\t\tcomponent.setExpanded(this.toolOutputExpanded);\n\t\t\t\t\treturn component;\n\t\t\t\t}\n\t\t\t: undefined,\n\t};\n};\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function (\n\tthis: InteractiveModeBase,\n\tentry: ChatMessageEntry,\n): Component {\n\tconst component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n\taddChatTranscriptEntry(this.chatContainer, component, entry.role);\n\treturn component;\n};\n\nInteractiveModeBase.prototype.addCompactionBoundaryToChat = function (\n\tthis: InteractiveModeBase,\n\tresult: VerbatimCompactionResult,\n): void {\n\tthis.chatContainer.addChild(new Spacer(1));\n\tconst component = new CompactionBoundaryMessageComponent(result);\n\tcomponent.setExpanded(this.toolOutputExpanded);\n\tthis.chatContainer.addChild(component);\n};\n\nInteractiveModeBase.prototype.addCompactionCostNotice = function (\n\tthis: InteractiveModeBase,\n\tkind: \"compaction\" | \"branch_summary\",\n\tusage: Usage,\n): void {\n\tif (!this.settingsManager.getShowCacheMissNotices()) return;\n\tconst tokens = usage.input + usage.output + usage.cacheRead + usage.cacheWrite;\n\tconst cost = usage.cost.total >= 0.01 ? ` (~$${usage.cost.total.toFixed(2)})` : \"\";\n\tconst label = kind === \"compaction\" ? \"Compaction\" : \"Branch summary\";\n\tthis.chatContainer.addChild(new Spacer(1));\n\tthis.chatContainer.addChild(\n\t\tnew Text(theme.fg(\"warning\", `${label}: ${tokens.toLocaleString()} tokens billed${cost}`), 1, 0),\n\t);\n};\n\nInteractiveModeBase.prototype.addCustomEntryToChat = function (this: InteractiveModeBase, entry: CustomEntry): void {\n\tconst renderer = this.session.extensionRunner.getEntryRenderer(entry.customType);\n\tif (!renderer) return;\n\tconst runner = this.session.extensionRunner;\n\tconst component = new CustomEntryComponent(entry, (...args) => runner.renderEntry(entry.customType, ...args));\n\tcomponent.setExpanded(this.toolOutputExpanded);\n\tif (!component.hasContent()) return;\n\tconst streamingIndex = this.streamingComponent ? this.chatContainer.children.indexOf(this.streamingComponent) : -1;\n\tif (streamingIndex >= 0) this.chatContainer.children.splice(streamingIndex, 0, component);\n\telse this.chatContainer.addChild(component);\n};\n\nInteractiveModeBase.prototype.addMessageToChat = function (\n\tthis: InteractiveModeBase,\n\tmessage: AgentMessage,\n\toptions?: { populateHistory?: boolean },\n): void {\n\tconst markdownTransformers = this.getMarkdownTransformers();\n\tswitch (message.role) {\n\t\tcase \"bashExecution\": {\n\t\t\tconst component = new BashExecutionComponent(message.command, this.ui, message.excludeFromContext);\n\t\t\tif (message.output) {\n\t\t\t\tcomponent.appendOutput(message.output);\n\t\t\t}\n\t\t\tcomponent.setComplete(\n\t\t\t\tmessage.exitCode,\n\t\t\t\tmessage.cancelled,\n\t\t\t\tmessage.truncated ? ({ truncated: true } as TruncationResult) : undefined,\n\t\t\t\tmessage.fullOutputPath,\n\t\t\t);\n\t\t\tthis.chatContainer.addChild(component);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"custom\": {\n\t\t\tif (message.display) {\n\t\t\t\tconst component =\n\t\t\t\t\tthis.runtimeHost instanceof IsolatedInteractiveRuntime\n\t\t\t\t\t\t? new RemoteCustomMessageComponent(\n\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\tthis.runtimeHost,\n\t\t\t\t\t\t\t\t() => this.ui.requestRender(),\n\t\t\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: new CustomMessageComponent(\n\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\tthis.session.extensionRunner.getMessageRenderer(message.customType),\n\t\t\t\t\t\t\t\tthis.getMarkdownThemeWithSettings(),\n\t\t\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t\t\t\tthis.settingsManager.getLatexRenderingEnabled(),\n\t\t\t\t\t\t\t);\n\t\t\t\tcomponent.setExpanded(this.toolOutputExpanded);\n\t\t\t\tthis.chatContainer.addChild(component);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"branchSummary\": {\n\t\t\tthis.chatContainer.addChild(new Spacer(1));\n\t\t\tconst component = new BranchSummaryMessageComponent(\n\t\t\t\tmessage,\n\t\t\t\tthis.getMarkdownThemeWithSettings(),\n\t\t\t\tthis.settingsManager.getLatexRenderingEnabled(),\n\t\t\t);\n\t\t\tcomponent.setExpanded(this.toolOutputExpanded);\n\t\t\tthis.chatContainer.addChild(component);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"user\": {\n\t\t\tconst textContent = this.getUserMessageText(message);\n\t\t\tif (textContent) {\n\t\t\t\tif (this.chatContainer.children.length > 0) {\n\t\t\t\t\tthis.chatContainer.addChild(new Spacer(1));\n\t\t\t\t}\n\t\t\t\tconst skillBlock = parseSkillBlock(textContent);\n\t\t\t\tif (skillBlock) {\n\t\t\t\t\t// Render skill block (collapsible)\n\t\t\t\t\tconst component = new SkillInvocationMessageComponent(\n\t\t\t\t\t\tskillBlock,\n\t\t\t\t\t\tthis.getMarkdownThemeWithSettings(),\n\t\t\t\t\t\tthis.settingsManager.getLatexRenderingEnabled(),\n\t\t\t\t\t);\n\t\t\t\t\tcomponent.setExpanded(this.toolOutputExpanded);\n\t\t\t\t\tthis.chatContainer.addChild(component);\n\t\t\t\t\t// Render user message separately if present\n\t\t\t\t\tif (skillBlock.userMessage) {\n\t\t\t\t\t\tconst userComponent = new UserMessageComponent(\n\t\t\t\t\t\t\tskillBlock.userMessage,\n\t\t\t\t\t\t\tthis.getMarkdownThemeWithSettings(),\n\t\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t\t\tmarkdownTransformers,\n\t\t\t\t\t\t\tthis.settingsManager.getLatexRenderingEnabled(),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.chatContainer.addChild(userComponent);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst userComponent = new UserMessageComponent(\n\t\t\t\t\t\ttextContent,\n\t\t\t\t\t\tthis.getMarkdownThemeWithSettings(),\n\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t\tmarkdownTransformers,\n\t\t\t\t\t\tthis.settingsManager.getLatexRenderingEnabled(),\n\t\t\t\t\t);\n\t\t\t\t\tthis.chatContainer.addChild(userComponent);\n\t\t\t\t}\n\t\t\t\tif (options?.populateHistory) {\n\t\t\t\t\tthis.editor.addToHistory?.(textContent);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"assistant\": {\n\t\t\tconst assistantComponent = new AssistantMessageComponent(\n\t\t\t\tmessage,\n\t\t\t\tthis.hideThinkingBlock,\n\t\t\t\tthis.getMarkdownThemeWithSettings(),\n\t\t\t\tthis.hiddenThinkingLabel,\n\t\t\t\tthis.outputPad,\n\t\t\t\tmarkdownTransformers,\n\t\t\t\tfalse,\n\t\t\t\tthis.settingsManager.getLatexRenderingEnabled(),\n\t\t\t);\n\t\t\tthis.chatContainer.addChild(assistantComponent);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"toolResult\": {\n\t\t\t// Tool results are rendered inline with tool calls, handled separately\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tbreak;\n\t}\n};\n\nInteractiveModeBase.prototype.renderSessionContext = function (\n\tthis: InteractiveModeBase,\n\tsessionContext: SessionContext,\n\toptions: { updateFooter?: boolean; populateHistory?: boolean } = {},\n): void {\n\tthis.pendingTools.clear();\n\tconst pendingDeferredInputs = [...this.deferredRenderedUserInputs];\n\tthis.deferredRenderedUserInputs = [];\n\tthis.deferredRenderedUserInputComponents.clear();\n\n\tif (options.updateFooter) {\n\t\tthis.footer.invalidate();\n\t\tthis.updateEditorBorderColor();\n\t}\n\n\tconst entries = chatEntriesFromAgentMessages(sessionContext.messages);\n\tfor (const entry of entries) {\n\t\tconst component = this.addRenderedChatEntry(entry);\n\t\tif (entry.kind === \"tool\" && entry.isPartial !== false && component instanceof ToolExecutionComponent) {\n\t\t\tthis.pendingTools.set(entry.toolCallId, component);\n\t\t}\n\t\tif (options.populateHistory && entry.kind === \"user\") {\n\t\t\tthis.editor.addToHistory?.(entry.text);\n\t\t}\n\t}\n\n\tfor (const input of pendingDeferredInputs) {\n\t\tthis.renderDeferredUserInput(input);\n\t}\n\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.renderSessionEntries = function (\n\tthis: InteractiveModeBase,\n\tsessionEntries: SessionEntry[],\n\toptions: {\n\t\tupdateFooter?: boolean;\n\t\tpopulateHistory?: boolean;\n\t\tsuppressCompactionBoundary?: VerbatimCompactionResult;\n\t} = {},\n): void {\n\tthis.pendingTools.clear();\n\tconst deferredInputs = [...this.deferredRenderedUserInputs];\n\tthis.deferredRenderedUserInputs = [];\n\tthis.deferredRenderedUserInputComponents.clear();\n\tif (options.updateFooter) {\n\t\tthis.footer.invalidate();\n\t\tthis.updateEditorBorderColor();\n\t}\n\tlet messageBuffer: AgentMessage[] = [];\n\tlet firstMessage = true;\n\tconst flushMessages = (): void => {\n\t\tif (\n\t\t\toptions.suppressCompactionBoundary &&\n\t\t\tfirstMessage &&\n\t\t\tisSynthesizedCompactionBoundary(messageBuffer[0], options.suppressCompactionBoundary)\n\t\t) {\n\t\t\tmessageBuffer = messageBuffer.slice(1);\n\t\t}\n\t\tfirstMessage = false;\n\t\tfor (const entry of chatEntriesFromAgentMessages(messageBuffer)) {\n\t\t\tconst component = this.addRenderedChatEntry(entry);\n\t\t\tif (entry.kind === \"tool\" && entry.isPartial !== false && component instanceof ToolExecutionComponent) {\n\t\t\t\tthis.pendingTools.set(entry.toolCallId, component);\n\t\t\t}\n\t\t\tif (options.populateHistory && entry.kind === \"user\") this.editor.addToHistory?.(entry.text);\n\t\t}\n\t\tmessageBuffer = [];\n\t};\n\tfor (const entry of sessionEntries) {\n\t\tif (entry.type === \"custom\") {\n\t\t\tflushMessages();\n\t\t\tthis.addCustomEntryToChat(entry);\n\t\t} else {\n\t\t\tmessageBuffer.push(...sessionEntryToContextMessages(entry));\n\t\t\tif ((entry.type === \"compaction\" || entry.type === \"branch_summary\") && entry.usage) {\n\t\t\t\tflushMessages();\n\t\t\t\tconst suppressedLiveBoundary =\n\t\t\t\t\tentry.type === \"compaction\" &&\n\t\t\t\t\toptions.suppressCompactionBoundary !== undefined &&\n\t\t\t\t\tentry.summary === options.suppressCompactionBoundary.compactedText &&\n\t\t\t\t\tentry.tokensBefore === options.suppressCompactionBoundary.tokensBefore;\n\t\t\t\tif (!suppressedLiveBoundary) this.addCompactionCostNotice(entry.type, entry.usage);\n\t\t\t}\n\t\t}\n\t}\n\tflushMessages();\n\tif (this.settingsManager.getShowCacheMissNotices()) {\n\t\tfor (const miss of collectCacheMisses(\n\t\t\tsessionEntries,\n\t\t\tcreateCacheMissModelSource(this.session.modelRuntime),\n\t\t).values()) {\n\t\t\tconst cause = describeCacheMissCause(miss);\n\t\t\tthis.chatContainer.addChild(\n\t\t\t\tnew Text(\n\t\t\t\t\ttheme.fg(\n\t\t\t\t\t\t\"warning\",\n\t\t\t\t\t\t`Prompt cache miss${cause}: ${miss.missedTokens.toLocaleString()} tokens re-billed ($${miss.missedCost.toFixed(3)})`,\n\t\t\t\t\t),\n\t\t\t\t\t1,\n\t\t\t\t\t0,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\tfor (const input of deferredInputs) this.renderDeferredUserInput(input);\n\tthis.ui.requestRender();\n};\n\nInteractiveModeBase.prototype.attachStartupNoticesContainer = function (\n\tthis: InteractiveModeBase,\n\toptions: { resetDetached?: boolean } = {},\n): void {\n\tconst disclosureIndex = this.chatContainer.children.indexOf(this.resourceDisclosureContainer);\n\tconst noticesIndex = this.chatContainer.children.indexOf(this.startupNoticesContainer);\n\tif (disclosureIndex >= 0 && noticesIndex >= 0) return;\n\tif (disclosureIndex < 0) {\n\t\tif (options.resetDetached) this.resourceDisclosureContainer.clear();\n\t\tif (noticesIndex >= 0) this.chatContainer.children.splice(noticesIndex, 0, this.resourceDisclosureContainer);\n\t\telse this.chatContainer.addChild(this.resourceDisclosureContainer);\n\t}\n\tif (noticesIndex < 0) {\n\t\tif (options.resetDetached) this.startupNoticesContainer.clear();\n\t\tthis.chatContainer.addChild(this.startupNoticesContainer);\n\t}\n};\n\nInteractiveModeBase.prototype.renderInitialMessages = function (this: InteractiveModeBase): void {\n\tthis.attachStartupNoticesContainer({ resetDetached: true });\n\tconst entries = buildContextEntries(this.sessionManager.getEntries(), this.sessionManager.getLeafId());\n\tthis.renderSessionEntries(entries, { updateFooter: true, populateHistory: true });\n\trenderProjectTrustWarningIfNeeded(this);\n\trefreshInteractiveTasks(this);\n};\n\nfunction renderProjectTrustWarningIfNeeded(mode: InteractiveModeBase): void {\n\tif (mode.settingsManager.isProjectTrusted() || !hasTrustRequiringProjectResources(mode.sessionManager.getCwd())) {\n\t\treturn;\n\t}\n\tif (mode.chatContainer.children.length > 0) {\n\t\tmode.chatContainer.addChild(new Spacer(1));\n\t}\n\tmode.chatContainer.addChild(\n\t\tnew ThemedText(\n\t\t\t() =>\n\t\t\t\ttheme.fg(\n\t\t\t\t\t\"warning\",\n\t\t\t\t\t`This project is not trusted. Project ${CONFIG_DIR_NAME} resources and packages are ignored. Use /trust to save a trust decision, then restart ${APP_NAME}.`,\n\t\t\t\t),\n\t\t\t1,\n\t\t\t0,\n\t\t),\n\t);\n}\n\nInteractiveModeBase.prototype.getUserInput = async function (\n\tthis: InteractiveModeBase,\n): Promise<InteractiveSubmission> {\n\twhile (true) {\n\t\tconst queuedInput = this.pendingUserInputs.shift();\n\t\tif (queuedInput !== undefined) {\n\t\t\treturn queuedInput;\n\t\t}\n\n\t\tif (this.startupReplayActiveInput) {\n\t\t\tawait this.drainStartupReplayCommands();\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn new Promise((resolve) => {\n\t\t\tthis.onInputCallback = (submission: InteractiveSubmission) => {\n\t\t\t\tthis.onInputCallback = undefined;\n\t\t\t\tresolve(submission);\n\t\t\t};\n\t\t\tif (!this.inputHandlerReadyRecorded) {\n\t\t\t\tthis.inputHandlerReadyRecorded = true;\n\t\t\t\trecordTimeSinceReset(\"interactive-input-handler-ready\");\n\t\t\t\tmarkLifecycleTiming(\"interactive-input-handler-ready\");\n\t\t\t\tvoid (async () => {\n\t\t\t\t\tawait yieldToEventLoop();\n\t\t\t\t\t// pi parity: the changelog/first-run notices need nothing from\n\t\t\t\t\t// extensions — render them right after the input handler is ready\n\t\t\t\t\t// instead of gating them behind the deferred extension reload (or,\n\t\t\t\t\t// when the user types immediately, behind the whole agent turn).\n\t\t\t\t\tthis.showStartupNoticesIfNeeded(this.startupNoticesContainer);\n\t\t\t\t\tthis.footerDataProvider.startGitWatcher();\n\t\t\t\t\tif (this.deferredStartupPending) {\n\t\t\t\t\t\tawait this.ensureDeferredStartupComplete();\n\t\t\t\t\t}\n\t\t\t\t})().catch((error) => {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tconsole.error(`Deferred input-readiness startup task failed: ${message}`);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n};\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function (\n\tthis: InteractiveModeBase,\n\toptions: {\n\t\tsuppressCompactionBoundary?: VerbatimCompactionResult;\n\t\tresetStartupDisclosure?: boolean;\n\t} = {},\n): void {\n\t// Generic rebuilds keep the same session: pending fd/rg callbacks still own\n\t// this transcript. Full session replacements invalidate their generation in\n\t// renderCurrentSessionState() before rebuilding the replacement transcript.\n\tthis.managedToolStatusStarted = false;\n\tthis.lastStatusSpacer = undefined;\n\tthis.lastStatusText = undefined;\n\tthis.chatContainer.clear();\n\tif (options.resetStartupDisclosure) this.resourceDisclosureContainer.clear();\n\tthis.attachStartupNoticesContainer();\n\tconst entries = buildContextEntries(this.sessionManager.getEntries(), this.sessionManager.getLeafId());\n\tthis.renderSessionEntries(entries, { suppressCompactionBoundary: options.suppressCompactionBoundary });\n};\n\nfunction isSynthesizedCompactionBoundary(message: AgentMessage | undefined, result: VerbatimCompactionResult): boolean {\n\tif (message?.role !== \"custom\" || message.customType !== \"compaction\" || !message.display) return false;\n\tconst details = message.details as { strategy?: string } | undefined;\n\tif (details?.strategy !== \"verbatim-lines\") return false;\n\tconst content = Array.isArray(message.content)\n\t\t? message.content\n\t\t\t\t.filter((block) => block.type === \"text\")\n\t\t\t\t.map((block) => block.text)\n\t\t\t\t.join(\"\\n\")\n\t\t: message.content;\n\treturn content === VERBATIM_COMPACTION_PREFIX + result.compactedText;\n}\n"]}
|
|
@@ -12,6 +12,13 @@ export interface RpcClientProcessOptions {
|
|
|
12
12
|
}
|
|
13
13
|
export declare function createRpcClientProcessEnvironment(overrides?: Record<string, string>, baseEnv?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
14
14
|
export declare function spawnRpcClientProcess(options: RpcClientProcessOptions): ChildProcess;
|
|
15
|
+
/**
|
|
16
|
+
* How long a SIGTERMed interactive engine may spend running extension
|
|
17
|
+
* `session_shutdown` handlers before its guardian and then a tree kill take over.
|
|
18
|
+
* Builtin shutdown (MCP servers, durable workflow storage) routinely exceeds a
|
|
19
|
+
* few hundred milliseconds on a loaded machine.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ENGINE_SHUTDOWN_GRACE_MS = 5000;
|
|
15
22
|
export declare function terminateRpcClientProcess(child: ChildProcess, processTree: boolean): Promise<void>;
|
|
16
23
|
export declare function createInteractiveJsonlOptions(enabled: boolean): {
|
|
17
24
|
maxBytesPerTurn?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-client-process.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-client-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,oBAAoB,CAAC;AAiB9D,MAAM,WAAW,uBAAuB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,2FAA2F;IAC3F,uBAAuB,CAAC,EAAE,MAAM,CAAC;CACjC;AAKD,wBAAgB,iCAAiC,CAChD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,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A2F;IAC3F,uBAAuB,CAAC,EAAE,MAAM,CAAC;CACjC;AAKD,wBAAgB,iCAAiC,CAChD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,OAAO,GAAE,MAAM,CAAC,UAAwB,GACtC,MAAM,CAAC,UAAU,CAEnB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,uBAAuB,GAAG,YAAY,CAkDpF;AAED;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAY9C,wBAAsB,yBAAyB,CAAC,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BxG;AAED,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,OAAO,GAAG;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,CAE5F;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAc7G;AAID,qFAAqF;AACrF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ3E;AAED,kFAAkF;AAClF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAc9F"}
|
|
@@ -65,6 +65,23 @@ export function spawnRpcClientProcess(options) {
|
|
|
65
65
|
}
|
|
66
66
|
return child;
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* How long a SIGTERMed interactive engine may spend running extension
|
|
70
|
+
* `session_shutdown` handlers before its guardian and then a tree kill take over.
|
|
71
|
+
* Builtin shutdown (MCP servers, durable workflow storage) routinely exceeds a
|
|
72
|
+
* few hundred milliseconds on a loaded machine.
|
|
73
|
+
*/
|
|
74
|
+
export const ENGINE_SHUTDOWN_GRACE_MS = 5_000;
|
|
75
|
+
const RPC_CHILD_SHUTDOWN_GRACE_MS = 250;
|
|
76
|
+
async function exitsWithin(exited, ms) {
|
|
77
|
+
const deadline = new AbortController();
|
|
78
|
+
try {
|
|
79
|
+
return await Promise.race([exited.then(() => true), sleep(ms, deadline.signal).then(() => false)]);
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
deadline.abort();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
68
85
|
export async function terminateRpcClientProcess(child, processTree) {
|
|
69
86
|
removeOwnedInteractiveEngineBootstrap(bootstrapHandles.get(child));
|
|
70
87
|
if (child.exitCode !== null || child.signalCode !== null)
|
|
@@ -76,14 +93,14 @@ export async function terminateRpcClientProcess(child, processTree) {
|
|
|
76
93
|
child.once("exit", resolveExit);
|
|
77
94
|
const guardianFile = guardianFiles.get(child);
|
|
78
95
|
child.kill("SIGTERM");
|
|
79
|
-
if (await
|
|
96
|
+
if (await exitsWithin(exited, processTree ? ENGINE_SHUTDOWN_GRACE_MS : RPC_CHILD_SHUTDOWN_GRACE_MS)) {
|
|
80
97
|
if (guardianFile)
|
|
81
98
|
await rm(guardianFile, { force: true });
|
|
82
99
|
return;
|
|
83
100
|
}
|
|
84
101
|
if (processTree && guardianFile) {
|
|
85
102
|
await writeFile(guardianFile, "stop");
|
|
86
|
-
if (await
|
|
103
|
+
if (await exitsWithin(exited, 500)) {
|
|
87
104
|
await rm(guardianFile, { force: true });
|
|
88
105
|
return;
|
|
89
106
|
}
|
|
@@ -92,7 +109,7 @@ export async function terminateRpcClientProcess(child, processTree) {
|
|
|
92
109
|
killProcessTree(child.pid);
|
|
93
110
|
else
|
|
94
111
|
child.kill("SIGKILL");
|
|
95
|
-
if (!(await
|
|
112
|
+
if (!(await exitsWithin(exited, 250))) {
|
|
96
113
|
throw new Error(`Agent process ${child.pid ?? "unknown"} did not exit after SIGKILL`);
|
|
97
114
|
}
|
|
98
115
|
if (guardianF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,CAAC;IAC9B,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,gBAAgB;QAAE,OAAO,IAAI,CAAC;IACrE,MAAM,MAAM,GAAG,sBAAsB,CAAC;IACtC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACxE,OAAO,KAAK,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAE,GAAG,IAAI,CAAC,KAAK,IAAI;QAAE,KAAK,EAAE,CAAC;IACxE,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC;AAC7D,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,oBAAoB,CAAC,MAAiC;IACrE,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,OAAO,CAAC,IAAI,EAAE,EAAE;QACf,OAAO,GAAG,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC7C,IAAI,SAAS;YAAE,OAAO;QACtB,SAAS,GAAG,IAAI,CAAC;QACjB,YAAY,CAAC,GAAG,EAAE;YACjB,MAAM,OAAO,GAAG,OAAO,CAAC;YACxB,OAAO,GAAG,EAAE,CAAC;YACb,SAAS,GAAG,KAAK,CAAC;YAClB,MAAM,CAAC,OAAO,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { type ChildProcess, spawn } from \"node:child_process\";\nimport { rm, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { markLifecycleTiming } from \"../../core/lifecycle-timings.ts\";\nimport { createChildProcessEnvironment } from \"../../utils/child-process.ts\";\nimport { flushPersistentCompileCache } from \"../../utils/compile-cache.ts\";\nimport {\n\tINTERACTIVE_ENGINE_BOOTSTRAP_FLAG,\n\ttype InteractiveEngineBootstrapHandle,\n\tremoveOwnedInteractiveEngineBootstrap,\n\twriteInteractiveEngineBootstrap,\n} from \"../../utils/interactive-engine-bootstrap.ts\";\nimport { scrubInteractiveEngineEnv } from \"../../utils/interactive-engine-env.ts\";\nimport { killProcessTree, trackDetachedChildPid, untrackDetachedChildPid } from \"../../utils/shell.ts\";\nimport { sleep } from \"../../utils/sleep.ts\";\n\nexport interface RpcClientProcessOptions {\n\tcliPath: string;\n\tcliArgs: string[];\n\tcwd?: string;\n\tenv?: Record<string, string>;\n\truntimeExecutable?: string;\n\truntimeArgs?: string[];\n\tinteractiveEngine: boolean;\n\t/** Credential handed to the engine child through the bootstrap file, never argv or env. */\n\tinteractiveEngineApiKey?: string;\n}\n\nconst guardianFiles = new WeakMap<ChildProcess, string>();\nconst bootstrapHandles = new WeakMap<ChildProcess, InteractiveEngineBootstrapHandle>();\n\nexport function createRpcClientProcessEnvironment(\n\toverrides?: Record<string, string>,\n\tbaseEnv: NodeJS.ProcessEnv = process.env,\n): NodeJS.ProcessEnv {\n\treturn scrubInteractiveEngineEnv(createChildProcessEnvironment(overrides, baseEnv));\n}\n\nexport function spawnRpcClientProcess(options: RpcClientProcessOptions): ChildProcess {\n\tconst guardianFile = options.interactiveEngine\n\t\t? join(tmpdir(), `atomic-engine-guardian-${process.pid}-${crypto.randomUUID()}`)\n\t\t: undefined;\n\t// The engine's startup metadata travels in a 0600 file rather than the\n\t// environment: a Bun child spawned without an explicit `env` inherits the\n\t// runtime's launch-time environment, so anything placed here would remain\n\t// reachable by every descendant of the engine no matter what the engine\n\t// deletes from its own `process.env` afterwards.\n\tconst bootstrap = options.interactiveEngine\n\t\t? writeInteractiveEngineBootstrap({\n\t\t\t\thostPid: process.pid,\n\t\t\t\tguardFile: guardianFile!,\n\t\t\t\t...(options.interactiveEngineApiKey ? { apiKey: options.interactiveEngineApiKey } : {}),\n\t\t\t})\n\t\t: undefined;\n\tif (options.interactiveEngine) flushPersistentCompileCache();\n\tconst cliArgs = bootstrap\n\t\t? [...options.cliArgs, INTERACTIVE_ENGINE_BOOTSTRAP_FLAG, bootstrap.path]\n\t\t: options.cliArgs;\n\tlet child: ChildProcess;\n\ttry {\n\t\tif (options.interactiveEngine) markLifecycleTiming(\"interactive-engine-spawn\");\n\t\tchild = spawn(\n\t\t\toptions.runtimeExecutable ?? \"bun\",\n\t\t\t[...(options.runtimeArgs ?? []), ...(options.cliPath ? [options.cliPath] : []), ...cliArgs],\n\t\t\t{\n\t\t\t\tcwd: options.cwd,\n\t\t\t\tenv: createRpcClientProcessEnvironment(options.env),\n\t\t\t\tdetached: options.interactiveEngine && process.platform !== \"win32\",\n\t\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\tremoveOwnedInteractiveEngineBootstrap(bootstrap);\n\t\tthrow error;\n\t}\n\tif (guardianFile) guardianFiles.set(child, guardianFile);\n\tif (bootstrap) {\n\t\tbootstrapHandles.set(child, bootstrap);\n\t\t// The child unlinks the record after reading it; this handle-scoped cleanup\n\t\t// removes the directory this process created, and only that directory.\n\t\tchild.once(\"error\", () => removeOwnedInteractiveEngineBootstrap(bootstrap));\n\t\tchild.once(\"exit\", () => removeOwnedInteractiveEngineBootstrap(bootstrap));\n\t}\n\tif (options.interactiveEngine && child.pid) {\n\t\ttrackDetachedChildPid(child.pid);\n\t\tchild.once(\"exit\", () => untrackDetachedChildPid(child.pid!));\n\t}\n\treturn child;\n}\n\nexport async function terminateRpcClientProcess(child: ChildProcess, processTree: boolean): Promise<void> {\n\tremoveOwnedInteractiveEngineBootstrap(bootstrapHandles.get(child));\n\tif (child.exitCode !== null || child.signalCode !== null) return;\n\tlet resolveExit!: () => void;\n\tconst exited = new Promise<void>((resolve) => {\n\t\tresolveExit = resolve;\n\t});\n\tchild.once(\"exit\", resolveExit);\n\tconst guardianFile = guardianFiles.get(child);\n\tchild.kill(\"SIGTERM\");\n\tif (await Promise.race([exited.then(() => true), sleep(250).then(() => false)])) {\n\t\tif (guardianFile) await rm(guardianFile, { force: true });\n\t\treturn;\n\t}\n\tif (processTree && guardianFile) {\n\t\tawait writeFile(guardianFile, \"stop\");\n\t\tif (await Promise.race([exited.then(() => true), sleep(500).then(() => false)])) {\n\t\t\tawait rm(guardianFile, { force: true });\n\t\t\treturn;\n\t\t}\n\t}\n\tif (processTree && child.pid) killProcessTree(child.pid);\n\telse child.kill(\"SIGKILL\");\n\tif (!(await Promise.race([exited.then(() => true), sleep(250).then(() => false)]))) {\n\t\tthrow new Error(`Agent process ${child.pid ?? \"unknown\"} did not exit after SIGKILL`);\n\t}\n\tif (guardianFile) await rm(guardianFile, { force: true });\n}\n\nexport function createInteractiveJsonlOptions(enabled: boolean): { maxBytesPerTurn?: number } {\n\treturn enabled ? { maxBytesPerTurn: 256 * 1024 } : {};\n}\n\n/**\n * CLI args for a replacement engine child: drop whatever session flag the\n * previous generation carried and bind the replacement to `sessionFile`, so a\n * restart resumes the same conversation instead of starting a fresh one.\n */\nexport function restartCliArgs(args: readonly string[] | undefined, sessionFile: string | undefined): string[] {\n\tconst result: string[] = [];\n\tfor (let index = 0; index < (args?.length ?? 0); index += 1) {\n\t\tconst value = args![index]!;\n\t\tif (value === \"--no-session\") continue;\n\t\tif (value === \"--session\") {\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tresult.push(value);\n\t}\n\tresult.push(sessionFile ? \"--session\" : \"--no-session\");\n\tif (sessionFile) result.push(sessionFile);\n\treturn result;\n}\n\nconst MAX_STDERR_BYTES = 256 * 1024;\n\n/** Keep only the tail of a child's stderr, so a noisy child cannot grow the host. */\nexport function appendBoundedStderr(existing: string, chunk: string): string {\n\tconst next = existing + chunk;\n\tif (Buffer.byteLength(next, \"utf8\") <= MAX_STDERR_BYTES) return next;\n\tconst marker = \"\\n[stderr truncated]\";\n\tconst bytes = Buffer.from(next);\n\tlet start = bytes.length - MAX_STDERR_BYTES + Buffer.byteLength(marker);\n\twhile (start < bytes.length && (bytes[start]! & 0xc0) === 0x80) start++;\n\treturn `${bytes.subarray(start).toString(\"utf8\")}${marker}`;\n}\n\n/** Batch noisy child output outside the pipe callback without filesystem work. */\nexport function createStderrReporter(report: (message: string) => void): (data: string) => void {\n\tlet pending = \"\";\n\tlet scheduled = false;\n\treturn (data) => {\n\t\tpending = appendBoundedStderr(pending, data);\n\t\tif (scheduled) return;\n\t\tscheduled = true;\n\t\tsetImmediate(() => {\n\t\t\tconst message = pending;\n\t\t\tpending = \"\";\n\t\t\tscheduled = false;\n\t\t\treport(message);\n\t\t});\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rpc-client-process.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-client-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EACN,iCAAiC,EAEjC,qCAAqC,EACrC,+BAA+B,GAC/B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACvG,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAc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AM,UAAU,oBAAoB,CAAC,MAAiC;IACrE,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,OAAO,CAAC,IAAI,EAAE,EAAE;QACf,OAAO,GAAG,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC7C,IAAI,SAAS;YAAE,OAAO;QACtB,SAAS,GAAG,IAAI,CAAC;QACjB,YAAY,CAAC,GAAG,EAAE;YACjB,MAAM,OAAO,GAAG,OAAO,CAAC;YACxB,OAAO,GAAG,EAAE,CAAC;YACb,SAAS,GAAG,KAAK,CAAC;YAClB,MAAM,CAAC,OAAO,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { type ChildProcess, spawn } from \"node:child_process\";\nimport { rm, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { markLifecycleTiming } from \"../../core/lifecycle-timings.ts\";\nimport { createChildProcessEnvironment } from \"../../utils/child-process.ts\";\nimport { flushPersistentCompileCache } from \"../../utils/compile-cache.ts\";\nimport {\n\tINTERACTIVE_ENGINE_BOOTSTRAP_FLAG,\n\ttype InteractiveEngineBootstrapHandle,\n\tremoveOwnedInteractiveEngineBootstrap,\n\twriteInteractiveEngineBootstrap,\n} from \"../../utils/interactive-engine-bootstrap.ts\";\nimport { scrubInteractiveEngineEnv } from \"../../utils/interactive-engine-env.ts\";\nimport { killProcessTree, trackDetachedChildPid, untrackDetachedChildPid } from \"../../utils/shell.ts\";\nimport { sleep } from \"../../utils/sleep.ts\";\n\nexport interface RpcClientProcessOptions {\n\tcliPath: string;\n\tcliArgs: string[];\n\tcwd?: string;\n\tenv?: Record<string, string>;\n\truntimeExecutable?: string;\n\truntimeArgs?: string[];\n\tinteractiveEngine: boolean;\n\t/** Credential handed to the engine child through the bootstrap file, never argv or env. */\n\tinteractiveEngineApiKey?: string;\n}\n\nconst guardianFiles = new WeakMap<ChildProcess, string>();\nconst bootstrapHandles = new WeakMap<ChildProcess, InteractiveEngineBootstrapHandle>();\n\nexport function createRpcClientProcessEnvironment(\n\toverrides?: Record<string, string>,\n\tbaseEnv: NodeJS.ProcessEnv = process.env,\n): NodeJS.ProcessEnv {\n\treturn scrubInteractiveEngineEnv(createChildProcessEnvironment(overrides, baseEnv));\n}\n\nexport function spawnRpcClientProcess(options: RpcClientProcessOptions): ChildProcess {\n\tconst guardianFile = options.interactiveEngine\n\t\t? join(tmpdir(), `atomic-engine-guardian-${process.pid}-${crypto.randomUUID()}`)\n\t\t: undefined;\n\t// The engine's startup metadata travels in a 0600 file rather than the\n\t// environment: a Bun child spawned without an explicit `env` inherits the\n\t// runtime's launch-time environment, so anything placed here would remain\n\t// reachable by every descendant of the engine no matter what the engine\n\t// deletes from its own `process.env` afterwards.\n\tconst bootstrap = options.interactiveEngine\n\t\t? writeInteractiveEngineBootstrap({\n\t\t\t\thostPid: process.pid,\n\t\t\t\tguardFile: guardianFile!,\n\t\t\t\t...(options.interactiveEngineApiKey ? { apiKey: options.interactiveEngineApiKey } : {}),\n\t\t\t})\n\t\t: undefined;\n\tif (options.interactiveEngine) flushPersistentCompileCache();\n\tconst cliArgs = bootstrap\n\t\t? [...options.cliArgs, INTERACTIVE_ENGINE_BOOTSTRAP_FLAG, bootstrap.path]\n\t\t: options.cliArgs;\n\tlet child: ChildProcess;\n\ttry {\n\t\tif (options.interactiveEngine) markLifecycleTiming(\"interactive-engine-spawn\");\n\t\tchild = spawn(\n\t\t\toptions.runtimeExecutable ?? \"bun\",\n\t\t\t[...(options.runtimeArgs ?? []), ...(options.cliPath ? [options.cliPath] : []), ...cliArgs],\n\t\t\t{\n\t\t\t\tcwd: options.cwd,\n\t\t\t\tenv: createRpcClientProcessEnvironment(options.env),\n\t\t\t\tdetached: options.interactiveEngine && process.platform !== \"win32\",\n\t\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\tremoveOwnedInteractiveEngineBootstrap(bootstrap);\n\t\tthrow error;\n\t}\n\tif (guardianFile) guardianFiles.set(child, guardianFile);\n\tif (bootstrap) {\n\t\tbootstrapHandles.set(child, bootstrap);\n\t\t// The child unlinks the record after reading it; this handle-scoped cleanup\n\t\t// removes the directory this process created, and only that directory.\n\t\tchild.once(\"error\", () => removeOwnedInteractiveEngineBootstrap(bootstrap));\n\t\tchild.once(\"exit\", () => removeOwnedInteractiveEngineBootstrap(bootstrap));\n\t}\n\tif (options.interactiveEngine && child.pid) {\n\t\ttrackDetachedChildPid(child.pid);\n\t\tchild.once(\"exit\", () => untrackDetachedChildPid(child.pid!));\n\t}\n\treturn child;\n}\n\n/**\n * How long a SIGTERMed interactive engine may spend running extension\n * `session_shutdown` handlers before its guardian and then a tree kill take over.\n * Builtin shutdown (MCP servers, durable workflow storage) routinely exceeds a\n * few hundred milliseconds on a loaded machine.\n */\nexport const ENGINE_SHUTDOWN_GRACE_MS = 5_000;\nconst RPC_CHILD_SHUTDOWN_GRACE_MS = 250;\n\nasync function exitsWithin(exited: Promise<void>, ms: number): Promise<boolean> {\n\tconst deadline = new AbortController();\n\ttry {\n\t\treturn await Promise.race([exited.then(() => true), sleep(ms, deadline.signal).then(() => false)]);\n\t} finally {\n\t\tdeadline.abort();\n\t}\n}\n\nexport async function terminateRpcClientProcess(child: ChildProcess, processTree: boolean): Promise<void> {\n\tremoveOwnedInteractiveEngineBootstrap(bootstrapHandles.get(child));\n\tif (child.exitCode !== null || child.signalCode !== null) return;\n\tlet resolveExit!: () => void;\n\tconst exited = new Promise<void>((resolve) => {\n\t\tresolveExit = resolve;\n\t});\n\tchild.once(\"exit\", resolveExit);\n\tconst guardianFile = guardianFiles.get(child);\n\tchild.kill(\"SIGTERM\");\n\tif (await exitsWithin(exited, processTree ? ENGINE_SHUTDOWN_GRACE_MS : RPC_CHILD_SHUTDOWN_GRACE_MS)) {\n\t\tif (guardianFile) await rm(guardianFile, { force: true });\n\t\treturn;\n\t}\n\tif (processTree && guardianFile) {\n\t\tawait writeFile(guardianFile, \"stop\");\n\t\tif (await exitsWithin(exited, 500)) {\n\t\t\tawait rm(guardianFile, { force: true });\n\t\t\treturn;\n\t\t}\n\t}\n\tif (processTree && child.pid) killProcessTree(child.pid);\n\telse child.kill(\"SIGKILL\");\n\tif (!(await exitsWithin(exited, 250))) {\n\t\tthrow new Error(`Agent process ${child.pid ?? \"unknown\"} did not exit after SIGKILL`);\n\t}\n\tif (guardianFile) await rm(guardianFile, { force: true });\n}\n\nexport function createInteractiveJsonlOptions(enabled: boolean): { maxBytesPerTurn?: number } {\n\treturn enabled ? { maxBytesPerTurn: 256 * 1024 } : {};\n}\n\n/**\n * CLI args for a replacement engine child: drop whatever session flag the\n * previous generation carried and bind the replacement to `sessionFile`, so a\n * restart resumes the same conversation instead of starting a fresh one.\n */\nexport function restartCliArgs(args: readonly string[] | undefined, sessionFile: string | undefined): string[] {\n\tconst result: string[] = [];\n\tfor (let index = 0; index < (args?.length ?? 0); index += 1) {\n\t\tconst value = args![index]!;\n\t\tif (value === \"--no-session\") continue;\n\t\tif (value === \"--session\") {\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tresult.push(value);\n\t}\n\tresult.push(sessionFile ? \"--session\" : \"--no-session\");\n\tif (sessionFile) result.push(sessionFile);\n\treturn result;\n}\n\nconst MAX_STDERR_BYTES = 256 * 1024;\n\n/** Keep only the tail of a child's stderr, so a noisy child cannot grow the host. */\nexport function appendBoundedStderr(existing: string, chunk: string): string {\n\tconst next = existing + chunk;\n\tif (Buffer.byteLength(next, \"utf8\") <= MAX_STDERR_BYTES) return next;\n\tconst marker = \"\\n[stderr truncated]\";\n\tconst bytes = Buffer.from(next);\n\tlet start = bytes.length - MAX_STDERR_BYTES + Buffer.byteLength(marker);\n\twhile (start < bytes.length && (bytes[start]! & 0xc0) === 0x80) start++;\n\treturn `${bytes.subarray(start).toString(\"utf8\")}${marker}`;\n}\n\n/** Batch noisy child output outside the pipe callback without filesystem work. */\nexport function createStderrReporter(report: (message: string) => void): (data: string) => void {\n\tlet pending = \"\";\n\tlet scheduled = false;\n\treturn (data) => {\n\t\tpending = appendBoundedStderr(pending, data);\n\t\tif (scheduled) return;\n\t\tscheduled = true;\n\t\tsetImmediate(() => {\n\t\t\tconst message = pending;\n\t\t\tpending = \"\";\n\t\t\tscheduled = false;\n\t\t\treport(message);\n\t\t});\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-command-timeouts.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-command-timeouts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"rpc-command-timeouts.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-command-timeouts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAuBlD,CAAC;AAEH,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,kFAAkF;AAClF,eAAO,MAAM,yBAAyB,yCAAyC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-command-timeouts.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-command-timeouts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAS;IACvE,qDAAqD;IACrD,OAAO;IACP,YAAY;IACZ,kBAAkB;IAClB,aAAa;IACb,uBAAuB;IACvB,mCAAmC;IACnC,QAAQ;IACR,gBAAgB;IAChB,OAAO;IACP,WAAW;IACX,MAAM;IACN,WAAW;IACX,SAAS;IACT,MAAM;IACN,OAAO;IACP,gBAAgB;IAChB,aAAa;IACb,gBAAgB;IAChB,eAAe;IACf,iBAAiB;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAEzC,kFAAkF;AAClF,MAAM,CAAC,MAAM,yBAAyB,GAAG,sCAAsC,CAAC","sourcesContent":["/**\n * Commands exempt from the generic request deadline.\n *\n * Two groups, for two reasons:\n *\n * - Work legitimately gated on human or agent interaction: interactive prompts\n * and custom-UI pickers (routed through `prompt`), queued turn-boundary sends\n * (`steer`/`follow_up`), long-running shell and compaction work, and\n * session-tree navigation or mutation that can open pickers.\n * - Cooperative cancellation. Escape's whole contract is that it asks the\n * engine to stop and waits for as long as the engine takes. A host-side\n * deadline would surface as `Timeout waiting for response to abort…` — a red\n * error about the host's own impatience while the engine is still working —\n * and would not stop anything.\n *\n * Failure detection is unaffected: engine exit, transport violations, generation\n * replacement, and explicit stop all reject pending requests through\n * rejectPendingRequests/failTransport independently of any timer.\n */\nexport const LONG_LIVED_COMMANDS: ReadonlySet<string> = new Set<string>([\n\t// Cooperative cancellation, all unbounded by design.\n\t\"abort\",\n\t\"abort_bash\",\n\t\"abort_compaction\",\n\t\"abort_retry\",\n\t\"cancel_login_provider\",\n\t// Interaction- or turn-gated work.\n\t\"prompt\",\n\t\"login_provider\",\n\t\"steer\",\n\t\"follow_up\",\n\t\"bash\",\n\t\"user_bash\",\n\t\"compact\",\n\t\"fork\",\n\t\"clone\",\n\t\"switch_session\",\n\t\"new_session\",\n\t\"import_session\",\n\t\"navigate_tree\",\n\t\"invoke_shortcut\",\n]);\n\nexport const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;\n\n/**\n * How long to wait for a dead child's stdout to drain before failing the\n * requests it never answered. `'close'` normally arrives first; this only\n * bounds the case where a descendant inherited stdout and keeps it open.\n */\nexport const EXIT_DRAIN_TIMEOUT_MS = 500;\n\n/** Rejection message for a restart superseded by an explicit stop or disposal. */\nexport const RESTART_CANCELLED_MESSAGE = \"Interactive engine restart cancelled\";\n"]}
|
|
1
|
+
{"version":3,"file":"rpc-command-timeouts.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-command-timeouts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAS;IACvE,qDAAqD;IACrD,OAAO;IACP,YAAY;IACZ,kBAAkB;IAClB,aAAa;IACb,uBAAuB;IACvB,mCAAmC;IACnC,QAAQ;IACR,gBAAgB;IAChB,OAAO;IACP,WAAW;IACX,wBAAwB;IACxB,MAAM;IACN,WAAW;IACX,SAAS;IACT,MAAM;IACN,OAAO;IACP,gBAAgB;IAChB,aAAa;IACb,gBAAgB;IAChB,eAAe;IACf,iBAAiB;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAEzC,kFAAkF;AAClF,MAAM,CAAC,MAAM,yBAAyB,GAAG,sCAAsC,CAAC","sourcesContent":["/**\n * Commands exempt from the generic request deadline.\n *\n * Two groups, for two reasons:\n *\n * - Work legitimately gated on human or agent interaction: interactive prompts\n * and custom-UI pickers (routed through `prompt`), queued turn-boundary sends\n * (`steer`/`follow_up`), long-running shell and compaction work, and\n * session-tree navigation or mutation that can open pickers.\n * - Cooperative cancellation. Escape's whole contract is that it asks the\n * engine to stop and waits for as long as the engine takes. A host-side\n * deadline would surface as `Timeout waiting for response to abort…` — a red\n * error about the host's own impatience while the engine is still working —\n * and would not stop anything.\n *\n * Failure detection is unaffected: engine exit, transport violations, generation\n * replacement, and explicit stop all reject pending requests through\n * rejectPendingRequests/failTransport independently of any timer.\n */\nexport const LONG_LIVED_COMMANDS: ReadonlySet<string> = new Set<string>([\n\t// Cooperative cancellation, all unbounded by design.\n\t\"abort\",\n\t\"abort_bash\",\n\t\"abort_compaction\",\n\t\"abort_retry\",\n\t\"cancel_login_provider\",\n\t// Interaction- or turn-gated work.\n\t\"prompt\",\n\t\"login_provider\",\n\t\"steer\",\n\t\"follow_up\",\n\t\"resume_queued_messages\",\n\t\"bash\",\n\t\"user_bash\",\n\t\"compact\",\n\t\"fork\",\n\t\"clone\",\n\t\"switch_session\",\n\t\"new_session\",\n\t\"import_session\",\n\t\"navigate_tree\",\n\t\"invoke_shortcut\",\n]);\n\nexport const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;\n\n/**\n * How long to wait for a dead child's stdout to drain before failing the\n * requests it never answered. `'close'` normally arrives first; this only\n * bounds the case where a descendant inherited stdout and keeps it open.\n */\nexport const EXIT_DRAIN_TIMEOUT_MS = 500;\n\n/** Rejection message for a restart superseded by an explicit stop or disposal. */\nexport const RESTART_CANCELLED_MESSAGE = \"Interactive engine restart cancelled\";\n"]}
|
package/dist/utils/ansi.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split streamed text into a part that is safe to pass to stripAnsi now and a trailing
|
|
3
|
+
* unfinished escape sequence that should be prepended to the next chunk.
|
|
4
|
+
*/
|
|
5
|
+
export declare function splitIncompleteAnsiSuffix(value: string): {
|
|
6
|
+
complete: string;
|
|
7
|
+
pending: string;
|
|
8
|
+
};
|
|
1
9
|
export declare function stripAnsi(value: string): string;
|
|
2
10
|
//# sourceMappingURL=ansi.d.ts.map
|
package/dist/utils/ansi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ansi.d.ts","sourceRoot":"","sources":["../../src/utils/ansi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ansi.d.ts","sourceRoot":"","sources":["../../src/utils/ansi.ts"],"names":[],"mappings":"AAkDA;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAW9F;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAc/C"}
|
package/dist/utils/ansi.js
CHANGED
|
@@ -25,17 +25,36 @@
|
|
|
25
25
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
26
|
* SOFTWARE.
|
|
27
27
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
// Valid string terminator sequences are BEL, ESC\, and 0x9c
|
|
29
|
+
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
30
|
+
// OSC sequences: ESC ] ... ST
|
|
31
|
+
const OSC_START = "\\u001B\\]";
|
|
32
|
+
// CSI and related: ESC/C1, optional intermediates, optional params (supports ; and :), then final byte
|
|
33
|
+
const CSI_START = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?";
|
|
34
|
+
const CSI_FINAL = "[\\dA-PR-TZcf-nq-uy=><~]";
|
|
35
|
+
// Complete sequences. OSC is non-greedy until the first ST.
|
|
36
|
+
const regex = new RegExp(`(?:${OSC_START}[\\s\\S]*?${ST})|${CSI_START}${CSI_FINAL}`, "g");
|
|
37
|
+
// Unfinished sequence at the end of the text: OSC without its ST (a trailing ESC may start ESC\),
|
|
38
|
+
// or CSI without its final byte.
|
|
39
|
+
const unfinishedAnsiAtEndRegex = new RegExp(`(?:${OSC_START}(?:[^\\u0007\\u009C\\u001B]|\\u001B(?!\\\\))*|${CSI_START})$`);
|
|
40
|
+
// Longest unfinished sequence held back while streaming. Longer ones are processed as-is.
|
|
41
|
+
const MAX_PENDING_ANSI_LENGTH = 256;
|
|
42
|
+
/**
|
|
43
|
+
* Split streamed text into a part that is safe to pass to stripAnsi now and a trailing
|
|
44
|
+
* unfinished escape sequence that should be prepended to the next chunk.
|
|
45
|
+
*/
|
|
46
|
+
export function splitIncompleteAnsiSuffix(value) {
|
|
47
|
+
if (!value.includes("\u001B") && !value.includes("\u009B")) {
|
|
48
|
+
return { complete: value, pending: "" };
|
|
49
|
+
}
|
|
50
|
+
const windowStart = Math.max(0, value.length - MAX_PENDING_ANSI_LENGTH);
|
|
51
|
+
const match = unfinishedAnsiAtEndRegex.exec(value.slice(windowStart));
|
|
52
|
+
if (!match) {
|
|
53
|
+
return { complete: value, pending: "" };
|
|
54
|
+
}
|
|
55
|
+
const splitAt = windowStart + match.index;
|
|
56
|
+
return { complete: value.slice(0, splitAt), pending: value.slice(splitAt) };
|
|
37
57
|
}
|
|
38
|
-
const regex = ansiRegex();
|
|
39
58
|
export function stripAnsi(value) {
|
|
40
59
|
if (typeof value !== "string") {
|
|
41
60
|
throw new TypeError(`Expected a \`string\`, got \`${typeof value}\``);
|
package/dist/utils/ansi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ansi.js","sourceRoot":"","sources":["../../src/utils/ansi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,
|
|
1
|
+
{"version":3,"file":"ansi.js","sourceRoot":"","sources":["../../src/utils/ansi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,4DAA4D;AAC5D,MAAM,EAAE,GAAG,oCAAoC,CAAC;AAEhD,8BAA8B;AAC9B,MAAM,SAAS,GAAG,YAAY,CAAC;AAE/B,uGAAuG;AACvG,MAAM,SAAS,GAAG,4DAA4D,CAAC;AAC/E,MAAM,SAAS,GAAG,0BAA0B,CAAC;AAE7C,4DAA4D;AAC5D,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,SAAS,aAAa,EAAE,KAA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AAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5D,OAAO,KAAK,CAAC;IACd,CAAC;IAED,2EAA2E;IAC3E,6EAA6E;IAC7E,mDAAmD;IACnD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACjC,CAAC","sourcesContent":["/*\n * Portions of this file are derived from:\n * - ansi-regex (https://github.com/chalk/ansi-regex)\n * - strip-ansi (https://github.com/chalk/strip-ansi)\n *\n * MIT License\n *\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n// Valid string terminator sequences are BEL, ESC\\, and 0x9c\nconst ST = \"(?:\\\\u0007|\\\\u001B\\\\u005C|\\\\u009C)\";\n\n// OSC sequences: ESC ] ... ST\nconst OSC_START = \"\\\\u001B\\\\]\";\n\n// CSI and related: ESC/C1, optional intermediates, optional params (supports ; and :), then final byte\nconst CSI_START = \"[\\\\u001B\\\\u009B][[\\\\]()#;?]*(?:\\\\d{1,4}(?:[;:]\\\\d{0,4})*)?\";\nconst CSI_FINAL = \"[\\\\dA-PR-TZcf-nq-uy=><~]\";\n\n// Complete sequences. OSC is non-greedy until the first ST.\nconst regex = new RegExp(`(?:${OSC_START}[\\\\s\\\\S]*?${ST})|${CSI_START}${CSI_FINAL}`, \"g\");\n\n// Unfinished sequence at the end of the text: OSC without its ST (a trailing ESC may start ESC\\),\n// or CSI without its final byte.\nconst unfinishedAnsiAtEndRegex = new RegExp(\n\t`(?:${OSC_START}(?:[^\\\\u0007\\\\u009C\\\\u001B]|\\\\u001B(?!\\\\\\\\))*|${CSI_START})$`,\n);\n\n// Longest unfinished sequence held back while streaming. Longer ones are processed as-is.\nconst MAX_PENDING_ANSI_LENGTH = 256;\n\n/**\n * Split streamed text into a part that is safe to pass to stripAnsi now and a trailing\n * unfinished escape sequence that should be prepended to the next chunk.\n */\nexport function splitIncompleteAnsiSuffix(value: string): { complete: string; pending: string } {\n\tif (!value.includes(\"\\u001B\") && !value.includes(\"\\u009B\")) {\n\t\treturn { complete: value, pending: \"\" };\n\t}\n\tconst windowStart = Math.max(0, value.length - MAX_PENDING_ANSI_LENGTH);\n\tconst match = unfinishedAnsiAtEndRegex.exec(value.slice(windowStart));\n\tif (!match) {\n\t\treturn { complete: value, pending: \"\" };\n\t}\n\tconst splitAt = windowStart + match.index;\n\treturn { complete: value.slice(0, splitAt), pending: value.slice(splitAt) };\n}\n\nexport function stripAnsi(value: string): string {\n\tif (typeof value !== \"string\") {\n\t\tthrow new TypeError(`Expected a \\`string\\`, got \\`${typeof value}\\``);\n\t}\n\n\t// Fast path: ANSI codes require ESC (7-bit) or CSI (8-bit) introducer\n\tif (!value.includes(\"\\u001B\") && !value.includes(\"\\u009B\")) {\n\t\treturn value;\n\t}\n\n\t// Even though the regex is global, we don't need to reset the `.lastIndex`\n\t// because unlike `.exec()` and `.test()`, `.replace()` does it automatically\n\t// and doing it manually has a performance penalty.\n\treturn value.replace(regex, \"\");\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../src/utils/clipboard.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,eAAe,EAAa,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../src/utils/clipboard.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,eAAe,EAAa,MAAM,uBAAuB,CAAC;AA6ExE,wBAAsB,iBAAiB,CACtC,MAAM,GAAE;IAAE,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,GAAG,IAAgB,GACvD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWxB;AAeD;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC3C,MAAM,GAAE,IAAI,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAgB,EACpE,eAAe,GAAE,MAAM,CAAC,QAA2B,GACjD,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAqB1B;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyIjE"}
|
package/dist/utils/clipboard.js
CHANGED
|
@@ -66,7 +66,17 @@ function copyViaWindowsClipboard(text) {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
+
function readTermuxClipboardText() {
|
|
70
|
+
return new Promise((resolve) => {
|
|
71
|
+
execFile("termux-clipboard-get", [], { timeout: 5000, env: createChildProcessEnvironment() }, (error, stdout) => resolve(error ? undefined : stdout));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
69
74
|
export async function readClipboardText(source = clipboard) {
|
|
75
|
+
if (process.env.TERMUX_VERSION) {
|
|
76
|
+
const text = await readTermuxClipboardText();
|
|
77
|
+
if (text !== undefined)
|
|
78
|
+
return text || null;
|
|
79
|
+
}
|
|
70
80
|
try {
|
|
71
81
|
if (!source)
|
|
72
82
|
return null;
|
|
@@ -245,10 +255,10 @@ export async function copyToClipboard(text) {
|
|
|
245
255
|
return;
|
|
246
256
|
if (oversized)
|
|
247
257
|
throw new Error("Clipboard unavailable: text exceeds the OSC 52 size limit");
|
|
258
|
+
if (env.TERMUX_VERSION) {
|
|
259
|
+
throw new Error("Clipboard unavailable: install the Termux:API app and `termux-api` package");
|
|
260
|
+
}
|
|
248
261
|
if (p === "linux") {
|
|
249
|
-
if (env.TERMUX_VERSION) {
|
|
250
|
-
throw new Error("Clipboard unavailable: install the Termux:API app and `termux-api` package");
|
|
251
|
-
}
|
|
252
262
|
if (env.WAYLAND_DISPLAY) {
|
|
253
263
|
throw new Error("Clipboard unavailable: install `wl-clipboard` (`wl-copy`) or check Wayland access");
|
|
254
264
|
}
|