@adhdev/daemon-core 0.8.82 → 0.8.83
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/index.js +132 -77
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +132 -77
- package/dist/index.mjs.map +1 -1
- 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/providers/cli-provider-instance.ts +1 -0
- 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
|
}
|
|
@@ -12080,6 +12131,7 @@ var CliProviderInstance = class {
|
|
|
12080
12131
|
}
|
|
12081
12132
|
async onTick() {
|
|
12082
12133
|
if (this.providerSessionId) return;
|
|
12134
|
+
if (this.type === "hermes-cli" && this.launchMode === "new") return;
|
|
12083
12135
|
let probedSessionId = null;
|
|
12084
12136
|
const probeConfig = this.provider.sessionProbe;
|
|
12085
12137
|
if (probeConfig) {
|
|
@@ -16765,6 +16817,8 @@ function buildStatusSnapshot(options) {
|
|
|
16765
16817
|
session.lastSeenAt = lastSeenAt;
|
|
16766
16818
|
session.unread = overlayUnread;
|
|
16767
16819
|
session.inboxBucket = overlayInboxBucket;
|
|
16820
|
+
session.completionMarker = completionMarker;
|
|
16821
|
+
session.seenCompletionMarker = seenCompletionMarker;
|
|
16768
16822
|
if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
|
|
16769
16823
|
const recentReadSnapshot = {
|
|
16770
16824
|
sessionId: session.id,
|
|
@@ -18015,6 +18069,7 @@ var DaemonStatusReporter = class {
|
|
|
18015
18069
|
|
|
18016
18070
|
// src/index.ts
|
|
18017
18071
|
init_logger();
|
|
18072
|
+
init_debug_config();
|
|
18018
18073
|
|
|
18019
18074
|
// src/ipc-protocol.ts
|
|
18020
18075
|
var DEFAULT_DAEMON_PORT = 19222;
|