@adhdev/daemon-core 0.9.82-rc.113 → 0.9.82-rc.114
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 +20 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +28 -10
package/dist/index.mjs
CHANGED
|
@@ -16231,7 +16231,16 @@ function readHistorySessionIdFromMessages(messages) {
|
|
|
16231
16231
|
}
|
|
16232
16232
|
return void 0;
|
|
16233
16233
|
}
|
|
16234
|
-
function
|
|
16234
|
+
function shouldPreserveNativeIdentity(providerType, sessionId, message) {
|
|
16235
|
+
const providerUnitKey = typeof message.providerUnitKey === "string" ? message.providerUnitKey.trim() : "";
|
|
16236
|
+
const turnKey = typeof message._turnKey === "string" ? message._turnKey.trim() : "";
|
|
16237
|
+
if (!providerUnitKey || !turnKey) return false;
|
|
16238
|
+
if (providerType === "hermes-cli" && sessionId) {
|
|
16239
|
+
return providerUnitKey.startsWith(`${providerType}:native:${sessionId}:`) && turnKey.startsWith(`${providerType}:native-turn:${sessionId}:`);
|
|
16240
|
+
}
|
|
16241
|
+
return true;
|
|
16242
|
+
}
|
|
16243
|
+
function normalizeNativeHistoryMessages(providerType, messages, nativeSessionId) {
|
|
16235
16244
|
let turnIndex = 0;
|
|
16236
16245
|
return normalizeChatMessages(messages).map((message, index) => {
|
|
16237
16246
|
const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
@@ -16246,7 +16255,11 @@ function normalizeNativeHistoryMessages(providerType, messages) {
|
|
|
16246
16255
|
kind,
|
|
16247
16256
|
flattenContent(message.content)
|
|
16248
16257
|
]).slice(0, 12);
|
|
16249
|
-
const
|
|
16258
|
+
const nativeIdentitySessionId = historySessionId || (typeof nativeSessionId === "string" ? nativeSessionId.trim() : "");
|
|
16259
|
+
const preserveNativeIdentity = shouldPreserveNativeIdentity(providerType, nativeIdentitySessionId, message);
|
|
16260
|
+
const existingProviderUnitKey = typeof message.providerUnitKey === "string" ? message.providerUnitKey.trim() : "";
|
|
16261
|
+
const existingTurnKey = typeof message._turnKey === "string" ? message._turnKey.trim() : "";
|
|
16262
|
+
const providerUnitKey = preserveNativeIdentity ? existingProviderUnitKey : `${providerType}:native:${nativeIdentitySessionId || "workspace"}:${index}:${role || "message"}:${kind}:${contentHash}`;
|
|
16250
16263
|
const meta = message.meta && typeof message.meta === "object" ? message.meta : void 0;
|
|
16251
16264
|
const isSystemSessionStart = role === "system" || kind === "system" || kind === "session_start";
|
|
16252
16265
|
const isActivity = role === "assistant" && (kind === "tool" || kind === "terminal" || kind === "thought");
|
|
@@ -16255,8 +16268,8 @@ function normalizeNativeHistoryMessages(providerType, messages) {
|
|
|
16255
16268
|
role: role === "human" ? "user" : role || "assistant",
|
|
16256
16269
|
kind: isSystemSessionStart ? "system" : kind,
|
|
16257
16270
|
providerUnitKey,
|
|
16258
|
-
bubbleId: typeof message.bubbleId === "string" && message.bubbleId.trim() ? message.bubbleId.trim() : `bubble:${providerUnitKey}`,
|
|
16259
|
-
_turnKey:
|
|
16271
|
+
bubbleId: typeof message.bubbleId === "string" && message.bubbleId.trim() && preserveNativeIdentity ? message.bubbleId.trim() : `bubble:${providerUnitKey}`,
|
|
16272
|
+
_turnKey: preserveNativeIdentity ? existingTurnKey : `${providerType}:native-turn:${nativeIdentitySessionId || "workspace"}:${turnIndex}`,
|
|
16260
16273
|
bubbleState: message.bubbleState || "final",
|
|
16261
16274
|
...isSystemSessionStart ? {
|
|
16262
16275
|
visibility: message.visibility || "hidden",
|
|
@@ -16967,7 +16980,7 @@ async function handleChatHistory(h, args) {
|
|
|
16967
16980
|
});
|
|
16968
16981
|
if (supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory)) {
|
|
16969
16982
|
const lookup = result.lookup === "workspace" ? "workspace" : "session";
|
|
16970
|
-
const messages = Array.isArray(result.messages) ? normalizeNativeHistoryMessages(agentStr, result.messages) : [];
|
|
16983
|
+
const messages = Array.isArray(result.messages) ? normalizeNativeHistoryMessages(agentStr, result.messages, result?.providerSessionId) : [];
|
|
16971
16984
|
const historyProviderSessionId = typeof result?.providerSessionId === "string" ? result.providerSessionId : readHistorySessionIdFromMessages(messages) || historySessionId;
|
|
16972
16985
|
const safeMapping = hasSafeNativeHistoryMapping({
|
|
16973
16986
|
historySessionId: lookup === "workspace" ? void 0 : historySessionId,
|
|
@@ -17075,7 +17088,7 @@ async function handleReadChat(h, args) {
|
|
|
17075
17088
|
nativeHistory = null;
|
|
17076
17089
|
}
|
|
17077
17090
|
if (nativeHistory) {
|
|
17078
|
-
const nativeMessages = Array.isArray(nativeHistory.messages) ? normalizeNativeHistoryMessages(agentStr, nativeHistory.messages) : [];
|
|
17091
|
+
const nativeMessages = Array.isArray(nativeHistory.messages) ? normalizeNativeHistoryMessages(agentStr, nativeHistory.messages, nativeHistory?.providerSessionId) : [];
|
|
17079
17092
|
const historyProviderSessionId = typeof nativeHistory?.providerSessionId === "string" ? nativeHistory.providerSessionId : readHistorySessionIdFromMessages(nativeMessages) || nativeHistorySessionId || historySessionId;
|
|
17080
17093
|
const nativeHistoryCoverage = typeof nativeHistory?.nativeHistoryCoverage === "string" ? nativeHistory.nativeHistoryCoverage : void 0;
|
|
17081
17094
|
const partialReason = typeof nativeHistory?.partialReason === "string" ? nativeHistory.partialReason : void 0;
|
|
@@ -17203,7 +17216,7 @@ async function handleReadChat(h, args) {
|
|
|
17203
17216
|
scripts: provider?.scripts
|
|
17204
17217
|
});
|
|
17205
17218
|
const lookup = history.lookup === "workspace" ? "workspace" : "session";
|
|
17206
|
-
const historyMessages = Array.isArray(history?.messages) ? normalizeNativeHistoryMessages(agentStr, history.messages) : [];
|
|
17219
|
+
const historyMessages = Array.isArray(history?.messages) ? normalizeNativeHistoryMessages(agentStr, history.messages, history?.providerSessionId) : [];
|
|
17207
17220
|
const historyProviderSessionId = typeof history?.providerSessionId === "string" ? history.providerSessionId : readHistorySessionIdFromMessages(historyMessages) || historySessionId;
|
|
17208
17221
|
const nativeHistoryCoverage = typeof history?.nativeHistoryCoverage === "string" ? history.nativeHistoryCoverage : void 0;
|
|
17209
17222
|
const partialReason = typeof history?.partialReason === "string" ? history.partialReason : void 0;
|