adhdev 0.8.83 → 0.8.84
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/index.js +45 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +45 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -12938,6 +12938,30 @@ ${data.message || ""}`.trim();
|
|
|
12938
12938
|
});
|
|
12939
12939
|
|
|
12940
12940
|
// ../../oss/packages/daemon-core/src/providers/cli-provider-instance.ts
|
|
12941
|
+
function normalizePersistableCliHistoryContent(content) {
|
|
12942
|
+
return flattenContent(content).replace(/\s+/g, " ").trim();
|
|
12943
|
+
}
|
|
12944
|
+
function buildPersistableCliHistorySignature(message) {
|
|
12945
|
+
return [
|
|
12946
|
+
String(message.role || ""),
|
|
12947
|
+
String(message.kind || ""),
|
|
12948
|
+
String(message.senderName || ""),
|
|
12949
|
+
normalizePersistableCliHistoryContent(message.content)
|
|
12950
|
+
].join("|");
|
|
12951
|
+
}
|
|
12952
|
+
function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages) {
|
|
12953
|
+
if (!Array.isArray(currentMessages) || currentMessages.length === 0) return [];
|
|
12954
|
+
if (!Array.isArray(previousMessages) || previousMessages.length === 0) return currentMessages;
|
|
12955
|
+
const previousSignatures = previousMessages.map(buildPersistableCliHistorySignature);
|
|
12956
|
+
const currentSignatures = currentMessages.map(buildPersistableCliHistorySignature);
|
|
12957
|
+
let sharedPrefixLength = 0;
|
|
12958
|
+
while (sharedPrefixLength < previousSignatures.length && sharedPrefixLength < currentSignatures.length && previousSignatures[sharedPrefixLength] === currentSignatures[sharedPrefixLength]) {
|
|
12959
|
+
sharedPrefixLength += 1;
|
|
12960
|
+
}
|
|
12961
|
+
if (sharedPrefixLength === currentSignatures.length) return [];
|
|
12962
|
+
if (sharedPrefixLength === previousSignatures.length) return currentMessages.slice(sharedPrefixLength);
|
|
12963
|
+
return currentMessages;
|
|
12964
|
+
}
|
|
12941
12965
|
function getDatabaseSync() {
|
|
12942
12966
|
if (CachedDatabaseSync) return CachedDatabaseSync;
|
|
12943
12967
|
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path11.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
|
|
@@ -13036,6 +13060,7 @@ var init_cli_provider_instance = __esm({
|
|
|
13036
13060
|
appliedEffectKeys = /* @__PURE__ */ new Set();
|
|
13037
13061
|
historyWriter;
|
|
13038
13062
|
runtimeMessages = [];
|
|
13063
|
+
lastPersistedHistoryMessages = [];
|
|
13039
13064
|
instanceId;
|
|
13040
13065
|
suppressIdleHistoryReplay = false;
|
|
13041
13066
|
errorMessage = void 0;
|
|
@@ -13076,6 +13101,13 @@ var init_cli_provider_instance = __esm({
|
|
|
13076
13101
|
this.providerSessionId,
|
|
13077
13102
|
this.instanceId
|
|
13078
13103
|
);
|
|
13104
|
+
this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
|
|
13105
|
+
role: message.role,
|
|
13106
|
+
content: message.content,
|
|
13107
|
+
kind: message.kind,
|
|
13108
|
+
senderName: message.senderName,
|
|
13109
|
+
receivedAt: message.receivedAt
|
|
13110
|
+
}));
|
|
13079
13111
|
this.suppressIdleHistoryReplay = restoredHistory.messages.length > 0;
|
|
13080
13112
|
if (restoredHistory.messages.length > 0) {
|
|
13081
13113
|
this.adapter.seedCommittedMessages(
|
|
@@ -13207,15 +13239,24 @@ var init_cli_provider_instance = __esm({
|
|
|
13207
13239
|
messagesToSave = messagesToSave.slice(0, lastIdx);
|
|
13208
13240
|
}
|
|
13209
13241
|
}
|
|
13210
|
-
|
|
13242
|
+
const normalizedMessagesToSave = messagesToSave.map((message) => ({
|
|
13243
|
+
role: message.role,
|
|
13244
|
+
content: flattenContent(message.content),
|
|
13245
|
+
kind: typeof message.kind === "string" ? message.kind : void 0,
|
|
13246
|
+
senderName: typeof message.senderName === "string" ? message.senderName : void 0,
|
|
13247
|
+
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
13248
|
+
}));
|
|
13249
|
+
if (!shouldSkipReplayPersist && normalizedMessagesToSave.length > 0) {
|
|
13250
|
+
const incrementalMessages = buildIncrementalHistoryAppendMessages(this.lastPersistedHistoryMessages, normalizedMessagesToSave);
|
|
13211
13251
|
this.historyWriter.appendNewMessages(
|
|
13212
13252
|
this.type,
|
|
13213
|
-
|
|
13253
|
+
incrementalMessages,
|
|
13214
13254
|
parsedStatus?.title || dirName,
|
|
13215
13255
|
this.instanceId,
|
|
13216
13256
|
this.providerSessionId
|
|
13217
13257
|
);
|
|
13218
13258
|
}
|
|
13259
|
+
this.lastPersistedHistoryMessages = normalizedMessagesToSave;
|
|
13219
13260
|
}
|
|
13220
13261
|
this.applyProviderResponse(parsedStatus, { phase: "immediate" });
|
|
13221
13262
|
const surface = resolveProviderStateSurface({
|
|
@@ -13463,6 +13504,7 @@ var init_cli_provider_instance = __esm({
|
|
|
13463
13504
|
}
|
|
13464
13505
|
if (data.sessionEvent === "new_session") {
|
|
13465
13506
|
this.runtimeMessages = [];
|
|
13507
|
+
this.lastPersistedHistoryMessages = [];
|
|
13466
13508
|
this.suppressIdleHistoryReplay = false;
|
|
13467
13509
|
this.adapter.clearHistory();
|
|
13468
13510
|
}
|
|
@@ -54404,7 +54446,7 @@ var init_adhdev_daemon = __esm({
|
|
|
54404
54446
|
init_source2();
|
|
54405
54447
|
init_version();
|
|
54406
54448
|
init_src();
|
|
54407
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.
|
|
54449
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.84" });
|
|
54408
54450
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
54409
54451
|
localHttpServer = null;
|
|
54410
54452
|
localWss = null;
|