@adhdev/daemon-standalone 0.8.62 → 0.8.64
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 +248 -23
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/public/assets/{index-DGqye5rQ.js → index-JfAYZJPk.js} +23 -23
- package/public/index.html +1 -1
package/dist/index.js
CHANGED
|
@@ -28313,19 +28313,75 @@ var require_dist2 = __commonJS({
|
|
|
28313
28313
|
LOG_PATH = path6.join(LOG_DIR, `daemon-${getDateStr()}.log`);
|
|
28314
28314
|
}
|
|
28315
28315
|
});
|
|
28316
|
+
function canonicalizeKindHint(value) {
|
|
28317
|
+
return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
28318
|
+
}
|
|
28319
|
+
function resolveBuiltinOrAliasKind(kind) {
|
|
28320
|
+
if (typeof kind !== "string") return null;
|
|
28321
|
+
const normalizedKind = canonicalizeKindHint(kind);
|
|
28322
|
+
if (!normalizedKind) return null;
|
|
28323
|
+
if (KNOWN_CHAT_MESSAGE_KINDS.has(normalizedKind)) return normalizedKind;
|
|
28324
|
+
return CHAT_MESSAGE_KIND_ALIASES[normalizedKind] || null;
|
|
28325
|
+
}
|
|
28326
|
+
function inferHintKind(value) {
|
|
28327
|
+
const direct = resolveBuiltinOrAliasKind(value);
|
|
28328
|
+
if (direct) return direct;
|
|
28329
|
+
if (typeof value !== "string") return null;
|
|
28330
|
+
const normalized = canonicalizeKindHint(value);
|
|
28331
|
+
if (!normalized) return null;
|
|
28332
|
+
if (/thought|thinking|reasoning/.test(normalized)) return "thought";
|
|
28333
|
+
if (/tool/.test(normalized)) return "tool";
|
|
28334
|
+
if (/terminal|command|shell|console/.test(normalized)) return "terminal";
|
|
28335
|
+
return null;
|
|
28336
|
+
}
|
|
28337
|
+
function inferKindFromToolCalls(message) {
|
|
28338
|
+
const toolCalls = Array.isArray(message?.toolCalls) ? message.toolCalls : [];
|
|
28339
|
+
if (toolCalls.length === 0) return null;
|
|
28340
|
+
if (toolCalls.some((toolCall) => toolCall?.kind === "think")) return "thought";
|
|
28341
|
+
if (toolCalls.some((toolCall) => toolCall?.kind === "execute")) return "terminal";
|
|
28342
|
+
if (toolCalls.some((toolCall) => Array.isArray(toolCall?.content) && toolCall.content.some((entry) => entry?.type === "terminal"))) {
|
|
28343
|
+
return "terminal";
|
|
28344
|
+
}
|
|
28345
|
+
return "tool";
|
|
28346
|
+
}
|
|
28347
|
+
function inferMissingChatMessageKind(message) {
|
|
28348
|
+
const role = typeof message?.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
28349
|
+
if (role === "system") return "system";
|
|
28350
|
+
const meta3 = message?.meta && typeof message.meta === "object" ? message.meta : void 0;
|
|
28351
|
+
const hintCandidates = [
|
|
28352
|
+
message?._sub,
|
|
28353
|
+
message?._type,
|
|
28354
|
+
meta3?.label,
|
|
28355
|
+
typeof message?.senderName === "string" ? message.senderName : void 0
|
|
28356
|
+
];
|
|
28357
|
+
for (const candidate of hintCandidates) {
|
|
28358
|
+
const inferred = inferHintKind(candidate);
|
|
28359
|
+
if (inferred) return inferred;
|
|
28360
|
+
}
|
|
28361
|
+
const inferredFromToolCalls = inferKindFromToolCalls(message);
|
|
28362
|
+
if (inferredFromToolCalls) return inferredFromToolCalls;
|
|
28363
|
+
return null;
|
|
28364
|
+
}
|
|
28316
28365
|
function isBuiltinChatMessageKind(kind) {
|
|
28317
|
-
return
|
|
28366
|
+
return resolveBuiltinOrAliasKind(kind) !== null;
|
|
28318
28367
|
}
|
|
28319
28368
|
function normalizeChatMessageKind(kind, role) {
|
|
28320
|
-
const
|
|
28321
|
-
if (
|
|
28369
|
+
const resolvedKind = resolveBuiltinOrAliasKind(kind);
|
|
28370
|
+
if (resolvedKind) return resolvedKind;
|
|
28322
28371
|
const normalizedRole = typeof role === "string" ? role.trim().toLowerCase() : "";
|
|
28323
28372
|
return normalizedRole === "system" ? "system" : "standard";
|
|
28324
28373
|
}
|
|
28374
|
+
function resolveChatMessageKind(message) {
|
|
28375
|
+
const explicitKind = resolveBuiltinOrAliasKind(message?.kind);
|
|
28376
|
+
if (explicitKind) return explicitKind;
|
|
28377
|
+
const inferredKind = inferMissingChatMessageKind(message);
|
|
28378
|
+
if (inferredKind) return inferredKind;
|
|
28379
|
+
return normalizeChatMessageKind(message?.kind, message?.role);
|
|
28380
|
+
}
|
|
28325
28381
|
function buildChatMessage(message) {
|
|
28326
28382
|
return {
|
|
28327
28383
|
...message,
|
|
28328
|
-
kind:
|
|
28384
|
+
kind: resolveChatMessageKind(message)
|
|
28329
28385
|
};
|
|
28330
28386
|
}
|
|
28331
28387
|
function buildSystemChatMessage(message) {
|
|
@@ -28348,6 +28404,24 @@ var require_dist2 = __commonJS({
|
|
|
28348
28404
|
kind: message?.kind || "standard"
|
|
28349
28405
|
});
|
|
28350
28406
|
}
|
|
28407
|
+
function buildThoughtChatMessage(message) {
|
|
28408
|
+
return buildAssistantChatMessage({
|
|
28409
|
+
...message,
|
|
28410
|
+
kind: message?.kind || "thought"
|
|
28411
|
+
});
|
|
28412
|
+
}
|
|
28413
|
+
function buildToolChatMessage(message) {
|
|
28414
|
+
return buildAssistantChatMessage({
|
|
28415
|
+
...message,
|
|
28416
|
+
kind: message?.kind || "tool"
|
|
28417
|
+
});
|
|
28418
|
+
}
|
|
28419
|
+
function buildTerminalChatMessage(message) {
|
|
28420
|
+
return buildAssistantChatMessage({
|
|
28421
|
+
...message,
|
|
28422
|
+
kind: message?.kind || "terminal"
|
|
28423
|
+
});
|
|
28424
|
+
}
|
|
28351
28425
|
function buildUserChatMessage(message) {
|
|
28352
28426
|
return buildChatMessage({
|
|
28353
28427
|
...message,
|
|
@@ -28363,11 +28437,30 @@ var require_dist2 = __commonJS({
|
|
|
28363
28437
|
}
|
|
28364
28438
|
var BUILTIN_CHAT_MESSAGE_KINDS;
|
|
28365
28439
|
var KNOWN_CHAT_MESSAGE_KINDS;
|
|
28440
|
+
var CHAT_MESSAGE_KIND_ALIASES;
|
|
28366
28441
|
var init_chat_message_normalization = __esm2({
|
|
28367
28442
|
"src/providers/chat-message-normalization.ts"() {
|
|
28368
28443
|
"use strict";
|
|
28369
28444
|
BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
|
|
28370
28445
|
KNOWN_CHAT_MESSAGE_KINDS = new Set(BUILTIN_CHAT_MESSAGE_KINDS);
|
|
28446
|
+
CHAT_MESSAGE_KIND_ALIASES = {
|
|
28447
|
+
text: "standard",
|
|
28448
|
+
message: "standard",
|
|
28449
|
+
assistant: "standard",
|
|
28450
|
+
thinking: "thought",
|
|
28451
|
+
think: "thought",
|
|
28452
|
+
reasoning: "thought",
|
|
28453
|
+
reason: "thought",
|
|
28454
|
+
toolcall: "tool",
|
|
28455
|
+
tool_call: "tool",
|
|
28456
|
+
tooluse: "tool",
|
|
28457
|
+
tool_use: "tool",
|
|
28458
|
+
action: "tool",
|
|
28459
|
+
command: "terminal",
|
|
28460
|
+
cmd: "terminal",
|
|
28461
|
+
shell: "terminal",
|
|
28462
|
+
console: "terminal"
|
|
28463
|
+
};
|
|
28371
28464
|
}
|
|
28372
28465
|
});
|
|
28373
28466
|
function isModuleNotFoundError(error48, ref) {
|
|
@@ -30953,6 +31046,8 @@ ${data.message || ""}`.trim();
|
|
|
30953
31046
|
CdpDomHandlers: () => CdpDomHandlers,
|
|
30954
31047
|
CliProviderInstance: () => CliProviderInstance,
|
|
30955
31048
|
DAEMON_WS_PATH: () => DAEMON_WS_PATH,
|
|
31049
|
+
DEFAULT_ACTIVE_CHAT_POLL_STATUSES: () => DEFAULT_ACTIVE_CHAT_POLL_STATUSES,
|
|
31050
|
+
DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS: () => DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS,
|
|
30956
31051
|
DEFAULT_DAEMON_PORT: () => DEFAULT_DAEMON_PORT,
|
|
30957
31052
|
DEFAULT_SESSION_HOST_APP_NAME: () => DEFAULT_SESSION_HOST_APP_NAME,
|
|
30958
31053
|
DEFAULT_STANDALONE_SESSION_HOST_APP_NAME: () => DEFAULT_STANDALONE_SESSION_HOST_APP_NAME,
|
|
@@ -30981,7 +31076,11 @@ ${data.message || ""}`.trim();
|
|
|
30981
31076
|
buildSessionEntries: () => buildSessionEntries,
|
|
30982
31077
|
buildStatusSnapshot: () => buildStatusSnapshot2,
|
|
30983
31078
|
buildSystemChatMessage: () => buildSystemChatMessage,
|
|
31079
|
+
buildTerminalChatMessage: () => buildTerminalChatMessage,
|
|
31080
|
+
buildThoughtChatMessage: () => buildThoughtChatMessage,
|
|
31081
|
+
buildToolChatMessage: () => buildToolChatMessage,
|
|
30984
31082
|
buildUserChatMessage: () => buildUserChatMessage,
|
|
31083
|
+
classifyHotChatSessionsForSubscriptionFlush: () => classifyHotChatSessionsForSubscriptionFlush2,
|
|
30985
31084
|
clearDebugTrace: () => clearDebugTrace,
|
|
30986
31085
|
configureDebugTraceStore: () => configureDebugTraceStore,
|
|
30987
31086
|
connectCdpManager: () => connectCdpManager,
|
|
@@ -31048,6 +31147,7 @@ ${data.message || ""}`.trim();
|
|
|
31048
31147
|
resetConfig: () => resetConfig,
|
|
31049
31148
|
resetDebugRuntimeConfig: () => resetDebugRuntimeConfig,
|
|
31050
31149
|
resetState: () => resetState,
|
|
31150
|
+
resolveChatMessageKind: () => resolveChatMessageKind,
|
|
31051
31151
|
resolveDebugRuntimeConfig: () => resolveDebugRuntimeConfig,
|
|
31052
31152
|
resolveSessionHostAppName: () => resolveSessionHostAppName2,
|
|
31053
31153
|
saveConfig: () => saveConfig,
|
|
@@ -31725,6 +31825,43 @@ ${data.message || ""}`.trim();
|
|
|
31725
31825
|
const availableMem = darwinAvail != null ? darwinAvail : freeMem;
|
|
31726
31826
|
return { totalMem, freeMem, availableMem };
|
|
31727
31827
|
}
|
|
31828
|
+
var DEFAULT_ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
|
|
31829
|
+
"generating",
|
|
31830
|
+
"waiting_approval",
|
|
31831
|
+
"starting"
|
|
31832
|
+
]);
|
|
31833
|
+
var DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS = 8e3;
|
|
31834
|
+
function parseMessageTimestamp(value) {
|
|
31835
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
31836
|
+
if (typeof value === "string") {
|
|
31837
|
+
const parsed = Date.parse(value);
|
|
31838
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
31839
|
+
}
|
|
31840
|
+
return 0;
|
|
31841
|
+
}
|
|
31842
|
+
function classifyHotChatSessionsForSubscriptionFlush2(sessions, previousHotSessionIds, options = {}) {
|
|
31843
|
+
const now = options.now ?? Date.now();
|
|
31844
|
+
const recentMessageGraceMs = Math.max(
|
|
31845
|
+
0,
|
|
31846
|
+
Number.isFinite(options.recentMessageGraceMs) ? Number(options.recentMessageGraceMs) : DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS
|
|
31847
|
+
);
|
|
31848
|
+
const activeStatuses = options.activeStatuses ?? DEFAULT_ACTIVE_CHAT_POLL_STATUSES;
|
|
31849
|
+
const active = /* @__PURE__ */ new Set();
|
|
31850
|
+
for (const session of sessions) {
|
|
31851
|
+
const sessionId = typeof session?.id === "string" ? session.id : "";
|
|
31852
|
+
if (!sessionId) continue;
|
|
31853
|
+
const status = String(session?.status || "").toLowerCase();
|
|
31854
|
+
const lastMessageAt = parseMessageTimestamp(session?.lastMessageAt);
|
|
31855
|
+
const recentlyUpdated = lastMessageAt > 0 && now - lastMessageAt <= recentMessageGraceMs;
|
|
31856
|
+
if (activeStatuses.has(status) || recentlyUpdated) {
|
|
31857
|
+
active.add(sessionId);
|
|
31858
|
+
}
|
|
31859
|
+
}
|
|
31860
|
+
const finalizing = new Set(
|
|
31861
|
+
Array.from(previousHotSessionIds).filter((sessionId) => !active.has(sessionId))
|
|
31862
|
+
);
|
|
31863
|
+
return { active, finalizing };
|
|
31864
|
+
}
|
|
31728
31865
|
var import_ws2 = __toESM2(require("ws"));
|
|
31729
31866
|
var http = __toESM2(require("http"));
|
|
31730
31867
|
init_logger();
|
|
@@ -34757,11 +34894,13 @@ ${effect.notification.body || ""}`.trim();
|
|
|
34757
34894
|
if (pm.receivedAt) prevByHash.set(h, pm.receivedAt);
|
|
34758
34895
|
}
|
|
34759
34896
|
const now = Date.now();
|
|
34760
|
-
const
|
|
34761
|
-
for (const msg of
|
|
34897
|
+
const rawMessages = chat.messages || [];
|
|
34898
|
+
for (const msg of rawMessages) {
|
|
34762
34899
|
const h = `${msg.role}:${(msg.content || "").slice(0, 100)}`;
|
|
34763
34900
|
msg.receivedAt = prevByHash.get(h) || now;
|
|
34764
34901
|
}
|
|
34902
|
+
chat.messages = normalizeChatMessages(rawMessages);
|
|
34903
|
+
const messages = chat.messages || [];
|
|
34765
34904
|
if (messages.length > 0) {
|
|
34766
34905
|
const hiddenKinds = /* @__PURE__ */ new Set();
|
|
34767
34906
|
if (this.settings.showThinking === false) hiddenKinds.add("thought");
|
|
@@ -39309,6 +39448,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
39309
39448
|
activeToolCalls = [];
|
|
39310
39449
|
stopReason = null;
|
|
39311
39450
|
partialContent = "";
|
|
39451
|
+
partialThoughtContent = "";
|
|
39312
39452
|
/** Rich content blocks accumulated during streaming */
|
|
39313
39453
|
partialBlocks = [];
|
|
39314
39454
|
/** Tool calls collected during current turn */
|
|
@@ -39354,6 +39494,10 @@ ${effect.notification.body || ""}`.trim();
|
|
|
39354
39494
|
content
|
|
39355
39495
|
});
|
|
39356
39496
|
}));
|
|
39497
|
+
if (this.currentStatus === "generating") {
|
|
39498
|
+
const partialThoughtMessage = this.buildPartialThoughtMessage(Date.now());
|
|
39499
|
+
if (partialThoughtMessage) recentMessages.push(partialThoughtMessage);
|
|
39500
|
+
}
|
|
39357
39501
|
if (this.currentStatus === "generating" && (this.partialContent || this.partialBlocks.length > 0)) {
|
|
39358
39502
|
const blocks = this.buildPartialBlocks();
|
|
39359
39503
|
if (blocks.length > 0) {
|
|
@@ -39912,6 +40056,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
39912
40056
|
}));
|
|
39913
40057
|
this.currentStatus = "generating";
|
|
39914
40058
|
this.partialContent = "";
|
|
40059
|
+
this.partialThoughtContent = "";
|
|
39915
40060
|
this.partialBlocks = [];
|
|
39916
40061
|
this.turnToolCalls = [];
|
|
39917
40062
|
this.detectStatusTransition();
|
|
@@ -39994,7 +40139,14 @@ ${effect.notification.body || ""}`.trim();
|
|
|
39994
40139
|
this.currentStatus = "generating";
|
|
39995
40140
|
break;
|
|
39996
40141
|
}
|
|
39997
|
-
case "agent_thought_chunk":
|
|
40142
|
+
case "agent_thought_chunk": {
|
|
40143
|
+
const content = update.content;
|
|
40144
|
+
if (content?.type === "text" && typeof content.text === "string") {
|
|
40145
|
+
this.partialThoughtContent += content.text;
|
|
40146
|
+
}
|
|
40147
|
+
this.currentStatus = "generating";
|
|
40148
|
+
break;
|
|
40149
|
+
}
|
|
39998
40150
|
case "user_message_chunk": {
|
|
39999
40151
|
break;
|
|
40000
40152
|
}
|
|
@@ -40149,8 +40301,82 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40149
40301
|
blocks.push(...this.partialBlocks);
|
|
40150
40302
|
return blocks;
|
|
40151
40303
|
}
|
|
40304
|
+
buildPartialThoughtMessage(timestamp = Date.now()) {
|
|
40305
|
+
const content = this.partialThoughtContent.trim();
|
|
40306
|
+
if (!content) return null;
|
|
40307
|
+
return buildThoughtChatMessage({
|
|
40308
|
+
content,
|
|
40309
|
+
timestamp,
|
|
40310
|
+
meta: {
|
|
40311
|
+
label: "Thought",
|
|
40312
|
+
isRunning: this.currentStatus === "generating"
|
|
40313
|
+
}
|
|
40314
|
+
});
|
|
40315
|
+
}
|
|
40316
|
+
buildToolCallBubbleKind(toolCall) {
|
|
40317
|
+
if (toolCall.kind === "think") return "thought";
|
|
40318
|
+
if (toolCall.kind === "execute") return "terminal";
|
|
40319
|
+
if (Array.isArray(toolCall.content) && toolCall.content.some((entry) => entry?.type === "terminal")) return "terminal";
|
|
40320
|
+
return "tool";
|
|
40321
|
+
}
|
|
40322
|
+
summarizeToolCallBubbleContent(toolCall) {
|
|
40323
|
+
const rawOutput = typeof toolCall.rawOutput === "string" ? toolCall.rawOutput.trim() : toolCall.rawOutput != null ? JSON.stringify(toolCall.rawOutput) : "";
|
|
40324
|
+
if (rawOutput) return rawOutput;
|
|
40325
|
+
const contentText = Array.isArray(toolCall.content) ? toolCall.content.map((entry) => {
|
|
40326
|
+
if (!entry || typeof entry !== "object") return "";
|
|
40327
|
+
if (entry.type === "content") return flattenContent([entry.content]).trim();
|
|
40328
|
+
if (entry.type === "diff") return `${entry.path}
|
|
40329
|
+
${entry.newText || ""}`.trim();
|
|
40330
|
+
if (entry.type === "terminal") return `Terminal: ${entry.terminalId || ""}`.trim();
|
|
40331
|
+
return "";
|
|
40332
|
+
}).filter(Boolean).join("\n\n").trim() : "";
|
|
40333
|
+
if (contentText) return contentText;
|
|
40334
|
+
const rawInput = typeof toolCall.rawInput === "string" ? toolCall.rawInput.trim() : toolCall.rawInput != null ? JSON.stringify(toolCall.rawInput) : "";
|
|
40335
|
+
if (rawInput) {
|
|
40336
|
+
return toolCall.title ? `${toolCall.title}
|
|
40337
|
+
${rawInput}` : rawInput;
|
|
40338
|
+
}
|
|
40339
|
+
return toolCall.title || "";
|
|
40340
|
+
}
|
|
40341
|
+
buildTurnToolCallMessages(timestamp = Date.now()) {
|
|
40342
|
+
return this.turnToolCalls.map((toolCall) => {
|
|
40343
|
+
const content = this.summarizeToolCallBubbleContent(toolCall);
|
|
40344
|
+
if (!content) return null;
|
|
40345
|
+
const isRunning = toolCall.status === "pending" || toolCall.status === "in_progress";
|
|
40346
|
+
const label = toolCall.title || void 0;
|
|
40347
|
+
const kind = this.buildToolCallBubbleKind(toolCall);
|
|
40348
|
+
if (kind === "thought") {
|
|
40349
|
+
return buildThoughtChatMessage({
|
|
40350
|
+
content,
|
|
40351
|
+
timestamp,
|
|
40352
|
+
meta: { label: label || "Thought", isRunning }
|
|
40353
|
+
});
|
|
40354
|
+
}
|
|
40355
|
+
if (kind === "terminal") {
|
|
40356
|
+
return buildTerminalChatMessage({
|
|
40357
|
+
content,
|
|
40358
|
+
timestamp,
|
|
40359
|
+
meta: { label: label || "Ran command", isRunning }
|
|
40360
|
+
});
|
|
40361
|
+
}
|
|
40362
|
+
return buildToolChatMessage({
|
|
40363
|
+
content,
|
|
40364
|
+
timestamp,
|
|
40365
|
+
meta: { label: label || "Tool call", isRunning }
|
|
40366
|
+
});
|
|
40367
|
+
}).filter(Boolean);
|
|
40368
|
+
}
|
|
40152
40369
|
/** Finalize streaming content into an assistant message */
|
|
40153
40370
|
finalizeAssistantMessage() {
|
|
40371
|
+
const timestamp = Date.now();
|
|
40372
|
+
const thoughtMessage = this.buildPartialThoughtMessage(timestamp);
|
|
40373
|
+
if (thoughtMessage) {
|
|
40374
|
+
this.messages.push(thoughtMessage);
|
|
40375
|
+
}
|
|
40376
|
+
const toolCallMessages = this.buildTurnToolCallMessages(timestamp);
|
|
40377
|
+
if (toolCallMessages.length > 0) {
|
|
40378
|
+
this.messages.push(...toolCallMessages);
|
|
40379
|
+
}
|
|
40154
40380
|
const blocks = this.buildPartialBlocks();
|
|
40155
40381
|
const finalBlocks = blocks.map((b2) => {
|
|
40156
40382
|
if (b2.type === "text" && b2.text.endsWith("...")) {
|
|
@@ -40166,6 +40392,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40166
40392
|
}));
|
|
40167
40393
|
}
|
|
40168
40394
|
this.partialContent = "";
|
|
40395
|
+
this.partialThoughtContent = "";
|
|
40169
40396
|
this.partialBlocks = [];
|
|
40170
40397
|
this.turnToolCalls = [];
|
|
40171
40398
|
}
|
|
@@ -42985,6 +43212,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
42985
43212
|
}
|
|
42986
43213
|
return 0;
|
|
42987
43214
|
}
|
|
43215
|
+
function getMessageEventTime(message) {
|
|
43216
|
+
return parseMessageTime(message?.receivedAt) || parseMessageTime(message?.timestamp) || 0;
|
|
43217
|
+
}
|
|
42988
43218
|
function stringifyPreviewContent(content) {
|
|
42989
43219
|
if (typeof content === "string") return content;
|
|
42990
43220
|
if (Array.isArray(content)) {
|
|
@@ -43029,7 +43259,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
43029
43259
|
return {
|
|
43030
43260
|
role,
|
|
43031
43261
|
preview,
|
|
43032
|
-
receivedAt:
|
|
43262
|
+
receivedAt: getMessageEventTime(candidate),
|
|
43033
43263
|
hash: simplePreviewHash(`${role}:${preview}`)
|
|
43034
43264
|
};
|
|
43035
43265
|
}
|
|
@@ -43038,7 +43268,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
43038
43268
|
function getSessionMessageUpdatedAt(session) {
|
|
43039
43269
|
const lastMessage = session.activeChat?.messages?.at?.(-1);
|
|
43040
43270
|
if (!lastMessage) return 0;
|
|
43041
|
-
return
|
|
43271
|
+
return getMessageEventTime(lastMessage);
|
|
43042
43272
|
}
|
|
43043
43273
|
function getSessionCompletionMarker(session) {
|
|
43044
43274
|
const lastMessage = session.activeChat?.messages?.at?.(-1);
|
|
@@ -43048,7 +43278,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
43048
43278
|
if (typeof lastMessage._turnKey === "string" && lastMessage._turnKey) return `turn:${lastMessage._turnKey}`;
|
|
43049
43279
|
if (typeof lastMessage.id === "string" && lastMessage.id) return `id:${lastMessage.id}`;
|
|
43050
43280
|
if (typeof lastMessage.index === "number" && Number.isFinite(lastMessage.index)) return `idx:${lastMessage.index}`;
|
|
43051
|
-
const timestamp =
|
|
43281
|
+
const timestamp = getMessageEventTime(lastMessage);
|
|
43052
43282
|
return timestamp > 0 ? `ts:${timestamp}` : "";
|
|
43053
43283
|
}
|
|
43054
43284
|
function getSessionLastUsedAt(session) {
|
|
@@ -44303,6 +44533,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44303
44533
|
init_logger();
|
|
44304
44534
|
var DEFAULT_DAEMON_PORT = 19222;
|
|
44305
44535
|
var DAEMON_WS_PATH = "/ipc";
|
|
44536
|
+
init_chat_message_normalization();
|
|
44306
44537
|
var ProviderStreamAdapter = class {
|
|
44307
44538
|
agentType;
|
|
44308
44539
|
agentName;
|
|
@@ -44412,7 +44643,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44412
44643
|
agentName: this.agentName,
|
|
44413
44644
|
extensionId: this.extensionId,
|
|
44414
44645
|
status: data.status || "idle",
|
|
44415
|
-
messages: data.messages
|
|
44646
|
+
messages: normalizeChatMessages(Array.isArray(data.messages) ? data.messages : []),
|
|
44416
44647
|
inputContent: data.inputContent || "",
|
|
44417
44648
|
activeModal: data.activeModal
|
|
44418
44649
|
};
|
|
@@ -52016,6 +52247,7 @@ async function getWorkspaceSocketInfo(workspaceName) {
|
|
|
52016
52247
|
}
|
|
52017
52248
|
|
|
52018
52249
|
// src/index.ts
|
|
52250
|
+
var import_daemon_core3 = __toESM(require_dist2());
|
|
52019
52251
|
var DEFAULT_PORT = 3847;
|
|
52020
52252
|
var STATUS_INTERVAL = 2e3;
|
|
52021
52253
|
var pkgVersion = process.env.ADHDEV_PKG_VERSION || "unknown";
|
|
@@ -52056,11 +52288,6 @@ var SESSION_TARGET_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
52056
52288
|
"restart_session",
|
|
52057
52289
|
"agent_command"
|
|
52058
52290
|
]);
|
|
52059
|
-
var ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
|
|
52060
|
-
"generating",
|
|
52061
|
-
"waiting_approval",
|
|
52062
|
-
"starting"
|
|
52063
|
-
]);
|
|
52064
52291
|
function hashSignatureParts(parts) {
|
|
52065
52292
|
let hash2 = 2166136261;
|
|
52066
52293
|
for (const part of parts) {
|
|
@@ -52838,14 +53065,12 @@ var StandaloneServer = class {
|
|
|
52838
53065
|
}
|
|
52839
53066
|
getHotChatSessionIdsForWsFlush() {
|
|
52840
53067
|
const snapshot = this.buildSharedSnapshot("live");
|
|
52841
|
-
const
|
|
52842
|
-
snapshot.sessions
|
|
52843
|
-
|
|
52844
|
-
const finalizing = new Set(
|
|
52845
|
-
Array.from(this.hotWsChatSessionIds).filter((sessionId) => !active.has(sessionId))
|
|
53068
|
+
const hotSessions = (0, import_daemon_core3.classifyHotChatSessionsForSubscriptionFlush)(
|
|
53069
|
+
snapshot.sessions,
|
|
53070
|
+
this.hotWsChatSessionIds
|
|
52846
53071
|
);
|
|
52847
|
-
this.hotWsChatSessionIds = active;
|
|
52848
|
-
return
|
|
53072
|
+
this.hotWsChatSessionIds = hotSessions.active;
|
|
53073
|
+
return hotSessions;
|
|
52849
53074
|
}
|
|
52850
53075
|
async flushWsChatSubscriptions(targetWs, options = {}) {
|
|
52851
53076
|
if (this.wsChatFlushInFlight) {
|