@adhdev/daemon-core 0.9.77-rc.34 → 0.9.77-rc.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/cli-adapters/provider-cli-adapter.d.ts +1 -0
- package/dist/index.js +29 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +14 -3
- package/src/commands/router.ts +7 -1
- package/src/mesh/mesh-events.ts +8 -1
package/package.json
CHANGED
|
@@ -1456,6 +1456,14 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
1456
1456
|
|
|
1457
1457
|
// ─── Script Execution ──────────────────────────
|
|
1458
1458
|
|
|
1459
|
+
private invokeCliScript<T>(script: Function, input: any): T {
|
|
1460
|
+
const hasStateFactory = typeof this.cliScripts?.createState === 'function';
|
|
1461
|
+
const expectsStateArgument = hasStateFactory || this.scriptState !== null || script.length >= 2;
|
|
1462
|
+
return expectsStateArgument
|
|
1463
|
+
? script(this.scriptState, input)
|
|
1464
|
+
: script(input);
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1459
1467
|
private runParseSession(): ParsedSession | null {
|
|
1460
1468
|
if (typeof this.cliScripts?.parseSession !== 'function') {
|
|
1461
1469
|
this.parseErrorMessage = `${this.cliType} parseSession unavailable`;
|
|
@@ -1476,7 +1484,10 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
1476
1484
|
scope: this.currentTurnScope,
|
|
1477
1485
|
runtimeSettings: this.runtimeSettings,
|
|
1478
1486
|
});
|
|
1479
|
-
const session = this.
|
|
1487
|
+
const session = this.invokeCliScript<ParsedSession | null>(
|
|
1488
|
+
this.cliScripts.parseSession,
|
|
1489
|
+
{ ...input, tail, tailScreen: buildCliScreenSnapshot(tail) },
|
|
1490
|
+
);
|
|
1480
1491
|
this.parseErrorMessage = null;
|
|
1481
1492
|
return session && typeof session === 'object' ? session : null;
|
|
1482
1493
|
} catch (e: any) {
|
|
@@ -1491,7 +1502,7 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
1491
1502
|
if (!this.cliScripts?.detectStatus) return null;
|
|
1492
1503
|
try {
|
|
1493
1504
|
const screenText = this.terminalScreen.getText();
|
|
1494
|
-
const status = this.cliScripts.detectStatus
|
|
1505
|
+
const status = this.invokeCliScript<string | null>(this.cliScripts.detectStatus, {
|
|
1495
1506
|
tail: text.slice(-500),
|
|
1496
1507
|
screenText,
|
|
1497
1508
|
rawBuffer: this.accumulatedRawBuffer,
|
|
@@ -1511,7 +1522,7 @@ export class ProviderCliAdapter implements CliAdapter {
|
|
|
1511
1522
|
try {
|
|
1512
1523
|
const screenText = this.terminalScreen.getText();
|
|
1513
1524
|
const buffer = screenText || this.accumulatedBuffer;
|
|
1514
|
-
return this.cliScripts.parseApproval
|
|
1525
|
+
return this.invokeCliScript<{ message: string; buttons: string[] } | null>(this.cliScripts.parseApproval, {
|
|
1515
1526
|
buffer,
|
|
1516
1527
|
screenText,
|
|
1517
1528
|
rawBuffer: this.accumulatedRawBuffer,
|
package/src/commands/router.ts
CHANGED
|
@@ -1569,7 +1569,13 @@ export class DaemonCommandRouter {
|
|
|
1569
1569
|
appendLedgerEntry(meshId, {
|
|
1570
1570
|
kind: 'node_removed',
|
|
1571
1571
|
nodeId,
|
|
1572
|
-
payload: {
|
|
1572
|
+
payload: {
|
|
1573
|
+
worktree: !!node?.isLocalWorktree,
|
|
1574
|
+
sessionCleanupMode,
|
|
1575
|
+
workspace: typeof node?.workspace === 'string' ? node.workspace : undefined,
|
|
1576
|
+
daemonId: typeof node?.daemonId === 'string' ? node.daemonId : undefined,
|
|
1577
|
+
worktreeBranch: typeof node?.worktreeBranch === 'string' ? node.worktreeBranch : undefined,
|
|
1578
|
+
},
|
|
1573
1579
|
});
|
|
1574
1580
|
} catch { /* ledger append is best-effort */ }
|
|
1575
1581
|
}
|
package/src/mesh/mesh-events.ts
CHANGED
|
@@ -240,13 +240,15 @@ function injectMeshSystemMessage(components: DaemonComponents, args: {
|
|
|
240
240
|
metadataEvent: Record<string, unknown>;
|
|
241
241
|
}) {
|
|
242
242
|
// ── Task Queue & Ledger ──
|
|
243
|
+
let completedTaskForLedger: { id?: string } | null = null;
|
|
243
244
|
if (args.event === 'agent:generating_completed') {
|
|
244
245
|
const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
245
246
|
const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
|
|
246
247
|
const providerType = readNonEmptyString(args.metadataEvent.providerType);
|
|
247
248
|
|
|
248
249
|
if (sessionId) {
|
|
249
|
-
updateSessionTaskStatus(args.meshId, sessionId, 'completed');
|
|
250
|
+
const completedTask = updateSessionTaskStatus(args.meshId, sessionId, 'completed');
|
|
251
|
+
completedTaskForLedger = completedTask ? { id: completedTask.id } : null;
|
|
250
252
|
if (nodeId && providerType) {
|
|
251
253
|
// Short delay to allow completion event to propagate before pulling next
|
|
252
254
|
setTimeout(() => {
|
|
@@ -262,6 +264,7 @@ function injectMeshSystemMessage(components: DaemonComponents, args: {
|
|
|
262
264
|
? updateSessionTaskStatus(args.meshId, sessionId, 'completed')
|
|
263
265
|
: null;
|
|
264
266
|
if (completedTask) {
|
|
267
|
+
completedTaskForLedger = { id: completedTask.id };
|
|
265
268
|
try {
|
|
266
269
|
appendLedgerEntry(args.meshId, {
|
|
267
270
|
kind: 'task_completed',
|
|
@@ -274,6 +277,7 @@ function injectMeshSystemMessage(components: DaemonComponents, args: {
|
|
|
274
277
|
taskId: completedTask.id,
|
|
275
278
|
completedViaReady: true,
|
|
276
279
|
providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || undefined,
|
|
280
|
+
finalSummary: readNonEmptyString(args.metadataEvent.finalSummary) || undefined,
|
|
277
281
|
},
|
|
278
282
|
});
|
|
279
283
|
} catch (e: any) {
|
|
@@ -318,7 +322,9 @@ function injectMeshSystemMessage(components: DaemonComponents, args: {
|
|
|
318
322
|
payload: {
|
|
319
323
|
event: args.event,
|
|
320
324
|
nodeLabel: args.nodeLabel,
|
|
325
|
+
taskId: completedTaskForLedger?.id || undefined,
|
|
321
326
|
providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || undefined,
|
|
327
|
+
finalSummary: readNonEmptyString(args.metadataEvent.finalSummary) || undefined,
|
|
322
328
|
},
|
|
323
329
|
});
|
|
324
330
|
} catch (e: any) {
|
|
@@ -451,6 +457,7 @@ export function handleMeshForwardEvent(components: DaemonComponents, payload: Re
|
|
|
451
457
|
targetSessionId: readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId) || readNonEmptyString(payload.instanceId),
|
|
452
458
|
providerType: readNonEmptyString(payload.providerType),
|
|
453
459
|
providerSessionId: readNonEmptyString(payload.providerSessionId),
|
|
460
|
+
finalSummary: readNonEmptyString(payload.finalSummary) || readNonEmptyString(payload.summary),
|
|
454
461
|
},
|
|
455
462
|
});
|
|
456
463
|
}
|