@adhdev/daemon-core 0.8.63 → 0.8.65

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.
@@ -6,11 +6,20 @@
6
6
  */
7
7
  import type { ProviderEffect } from '../providers/contracts.js';
8
8
  import type { ProviderSummaryMetadata } from '../shared-types.js';
9
+ import type { ChatMessageKind } from '../providers/chat-message-normalization.js';
9
10
  /** Agent chat message */
10
11
  export interface AgentChatMessage {
11
12
  role: 'user' | 'assistant' | 'system';
12
13
  content: string;
14
+ kind?: ChatMessageKind;
13
15
  timestamp?: number;
16
+ receivedAt?: number;
17
+ id?: string;
18
+ index?: number;
19
+ meta?: Record<string, unknown>;
20
+ senderName?: string;
21
+ _type?: string;
22
+ _sub?: string;
14
23
  }
15
24
  /** Agent chat history item */
16
25
  export interface AgentChatListItem {
package/dist/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export type { IDEInfo } from './detection/ide-detector.js';
29
29
  export { detectCLIs } from './detection/cli-detector.js';
30
30
  export { getHostMemorySnapshot } from './system/host-memory.js';
31
31
  export type { HostMemorySnapshot } from './system/host-memory.js';
32
+ export { classifyHotChatSessionsForSubscriptionFlush, DEFAULT_ACTIVE_CHAT_POLL_STATUSES, DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS, } from './status/chat-tail-hot-sessions.js';
32
33
  export { DaemonCdpManager } from './cdp/manager.js';
33
34
  export { CdpDomHandlers } from './cdp/devtools.js';
34
35
  export { setupIdeInstance, registerExtensionProviders, connectCdpManager, probeCdpPort } from './cdp/setup.js';
@@ -73,7 +74,7 @@ export type { ProviderModule, CdpTargetFilter, ProviderResumeCapability, InputEn
73
74
  export type { ProviderSourceConfigSnapshot, ProviderSourceConfigUpdate } from './config/provider-source-config.js';
74
75
  export { parseProviderSourceConfigUpdate } from './config/provider-source-config.js';
75
76
  export { normalizeInputEnvelope, normalizeMessageParts, flattenMessageParts } from './providers/io-contracts.js';
76
- export { BUILTIN_CHAT_MESSAGE_KINDS, isBuiltinChatMessageKind, normalizeChatMessageKind, buildChatMessage, buildSystemChatMessage, buildRuntimeSystemChatMessage, buildAssistantChatMessage, buildUserChatMessage, normalizeChatMessage, normalizeChatMessages, } from './providers/chat-message-normalization.js';
77
+ export { BUILTIN_CHAT_MESSAGE_KINDS, isBuiltinChatMessageKind, normalizeChatMessageKind, resolveChatMessageKind, buildChatMessage, buildSystemChatMessage, buildRuntimeSystemChatMessage, buildAssistantChatMessage, buildThoughtChatMessage, buildToolChatMessage, buildTerminalChatMessage, buildUserChatMessage, normalizeChatMessage, normalizeChatMessages, } from './providers/chat-message-normalization.js';
77
78
  export type { BuiltinChatMessageKind, ChatMessageKind } from './providers/chat-message-normalization.js';
78
79
  export { VersionArchive, detectAllVersions } from './providers/version-archive.js';
79
80
  export type { ProviderVersionInfo, VersionHistory } from './providers/version-archive.js';
package/dist/index.js CHANGED
@@ -459,19 +459,75 @@ var init_logger = __esm({
459
459
  });
460
460
 
461
461
  // src/providers/chat-message-normalization.ts
462
+ function canonicalizeKindHint(value) {
463
+ return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
464
+ }
465
+ function resolveBuiltinOrAliasKind(kind) {
466
+ if (typeof kind !== "string") return null;
467
+ const normalizedKind = canonicalizeKindHint(kind);
468
+ if (!normalizedKind) return null;
469
+ if (KNOWN_CHAT_MESSAGE_KINDS.has(normalizedKind)) return normalizedKind;
470
+ return CHAT_MESSAGE_KIND_ALIASES[normalizedKind] || null;
471
+ }
472
+ function inferHintKind(value) {
473
+ const direct = resolveBuiltinOrAliasKind(value);
474
+ if (direct) return direct;
475
+ if (typeof value !== "string") return null;
476
+ const normalized = canonicalizeKindHint(value);
477
+ if (!normalized) return null;
478
+ if (/thought|thinking|reasoning/.test(normalized)) return "thought";
479
+ if (/tool/.test(normalized)) return "tool";
480
+ if (/terminal|command|shell|console/.test(normalized)) return "terminal";
481
+ return null;
482
+ }
483
+ function inferKindFromToolCalls(message) {
484
+ const toolCalls = Array.isArray(message?.toolCalls) ? message.toolCalls : [];
485
+ if (toolCalls.length === 0) return null;
486
+ if (toolCalls.some((toolCall) => toolCall?.kind === "think")) return "thought";
487
+ if (toolCalls.some((toolCall) => toolCall?.kind === "execute")) return "terminal";
488
+ if (toolCalls.some((toolCall) => Array.isArray(toolCall?.content) && toolCall.content.some((entry) => entry?.type === "terminal"))) {
489
+ return "terminal";
490
+ }
491
+ return "tool";
492
+ }
493
+ function inferMissingChatMessageKind(message) {
494
+ const role = typeof message?.role === "string" ? message.role.trim().toLowerCase() : "";
495
+ if (role === "system") return "system";
496
+ const meta = message?.meta && typeof message.meta === "object" ? message.meta : void 0;
497
+ const hintCandidates = [
498
+ message?._sub,
499
+ message?._type,
500
+ meta?.label,
501
+ typeof message?.senderName === "string" ? message.senderName : void 0
502
+ ];
503
+ for (const candidate of hintCandidates) {
504
+ const inferred = inferHintKind(candidate);
505
+ if (inferred) return inferred;
506
+ }
507
+ const inferredFromToolCalls = inferKindFromToolCalls(message);
508
+ if (inferredFromToolCalls) return inferredFromToolCalls;
509
+ return null;
510
+ }
462
511
  function isBuiltinChatMessageKind(kind) {
463
- return typeof kind === "string" && KNOWN_CHAT_MESSAGE_KINDS.has(kind.trim().toLowerCase());
512
+ return resolveBuiltinOrAliasKind(kind) !== null;
464
513
  }
465
514
  function normalizeChatMessageKind(kind, role) {
466
- const normalizedKind = typeof kind === "string" ? kind.trim().toLowerCase() : "";
467
- if (normalizedKind && KNOWN_CHAT_MESSAGE_KINDS.has(normalizedKind)) return normalizedKind;
515
+ const resolvedKind = resolveBuiltinOrAliasKind(kind);
516
+ if (resolvedKind) return resolvedKind;
468
517
  const normalizedRole = typeof role === "string" ? role.trim().toLowerCase() : "";
469
518
  return normalizedRole === "system" ? "system" : "standard";
470
519
  }
520
+ function resolveChatMessageKind(message) {
521
+ const explicitKind = resolveBuiltinOrAliasKind(message?.kind);
522
+ if (explicitKind) return explicitKind;
523
+ const inferredKind = inferMissingChatMessageKind(message);
524
+ if (inferredKind) return inferredKind;
525
+ return normalizeChatMessageKind(message?.kind, message?.role);
526
+ }
471
527
  function buildChatMessage(message) {
472
528
  return {
473
529
  ...message,
474
- kind: normalizeChatMessageKind(message?.kind, message?.role)
530
+ kind: resolveChatMessageKind(message)
475
531
  };
476
532
  }
477
533
  function buildSystemChatMessage(message) {
@@ -494,6 +550,24 @@ function buildAssistantChatMessage(message) {
494
550
  kind: message?.kind || "standard"
495
551
  });
496
552
  }
553
+ function buildThoughtChatMessage(message) {
554
+ return buildAssistantChatMessage({
555
+ ...message,
556
+ kind: message?.kind || "thought"
557
+ });
558
+ }
559
+ function buildToolChatMessage(message) {
560
+ return buildAssistantChatMessage({
561
+ ...message,
562
+ kind: message?.kind || "tool"
563
+ });
564
+ }
565
+ function buildTerminalChatMessage(message) {
566
+ return buildAssistantChatMessage({
567
+ ...message,
568
+ kind: message?.kind || "terminal"
569
+ });
570
+ }
497
571
  function buildUserChatMessage(message) {
498
572
  return buildChatMessage({
499
573
  ...message,
@@ -507,12 +581,30 @@ function normalizeChatMessage(message) {
507
581
  function normalizeChatMessages(messages) {
508
582
  return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
509
583
  }
510
- var BUILTIN_CHAT_MESSAGE_KINDS, KNOWN_CHAT_MESSAGE_KINDS;
584
+ var BUILTIN_CHAT_MESSAGE_KINDS, KNOWN_CHAT_MESSAGE_KINDS, CHAT_MESSAGE_KIND_ALIASES;
511
585
  var init_chat_message_normalization = __esm({
512
586
  "src/providers/chat-message-normalization.ts"() {
513
587
  "use strict";
514
588
  BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
515
589
  KNOWN_CHAT_MESSAGE_KINDS = new Set(BUILTIN_CHAT_MESSAGE_KINDS);
590
+ CHAT_MESSAGE_KIND_ALIASES = {
591
+ text: "standard",
592
+ message: "standard",
593
+ assistant: "standard",
594
+ thinking: "thought",
595
+ think: "thought",
596
+ reasoning: "thought",
597
+ reason: "thought",
598
+ toolcall: "tool",
599
+ tool_call: "tool",
600
+ tooluse: "tool",
601
+ tool_use: "tool",
602
+ action: "tool",
603
+ command: "terminal",
604
+ cmd: "terminal",
605
+ shell: "terminal",
606
+ console: "terminal"
607
+ };
516
608
  }
517
609
  });
518
610
 
@@ -3106,6 +3198,8 @@ __export(index_exports, {
3106
3198
  CdpDomHandlers: () => CdpDomHandlers,
3107
3199
  CliProviderInstance: () => CliProviderInstance,
3108
3200
  DAEMON_WS_PATH: () => DAEMON_WS_PATH,
3201
+ DEFAULT_ACTIVE_CHAT_POLL_STATUSES: () => DEFAULT_ACTIVE_CHAT_POLL_STATUSES,
3202
+ DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS: () => DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS,
3109
3203
  DEFAULT_DAEMON_PORT: () => DEFAULT_DAEMON_PORT,
3110
3204
  DEFAULT_SESSION_HOST_APP_NAME: () => DEFAULT_SESSION_HOST_APP_NAME,
3111
3205
  DEFAULT_STANDALONE_SESSION_HOST_APP_NAME: () => DEFAULT_STANDALONE_SESSION_HOST_APP_NAME,
@@ -3134,7 +3228,11 @@ __export(index_exports, {
3134
3228
  buildSessionEntries: () => buildSessionEntries,
3135
3229
  buildStatusSnapshot: () => buildStatusSnapshot,
3136
3230
  buildSystemChatMessage: () => buildSystemChatMessage,
3231
+ buildTerminalChatMessage: () => buildTerminalChatMessage,
3232
+ buildThoughtChatMessage: () => buildThoughtChatMessage,
3233
+ buildToolChatMessage: () => buildToolChatMessage,
3137
3234
  buildUserChatMessage: () => buildUserChatMessage,
3235
+ classifyHotChatSessionsForSubscriptionFlush: () => classifyHotChatSessionsForSubscriptionFlush,
3138
3236
  clearDebugTrace: () => clearDebugTrace,
3139
3237
  configureDebugTraceStore: () => configureDebugTraceStore,
3140
3238
  connectCdpManager: () => connectCdpManager,
@@ -3201,6 +3299,7 @@ __export(index_exports, {
3201
3299
  resetConfig: () => resetConfig,
3202
3300
  resetDebugRuntimeConfig: () => resetDebugRuntimeConfig,
3203
3301
  resetState: () => resetState,
3302
+ resolveChatMessageKind: () => resolveChatMessageKind,
3204
3303
  resolveDebugRuntimeConfig: () => resolveDebugRuntimeConfig,
3205
3304
  resolveSessionHostAppName: () => resolveSessionHostAppName,
3206
3305
  saveConfig: () => saveConfig,
@@ -3897,6 +3996,45 @@ function getHostMemorySnapshot() {
3897
3996
  return { totalMem, freeMem, availableMem };
3898
3997
  }
3899
3998
 
3999
+ // src/status/chat-tail-hot-sessions.ts
4000
+ var DEFAULT_ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
4001
+ "generating",
4002
+ "waiting_approval",
4003
+ "starting"
4004
+ ]);
4005
+ var DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS = 8e3;
4006
+ function parseMessageTimestamp(value) {
4007
+ if (typeof value === "number" && Number.isFinite(value)) return value;
4008
+ if (typeof value === "string") {
4009
+ const parsed = Date.parse(value);
4010
+ if (Number.isFinite(parsed)) return parsed;
4011
+ }
4012
+ return 0;
4013
+ }
4014
+ function classifyHotChatSessionsForSubscriptionFlush(sessions, previousHotSessionIds, options = {}) {
4015
+ const now = options.now ?? Date.now();
4016
+ const recentMessageGraceMs = Math.max(
4017
+ 0,
4018
+ Number.isFinite(options.recentMessageGraceMs) ? Number(options.recentMessageGraceMs) : DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS
4019
+ );
4020
+ const activeStatuses = options.activeStatuses ?? DEFAULT_ACTIVE_CHAT_POLL_STATUSES;
4021
+ const active = /* @__PURE__ */ new Set();
4022
+ for (const session of sessions) {
4023
+ const sessionId = typeof session?.id === "string" ? session.id : "";
4024
+ if (!sessionId) continue;
4025
+ const status = String(session?.status || "").toLowerCase();
4026
+ const lastMessageAt = parseMessageTimestamp(session?.lastMessageAt);
4027
+ const recentlyUpdated = lastMessageAt > 0 && now - lastMessageAt <= recentMessageGraceMs;
4028
+ if (activeStatuses.has(status) || recentlyUpdated) {
4029
+ active.add(sessionId);
4030
+ }
4031
+ }
4032
+ const finalizing = new Set(
4033
+ Array.from(previousHotSessionIds).filter((sessionId) => !active.has(sessionId))
4034
+ );
4035
+ return { active, finalizing };
4036
+ }
4037
+
3900
4038
  // src/cdp/manager.ts
3901
4039
  var import_ws = __toESM(require("ws"));
3902
4040
  var http = __toESM(require("http"));
@@ -6954,11 +7092,13 @@ var IdeProviderInstance = class {
6954
7092
  if (pm.receivedAt) prevByHash.set(h, pm.receivedAt);
6955
7093
  }
6956
7094
  const now = Date.now();
6957
- const messages = chat.messages || [];
6958
- for (const msg of messages) {
7095
+ const rawMessages = chat.messages || [];
7096
+ for (const msg of rawMessages) {
6959
7097
  const h = `${msg.role}:${(msg.content || "").slice(0, 100)}`;
6960
7098
  msg.receivedAt = prevByHash.get(h) || now;
6961
7099
  }
7100
+ chat.messages = normalizeChatMessages(rawMessages);
7101
+ const messages = chat.messages || [];
6962
7102
  if (messages.length > 0) {
6963
7103
  const hiddenKinds = /* @__PURE__ */ new Set();
6964
7104
  if (this.settings.showThinking === false) hiddenKinds.add("thought");
@@ -11548,6 +11688,7 @@ var AcpProviderInstance = class {
11548
11688
  activeToolCalls = [];
11549
11689
  stopReason = null;
11550
11690
  partialContent = "";
11691
+ partialThoughtContent = "";
11551
11692
  /** Rich content blocks accumulated during streaming */
11552
11693
  partialBlocks = [];
11553
11694
  /** Tool calls collected during current turn */
@@ -11593,6 +11734,10 @@ var AcpProviderInstance = class {
11593
11734
  content
11594
11735
  });
11595
11736
  }));
11737
+ if (this.currentStatus === "generating") {
11738
+ const partialThoughtMessage = this.buildPartialThoughtMessage(Date.now());
11739
+ if (partialThoughtMessage) recentMessages.push(partialThoughtMessage);
11740
+ }
11596
11741
  if (this.currentStatus === "generating" && (this.partialContent || this.partialBlocks.length > 0)) {
11597
11742
  const blocks = this.buildPartialBlocks();
11598
11743
  if (blocks.length > 0) {
@@ -12151,6 +12296,7 @@ var AcpProviderInstance = class {
12151
12296
  }));
12152
12297
  this.currentStatus = "generating";
12153
12298
  this.partialContent = "";
12299
+ this.partialThoughtContent = "";
12154
12300
  this.partialBlocks = [];
12155
12301
  this.turnToolCalls = [];
12156
12302
  this.detectStatusTransition();
@@ -12233,7 +12379,14 @@ var AcpProviderInstance = class {
12233
12379
  this.currentStatus = "generating";
12234
12380
  break;
12235
12381
  }
12236
- case "agent_thought_chunk":
12382
+ case "agent_thought_chunk": {
12383
+ const content = update.content;
12384
+ if (content?.type === "text" && typeof content.text === "string") {
12385
+ this.partialThoughtContent += content.text;
12386
+ }
12387
+ this.currentStatus = "generating";
12388
+ break;
12389
+ }
12237
12390
  case "user_message_chunk": {
12238
12391
  break;
12239
12392
  }
@@ -12388,8 +12541,82 @@ var AcpProviderInstance = class {
12388
12541
  blocks.push(...this.partialBlocks);
12389
12542
  return blocks;
12390
12543
  }
12544
+ buildPartialThoughtMessage(timestamp = Date.now()) {
12545
+ const content = this.partialThoughtContent.trim();
12546
+ if (!content) return null;
12547
+ return buildThoughtChatMessage({
12548
+ content,
12549
+ timestamp,
12550
+ meta: {
12551
+ label: "Thought",
12552
+ isRunning: this.currentStatus === "generating"
12553
+ }
12554
+ });
12555
+ }
12556
+ buildToolCallBubbleKind(toolCall) {
12557
+ if (toolCall.kind === "think") return "thought";
12558
+ if (toolCall.kind === "execute") return "terminal";
12559
+ if (Array.isArray(toolCall.content) && toolCall.content.some((entry) => entry?.type === "terminal")) return "terminal";
12560
+ return "tool";
12561
+ }
12562
+ summarizeToolCallBubbleContent(toolCall) {
12563
+ const rawOutput = typeof toolCall.rawOutput === "string" ? toolCall.rawOutput.trim() : toolCall.rawOutput != null ? JSON.stringify(toolCall.rawOutput) : "";
12564
+ if (rawOutput) return rawOutput;
12565
+ const contentText = Array.isArray(toolCall.content) ? toolCall.content.map((entry) => {
12566
+ if (!entry || typeof entry !== "object") return "";
12567
+ if (entry.type === "content") return flattenContent([entry.content]).trim();
12568
+ if (entry.type === "diff") return `${entry.path}
12569
+ ${entry.newText || ""}`.trim();
12570
+ if (entry.type === "terminal") return `Terminal: ${entry.terminalId || ""}`.trim();
12571
+ return "";
12572
+ }).filter(Boolean).join("\n\n").trim() : "";
12573
+ if (contentText) return contentText;
12574
+ const rawInput = typeof toolCall.rawInput === "string" ? toolCall.rawInput.trim() : toolCall.rawInput != null ? JSON.stringify(toolCall.rawInput) : "";
12575
+ if (rawInput) {
12576
+ return toolCall.title ? `${toolCall.title}
12577
+ ${rawInput}` : rawInput;
12578
+ }
12579
+ return toolCall.title || "";
12580
+ }
12581
+ buildTurnToolCallMessages(timestamp = Date.now()) {
12582
+ return this.turnToolCalls.map((toolCall) => {
12583
+ const content = this.summarizeToolCallBubbleContent(toolCall);
12584
+ if (!content) return null;
12585
+ const isRunning = toolCall.status === "pending" || toolCall.status === "in_progress";
12586
+ const label = toolCall.title || void 0;
12587
+ const kind = this.buildToolCallBubbleKind(toolCall);
12588
+ if (kind === "thought") {
12589
+ return buildThoughtChatMessage({
12590
+ content,
12591
+ timestamp,
12592
+ meta: { label: label || "Thought", isRunning }
12593
+ });
12594
+ }
12595
+ if (kind === "terminal") {
12596
+ return buildTerminalChatMessage({
12597
+ content,
12598
+ timestamp,
12599
+ meta: { label: label || "Ran command", isRunning }
12600
+ });
12601
+ }
12602
+ return buildToolChatMessage({
12603
+ content,
12604
+ timestamp,
12605
+ meta: { label: label || "Tool call", isRunning }
12606
+ });
12607
+ }).filter(Boolean);
12608
+ }
12391
12609
  /** Finalize streaming content into an assistant message */
12392
12610
  finalizeAssistantMessage() {
12611
+ const timestamp = Date.now();
12612
+ const thoughtMessage = this.buildPartialThoughtMessage(timestamp);
12613
+ if (thoughtMessage) {
12614
+ this.messages.push(thoughtMessage);
12615
+ }
12616
+ const toolCallMessages = this.buildTurnToolCallMessages(timestamp);
12617
+ if (toolCallMessages.length > 0) {
12618
+ this.messages.push(...toolCallMessages);
12619
+ }
12393
12620
  const blocks = this.buildPartialBlocks();
12394
12621
  const finalBlocks = blocks.map((b) => {
12395
12622
  if (b.type === "text" && b.text.endsWith("...")) {
@@ -12405,6 +12632,7 @@ var AcpProviderInstance = class {
12405
12632
  }));
12406
12633
  }
12407
12634
  this.partialContent = "";
12635
+ this.partialThoughtContent = "";
12408
12636
  this.partialBlocks = [];
12409
12637
  this.turnToolCalls = [];
12410
12638
  }
@@ -15250,6 +15478,9 @@ function parseMessageTime(value) {
15250
15478
  }
15251
15479
  return 0;
15252
15480
  }
15481
+ function getMessageEventTime(message) {
15482
+ return parseMessageTime(message?.receivedAt) || parseMessageTime(message?.timestamp) || 0;
15483
+ }
15253
15484
  function stringifyPreviewContent(content) {
15254
15485
  if (typeof content === "string") return content;
15255
15486
  if (Array.isArray(content)) {
@@ -15294,7 +15525,7 @@ function getLastDisplayMessage(session) {
15294
15525
  return {
15295
15526
  role,
15296
15527
  preview,
15297
- receivedAt: parseMessageTime(candidate?.receivedAt),
15528
+ receivedAt: getMessageEventTime(candidate),
15298
15529
  hash: simplePreviewHash(`${role}:${preview}`)
15299
15530
  };
15300
15531
  }
@@ -15303,7 +15534,7 @@ function getLastDisplayMessage(session) {
15303
15534
  function getSessionMessageUpdatedAt(session) {
15304
15535
  const lastMessage = session.activeChat?.messages?.at?.(-1);
15305
15536
  if (!lastMessage) return 0;
15306
- return parseMessageTime(lastMessage.receivedAt) || 0;
15537
+ return getMessageEventTime(lastMessage);
15307
15538
  }
15308
15539
  function getSessionCompletionMarker(session) {
15309
15540
  const lastMessage = session.activeChat?.messages?.at?.(-1);
@@ -15313,7 +15544,7 @@ function getSessionCompletionMarker(session) {
15313
15544
  if (typeof lastMessage._turnKey === "string" && lastMessage._turnKey) return `turn:${lastMessage._turnKey}`;
15314
15545
  if (typeof lastMessage.id === "string" && lastMessage.id) return `id:${lastMessage.id}`;
15315
15546
  if (typeof lastMessage.index === "number" && Number.isFinite(lastMessage.index)) return `idx:${lastMessage.index}`;
15316
- const timestamp = parseMessageTime(lastMessage.receivedAt);
15547
+ const timestamp = getMessageEventTime(lastMessage);
15317
15548
  return timestamp > 0 ? `ts:${timestamp}` : "";
15318
15549
  }
15319
15550
  function getSessionLastUsedAt(session) {
@@ -16580,6 +16811,7 @@ var DEFAULT_DAEMON_PORT = 19222;
16580
16811
  var DAEMON_WS_PATH = "/ipc";
16581
16812
 
16582
16813
  // src/agent-stream/provider-adapter.ts
16814
+ init_chat_message_normalization();
16583
16815
  var ProviderStreamAdapter = class {
16584
16816
  agentType;
16585
16817
  agentName;
@@ -16689,7 +16921,7 @@ var ProviderStreamAdapter = class {
16689
16921
  agentName: this.agentName,
16690
16922
  extensionId: this.extensionId,
16691
16923
  status: data.status || "idle",
16692
- messages: data.messages || [],
16924
+ messages: normalizeChatMessages(Array.isArray(data.messages) ? data.messages : []),
16693
16925
  inputContent: data.inputContent || "",
16694
16926
  activeModal: data.activeModal
16695
16927
  };
@@ -23823,6 +24055,8 @@ async function shutdownDaemonComponents(components) {
23823
24055
  CdpDomHandlers,
23824
24056
  CliProviderInstance,
23825
24057
  DAEMON_WS_PATH,
24058
+ DEFAULT_ACTIVE_CHAT_POLL_STATUSES,
24059
+ DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS,
23826
24060
  DEFAULT_DAEMON_PORT,
23827
24061
  DEFAULT_SESSION_HOST_APP_NAME,
23828
24062
  DEFAULT_STANDALONE_SESSION_HOST_APP_NAME,
@@ -23851,7 +24085,11 @@ async function shutdownDaemonComponents(components) {
23851
24085
  buildSessionEntries,
23852
24086
  buildStatusSnapshot,
23853
24087
  buildSystemChatMessage,
24088
+ buildTerminalChatMessage,
24089
+ buildThoughtChatMessage,
24090
+ buildToolChatMessage,
23854
24091
  buildUserChatMessage,
24092
+ classifyHotChatSessionsForSubscriptionFlush,
23855
24093
  clearDebugTrace,
23856
24094
  configureDebugTraceStore,
23857
24095
  connectCdpManager,
@@ -23918,6 +24156,7 @@ async function shutdownDaemonComponents(components) {
23918
24156
  resetConfig,
23919
24157
  resetDebugRuntimeConfig,
23920
24158
  resetState,
24159
+ resolveChatMessageKind,
23921
24160
  resolveDebugRuntimeConfig,
23922
24161
  resolveSessionHostAppName,
23923
24162
  saveConfig,