@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.js
CHANGED
|
@@ -16490,7 +16490,16 @@ function readHistorySessionIdFromMessages(messages) {
|
|
|
16490
16490
|
}
|
|
16491
16491
|
return void 0;
|
|
16492
16492
|
}
|
|
16493
|
-
function
|
|
16493
|
+
function shouldPreserveNativeIdentity(providerType, sessionId, message) {
|
|
16494
|
+
const providerUnitKey = typeof message.providerUnitKey === "string" ? message.providerUnitKey.trim() : "";
|
|
16495
|
+
const turnKey = typeof message._turnKey === "string" ? message._turnKey.trim() : "";
|
|
16496
|
+
if (!providerUnitKey || !turnKey) return false;
|
|
16497
|
+
if (providerType === "hermes-cli" && sessionId) {
|
|
16498
|
+
return providerUnitKey.startsWith(`${providerType}:native:${sessionId}:`) && turnKey.startsWith(`${providerType}:native-turn:${sessionId}:`);
|
|
16499
|
+
}
|
|
16500
|
+
return true;
|
|
16501
|
+
}
|
|
16502
|
+
function normalizeNativeHistoryMessages(providerType, messages, nativeSessionId) {
|
|
16494
16503
|
let turnIndex = 0;
|
|
16495
16504
|
return normalizeChatMessages(messages).map((message, index) => {
|
|
16496
16505
|
const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
@@ -16505,7 +16514,11 @@ function normalizeNativeHistoryMessages(providerType, messages) {
|
|
|
16505
16514
|
kind,
|
|
16506
16515
|
flattenContent(message.content)
|
|
16507
16516
|
]).slice(0, 12);
|
|
16508
|
-
const
|
|
16517
|
+
const nativeIdentitySessionId = historySessionId || (typeof nativeSessionId === "string" ? nativeSessionId.trim() : "");
|
|
16518
|
+
const preserveNativeIdentity = shouldPreserveNativeIdentity(providerType, nativeIdentitySessionId, message);
|
|
16519
|
+
const existingProviderUnitKey = typeof message.providerUnitKey === "string" ? message.providerUnitKey.trim() : "";
|
|
16520
|
+
const existingTurnKey = typeof message._turnKey === "string" ? message._turnKey.trim() : "";
|
|
16521
|
+
const providerUnitKey = preserveNativeIdentity ? existingProviderUnitKey : `${providerType}:native:${nativeIdentitySessionId || "workspace"}:${index}:${role || "message"}:${kind}:${contentHash}`;
|
|
16509
16522
|
const meta = message.meta && typeof message.meta === "object" ? message.meta : void 0;
|
|
16510
16523
|
const isSystemSessionStart = role === "system" || kind === "system" || kind === "session_start";
|
|
16511
16524
|
const isActivity = role === "assistant" && (kind === "tool" || kind === "terminal" || kind === "thought");
|
|
@@ -16514,8 +16527,8 @@ function normalizeNativeHistoryMessages(providerType, messages) {
|
|
|
16514
16527
|
role: role === "human" ? "user" : role || "assistant",
|
|
16515
16528
|
kind: isSystemSessionStart ? "system" : kind,
|
|
16516
16529
|
providerUnitKey,
|
|
16517
|
-
bubbleId: typeof message.bubbleId === "string" && message.bubbleId.trim() ? message.bubbleId.trim() : `bubble:${providerUnitKey}`,
|
|
16518
|
-
_turnKey:
|
|
16530
|
+
bubbleId: typeof message.bubbleId === "string" && message.bubbleId.trim() && preserveNativeIdentity ? message.bubbleId.trim() : `bubble:${providerUnitKey}`,
|
|
16531
|
+
_turnKey: preserveNativeIdentity ? existingTurnKey : `${providerType}:native-turn:${nativeIdentitySessionId || "workspace"}:${turnIndex}`,
|
|
16519
16532
|
bubbleState: message.bubbleState || "final",
|
|
16520
16533
|
...isSystemSessionStart ? {
|
|
16521
16534
|
visibility: message.visibility || "hidden",
|
|
@@ -17226,7 +17239,7 @@ async function handleChatHistory(h, args) {
|
|
|
17226
17239
|
});
|
|
17227
17240
|
if (supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory)) {
|
|
17228
17241
|
const lookup = result.lookup === "workspace" ? "workspace" : "session";
|
|
17229
|
-
const messages = Array.isArray(result.messages) ? normalizeNativeHistoryMessages(agentStr, result.messages) : [];
|
|
17242
|
+
const messages = Array.isArray(result.messages) ? normalizeNativeHistoryMessages(agentStr, result.messages, result?.providerSessionId) : [];
|
|
17230
17243
|
const historyProviderSessionId = typeof result?.providerSessionId === "string" ? result.providerSessionId : readHistorySessionIdFromMessages(messages) || historySessionId;
|
|
17231
17244
|
const safeMapping = hasSafeNativeHistoryMapping({
|
|
17232
17245
|
historySessionId: lookup === "workspace" ? void 0 : historySessionId,
|
|
@@ -17334,7 +17347,7 @@ async function handleReadChat(h, args) {
|
|
|
17334
17347
|
nativeHistory = null;
|
|
17335
17348
|
}
|
|
17336
17349
|
if (nativeHistory) {
|
|
17337
|
-
const nativeMessages = Array.isArray(nativeHistory.messages) ? normalizeNativeHistoryMessages(agentStr, nativeHistory.messages) : [];
|
|
17350
|
+
const nativeMessages = Array.isArray(nativeHistory.messages) ? normalizeNativeHistoryMessages(agentStr, nativeHistory.messages, nativeHistory?.providerSessionId) : [];
|
|
17338
17351
|
const historyProviderSessionId = typeof nativeHistory?.providerSessionId === "string" ? nativeHistory.providerSessionId : readHistorySessionIdFromMessages(nativeMessages) || nativeHistorySessionId || historySessionId;
|
|
17339
17352
|
const nativeHistoryCoverage = typeof nativeHistory?.nativeHistoryCoverage === "string" ? nativeHistory.nativeHistoryCoverage : void 0;
|
|
17340
17353
|
const partialReason = typeof nativeHistory?.partialReason === "string" ? nativeHistory.partialReason : void 0;
|
|
@@ -17462,7 +17475,7 @@ async function handleReadChat(h, args) {
|
|
|
17462
17475
|
scripts: provider?.scripts
|
|
17463
17476
|
});
|
|
17464
17477
|
const lookup = history.lookup === "workspace" ? "workspace" : "session";
|
|
17465
|
-
const historyMessages = Array.isArray(history?.messages) ? normalizeNativeHistoryMessages(agentStr, history.messages) : [];
|
|
17478
|
+
const historyMessages = Array.isArray(history?.messages) ? normalizeNativeHistoryMessages(agentStr, history.messages, history?.providerSessionId) : [];
|
|
17466
17479
|
const historyProviderSessionId = typeof history?.providerSessionId === "string" ? history.providerSessionId : readHistorySessionIdFromMessages(historyMessages) || historySessionId;
|
|
17467
17480
|
const nativeHistoryCoverage = typeof history?.nativeHistoryCoverage === "string" ? history.nativeHistoryCoverage : void 0;
|
|
17468
17481
|
const partialReason = typeof history?.partialReason === "string" ? history.partialReason : void 0;
|