@adhdev/daemon-core 0.8.82 → 0.8.84
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-adapters/provider-cli-adapter.d.ts +1 -0
- package/dist/config/chat-history.d.ts +1 -0
- package/dist/index.js +176 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +176 -79
- package/dist/index.mjs.map +1 -1
- package/dist/providers/cli-provider-instance.d.ts +10 -0
- package/dist/shared-types.d.ts +2 -0
- package/dist/status/chat-tail-hot-sessions.d.ts +2 -0
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +94 -26
- package/src/cli-adapters/terminal-screen.ts +6 -4
- package/src/config/chat-history.ts +137 -0
- package/src/providers/cli-provider-instance.ts +66 -2
- package/src/shared-types.d.ts +3 -0
- package/src/shared-types.ts +2 -0
- package/src/status/chat-tail-hot-sessions.ts +15 -1
- package/src/status/snapshot.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -951,6 +951,58 @@ var init_read_chat_contract = __esm({
|
|
|
951
951
|
}
|
|
952
952
|
});
|
|
953
953
|
|
|
954
|
+
// src/logging/debug-config.ts
|
|
955
|
+
function normalizeCategories(categories) {
|
|
956
|
+
if (!Array.isArray(categories)) return [];
|
|
957
|
+
return categories.map((category) => String(category || "").trim()).filter(Boolean);
|
|
958
|
+
}
|
|
959
|
+
function resolveDebugRuntimeConfig(options = {}) {
|
|
960
|
+
const dev = options.dev === true;
|
|
961
|
+
return {
|
|
962
|
+
logLevel: options.logLevel || (dev ? "debug" : DEFAULT_CONFIG2.logLevel),
|
|
963
|
+
collectDebugTrace: typeof options.trace === "boolean" ? options.trace : dev,
|
|
964
|
+
traceContent: options.traceContent === true,
|
|
965
|
+
traceBufferSize: Number.isFinite(options.traceBufferSize) ? Math.max(10, Math.floor(options.traceBufferSize)) : dev ? DEV_TRACE_BUFFER_SIZE : DEFAULT_CONFIG2.traceBufferSize,
|
|
966
|
+
traceCategories: normalizeCategories(options.traceCategories)
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
function setDebugRuntimeConfig(config) {
|
|
970
|
+
currentConfig = {
|
|
971
|
+
...config,
|
|
972
|
+
traceCategories: normalizeCategories(config.traceCategories),
|
|
973
|
+
traceBufferSize: Math.max(10, Math.floor(config.traceBufferSize || DEFAULT_CONFIG2.traceBufferSize))
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
function getDebugRuntimeConfig() {
|
|
977
|
+
return { ...currentConfig, traceCategories: [...currentConfig.traceCategories] };
|
|
978
|
+
}
|
|
979
|
+
function resetDebugRuntimeConfig() {
|
|
980
|
+
currentConfig = { ...DEFAULT_CONFIG2 };
|
|
981
|
+
}
|
|
982
|
+
function shouldCollectTraceCategory(category) {
|
|
983
|
+
const config = currentConfig;
|
|
984
|
+
if (!config.collectDebugTrace) return false;
|
|
985
|
+
if (!category) return true;
|
|
986
|
+
if (config.traceCategories.length === 0) return true;
|
|
987
|
+
return config.traceCategories.includes(category);
|
|
988
|
+
}
|
|
989
|
+
var NORMAL_TRACE_BUFFER_SIZE, DEV_TRACE_BUFFER_SIZE, DEFAULT_CONFIG2, currentConfig;
|
|
990
|
+
var init_debug_config = __esm({
|
|
991
|
+
"src/logging/debug-config.ts"() {
|
|
992
|
+
"use strict";
|
|
993
|
+
NORMAL_TRACE_BUFFER_SIZE = 200;
|
|
994
|
+
DEV_TRACE_BUFFER_SIZE = 1e3;
|
|
995
|
+
DEFAULT_CONFIG2 = {
|
|
996
|
+
logLevel: "info",
|
|
997
|
+
collectDebugTrace: false,
|
|
998
|
+
traceContent: false,
|
|
999
|
+
traceBufferSize: NORMAL_TRACE_BUFFER_SIZE,
|
|
1000
|
+
traceCategories: []
|
|
1001
|
+
};
|
|
1002
|
+
currentConfig = { ...DEFAULT_CONFIG2 };
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
|
|
954
1006
|
// src/cli-adapters/terminal-backends/ghostty-vt-backend.ts
|
|
955
1007
|
function isModuleNotFoundError(error, ref) {
|
|
956
1008
|
if (!(error instanceof Error)) return false;
|
|
@@ -1149,10 +1201,12 @@ function logTerminalBackendSelection(preference, ghosttyAvailable, backendKind)
|
|
|
1149
1201
|
if (loggedTerminalBackends.has(key)) return;
|
|
1150
1202
|
loggedTerminalBackends.add(key);
|
|
1151
1203
|
if (backendKind === "xterm" && preference !== "xterm" && !ghosttyAvailable) {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1204
|
+
const message = `[terminal-screen] ghostty-vt unavailable; using xterm fallback (preference=${preference})`;
|
|
1205
|
+
if (preference === "auto") {
|
|
1206
|
+
LOG.info("Terminal", message);
|
|
1207
|
+
} else {
|
|
1208
|
+
LOG.warn("Terminal", message);
|
|
1209
|
+
}
|
|
1156
1210
|
return;
|
|
1157
1211
|
}
|
|
1158
1212
|
LOG.info(
|
|
@@ -1806,6 +1860,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
1806
1860
|
"src/cli-adapters/provider-cli-adapter.ts"() {
|
|
1807
1861
|
"use strict";
|
|
1808
1862
|
init_logger();
|
|
1863
|
+
init_debug_config();
|
|
1809
1864
|
init_terminal_screen();
|
|
1810
1865
|
init_pty_transport();
|
|
1811
1866
|
init_provider_cli_shared();
|
|
@@ -1839,7 +1894,15 @@ var init_provider_cli_adapter = __esm({
|
|
|
1839
1894
|
`[${this.cliType}] Provider resolution: providerDir=${this.providerResolutionMeta.providerDir || "-"} scriptDir=${this.providerResolutionMeta.scriptDir || "-"} scriptsPath=${this.providerResolutionMeta.scriptsPath || "-"} source=${this.providerResolutionMeta.scriptsSource || "-"} version=${this.providerResolutionMeta.resolvedVersion || "-"}`
|
|
1840
1895
|
);
|
|
1841
1896
|
} else {
|
|
1842
|
-
|
|
1897
|
+
const resolutionSummary = `providerDir=${this.providerResolutionMeta.providerDir || "-"} scriptDir=${this.providerResolutionMeta.scriptDir || "-"} scriptsPath=${this.providerResolutionMeta.scriptsPath || "-"} source=${this.providerResolutionMeta.scriptsSource || "-"} version=${this.providerResolutionMeta.resolvedVersion || "-"}`;
|
|
1898
|
+
const hasResolvedProviderScripts = Boolean(
|
|
1899
|
+
this.providerResolutionMeta.providerDir || this.providerResolutionMeta.scriptDir || this.providerResolutionMeta.scriptsPath || this.providerResolutionMeta.scriptsSource || this.providerResolutionMeta.resolvedVersion
|
|
1900
|
+
);
|
|
1901
|
+
if (hasResolvedProviderScripts) {
|
|
1902
|
+
LOG.warn("CLI", `[${this.cliType}] \u26A0 No CLI scripts loaded! Provider needs scripts/{version}/scripts.js (${resolutionSummary})`);
|
|
1903
|
+
} else {
|
|
1904
|
+
LOG.info("CLI", `[${this.cliType}] CLI scripts not yet resolved (${resolutionSummary})`);
|
|
1905
|
+
}
|
|
1843
1906
|
}
|
|
1844
1907
|
}
|
|
1845
1908
|
cliType;
|
|
@@ -1918,7 +1981,8 @@ var init_provider_cli_adapter = __esm({
|
|
|
1918
1981
|
currentTurnScope = null;
|
|
1919
1982
|
traceEntries = [];
|
|
1920
1983
|
traceSeq = 0;
|
|
1921
|
-
traceSessionId =
|
|
1984
|
+
traceSessionId = "";
|
|
1985
|
+
parsedStatusCache = null;
|
|
1922
1986
|
static MAX_TRACE_ENTRIES = 250;
|
|
1923
1987
|
providerResolutionMeta;
|
|
1924
1988
|
static FINISH_RETRY_DELAY_MS = 300;
|
|
@@ -2159,7 +2223,8 @@ var init_provider_cli_adapter = __esm({
|
|
|
2159
2223
|
this.terminalScreen.write(rawData);
|
|
2160
2224
|
const cleanData = sanitizeTerminalText(rawData);
|
|
2161
2225
|
const now = Date.now();
|
|
2162
|
-
const
|
|
2226
|
+
const screenText = this.terminalScreen.getText();
|
|
2227
|
+
const normalizedScreenSnapshot = normalizeScreenSnapshot(screenText);
|
|
2163
2228
|
this.lastOutputAt = now;
|
|
2164
2229
|
if (cleanData.trim()) this.lastNonEmptyOutputAt = now;
|
|
2165
2230
|
if (normalizedScreenSnapshot !== this.lastScreenSnapshot) {
|
|
@@ -2172,13 +2237,14 @@ var init_provider_cli_adapter = __esm({
|
|
|
2172
2237
|
if (this.idleFinishCandidate && (rawData.length > 0 || cleanData.length > 0)) {
|
|
2173
2238
|
this.clearIdleFinishCandidate("new_output");
|
|
2174
2239
|
}
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2240
|
+
if (getDebugRuntimeConfig().collectDebugTrace) {
|
|
2241
|
+
this.recordTrace("output", {
|
|
2242
|
+
rawLength: rawData.length,
|
|
2243
|
+
cleanLength: cleanData.length,
|
|
2244
|
+
rawPreview: summarizeCliTraceText(rawData, 300),
|
|
2245
|
+
cleanPreview: summarizeCliTraceText(cleanData, 300)
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2182
2248
|
if (this.startupParseGate) {
|
|
2183
2249
|
this.scheduleStartupSettleCheck();
|
|
2184
2250
|
}
|
|
@@ -2880,12 +2946,19 @@ var init_provider_cli_adapter = __esm({
|
|
|
2880
2946
|
* Called by command handler / dashboard for rich content rendering.
|
|
2881
2947
|
*/
|
|
2882
2948
|
getScriptParsedStatus() {
|
|
2949
|
+
const screenText = this.terminalScreen.getText();
|
|
2950
|
+
const cached = this.parsedStatusCache;
|
|
2951
|
+
if (cached && cached.committedMessagesRef === this.committedMessages && cached.responseBuffer === this.responseBuffer && cached.currentTurnScope === this.currentTurnScope && cached.recentOutputBuffer === this.recentOutputBuffer && cached.accumulatedBuffer === this.accumulatedBuffer && cached.accumulatedRawBuffer === this.accumulatedRawBuffer && cached.screenText === screenText && cached.currentStatus === this.currentStatus && cached.activeModal === this.activeModal && cached.cliName === this.cliName && cached.lastOutputAt === this.lastOutputAt) {
|
|
2952
|
+
return cached.result;
|
|
2953
|
+
}
|
|
2883
2954
|
const parsed = this.parseCurrentTranscript(
|
|
2884
2955
|
this.committedMessages,
|
|
2885
2956
|
this.responseBuffer,
|
|
2886
|
-
this.currentTurnScope
|
|
2957
|
+
this.currentTurnScope,
|
|
2958
|
+
screenText
|
|
2887
2959
|
);
|
|
2888
2960
|
const shouldPreferCommittedMessages = !this.currentTurnScope && this.currentStatus === "idle" && !this.activeModal;
|
|
2961
|
+
let result;
|
|
2889
2962
|
if (parsed && Array.isArray(parsed.messages)) {
|
|
2890
2963
|
const hydratedMessages = shouldPreferCommittedMessages ? this.committedMessages.map((message, index) => buildChatMessage({
|
|
2891
2964
|
...message,
|
|
@@ -2897,7 +2970,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
2897
2970
|
scope: this.currentTurnScope,
|
|
2898
2971
|
lastOutputAt: this.lastOutputAt
|
|
2899
2972
|
});
|
|
2900
|
-
|
|
2973
|
+
result = {
|
|
2901
2974
|
id: parsed.id || "cli_session",
|
|
2902
2975
|
status: parsed.status || this.currentStatus,
|
|
2903
2976
|
title: parsed.title || this.cliName,
|
|
@@ -2905,20 +2978,36 @@ var init_provider_cli_adapter = __esm({
|
|
|
2905
2978
|
activeModal: parsed.activeModal ?? this.activeModal,
|
|
2906
2979
|
providerSessionId: typeof parsed.providerSessionId === "string" ? parsed.providerSessionId : void 0
|
|
2907
2980
|
};
|
|
2981
|
+
} else {
|
|
2982
|
+
const messages = [...this.committedMessages];
|
|
2983
|
+
result = {
|
|
2984
|
+
id: "cli_session",
|
|
2985
|
+
status: this.currentStatus,
|
|
2986
|
+
title: this.cliName,
|
|
2987
|
+
messages: messages.map((message, index) => buildChatMessage({
|
|
2988
|
+
...message,
|
|
2989
|
+
id: message.id || `msg_${index}`,
|
|
2990
|
+
index: typeof message.index === "number" ? message.index : index,
|
|
2991
|
+
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
2992
|
+
})),
|
|
2993
|
+
activeModal: this.activeModal
|
|
2994
|
+
};
|
|
2908
2995
|
}
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2996
|
+
this.parsedStatusCache = {
|
|
2997
|
+
committedMessagesRef: this.committedMessages,
|
|
2998
|
+
responseBuffer: this.responseBuffer,
|
|
2999
|
+
currentTurnScope: this.currentTurnScope,
|
|
3000
|
+
recentOutputBuffer: this.recentOutputBuffer,
|
|
3001
|
+
accumulatedBuffer: this.accumulatedBuffer,
|
|
3002
|
+
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
3003
|
+
screenText,
|
|
3004
|
+
currentStatus: this.currentStatus,
|
|
3005
|
+
activeModal: this.activeModal,
|
|
3006
|
+
cliName: this.cliName,
|
|
3007
|
+
lastOutputAt: this.lastOutputAt,
|
|
3008
|
+
result
|
|
2921
3009
|
};
|
|
3010
|
+
return result;
|
|
2922
3011
|
}
|
|
2923
3012
|
async invokeScript(scriptName, args) {
|
|
2924
3013
|
const fn = this.cliScripts?.[scriptName];
|
|
@@ -2941,17 +3030,18 @@ var init_provider_cli_adapter = __esm({
|
|
|
2941
3030
|
args: args && typeof args === "object" ? { ...args } : {}
|
|
2942
3031
|
}));
|
|
2943
3032
|
}
|
|
2944
|
-
parseCurrentTranscript(baseMessages, partialResponse, scope) {
|
|
3033
|
+
parseCurrentTranscript(baseMessages, partialResponse, scope, screenTextOverride) {
|
|
2945
3034
|
if (!this.cliScripts?.parseOutput) {
|
|
2946
3035
|
this.parseErrorMessage = null;
|
|
2947
3036
|
return null;
|
|
2948
3037
|
}
|
|
2949
3038
|
try {
|
|
3039
|
+
const screenText = typeof screenTextOverride === "string" ? screenTextOverride : this.terminalScreen.getText();
|
|
2950
3040
|
const input = buildCliParseInput({
|
|
2951
3041
|
accumulatedBuffer: this.accumulatedBuffer,
|
|
2952
3042
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
2953
3043
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
2954
|
-
terminalScreenText:
|
|
3044
|
+
terminalScreenText: screenText,
|
|
2955
3045
|
baseMessages,
|
|
2956
3046
|
partialResponse,
|
|
2957
3047
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
@@ -4491,9 +4581,15 @@ function classifyHotChatSessionsForSubscriptionFlush(sessions, previousHotSessio
|
|
|
4491
4581
|
continue;
|
|
4492
4582
|
}
|
|
4493
4583
|
const status = String(session?.status || "").toLowerCase();
|
|
4584
|
+
const unread = session?.unread === true;
|
|
4585
|
+
const inboxBucket = String(session?.inboxBucket || "").toLowerCase();
|
|
4586
|
+
const runtimeSurfaceKind = String(session?.runtimeSurfaceKind || "").toLowerCase();
|
|
4587
|
+
const runtimeLifecycle = String(session?.runtimeLifecycle || "").toLowerCase();
|
|
4588
|
+
const isLiveRuntime = runtimeSurfaceKind === "live_runtime" || LIVE_RUNTIME_LIFECYCLES.has(runtimeLifecycle);
|
|
4494
4589
|
const lastMessageAt = parseMessageTimestamp(session?.lastMessageAt);
|
|
4495
4590
|
const recentlyUpdated = lastMessageAt > 0 && now - lastMessageAt <= recentMessageGraceMs;
|
|
4496
|
-
|
|
4591
|
+
const shouldKeepRecentTailHot = recentlyUpdated && (unread || inboxBucket === "task_complete" || inboxBucket === "needs_attention" || isLiveRuntime || activeStatuses.has(status));
|
|
4592
|
+
if (activeStatuses.has(status) || shouldKeepRecentTailHot) {
|
|
4497
4593
|
active.add(sessionId);
|
|
4498
4594
|
}
|
|
4499
4595
|
}
|
|
@@ -9125,53 +9221,8 @@ function assertProviderSupportsDeclaredInput(provider, input) {
|
|
|
9125
9221
|
init_read_chat_contract();
|
|
9126
9222
|
init_logger();
|
|
9127
9223
|
|
|
9128
|
-
// src/logging/debug-config.ts
|
|
9129
|
-
var NORMAL_TRACE_BUFFER_SIZE = 200;
|
|
9130
|
-
var DEV_TRACE_BUFFER_SIZE = 1e3;
|
|
9131
|
-
var DEFAULT_CONFIG2 = {
|
|
9132
|
-
logLevel: "info",
|
|
9133
|
-
collectDebugTrace: false,
|
|
9134
|
-
traceContent: false,
|
|
9135
|
-
traceBufferSize: NORMAL_TRACE_BUFFER_SIZE,
|
|
9136
|
-
traceCategories: []
|
|
9137
|
-
};
|
|
9138
|
-
var currentConfig = { ...DEFAULT_CONFIG2 };
|
|
9139
|
-
function normalizeCategories(categories) {
|
|
9140
|
-
if (!Array.isArray(categories)) return [];
|
|
9141
|
-
return categories.map((category) => String(category || "").trim()).filter(Boolean);
|
|
9142
|
-
}
|
|
9143
|
-
function resolveDebugRuntimeConfig(options = {}) {
|
|
9144
|
-
const dev = options.dev === true;
|
|
9145
|
-
return {
|
|
9146
|
-
logLevel: options.logLevel || (dev ? "debug" : DEFAULT_CONFIG2.logLevel),
|
|
9147
|
-
collectDebugTrace: typeof options.trace === "boolean" ? options.trace : dev,
|
|
9148
|
-
traceContent: options.traceContent === true,
|
|
9149
|
-
traceBufferSize: Number.isFinite(options.traceBufferSize) ? Math.max(10, Math.floor(options.traceBufferSize)) : dev ? DEV_TRACE_BUFFER_SIZE : DEFAULT_CONFIG2.traceBufferSize,
|
|
9150
|
-
traceCategories: normalizeCategories(options.traceCategories)
|
|
9151
|
-
};
|
|
9152
|
-
}
|
|
9153
|
-
function setDebugRuntimeConfig(config) {
|
|
9154
|
-
currentConfig = {
|
|
9155
|
-
...config,
|
|
9156
|
-
traceCategories: normalizeCategories(config.traceCategories),
|
|
9157
|
-
traceBufferSize: Math.max(10, Math.floor(config.traceBufferSize || DEFAULT_CONFIG2.traceBufferSize))
|
|
9158
|
-
};
|
|
9159
|
-
}
|
|
9160
|
-
function getDebugRuntimeConfig() {
|
|
9161
|
-
return { ...currentConfig, traceCategories: [...currentConfig.traceCategories] };
|
|
9162
|
-
}
|
|
9163
|
-
function resetDebugRuntimeConfig() {
|
|
9164
|
-
currentConfig = { ...DEFAULT_CONFIG2 };
|
|
9165
|
-
}
|
|
9166
|
-
function shouldCollectTraceCategory(category) {
|
|
9167
|
-
const config = currentConfig;
|
|
9168
|
-
if (!config.collectDebugTrace) return false;
|
|
9169
|
-
if (!category) return true;
|
|
9170
|
-
if (config.traceCategories.length === 0) return true;
|
|
9171
|
-
return config.traceCategories.includes(category);
|
|
9172
|
-
}
|
|
9173
|
-
|
|
9174
9224
|
// src/logging/debug-trace.ts
|
|
9225
|
+
init_debug_config();
|
|
9175
9226
|
function summarizeString(value) {
|
|
9176
9227
|
return `[${value.length} chars]`;
|
|
9177
9228
|
}
|
|
@@ -11933,6 +11984,30 @@ import { createRequire } from "module";
|
|
|
11933
11984
|
init_provider_cli_adapter();
|
|
11934
11985
|
init_logger();
|
|
11935
11986
|
init_chat_message_normalization();
|
|
11987
|
+
function normalizePersistableCliHistoryContent(content) {
|
|
11988
|
+
return flattenContent(content).replace(/\s+/g, " ").trim();
|
|
11989
|
+
}
|
|
11990
|
+
function buildPersistableCliHistorySignature(message) {
|
|
11991
|
+
return [
|
|
11992
|
+
String(message.role || ""),
|
|
11993
|
+
String(message.kind || ""),
|
|
11994
|
+
String(message.senderName || ""),
|
|
11995
|
+
normalizePersistableCliHistoryContent(message.content)
|
|
11996
|
+
].join("|");
|
|
11997
|
+
}
|
|
11998
|
+
function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages) {
|
|
11999
|
+
if (!Array.isArray(currentMessages) || currentMessages.length === 0) return [];
|
|
12000
|
+
if (!Array.isArray(previousMessages) || previousMessages.length === 0) return currentMessages;
|
|
12001
|
+
const previousSignatures = previousMessages.map(buildPersistableCliHistorySignature);
|
|
12002
|
+
const currentSignatures = currentMessages.map(buildPersistableCliHistorySignature);
|
|
12003
|
+
let sharedPrefixLength = 0;
|
|
12004
|
+
while (sharedPrefixLength < previousSignatures.length && sharedPrefixLength < currentSignatures.length && previousSignatures[sharedPrefixLength] === currentSignatures[sharedPrefixLength]) {
|
|
12005
|
+
sharedPrefixLength += 1;
|
|
12006
|
+
}
|
|
12007
|
+
if (sharedPrefixLength === currentSignatures.length) return [];
|
|
12008
|
+
if (sharedPrefixLength === previousSignatures.length) return currentMessages.slice(sharedPrefixLength);
|
|
12009
|
+
return currentMessages;
|
|
12010
|
+
}
|
|
11936
12011
|
var CachedDatabaseSync = null;
|
|
11937
12012
|
function getDatabaseSync() {
|
|
11938
12013
|
if (CachedDatabaseSync) return CachedDatabaseSync;
|
|
@@ -12010,6 +12085,7 @@ var CliProviderInstance = class {
|
|
|
12010
12085
|
appliedEffectKeys = /* @__PURE__ */ new Set();
|
|
12011
12086
|
historyWriter;
|
|
12012
12087
|
runtimeMessages = [];
|
|
12088
|
+
lastPersistedHistoryMessages = [];
|
|
12013
12089
|
instanceId;
|
|
12014
12090
|
suppressIdleHistoryReplay = false;
|
|
12015
12091
|
errorMessage = void 0;
|
|
@@ -12050,6 +12126,13 @@ var CliProviderInstance = class {
|
|
|
12050
12126
|
this.providerSessionId,
|
|
12051
12127
|
this.instanceId
|
|
12052
12128
|
);
|
|
12129
|
+
this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
|
|
12130
|
+
role: message.role,
|
|
12131
|
+
content: message.content,
|
|
12132
|
+
kind: message.kind,
|
|
12133
|
+
senderName: message.senderName,
|
|
12134
|
+
receivedAt: message.receivedAt
|
|
12135
|
+
}));
|
|
12053
12136
|
this.suppressIdleHistoryReplay = restoredHistory.messages.length > 0;
|
|
12054
12137
|
if (restoredHistory.messages.length > 0) {
|
|
12055
12138
|
this.adapter.seedCommittedMessages(
|
|
@@ -12080,6 +12163,7 @@ var CliProviderInstance = class {
|
|
|
12080
12163
|
}
|
|
12081
12164
|
async onTick() {
|
|
12082
12165
|
if (this.providerSessionId) return;
|
|
12166
|
+
if (this.type === "hermes-cli" && this.launchMode === "new") return;
|
|
12083
12167
|
let probedSessionId = null;
|
|
12084
12168
|
const probeConfig = this.provider.sessionProbe;
|
|
12085
12169
|
if (probeConfig) {
|
|
@@ -12180,15 +12264,24 @@ var CliProviderInstance = class {
|
|
|
12180
12264
|
messagesToSave = messagesToSave.slice(0, lastIdx);
|
|
12181
12265
|
}
|
|
12182
12266
|
}
|
|
12183
|
-
|
|
12267
|
+
const normalizedMessagesToSave = messagesToSave.map((message) => ({
|
|
12268
|
+
role: message.role,
|
|
12269
|
+
content: flattenContent(message.content),
|
|
12270
|
+
kind: typeof message.kind === "string" ? message.kind : void 0,
|
|
12271
|
+
senderName: typeof message.senderName === "string" ? message.senderName : void 0,
|
|
12272
|
+
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
12273
|
+
}));
|
|
12274
|
+
if (!shouldSkipReplayPersist && normalizedMessagesToSave.length > 0) {
|
|
12275
|
+
const incrementalMessages = buildIncrementalHistoryAppendMessages(this.lastPersistedHistoryMessages, normalizedMessagesToSave);
|
|
12184
12276
|
this.historyWriter.appendNewMessages(
|
|
12185
12277
|
this.type,
|
|
12186
|
-
|
|
12278
|
+
incrementalMessages,
|
|
12187
12279
|
parsedStatus?.title || dirName,
|
|
12188
12280
|
this.instanceId,
|
|
12189
12281
|
this.providerSessionId
|
|
12190
12282
|
);
|
|
12191
12283
|
}
|
|
12284
|
+
this.lastPersistedHistoryMessages = normalizedMessagesToSave;
|
|
12192
12285
|
}
|
|
12193
12286
|
this.applyProviderResponse(parsedStatus, { phase: "immediate" });
|
|
12194
12287
|
const surface = resolveProviderStateSurface({
|
|
@@ -12436,6 +12529,7 @@ var CliProviderInstance = class {
|
|
|
12436
12529
|
}
|
|
12437
12530
|
if (data.sessionEvent === "new_session") {
|
|
12438
12531
|
this.runtimeMessages = [];
|
|
12532
|
+
this.lastPersistedHistoryMessages = [];
|
|
12439
12533
|
this.suppressIdleHistoryReplay = false;
|
|
12440
12534
|
this.adapter.clearHistory();
|
|
12441
12535
|
}
|
|
@@ -16765,6 +16859,8 @@ function buildStatusSnapshot(options) {
|
|
|
16765
16859
|
session.lastSeenAt = lastSeenAt;
|
|
16766
16860
|
session.unread = overlayUnread;
|
|
16767
16861
|
session.inboxBucket = overlayInboxBucket;
|
|
16862
|
+
session.completionMarker = completionMarker;
|
|
16863
|
+
session.seenCompletionMarker = seenCompletionMarker;
|
|
16768
16864
|
if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
|
|
16769
16865
|
const recentReadSnapshot = {
|
|
16770
16866
|
sessionId: session.id,
|
|
@@ -18015,6 +18111,7 @@ var DaemonStatusReporter = class {
|
|
|
18015
18111
|
|
|
18016
18112
|
// src/index.ts
|
|
18017
18113
|
init_logger();
|
|
18114
|
+
init_debug_config();
|
|
18018
18115
|
|
|
18019
18116
|
// src/ipc-protocol.ts
|
|
18020
18117
|
var DEFAULT_DAEMON_PORT = 19222;
|