@adhdev/daemon-standalone 0.9.82-rc.176 → 0.9.82-rc.178
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 +93 -10
- 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),
|
|
@@ -62823,7 +62830,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62823
62830
|
activeInteractivePrompt: this.activeInteractivePrompt
|
|
62824
62831
|
};
|
|
62825
62832
|
}
|
|
62826
|
-
if (
|
|
62833
|
+
if (lc === "busy" || lc === "generating") {
|
|
62827
62834
|
return { status: "generating", messages: [], activeModal: null, activeInteractivePrompt: this.activeInteractivePrompt };
|
|
62828
62835
|
}
|
|
62829
62836
|
return { status: "idle", messages: [], activeModal: null, activeInteractivePrompt: this.activeInteractivePrompt };
|
|
@@ -62957,13 +62964,37 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62957
62964
|
return Promise.resolve({ ok: true, effects });
|
|
62958
62965
|
}
|
|
62959
62966
|
getDebugSnapshot() {
|
|
62967
|
+
let screen = "";
|
|
62968
|
+
let sections;
|
|
62969
|
+
try {
|
|
62970
|
+
screen = this.driver.snapshot();
|
|
62971
|
+
const lines = screen.split("\n");
|
|
62972
|
+
sections = {};
|
|
62973
|
+
for (const sec of this.spec.layout?.sections ?? []) {
|
|
62974
|
+
const from = sec.from_top;
|
|
62975
|
+
const fromBottom = sec.from_bottom;
|
|
62976
|
+
let start = 0;
|
|
62977
|
+
let end = lines.length;
|
|
62978
|
+
if (typeof from === "number") start = Math.max(0, from);
|
|
62979
|
+
else if (typeof fromBottom === "number") start = Math.max(0, lines.length - fromBottom);
|
|
62980
|
+
const until = sec.until;
|
|
62981
|
+
if (until && typeof until === "object" && typeof until.section === "string") {
|
|
62982
|
+
const ref = (this.spec.layout?.sections ?? []).find((s) => s.id === until.section);
|
|
62983
|
+
if (ref && typeof ref.from_bottom === "number") end = Math.max(start, lines.length - ref.from_bottom);
|
|
62984
|
+
}
|
|
62985
|
+
sections[sec.id] = lines.slice(start, end).join("\n");
|
|
62986
|
+
}
|
|
62987
|
+
} catch {
|
|
62988
|
+
}
|
|
62960
62989
|
return {
|
|
62961
62990
|
cliType: this.cliType,
|
|
62962
62991
|
spec_id: this.spec.id,
|
|
62963
62992
|
current_state: this.latestState,
|
|
62964
62993
|
current_modal: this.latestModal,
|
|
62965
62994
|
activeInteractivePrompt: this.activeInteractivePrompt,
|
|
62966
|
-
exited: this.exited
|
|
62995
|
+
exited: this.exited,
|
|
62996
|
+
screen,
|
|
62997
|
+
sections
|
|
62967
62998
|
};
|
|
62968
62999
|
}
|
|
62969
63000
|
getRuntimeMetadata() {
|
|
@@ -63721,6 +63752,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63721
63752
|
}
|
|
63722
63753
|
completedDebounceTimer = null;
|
|
63723
63754
|
completedDebouncePending = null;
|
|
63755
|
+
lastExternalCompletionProbe = null;
|
|
63724
63756
|
async enforceFreshSessionLaunchIfNeeded() {
|
|
63725
63757
|
const scriptName = getForcedNewSessionScriptName(this.provider, this.launchMode);
|
|
63726
63758
|
if (!scriptName) return;
|
|
@@ -63753,11 +63785,44 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63753
63785
|
if (looksLikeActiveApprovalPromptText(content)) return false;
|
|
63754
63786
|
return true;
|
|
63755
63787
|
}
|
|
63788
|
+
buildExternalTranscriptProbe(messages, sourcePath, sourceMtimeMs) {
|
|
63789
|
+
const visibleMessages = messages.filter((message) => isUserFacingChatMessage(message));
|
|
63790
|
+
const lastVisible = visibleMessages[visibleMessages.length - 1];
|
|
63791
|
+
const readAt = Date.now();
|
|
63792
|
+
const mtimeMs = Number(sourceMtimeMs) || 0;
|
|
63793
|
+
return {
|
|
63794
|
+
readAt,
|
|
63795
|
+
msgCount: messages.length,
|
|
63796
|
+
lastRole: typeof lastVisible?.role === "string" ? lastVisible.role.trim().toLowerCase() : null,
|
|
63797
|
+
lastKind: typeof lastVisible?.kind === "string" ? lastVisible.kind : null,
|
|
63798
|
+
contentLen: lastVisible ? flattenContent(lastVisible.content).trim().length : 0,
|
|
63799
|
+
sourcePath: typeof sourcePath === "string" && sourcePath ? sourcePath : null,
|
|
63800
|
+
sourceMtimeMs: mtimeMs || null,
|
|
63801
|
+
mtimeAgeMs: mtimeMs ? Math.max(0, readAt - mtimeMs) : null
|
|
63802
|
+
};
|
|
63803
|
+
}
|
|
63804
|
+
recordPendingTranscriptProbe(pending) {
|
|
63805
|
+
const probe = this.lastExternalCompletionProbe;
|
|
63806
|
+
if (!probe) return null;
|
|
63807
|
+
const history = pending.transcriptProbeHistory || [];
|
|
63808
|
+
const last = history[history.length - 1];
|
|
63809
|
+
if (!last || last.readAt !== probe.readAt || last.msgCount !== probe.msgCount || last.lastRole !== probe.lastRole || last.contentLen !== probe.contentLen) {
|
|
63810
|
+
history.push(probe);
|
|
63811
|
+
pending.transcriptProbeHistory = history.slice(-5);
|
|
63812
|
+
}
|
|
63813
|
+
return probe;
|
|
63814
|
+
}
|
|
63756
63815
|
readExternalCompletionMessages() {
|
|
63757
63816
|
const adapterOwnsMessagesElsewhere = this.adapter?.chatMessagesOwnedExternally === true;
|
|
63758
63817
|
if (!adapterOwnsMessagesElsewhere) return null;
|
|
63759
63818
|
if (!this.providerSessionId) return null;
|
|
63760
63819
|
if (!isNativeSourceCanonicalHistory(this.provider.nativeHistory)) return null;
|
|
63820
|
+
if (this.lastExternalCompletionProbe?.sourcePath) {
|
|
63821
|
+
try {
|
|
63822
|
+
fs12.statSync(this.lastExternalCompletionProbe.sourcePath);
|
|
63823
|
+
} catch {
|
|
63824
|
+
}
|
|
63825
|
+
}
|
|
63761
63826
|
const restoredHistory = readProviderChatHistory(this.type, {
|
|
63762
63827
|
canonicalHistory: this.provider.nativeHistory,
|
|
63763
63828
|
historySessionId: this.providerSessionId,
|
|
@@ -63766,9 +63831,18 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63766
63831
|
limit: Number.MAX_SAFE_INTEGER,
|
|
63767
63832
|
historyBehavior: this.provider.historyBehavior,
|
|
63768
63833
|
scripts: this.provider.scripts,
|
|
63769
|
-
sessionStartedAtMs: this.startedAt
|
|
63834
|
+
sessionStartedAtMs: this.startedAt,
|
|
63835
|
+
forceRefresh: true
|
|
63770
63836
|
});
|
|
63771
|
-
if (restoredHistory.source !== "provider-native")
|
|
63837
|
+
if (restoredHistory.source !== "provider-native") {
|
|
63838
|
+
this.lastExternalCompletionProbe = null;
|
|
63839
|
+
return null;
|
|
63840
|
+
}
|
|
63841
|
+
this.lastExternalCompletionProbe = this.buildExternalTranscriptProbe(
|
|
63842
|
+
restoredHistory.messages,
|
|
63843
|
+
restoredHistory.sourcePath,
|
|
63844
|
+
restoredHistory.sourceMtimeMs
|
|
63845
|
+
);
|
|
63772
63846
|
return restoredHistory.messages;
|
|
63773
63847
|
}
|
|
63774
63848
|
completionFinalAssistantEvidence(parsedMessages) {
|
|
@@ -63806,6 +63880,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63806
63880
|
parseError = error48?.message || String(error48);
|
|
63807
63881
|
}
|
|
63808
63882
|
const evidence = this.completionFinalAssistantEvidence(parsed?.messages);
|
|
63883
|
+
if (evidence.source === "external-native") {
|
|
63884
|
+
this.recordPendingTranscriptProbe(args.pending);
|
|
63885
|
+
}
|
|
63809
63886
|
const visibleMessages = (Array.isArray(evidence.messages) ? evidence.messages : []).filter((message) => isUserFacingChatMessage(message));
|
|
63810
63887
|
const lastVisible = visibleMessages[visibleMessages.length - 1];
|
|
63811
63888
|
const lastVisibleRole = typeof lastVisible?.role === "string" ? lastVisible.role.trim().toLowerCase() : null;
|
|
@@ -63834,7 +63911,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63834
63911
|
pendingFirstObservedAt: args.pending.firstObservedAt,
|
|
63835
63912
|
pendingTimestamp: args.pending.timestamp,
|
|
63836
63913
|
pendingDurationSec: args.pending.duration,
|
|
63837
|
-
previousBlockReason: args.pending.loggedBlockReason || null
|
|
63914
|
+
previousBlockReason: args.pending.loggedBlockReason || null,
|
|
63915
|
+
transcriptProbeHistory: args.pending.transcriptProbeHistory || []
|
|
63838
63916
|
};
|
|
63839
63917
|
}
|
|
63840
63918
|
hasAdapterPendingResponse() {
|
|
@@ -63892,6 +63970,11 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
63892
63970
|
if (!finalAssistantEvidence.present) {
|
|
63893
63971
|
if (adapterOwnsMessagesElsewhere) {
|
|
63894
63972
|
if (finalAssistantEvidence.source === "external-native") {
|
|
63973
|
+
const probe = this.recordPendingTranscriptProbe(pending);
|
|
63974
|
+
if (probe && !pending.loggedTranscriptProbe) {
|
|
63975
|
+
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`);
|
|
63976
|
+
pending.loggedTranscriptProbe = true;
|
|
63977
|
+
}
|
|
63895
63978
|
return { reason: "missing_final_assistant", terminal: true };
|
|
63896
63979
|
}
|
|
63897
63980
|
if (this.provider.requiresFinalAssistantBeforeIdle === true) {
|