@adhdev/daemon-core 0.9.76-rc.54 → 0.9.76-rc.55

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.mjs CHANGED
@@ -7960,27 +7960,21 @@ function readMessageMeta(message) {
7960
7960
  const meta = message?.meta;
7961
7961
  return meta && typeof meta === "object" && !Array.isArray(meta) ? meta : null;
7962
7962
  }
7963
- function readStringField(value) {
7964
- return typeof value === "string" ? value.trim().toLowerCase() : "";
7965
- }
7966
- function isExplicitlyHiddenFromTranscript(message, meta) {
7967
- const record = message;
7968
- const visibility = readStringField(record.visibility || meta?.visibility || meta?.transcriptVisibility);
7969
- const audience = readStringField(record.audience || meta?.audience);
7970
- const source = readStringField(record.source || meta?.source);
7971
- return visibility === "hidden" || visibility === "debug" || visibility === "internal" || audience === "debug" || audience === "trace" || audience === "internal" || source === "runtime_status" || source === "provider_chrome" || source === "control" || record.internal === true || record.isInternal === true || record.debug === true || meta?.internal === true || meta?.isInternal === true || meta?.debug === true || meta?.statusOnly === true || meta?.controlOnly === true;
7972
- }
7973
- function isExplicitlyVisibleInTranscript(message, meta) {
7974
- const record = message;
7975
- const visibility = readStringField(record.visibility || meta?.visibility || meta?.transcriptVisibility);
7976
- const audience = readStringField(record.audience || meta?.audience);
7977
- return visibility === "visible" || visibility === "user" || audience === "chat" || record.userFacing === true || meta?.userFacing === true;
7963
+ function isExplicitlyHiddenFromTranscript(meta) {
7964
+ if (!meta) return false;
7965
+ const visibility = typeof meta.transcriptVisibility === "string" ? meta.transcriptVisibility.trim().toLowerCase() : "";
7966
+ return visibility === "hidden" || visibility === "debug" || meta.internal === true || meta.debug === true || meta.statusOnly === true || meta.controlOnly === true;
7967
+ }
7968
+ function isExplicitlyVisibleInTranscript(meta) {
7969
+ if (!meta) return false;
7970
+ const visibility = typeof meta.transcriptVisibility === "string" ? meta.transcriptVisibility.trim().toLowerCase() : "";
7971
+ return visibility === "visible" || meta.userFacing === true;
7978
7972
  }
7979
7973
  function isUserFacingChatMessage(message) {
7980
7974
  if (!message) return false;
7981
7975
  const meta = readMessageMeta(message);
7982
- if (isExplicitlyHiddenFromTranscript(message, meta)) return false;
7983
- if (isExplicitlyVisibleInTranscript(message, meta)) return true;
7976
+ if (isExplicitlyHiddenFromTranscript(meta)) return false;
7977
+ if (isExplicitlyVisibleInTranscript(meta)) return true;
7984
7978
  const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
7985
7979
  const kind = resolveChatMessageKind(message);
7986
7980
  if (role === "user" || role === "human") return kind === "standard" || kind === "";
@@ -11869,7 +11863,7 @@ function normalizeReadChatTailLimit(args) {
11869
11863
  }
11870
11864
  function normalizeReadChatMessages(payload) {
11871
11865
  const messages = Array.isArray(payload.messages) ? payload.messages : [];
11872
- return messages;
11866
+ return normalizeChatMessages(messages);
11873
11867
  }
11874
11868
  function deriveHistoryDedupKey(message) {
11875
11869
  const unitKey = typeof message._unitKey === "string" ? message._unitKey.trim() : "";
@@ -11966,19 +11960,19 @@ function buildReadChatCommandResult(payload, args) {
11966
11960
  const visibleMessages = filterUserFacingChatMessages(messages);
11967
11961
  const sync = buildFullTail(visibleMessages, normalizeReadChatTailLimit(args));
11968
11962
  const hiddenMsgCount = Math.max(0, messages.length - visibleMessages.length);
11969
- const returnedDebugReadChat = debugReadChat ? {
11970
- ...debugReadChat,
11971
- fullMsgCount: typeof debugReadChat.fullMsgCount === "number" ? debugReadChat.fullMsgCount : messages.length,
11963
+ const nextDebugReadChat = {
11964
+ ...debugReadChat || {},
11965
+ fullMsgCount: messages.length,
11972
11966
  visibleMsgCount: visibleMessages.length,
11973
11967
  hiddenMsgCount,
11974
11968
  returnedMsgCount: sync.messages.length
11975
- } : void 0;
11969
+ };
11976
11970
  return {
11977
11971
  success: true,
11978
11972
  ...validatedPayload,
11979
11973
  messages: sync.messages,
11980
11974
  totalMessages: sync.totalMessages,
11981
- ...returnedDebugReadChat ? { debugReadChat: returnedDebugReadChat } : {}
11975
+ debugReadChat: nextDebugReadChat
11982
11976
  };
11983
11977
  }
11984
11978
  var DEFAULT_DEBUG_SANITIZE_OPTIONS = {
@@ -15601,16 +15595,47 @@ ${effect.notification.body || ""}`.trim();
15601
15595
  const runtimeEntries = this.runtimeMessages.map((entry, index) => ({
15602
15596
  message: entry.message,
15603
15597
  index: parsedMessages.length + index,
15604
- source: "runtime"
15598
+ source: "runtime",
15599
+ runtimeKey: entry.key
15605
15600
  }));
15606
15601
  const getTime = (message) => {
15607
15602
  const value = typeof message.receivedAt === "number" ? message.receivedAt : typeof message.timestamp === "number" ? message.timestamp : 0;
15608
15603
  return Number.isFinite(value) && value > 0 ? value : 0;
15609
15604
  };
15605
+ const getRole = (message) => typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
15606
+ const isAutoApprovalRuntimeOverlay = (entry) => {
15607
+ if (entry.source !== "runtime") return false;
15608
+ const key = typeof entry.runtimeKey === "string" ? entry.runtimeKey.trim().toLowerCase() : "";
15609
+ if (key.startsWith("auto_approval:")) return true;
15610
+ const content = typeof entry.message.content === "string" ? entry.message.content.trim().toLowerCase() : flattenContent(entry.message.content).trim().toLowerCase();
15611
+ return content.startsWith("auto-approved:");
15612
+ };
15613
+ const shouldKeepParsedBeforeUntimedRuntime = (message) => {
15614
+ const role = getRole(message);
15615
+ return role === "user" || role === "human";
15616
+ };
15617
+ const shouldKeepParsedAfterUntimedRuntime = (message) => {
15618
+ const role = getRole(message);
15619
+ if (role !== "assistant") return false;
15620
+ const kind = resolveChatMessageKind(message);
15621
+ return kind === "standard" || kind === "terminal";
15622
+ };
15610
15623
  return normalizeChatMessages([...parsedEntries, ...runtimeEntries].sort((a, b) => {
15611
15624
  const aTime = getTime(a.message);
15612
15625
  const bTime = getTime(b.message);
15613
15626
  if (aTime && bTime && aTime !== bTime) return aTime - bTime;
15627
+ if (a.source !== b.source && aTime !== bTime) {
15628
+ const parsedEntry = a.source === "parsed" ? a : b.source === "parsed" ? b : null;
15629
+ const runtimeEntry = a.source === "runtime" ? a : b.source === "runtime" ? b : null;
15630
+ if (parsedEntry && runtimeEntry && isAutoApprovalRuntimeOverlay(runtimeEntry) && getTime(parsedEntry.message) === 0 && getTime(runtimeEntry.message) > 0) {
15631
+ if (shouldKeepParsedBeforeUntimedRuntime(parsedEntry.message)) {
15632
+ return a.source === "parsed" ? -1 : 1;
15633
+ }
15634
+ if (shouldKeepParsedAfterUntimedRuntime(parsedEntry.message)) {
15635
+ return a.source === "parsed" ? 1 : -1;
15636
+ }
15637
+ }
15638
+ }
15614
15639
  return a.index - b.index;
15615
15640
  }).map((entry) => entry.message));
15616
15641
  }