@adhdev/daemon-standalone 0.9.76-rc.53 → 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
@@ -35104,6 +35104,7 @@ ${lastSnapshot}`;
35104
35104
  detectIDEs: () => detectIDEs,
35105
35105
  ensureSessionHostReady: () => ensureSessionHostReady2,
35106
35106
  execNpmCommandSync: () => execNpmCommandSync,
35107
+ filterUserFacingChatMessages: () => filterUserFacingChatMessages,
35107
35108
  findCdpManager: () => findCdpManager,
35108
35109
  flattenMessageParts: () => flattenMessageParts,
35109
35110
  forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance2,
@@ -35145,6 +35146,7 @@ ${lastSnapshot}`;
35145
35146
  isSessionHostLiveRuntime: () => isSessionHostLiveRuntime,
35146
35147
  isSessionHostRecoverySnapshot: () => isSessionHostRecoverySnapshot,
35147
35148
  isSetupComplete: () => isSetupComplete,
35149
+ isUserFacingChatMessage: () => isUserFacingChatMessage,
35148
35150
  killIdeProcess: () => killIdeProcess,
35149
35151
  launchIDE: () => launchIDE,
35150
35152
  launchWithCdp: () => launchWithCdp,
@@ -39296,6 +39298,34 @@ ${lastSnapshot}`;
39296
39298
  function normalizeChatMessages(messages) {
39297
39299
  return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
39298
39300
  }
39301
+ function readMessageMeta(message) {
39302
+ const meta3 = message?.meta;
39303
+ return meta3 && typeof meta3 === "object" && !Array.isArray(meta3) ? meta3 : null;
39304
+ }
39305
+ function isExplicitlyHiddenFromTranscript(meta3) {
39306
+ if (!meta3) return false;
39307
+ const visibility = typeof meta3.transcriptVisibility === "string" ? meta3.transcriptVisibility.trim().toLowerCase() : "";
39308
+ return visibility === "hidden" || visibility === "debug" || meta3.internal === true || meta3.debug === true || meta3.statusOnly === true || meta3.controlOnly === true;
39309
+ }
39310
+ function isExplicitlyVisibleInTranscript(meta3) {
39311
+ if (!meta3) return false;
39312
+ const visibility = typeof meta3.transcriptVisibility === "string" ? meta3.transcriptVisibility.trim().toLowerCase() : "";
39313
+ return visibility === "visible" || meta3.userFacing === true;
39314
+ }
39315
+ function isUserFacingChatMessage(message) {
39316
+ if (!message) return false;
39317
+ const meta3 = readMessageMeta(message);
39318
+ if (isExplicitlyHiddenFromTranscript(meta3)) return false;
39319
+ if (isExplicitlyVisibleInTranscript(meta3)) return true;
39320
+ const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
39321
+ const kind = resolveChatMessageKind(message);
39322
+ if (role === "user" || role === "human") return kind === "standard" || kind === "";
39323
+ if (role === "assistant") return kind === "standard" || kind === "";
39324
+ return false;
39325
+ }
39326
+ function filterUserFacingChatMessages(messages) {
39327
+ return (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
39328
+ }
39299
39329
  function extractProviderControlValues(controls, data) {
39300
39330
  if (!data || typeof data !== "object") return void 0;
39301
39331
  const values = {};
@@ -43125,7 +43155,7 @@ ${effect.notification.body || ""}`.trim();
43125
43155
  }
43126
43156
  function normalizeReadChatMessages(payload) {
43127
43157
  const messages = Array.isArray(payload.messages) ? payload.messages : [];
43128
- return messages;
43158
+ return normalizeChatMessages(messages);
43129
43159
  }
