@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.js CHANGED
@@ -8158,27 +8158,21 @@ function readMessageMeta(message) {
8158
8158
  const meta = message?.meta;
8159
8159
  return meta && typeof meta === "object" && !Array.isArray(meta) ? meta : null;
8160
8160
  }
8161
- function readStringField(value) {
8162
- return typeof value === "string" ? value.trim().toLowerCase() : "";
8163
- }
8164
- function isExplicitlyHiddenFromTranscript(message, meta) {
8165
- const record = message;
8166
- const visibility = readStringField(record.visibility || meta?.visibility || meta?.transcriptVisibility);
8167
- const audience = readStringField(record.audience || meta?.audience);
8168
- const source = readStringField(record.source || meta?.source);
8169
- 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;
8170
- }
8171
- function isExplicitlyVisibleInTranscript(message, meta) {
8172
- const record = message;
8173
- const visibility = readStringField(record.visibility || meta?.visibility || meta?.transcriptVisibility);
8174
- const audience = readStringField(record.audience || meta?.audience);
8175
- return visibility === "visible" || visibility === "user" || audience === "chat" || record.userFacing === true || meta?.userFacing === true;
8161
+ function isExplicitlyHiddenFromTranscript(meta) {
8162
+ if (!meta) return false;
8163
+ const visibility = typeof meta.transcriptVisibility === "string" ? meta.transcriptVisibility.trim().toLowerCase() : "";
8164
+ return visibility === "hidden" || visibility === "debug" || meta.internal === true || meta.debug === true || meta.statusOnly === true || meta.controlOnly === true;
8165
+ }
8166
+ function isExplicitlyVisibleInTranscript(meta) {
8167
+ if (!meta) return false;
8168
+ const visibility = typeof meta.transcriptVisibility === "string" ? meta.transcriptVisibility.trim().toLowerCase() : "";
8169
+ return visibility === "visible" || meta.userFacing === true;
8176
8170
  }
8177
8171
  function isUserFacingChatMessage(message) {
8178
8172
  if (!message) return false;
8179
8173
  const meta = readMessageMeta(message);
8180
- if (isExplicitlyHiddenFromTranscript(message, meta)) return false;
8181
- if (isExplicitlyVisibleInTranscript(message, meta)) return true;
8174
+ if (isExplicitlyHiddenFromTranscript(meta)) return false;
8175
+ if (isExplicitlyVisibleInTranscript(meta)) return true;
8182
8176
  const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
8183
8177
  const kind = resolveChatMessageKind(message);
8184
8178
  if (role === "user" || role === "human") return kind === "standard" || kind === "";
@@ -12067,7 +12061,7 @@ function normalizeReadChatTailLimit(args) {
12067
12061
  }
12068
12062
  function normalizeReadChatMessages(payload) {
12069
12063
  const messages = Array.isArray(payload.messages) ? payload.messages : [];
12070
- return messages;
12064
+ return normalizeChatMessages(messages);
12071
12065
  }
12072
12066
  function deriveHistoryDedupKey(message) {
12073
12067
  const unitKey = typeof message._unitKey === "string" ? message._unitKey.trim() : "";
@@ -12164,19 +12158,19 @@ function buildReadChatCommandResult(payload, args) {
12164
12158
  const visibleMessages = filterUserFacingChatMessages(messages);
12165
12159
  const sync = buildFullTail(visibleMessages, normalizeReadChatTailLimit(args));
12166
12160
  const hiddenMsgCount = Math.max(0, messages.length - visibleMessages.length);
12167
- const returnedDebugReadChat = debugReadChat ? {
12168
- ...debugReadChat,
12169
- fullMsgCount: typeof debugReadChat.fullMsgCount === "number" ? debugReadChat.fullMsgCount : messages.length,
12161
+ const nextDebugReadChat = {
12162
+ ...debugReadChat || {},
12163
+ fullMsgCount: messages.length,
12170
12164
  visibleMsgCount: visibleMessages.length,
12171
12165
  hiddenMsgCount,
12172
12166
  returnedMsgCount: sync.messages.length
12173
- } : void 0;
12167
+ };
12174
12168
  return {
12175
12169
  success: true,
12176
12170
  ...validatedPayload,
12177
12171
  messages: sync.messages,
12178
12172
  totalMessages: sync.totalMessages,
12179
- ...returnedDebugReadChat ? { debugReadChat: returnedDebugReadChat } : {}
12173
+ debugReadChat: nextDebugReadChat
12180
12174
  };
12181
12175
  }
12182
12176
  var DEFAULT_DEBUG_SANITIZE_OPTIONS = {
@@ -15799,16 +15793,47 @@ ${effect.notification.body || ""}`.trim();
15799
15793
  const runtimeEntries = this.runtimeMessages.map((entry, index) => ({
15800
15794
  message: entry.message,
15801
15795
  index: parsedMessages.length + index,
15802
- source: "runtime"
15796
+ source: "runtime",
15797
+ runtimeKey: entry.key
15803
15798
  }));
15804
15799
  const getTime = (message) => {
15805
15800
  const value = typeof message.receivedAt === "number" ? message.receivedAt : typeof message.timestamp === "number" ? message.timestamp : 0;
15806
15801
  return Number.isFinite(value) && value > 0 ? value : 0;
15807
15802
  };
15803
+ const getRole = (message) => typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
15804
+ const isAutoApprovalRuntimeOverlay = (entry) => {
15805
+ if (entry.source !== "runtime") return false;
15806
+ const key = typeof entry.runtimeKey === "string" ? entry.runtimeKey.trim().toLowerCase() : "";
15807
+ if (key.startsWith("auto_approval:")) return true;
15808
+ const content = typeof entry.message.content === "string" ? entry.message.content.trim().toLowerCase() : flattenContent(entry.message.content).trim().toLowerCase();
15809
+ return content.startsWith("auto-approved:");
15810
+ };
15811
+ const shouldKeepParsedBeforeUntimedRuntime = (message) => {
15812
+ const role = getRole(message);
15813
+ return role === "user" || role === "human";
15814
+ };
15815
+ const shouldKeepParsedAfterUntimedRuntime = (message) => {
15816
+ const role = getRole(message);
15817
+ if (role !== "assistant") return false;
15818
+ const kind = resolveChatMessageKind(message);
15819
+ return kind === "standard" || kind === "terminal";
15820
+ };
15808
15821
  return normalizeChatMessages([...parsedEntries, ...runtimeEntries].sort((a, b) => {
15809
15822
  const aTime = getTime(a.message);
15810
15823
  const bTime = getTime(b.message);
15811
15824
  if (aTime && bTime && aTime !== bTime) return aTime - bTime;
15825
+ if (a.source !== b.source && aTime !== bTime) {
15826
+ const parsedEntry = a.source === "parsed" ? a : b.source === "parsed" ? b : null;
15827
+ const runtimeEntry = a.source === "runtime" ? a : b.source === "runtime" ? b : null;
15828
+ if (parsedEntry && runtimeEntry && isAutoApprovalRuntimeOverlay(runtimeEntry) && getTime(parsedEntry.message) === 0 && getTime(runtimeEntry.message) > 0) {
15829
+ if (shouldKeepParsedBeforeUntimedRuntime(parsedEntry.message)) {
15830
+ return a.source === "parsed" ? -1 : 1;
15831
+ }
15832
+ if (shouldKeepParsedAfterUntimedRuntime(parsedEntry.message)) {
15833
+ return a.source === "parsed" ? 1 : -1;
15834
+ }
15835
+ }
15836
+ }
15812
15837
  return a.index - b.index;
15813
15838
  }).map((entry) => entry.message));
15814
15839
  }