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

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.76-rc.53",
3
+ "version": "0.9.76-rc.54",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,6 +18,7 @@ import { LOG, getRecentLogs } from '../logging/logger.js';
18
18
  import { getRecentDebugTrace, recordDebugTrace } from '../logging/debug-trace.js';
19
19
  import { buildChatMessageSignature } from '../chat/chat-signatures.js';
20
20
  import type { ChatMessage } from '../types.js';
21
+ import { filterUserFacingChatMessages } from '../providers/chat-message-normalization.js';
21
22
  import type { SessionTransport } from '../shared-types.js';
22
23
 
23
24
  const RECENT_SEND_WINDOW_MS = 1200;
@@ -316,13 +317,26 @@ function buildReadChatCommandResult(payload: Record<string, any>, args: any): Co
316
317
  return { success: false, error: error?.message || String(error) };
317
318
  }
318
319
  const messages = normalizeReadChatMessages(validatedPayload);
319
- const sync = buildFullTail(messages, normalizeReadChatTailLimit(args));
320
+ const visibleMessages = filterUserFacingChatMessages(messages);
321
+ const sync = buildFullTail(visibleMessages, normalizeReadChatTailLimit(args));
322
+ const hiddenMsgCount = Math.max(0, messages.length - visibleMessages.length);
323
+ const returnedDebugReadChat = debugReadChat
324
+ ? {
325
+ ...debugReadChat,
326
+ fullMsgCount: typeof debugReadChat.fullMsgCount === 'number'
327
+ ? debugReadChat.fullMsgCount
328
+ : messages.length,
329
+ visibleMsgCount: visibleMessages.length,
330
+ hiddenMsgCount,
331
+ returnedMsgCount: sync.messages.length,
332
+ }
333
+ : undefined;
320
334
  return {
321
335
  success: true,
322
336
  ...validatedPayload,
323
337
  messages: sync.messages,
324
338
  totalMessages: sync.totalMessages,
325
- ...(debugReadChat ? { debugReadChat } : {}),
339
+ ...(returnedDebugReadChat ? { debugReadChat: returnedDebugReadChat } : {}),
326
340
  };
327
341
  }
328
342
 
package/src/index.ts CHANGED
@@ -311,6 +311,8 @@ export {
311
311
  buildUserChatMessage,
312
312
  normalizeChatMessage,
313
313
  normalizeChatMessages,
314
+ isUserFacingChatMessage,
315
+ filterUserFacingChatMessages,
314
316
  } from './providers/chat-message-normalization.js';
315
317
  export type { BuiltinChatMessageKind, ChatMessageKind } from './providers/chat-message-normalization.js';
316
318
  export { VersionArchive, detectAllVersions } from './providers/version-archive.js';
@@ -179,25 +179,44 @@ function readMessageMeta(message: ChatMessage): Record<string, unknown> | null {
179
179
  : null;
180
180
  }
181
181
 
182
- function isExplicitlyHiddenFromTranscript(meta: Record<string, unknown> | null): boolean {
183
- if (!meta) return false;
184
- const visibility = typeof meta.transcriptVisibility === 'string'
185
- ? meta.transcriptVisibility.trim().toLowerCase()
186
- : '';
187
- return visibility === 'hidden'
188
- || visibility === 'debug'
189
- || meta.internal === true
190
- || meta.debug === true
191
- || meta.statusOnly === true
192
- || meta.controlOnly === true;
182
+ function readStringField(value: unknown): string {
183
+ return typeof value === 'string' ? value.trim().toLowerCase() : '';
193
184
  }
194
185
 
195
- function isExplicitlyVisibleInTranscript(meta: Record<string, unknown> | null): boolean {
196
- if (!meta) return false;
197
- const visibility = typeof meta.transcriptVisibility === 'string'
198
- ? meta.transcriptVisibility.trim().toLowerCase()
199
- : '';
200
- return visibility === 'visible' || meta.userFacing === true;
186
+ function isExplicitlyHiddenFromTranscript(message: ChatMessage, meta: Record<string, unknown> | null): boolean {
187
+ const record = message as ChatMessage & Record<string, unknown>;
188
+ const visibility = readStringField(record.visibility || meta?.visibility || meta?.transcriptVisibility);
189
+ const audience = readStringField(record.audience || meta?.audience);
190
+ const source = readStringField(record.source || meta?.source);
191
+
192
+ return visibility === 'hidden'
193
+ || visibility === 'debug'
194
+ || visibility === 'internal'
195
+ || audience === 'debug'
196
+ || audience === 'trace'
197
+ || audience === 'internal'
198
+ || source === 'runtime_status'
199
+ || source === 'provider_chrome'
200
+ || source === 'control'
201
+ || record.internal === true
202
+ || record.isInternal === true
203
+ || record.debug === true
204
+ || meta?.internal === true
205
+ || meta?.isInternal === true
206
+ || meta?.debug === true
207
+ || meta?.statusOnly === true
208
+ || meta?.controlOnly === true;
209
+ }
210
+
211
+ function isExplicitlyVisibleInTranscript(message: ChatMessage, meta: Record<string, unknown> | null): boolean {
212
+ const record = message as ChatMessage & Record<string, unknown>;
213
+ const visibility = readStringField(record.visibility || meta?.visibility || meta?.transcriptVisibility);
214
+ const audience = readStringField(record.audience || meta?.audience);
215
+ return visibility === 'visible'
216
+ || visibility === 'user'
217
+ || audience === 'chat'
218
+ || record.userFacing === true
219
+ || meta?.userFacing === true;
201
220
  }
202
221
 
203
222
  /**
@@ -212,8 +231,8 @@ function isExplicitlyVisibleInTranscript(meta: Record<string, unknown> | null):
212
231
  export function isUserFacingChatMessage(message: ChatMessage | null | undefined): boolean {
213
232
  if (!message) return false;
214
233
  const meta = readMessageMeta(message);
215
- if (isExplicitlyHiddenFromTranscript(meta)) return false;
216
- if (isExplicitlyVisibleInTranscript(meta)) return true;
234
+ if (isExplicitlyHiddenFromTranscript(message, meta)) return false;
235
+ if (isExplicitlyVisibleInTranscript(message, meta)) return true;
217
236
 
218
237
  const role = typeof message.role === 'string' ? message.role.trim().toLowerCase() : '';
219
238
  const kind = resolveChatMessageKind(message);