@adhdev/daemon-core 0.9.82-rc.201 → 0.9.82-rc.203
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.js +5280 -5222
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5289 -5231
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/providers/spec/cli-adapter.ts +61 -0
- package/src/providers/spec/evaluator.ts +7 -3
- package/src/providers/spec/schema.json +18 -1
package/package.json
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
import { SpecDriver, type DashboardEvent } from './driver.js';
|
|
22
22
|
import { evaluate } from './evaluator.js';
|
|
23
|
+
import { executeNativeHistory } from './native-history-executor.js';
|
|
23
24
|
import { loadSpec } from './loader.js';
|
|
24
25
|
import type { CliSpec } from './types.js';
|
|
25
26
|
import type { CliAdapter, CliAdapterStatus } from '../../cli-adapter-types.js';
|
|
@@ -340,6 +341,22 @@ export class SpecCliAdapter implements CliAdapter {
|
|
|
340
341
|
sections[(sec as any).id] = lines.slice(start, end).join('\n');
|
|
341
342
|
}
|
|
342
343
|
} catch { /* best-effort */ }
|
|
344
|
+
// Read native transcript messages for the debug snapshot
|
|
345
|
+
let messages: any[] = [];
|
|
346
|
+
if (this.spec.native_history?.source) {
|
|
347
|
+
try {
|
|
348
|
+
const nhResult = executeNativeHistory(this.spec.native_history, {
|
|
349
|
+
agentType: this.cliType,
|
|
350
|
+
providerSessionId: this.providerSessionId,
|
|
351
|
+
sessionStartedAtMs: this.spawnedAtMs,
|
|
352
|
+
envOverrides: this.spawnedEnv,
|
|
353
|
+
workspace: this.workingDir,
|
|
354
|
+
});
|
|
355
|
+
if (nhResult && Array.isArray(nhResult.messages)) messages = nhResult.messages;
|
|
356
|
+
} catch { /* best-effort */ }
|
|
357
|
+
} else {
|
|
358
|
+
messages = this.readClaudeScreenAssistantMessages();
|
|
359
|
+
}
|
|
343
360
|
return {
|
|
344
361
|
cliType: this.cliType,
|
|
345
362
|
spec_id: this.spec.id,
|
|
@@ -353,6 +370,14 @@ export class SpecCliAdapter implements CliAdapter {
|
|
|
353
370
|
idleHoldPending: this.driver.hasIdleHoldPending(),
|
|
354
371
|
lastBusyAt: this.driver.getLastBusyAt(),
|
|
355
372
|
specPath: this.driver.getSpecPath(),
|
|
373
|
+
// Extended fields
|
|
374
|
+
name: this.cliName,
|
|
375
|
+
status: this.getStatus().status,
|
|
376
|
+
workingDir: this.workingDir,
|
|
377
|
+
spawnedAtMs: this.spawnedAtMs,
|
|
378
|
+
providerSessionId: this.providerSessionId ?? null,
|
|
379
|
+
messages,
|
|
380
|
+
committedMessages: messages,
|
|
356
381
|
};
|
|
357
382
|
}
|
|
358
383
|
getRuntimeMetadata(): unknown {
|
|
@@ -540,6 +565,29 @@ export class SpecCliAdapter implements CliAdapter {
|
|
|
540
565
|
const screen = this.driver.getScreen?.() ?? '';
|
|
541
566
|
const history = this.driver.getStateHistory();
|
|
542
567
|
const status = this.getStatus();
|
|
568
|
+
|
|
569
|
+
let messages: any[] = [];
|
|
570
|
+
if (this.spec.native_history?.source) {
|
|
571
|
+
try {
|
|
572
|
+
const result = executeNativeHistory(this.spec.native_history, {
|
|
573
|
+
agentType: this.cliType,
|
|
574
|
+
providerSessionId: this.providerSessionId,
|
|
575
|
+
sessionStartedAtMs: this.spawnedAtMs,
|
|
576
|
+
envOverrides: this.spawnedEnv,
|
|
577
|
+
workspace: this.workingDir,
|
|
578
|
+
});
|
|
579
|
+
if (result && Array.isArray(result.messages)) {
|
|
580
|
+
messages = result.messages;
|
|
581
|
+
}
|
|
582
|
+
} catch (e) {
|
|
583
|
+
// Ignore native history read errors in debug state
|
|
584
|
+
}
|
|
585
|
+
} else {
|
|
586
|
+
messages = this.readClaudeScreenAssistantMessages();
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
const latestState = this.latestState;
|
|
590
|
+
const latestModal = this.latestModal;
|
|
543
591
|
return {
|
|
544
592
|
type: this.cliType,
|
|
545
593
|
name: this.cliName,
|
|
@@ -547,10 +595,23 @@ export class SpecCliAdapter implements CliAdapter {
|
|
|
547
595
|
rawStatus: status.status,
|
|
548
596
|
projectedStatus: status.status,
|
|
549
597
|
ready: this.spawned,
|
|
598
|
+
// Legacy snapshot-style fields for panels that read getDebugSnapshot shape
|
|
599
|
+
spec_id: this.spec.id,
|
|
600
|
+
current_state: latestState ?? null,
|
|
601
|
+
current_modal: latestModal ?? null,
|
|
602
|
+
exited: this.exited,
|
|
603
|
+
idleHoldPending: this.driver.hasIdleHoldPending?.() ?? false,
|
|
604
|
+
lastBusyAt: this.driver.getLastBusyAt?.() ?? 0,
|
|
605
|
+
screen: screen,
|
|
550
606
|
screenText: screen,
|
|
607
|
+
workingDir: this.workingDir,
|
|
608
|
+
spawnedAtMs: this.spawnedAtMs,
|
|
609
|
+
providerSessionId: this.providerSessionId ?? null,
|
|
551
610
|
sections: this.driver.getSections?.() ?? null,
|
|
552
611
|
stateHistory: history,
|
|
553
612
|
specPath: (this.driver as any).opts?.specPath ?? null,
|
|
613
|
+
messages,
|
|
614
|
+
committedMessages: messages,
|
|
554
615
|
};
|
|
555
616
|
}
|
|
556
617
|
|
|
@@ -281,7 +281,11 @@ export function evaluate(
|
|
|
281
281
|
cursor?: { row: number; col: number },
|
|
282
282
|
): SpecEvaluation {
|
|
283
283
|
const trace: TraceEntry[] = [];
|
|
284
|
-
const lines = screenText.split('\n');
|
|
284
|
+
const lines = screenText.split('\n').map(l => l.endsWith('\r') ? l.slice(0, -1) : l);
|
|
285
|
+
// Use \r-stripped text for all regex matching so that anchor patterns
|
|
286
|
+
// like ^[─╌]+$ and full-screen when-regex work correctly against PTY
|
|
287
|
+
// output where lines end with \r\n rather than plain \n.
|
|
288
|
+
const cleanScreen = lines.join('\n');
|
|
285
289
|
const sections = resolveSections(spec, lines);
|
|
286
290
|
for (const s of sections) {
|
|
287
291
|
trace.push({ kind: 'section', text: `section[${s.id}] lines [${s.fromLine}, ${s.toLine}) (${s.toLine - s.fromLine} lines)` });
|
|
@@ -294,9 +298,9 @@ export function evaluate(
|
|
|
294
298
|
let modal: ModalSnapshot | null = null;
|
|
295
299
|
|
|
296
300
|
for (const st of spec.states) {
|
|
297
|
-
const { matched, title } = matchState(st, sections,
|
|
301
|
+
const { matched, title } = matchState(st, sections, cleanScreen, trace, cursor);
|
|
298
302
|
if (!matched) continue;
|
|
299
|
-
const extractedModal = extractModal(st, sections,
|
|
303
|
+
const extractedModal = extractModal(st, sections, cleanScreen, title, trace);
|
|
300
304
|
// If the state declares modal_buttons but extraction failed (button
|
|
301
305
|
// count below min_count, or text-was-mistaken-for-modal), do not
|
|
302
306
|
// promote the state. Otherwise we would surface a phantom approval
|
|
@@ -77,7 +77,8 @@
|
|
|
77
77
|
"section": { "type": "string", "minLength": 1 },
|
|
78
78
|
"regex": { "type": "string", "minLength": 1 },
|
|
79
79
|
"flags": { "type": "string" },
|
|
80
|
-
"hold_ms": { "type": "integer", "minimum": 0 }
|
|
80
|
+
"hold_ms": { "type": "integer", "minimum": 0 },
|
|
81
|
+
"force_after_ms": { "type": "integer", "minimum": 0 }
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
}
|
|
@@ -98,6 +99,22 @@
|
|
|
98
99
|
"id": { "type": "string", "minLength": 1, "pattern": "^[a-z][a-z0-9_]*$" },
|
|
99
100
|
"from_top": { "$ref": "#/definitions/size" },
|
|
100
101
|
"from_bottom": { "$ref": "#/definitions/size" },
|
|
102
|
+
"lines": { "type": "integer", "minimum": 1 },
|
|
103
|
+
"anchor_regex": { "type": "string", "minLength": 1 },
|
|
104
|
+
"anchor_flags": { "type": "string" },
|
|
105
|
+
"anchor_last": { "type": "boolean" },
|
|
106
|
+
"anchor_context": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"additionalProperties": false,
|
|
109
|
+
"properties": {
|
|
110
|
+
"prev": { "type": "string" },
|
|
111
|
+
"prev_flags": { "type": "string" },
|
|
112
|
+
"next": { "type": "string" },
|
|
113
|
+
"next_flags": { "type": "string" }
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"until_regex": { "type": "string", "minLength": 1 },
|
|
117
|
+
"until_regex_flags": { "type": "string" },
|
|
101
118
|
"until": {
|
|
102
119
|
"type": "object",
|
|
103
120
|
"additionalProperties": false,
|