@adhdev/daemon-core 0.7.46 → 0.8.0
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/cli-adapters/provider-cli-adapter.d.ts +33 -0
- package/dist/cli-adapters/session-host-transport.d.ts +1 -0
- package/dist/config/chat-history.d.ts +3 -0
- package/dist/config/config.d.ts +1 -1
- package/dist/daemon/dev-auto-implement.d.ts +18 -2
- package/dist/daemon/dev-cli-debug.d.ts +82 -0
- package/dist/daemon/dev-server.d.ts +7 -0
- package/dist/index.js +1625 -191
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1625 -191
- package/dist/index.mjs.map +1 -1
- package/dist/providers/cli-provider-instance.d.ts +5 -0
- package/dist/providers/contracts.d.ts +8 -0
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +417 -6
- package/src/cli-adapters/session-host-transport.ts +13 -1
- package/src/commands/chat-commands.ts +8 -0
- package/src/config/chat-history.ts +5 -1
- package/src/config/config.ts +2 -2
- package/src/daemon/dev-auto-implement.ts +371 -38
- package/src/daemon/dev-cli-debug.ts +839 -0
- package/src/daemon/dev-server.ts +29 -1
- package/src/providers/cli-provider-instance.ts +79 -1
- package/src/providers/contracts.ts +8 -0
- package/src/providers/provider-loader.ts +39 -0
|
@@ -67,6 +67,18 @@ export interface CliScriptInput {
|
|
|
67
67
|
messages: CliChatMessage[];
|
|
68
68
|
partialResponse: string;
|
|
69
69
|
}
|
|
70
|
+
export interface CliTraceEntry {
|
|
71
|
+
id: number;
|
|
72
|
+
at: number;
|
|
73
|
+
type: string;
|
|
74
|
+
status: CliSessionStatus['status'];
|
|
75
|
+
isWaitingForResponse: boolean;
|
|
76
|
+
activeModal: {
|
|
77
|
+
message: string;
|
|
78
|
+
buttons: string[];
|
|
79
|
+
} | null;
|
|
80
|
+
payload: Record<string, any>;
|
|
81
|
+
}
|
|
70
82
|
export interface CliProviderModule {
|
|
71
83
|
type: string;
|
|
72
84
|
name: string;
|
|
@@ -139,6 +151,10 @@ export declare class ProviderCliAdapter implements CliAdapter {
|
|
|
139
151
|
private ptyOutputBuffer;
|
|
140
152
|
private ptyOutputFlushTimer;
|
|
141
153
|
private pendingTerminalQueryTail;
|
|
154
|
+
private lastOutputAt;
|
|
155
|
+
private lastNonEmptyOutputAt;
|
|
156
|
+
private lastScreenChangeAt;
|
|
157
|
+
private lastScreenSnapshot;
|
|
142
158
|
private serverConn;
|
|
143
159
|
private logBuffer;
|
|
144
160
|
private lastApprovalResolvedAt;
|
|
@@ -155,6 +171,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
|
|
|
155
171
|
private submitRetryTimer;
|
|
156
172
|
private submitRetryUsed;
|
|
157
173
|
private submitRetryPromptSnippet;
|
|
174
|
+
private idleFinishCandidate;
|
|
158
175
|
private resizeSuppressUntil;
|
|
159
176
|
private statusHistory;
|
|
160
177
|
private cliScripts;
|
|
@@ -167,11 +184,24 @@ export declare class ProviderCliAdapter implements CliAdapter {
|
|
|
167
184
|
/** Max accumulated buffer size (last 50KB) */
|
|
168
185
|
private static readonly MAX_ACCUMULATED_BUFFER;
|
|
169
186
|
private currentTurnScope;
|
|
187
|
+
private traceEntries;
|
|
188
|
+
private traceSeq;
|
|
189
|
+
private traceSessionId;
|
|
190
|
+
private static readonly MAX_TRACE_ENTRIES;
|
|
191
|
+
private readonly providerResolutionMeta;
|
|
192
|
+
private static readonly IDLE_FINISH_CONFIRM_MS;
|
|
170
193
|
private syncMessageViews;
|
|
171
194
|
private normalizeParsedMessages;
|
|
172
195
|
private sliceFromOffset;
|
|
173
196
|
private buildParseInput;
|
|
174
197
|
private setStatus;
|
|
198
|
+
private clearIdleFinishCandidate;
|
|
199
|
+
private armIdleFinishCandidate;
|
|
200
|
+
private summarizeTraceText;
|
|
201
|
+
private summarizeTraceMessages;
|
|
202
|
+
private buildTraceParseSnapshot;
|
|
203
|
+
private recordTrace;
|
|
204
|
+
private resetTraceSession;
|
|
175
205
|
private readonly timeouts;
|
|
176
206
|
private readonly approvalKeys;
|
|
177
207
|
private readonly sendDelayMs;
|
|
@@ -190,6 +220,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
|
|
|
190
220
|
private scheduleSettle;
|
|
191
221
|
private armApprovalExitTimeout;
|
|
192
222
|
private looksLikeVisibleIdlePrompt;
|
|
223
|
+
private waitForInteractivePrompt;
|
|
193
224
|
private evaluateSettled;
|
|
194
225
|
private finishResponse;
|
|
195
226
|
private commitCurrentTranscript;
|
|
@@ -225,5 +256,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
|
|
|
225
256
|
resolveModal(buttonIndex: number): void;
|
|
226
257
|
resize(cols: number, rows: number): void;
|
|
227
258
|
getDebugState(): Record<string, any>;
|
|
259
|
+
getTraceState(limit?: number): Record<string, any>;
|
|
260
|
+
getProviderResolutionMeta(): Record<string, any>;
|
|
228
261
|
private respondToTerminalQueries;
|
|
229
262
|
}
|
|
@@ -3,6 +3,7 @@ import type { PtyRuntimeTransport, PtySpawnOptions, PtyTransportFactory } from '
|
|
|
3
3
|
interface SessionHostPtyTransportFactoryOptions {
|
|
4
4
|
endpoint?: SessionHostEndpoint;
|
|
5
5
|
appName?: string;
|
|
6
|
+
ensureReady?: () => Promise<void>;
|
|
6
7
|
clientId: string;
|
|
7
8
|
runtimeId: string;
|
|
8
9
|
providerType: string;
|
|
@@ -14,6 +14,7 @@ interface HistoryMessage {
|
|
|
14
14
|
role: 'user' | 'assistant' | 'system';
|
|
15
15
|
content: string;
|
|
16
16
|
kind?: string;
|
|
17
|
+
senderName?: string;
|
|
17
18
|
agent: string;
|
|
18
19
|
instanceId?: string;
|
|
19
20
|
historySessionId?: string;
|
|
@@ -46,6 +47,7 @@ export declare class ChatHistoryWriter {
|
|
|
46
47
|
content: string;
|
|
47
48
|
receivedAt?: number;
|
|
48
49
|
kind?: string;
|
|
50
|
+
senderName?: string;
|
|
49
51
|
historyDedupKey?: string;
|
|
50
52
|
}>, sessionTitle?: string, instanceId?: string, historySessionId?: string): void;
|
|
51
53
|
appendSystemMarker(agentType: string, content: string, options?: {
|
|
@@ -54,6 +56,7 @@ export declare class ChatHistoryWriter {
|
|
|
54
56
|
historySessionId?: string;
|
|
55
57
|
dedupKey?: string;
|
|
56
58
|
receivedAt?: number;
|
|
59
|
+
senderName?: string;
|
|
57
60
|
}): void;
|
|
58
61
|
promoteHistorySession(agentType: string, previousHistorySessionId: string, nextHistorySessionId: string): void;
|
|
59
62
|
/** Called when agent session is explicitly changed */
|
package/dist/config/config.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export interface ADHDevConfig {
|
|
|
42
42
|
* Server-side D1 `machines.id` — the row ID assigned when daemon registers via
|
|
43
43
|
* `POST /cli/complete`. Used as fallback for machine lookup on re-auth.
|
|
44
44
|
*
|
|
45
|
-
* @deprecated Legacy bridge field — will be removed after 2026-
|
|
45
|
+
* @deprecated Legacy bridge field — will be removed after 2026-05-01.
|
|
46
46
|
* Modern auth flow uses `machineSecret` (adm_) to identify machines.
|
|
47
47
|
*/
|
|
48
48
|
registeredMachineId?: string;
|
|
@@ -7,6 +7,21 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type * as http from 'http';
|
|
9
9
|
import type { DevServerContext, ProviderCategory } from './dev-server-types.js';
|
|
10
|
+
type CliExerciseVerification = {
|
|
11
|
+
request?: Record<string, any>;
|
|
12
|
+
mustContainAny?: string[];
|
|
13
|
+
mustNotContainAny?: string[];
|
|
14
|
+
mustMatchAny?: string[];
|
|
15
|
+
mustNotMatchAny?: string[];
|
|
16
|
+
lastAssistantMustContainAny?: string[];
|
|
17
|
+
lastAssistantMustNotContainAny?: string[];
|
|
18
|
+
lastAssistantMustMatchAny?: string[];
|
|
19
|
+
lastAssistantMustNotMatchAny?: string[];
|
|
20
|
+
inspectFields?: string[];
|
|
21
|
+
description?: string;
|
|
22
|
+
fixtureName?: string;
|
|
23
|
+
fixtureNames?: string[];
|
|
24
|
+
};
|
|
10
25
|
export declare function getDefaultAutoImplReference(ctx: DevServerContext, category: string, type: string): string;
|
|
11
26
|
export declare function resolveAutoImplReference(ctx: DevServerContext, category: string, requestedReference: string | undefined, targetType: string): string | null;
|
|
12
27
|
export declare function getLatestScriptVersionDir(scriptsDir: string): string | null;
|
|
@@ -16,11 +31,12 @@ export declare function resolveAutoImplWritableProviderDir(ctx: DevServerContext
|
|
|
16
31
|
};
|
|
17
32
|
export declare function loadAutoImplReferenceScripts(ctx: DevServerContext, referenceType: string | null): Record<string, string>;
|
|
18
33
|
export declare function handleAutoImplement(ctx: DevServerContext, type: string, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
19
|
-
export declare function buildAutoImplPrompt(ctx: DevServerContext, type: string, provider: any, providerDir: string, functions: string[], domContext: any, referenceScripts: Record<string, string>, userComment?: string, referenceType?: string | null): string;
|
|
20
|
-
export declare function buildCliAutoImplPrompt(ctx: DevServerContext, type: string, provider: any, providerDir: string, functions: string[], referenceScripts: Record<string, string>, userComment?: string, referenceType?: string | null): string;
|
|
34
|
+
export declare function buildAutoImplPrompt(ctx: DevServerContext, type: string, provider: any, providerDir: string, functions: string[], domContext: any, referenceScripts: Record<string, string>, userComment?: string, referenceType?: string | null, verification?: CliExerciseVerification): string;
|
|
35
|
+
export declare function buildCliAutoImplPrompt(ctx: DevServerContext, type: string, provider: any, providerDir: string, functions: string[], referenceScripts: Record<string, string>, userComment?: string, referenceType?: string | null, verification?: CliExerciseVerification): string;
|
|
21
36
|
export declare function handleAutoImplSSE(ctx: DevServerContext, type: string, req: http.IncomingMessage, res: http.ServerResponse): void;
|
|
22
37
|
export declare function handleAutoImplCancel(ctx: DevServerContext, _type: string, _req: http.IncomingMessage, res: http.ServerResponse): void;
|
|
23
38
|
export declare function sendAutoImplSSE(ctx: DevServerContext, msg: {
|
|
24
39
|
event: string;
|
|
25
40
|
data: any;
|
|
26
41
|
}): void;
|
|
42
|
+
export {};
|
|
@@ -6,6 +6,77 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type * as http from 'http';
|
|
8
8
|
import type { DevServerContext } from './dev-server-types.js';
|
|
9
|
+
type CliExerciseRequest = {
|
|
10
|
+
type?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
instanceId?: string;
|
|
13
|
+
workingDir?: string;
|
|
14
|
+
args?: string[];
|
|
15
|
+
autoLaunch?: boolean;
|
|
16
|
+
freshSession?: boolean;
|
|
17
|
+
autoResolveApprovals?: boolean;
|
|
18
|
+
approvalButtonIndex?: number;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
readyTimeoutMs?: number;
|
|
21
|
+
idleSettledMs?: number;
|
|
22
|
+
traceLimit?: number;
|
|
23
|
+
stopWhenDone?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type CliFixtureAssertions = {
|
|
26
|
+
mustContainAny?: string[];
|
|
27
|
+
mustNotContainAny?: string[];
|
|
28
|
+
mustMatchAny?: string[];
|
|
29
|
+
mustNotMatchAny?: string[];
|
|
30
|
+
lastAssistantMustContainAny?: string[];
|
|
31
|
+
lastAssistantMustNotContainAny?: string[];
|
|
32
|
+
lastAssistantMustMatchAny?: string[];
|
|
33
|
+
lastAssistantMustNotMatchAny?: string[];
|
|
34
|
+
statusesSeen?: string[];
|
|
35
|
+
requireNotTimedOut?: boolean;
|
|
36
|
+
};
|
|
37
|
+
type CliExerciseFixture = {
|
|
38
|
+
version: 1;
|
|
39
|
+
kind: 'cli-exercise-fixture';
|
|
40
|
+
name: string;
|
|
41
|
+
type: string;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
providerDir: string | null;
|
|
44
|
+
providerResolution: Record<string, any> | null;
|
|
45
|
+
request: CliExerciseRequest;
|
|
46
|
+
result: Record<string, any>;
|
|
47
|
+
assertions: CliFixtureAssertions;
|
|
48
|
+
notes?: string;
|
|
49
|
+
};
|
|
50
|
+
export declare function validateCliFixtureResult(result: any, assertions: CliFixtureAssertions): string[];
|
|
51
|
+
export declare function runCliExerciseInternal(ctx: DevServerContext, body: CliExerciseRequest): Promise<Record<string, any>>;
|
|
52
|
+
export declare function runCliAutoImplVerification(ctx: DevServerContext, type: string, verification?: {
|
|
53
|
+
request?: Record<string, any>;
|
|
54
|
+
mustContainAny?: string[];
|
|
55
|
+
mustNotContainAny?: string[];
|
|
56
|
+
mustMatchAny?: string[];
|
|
57
|
+
mustNotMatchAny?: string[];
|
|
58
|
+
lastAssistantMustContainAny?: string[];
|
|
59
|
+
lastAssistantMustNotContainAny?: string[];
|
|
60
|
+
lastAssistantMustMatchAny?: string[];
|
|
61
|
+
lastAssistantMustNotMatchAny?: string[];
|
|
62
|
+
fixtureName?: string;
|
|
63
|
+
fixtureNames?: string[];
|
|
64
|
+
}): Promise<{
|
|
65
|
+
mode: 'fixture_replay' | 'fixture_replay_suite' | 'exercise';
|
|
66
|
+
pass: boolean;
|
|
67
|
+
failures: string[];
|
|
68
|
+
result: Record<string, any>;
|
|
69
|
+
assertions: CliFixtureAssertions;
|
|
70
|
+
fixture?: CliExerciseFixture;
|
|
71
|
+
results?: Array<{
|
|
72
|
+
fixtureName: string;
|
|
73
|
+
pass: boolean;
|
|
74
|
+
failures: string[];
|
|
75
|
+
result: Record<string, any>;
|
|
76
|
+
assertions: CliFixtureAssertions;
|
|
77
|
+
fixture: CliExerciseFixture;
|
|
78
|
+
}>;
|
|
79
|
+
}>;
|
|
9
80
|
/** GET /api/cli/status — list all running CLI/ACP instances with state */
|
|
10
81
|
export declare function handleCliStatus(ctx: DevServerContext, _req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
11
82
|
/** POST /api/cli/launch — launch a CLI agent { type, workingDir?, args? } */
|
|
@@ -18,7 +89,18 @@ export declare function handleCliStop(ctx: DevServerContext, req: http.IncomingM
|
|
|
18
89
|
export declare function handleCliSSE(ctx: DevServerContext, cliSSEClients: http.ServerResponse[], _req: http.IncomingMessage, res: http.ServerResponse): void;
|
|
19
90
|
/** GET /api/cli/debug/:type — full internal debug state of a CLI adapter */
|
|
20
91
|
export declare function handleCliDebug(ctx: DevServerContext, type: string, _req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
92
|
+
/** GET /api/cli/trace/:type — recent CLI trace timeline plus current debug snapshot */
|
|
93
|
+
export declare function handleCliTrace(ctx: DevServerContext, type: string, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
94
|
+
/** POST /api/cli/exercise — autonomously run a CLI repro and wait for final settled trace */
|
|
95
|
+
export declare function handleCliExercise(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
96
|
+
/** POST /api/cli/fixture/capture — run exact exercise once and persist it as a reusable fixture */
|
|
97
|
+
export declare function handleCliFixtureCapture(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
98
|
+
/** GET /api/cli/fixtures/:type — list saved exercise fixtures for a provider */
|
|
99
|
+
export declare function handleCliFixtureList(ctx: DevServerContext, type: string, _req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
100
|
+
/** POST /api/cli/fixture/replay — rerun a saved exact exercise and validate against saved assertions */
|
|
101
|
+
export declare function handleCliFixtureReplay(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
21
102
|
/** POST /api/cli/resolve — resolve an approval modal { type, buttonIndex } */
|
|
22
103
|
export declare function handleCliResolve(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
23
104
|
/** POST /api/cli/raw — send raw keystrokes to PTY { type, keys } */
|
|
24
105
|
export declare function handleCliRaw(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
106
|
+
export {};
|
|
@@ -119,6 +119,10 @@ export declare class DevServer implements DevServerContext {
|
|
|
119
119
|
private handleCliLaunch;
|
|
120
120
|
/** POST /api/cli/send — send message to a running CLI { type, text } */
|
|
121
121
|
private handleCliSend;
|
|
122
|
+
/** POST /api/cli/exercise — launch/send/approve/wait helper for provider-fix loops */
|
|
123
|
+
private handleCliExercise;
|
|
124
|
+
private handleCliFixtureCapture;
|
|
125
|
+
private handleCliFixtureReplay;
|
|
122
126
|
/** POST /api/cli/stop — stop a running CLI { type } */
|
|
123
127
|
private handleCliStop;
|
|
124
128
|
/** GET /api/cli/events — SSE stream of CLI status events */
|
|
@@ -126,6 +130,9 @@ export declare class DevServer implements DevServerContext {
|
|
|
126
130
|
sendCliSSE(data: any): void;
|
|
127
131
|
/** GET /api/cli/debug/:type — full internal debug state of a CLI adapter */
|
|
128
132
|
private handleCliDebug;
|
|
133
|
+
/** GET /api/cli/trace/:type — recent CLI trace timeline plus current debug snapshot */
|
|
134
|
+
private handleCliTrace;
|
|
135
|
+
private handleCliFixtureList;
|
|
129
136
|
/** POST /api/cli/resolve — resolve an approval modal { type, buttonIndex } */
|
|
130
137
|
private handleCliResolve;
|
|
131
138
|
/** POST /api/cli/raw — send raw keystrokes to PTY { type, keys } */
|