@adhdev/daemon-standalone 0.9.82-rc.110 → 0.9.82-rc.112
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 +156 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/index-kt4CV7OM.js +100 -0
- package/public/index.html +1 -1
package/dist/index.js
CHANGED
|
@@ -26809,6 +26809,8 @@ Next step: ${nextStep}`;
|
|
|
26809
26809
|
pendingOutboundQueue = [];
|
|
26810
26810
|
pendingOutboundFlushTimer = null;
|
|
26811
26811
|
pendingOutboundFlushInFlight = false;
|
|
26812
|
+
providerErrorRetryTimer = null;
|
|
26813
|
+
providerErrorRetryKey = "";
|
|
26812
26814
|
// Resize redraw suppression
|
|
26813
26815
|
resizeSuppressUntil = 0;
|
|
26814
26816
|
// Debug: status transition history
|
|
@@ -27415,6 +27417,11 @@ ${lastSnapshot}`;
|
|
|
27415
27417
|
clearTimeout(this.ptyOutputFlushTimer);
|
|
27416
27418
|
this.ptyOutputFlushTimer = null;
|
|
27417
27419
|
}
|
|
27420
|
+
if (this.providerErrorRetryTimer) {
|
|
27421
|
+
clearTimeout(this.providerErrorRetryTimer);
|
|
27422
|
+
this.providerErrorRetryTimer = null;
|
|
27423
|
+
}
|
|
27424
|
+
this.providerErrorRetryKey = "";
|
|
27418
27425
|
}
|
|
27419
27426
|
clearStaleIdleResponseGuard(reason) {
|
|
27420
27427
|
const blockingModal = this.activeModal || this.runParseApproval(this.recentOutputBuffer);
|
|
@@ -27564,6 +27571,7 @@ ${lastSnapshot}`;
|
|
|
27564
27571
|
return;
|
|
27565
27572
|
}
|
|
27566
27573
|
if (status === "error") {
|
|
27574
|
+
if (this.maybeScheduleProviderErrorRetry(ctx, session)) return;
|
|
27567
27575
|
this.applyError(ctx, session);
|
|
27568
27576
|
return;
|
|
27569
27577
|
}
|
|
@@ -27750,6 +27758,63 @@ ${lastSnapshot}`;
|
|
|
27750
27758
|
});
|
|
27751
27759
|
this.onStatusChange?.();
|
|
27752
27760
|
}
|
|
27761
|
+
maybeScheduleProviderErrorRetry(ctx, session) {
|
|
27762
|
+
const retryPrompt = typeof session.retryPrompt === "string" ? String(session.retryPrompt).trim() : "";
|
|
27763
|
+
const retryDelayMs = typeof session.retryDelayMs === "number" ? Number(session.retryDelayMs) : NaN;
|
|
27764
|
+
if (!retryPrompt || !Number.isFinite(retryDelayMs) || retryDelayMs < 0) return false;
|
|
27765
|
+
if (!this.ptyProcess) return false;
|
|
27766
|
+
const retryAttempt = typeof session.retryAttempt === "number" ? Number(session.retryAttempt) : 0;
|
|
27767
|
+
const retryMaxAttempts = typeof session.retryMaxAttempts === "number" ? Number(session.retryMaxAttempts) : 0;
|
|
27768
|
+
const errorReason = typeof session.errorReason === "string" && session.errorReason.trim() ? session.errorReason.trim() : "provider_error";
|
|
27769
|
+
const retryKey = `${errorReason}:${retryAttempt}:${retryPrompt}`;
|
|
27770
|
+
if (this.providerErrorRetryTimer && this.providerErrorRetryKey === retryKey) return true;
|
|
27771
|
+
if (this.providerErrorRetryTimer) clearTimeout(this.providerErrorRetryTimer);
|
|
27772
|
+
this.providerErrorRetryKey = retryKey;
|
|
27773
|
+
this.clearIdleFinishCandidate("provider_error_retry");
|
|
27774
|
+
if (this.idleTimeout) {
|
|
27775
|
+
clearTimeout(this.idleTimeout);
|
|
27776
|
+
this.idleTimeout = null;
|
|
27777
|
+
}
|
|
27778
|
+
if (this.approvalExitTimeout) {
|
|
27779
|
+
clearTimeout(this.approvalExitTimeout);
|
|
27780
|
+
this.approvalExitTimeout = null;
|
|
27781
|
+
}
|
|
27782
|
+
this.providerErrorMessage = typeof session.errorMessage === "string" && session.errorMessage.trim() ? session.errorMessage.trim() : "Provider reported an error";
|
|
27783
|
+
this.providerErrorReason = errorReason;
|
|
27784
|
+
this.activeModal = null;
|
|
27785
|
+
this.responseSettleIgnoreUntil = Date.now() + retryDelayMs + this.timeouts.outputSettle + 400;
|
|
27786
|
+
this.setStatus("generating", "provider_error_retry_scheduled");
|
|
27787
|
+
this.recordTrace("provider_error_retry_scheduled", {
|
|
27788
|
+
retryPrompt,
|
|
27789
|
+
retryDelayMs,
|
|
27790
|
+
retryAttempt,
|
|
27791
|
+
retryMaxAttempts,
|
|
27792
|
+
errorReason,
|
|
27793
|
+
parsedStatus: ctx.parsedStatus || ctx.status
|
|
27794
|
+
});
|
|
27795
|
+
this.onStatusChange?.();
|
|
27796
|
+
this.providerErrorRetryTimer = setTimeout(() => {
|
|
27797
|
+
this.providerErrorRetryTimer = null;
|
|
27798
|
+
this.providerErrorRetryKey = "";
|
|
27799
|
+
if (!this.ptyProcess) return;
|
|
27800
|
+
this.responseSettleIgnoreUntil = Date.now() + this.timeouts.outputSettle + 400;
|
|
27801
|
+
this.submitRetryUsed = false;
|
|
27802
|
+
this.recordTrace("provider_error_retry_write", {
|
|
27803
|
+
retryPrompt,
|
|
27804
|
+
retryAttempt,
|
|
27805
|
+
retryMaxAttempts,
|
|
27806
|
+
errorReason
|
|
27807
|
+
});
|
|
27808
|
+
this.ptyProcess.write(`${retryPrompt}\r`);
|
|
27809
|
+
if (this.settleTimer) clearTimeout(this.settleTimer);
|
|
27810
|
+
this.settleTimer = setTimeout(() => {
|
|
27811
|
+
this.settleTimer = null;
|
|
27812
|
+
this.settledBuffer = this.recentOutputBuffer;
|
|
27813
|
+
this.evaluateSettled();
|
|
27814
|
+
}, this.timeouts.outputSettle + 150);
|
|
27815
|
+
}, retryDelayMs);
|
|
27816
|
+
return true;
|
|
27817
|
+
}
|
|
27753
27818
|
applyIdle(ctx, now) {
|
|
27754
27819
|
const { modal, lastParsedAssistant, prevStatus } = ctx;
|
|
27755
27820
|
if (prevStatus === "waiting_approval") {
|
|
@@ -30862,11 +30927,17 @@ ${lastSnapshot}`;
|
|
|
30862
30927
|
}
|
|
30863
30928
|
function getSessionSeenAt(state, sessionId, providerSessionId) {
|
|
30864
30929
|
const providerKey = buildSessionReadStateKey(sessionId, providerSessionId);
|
|
30865
|
-
return state.sessionReads?.[providerKey] || state.sessionReads?.[sessionId] || 0;
|
|
30930
|
+
return Math.max(state.sessionReads?.[providerKey] || 0, state.sessionReads?.[sessionId] || 0);
|
|
30866
30931
|
}
|
|
30867
30932
|
function getSessionSeenMarker(state, sessionId, providerSessionId) {
|
|
30868
30933
|
const providerKey = buildSessionReadStateKey(sessionId, providerSessionId);
|
|
30869
|
-
|
|
30934
|
+
const providerSeenAt = state.sessionReads?.[providerKey] || 0;
|
|
30935
|
+
const sessionSeenAt = state.sessionReads?.[sessionId] || 0;
|
|
30936
|
+
const providerMarker = state.sessionReadMarkers?.[providerKey] || "";
|
|
30937
|
+
const sessionMarker = state.sessionReadMarkers?.[sessionId] || "";
|
|
30938
|
+
if (sessionSeenAt > providerSeenAt && sessionMarker) return sessionMarker;
|
|
30939
|
+
if (providerSeenAt > sessionSeenAt && providerMarker) return providerMarker;
|
|
30940
|
+
return providerMarker || sessionMarker;
|
|
30870
30941
|
}
|
|
30871
30942
|
function getSessionNotificationDismissal(state, sessionId, providerSessionId) {
|
|
30872
30943
|
const providerKey = buildSessionReadStateKey(sessionId, providerSessionId);
|
|
@@ -39160,7 +39231,20 @@ ${effect.notification.body || ""}`.trim();
|
|
|
39160
39231
|
if (visibleCount > excludeRecentCount) excludeRecentCount = visibleCount;
|
|
39161
39232
|
}
|
|
39162
39233
|
const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
|
|
39163
|
-
const
|
|
39234
|
+
const exactNativeHistoryScope = Boolean(
|
|
39235
|
+
typeof args?.targetSessionId === "string" && args.targetSessionId.trim() || typeof args?.historySessionId === "string" && args.historySessionId.trim() || typeof args?.providerSessionId === "string" && args.providerSessionId.trim()
|
|
39236
|
+
);
|
|
39237
|
+
const result = supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory) ? readCliProviderNativeHistory(agentStr, {
|
|
39238
|
+
canonicalHistory: provider?.canonicalHistory,
|
|
39239
|
+
historySessionId,
|
|
39240
|
+
workspace,
|
|
39241
|
+
offset: offset || 0,
|
|
39242
|
+
limit: limit || 30,
|
|
39243
|
+
excludeRecentCount,
|
|
39244
|
+
historyBehavior: provider?.historyBehavior,
|
|
39245
|
+
scripts: provider?.scripts,
|
|
39246
|
+
exactSessionScoped: exactNativeHistoryScope
|
|
39247
|
+
}) : readProviderChatHistory(agentStr, {
|
|
39164
39248
|
canonicalHistory: provider?.canonicalHistory,
|
|
39165
39249
|
historySessionId,
|
|
39166
39250
|
workspace,
|
|
@@ -39170,6 +39254,26 @@ ${effect.notification.body || ""}`.trim();
|
|
|
39170
39254
|
historyBehavior: provider?.historyBehavior,
|
|
39171
39255
|
scripts: provider?.scripts
|
|
39172
39256
|
});
|
|
39257
|
+
if (supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory)) {
|
|
39258
|
+
const lookup = result.lookup === "workspace" ? "workspace" : "session";
|
|
39259
|
+
const messages = Array.isArray(result.messages) ? normalizeNativeHistoryMessages(agentStr, result.messages) : [];
|
|
39260
|
+
const historyProviderSessionId = typeof result?.providerSessionId === "string" ? result.providerSessionId : readHistorySessionIdFromMessages(messages) || historySessionId;
|
|
39261
|
+
const safeMapping = hasSafeNativeHistoryMapping({
|
|
39262
|
+
historySessionId: lookup === "workspace" ? void 0 : historySessionId,
|
|
39263
|
+
providerSessionId: lookup === "workspace" ? void 0 : historyProviderSessionId,
|
|
39264
|
+
workspace,
|
|
39265
|
+
nativeMessages: messages
|
|
39266
|
+
});
|
|
39267
|
+
if (result.source === "provider-native" && messages.length > 0 && !safeMapping) {
|
|
39268
|
+
return {
|
|
39269
|
+
success: true,
|
|
39270
|
+
messages: [],
|
|
39271
|
+
hasMore: false,
|
|
39272
|
+
source: "native-unavailable",
|
|
39273
|
+
agent: agentStr
|
|
39274
|
+
};
|
|
39275
|
+
}
|
|
39276
|
+
}
|
|
39173
39277
|
return { success: true, ...result, agent: agentStr };
|
|
39174
39278
|
} catch (e) {
|
|
39175
39279
|
return { success: false, error: e.message };
|
|
@@ -41779,6 +41883,16 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41779
41883
|
}
|
|
41780
41884
|
return normalizedId;
|
|
41781
41885
|
}
|
|
41886
|
+
function isIdleStatus(value) {
|
|
41887
|
+
const status = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
41888
|
+
return !status || status === "idle" || status === "ready";
|
|
41889
|
+
}
|
|
41890
|
+
function getMessageTime(message) {
|
|
41891
|
+
if (!message || typeof message !== "object") return 0;
|
|
41892
|
+
const record2 = message;
|
|
41893
|
+
const value = Number(record2.receivedAt ?? record2.timestamp ?? 0);
|
|
41894
|
+
return Number.isFinite(value) ? value : 0;
|
|
41895
|
+
}
|
|
41782
41896
|
var COMPLETED_FINALIZATION_RETRY_MS = 1e3;
|
|
41783
41897
|
var COMPLETED_FINALIZATION_MAX_WAIT_MS = 3e4;
|
|
41784
41898
|
var IMAGE_MIME_EXTENSIONS = {
|
|
@@ -42040,7 +42154,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
42040
42154
|
await this.adapter.spawn();
|
|
42041
42155
|
await this.enforceFreshSessionLaunchIfNeeded();
|
|
42042
42156
|
this.maybeAppendRuntimeRecoveryMessage(this.adapter.getRuntimeMetadata());
|
|
42043
|
-
if (this.providerSessionId) {
|
|
42157
|
+
if (this.providerSessionId && this.shouldHydrateExistingProviderHistory()) {
|
|
42044
42158
|
this.restorePersistedHistoryFromCurrentSession();
|
|
42045
42159
|
}
|
|
42046
42160
|
if (this.providerSessionId && this.launchMode === "resume") {
|
|
@@ -42122,28 +42236,37 @@ ${effect.notification.body || ""}`.trim();
|
|
|
42122
42236
|
this.provider,
|
|
42123
42237
|
typeof adapterStatus?.providerSessionId === "string" ? adapterStatus.providerSessionId : ""
|
|
42124
42238
|
);
|
|
42125
|
-
if (adapterProviderSessionId) {
|
|
42126
|
-
this.promoteProviderSessionId(adapterProviderSessionId);
|
|
42127
|
-
}
|
|
42128
42239
|
const autoApproveActive = this.maybeAutoApproveStatus(adapterStatus, Date.now());
|
|
42129
42240
|
const visibleStatus = parseErrorMessage || parsedStatus?.status === "error" ? "error" : autoApproveActive ? "generating" : adapterStatus.status;
|
|
42241
|
+
const runtime = this.adapter.getRuntimeMetadata();
|
|
42242
|
+
this.maybeAppendRuntimeRecoveryMessage(runtime);
|
|
42243
|
+
let parsedMessages = Array.isArray(parsedStatus?.messages) ? parsedStatus.messages : [];
|
|
42130
42244
|
const parsedProviderSessionId = normalizeProviderSessionId(
|
|
42131
42245
|
this.provider,
|
|
42132
42246
|
typeof parsedStatus?.providerSessionId === "string" ? parsedStatus.providerSessionId : ""
|
|
42133
42247
|
);
|
|
42134
|
-
|
|
42248
|
+
const suppressFreshLaunchStartupReplay = this.shouldSuppressFreshLaunchStartupReplay(
|
|
42249
|
+
parsedMessages,
|
|
42250
|
+
parsedStatus,
|
|
42251
|
+
adapterStatus,
|
|
42252
|
+
parsedProviderSessionId
|
|
42253
|
+
);
|
|
42254
|
+
if (adapterProviderSessionId && !suppressFreshLaunchStartupReplay) {
|
|
42255
|
+
this.promoteProviderSessionId(adapterProviderSessionId);
|
|
42256
|
+
}
|
|
42257
|
+
if (parsedProviderSessionId && !suppressFreshLaunchStartupReplay) {
|
|
42135
42258
|
this.promoteProviderSessionId(parsedProviderSessionId);
|
|
42136
42259
|
}
|
|
42137
|
-
|
|
42138
|
-
|
|
42260
|
+
if (suppressFreshLaunchStartupReplay) {
|
|
42261
|
+
parsedMessages = [];
|
|
42262
|
+
}
|
|
42139
42263
|
const activeChatId = this.providerSessionId || runtime?.runtimeId || this.instanceId;
|
|
42140
|
-
let parsedMessages = Array.isArray(parsedStatus?.messages) ? parsedStatus.messages : [];
|
|
42141
42264
|
const historyMessageCount = Number.isFinite(parsedStatus?.historyMessageCount) ? Math.max(0, Number(parsedStatus.historyMessageCount)) : null;
|
|
42142
42265
|
if (historyMessageCount !== null) {
|
|
42143
42266
|
parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
|
|
42144
42267
|
}
|
|
42145
42268
|
const mergedMessages = this.mergeConversationMessages(parsedMessages);
|
|
42146
|
-
const canonicalBackedHistory = this.syncCanonicalSavedHistoryIfNeeded();
|
|
42269
|
+
const canonicalBackedHistory = this.shouldHydrateExistingProviderHistory() ? this.syncCanonicalSavedHistoryIfNeeded() : false;
|
|
42147
42270
|
const statusMessages = canonicalBackedHistory && this.lastPersistedHistoryMessages.length > 0 ? this.lastPersistedHistoryMessages.map((message) => ({
|
|
42148
42271
|
role: message.role,
|
|
42149
42272
|
content: message.content,
|
|
@@ -42186,7 +42309,10 @@ ${effect.notification.body || ""}`.trim();
|
|
|
42186
42309
|
this.lastPersistedHistoryMessages = normalizedMessagesToSave;
|
|
42187
42310
|
}
|
|
42188
42311
|
}
|
|
42189
|
-
this.applyProviderResponse(
|
|
42312
|
+
this.applyProviderResponse(
|
|
42313
|
+
suppressFreshLaunchStartupReplay && parsedStatus && typeof parsedStatus === "object" ? { ...parsedStatus, providerSessionId: void 0 } : parsedStatus,
|
|
42314
|
+
{ phase: "immediate" }
|
|
42315
|
+
);
|
|
42190
42316
|
const surface = resolveProviderStateSurface({
|
|
42191
42317
|
summaryMetadata: this.summaryMetadata,
|
|
42192
42318
|
controlValues: this.controlValues
|
|
@@ -42938,7 +43064,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
42938
43064
|
this.providerSessionId = nextSessionId;
|
|
42939
43065
|
this.historyWriter.promoteHistorySession(this.type, previousHistorySessionId, nextSessionId);
|
|
42940
43066
|
this.historyWriter.writeSessionStart(this.type, nextSessionId, this.workingDir, this.instanceId);
|
|
42941
|
-
this.
|
|
43067
|
+
if (this.shouldHydrateExistingProviderHistory()) {
|
|
43068
|
+
this.restorePersistedHistoryFromCurrentSession();
|
|
43069
|
+
}
|
|
42942
43070
|
this.adapter.updateRuntimeMeta({ providerSessionId: nextSessionId });
|
|
42943
43071
|
this.onProviderSessionResolved?.({
|
|
42944
43072
|
instanceId: this.instanceId,
|
|
@@ -42950,6 +43078,18 @@ ${effect.notification.body || ""}`.trim();
|
|
|
42950
43078
|
});
|
|
42951
43079
|
LOG2.info("CLI", `[${this.type}] discovered provider session id: ${nextSessionId}`);
|
|
42952
43080
|
}
|
|
43081
|
+
shouldHydrateExistingProviderHistory() {
|
|
43082
|
+
return this.launchMode === "resume" || this.launchMode === "manual";
|
|
43083
|
+
}
|
|
43084
|
+
shouldSuppressFreshLaunchStartupReplay(parsedMessages, parsedStatus, adapterStatus, parsedProviderSessionId = "") {
|
|
43085
|
+
if (this.launchMode !== "new") return false;
|
|
43086
|
+
if (this.providerSessionId) return false;
|
|
43087
|
+
if (!Array.isArray(parsedMessages) || parsedMessages.length === 0) return false;
|
|
43088
|
+
if (!isIdleStatus(adapterStatus?.status) || !isIdleStatus(parsedStatus?.status)) return false;
|
|
43089
|
+
if (parsedProviderSessionId) return true;
|
|
43090
|
+
const newestMessageAt = parsedMessages.reduce((newest, message) => Math.max(newest, getMessageTime(message)), 0);
|
|
43091
|
+
return newestMessageAt === 0;
|
|
43092
|
+
}
|
|
42953
43093
|
syncCanonicalSavedHistoryIfNeeded() {
|
|
42954
43094
|
if (!this.providerSessionId) return false;
|
|
42955
43095
|
const canonicalHistory = this.provider.canonicalHistory;
|
|
@@ -53489,7 +53629,8 @@ ${block2}`);
|
|
|
53489
53629
|
update: null
|
|
53490
53630
|
};
|
|
53491
53631
|
}
|
|
53492
|
-
const
|
|
53632
|
+
const rawMessages = Array.isArray(result.messages) ? result.messages : Array.isArray(result.messagesTail) ? result.messagesTail : [];
|
|
53633
|
+
const fullMessages = normalizeChatMessages(rawMessages);
|
|
53493
53634
|
const messages = fullMessages;
|
|
53494
53635
|
const title = typeof result.title === "string" ? result.title : void 0;
|
|
53495
53636
|
const activeModal = normalizeChatTailActiveModal(result.activeModal);
|