@adhdev/daemon-core 0.9.35 → 0.9.36
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 +5 -0
- package/dist/index.js +88 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -22
- package/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +108 -32
|
@@ -117,6 +117,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
|
|
|
117
117
|
private resetTerminalScreen;
|
|
118
118
|
private getFreshParsedStatusCache;
|
|
119
119
|
private selectParseBaseMessages;
|
|
120
|
+
private messagesShareStableIdentity;
|
|
120
121
|
private messagesComparable;
|
|
121
122
|
private stitchParsedMessagesWithCommittedBase;
|
|
122
123
|
private getIdleFinishConfirmMs;
|
|
@@ -173,6 +174,10 @@ export declare class ProviderCliAdapter implements CliAdapter {
|
|
|
173
174
|
private suppressStaleParsedApproval;
|
|
174
175
|
getStatus(): CliSessionStatus;
|
|
175
176
|
seedCommittedMessages(messages: SeedCliChatMessage[]): void;
|
|
177
|
+
private getSharedCommittedPrefixLength;
|
|
178
|
+
private hydrateCommittedPrefixForParsedStatus;
|
|
179
|
+
private hydrateParsedMessagesForStatus;
|
|
180
|
+
private buildCommittedChatMessages;
|
|
176
181
|
/**
|
|
177
182
|
* Script-based full parse — returns ReadChatResult.
|
|
178
183
|
* Called by command handler / dashboard for rich content rendering.
|
package/dist/index.js
CHANGED
|
@@ -2227,7 +2227,16 @@ var init_provider_cli_adapter = __esm({
|
|
|
2227
2227
|
if (baseMessages.length <= _ProviderCliAdapter.PARSE_MESSAGE_TAIL_LIMIT) return baseMessages;
|
|
2228
2228
|
return baseMessages.slice(-_ProviderCliAdapter.PARSE_MESSAGE_TAIL_LIMIT);
|
|
2229
2229
|
}
|
|
2230
|
+
messagesShareStableIdentity(left, right) {
|
|
2231
|
+
if (left === right) return true;
|
|
2232
|
+
if (!left || !right) return false;
|
|
2233
|
+
if ((left.role || "") !== (right.role || "")) return false;
|
|
2234
|
+
if (left.id && right.id && String(left.id) === String(right.id)) return true;
|
|
2235
|
+
if (typeof left.index === "number" && typeof right.index === "number" && left.index === right.index) return true;
|
|
2236
|
+
return false;
|
|
2237
|
+
}
|
|
2230
2238
|
messagesComparable(left, right) {
|
|
2239
|
+
if (this.messagesShareStableIdentity(left, right)) return true;
|
|
2231
2240
|
if (!left || !right) return false;
|
|
2232
2241
|
if ((left.role || "") !== (right.role || "")) return false;
|
|
2233
2242
|
const leftText = normalizeComparableTranscriptText(left.content);
|
|
@@ -3378,6 +3387,69 @@ var init_provider_cli_adapter = __esm({
|
|
|
3378
3387
|
this.committedMessages = normalized;
|
|
3379
3388
|
this.syncMessageViews();
|
|
3380
3389
|
}
|
|
3390
|
+
getSharedCommittedPrefixLength(parsedMessages) {
|
|
3391
|
+
const committedMessages = this.committedMessages;
|
|
3392
|
+
const max = Math.min(parsedMessages.length, committedMessages.length);
|
|
3393
|
+
let index = 0;
|
|
3394
|
+
while (index < max && this.messagesShareStableIdentity(parsedMessages[index], committedMessages[index])) {
|
|
3395
|
+
index += 1;
|
|
3396
|
+
}
|
|
3397
|
+
return index;
|
|
3398
|
+
}
|
|
3399
|
+
hydrateCommittedPrefixForParsedStatus(parsedMessages) {
|
|
3400
|
+
const sharedPrefixLength = this.getSharedCommittedPrefixLength(parsedMessages);
|
|
3401
|
+
if (sharedPrefixLength !== this.committedMessages.length) return null;
|
|
3402
|
+
const committedHydratedMessages = this.committedMessages.map((message, index) => {
|
|
3403
|
+
const timestamp = typeof message.timestamp === "number" && Number.isFinite(message.timestamp) ? message.timestamp : this.lastOutputAt || this.currentTurnScope?.startedAt || Date.now();
|
|
3404
|
+
const contentValue = message.content;
|
|
3405
|
+
return {
|
|
3406
|
+
role: message.role,
|
|
3407
|
+
content: typeof contentValue === "string" ? contentValue : String(contentValue || ""),
|
|
3408
|
+
timestamp,
|
|
3409
|
+
receivedAt: typeof message.receivedAt === "number" && Number.isFinite(message.receivedAt) ? message.receivedAt : timestamp,
|
|
3410
|
+
kind: message.kind,
|
|
3411
|
+
id: message.id || `msg_${index}`,
|
|
3412
|
+
index: typeof message.index === "number" ? message.index : index,
|
|
3413
|
+
meta: message.meta,
|
|
3414
|
+
senderName: message.senderName
|
|
3415
|
+
};
|
|
3416
|
+
});
|
|
3417
|
+
const extraMessages = parsedMessages.slice(sharedPrefixLength);
|
|
3418
|
+
if (extraMessages.length === 0) return committedHydratedMessages;
|
|
3419
|
+
const extraHydratedMessages = hydrateCliParsedMessages(extraMessages, {
|
|
3420
|
+
committedMessages: [],
|
|
3421
|
+
scope: this.currentTurnScope,
|
|
3422
|
+
lastOutputAt: this.lastOutputAt
|
|
3423
|
+
}).map((message, offset) => ({
|
|
3424
|
+
...message,
|
|
3425
|
+
id: message.id || `msg_${sharedPrefixLength + offset}`,
|
|
3426
|
+
index: typeof message.index === "number" ? message.index : sharedPrefixLength + offset
|
|
3427
|
+
}));
|
|
3428
|
+
return [...committedHydratedMessages, ...extraHydratedMessages];
|
|
3429
|
+
}
|
|
3430
|
+
hydrateParsedMessagesForStatus(parsedMessages) {
|
|
3431
|
+
return this.hydrateCommittedPrefixForParsedStatus(parsedMessages) || hydrateCliParsedMessages(parsedMessages, {
|
|
3432
|
+
committedMessages: this.committedMessages,
|
|
3433
|
+
scope: this.currentTurnScope,
|
|
3434
|
+
lastOutputAt: this.lastOutputAt
|
|
3435
|
+
});
|
|
3436
|
+
}
|
|
3437
|
+
buildCommittedChatMessages() {
|
|
3438
|
+
return this.committedMessages.map((message, index) => {
|
|
3439
|
+
const contentValue = message.content;
|
|
3440
|
+
return buildChatMessage({
|
|
3441
|
+
role: message.role,
|
|
3442
|
+
content: typeof contentValue === "string" ? contentValue : String(contentValue || ""),
|
|
3443
|
+
timestamp: message.timestamp,
|
|
3444
|
+
kind: message.kind,
|
|
3445
|
+
meta: message.meta,
|
|
3446
|
+
senderName: message.senderName,
|
|
3447
|
+
id: message.id || `msg_${index}`,
|
|
3448
|
+
index: typeof message.index === "number" ? message.index : index,
|
|
3449
|
+
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
3450
|
+
});
|
|
3451
|
+
});
|
|
3452
|
+
}
|
|
3381
3453
|
/**
|
|
3382
3454
|
* Script-based full parse — returns ReadChatResult.
|
|
3383
3455
|
* Called by command handler / dashboard for rich content rendering.
|
|
@@ -3403,7 +3475,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
3403
3475
|
this.onStatusChange?.();
|
|
3404
3476
|
}
|
|
3405
3477
|
}
|
|
3406
|
-
if (parsed && Array.isArray(parsed.messages)) {
|
|
3478
|
+
if (parsed && Array.isArray(parsed.messages) && this.provider.allowInputDuringGeneration === true) {
|
|
3407
3479
|
const hydratedForCommit = normalizeCliParsedMessages(parsed.messages, {
|
|
3408
3480
|
committedMessages: this.committedMessages,
|
|
3409
3481
|
scope: this.currentTurnScope,
|
|
@@ -3422,21 +3494,21 @@ var init_provider_cli_adapter = __esm({
|
|
|
3422
3494
|
const shouldPreferCommittedMessages = !this.currentTurnScope && !this.activeModal && this.currentStatus === "idle";
|
|
3423
3495
|
let result;
|
|
3424
3496
|
if (parsed && Array.isArray(parsed.messages)) {
|
|
3425
|
-
const parsedHydratedMessages =
|
|
3426
|
-
committedMessages: this.committedMessages,
|
|
3427
|
-
scope: this.currentTurnScope,
|
|
3428
|
-
lastOutputAt: this.lastOutputAt
|
|
3429
|
-
});
|
|
3430
|
-
const committedHydratedMessages = this.committedMessages.map((message, index) => buildChatMessage({
|
|
3431
|
-
...message,
|
|
3432
|
-
id: message.id || `msg_${index}`,
|
|
3433
|
-
index: typeof message.index === "number" ? message.index : index,
|
|
3434
|
-
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
3435
|
-
}));
|
|
3497
|
+
const parsedHydratedMessages = this.hydrateParsedMessagesForStatus(parsed.messages);
|
|
3436
3498
|
const parsedLastAssistant = [...parsedHydratedMessages].reverse().find((message) => message.role === "assistant" && typeof message.content === "string" && message.content.trim());
|
|
3437
|
-
const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedTranscriptIsRicherThanCommitted(parsedHydratedMessages,
|
|
3499
|
+
const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedTranscriptIsRicherThanCommitted(parsedHydratedMessages, this.committedMessages) && (this.currentStatus === "idle" || this.currentStatus === "generating" && this.isWaitingForResponse && parsed.status === "idle" && this.runDetectStatus(this.recentOutputBuffer) === "idle");
|
|
3438
3500
|
if (shouldAdoptParsedIdleReplay) {
|
|
3439
|
-
this.committedMessages =
|
|
3501
|
+
this.committedMessages = this.getSharedCommittedPrefixLength(parsed.messages) === this.committedMessages.length ? parsedHydratedMessages.map((message) => ({
|
|
3502
|
+
role: message.role,
|
|
3503
|
+
content: typeof message.content === "string" ? message.content : String(message.content || ""),
|
|
3504
|
+
timestamp: message.timestamp,
|
|
3505
|
+
receivedAt: message.receivedAt,
|
|
3506
|
+
kind: message.kind,
|
|
3507
|
+
id: message.id,
|
|
3508
|
+
index: message.index,
|
|
3509
|
+
meta: message.meta,
|
|
3510
|
+
senderName: message.senderName
|
|
3511
|
+
})) : normalizeCliParsedMessages(parsed.messages, {
|
|
3440
3512
|
committedMessages: this.committedMessages,
|
|
3441
3513
|
scope: this.currentTurnScope,
|
|
3442
3514
|
lastOutputAt: this.lastOutputAt
|
|
@@ -3455,15 +3527,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
3455
3527
|
this.onStatusChange?.();
|
|
3456
3528
|
}
|
|
3457
3529
|
}
|
|
3458
|
-
const
|
|
3459
|
-
...message,
|
|
3460
|
-
id: message.id || `msg_${index}`,
|
|
3461
|
-
index: typeof message.index === "number" ? message.index : index,
|
|
3462
|
-
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
3463
|
-
})) : committedHydratedMessages;
|
|
3464
|
-
const shouldPreferCommittedHistoryReplay = !this.currentTurnScope && !this.activeModal && effectiveCommittedHydratedMessages.length > parsedHydratedMessages.length;
|
|
3530
|
+
const shouldPreferCommittedHistoryReplay = !this.currentTurnScope && !this.activeModal && this.committedMessages.length > parsedHydratedMessages.length;
|
|
3465
3531
|
const shouldPreferCommittedIdleReplay = shouldPreferCommittedMessages && !shouldAdoptParsedIdleReplay;
|
|
3466
|
-
const hydratedMessages = shouldPreferCommittedIdleReplay || shouldPreferCommittedHistoryReplay ?
|
|
3532
|
+
const hydratedMessages = shouldPreferCommittedIdleReplay || shouldPreferCommittedHistoryReplay ? this.buildCommittedChatMessages() : parsedHydratedMessages;
|
|
3467
3533
|
result = {
|
|
3468
3534
|
id: parsed.id || "cli_session",
|
|
3469
3535
|
status: parsed.status || this.currentStatus,
|