43130
43160
  function deriveHistoryDedupKey(message) {
43131
43161
  const unitKey = typeof message._unitKey === "string" ? message._unitKey.trim() : "";
@@ -43219,13 +43249,22 @@ ${effect.notification.body || ""}`.trim();
43219
43249
  return { success: false, error: error48?.message || String(error48) };
43220
43250
  }
43221
43251
  const messages = normalizeReadChatMessages(validatedPayload);
43222
- const sync = buildFullTail(messages, normalizeReadChatTailLimit(args));
43252
+ const visibleMessages = filterUserFacingChatMessages(messages);
43253
+ const sync = buildFullTail(visibleMessages, normalizeReadChatTailLimit(args));
43254
+ const hiddenMsgCount = Math.max(0, messages.length - visibleMessages.length);
43255
+ const nextDebugReadChat = {
43256
+ ...debugReadChat || {},
43257
+ fullMsgCount: messages.length,
43258
+ visibleMsgCount: visibleMessages.length,
43259
+ hiddenMsgCount,
43260
+ returnedMsgCount: sync.messages.length
43261
+ };
43223
43262
  return {
43224
43263
  success: true,
43225
43264
  ...validatedPayload,
43226
43265
  messages: sync.messages,
43227
43266
  totalMessages: sync.totalMessages,
43228
- ...debugReadChat ? { debugReadChat } : {}
43267
+ debugReadChat: nextDebugReadChat
43229
43268
  };
43230
43269
  }
43231
43270
  var DEFAULT_DEBUG_SANITIZE_OPTIONS = {
@@ -46826,16 +46865,47 @@ ${effect.notification.body || ""}`.trim();
46826
46865
  const runtimeEntries = this.runtimeMessages.map((entry, index) => ({
46827
46866
  message: entry.message,
46828
46867
  index: parsedMessages.length + index,
46829
- source: "runtime"
46868
+ source: "runtime",
46869
+ runtimeKey: entry.key
46830
46870
  }));
46831
46871
  const getTime = (message) => {
46832
46872
  const value = typeof message.receivedAt === "number" ? message.receivedAt : typeof message.timestamp === "number" ? message.timestamp : 0;
46833
46873
  return Number.isFinite(value) && value > 0 ? value : 0;
46834
46874
  };
46875
+ const getRole = (message) => typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
46876
+ const isAutoApprovalRuntimeOverlay = (entry) => {
46877
+ if (entry.source !== "runtime") return false;
46878
+ const key = typeof entry.runtimeKey === "string" ? entry.runtimeKey.trim().toLowerCase() : "";
46879
+ if (key.startsWith("auto_approval:")) return true;
46880
+ const content = typeof entry.message.content === "string" ? entry.message.content.trim().toLowerCase() : flattenContent(entry.message.content).trim().toLowerCase();
46881
+ return content.startsWith("auto-approved:");
46882
+ };
46883
+ const shouldKeepParsedBeforeUntimedRuntime = (message) => {
46884
+ const role = getRole(message);
46885
+ return role === "user" || role === "human";
46886
+ };
46887
+ const shouldKeepParsedAfterUntimedRuntime = (message) => {
46888
+ const role = getRole(message);
46889
+ if (role !== "assistant") return false;
46890
+ const kind = resolveChatMessageKind(message);
46891
+ return kind === "standard" || kind === "terminal";
46892
+ };
46835
46893
  return normalizeChatMessages([...parsedEntries, ...runtimeEntries].sort((a, b2) => {
46836
46894
  const aTime = getTime(a.message);
46837
46895
  const bTime = getTime(b2.message);
46838
46896
  if (aTime && bTime && aTime !== bTime) return aTime - bTime;
46897
+ if (a.source !== b2.source && aTime !== bTime) {
46898
+ const parsedEntry = a.source === "parsed" ? a : b2.source === "parsed" ? b2 : null;
46899
+ const runtimeEntry = a.source === "runtime" ? a : b2.source === "runtime" ? b2 : null;
46900
+ if (parsedEntry && runtimeEntry && isAutoApprovalRuntimeOverlay(runtimeEntry) && getTime(parsedEntry.message) === 0 && getTime(runtimeEntry.message) > 0) {
46901
+ if (shouldKeepParsedBeforeUntimedRuntime(parsedEntry.message)) {
46902
+ return a.source === "parsed" ? -1 : 1;
46903
+ }
46904
+ if (shouldKeepParsedAfterUntimedRuntime(parsedEntry.message)) {
46905
+ return a.source === "parsed" ? 1 : -1;
46906
+ }
46907
+ }
46908
+ }
46839
46909
  return a.index - b2.index;
46840
46910
  }).map((entry) => entry.message));
46841
46911
  }