@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-standalone",
3
- "version": "0.9.76-rc.53",
3
+ "version": "0.9.76-rc.55",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -25132,6 +25132,7 @@ __export(dist_exports, {
25132
25132
  detectIDEs: () => detectIDEs,
25133
25133
  ensureSessionHostReady: () => ensureSessionHostReady,
25134
25134
  execNpmCommandSync: () => execNpmCommandSync,
25135
+ filterUserFacingChatMessages: () => filterUserFacingChatMessages,
25135
25136
  findCdpManager: () => findCdpManager,
25136
25137
  flattenMessageParts: () => flattenMessageParts,
25137
25138
  forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance,
@@ -25173,6 +25174,7 @@ __export(dist_exports, {
25173
25174
  isSessionHostLiveRuntime: () => isSessionHostLiveRuntime,
25174
25175
  isSessionHostRecoverySnapshot: () => isSessionHostRecoverySnapshot,
25175
25176
  isSetupComplete: () => isSetupComplete,
25177
+ isUserFacingChatMessage: () => isUserFacingChatMessage,
25176
25178
  killIdeProcess: () => killIdeProcess,
25177
25179
  launchIDE: () => launchIDE,
25178
25180
  launchWithCdp: () => launchWithCdp,
@@ -28794,6 +28796,34 @@ function normalizeChatMessage(message) {
28794
28796
  function normalizeChatMessages(messages) {
28795
28797
  return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
28796
28798
  }
28799
+ function readMessageMeta(message) {
28800
+ const meta3 = message?.meta;
28801
+ return meta3 && typeof meta3 === "object" && !Array.isArray(meta3) ? meta3 : null;
28802
+ }
28803
+ function isExplicitlyHiddenFromTranscript(meta3) {
28804
+ if (!meta3) return false;
28805
+ const visibility = typeof meta3.transcriptVisibility === "string" ? meta3.transcriptVisibility.trim().toLowerCase() : "";
28806
+ return visibility === "hidden" || visibility === "debug" || meta3.internal === true || meta3.debug === true || meta3.statusOnly === true || meta3.controlOnly === true;
28807
+ }
28808
+ function isExplicitlyVisibleInTranscript(meta3) {
28809
+ if (!meta3) return false;
28810
+ const visibility = typeof meta3.transcriptVisibility === "string" ? meta3.transcriptVisibility.trim().toLowerCase() : "";
28811
+ return visibility === "visible" || meta3.userFacing === true;
28812
+ }
28813
+ function isUserFacingChatMessage(message) {
28814
+ if (!message) return false;
28815
+ const meta3 = readMessageMeta(message);
28816
+ if (isExplicitlyHiddenFromTranscript(meta3)) return false;
28817
+ if (isExplicitlyVisibleInTranscript(meta3)) return true;
28818
+ const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
28819
+ const kind = resolveChatMessageKind(message);
28820
+ if (role === "user" || role === "human") return kind === "standard" || kind === "";
28821
+ if (role === "assistant") return kind === "standard" || kind === "";
28822
+ return false;
28823
+ }
28824
+ function filterUserFacingChatMessages(messages) {
28825
+ return (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
28826
+ }
28797
28827
  function extractProviderControlValues(controls, data) {
28798
28828
  if (!data || typeof data !== "object") return void 0;
28799
28829
  const values = {};
@@ -30865,7 +30895,7 @@ function normalizeReadChatTailLimit(args) {
30865
30895
  }
30866
30896
  function normalizeReadChatMessages(payload) {
30867
30897
  const messages = Array.isArray(payload.messages) ? payload.messages : [];
30868
- return messages;
30898
+ return normalizeChatMessages(messages);
30869
30899
  }
30870
30900
  function deriveHistoryDedupKey(message) {
30871
30901
  const unitKey = typeof message._unitKey === "string" ? message._unitKey.trim() : "";
@@ -30959,13 +30989,22 @@ function buildReadChatCommandResult(payload, args) {
30959
30989
  return { success: false, error: error48?.message || String(error48) };
30960
30990
  }
30961
30991
  const messages = normalizeReadChatMessages(validatedPayload);
30962
- const sync = buildFullTail(messages, normalizeReadChatTailLimit(args));
30992
+ const visibleMessages = filterUserFacingChatMessages(messages);
30993
+ const sync = buildFullTail(visibleMessages, normalizeReadChatTailLimit(args));
30994
+ const hiddenMsgCount = Math.max(0, messages.length - visibleMessages.length);
30995
+ const nextDebugReadChat = {
30996
+ ...debugReadChat || {},
30997
+ fullMsgCount: messages.length,
30998
+ visibleMsgCount: visibleMessages.length,
30999
+ hiddenMsgCount,
31000
+ returnedMsgCount: sync.messages.length
31001
+ };
30963
31002
  return {
30964
31003
  success: true,
30965
31004
  ...validatedPayload,
30966
31005
  messages: sync.messages,
30967
31006
  totalMessages: sync.totalMessages,
30968
- ...debugReadChat ? { debugReadChat } : {}
31007
+ debugReadChat: nextDebugReadChat
30969
31008
  };
30970
31009
  }
30971
31010
  function truncateDebugString(value, maxLength) {
@@ -47201,16 +47240,47 @@ ${effect.notification.body || ""}`.trim();
47201
47240
  const runtimeEntries = this.runtimeMessages.map((entry, index) => ({
47202
47241
  message: entry.message,
47203
47242
  index: parsedMessages.length + index,
47204
- source: "runtime"
47243
+ source: "runtime",
47244
+ runtimeKey: entry.key
47205
47245
  }));
47206
47246
  const getTime = (message) => {
47207
47247
  const value = typeof message.receivedAt === "number" ? message.receivedAt : typeof message.timestamp === "number" ? message.timestamp : 0;
47208
47248
  return Number.isFinite(value) && value > 0 ? value : 0;
47209
47249
  };
47250
+ const getRole = (message) => typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
47251
+ const isAutoApprovalRuntimeOverlay = (entry) => {
47252
+ if (entry.source !== "runtime") return false;
47253
+ const key = typeof entry.runtimeKey === "string" ? entry.runtimeKey.trim().toLowerCase() : "";
47254
+ if (key.startsWith("auto_approval:")) return true;
47255
+ const content = typeof entry.message.content === "string" ? entry.message.content.trim().toLowerCase() : flattenContent(entry.message.content).trim().toLowerCase();
47256
+ return content.startsWith("auto-approved:");
47257
+ };
47258
+ const shouldKeepParsedBeforeUntimedRuntime = (message) => {
47259
+ const role = getRole(message);
47260
+ return role === "user" || role === "human";
47261
+ };
47262
+ const shouldKeepParsedAfterUntimedRuntime = (message) => {
47263
+ const role = getRole(message);
47264
+ if (role !== "assistant") return false;
47265
+ const kind = resolveChatMessageKind(message);
47266
+ return kind === "standard" || kind === "terminal";
47267
+ };
47210
47268
  return normalizeChatMessages([...parsedEntries, ...runtimeEntries].sort((a, b) => {
47211
47269
  const aTime = getTime(a.message);
47212
47270
  const bTime = getTime(b.message);
47213
47271
  if (aTime && bTime && aTime !== bTime) return aTime - bTime;
47272
+ if (a.source !== b.source && aTime !== bTime) {
47273
+ const parsedEntry = a.source === "parsed" ? a : b.source === "parsed" ? b : null;
47274
+ const runtimeEntry = a.source === "runtime" ? a : b.source === "runtime" ? b : null;
47275
+ if (parsedEntry && runtimeEntry && isAutoApprovalRuntimeOverlay(runtimeEntry) && getTime(parsedEntry.message) === 0 && getTime(runtimeEntry.message) > 0) {
47276
+ if (shouldKeepParsedBeforeUntimedRuntime(parsedEntry.message)) {
47277
+ return a.source === "parsed" ? -1 : 1;
47278
+ }
47279
+ if (shouldKeepParsedAfterUntimedRuntime(parsedEntry.message)) {
47280
+ return a.source === "parsed" ? 1 : -1;
47281
+ }
47282
+ }
47283
+ }
47214
47284
  return a.index - b.index;
47215
47285
  }).map((entry) => entry.message));
47216
47286
  }