@adhdev/daemon-standalone 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 CHANGED
@@ -38520,7 +38520,16 @@ ${effect.notification.body || ""}`.trim();
38520
38520
  }
38521
38521
  return void 0;
38522
38522
  }
38523
- function normalizeNativeHistoryMessages(providerType, messages) {
38523
+ function shouldPreserveNativeIdentity(providerType, sessionId, message) {
38524
+ const providerUnitKey = typeof message.providerUnitKey === "string" ? message.providerUnitKey.trim() : "";
38525
+ const turnKey = typeof message._turnKey === "string" ? message._turnKey.trim() : "";
38526
+ if (!providerUnitKey || !turnKey) return false;
38527
+ if (providerType === "hermes-cli" && sessionId) {
38528
+ return providerUnitKey.startsWith(`${providerType}:native:${sessionId}:`) && turnKey.startsWith(`${providerType}:native-turn:${sessionId}:`);
38529
+ }
38530
+ return true;
38531
+ }
38532
+ function normalizeNativeHistoryMessages(providerType, messages, nativeSessionId) {
38524
38533
  let turnIndex = 0;
38525
38534
  return normalizeChatMessages(messages).map((message, index) => {
38526
38535
  const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
@@ -38535,7 +38544,11 @@ ${effect.notification.body || ""}`.trim();
38535
38544
  kind,
38536
38545
  flattenContent(message.content)
38537
38546
  ]).slice(0, 12);
38538
- const providerUnitKey = typeof message.providerUnitKey === "string" && message.providerUnitKey.trim() ? message.providerUnitKey.trim() : `${providerType}:native:${historySessionId || "workspace"}:${index}:${role || "message"}:${kind}:${contentHash}`;
38547
+ const nativeIdentitySessionId = historySessionId || (typeof nativeSessionId === "string" ? nativeSessionId.trim() : "");
38548
+ const preserveNativeIdentity = shouldPreserveNativeIdentity(providerType, nativeIdentitySessionId, message);
38549
+ const existingProviderUnitKey = typeof message.providerUnitKey === "string" ? message.providerUnitKey.trim() : "";
38550
+ const existingTurnKey = typeof message._turnKey === "string" ? message._turnKey.trim() : "";
38551
+ const providerUnitKey = preserveNativeIdentity ? existingProviderUnitKey : `${providerType}:native:${nativeIdentitySessionId || "workspace"}:${index}:${role || "message"}:${kind}:${contentHash}`;
38539
38552
  const meta3 = message.meta && typeof message.meta === "object" ? message.meta : void 0;
38540
38553
  const isSystemSessionStart = role === "system" || kind === "system" || kind === "session_start";
38541
38554
  const isActivity = role === "assistant" && (kind === "tool" || kind === "terminal" || kind === "thought");
@@ -38544,8 +38557,8 @@ ${effect.notification.body || ""}`.trim();
38544
38557
  role: role === "human" ? "user" : role || "assistant",
38545
38558
  kind: isSystemSessionStart ? "system" : kind,
38546
38559
  providerUnitKey,
38547
- bubbleId: typeof message.bubbleId === "string" && message.bubbleId.trim() ? message.bubbleId.trim() : `bubble:${providerUnitKey}`,
38548
- _turnKey: typeof message._turnKey === "string" && message._turnKey.trim() ? message._turnKey.trim() : `${providerType}:native-turn:${historySessionId || "workspace"}:${turnIndex}`,
38560
+ bubbleId: typeof message.bubbleId === "string" && message.bubbleId.trim() && preserveNativeIdentity ? message.bubbleId.trim() : `bubble:${providerUnitKey}`,
38561
+ _turnKey: preserveNativeIdentity ? existingTurnKey : `${providerType}:native-turn:${nativeIdentitySessionId || "workspace"}:${turnIndex}`,
38549
38562
  bubbleState: message.bubbleState || "final",
38550
38563
  ...isSystemSessionStart ? {
38551
38564
  visibility: message.visibility || "hidden",
@@ -39256,7 +39269,7 @@ ${effect.notification.body || ""}`.trim();
39256
39269
  });
39257
39270
  if (supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory)) {
39258
39271
  const lookup = result.lookup === "workspace" ? "workspace" : "session";
39259
- const messages = Array.isArray(result.messages) ? normalizeNativeHistoryMessages(agentStr, result.messages) : [];
39272
+ const messages = Array.isArray(result.messages) ? normalizeNativeHistoryMessages(agentStr, result.messages, result?.providerSessionId) : [];
39260
39273
  const historyProviderSessionId = typeof result?.providerSessionId === "string" ? result.providerSessionId : readHistorySessionIdFromMessages(messages) || historySessionId;
39261
39274
  const safeMapping = hasSafeNativeHistoryMapping({
39262
39275
  historySessionId: lookup === "workspace" ? void 0 : historySessionId,
@@ -39364,7 +39377,7 @@ ${effect.notification.body || ""}`.trim();
39364
39377
  nativeHistory = null;
39365
39378
  }
39366
39379
  if (nativeHistory) {
39367
- const nativeMessages = Array.isArray(nativeHistory.messages) ? normalizeNativeHistoryMessages(agentStr, nativeHistory.messages) : [];
39380
+ const nativeMessages = Array.isArray(nativeHistory.messages) ? normalizeNativeHistoryMessages(agentStr, nativeHistory.messages, nativeHistory?.providerSessionId) : [];
39368
39381
  const historyProviderSessionId = typeof nativeHistory?.providerSessionId === "string" ? nativeHistory.providerSessionId : readHistorySessionIdFromMessages(nativeMessages) || nativeHistorySessionId || historySessionId;
39369
39382
  const nativeHistoryCoverage = typeof nativeHistory?.nativeHistoryCoverage === "string" ? nativeHistory.nativeHistoryCoverage : void 0;
39370
39383
  const partialReason = typeof nativeHistory?.partialReason === "string" ? nativeHistory.partialReason : void 0;
@@ -39492,7 +39505,7 @@ ${effect.notification.body || ""}`.trim();
39492
39505
  scripts: provider?.scripts
39493
39506
  });
39494
39507
  const lookup = history.lookup === "workspace" ? "workspace" : "session";
39495
- const historyMessages = Array.isArray(history?.messages) ? normalizeNativeHistoryMessages(agentStr, history.messages) : [];
39508
+ const historyMessages = Array.isArray(history?.messages) ? normalizeNativeHistoryMessages(agentStr, history.messages, history?.providerSessionId) : [];
39496
39509
  const historyProviderSessionId = typeof history?.providerSessionId === "string" ? history.providerSessionId : readHistorySessionIdFromMessages(historyMessages) || historySessionId;
39497
39510
  const nativeHistoryCoverage = typeof history?.nativeHistoryCoverage === "string" ? history.nativeHistoryCoverage : void 0;
39498
39511
  const partialReason = typeof history?.partialReason === "string" ? history.partialReason : void 0;