@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.js
CHANGED
|
@@ -8135,6 +8135,10 @@ var ChatHistoryWriter = class {
|
|
|
8135
8135
|
return name.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
8136
8136
|
}
|
|
8137
8137
|
};
|
|
8138
|
+
function normalizePaginationNumber(value, fallback, min) {
|
|
8139
|
+
const numeric = Number(value);
|
|
8140
|
+
return Number.isFinite(numeric) ? Math.max(min, numeric) : fallback;
|
|
8141
|
+
}
|
|
8138
8142
|
function pageHistoryRecords(agentType, records, offset = 0, limit = 30, excludeRecentCount = 0, historyBehavior) {
|
|
8139
8143
|
const allMessages = records.map((message) => sanitizeHistoryMessage(agentType, message)).filter(Boolean);
|
|
8140
8144
|
allMessages.sort((a, b) => a.receivedAt - b.receivedAt);
|
|
@@ -8148,9 +8152,12 @@ function pageHistoryRecords(agentType, records, offset = 0, limit = 30, excludeR
|
|
|
8148
8152
|
if (message.role !== "system") lastTurn = message;
|
|
8149
8153
|
}
|
|
8150
8154
|
const collapsed = collapseReplayAssistantTurns(chronological, historyBehavior);
|
|
8151
|
-
const boundedLimit =
|
|
8152
|
-
const boundedOffset =
|
|
8153
|
-
const boundedExclude = Math.
|
|
8155
|
+
const boundedLimit = normalizePaginationNumber(limit, 30, 1);
|
|
8156
|
+
const boundedOffset = normalizePaginationNumber(offset, 0, 0);
|
|
8157
|
+
const boundedExclude = Math.min(
|
|
8158
|
+
normalizePaginationNumber(excludeRecentCount, 0, 0),
|
|
8159
|
+
collapsed.length
|
|
8160
|
+
);
|
|
8154
8161
|
const endExclusive = Math.max(0, collapsed.length - boundedExclude - boundedOffset);
|
|
8155
8162
|
const startInclusive = Math.max(0, endExclusive - boundedLimit);
|
|
8156
8163
|
const sliced = collapsed.slice(startInclusive, endExclusive);
|
|
@@ -11363,6 +11370,28 @@ function getStateLastSignature(state) {
|
|
|
11363
11370
|
if (!last) return "";
|
|
11364
11371
|
return `${last.role || ""}:${String(last.content || "").replace(/\s+/g, " ").trim()}`;
|
|
11365
11372
|
}
|
|
11373
|
+
function toNonNegativeNumber(value) {
|
|
11374
|
+
const numeric = Number(value ?? 0);
|
|
11375
|
+
return Number.isFinite(numeric) ? Math.max(0, numeric) : 0;
|
|
11376
|
+
}
|
|
11377
|
+
function getCliVisibleTranscriptCount(adapter) {
|
|
11378
|
+
const adapterStatus = adapter?.getStatus?.() || {};
|
|
11379
|
+
const adapterMessages = Array.isArray(adapterStatus.messages) ? adapterStatus.messages : [];
|
|
11380
|
+
let parsedRecord = null;
|
|
11381
|
+
if (typeof adapter?.getScriptParsedStatus === "function") {
|
|
11382
|
+
try {
|
|
11383
|
+
const parsed = parseMaybeJson(adapter.getScriptParsedStatus());
|
|
11384
|
+
parsedRecord = parsed && typeof parsed === "object" ? parsed : null;
|
|
11385
|
+
} catch {
|
|
11386
|
+
parsedRecord = null;
|
|
11387
|
+
}
|
|
11388
|
+
}
|
|
11389
|
+
const parsedMessages = Array.isArray(parsedRecord?.messages) ? parsedRecord.messages : [];
|
|
11390
|
+
if (!parsedRecord) return adapterMessages.length;
|
|
11391
|
+
const parsedIsProviderAuthoritative = parsedRecord.transcriptAuthority === "provider" || parsedRecord.coverage === "full";
|
|
11392
|
+
const shouldPreferAdapterMessages = !parsedIsProviderAuthoritative && adapterMessages.length > 0 && adapterMessages.length > parsedMessages.length;
|
|
11393
|
+
return shouldPreferAdapterMessages ? adapterMessages.length : parsedMessages.length;
|
|
11394
|
+
}
|
|
11366
11395
|
async function getStableExtensionBaseline(h) {
|
|
11367
11396
|
const first = await readExtensionChatState(h);
|
|
11368
11397
|
if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
|
|
@@ -11391,11 +11420,11 @@ async function handleChatHistory(h, args) {
|
|
|
11391
11420
|
const provider = h.getProvider(agentType);
|
|
11392
11421
|
const agentStr = provider?.type || agentType || getCurrentProviderType(h);
|
|
11393
11422
|
const transport = getTargetTransport(h, provider);
|
|
11394
|
-
|
|
11395
|
-
|
|
11423
|
+
const hasExplicitExcludeRecentCount = args?.excludeRecentCount !== void 0 && args?.excludeRecentCount !== null;
|
|
11424
|
+
let excludeRecentCount = toNonNegativeNumber(args?.excludeRecentCount);
|
|
11425
|
+
if (!hasExplicitExcludeRecentCount && isCliLikeTransport(transport)) {
|
|
11396
11426
|
const adapter = getTargetedCliAdapter(h, args, provider?.type);
|
|
11397
|
-
const
|
|
11398
|
-
const visibleCount = Array.isArray(status?.messages) ? status.messages.length : 0;
|
|
11427
|
+
const visibleCount = getCliVisibleTranscriptCount(adapter);
|
|
11399
11428
|
if (visibleCount > excludeRecentCount) excludeRecentCount = visibleCount;
|
|
11400
11429
|
}
|
|
11401
11430
|
const workspace = typeof args?.workspace === "string" ? args.workspace : typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
|