@adhdev/daemon-core 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.d.ts CHANGED
@@ -90,7 +90,7 @@ export type { ProviderModule, CdpTargetFilter, ProviderResumeCapability, InputEn
90
90
  export type { ProviderSourceConfigSnapshot, ProviderSourceConfigUpdate } from './config/provider-source-config.js';
91
91
  export { parseProviderSourceConfigUpdate } from './config/provider-source-config.js';
92
92
  export { normalizeInputEnvelope, normalizeMessageParts, flattenMessageParts } from './providers/io-contracts.js';
93
- export { BUILTIN_CHAT_MESSAGE_KINDS, isBuiltinChatMessageKind, normalizeChatMessageKind, resolveChatMessageKind, buildChatMessage, buildSystemChatMessage, buildRuntimeSystemChatMessage, buildAssistantChatMessage, buildThoughtChatMessage, buildToolChatMessage, buildTerminalChatMessage, buildUserChatMessage, normalizeChatMessage, normalizeChatMessages, } from './providers/chat-message-normalization.js';
93
+ export { BUILTIN_CHAT_MESSAGE_KINDS, isBuiltinChatMessageKind, normalizeChatMessageKind, resolveChatMessageKind, buildChatMessage, buildSystemChatMessage, buildRuntimeSystemChatMessage, buildAssistantChatMessage, buildThoughtChatMessage, buildToolChatMessage, buildTerminalChatMessage, buildUserChatMessage, normalizeChatMessage, normalizeChatMessages, isUserFacingChatMessage, filterUserFacingChatMessages, } from './providers/chat-message-normalization.js';
94
94
  export type { BuiltinChatMessageKind, ChatMessageKind } from './providers/chat-message-normalization.js';
95
95
  export { VersionArchive, detectAllVersions } from './providers/version-archive.js';
96
96
  export type { ProviderVersionInfo, VersionHistory } from './providers/version-archive.js';
package/dist/index.js CHANGED
@@ -3900,6 +3900,7 @@ __export(index_exports, {
3900
3900
  detectIDEs: () => detectIDEs,
3901
3901
  ensureSessionHostReady: () => ensureSessionHostReady,
3902
3902
  execNpmCommandSync: () => execNpmCommandSync,
3903
+ filterUserFacingChatMessages: () => filterUserFacingChatMessages,
3903
3904
  findCdpManager: () => findCdpManager,
3904
3905
  flattenMessageParts: () => flattenMessageParts,
3905
3906
  forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance,
@@ -3941,6 +3942,7 @@ __export(index_exports, {
3941
3942
  isSessionHostLiveRuntime: () => isSessionHostLiveRuntime,
3942
3943
  isSessionHostRecoverySnapshot: () => isSessionHostRecoverySnapshot,
3943
3944
  isSetupComplete: () => isSetupComplete,
3945
+ isUserFacingChatMessage: () => isUserFacingChatMessage,
3944
3946
  killIdeProcess: () => killIdeProcess,
3945
3947
  launchIDE: () => launchIDE,
3946
3948
  launchWithCdp: () => launchWithCdp,
@@ -8152,6 +8154,34 @@ function normalizeChatMessage(message) {
8152
8154
  function normalizeChatMessages(messages) {
8153
8155
  return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
8154
8156
  }
8157
+ function readMessageMeta(message) {
8158
+ const meta = message?.meta;
8159
+ return meta && typeof meta === "object" && !Array.isArray(meta) ? meta : null;
8160
+ }
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;
8170
+ }
8171
+ function isUserFacingChatMessage(message) {
8172
+ if (!message) return false;
8173
+ const meta = readMessageMeta(message);
8174
+ if (isExplicitlyHiddenFromTranscript(meta)) return false;
8175
+ if (isExplicitlyVisibleInTranscript(meta)) return true;
8176
+ const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
8177
+ const kind = resolveChatMessageKind(message);
8178
+ if (role === "user" || role === "human") return kind === "standard" || kind === "";
8179
+ if (role === "assistant") return kind === "standard" || kind === "";
8180
+ return false;
8181
+ }
8182
+ function filterUserFacingChatMessages(messages) {
8183
+ return (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
8184
+ }
8155
8185
 
8156
8186
  // src/providers/control-effects.ts
8157
8187
  function extractProviderControlValues(controls, data) {
@@ -12031,7 +12061,7 @@ function normalizeReadChatTailLimit(args) {
12031
12061
  }
12032
12062
  function normalizeReadChatMessages(payload) {
12033
12063
  const messages = Array.isArray(payload.messages) ? payload.messages : [];
12034
- return messages;
12064
+ return normalizeChatMessages(messages);
12035
12065
  }
12036
12066
  function deriveHistoryDedupKey(message) {
12037
12067
  const unitKey = typeof message._unitKey === "string" ? message._unitKey.trim() : "";
@@ -12125,13 +12155,22 @@ function buildReadChatCommandResult(payload, args) {
12125
12155
  return { success: false, error: error?.message || String(error) };
12126
12156
  }
12127
12157
  const messages = normalizeReadChatMessages(validatedPayload);
12128
- const sync = buildFullTail(messages, normalizeReadChatTailLimit(args));
12158
+ const visibleMessages = filterUserFacingChatMessages(messages);
12159
+ const sync = buildFullTail(visibleMessages, normalizeReadChatTailLimit(args));
12160
+ const hiddenMsgCount = Math.max(0, messages.length - visibleMessages.length);
12161
+ const nextDebugReadChat = {
12162
+ ...debugReadChat || {},
12163
+ fullMsgCount: messages.length,
12164
+ visibleMsgCount: visibleMessages.length,
12165
+ hiddenMsgCount,
12166
+ returnedMsgCount: sync.messages.length
12167
+ };
12129
12168
  return {
12130
12169
  success: true,
12131
12170
  ...validatedPayload,
12132
12171
  messages: sync.messages,
12133
12172
  totalMessages: sync.totalMessages,
12134
- ...debugReadChat ? { debugReadChat } : {}
12173
+ debugReadChat: nextDebugReadChat
12135
12174
  };
12136
12175
  }
12137
12176
  var DEFAULT_DEBUG_SANITIZE_OPTIONS = {
@@ -15754,16 +15793,47 @@ ${effect.notification.body || ""}`.trim();
15754
15793
  const runtimeEntries = this.runtimeMessages.map((entry, index) => ({
15755
15794
  message: entry.message,
15756
15795
  index: parsedMessages.length + index,
15757
- source: "runtime"
15796
+ source: "runtime",
15797
+ runtimeKey: entry.key
15758
15798
  }));
15759
15799
  const getTime = (message) => {
15760
15800
  const value = typeof message.receivedAt === "number" ? message.receivedAt : typeof message.timestamp === "number" ? message.timestamp : 0;
15761
15801
  return Number.isFinite(value) && value > 0 ? value : 0;
15762
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
+ };
15763
15821
  return normalizeChatMessages([...parsedEntries, ...runtimeEntries].sort((a, b) => {
15764
15822
  const aTime = getTime(a.message);
15765
15823
  const bTime = getTime(b.message);
15766
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
+ }
15767
15837
  return a.index - b.index;
15768
15838
  }).map((entry) => entry.message));
15769
15839
  }
@@ -30805,6 +30875,7 @@ async function shutdownDaemonComponents(components) {
30805
30875
  detectIDEs,
30806
30876
  ensureSessionHostReady,
30807
30877
  execNpmCommandSync,
30878
+ filterUserFacingChatMessages,
30808
30879
  findCdpManager,
30809
30880
  flattenMessageParts,
30810
30881
  forwardAgentStreamsToIdeInstance,
@@ -30846,6 +30917,7 @@ async function shutdownDaemonComponents(components) {
30846
30917
  isSessionHostLiveRuntime,
30847
30918
  isSessionHostRecoverySnapshot,
30848
30919
  isSetupComplete,
30920
+ isUserFacingChatMessage,
30849
30921
  killIdeProcess,
30850
30922
  launchIDE,
30851
30923
  launchWithCdp,