@di-code/coding-agent 0.1.9 → 0.2.2
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/README.md +7 -0
- package/compositions/base.yml +3 -0
- package/dist/compositions.d.ts.map +1 -1
- package/dist/compositions.js +2 -0
- package/dist/compositions.js.map +1 -1
- package/dist/core/image-input.d.ts +1 -1
- package/dist/core/image-input.d.ts.map +1 -1
- package/dist/core/image-input.js +15 -4
- package/dist/core/image-input.js.map +1 -1
- package/dist/core/session/session-manager.d.ts +18 -1
- package/dist/core/session/session-manager.d.ts.map +1 -1
- package/dist/core/session/session-manager.js +90 -1
- package/dist/core/session/session-manager.js.map +1 -1
- package/dist/core/session/session-storage.d.ts +2 -0
- package/dist/core/session/session-storage.d.ts.map +1 -1
- package/dist/core/session/session-storage.js +34 -2
- package/dist/core/session/session-storage.js.map +1 -1
- package/dist/core/session/types.d.ts +16 -1
- package/dist/core/session/types.d.ts.map +1 -1
- package/dist/core/session/types.js.map +1 -1
- package/dist/core/session.d.ts +27 -2
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +59 -0
- package/dist/core/session.js.map +1 -1
- package/dist/entry.js +1 -1
- package/dist/entry.js.map +1 -1
- package/dist/i18n.js +4 -4
- package/dist/i18n.js.map +1 -1
- package/dist/interactive-host-entry.d.ts.map +1 -1
- package/dist/interactive-host-entry.js +107 -12
- package/dist/interactive-host-entry.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +8 -1
- package/dist/main.js.map +1 -1
- package/dist/mcp/config.d.ts.map +1 -1
- package/dist/mcp/config.js +19 -0
- package/dist/mcp/config.js.map +1 -1
- package/dist/mcp-command-entry.d.ts +8 -0
- package/dist/mcp-command-entry.d.ts.map +1 -0
- package/dist/mcp-command-entry.js +56 -0
- package/dist/mcp-command-entry.js.map +1 -0
- package/dist/modes/interactive-components.d.ts +8 -0
- package/dist/modes/interactive-components.d.ts.map +1 -1
- package/dist/modes/interactive-components.js +7 -2
- package/dist/modes/interactive-components.js.map +1 -1
- package/dist/modes/interactive-state.d.ts.map +1 -1
- package/dist/modes/interactive-state.js +1 -4
- package/dist/modes/interactive-state.js.map +1 -1
- package/dist/modes/interactive.d.ts +4 -0
- package/dist/modes/interactive.d.ts.map +1 -1
- package/dist/modes/interactive.js +69 -0
- package/dist/modes/interactive.js.map +1 -1
- package/dist/modes/tree-selector.d.ts.map +1 -1
- package/dist/modes/tree-selector.js +5 -4
- package/dist/modes/tree-selector.js.map +1 -1
- package/dist/rpc/client.d.ts +2 -0
- package/dist/rpc/client.d.ts.map +1 -1
- package/dist/rpc/client.js +3 -0
- package/dist/rpc/client.js.map +1 -1
- package/dist/rpc/dispatcher.d.ts +14 -0
- package/dist/rpc/dispatcher.d.ts.map +1 -1
- package/dist/rpc/dispatcher.js +222 -7
- package/dist/rpc/dispatcher.js.map +1 -1
- package/dist/rpc/protocol.d.ts +12 -5
- package/dist/rpc/protocol.d.ts.map +1 -1
- package/dist/rpc/protocol.js +56 -0
- package/dist/rpc/protocol.js.map +1 -1
- package/dist/rpc/server.d.ts +5 -0
- package/dist/rpc/server.d.ts.map +1 -1
- package/dist/rpc/server.js +4 -0
- package/dist/rpc/server.js.map +1 -1
- package/dist/rpc-server-entry.d.ts.map +1 -1
- package/dist/rpc-server-entry.js +15 -1
- package/dist/rpc-server-entry.js.map +1 -1
- package/dist/runtime/product-host.d.ts +7 -0
- package/dist/runtime/product-host.d.ts.map +1 -1
- package/dist/runtime/product-host.js +29 -9
- package/dist/runtime/product-host.js.map +1 -1
- package/dist/runtime/session-factory.d.ts +18 -2
- package/dist/runtime/session-factory.d.ts.map +1 -1
- package/dist/runtime/session-factory.js +286 -23
- package/dist/runtime/session-factory.js.map +1 -1
- package/dist/runtime/session-host.d.ts +46 -1
- package/dist/runtime/session-host.d.ts.map +1 -1
- package/dist/runtime/session-host.js +38 -6
- package/dist/runtime/session-host.js.map +1 -1
- package/dist/ui-host.d.ts.map +1 -1
- package/dist/ui-host.js +3 -0
- package/dist/ui-host.js.map +1 -1
- package/dist/web/assets/index-C2SOU925.css +1 -0
- package/dist/web/assets/index-knXkInvO.js +41 -0
- package/dist/web/assets/index-knXkInvO.js.map +1 -0
- package/dist/web/index.html +2 -2
- package/dist/web-command.d.ts.map +1 -1
- package/dist/web-command.js +8 -1
- package/dist/web-command.js.map +1 -1
- package/dist/webui-entry.js +9 -1
- package/dist/webui-entry.js.map +1 -1
- package/dist/webui.d.ts +10 -0
- package/dist/webui.d.ts.map +1 -1
- package/dist/webui.js +21 -0
- package/dist/webui.js.map +1 -1
- package/package.json +11 -9
- package/dist/web/assets/index-BwfuGMvv.css +0 -1
- package/dist/web/assets/index-DPUaJqFJ.js +0 -41
- package/dist/web/assets/index-DPUaJqFJ.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-state.js","sourceRoot":"","sources":["../../src/modes/interactive-state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAa,MAAM,4BAA4B,CAAC;AA0CzE,SAAS,MAAM,CAAC,OAAgB;IAE/B,OAAO,OAAO,CAAC,OAAO;SACpB,MAAM,CAAC,CAAC,OAAO,EAAwB,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC;SAClE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;SAC9B,IAAI,CAAC,EAAE,CAAC,CAAC;AACZ,CAAC;AAED,MAAM,OAAO,qBAAqB;IAChB,QAAQ,GAAa,EAAE,CAAC;IACxB,YAAY,GAAyB,EAAE,CAAC;IACxC,kBAAkB,GAAG,IAAI,GAAG,EAA+B,CAAC;IAC5D,YAAY,GAA6B,EAAE,CAAC;IAC5C,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAChD,YAAY,GAAG,CAAC,CAAC;IACjB,aAAa,GAAG,EAAE,CAAC;IACnB,IAAI,GAAG,KAAK,CAAC;IACb,K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,CAAC,IAAI,KAAK,QAAQ;QAC9B,CAAC,KAAK,CAAC,gBAAgB,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,gBAAgB,KAAK,QAAQ,CAAC,CACpF,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAgB,EAAE,cAAuC;IACnF,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAClD,OAAO,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,UAAU,EAAE,CAAC;AACrE,CAAC","sourcesContent":["import type { Message } from \"@di-code/ai\";\nimport type { AgentSessionEvent, SessionUsage } from \"../core/session.ts\";\nimport { computeEditsDiff, type Edit } from \"../core/tools/edit-diff.ts\";\n\nexport type InteractiveMessage =\n\t| { readonly role: \"user\" | \"assistant\"; readonly text: string }\n\t| {\n\t\t\treadonly role: \"file_change\";\n\t\t\treadonly id: string;\n\t\t\treadonly path: string;\n\t\t\treadonly kind: \"edit\" | \"write\";\n\t\t\treadonly removed: readonly string[];\n\t\t\treadonly added: readonly string[];\n\t\t\treadonly diff?: string;\n\t\t\treadonly firstChangedLine?: number;\n\t };\n\ntype FileChangeCandidate = Extract<InteractiveMessage, { role: \"file_change\" }>;\n\nexport type InteractiveProcessItem =\n\t| { readonly type: \"thinking\"; readonly id: \"thinking\" }\n\t| {\n\t\t\treadonly type: \"tool\";\n\t\t\treadonly id: string;\n\t\t\treadonly command: string;\n\t\t\treadonly status: \"running\" | \"done\" | \"error\";\n\t };\n\nexport interface InteractiveState {\n\treadonly messages: readonly string[];\n\treadonly messageItems: readonly InteractiveMessage[];\n\treadonly processItems: readonly InteractiveProcessItem[];\n\treadonly spinnerFrame: number;\n\treadonly streamingText: string;\n\treadonly toolStatus: readonly string[];\n\treadonly busy: boolean;\n\treadonly error?: string;\n\treadonly queue: readonly string[];\n\treadonly status?: string;\n\treadonly compacting: boolean;\n\treadonly retrying: boolean;\n\treadonly usage: SessionUsage;\n}\n\nfunction textOf(message: Message): string {\n\ttype TextBlock = Extract<Message[\"content\"][number], { type: \"text\" }>;\n\treturn message.content\n\t\t.filter((content): content is TextBlock => content.type === \"text\")\n\t\t.map((content) => content.text)\n\t\t.join(\"\");\n}\n\nexport class InteractiveProjection {\n\tprivate readonly messages: string[] = [];\n\tprivate readonly messageItems: InteractiveMessage[] = [];\n\tprivate readonly pendingFileChanges = new Map<string, FileChangeCandidate>();\n\tprivate readonly processItems: InteractiveProcessItem[] = [];\n\tprivate readonly toolStatus = new Map<string, string>();\n\tprivate spinnerFrame = 0;\n\tprivate streamingText = \"\";\n\tprivate busy = false;\n\tprivate error: string | undefined;\n\tprivate queue: string[] = [];\n\tprivate status: string | undefined;\n\tprivate compacting = false;\n\tprivate retrying = false;\n\tprivate previewRoot: string | undefined;\n\tprivate previewChange: (() => void) | undefined;\n\tprivate usage: SessionUsage = {\n\t\trequestCount: 0,\n\t\tinputTokens: 0,\n\t\toutputTokens: 0,\n\t\tcacheReadTokens: 0,\n\t\tcacheWriteTokens: 0,\n\t\ttotalTokens: 0,\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t\testimatedContextTokens: 0,\n\t\tcontextWindow: 0,\n\t\treserveTokens: 0,\n\t\ttriggerTokens: 0,\n\t};\n\n\tget state(): InteractiveState {\n\t\tconst visibleMessageItems = [...this.messageItems, ...this.pendingFileChanges.values()];\n\t\treturn {\n\t\t\tmessages: [...this.messages],\n\t\t\tmessageItems: visibleMessageItems.map((message) =>\n\t\t\t\tmessage.role === \"file_change\"\n\t\t\t\t\t? { ...message, removed: [...message.removed], added: [...message.added] }\n\t\t\t\t\t: { ...message },\n\t\t\t),\n\t\t\tprocessItems: this.processItems.map((item) => ({ ...item })),\n\t\t\tspinnerFrame: this.spinnerFrame,\n\t\t\tstreamingText: this.streamingText,\n\t\t\ttoolStatus: [...this.toolStatus.values()],\n\t\t\tbusy: this.busy,\n\t\t\terror: this.error,\n\t\t\tqueue: [...this.queue],\n\t\t\tstatus: this.status,\n\t\t\tcompacting: this.compacting,\n\t\t\tretrying: this.retrying,\n\t\t\tusage: { ...this.usage, cost: { ...this.usage.cost } },\n\t\t};\n\t}\n\n\tsetError(message: string | undefined): void {\n\t\tthis.error = message;\n\t}\n\n\tclearVisibleMessages(): void {\n\t\tthis.messages.length = 0;\n\t\tthis.messageItems.length = 0;\n\t\tthis.pendingFileChanges.clear();\n\t\tthis.streamingText = \"\";\n\t\tthis.processItems.length = 0;\n\t\tthis.toolStatus.clear();\n\t\tthis.error = undefined;\n\t}\n\n\tsetQueue(queue: readonly string[]): void {\n\t\tthis.queue = [...queue];\n\t}\n\n\tsetStatus(status: string | undefined): void {\n\t\tthis.status = status;\n\t}\n\n\tsetCompacting(value: boolean): void {\n\t\tthis.compacting = value;\n\t}\n\n\tsetRetrying(value: boolean): void {\n\t\tthis.retrying = value;\n\t}\n\n\tsetUsage(usage: SessionUsage): void {\n\t\tthis.usage = structuredClone(usage);\n\t}\n\n\tconfigureFilePreview(root: string, onChange: () => void): void {\n\t\tthis.previewRoot = root;\n\t\tthis.previewChange = onChange;\n\t}\n\n\tadvanceSpinner(): boolean {\n\t\tif (!this.busy) return false;\n\t\tthis.spinnerFrame = (this.spinnerFrame + 1) % 4;\n\t\treturn true;\n\t}\n\n\tclearTransientProcess(): void {\n\t\tthis.processItems.length = 0;\n\t\tthis.toolStatus.clear();\n\t\tthis.spinnerFrame = 0;\n\t}\n\n\treplaceTranscript(messages: readonly Message[]): void {\n\t\tthis.messages.length = 0;\n\t\tthis.messageItems.length = 0;\n\t\tthis.pendingFileChanges.clear();\n\t\tthis.processItems.length = 0;\n\t\tthis.toolStatus.clear();\n\t\tthis.spinnerFrame = 0;\n\t\tthis.streamingText = \"\";\n\t\tthis.busy = false;\n\t\tthis.error = undefined;\n\t\tfor (const message of messages) this.appendCompletedMessage(message);\n\t}\n\n\tapply(event: AgentSessionEvent): void {\n\t\tswitch (event.type) {\n\t\t\tcase \"agent_start\":\n\t\t\t\tthis.busy = true;\n\t\t\t\tthis.error = undefined;\n\t\t\t\tthis.retrying = false;\n\t\t\t\tthis.processItems.length = 0;\n\t\t\t\tthis.processItems.push({ type: \"thinking\", id: \"thinking\" });\n\t\t\t\tthis.toolStatus.clear();\n\t\t\t\tthis.spinnerFrame = 0;\n\t\t\t\treturn;\n\t\t\tcase \"compaction_start\":\n\t\t\t\tthis.compacting = true;\n\t\t\t\treturn;\n\t\t\tcase \"compaction_end\":\n\t\t\t\tthis.compacting = false;\n\t\t\t\tif (!event.success) this.error = event.errorMessage;\n\t\t\t\treturn;\n\t\t\tcase \"usage_update\":\n\t\t\t\tthis.setUsage(event.usage);\n\t\t\t\treturn;\n\t\t\tcase \"queue_update\":\n\t\t\tcase \"tree_navigated\":\n\t\t\t\treturn;\n\t\t\tcase \"message_start\":\n\t\t\t\tif (event.message.role === \"assistant\") this.streamingText = \"\";\n\t\t\t\treturn;\n\t\t\tcase \"message_update\":\n\t\t\t\tif (event.event.type === \"text_delta\") {\n\t\t\t\t\tif (event.event.delta.length > 0) this.removeThinking();\n\t\t\t\t\tthis.streamingText += event.event.delta;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"tool_execution_start\":\n\t\t\t\tthis.removeThinking();\n\t\t\t\tthis.processItems.push({\n\t\t\t\t\ttype: \"tool\",\n\t\t\t\t\tid: event.toolCallId,\n\t\t\t\t\tcommand: formatToolCommand(event.toolName, event.arguments),\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t});\n\t\t\t\tthis.toolStatus.set(event.toolCallId, `${event.toolName}: running`);\n\t\t\t\tthis.storeFileChange(event.toolCallId, event.toolName, event.arguments);\n\t\t\t\treturn;\n\t\t\tcase \"tool_execution_end\":\n\t\t\t\tthis.updateToolStatus(event.toolCallId, event.result.isError ? \"error\" : \"done\");\n\t\t\t\tthis.toolStatus.set(event.toolCallId, `${event.toolName}: ${event.result.isError ? \"error\" : \"done\"}`);\n\t\t\t\tthis.commitFileChange(event.toolCallId, event.result.isError, event.result.details);\n\t\t\t\treturn;\n\t\t\tcase \"message_end\":\n\t\t\t\tthis.appendCompletedMessage(event.message);\n\t\t\t\treturn;\n\t\t\tcase \"agent_end\":\n\t\t\t\tthis.busy = false;\n\t\t\t\tthis.retrying = false;\n\t\t\t\tthis.pendingFileChanges.clear();\n\t\t\t\tthis.processItems.length = 0;\n\t\t\t\tthis.toolStatus.clear();\n\t\t\t\tthis.spinnerFrame = 0;\n\t\t\t\treturn;\n\t\t\tcase \"turn_start\":\n\t\t\t\tif (this.busy && !this.processItems.some((item) => item.type === \"thinking\")) {\n\t\t\t\t\tthis.processItems.push({ type: \"thinking\", id: \"thinking\" });\n\t\t\t\t\tthis.spinnerFrame = 0;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"turn_end\":\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate removeThinking(): void {\n\t\tconst index = this.processItems.findIndex((item) => item.type === \"thinking\");\n\t\tif (index >= 0) this.processItems.splice(index, 1);\n\t}\n\n\tprivate updateToolStatus(id: string, status: \"done\" | \"error\"): void {\n\t\tconst index = this.processItems.findIndex((item) => item.type === \"tool\" && item.id === id);\n\t\tconst item = this.processItems[index];\n\t\tif (index < 0 || item?.type !== \"tool\") return;\n\t\tthis.processItems[index] = { ...item, status };\n\t}\n\n\tprivate appendCompletedMessage(message: Message): void {\n\t\tif (message.role === \"tool_result\") {\n\t\t\tthis.commitFileChange(message.toolCallId, message.isError, message.details);\n\t\t\treturn;\n\t\t}\n\t\tconst text = textOf(message);\n\t\tif (message.role === \"user\") {\n\t\t\tif (text.length > 0) {\n\t\t\t\tthis.messages.push(text);\n\t\t\t\tthis.messageItems.push({ role: \"user\", text });\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (text.length > 0 && message.stopReason !== \"tool_use\") {\n\t\t\tthis.messages.push(text);\n\t\t\tthis.messageItems.push({ role: \"assistant\", text });\n\t\t}\n\t\tfor (const content of message.content) {\n\t\t\tif (content.type === \"tool_call\") this.storeFileChange(content.id, content.name, content.arguments);\n\t\t}\n\t\tif (message.stopReason === \"error\") this.error = message.errorMessage;\n\t\tthis.streamingText = \"\";\n\t}\n\n\tprivate storeFileChange(id: string, toolName: string, argumentsValue: Record<string, unknown>): void {\n\t\tconst path = argumentsValue.path;\n\t\tif (typeof path !== \"string\") return;\n\t\tif (toolName === \"edit\") {\n\t\t\tconst edits = parseEditArguments(argumentsValue);\n\t\t\tif (!edits) return;\n\t\t\tconst fallback = edits.flatMap((edit) => ({\n\t\t\t\tremoved: edit.oldText.replaceAll(\"\\r\\n\", \"\\n\").split(\"\\n\"),\n\t\t\t\tadded: edit.newText.replaceAll(\"\\r\\n\", \"\\n\").split(\"\\n\"),\n\t\t\t}));\n\t\t\tthis.pendingFileChanges.set(id, {\n\t\t\t\trole: \"file_change\",\n\t\t\t\tid,\n\t\t\t\tpath,\n\t\t\t\tkind: \"edit\",\n\t\t\t\tremoved: fallback.flatMap((edit) => edit.removed),\n\t\t\t\tadded: fallback.flatMap((edit) => edit.added),\n\t\t\t});\n\t\t\tif (this.previewRoot) {\n\t\t\t\tvoid computeEditsDiff(path, edits, this.previewRoot).then((preview) => {\n\t\t\t\t\tconst current = this.pendingFileChanges.get(id);\n\t\t\t\t\tif (!current || \"error\" in preview) return;\n\t\t\t\t\tthis.pendingFileChanges.set(id, {\n\t\t\t\t\t\t...current,\n\t\t\t\t\t\tdiff: preview.diff,\n\t\t\t\t\t\tfirstChangedLine: preview.firstChangedLine,\n\t\t\t\t\t});\n\t\t\t\t\tthis.previewChange?.();\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tif (toolName === \"write\" && typeof argumentsValue.content === \"string\") {\n\t\t\tthis.pendingFileChanges.set(id, {\n\t\t\t\trole: \"file_change\",\n\t\t\t\tid,\n\t\t\t\tpath,\n\t\t\t\tkind: \"write\",\n\t\t\t\tremoved: [],\n\t\t\t\tadded: argumentsValue.content.replaceAll(\"\\r\\n\", \"\\n\").split(\"\\n\"),\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate commitFileChange(id: string, isError: boolean, details: unknown = undefined): void {\n\t\tconst change = this.pendingFileChanges.get(id);\n\t\tthis.pendingFileChanges.delete(id);\n\t\tif (!change || isError) return;\n\t\tconst metadata = isEditDetails(details) ? details : undefined;\n\t\tthis.messageItems.push(\n\t\t\tmetadata ? { ...change, diff: metadata.diff, firstChangedLine: metadata.firstChangedLine } : change,\n\t\t);\n\t}\n}\n\nfunction parseEditArguments(argumentsValue: Record<string, unknown>): Edit[] | undefined {\n\tif (Array.isArray(argumentsValue.edits)) {\n\t\tconst edits: Edit[] = [];\n\t\tfor (const value of argumentsValue.edits) {\n\t\t\tif (!isRecord(value) || typeof value.oldText !== \"string\" || typeof value.newText !== \"string\") return undefined;\n\t\t\tedits.push({ oldText: value.oldText, newText: value.newText });\n\t\t}\n\t\treturn edits.length > 0 ? edits : undefined;\n\t}\n\treturn typeof argumentsValue.oldText === \"string\" && typeof argumentsValue.newText === \"string\"\n\t\t? [{ oldText: argumentsValue.oldText, newText: argumentsValue.newText }]\n\t\t: undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction isEditDetails(value: unknown): value is { diff: string; firstChangedLine?: number } {\n\treturn (\n\t\tisRecord(value) &&\n\t\ttypeof value.diff === \"string\" &&\n\t\t(value.firstChangedLine === undefined || typeof value.firstChangedLine === \"number\")\n\t);\n}\n\nfunction formatToolCommand(toolName: string, argumentsValue: Record<string, unknown>): string {\n\tconst serialized = JSON.stringify(argumentsValue);\n\treturn serialized === \"{}\" ? toolName : `${toolName} ${serialized}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interactive-state.js","sourceRoot":"","sources":["../../src/modes/interactive-state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAa,MAAM,4BAA4B,CAAC;AA0CzE,SAAS,MAAM,CA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CAAC;QACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7C,CAAC;IACD,OAAO,OAAO,cAAc,CAAC,OAAO,KAAK,QAAQ,IAAI,OAAO,cAAc,CAAC,OAAO,KAAK,QAAQ;QAC9F,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,CAAC,OAAO,EAAE,CAAC;QACxE,CAAC,CAAC,SAAS,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACpC,OAAO,CACN,QAAQ,CAAC,KAAK,CAAC;QACf,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,CAAC,KAAK,CAAC,gBAAgB,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,gBAAgB,KAAK,QAAQ,CAAC,CACpF,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAgB,EAAE,cAAuC;IACnF,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAClD,OAAO,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,UAAU,EAAE,CAAC;AACrE,CAAC","sourcesContent":["import type { Message } from \"@di-code/ai\";\nimport type { AgentSessionEvent, SessionUsage } from \"../core/session.ts\";\nimport { computeEditsDiff, type Edit } from \"../core/tools/edit-diff.ts\";\n\nexport type InteractiveMessage =\n\t| { readonly role: \"user\" | \"assistant\"; readonly text: string }\n\t| {\n\t\t\treadonly role: \"file_change\";\n\t\t\treadonly id: string;\n\t\t\treadonly path: string;\n\t\t\treadonly kind: \"edit\" | \"write\";\n\t\t\treadonly removed: readonly string[];\n\t\t\treadonly added: readonly string[];\n\t\t\treadonly diff?: string;\n\t\t\treadonly firstChangedLine?: number;\n\t };\n\ntype FileChangeCandidate = Extract<InteractiveMessage, { role: \"file_change\" }>;\n\nexport type InteractiveProcessItem =\n\t| { readonly type: \"thinking\"; readonly id: \"thinking\" }\n\t| {\n\t\t\treadonly type: \"tool\";\n\t\t\treadonly id: string;\n\t\t\treadonly command: string;\n\t\t\treadonly status: \"running\" | \"done\" | \"error\";\n\t };\n\nexport interface InteractiveState {\n\treadonly messages: readonly string[];\n\treadonly messageItems: readonly InteractiveMessage[];\n\treadonly processItems: readonly InteractiveProcessItem[];\n\treadonly spinnerFrame: number;\n\treadonly streamingText: string;\n\treadonly toolStatus: readonly string[];\n\treadonly busy: boolean;\n\treadonly error?: string;\n\treadonly queue: readonly string[];\n\treadonly status?: string;\n\treadonly compacting: boolean;\n\treadonly retrying: boolean;\n\treadonly usage: SessionUsage;\n}\n\nfunction textOf(message: Message): string {\n\treturn message.content.map((content) => (content.type === \"text\" ? content.text : \"\")).join(\"\");\n}\n\nexport class InteractiveProjection {\n\tprivate readonly messages: string[] = [];\n\tprivate readonly messageItems: InteractiveMessage[] = [];\n\tprivate readonly pendingFileChanges = new Map<string, FileChangeCandidate>();\n\tprivate readonly processItems: InteractiveProcessItem[] = [];\n\tprivate readonly toolStatus = new Map<string, string>();\n\tprivate spinnerFrame = 0;\n\tprivate streamingText = \"\";\n\tprivate busy = false;\n\tprivate error: string | undefined;\n\tprivate queue: string[] = [];\n\tprivate status: string | undefined;\n\tprivate compacting = false;\n\tprivate retrying = false;\n\tprivate previewRoot: string | undefined;\n\tprivate previewChange: (() => void) | undefined;\n\tprivate usage: SessionUsage = {\n\t\trequestCount: 0,\n\t\tinputTokens: 0,\n\t\toutputTokens: 0,\n\t\tcacheReadTokens: 0,\n\t\tcacheWriteTokens: 0,\n\t\ttotalTokens: 0,\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t\testimatedContextTokens: 0,\n\t\tcontextWindow: 0,\n\t\treserveTokens: 0,\n\t\ttriggerTokens: 0,\n\t};\n\n\tget state(): InteractiveState {\n\t\tconst visibleMessageItems = [...this.messageItems, ...this.pendingFileChanges.values()];\n\t\treturn {\n\t\t\tmessages: [...this.messages],\n\t\t\tmessageItems: visibleMessageItems.map((message) =>\n\t\t\t\tmessage.role === \"file_change\"\n\t\t\t\t\t? { ...message, removed: [...message.removed], added: [...message.added] }\n\t\t\t\t\t: { ...message },\n\t\t\t),\n\t\t\tprocessItems: this.processItems.map((item) => ({ ...item })),\n\t\t\tspinnerFrame: this.spinnerFrame,\n\t\t\tstreamingText: this.streamingText,\n\t\t\ttoolStatus: [...this.toolStatus.values()],\n\t\t\tbusy: this.busy,\n\t\t\terror: this.error,\n\t\t\tqueue: [...this.queue],\n\t\t\tstatus: this.status,\n\t\t\tcompacting: this.compacting,\n\t\t\tretrying: this.retrying,\n\t\t\tusage: { ...this.usage, cost: { ...this.usage.cost } },\n\t\t};\n\t}\n\n\tsetError(message: string | undefined): void {\n\t\tthis.error = message;\n\t}\n\n\tclearVisibleMessages(): void {\n\t\tthis.messages.length = 0;\n\t\tthis.messageItems.length = 0;\n\t\tthis.pendingFileChanges.clear();\n\t\tthis.streamingText = \"\";\n\t\tthis.processItems.length = 0;\n\t\tthis.toolStatus.clear();\n\t\tthis.error = undefined;\n\t}\n\n\tsetQueue(queue: readonly string[]): void {\n\t\tthis.queue = [...queue];\n\t}\n\n\tsetStatus(status: string | undefined): void {\n\t\tthis.status = status;\n\t}\n\n\tsetCompacting(value: boolean): void {\n\t\tthis.compacting = value;\n\t}\n\n\tsetRetrying(value: boolean): void {\n\t\tthis.retrying = value;\n\t}\n\n\tsetUsage(usage: SessionUsage): void {\n\t\tthis.usage = structuredClone(usage);\n\t}\n\n\tconfigureFilePreview(root: string, onChange: () => void): void {\n\t\tthis.previewRoot = root;\n\t\tthis.previewChange = onChange;\n\t}\n\n\tadvanceSpinner(): boolean {\n\t\tif (!this.busy) return false;\n\t\tthis.spinnerFrame = (this.spinnerFrame + 1) % 4;\n\t\treturn true;\n\t}\n\n\tclearTransientProcess(): void {\n\t\tthis.processItems.length = 0;\n\t\tthis.toolStatus.clear();\n\t\tthis.spinnerFrame = 0;\n\t}\n\n\treplaceTranscript(messages: readonly Message[]): void {\n\t\tthis.messages.length = 0;\n\t\tthis.messageItems.length = 0;\n\t\tthis.pendingFileChanges.clear();\n\t\tthis.processItems.length = 0;\n\t\tthis.toolStatus.clear();\n\t\tthis.spinnerFrame = 0;\n\t\tthis.streamingText = \"\";\n\t\tthis.busy = false;\n\t\tthis.error = undefined;\n\t\tfor (const message of messages) this.appendCompletedMessage(message);\n\t}\n\n\tapply(event: AgentSessionEvent): void {\n\t\tswitch (event.type) {\n\t\t\tcase \"agent_start\":\n\t\t\t\tthis.busy = true;\n\t\t\t\tthis.error = undefined;\n\t\t\t\tthis.retrying = false;\n\t\t\t\tthis.processItems.length = 0;\n\t\t\t\tthis.processItems.push({ type: \"thinking\", id: \"thinking\" });\n\t\t\t\tthis.toolStatus.clear();\n\t\t\t\tthis.spinnerFrame = 0;\n\t\t\t\treturn;\n\t\t\tcase \"compaction_start\":\n\t\t\t\tthis.compacting = true;\n\t\t\t\treturn;\n\t\t\tcase \"compaction_end\":\n\t\t\t\tthis.compacting = false;\n\t\t\t\tif (!event.success) this.error = event.errorMessage;\n\t\t\t\treturn;\n\t\t\tcase \"usage_update\":\n\t\t\t\tthis.setUsage(event.usage);\n\t\t\t\treturn;\n\t\t\tcase \"queue_update\":\n\t\t\tcase \"tree_navigated\":\n\t\t\t\treturn;\n\t\t\tcase \"message_start\":\n\t\t\t\tif (event.message.role === \"assistant\") this.streamingText = \"\";\n\t\t\t\treturn;\n\t\t\tcase \"message_update\":\n\t\t\t\tif (event.event.type === \"text_delta\") {\n\t\t\t\t\tif (event.event.delta.length > 0) this.removeThinking();\n\t\t\t\t\tthis.streamingText += event.event.delta;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"tool_execution_start\":\n\t\t\t\tthis.removeThinking();\n\t\t\t\tthis.processItems.push({\n\t\t\t\t\ttype: \"tool\",\n\t\t\t\t\tid: event.toolCallId,\n\t\t\t\t\tcommand: formatToolCommand(event.toolName, event.arguments),\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t});\n\t\t\t\tthis.toolStatus.set(event.toolCallId, `${event.toolName}: running`);\n\t\t\t\tthis.storeFileChange(event.toolCallId, event.toolName, event.arguments);\n\t\t\t\treturn;\n\t\t\tcase \"tool_execution_end\":\n\t\t\t\tthis.updateToolStatus(event.toolCallId, event.result.isError ? \"error\" : \"done\");\n\t\t\t\tthis.toolStatus.set(event.toolCallId, `${event.toolName}: ${event.result.isError ? \"error\" : \"done\"}`);\n\t\t\t\tthis.commitFileChange(event.toolCallId, event.result.isError, event.result.details);\n\t\t\t\treturn;\n\t\t\tcase \"message_end\":\n\t\t\t\tthis.appendCompletedMessage(event.message);\n\t\t\t\treturn;\n\t\t\tcase \"agent_end\":\n\t\t\t\tthis.busy = false;\n\t\t\t\tthis.retrying = false;\n\t\t\t\tthis.pendingFileChanges.clear();\n\t\t\t\tthis.processItems.length = 0;\n\t\t\t\tthis.toolStatus.clear();\n\t\t\t\tthis.spinnerFrame = 0;\n\t\t\t\treturn;\n\t\t\tcase \"turn_start\":\n\t\t\t\tif (this.busy && !this.processItems.some((item) => item.type === \"thinking\")) {\n\t\t\t\t\tthis.processItems.push({ type: \"thinking\", id: \"thinking\" });\n\t\t\t\t\tthis.spinnerFrame = 0;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"turn_end\":\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate removeThinking(): void {\n\t\tconst index = this.processItems.findIndex((item) => item.type === \"thinking\");\n\t\tif (index >= 0) this.processItems.splice(index, 1);\n\t}\n\n\tprivate updateToolStatus(id: string, status: \"done\" | \"error\"): void {\n\t\tconst index = this.processItems.findIndex((item) => item.type === \"tool\" && item.id === id);\n\t\tconst item = this.processItems[index];\n\t\tif (index < 0 || item?.type !== \"tool\") return;\n\t\tthis.processItems[index] = { ...item, status };\n\t}\n\n\tprivate appendCompletedMessage(message: Message): void {\n\t\tif (message.role === \"tool_result\") {\n\t\t\tthis.commitFileChange(message.toolCallId, message.isError, message.details);\n\t\t\treturn;\n\t\t}\n\t\tconst text = textOf(message);\n\t\tif (message.role === \"user\") {\n\t\t\tif (text.length > 0) {\n\t\t\t\tthis.messages.push(text);\n\t\t\t\tthis.messageItems.push({ role: \"user\", text });\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (text.length > 0 && message.stopReason !== \"tool_use\") {\n\t\t\tthis.messages.push(text);\n\t\t\tthis.messageItems.push({ role: \"assistant\", text });\n\t\t}\n\t\tfor (const content of message.content) {\n\t\t\tif (content.type === \"tool_call\") this.storeFileChange(content.id, content.name, content.arguments);\n\t\t}\n\t\tif (message.stopReason === \"error\") this.error = message.errorMessage;\n\t\tthis.streamingText = \"\";\n\t}\n\n\tprivate storeFileChange(id: string, toolName: string, argumentsValue: Record<string, unknown>): void {\n\t\tconst path = argumentsValue.path;\n\t\tif (typeof path !== \"string\") return;\n\t\tif (toolName === \"edit\") {\n\t\t\tconst edits = parseEditArguments(argumentsValue);\n\t\t\tif (!edits) return;\n\t\t\tconst fallback = edits.flatMap((edit) => ({\n\t\t\t\tremoved: edit.oldText.replaceAll(\"\\r\\n\", \"\\n\").split(\"\\n\"),\n\t\t\t\tadded: edit.newText.replaceAll(\"\\r\\n\", \"\\n\").split(\"\\n\"),\n\t\t\t}));\n\t\t\tthis.pendingFileChanges.set(id, {\n\t\t\t\trole: \"file_change\",\n\t\t\t\tid,\n\t\t\t\tpath,\n\t\t\t\tkind: \"edit\",\n\t\t\t\tremoved: fallback.flatMap((edit) => edit.removed),\n\t\t\t\tadded: fallback.flatMap((edit) => edit.added),\n\t\t\t});\n\t\t\tif (this.previewRoot) {\n\t\t\t\tvoid computeEditsDiff(path, edits, this.previewRoot).then((preview) => {\n\t\t\t\t\tconst current = this.pendingFileChanges.get(id);\n\t\t\t\t\tif (!current || \"error\" in preview) return;\n\t\t\t\t\tthis.pendingFileChanges.set(id, {\n\t\t\t\t\t\t...current,\n\t\t\t\t\t\tdiff: preview.diff,\n\t\t\t\t\t\tfirstChangedLine: preview.firstChangedLine,\n\t\t\t\t\t});\n\t\t\t\t\tthis.previewChange?.();\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tif (toolName === \"write\" && typeof argumentsValue.content === \"string\") {\n\t\t\tthis.pendingFileChanges.set(id, {\n\t\t\t\trole: \"file_change\",\n\t\t\t\tid,\n\t\t\t\tpath,\n\t\t\t\tkind: \"write\",\n\t\t\t\tremoved: [],\n\t\t\t\tadded: argumentsValue.content.replaceAll(\"\\r\\n\", \"\\n\").split(\"\\n\"),\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate commitFileChange(id: string, isError: boolean, details: unknown = undefined): void {\n\t\tconst change = this.pendingFileChanges.get(id);\n\t\tthis.pendingFileChanges.delete(id);\n\t\tif (!change || isError) return;\n\t\tconst metadata = isEditDetails(details) ? details : undefined;\n\t\tthis.messageItems.push(\n\t\t\tmetadata ? { ...change, diff: metadata.diff, firstChangedLine: metadata.firstChangedLine } : change,\n\t\t);\n\t}\n}\n\nfunction parseEditArguments(argumentsValue: Record<string, unknown>): Edit[] | undefined {\n\tif (Array.isArray(argumentsValue.edits)) {\n\t\tconst edits: Edit[] = [];\n\t\tfor (const value of argumentsValue.edits) {\n\t\t\tif (!isRecord(value) || typeof value.oldText !== \"string\" || typeof value.newText !== \"string\") return undefined;\n\t\t\tedits.push({ oldText: value.oldText, newText: value.newText });\n\t\t}\n\t\treturn edits.length > 0 ? edits : undefined;\n\t}\n\treturn typeof argumentsValue.oldText === \"string\" && typeof argumentsValue.newText === \"string\"\n\t\t? [{ oldText: argumentsValue.oldText, newText: argumentsValue.newText }]\n\t\t: undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction isEditDetails(value: unknown): value is { diff: string; firstChangedLine?: number } {\n\treturn (\n\t\tisRecord(value) &&\n\t\ttypeof value.diff === \"string\" &&\n\t\t(value.firstChangedLine === undefined || typeof value.firstChangedLine === \"number\")\n\t);\n}\n\nfunction formatToolCommand(toolName: string, argumentsValue: Record<string, unknown>): string {\n\tconst serialized = JSON.stringify(argumentsValue);\n\treturn serialized === \"{}\" ? toolName : `${toolName} ${serialized}`;\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommandRegistry, InteractiveContextService } from "@di-code/builtins";
|
|
2
|
+
import type { UserInteractionInput, UserInteractionResult } from "@di-code/plugin-sdk";
|
|
2
3
|
import { type TUI } from "@di-code/tui";
|
|
3
4
|
import type { AgentSession, AgentSessionEvent } from "../core/session.ts";
|
|
4
5
|
import { type Locale } from "../i18n.ts";
|
|
@@ -68,6 +69,7 @@ export declare class InteractiveMode {
|
|
|
68
69
|
retryLastPrompt(): void;
|
|
69
70
|
private exit;
|
|
70
71
|
private handleCommand;
|
|
72
|
+
private togglePlanMode;
|
|
71
73
|
private attachClipboardImage;
|
|
72
74
|
private openThemeSelector;
|
|
73
75
|
private openModelSelector;
|
|
@@ -78,6 +80,8 @@ export declare class InteractiveMode {
|
|
|
78
80
|
private openSettingsSelector;
|
|
79
81
|
private showOverlay;
|
|
80
82
|
private closeOverlay;
|
|
83
|
+
/** Presents a structured choice for the host UserInteraction bridge. */
|
|
84
|
+
requestInteraction(input: UserInteractionInput, signal?: AbortSignal): Promise<UserInteractionResult>;
|
|
81
85
|
private updateAutocompleteOverlay;
|
|
82
86
|
private closeAutocompleteOverlay;
|
|
83
87
|
private refresh;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../../src/modes/interactive.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,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B;IA8B3B,OAAO,CAAC,gBAAgB;YA6CV,iBAAiB;YAsBjB,mBAAmB;IAmBjC,OAAO,CAAC,oBAAoB;IAgD5B,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,YAAY;IAKpB,wEAAwE;IAClE,kBAAkB,CAAC,KAAK,EAAE,oBAAoB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA6B3G,OAAO,CAAC,yBAAyB;IA2BjC,OAAO,CAAC,wBAAwB;IAKhC,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,kBAAkB;YAoBZ,aAAa;YAkCb,MAAM;YAyEN,cAAc;IA+C5B,OAAO,CAAC,YAAY;YAON,iCAAiC;YAOjC,qBAAqB;IAMnC,OAAO,CAAC,kBAAkB;IAqB1B,OAAO,CAAC,oBAAoB;IAwE5B,OAAO,CAAC,iBAAiB;YAoCX,cAAc;IA4B5B,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,WAAW;YAQL,mBAAmB;CAqBjC"}
|
|
@@ -31,6 +31,7 @@ function builtinSlashCommands(locale) {
|
|
|
31
31
|
{ name: "usage", description: t("showUsage") },
|
|
32
32
|
{ name: "retry", description: t("retryPrompt") },
|
|
33
33
|
{ name: "steer", description: t("steerAgent") },
|
|
34
|
+
{ name: "plan", description: "Enter or leave plan mode" },
|
|
34
35
|
];
|
|
35
36
|
}
|
|
36
37
|
function asImageAttachmentReference(pasted, cwd) {
|
|
@@ -165,6 +166,7 @@ export class InteractiveMode {
|
|
|
165
166
|
theme: this.theme,
|
|
166
167
|
locale: this.locale,
|
|
167
168
|
pasteImageShortcut: PASTE_IMAGE_SHORTCUT,
|
|
169
|
+
planMode: this.session.planMode?.(),
|
|
168
170
|
});
|
|
169
171
|
this.root = new InteractiveLayout({
|
|
170
172
|
header: new InteractiveHeader(readViewState),
|
|
@@ -230,6 +232,10 @@ export class InteractiveMode {
|
|
|
230
232
|
}
|
|
231
233
|
handleCommand(data) {
|
|
232
234
|
this.context?.keybindings();
|
|
235
|
+
if (matchesKey(data, Key.alt("p"))) {
|
|
236
|
+
void this.togglePlanMode();
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
233
239
|
if (matchesKey(data, Key.alt("s"))) {
|
|
234
240
|
void this.submitSteering(this.editor.getValue());
|
|
235
241
|
return true;
|
|
@@ -277,6 +283,23 @@ export class InteractiveMode {
|
|
|
277
283
|
}
|
|
278
284
|
return false;
|
|
279
285
|
}
|
|
286
|
+
async togglePlanMode() {
|
|
287
|
+
const planSession = this.session;
|
|
288
|
+
if (!planSession.planCommand || !planSession.planMode) {
|
|
289
|
+
this.projection.setError("Plan mode is unavailable in this session.");
|
|
290
|
+
this.refresh();
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
try {
|
|
294
|
+
const projection = planSession.planMode();
|
|
295
|
+
const message = await planSession.planCommand(projection?.active ? "off" : "");
|
|
296
|
+
this.projection.setStatus(message);
|
|
297
|
+
}
|
|
298
|
+
catch (cause) {
|
|
299
|
+
this.projection.setError(cause instanceof Error ? cause.message : String(cause));
|
|
300
|
+
}
|
|
301
|
+
this.refresh();
|
|
302
|
+
}
|
|
280
303
|
async attachClipboardImage() {
|
|
281
304
|
try {
|
|
282
305
|
const path = await this.readClipboardImagePath(this.clipboardDirectory);
|
|
@@ -506,6 +529,33 @@ export class InteractiveMode {
|
|
|
506
529
|
this.overlay?.hide();
|
|
507
530
|
this.overlay = undefined;
|
|
508
531
|
}
|
|
532
|
+
/** Presents a structured choice for the host UserInteraction bridge. */
|
|
533
|
+
async requestInteraction(input, signal) {
|
|
534
|
+
const options = input.options ?? [];
|
|
535
|
+
if (options.length === 0)
|
|
536
|
+
return { requestId: input.requestId, toolCallId: input.toolCallId, status: "cancelled" };
|
|
537
|
+
return await new Promise((resolve) => {
|
|
538
|
+
let settled = false;
|
|
539
|
+
const finish = (result) => {
|
|
540
|
+
if (settled)
|
|
541
|
+
return;
|
|
542
|
+
settled = true;
|
|
543
|
+
signal?.removeEventListener("abort", abort);
|
|
544
|
+
this.closeOverlay();
|
|
545
|
+
resolve(result);
|
|
546
|
+
};
|
|
547
|
+
const abort = () => finish({ requestId: input.requestId, toolCallId: input.toolCallId, status: "cancelled" });
|
|
548
|
+
const list = new SelectList(options.map((option) => ({ value: option.value, label: option.label, description: input.prompt })));
|
|
549
|
+
list.onSelect = (item) => finish({ requestId: input.requestId, toolCallId: input.toolCallId, status: "answered", value: item.value });
|
|
550
|
+
list.onCancel = abort;
|
|
551
|
+
if (signal?.aborted) {
|
|
552
|
+
abort();
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
556
|
+
this.showOverlay(list, true);
|
|
557
|
+
});
|
|
558
|
+
}
|
|
509
559
|
updateAutocompleteOverlay() {
|
|
510
560
|
this.closeAutocompleteOverlay();
|
|
511
561
|
if (!this.editor.isShowingAutocomplete()) {
|
|
@@ -801,6 +851,25 @@ export class InteractiveMode {
|
|
|
801
851
|
else
|
|
802
852
|
this.projection.setStatus(translate(this.locale, "nothingToRetry"));
|
|
803
853
|
break;
|
|
854
|
+
case "plan":
|
|
855
|
+
{
|
|
856
|
+
const planSession = this.session;
|
|
857
|
+
if (!planSession.planCommand || !planSession.planMode) {
|
|
858
|
+
this.projection.setError("Plan mode is unavailable in this session.");
|
|
859
|
+
break;
|
|
860
|
+
}
|
|
861
|
+
void planSession
|
|
862
|
+
.planCommand(_args)
|
|
863
|
+
.then((message) => {
|
|
864
|
+
this.projection.setStatus(`${message}${planSession.planMode?.()?.active ? " [plan]" : ""}`);
|
|
865
|
+
this.refresh();
|
|
866
|
+
})
|
|
867
|
+
.catch((cause) => {
|
|
868
|
+
this.projection.setError(cause instanceof Error ? cause.message : String(cause));
|
|
869
|
+
this.refresh();
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
return 0;
|
|
804
873
|
default:
|
|
805
874
|
this.projection.setError(`Unknown command: /${command}`);
|
|
806
875
|
}
|