adhdev 0.8.61 → 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.
- package/dist/cli/index.js +283 -27
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +283 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -974,6 +974,51 @@ var init_host_memory = __esm({
|
|
|
974
974
|
}
|
|
975
975
|
});
|
|
976
976
|
|
|
977
|
+
// ../../oss/packages/daemon-core/src/status/chat-tail-hot-sessions.ts
|
|
978
|
+
function parseMessageTimestamp(value) {
|
|
979
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
980
|
+
if (typeof value === "string") {
|
|
981
|
+
const parsed = Date.parse(value);
|
|
982
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
983
|
+
}
|
|
984
|
+
return 0;
|
|
985
|
+
}
|
|
986
|
+
function classifyHotChatSessionsForSubscriptionFlush(sessions, previousHotSessionIds, options = {}) {
|
|
987
|
+
const now = options.now ?? Date.now();
|
|
988
|
+
const recentMessageGraceMs = Math.max(
|
|
989
|
+
0,
|
|
990
|
+
Number.isFinite(options.recentMessageGraceMs) ? Number(options.recentMessageGraceMs) : DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS
|
|
991
|
+
);
|
|
992
|
+
const activeStatuses = options.activeStatuses ?? DEFAULT_ACTIVE_CHAT_POLL_STATUSES;
|
|
993
|
+
const active = /* @__PURE__ */ new Set();
|
|
994
|
+
for (const session of sessions) {
|
|
995
|
+
const sessionId = typeof session?.id === "string" ? session.id : "";
|
|
996
|
+
if (!sessionId) continue;
|
|
997
|
+
const status = String(session?.status || "").toLowerCase();
|
|
998
|
+
const lastMessageAt = parseMessageTimestamp(session?.lastMessageAt);
|
|
999
|
+
const recentlyUpdated = lastMessageAt > 0 && now - lastMessageAt <= recentMessageGraceMs;
|
|
1000
|
+
if (activeStatuses.has(status) || recentlyUpdated) {
|
|
1001
|
+
active.add(sessionId);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
const finalizing = new Set(
|
|
1005
|
+
Array.from(previousHotSessionIds).filter((sessionId) => !active.has(sessionId))
|
|
1006
|
+
);
|
|
1007
|
+
return { active, finalizing };
|
|
1008
|
+
}
|
|
1009
|
+
var DEFAULT_ACTIVE_CHAT_POLL_STATUSES, DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS;
|
|
1010
|
+
var init_chat_tail_hot_sessions = __esm({
|
|
1011
|
+
"../../oss/packages/daemon-core/src/status/chat-tail-hot-sessions.ts"() {
|
|
1012
|
+
"use strict";
|
|
1013
|
+
DEFAULT_ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
|
|
1014
|
+
"generating",
|
|
1015
|
+
"waiting_approval",
|
|
1016
|
+
"starting"
|
|
1017
|
+
]);
|
|
1018
|
+
DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS = 8e3;
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
|
|
977
1022
|
// ../../oss/packages/daemon-core/src/logging/logger.ts
|
|
978
1023
|
function setLogLevel(level) {
|
|
979
1024
|
currentLevel = level;
|
|
@@ -2839,19 +2884,75 @@ var init_status_monitor = __esm({
|
|
|
2839
2884
|
});
|
|
2840
2885
|
|
|
2841
2886
|
// ../../oss/packages/daemon-core/src/providers/chat-message-normalization.ts
|
|
2887
|
+
function canonicalizeKindHint(value) {
|
|
2888
|
+
return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
2889
|
+
}
|
|
2890
|
+
function resolveBuiltinOrAliasKind(kind) {
|
|
2891
|
+
if (typeof kind !== "string") return null;
|
|
2892
|
+
const normalizedKind = canonicalizeKindHint(kind);
|
|
2893
|
+
if (!normalizedKind) return null;
|
|
2894
|
+
if (KNOWN_CHAT_MESSAGE_KINDS.has(normalizedKind)) return normalizedKind;
|
|
2895
|
+
return CHAT_MESSAGE_KIND_ALIASES[normalizedKind] || null;
|
|
2896
|
+
}
|
|
2897
|
+
function inferHintKind(value) {
|
|
2898
|
+
const direct = resolveBuiltinOrAliasKind(value);
|
|
2899
|
+
if (direct) return direct;
|
|
2900
|
+
if (typeof value !== "string") return null;
|
|
2901
|
+
const normalized = canonicalizeKindHint(value);
|
|
2902
|
+
if (!normalized) return null;
|
|
2903
|
+
if (/thought|thinking|reasoning/.test(normalized)) return "thought";
|
|
2904
|
+
if (/tool/.test(normalized)) return "tool";
|
|
2905
|
+
if (/terminal|command|shell|console/.test(normalized)) return "terminal";
|
|
2906
|
+
return null;
|
|
2907
|
+
}
|
|
2908
|
+
function inferKindFromToolCalls(message) {
|
|
2909
|
+
const toolCalls = Array.isArray(message?.toolCalls) ? message.toolCalls : [];
|
|
2910
|
+
if (toolCalls.length === 0) return null;
|
|
2911
|
+
if (toolCalls.some((toolCall) => toolCall?.kind === "think")) return "thought";
|
|
2912
|
+
if (toolCalls.some((toolCall) => toolCall?.kind === "execute")) return "terminal";
|
|
2913
|
+
if (toolCalls.some((toolCall) => Array.isArray(toolCall?.content) && toolCall.content.some((entry) => entry?.type === "terminal"))) {
|
|
2914
|
+
return "terminal";
|
|
2915
|
+
}
|
|
2916
|
+
return "tool";
|
|
2917
|
+
}
|
|
2918
|
+
function inferMissingChatMessageKind(message) {
|
|
2919
|
+
const role = typeof message?.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
2920
|
+
if (role === "system") return "system";
|
|
2921
|
+
const meta3 = message?.meta && typeof message.meta === "object" ? message.meta : void 0;
|
|
2922
|
+
const hintCandidates = [
|
|
2923
|
+
message?._sub,
|
|
2924
|
+
message?._type,
|
|
2925
|
+
meta3?.label,
|
|
2926
|
+
typeof message?.senderName === "string" ? message.senderName : void 0
|
|
2927
|
+
];
|
|
2928
|
+
for (const candidate of hintCandidates) {
|
|
2929
|
+
const inferred = inferHintKind(candidate);
|
|
2930
|
+
if (inferred) return inferred;
|
|
2931
|
+
}
|
|
2932
|
+
const inferredFromToolCalls = inferKindFromToolCalls(message);
|
|
2933
|
+
if (inferredFromToolCalls) return inferredFromToolCalls;
|
|
2934
|
+
return null;
|
|
2935
|
+
}
|
|
2842
2936
|
function isBuiltinChatMessageKind(kind) {
|
|
2843
|
-
return
|
|
2937
|
+
return resolveBuiltinOrAliasKind(kind) !== null;
|
|
2844
2938
|
}
|
|
2845
2939
|
function normalizeChatMessageKind(kind, role) {
|
|
2846
|
-
const
|
|
2847
|
-
if (
|
|
2940
|
+
const resolvedKind = resolveBuiltinOrAliasKind(kind);
|
|
2941
|
+
if (resolvedKind) return resolvedKind;
|
|
2848
2942
|
const normalizedRole = typeof role === "string" ? role.trim().toLowerCase() : "";
|
|
2849
2943
|
return normalizedRole === "system" ? "system" : "standard";
|
|
2850
2944
|
}
|
|
2945
|
+
function resolveChatMessageKind(message) {
|
|
2946
|
+
const explicitKind = resolveBuiltinOrAliasKind(message?.kind);
|
|
2947
|
+
if (explicitKind) return explicitKind;
|
|
2948
|
+
const inferredKind = inferMissingChatMessageKind(message);
|
|
2949
|
+
if (inferredKind) return inferredKind;
|
|
2950
|
+
return normalizeChatMessageKind(message?.kind, message?.role);
|
|
2951
|
+
}
|
|
2851
2952
|
function buildChatMessage(message) {
|
|
2852
2953
|
return {
|
|
2853
2954
|
...message,
|
|
2854
|
-
kind:
|
|
2955
|
+
kind: resolveChatMessageKind(message)
|
|
2855
2956
|
};
|
|
2856
2957
|
}
|
|
2857
2958
|
function buildSystemChatMessage(message) {
|
|
@@ -2874,6 +2975,24 @@ function buildAssistantChatMessage(message) {
|
|
|
2874
2975
|
kind: message?.kind || "standard"
|
|
2875
2976
|
});
|
|
2876
2977
|
}
|
|
2978
|
+
function buildThoughtChatMessage(message) {
|
|
2979
|
+
return buildAssistantChatMessage({
|
|
2980
|
+
...message,
|
|
2981
|
+
kind: message?.kind || "thought"
|
|
2982
|
+
});
|
|
2983
|
+
}
|
|
2984
|
+
function buildToolChatMessage(message) {
|
|
2985
|
+
return buildAssistantChatMessage({
|
|
2986
|
+
...message,
|
|
2987
|
+
kind: message?.kind || "tool"
|
|
2988
|
+
});
|
|
2989
|
+
}
|
|
2990
|
+
function buildTerminalChatMessage(message) {
|
|
2991
|
+
return buildAssistantChatMessage({
|
|
2992
|
+
...message,
|
|
2993
|
+
kind: message?.kind || "terminal"
|
|
2994
|
+
});
|
|
2995
|
+
}
|
|
2877
2996
|
function buildUserChatMessage(message) {
|
|
2878
2997
|
return buildChatMessage({
|
|
2879
2998
|
...message,
|
|
@@ -2887,12 +3006,30 @@ function normalizeChatMessage(message) {
|
|
|
2887
3006
|
function normalizeChatMessages(messages) {
|
|
2888
3007
|
return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
|
|
2889
3008
|
}
|
|
2890
|
-
var BUILTIN_CHAT_MESSAGE_KINDS, KNOWN_CHAT_MESSAGE_KINDS;
|
|
3009
|
+
var BUILTIN_CHAT_MESSAGE_KINDS, KNOWN_CHAT_MESSAGE_KINDS, CHAT_MESSAGE_KIND_ALIASES;
|
|
2891
3010
|
var init_chat_message_normalization = __esm({
|
|
2892
3011
|
"../../oss/packages/daemon-core/src/providers/chat-message-normalization.ts"() {
|
|
2893
3012
|
"use strict";
|
|
2894
3013
|
BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
|
|
2895
3014
|
KNOWN_CHAT_MESSAGE_KINDS = new Set(BUILTIN_CHAT_MESSAGE_KINDS);
|
|
3015
|
+
CHAT_MESSAGE_KIND_ALIASES = {
|
|
3016
|
+
text: "standard",
|
|
3017
|
+
message: "standard",
|
|
3018
|
+
assistant: "standard",
|
|
3019
|
+
thinking: "thought",
|
|
3020
|
+
think: "thought",
|
|
3021
|
+
reasoning: "thought",
|
|
3022
|
+
reason: "thought",
|
|
3023
|
+
toolcall: "tool",
|
|
3024
|
+
tool_call: "tool",
|
|
3025
|
+
tooluse: "tool",
|
|
3026
|
+
tool_use: "tool",
|
|
3027
|
+
action: "tool",
|
|
3028
|
+
command: "terminal",
|
|
3029
|
+
cmd: "terminal",
|
|
3030
|
+
shell: "terminal",
|
|
3031
|
+
console: "terminal"
|
|
3032
|
+
};
|
|
2896
3033
|
}
|
|
2897
3034
|
});
|
|
2898
3035
|
|
|
@@ -4377,11 +4514,13 @@ var init_ide_provider_instance = __esm({
|
|
|
4377
4514
|
if (pm.receivedAt) prevByHash.set(h, pm.receivedAt);
|
|
4378
4515
|
}
|
|
4379
4516
|
const now = Date.now();
|
|
4380
|
-
const
|
|
4381
|
-
for (const msg of
|
|
4517
|
+
const rawMessages = chat.messages || [];
|
|
4518
|
+
for (const msg of rawMessages) {
|
|
4382
4519
|
const h = `${msg.role}:${(msg.content || "").slice(0, 100)}`;
|
|
4383
4520
|
msg.receivedAt = prevByHash.get(h) || now;
|
|
4384
4521
|
}
|
|
4522
|
+
chat.messages = normalizeChatMessages(rawMessages);
|
|
4523
|
+
const messages = chat.messages || [];
|
|
4385
4524
|
if (messages.length > 0) {
|
|
4386
4525
|
const hiddenKinds = /* @__PURE__ */ new Set();
|
|
4387
4526
|
if (this.settings.showThinking === false) hiddenKinds.add("thought");
|
|
@@ -9567,6 +9706,7 @@ function buildCliParseInput(options) {
|
|
|
9567
9706
|
terminalScreenText,
|
|
9568
9707
|
baseMessages,
|
|
9569
9708
|
partialResponse,
|
|
9709
|
+
isWaitingForResponse,
|
|
9570
9710
|
scope,
|
|
9571
9711
|
runtimeSettings
|
|
9572
9712
|
} = options;
|
|
@@ -9584,6 +9724,7 @@ function buildCliParseInput(options) {
|
|
|
9584
9724
|
recentScreen: buildCliScreenSnapshot(recentBuffer),
|
|
9585
9725
|
messages: [...baseMessages],
|
|
9586
9726
|
partialResponse,
|
|
9727
|
+
isWaitingForResponse,
|
|
9587
9728
|
promptText: scope?.prompt || "",
|
|
9588
9729
|
settings: { ...runtimeSettings }
|
|
9589
9730
|
};
|
|
@@ -10322,6 +10463,18 @@ var init_provider_cli_adapter = __esm({
|
|
|
10322
10463
|
const holdMs = this.getStatusActivityHoldMs();
|
|
10323
10464
|
return quietForMs < holdMs || screenStableMs < holdMs;
|
|
10324
10465
|
}
|
|
10466
|
+
shouldDeferIdleTimeoutFinish() {
|
|
10467
|
+
if (!this.isWaitingForResponse || this.currentStatus === "waiting_approval") {
|
|
10468
|
+
return false;
|
|
10469
|
+
}
|
|
10470
|
+
const latestStatus = this.runDetectStatus(this.recentOutputBuffer) || this.currentStatus;
|
|
10471
|
+
if (latestStatus === "generating") {
|
|
10472
|
+
this.settledBuffer = this.recentOutputBuffer;
|
|
10473
|
+
this.evaluateSettled();
|
|
10474
|
+
return true;
|
|
10475
|
+
}
|
|
10476
|
+
return false;
|
|
10477
|
+
}
|
|
10325
10478
|
getStartupConfirmationModal(screenText) {
|
|
10326
10479
|
const text = sanitizeTerminalText(String(screenText || ""));
|
|
10327
10480
|
if (!text.trim()) return null;
|
|
@@ -10480,6 +10633,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
10480
10633
|
if (this.idleTimeout) clearTimeout(this.idleTimeout);
|
|
10481
10634
|
this.idleTimeout = setTimeout(() => {
|
|
10482
10635
|
if (this.isWaitingForResponse && this.currentStatus !== "waiting_approval") {
|
|
10636
|
+
if (this.shouldDeferIdleTimeoutFinish()) return;
|
|
10483
10637
|
this.finishResponse();
|
|
10484
10638
|
}
|
|
10485
10639
|
}, this.timeouts.generatingIdle);
|
|
@@ -10515,6 +10669,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
10515
10669
|
if (this.idleTimeout) clearTimeout(this.idleTimeout);
|
|
10516
10670
|
this.idleTimeout = setTimeout(() => {
|
|
10517
10671
|
if (this.isWaitingForResponse && this.currentStatus !== "waiting_approval") {
|
|
10672
|
+
if (this.shouldDeferIdleTimeoutFinish()) return;
|
|
10518
10673
|
this.finishResponse();
|
|
10519
10674
|
}
|
|
10520
10675
|
}, this.timeouts.generatingIdle);
|
|
@@ -10557,7 +10712,10 @@ var init_provider_cli_adapter = __esm({
|
|
|
10557
10712
|
this.setStatus("generating", "script_detect");
|
|
10558
10713
|
if (this.idleTimeout) clearTimeout(this.idleTimeout);
|
|
10559
10714
|
this.idleTimeout = setTimeout(() => {
|
|
10560
|
-
if (this.isWaitingForResponse)
|
|
10715
|
+
if (this.isWaitingForResponse) {
|
|
10716
|
+
if (this.shouldDeferIdleTimeoutFinish()) return;
|
|
10717
|
+
this.finishResponse();
|
|
10718
|
+
}
|
|
10561
10719
|
}, this.timeouts.generatingIdle);
|
|
10562
10720
|
this.onStatusChange?.();
|
|
10563
10721
|
return;
|
|
@@ -10625,6 +10783,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
10625
10783
|
if (this.idleTimeout) clearTimeout(this.idleTimeout);
|
|
10626
10784
|
this.idleTimeout = setTimeout(() => {
|
|
10627
10785
|
if (this.isWaitingForResponse && this.currentStatus !== "waiting_approval") {
|
|
10786
|
+
if (this.shouldDeferIdleTimeoutFinish()) return;
|
|
10628
10787
|
this.clearIdleFinishCandidate("idle_timeout_finish");
|
|
10629
10788
|
this.finishResponse();
|
|
10630
10789
|
}
|
|
@@ -10763,6 +10922,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
10763
10922
|
tail: text.slice(-500),
|
|
10764
10923
|
screenText,
|
|
10765
10924
|
rawBuffer: this.accumulatedRawBuffer,
|
|
10925
|
+
isWaitingForResponse: this.isWaitingForResponse,
|
|
10766
10926
|
screen: buildCliScreenSnapshot(screenText),
|
|
10767
10927
|
tailScreen: buildCliScreenSnapshot(text.slice(-500))
|
|
10768
10928
|
});
|
|
@@ -10872,6 +11032,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
10872
11032
|
terminalScreenText: this.terminalScreen.getText(),
|
|
10873
11033
|
baseMessages: this.committedMessages,
|
|
10874
11034
|
partialResponse: this.responseBuffer,
|
|
11035
|
+
isWaitingForResponse: this.isWaitingForResponse,
|
|
10875
11036
|
scope: this.currentTurnScope,
|
|
10876
11037
|
runtimeSettings: this.runtimeSettings
|
|
10877
11038
|
});
|
|
@@ -10890,6 +11051,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
10890
11051
|
terminalScreenText: this.terminalScreen.getText(),
|
|
10891
11052
|
baseMessages,
|
|
10892
11053
|
partialResponse,
|
|
11054
|
+
isWaitingForResponse: this.isWaitingForResponse,
|
|
10893
11055
|
scope,
|
|
10894
11056
|
runtimeSettings: this.runtimeSettings
|
|
10895
11057
|
});
|
|
@@ -28669,6 +28831,7 @@ var init_acp_provider_instance = __esm({
|
|
|
28669
28831
|
activeToolCalls = [];
|
|
28670
28832
|
stopReason = null;
|
|
28671
28833
|
partialContent = "";
|
|
28834
|
+
partialThoughtContent = "";
|
|
28672
28835
|
/** Rich content blocks accumulated during streaming */
|
|
28673
28836
|
partialBlocks = [];
|
|
28674
28837
|
/** Tool calls collected during current turn */
|
|
@@ -28714,6 +28877,10 @@ var init_acp_provider_instance = __esm({
|
|
|
28714
28877
|
content
|
|
28715
28878
|
});
|
|
28716
28879
|
}));
|
|
28880
|
+
if (this.currentStatus === "generating") {
|
|
28881
|
+
const partialThoughtMessage = this.buildPartialThoughtMessage(Date.now());
|
|
28882
|
+
if (partialThoughtMessage) recentMessages.push(partialThoughtMessage);
|
|
28883
|
+
}
|
|
28717
28884
|
if (this.currentStatus === "generating" && (this.partialContent || this.partialBlocks.length > 0)) {
|
|
28718
28885
|
const blocks = this.buildPartialBlocks();
|
|
28719
28886
|
if (blocks.length > 0) {
|
|
@@ -29272,6 +29439,7 @@ var init_acp_provider_instance = __esm({
|
|
|
29272
29439
|
}));
|
|
29273
29440
|
this.currentStatus = "generating";
|
|
29274
29441
|
this.partialContent = "";
|
|
29442
|
+
this.partialThoughtContent = "";
|
|
29275
29443
|
this.partialBlocks = [];
|
|
29276
29444
|
this.turnToolCalls = [];
|
|
29277
29445
|
this.detectStatusTransition();
|
|
@@ -29354,7 +29522,14 @@ var init_acp_provider_instance = __esm({
|
|
|
29354
29522
|
this.currentStatus = "generating";
|
|
29355
29523
|
break;
|
|
29356
29524
|
}
|
|
29357
|
-
case "agent_thought_chunk":
|
|
29525
|
+
case "agent_thought_chunk": {
|
|
29526
|
+
const content = update.content;
|
|
29527
|
+
if (content?.type === "text" && typeof content.text === "string") {
|
|
29528
|
+
this.partialThoughtContent += content.text;
|
|
29529
|
+
}
|
|
29530
|
+
this.currentStatus = "generating";
|
|
29531
|
+
break;
|
|
29532
|
+
}
|
|
29358
29533
|
case "user_message_chunk": {
|
|
29359
29534
|
break;
|
|
29360
29535
|
}
|
|
@@ -29509,8 +29684,82 @@ var init_acp_provider_instance = __esm({
|
|
|
29509
29684
|
blocks.push(...this.partialBlocks);
|
|
29510
29685
|
return blocks;
|
|
29511
29686
|
}
|
|
29687
|
+
buildPartialThoughtMessage(timestamp = Date.now()) {
|
|
29688
|
+
const content = this.partialThoughtContent.trim();
|
|
29689
|
+
if (!content) return null;
|
|
29690
|
+
return buildThoughtChatMessage({
|
|
29691
|
+
content,
|
|
29692
|
+
timestamp,
|
|
29693
|
+
meta: {
|
|
29694
|
+
label: "Thought",
|
|
29695
|
+
isRunning: this.currentStatus === "generating"
|
|
29696
|
+
}
|
|
29697
|
+
});
|
|
29698
|
+
}
|
|
29699
|
+
buildToolCallBubbleKind(toolCall) {
|
|
29700
|
+
if (toolCall.kind === "think") return "thought";
|
|
29701
|
+
if (toolCall.kind === "execute") return "terminal";
|
|
29702
|
+
if (Array.isArray(toolCall.content) && toolCall.content.some((entry) => entry?.type === "terminal")) return "terminal";
|
|
29703
|
+
return "tool";
|
|
29704
|
+
}
|
|
29705
|
+
summarizeToolCallBubbleContent(toolCall) {
|
|
29706
|
+
const rawOutput = typeof toolCall.rawOutput === "string" ? toolCall.rawOutput.trim() : toolCall.rawOutput != null ? JSON.stringify(toolCall.rawOutput) : "";
|
|
29707
|
+
if (rawOutput) return rawOutput;
|
|
29708
|
+
const contentText = Array.isArray(toolCall.content) ? toolCall.content.map((entry) => {
|
|
29709
|
+
if (!entry || typeof entry !== "object") return "";
|
|
29710
|
+
if (entry.type === "content") return flattenContent([entry.content]).trim();
|
|
29711
|
+
if (entry.type === "diff") return `${entry.path}
|
|
29712
|
+
${entry.newText || ""}`.trim();
|
|
29713
|
+
if (entry.type === "terminal") return `Terminal: ${entry.terminalId || ""}`.trim();
|
|
29714
|
+
return "";
|
|
29715
|
+
}).filter(Boolean).join("\n\n").trim() : "";
|
|
29716
|
+
if (contentText) return contentText;
|
|
29717
|
+
const rawInput = typeof toolCall.rawInput === "string" ? toolCall.rawInput.trim() : toolCall.rawInput != null ? JSON.stringify(toolCall.rawInput) : "";
|
|
29718
|
+
if (rawInput) {
|
|
29719
|
+
return toolCall.title ? `${toolCall.title}
|
|
29720
|
+
${rawInput}` : rawInput;
|
|
29721
|
+
}
|
|
29722
|
+
return toolCall.title || "";
|
|
29723
|
+
}
|
|
29724
|
+
buildTurnToolCallMessages(timestamp = Date.now()) {
|
|
29725
|
+
return this.turnToolCalls.map((toolCall) => {
|
|
29726
|
+
const content = this.summarizeToolCallBubbleContent(toolCall);
|
|
29727
|
+
if (!content) return null;
|
|
29728
|
+
const isRunning = toolCall.status === "pending" || toolCall.status === "in_progress";
|
|
29729
|
+
const label = toolCall.title || void 0;
|
|
29730
|
+
const kind = this.buildToolCallBubbleKind(toolCall);
|
|
29731
|
+
if (kind === "thought") {
|
|
29732
|
+
return buildThoughtChatMessage({
|
|
29733
|
+
content,
|
|
29734
|
+
timestamp,
|
|
29735
|
+
meta: { label: label || "Thought", isRunning }
|
|
29736
|
+
});
|
|
29737
|
+
}
|
|
29738
|
+
if (kind === "terminal") {
|
|
29739
|
+
return buildTerminalChatMessage({
|
|
29740
|
+
content,
|
|
29741
|
+
timestamp,
|
|
29742
|
+
meta: { label: label || "Ran command", isRunning }
|
|
29743
|
+
});
|
|
29744
|
+
}
|
|
29745
|
+
return buildToolChatMessage({
|
|
29746
|
+
content,
|
|
29747
|
+
timestamp,
|
|
29748
|
+
meta: { label: label || "Tool call", isRunning }
|
|
29749
|
+
});
|
|
29750
|
+
}).filter(Boolean);
|
|
29751
|
+
}
|
|
29512
29752
|
/** Finalize streaming content into an assistant message */
|
|
29513
29753
|
finalizeAssistantMessage() {
|
|
29754
|
+
const timestamp = Date.now();
|
|
29755
|
+
const thoughtMessage = this.buildPartialThoughtMessage(timestamp);
|
|
29756
|
+
if (thoughtMessage) {
|
|
29757
|
+
this.messages.push(thoughtMessage);
|
|
29758
|
+
}
|
|
29759
|
+
const toolCallMessages = this.buildTurnToolCallMessages(timestamp);
|
|
29760
|
+
if (toolCallMessages.length > 0) {
|
|
29761
|
+
this.messages.push(...toolCallMessages);
|
|
29762
|
+
}
|
|
29514
29763
|
const blocks = this.buildPartialBlocks();
|
|
29515
29764
|
const finalBlocks = blocks.map((b) => {
|
|
29516
29765
|
if (b.type === "text" && b.text.endsWith("...")) {
|
|
@@ -29526,6 +29775,7 @@ var init_acp_provider_instance = __esm({
|
|
|
29526
29775
|
}));
|
|
29527
29776
|
}
|
|
29528
29777
|
this.partialContent = "";
|
|
29778
|
+
this.partialThoughtContent = "";
|
|
29529
29779
|
this.partialBlocks = [];
|
|
29530
29780
|
this.turnToolCalls = [];
|
|
29531
29781
|
}
|
|
@@ -34164,6 +34414,9 @@ function parseMessageTime(value) {
|
|
|
34164
34414
|
}
|
|
34165
34415
|
return 0;
|
|
34166
34416
|
}
|
|
34417
|
+
function getMessageEventTime(message) {
|
|
34418
|
+
return parseMessageTime(message?.receivedAt) || parseMessageTime(message?.timestamp) || 0;
|
|
34419
|
+
}
|
|
34167
34420
|
function stringifyPreviewContent(content) {
|
|
34168
34421
|
if (typeof content === "string") return content;
|
|
34169
34422
|
if (Array.isArray(content)) {
|
|
@@ -34208,7 +34461,7 @@ function getLastDisplayMessage(session) {
|
|
|
34208
34461
|
return {
|
|
34209
34462
|
role,
|
|
34210
34463
|
preview,
|
|
34211
|
-
receivedAt:
|
|
34464
|
+
receivedAt: getMessageEventTime(candidate),
|
|
34212
34465
|
hash: simplePreviewHash(`${role}:${preview}`)
|
|
34213
34466
|
};
|
|
34214
34467
|
}
|
|
@@ -34217,7 +34470,7 @@ function getLastDisplayMessage(session) {
|
|
|
34217
34470
|
function getSessionMessageUpdatedAt(session) {
|
|
34218
34471
|
const lastMessage = session.activeChat?.messages?.at?.(-1);
|
|
34219
34472
|
if (!lastMessage) return 0;
|
|
34220
|
-
return
|
|
34473
|
+
return getMessageEventTime(lastMessage);
|
|
34221
34474
|
}
|
|
34222
34475
|
function getSessionCompletionMarker(session) {
|
|
34223
34476
|
const lastMessage = session.activeChat?.messages?.at?.(-1);
|
|
@@ -34227,7 +34480,7 @@ function getSessionCompletionMarker(session) {
|
|
|
34227
34480
|
if (typeof lastMessage._turnKey === "string" && lastMessage._turnKey) return `turn:${lastMessage._turnKey}`;
|
|
34228
34481
|
if (typeof lastMessage.id === "string" && lastMessage.id) return `id:${lastMessage.id}`;
|
|
34229
34482
|
if (typeof lastMessage.index === "number" && Number.isFinite(lastMessage.index)) return `idx:${lastMessage.index}`;
|
|
34230
|
-
const timestamp =
|
|
34483
|
+
const timestamp = getMessageEventTime(lastMessage);
|
|
34231
34484
|
return timestamp > 0 ? `ts:${timestamp}` : "";
|
|
34232
34485
|
}
|
|
34233
34486
|
function getSessionLastUsedAt(session) {
|
|
@@ -35560,6 +35813,7 @@ var init_provider_adapter = __esm({
|
|
|
35560
35813
|
"use strict";
|
|
35561
35814
|
init_control_effects();
|
|
35562
35815
|
init_provider_patch_state();
|
|
35816
|
+
init_chat_message_normalization();
|
|
35563
35817
|
ProviderStreamAdapter = class {
|
|
35564
35818
|
agentType;
|
|
35565
35819
|
agentName;
|
|
@@ -35669,7 +35923,7 @@ var init_provider_adapter = __esm({
|
|
|
35669
35923
|
agentName: this.agentName,
|
|
35670
35924
|
extensionId: this.extensionId,
|
|
35671
35925
|
status: data.status || "idle",
|
|
35672
|
-
messages: data.messages
|
|
35926
|
+
messages: normalizeChatMessages(Array.isArray(data.messages) ? data.messages : []),
|
|
35673
35927
|
inputContent: data.inputContent || "",
|
|
35674
35928
|
activeModal: data.activeModal
|
|
35675
35929
|
};
|
|
@@ -42940,6 +43194,8 @@ __export(src_exports, {
|
|
|
42940
43194
|
CdpDomHandlers: () => CdpDomHandlers,
|
|
42941
43195
|
CliProviderInstance: () => CliProviderInstance,
|
|
42942
43196
|
DAEMON_WS_PATH: () => DAEMON_WS_PATH,
|
|
43197
|
+
DEFAULT_ACTIVE_CHAT_POLL_STATUSES: () => DEFAULT_ACTIVE_CHAT_POLL_STATUSES,
|
|
43198
|
+
DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS: () => DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS,
|
|
42943
43199
|
DEFAULT_DAEMON_PORT: () => DEFAULT_DAEMON_PORT,
|
|
42944
43200
|
DEFAULT_SESSION_HOST_APP_NAME: () => DEFAULT_SESSION_HOST_APP_NAME,
|
|
42945
43201
|
DEFAULT_STANDALONE_SESSION_HOST_APP_NAME: () => DEFAULT_STANDALONE_SESSION_HOST_APP_NAME,
|
|
@@ -42968,7 +43224,11 @@ __export(src_exports, {
|
|
|
42968
43224
|
buildSessionEntries: () => buildSessionEntries,
|
|
42969
43225
|
buildStatusSnapshot: () => buildStatusSnapshot,
|
|
42970
43226
|
buildSystemChatMessage: () => buildSystemChatMessage,
|
|
43227
|
+
buildTerminalChatMessage: () => buildTerminalChatMessage,
|
|
43228
|
+
buildThoughtChatMessage: () => buildThoughtChatMessage,
|
|
43229
|
+
buildToolChatMessage: () => buildToolChatMessage,
|
|
42971
43230
|
buildUserChatMessage: () => buildUserChatMessage,
|
|
43231
|
+
classifyHotChatSessionsForSubscriptionFlush: () => classifyHotChatSessionsForSubscriptionFlush,
|
|
42972
43232
|
clearDebugTrace: () => clearDebugTrace,
|
|
42973
43233
|
configureDebugTraceStore: () => configureDebugTraceStore,
|
|
42974
43234
|
connectCdpManager: () => connectCdpManager,
|
|
@@ -43035,6 +43295,7 @@ __export(src_exports, {
|
|
|
43035
43295
|
resetConfig: () => resetConfig,
|
|
43036
43296
|
resetDebugRuntimeConfig: () => resetDebugRuntimeConfig,
|
|
43037
43297
|
resetState: () => resetState,
|
|
43298
|
+
resolveChatMessageKind: () => resolveChatMessageKind,
|
|
43038
43299
|
resolveDebugRuntimeConfig: () => resolveDebugRuntimeConfig,
|
|
43039
43300
|
resolveSessionHostAppName: () => resolveSessionHostAppName,
|
|
43040
43301
|
saveConfig: () => saveConfig,
|
|
@@ -43061,6 +43322,7 @@ var init_src = __esm({
|
|
|
43061
43322
|
init_ide_detector();
|
|
43062
43323
|
init_cli_detector();
|
|
43063
43324
|
init_host_memory();
|
|
43325
|
+
init_chat_tail_hot_sessions();
|
|
43064
43326
|
init_manager();
|
|
43065
43327
|
init_devtools();
|
|
43066
43328
|
init_setup();
|
|
@@ -52380,7 +52642,7 @@ function stopDaemon(ref = {}) {
|
|
|
52380
52642
|
return false;
|
|
52381
52643
|
}
|
|
52382
52644
|
}
|
|
52383
|
-
var os26, fs18, path27, import_http, import_ws3, pkgVersion,
|
|
52645
|
+
var os26, fs18, path27, import_http, import_ws3, pkgVersion, AdhdevDaemon;
|
|
52384
52646
|
var init_adhdev_daemon = __esm({
|
|
52385
52647
|
"src/adhdev-daemon.ts"() {
|
|
52386
52648
|
"use strict";
|
|
@@ -52399,12 +52661,8 @@ var init_adhdev_daemon = __esm({
|
|
|
52399
52661
|
import_ws3 = require("ws");
|
|
52400
52662
|
init_source2();
|
|
52401
52663
|
init_version();
|
|
52402
|
-
|
|
52403
|
-
|
|
52404
|
-
"generating",
|
|
52405
|
-
"waiting_approval",
|
|
52406
|
-
"starting"
|
|
52407
|
-
]);
|
|
52664
|
+
init_src();
|
|
52665
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.65" });
|
|
52408
52666
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
52409
52667
|
localHttpServer = null;
|
|
52410
52668
|
localWss = null;
|
|
@@ -52631,14 +52889,12 @@ var init_adhdev_daemon = __esm({
|
|
|
52631
52889
|
}
|
|
52632
52890
|
getHotChatSessionIdsForP2PFlush() {
|
|
52633
52891
|
const snapshot = this.buildLiveStatusSnapshot();
|
|
52634
|
-
const
|
|
52635
|
-
snapshot.sessions
|
|
52636
|
-
|
|
52637
|
-
const finalizing = new Set(
|
|
52638
|
-
Array.from(this.hotP2PChatSessionIds).filter((sessionId) => !active.has(sessionId))
|
|
52892
|
+
const hotSessions = classifyHotChatSessionsForSubscriptionFlush(
|
|
52893
|
+
snapshot.sessions,
|
|
52894
|
+
this.hotP2PChatSessionIds
|
|
52639
52895
|
);
|
|
52640
|
-
this.hotP2PChatSessionIds = active;
|
|
52641
|
-
return
|
|
52896
|
+
this.hotP2PChatSessionIds = hotSessions.active;
|
|
52897
|
+
return hotSessions;
|
|
52642
52898
|
}
|
|
52643
52899
|
async flushP2PChatSubscriptions(options = {}) {
|
|
52644
52900
|
if (!this.p2p?.isConnected || !this.p2p.hasChatSubscriptions()) return;
|