@di-code/coding-agent 0.1.6 → 0.1.8
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 +112 -68
- package/compositions/base.yml +54 -0
- package/compositions/interactive.yml +14 -0
- package/compositions/json.yml +6 -0
- package/compositions/print.yml +5 -0
- package/compositions/rpc.yml +12 -0
- package/compositions/webui.yml +9 -0
- package/dist/cli.d.ts +22 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +97 -3
- package/dist/cli.js.map +1 -1
- package/dist/composition-loader-entry.d.ts +11 -0
- package/dist/composition-loader-entry.d.ts.map +1 -0
- package/dist/composition-loader-entry.js +12 -0
- package/dist/composition-loader-entry.js.map +1 -0
- package/dist/compositions.d.ts +32 -0
- package/dist/compositions.d.ts.map +1 -0
- package/dist/compositions.js +173 -0
- package/dist/compositions.js.map +1 -0
- package/dist/core/session/session-manager.d.ts +9 -2
- package/dist/core/session/session-manager.d.ts.map +1 -1
- package/dist/core/session/session-manager.js +28 -0
- package/dist/core/session/session-manager.js.map +1 -1
- package/dist/core/session/session-storage.d.ts.map +1 -1
- package/dist/core/session/session-storage.js +20 -3
- package/dist/core/session/session-storage.js.map +1 -1
- package/dist/core/session/types.d.ts +11 -2
- package/dist/core/session/types.d.ts.map +1 -1
- package/dist/core/session/types.js.map +1 -1
- package/dist/core/session-tools.d.ts +5 -0
- package/dist/core/session-tools.d.ts.map +1 -0
- package/dist/core/session-tools.js +17 -0
- package/dist/core/session-tools.js.map +1 -0
- package/dist/core/session.d.ts +21 -7
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +77 -41
- package/dist/core/session.js.map +1 -1
- package/dist/core/tools/bash.d.ts +1 -38
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +1 -207
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +1 -24
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +1 -135
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +1 -26
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +1 -140
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js +1 -23
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/file-search.d.ts +1 -13
- package/dist/core/tools/file-search.d.ts.map +1 -1
- package/dist/core/tools/file-search.js +1 -98
- package/dist/core/tools/file-search.js.map +1 -1
- package/dist/core/tools/glob.d.ts +1 -10
- package/dist/core/tools/glob.d.ts.map +1 -1
- package/dist/core/tools/glob.js +1 -43
- package/dist/core/tools/glob.js.map +1 -1
- package/dist/core/tools/grep.d.ts +1 -12
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +1 -66
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/load-skill.d.ts +1 -9
- package/dist/core/tools/load-skill.d.ts.map +1 -1
- package/dist/core/tools/load-skill.js +1 -21
- package/dist/core/tools/load-skill.js.map +1 -1
- package/dist/core/tools/path-boundary.d.ts +1 -4
- package/dist/core/tools/path-boundary.d.ts.map +1 -1
- package/dist/core/tools/path-boundary.js +1 -65
- package/dist/core/tools/path-boundary.js.map +1 -1
- package/dist/core/tools/read.d.ts +1 -16
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -131
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts +1 -16
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +1 -44
- package/dist/core/tools/write.js.map +1 -1
- package/dist/entry.js +30 -28
- package/dist/entry.js.map +1 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +2 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/interactive/builtin.d.ts +17 -0
- package/dist/interactive/builtin.d.ts.map +1 -0
- package/dist/interactive/builtin.js +47 -0
- package/dist/interactive/builtin.js.map +1 -0
- package/dist/interactive/controller.d.ts +85 -0
- package/dist/interactive/controller.d.ts.map +1 -0
- package/dist/interactive/controller.js +211 -0
- package/dist/interactive/controller.js.map +1 -0
- package/dist/interactive/index.d.ts +3 -0
- package/dist/interactive/index.d.ts.map +1 -0
- package/dist/interactive/index.js +3 -0
- package/dist/interactive/index.js.map +1 -0
- package/dist/interactive-host-entry.d.ts +7 -0
- package/dist/interactive-host-entry.d.ts.map +1 -0
- package/dist/interactive-host-entry.js +123 -0
- package/dist/interactive-host-entry.js.map +1 -0
- package/dist/interactive-profile.d.ts +18 -0
- package/dist/interactive-profile.d.ts.map +1 -0
- package/dist/interactive-profile.js +290 -0
- package/dist/interactive-profile.js.map +1 -0
- package/dist/interactive-resources-entry.d.ts +7 -0
- package/dist/interactive-resources-entry.d.ts.map +1 -0
- package/dist/interactive-resources-entry.js +42 -0
- package/dist/interactive-resources-entry.js.map +1 -0
- package/dist/legacy-main.d.ts +39 -0
- package/dist/legacy-main.d.ts.map +1 -0
- package/dist/legacy-main.js +611 -0
- package/dist/legacy-main.js.map +1 -0
- package/dist/main.d.ts +15 -34
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +130 -513
- package/dist/main.js.map +1 -1
- package/dist/mcp/entries.d.ts +42 -0
- package/dist/mcp/entries.d.ts.map +1 -0
- package/dist/mcp/entries.js +98 -0
- package/dist/mcp/entries.js.map +1 -0
- package/dist/mcp-client-entry.d.ts +5 -0
- package/dist/mcp-client-entry.d.ts.map +1 -0
- package/dist/mcp-client-entry.js +6 -0
- package/dist/mcp-client-entry.js.map +1 -0
- package/dist/mcp-config-entry.d.ts +5 -0
- package/dist/mcp-config-entry.d.ts.map +1 -0
- package/dist/mcp-config-entry.js +6 -0
- package/dist/mcp-config-entry.js.map +1 -0
- package/dist/mcp-tools-entry.d.ts +5 -0
- package/dist/mcp-tools-entry.d.ts.map +1 -0
- package/dist/mcp-tools-entry.js +6 -0
- package/dist/mcp-tools-entry.js.map +1 -0
- package/dist/mcp-transport-entry.d.ts +5 -0
- package/dist/mcp-transport-entry.d.ts.map +1 -0
- package/dist/mcp-transport-entry.js +6 -0
- package/dist/mcp-transport-entry.js.map +1 -0
- package/dist/modes/interactive-entry.d.ts +18 -0
- package/dist/modes/interactive-entry.d.ts.map +1 -0
- package/dist/modes/interactive-entry.js +21 -0
- package/dist/modes/interactive-entry.js.map +1 -0
- package/dist/modes/interactive-state.js +1 -1
- package/dist/modes/interactive-state.js.map +1 -1
- package/dist/modes/interactive.d.ts +16 -6
- package/dist/modes/interactive.d.ts.map +1 -1
- package/dist/modes/interactive.js +99 -33
- package/dist/modes/interactive.js.map +1 -1
- package/dist/modes/json-entry.d.ts +13 -0
- package/dist/modes/json-entry.d.ts.map +1 -0
- package/dist/modes/json-entry.js +14 -0
- package/dist/modes/json-entry.js.map +1 -0
- package/dist/modes/json.d.ts +4 -1
- package/dist/modes/json.d.ts.map +1 -1
- package/dist/modes/json.js +3 -3
- package/dist/modes/json.js.map +1 -1
- package/dist/modes/print-entry.d.ts +10 -0
- package/dist/modes/print-entry.d.ts.map +1 -0
- package/dist/modes/print-entry.js +11 -0
- package/dist/modes/print-entry.js.map +1 -0
- package/dist/modes/tree-selector.d.ts.map +1 -1
- package/dist/modes/tree-selector.js +4 -0
- package/dist/modes/tree-selector.js.map +1 -1
- package/dist/plugin-dump-composition.d.ts +6 -0
- package/dist/plugin-dump-composition.d.ts.map +1 -0
- package/dist/plugin-dump-composition.js +7 -0
- package/dist/plugin-dump-composition.js.map +1 -0
- package/dist/plugin-inventory.d.ts +7 -0
- package/dist/plugin-inventory.d.ts.map +1 -0
- package/dist/plugin-inventory.js +8 -0
- package/dist/plugin-inventory.js.map +1 -0
- package/dist/plugin-manager.d.ts +6 -0
- package/dist/plugin-manager.d.ts.map +1 -0
- package/dist/plugin-manager.js +7 -0
- package/dist/plugin-manager.js.map +1 -0
- package/dist/plugin-trace.d.ts +6 -0
- package/dist/plugin-trace.d.ts.map +1 -0
- package/dist/plugin-trace.js +7 -0
- package/dist/plugin-trace.js.map +1 -0
- package/dist/plugins/dynamic-broker.d.ts +76 -0
- package/dist/plugins/dynamic-broker.d.ts.map +1 -0
- package/dist/plugins/dynamic-broker.js +852 -0
- package/dist/plugins/dynamic-broker.js.map +1 -0
- package/dist/plugins/profile.d.ts +15 -0
- package/dist/plugins/profile.d.ts.map +1 -0
- package/dist/plugins/profile.js +34 -0
- package/dist/plugins/profile.js.map +1 -0
- package/dist/plugins/runtime-host.d.ts +37 -0
- package/dist/plugins/runtime-host.d.ts.map +1 -0
- package/dist/plugins/runtime-host.js +95 -0
- package/dist/plugins/runtime-host.js.map +1 -0
- package/dist/plugins/trust.d.ts +8 -0
- package/dist/plugins/trust.d.ts.map +1 -0
- package/dist/plugins/trust.js +59 -0
- package/dist/plugins/trust.js.map +1 -0
- package/dist/project-trust-entry.d.ts +15 -0
- package/dist/project-trust-entry.d.ts.map +1 -0
- package/dist/project-trust-entry.js +15 -0
- package/dist/project-trust-entry.js.map +1 -0
- package/dist/rpc/client.d.ts +78 -6
- package/dist/rpc/client.d.ts.map +1 -1
- package/dist/rpc/client.js +172 -4
- package/dist/rpc/client.js.map +1 -1
- package/dist/rpc/dispatcher.d.ts +121 -0
- package/dist/rpc/dispatcher.d.ts.map +1 -0
- package/dist/rpc/dispatcher.js +994 -0
- package/dist/rpc/dispatcher.js.map +1 -0
- package/dist/rpc/index.d.ts +2 -0
- package/dist/rpc/index.d.ts.map +1 -1
- package/dist/rpc/index.js +2 -0
- package/dist/rpc/index.js.map +1 -1
- package/dist/rpc/lifecycle.d.ts +6 -0
- package/dist/rpc/lifecycle.d.ts.map +1 -0
- package/dist/rpc/lifecycle.js +24 -0
- package/dist/rpc/lifecycle.js.map +1 -0
- package/dist/rpc/protocol.d.ts +112 -31
- package/dist/rpc/protocol.d.ts.map +1 -1
- package/dist/rpc/protocol.js +569 -117
- package/dist/rpc/protocol.js.map +1 -1
- package/dist/rpc/server-service.d.ts +7 -0
- package/dist/rpc/server-service.d.ts.map +1 -0
- package/dist/rpc/server-service.js +3 -0
- package/dist/rpc/server-service.js.map +1 -0
- package/dist/rpc/server.d.ts +16 -19
- package/dist/rpc/server.d.ts.map +1 -1
- package/dist/rpc/server.js +59 -115
- package/dist/rpc/server.js.map +1 -1
- package/dist/rpc-client-sdk-entry.d.ts +12 -0
- package/dist/rpc-client-sdk-entry.d.ts.map +1 -0
- package/dist/rpc-client-sdk-entry.js +11 -0
- package/dist/rpc-client-sdk-entry.js.map +1 -0
- package/dist/rpc-entry.js +50 -18
- package/dist/rpc-entry.js.map +1 -1
- package/dist/rpc-server-entry.d.ts +8 -0
- package/dist/rpc-server-entry.d.ts.map +1 -0
- package/dist/rpc-server-entry.js +67 -0
- package/dist/rpc-server-entry.js.map +1 -0
- package/dist/runtime/attachment-store.d.ts +13 -0
- package/dist/runtime/attachment-store.d.ts.map +1 -0
- package/dist/runtime/attachment-store.js +93 -0
- package/dist/runtime/attachment-store.js.map +1 -0
- package/dist/runtime/bootstrap.d.ts +14 -0
- package/dist/runtime/bootstrap.d.ts.map +1 -0
- package/dist/runtime/bootstrap.js +29 -0
- package/dist/runtime/bootstrap.js.map +1 -0
- package/dist/runtime/interactive-host-service.d.ts +22 -0
- package/dist/runtime/interactive-host-service.d.ts.map +1 -0
- package/dist/runtime/interactive-host-service.js +2 -0
- package/dist/runtime/interactive-host-service.js.map +1 -0
- package/dist/runtime/interactive-resource-service.d.ts +11 -0
- package/dist/runtime/interactive-resource-service.d.ts.map +1 -0
- package/dist/runtime/interactive-resource-service.js +3 -0
- package/dist/runtime/interactive-resource-service.js.map +1 -0
- package/dist/runtime/plugin-inventory-entry.d.ts +5 -0
- package/dist/runtime/plugin-inventory-entry.d.ts.map +1 -0
- package/dist/runtime/plugin-inventory-entry.js +18 -0
- package/dist/runtime/plugin-inventory-entry.js.map +1 -0
- package/dist/runtime/plugin-inventory-service.d.ts +8 -0
- package/dist/runtime/plugin-inventory-service.d.ts.map +1 -0
- package/dist/runtime/plugin-inventory-service.js +3 -0
- package/dist/runtime/plugin-inventory-service.js.map +1 -0
- package/dist/runtime/plugin-manager-entry.d.ts +20 -0
- package/dist/runtime/plugin-manager-entry.d.ts.map +1 -0
- package/dist/runtime/plugin-manager-entry.js +96 -0
- package/dist/runtime/plugin-manager-entry.js.map +1 -0
- package/dist/runtime/plugin-observability-entry.d.ts +12 -0
- package/dist/runtime/plugin-observability-entry.d.ts.map +1 -0
- package/dist/runtime/plugin-observability-entry.js +73 -0
- package/dist/runtime/plugin-observability-entry.js.map +1 -0
- package/dist/runtime/product-host.d.ts +91 -0
- package/dist/runtime/product-host.d.ts.map +1 -0
- package/dist/runtime/product-host.js +529 -0
- package/dist/runtime/product-host.js.map +1 -0
- package/dist/runtime/session-factory.d.ts +17 -0
- package/dist/runtime/session-factory.d.ts.map +1 -0
- package/dist/runtime/session-factory.js +75 -0
- package/dist/runtime/session-factory.js.map +1 -0
- package/dist/runtime/session-host.d.ts +152 -0
- package/dist/runtime/session-host.d.ts.map +1 -0
- package/dist/runtime/session-host.js +895 -0
- package/dist/runtime/session-host.js.map +1 -0
- package/dist/runtime-core-entry.d.ts +11 -0
- package/dist/runtime-core-entry.d.ts.map +1 -0
- package/dist/runtime-core-entry.js +9 -0
- package/dist/runtime-core-entry.js.map +1 -0
- package/dist/session-factory-entry.d.ts +7 -0
- package/dist/session-factory-entry.d.ts.map +1 -0
- package/dist/session-factory-entry.js +9 -0
- package/dist/session-factory-entry.js.map +1 -0
- package/dist/session-store-jsonl-entry.d.ts +7 -0
- package/dist/session-store-jsonl-entry.d.ts.map +1 -0
- package/dist/session-store-jsonl-entry.js +33 -0
- package/dist/session-store-jsonl-entry.js.map +1 -0
- package/dist/startup.d.ts +21 -1
- package/dist/startup.d.ts.map +1 -1
- package/dist/startup.js +179 -10
- package/dist/startup.js.map +1 -1
- package/dist/subagents/index.d.ts +2 -0
- package/dist/subagents/index.d.ts.map +1 -0
- package/dist/subagents/index.js +2 -0
- package/dist/subagents/index.js.map +1 -0
- package/dist/subagents/service.d.ts +50 -0
- package/dist/subagents/service.d.ts.map +1 -0
- package/dist/subagents/service.js +521 -0
- package/dist/subagents/service.js.map +1 -0
- package/dist/ui-host.d.ts +125 -0
- package/dist/ui-host.d.ts.map +1 -0
- package/dist/ui-host.js +275 -0
- package/dist/ui-host.js.map +1 -0
- package/dist/web/assets/index-BwfuGMvv.css +1 -0
- package/dist/web/assets/index-DPUaJqFJ.js +41 -0
- package/dist/web/assets/index-DPUaJqFJ.js.map +1 -0
- package/dist/web/index.html +14 -0
- package/dist/web-command.d.ts +11 -0
- package/dist/web-command.d.ts.map +1 -0
- package/dist/web-command.js +114 -0
- package/dist/web-command.js.map +1 -0
- package/dist/web-frontend.d.ts +73 -0
- package/dist/web-frontend.d.ts.map +1 -0
- package/dist/web-frontend.js +249 -0
- package/dist/web-frontend.js.map +1 -0
- package/dist/web.d.ts +254 -0
- package/dist/web.d.ts.map +1 -0
- package/dist/web.js +740 -0
- package/dist/web.js.map +1 -0
- package/dist/webui-entry.d.ts +3 -0
- package/dist/webui-entry.d.ts.map +1 -0
- package/dist/webui-entry.js +73 -0
- package/dist/webui-entry.js.map +1 -0
- package/dist/webui.d.ts +91 -0
- package/dist/webui.d.ts.map +1 -0
- package/dist/webui.js +882 -0
- package/dist/webui.js.map +1 -0
- package/package.json +89 -8
|
@@ -1,29 +1,34 @@
|
|
|
1
|
+
import type { CommandRegistry, InteractiveContextService } from "@di-code/builtins";
|
|
1
2
|
import { type TUI } from "@di-code/tui";
|
|
2
3
|
import type { AgentSession, AgentSessionEvent } from "../core/session.ts";
|
|
3
|
-
import type { ExtensionHost } from "../extensions/runtime.ts";
|
|
4
4
|
import { type Locale } from "../i18n.ts";
|
|
5
5
|
import { type InteractiveProviderOnboardingOptions } from "../provider-onboarding.ts";
|
|
6
|
+
import type { SessionHostUi } from "../runtime/session-host.ts";
|
|
6
7
|
export type { AgentSessionEvent };
|
|
7
8
|
export type { InteractiveMessage, InteractiveProcessItem, InteractiveState } from "./interactive-state.ts";
|
|
8
9
|
export { InteractiveProjection } from "./interactive-state.ts";
|
|
9
10
|
export interface InteractiveModeOptions {
|
|
10
|
-
readonly session:
|
|
11
|
+
readonly session: InteractiveSessionHandle;
|
|
11
12
|
readonly tui: TUI;
|
|
12
13
|
readonly onExit?: () => void;
|
|
13
14
|
readonly sessions?: readonly InteractiveSessionChoice[];
|
|
14
|
-
readonly extensionHost?: ExtensionHost;
|
|
15
15
|
readonly providerOnboarding?: Omit<InteractiveProviderOnboardingOptions, "tui">;
|
|
16
16
|
/** User data directory that owns clipboard image temporaries. */
|
|
17
17
|
readonly agentDir?: string;
|
|
18
18
|
readonly readClipboardImagePath?: (directory?: string) => Promise<string | null>;
|
|
19
19
|
readonly locale?: Locale;
|
|
20
|
+
/** Command contributions are resolved through the composition registry. */
|
|
21
|
+
readonly commandRegistry?: CommandRegistry;
|
|
22
|
+
/** Session controls and preferences are supplied by the active Context. */
|
|
23
|
+
readonly context?: InteractiveContextService;
|
|
20
24
|
}
|
|
21
25
|
export interface InteractiveSessionChoice {
|
|
22
26
|
readonly id: string;
|
|
23
27
|
readonly label: string;
|
|
24
28
|
readonly description?: string;
|
|
25
|
-
open():
|
|
29
|
+
open(): InteractiveSessionHandle | Promise<InteractiveSessionHandle>;
|
|
26
30
|
}
|
|
31
|
+
export type InteractiveSessionHandle = AgentSession | SessionHostUi;
|
|
27
32
|
export declare class InteractiveMode {
|
|
28
33
|
private readonly projection;
|
|
29
34
|
private readonly root;
|
|
@@ -31,7 +36,6 @@ export declare class InteractiveMode {
|
|
|
31
36
|
private session;
|
|
32
37
|
private readonly tui;
|
|
33
38
|
private readonly sessionChoices;
|
|
34
|
-
private readonly extensionHost?;
|
|
35
39
|
private readonly providerOnboarding?;
|
|
36
40
|
private readonly agentDir;
|
|
37
41
|
private readonly readClipboardImagePath;
|
|
@@ -51,12 +55,17 @@ export declare class InteractiveMode {
|
|
|
51
55
|
private overlay?;
|
|
52
56
|
private autocompleteOverlay?;
|
|
53
57
|
private spinnerTimer?;
|
|
54
|
-
private shutdownEmitted;
|
|
55
58
|
private preserveClipboardFiles;
|
|
56
59
|
private locale;
|
|
60
|
+
private readonly commandRegistry?;
|
|
61
|
+
private readonly context?;
|
|
57
62
|
constructor(options: InteractiveModeOptions);
|
|
58
63
|
start(initialPrompt?: string): void;
|
|
59
64
|
stop(): void;
|
|
65
|
+
/** Cancels the active prompt without changing Session history. */
|
|
66
|
+
cancelActivePrompt(): void;
|
|
67
|
+
/** Re-submits the last failed prompt when the mode is idle. */
|
|
68
|
+
retryLastPrompt(): void;
|
|
60
69
|
private exit;
|
|
61
70
|
private handleCommand;
|
|
62
71
|
private attachClipboardImage;
|
|
@@ -82,6 +91,7 @@ export declare class InteractiveMode {
|
|
|
82
91
|
private cleanupUnreferencedClipboardFiles;
|
|
83
92
|
private cleanupClipboardFiles;
|
|
84
93
|
private handleSlashCommand;
|
|
94
|
+
private runRegisteredCommand;
|
|
85
95
|
private openProviderLogin;
|
|
86
96
|
private logoutProvider;
|
|
87
97
|
private listSlashCommands;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../../src/modes/interactive.ts"],"names":[],"mappings":"AAGA,OAAO,EAWN,KAAK,GAAG,EACR,MAAM,cAAc,CAAC;AAStB,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../../src/modes/interactive.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,C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7
7
|
import { DEFAULT_LOCALE, translate } from "../i18n.js";
|
|
8
8
|
import { showInteractiveProviderOnboarding, } from "../provider-onboarding.js";
|
|
9
|
-
import { removeGlobalProviderApiKey, saveGlobalLocale } from "../startup.js";
|
|
9
|
+
import { removeGlobalProviderApiKey, saveGlobalLocale, saveGlobalModelSelection, saveGlobalThinkingLevel, } from "../startup.js";
|
|
10
10
|
import { AutocompleteMenu, InteractiveChat, InteractiveComposer, InteractiveFooter, InteractiveHeader, } from "./interactive-components.js";
|
|
11
11
|
import { InteractiveLayout } from "./interactive-layout.js";
|
|
12
12
|
import { InteractiveProjection } from "./interactive-state.js";
|
|
@@ -64,6 +64,16 @@ function steeringCommandArgument(prompt) {
|
|
|
64
64
|
const match = /^\/steer(?:\s+([\s\S]*))?$/i.exec(prompt);
|
|
65
65
|
return match ? (match[1] ?? "").trim() : undefined;
|
|
66
66
|
}
|
|
67
|
+
function isContextSessionChoice(value) {
|
|
68
|
+
return (typeof value === "object" &&
|
|
69
|
+
value !== null &&
|
|
70
|
+
"id" in value &&
|
|
71
|
+
typeof value.id === "string" &&
|
|
72
|
+
"label" in value &&
|
|
73
|
+
typeof value.label === "string" &&
|
|
74
|
+
"open" in value &&
|
|
75
|
+
typeof value.open === "function");
|
|
76
|
+
}
|
|
67
77
|
export class InteractiveMode {
|
|
68
78
|
projection = new InteractiveProjection();
|
|
69
79
|
root;
|
|
@@ -71,7 +81,6 @@ export class InteractiveMode {
|
|
|
71
81
|
session;
|
|
72
82
|
tui;
|
|
73
83
|
sessionChoices;
|
|
74
|
-
extensionHost;
|
|
75
84
|
providerOnboarding;
|
|
76
85
|
agentDir;
|
|
77
86
|
readClipboardImagePath;
|
|
@@ -91,19 +100,32 @@ export class InteractiveMode {
|
|
|
91
100
|
overlay;
|
|
92
101
|
autocompleteOverlay;
|
|
93
102
|
spinnerTimer;
|
|
94
|
-
shutdownEmitted = false;
|
|
95
103
|
preserveClipboardFiles = false;
|
|
96
104
|
locale;
|
|
105
|
+
commandRegistry;
|
|
106
|
+
context;
|
|
97
107
|
constructor(options) {
|
|
98
108
|
this.session = options.session;
|
|
99
109
|
this.projection.configureFilePreview(this.session.allowedRoot, () => this.refresh());
|
|
100
110
|
this.tui = options.tui;
|
|
101
111
|
this.onExit = options.onExit;
|
|
102
|
-
|
|
103
|
-
|
|
112
|
+
const contextChoices = (options.context?.sessionChoices() ?? []).filter(isContextSessionChoice).map((choice) => ({
|
|
113
|
+
...choice,
|
|
114
|
+
open: async () => {
|
|
115
|
+
const session = await choice.open();
|
|
116
|
+
if (typeof session !== "object" || session === null)
|
|
117
|
+
throw new Error(`Session choice ${choice.id} is invalid`);
|
|
118
|
+
return session;
|
|
119
|
+
},
|
|
120
|
+
}));
|
|
121
|
+
this.sessionChoices = [...(options.sessions ?? contextChoices)];
|
|
104
122
|
this.providerOnboarding = options.providerOnboarding;
|
|
105
123
|
this.agentDir = resolve(options.agentDir ?? join(homedir(), ".di-code"));
|
|
106
124
|
this.locale = options.locale ?? DEFAULT_LOCALE;
|
|
125
|
+
this.commandRegistry = options.commandRegistry;
|
|
126
|
+
this.context = options.context;
|
|
127
|
+
if (this.context?.theme() === "light")
|
|
128
|
+
this.theme = "light";
|
|
107
129
|
this.readClipboardImagePath = options.readClipboardImagePath ?? readClipboardImagePath;
|
|
108
130
|
this.clipboardDirectory = clipboardImageDirectory(this.agentDir, this.session.allowedRoot);
|
|
109
131
|
const autocomplete = {
|
|
@@ -113,9 +135,19 @@ export class InteractiveMode {
|
|
|
113
135
|
this.editor = new Editor({
|
|
114
136
|
maxHeight: 3,
|
|
115
137
|
autocomplete,
|
|
138
|
+
submitAutocomplete: (context) => /^\/[^\s/]*$/.test(context.text.slice(0, context.cursor)),
|
|
116
139
|
});
|
|
117
140
|
this.editor.onSubmit = (text) => void this.submit(text);
|
|
118
|
-
this.editor.onEscape = () =>
|
|
141
|
+
this.editor.onEscape = () => {
|
|
142
|
+
if (!this.activeAbort) {
|
|
143
|
+
this.context?.cancel();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.projection.setStatus(translate(this.locale, "cancelled"));
|
|
147
|
+
this.context?.cancel();
|
|
148
|
+
this.activeAbort.abort();
|
|
149
|
+
this.refresh();
|
|
150
|
+
};
|
|
119
151
|
this.editor.onCommand = (data) => this.handleCommand(data);
|
|
120
152
|
this.editor.onInterrupt = () => this.exit();
|
|
121
153
|
this.editor.onChange = () => {
|
|
@@ -148,8 +180,6 @@ export class InteractiveMode {
|
|
|
148
180
|
if (this.started)
|
|
149
181
|
throw new Error("Interactive mode is already started");
|
|
150
182
|
this.started = true;
|
|
151
|
-
this.shutdownEmitted = false;
|
|
152
|
-
void this.extensionHost?.emit({ type: "session_start", cwd: this.session.allowedRoot });
|
|
153
183
|
this.projection.replaceTranscript(this.session.transcript);
|
|
154
184
|
this.projection.setUsage(this.session.usage);
|
|
155
185
|
this.subscribeToSession();
|
|
@@ -184,16 +214,22 @@ export class InteractiveMode {
|
|
|
184
214
|
this.unsubscribeSession = undefined;
|
|
185
215
|
void this.cleanupClipboardFiles();
|
|
186
216
|
this.tui.stop({ finalLines: this.root.renderTranscript(this.tui.columns) });
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
217
|
+
}
|
|
218
|
+
/** Cancels the active prompt without changing Session history. */
|
|
219
|
+
cancelActivePrompt() {
|
|
220
|
+
this.activeAbort?.abort();
|
|
221
|
+
}
|
|
222
|
+
/** Re-submits the last failed prompt when the mode is idle. */
|
|
223
|
+
retryLastPrompt() {
|
|
224
|
+
if (this.lastFailedPrompt && !this.promptInFlight)
|
|
225
|
+
void this.submit(this.lastFailedPrompt, true);
|
|
191
226
|
}
|
|
192
227
|
exit() {
|
|
193
228
|
this.stop();
|
|
194
229
|
this.onExit?.();
|
|
195
230
|
}
|
|
196
231
|
handleCommand(data) {
|
|
232
|
+
this.context?.keybindings();
|
|
197
233
|
if (matchesKey(data, Key.alt("s"))) {
|
|
198
234
|
void this.submitSteering(this.editor.getValue());
|
|
199
235
|
return true;
|
|
@@ -202,6 +238,12 @@ export class InteractiveMode {
|
|
|
202
238
|
try {
|
|
203
239
|
const level = this.session.cycleThinkingLevel();
|
|
204
240
|
this.projection.setStatus(level ? `thinking=${level}` : "Current model does not support thinking levels.");
|
|
241
|
+
if (level) {
|
|
242
|
+
void saveGlobalThinkingLevel(this.agentDir, this.session.providerId, this.session.modelId, level).catch((cause) => {
|
|
243
|
+
this.projection.setError(cause instanceof Error ? cause.message : String(cause));
|
|
244
|
+
this.refresh();
|
|
245
|
+
});
|
|
246
|
+
}
|
|
205
247
|
}
|
|
206
248
|
catch (cause) {
|
|
207
249
|
this.projection.setError(cause instanceof Error ? cause.message : String(cause));
|
|
@@ -260,6 +302,7 @@ export class InteractiveMode {
|
|
|
260
302
|
]);
|
|
261
303
|
list.onSelect = (item) => {
|
|
262
304
|
this.theme = item.value === "light" ? "light" : "dark";
|
|
305
|
+
this.context?.setTheme(this.theme);
|
|
263
306
|
this.projection.setStatus(`theme=${this.theme}`);
|
|
264
307
|
this.closeOverlay();
|
|
265
308
|
this.refresh();
|
|
@@ -277,6 +320,10 @@ export class InteractiveMode {
|
|
|
277
320
|
try {
|
|
278
321
|
this.session.setModel(item.value);
|
|
279
322
|
this.projection.setStatus(`model=${item.value}`);
|
|
323
|
+
void saveGlobalModelSelection(this.agentDir, this.session.providerId, this.session.modelId).catch((cause) => {
|
|
324
|
+
this.projection.setError(cause instanceof Error ? cause.message : String(cause));
|
|
325
|
+
this.refresh();
|
|
326
|
+
});
|
|
280
327
|
this.closeOverlay();
|
|
281
328
|
this.refresh();
|
|
282
329
|
}
|
|
@@ -602,7 +649,9 @@ export class InteractiveMode {
|
|
|
602
649
|
const input = await extractImageAttachments(normalizeDroppedImagePrompt(prompt, this.session.allowedRoot), this.session.allowedRoot);
|
|
603
650
|
this.preserveClipboardFiles = true;
|
|
604
651
|
this.editor.setValue("");
|
|
605
|
-
const result =
|
|
652
|
+
const result = retry && "retry" in this.session
|
|
653
|
+
? await this.session.retry(this.activeAbort.signal)
|
|
654
|
+
: await this.session.promptWithImages(input.text, input.images, this.activeAbort.signal);
|
|
606
655
|
if (result.stopReason === "error" || result.stopReason === "aborted")
|
|
607
656
|
this.lastFailedPrompt = prompt;
|
|
608
657
|
else {
|
|
@@ -689,6 +738,22 @@ export class InteractiveMode {
|
|
|
689
738
|
const [rawCommand = "", ...argParts] = trimmed.split(/\s+/);
|
|
690
739
|
const command = rawCommand.toLowerCase();
|
|
691
740
|
const args = argParts.join(" ");
|
|
741
|
+
if (this.commandRegistry?.list().some((entry) => entry.name === command)) {
|
|
742
|
+
void this.commandRegistry
|
|
743
|
+
.execute(command, {
|
|
744
|
+
host: { runCommand: (name, value) => this.runRegisteredCommand(name, value) },
|
|
745
|
+
args,
|
|
746
|
+
})
|
|
747
|
+
.catch((cause) => {
|
|
748
|
+
this.projection.setError(cause instanceof Error ? cause.message : String(cause));
|
|
749
|
+
this.refresh();
|
|
750
|
+
});
|
|
751
|
+
this.refresh();
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
this.runRegisteredCommand(command, args);
|
|
755
|
+
}
|
|
756
|
+
runRegisteredCommand(command, _args) {
|
|
692
757
|
switch (command) {
|
|
693
758
|
case "help":
|
|
694
759
|
this.projection.setStatus(`commands: ${this.listSlashCommands()
|
|
@@ -701,49 +766,46 @@ export class InteractiveMode {
|
|
|
701
766
|
break;
|
|
702
767
|
case "model":
|
|
703
768
|
this.openModelSelector();
|
|
704
|
-
return;
|
|
769
|
+
return 0;
|
|
705
770
|
case "session":
|
|
706
771
|
this.openSessionSelector();
|
|
707
|
-
return;
|
|
772
|
+
return 0;
|
|
708
773
|
case "tree":
|
|
709
774
|
this.openTreeSelector();
|
|
710
|
-
return;
|
|
775
|
+
return 0;
|
|
711
776
|
case "theme":
|
|
712
777
|
this.openThemeSelector();
|
|
713
|
-
return;
|
|
778
|
+
return 0;
|
|
714
779
|
case "settings":
|
|
715
780
|
this.openSettingsSelector();
|
|
716
|
-
return;
|
|
781
|
+
return 0;
|
|
717
782
|
case "login":
|
|
718
783
|
this.openProviderLogin();
|
|
719
|
-
return;
|
|
784
|
+
return 0;
|
|
720
785
|
case "logout":
|
|
721
786
|
void this.logoutProvider();
|
|
722
|
-
return;
|
|
787
|
+
return 0;
|
|
723
788
|
case "compact":
|
|
724
789
|
void this.runManualCompaction();
|
|
725
|
-
return;
|
|
790
|
+
return 0;
|
|
726
791
|
case "usage":
|
|
727
792
|
this.projection.setStatus(this.formatUsage());
|
|
728
793
|
break;
|
|
729
794
|
case "retry":
|
|
730
|
-
if (this.lastFailedPrompt && !this.promptInFlight)
|
|
731
|
-
|
|
795
|
+
if (this.lastFailedPrompt && !this.promptInFlight) {
|
|
796
|
+
if (this.context)
|
|
797
|
+
void this.context.retry();
|
|
798
|
+
else
|
|
799
|
+
void this.submit(this.lastFailedPrompt, true);
|
|
800
|
+
}
|
|
732
801
|
else
|
|
733
802
|
this.projection.setStatus(translate(this.locale, "nothingToRetry"));
|
|
734
803
|
break;
|
|
735
|
-
default:
|
|
736
|
-
if (this.extensionHost?.listCommands().some((entry) => entry.name === command)) {
|
|
737
|
-
void this.extensionHost.runCommand(command, args).catch((cause) => {
|
|
738
|
-
this.projection.setError(cause instanceof Error ? cause.message : String(cause));
|
|
739
|
-
this.refresh();
|
|
740
|
-
});
|
|
741
|
-
break;
|
|
742
|
-
}
|
|
804
|
+
default:
|
|
743
805
|
this.projection.setError(`Unknown command: /${command}`);
|
|
744
|
-
}
|
|
745
806
|
}
|
|
746
807
|
this.refresh();
|
|
808
|
+
return 0;
|
|
747
809
|
}
|
|
748
810
|
openProviderLogin() {
|
|
749
811
|
if (!this.providerOnboarding) {
|
|
@@ -813,7 +875,11 @@ export class InteractiveMode {
|
|
|
813
875
|
name: `skill:${skill.name}`,
|
|
814
876
|
description: skill.description,
|
|
815
877
|
}));
|
|
816
|
-
|
|
878
|
+
const registryCommands = this.commandRegistry?.list().map((command) => ({
|
|
879
|
+
name: command.name,
|
|
880
|
+
description: typeof command.description === "function" ? command.description(this.locale) : command.description,
|
|
881
|
+
}));
|
|
882
|
+
return [...(registryCommands ?? builtinSlashCommands(this.locale)), ...skills];
|
|
817
883
|
}
|
|
818
884
|
isLoadedSkillCommand(input) {
|
|
819
885
|
const name = /^\/skill:([a-z0-9]+(?:-[a-z0-9]+)*)(?:\s|$)/.exec(input)?.[1];
|