@adhdev/daemon-core 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 +36 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -7
- package/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +31 -4
- package/src/config/chat-history.ts +11 -3
package/dist/index.mjs
CHANGED
|
@@ -7980,6 +7980,10 @@ var ChatHistoryWriter = class {
|
|
|
7980
7980
|
return name.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
7981
7981
|
}
|
|
7982
7982
|
};
|
|
7983
|
+
function normalizePaginationNumber(value, fallback, min) {
|
|
7984
|
+
const numeric = Number(value);
|
|
7985
|
+
return Number.isFinite(numeric) ? Math.max(min, numeric) : fallback;
|
|
7986
|
+
}
|
|
7983
7987
|
function pageHistoryRecords(agentType, records, offset = 0, limit = 30, excludeRecentCount = 0, historyBehavior) {
|
|
7984
7988
|
const allMessages = records.map((message) => sanitizeHistoryMessage(agentType, message)).filter(Boolean);
|
|
7985
7989
|
allMessages.sort((a, b) => a.receivedAt - b.receivedAt);
|
|
@@ -7993,9 +7997,12 @@ function pageHistoryRecords(agentType, records, offset = 0, limit = 30, excludeR
|
|
|
7993
7997
|
if (message.role !== "system") lastTurn = message;
|
|
7994
7998
|
}
|
|
7995
7999
|
const collapsed = collapseReplayAssistantTurns(chronological, historyBehavior);
|
|
7996
|
-
const boundedLimit =
|
|
7997
|
-
const boundedOffset =
|
|
7998
|
-
const boundedExclude = Math.
|
|
8000
|
+
const boundedLimit = normalizePaginationNumber(limit, 30, 1);
|
|
8001
|
+
const boundedOffset = normalizePaginationNumber(offset, 0, 0);
|
|
8002
|
+
const boundedExclude = Math.min(
|
|
8003
|
+
normalizePaginationNumber(excludeRecentCount, 0, 0),
|
|
8004
|
+
collapsed.length
|
|
8005
|
+
);
|
|
7999
8006
|
const endExclusive = Math.max(0, collapsed.length - boundedExclude - boundedOffset);
|
|
8000
8007
|
const startInclusive = Math.max(0, endExclusive - boundedLimit);
|
|
8001
8008
|
const sliced = collapsed.slice(startInclusive, endExclusive);
|
|
@@ -11208,6 +11215,28 @@ function getStateLastSignature(state) {
|
|
|
11208
11215
|
if (!last) return "";
|
|
11209
11216
|
return `${last.role || ""}:${String(last.content || "").replace(/\s+/g, " ").trim()}`;
|
|
11210
11217
|
}
|
|
11218
|
+
function toNonNegativeNumber(value) {
|
|
11219
|
+
const numeric = Number(value ?? 0);
|
|
11220
|
+
return Number.isFinite(numeric) ? Math.max(0, numeric) : 0;
|
|
11221
|
+
}
|
|
11222
|
+
function getCliVisibleTranscriptCount(adapter) {
|
|
11223
|
+
const adapterStatus = adapter?.getStatus?.() || {};
|
|
11224
|
+
const adapterMessages = Array.isArray(adapterStatus.messages) ? adapterStatus.messages : [];
|
|
11225
|
+
let parsedRecord = null;
|
|
11226
|
+
if (typeof adapter?.getScriptParsedStatus === "function") {
|
|
11227
|
+
try {
|
|
11228
|
+
const parsed = parseMaybeJson(adapter.getScriptParsedStatus());
|
|
11229
|
+
parsedRecord = parsed && typeof parsed === "object" ? parsed : null;
|
|
11230
|
+
} catch {
|
|
11231
|
+
parsedRecord = null;
|
|
11232
|
+
}
|
|
11233
|
+
}
|
|
11234
|
+
const parsedMessages = Array.isArray(parsedRecord?.messages) ? parsedRecord.messages : [];
|
|
11235
|
+
if (!parsedRecord) return adapterMessages.length;
|
|
11236
|
+
const parsedIsProviderAuthoritative = parsedRecord.transcriptAuthority === "provider" || parsedRecord.coverage === "full";
|
|
11237
|
+
const shouldPreferAdapterMessages = !parsedIsProviderAuthoritative && adapterMessages.length > 0 && adapterMessages.length > parsedMessages.length;
|
|
11238
|
+
return shouldPreferAdapterMessages ? adapterMessages.length : parsedMessages.length;
|
|
11239
|
+
}
|
|
11211
11240
|
async function getStableExtensionBaseline(h) {
|
|
11212
11241
|
const first = await readExtensionChatState(h);
|
|
11213
11242
|
if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
|
|
@@ -11236,11 +11265,11 @@ async function handleChatHistory(h, args) {
|
|
|
11236
11265
|
const provider = h.getProvider(agentType);
|
|
11237
11266
|
const agentStr = provider?.type || agentType || getCurrentProviderType(h);
|
|
11238
11267
|
const transport = getTargetTransport(h, provider);
|
|
11239
|
-
|
|
11240
|
-
|
|
11268
|
+
const hasExplicitExcludeRecentCount = args?.excludeRecentCount !== void 0 && args?.excludeRecentCount !== null;
|
|
11269
|
+
let excludeRecentCount = toNonNegativeNumber(args?.excludeRecentCount);
|
|
11270
|
+
if (!hasExplicitExcludeRecentCount && isCliLikeTransport(transport)) {
|
|
11241
11271
|
const adapter = getTargetedCliAdapter(h, args, provider?.type);
|
|
11242
|
-
const
|
|
11243
|
-
const visibleCount = Array.isArray(status?.messages) ? status.messages.length : 0;
|
|
11272
|
+
const visibleCount = getCliVisibleTranscriptCount(adapter);
|
|
11244
11273
|
if (visibleCount > excludeRecentCount) excludeRecentCount = visibleCount;
|
|
11245
11274
|
}
|
|
11246
11275
|
const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
|