@adhdev/daemon-standalone 0.9.82-rc.175 → 0.9.82-rc.177
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 +67 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47545,6 +47545,12 @@ ${lastSnapshot}`;
|
|
|
47545
47545
|
const requestedProviderSid = input.providerSessionId || "";
|
|
47546
47546
|
const sourcePath = resolveSourcePath(reader, workspace, sessionId);
|
|
47547
47547
|
if (!sourcePath) return null;
|
|
47548
|
+
if (input.forceRefresh === true || input.args?.forceRefresh === true) {
|
|
47549
|
+
try {
|
|
47550
|
+
fs18.statSync(sourcePath);
|
|
47551
|
+
} catch {
|
|
47552
|
+
}
|
|
47553
|
+
}
|
|
47548
47554
|
const session = readByReader(reader, sourcePath, sessionId, workspace);
|
|
47549
47555
|
if (!session) return null;
|
|
47550
47556
|
if (requestedProviderSid && session.providerSessionId && session.providerSessionId !== requestedProviderSid) {
|
|
@@ -54416,7 +54422,7 @@ ${cleanBody}`;
|
|
|
54416
54422
|
return sanitizeHistoryMessage(agentType, base);
|
|
54417
54423
|
}).filter(Boolean);
|
|
54418
54424
|
}
|
|
54419
|
-
function callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, historySessionId, workspace, excludeInProgressTurn, sessionStartedAtMs, envOverrides) {
|
|
54425
|
+
function callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, historySessionId, workspace, excludeInProgressTurn, sessionStartedAtMs, envOverrides, forceRefresh) {
|
|
54420
54426
|
const fn = getProviderNativeHistoryScript(scripts, canonicalHistory, "readSession");
|
|
54421
54427
|
if (!fn) return null;
|
|
54422
54428
|
const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId || "");
|
|
@@ -54430,7 +54436,8 @@ ${cleanBody}`;
|
|
|
54430
54436
|
excludeInProgressTurn: excludeInProgressTurn === true,
|
|
54431
54437
|
sessionStartedAtMs,
|
|
54432
54438
|
envOverrides,
|
|
54433
|
-
|
|
54439
|
+
forceRefresh: forceRefresh === true,
|
|
54440
|
+
args: { sessionId: normalizedSessionId, historySessionId: normalizedSessionId, workspace, excludeInProgressTurn: excludeInProgressTurn === true, sessionStartedAtMs, envOverrides, forceRefresh: forceRefresh === true }
|
|
54434
54441
|
});
|
|
54435
54442
|
if (!result || typeof result !== "object") return null;
|
|
54436
54443
|
const records = normalizeProviderNativeHistoryRecords(agentType, normalizedSessionId, result.messages || result.records);
|
|
@@ -54445,11 +54452,11 @@ ${cleanBody}`;
|
|
|
54445
54452
|
unavailableReason: typeof result.unavailableReason === "string" ? result.unavailableReason.trim() : void 0
|
|
54446
54453
|
};
|
|
54447
54454
|
}
|
|
54448
|
-
function buildNativeHistoryReadResult(agentType, canonicalHistory, scripts, historySessionId, workspace, excludeInProgressTurn, sessionStartedAtMs, envOverrides) {
|
|
54455
|
+
function buildNativeHistoryReadResult(agentType, canonicalHistory, scripts, historySessionId, workspace, excludeInProgressTurn, sessionStartedAtMs, envOverrides, forceRefresh) {
|
|
54449
54456
|
const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId || "");
|
|
54450
54457
|
const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
|
|
54451
54458
|
if (!canonicalHistory || !normalizedSessionId && !normalizedWorkspace || !isNativeSourceCanonicalHistory(canonicalHistory)) return null;
|
|
54452
|
-
return callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, normalizedSessionId, workspace, excludeInProgressTurn, sessionStartedAtMs, envOverrides);
|
|
54459
|
+
return callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, normalizedSessionId, workspace, excludeInProgressTurn, sessionStartedAtMs, envOverrides, forceRefresh);
|
|
54453
54460
|
}
|
|
54454
54461
|
function materializeNativeHistoryToMirror(agentType, canonicalHistory, historySessionId, workspace, scripts) {
|
|
54455
54462
|
const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId);
|
|
@@ -54478,7 +54485,7 @@ ${cleanBody}`;
|
|
|
54478
54485
|
}
|
|
54479
54486
|
function readProviderChatHistory(agentType, options = {}) {
|
|
54480
54487
|
if (isNativeSourceCanonicalHistory(options.canonicalHistory) && (options.historySessionId || options.workspace)) {
|
|
54481
|
-
const nativeResult = buildNativeHistoryReadResult(agentType, options.canonicalHistory, options.scripts, options.historySessionId, options.workspace, options.excludeInProgressTurn, options.sessionStartedAtMs, options.envOverrides);
|
|
54488
|
+
const nativeResult = buildNativeHistoryReadResult(agentType, options.canonicalHistory, options.scripts, options.historySessionId, options.workspace, options.excludeInProgressTurn, options.sessionStartedAtMs, options.envOverrides, options.forceRefresh);
|
|
54482
54489
|
if (!nativeResult) return { messages: [], hasMore: false, source: "native-unavailable" };
|
|
54483
54490
|
return {
|
|
54484
54491
|
...pageHistoryRecords(agentType, nativeResult.records, options.offset || 0, options.limit || 30, options.excludeRecentCount || 0, options.historyBehavior),
|
|
@@ -63721,6 +63728,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63721
63728
|
}
|
|
63722
63729
|
completedDebounceTimer = null;
|
|
63723
63730
|
completedDebouncePending = null;
|
|
63731
|
+
lastExternalCompletionProbe = null;
|
|
63724
63732
|
async enforceFreshSessionLaunchIfNeeded() {
|
|
63725
63733
|
const scriptName = getForcedNewSessionScriptName(this.provider, this.launchMode);
|
|
63726
63734
|
if (!scriptName) return;
|
|
@@ -63753,11 +63761,44 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63753
63761
|
if (looksLikeActiveApprovalPromptText(content)) return false;
|
|
63754
63762
|
return true;
|
|
63755
63763
|
}
|
|
63764
|
+
buildExternalTranscriptProbe(messages, sourcePath, sourceMtimeMs) {
|
|
63765
|
+
const visibleMessages = messages.filter((message) => isUserFacingChatMessage(message));
|
|
63766
|
+
const lastVisible = visibleMessages[visibleMessages.length - 1];
|
|
63767
|
+
const readAt = Date.now();
|
|
63768
|
+
const mtimeMs = Number(sourceMtimeMs) || 0;
|
|
63769
|
+
return {
|
|
63770
|
+
readAt,
|
|
63771
|
+
msgCount: messages.length,
|
|
63772
|
+
lastRole: typeof lastVisible?.role === "string" ? lastVisible.role.trim().toLowerCase() : null,
|
|
63773
|
+
lastKind: typeof lastVisible?.kind === "string" ? lastVisible.kind : null,
|
|
63774
|
+
contentLen: lastVisible ? flattenContent(lastVisible.content).trim().length : 0,
|
|
63775
|
+
sourcePath: typeof sourcePath === "string" && sourcePath ? sourcePath : null,
|
|
63776
|
+
sourceMtimeMs: mtimeMs || null,
|
|
63777
|
+
mtimeAgeMs: mtimeMs ? Math.max(0, readAt - mtimeMs) : null
|
|
63778
|
+
};
|
|
63779
|
+
}
|
|
63780
|
+
recordPendingTranscriptProbe(pending) {
|
|
63781
|
+
const probe = this.lastExternalCompletionProbe;
|
|
63782
|
+
if (!probe) return null;
|
|
63783
|
+
const history = pending.transcriptProbeHistory || [];
|
|
63784
|
+
const last = history[history.length - 1];
|
|
63785
|
+
if (!last || last.readAt !== probe.readAt || last.msgCount !== probe.msgCount || last.lastRole !== probe.lastRole || last.contentLen !== probe.contentLen) {
|
|
63786
|
+
history.push(probe);
|
|
63787
|
+
pending.transcriptProbeHistory = history.slice(-5);
|
|
63788
|
+
}
|
|
63789
|
+
return probe;
|
|
63790
|
+
}
|
|
63756
63791
|
readExternalCompletionMessages() {
|
|
63757
63792
|
const adapterOwnsMessagesElsewhere = this.adapter?.chatMessagesOwnedExternally === true;
|
|
63758
63793
|
if (!adapterOwnsMessagesElsewhere) return null;
|
|
63759
63794
|
if (!this.providerSessionId) return null;
|
|
63760
63795
|
if (!isNativeSourceCanonicalHistory(this.provider.nativeHistory)) return null;
|
|
63796
|
+
if (this.lastExternalCompletionProbe?.sourcePath) {
|
|
63797
|
+
try {
|
|
63798
|
+
fs12.statSync(this.lastExternalCompletionProbe.sourcePath);
|
|
63799
|
+
} catch {
|
|
63800
|
+
}
|
|
63801
|
+
}
|
|
63761
63802
|
const restoredHistory = readProviderChatHistory(this.type, {
|
|
63762
63803
|
canonicalHistory: this.provider.nativeHistory,
|
|
63763
63804
|
historySessionId: this.providerSessionId,
|
|
@@ -63766,9 +63807,18 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63766
63807
|
limit: Number.MAX_SAFE_INTEGER,
|
|
63767
63808
|
historyBehavior: this.provider.historyBehavior,
|
|
63768
63809
|
scripts: this.provider.scripts,
|
|
63769
|
-
sessionStartedAtMs: this.startedAt
|
|
63810
|
+
sessionStartedAtMs: this.startedAt,
|
|
63811
|
+
forceRefresh: true
|
|
63770
63812
|
});
|
|
63771
|
-
if (restoredHistory.source !== "provider-native")
|
|
63813
|
+
if (restoredHistory.source !== "provider-native") {
|
|
63814
|
+
this.lastExternalCompletionProbe = null;
|
|
63815
|
+
return null;
|
|
63816
|
+
}
|
|
63817
|
+
this.lastExternalCompletionProbe = this.buildExternalTranscriptProbe(
|
|
63818
|
+
restoredHistory.messages,
|
|
63819
|
+
restoredHistory.sourcePath,
|
|
63820
|
+
restoredHistory.sourceMtimeMs
|
|
63821
|
+
);
|
|
63772
63822
|
return restoredHistory.messages;
|
|
63773
63823
|
}
|
|
63774
63824
|
completionFinalAssistantEvidence(parsedMessages) {
|
|
@@ -63806,6 +63856,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63806
63856
|
parseError = error48?.message || String(error48);
|
|
63807
63857
|
}
|
|
63808
63858
|
const evidence = this.completionFinalAssistantEvidence(parsed?.messages);
|
|
63859
|
+
if (evidence.source === "external-native") {
|
|
63860
|
+
this.recordPendingTranscriptProbe(args.pending);
|
|
63861
|
+
}
|
|
63809
63862
|
const visibleMessages = (Array.isArray(evidence.messages) ? evidence.messages : []).filter((message) => isUserFacingChatMessage(message));
|
|
63810
63863
|
const lastVisible = visibleMessages[visibleMessages.length - 1];
|
|
63811
63864
|
const lastVisibleRole = typeof lastVisible?.role === "string" ? lastVisible.role.trim().toLowerCase() : null;
|
|
@@ -63834,7 +63887,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63834
63887
|
pendingFirstObservedAt: args.pending.firstObservedAt,
|
|
63835
63888
|
pendingTimestamp: args.pending.timestamp,
|
|
63836
63889
|
pendingDurationSec: args.pending.duration,
|
|
63837
|
-
previousBlockReason: args.pending.loggedBlockReason || null
|
|
63890
|
+
previousBlockReason: args.pending.loggedBlockReason || null,
|
|
63891
|
+
transcriptProbeHistory: args.pending.transcriptProbeHistory || []
|
|
63838
63892
|
};
|
|
63839
63893
|
}
|
|
63840
63894
|
hasAdapterPendingResponse() {
|
|
@@ -63892,6 +63946,11 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63892
63946
|
if (!finalAssistantEvidence.present) {
|
|
63893
63947
|
if (adapterOwnsMessagesElsewhere) {
|
|
63894
63948
|
if (finalAssistantEvidence.source === "external-native") {
|
|
63949
|
+
const probe = this.recordPendingTranscriptProbe(pending);
|
|
63950
|
+
if (probe && !pending.loggedTranscriptProbe) {
|
|
63951
|
+
LOG2.info("CLI", `[${this.type}] external transcript probe: msgCount=${probe.msgCount} lastRole=${probe.lastRole || "none"} lastKind=${probe.lastKind || "none"} contentLen=${probe.contentLen} sourceMtime=${probe.sourceMtimeMs ?? "unknown"} mtimeAge=${probe.mtimeAgeMs ?? "unknown"}ms`);
|
|
63952
|
+
pending.loggedTranscriptProbe = true;
|
|
63953
|
+
}
|
|
63895
63954
|
return { reason: "missing_final_assistant", terminal: true };
|
|
63896
63955
|
}
|
|
63897
63956
|
if (this.provider.requiresFinalAssistantBeforeIdle === true) {
|