@adhdev/daemon-core 0.8.33 → 0.8.35
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/dist/index.d.ts +1 -1
- package/dist/index.js +127 -102
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +127 -102
- package/dist/index.mjs.map +1 -1
- package/dist/shared-types.d.ts +38 -0
- package/dist/status/reporter.d.ts +3 -0
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/agent-stream/forward.d.ts +8 -0
- package/src/agent-stream/index.d.ts +6 -0
- package/src/agent-stream/manager.d.ts +60 -0
- package/src/agent-stream/poller.d.ts +41 -0
- package/src/agent-stream/provider-adapter.d.ts +36 -0
- package/src/agent-stream/types.d.ts +68 -0
- package/src/boot/daemon-lifecycle.d.ts +100 -0
- package/src/cdp/devtools.d.ts +51 -0
- package/src/cdp/initializer.d.ts +50 -0
- package/src/cdp/manager.d.ts +147 -0
- package/src/cdp/scanner.d.ts +58 -0
- package/src/cdp/setup.d.ts +58 -0
- package/src/cli-adapter-types.d.ts +57 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +177 -0
- package/src/cli-adapters/provider-cli-adapter.ts +115 -91
- package/src/cli-adapters/provider-cli-config.d.ts +30 -0
- package/src/cli-adapters/provider-cli-parse.d.ts +42 -0
- package/src/cli-adapters/provider-cli-runtime.d.ts +29 -0
- package/src/cli-adapters/provider-cli-shared.d.ts +158 -0
- package/src/cli-adapters/pty-transport.d.ts +48 -0
- package/src/cli-adapters/session-host-transport.d.ts +20 -0
- package/src/cli-adapters/spawn-env.d.ts +8 -0
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +16 -0
- package/src/cli-adapters/terminal-backends/types.d.ts +18 -0
- package/src/cli-adapters/terminal-backends/xterm-backend.d.ts +17 -0
- package/src/cli-adapters/terminal-screen.d.ts +33 -0
- package/src/commands/cdp-commands.d.ts +15 -0
- package/src/commands/chat-commands.d.ts +15 -0
- package/src/commands/cli-manager.d.ts +94 -0
- package/src/commands/handler.d.ts +103 -0
- package/src/commands/router.d.ts +98 -0
- package/src/commands/stream-commands.d.ts +14 -0
- package/src/commands/upgrade-helper.d.ts +10 -0
- package/src/commands/workspace-commands.d.ts +11 -0
- package/src/config/chat-history.d.ts +99 -0
- package/src/config/config.d.ts +14 -0
- package/src/config/recent-activity.d.ts +29 -0
- package/src/config/saved-sessions.d.ts +22 -0
- package/src/config/state-store.d.ts +32 -0
- package/src/config/workspaces.d.ts +0 -1
- package/src/daemon/dev-auto-implement.d.ts +43 -0
- package/src/daemon/dev-cdp-handlers.d.ts +22 -0
- package/src/daemon/dev-cli-debug.d.ts +106 -0
- package/src/daemon/dev-server-types.d.ts +43 -0
- package/src/daemon/dev-server.d.ts +140 -0
- package/src/daemon/scaffold-template.d.ts +32 -0
- package/src/daemon-core.d.ts +36 -0
- package/src/detection/cli-detector.d.ts +31 -0
- package/src/detection/ide-detector.d.ts +35 -0
- package/src/index.d.ts +83 -0
- package/src/index.ts +2 -0
- package/src/installer.d.ts +50 -0
- package/src/ipc-protocol.d.ts +111 -0
- package/src/launch.d.ts +46 -0
- package/src/logging/command-log.d.ts +31 -0
- package/src/logging/logger.d.ts +89 -0
- package/src/providers/acp-provider-instance.d.ts +102 -0
- package/src/providers/approval-utils.d.ts +7 -0
- package/src/providers/cli-provider-instance.d.ts +86 -0
- package/src/providers/contracts.d.ts +193 -1
- package/src/providers/control-effects.d.ts +4 -0
- package/src/providers/extension-provider-instance.d.ts +61 -0
- package/src/providers/ide-provider-instance.d.ts +70 -0
- package/src/providers/provider-instance-manager.d.ts +84 -0
- package/src/providers/provider-instance.d.ts +7 -1
- package/src/providers/provider-loader.d.ts +299 -0
- package/src/providers/status-monitor.d.ts +48 -0
- package/src/providers/version-archive.d.ts +52 -0
- package/src/session-host/runtime-support.d.ts +8 -0
- package/src/sessions/reconcile.d.ts +22 -0
- package/src/sessions/registry.d.ts +24 -0
- package/src/shared-types-extra.d.ts +29 -0
- package/src/shared-types.d.ts +79 -22
- package/src/shared-types.ts +40 -0
- package/src/status/builders.d.ts +33 -0
- package/src/status/reporter.d.ts +69 -0
- package/src/status/reporter.ts +16 -13
- package/src/status/snapshot.d.ts +58 -0
- package/src/system/host-memory.d.ts +19 -0
- package/src/types.d.ts +3 -7
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PtySpawnOptions, PtyRuntimeTransport } from './pty-transport.js';
|
|
2
|
+
import type { TerminalScreen } from './terminal-screen.js';
|
|
3
|
+
import { type CliProviderModule } from './provider-cli-shared.js';
|
|
4
|
+
export interface CliSpawnPlan {
|
|
5
|
+
binaryPath: string;
|
|
6
|
+
allArgs: string[];
|
|
7
|
+
shellCmd: string;
|
|
8
|
+
shellArgs: string[];
|
|
9
|
+
ptyOptions: PtySpawnOptions;
|
|
10
|
+
isWin: boolean;
|
|
11
|
+
useShell: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function resolveCliSpawnPlan(options: {
|
|
14
|
+
provider: CliProviderModule;
|
|
15
|
+
runtimeSettings: Record<string, any>;
|
|
16
|
+
workingDir: string;
|
|
17
|
+
extraArgs: string[];
|
|
18
|
+
}): CliSpawnPlan;
|
|
19
|
+
export declare function buildCliLoginShellRetry(plan: Pick<CliSpawnPlan, 'binaryPath' | 'allArgs'>): {
|
|
20
|
+
shellCmd: string;
|
|
21
|
+
shellArgs: string[];
|
|
22
|
+
};
|
|
23
|
+
export declare function getCliSpawnErrorHint(message: string, shellCmd: string, isWin: boolean): string | null;
|
|
24
|
+
export declare function respondToCliTerminalQueries(options: {
|
|
25
|
+
ptyProcess: PtyRuntimeTransport | null;
|
|
26
|
+
pendingTail: string;
|
|
27
|
+
data: string;
|
|
28
|
+
terminalScreen: TerminalScreen;
|
|
29
|
+
}): string;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { ProviderResumeCapability } from '../providers/contracts.js';
|
|
2
|
+
import { sanitizeSpawnEnv } from './spawn-env.js';
|
|
3
|
+
export interface CliChatMessage {
|
|
4
|
+
role: 'user' | 'assistant';
|
|
5
|
+
content: string;
|
|
6
|
+
timestamp?: number;
|
|
7
|
+
receivedAt?: number;
|
|
8
|
+
kind?: string;
|
|
9
|
+
id?: string;
|
|
10
|
+
index?: number;
|
|
11
|
+
meta?: Record<string, any>;
|
|
12
|
+
senderName?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CliSessionStatus {
|
|
15
|
+
status: 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting';
|
|
16
|
+
messages: CliChatMessage[];
|
|
17
|
+
workingDir: string;
|
|
18
|
+
activeModal: {
|
|
19
|
+
message: string;
|
|
20
|
+
buttons: string[];
|
|
21
|
+
} | null;
|
|
22
|
+
}
|
|
23
|
+
export interface CliScripts {
|
|
24
|
+
parseOutput?: (input: CliScriptInput) => any;
|
|
25
|
+
detectStatus?: (input: CliStatusInput) => string | null;
|
|
26
|
+
parseApproval?: (input: CliApprovalInput) => {
|
|
27
|
+
message: string;
|
|
28
|
+
buttons: string[];
|
|
29
|
+
} | null;
|
|
30
|
+
resolveAction?: (data: any) => string;
|
|
31
|
+
[name: string]: ((input: any) => any) | undefined;
|
|
32
|
+
}
|
|
33
|
+
export interface CliScreenLine {
|
|
34
|
+
index: number;
|
|
35
|
+
fromTop: number;
|
|
36
|
+
fromBottom: number;
|
|
37
|
+
text: string;
|
|
38
|
+
trimmed: string;
|
|
39
|
+
isEmpty: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface CliScreenSnapshot {
|
|
42
|
+
text: string;
|
|
43
|
+
lineCount: number;
|
|
44
|
+
lines: CliScreenLine[];
|
|
45
|
+
nonEmptyLines: CliScreenLine[];
|
|
46
|
+
firstNonEmptyLineIndex: number;
|
|
47
|
+
lastNonEmptyLineIndex: number;
|
|
48
|
+
firstNonEmptyLine: CliScreenLine | null;
|
|
49
|
+
lastNonEmptyLine: CliScreenLine | null;
|
|
50
|
+
promptLineIndex: number;
|
|
51
|
+
promptLine: CliScreenLine | null;
|
|
52
|
+
linesAbovePrompt: CliScreenLine[];
|
|
53
|
+
linesBelowPrompt: CliScreenLine[];
|
|
54
|
+
}
|
|
55
|
+
export interface CliScriptInput {
|
|
56
|
+
buffer: string;
|
|
57
|
+
rawBuffer: string;
|
|
58
|
+
recentBuffer: string;
|
|
59
|
+
screenText: string;
|
|
60
|
+
screen: CliScreenSnapshot;
|
|
61
|
+
bufferScreen: CliScreenSnapshot;
|
|
62
|
+
recentScreen: CliScreenSnapshot;
|
|
63
|
+
messages: CliChatMessage[];
|
|
64
|
+
partialResponse: string;
|
|
65
|
+
promptText?: string;
|
|
66
|
+
settings?: Record<string, any>;
|
|
67
|
+
args?: Record<string, any>;
|
|
68
|
+
}
|
|
69
|
+
export interface CliStatusInput {
|
|
70
|
+
tail: string;
|
|
71
|
+
screenText?: string;
|
|
72
|
+
rawBuffer?: string;
|
|
73
|
+
screen: CliScreenSnapshot;
|
|
74
|
+
tailScreen: CliScreenSnapshot;
|
|
75
|
+
}
|
|
76
|
+
export interface CliApprovalInput {
|
|
77
|
+
buffer: string;
|
|
78
|
+
screenText?: string;
|
|
79
|
+
rawBuffer?: string;
|
|
80
|
+
tail: string;
|
|
81
|
+
screen: CliScreenSnapshot;
|
|
82
|
+
bufferScreen: CliScreenSnapshot;
|
|
83
|
+
tailScreen: CliScreenSnapshot;
|
|
84
|
+
}
|
|
85
|
+
export interface CliTraceEntry {
|
|
86
|
+
id: number;
|
|
87
|
+
at: number;
|
|
88
|
+
type: string;
|
|
89
|
+
status: CliSessionStatus['status'];
|
|
90
|
+
isWaitingForResponse: boolean;
|
|
91
|
+
activeModal: {
|
|
92
|
+
message: string;
|
|
93
|
+
buttons: string[];
|
|
94
|
+
} | null;
|
|
95
|
+
payload: Record<string, any>;
|
|
96
|
+
}
|
|
97
|
+
export interface CliProviderModule {
|
|
98
|
+
type: string;
|
|
99
|
+
name: string;
|
|
100
|
+
category: 'cli';
|
|
101
|
+
binary: string;
|
|
102
|
+
approvalKeys?: Record<number, string>;
|
|
103
|
+
sendDelayMs?: number;
|
|
104
|
+
sendKey?: string;
|
|
105
|
+
submitStrategy?: 'wait_for_echo' | 'immediate';
|
|
106
|
+
scripts?: CliScripts;
|
|
107
|
+
spawn: {
|
|
108
|
+
command: string;
|
|
109
|
+
args: string[];
|
|
110
|
+
shell: boolean;
|
|
111
|
+
env: Record<string, string>;
|
|
112
|
+
};
|
|
113
|
+
timeouts?: {
|
|
114
|
+
ptyFlush?: number;
|
|
115
|
+
dialogAccept?: number;
|
|
116
|
+
approvalCooldown?: number;
|
|
117
|
+
generatingIdle?: number;
|
|
118
|
+
idleFinish?: number;
|
|
119
|
+
maxResponse?: number;
|
|
120
|
+
shutdownGrace?: number;
|
|
121
|
+
outputSettle?: number;
|
|
122
|
+
};
|
|
123
|
+
resume?: ProviderResumeCapability;
|
|
124
|
+
_resolvedVersion?: string | null;
|
|
125
|
+
_resolvedOs?: string | null;
|
|
126
|
+
_resolvedProviderDir?: string | null;
|
|
127
|
+
_resolvedScriptDir?: string | null;
|
|
128
|
+
_resolvedScriptsPath?: string | null;
|
|
129
|
+
_resolvedScriptsSource?: string | null;
|
|
130
|
+
_versionWarning?: string | null;
|
|
131
|
+
}
|
|
132
|
+
export declare function sanitizeTerminalText(str: string): string;
|
|
133
|
+
export declare function listCliScriptNames(scripts: CliScripts | undefined): string[];
|
|
134
|
+
export declare function buildCliScreenSnapshot(text: string): CliScreenSnapshot;
|
|
135
|
+
export declare const buildCliSpawnEnv: typeof sanitizeSpawnEnv;
|
|
136
|
+
export declare function computeTerminalQueryTail(buffer: string): string;
|
|
137
|
+
export declare function findBinary(name: string): string;
|
|
138
|
+
export declare function isScriptBinary(binaryPath: string): boolean;
|
|
139
|
+
export declare function looksLikeMachOOrElf(filePath: string): boolean;
|
|
140
|
+
export declare function shSingleQuote(arg: string): string;
|
|
141
|
+
export declare function estimatePromptDisplayLines(text: string, cols?: number): number;
|
|
142
|
+
export declare function extractPromptRetrySnippet(text: string): string;
|
|
143
|
+
export declare function normalizePromptText(text: string): string;
|
|
144
|
+
export declare function compactPromptText(text: string): string;
|
|
145
|
+
export declare function promptLikelyVisible(screenText: string, promptSnippet: string): boolean;
|
|
146
|
+
export declare function normalizeScreenSnapshot(text: string): string;
|
|
147
|
+
export declare function normalizeComparableMessageContent(text: string): string;
|
|
148
|
+
export declare function trimPromptEchoPrefix(text: string, promptText?: string | null): string;
|
|
149
|
+
export declare function getLastUserPromptText(messages: Array<{
|
|
150
|
+
role?: string;
|
|
151
|
+
content?: string;
|
|
152
|
+
}> | null | undefined): string;
|
|
153
|
+
export declare function looksLikeConfirmOnlyLabel(label: string): boolean;
|
|
154
|
+
export declare function normalizeCliProviderForRuntime(raw: unknown): {
|
|
155
|
+
patterns: {
|
|
156
|
+
approval: RegExp[];
|
|
157
|
+
};
|
|
158
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface PtySpawnOptions {
|
|
2
|
+
cwd: string;
|
|
3
|
+
env: Record<string, string>;
|
|
4
|
+
cols: number;
|
|
5
|
+
rows: number;
|
|
6
|
+
}
|
|
7
|
+
export interface PtyRuntimeWriteOwner {
|
|
8
|
+
clientId: string;
|
|
9
|
+
ownerType: 'agent' | 'user';
|
|
10
|
+
}
|
|
11
|
+
export interface PtyRuntimeClientInfo {
|
|
12
|
+
clientId: string;
|
|
13
|
+
type: 'daemon' | 'web' | 'local-terminal';
|
|
14
|
+
readOnly: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface PtyRuntimeMetadata {
|
|
17
|
+
runtimeId: string;
|
|
18
|
+
runtimeKey?: string;
|
|
19
|
+
displayName?: string;
|
|
20
|
+
workspaceLabel?: string;
|
|
21
|
+
writeOwner?: PtyRuntimeWriteOwner | null;
|
|
22
|
+
attachedClients?: PtyRuntimeClientInfo[];
|
|
23
|
+
restoredFromStorage?: boolean;
|
|
24
|
+
recoveryState?: string | null;
|
|
25
|
+
recoveryError?: string | null;
|
|
26
|
+
}
|
|
27
|
+
export interface PtyRuntimeTransport {
|
|
28
|
+
readonly pid: number;
|
|
29
|
+
readonly ready: Promise<void>;
|
|
30
|
+
readonly terminalQueriesHandled?: boolean;
|
|
31
|
+
write(data: string): void;
|
|
32
|
+
resize(cols: number, rows: number): void;
|
|
33
|
+
kill(): void;
|
|
34
|
+
clearBuffer?(): void;
|
|
35
|
+
detach?(): void;
|
|
36
|
+
updateMeta?(meta: Record<string, unknown>, replace?: boolean): void;
|
|
37
|
+
getMetadata?(): PtyRuntimeMetadata | null;
|
|
38
|
+
onData(callback: (data: string) => void): void;
|
|
39
|
+
onExit(callback: (info: {
|
|
40
|
+
exitCode: number;
|
|
41
|
+
}) => void): void;
|
|
42
|
+
}
|
|
43
|
+
export interface PtyTransportFactory {
|
|
44
|
+
spawn(command: string, args: string[], options: PtySpawnOptions): PtyRuntimeTransport;
|
|
45
|
+
}
|
|
46
|
+
export declare class NodePtyTransportFactory implements PtyTransportFactory {
|
|
47
|
+
spawn(command: string, args: string[], options: PtySpawnOptions): PtyRuntimeTransport;
|
|
48
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type SessionHostEndpoint, type SessionHostCategory } from '@adhdev/session-host-core';
|
|
2
|
+
import type { PtyRuntimeTransport, PtySpawnOptions, PtyTransportFactory } from './pty-transport.js';
|
|
3
|
+
interface SessionHostPtyTransportFactoryOptions {
|
|
4
|
+
endpoint?: SessionHostEndpoint;
|
|
5
|
+
appName?: string;
|
|
6
|
+
ensureReady?: () => Promise<void>;
|
|
7
|
+
clientId: string;
|
|
8
|
+
runtimeId: string;
|
|
9
|
+
providerType: string;
|
|
10
|
+
category?: SessionHostCategory;
|
|
11
|
+
workspace: string;
|
|
12
|
+
meta?: Record<string, unknown>;
|
|
13
|
+
attachExisting?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare class SessionHostPtyTransportFactory implements PtyTransportFactory {
|
|
16
|
+
private readonly options;
|
|
17
|
+
constructor(options: SessionHostPtyTransportFactoryOptions);
|
|
18
|
+
spawn(command: string, args: string[], spawnOptions: PtySpawnOptions): PtyRuntimeTransport;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-export spawn environment utilities from @adhdev/session-host-core.
|
|
3
|
+
*
|
|
4
|
+
* The canonical implementation lives in session-host-core so that both
|
|
5
|
+
* daemon-core and session-host-daemon can share it. This file exists
|
|
6
|
+
* to keep the import path short within daemon-core consumers.
|
|
7
|
+
*/
|
|
8
|
+
export { sanitizeSpawnEnv, applyTerminalColorEnv, ensureNodePtySpawnHelperPermissions, } from '@adhdev/session-host-core';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TerminalViewportBackend, TerminalViewportBackendOptions, TerminalViewportBackendPreference } from './types.js';
|
|
2
|
+
export declare function resolveTerminalBackendPreference(): TerminalViewportBackendPreference;
|
|
3
|
+
export declare function isGhosttyVtBackendAvailable(): boolean;
|
|
4
|
+
export declare class GhosttyVtTerminalBackend implements TerminalViewportBackend {
|
|
5
|
+
readonly kind: "ghostty-vt";
|
|
6
|
+
private terminal;
|
|
7
|
+
constructor(options: TerminalViewportBackendOptions);
|
|
8
|
+
resize(rows: number, cols: number): void;
|
|
9
|
+
write(data: string): void;
|
|
10
|
+
getText(): string;
|
|
11
|
+
getCursorPosition(): {
|
|
12
|
+
col: number;
|
|
13
|
+
row: number;
|
|
14
|
+
};
|
|
15
|
+
dispose(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type TerminalViewportBackendKind = 'xterm' | 'ghostty-vt';
|
|
2
|
+
export type TerminalViewportBackendPreference = TerminalViewportBackendKind | 'auto';
|
|
3
|
+
export type TerminalViewportBackendOptions = {
|
|
4
|
+
rows: number;
|
|
5
|
+
cols: number;
|
|
6
|
+
scrollback: number;
|
|
7
|
+
};
|
|
8
|
+
export interface TerminalViewportBackend {
|
|
9
|
+
readonly kind: TerminalViewportBackendKind;
|
|
10
|
+
resize(rows: number, cols: number): void;
|
|
11
|
+
write(data: string): void;
|
|
12
|
+
getText(): string;
|
|
13
|
+
getCursorPosition(): {
|
|
14
|
+
col: number;
|
|
15
|
+
row: number;
|
|
16
|
+
};
|
|
17
|
+
dispose(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TerminalViewportBackend, TerminalViewportBackendOptions } from './types.js';
|
|
2
|
+
export declare class XtermTerminalBackend implements TerminalViewportBackend {
|
|
3
|
+
readonly kind: "xterm";
|
|
4
|
+
private rows;
|
|
5
|
+
private cols;
|
|
6
|
+
private terminal;
|
|
7
|
+
constructor(options: TerminalViewportBackendOptions);
|
|
8
|
+
resize(rows: number, cols: number): void;
|
|
9
|
+
write(data: string): void;
|
|
10
|
+
getText(): string;
|
|
11
|
+
getCursorPosition(): {
|
|
12
|
+
col: number;
|
|
13
|
+
row: number;
|
|
14
|
+
};
|
|
15
|
+
dispose(): void;
|
|
16
|
+
private createTerminal;
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PTY screen snapshot abstraction.
|
|
3
|
+
*
|
|
4
|
+
* Terminal viewport backend selection.
|
|
5
|
+
*
|
|
6
|
+
* Runtime preference is backend-agnostic:
|
|
7
|
+
* - prefer ghostty-vt when available (or when explicitly requested)
|
|
8
|
+
* - fall back to xterm when ghostty-vt is unavailable
|
|
9
|
+
*/
|
|
10
|
+
import type { TerminalViewportBackendKind, TerminalViewportBackendPreference } from './terminal-backends/types.js';
|
|
11
|
+
export declare function getTerminalBackendRuntimeStatus(): {
|
|
12
|
+
backend: TerminalViewportBackendKind;
|
|
13
|
+
preference: TerminalViewportBackendPreference;
|
|
14
|
+
ghosttyAvailable: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare class TerminalScreen {
|
|
17
|
+
readonly backendKind: TerminalViewportBackendKind;
|
|
18
|
+
private rows;
|
|
19
|
+
private cols;
|
|
20
|
+
private readonly preference;
|
|
21
|
+
private terminal;
|
|
22
|
+
constructor(rows?: number, cols?: number);
|
|
23
|
+
reset(rows?: number, cols?: number): void;
|
|
24
|
+
resize(rows: number, cols: number): void;
|
|
25
|
+
write(data: string): void;
|
|
26
|
+
getText(): string;
|
|
27
|
+
getCursorPosition(): {
|
|
28
|
+
col: number;
|
|
29
|
+
row: number;
|
|
30
|
+
};
|
|
31
|
+
dispose(): void;
|
|
32
|
+
private createBackend;
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CDP Commands — cdpEval, screenshot, cdpCommand, cdpBatch, cdpRemoteAction,
|
|
3
|
+
* discoverAgents, file operations
|
|
4
|
+
*/
|
|
5
|
+
import type { CommandResult, CommandHelpers } from './handler.js';
|
|
6
|
+
export declare function handleCdpEval(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
7
|
+
export declare function handleScreenshot(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
8
|
+
export declare function handleCdpCommand(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
9
|
+
export declare function handleCdpBatch(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
10
|
+
export declare function handleCdpRemoteAction(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
11
|
+
export declare function handleDiscoverAgents(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
12
|
+
export declare function handleFileRead(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
13
|
+
export declare function handleFileWrite(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
14
|
+
export declare function handleFileList(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
15
|
+
export declare function handleFileListBrowse(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Commands — readChat, sendChat, listChats, newChat, switchChat,
|
|
3
|
+
* setMode, changeModel, setThoughtLevel, resolveAction, chatHistory
|
|
4
|
+
*/
|
|
5
|
+
import type { CommandResult, CommandHelpers } from './handler.js';
|
|
6
|
+
export declare function handleChatHistory(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
7
|
+
export declare function handleReadChat(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
8
|
+
export declare function handleSendChat(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
9
|
+
export declare function handleListChats(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
10
|
+
export declare function handleNewChat(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
11
|
+
export declare function handleSwitchChat(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
12
|
+
export declare function handleSetMode(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
13
|
+
export declare function handleChangeModel(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
14
|
+
export declare function handleSetThoughtLevel(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
15
|
+
export declare function handleResolveAction(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DaemonCliManager — CLI session creation, management, and command handling
|
|
3
|
+
*
|
|
4
|
+
* Separated from adhdev-daemon.ts.
|
|
5
|
+
* CLI cases of createAdapter, startCliSession, stopCliSession, executeDaemonCommand extracted to independent module extract.
|
|
6
|
+
*/
|
|
7
|
+
import type { ProviderInstanceManager } from '../providers/provider-instance-manager.js';
|
|
8
|
+
import { ProviderLoader } from '../providers/provider-loader.js';
|
|
9
|
+
import type { ProviderResumeCapability } from '../providers/contracts.js';
|
|
10
|
+
import type { CliAdapter } from '../cli-adapter-types.js';
|
|
11
|
+
import type { PtyTransportFactory } from '../cli-adapters/pty-transport.js';
|
|
12
|
+
import type { SessionRegistry } from '../sessions/registry.js';
|
|
13
|
+
export interface CliManagerDeps {
|
|
14
|
+
/** Server connection — injected into adapter */
|
|
15
|
+
getServerConn(): any | null;
|
|
16
|
+
/** P2P — PTY output transmit */
|
|
17
|
+
getP2p(): {
|
|
18
|
+
broadcastSessionOutput(key: string, data: string): void;
|
|
19
|
+
} | null;
|
|
20
|
+
/** StatusReporter callback */
|
|
21
|
+
onStatusChange(): void;
|
|
22
|
+
removeAgentTracking(key: string): void;
|
|
23
|
+
/** InstanceManager — register in CLI unified status */
|
|
24
|
+
getInstanceManager(): ProviderInstanceManager | null;
|
|
25
|
+
getSessionRegistry?(): SessionRegistry | null;
|
|
26
|
+
createPtyTransportFactory?: (params: CliTransportFactoryParams) => PtyTransportFactory | null;
|
|
27
|
+
listHostedCliRuntimes?: () => Promise<HostedCliRuntimeDescriptor[]>;
|
|
28
|
+
}
|
|
29
|
+
type CommandResult = {
|
|
30
|
+
success: boolean;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
};
|
|
33
|
+
export interface CliTransportFactoryParams {
|
|
34
|
+
runtimeId: string;
|
|
35
|
+
providerType: string;
|
|
36
|
+
workspace: string;
|
|
37
|
+
cliArgs?: string[];
|
|
38
|
+
providerSessionId?: string;
|
|
39
|
+
attachExisting?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface HostedCliRuntimeDescriptor {
|
|
42
|
+
runtimeId: string;
|
|
43
|
+
runtimeKey?: string;
|
|
44
|
+
displayName?: string;
|
|
45
|
+
workspaceLabel?: string;
|
|
46
|
+
lifecycle?: 'starting' | 'running' | 'stopping' | 'stopped' | 'failed' | 'interrupted';
|
|
47
|
+
recoveryState?: string | null;
|
|
48
|
+
cliType: string;
|
|
49
|
+
workspace: string;
|
|
50
|
+
cliArgs?: string[];
|
|
51
|
+
providerSessionId?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare function supportsExplicitSessionResume(resume?: ProviderResumeCapability): boolean;
|
|
54
|
+
export declare class DaemonCliManager {
|
|
55
|
+
readonly adapters: Map<string, CliAdapter>;
|
|
56
|
+
private deps;
|
|
57
|
+
private providerLoader;
|
|
58
|
+
constructor(deps: CliManagerDeps, providerLoader: ProviderLoader);
|
|
59
|
+
getCliKey(cliType: string, dir: string): string;
|
|
60
|
+
getSessionPresentationMode(sessionId: string): 'terminal' | 'chat' | null;
|
|
61
|
+
isTerminalSession(sessionId: string): boolean;
|
|
62
|
+
private persistRecentActivity;
|
|
63
|
+
private getTransportFactory;
|
|
64
|
+
private createAdapter;
|
|
65
|
+
private startCliExitMonitor;
|
|
66
|
+
private registerCliInstance;
|
|
67
|
+
startSession(cliType: string, workingDir: string, cliArgs?: string[], initialModel?: string, options?: {
|
|
68
|
+
resumeSessionId?: string;
|
|
69
|
+
}): Promise<{
|
|
70
|
+
runtimeSessionId: string;
|
|
71
|
+
providerSessionId?: string;
|
|
72
|
+
}>;
|
|
73
|
+
stopSession(key: string): Promise<void>;
|
|
74
|
+
stopSessionWithMode(key: string, mode: 'hard' | 'save'): Promise<void>;
|
|
75
|
+
shutdownAll(): void;
|
|
76
|
+
detachAll(): void;
|
|
77
|
+
restoreHostedSessions(records?: HostedCliRuntimeDescriptor[]): Promise<number>;
|
|
78
|
+
/**
|
|
79
|
+
* Search for CLI adapter. Priority order:
|
|
80
|
+
* 0. sessionId (UUID direct match)
|
|
81
|
+
* 1. agentType + dir (iteration match)
|
|
82
|
+
* 2. agentType fuzzy match (⚠ returns first match when multiple sessions exist)
|
|
83
|
+
*/
|
|
84
|
+
findAdapter(agentType: string, opts?: {
|
|
85
|
+
dir?: string;
|
|
86
|
+
instanceKey?: string;
|
|
87
|
+
}): {
|
|
88
|
+
adapter: CliAdapter;
|
|
89
|
+
key: string;
|
|
90
|
+
} | null;
|
|
91
|
+
private findAdapterBySessionId;
|
|
92
|
+
handleCliCommand(cmd: string, args: any): Promise<CommandResult | null>;
|
|
93
|
+
}
|
|
94
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DaemonCommandHandler — unified command routing for CDP & CLI
|
|
3
|
+
*
|
|
4
|
+
* Routes incoming commands (from server WS, P2P, or local WS) to
|
|
5
|
+
* the correct CDP manager or CLI adapter.
|
|
6
|
+
*
|
|
7
|
+
* Key concepts:
|
|
8
|
+
* - extractIdeType(): determines target IDE from targetSessionId or ideType
|
|
9
|
+
* - getCdp(): returns the DaemonCdpManager for current command
|
|
10
|
+
* - getProvider(): returns the ProviderModule for current command
|
|
11
|
+
* - handle(): main entry point, sets context then dispatches
|
|
12
|
+
*/
|
|
13
|
+
import type { DaemonCdpManager } from '../cdp/manager.js';
|
|
14
|
+
import { ProviderLoader } from '../providers/provider-loader.js';
|
|
15
|
+
import type { ProviderInstanceManager } from '../providers/provider-instance-manager.js';
|
|
16
|
+
import type { ProviderModule } from '../providers/contracts.js';
|
|
17
|
+
import type { DaemonAgentStreamManager } from '../agent-stream/index.js';
|
|
18
|
+
import type { CliAdapter } from '../cli-adapter-types.js';
|
|
19
|
+
import { ChatHistoryWriter } from '../config/chat-history.js';
|
|
20
|
+
import type { SessionRegistry, SessionRuntimeTarget } from '../sessions/registry.js';
|
|
21
|
+
export interface CommandResult {
|
|
22
|
+
success: boolean;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
export interface CommandContext {
|
|
26
|
+
cdpManagers: Map<string, DaemonCdpManager>;
|
|
27
|
+
ideType: string;
|
|
28
|
+
adapters: Map<string, CliAdapter>;
|
|
29
|
+
providerLoader?: ProviderLoader;
|
|
30
|
+
/** ProviderInstanceManager — for runtime settings propagation */
|
|
31
|
+
instanceManager?: ProviderInstanceManager;
|
|
32
|
+
sessionRegistry?: SessionRegistry;
|
|
33
|
+
onProviderSettingChanged?: (providerType: string, key: string, value: any) => Promise<void> | void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Shared helpers interface — passed to sub-module command functions
|
|
37
|
+
* for accessing CDP, providers, agent streams, and other handler-owned state.
|
|
38
|
+
*/
|
|
39
|
+
export interface CommandHelpers {
|
|
40
|
+
getCdp(ideType?: string): DaemonCdpManager | null;
|
|
41
|
+
getProvider(overrideType?: string): ProviderModule | undefined;
|
|
42
|
+
getProviderScript(scriptName: string, params?: Record<string, string>, ideType?: string): string | null;
|
|
43
|
+
evaluateProviderScript(scriptName: string, params?: Record<string, string>, timeout?: number): Promise<{
|
|
44
|
+
result: any;
|
|
45
|
+
category: string;
|
|
46
|
+
} | null>;
|
|
47
|
+
getCliAdapter(type?: string): CliAdapter | null;
|
|
48
|
+
readonly currentManagerKey: string | undefined;
|
|
49
|
+
readonly currentIdeType: string | undefined;
|
|
50
|
+
readonly currentProviderType: string | undefined;
|
|
51
|
+
readonly currentSession: SessionRuntimeTarget | undefined;
|
|
52
|
+
readonly agentStream: DaemonAgentStreamManager | null;
|
|
53
|
+
readonly ctx: CommandContext;
|
|
54
|
+
readonly historyWriter: ChatHistoryWriter;
|
|
55
|
+
}
|
|
56
|
+
export declare class DaemonCommandHandler implements CommandHelpers {
|
|
57
|
+
private _ctx;
|
|
58
|
+
private _agentStream;
|
|
59
|
+
private domHandlers;
|
|
60
|
+
private _historyWriter;
|
|
61
|
+
/** Current request route context */
|
|
62
|
+
private _currentRoute;
|
|
63
|
+
constructor(ctx: CommandContext);
|
|
64
|
+
get ctx(): CommandContext;
|
|
65
|
+
get agentStream(): DaemonAgentStreamManager | null;
|
|
66
|
+
get historyWriter(): ChatHistoryWriter;
|
|
67
|
+
get currentManagerKey(): string | undefined;
|
|
68
|
+
get currentIdeType(): string | undefined;
|
|
69
|
+
get currentProviderType(): string | undefined;
|
|
70
|
+
get currentSession(): SessionRuntimeTarget | undefined;
|
|
71
|
+
/** Get CDP manager for a specific session or manager key. */
|
|
72
|
+
getCdp(ideType?: string): DaemonCdpManager | null;
|
|
73
|
+
/**
|
|
74
|
+
* Get provider module — _currentProviderType (agentType priority) use.
|
|
75
|
+
*/
|
|
76
|
+
getProvider(overrideType?: string): ProviderModule | undefined;
|
|
77
|
+
/** Get a provider script by name from ProviderLoader. */
|
|
78
|
+
getProviderScript(scriptName: string, params?: Record<string, string>, ideType?: string): string | null;
|
|
79
|
+
/**
|
|
80
|
+
* per-category CDP script execute:
|
|
81
|
+
* IDE → cdp.evaluate(script) (main window)
|
|
82
|
+
* Extension → cdp.evaluateInSession(sessionId, script) (webview)
|
|
83
|
+
*/
|
|
84
|
+
evaluateProviderScript(scriptName: string, params?: Record<string, string>, timeout?: number): Promise<{
|
|
85
|
+
result: any;
|
|
86
|
+
category: string;
|
|
87
|
+
} | null>;
|
|
88
|
+
/** CLI adapter search */
|
|
89
|
+
getCliAdapter(type?: string): CliAdapter | null;
|
|
90
|
+
private inferProviderType;
|
|
91
|
+
private resolveRoute;
|
|
92
|
+
/** Extract CDP scope key from target session or explicit ideType */
|
|
93
|
+
private extractIdeType;
|
|
94
|
+
private logCommandStart;
|
|
95
|
+
private logCommandEnd;
|
|
96
|
+
setAgentStreamManager(manager: DaemonAgentStreamManager): void;
|
|
97
|
+
handle(cmd: string, args: any): Promise<CommandResult>;
|
|
98
|
+
private dispatch;
|
|
99
|
+
private handleRefreshScripts;
|
|
100
|
+
private proxyDevServerPost;
|
|
101
|
+
private proxyDevServerGet;
|
|
102
|
+
private proxyDevServerScaffold;
|
|
103
|
+
}
|