@adhdev/daemon-standalone 0.9.52 → 0.9.53
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
CHANGED
|
@@ -35967,6 +35967,10 @@ ${cleanBody}`;
|
|
|
35967
35967
|
return name.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
35968
35968
|
}
|
|
35969
35969
|
};
|
|
35970
|
+
function normalizePaginationNumber(value, fallback, min) {
|
|
35971
|
+
const numeric = Number(value);
|
|
35972
|
+
return Number.isFinite(numeric) ? Math.max(min, numeric) : fallback;
|
|
35973
|
+
}
|
|
35970
35974
|
function pageHistoryRecords(agentType, records, offset = 0, limit = 30, excludeRecentCount = 0, historyBehavior) {
|
|
35971
35975
|
const allMessages = records.map((message) => sanitizeHistoryMessage(agentType, message)).filter(Boolean);
|
|
35972
35976
|
allMessages.sort((a, b2) => a.receivedAt - b2.receivedAt);
|
|
@@ -35980,9 +35984,12 @@ ${cleanBody}`;
|
|
|
35980
35984
|
if (message.role !== "system") lastTurn = message;
|
|
35981
35985
|
}
|
|
35982
35986
|
const collapsed = collapseReplayAssistantTurns(chronological, historyBehavior);
|
|
35983
|
-
const boundedLimit =
|
|
35984
|
-
const boundedOffset =
|
|
35985
|
-
const boundedExclude = Math.
|
|
35987
|
+
const boundedLimit = normalizePaginationNumber(limit, 30, 1);
|
|
35988
|
+
const boundedOffset = normalizePaginationNumber(offset, 0, 0);
|
|
35989
|
+
const boundedExclude = Math.min(
|
|
35990
|
+
normalizePaginationNumber(excludeRecentCount, 0, 0),
|
|
35991
|
+
collapsed.length
|
|
35992
|
+
);
|
|
35986
35993
|
const endExclusive = Math.max(0, collapsed.length - boundedExclude - boundedOffset);
|
|
35987
35994
|
const startInclusive = Math.max(0, endExclusive - boundedLimit);
|
|
35988
35995
|
const sliced = collapsed.slice(startInclusive, endExclusive);
|
|
@@ -39149,6 +39156,28 @@ ${effect.notification.body || ""}`.trim();
|
|
|
39149
39156
|
if (!last) return "";
|
|
39150
39157
|
return `${last.role || ""}:${String(last.content || "").replace(/\s+/g, " ").trim()}`;
|
|
39151
39158
|
}
|
|
39159
|
+
function toNonNegativeNumber(value) {
|
|
39160
|
+
const numeric = Number(value ?? 0);
|
|
39161
|
+
return Number.isFinite(numeric) ? Math.max(0, numeric) : 0;
|
|
39162
|
+
}
|
|
39163
|
+
function getCliVisibleTranscriptCount(adapter) {
|
|
39164
|
+
const adapterStatus = adapter?.getStatus?.() || {};
|
|
39165
|
+
const adapterMessages = Array.isArray(adapterStatus.messages) ? adapterStatus.messages : [];
|
|
39166
|
+
let parsedRecord = null;
|
|
39167
|
+
if (typeof adapter?.getScriptParsedStatus === "function") {
|
|
39168
|
+
try {
|
|
39169
|
+
const parsed = parseMaybeJson(adapter.getScriptParsedStatus());
|
|
39170
|
+
parsedRecord = parsed && typeof parsed === "object" ? parsed : null;
|
|
39171
|
+
} catch {
|
|
39172
|
+
parsedRecord = null;
|
|
39173
|
+
}
|
|
39174
|
+
}
|
|
39175
|
+
const parsedMessages = Array.isArray(parsedRecord?.messages) ? parsedRecord.messages : [];
|
|
39176
|
+
if (!parsedRecord) return adapterMessages.length;
|
|
39177
|
+
const parsedIsProviderAuthoritative = parsedRecord.transcriptAuthority === "provider" || parsedRecord.coverage === "full";
|
|
39178
|
+
const shouldPreferAdapterMessages = !parsedIsProviderAuthoritative && adapterMessages.length > 0 && adapterMessages.length > parsedMessages.length;
|
|
39179
|
+
return shouldPreferAdapterMessages ? adapterMessages.length : parsedMessages.length;
|
|
39180
|
+
}
|
|
39152
39181
|
async function getStableExtensionBaseline(h) {
|
|
39153
39182
|
const first = await readExtensionChatState(h);
|
|
39154
39183
|
if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
|
|
@@ -39177,11 +39206,11 @@ ${effect.notification.body || ""}`.trim();
|
|
|
39177
39206
|
const provider = h.getProvider(agentType);
|
|
39178
39207
|
const agentStr = provider?.type || agentType || getCurrentProviderType(h);
|
|
39179
39208
|
const transport = getTargetTransport(h, provider);
|
|
39180
|
-
|
|
39181
|
-
|
|
39209
|
+
const hasExplicitExcludeRecentCount = args?.excludeRecentCount !== void 0 && args?.excludeRecentCount !== null;
|
|
39210
|
+
let excludeRecentCount = toNonNegativeNumber(args?.excludeRecentCount);
|
|
39211
|
+
if (!hasExplicitExcludeRecentCount && isCliLikeTransport(transport)) {
|
|
39182
39212
|
const adapter = getTargetedCliAdapter(h, args, provider?.type);
|
|
39183
|
-
const
|
|
39184
|
-
const visibleCount = Array.isArray(status?.messages) ? status.messages.length : 0;
|
|
39213
|
+
const visibleCount = getCliVisibleTranscriptCount(adapter);
|
|
39185
39214
|
if (visibleCount > excludeRecentCount) excludeRecentCount = visibleCount;
|
|
39186
39215
|
}
|
|
39187
39216
|
const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
|