@adhdev/daemon-core 0.9.82-rc.100 → 0.9.82-rc.102
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 +3 -0
- package/dist/config/chat-history.d.ts +4 -0
- package/dist/index.js +94 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +64 -0
- package/src/commands/chat-commands.ts +41 -1
- package/src/config/chat-history.ts +28 -2
- package/src/providers/cli-provider-instance.ts +9 -3
package/dist/index.mjs
CHANGED
|
@@ -5610,6 +5610,11 @@ ${lastSnapshot}`;
|
|
|
5610
5610
|
this.idleTimeout = setTimeout(() => {
|
|
5611
5611
|
if (this.isWaitingForResponse && !this.hasActionableApproval()) {
|
|
5612
5612
|
if (this.shouldDeferIdleTimeoutFinish()) return;
|
|
5613
|
+
const parsed = this.runParseSession();
|
|
5614
|
+
if (this.shouldKeepCodexTurnOpenForFinish(parsed)) {
|
|
5615
|
+
this.rescheduleCodexFinishCheck("codex_idle_timeout_not_final");
|
|
5616
|
+
return;
|
|
5617
|
+
}
|
|
5613
5618
|
this.clearIdleFinishCandidate("idle_timeout_finish");
|
|
5614
5619
|
this.finishResponse();
|
|
5615
5620
|
}
|
|
@@ -5618,6 +5623,11 @@ ${lastSnapshot}`;
|
|
|
5618
5623
|
finishResponse() {
|
|
5619
5624
|
if (this.submitPendingUntil > Date.now()) return;
|
|
5620
5625
|
if (this.responseSettleIgnoreUntil > Date.now()) return;
|
|
5626
|
+
const parsedBeforeFinish = this.runParseSession();
|
|
5627
|
+
if (this.shouldKeepCodexTurnOpenForFinish(parsedBeforeFinish)) {
|
|
5628
|
+
this.rescheduleCodexFinishCheck("codex_finish_not_final");
|
|
5629
|
+
return;
|
|
5630
|
+
}
|
|
5621
5631
|
this.clearIdleFinishCandidate("finish_response_enter");
|
|
5622
5632
|
this.recordTrace("finish_response", {
|
|
5623
5633
|
...buildCliTraceParseSnapshot({
|
|
@@ -5833,6 +5843,44 @@ ${lastSnapshot}`;
|
|
|
5833
5843
|
});
|
|
5834
5844
|
return !!lastAssistant;
|
|
5835
5845
|
}
|
|
5846
|
+
parsedStatusHasFinalStandardAssistantMessage(parsed) {
|
|
5847
|
+
const messages = Array.isArray(parsed?.messages) ? parsed.messages : [];
|
|
5848
|
+
const lastAssistant = [...messages].reverse().find((message) => {
|
|
5849
|
+
if (!message || message.role !== "assistant") return false;
|
|
5850
|
+
return typeof message.content === "string" && message.content.trim().length > 0;
|
|
5851
|
+
});
|
|
5852
|
+
if (!lastAssistant) return false;
|
|
5853
|
+
const kind = typeof lastAssistant.kind === "string" && lastAssistant.kind.trim() ? lastAssistant.kind.trim() : "standard";
|
|
5854
|
+
return kind === "standard" && lastAssistant.meta?.streaming !== true;
|
|
5855
|
+
}
|
|
5856
|
+
shouldKeepCodexTurnOpenForFinish(parsed) {
|
|
5857
|
+
if (this.cliType !== "codex-cli") return false;
|
|
5858
|
+
if (!this.isWaitingForResponse || !this.currentTurnScope || this.hasActionableApproval()) return false;
|
|
5859
|
+
const parsedStatus = typeof parsed?.status === "string" ? parsed.status.trim() : "";
|
|
5860
|
+
if (parsedStatus !== "idle") return true;
|
|
5861
|
+
if (parsed?.activeModal || parsed?.modal) return true;
|
|
5862
|
+
return !this.parsedStatusHasFinalStandardAssistantMessage(parsed);
|
|
5863
|
+
}
|
|
5864
|
+
rescheduleCodexFinishCheck(reason) {
|
|
5865
|
+
this.clearIdleFinishCandidate(reason);
|
|
5866
|
+
this.setStatus("generating", reason);
|
|
5867
|
+
if (this.idleTimeout) clearTimeout(this.idleTimeout);
|
|
5868
|
+
this.idleTimeout = setTimeout(() => {
|
|
5869
|
+
if (!this.isWaitingForResponse || this.hasActionableApproval()) return;
|
|
5870
|
+
this.settledBuffer = this.recentOutputBuffer;
|
|
5871
|
+
this.evaluateSettled();
|
|
5872
|
+
}, this.getIdleFinishConfirmMs());
|
|
5873
|
+
this.recordTrace("codex_finish_deferred", {
|
|
5874
|
+
reason,
|
|
5875
|
+
...buildCliTraceParseSnapshot({
|
|
5876
|
+
accumulatedBuffer: this.accumulatedBuffer,
|
|
5877
|
+
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
5878
|
+
responseBuffer: this.responseBuffer,
|
|
5879
|
+
partialResponse: this.responseBuffer,
|
|
5880
|
+
scope: this.currentTurnScope
|
|
5881
|
+
})
|
|
5882
|
+
});
|
|
5883
|
+
}
|
|
5836
5884
|
projectEffectiveStatus(startupModal = null) {
|
|
5837
5885
|
if (this.parseErrorMessage) return "error";
|
|
5838
5886
|
if (this.hasActionableApproval(startupModal)) return "waiting_approval";
|
|
@@ -5910,6 +5958,8 @@ ${lastSnapshot}`;
|
|
|
5910
5958
|
}),
|
|
5911
5959
|
activeModal,
|
|
5912
5960
|
providerSessionId: typeof parsed.providerSessionId === "string" ? parsed.providerSessionId : void 0,
|
|
5961
|
+
errorMessage: typeof parsed.errorMessage === "string" && parsed.errorMessage.trim() ? parsed.errorMessage.trim() : void 0,
|
|
5962
|
+
errorReason: typeof parsed.errorReason === "string" && parsed.errorReason.trim() ? parsed.errorReason.trim() : void 0,
|
|
5913
5963
|
...bufferState ? { bufferState } : {},
|
|
5914
5964
|
...parsed.transcriptAuthority === "provider" || parsed.transcriptAuthority === "daemon" ? { transcriptAuthority: parsed.transcriptAuthority } : this.providerOwnsTranscript() ? { transcriptAuthority: "provider" } : {},
|
|
5915
5965
|
...parsed.coverage === "full" || parsed.coverage === "tail" || parsed.coverage === "current-turn" ? { coverage: parsed.coverage } : this.providerOwnsTranscript() ? { coverage: this.shouldUseFullProviderTranscriptContext() ? "full" : "tail" } : {}
|
|
@@ -6713,6 +6763,9 @@ ${lastSnapshot}`;
|
|
|
6713
6763
|
const parsedDebugState = this.getParsedDebugState();
|
|
6714
6764
|
const parsedMessages = Array.isArray(parsedDebugState?.messages) ? parsedDebugState.messages : [];
|
|
6715
6765
|
let effectiveStatus = this.projectEffectiveStatus(startupModal);
|
|
6766
|
+
if (parsedDebugState?.status === "error") {
|
|
6767
|
+
effectiveStatus = "error";
|
|
6768
|
+
}
|
|
6716
6769
|
if (startupDetectedStatus === "waiting_approval") {
|
|
6717
6770
|
effectiveStatus = "waiting_approval";
|
|
6718
6771
|
}
|
|
@@ -6740,6 +6793,8 @@ ${lastSnapshot}`;
|
|
|
6740
6793
|
providerSessionId: parsedDebugState.providerSessionId,
|
|
6741
6794
|
transcriptAuthority: parsedDebugState.transcriptAuthority,
|
|
6742
6795
|
coverage: parsedDebugState.coverage,
|
|
6796
|
+
errorMessage: parsedDebugState.errorMessage,
|
|
6797
|
+
errorReason: parsedDebugState.errorReason,
|
|
6743
6798
|
activeModal: parsedDebugState.activeModal,
|
|
6744
6799
|
messageCount: parsedMessages.length
|
|
6745
6800
|
} : null,
|
|
@@ -13258,7 +13313,11 @@ function callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, his
|
|
|
13258
13313
|
return {
|
|
13259
13314
|
records,
|
|
13260
13315
|
sourcePath: typeof result.sourcePath === "string" ? result.sourcePath : "",
|
|
13261
|
-
sourceMtimeMs: Number(result.sourceMtimeMs) || 0
|
|
13316
|
+
sourceMtimeMs: Number(result.sourceMtimeMs) || 0,
|
|
13317
|
+
providerSessionId: typeof result.providerSessionId === "string" ? result.providerSessionId.trim() : void 0,
|
|
13318
|
+
nativeHistoryCoverage: typeof result.nativeHistoryCoverage === "string" ? result.nativeHistoryCoverage.trim() : void 0,
|
|
13319
|
+
partialReason: typeof result.partialReason === "string" ? result.partialReason.trim() : void 0,
|
|
13320
|
+
unavailableReason: typeof result.unavailableReason === "string" ? result.unavailableReason.trim() : void 0
|
|
13262
13321
|
};
|
|
13263
13322
|
}
|
|
13264
13323
|
function buildNativeHistoryReadResult(agentType, canonicalHistory, scripts, historySessionId, workspace) {
|
|
@@ -13300,7 +13359,11 @@ function readProviderChatHistory(agentType, options = {}) {
|
|
|
13300
13359
|
...pageHistoryRecords(agentType, nativeResult.records, options.offset || 0, options.limit || 30, options.excludeRecentCount || 0, options.historyBehavior),
|
|
13301
13360
|
source: "provider-native",
|
|
13302
13361
|
sourcePath: nativeResult.sourcePath,
|
|
13303
|
-
sourceMtimeMs: nativeResult.sourceMtimeMs
|
|
13362
|
+
sourceMtimeMs: nativeResult.sourceMtimeMs,
|
|
13363
|
+
providerSessionId: nativeResult.providerSessionId,
|
|
13364
|
+
nativeHistoryCoverage: nativeResult.nativeHistoryCoverage,
|
|
13365
|
+
partialReason: nativeResult.partialReason,
|
|
13366
|
+
unavailableReason: nativeResult.unavailableReason
|
|
13304
13367
|
};
|
|
13305
13368
|
}
|
|
13306
13369
|
return {
|
|
@@ -16096,6 +16159,9 @@ function buildCliMessageSourceProvenance(args) {
|
|
|
16096
16159
|
...args.fallbackReason ? { fallbackReason: args.fallbackReason } : {},
|
|
16097
16160
|
...args.nativeSource ? { nativeSource: args.nativeSource } : {},
|
|
16098
16161
|
...args.sourcePath ? { sourcePath: args.sourcePath } : {},
|
|
16162
|
+
...args.nativeHistoryCoverage ? { nativeHistoryCoverage: args.nativeHistoryCoverage } : {},
|
|
16163
|
+
...args.partialReason ? { partialReason: args.partialReason } : {},
|
|
16164
|
+
...args.unavailableReason ? { unavailableReason: args.unavailableReason } : {},
|
|
16099
16165
|
ptyStatusApprovalOnly: args.ptyStatusApprovalOnly === true,
|
|
16100
16166
|
staleness: {
|
|
16101
16167
|
sourceMtimeMs: sourceMtimeMs || void 0,
|
|
@@ -16115,6 +16181,8 @@ function buildCliMessageSourceProvenance(args) {
|
|
|
16115
16181
|
function buildNativeHistoryFallbackReason(args) {
|
|
16116
16182
|
if (!supportsCliNativeTranscript(args.providerType, args.provider)) return "provider_native_transcript_not_supported";
|
|
16117
16183
|
if (args.nativeSource === "native-unavailable") return "native_history_unavailable";
|
|
16184
|
+
if (args.nativeHistoryCoverage === "partial") return "native_history_partial";
|
|
16185
|
+
if (args.nativeHistoryCoverage === "unavailable") return "native_history_unavailable";
|
|
16118
16186
|
if (args.nativeSource && args.nativeSource !== "provider-native") return `native_history_source_${args.nativeSource}`;
|
|
16119
16187
|
if (args.nativeMessageCount <= 0) return "native_history_empty";
|
|
16120
16188
|
if (!args.safeMapping) return "native_history_not_safely_mapped";
|
|
@@ -16848,6 +16916,9 @@ async function handleReadChat(h, args) {
|
|
|
16848
16916
|
if (nativeHistory) {
|
|
16849
16917
|
const nativeMessages = Array.isArray(nativeHistory.messages) ? normalizeNativeHistoryMessages(agentStr, nativeHistory.messages) : [];
|
|
16850
16918
|
const historyProviderSessionId = typeof nativeHistory?.providerSessionId === "string" ? nativeHistory.providerSessionId : readHistorySessionIdFromMessages(nativeMessages) || nativeHistorySessionId || historySessionId;
|
|
16919
|
+
const nativeHistoryCoverage = typeof nativeHistory?.nativeHistoryCoverage === "string" ? nativeHistory.nativeHistoryCoverage : void 0;
|
|
16920
|
+
const partialReason = typeof nativeHistory?.partialReason === "string" ? nativeHistory.partialReason : void 0;
|
|
16921
|
+
const unavailableReason = typeof nativeHistory?.unavailableReason === "string" ? nativeHistory.unavailableReason : void 0;
|
|
16851
16922
|
const lookup = nativeHistory.lookup === "workspace" ? "workspace" : "session";
|
|
16852
16923
|
const safeMapping = hasSafeNativeHistoryMapping({
|
|
16853
16924
|
historySessionId: lookup === "workspace" ? void 0 : nativeHistorySessionId,
|
|
@@ -16862,7 +16933,7 @@ async function handleReadChat(h, args) {
|
|
|
16862
16933
|
nativeMessages,
|
|
16863
16934
|
ptyMessages: returnedMessages
|
|
16864
16935
|
});
|
|
16865
|
-
if (nativeHistory.source === "provider-native" && nativeMessages.length > 0 && safeMapping && freshEnough) {
|
|
16936
|
+
if (nativeHistory.source === "provider-native" && nativeMessages.length > 0 && nativeHistoryCoverage !== "partial" && nativeHistoryCoverage !== "unavailable" && safeMapping && freshEnough) {
|
|
16866
16937
|
selectedMessages = finalizeStreamingMessagesWhenIdle(nativeMessages, returnedStatus);
|
|
16867
16938
|
selectedProviderSessionId = historyProviderSessionId || providerSessionId;
|
|
16868
16939
|
selectedTranscriptAuthority = "provider";
|
|
@@ -16874,6 +16945,9 @@ async function handleReadChat(h, args) {
|
|
|
16874
16945
|
nativeSource: nativeHistory.source,
|
|
16875
16946
|
sourcePath: nativeHistory.sourcePath,
|
|
16876
16947
|
sourceMtimeMs: nativeHistory.sourceMtimeMs,
|
|
16948
|
+
nativeHistoryCoverage,
|
|
16949
|
+
partialReason,
|
|
16950
|
+
unavailableReason,
|
|
16877
16951
|
nativeMessages,
|
|
16878
16952
|
ptyMessages: returnedMessages,
|
|
16879
16953
|
returnedMessages: selectedMessages,
|
|
@@ -16886,6 +16960,7 @@ async function handleReadChat(h, args) {
|
|
|
16886
16960
|
providerType,
|
|
16887
16961
|
provider,
|
|
16888
16962
|
nativeSource: nativeHistory.source,
|
|
16963
|
+
nativeHistoryCoverage,
|
|
16889
16964
|
nativeMessageCount: nativeMessages.length,
|
|
16890
16965
|
safeMapping,
|
|
16891
16966
|
freshEnough
|
|
@@ -16898,6 +16973,9 @@ async function handleReadChat(h, args) {
|
|
|
16898
16973
|
nativeSource: nativeHistory.source,
|
|
16899
16974
|
sourcePath: nativeHistory.sourcePath,
|
|
16900
16975
|
sourceMtimeMs: nativeHistory.sourceMtimeMs,
|
|
16976
|
+
nativeHistoryCoverage,
|
|
16977
|
+
partialReason,
|
|
16978
|
+
unavailableReason,
|
|
16901
16979
|
nativeMessages,
|
|
16902
16980
|
ptyMessages: returnedMessages,
|
|
16903
16981
|
returnedMessages,
|
|
@@ -16963,13 +17041,16 @@ async function handleReadChat(h, args) {
|
|
|
16963
17041
|
const lookup = history.lookup === "workspace" ? "workspace" : "session";
|
|
16964
17042
|
const historyMessages = Array.isArray(history?.messages) ? normalizeNativeHistoryMessages(agentStr, history.messages) : [];
|
|
16965
17043
|
const historyProviderSessionId = typeof history?.providerSessionId === "string" ? history.providerSessionId : readHistorySessionIdFromMessages(historyMessages) || historySessionId;
|
|
17044
|
+
const nativeHistoryCoverage = typeof history?.nativeHistoryCoverage === "string" ? history.nativeHistoryCoverage : void 0;
|
|
17045
|
+
const partialReason = typeof history?.partialReason === "string" ? history.partialReason : void 0;
|
|
17046
|
+
const unavailableReason = typeof history?.unavailableReason === "string" ? history.unavailableReason : void 0;
|
|
16966
17047
|
const safeMapping = supportsCliNativeTranscript(agentStr, provider) ? hasSafeNativeHistoryMapping({
|
|
16967
17048
|
historySessionId: lookup === "workspace" ? void 0 : historySessionId,
|
|
16968
17049
|
providerSessionId: lookup === "workspace" ? void 0 : historyProviderSessionId,
|
|
16969
17050
|
workspace,
|
|
16970
17051
|
nativeMessages: historyMessages
|
|
16971
17052
|
}) : false;
|
|
16972
|
-
const nativeSelected = supportsCliNativeTranscript(agentStr, provider) && history.source === "provider-native" && historyMessages.length > 0 && safeMapping;
|
|
17053
|
+
const nativeSelected = supportsCliNativeTranscript(agentStr, provider) && history.source === "provider-native" && historyMessages.length > 0 && nativeHistoryCoverage !== "partial" && nativeHistoryCoverage !== "unavailable" && safeMapping;
|
|
16973
17054
|
const messageSource = buildCliMessageSourceProvenance({
|
|
16974
17055
|
selected: nativeSelected ? "native-history" : "pty-parser",
|
|
16975
17056
|
provider: agentStr,
|
|
@@ -16978,6 +17059,7 @@ async function handleReadChat(h, args) {
|
|
|
16978
17059
|
providerType: agentStr,
|
|
16979
17060
|
provider,
|
|
16980
17061
|
nativeSource: history.source,
|
|
17062
|
+
nativeHistoryCoverage,
|
|
16981
17063
|
nativeMessageCount: historyMessages.length,
|
|
16982
17064
|
safeMapping,
|
|
16983
17065
|
freshEnough: true
|
|
@@ -16985,6 +17067,9 @@ async function handleReadChat(h, args) {
|
|
|
16985
17067
|
nativeSource: history.source,
|
|
16986
17068
|
sourcePath: history.sourcePath,
|
|
16987
17069
|
sourceMtimeMs: history.sourceMtimeMs,
|
|
17070
|
+
nativeHistoryCoverage,
|
|
17071
|
+
partialReason,
|
|
17072
|
+
unavailableReason,
|
|
16988
17073
|
nativeMessages: historyMessages,
|
|
16989
17074
|
returnedMessages: historyMessages,
|
|
16990
17075
|
safeMapping,
|
|
@@ -19690,8 +19775,10 @@ var CliProviderInstance = class {
|
|
|
19690
19775
|
if (typeof this.adapter.getScriptParsedStatus === "function") {
|
|
19691
19776
|
try {
|
|
19692
19777
|
parsedStatus = this.adapter.getScriptParsedStatus() || null;
|
|
19693
|
-
|
|
19694
|
-
|
|
19778
|
+
const parsedErrorMessage = typeof parsedStatus?.errorMessage === "string" && parsedStatus.errorMessage.trim() ? parsedStatus.errorMessage.trim() : void 0;
|
|
19779
|
+
const parsedErrorReason = typeof parsedStatus?.errorReason === "string" && parsedStatus.errorReason.trim() ? parsedStatus.errorReason.trim() : void 0;
|
|
19780
|
+
this.errorMessage = parsedErrorMessage;
|
|
19781
|
+
this.errorReason = parsedErrorReason;
|
|
19695
19782
|
} catch (error) {
|
|
19696
19783
|
parseErrorMessage = error?.message || String(error);
|
|
19697
19784
|
this.errorMessage = parseErrorMessage;
|
|
@@ -19702,7 +19789,7 @@ var CliProviderInstance = class {
|
|
|
19702
19789
|
this.errorReason = void 0;
|
|
19703
19790
|
}
|
|
19704
19791
|
const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, Date.now());
|
|
19705
|
-
const visibleStatus = parseErrorMessage ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
|
|
19792
|
+
const visibleStatus = parseErrorMessage || parsedStatus?.status === "error" ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
|
|
19706
19793
|
const parsedProviderSessionId = normalizeProviderSessionId(
|
|
19707
19794
|
this.provider,
|
|
19708
19795
|
typeof parsedStatus?.providerSessionId === "string" ? parsedStatus.providerSessionId : ""
|