@bastani/atomic 0.9.19-alpha.9 → 0.9.19
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 +91 -0
- package/dist/builtin/intercom/CHANGELOG.md +24 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/CHANGELOG.md +8 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +30 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/CHANGELOG.md +14 -0
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +59 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +236 -68
- package/dist/builtin/workflows/src/index.js +97 -18
- package/dist/core/extensions/api-types.d.ts +2 -0
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-host-modules.js +3 -1
- package/dist/core/extensions/loader-host-modules.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +2 -0
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/reactive-widget.d.ts +6 -0
- package/dist/core/extensions/reactive-widget.d.ts.map +1 -1
- package/dist/core/extensions/reactive-widget.js +7 -1
- package/dist/core/extensions/reactive-widget.js.map +1 -1
- package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -1
- package/dist/core/extensions/runner-shortcuts.js +32 -3
- package/dist/core/extensions/runner-shortcuts.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +4 -0
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +20 -0
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/keybinding-identity.d.ts +4 -0
- package/dist/core/keybinding-identity.d.ts.map +1 -0
- package/dist/core/keybinding-identity.js +10 -0
- package/dist/core/keybinding-identity.js.map +1 -0
- package/dist/core/keybindings.d.ts +10 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +2 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +7 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/scroll-widget.d.ts +23 -0
- package/dist/modes/interactive/components/scroll-widget.d.ts.map +1 -0
- package/dist/modes/interactive/components/scroll-widget.js +61 -0
- package/dist/modes/interactive/components/scroll-widget.js.map +1 -0
- package/dist/modes/interactive/interactive-extension-runtime.js +10 -3
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +3 -2
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts +4 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +15 -7
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-dialog-host.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-dialog-host.js +4 -1
- package/dist/modes/interactive-engine/engine-dialog-host.js.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +12 -1
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +45 -2
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +18 -8
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.js +2 -1
- package/dist/modes/rpc/rpc-extension-ui.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/dist/modes/rpc/rpc-types.d.ts +4 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/extensions/api-reference.md +2 -0
- package/docs/extensions/authoring.md +2 -0
- package/docs/keybindings.md +17 -0
- package/docs/tui.md +34 -0
- package/docs/workflows/api-reference.md +2 -0
- package/docs/workflows/operations.md +5 -1
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-custom-ui.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/engine-custom-ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,YAAY,EAKZ,aAAa,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,WAA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AAmB,EAAE,MAAS;QACjD,IAAI,CAAC,IAAI,CAAC;YACT,IAAI,EAAE,oBAAoB;YAC1B,WAAW;YACX,MAAM,EAAE,UAAU,CAAC,MAA+D,CAAC;SACnF,CAAC,CAAC;IACJ,CAAC;IAEO,IAAI,CAAC,OAAiC;QAC7C,IAAI,CAAC,KAAK,CAAC,iCAAiC,CAAC,OAAO,CAAC,CAAC,CAAC;IACxD,CAAC;CACD","sourcesContent":["import {\n\ttype Component,\n\tisKeyRelease,\n\ttype OverlayHandle,\n\ttype OverlayOptions,\n\ttype Terminal,\n\ttype TUI,\n\tTuiMainScreen,\n} from \"@earendil-works/pi-tui\";\nimport { getAgentDir } from \"../../config.js\";\nimport { runCallback } from \"../../core/callback-activity.ts\";\nimport type { HostCustomUiState, HostCustomUiStateListener } from \"../../core/extensions/index.js\";\nimport type { KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { Theme } from \"../interactive/theme/theme.js\";\nimport { theme } from \"../interactive/theme/theme.js\";\nimport {\n\ttype EngineTerminalControl,\n\ttype InteractiveEngineMessage,\n\tisJsonValue,\n\ttype JsonValue,\n\tparseInteractiveEngineCommand,\n\ttype SerializableOverlayOptions,\n\tserializeInteractiveEngineMessage,\n} from \"./protocol.ts\";\n\ninterface CustomUiOptions {\n\tpurpose?: \"prompt\" | \"navigation\";\n\toverlay?: boolean;\n\tdeferInlineCustomUiFocus?: boolean;\n\t/** The component binds Ctrl+C itself; see ExtensionUIContext.custom options. */\n\thandlesCtrlC?: boolean;\n\t/** The component claims internal UI actions such as the jump-to-bottom URL. */\n\thandlesInternalUiAction?: boolean;\n\t/** Bound this overlay and reserve transcript scroll extent on the host. */\n\treserveTranscriptRows?: boolean;\n\toverlayOptions?: OverlayOptions | (() => OverlayOptions);\n\tonHandle?: (handle: OverlayHandle) => void;\n\tsignal?: AbortSignal;\n}\n\ninterface ActiveComponent {\n\tcomponent: Component & { dispose?(): void };\n\tresolve: (value: JsonValue | undefined) => void;\n\toverlay: boolean;\n\tpurpose?: \"prompt\" | \"navigation\";\n\tterminal: RemoteTerminal;\n\ttui: TUI;\n\twidgetKey?: string;\n\t/**\n\t * Overlay visibility as last driven through the remote OverlayHandle.\n\t * Hidden components are skipped by the extension-level `requestRender()`\n\t * broadcast (#1856) — invalidating a hidden overlay only produced host\n\t * render work and terminal writes for frames the user cannot see.\n\t */\n\thidden?: boolean;\n}\n\nclass RemoteTerminal implements Terminal {\n\tcolumns = 80;\n\trows = 24;\n\tkittyProtocolActive = false;\n\tprivate readonly invalidate: () => void;\n\tprivate readonly control: ((control: EngineTerminalControl) => void) | undefined;\n\tconstructor(invalidate: () => void, control?: (control: EngineTerminalControl) => void) {\n\t\tthis.invalidate = invalidate;\n\t\tthis.control = control;\n\t}\n\tstart(): void {}\n\tstop(): void {}\n\tasync drainInput(): Promise<void> {}\n\twrite(): void {\n\t\tthis.invalidate();\n\t}\n\tmoveBy(): void {}\n\thideCursor(): void {}\n\tshowCursor(): void {}\n\tclearLine(): void {}\n\tclearFromCursor(): void {}\n\tclearScreen(): void {}\n\tsetTitle(): void {}\n\tsetProgress(): void {}\n\t/** Ask the host to toggle host-TTY autowrap (DECAWM) for this component. */\n\tsetAutowrap(enabled: boolean): void {\n\t\tthis.control?.({ kind: \"autowrap\", enabled });\n\t}\n}\n\nfunction serializableOverlayOptions(\n\toptions: CustomUiOptions[\"overlayOptions\"],\n): SerializableOverlayOptions | undefined {\n\tconst value = typeof options === \"function\" ? options() : options;\n\tif (!value) return undefined;\n\tconst { anchor, col, margin, maxHeight, minWidth, offsetX, offsetY, row, width } = value;\n\treturn { anchor, col, margin, maxHeight, minWidth, offsetX, offsetY, row, width };\n}\n\nfunction jsonResult(value: object | boolean | null | number | string | undefined): JsonValue | undefined {\n\tif (value === undefined) return undefined;\n\tconst encoded = JSON.stringify(value);\n\tif (encoded === undefined) return undefined;\n\tconst decoded = JSON.parse(encoded) as JsonValue;\n\tif (!isJsonValue(decoded)) throw new Error(\"Custom UI result is not JSON-safe\");\n\treturn decoded;\n}\n\nexport class EngineCustomUiService {\n\tprivate readonly widgetIds = new Map<string, string>();\n\tprivate readonly active = new Map<string, ActiveComponent>();\n\tprivate nextId = 0;\n\tprivate readonly write: (line: string) => void;\n\tprivate readonly keybindings: KeybindingsManager;\n\tprivate readonly stateListeners = new Set<HostCustomUiStateListener>();\n\tprivate readonly widgetReleaseListeners = new Map<string, Set<() => void>>();\n\n\tsetWidget(\n\t\tkey: string,\n\t\tfactory: ((tui: TUI, theme: Theme) => Component & { dispose?(): void }) | undefined,\n\t\tplacement?: \"aboveEditor\" | \"belowEditor\",\n\t): void {\n\t\tconst previous = this.widgetIds.get(key);\n\t\tif (previous) this.disposeComponent(previous, false, false);\n\t\tif (!factory) return;\n\t\tconst componentId = `remote_widget_${++this.nextId}`;\n\t\tthis.widgetIds.set(key, componentId);\n\t\tconst terminal = new RemoteTerminal(() => this.send({ type: \"engine_custom_invalidate\", componentId }));\n\t\tconst tui = new TuiMainScreen(terminal, undefined, getAgentDir());\n\t\tvoid runCallback({ kind: \"renderer\", name: `widget:${key}` }, () => factory(tui, theme))\n\t\t\t.then((component) => {\n\t\t\t\tif (this.widgetIds.get(key) !== componentId) {\n\t\t\t\t\tcomponent.dispose?.();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttui.addChild(component);\n\t\t\t\tthis.active.set(componentId, {\n\t\t\t\t\tcomponent,\n\t\t\t\t\tresolve: () => {},\n\t\t\t\t\toverlay: false,\n\t\t\t\t\tterminal,\n\t\t\t\t\ttui,\n\t\t\t\t\twidgetKey: key,\n\t\t\t\t});\n\t\t\t\tthis.send({\n\t\t\t\t\ttype: \"engine_custom_open\",\n\t\t\t\t\tcomponentId,\n\t\t\t\t\toverlay: false,\n\t\t\t\t\twidgetKey: key,\n\t\t\t\t\twidgetPlacement: placement,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.catch((error: Error) => {\n\t\t\t\tif (this.widgetIds.get(key) === componentId) this.widgetIds.delete(key);\n\t\t\t\tthis.send({\n\t\t\t\t\ttype: \"engine_custom_frame\",\n\t\t\t\t\tcomponentId,\n\t\t\t\t\trequestId: 0,\n\t\t\t\t\tlines: [`Widget ${key} failed: ${error.message}`],\n\t\t\t\t});\n\t\t\t});\n\t}\n\tconstructor(write: (line: string) => void, keybindings: KeybindingsManager) {\n\t\tthis.write = write;\n\t\tthis.keybindings = keybindings;\n\t}\n\n\tasync custom<T>(\n\t\tfactory: (\n\t\t\ttui: TUI,\n\t\t\ttheme: Theme,\n\t\t\tkeybindings: KeybindingsManager,\n\t\t\tdone: (result: T) => void,\n\t\t) => (Component & { dispose?(): void }) | Promise<Component & { dispose?(): void }>,\n\t\toptions?: CustomUiOptions,\n\t): Promise<T> {\n\t\tconst componentId = `remote_component_${++this.nextId}`;\n\t\tlet resolveCompletion!: (value: T) => void;\n\t\tconst completion = new Promise<T>((resolve) => {\n\t\t\tresolveCompletion = resolve;\n\t\t});\n\t\tlet opened = false;\n\t\tlet pendingDone: T | undefined;\n\t\tlet doneCalled = false;\n\t\tconst done = (result: T): void => {\n\t\t\tif (doneCalled) return;\n\t\t\tdoneCalled = true;\n\t\t\tpendingDone = result;\n\t\t\tresolveCompletion(result);\n\t\t\tif (opened) this.sendDone(componentId, result);\n\t\t};\n\t\tconst terminal = new RemoteTerminal(\n\t\t\t() => this.send({ type: \"engine_custom_invalidate\", componentId }),\n\t\t\t(control) => this.send({ type: \"engine_custom_terminal\", componentId, control }),\n\t\t);\n\t\tconst tui = new TuiMainScreen(terminal, undefined, getAgentDir());\n\t\tconst component = await factory(tui, theme, this.keybindings, done);\n\t\ttui.addChild(component);\n\t\ttui.setFocus(component);\n\t\tconst record: ActiveComponent = {\n\t\t\tcomponent,\n\t\t\t// Cancellation must settle through the same guarded host completion as done().\n\t\t\tresolve: (value) => done(value as T),\n\t\t\tterminal,\n\t\t\ttui,\n\t\t\toverlay: options?.overlay === true,\n\t\t\tpurpose: options?.purpose,\n\t\t};\n\t\tthis.active.set(componentId, record);\n\t\tthis.notifyState();\n\t\topened = true;\n\t\tthis.send({\n\t\t\ttype: \"engine_custom_open\",\n\t\t\tcomponentId,\n\t\t\toverlay: options?.overlay === true,\n\t\t\tpurpose: options?.purpose,\n\t\t\tdeferInlineCustomUiFocus: options?.deferInlineCustomUiFocus,\n\t\t\thandlesCtrlC: options?.handlesCtrlC,\n\t\t\thandlesInternalUiAction: options?.handlesInternalUiAction,\n\t\t\treserveTranscriptRows: options?.reserveTranscriptRows,\n\t\t\toverlayOptions: serializableOverlayOptions(options?.overlayOptions),\n\t\t});\n\t\tif (options?.onHandle) options.onHandle(this.remoteHandle(componentId));\n\t\tif (doneCalled) this.sendDone(componentId, pendingDone as T);\n\t\tconst onAbort = () => this.disposeComponent(componentId, true);\n\t\toptions?.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\ttry {\n\t\t\treturn await completion;\n\t\t} finally {\n\t\t\toptions?.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\tthis.disposeComponent(componentId, false);\n\t\t}\n\t}\n\tgetHostCustomUiState(): HostCustomUiState {\n\t\tconst inline = [...this.active.values()].filter((record) => !record.overlay && !record.widgetKey);\n\t\tconst navigation = inline.filter((record) => record.purpose === \"navigation\").length;\n\t\treturn {\n\t\t\tblockingInlineCustomUiDepth: inline.length,\n\t\t\tblockingInlineCustomUiActive: inline.length > 0,\n\t\t\t...(navigation > 0 ? { blockingInlineCustomUiNeedsInput: inline.length > navigation } : {}),\n\t\t};\n\t}\n\n\tonHostCustomUiStateChange(listener: HostCustomUiStateListener): () => void {\n\t\tthis.stateListeners.add(listener);\n\t\treturn () => this.stateListeners.delete(listener);\n\t}\n\tonWidgetRelease(key: string, listener: () => void): () => void {\n\t\tconst listeners = this.widgetReleaseListeners.get(key) ?? new Set<() => void>();\n\t\tlisteners.add(listener);\n\t\tthis.widgetReleaseListeners.set(key, listeners);\n\t\treturn () => {\n\t\t\tlisteners.delete(listener);\n\t\t\tif (listeners.size === 0) this.widgetReleaseListeners.delete(key);\n\t\t};\n\t}\n\n\tfocusHostInlineCustomUi(): boolean {\n\t\treturn this.getHostCustomUiState().blockingInlineCustomUiActive;\n\t}\n\n\trequestRender(): void {\n\t\tfor (const [componentId, record] of this.active) {\n\t\t\tif (record.hidden === true) continue;\n\t\t\tthis.send({ type: \"engine_custom_invalidate\", componentId });\n\t\t}\n\t}\n\n\thandleLine(line: string): boolean {\n\t\tconst command = parseInteractiveEngineCommand(line);\n\t\tif (!command) return false;\n\t\tif (!command.type.startsWith(\"engine_custom_\")) return false;\n\t\tconst record = this.active.get(command.componentId);\n\t\tif (!record) {\n\t\t\tif (command.type === \"engine_custom_input\")\n\t\t\t\tthis.send({\n\t\t\t\t\ttype: \"engine_custom_input_result\",\n\t\t\t\t\tcomponentId: command.componentId,\n\t\t\t\t\trequestId: command.requestId,\n\t\t\t\t\thandled: false,\n\t\t\t\t});\n\t\t\treturn true;\n\t\t}\n\t\tswitch (command.type) {\n\t\t\tcase \"engine_custom_render\":\n\t\t\t\trecord.terminal.columns = Math.max(1, command.width);\n\t\t\t\trecord.terminal.rows = Math.max(1, command.rows);\n\t\t\t\tvoid runCallback({ kind: \"renderer\", name: command.componentId }, () =>\n\t\t\t\t\trecord.component.render(record.terminal.columns),\n\t\t\t\t)\n\t\t\t\t\t.then((lines) =>\n\t\t\t\t\t\tthis.send({\n\t\t\t\t\t\t\ttype: \"engine_custom_frame\",\n\t\t\t\t\t\t\tcomponentId: command.componentId,\n\t\t\t\t\t\t\trequestId: command.requestId,\n\t\t\t\t\t\t\tlines,\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t\t.catch((error: Error) =>\n\t\t\t\t\t\tthis.send({\n\t\t\t\t\t\t\ttype: \"engine_custom_frame\",\n\t\t\t\t\t\t\tcomponentId: command.componentId,\n\t\t\t\t\t\t\trequestId: command.requestId,\n\t\t\t\t\t\t\tlines: [`Remote component render failed: ${error.message}`],\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_input\":\n\t\t\t\tvoid runCallback({ kind: \"renderer\", name: command.componentId }, () => {\n\t\t\t\t\tif (isKeyRelease(command.data) && record.component.wantsKeyRelease !== true) return false;\n\t\t\t\t\tconst handleInput = record.component.handleInput as ((data: string) => boolean | undefined) | undefined;\n\t\t\t\t\treturn handleInput?.call(record.component, command.data) === true;\n\t\t\t\t})\n\t\t\t\t\t.then((handled) =>\n\t\t\t\t\t\tthis.send({\n\t\t\t\t\t\t\ttype: \"engine_custom_input_result\",\n\t\t\t\t\t\t\tcomponentId: command.componentId,\n\t\t\t\t\t\t\trequestId: command.requestId,\n\t\t\t\t\t\t\thandled,\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t\t.catch(() =>\n\t\t\t\t\t\tthis.send({\n\t\t\t\t\t\t\ttype: \"engine_custom_input_result\",\n\t\t\t\t\t\t\tcomponentId: command.componentId,\n\t\t\t\t\t\t\trequestId: command.requestId,\n\t\t\t\t\t\t\thandled: false,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_dispose\":\n\t\t\t\tthis.disposeComponent(command.componentId, true);\n\t\t\t\tbreak;\n\t\t}\n\t\treturn true;\n\t}\n\n\tdispose(): void {\n\t\tfor (const componentId of [...this.active.keys()]) this.disposeComponent(componentId, true, false);\n\t}\n\tprivate disposeComponent(componentId: string, resolve: boolean, notifyWidgetRelease = true): void {\n\t\tconst record = this.active.get(componentId);\n\t\tif (!record) return;\n\t\tthis.active.delete(componentId);\n\t\t// Claim cancellation before user disposal code can call done() reentrantly.\n\t\tif (resolve) record.resolve(undefined);\n\t\trecord.component.dispose?.();\n\t\trecord.tui.stop();\n\t\tif (record.widgetKey) {\n\t\t\tif (this.widgetIds.get(record.widgetKey) === componentId) this.widgetIds.delete(record.widgetKey);\n\t\t\tthis.send({ type: \"engine_custom_close\", componentId });\n\t\t\tif (notifyWidgetRelease) this.notifyWidgetRelease(record.widgetKey);\n\t\t}\n\t\tthis.notifyState();\n\t}\n\tprivate notifyWidgetRelease(key: string): void {\n\t\tfor (const listener of this.widgetReleaseListeners.get(key) ?? []) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t// A release observer must not break engine UI teardown.\n\t\t\t}\n\t\t}\n\t}\n\tprivate notifyState(): void {\n\t\tconst state = this.getHostCustomUiState();\n\t\tfor (const listener of this.stateListeners) listener(state);\n\t}\n\n\tprivate remoteHandle(componentId: string): OverlayHandle {\n\t\tlet focused = true;\n\t\tconst setHiddenFlag = (value: boolean): void => {\n\t\t\tconst record = this.active.get(componentId);\n\t\t\tif (record) record.hidden = value;\n\t\t};\n\t\treturn {\n\t\t\thide: () => {\n\t\t\t\tsetHiddenFlag(true);\n\t\t\t\tthis.send({ type: \"engine_custom_control\", componentId, action: \"hide\" });\n\t\t\t},\n\t\t\tsetHidden: (value) => {\n\t\t\t\tsetHiddenFlag(value);\n\t\t\t\tthis.send({ type: \"engine_custom_control\", componentId, action: value ? \"hide\" : \"show\" });\n\t\t\t},\n\t\t\tisHidden: () => this.active.get(componentId)?.hidden === true,\n\t\t\tfocus: () => {\n\t\t\t\tfocused = true;\n\t\t\t\tthis.send({ type: \"engine_custom_control\", componentId, action: \"focus\" });\n\t\t\t},\n\t\t\tunfocus: () => {\n\t\t\t\tfocused = false;\n\t\t\t\tthis.send({ type: \"engine_custom_control\", componentId, action: \"unfocus\" });\n\t\t\t},\n\t\t\tisFocused: () => focused,\n\t\t\tgetBounds: () => undefined,\n\t\t};\n\t}\n\n\tprivate sendDone<T>(componentId: string, result: T): void {\n\t\tthis.send({\n\t\t\ttype: \"engine_custom_done\",\n\t\t\tcomponentId,\n\t\t\tresult: jsonResult(result as object | boolean | null | number | string | undefined),\n\t\t});\n\t}\n\n\tprivate send(message: InteractiveEngineMessage): void {\n\t\tthis.write(serializeInteractiveEngineMessage(message));\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"engine-cust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AE,CAAC,CAAC;YAC5F,CAAC;YACD,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,KAAK,IAAI;YAC7D,KAAK,EAAE,GAAG,EAAE;gBACX,OAAO,GAAG,IAAI,CAAC;gBACf,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;YAC5E,CAAC;YACD,OAAO,EAAE,GAAG,EAAE;gBACb,OAAO,GAAG,KAAK,CAAC;gBAChB,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;YAC9E,CAAC;YACD,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO;YACxB,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS;SAC1B,CAAC;IACH,CAAC;IAEO,QAAQ,CAAI,WAAmB,EAAE,MAAS;QACjD,IAAI,CAAC,IAAI,CAAC;YACT,IAAI,EAAE,oBAAoB;YAC1B,WAAW;YACX,MAAM,EAAE,UAAU,CAAC,MAA+D,CAAC;SACnF,CAAC,CAAC;IACJ,CAAC;IAEO,IAAI,CAAC,OAAiC;QAC7C,IAAI,CAAC,KAAK,CAAC,iCAAiC,CAAC,OAAO,CAAC,CAAC,CAAC;IACxD,CAAC;CACD","sourcesContent":["import {\n\ttype Component,\n\tisKeyRelease,\n\ttype OverlayHandle,\n\ttype OverlayOptions,\n\ttype Terminal,\n\ttype TUI,\n\tTuiMainScreen,\n} from \"@earendil-works/pi-tui\";\nimport { getAgentDir } from \"../../config.js\";\nimport { runCallback } from \"../../core/callback-activity.ts\";\nimport type { HostCustomUiState, HostCustomUiStateListener } from \"../../core/extensions/index.js\";\nimport type { ScrollableWidgetComponent } from \"../../core/extensions/ui-types.ts\";\nimport type { KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { Theme } from \"../interactive/theme/theme.js\";\nimport { theme } from \"../interactive/theme/theme.js\";\nimport {\n\ttype EngineTerminalControl,\n\ttype InteractiveEngineMessage,\n\tisJsonValue,\n\ttype JsonValue,\n\tparseInteractiveEngineCommand,\n\ttype SerializableOverlayOptions,\n\tserializeInteractiveEngineMessage,\n} from \"./protocol.ts\";\n\ninterface CustomUiOptions {\n\tpurpose?: \"prompt\" | \"navigation\";\n\toverlay?: boolean;\n\tdeferInlineCustomUiFocus?: boolean;\n\t/** The component binds Ctrl+C itself; see ExtensionUIContext.custom options. */\n\thandlesCtrlC?: boolean;\n\t/** The component claims internal UI actions such as the jump-to-bottom URL. */\n\thandlesInternalUiAction?: boolean;\n\t/** Bound this overlay and reserve transcript scroll extent on the host. */\n\treserveTranscriptRows?: boolean;\n\toverlayOptions?: OverlayOptions | (() => OverlayOptions);\n\tonHandle?: (handle: OverlayHandle) => void;\n\tsignal?: AbortSignal;\n}\n\ninterface ActiveComponent {\n\tcomponent: Component & { dispose?(): void };\n\tresolve: (value: JsonValue | undefined) => void;\n\toverlay: boolean;\n\tpurpose?: \"prompt\" | \"navigation\";\n\tterminal: RemoteTerminal;\n\ttui: TUI;\n\twidgetKey?: string;\n\t/**\n\t * Overlay visibility as last driven through the remote OverlayHandle.\n\t * Hidden components are skipped by the extension-level `requestRender()`\n\t * broadcast (#1856) — invalidating a hidden overlay only produced host\n\t * render work and terminal writes for frames the user cannot see.\n\t */\n\thidden?: boolean;\n}\n\nclass RemoteTerminal implements Terminal {\n\tcolumns = 80;\n\trows = 24;\n\tkittyProtocolActive = false;\n\tprivate readonly invalidate: () => void;\n\tprivate readonly control: ((control: EngineTerminalControl) => void) | undefined;\n\tconstructor(invalidate: () => void, control?: (control: EngineTerminalControl) => void) {\n\t\tthis.invalidate = invalidate;\n\t\tthis.control = control;\n\t}\n\tstart(): void {}\n\tstop(): void {}\n\tasync drainInput(): Promise<void> {}\n\twrite(): void {\n\t\tthis.invalidate();\n\t}\n\tmoveBy(): void {}\n\thideCursor(): void {}\n\tshowCursor(): void {}\n\tclearLine(): void {}\n\tclearFromCursor(): void {}\n\tclearScreen(): void {}\n\tsetTitle(): void {}\n\tsetProgress(): void {}\n\t/** Ask the host to toggle host-TTY autowrap (DECAWM) for this component. */\n\tsetAutowrap(enabled: boolean): void {\n\t\tthis.control?.({ kind: \"autowrap\", enabled });\n\t}\n}\n\nfunction serializableOverlayOptions(\n\toptions: CustomUiOptions[\"overlayOptions\"],\n): SerializableOverlayOptions | undefined {\n\tconst value = typeof options === \"function\" ? options() : options;\n\tif (!value) return undefined;\n\tconst { anchor, col, margin, maxHeight, minWidth, offsetX, offsetY, row, width } = value;\n\treturn { anchor, col, margin, maxHeight, minWidth, offsetX, offsetY, row, width };\n}\n\nfunction jsonResult(value: object | boolean | null | number | string | undefined): JsonValue | undefined {\n\tif (value === undefined) return undefined;\n\tconst encoded = JSON.stringify(value);\n\tif (encoded === undefined) return undefined;\n\tconst decoded = JSON.parse(encoded) as JsonValue;\n\tif (!isJsonValue(decoded)) throw new Error(\"Custom UI result is not JSON-safe\");\n\treturn decoded;\n}\n\nexport class EngineCustomUiService {\n\tprivate readonly widgetIds = new Map<string, string>();\n\tprivate readonly active = new Map<string, ActiveComponent>();\n\tprivate nextId = 0;\n\tprivate readonly write: (line: string) => void;\n\tprivate readonly keybindings: KeybindingsManager;\n\tprivate readonly stateListeners = new Set<HostCustomUiStateListener>();\n\tprivate readonly widgetReleaseListeners = new Map<string, Set<() => void>>();\n\n\tsetWidget(\n\t\tkey: string,\n\t\tfactory: ((tui: TUI, theme: Theme) => Component & { dispose?(): void }) | undefined,\n\t\tplacement?: \"aboveEditor\" | \"belowEditor\",\n\t\tscroll?: { maxHeight: number; maxHeightFraction?: number },\n\t): void {\n\t\tconst previous = this.widgetIds.get(key);\n\t\tif (previous) this.disposeComponent(previous, false, false);\n\t\tif (!factory) return;\n\t\tconst componentId = `remote_widget_${++this.nextId}`;\n\t\tthis.widgetIds.set(key, componentId);\n\t\tconst terminal = new RemoteTerminal(() => this.send({ type: \"engine_custom_invalidate\", componentId }));\n\t\tconst tui = new TuiMainScreen(terminal, undefined, getAgentDir());\n\t\tvoid runCallback({ kind: \"renderer\", name: `widget:${key}` }, () => factory(tui, theme))\n\t\t\t.then((component) => {\n\t\t\t\tif (this.widgetIds.get(key) !== componentId) {\n\t\t\t\t\tcomponent.dispose?.();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttui.addChild(component);\n\t\t\t\tthis.active.set(componentId, {\n\t\t\t\t\tcomponent,\n\t\t\t\t\tresolve: () => {},\n\t\t\t\t\toverlay: false,\n\t\t\t\t\tterminal,\n\t\t\t\t\ttui,\n\t\t\t\t\twidgetKey: key,\n\t\t\t\t});\n\t\t\t\tthis.send({\n\t\t\t\t\ttype: \"engine_custom_open\",\n\t\t\t\t\tcomponentId,\n\t\t\t\t\toverlay: false,\n\t\t\t\t\twidgetKey: key,\n\t\t\t\t\twidgetPlacement: placement,\n\t\t\t\t\t...(scroll ? { widgetScroll: scroll } : {}),\n\t\t\t\t});\n\t\t\t})\n\t\t\t.catch((error: Error) => {\n\t\t\t\tif (this.widgetIds.get(key) === componentId) this.widgetIds.delete(key);\n\t\t\t\tthis.send({\n\t\t\t\t\ttype: \"engine_custom_frame\",\n\t\t\t\t\tcomponentId,\n\t\t\t\t\trequestId: 0,\n\t\t\t\t\tlines: [`Widget ${key} failed: ${error.message}`],\n\t\t\t\t});\n\t\t\t});\n\t}\n\tconstructor(write: (line: string) => void, keybindings: KeybindingsManager) {\n\t\tthis.write = write;\n\t\tthis.keybindings = keybindings;\n\t}\n\n\tasync custom<T>(\n\t\tfactory: (\n\t\t\ttui: TUI,\n\t\t\ttheme: Theme,\n\t\t\tkeybindings: KeybindingsManager,\n\t\t\tdone: (result: T) => void,\n\t\t) => (Component & { dispose?(): void }) | Promise<Component & { dispose?(): void }>,\n\t\toptions?: CustomUiOptions,\n\t): Promise<T> {\n\t\tconst componentId = `remote_component_${++this.nextId}`;\n\t\tlet resolveCompletion!: (value: T) => void;\n\t\tconst completion = new Promise<T>((resolve) => {\n\t\t\tresolveCompletion = resolve;\n\t\t});\n\t\tlet opened = false;\n\t\tlet pendingDone: T | undefined;\n\t\tlet doneCalled = false;\n\t\tconst done = (result: T): void => {\n\t\t\tif (doneCalled) return;\n\t\t\tdoneCalled = true;\n\t\t\tpendingDone = result;\n\t\t\tresolveCompletion(result);\n\t\t\tif (opened) this.sendDone(componentId, result);\n\t\t};\n\t\tconst terminal = new RemoteTerminal(\n\t\t\t() => this.send({ type: \"engine_custom_invalidate\", componentId }),\n\t\t\t(control) => this.send({ type: \"engine_custom_terminal\", componentId, control }),\n\t\t);\n\t\tconst tui = new TuiMainScreen(terminal, undefined, getAgentDir());\n\t\tconst component = await factory(tui, theme, this.keybindings, done);\n\t\ttui.addChild(component);\n\t\ttui.setFocus(component);\n\t\tconst record: ActiveComponent = {\n\t\t\tcomponent,\n\t\t\t// Cancellation must settle through the same guarded host completion as done().\n\t\t\tresolve: (value) => done(value as T),\n\t\t\tterminal,\n\t\t\ttui,\n\t\t\toverlay: options?.overlay === true,\n\t\t\tpurpose: options?.purpose,\n\t\t};\n\t\tthis.active.set(componentId, record);\n\t\tthis.notifyState();\n\t\topened = true;\n\t\tthis.send({\n\t\t\ttype: \"engine_custom_open\",\n\t\t\tcomponentId,\n\t\t\toverlay: options?.overlay === true,\n\t\t\tpurpose: options?.purpose,\n\t\t\tdeferInlineCustomUiFocus: options?.deferInlineCustomUiFocus,\n\t\t\thandlesCtrlC: options?.handlesCtrlC,\n\t\t\thandlesInternalUiAction: options?.handlesInternalUiAction,\n\t\t\treserveTranscriptRows: options?.reserveTranscriptRows,\n\t\t\toverlayOptions: serializableOverlayOptions(options?.overlayOptions),\n\t\t});\n\t\tif (options?.onHandle) options.onHandle(this.remoteHandle(componentId));\n\t\tif (doneCalled) this.sendDone(componentId, pendingDone as T);\n\t\tconst onAbort = () => this.disposeComponent(componentId, true);\n\t\toptions?.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\ttry {\n\t\t\treturn await completion;\n\t\t} finally {\n\t\t\toptions?.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\tthis.disposeComponent(componentId, false);\n\t\t}\n\t}\n\tgetHostCustomUiState(): HostCustomUiState {\n\t\tconst inline = [...this.active.values()].filter((record) => !record.overlay && !record.widgetKey);\n\t\tconst navigation = inline.filter((record) => record.purpose === \"navigation\").length;\n\t\treturn {\n\t\t\tblockingInlineCustomUiDepth: inline.length,\n\t\t\tblockingInlineCustomUiActive: inline.length > 0,\n\t\t\t...(navigation > 0 ? { blockingInlineCustomUiNeedsInput: inline.length > navigation } : {}),\n\t\t};\n\t}\n\n\tonHostCustomUiStateChange(listener: HostCustomUiStateListener): () => void {\n\t\tthis.stateListeners.add(listener);\n\t\treturn () => this.stateListeners.delete(listener);\n\t}\n\tonWidgetRelease(key: string, listener: () => void): () => void {\n\t\tconst listeners = this.widgetReleaseListeners.get(key) ?? new Set<() => void>();\n\t\tlisteners.add(listener);\n\t\tthis.widgetReleaseListeners.set(key, listeners);\n\t\treturn () => {\n\t\t\tlisteners.delete(listener);\n\t\t\tif (listeners.size === 0) this.widgetReleaseListeners.delete(key);\n\t\t};\n\t}\n\n\tfocusHostInlineCustomUi(): boolean {\n\t\treturn this.getHostCustomUiState().blockingInlineCustomUiActive;\n\t}\n\n\trequestRender(): void {\n\t\tfor (const [componentId, record] of this.active) {\n\t\t\tif (record.hidden === true) continue;\n\t\t\tthis.send({ type: \"engine_custom_invalidate\", componentId });\n\t\t}\n\t}\n\n\thandleLine(line: string): boolean {\n\t\tconst command = parseInteractiveEngineCommand(line);\n\t\tif (!command) return false;\n\t\tif (!command.type.startsWith(\"engine_custom_\")) return false;\n\t\tconst record = this.active.get(command.componentId);\n\t\tif (!record) {\n\t\t\tif (command.type === \"engine_custom_input\")\n\t\t\t\tthis.send({\n\t\t\t\t\ttype: \"engine_custom_input_result\",\n\t\t\t\t\tcomponentId: command.componentId,\n\t\t\t\t\trequestId: command.requestId,\n\t\t\t\t\thandled: false,\n\t\t\t\t});\n\t\t\treturn true;\n\t\t}\n\t\tswitch (command.type) {\n\t\t\tcase \"engine_custom_scroll\":\n\t\t\t\t(record.component as ScrollableWidgetComponent).onScroll?.(command.state);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_render\":\n\t\t\t\trecord.terminal.columns = Math.max(1, command.width);\n\t\t\t\trecord.terminal.rows = Math.max(1, command.rows);\n\t\t\t\tvoid runCallback({ kind: \"renderer\", name: command.componentId }, () =>\n\t\t\t\t\trecord.component.render(record.terminal.columns),\n\t\t\t\t)\n\t\t\t\t\t.then((lines) => {\n\t\t\t\t\t\tconst scrollRequest = (record.component as ScrollableWidgetComponent).getScrollRequest?.();\n\t\t\t\t\t\tthis.send({\n\t\t\t\t\t\t\ttype: \"engine_custom_frame\",\n\t\t\t\t\t\t\tcomponentId: command.componentId,\n\t\t\t\t\t\t\trequestId: command.requestId,\n\t\t\t\t\t\t\tlines,\n\t\t\t\t\t\t\t...(scrollRequest ? { scrollRequest } : {}),\n\t\t\t\t\t\t});\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error: Error) =>\n\t\t\t\t\t\tthis.send({\n\t\t\t\t\t\t\ttype: \"engine_custom_frame\",\n\t\t\t\t\t\t\tcomponentId: command.componentId,\n\t\t\t\t\t\t\trequestId: command.requestId,\n\t\t\t\t\t\t\tlines: [`Remote component render failed: ${error.message}`],\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_input\":\n\t\t\t\tvoid runCallback({ kind: \"renderer\", name: command.componentId }, () => {\n\t\t\t\t\tif (isKeyRelease(command.data) && record.component.wantsKeyRelease !== true) return false;\n\t\t\t\t\tconst handleInput = record.component.handleInput as ((data: string) => boolean | undefined) | undefined;\n\t\t\t\t\treturn handleInput?.call(record.component, command.data) === true;\n\t\t\t\t})\n\t\t\t\t\t.then((handled) =>\n\t\t\t\t\t\tthis.send({\n\t\t\t\t\t\t\ttype: \"engine_custom_input_result\",\n\t\t\t\t\t\t\tcomponentId: command.componentId,\n\t\t\t\t\t\t\trequestId: command.requestId,\n\t\t\t\t\t\t\thandled,\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t\t.catch(() =>\n\t\t\t\t\t\tthis.send({\n\t\t\t\t\t\t\ttype: \"engine_custom_input_result\",\n\t\t\t\t\t\t\tcomponentId: command.componentId,\n\t\t\t\t\t\t\trequestId: command.requestId,\n\t\t\t\t\t\t\thandled: false,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_dispose\":\n\t\t\t\tthis.disposeComponent(command.componentId, true);\n\t\t\t\tbreak;\n\t\t}\n\t\treturn true;\n\t}\n\n\tdispose(): void {\n\t\tfor (const componentId of [...this.active.keys()]) this.disposeComponent(componentId, true, false);\n\t}\n\tprivate disposeComponent(componentId: string, resolve: boolean, notifyWidgetRelease = true): void {\n\t\tconst record = this.active.get(componentId);\n\t\tif (!record) return;\n\t\tthis.active.delete(componentId);\n\t\t// Claim cancellation before user disposal code can call done() reentrantly.\n\t\tif (resolve) record.resolve(undefined);\n\t\trecord.component.dispose?.();\n\t\trecord.tui.stop();\n\t\tif (record.widgetKey) {\n\t\t\tif (this.widgetIds.get(record.widgetKey) === componentId) this.widgetIds.delete(record.widgetKey);\n\t\t\tthis.send({ type: \"engine_custom_close\", componentId });\n\t\t\tif (notifyWidgetRelease) this.notifyWidgetRelease(record.widgetKey);\n\t\t}\n\t\tthis.notifyState();\n\t}\n\tprivate notifyWidgetRelease(key: string): void {\n\t\tfor (const listener of this.widgetReleaseListeners.get(key) ?? []) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t// A release observer must not break engine UI teardown.\n\t\t\t}\n\t\t}\n\t}\n\tprivate notifyState(): void {\n\t\tconst state = this.getHostCustomUiState();\n\t\tfor (const listener of this.stateListeners) listener(state);\n\t}\n\n\tprivate remoteHandle(componentId: string): OverlayHandle {\n\t\tlet focused = true;\n\t\tconst setHiddenFlag = (value: boolean): void => {\n\t\t\tconst record = this.active.get(componentId);\n\t\t\tif (record) record.hidden = value;\n\t\t};\n\t\treturn {\n\t\t\thide: () => {\n\t\t\t\tsetHiddenFlag(true);\n\t\t\t\tthis.send({ type: \"engine_custom_control\", componentId, action: \"hide\" });\n\t\t\t},\n\t\t\tsetHidden: (value) => {\n\t\t\t\tsetHiddenFlag(value);\n\t\t\t\tthis.send({ type: \"engine_custom_control\", componentId, action: value ? \"hide\" : \"show\" });\n\t\t\t},\n\t\t\tisHidden: () => this.active.get(componentId)?.hidden === true,\n\t\t\tfocus: () => {\n\t\t\t\tfocused = true;\n\t\t\t\tthis.send({ type: \"engine_custom_control\", componentId, action: \"focus\" });\n\t\t\t},\n\t\t\tunfocus: () => {\n\t\t\t\tfocused = false;\n\t\t\t\tthis.send({ type: \"engine_custom_control\", componentId, action: \"unfocus\" });\n\t\t\t},\n\t\t\tisFocused: () => focused,\n\t\t\tgetBounds: () => undefined,\n\t\t};\n\t}\n\n\tprivate sendDone<T>(componentId: string, result: T): void {\n\t\tthis.send({\n\t\t\ttype: \"engine_custom_done\",\n\t\t\tcomponentId,\n\t\t\tresult: jsonResult(result as object | boolean | null | number | string | undefined),\n\t\t});\n\t}\n\n\tprivate send(message: InteractiveEngineMessage): void {\n\t\tthis.write(serializeInteractiveEngineMessage(message));\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-dialog-host.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/engine-dialog-host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"engine-dialog-host.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/engine-dialog-host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAsDxE;;;;;;;;;;;;;;GAcG;AACH,qBAAa,0BAA0B;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAqB;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqE;IAC7F,wDAAwD;IACxD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6B;IAC1D,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAa;IAChD,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAa;IAExD,YAAY,OAAO,EAAE,0BAA0B,EAAE,EAAE,EAAE,kBAAkB,EAKtE;IAED,OAAO,IAAI,IAAI,CAMd;IAED,oFAAoF;IACpF,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAa1C;IAED,OAAO,CAAC,QAAQ;YAKF,MAAM;CAuBpB"}
|
|
@@ -31,7 +31,10 @@ async function handleRequest(ui, request, signal) {
|
|
|
31
31
|
ui.setStatus(request.statusKey, request.statusText);
|
|
32
32
|
return undefined;
|
|
33
33
|
case "setWidget":
|
|
34
|
-
ui.setWidget(request.widgetKey, request.widgetLines, {
|
|
34
|
+
ui.setWidget(request.widgetKey, request.widgetLines, {
|
|
35
|
+
placement: request.widgetPlacement,
|
|
36
|
+
...(request.widgetScroll ? { scroll: request.widgetScroll } : {}),
|
|
37
|
+
});
|
|
35
38
|
return undefined;
|
|
36
39
|
case "setTitle":
|
|
37
40
|
ui.setTitle(request.title);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-dialog-host.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/engine-dialog-host.ts"],"names":[],"mappings":"AAIA,iFAAiF;AACjF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AU,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;QACtD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QACpD,IAAI,QAA4C,CAAC;QACjD,IAAI,CAAC;YACJ,QAAQ,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAChE,CAAC;gBAAS,CAAC;YACV,yEAAyE;YACzE,8CAA8C;YAC9C,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,KAAK,KAAK,KAAK;gBAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACpF,CAAC;QACD,mEAAmE;QACnE,6EAA6E;QAC7E,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QAC3C,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD","sourcesContent":["import type { ExtensionUIContext } from \"../../core/extensions/index.js\";\nimport type { RpcExtensionUIRequest, RpcExtensionUIResponse } from \"../rpc/rpc-types.ts\";\nimport type { IsolatedInteractiveRuntime } from \"./isolated-runtime.js\";\n\n/** Requests that mount a host dialog and therefore need generation ownership. */\nconst MOUNTING_METHODS: ReadonlySet<string> = new Set([\"select\", \"confirm\", \"input\", \"editor\"]);\n\nasync function handleRequest(\n\tui: ExtensionUIContext,\n\trequest: RpcExtensionUIRequest,\n\tsignal: AbortSignal | undefined,\n): Promise<RpcExtensionUIResponse | undefined> {\n\tswitch (request.method) {\n\t\tcase \"select\": {\n\t\t\tconst value = await ui.select(request.title, request.options, { timeout: request.timeout, signal });\n\t\t\treturn value === undefined\n\t\t\t\t? { type: \"extension_ui_response\", id: request.id, cancelled: true }\n\t\t\t\t: { type: \"extension_ui_response\", id: request.id, value };\n\t\t}\n\t\tcase \"confirm\": {\n\t\t\tconst confirmed = await ui.confirm(request.title, request.message, { timeout: request.timeout, signal });\n\t\t\treturn { type: \"extension_ui_response\", id: request.id, confirmed };\n\t\t}\n\t\tcase \"input\": {\n\t\t\tconst value = await ui.input(request.title, request.placeholder, { timeout: request.timeout, signal });\n\t\t\treturn value === undefined\n\t\t\t\t? { type: \"extension_ui_response\", id: request.id, cancelled: true }\n\t\t\t\t: { type: \"extension_ui_response\", id: request.id, value };\n\t\t}\n\t\tcase \"editor\": {\n\t\t\tconst value = await ui.editor(request.title, request.prefill, { signal });\n\t\t\treturn value === undefined\n\t\t\t\t? { type: \"extension_ui_response\", id: request.id, cancelled: true }\n\t\t\t\t: { type: \"extension_ui_response\", id: request.id, value };\n\t\t}\n\t\tcase \"notify\":\n\t\t\tui.notify(request.message, request.notifyType);\n\t\t\treturn undefined;\n\t\tcase \"setStatus\":\n\t\t\tui.setStatus(request.statusKey, request.statusText);\n\t\t\treturn undefined;\n\t\tcase \"setWidget\":\n\t\t\tui.setWidget(request.widgetKey, request.widgetLines, { placement: request.widgetPlacement });\n\t\t\treturn undefined;\n\t\tcase \"setTitle\":\n\t\t\tui.setTitle(request.title);\n\t\t\treturn undefined;\n\t\tcase \"set_editor_text\":\n\t\t\tui.setEditorText(request.text);\n\t\t\treturn undefined;\n\t}\n}\n\n/**\n * Generation-owned host dialogs and line widgets for the isolated engine.\n *\n * `select`, `confirm`, `input`, and `editor` mount real host components and can\n * outlive the engine child that asked for them. Without ownership a dead\n * generation left its dialog on screen forever, its host promise unsettled, and\n * could answer through the replacement child's writer. Each request is recorded\n * with the generation that issued it; when that generation ends the mount is\n * aborted — closing only its own instance — and any answer is suppressed.\n *\n * Line widgets (`setWidget` with `string[]`) have the same problem without any\n * component to close: they are plain host state keyed by name, so the key is\n * tracked against its latest writer and released only if that writer's\n * generation is the one that died.\n */\nexport class EngineDialogHostController {\n\tprivate readonly runtime: IsolatedInteractiveRuntime;\n\tprivate readonly ui: ExtensionUIContext;\n\tprivate readonly records = new Map<string, { generation: number; abort: AbortController }>();\n\t/** Line-widget key -> generation that last wrote it. */\n\tprivate readonly widgetOwners = new Map<string, number>();\n\tprivate readonly unsubscribeHandler: () => void;\n\tprivate readonly unsubscribeGenerationEnded: () => void;\n\n\tconstructor(runtime: IsolatedInteractiveRuntime, ui: ExtensionUIContext) {\n\t\tthis.runtime = runtime;\n\t\tthis.ui = ui;\n\t\tthis.unsubscribeHandler = runtime.setExtensionUIHandler((request) => this.handle(request));\n\t\tthis.unsubscribeGenerationEnded = runtime.onGenerationEnded((event) => this.disposeGeneration(event.generation));\n\t}\n\n\tdispose(): void {\n\t\tthis.unsubscribeHandler();\n\t\tthis.unsubscribeGenerationEnded();\n\t\tthis.abortAll();\n\t\tfor (const key of [...this.widgetOwners.keys()]) this.ui.setWidget(key, undefined);\n\t\tthis.widgetOwners.clear();\n\t}\n\n\t/** Close every dialog and release every widget key owned by an ended generation. */\n\tdisposeGeneration(generation: number): void {\n\t\tfor (const [id, record] of [...this.records]) {\n\t\t\tif (record.generation !== generation) continue;\n\t\t\tthis.records.delete(id);\n\t\t\trecord.abort.abort();\n\t\t}\n\t\tfor (const [key, owner] of [...this.widgetOwners]) {\n\t\t\t// A newer generation that rewrote this key owns it now; clearing here\n\t\t\t// would wipe live content the replacement child just published.\n\t\t\tif (owner !== generation) continue;\n\t\t\tthis.widgetOwners.delete(key);\n\t\t\tthis.ui.setWidget(key, undefined);\n\t\t}\n\t}\n\n\tprivate abortAll(): void {\n\t\tfor (const [, record] of [...this.records]) record.abort.abort();\n\t\tthis.records.clear();\n\t}\n\n\tprivate async handle(request: RpcExtensionUIRequest): Promise<RpcExtensionUIResponse | undefined> {\n\t\tif (request.method === \"setWidget\") {\n\t\t\tif (request.widgetLines === undefined) this.widgetOwners.delete(request.widgetKey);\n\t\t\telse this.widgetOwners.set(request.widgetKey, this.runtime.getEngineGeneration());\n\t\t\treturn handleRequest(this.ui, request, undefined);\n\t\t}\n\t\tif (!MOUNTING_METHODS.has(request.method)) return handleRequest(this.ui, request, undefined);\n\t\tconst abort = new AbortController();\n\t\tconst generation = this.runtime.getEngineGeneration();\n\t\tthis.records.set(request.id, { generation, abort });\n\t\tlet response: RpcExtensionUIResponse | undefined;\n\t\ttry {\n\t\t\tresponse = await handleRequest(this.ui, request, abort.signal);\n\t\t} finally {\n\t\t\t// Only the owning record may be removed: a late settle must not delete a\n\t\t\t// newer record that happens to share this id.\n\t\t\tif (this.records.get(request.id)?.abort === abort) this.records.delete(request.id);\n\t\t}\n\t\t// The generation that asked is gone, so the writer now points at a\n\t\t// replacement child. Answering would deliver this reply to the wrong engine.\n\t\tif (abort.signal.aborted) return undefined;\n\t\treturn response;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"engine-dialog-host.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/engine-dialog-host.ts"],"names":[],"mappings":"AAIA,iFAAiF;AACjF,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEhG,KAAK,UAAU,aAAa,CAC3B,EAAsB,EACtB,OAA8B,EAC9B,MAA+B;IAE/B,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;QACxB,KAAK,QAAQ,EAAE,CAAC;YACf,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;YACpG,OAAO,KAAK,KAAK,SAAS;gBACzB,CAAC,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;gBACpE,CAAC,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,KA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,CAAC;QACpF,CAAC;QACD,mEAAmE;QACnE,6EAA6E;QAC7E,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QAC3C,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD","sourcesContent":["import type { ExtensionUIContext } from \"../../core/extensions/index.js\";\nimport type { RpcExtensionUIRequest, RpcExtensionUIResponse } from \"../rpc/rpc-types.ts\";\nimport type { IsolatedInteractiveRuntime } from \"./isolated-runtime.js\";\n\n/** Requests that mount a host dialog and therefore need generation ownership. */\nconst MOUNTING_METHODS: ReadonlySet<string> = new Set([\"select\", \"confirm\", \"input\", \"editor\"]);\n\nasync function handleRequest(\n\tui: ExtensionUIContext,\n\trequest: RpcExtensionUIRequest,\n\tsignal: AbortSignal | undefined,\n): Promise<RpcExtensionUIResponse | undefined> {\n\tswitch (request.method) {\n\t\tcase \"select\": {\n\t\t\tconst value = await ui.select(request.title, request.options, { timeout: request.timeout, signal });\n\t\t\treturn value === undefined\n\t\t\t\t? { type: \"extension_ui_response\", id: request.id, cancelled: true }\n\t\t\t\t: { type: \"extension_ui_response\", id: request.id, value };\n\t\t}\n\t\tcase \"confirm\": {\n\t\t\tconst confirmed = await ui.confirm(request.title, request.message, { timeout: request.timeout, signal });\n\t\t\treturn { type: \"extension_ui_response\", id: request.id, confirmed };\n\t\t}\n\t\tcase \"input\": {\n\t\t\tconst value = await ui.input(request.title, request.placeholder, { timeout: request.timeout, signal });\n\t\t\treturn value === undefined\n\t\t\t\t? { type: \"extension_ui_response\", id: request.id, cancelled: true }\n\t\t\t\t: { type: \"extension_ui_response\", id: request.id, value };\n\t\t}\n\t\tcase \"editor\": {\n\t\t\tconst value = await ui.editor(request.title, request.prefill, { signal });\n\t\t\treturn value === undefined\n\t\t\t\t? { type: \"extension_ui_response\", id: request.id, cancelled: true }\n\t\t\t\t: { type: \"extension_ui_response\", id: request.id, value };\n\t\t}\n\t\tcase \"notify\":\n\t\t\tui.notify(request.message, request.notifyType);\n\t\t\treturn undefined;\n\t\tcase \"setStatus\":\n\t\t\tui.setStatus(request.statusKey, request.statusText);\n\t\t\treturn undefined;\n\t\tcase \"setWidget\":\n\t\t\tui.setWidget(request.widgetKey, request.widgetLines, {\n\t\t\t\tplacement: request.widgetPlacement,\n\t\t\t\t...(request.widgetScroll ? { scroll: request.widgetScroll } : {}),\n\t\t\t});\n\t\t\treturn undefined;\n\t\tcase \"setTitle\":\n\t\t\tui.setTitle(request.title);\n\t\t\treturn undefined;\n\t\tcase \"set_editor_text\":\n\t\t\tui.setEditorText(request.text);\n\t\t\treturn undefined;\n\t}\n}\n\n/**\n * Generation-owned host dialogs and line widgets for the isolated engine.\n *\n * `select`, `confirm`, `input`, and `editor` mount real host components and can\n * outlive the engine child that asked for them. Without ownership a dead\n * generation left its dialog on screen forever, its host promise unsettled, and\n * could answer through the replacement child's writer. Each request is recorded\n * with the generation that issued it; when that generation ends the mount is\n * aborted — closing only its own instance — and any answer is suppressed.\n *\n * Line widgets (`setWidget` with `string[]`) have the same problem without any\n * component to close: they are plain host state keyed by name, so the key is\n * tracked against its latest writer and released only if that writer's\n * generation is the one that died.\n */\nexport class EngineDialogHostController {\n\tprivate readonly runtime: IsolatedInteractiveRuntime;\n\tprivate readonly ui: ExtensionUIContext;\n\tprivate readonly records = new Map<string, { generation: number; abort: AbortController }>();\n\t/** Line-widget key -> generation that last wrote it. */\n\tprivate readonly widgetOwners = new Map<string, number>();\n\tprivate readonly unsubscribeHandler: () => void;\n\tprivate readonly unsubscribeGenerationEnded: () => void;\n\n\tconstructor(runtime: IsolatedInteractiveRuntime, ui: ExtensionUIContext) {\n\t\tthis.runtime = runtime;\n\t\tthis.ui = ui;\n\t\tthis.unsubscribeHandler = runtime.setExtensionUIHandler((request) => this.handle(request));\n\t\tthis.unsubscribeGenerationEnded = runtime.onGenerationEnded((event) => this.disposeGeneration(event.generation));\n\t}\n\n\tdispose(): void {\n\t\tthis.unsubscribeHandler();\n\t\tthis.unsubscribeGenerationEnded();\n\t\tthis.abortAll();\n\t\tfor (const key of [...this.widgetOwners.keys()]) this.ui.setWidget(key, undefined);\n\t\tthis.widgetOwners.clear();\n\t}\n\n\t/** Close every dialog and release every widget key owned by an ended generation. */\n\tdisposeGeneration(generation: number): void {\n\t\tfor (const [id, record] of [...this.records]) {\n\t\t\tif (record.generation !== generation) continue;\n\t\t\tthis.records.delete(id);\n\t\t\trecord.abort.abort();\n\t\t}\n\t\tfor (const [key, owner] of [...this.widgetOwners]) {\n\t\t\t// A newer generation that rewrote this key owns it now; clearing here\n\t\t\t// would wipe live content the replacement child just published.\n\t\t\tif (owner !== generation) continue;\n\t\t\tthis.widgetOwners.delete(key);\n\t\t\tthis.ui.setWidget(key, undefined);\n\t\t}\n\t}\n\n\tprivate abortAll(): void {\n\t\tfor (const [, record] of [...this.records]) record.abort.abort();\n\t\tthis.records.clear();\n\t}\n\n\tprivate async handle(request: RpcExtensionUIRequest): Promise<RpcExtensionUIResponse | undefined> {\n\t\tif (request.method === \"setWidget\") {\n\t\t\tif (request.widgetLines === undefined) this.widgetOwners.delete(request.widgetKey);\n\t\t\telse this.widgetOwners.set(request.widgetKey, this.runtime.getEngineGeneration());\n\t\t\treturn handleRequest(this.ui, request, undefined);\n\t\t}\n\t\tif (!MOUNTING_METHODS.has(request.method)) return handleRequest(this.ui, request, undefined);\n\t\tconst abort = new AbortController();\n\t\tconst generation = this.runtime.getEngineGeneration();\n\t\tthis.records.set(request.id, { generation, abort });\n\t\tlet response: RpcExtensionUIResponse | undefined;\n\t\ttry {\n\t\t\tresponse = await handleRequest(this.ui, request, abort.signal);\n\t\t} finally {\n\t\t\t// Only the owning record may be removed: a late settle must not delete a\n\t\t\t// newer record that happens to share this id.\n\t\t\tif (this.records.get(request.id)?.abort === abort) this.records.delete(request.id);\n\t\t}\n\t\t// The generation that asked is gone, so the writer now points at a\n\t\t// replacement child. Answering would deliver this reply to the wrong engine.\n\t\tif (abort.signal.aborted) return undefined;\n\t\treturn response;\n\t}\n}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;AACpE,wBAAgB,4CAA4C,CAC3D,OAAO,EAAE,mBAAmB,EAC5B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,EAAE,GAAG,IAAI,CAAC,CAIvC;AAED,kFAAkF;AAClF,wBAAgB,wCAAwC,CACvD,OAAO,EAAE,mBAAmB,EAC5B,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,KAAK,IAAI,GACtD,MAAM,IAAI,CAEZ"}
|
|
@@ -26,7 +26,7 @@ export function attachInteractiveEngineHost(runtime, ui, onDiagnostic, tuiRender
|
|
|
26
26
|
const dialogs = new EngineDialogHostController(runtime, ui);
|
|
27
27
|
let shortcuts = [];
|
|
28
28
|
const dispatchShortcut = (data) => {
|
|
29
|
-
const shortcut = shortcuts.find(({ key }) => matchesKey(data, key));
|
|
29
|
+
const shortcut = shortcuts.find(({ key, editorKeys }) => matchesKey(data, key) && !editorKeys?.some((editorKey) => matchesKey(data, editorKey)));
|
|
30
30
|
if (!shortcut)
|
|
31
31
|
return false;
|
|
32
32
|
void runtime
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-ui-bridge.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/extension-ui-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOhE,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,yBAAyB,EAA6B,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAOvE,MAAM,UAAU,qCAAqC,CACpD,OAA4B,EAC5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,wCAAwC,CACvD,OAA4B,EAC5B,QAAwD;IAExD,OAAO,OAAO,YAAY,0BAA0B,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;AAC7G,CAAC","sourcesContent":["import { type KeyId, matchesKey } from \"@earendil-works/pi-tui\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport type { ResourceOverlap } from \"../../core/diagnostics.ts\";\nimport type { ExtensionUIContext } from \"../../core/extensions/index.js\";\nimport type { KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { RpcAutocompleteItem, RpcResourceExtension, RpcSlashCommand } from \"../rpc/rpc-types.ts\";\nimport type { ActivityWatchdogDiagnostic } from \"./activity-watchdog.ts\";\nimport { EngineDialogHostController } from \"./engine-dialog-host.ts\";\nimport { InputFormHostController } from \"./input-form-host.ts\";\nimport { IsolatedInteractiveRuntime } from \"./isolated-runtime.js\";\nimport type { EngineExtensionShortcut, EngineKeybindingState, InteractiveEngineMessage } from \"./protocol.ts\";\nimport { RemoteComponentController, type TuiRendererLifecycle } from \"./remote-component.ts\";\nimport { registerRemoteProxyOwnership } from \"./remote-input-ownership.ts\";\nimport { SessionPickerHostController } from \"./session-picker-host.ts\";\n\ninterface EngineMessageSource {\n\tonEngineMessage(listener: (message: InteractiveEngineMessage) => void): () => void;\n\tonKeybindingState?(listener: (state: EngineKeybindingState) => void): () => void;\n}\n\nexport function attachInteractiveEngineKeybindingSync(\n\truntime: EngineMessageSource,\n\tkeybindings: KeybindingsManager,\n\tonState?: (state: EngineKeybindingState) => void,\n): () => void {\n\tconst applyState = (state: EngineKeybindingState): void => {\n\t\tkeybindings.setUserBindings(state.userBindings);\n\t\tonState?.(state);\n\t};\n\tif (runtime.onKeybindingState) return runtime.onKeybindingState(applyState);\n\treturn runtime.onEngineMessage((message) => {\n\t\tif (message.type === \"engine_keybindings_reloaded\") applyState(message.state);\n\t});\n}\n\nexport function attachInteractiveEngineHost(\n\truntime: AgentSessionRuntime,\n\tui: ExtensionUIContext,\n\tonDiagnostic: (diagnostic: ActivityWatchdogDiagnostic) => void,\n\ttuiRendererLifecycle: TuiRendererLifecycle,\n\tsetShortcutHandler?: (handler: (data: string) => boolean) => undefined | (() => void),\n\tkeybindings?: KeybindingsManager,\n): () => void {\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return () => {};\n\tconst disposeDiagnostic = runtime.onDiagnostic(onDiagnostic);\n\t// Generation-owned: RPC dialogs mount real host components and must not\n\t// outlive, or answer through, a replacement engine child.\n\tconst dialogs = new EngineDialogHostController(runtime, ui);\n\tlet shortcuts: EngineExtensionShortcut[] = [];\n\tconst dispatchShortcut = (data: string): boolean => {\n\t\tconst shortcut = shortcuts.find(({ key }) => matchesKey(data, key as KeyId));\n\t\tif (!shortcut) return false;\n\t\tvoid runtime\n\t\t\t.invokeRemoteShortcut(shortcut.key)\n\t\t\t.catch((error: Error) =>\n\t\t\t\tonDiagnostic({ activity: undefined, elapsedMs: 0, level: \"unresponsive\", message: error.message }),\n\t\t\t);\n\t\treturn true;\n\t};\n\tlet disposeShortcutHandler: (() => void) | undefined;\n\tconst installShortcutHandler = (): void => {\n\t\tdisposeShortcutHandler?.();\n\t\tconst dispose = setShortcutHandler?.(dispatchShortcut);\n\t\tdisposeShortcutHandler = typeof dispose === \"function\" ? dispose : undefined;\n\t};\n\tconst applyState = (state: EngineKeybindingState): void => {\n\t\tshortcuts = [...state.shortcuts];\n\t\tinstallShortcutHandler();\n\t};\n\tinstallShortcutHandler();\n\tconst disposeKeybindings = keybindings\n\t\t? attachInteractiveEngineKeybindingSync(runtime, keybindings, applyState)\n\t\t: runtime.onEngineMessage((message) => {\n\t\t\t\tif (message.type === \"engine_keybindings_reloaded\") applyState(message.state);\n\t\t\t});\n\tconst remoteComponents = new RemoteComponentController(runtime, ui, tuiRendererLifecycle);\n\t// Ctrl+C must reach the host while a remote proxy owns input, so publish the\n\t// only component that can answer that question exactly.\n\tconst disposeOwnership = registerRemoteProxyOwnership(runtime, remoteComponents);\n\tconst sessionPicker = new SessionPickerHostController(runtime, ui);\n\tconst inputForm = new InputFormHostController(runtime, ui);\n\tlet disposed = false;\n\treturn () => {\n\t\tif (disposed) return;\n\t\tdisposed = true;\n\t\tdisposeShortcutHandler?.();\n\t\tdisposeKeybindings();\n\t\tdisposeOwnership();\n\t\tremoteComponents.dispose();\n\t\tsessionPicker.dispose();\n\t\tinputForm.dispose();\n\t\tdialogs.dispose();\n\t\tdisposeDiagnostic();\n\t};\n}\n\n/** Route host-owned trust waits to the runner that actually owns the subscribers. */\nexport function withHostProjectTrustPrompt<T>(\n\truntime: AgentSessionRuntime,\n\tkind: \"select\" | \"confirm\" | \"input\",\n\ttitle: string,\n\trun: () => Promise<T>,\n): Promise<T> {\n\treturn runtime instanceof IsolatedInteractiveRuntime\n\t\t? runtime.withProjectTrustPrompt(kind, title, run)\n\t\t: runtime.session.extensionRunner.withProjectTrustPrompt(kind, title, run);\n}\n\nexport async function waitForInteractiveEngineBound(runtime: AgentSessionRuntime): Promise<void> {\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return;\n\tawait runtime.waitUntilBound();\n\tawait runtime.initializeFromEngine();\n}\n\nexport function interruptBlockedInteractiveEngine(runtime: AgentSessionRuntime): boolean {\n\treturn runtime instanceof IsolatedInteractiveRuntime && runtime.interruptBlockedCallback();\n}\n\n/**\n * True when the interactive engine still owes a cooperative abort or the\n * heartbeat watchdog has declared it unresponsive, i.e. when the explicit\n * Ctrl+C escape hatch promised by the watchdog copy applies.\n */\nexport function interactiveEngineNeedsExplicitTermination(runtime: AgentSessionRuntime): boolean {\n\treturn runtime instanceof IsolatedInteractiveRuntime && runtime.needsExplicitTermination();\n}\n\n/**\n * Explicitly terminate an unresponsive interactive engine and start recovery.\n * Only ever reached from a deliberate user action (Ctrl+C) — never from Escape.\n */\nexport function terminateInteractiveEngine(runtime: AgentSessionRuntime): boolean {\n\tif (!interactiveEngineNeedsExplicitTermination(runtime)) return false;\n\tvoid (runtime as IsolatedInteractiveRuntime).terminateAndRecover();\n\treturn true;\n}\n\n/**\n * Command catalog the engine child exposes to the isolated host. Returns an\n * empty list for non-isolated runtimes so callers can merge unconditionally.\n */\nexport function getInteractiveEngineRemoteCommands(runtime: AgentSessionRuntime): readonly RpcSlashCommand[] {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getRemoteCommands() : [];\n}\n\nexport function getInteractiveEngineResourceOverlaps(runtime: AgentSessionRuntime): readonly ResourceOverlap[] {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getResourceOverlaps() : [];\n}\n\nexport function getInteractiveEngineResourceExtensions(runtime: AgentSessionRuntime): readonly RpcResourceExtension[] {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getResourceExtensions() : [];\n}\n\nexport function onInteractiveEngineResourceExtensionsChanged(\n\truntime: AgentSessionRuntime,\n\tlistener: (extensions: readonly RpcResourceExtension[]) => void,\n): () => void {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.onResourceExtensionsChanged(listener) : () => {};\n}\n\n/** Evaluate an engine-child command's live argument completions. */\nexport function getInteractiveEngineRemoteCommandCompletions(\n\truntime: AgentSessionRuntime,\n\tcommandName: string,\n\targumentPrefix: string,\n): Promise<RpcAutocompleteItem[] | null> {\n\treturn runtime instanceof IsolatedInteractiveRuntime\n\t\t? runtime.getRemoteCommandCompletions(commandName, argumentPrefix)\n\t\t: Promise.resolve(null);\n}\n\n/** Subscribe to engine-child command catalog changes. No-op when not isolated. */\nexport function onInteractiveEngineRemoteCommandsChanged(\n\truntime: AgentSessionRuntime,\n\tlistener: (commands: readonly RpcSlashCommand[]) => void,\n): () => void {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.onRemoteCommandsChanged(listener) : () => {};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"extension-ui-bridge.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/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,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7F,CAAC;AAED,MAAM,UAAU,4CAA4C,CAC3D,OAA4B,EAC5B,QAA+D;IAE/D,OAAO,OAAO,YAAY,0BAA0B,CAAC,CAAC,CAAC,OAAO,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;AACjH,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,4CAA4C,CAC3D,OAA4B,EAC5B,WAAmB,EACnB,cAAsB;IAEtB,OAAO,OAAO,YAAY,0BAA0B;QACnD,CAAC,CAAC,OAAO,CAAC,2BAA2B,CAAC,WAAW,EAAE,cAAc,CAAC;QAClE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,wCAAwC,CACvD,OAA4B,EAC5B,QAAwD;IAExD,OAAO,OAAO,YAAY,0BAA0B,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;AAC7G,CAAC","sourcesContent":["import { type KeyId, matchesKey } from \"@earendil-works/pi-tui\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport type { ResourceOverlap } from \"../../core/diagnostics.ts\";\nimport type { ExtensionUIContext } from \"../../core/extensions/index.js\";\nimport type { KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { RpcAutocompleteItem, RpcResourceExtension, RpcSlashCommand } from \"../rpc/rpc-types.ts\";\nimport type { ActivityWatchdogDiagnostic } from \"./activity-watchdog.ts\";\nimport { EngineDialogHostController } from \"./engine-dialog-host.ts\";\nimport { InputFormHostController } from \"./input-form-host.ts\";\nimport { IsolatedInteractiveRuntime } from \"./isolated-runtime.js\";\nimport type { EngineExtensionShortcut, EngineKeybindingState, InteractiveEngineMessage } from \"./protocol.ts\";\nimport { RemoteComponentController, type TuiRendererLifecycle } from \"./remote-component.ts\";\nimport { registerRemoteProxyOwnership } from \"./remote-input-ownership.ts\";\nimport { SessionPickerHostController } from \"./session-picker-host.ts\";\n\ninterface EngineMessageSource {\n\tonEngineMessage(listener: (message: InteractiveEngineMessage) => void): () => void;\n\tonKeybindingState?(listener: (state: EngineKeybindingState) => void): () => void;\n}\n\nexport function attachInteractiveEngineKeybindingSync(\n\truntime: EngineMessageSource,\n\tkeybindings: KeybindingsManager,\n\tonState?: (state: EngineKeybindingState) => void,\n): () => void {\n\tconst applyState = (state: EngineKeybindingState): void => {\n\t\tkeybindings.setUserBindings(state.userBindings);\n\t\tonState?.(state);\n\t};\n\tif (runtime.onKeybindingState) return runtime.onKeybindingState(applyState);\n\treturn runtime.onEngineMessage((message) => {\n\t\tif (message.type === \"engine_keybindings_reloaded\") applyState(message.state);\n\t});\n}\n\nexport function attachInteractiveEngineHost(\n\truntime: AgentSessionRuntime,\n\tui: ExtensionUIContext,\n\tonDiagnostic: (diagnostic: ActivityWatchdogDiagnostic) => void,\n\ttuiRendererLifecycle: TuiRendererLifecycle,\n\tsetShortcutHandler?: (handler: (data: string) => boolean) => undefined | (() => void),\n\tkeybindings?: KeybindingsManager,\n): () => void {\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return () => {};\n\tconst disposeDiagnostic = runtime.onDiagnostic(onDiagnostic);\n\t// Generation-owned: RPC dialogs mount real host components and must not\n\t// outlive, or answer through, a replacement engine child.\n\tconst dialogs = new EngineDialogHostController(runtime, ui);\n\tlet shortcuts: EngineExtensionShortcut[] = [];\n\tconst dispatchShortcut = (data: string): boolean => {\n\t\tconst shortcut = shortcuts.find(\n\t\t\t({ key, editorKeys }) =>\n\t\t\t\tmatchesKey(data, key as KeyId) && !editorKeys?.some((editorKey) => matchesKey(data, editorKey)),\n\t\t);\n\t\tif (!shortcut) return false;\n\t\tvoid runtime\n\t\t\t.invokeRemoteShortcut(shortcut.key)\n\t\t\t.catch((error: Error) =>\n\t\t\t\tonDiagnostic({ activity: undefined, elapsedMs: 0, level: \"unresponsive\", message: error.message }),\n\t\t\t);\n\t\treturn true;\n\t};\n\tlet disposeShortcutHandler: (() => void) | undefined;\n\tconst installShortcutHandler = (): void => {\n\t\tdisposeShortcutHandler?.();\n\t\tconst dispose = setShortcutHandler?.(dispatchShortcut);\n\t\tdisposeShortcutHandler = typeof dispose === \"function\" ? dispose : undefined;\n\t};\n\tconst applyState = (state: EngineKeybindingState): void => {\n\t\tshortcuts = [...state.shortcuts];\n\t\tinstallShortcutHandler();\n\t};\n\tinstallShortcutHandler();\n\tconst disposeKeybindings = keybindings\n\t\t? attachInteractiveEngineKeybindingSync(runtime, keybindings, applyState)\n\t\t: runtime.onEngineMessage((message) => {\n\t\t\t\tif (message.type === \"engine_keybindings_reloaded\") applyState(message.state);\n\t\t\t});\n\tconst remoteComponents = new RemoteComponentController(runtime, ui, tuiRendererLifecycle);\n\t// Ctrl+C must reach the host while a remote proxy owns input, so publish the\n\t// only component that can answer that question exactly.\n\tconst disposeOwnership = registerRemoteProxyOwnership(runtime, remoteComponents);\n\tconst sessionPicker = new SessionPickerHostController(runtime, ui);\n\tconst inputForm = new InputFormHostController(runtime, ui);\n\tlet disposed = false;\n\treturn () => {\n\t\tif (disposed) return;\n\t\tdisposed = true;\n\t\tdisposeShortcutHandler?.();\n\t\tdisposeKeybindings();\n\t\tdisposeOwnership();\n\t\tremoteComponents.dispose();\n\t\tsessionPicker.dispose();\n\t\tinputForm.dispose();\n\t\tdialogs.dispose();\n\t\tdisposeDiagnostic();\n\t};\n}\n\n/** Route host-owned trust waits to the runner that actually owns the subscribers. */\nexport function withHostProjectTrustPrompt<T>(\n\truntime: AgentSessionRuntime,\n\tkind: \"select\" | \"confirm\" | \"input\",\n\ttitle: string,\n\trun: () => Promise<T>,\n): Promise<T> {\n\treturn runtime instanceof IsolatedInteractiveRuntime\n\t\t? runtime.withProjectTrustPrompt(kind, title, run)\n\t\t: runtime.session.extensionRunner.withProjectTrustPrompt(kind, title, run);\n}\n\nexport async function waitForInteractiveEngineBound(runtime: AgentSessionRuntime): Promise<void> {\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return;\n\tawait runtime.waitUntilBound();\n\tawait runtime.initializeFromEngine();\n}\n\nexport function interruptBlockedInteractiveEngine(runtime: AgentSessionRuntime): boolean {\n\treturn runtime instanceof IsolatedInteractiveRuntime && runtime.interruptBlockedCallback();\n}\n\n/**\n * True when the interactive engine still owes a cooperative abort or the\n * heartbeat watchdog has declared it unresponsive, i.e. when the explicit\n * Ctrl+C escape hatch promised by the watchdog copy applies.\n */\nexport function interactiveEngineNeedsExplicitTermination(runtime: AgentSessionRuntime): boolean {\n\treturn runtime instanceof IsolatedInteractiveRuntime && runtime.needsExplicitTermination();\n}\n\n/**\n * Explicitly terminate an unresponsive interactive engine and start recovery.\n * Only ever reached from a deliberate user action (Ctrl+C) — never from Escape.\n */\nexport function terminateInteractiveEngine(runtime: AgentSessionRuntime): boolean {\n\tif (!interactiveEngineNeedsExplicitTermination(runtime)) return false;\n\tvoid (runtime as IsolatedInteractiveRuntime).terminateAndRecover();\n\treturn true;\n}\n\n/**\n * Command catalog the engine child exposes to the isolated host. Returns an\n * empty list for non-isolated runtimes so callers can merge unconditionally.\n */\nexport function getInteractiveEngineRemoteCommands(runtime: AgentSessionRuntime): readonly RpcSlashCommand[] {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getRemoteCommands() : [];\n}\n\nexport function getInteractiveEngineResourceOverlaps(runtime: AgentSessionRuntime): readonly ResourceOverlap[] {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getResourceOverlaps() : [];\n}\n\nexport function getInteractiveEngineResourceExtensions(runtime: AgentSessionRuntime): readonly RpcResourceExtension[] {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.getResourceExtensions() : [];\n}\n\nexport function onInteractiveEngineResourceExtensionsChanged(\n\truntime: AgentSessionRuntime,\n\tlistener: (extensions: readonly RpcResourceExtension[]) => void,\n): () => void {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.onResourceExtensionsChanged(listener) : () => {};\n}\n\n/** Evaluate an engine-child command's live argument completions. */\nexport function getInteractiveEngineRemoteCommandCompletions(\n\truntime: AgentSessionRuntime,\n\tcommandName: string,\n\targumentPrefix: string,\n): Promise<RpcAutocompleteItem[] | null> {\n\treturn runtime instanceof IsolatedInteractiveRuntime\n\t\t? runtime.getRemoteCommandCompletions(commandName, argumentPrefix)\n\t\t: Promise.resolve(null);\n}\n\n/** Subscribe to engine-child command catalog changes. No-op when not isolated. */\nexport function onInteractiveEngineRemoteCommandsChanged(\n\truntime: AgentSessionRuntime,\n\tlistener: (commands: readonly RpcSlashCommand[]) => void,\n): () => void {\n\treturn runtime instanceof IsolatedInteractiveRuntime ? runtime.onRemoteCommandsChanged(listener) : () => {};\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CallbackActivity } from "../../core/callback-activity.ts";
|
|
2
|
-
import type { HostInputFormField, HostSessionPickerRow } from "../../core/extensions/ui-types.ts";
|
|
2
|
+
import type { HostInputFormField, HostSessionPickerRow, WidgetScrollRequest, WidgetScrollState } from "../../core/extensions/ui-types.ts";
|
|
3
3
|
import type { KeyId } from "../../core/keybindings.ts";
|
|
4
4
|
/**
|
|
5
5
|
* Version 4 separates minimal session binding from optional resource readiness.
|
|
@@ -42,6 +42,8 @@ export type EngineTerminalControl = {
|
|
|
42
42
|
export interface EngineExtensionShortcut {
|
|
43
43
|
key: string;
|
|
44
44
|
description?: string;
|
|
45
|
+
/** Editor-owned input exclusions resolved in the engine and matched by the host. */
|
|
46
|
+
editorKeys?: KeyId[];
|
|
45
47
|
}
|
|
46
48
|
export type SerializableKeybindingsConfig = Record<string, KeyId | KeyId[]>;
|
|
47
49
|
export interface EngineKeybindingState {
|
|
@@ -96,6 +98,10 @@ export type InteractiveEngineMessage = {
|
|
|
96
98
|
overlayOptions?: SerializableOverlayOptions;
|
|
97
99
|
widgetKey?: string;
|
|
98
100
|
widgetPlacement?: "aboveEditor" | "belowEditor";
|
|
101
|
+
widgetScroll?: {
|
|
102
|
+
maxHeight: number;
|
|
103
|
+
maxHeightFraction?: number;
|
|
104
|
+
};
|
|
99
105
|
} | {
|
|
100
106
|
type: "engine_custom_close";
|
|
101
107
|
componentId: string;
|
|
@@ -104,6 +110,7 @@ export type InteractiveEngineMessage = {
|
|
|
104
110
|
componentId: string;
|
|
105
111
|
requestId: number;
|
|
106
112
|
lines: string[];
|
|
113
|
+
scrollRequest?: WidgetScrollRequest;
|
|
107
114
|
} | {
|
|
108
115
|
type: "engine_custom_input_result";
|
|
109
116
|
componentId: string;
|
|
@@ -170,6 +177,10 @@ export type InteractiveEngineCommand = {
|
|
|
170
177
|
componentId: string;
|
|
171
178
|
requestId: number;
|
|
172
179
|
data: string;
|
|
180
|
+
} | {
|
|
181
|
+
type: "engine_custom_scroll";
|
|
182
|
+
componentId: string;
|
|
183
|
+
state: WidgetScrollState;
|
|
173
184
|
} | {
|
|
174
185
|
type: "engine_custom_dispose";
|
|
175
186
|
componentId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAwB,MAAM,iCAAiC,CAAC;AAC9F,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAwB,MAAM,iCAAiC,CAAC;AAC9F,OAAO,KAAK,EACX,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEvD;;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;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAY7D,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,IAAI,SAAS,CAIhG;AA+KD,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS,CAgKhG;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS,CA2GhG;AAED,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,wBAAwB,GAAG,wBAAwB,GAAG,MAAM,CAEpH;AAED,eAAO,MAAM,iCAAiC,wCAAkC,CAAC"}
|
|
@@ -156,11 +156,14 @@ function parseKeybindingState(value) {
|
|
|
156
156
|
for (const shortcut of value.shortcuts) {
|
|
157
157
|
if (!isJsonObject(shortcut) ||
|
|
158
158
|
typeof shortcut.key !== "string" ||
|
|
159
|
-
(shortcut.description !== undefined && typeof shortcut.description !== "string")
|
|
159
|
+
(shortcut.description !== undefined && typeof shortcut.description !== "string") ||
|
|
160
|
+
(shortcut.editorKeys !== undefined &&
|
|
161
|
+
(!Array.isArray(shortcut.editorKeys) || shortcut.editorKeys.some((key) => typeof key !== "string"))))
|
|
160
162
|
return undefined;
|
|
161
163
|
shortcuts.push({
|
|
162
164
|
key: shortcut.key,
|
|
163
165
|
...(typeof shortcut.description === "string" ? { description: shortcut.description } : {}),
|
|
166
|
+
...(Array.isArray(shortcut.editorKeys) ? { editorKeys: shortcut.editorKeys } : {}),
|
|
164
167
|
});
|
|
165
168
|
}
|
|
166
169
|
return { userBindings, effectiveBindings, shortcuts };
|
|
@@ -219,6 +222,16 @@ export function parseInteractiveEngineMessage(line) {
|
|
|
219
222
|
? value.overlayOptions
|
|
220
223
|
: undefined,
|
|
221
224
|
widgetKey: typeof value.widgetKey === "string" ? value.widgetKey : undefined,
|
|
225
|
+
...(isJsonObject(value.widgetScroll) && typeof value.widgetScroll.maxHeight === "number"
|
|
226
|
+
? {
|
|
227
|
+
widgetScroll: {
|
|
228
|
+
maxHeight: value.widgetScroll.maxHeight,
|
|
229
|
+
...(typeof value.widgetScroll.maxHeightFraction === "number"
|
|
230
|
+
? { maxHeightFraction: value.widgetScroll.maxHeightFraction }
|
|
231
|
+
: {}),
|
|
232
|
+
},
|
|
233
|
+
}
|
|
234
|
+
: {}),
|
|
222
235
|
widgetPlacement: value.widgetPlacement === "belowEditor"
|
|
223
236
|
? "belowEditor"
|
|
224
237
|
: value.widgetPlacement === "aboveEditor"
|
|
@@ -235,7 +248,22 @@ export function parseInteractiveEngineMessage(line) {
|
|
|
235
248
|
typeof value.requestId === "number" &&
|
|
236
249
|
Array.isArray(value.lines) &&
|
|
237
250
|
value.lines.every((entry) => typeof entry === "string")
|
|
238
|
-
? {
|
|
251
|
+
? {
|
|
252
|
+
type: value.type,
|
|
253
|
+
componentId: value.componentId,
|
|
254
|
+
requestId: value.requestId,
|
|
255
|
+
lines: value.lines,
|
|
256
|
+
...(isJsonObject(value.scrollRequest) &&
|
|
257
|
+
typeof value.scrollRequest.version === "number" &&
|
|
258
|
+
typeof value.scrollRequest.scrollTop === "number"
|
|
259
|
+
? {
|
|
260
|
+
scrollRequest: {
|
|
261
|
+
version: value.scrollRequest.version,
|
|
262
|
+
scrollTop: value.scrollRequest.scrollTop,
|
|
263
|
+
},
|
|
264
|
+
}
|
|
265
|
+
: {}),
|
|
266
|
+
}
|
|
239
267
|
: undefined;
|
|
240
268
|
case "engine_custom_input_result":
|
|
241
269
|
return typeof value.componentId === "string" &&
|
|
@@ -322,6 +350,21 @@ export function parseInteractiveEngineCommand(line) {
|
|
|
322
350
|
typeof value.title === "string") {
|
|
323
351
|
return { type: value.type, componentId: value.componentId, kind: value.kind, title: value.title };
|
|
324
352
|
}
|
|
353
|
+
if (value.type === "engine_custom_scroll" &&
|
|
354
|
+
isJsonObject(value.state) &&
|
|
355
|
+
typeof value.state.scrollTop === "number" &&
|
|
356
|
+
typeof value.state.viewportHeight === "number" &&
|
|
357
|
+
typeof value.state.contentHeight === "number") {
|
|
358
|
+
return {
|
|
359
|
+
type: value.type,
|
|
360
|
+
componentId: value.componentId,
|
|
361
|
+
state: {
|
|
362
|
+
scrollTop: value.state.scrollTop,
|
|
363
|
+
viewportHeight: value.state.viewportHeight,
|
|
364
|
+
contentHeight: value.state.contentHeight,
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
}
|
|
325
368
|
if (value.type === "engine_custom_render" &&
|
|
326
369
|
typeof value.requestId === "number" &&
|
|
327
370
|
typeof value.width === "number" &&
|