@bastani/atomic 0.9.68 → 0.9.69
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 +68 -0
- package/dist/builtin/intercom/package.json +1 -1
- 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 +20 -0
- package/dist/builtin/workflows/builtin/{chunk-95r61ve5.js → chunk-3gk3k003.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-qbthhjjk.js → chunk-6bgw5p0e.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-rv4xxwd6.js → chunk-k8930apc.js} +101 -37
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +740 -453
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +563 -280
- package/dist/builtin/workflows/src/index.js +549 -266
- package/dist/builtin/workflows/src/local-worker-entry.mjs +563 -280
- package/dist/core/agent-session-boundaries.d.ts.map +1 -1
- package/dist/core/agent-session-boundaries.js +14 -1
- package/dist/core/agent-session-boundaries.js.map +1 -1
- package/dist/core/agent-session-events.d.ts +6 -0
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +99 -20
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-held-input.d.ts +44 -0
- package/dist/core/agent-session-held-input.d.ts.map +1 -0
- package/dist/core/agent-session-held-input.js +76 -0
- package/dist/core/agent-session-held-input.js.map +1 -0
- package/dist/core/agent-session-message-queue.d.ts +6 -2
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +29 -7
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +4 -2
- 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-persistence-failures.d.ts +19 -0
- package/dist/core/agent-session-persistence-failures.d.ts.map +1 -0
- package/dist/core/agent-session-persistence-failures.js +39 -0
- package/dist/core/agent-session-persistence-failures.js.map +1 -0
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +3 -0
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.js +5 -1
- package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +156 -16
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +14 -3
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session.d.ts +5 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +5 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +3 -0
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +10 -2
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +1 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/workflow-run-control.d.ts +6 -0
- package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
- package/dist/core/extensions/workflow-run-control.js.map +1 -1
- package/dist/core/queued-input-admission.d.ts +2 -0
- package/dist/core/queued-input-admission.d.ts.map +1 -1
- package/dist/core/queued-input-admission.js +4 -0
- package/dist/core/queued-input-admission.js.map +1 -1
- package/dist/core/storage/errors.d.ts +2 -0
- package/dist/core/storage/errors.d.ts.map +1 -1
- package/dist/core/storage/errors.js +9 -0
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/storage/storage-status.d.ts +2 -2
- package/dist/core/storage/storage-status.d.ts.map +1 -1
- package/dist/core/storage/storage-status.js +2 -10
- package/dist/core/storage/storage-status.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +16 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/conflict-registry.d.ts +17 -0
- package/dist/core/tools/conflict-registry.d.ts.map +1 -1
- package/dist/core/tools/conflict-registry.js +80 -0
- package/dist/core/tools/conflict-registry.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +23 -4
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/history-protocol.d.ts +29 -0
- package/dist/core/tools/history-protocol.d.ts.map +1 -0
- package/dist/core/tools/history-protocol.js +438 -0
- package/dist/core/tools/history-protocol.js.map +1 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +4 -4
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/resource-selectors.d.ts +28 -0
- package/dist/core/tools/resource-selectors.d.ts.map +1 -1
- package/dist/core/tools/resource-selectors.js +73 -13
- package/dist/core/tools/resource-selectors.js.map +1 -1
- package/dist/core/tools/search-line-ranges.d.ts +5 -0
- package/dist/core/tools/search-line-ranges.d.ts.map +1 -1
- package/dist/core/tools/search-line-ranges.js +7 -3
- package/dist/core/tools/search-line-ranges.js.map +1 -1
- package/dist/core/tools/search.d.ts.map +1 -1
- package/dist/core/tools/search.js +5 -5
- package/dist/core/tools/search.js.map +1 -1
- package/dist/core/tools/shell-plain-words.d.ts +8 -0
- package/dist/core/tools/shell-plain-words.d.ts.map +1 -0
- package/dist/core/tools/shell-plain-words.js +139 -0
- package/dist/core/tools/shell-plain-words.js.map +1 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +8 -45
- package/dist/core/tools/write.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +4 -0
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +4 -0
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts +9 -1
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +82 -9
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +15 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +5 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts +6 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +16 -1
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +1 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/docs/compaction.md +1 -1
- package/docs/extensions/api-reference.md +3 -1
- package/docs/rpc/protocol.md +1 -1
- package/docs/sdk.md +3 -1
- package/docs/sessions.md +17 -0
- package/docs/storage.md +2 -0
- package/docs/tools.md +8 -4
- package/docs/usage.md +1 -1
- package/npm-shrinkwrap.json +75 -53
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-process-lifecycle.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-process-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MA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teractiveEngine } from \"../interactive-engine/extension-ui-bridge.ts\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { APP_TITLE, chalk, killTrackedDetachedChildren } from \"./interactive-mode-deps.ts\";\nimport { formatCrashExtensionHint, formatResumeCommand, isDeadTerminalError } from \"./interactive-mode-helpers.ts\";\nimport { pauseAndAbortInteractiveSession } from \"./interactive-pause.ts\";\nimport { restoreFailedSubmissionDraft } from \"./interactive-prompt-restore.ts\";\nimport { isWindowsSubshellActive, openWindowsSubshell } from \"./interactive-windows-subshell.ts\";\n\nconst SHUTDOWN_INPUT_DRAIN_MAX_MS = 250;\nconst SHUTDOWN_INPUT_DRAIN_IDLE_MS = 50;\n\nInteractiveModeBase.prototype.handleCtrlC = function (this: InteractiveModeBase): void {\n\tif (isWindowsSubshellActive(this)) return;\n\t// When the agent is doing work, Ctrl+C interrupts it (matching Escape and\n\t// common CLI muscle memory) instead of clearing/exiting the editor. Only\n\t// fall back to the clear / double-press-exit behavior when idle.\n\tif (this.interruptActiveOperation()) {\n\t\t// Reset the double-press window so a follow-up Ctrl+C after the abort\n\t\t// does not immediately exit.\n\t\tthis.lastSigintTime = 0;\n\t\treturn;\n\t}\n\tconst now = Date.now();\n\tif (now - this.lastSigintTime < 500) {\n\t\tvoid this.shutdown();\n\t} else {\n\t\tthis.clearEditor();\n\t\tthis.lastSigintTime = now;\n\t}\n};\n\n/**\n * A SIGINT signal, as opposed to the Ctrl+C key. In raw mode the keyboard sends Ctrl+C to the\n * editor as input, so a signal came from outside the TUI: on Windows, any process attached to\n * the same console that raises a console control event. It may interrupt running work, as the\n * key does, but never clears the editor or counts toward the double-press exit.\n */\nInteractiveModeBase.prototype.handleSigintSignal = function (this: InteractiveModeBase): void {\n\tif (!process.stdin.isTTY || !process.stdin.isRaw) {\n\t\tthis.handleCtrlC();\n\t\treturn;\n\t}\n\tif (isWindowsSubshellActive(this)) return;\n\tif (this.interruptActiveOperation()) this.lastSigintTime = 0;\n};\n\nInteractiveModeBase.prototype.interruptActiveOperation = function (this: InteractiveModeBase): boolean {\n\t// Mirror the Escape interrupt paths so Ctrl+C aborts whichever operation is\n\t// currently running. Returns true when something was aborted.\n\t//\n\t// Escalate first when the interactive engine owes a cooperative abort or the\n\t// heartbeat watchdog calls it unresponsive: that is the explicit termination\n\t// the watchdog advertises with \"Esc interrupt · Ctrl+C terminate\". Every\n\t// cooperative route below would otherwise queue another request for a child\n\t// that cannot answer.\n\tif (terminateInteractiveEngine(this.runtimeHost)) {\n\t\treturn true;\n\t}\n\tif (this.session.isStreaming || this.session.agent.hasQueuedMessages()) {\n\t\tpauseAndAbortInteractiveSession(this);\n\t\treturn true;\n\t}\n\tif (this.session.isBashRunning) {\n\t\tthis.session.abortBash();\n\t\treturn true;\n\t}\n\tif (this.session.isCompacting) {\n\t\tthis.session.abortCompaction();\n\t\treturn true;\n\t}\n\tif (this.session.isRetrying) {\n\t\tthis.session.abortRetry();\n\t\treturn true;\n\t}\n\treturn false;\n};\n\nInteractiveModeBase.prototype.handleCtrlD = function (this: InteractiveModeBase): void {\n\t// Only called when editor is empty (enforced by CustomEditor)\n\tvoid this.shutdown();\n};\n\nInteractiveModeBase.prototype.shutdown = async function (\n\tthis: InteractiveModeBase,\n\toptions?: { fromSignal?: boolean },\n): Promise<void> {\n\tif (this.isShuttingDown) return;\n\tthis.isShuttingDown = true;\n\t// Keep signal handlers registered until terminal cleanup has completed.\n\t// `signal-exit` checks the listener list during the same SIGTERM/SIGHUP\n\t// dispatch and re-sends the signal if only its own listeners remain.\n\n\tif (options?.fromSignal) {\n\t\tawait this.runtimeHost.dispose({ fromSignal: true });\n\t\tthis.themeController.disableAutoSync();\n\t\t// Drain any in-flight Kitty key release events briefly before stopping.\n\t\t// Keep this bounded so Ctrl+C exits do not feel stalled on Windows.\n\t\tawait this.ui.terminal.drainInput(SHUTDOWN_INPUT_DRAIN_MAX_MS, SHUTDOWN_INPUT_DRAIN_IDLE_MS);\n\t\tthis.stop();\n\t\tprocess.exit(0);\n\t}\n\n\t// Drain any in-flight Kitty key release events briefly before stopping.\n\t// Keep this bounded so Ctrl+C exits do not feel stalled on Windows.\n\tthis.themeController.disableAutoSync();\n\tawait this.ui.terminal.drainInput(SHUTDOWN_INPUT_DRAIN_MAX_MS, SHUTDOWN_INPUT_DRAIN_IDLE_MS);\n\n\tthis.stop();\n\tawait this.runtimeHost.dispose();\n\tconst resumeCommand = formatResumeCommand(this.sessionManager);\n\tif (resumeCommand) {\n\t\tprocess.stdout.write(`${chalk.dim(\"To resume this session:\")} ${resumeCommand}\\n`);\n\t}\n\tprocess.exit(0);\n};\n\nInteractiveModeBase.prototype.emergencyTerminalExit = function (this: InteractiveModeBase): never {\n\tthis.isShuttingDown = true;\n\tthis.unregisterSignalHandlers();\n\tkillTrackedDetachedChildren();\n\t// The terminal is gone. Do not run normal shutdown because TUI and\n\t// extension cleanup can write restore sequences and re-trigger EIO.\n\tprocess.exit(129);\n};\n\nInteractiveModeBase.prototype.uncaughtCrash = function (this: InteractiveModeBase, error: Error): never {\n\tif (isDeadTerminalError(error) && (error as NodeJS.ErrnoException).syscall === \"setRawMode\") {\n\t\tthis.emergencyTerminalExit();\n\t}\n\tif (this.isShuttingDown) {\n\t\tprocess.exit(1);\n\t}\n\tthis.isShuttingDown = true;\n\ttry {\n\t\tthis.unregisterSignalHandlers();\n\t} catch {}\n\ttry {\n\t\tkillTrackedDetachedChildren();\n\t} catch {}\n\ttry {\n\t\tthis.ui.stop();\n\t} catch {}\n\tconsole.error(`${APP_TITLE} exiting due to uncaughtException:`);\n\tconsole.error(error);\n\tconst extensionHint = this.getCrashExtensionHint(error);\n\tif (extensionHint) console.error(`\\n${extensionHint}`);\n\tprocess.exit(1);\n};\n\nInteractiveModeBase.prototype.getCrashExtensionHint = function (\n\tthis: InteractiveModeBase,\n\terror: unknown,\n): string | undefined {\n\ttry {\n\t\treturn formatCrashExtensionHint(\n\t\t\tfindExtensionStackMatches(\n\t\t\t\terror instanceof Error ? error.stack : undefined,\n\t\t\t\tthis.session.resourceLoader.getExtensions().extensions,\n\t\t\t),\n\t\t);\n\t} catch {\n\t\treturn undefined;\n\t}\n};\n\nInteractiveModeBase.prototype.checkShutdownRequested = async function (this: InteractiveModeBase): Promise<void> {\n\tif (!this.shutdownRequested) return;\n\tawait this.shutdown();\n};\n\nInteractiveModeBase.prototype.registerSignalHandlers = function (this: InteractiveModeBase): void {\n\tthis.unregisterSignalHandlers();\n\n\tconst signals: NodeJS.Signals[] = [\"SIGTERM\"];\n\tif (process.platform !== \"win32\") {\n\t\tsignals.push(\"SIGHUP\");\n\t}\n\n\tfor (const signal of signals) {\n\t\tconst handler = () => {\n\t\t\tkillTrackedDetachedChildren();\n\t\t\tvoid this.shutdown({ fromSignal: true });\n\t\t};\n\t\tprocess.prependListener(signal, handler);\n\t\tthis.signalCleanupHandlers.push(() => process.off(signal, handler));\n\t}\n\n\tconst sigintHandler = () => {\n\t\tthis.handleSigintSignal();\n\t};\n\tprocess.prependListener(\"SIGINT\", sigintHandler);\n\tthis.signalCleanupHandlers.push(() => process.off(\"SIGINT\", sigintHandler));\n\n\tconst terminalErrorHandler = (error: Error) => {\n\t\tif (isDeadTerminalError(error)) {\n\t\t\tthis.emergencyTerminalExit();\n\t\t}\n\t\tthrow error;\n\t};\n\tfor (const stream of [process.stdin, process.stdout, process.stderr]) {\n\t\tstream.on(\"error\", terminalErrorHandler);\n\t\tthis.signalCleanupHandlers.push(() => stream.off(\"error\", terminalErrorHandler));\n\t}\n\n\t// Restore the terminal before the process dies on any uncaught throw.\n\t// Without this, an unhandled exception from extension code (or anywhere\n\t// in pi) leaves the terminal in raw mode with no cursor.\n\tconst uncaughtExceptionHandler = (error: Error) => this.uncaughtCrash(error);\n\tprocess.prependListener(\"uncaughtException\", uncaughtExceptionHandler);\n\tthis.signalCleanupHandlers.push(() => process.off(\"uncaughtException\", uncaughtExceptionHandler));\n};\n\nInteractiveModeBase.prototype.unregisterSignalHandlers = function (this: InteractiveModeBase): void {\n\tfor (const cleanup of this.signalCleanupHandlers) {\n\t\tcleanup();\n\t}\n\tthis.signalCleanupHandlers = [];\n};\n\nInteractiveModeBase.prototype.handleCtrlZ = function (this: InteractiveModeBase): void {\n\tif (process.platform === \"win32\") {\n\t\tvoid openWindowsSubshell(this).catch((error: Error) =>\n\t\t\tthis.showStatus(`PowerShell subshell failed: ${error.message}`),\n\t\t);\n\t\treturn;\n\t}\n\n\t// Keep the event loop alive while suspended. Without this, stopping the TUI\n\t// can leave Node with no ref'ed handles, causing the process to exit on fg\n\t// before the SIGCONT handler gets a chance to restore the terminal.\n\tconst suspendKeepAlive = setInterval(() => {}, 2 ** 30);\n\n\t// Ignore SIGINT while suspended so Ctrl+C in the terminal does not\n\t// kill the backgrounded process. The handler is removed on resume.\n\tconst ignoreSigint = () => {};\n\tprocess.on(\"SIGINT\", ignoreSigint);\n\n\t// Set up handler to restore TUI when resumed\n\tprocess.once(\"SIGCONT\", () => {\n\t\tclearInterval(suspendKeepAlive);\n\t\tprocess.removeListener(\"SIGINT\", ignoreSigint);\n\t\tthis.ui.start();\n\t\tthis.ui.requestRender(true);\n\t});\n\n\ttry {\n\t\t// Stop the TUI (restore terminal to normal mode)\n\t\tthis.ui.stop();\n\n\t\t// Send SIGTSTP to process group (pid=0 means all processes in group)\n\t\tprocess.kill(0, \"SIGTSTP\");\n\t} catch (error) {\n\t\tclearInterval(suspendKeepAlive);\n\t\tprocess.removeListener(\"SIGINT\", ignoreSigint);\n\t\tthrow error;\n\t}\n};\n\nInteractiveModeBase.prototype.handleFollowUp = async function (this: InteractiveModeBase): Promise<void> {\n\tconst rawText = this.editor.getExpandedText?.() ?? this.editor.getText();\n\tconst text = rawText.trim();\n\tif (!text) return;\n\n\t// Alt+Enter dispatches straight to the engine, exactly like the direct\n\t// branches of the Enter handler, so it needs the same send-failure restore:\n\t// otherwise a queued follow-up submitted while the engine is gone is lost.\n\tconst dispatch = async (send: () => Promise<void>): Promise<void> => {\n\t\ttry {\n\t\t\tawait send();\n\t\t} catch (error) {\n\t\t\tif (!restoreFailedSubmissionDraft(this, error, rawText)) throw error;\n\t\t}\n\t};\n\n\t// Queue input behind compaction-queued messages (extension commands execute immediately)\n\tif (\n\t\tthis.compactionActive ||\n\t\t(!this.session.queuedMessagesPaused && (this.compactionFlushPending || this.compactionSendFailed))\n\t) {\n\t\tif (this.isExtensionCommand(text)) {\n\t\t\tthis.editor.addToHistory?.(text);\n\t\t\tthis.editor.setText(\"\");\n\t\t\tawait dispatch(() => this.session.prompt(text));\n\t\t} else {\n\t\t\tthis.queueCompactionMessage(text, \"followUp\");\n\t\t}\n\t\treturn;\n\t}\n\n\t// A paused submission releases the session queue before its own turn, so move held\n\t// messages there first to keep them ahead of this one.\n\tif (this.session.queuedMessagesPaused && this.compactionSendFailed && !this.compactionFlushPending) {\n\t\tawait this.flushCompactionQueue({ willRetry: false });\n\t}\n\n\t// Alt+Enter queues a follow-up message (waits until agent finishes)\n\t// This handles extension commands (execute immediately), prompt template expansion, and queueing\n\tif (this.session.isStreaming) {\n\t\tthis.editor.addToHistory?.(text);\n\t\tthis.editor.setText(\"\");\n\t\tawait dispatch(async () => {\n\t\t\tawait this.session.prompt(text, { streamingBehavior: \"followUp\" });\n\t\t\tthis.updatePendingMessagesDisplay();\n\t\t\tthis.ui.requestRender();\n\t\t});\n\t}\n\t// If not streaming, Alt+Enter acts like regular Enter (trigger onSubmit).\n\t// Hand over the raw expanded buffer, not the trimmed text: Alt+Enter is an\n\t// app action, so CustomEditor returns before its own pre-trim snapshot runs\n\t// and the submit handler's only draft is this argument. It trims the value\n\t// itself for delivery, so the agent still receives the normalized prompt.\n\telse if (this.editor.onSubmit) {\n\t\tthis.editor.setText(\"\");\n\t\tthis.editor.onSubmit(rawText);\n\t}\n};\n\nInteractiveModeBase.prototype.handleDequeue = function (this: InteractiveModeBase): void {\n\tconst restored = this.restoreQueuedMessagesToEditor();\n\tif (restored === 0) {\n\t\tthis.showStatus(\"No queued messages to restore\");\n\t}\n};\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-process-lifecycle.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-process-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACnH,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAEjG,MAAM,2BAA2B,GAAG,GAAG,CAAC;AACxC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAExC,mBAAmB,CAAC,SAAS,CAAC,WAAW,GAAG;IAC3C,IAAI,uBAAuB,CAAC,IAAI,CAAC;QAAE,OAAO;IAC1C,0EAA0E;IAC1E,yEAAyE;IACzE,iEAAiE;IACjE,IAAI,IAAI,CAAC,wBAAwB,EAAE,EAAE,CAAC;QACrC,sEAAsE;QACtE,6BAA6B;QAC7B,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;QACxB,OAAO;IACR,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,IAAI,GAAG,GAAG,IAAI,CAAC,cAAc,GAAG,GAAG,EAAE,CAAC;QACrC,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;IACtB,CAAC;SAAM,CAAC;QACP,IAAI,CAAC,WAAW,EAAE,CAA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BAAmB,CAAC,SAAS,CAAC,aAAa,GAAG;IAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,6BAA6B,EAAE,CAAC;IACtD,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACpB,IAAI,CAAC,UAAU,CAAC,+BAA+B,CAAC,CAAC;IAClD,CAAC;AACF,CAAC,CAAC","sourcesContent":["import { findExtensionStackMatches } from \"../../core/crash-log.ts\";\nimport { terminateInteractiveEngine } from \"../interactive-engine/extension-ui-bridge.ts\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { APP_TITLE, chalk, killTrackedDetachedChildren } from \"./interactive-mode-deps.ts\";\nimport { formatCrashExtensionHint, formatResumeCommand, isDeadTerminalError } from \"./interactive-mode-helpers.ts\";\nimport { pauseAndAbortInteractiveSession } from \"./interactive-pause.ts\";\nimport { restoreFailedSubmissionDraft } from \"./interactive-prompt-restore.ts\";\nimport { handOffCompactionQueue } from \"./interactive-queueing.ts\";\nimport { isWindowsSubshellActive, openWindowsSubshell } from \"./interactive-windows-subshell.ts\";\n\nconst SHUTDOWN_INPUT_DRAIN_MAX_MS = 250;\nconst SHUTDOWN_INPUT_DRAIN_IDLE_MS = 50;\n\nInteractiveModeBase.prototype.handleCtrlC = function (this: InteractiveModeBase): void {\n\tif (isWindowsSubshellActive(this)) return;\n\t// When the agent is doing work, Ctrl+C interrupts it (matching Escape and\n\t// common CLI muscle memory) instead of clearing/exiting the editor. Only\n\t// fall back to the clear / double-press-exit behavior when idle.\n\tif (this.interruptActiveOperation()) {\n\t\t// Reset the double-press window so a follow-up Ctrl+C after the abort\n\t\t// does not immediately exit.\n\t\tthis.lastSigintTime = 0;\n\t\treturn;\n\t}\n\tconst now = Date.now();\n\tif (now - this.lastSigintTime < 500) {\n\t\tvoid this.shutdown();\n\t} else {\n\t\tthis.clearEditor();\n\t\tthis.lastSigintTime = now;\n\t}\n};\n\n/**\n * A SIGINT signal, as opposed to the Ctrl+C key. In raw mode the keyboard sends Ctrl+C to the\n * editor as input, so a signal came from outside the TUI: on Windows, any process attached to\n * the same console that raises a console control event. It may interrupt running work, as the\n * key does, but never clears the editor or counts toward the double-press exit.\n */\nInteractiveModeBase.prototype.handleSigintSignal = function (this: InteractiveModeBase): void {\n\tif (!process.stdin.isTTY || !process.stdin.isRaw) {\n\t\tthis.handleCtrlC();\n\t\treturn;\n\t}\n\tif (isWindowsSubshellActive(this)) return;\n\tif (this.interruptActiveOperation()) this.lastSigintTime = 0;\n};\n\nInteractiveModeBase.prototype.interruptActiveOperation = function (this: InteractiveModeBase): boolean {\n\t// Mirror the Escape interrupt paths so Ctrl+C aborts whichever operation is\n\t// currently running. Returns true when something was aborted.\n\t//\n\t// Escalate first when the interactive engine owes a cooperative abort or the\n\t// heartbeat watchdog calls it unresponsive: that is the explicit termination\n\t// the watchdog advertises with \"Esc interrupt · Ctrl+C terminate\". Every\n\t// cooperative route below would otherwise queue another request for a child\n\t// that cannot answer.\n\tif (terminateInteractiveEngine(this.runtimeHost)) {\n\t\treturn true;\n\t}\n\tif (this.session.isStreaming || this.session.agent.hasQueuedMessages()) {\n\t\tpauseAndAbortInteractiveSession(this);\n\t\treturn true;\n\t}\n\tif (this.session.isBashRunning) {\n\t\tthis.session.abortBash();\n\t\treturn true;\n\t}\n\tif (this.session.isCompacting) {\n\t\tthis.session.abortCompaction();\n\t\treturn true;\n\t}\n\tif (this.session.isRetrying) {\n\t\tthis.session.abortRetry();\n\t\treturn true;\n\t}\n\treturn false;\n};\n\nInteractiveModeBase.prototype.handleCtrlD = function (this: InteractiveModeBase): void {\n\t// Only called when editor is empty (enforced by CustomEditor)\n\tvoid this.shutdown();\n};\n\nInteractiveModeBase.prototype.shutdown = async function (\n\tthis: InteractiveModeBase,\n\toptions?: { fromSignal?: boolean },\n): Promise<void> {\n\tif (this.isShuttingDown) return;\n\tthis.isShuttingDown = true;\n\t// Keep signal handlers registered until terminal cleanup has completed.\n\t// `signal-exit` checks the listener list during the same SIGTERM/SIGHUP\n\t// dispatch and re-sends the signal if only its own listeners remain.\n\n\tif (options?.fromSignal) {\n\t\tawait this.runtimeHost.dispose({ fromSignal: true });\n\t\tthis.themeController.disableAutoSync();\n\t\t// Drain any in-flight Kitty key release events briefly before stopping.\n\t\t// Keep this bounded so Ctrl+C exits do not feel stalled on Windows.\n\t\tawait this.ui.terminal.drainInput(SHUTDOWN_INPUT_DRAIN_MAX_MS, SHUTDOWN_INPUT_DRAIN_IDLE_MS);\n\t\tthis.stop();\n\t\tprocess.exit(0);\n\t}\n\n\t// Drain any in-flight Kitty key release events briefly before stopping.\n\t// Keep this bounded so Ctrl+C exits do not feel stalled on Windows.\n\tthis.themeController.disableAutoSync();\n\tawait this.ui.terminal.drainInput(SHUTDOWN_INPUT_DRAIN_MAX_MS, SHUTDOWN_INPUT_DRAIN_IDLE_MS);\n\n\tthis.stop();\n\tawait this.runtimeHost.dispose();\n\tconst resumeCommand = formatResumeCommand(this.sessionManager);\n\tif (resumeCommand) {\n\t\tprocess.stdout.write(`${chalk.dim(\"To resume this session:\")} ${resumeCommand}\\n`);\n\t}\n\tprocess.exit(0);\n};\n\nInteractiveModeBase.prototype.emergencyTerminalExit = function (this: InteractiveModeBase): never {\n\tthis.isShuttingDown = true;\n\tthis.unregisterSignalHandlers();\n\tkillTrackedDetachedChildren();\n\t// The terminal is gone. Do not run normal shutdown because TUI and\n\t// extension cleanup can write restore sequences and re-trigger EIO.\n\tprocess.exit(129);\n};\n\nInteractiveModeBase.prototype.uncaughtCrash = function (this: InteractiveModeBase, error: Error): never {\n\tif (isDeadTerminalError(error) && (error as NodeJS.ErrnoException).syscall === \"setRawMode\") {\n\t\tthis.emergencyTerminalExit();\n\t}\n\tif (this.isShuttingDown) {\n\t\tprocess.exit(1);\n\t}\n\tthis.isShuttingDown = true;\n\ttry {\n\t\tthis.unregisterSignalHandlers();\n\t} catch {}\n\ttry {\n\t\tkillTrackedDetachedChildren();\n\t} catch {}\n\ttry {\n\t\tthis.ui.stop();\n\t} catch {}\n\tconsole.error(`${APP_TITLE} exiting due to uncaughtException:`);\n\tconsole.error(error);\n\tconst extensionHint = this.getCrashExtensionHint(error);\n\tif (extensionHint) console.error(`\\n${extensionHint}`);\n\tprocess.exit(1);\n};\n\nInteractiveModeBase.prototype.getCrashExtensionHint = function (\n\tthis: InteractiveModeBase,\n\terror: unknown,\n): string | undefined {\n\ttry {\n\t\treturn formatCrashExtensionHint(\n\t\t\tfindExtensionStackMatches(\n\t\t\t\terror instanceof Error ? error.stack : undefined,\n\t\t\t\tthis.session.resourceLoader.getExtensions().extensions,\n\t\t\t),\n\t\t);\n\t} catch {\n\t\treturn undefined;\n\t}\n};\n\nInteractiveModeBase.prototype.checkShutdownRequested = async function (this: InteractiveModeBase): Promise<void> {\n\tif (!this.shutdownRequested) return;\n\tawait this.shutdown();\n};\n\nInteractiveModeBase.prototype.registerSignalHandlers = function (this: InteractiveModeBase): void {\n\tthis.unregisterSignalHandlers();\n\n\tconst signals: NodeJS.Signals[] = [\"SIGTERM\"];\n\tif (process.platform !== \"win32\") {\n\t\tsignals.push(\"SIGHUP\");\n\t}\n\n\tfor (const signal of signals) {\n\t\tconst handler = () => {\n\t\t\tkillTrackedDetachedChildren();\n\t\t\tvoid this.shutdown({ fromSignal: true });\n\t\t};\n\t\tprocess.prependListener(signal, handler);\n\t\tthis.signalCleanupHandlers.push(() => process.off(signal, handler));\n\t}\n\n\tconst sigintHandler = () => {\n\t\tthis.handleSigintSignal();\n\t};\n\tprocess.prependListener(\"SIGINT\", sigintHandler);\n\tthis.signalCleanupHandlers.push(() => process.off(\"SIGINT\", sigintHandler));\n\n\tconst terminalErrorHandler = (error: Error) => {\n\t\tif (isDeadTerminalError(error)) {\n\t\t\tthis.emergencyTerminalExit();\n\t\t}\n\t\tthrow error;\n\t};\n\tfor (const stream of [process.stdin, process.stdout, process.stderr]) {\n\t\tstream.on(\"error\", terminalErrorHandler);\n\t\tthis.signalCleanupHandlers.push(() => stream.off(\"error\", terminalErrorHandler));\n\t}\n\n\t// Restore the terminal before the process dies on any uncaught throw.\n\t// Without this, an unhandled exception from extension code (or anywhere\n\t// in pi) leaves the terminal in raw mode with no cursor.\n\tconst uncaughtExceptionHandler = (error: Error) => this.uncaughtCrash(error);\n\tprocess.prependListener(\"uncaughtException\", uncaughtExceptionHandler);\n\tthis.signalCleanupHandlers.push(() => process.off(\"uncaughtException\", uncaughtExceptionHandler));\n};\n\nInteractiveModeBase.prototype.unregisterSignalHandlers = function (this: InteractiveModeBase): void {\n\tfor (const cleanup of this.signalCleanupHandlers) {\n\t\tcleanup();\n\t}\n\tthis.signalCleanupHandlers = [];\n};\n\nInteractiveModeBase.prototype.handleCtrlZ = function (this: InteractiveModeBase): void {\n\tif (process.platform === \"win32\") {\n\t\tvoid openWindowsSubshell(this).catch((error: Error) =>\n\t\t\tthis.showStatus(`PowerShell subshell failed: ${error.message}`),\n\t\t);\n\t\treturn;\n\t}\n\n\t// Keep the event loop alive while suspended. Without this, stopping the TUI\n\t// can leave Node with no ref'ed handles, causing the process to exit on fg\n\t// before the SIGCONT handler gets a chance to restore the terminal.\n\tconst suspendKeepAlive = setInterval(() => {}, 2 ** 30);\n\n\t// Ignore SIGINT while suspended so Ctrl+C in the terminal does not\n\t// kill the backgrounded process. The handler is removed on resume.\n\tconst ignoreSigint = () => {};\n\tprocess.on(\"SIGINT\", ignoreSigint);\n\n\t// Set up handler to restore TUI when resumed\n\tprocess.once(\"SIGCONT\", () => {\n\t\tclearInterval(suspendKeepAlive);\n\t\tprocess.removeListener(\"SIGINT\", ignoreSigint);\n\t\tthis.ui.start();\n\t\tthis.ui.requestRender(true);\n\t});\n\n\ttry {\n\t\t// Stop the TUI (restore terminal to normal mode)\n\t\tthis.ui.stop();\n\n\t\t// Send SIGTSTP to process group (pid=0 means all processes in group)\n\t\tprocess.kill(0, \"SIGTSTP\");\n\t} catch (error) {\n\t\tclearInterval(suspendKeepAlive);\n\t\tprocess.removeListener(\"SIGINT\", ignoreSigint);\n\t\tthrow error;\n\t}\n};\n\nInteractiveModeBase.prototype.handleFollowUp = async function (this: InteractiveModeBase): Promise<void> {\n\tconst rawText = this.editor.getExpandedText?.() ?? this.editor.getText();\n\tconst text = rawText.trim();\n\tif (!text) return;\n\n\t// Alt+Enter dispatches straight to the engine, exactly like the direct\n\t// branches of the Enter handler, so it needs the same send-failure restore:\n\t// otherwise a queued follow-up submitted while the engine is gone is lost.\n\tconst dispatch = async (send: () => Promise<void>): Promise<void> => {\n\t\ttry {\n\t\t\tawait send();\n\t\t} catch (error) {\n\t\t\tif (!restoreFailedSubmissionDraft(this, error, rawText)) throw error;\n\t\t}\n\t};\n\n\t// Queue input behind compaction-queued messages (extension commands execute immediately)\n\tif (\n\t\tthis.compactionActive ||\n\t\t(!this.session.queuedMessagesPaused && (this.compactionFlushPending || this.compactionSendFailed))\n\t) {\n\t\tif (this.isExtensionCommand(text)) {\n\t\t\tthis.editor.addToHistory?.(text);\n\t\t\tthis.editor.setText(\"\");\n\t\t\t// Messages the command sends must follow the ones already typed (#4251).\n\t\t\tif (this.compactionActive) handOffCompactionQueue(this);\n\t\t\tawait dispatch(() => this.session.prompt(text));\n\t\t} else {\n\t\t\tthis.queueCompactionMessage(text, \"followUp\");\n\t\t}\n\t\treturn;\n\t}\n\n\t// A paused submission releases the session queue before its own turn, so move held\n\t// messages there first to keep them ahead of this one.\n\tif (this.session.queuedMessagesPaused && this.compactionSendFailed && !this.compactionFlushPending) {\n\t\tawait this.flushCompactionQueue({ willRetry: false });\n\t}\n\n\t// Alt+Enter queues a follow-up message (waits until agent finishes)\n\t// This handles extension commands (execute immediately), prompt template expansion, and queueing\n\tif (this.session.isStreaming) {\n\t\tthis.editor.addToHistory?.(text);\n\t\tthis.editor.setText(\"\");\n\t\tawait dispatch(async () => {\n\t\t\tawait this.session.prompt(text, { streamingBehavior: \"followUp\" });\n\t\t\tthis.updatePendingMessagesDisplay();\n\t\t\tthis.ui.requestRender();\n\t\t});\n\t}\n\t// If not streaming, Alt+Enter acts like regular Enter (trigger onSubmit).\n\t// Hand over the raw expanded buffer, not the trimmed text: Alt+Enter is an\n\t// app action, so CustomEditor returns before its own pre-trim snapshot runs\n\t// and the submit handler's only draft is this argument. It trims the value\n\t// itself for delivery, so the agent still receives the normalized prompt.\n\telse if (this.editor.onSubmit) {\n\t\tthis.editor.setText(\"\");\n\t\tthis.editor.onSubmit(rawText);\n\t}\n};\n\nInteractiveModeBase.prototype.handleDequeue = function (this: InteractiveModeBase): void {\n\tconst restored = this.restoreQueuedMessagesToEditor();\n\tif (restored === 0) {\n\t\tthis.showStatus(\"No queued messages to restore\");\n\t}\n};\n"]}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { InteractiveModeBase } from "./interactive-mode-base.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Hand the editor's held messages to the session before an extension command runs during compaction (#4251).
|
|
4
|
+
* The session registers input as it arrives and holds it until compaction ends, so a message the command sends
|
|
5
|
+
* goes out after them, in typing order. Each message stays shown and restorable here until the session confirms
|
|
6
|
+
* it took it, and from then on the session lists it as queued and its clearQueue() returns it for Alt+Up and
|
|
7
|
+
* Ctrl+C. A message the session refuses returns to the editor queue.
|
|
8
|
+
*/
|
|
9
|
+
export declare function handOffCompactionQueue(mode: InteractiveModeBase): void;
|
|
2
10
|
//# sourceMappingURL=interactive-queueing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-queueing.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-queueing.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"interactive-queueing.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-queueing.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAgNjE;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CA2BtE"}
|
|
@@ -1,26 +1,38 @@
|
|
|
1
|
+
import { getInteractiveEngineRemoteCommands } from "../interactive-engine/extension-ui-bridge.js";
|
|
1
2
|
import { isRpcRequestAcceptedFailure } from "../rpc/rpc-transport-error.js";
|
|
2
3
|
import { InteractiveModeBase } from "./interactive-mode-base.js";
|
|
3
4
|
import { combineQueuedMessagesForEditor, Spacer, TruncatedText, theme } from "./interactive-mode-deps.js";
|
|
5
|
+
/** Typing order of messages handed to the session, so one it refuses returns to its own place. */
|
|
6
|
+
const handOffOrder = new WeakMap();
|
|
7
|
+
let nextHandOff = 0;
|
|
8
|
+
/**
|
|
9
|
+
* Messages handed to the session that it has not confirmed yet. The editor keeps showing and restoring them
|
|
10
|
+
* until the session reports it took them; from then on the session lists them itself.
|
|
11
|
+
*/
|
|
12
|
+
const unconfirmedHandOffs = new WeakMap();
|
|
13
|
+
function heldByEditor(mode) {
|
|
14
|
+
return [...(unconfirmedHandOffs.get(mode) ?? []), ...mode.compactionQueuedMessages];
|
|
15
|
+
}
|
|
4
16
|
InteractiveModeBase.prototype.getAllQueuedMessages = function () {
|
|
17
|
+
const held = heldByEditor(this);
|
|
5
18
|
return {
|
|
6
19
|
steering: [
|
|
7
20
|
...this.session.getSteeringMessages(),
|
|
8
|
-
...
|
|
21
|
+
...held.filter((msg) => msg.mode === "steer").map((msg) => msg.text),
|
|
9
22
|
],
|
|
10
23
|
followUp: [
|
|
11
24
|
...this.session.getFollowUpMessages(),
|
|
12
|
-
...
|
|
25
|
+
...held.filter((msg) => msg.mode === "followUp").map((msg) => msg.text),
|
|
13
26
|
],
|
|
14
27
|
};
|
|
15
28
|
};
|
|
16
29
|
InteractiveModeBase.prototype.clearAllQueues = function (options) {
|
|
17
30
|
const { steering, followUp } = this.session.clearQueue(options);
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.map((msg) => msg.text);
|
|
31
|
+
const held = heldByEditor(this);
|
|
32
|
+
const compactionSteering = held.filter((msg) => msg.mode === "steer").map((msg) => msg.text);
|
|
33
|
+
const compactionFollowUp = held.filter((msg) => msg.mode === "followUp").map((msg) => msg.text);
|
|
34
|
+
// clearQueue() also cancels unconfirmed hand-offs once they reach the session, so none is sent.
|
|
35
|
+
unconfirmedHandOffs.delete(this);
|
|
24
36
|
this.compactionQueuedMessages = [];
|
|
25
37
|
this.compactionSendFailed = false;
|
|
26
38
|
return {
|
|
@@ -83,7 +95,9 @@ InteractiveModeBase.prototype.isExtensionCommand = function (text) {
|
|
|
83
95
|
const extensionRunner = this.session.extensionRunner;
|
|
84
96
|
const spaceIndex = text.indexOf(" ");
|
|
85
97
|
const commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);
|
|
86
|
-
|
|
98
|
+
if (extensionRunner.getCommand(commandName))
|
|
99
|
+
return true;
|
|
100
|
+
return getInteractiveEngineRemoteCommands(this.runtimeHost).some((command) => command.source === "extension" && command.name === commandName);
|
|
87
101
|
};
|
|
88
102
|
InteractiveModeBase.prototype.flushCompactionQueue = async function (options) {
|
|
89
103
|
if (this.compactionFlushPending || this.compactionQueuedMessages.length === 0)
|
|
@@ -137,6 +151,65 @@ function returnCompactionMessage(mode, message, error) {
|
|
|
137
151
|
mode.updatePendingMessagesDisplay();
|
|
138
152
|
showCompactionQueueError(mode, error);
|
|
139
153
|
}
|
|
154
|
+
function returnHandedOffMessage(mode, message, error) {
|
|
155
|
+
const rank = handOffOrder.get(message) ?? -1;
|
|
156
|
+
const queue = mode.compactionQueuedMessages;
|
|
157
|
+
const index = queue.findIndex((queued) => (handOffOrder.get(queued) ?? Number.POSITIVE_INFINITY) > rank);
|
|
158
|
+
mode.compactionQueuedMessages =
|
|
159
|
+
index === -1 ? [...queue, message] : [...queue.slice(0, index), message, ...queue.slice(index)];
|
|
160
|
+
mode.compactionSendFailed = true;
|
|
161
|
+
mode.updatePendingMessagesDisplay();
|
|
162
|
+
showCompactionQueueError(mode, error);
|
|
163
|
+
}
|
|
164
|
+
function confirmHandOff(mode, message) {
|
|
165
|
+
const pending = unconfirmedHandOffs.get(mode);
|
|
166
|
+
const index = pending?.indexOf(message) ?? -1;
|
|
167
|
+
if (!pending || index === -1)
|
|
168
|
+
return false;
|
|
169
|
+
pending.splice(index, 1);
|
|
170
|
+
if (pending.length === 0)
|
|
171
|
+
unconfirmedHandOffs.delete(mode);
|
|
172
|
+
mode.updatePendingMessagesDisplay();
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Hand the editor's held messages to the session before an extension command runs during compaction (#4251).
|
|
177
|
+
* The session registers input as it arrives and holds it until compaction ends, so a message the command sends
|
|
178
|
+
* goes out after them, in typing order. Each message stays shown and restorable here until the session confirms
|
|
179
|
+
* it took it, and from then on the session lists it as queued and its clearQueue() returns it for Alt+Up and
|
|
180
|
+
* Ctrl+C. A message the session refuses returns to the editor queue.
|
|
181
|
+
*/
|
|
182
|
+
export function handOffCompactionQueue(mode) {
|
|
183
|
+
const messages = mode.compactionQueuedMessages;
|
|
184
|
+
if (messages.length === 0)
|
|
185
|
+
return;
|
|
186
|
+
mode.compactionQueuedMessages = [];
|
|
187
|
+
unconfirmedHandOffs.set(mode, [...(unconfirmedHandOffs.get(mode) ?? []), ...messages]);
|
|
188
|
+
for (const message of messages) {
|
|
189
|
+
handOffOrder.set(message, nextHandOff++);
|
|
190
|
+
let accepted = false;
|
|
191
|
+
void mode.session
|
|
192
|
+
.prompt(message.text, {
|
|
193
|
+
streamingBehavior: message.mode,
|
|
194
|
+
preflightResult: (success) => {
|
|
195
|
+
accepted = success;
|
|
196
|
+
if (success)
|
|
197
|
+
confirmHandOff(mode, message);
|
|
198
|
+
},
|
|
199
|
+
})
|
|
200
|
+
.catch((error) => {
|
|
201
|
+
if (accepted || isRpcRequestAcceptedFailure(error)) {
|
|
202
|
+
confirmHandOff(mode, message);
|
|
203
|
+
showCompactionQueueError(mode, error);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
// Alt+Up may already have returned it to the editor; only an unconfirmed message goes back.
|
|
207
|
+
if (confirmHandOff(mode, message))
|
|
208
|
+
returnHandedOffMessage(mode, message, error);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
mode.updatePendingMessagesDisplay();
|
|
212
|
+
}
|
|
140
213
|
/**
|
|
141
214
|
* Deliver messages one at a time from the front of the compaction queue. Input submitted meanwhile
|
|
142
215
|
* joins the back of that queue, so a failed message returns to the front ahead of everything after it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-queueing.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-queueing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAG1G,mBAAmB,CAAC,SAAS,CAAC,oBAAoB,GAAG;IAIpD,OAAO;QACN,QAAQ,EAAE;YACT,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE;YACrC,GAAG,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;SAC7F;QACD,QAAQ,EAAE;YACT,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE;YACrC,GAAG,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;SAChG;KACD,CAAC;AACH,CAAC,CAAC;AAEF,mBAAmB,CAAC,SAAS,CAAC,cA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AC;AAED,mBAAmB,CAAC,SAAS,CAAC,0BAA0B,GAAG;IAC1D,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACpD,IAAI,CAAC,wBAAwB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;AACjC,CAAC,CAAC","sourcesContent":["import { isRpcRequestAcceptedFailure } from \"../rpc/rpc-transport-error.ts\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { combineQueuedMessagesForEditor, Spacer, TruncatedText, theme } from \"./interactive-mode-deps.ts\";\nimport type { CompactionQueuedMessage } from \"./interactive-mode-types.ts\";\n\nInteractiveModeBase.prototype.getAllQueuedMessages = function (this: InteractiveModeBase): {\n\tsteering: string[];\n\tfollowUp: string[];\n} {\n\treturn {\n\t\tsteering: [\n\t\t\t...this.session.getSteeringMessages(),\n\t\t\t...this.compactionQueuedMessages.filter((msg) => msg.mode === \"steer\").map((msg) => msg.text),\n\t\t],\n\t\tfollowUp: [\n\t\t\t...this.session.getFollowUpMessages(),\n\t\t\t...this.compactionQueuedMessages.filter((msg) => msg.mode === \"followUp\").map((msg) => msg.text),\n\t\t],\n\t};\n};\n\nInteractiveModeBase.prototype.clearAllQueues = function (\n\tthis: InteractiveModeBase,\n\toptions?: { preserveUnprotectedCustomMessages?: boolean },\n): {\n\tsteering: string[];\n\tfollowUp: string[];\n} {\n\tconst { steering, followUp } = this.session.clearQueue(options);\n\tconst compactionSteering = this.compactionQueuedMessages\n\t\t.filter((msg) => msg.mode === \"steer\")\n\t\t.map((msg) => msg.text);\n\tconst compactionFollowUp = this.compactionQueuedMessages\n\t\t.filter((msg) => msg.mode === \"followUp\")\n\t\t.map((msg) => msg.text);\n\tthis.compactionQueuedMessages = [];\n\tthis.compactionSendFailed = false;\n\treturn {\n\t\tsteering: [...steering, ...compactionSteering],\n\t\tfollowUp: [...followUp, ...compactionFollowUp],\n\t};\n};\n\nInteractiveModeBase.prototype.updatePendingMessagesDisplay = function (this: InteractiveModeBase): void {\n\tthis.pendingMessagesContainer.clear();\n\tconst { steering: steeringMessages, followUp: followUpMessages } = this.getAllQueuedMessages();\n\tif (steeringMessages.length > 0 || followUpMessages.length > 0) {\n\t\tthis.pendingMessagesContainer.addChild(new Spacer(1));\n\t\tfor (const message of steeringMessages) {\n\t\t\tconst text = theme.fg(\"dim\", `Steering: ${message}`);\n\t\t\tthis.pendingMessagesContainer.addChild(new TruncatedText(text, 1, 0));\n\t\t}\n\t\tfor (const message of followUpMessages) {\n\t\t\tconst text = theme.fg(\"dim\", `Follow-up: ${message}`);\n\t\t\tthis.pendingMessagesContainer.addChild(new TruncatedText(text, 1, 0));\n\t\t}\n\t\tconst dequeueHint = this.getAppKeyDisplay(\"app.message.dequeue\");\n\t\tconst hintText = theme.fg(\"dim\", `↳ ${dequeueHint} to edit all queued messages`);\n\t\tthis.pendingMessagesContainer.addChild(new TruncatedText(hintText, 1, 0));\n\t}\n};\n\nInteractiveModeBase.prototype.restoreQueuedMessagesToEditor = function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\tabort?: boolean;\n\t\tcurrentText?: string;\n\t\tpreserveUnprotectedCustomMessages?: boolean;\n\t},\n): number {\n\tconst { steering, followUp } = this.clearAllQueues(options);\n\tconst allQueued = [...steering, ...followUp];\n\tif (allQueued.length === 0) {\n\t\tthis.updatePendingMessagesDisplay();\n\t\tif (options?.abort) {\n\t\t\tvoid this.session.abort();\n\t\t}\n\t\treturn 0;\n\t}\n\tconst currentText = options?.currentText ?? this.editor.getText();\n\tconst combinedText = combineQueuedMessagesForEditor(allQueued, currentText);\n\tthis.editor.setText(combinedText);\n\tthis.updatePendingMessagesDisplay();\n\tif (options?.abort) {\n\t\tvoid this.session.abort();\n\t}\n\treturn allQueued.length;\n};\n\nInteractiveModeBase.prototype.queueCompactionMessage = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n\tmode: \"steer\" | \"followUp\",\n): void {\n\tthis.compactionQueuedMessages.push({ text, mode });\n\tthis.editor.addToHistory?.(text);\n\tthis.editor.setText(\"\");\n\tthis.updatePendingMessagesDisplay();\n\tif (this.compactionActive) {\n\t\tthis.showStatus(\"Queued message for after compaction\");\n\t\treturn;\n\t}\n\tif (!this.compactionFlushPending) void this.flushCompactionQueue({ willRetry: false });\n};\n\nInteractiveModeBase.prototype.isExtensionCommand = function (this: InteractiveModeBase, text: string): boolean {\n\tif (!text.startsWith(\"/\")) return false;\n\n\tconst extensionRunner = this.session.extensionRunner;\n\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\treturn !!extensionRunner.getCommand(commandName);\n};\n\nInteractiveModeBase.prototype.flushCompactionQueue = async function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\twillRetry?: boolean;\n\t\tafterPrompt?: boolean;\n\t},\n): Promise<void> {\n\tif (this.compactionFlushPending || this.compactionQueuedMessages.length === 0) return;\n\tif (this.promptTurn?.dispatched === false) return;\n\tthis.compactionFlushPending = true;\n\tthis.compactionSendFailed = false;\n\ttry {\n\t\tif (options?.afterPrompt === true) await sendHeldInput(this);\n\t\telse await sendCompactionQueue(this, options?.willRetry === true);\n\t} finally {\n\t\tthis.compactionFlushPending = false;\n\t\tthis.updatePendingMessagesDisplay();\n\t}\n\tconst arrivedAfterDrain =\n\t\tthis.compactionQueuedMessages.length > 0 && !this.compactionSendFailed && !this.compactionActive;\n\tif (arrivedAfterDrain) await this.flushCompactionQueue(options);\n};\n\nasync function sendCompactionQueue(mode: InteractiveModeBase, willRetry: boolean): Promise<void> {\n\tconst queueOnly = !willRetry && (mode.session.isStreaming || mode.session.queuedMessagesPaused);\n\tif (queueOnly) {\n\t\tawait drainCompactionQueue(mode, (message) =>\n\t\t\tmode.session.prompt(message.text, { streamingBehavior: message.mode }),\n\t\t);\n\t\treturn;\n\t}\n\tif (!willRetry && !(await startCompactionQueuePrompt(mode))) return;\n\tawait drainCompactionQueue(mode, (message) => {\n\t\tif (mode.isExtensionCommand(message.text)) return mode.session.prompt(message.text);\n\t\tif (message.mode === \"followUp\") return mode.session.followUp(message.text);\n\t\treturn mode.session.steer(message.text);\n\t});\n}\n\nfunction showCompactionQueueError(mode: InteractiveModeBase, error: unknown): void {\n\tmode.showError(`Failed to send queued message: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nfunction takeNextCompactionMessage(mode: InteractiveModeBase): CompactionQueuedMessage | undefined {\n\tconst [next, ...rest] = mode.compactionQueuedMessages;\n\tmode.compactionQueuedMessages = rest;\n\tmode.updatePendingMessagesDisplay();\n\treturn next;\n}\n\nfunction returnCompactionMessage(mode: InteractiveModeBase, message: CompactionQueuedMessage, error: unknown): void {\n\tmode.compactionQueuedMessages = [message, ...mode.compactionQueuedMessages];\n\tmode.compactionSendFailed = true;\n\tmode.updatePendingMessagesDisplay();\n\tshowCompactionQueueError(mode, error);\n}\n\n/**\n * Deliver messages one at a time from the front of the compaction queue. Input submitted meanwhile\n * joins the back of that queue, so a failed message returns to the front ahead of everything after it.\n */\nasync function drainCompactionQueue(\n\tmode: InteractiveModeBase,\n\tdeliver: (message: CompactionQueuedMessage) => Promise<unknown>,\n\tlimit = Number.POSITIVE_INFINITY,\n): Promise<boolean> {\n\tfor (let delivered = 0; delivered < limit; delivered++) {\n\t\tconst message = takeNextCompactionMessage(mode);\n\t\tif (!message) break;\n\t\ttry {\n\t\t\tawait deliver(message);\n\t\t} catch (error) {\n\t\t\treturnCompactionMessage(mode, message, error);\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Run leading extension commands, then start the first prompt. The rest of the batch stays in the\n * compaction queue until that prompt is accepted, so a rejected prompt is restored ahead of it.\n */\nasync function startCompactionQueuePrompt(mode: InteractiveModeBase): Promise<boolean> {\n\tconst firstPromptIndex = mode.compactionQueuedMessages.findIndex(\n\t\t(message) => !mode.isExtensionCommand(message.text),\n\t);\n\tconst leadingCommands = firstPromptIndex === -1 ? mode.compactionQueuedMessages.length : firstPromptIndex;\n\tconst ranCommands = await drainCompactionQueue(\n\t\tmode,\n\t\t(message) => mode.session.prompt(message.text),\n\t\tleadingCommands,\n\t);\n\tif (!ranCommands) return false;\n\tconst first = takeNextCompactionMessage(mode);\n\tif (!first) return false;\n\tconst refused = await promptUntilAccepted(mode, first);\n\tif (refused === undefined) return true;\n\treturnCompactionMessage(mode, first, refused.error);\n\treturn false;\n}\n\nasync function promptUntilAccepted(\n\tmode: InteractiveModeBase,\n\tmessage: CompactionQueuedMessage,\n\tonQueued?: () => void,\n): Promise<{ error: unknown } | undefined> {\n\tlet accept!: (accepted: boolean) => void;\n\tconst accepted = new Promise<boolean>((resolve) => {\n\t\taccept = resolve;\n\t});\n\tconst prompt = mode.session.prompt(message.text, {\n\t\tstreamingBehavior: message.mode,\n\t\tpreflightResult: (success, disposition) => {\n\t\t\tif (success && disposition === \"queued\") onQueued?.();\n\t\t\taccept(success);\n\t\t},\n\t});\n\tprompt.then(\n\t\t() => accept(true),\n\t\t(error: unknown) => accept(isRpcRequestAcceptedFailure(error)),\n\t);\n\tif (await accepted) {\n\t\tprompt.catch((error) => showCompactionQueueError(mode, error));\n\t\treturn undefined;\n\t}\n\treturn {\n\t\terror: await prompt.then(\n\t\t\t() => undefined,\n\t\t\t(error: unknown) => error,\n\t\t),\n\t};\n}\n\nasync function sendHeldInput(mode: InteractiveModeBase): Promise<void> {\n\twhile (mode.compactionQueuedMessages.length > 0) {\n\t\tconst message = takeNextCompactionMessage(mode);\n\t\tif (!message) return;\n\t\tconst echoed = !message.text.startsWith(\"/\");\n\t\tif (echoed) mode.renderDeferredUserInput(message.text);\n\t\tconst refused = await promptUntilAccepted(\n\t\t\tmode,\n\t\t\tmessage,\n\t\t\techoed ? () => mode.discardDeferredRenderedUserInput(message.text) : undefined,\n\t\t);\n\t\tif (refused !== undefined) {\n\t\t\tif (echoed) mode.discardDeferredRenderedUserInput(message.text);\n\t\t\treturnCompactionMessage(mode, message, refused.error);\n\t\t\treturn;\n\t\t}\n\t}\n}\n\nInteractiveModeBase.prototype.flushPendingBashComponents = function (this: InteractiveModeBase): void {\n\tfor (const component of this.pendingBashComponents) {\n\t\tthis.pendingMessagesContainer.removeChild(component);\n\t\tthis.chatContainer.addChild(component);\n\t}\n\tthis.pendingBashComponents = [];\n};\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-queueing.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-queueing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAClG,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAG1G,kGAAkG;AAClG,MAAM,YAAY,GAAG,IAAI,OAAO,EAAmC,CAAC;AACpE,IAAI,WAAW,GAAG,CAAC,CAAC;AACpB;;;GAGG;AACH,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAkD,CAAC;AAE1F,SAAS,YAAY,CAAC,IAAyB;IAC9C,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC;AACrF,CAAC;AAED,mBAAmB,CAAC,SAAS,CAAC,oBAAoB,GAAG;IAIpD,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO;QACN,QAAQ,EAAE;YACT,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE;YACrC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAA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IACrD,OAAO,IAAI,CAAC,wBAAwB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjD,MAAM,OAAO,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,MAAM;YAAE,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG,MAAM,mBAAmB,CACxC,IAAI,EACJ,OAAO,EACP,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,gCAAgC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAC9E,CAAC;QACF,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC3B,IAAI,MAAM;gBAAE,IAAI,CAAC,gCAAgC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAChE,uBAAuB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;YACtD,OAAO;QACR,CAAC;IACF,CAAC;AACF,CAAC;AAED,mBAAmB,CAAC,SAAS,CAAC,0BAA0B,GAAG;IAC1D,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACpD,IAAI,CAAC,wBAAwB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;AACjC,CAAC,CAAC","sourcesContent":["import { getInteractiveEngineRemoteCommands } from \"../interactive-engine/extension-ui-bridge.ts\";\nimport { isRpcRequestAcceptedFailure } from \"../rpc/rpc-transport-error.ts\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { combineQueuedMessagesForEditor, Spacer, TruncatedText, theme } from \"./interactive-mode-deps.ts\";\nimport type { CompactionQueuedMessage } from \"./interactive-mode-types.ts\";\n\n/** Typing order of messages handed to the session, so one it refuses returns to its own place. */\nconst handOffOrder = new WeakMap<CompactionQueuedMessage, number>();\nlet nextHandOff = 0;\n/**\n * Messages handed to the session that it has not confirmed yet. The editor keeps showing and restoring them\n * until the session reports it took them; from then on the session lists them itself.\n */\nconst unconfirmedHandOffs = new WeakMap<InteractiveModeBase, CompactionQueuedMessage[]>();\n\nfunction heldByEditor(mode: InteractiveModeBase): CompactionQueuedMessage[] {\n\treturn [...(unconfirmedHandOffs.get(mode) ?? []), ...mode.compactionQueuedMessages];\n}\n\nInteractiveModeBase.prototype.getAllQueuedMessages = function (this: InteractiveModeBase): {\n\tsteering: string[];\n\tfollowUp: string[];\n} {\n\tconst held = heldByEditor(this);\n\treturn {\n\t\tsteering: [\n\t\t\t...this.session.getSteeringMessages(),\n\t\t\t...held.filter((msg) => msg.mode === \"steer\").map((msg) => msg.text),\n\t\t],\n\t\tfollowUp: [\n\t\t\t...this.session.getFollowUpMessages(),\n\t\t\t...held.filter((msg) => msg.mode === \"followUp\").map((msg) => msg.text),\n\t\t],\n\t};\n};\n\nInteractiveModeBase.prototype.clearAllQueues = function (\n\tthis: InteractiveModeBase,\n\toptions?: { preserveUnprotectedCustomMessages?: boolean },\n): {\n\tsteering: string[];\n\tfollowUp: string[];\n} {\n\tconst { steering, followUp } = this.session.clearQueue(options);\n\tconst held = heldByEditor(this);\n\tconst compactionSteering = held.filter((msg) => msg.mode === \"steer\").map((msg) => msg.text);\n\tconst compactionFollowUp = held.filter((msg) => msg.mode === \"followUp\").map((msg) => msg.text);\n\t// clearQueue() also cancels unconfirmed hand-offs once they reach the session, so none is sent.\n\tunconfirmedHandOffs.delete(this);\n\tthis.compactionQueuedMessages = [];\n\tthis.compactionSendFailed = false;\n\treturn {\n\t\tsteering: [...steering, ...compactionSteering],\n\t\tfollowUp: [...followUp, ...compactionFollowUp],\n\t};\n};\n\nInteractiveModeBase.prototype.updatePendingMessagesDisplay = function (this: InteractiveModeBase): void {\n\tthis.pendingMessagesContainer.clear();\n\tconst { steering: steeringMessages, followUp: followUpMessages } = this.getAllQueuedMessages();\n\tif (steeringMessages.length > 0 || followUpMessages.length > 0) {\n\t\tthis.pendingMessagesContainer.addChild(new Spacer(1));\n\t\tfor (const message of steeringMessages) {\n\t\t\tconst text = theme.fg(\"dim\", `Steering: ${message}`);\n\t\t\tthis.pendingMessagesContainer.addChild(new TruncatedText(text, 1, 0));\n\t\t}\n\t\tfor (const message of followUpMessages) {\n\t\t\tconst text = theme.fg(\"dim\", `Follow-up: ${message}`);\n\t\t\tthis.pendingMessagesContainer.addChild(new TruncatedText(text, 1, 0));\n\t\t}\n\t\tconst dequeueHint = this.getAppKeyDisplay(\"app.message.dequeue\");\n\t\tconst hintText = theme.fg(\"dim\", `↳ ${dequeueHint} to edit all queued messages`);\n\t\tthis.pendingMessagesContainer.addChild(new TruncatedText(hintText, 1, 0));\n\t}\n};\n\nInteractiveModeBase.prototype.restoreQueuedMessagesToEditor = function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\tabort?: boolean;\n\t\tcurrentText?: string;\n\t\tpreserveUnprotectedCustomMessages?: boolean;\n\t},\n): number {\n\tconst { steering, followUp } = this.clearAllQueues(options);\n\tconst allQueued = [...steering, ...followUp];\n\tif (allQueued.length === 0) {\n\t\tthis.updatePendingMessagesDisplay();\n\t\tif (options?.abort) {\n\t\t\tvoid this.session.abort();\n\t\t}\n\t\treturn 0;\n\t}\n\tconst currentText = options?.currentText ?? this.editor.getText();\n\tconst combinedText = combineQueuedMessagesForEditor(allQueued, currentText);\n\tthis.editor.setText(combinedText);\n\tthis.updatePendingMessagesDisplay();\n\tif (options?.abort) {\n\t\tvoid this.session.abort();\n\t}\n\treturn allQueued.length;\n};\n\nInteractiveModeBase.prototype.queueCompactionMessage = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n\tmode: \"steer\" | \"followUp\",\n): void {\n\tthis.compactionQueuedMessages.push({ text, mode });\n\tthis.editor.addToHistory?.(text);\n\tthis.editor.setText(\"\");\n\tthis.updatePendingMessagesDisplay();\n\tif (this.compactionActive) {\n\t\tthis.showStatus(\"Queued message for after compaction\");\n\t\treturn;\n\t}\n\tif (!this.compactionFlushPending) void this.flushCompactionQueue({ willRetry: false });\n};\n\nInteractiveModeBase.prototype.isExtensionCommand = function (this: InteractiveModeBase, text: string): boolean {\n\tif (!text.startsWith(\"/\")) return false;\n\n\tconst extensionRunner = this.session.extensionRunner;\n\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tif (extensionRunner.getCommand(commandName)) return true;\n\treturn getInteractiveEngineRemoteCommands(this.runtimeHost).some(\n\t\t(command) => command.source === \"extension\" && command.name === commandName,\n\t);\n};\n\nInteractiveModeBase.prototype.flushCompactionQueue = async function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\twillRetry?: boolean;\n\t\tafterPrompt?: boolean;\n\t},\n): Promise<void> {\n\tif (this.compactionFlushPending || this.compactionQueuedMessages.length === 0) return;\n\tif (this.promptTurn?.dispatched === false) return;\n\tthis.compactionFlushPending = true;\n\tthis.compactionSendFailed = false;\n\ttry {\n\t\tif (options?.afterPrompt === true) await sendHeldInput(this);\n\t\telse await sendCompactionQueue(this, options?.willRetry === true);\n\t} finally {\n\t\tthis.compactionFlushPending = false;\n\t\tthis.updatePendingMessagesDisplay();\n\t}\n\tconst arrivedAfterDrain =\n\t\tthis.compactionQueuedMessages.length > 0 && !this.compactionSendFailed && !this.compactionActive;\n\tif (arrivedAfterDrain) await this.flushCompactionQueue(options);\n};\n\nasync function sendCompactionQueue(mode: InteractiveModeBase, willRetry: boolean): Promise<void> {\n\tconst queueOnly = !willRetry && (mode.session.isStreaming || mode.session.queuedMessagesPaused);\n\tif (queueOnly) {\n\t\tawait drainCompactionQueue(mode, (message) =>\n\t\t\tmode.session.prompt(message.text, { streamingBehavior: message.mode }),\n\t\t);\n\t\treturn;\n\t}\n\tif (!willRetry && !(await startCompactionQueuePrompt(mode))) return;\n\tawait drainCompactionQueue(mode, (message) => {\n\t\tif (mode.isExtensionCommand(message.text)) return mode.session.prompt(message.text);\n\t\tif (message.mode === \"followUp\") return mode.session.followUp(message.text);\n\t\treturn mode.session.steer(message.text);\n\t});\n}\n\nfunction showCompactionQueueError(mode: InteractiveModeBase, error: unknown): void {\n\tmode.showError(`Failed to send queued message: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nfunction takeNextCompactionMessage(mode: InteractiveModeBase): CompactionQueuedMessage | undefined {\n\tconst [next, ...rest] = mode.compactionQueuedMessages;\n\tmode.compactionQueuedMessages = rest;\n\tmode.updatePendingMessagesDisplay();\n\treturn next;\n}\n\nfunction returnCompactionMessage(mode: InteractiveModeBase, message: CompactionQueuedMessage, error: unknown): void {\n\tmode.compactionQueuedMessages = [message, ...mode.compactionQueuedMessages];\n\tmode.compactionSendFailed = true;\n\tmode.updatePendingMessagesDisplay();\n\tshowCompactionQueueError(mode, error);\n}\n\nfunction returnHandedOffMessage(mode: InteractiveModeBase, message: CompactionQueuedMessage, error: unknown): void {\n\tconst rank = handOffOrder.get(message) ?? -1;\n\tconst queue = mode.compactionQueuedMessages;\n\tconst index = queue.findIndex((queued) => (handOffOrder.get(queued) ?? Number.POSITIVE_INFINITY) > rank);\n\tmode.compactionQueuedMessages =\n\t\tindex === -1 ? [...queue, message] : [...queue.slice(0, index), message, ...queue.slice(index)];\n\tmode.compactionSendFailed = true;\n\tmode.updatePendingMessagesDisplay();\n\tshowCompactionQueueError(mode, error);\n}\n\nfunction confirmHandOff(mode: InteractiveModeBase, message: CompactionQueuedMessage): boolean {\n\tconst pending = unconfirmedHandOffs.get(mode);\n\tconst index = pending?.indexOf(message) ?? -1;\n\tif (!pending || index === -1) return false;\n\tpending.splice(index, 1);\n\tif (pending.length === 0) unconfirmedHandOffs.delete(mode);\n\tmode.updatePendingMessagesDisplay();\n\treturn true;\n}\n\n/**\n * Hand the editor's held messages to the session before an extension command runs during compaction (#4251).\n * The session registers input as it arrives and holds it until compaction ends, so a message the command sends\n * goes out after them, in typing order. Each message stays shown and restorable here until the session confirms\n * it took it, and from then on the session lists it as queued and its clearQueue() returns it for Alt+Up and\n * Ctrl+C. A message the session refuses returns to the editor queue.\n */\nexport function handOffCompactionQueue(mode: InteractiveModeBase): void {\n\tconst messages = mode.compactionQueuedMessages;\n\tif (messages.length === 0) return;\n\tmode.compactionQueuedMessages = [];\n\tunconfirmedHandOffs.set(mode, [...(unconfirmedHandOffs.get(mode) ?? []), ...messages]);\n\tfor (const message of messages) {\n\t\thandOffOrder.set(message, nextHandOff++);\n\t\tlet accepted = false;\n\t\tvoid mode.session\n\t\t\t.prompt(message.text, {\n\t\t\t\tstreamingBehavior: message.mode,\n\t\t\t\tpreflightResult: (success) => {\n\t\t\t\t\taccepted = success;\n\t\t\t\t\tif (success) confirmHandOff(mode, message);\n\t\t\t\t},\n\t\t\t})\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tif (accepted || isRpcRequestAcceptedFailure(error)) {\n\t\t\t\t\tconfirmHandOff(mode, message);\n\t\t\t\t\tshowCompactionQueueError(mode, error);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Alt+Up may already have returned it to the editor; only an unconfirmed message goes back.\n\t\t\t\tif (confirmHandOff(mode, message)) returnHandedOffMessage(mode, message, error);\n\t\t\t});\n\t}\n\tmode.updatePendingMessagesDisplay();\n}\n\n/**\n * Deliver messages one at a time from the front of the compaction queue. Input submitted meanwhile\n * joins the back of that queue, so a failed message returns to the front ahead of everything after it.\n */\nasync function drainCompactionQueue(\n\tmode: InteractiveModeBase,\n\tdeliver: (message: CompactionQueuedMessage) => Promise<unknown>,\n\tlimit = Number.POSITIVE_INFINITY,\n): Promise<boolean> {\n\tfor (let delivered = 0; delivered < limit; delivered++) {\n\t\tconst message = takeNextCompactionMessage(mode);\n\t\tif (!message) break;\n\t\ttry {\n\t\t\tawait deliver(message);\n\t\t} catch (error) {\n\t\t\treturnCompactionMessage(mode, message, error);\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Run leading extension commands, then start the first prompt. The rest of the batch stays in the\n * compaction queue until that prompt is accepted, so a rejected prompt is restored ahead of it.\n */\nasync function startCompactionQueuePrompt(mode: InteractiveModeBase): Promise<boolean> {\n\tconst firstPromptIndex = mode.compactionQueuedMessages.findIndex(\n\t\t(message) => !mode.isExtensionCommand(message.text),\n\t);\n\tconst leadingCommands = firstPromptIndex === -1 ? mode.compactionQueuedMessages.length : firstPromptIndex;\n\tconst ranCommands = await drainCompactionQueue(\n\t\tmode,\n\t\t(message) => mode.session.prompt(message.text),\n\t\tleadingCommands,\n\t);\n\tif (!ranCommands) return false;\n\tconst first = takeNextCompactionMessage(mode);\n\tif (!first) return false;\n\tconst refused = await promptUntilAccepted(mode, first);\n\tif (refused === undefined) return true;\n\treturnCompactionMessage(mode, first, refused.error);\n\treturn false;\n}\n\nasync function promptUntilAccepted(\n\tmode: InteractiveModeBase,\n\tmessage: CompactionQueuedMessage,\n\tonQueued?: () => void,\n): Promise<{ error: unknown } | undefined> {\n\tlet accept!: (accepted: boolean) => void;\n\tconst accepted = new Promise<boolean>((resolve) => {\n\t\taccept = resolve;\n\t});\n\tconst prompt = mode.session.prompt(message.text, {\n\t\tstreamingBehavior: message.mode,\n\t\tpreflightResult: (success, disposition) => {\n\t\t\tif (success && disposition === \"queued\") onQueued?.();\n\t\t\taccept(success);\n\t\t},\n\t});\n\tprompt.then(\n\t\t() => accept(true),\n\t\t(error: unknown) => accept(isRpcRequestAcceptedFailure(error)),\n\t);\n\tif (await accepted) {\n\t\tprompt.catch((error) => showCompactionQueueError(mode, error));\n\t\treturn undefined;\n\t}\n\treturn {\n\t\terror: await prompt.then(\n\t\t\t() => undefined,\n\t\t\t(error: unknown) => error,\n\t\t),\n\t};\n}\n\nasync function sendHeldInput(mode: InteractiveModeBase): Promise<void> {\n\twhile (mode.compactionQueuedMessages.length > 0) {\n\t\tconst message = takeNextCompactionMessage(mode);\n\t\tif (!message) return;\n\t\tconst echoed = !message.text.startsWith(\"/\");\n\t\tif (echoed) mode.renderDeferredUserInput(message.text);\n\t\tconst refused = await promptUntilAccepted(\n\t\t\tmode,\n\t\t\tmessage,\n\t\t\techoed ? () => mode.discardDeferredRenderedUserInput(message.text) : undefined,\n\t\t);\n\t\tif (refused !== undefined) {\n\t\t\tif (echoed) mode.discardDeferredRenderedUserInput(message.text);\n\t\t\treturnCompactionMessage(mode, message, refused.error);\n\t\t\treturn;\n\t\t}\n\t}\n}\n\nInteractiveModeBase.prototype.flushPendingBashComponents = function (this: InteractiveModeBase): void {\n\tfor (const component of this.pendingBashComponents) {\n\t\tthis.pendingMessagesContainer.removeChild(component);\n\t\tthis.chatContainer.addChild(component);\n\t}\n\tthis.pendingBashComponents = [];\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isolated-runtime.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/isolated-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,KAAK,gCAAgC,EAAE,MAAM,qCAAqC,CAAC;AAOjH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"isolated-runtime.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/isolated-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,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
|
|
|
15
15
|
import { RemoteModelCatalog } from "./remote-model-catalog.js";
|
|
16
16
|
import { RemoteQueuePause } from "./remote-queue-pause.js";
|
|
17
17
|
import { InteractiveEngineResourceReadinessError } from "./resource-readiness-error.js";
|
|
18
|
+
/** An extension error of the engine's session, as its RPC binding reports it on the event stream. */
|
|
19
|
+
function isEngineExtensionError(record) {
|
|
20
|
+
return typeof record === "object" && record !== null && record.type === "extension_error";
|
|
21
|
+
}
|
|
18
22
|
function applyPersistedModelDefault(session, model, alreadyInScope) {
|
|
19
23
|
session.settingsManager.setDefaultModelAndProvider(model.provider, model.id);
|
|
20
24
|
if (alreadyInScope || session.scopedModels.length === 0)
|
|
@@ -931,6 +935,17 @@ export class IsolatedInteractiveRuntime extends AgentSessionRuntime {
|
|
|
931
935
|
}
|
|
932
936
|
observeEvent(event) {
|
|
933
937
|
const session = super.session;
|
|
938
|
+
// The engine reports its session's extension errors on this stream. They are this host session's errors, and
|
|
939
|
+
// its error listeners show them; a message the engine could not save is reported only this way (#4226).
|
|
940
|
+
const record = event;
|
|
941
|
+
if (isEngineExtensionError(record)) {
|
|
942
|
+
session.extensionRunner.emitError({
|
|
943
|
+
extensionPath: record.extensionPath,
|
|
944
|
+
event: record.event,
|
|
945
|
+
error: record.error,
|
|
946
|
+
});
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
934
949
|
switch (event.type) {
|
|
935
950
|
case "agent_start":
|
|
936
951
|
this.streaming = true;
|