@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
|
@@ -93,6 +93,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
|
|
|
93
93
|
private traceEntries;
|
|
94
94
|
private traceSeq;
|
|
95
95
|
private traceSessionId;
|
|
96
|
+
private parsedStatusCache;
|
|
96
97
|
private static readonly MAX_TRACE_ENTRIES;
|
|
97
98
|
private readonly providerResolutionMeta;
|
|
98
99
|
private static readonly FINISH_RETRY_DELAY_MS;
|
|
@@ -102,4 +102,5 @@ export declare function listSavedHistorySessions(agentType: string, options?: {
|
|
|
102
102
|
sessions: SavedHistorySessionSummary[];
|
|
103
103
|
hasMore: boolean;
|
|
104
104
|
};
|
|
105
|
+
export declare function rebuildHermesSavedHistoryFromCanonicalSession(historySessionId: string): boolean;
|
|
105
106
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -956,6 +956,58 @@ var init_read_chat_contract = __esm({
|
|
|
956
956
|
}
|
|
957
957
|
});
|
|
958
958
|
|
|
959
|
+
// src/logging/debug-config.ts
|
|
960
|
+
function normalizeCategories(categories) {
|
|
961
|
+
if (!Array.isArray(categories)) return [];
|
|
962
|
+
return categories.map((category) => String(category || "").trim()).filter(Boolean);
|
|
963
|
+
}
|
|
964
|
+
function resolveDebugRuntimeConfig(options = {}) {
|
|
965
|
+
const dev = options.dev === true;
|
|
966
|
+
return {
|
|
967
|
+
logLevel: options.logLevel || (dev ? "debug" : DEFAULT_CONFIG2.logLevel),
|
|
968
|
+
collectDebugTrace: typeof options.trace === "boolean" ? options.trace : dev,
|
|
969
|
+
traceContent: options.traceContent === true,
|
|
970
|
+
traceBufferSize: Number.isFinite(options.traceBufferSize) ? Math.max(10, Math.floor(options.traceBufferSize)) : dev ? DEV_TRACE_BUFFER_SIZE : DEFAULT_CONFIG2.traceBufferSize,
|
|
971
|
+
traceCategories: normalizeCategories(options.traceCategories)
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
function setDebugRuntimeConfig(config) {
|
|
975
|
+
currentConfig = {
|
|
976
|
+
...config,
|
|
977
|
+
traceCategories: normalizeCategories(config.traceCategories),
|
|
978
|
+
traceBufferSize: Math.max(10, Math.floor(config.traceBufferSize || DEFAULT_CONFIG2.traceBufferSize))
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
function getDebugRuntimeConfig() {
|
|
982
|
+
return { ...currentConfig, traceCategories: [...currentConfig.traceCategories] };
|
|
983
|
+
}
|
|
984
|
+
function resetDebugRuntimeConfig() {
|
|
985
|
+
currentConfig = { ...DEFAULT_CONFIG2 };
|
|
986
|
+
}
|
|
987
|
+
function shouldCollectTraceCategory(category) {
|
|
988
|
+
const config = currentConfig;
|
|
989
|
+
if (!config.collectDebugTrace) return false;
|
|
990
|
+
if (!category) return true;
|
|
991
|
+
if (config.traceCategories.length === 0) return true;
|
|
992
|
+
return config.traceCategories.includes(category);
|
|
993
|
+
}
|
|
994
|
+
var NORMAL_TRACE_BUFFER_SIZE, DEV_TRACE_BUFFER_SIZE, DEFAULT_CONFIG2, currentConfig;
|
|
995
|
+
var init_debug_config = __esm({
|
|
996
|
+
"src/logging/debug-config.ts"() {
|
|
997
|
+
"use strict";
|
|
998
|
+
NORMAL_TRACE_BUFFER_SIZE = 200;
|
|
999
|
+
DEV_TRACE_BUFFER_SIZE = 1e3;
|
|
1000
|
+
DEFAULT_CONFIG2 = {
|
|
1001
|
+
logLevel: "info",
|
|
1002
|
+
collectDebugTrace: false,
|
|
1003
|
+
traceContent: false,
|
|
1004
|
+
traceBufferSize: NORMAL_TRACE_BUFFER_SIZE,
|
|
1005
|
+
traceCategories: []
|
|
1006
|
+
};
|
|
1007
|
+
currentConfig = { ...DEFAULT_CONFIG2 };
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1010
|
+
|
|
959
1011
|
// src/cli-adapters/terminal-backends/ghostty-vt-backend.ts
|
|
960
1012
|
function isModuleNotFoundError(error, ref) {
|
|
961
1013
|
if (!(error instanceof Error)) return false;
|
|
@@ -1154,10 +1206,12 @@ function logTerminalBackendSelection(preference, ghosttyAvailable, backendKind)
|
|
|
1154
1206
|
if (loggedTerminalBackends.has(key)) return;
|
|
1155
1207
|
loggedTerminalBackends.add(key);
|
|
1156
1208
|
if (backendKind === "xterm" && preference !== "xterm" && !ghosttyAvailable) {
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1209
|
+
const message = `[terminal-screen] ghostty-vt unavailable; using xterm fallback (preference=${preference})`;
|
|
1210
|
+
if (preference === "auto") {
|
|
1211
|
+
LOG.info("Terminal", message);
|
|
1212
|
+
} else {
|
|
1213
|
+
LOG.warn("Terminal", message);
|
|
1214
|
+
}
|
|
1161
1215
|
return;
|
|
1162
1216
|
}
|
|
1163
1217
|
LOG.info(
|
|
@@ -1809,6 +1863,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
1809
1863
|
"use strict";
|
|
1810
1864
|
os10 = __toESM(require("os"));
|
|
1811
1865
|
init_logger();
|
|
1866
|
+
init_debug_config();
|
|
1812
1867
|
init_terminal_screen();
|
|
1813
1868
|
init_pty_transport();
|
|
1814
1869
|
init_provider_cli_shared();
|
|
@@ -1842,7 +1897,15 @@ var init_provider_cli_adapter = __esm({
|
|
|
1842
1897
|
`[${this.cliType}] Provider resolution: providerDir=${this.providerResolutionMeta.providerDir || "-"} scriptDir=${this.providerResolutionMeta.scriptDir || "-"} scriptsPath=${this.providerResolutionMeta.scriptsPath || "-"} source=${this.providerResolutionMeta.scriptsSource || "-"} version=${this.providerResolutionMeta.resolvedVersion || "-"}`
|
|
1843
1898
|
);
|
|
1844
1899
|
} else {
|
|
1845
|
-
|
|
1900
|
+
const resolutionSummary = `providerDir=${this.providerResolutionMeta.providerDir || "-"} scriptDir=${this.providerResolutionMeta.scriptDir || "-"} scriptsPath=${this.providerResolutionMeta.scriptsPath || "-"} source=${this.providerResolutionMeta.scriptsSource || "-"} version=${this.providerResolutionMeta.resolvedVersion || "-"}`;
|
|
1901
|
+
const hasResolvedProviderScripts = Boolean(
|
|
1902
|
+
this.providerResolutionMeta.providerDir || this.providerResolutionMeta.scriptDir || this.providerResolutionMeta.scriptsPath || this.providerResolutionMeta.scriptsSource || this.providerResolutionMeta.resolvedVersion
|
|
1903
|
+
);
|
|
1904
|
+
if (hasResolvedProviderScripts) {
|
|
1905
|
+
LOG.warn("CLI", `[${this.cliType}] \u26A0 No CLI scripts loaded! Provider needs scripts/{version}/scripts.js (${resolutionSummary})`);
|
|
1906
|
+
} else {
|
|
1907
|
+
LOG.info("CLI", `[${this.cliType}] CLI scripts not yet resolved (${resolutionSummary})`);
|
|
1908
|
+
}
|
|
1846
1909
|
}
|
|
1847
1910
|
}
|
|
1848
1911
|
cliType;
|
|
@@ -1921,7 +1984,8 @@ var init_provider_cli_adapter = __esm({
|
|
|
1921
1984
|
currentTurnScope = null;
|
|
1922
1985
|
traceEntries = [];
|
|
1923
1986
|
traceSeq = 0;
|
|
1924
|
-
traceSessionId =
|
|
1987
|
+
traceSessionId = "";
|
|
1988
|
+
parsedStatusCache = null;
|
|
1925
1989
|
static MAX_TRACE_ENTRIES = 250;
|
|
1926
1990
|
providerResolutionMeta;
|
|
1927
1991
|
static FINISH_RETRY_DELAY_MS = 300;
|
|
@@ -2162,7 +2226,8 @@ var init_provider_cli_adapter = __esm({
|
|
|
2162
2226
|
this.terminalScreen.write(rawData);
|
|
2163
2227
|
const cleanData = sanitizeTerminalText(rawData);
|
|
2164
2228
|
const now = Date.now();
|
|
2165
|
-
const
|
|
2229
|
+
const screenText = this.terminalScreen.getText();
|
|
2230
|
+
const normalizedScreenSnapshot = normalizeScreenSnapshot(screenText);
|
|
2166
2231
|
this.lastOutputAt = now;
|
|
2167
2232
|
if (cleanData.trim()) this.lastNonEmptyOutputAt = now;
|
|
2168
2233
|
if (normalizedScreenSnapshot !== this.lastScreenSnapshot) {
|
|
@@ -2175,13 +2240,14 @@ var init_provider_cli_adapter = __esm({
|
|
|
2175
2240
|
if (this.idleFinishCandidate && (rawData.length > 0 || cleanData.length > 0)) {
|
|
2176
2241
|
this.clearIdleFinishCandidate("new_output");
|
|
2177
2242
|
}
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2243
|
+
if (getDebugRuntimeConfig().collectDebugTrace) {
|
|
2244
|
+
this.recordTrace("output", {
|
|
2245
|
+
rawLength: rawData.length,
|
|
2246
|
+
cleanLength: cleanData.length,
|
|
2247
|
+
rawPreview: summarizeCliTraceText(rawData, 300),
|
|
2248
|
+
cleanPreview: summarizeCliTraceText(cleanData, 300)
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2185
2251
|
if (this.startupParseGate) {
|
|
2186
2252
|
this.scheduleStartupSettleCheck();
|
|
2187
2253
|
}
|
|
@@ -2883,12 +2949,19 @@ var init_provider_cli_adapter = __esm({
|
|
|
2883
2949
|
* Called by command handler / dashboard for rich content rendering.
|
|
2884
2950
|
*/
|
|
2885
2951
|
getScriptParsedStatus() {
|
|
2952
|
+
const screenText = this.terminalScreen.getText();
|
|
2953
|
+
const cached = this.parsedStatusCache;
|
|
2954
|
+
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) {
|
|
2955
|
+
return cached.result;
|
|
2956
|
+
}
|
|
2886
2957
|
const parsed = this.parseCurrentTranscript(
|
|
2887
2958
|
this.committedMessages,
|
|
2888
2959
|
this.responseBuffer,
|
|
2889
|
-
this.currentTurnScope
|
|
2960
|
+
this.currentTurnScope,
|
|
2961
|
+
screenText
|
|
2890
2962
|
);
|
|
2891
2963
|
const shouldPreferCommittedMessages = !this.currentTurnScope && this.currentStatus === "idle" && !this.activeModal;
|
|
2964
|
+
let result;
|
|
2892
2965
|
if (parsed && Array.isArray(parsed.messages)) {
|
|
2893
2966
|
const hydratedMessages = shouldPreferCommittedMessages ? this.committedMessages.map((message, index) => buildChatMessage({
|
|
2894
2967
|
...message,
|
|
@@ -2900,7 +2973,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
2900
2973
|
scope: this.currentTurnScope,
|
|
2901
2974
|
lastOutputAt: this.lastOutputAt
|
|
2902
2975
|
});
|
|
2903
|
-
|
|
2976
|
+
result = {
|
|
2904
2977
|
id: parsed.id || "cli_session",
|
|
2905
2978
|
status: parsed.status || this.currentStatus,
|
|
2906
2979
|
title: parsed.title || this.cliName,
|
|
@@ -2908,20 +2981,36 @@ var init_provider_cli_adapter = __esm({
|
|
|
2908
2981
|
activeModal: parsed.activeModal ?? this.activeModal,
|
|
2909
2982
|
providerSessionId: typeof parsed.providerSessionId === "string" ? parsed.providerSessionId : void 0
|
|
2910
2983
|
};
|
|
2984
|
+
} else {
|
|
2985
|
+
const messages = [...this.committedMessages];
|
|
2986
|
+
result = {
|
|
2987
|
+
id: "cli_session",
|
|
2988
|
+
status: this.currentStatus,
|
|
2989
|
+
title: this.cliName,
|
|
2990
|
+
messages: messages.map((message, index) => buildChatMessage({
|
|
2991
|
+
...message,
|
|
2992
|
+
id: message.id || `msg_${index}`,
|
|
2993
|
+
index: typeof message.index === "number" ? message.index : index,
|
|
2994
|
+
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
2995
|
+
})),
|
|
2996
|
+
activeModal: this.activeModal
|
|
2997
|
+
};
|
|
2911
2998
|
}
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2999
|
+
this.parsedStatusCache = {
|
|
3000
|
+
committedMessagesRef: this.committedMessages,
|
|
3001
|
+
responseBuffer: this.responseBuffer,
|
|
3002
|
+
currentTurnScope: this.currentTurnScope,
|
|
3003
|
+
recentOutputBuffer: this.recentOutputBuffer,
|
|
3004
|
+
accumulatedBuffer: this.accumulatedBuffer,
|
|
3005
|
+
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
3006
|
+
screenText,
|
|
3007
|
+
currentStatus: this.currentStatus,
|
|
3008
|
+
activeModal: this.activeModal,
|
|
3009
|
+
cliName: this.cliName,
|
|
3010
|
+
lastOutputAt: this.lastOutputAt,
|
|
3011
|
+
result
|
|
2924
3012
|
};
|
|
3013
|
+
return result;
|
|
2925
3014
|
}
|
|
2926
3015
|
async invokeScript(scriptName, args) {
|
|
2927
3016
|
const fn = this.cliScripts?.[scriptName];
|
|
@@ -2944,17 +3033,18 @@ var init_provider_cli_adapter = __esm({
|
|
|
2944
3033
|
args: args && typeof args === "object" ? { ...args } : {}
|
|
2945
3034
|
}));
|
|
2946
3035
|
}
|
|
2947
|
-
parseCurrentTranscript(baseMessages, partialResponse, scope) {
|
|
3036
|
+
parseCurrentTranscript(baseMessages, partialResponse, scope, screenTextOverride) {
|
|
2948
3037
|
if (!this.cliScripts?.parseOutput) {
|
|
2949
3038
|
this.parseErrorMessage = null;
|
|
2950
3039
|
return null;
|
|
2951
3040
|
}
|
|
2952
3041
|
try {
|
|
3042
|
+
const screenText = typeof screenTextOverride === "string" ? screenTextOverride : this.terminalScreen.getText();
|
|
2953
3043
|
const input = buildCliParseInput({
|
|
2954
3044
|
accumulatedBuffer: this.accumulatedBuffer,
|
|
2955
3045
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
2956
3046
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
2957
|
-
terminalScreenText:
|
|
3047
|
+
terminalScreenText: screenText,
|
|
2958
3048
|
baseMessages,
|
|
2959
3049
|
partialResponse,
|
|
2960
3050
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
@@ -4630,9 +4720,15 @@ function classifyHotChatSessionsForSubscriptionFlush(sessions, previousHotSessio
|
|
|
4630
4720
|
continue;
|
|
4631
4721
|
}
|
|
4632
4722
|
const status = String(session?.status || "").toLowerCase();
|
|
4723
|
+
const unread = session?.unread === true;
|
|
4724
|
+
const inboxBucket = String(session?.inboxBucket || "").toLowerCase();
|
|
4725
|
+
const runtimeSurfaceKind = String(session?.runtimeSurfaceKind || "").toLowerCase();
|
|
4726
|
+
const runtimeLifecycle = String(session?.runtimeLifecycle || "").toLowerCase();
|
|
4727
|
+
const isLiveRuntime = runtimeSurfaceKind === "live_runtime" || LIVE_RUNTIME_LIFECYCLES.has(runtimeLifecycle);
|
|
4633
4728
|
const lastMessageAt = parseMessageTimestamp(session?.lastMessageAt);
|
|
4634
4729
|
const recentlyUpdated = lastMessageAt > 0 && now - lastMessageAt <= recentMessageGraceMs;
|
|
4635
|
-
|
|
4730
|
+
const shouldKeepRecentTailHot = recentlyUpdated && (unread || inboxBucket === "task_complete" || inboxBucket === "needs_attention" || isLiveRuntime || activeStatuses.has(status));
|
|
4731
|
+
if (activeStatuses.has(status) || shouldKeepRecentTailHot) {
|
|
4636
4732
|
active.add(sessionId);
|
|
4637
4733
|
}
|
|
4638
4734
|
}
|
|
@@ -9264,53 +9360,8 @@ function assertProviderSupportsDeclaredInput(provider, input) {
|
|
|
9264
9360
|
init_read_chat_contract();
|
|
9265
9361
|
init_logger();
|
|
9266
9362
|
|
|
9267
|
-
// src/logging/debug-config.ts
|
|
9268
|
-
var NORMAL_TRACE_BUFFER_SIZE = 200;
|
|
9269
|
-
var DEV_TRACE_BUFFER_SIZE = 1e3;
|
|
9270
|
-
var DEFAULT_CONFIG2 = {
|
|
9271
|
-
logLevel: "info",
|
|
9272
|
-
collectDebugTrace: false,
|
|
9273
|
-
traceContent: false,
|
|
9274
|
-
traceBufferSize: NORMAL_TRACE_BUFFER_SIZE,
|
|
9275
|
-
traceCategories: []
|
|
9276
|
-
};
|
|
9277
|
-
var currentConfig = { ...DEFAULT_CONFIG2 };
|
|
9278
|
-
function normalizeCategories(categories) {
|
|
9279
|
-
if (!Array.isArray(categories)) return [];
|
|
9280
|
-
return categories.map((category) => String(category || "").trim()).filter(Boolean);
|
|
9281
|
-
}
|
|
9282
|
-
function resolveDebugRuntimeConfig(options = {}) {
|
|
9283
|
-
const dev = options.dev === true;
|
|
9284
|
-
return {
|
|
9285
|
-
logLevel: options.logLevel || (dev ? "debug" : DEFAULT_CONFIG2.logLevel),
|
|
9286
|
-
collectDebugTrace: typeof options.trace === "boolean" ? options.trace : dev,
|
|
9287
|
-
traceContent: options.traceContent === true,
|
|
9288
|
-
traceBufferSize: Number.isFinite(options.traceBufferSize) ? Math.max(10, Math.floor(options.traceBufferSize)) : dev ? DEV_TRACE_BUFFER_SIZE : DEFAULT_CONFIG2.traceBufferSize,
|
|
9289
|
-
traceCategories: normalizeCategories(options.traceCategories)
|
|
9290
|
-
};
|
|
9291
|
-
}
|
|
9292
|
-
function setDebugRuntimeConfig(config) {
|
|
9293
|
-
currentConfig = {
|
|
9294
|
-
...config,
|
|
9295
|
-
traceCategories: normalizeCategories(config.traceCategories),
|
|
9296
|
-
traceBufferSize: Math.max(10, Math.floor(config.traceBufferSize || DEFAULT_CONFIG2.traceBufferSize))
|
|
9297
|
-
};
|
|
9298
|
-
}
|
|
9299
|
-
function getDebugRuntimeConfig() {
|
|
9300
|
-
return { ...currentConfig, traceCategories: [...currentConfig.traceCategories] };
|
|
9301
|
-
}
|
|
9302
|
-
function resetDebugRuntimeConfig() {
|
|
9303
|
-
currentConfig = { ...DEFAULT_CONFIG2 };
|
|
9304
|
-
}
|
|
9305
|
-
function shouldCollectTraceCategory(category) {
|
|
9306
|
-
const config = currentConfig;
|
|
9307
|
-
if (!config.collectDebugTrace) return false;
|
|
9308
|
-
if (!category) return true;
|
|
9309
|
-
if (config.traceCategories.length === 0) return true;
|
|
9310
|
-
return config.traceCategories.includes(category);
|
|
9311
|
-
}
|
|
9312
|
-
|
|
9313
9363
|
// src/logging/debug-trace.ts
|
|
9364
|
+
init_debug_config();
|
|
9314
9365
|
function summarizeString(value) {
|
|
9315
9366
|
return `[${value.length} chars]`;
|
|
9316
9367
|
}
|
|
@@ -12072,6 +12123,30 @@ init_contracts();
|
|
|
12072
12123
|
init_provider_cli_adapter();
|
|
12073
12124
|
init_logger();
|
|
12074
12125
|
init_chat_message_normalization();
|
|
12126
|
+
function normalizePersistableCliHistoryContent(content) {
|
|
12127
|
+
return flattenContent(content).replace(/\s+/g, " ").trim();
|
|
12128
|
+
}
|
|
12129
|
+
function buildPersistableCliHistorySignature(message) {
|
|
12130
|
+
return [
|
|
12131
|
+
String(message.role || ""),
|
|
12132
|
+
String(message.kind || ""),
|
|
12133
|
+
String(message.senderName || ""),
|
|
12134
|
+
normalizePersistableCliHistoryContent(message.content)
|
|
12135
|
+
].join("|");
|
|
12136
|
+
}
|
|
12137
|
+
function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages) {
|
|
12138
|
+
if (!Array.isArray(currentMessages) || currentMessages.length === 0) return [];
|
|
12139
|
+
if (!Array.isArray(previousMessages) || previousMessages.length === 0) return currentMessages;
|
|
12140
|
+
const previousSignatures = previousMessages.map(buildPersistableCliHistorySignature);
|
|
12141
|
+
const currentSignatures = currentMessages.map(buildPersistableCliHistorySignature);
|
|
12142
|
+
let sharedPrefixLength = 0;
|
|
12143
|
+
while (sharedPrefixLength < previousSignatures.length && sharedPrefixLength < currentSignatures.length && previousSignatures[sharedPrefixLength] === currentSignatures[sharedPrefixLength]) {
|
|
12144
|
+
sharedPrefixLength += 1;
|
|
12145
|
+
}
|
|
12146
|
+
if (sharedPrefixLength === currentSignatures.length) return [];
|
|
12147
|
+
if (sharedPrefixLength === previousSignatures.length) return currentMessages.slice(sharedPrefixLength);
|
|
12148
|
+
return currentMessages;
|
|
12149
|
+
}
|
|
12075
12150
|
var CachedDatabaseSync = null;
|
|
12076
12151
|
function getDatabaseSync() {
|
|
12077
12152
|
if (CachedDatabaseSync) return CachedDatabaseSync;
|
|
@@ -12149,6 +12224,7 @@ var CliProviderInstance = class {
|
|
|
12149
12224
|
appliedEffectKeys = /* @__PURE__ */ new Set();
|
|
12150
12225
|
historyWriter;
|
|
12151
12226
|
runtimeMessages = [];
|
|
12227
|
+
lastPersistedHistoryMessages = [];
|
|
12152
12228
|
instanceId;
|
|
12153
12229
|
suppressIdleHistoryReplay = false;
|
|
12154
12230
|
errorMessage = void 0;
|
|
@@ -12189,6 +12265,13 @@ var CliProviderInstance = class {
|
|
|
12189
12265
|
this.providerSessionId,
|
|
12190
12266
|
this.instanceId
|
|
12191
12267
|
);
|
|
12268
|
+
this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
|
|
12269
|
+
role: message.role,
|
|
12270
|
+
content: message.content,
|
|
12271
|
+
kind: message.kind,
|
|
12272
|
+
senderName: message.senderName,
|
|
12273
|
+
receivedAt: message.receivedAt
|
|
12274
|
+
}));
|
|
12192
12275
|
this.suppressIdleHistoryReplay = restoredHistory.messages.length > 0;
|
|
12193
12276
|
if (restoredHistory.messages.length > 0) {
|
|
12194
12277
|
this.adapter.seedCommittedMessages(
|
|
@@ -12219,6 +12302,7 @@ var CliProviderInstance = class {
|
|
|
12219
12302
|
}
|
|
12220
12303
|
async onTick() {
|
|
12221
12304
|
if (this.providerSessionId) return;
|
|
12305
|
+
if (this.type === "hermes-cli" && this.launchMode === "new") return;
|
|
12222
12306
|
let probedSessionId = null;
|
|
12223
12307
|
const probeConfig = this.provider.sessionProbe;
|
|
12224
12308
|
if (probeConfig) {
|
|
@@ -12319,15 +12403,24 @@ var CliProviderInstance = class {
|
|
|
12319
12403
|
messagesToSave = messagesToSave.slice(0, lastIdx);
|
|
12320
12404
|
}
|
|
12321
12405
|
}
|
|
12322
|
-
|
|
12406
|
+
const normalizedMessagesToSave = messagesToSave.map((message) => ({
|
|
12407
|
+
role: message.role,
|
|
12408
|
+
content: flattenContent(message.content),
|
|
12409
|
+
kind: typeof message.kind === "string" ? message.kind : void 0,
|
|
12410
|
+
senderName: typeof message.senderName === "string" ? message.senderName : void 0,
|
|
12411
|
+
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
12412
|
+
}));
|
|
12413
|
+
if (!shouldSkipReplayPersist && normalizedMessagesToSave.length > 0) {
|
|
12414
|
+
const incrementalMessages = buildIncrementalHistoryAppendMessages(this.lastPersistedHistoryMessages, normalizedMessagesToSave);
|
|
12323
12415
|
this.historyWriter.appendNewMessages(
|
|
12324
12416
|
this.type,
|
|
12325
|
-
|
|
12417
|
+
incrementalMessages,
|
|
12326
12418
|
parsedStatus?.title || dirName,
|
|
12327
12419
|
this.instanceId,
|
|
12328
12420
|
this.providerSessionId
|
|
12329
12421
|
);
|
|
12330
12422
|
}
|
|
12423
|
+
this.lastPersistedHistoryMessages = normalizedMessagesToSave;
|
|
12331
12424
|
}
|
|
12332
12425
|
this.applyProviderResponse(parsedStatus, { phase: "immediate" });
|
|
12333
12426
|
const surface = resolveProviderStateSurface({
|
|
@@ -12575,6 +12668,7 @@ var CliProviderInstance = class {
|
|
|
12575
12668
|
}
|
|
12576
12669
|
if (data.sessionEvent === "new_session") {
|
|
12577
12670
|
this.runtimeMessages = [];
|
|
12671
|
+
this.lastPersistedHistoryMessages = [];
|
|
12578
12672
|
this.suppressIdleHistoryReplay = false;
|
|
12579
12673
|
this.adapter.clearHistory();
|
|
12580
12674
|
}
|
|
@@ -16899,6 +16993,8 @@ function buildStatusSnapshot(options) {
|
|
|
16899
16993
|
session.lastSeenAt = lastSeenAt;
|
|
16900
16994
|
session.unread = overlayUnread;
|
|
16901
16995
|
session.inboxBucket = overlayInboxBucket;
|
|
16996
|
+
session.completionMarker = completionMarker;
|
|
16997
|
+
session.seenCompletionMarker = seenCompletionMarker;
|
|
16902
16998
|
if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
|
|
16903
16999
|
const recentReadSnapshot = {
|
|
16904
17000
|
sessionId: session.id,
|
|
@@ -18149,6 +18245,7 @@ var DaemonStatusReporter = class {
|
|
|
18149
18245
|
|
|
18150
18246
|
// src/index.ts
|
|
18151
18247
|
init_logger();
|
|
18248
|
+
init_debug_config();
|
|
18152
18249
|
|
|
18153
18250
|
// src/ipc-protocol.ts
|
|
18154
18251
|
var DEFAULT_DAEMON_PORT = 19222;
|