@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
package/dist/index.mjs
CHANGED
|
@@ -2224,7 +2224,16 @@ var init_provider_cli_adapter = __esm({
|
|
|
2224
2224
|
if (baseMessages.length <= _ProviderCliAdapter.PARSE_MESSAGE_TAIL_LIMIT) return baseMessages;
|
|
2225
2225
|
return baseMessages.slice(-_ProviderCliAdapter.PARSE_MESSAGE_TAIL_LIMIT);
|
|
2226
2226
|
}
|
|
2227
|
+
messagesShareStableIdentity(left, right) {
|
|
2228
|
+
if (left === right) return true;
|
|
2229
|
+
if (!left || !right) return false;
|
|
2230
|
+
if ((left.role || "") !== (right.role || "")) return false;
|
|
2231
|
+
if (left.id && right.id && String(left.id) === String(right.id)) return true;
|
|
2232
|
+
if (typeof left.index === "number" && typeof right.index === "number" && left.index === right.index) return true;
|
|
2233
|
+
return false;
|
|
2234
|
+
}
|
|
2227
2235
|
messagesComparable(left, right) {
|
|
2236
|
+
if (this.messagesShareStableIdentity(left, right)) return true;
|
|
2228
2237
|
if (!left || !right) return false;
|
|
2229
2238
|
if ((left.role || "") !== (right.role || "")) return false;
|
|
2230
2239
|
const leftText = normalizeComparableTranscriptText(left.content);
|
|
@@ -3375,6 +3384,69 @@ var init_provider_cli_adapter = __esm({
|
|
|
3375
3384
|
this.committedMessages = normalized;
|
|
3376
3385
|
this.syncMessageViews();
|
|
3377
3386
|
}
|
|
3387
|
+
getSharedCommittedPrefixLength(parsedMessages) {
|
|
3388
|
+
const committedMessages = this.committedMessages;
|
|
3389
|
+
const max = Math.min(parsedMessages.length, committedMessages.length);
|
|
3390
|
+
let index = 0;
|
|
3391
|
+
while (index < max && this.messagesShareStableIdentity(parsedMessages[index], committedMessages[index])) {
|
|
3392
|
+
index += 1;
|
|
3393
|
+
}
|
|
3394
|
+
return index;
|
|
3395
|
+
}
|
|
3396
|
+
hydrateCommittedPrefixForParsedStatus(parsedMessages) {
|
|
3397
|
+
const sharedPrefixLength = this.getSharedCommittedPrefixLength(parsedMessages);
|
|
3398
|
+
if (sharedPrefixLength !== this.committedMessages.length) return null;
|
|
3399
|
+
const committedHydratedMessages = this.committedMessages.map((message, index) => {
|
|
3400
|
+
const timestamp = typeof message.timestamp === "number" && Number.isFinite(message.timestamp) ? message.timestamp : this.lastOutputAt || this.currentTurnScope?.startedAt || Date.now();
|
|
3401
|
+
const contentValue = message.content;
|
|
3402
|
+
return {
|
|
3403
|
+
role: message.role,
|
|
3404
|
+
content: typeof contentValue === "string" ? contentValue : String(contentValue || ""),
|
|
3405
|
+
timestamp,
|
|
3406
|
+
receivedAt: typeof message.receivedAt === "number" && Number.isFinite(message.receivedAt) ? message.receivedAt : timestamp,
|
|
3407
|
+
kind: message.kind,
|
|
3408
|
+
id: message.id || `msg_${index}`,
|
|
3409
|
+
index: typeof message.index === "number" ? message.index : index,
|
|
3410
|
+
meta: message.meta,
|
|
3411
|
+
senderName: message.senderName
|
|
3412
|
+
};
|
|
3413
|
+
});
|
|
3414
|
+
const extraMessages = parsedMessages.slice(sharedPrefixLength);
|
|
3415
|
+
if (extraMessages.length === 0) return committedHydratedMessages;
|
|
3416
|
+
const extraHydratedMessages = hydrateCliParsedMessages(extraMessages, {
|
|
3417
|
+
committedMessages: [],
|
|
3418
|
+
scope: this.currentTurnScope,
|
|
3419
|
+
lastOutputAt: this.lastOutputAt
|
|
3420
|
+
}).map((message, offset) => ({
|
|
3421
|
+
...message,
|
|
3422
|
+
id: message.id || `msg_${sharedPrefixLength + offset}`,
|
|
3423
|
+
index: typeof message.index === "number" ? message.index : sharedPrefixLength + offset
|
|
3424
|
+
}));
|
|
3425
|
+
return [...committedHydratedMessages, ...extraHydratedMessages];
|
|
3426
|
+
}
|
|
3427
|
+
hydrateParsedMessagesForStatus(parsedMessages) {
|
|
3428
|
+
return this.hydrateCommittedPrefixForParsedStatus(parsedMessages) || hydrateCliParsedMessages(parsedMessages, {
|
|
3429
|
+
committedMessages: this.committedMessages,
|
|
3430
|
+
scope: this.currentTurnScope,
|
|
3431
|
+
lastOutputAt: this.lastOutputAt
|
|
3432
|
+
});
|
|
3433
|
+
}
|
|
3434
|
+
buildCommittedChatMessages() {
|
|
3435
|
+
return this.committedMessages.map((message, index) => {
|
|
3436
|
+
const contentValue = message.content;
|
|
3437
|
+
return buildChatMessage({
|
|
3438
|
+
role: message.role,
|
|
3439
|
+
content: typeof contentValue === "string" ? contentValue : String(contentValue || ""),
|
|
3440
|
+
timestamp: message.timestamp,
|
|
3441
|
+
kind: message.kind,
|
|
3442
|
+
meta: message.meta,
|
|
3443
|
+
senderName: message.senderName,
|
|
3444
|
+
id: message.id || `msg_${index}`,
|
|
3445
|
+
index: typeof message.index === "number" ? message.index : index,
|
|
3446
|
+
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
3447
|
+
});
|
|
3448
|
+
});
|
|
3449
|
+
}
|
|
3378
3450
|
/**
|
|
3379
3451
|
* Script-based full parse — returns ReadChatResult.
|
|
3380
3452
|
* Called by command handler / dashboard for rich content rendering.
|
|
@@ -3400,7 +3472,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
3400
3472
|
this.onStatusChange?.();
|
|
3401
3473
|
}
|
|
3402
3474
|
}
|
|
3403
|
-
if (parsed && Array.isArray(parsed.messages)) {
|
|
3475
|
+
if (parsed && Array.isArray(parsed.messages) && this.provider.allowInputDuringGeneration === true) {
|
|
3404
3476
|
const hydratedForCommit = normalizeCliParsedMessages(parsed.messages, {
|
|
3405
3477
|
committedMessages: this.committedMessages,
|
|
3406
3478
|
scope: this.currentTurnScope,
|
|
@@ -3419,21 +3491,21 @@ var init_provider_cli_adapter = __esm({
|
|
|
3419
3491
|
const shouldPreferCommittedMessages = !this.currentTurnScope && !this.activeModal && this.currentStatus === "idle";
|
|
3420
3492
|
let result;
|
|
3421
3493
|
if (parsed && Array.isArray(parsed.messages)) {
|
|
3422
|
-
const parsedHydratedMessages =
|
|
3423
|
-
committedMessages: this.committedMessages,
|
|
3424
|
-
scope: this.currentTurnScope,
|
|
3425
|
-
lastOutputAt: this.lastOutputAt
|
|
3426
|
-
});
|
|
3427
|
-
const committedHydratedMessages = this.committedMessages.map((message, index) => buildChatMessage({
|
|
3428
|
-
...message,
|
|
3429
|
-
id: message.id || `msg_${index}`,
|
|
3430
|
-
index: typeof message.index === "number" ? message.index : index,
|
|
3431
|
-
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
3432
|
-
}));
|
|
3494
|
+
const parsedHydratedMessages = this.hydrateParsedMessagesForStatus(parsed.messages);
|
|
3433
3495
|
const parsedLastAssistant = [...parsedHydratedMessages].reverse().find((message) => message.role === "assistant" && typeof message.content === "string" && message.content.trim());
|
|
3434
|
-
const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedTranscriptIsRicherThanCommitted(parsedHydratedMessages,
|
|
3496
|
+
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");
|
|
3435
3497
|
if (shouldAdoptParsedIdleReplay) {
|
|
3436
|
-
this.committedMessages =
|
|
3498
|
+
this.committedMessages = this.getSharedCommittedPrefixLength(parsed.messages) === this.committedMessages.length ? parsedHydratedMessages.map((message) => ({
|
|
3499
|
+
role: message.role,
|
|
3500
|
+
content: typeof message.content === "string" ? message.content : String(message.content || ""),
|
|
3501
|
+
timestamp: message.timestamp,
|
|
3502
|
+
receivedAt: message.receivedAt,
|
|
3503
|
+
kind: message.kind,
|
|
3504
|
+
id: message.id,
|
|
3505
|
+
index: message.index,
|
|
3506
|
+
meta: message.meta,
|
|
3507
|
+
senderName: message.senderName
|
|
3508
|
+
})) : normalizeCliParsedMessages(parsed.messages, {
|
|
3437
3509
|
committedMessages: this.committedMessages,
|
|
3438
3510
|
scope: this.currentTurnScope,
|
|
3439
3511
|
lastOutputAt: this.lastOutputAt
|
|
@@ -3452,15 +3524,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
3452
3524
|
this.onStatusChange?.();
|
|
3453
3525
|
}
|
|
3454
3526
|
}
|
|
3455
|
-
const
|
|
3456
|
-
...message,
|
|
3457
|
-
id: message.id || `msg_${index}`,
|
|
3458
|
-
index: typeof message.index === "number" ? message.index : index,
|
|
3459
|
-
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
3460
|
-
})) : committedHydratedMessages;
|
|
3461
|
-
const shouldPreferCommittedHistoryReplay = !this.currentTurnScope && !this.activeModal && effectiveCommittedHydratedMessages.length > parsedHydratedMessages.length;
|
|
3527
|
+
const shouldPreferCommittedHistoryReplay = !this.currentTurnScope && !this.activeModal && this.committedMessages.length > parsedHydratedMessages.length;
|
|
3462
3528
|
const shouldPreferCommittedIdleReplay = shouldPreferCommittedMessages && !shouldAdoptParsedIdleReplay;
|
|
3463
|
-
const hydratedMessages = shouldPreferCommittedIdleReplay || shouldPreferCommittedHistoryReplay ?
|
|
3529
|
+
const hydratedMessages = shouldPreferCommittedIdleReplay || shouldPreferCommittedHistoryReplay ? this.buildCommittedChatMessages() : parsedHydratedMessages;
|
|
3464
3530
|
result = {
|
|
3465
3531
|
id: parsed.id || "cli_session",
|
|
3466
3532
|
status: parsed.status || this.currentStatus,
|