adhdev 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
@@ -5212,6 +5212,34 @@ function normalizeChatMessage(message) {
5212
5212
  function normalizeChatMessages(messages) {
5213
5213
  return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
5214
5214
  }
5215
+ function readMessageMeta(message) {
5216
+ const meta3 = message?.meta;
5217
+ return meta3 && typeof meta3 === "object" && !Array.isArray(meta3) ? meta3 : null;
5218
+ }
5219
+ function isExplicitlyHiddenFromTranscript(meta3) {
5220
+ if (!meta3) return false;
5221
+ const visibility = typeof meta3.transcriptVisibility === "string" ? meta3.transcriptVisibility.trim().toLowerCase() : "";
5222
+ return visibility === "hidden" || visibility === "debug" || meta3.internal === true || meta3.debug === true || meta3.statusOnly === true || meta3.controlOnly === true;
5223
+ }
5224
+ function isExplicitlyVisibleInTranscript(meta3) {
5225
+ if (!meta3) return false;
5226
+ const visibility = typeof meta3.transcriptVisibility === "string" ? meta3.transcriptVisibility.trim().toLowerCase() : "";
5227
+ return visibility === "visible" || meta3.userFacing === true;
5228
+ }
5229
+ function isUserFacingChatMessage(message) {
5230
+ if (!message) return false;
5231
+ const meta3 = readMessageMeta(message);
5232
+ if (isExplicitlyHiddenFromTranscript(meta3)) return false;
5233
+ if (isExplicitlyVisibleInTranscript(meta3)) return true;
5234
+ const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
5235
+ const kind = resolveChatMessageKind(message);
5236
+ if (role === "user" || role === "human") return kind === "standard" || kind === "";
5237
+ if (role === "assistant") return kind === "standard" || kind === "";
5238
+ return false;
5239
+ }
5240
+ function filterUserFacingChatMessages(messages) {
5241
+ return (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
5242
+ }
5215
5243
  var BUILTIN_CHAT_MESSAGE_KINDS, KNOWN_CHAT_MESSAGE_KINDS, CHAT_MESSAGE_KIND_ALIASES;
5216
5244
  var init_chat_message_normalization = __esm({
5217
5245
  "../../oss/packages/daemon-core/src/providers/chat-message-normalization.ts"() {
@@ -9294,7 +9322,7 @@ function normalizeReadChatTailLimit(args) {
9294
9322
  }
9295
9323
  function normalizeReadChatMessages(payload) {
9296
9324
  const messages = Array.isArray(payload.messages) ? payload.messages : [];
9297
- return messages;
9325
+ return normalizeChatMessages(messages);
9298
9326
  }
9299
9327
  function deriveHistoryDedupKey(message) {
9300
9328
  const unitKey = typeof message._unitKey === "string" ? message._unitKey.trim() : "";
@@ -9388,13 +9416,22 @@ function buildReadChatCommandResult(payload, args) {
9388
9416
  return { success: false, error: error48?.message || String(error48) };
9389
9417
  }
9390
9418
  const messages = normalizeReadChatMessages(validatedPayload);
9391
- const sync = buildFullTail(messages, normalizeReadChatTailLimit(args));
9419
+ const visibleMessages = filterUserFacingChatMessages(messages);
9420
+ const sync = buildFullTail(visibleMessages, normalizeReadChatTailLimit(args));
9421
+ const hiddenMsgCount = Math.max(0, messages.length - visibleMessages.length);
9422
+ const nextDebugReadChat = {
9423
+ ...debugReadChat || {},
9424
+ fullMsgCount: messages.length,
9425
+ visibleMsgCount: visibleMessages.length,
9426
+ hiddenMsgCount,
9427
+ returnedMsgCount: sync.messages.length
9428
+ };
9392
9429
  return {
9393
9430
  success: true,
9394
9431
  ...validatedPayload,
9395
9432
  messages: sync.messages,
9396
9433
  totalMessages: sync.totalMessages,
9397
- ...debugReadChat ? { debugReadChat } : {}
9434
+ debugReadChat: nextDebugReadChat
9398
9435
  };
9399
9436
  }
9400
9437
  function truncateDebugString(value, maxLength) {
@@ -10740,6 +10777,7 @@ var init_chat_commands = __esm({
10740
10777
  init_logger();
10741
10778
  init_debug_trace();
10742
10779
  init_chat_signatures();
10780
+ init_chat_message_normalization();
10743
10781
  RECENT_SEND_WINDOW_MS = 1200;
10744
10782
  READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
10745
10783
  HERMES_CLI_STARTING_SEND_SETTLE_MS = 2e3;
@@ -16646,16 +16684,47 @@ ${effect.notification.body || ""}`.trim();
16646
16684
  const runtimeEntries = this.runtimeMessages.map((entry, index) => ({
16647
16685
  message: entry.message,
16648
16686
  index: parsedMessages.length + index,
16649
- source: "runtime"
16687
+ source: "runtime",
16688
+ runtimeKey: entry.key
16650
16689
  }));
16651
16690
  const getTime = (message) => {
16652
16691
  const value = typeof message.receivedAt === "number" ? message.receivedAt : typeof message.timestamp === "number" ? message.timestamp : 0;
16653
16692
  return Number.isFinite(value) && value > 0 ? value : 0;
16654
16693
  };
16694
+ const getRole = (message) => typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
16695
+ const isAutoApprovalRuntimeOverlay = (entry) => {
16696
+ if (entry.source !== "runtime") return false;
16697
+ const key = typeof entry.runtimeKey === "string" ? entry.runtimeKey.trim().toLowerCase() : "";
16698
+ if (key.startsWith("auto_approval:")) return true;
16699
+ const content = typeof entry.message.content === "string" ? entry.message.content.trim().toLowerCase() : flattenContent(entry.message.content).trim().toLowerCase();
16700
+ return content.startsWith("auto-approved:");
16701
+ };
16702
+ const shouldKeepParsedBeforeUntimedRuntime = (message) => {
16703
+ const role = getRole(message);
16704
+ return role === "user" || role === "human";
16705
+ };
16706
+ const shouldKeepParsedAfterUntimedRuntime = (message) => {
16707
+ const role = getRole(message);
16708
+ if (role !== "assistant") return false;
16709
+ const kind = resolveChatMessageKind(message);
16710
+ return kind === "standard" || kind === "terminal";
16711
+ };
16655
16712
  return normalizeChatMessages([...parsedEntries, ...runtimeEntries].sort((a, b) => {
16656
16713
  const aTime = getTime(a.message);
16657
16714
  const bTime = getTime(b.message);
16658
16715
  if (aTime && bTime && aTime !== bTime) return aTime - bTime;
16716
+ if (a.source !== b.source && aTime !== bTime) {
16717
+ const parsedEntry = a.source === "parsed" ? a : b.source === "parsed" ? b : null;
16718
+ const runtimeEntry = a.source === "runtime" ? a : b.source === "runtime" ? b : null;
16719
+ if (parsedEntry && runtimeEntry && isAutoApprovalRuntimeOverlay(runtimeEntry) && getTime(parsedEntry.message) === 0 && getTime(runtimeEntry.message) > 0) {
16720
+ if (shouldKeepParsedBeforeUntimedRuntime(parsedEntry.message)) {
16721
+ return a.source === "parsed" ? -1 : 1;
16722
+ }
16723
+ if (shouldKeepParsedAfterUntimedRuntime(parsedEntry.message)) {
16724
+ return a.source === "parsed" ? 1 : -1;
16725
+ }
16726
+ }
16727
+ }
16659
16728
  return a.index - b.index;
16660
16729
  }).map((entry) => entry.message));
16661
16730
  }
@@ -52653,6 +52722,7 @@ __export(src_exports, {
52653
52722
  detectIDEs: () => detectIDEs,
52654
52723
  ensureSessionHostReady: () => ensureSessionHostReady,
52655
52724
  execNpmCommandSync: () => execNpmCommandSync,
52725
+ filterUserFacingChatMessages: () => filterUserFacingChatMessages,
52656
52726
  findCdpManager: () => findCdpManager,
52657
52727
  flattenMessageParts: () => flattenMessageParts,
52658
52728
  forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance,
@@ -52694,6 +52764,7 @@ __export(src_exports, {
52694
52764
  isSessionHostLiveRuntime: () => isSessionHostLiveRuntime,
52695
52765
  isSessionHostRecoverySnapshot: () => isSessionHostRecoverySnapshot,
52696
52766
  isSetupComplete: () => isSetupComplete,
52767
+ isUserFacingChatMessage: () => isUserFacingChatMessage,
52697
52768
  killIdeProcess: () => killIdeProcess,
52698
52769
  launchIDE: () => launchIDE,
52699
52770
  launchWithCdp: () => launchWithCdp,
@@ -62809,7 +62880,7 @@ var init_adhdev_daemon = __esm({
62809
62880
  init_version();
62810
62881
  init_src();
62811
62882
  init_runtime_defaults();
62812
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.76-rc.53" });
62883
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.76-rc.55" });
62813
62884
  AdhdevDaemon = class _AdhdevDaemon {
62814
62885
  localHttpServer = null;
62815
62886
  localWss = null;