@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.
@@ -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;
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
- LOG.warn(
1158
- "Terminal",
1159
- `[terminal-screen] ghostty-vt unavailable; using xterm fallback (preference=${preference})`
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
- LOG.warn("CLI", `[${this.cliType}] \u26A0 No CLI scripts loaded! Provider needs scripts/{version}/scripts.js`);
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 = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
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 normalizedScreenSnapshot = normalizeScreenSnapshot(this.terminalScreen.getText());
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
- this.recordTrace("output", {
2179
- rawLength: rawData.length,
2180
- cleanLength: cleanData.length,
2181
- rawPreview: summarizeCliTraceText(rawData, 300),
2182
- cleanPreview: summarizeCliTraceText(cleanData, 300),
2183
- screenText: summarizeCliTraceText(this.terminalScreen.getText(), 1200)
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
- return {
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
- const messages = [...this.committedMessages];
2913
- return {
2914
- id: "cli_session",
2915
- status: this.currentStatus,
2916
- title: this.cliName,
2917
- messages: messages.map((message, index) => buildChatMessage({
2918
- ...message,
2919
- id: message.id || `msg_${index}`,
2920
- index: typeof message.index === "number" ? message.index : index,
2921
- receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
2922
- })),
2923
- activeModal: this.activeModal
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: this.terminalScreen.getText(),
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
- if (activeStatuses.has(status) || recentlyUpdated) {
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
  }
@@ -12219,6 +12270,7 @@ var CliProviderInstance = class {
12219
12270
  }
12220
12271
  async onTick() {
12221
12272
  if (this.providerSessionId) return;
12273
+ if (this.type === "hermes-cli" && this.launchMode === "new") return;
12222
12274
  let probedSessionId = null;
12223
12275
  const probeConfig = this.provider.sessionProbe;
12224
12276
  if (probeConfig) {
@@ -16899,6 +16951,8 @@ function buildStatusSnapshot(options) {
16899
16951
  session.lastSeenAt = lastSeenAt;
16900
16952
  session.unread = overlayUnread;
16901
16953
  session.inboxBucket = overlayInboxBucket;
16954
+ session.completionMarker = completionMarker;
16955
+ session.seenCompletionMarker = seenCompletionMarker;
16902
16956
  if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== "idle" || session.providerType.includes("codex"))) {
16903
16957
  const recentReadSnapshot = {
16904
16958
  sessionId: session.id,
@@ -18149,6 +18203,7 @@ var DaemonStatusReporter = class {
18149
18203
 
18150
18204
  // src/index.ts
18151
18205
  init_logger();
18206
+ init_debug_config();
18152
18207
 
18153
18208
  // src/ipc-protocol.ts
18154
18209
  var DEFAULT_DAEMON_PORT = 19222;