adhdev 0.8.76 → 0.8.79

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/index.js CHANGED
@@ -1026,6 +1026,67 @@ var init_host_memory = __esm({
1026
1026
  }
1027
1027
  });
1028
1028
 
1029
+ // ../../oss/packages/daemon-core/src/session-host/runtime-surface.ts
1030
+ function isSessionHostLiveRuntime(record2) {
1031
+ const lifecycle = String(record2?.lifecycle || "").trim();
1032
+ return LIVE_LIFECYCLES.has(lifecycle);
1033
+ }
1034
+ function getSessionHostRecoveryLabel(meta3) {
1035
+ const recoveryState = typeof meta3?.runtimeRecoveryState === "string" ? String(meta3.runtimeRecoveryState).trim() : "";
1036
+ if (!recoveryState) return null;
1037
+ if (recoveryState === "auto_resumed") return "restored after restart";
1038
+ if (recoveryState === "resume_failed") return "restore failed";
1039
+ if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
1040
+ if (recoveryState === "orphan_snapshot") return "snapshot recovered";
1041
+ return recoveryState.replace(/_/g, " ");
1042
+ }
1043
+ function isSessionHostRecoverySnapshot(record2) {
1044
+ if (!record2) return false;
1045
+ if (isSessionHostLiveRuntime(record2)) return false;
1046
+ const lifecycle = String(record2.lifecycle || "").trim();
1047
+ if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
1048
+ return false;
1049
+ }
1050
+ const meta3 = record2.meta || void 0;
1051
+ if (meta3?.restoredFromStorage === true) return true;
1052
+ return getSessionHostRecoveryLabel(meta3) !== null;
1053
+ }
1054
+ function getSessionHostSurfaceKind(record2) {
1055
+ if (isSessionHostLiveRuntime(record2)) return "live_runtime";
1056
+ if (isSessionHostRecoverySnapshot(record2)) return "recovery_snapshot";
1057
+ return "inactive_record";
1058
+ }
1059
+ function partitionSessionHostRecords(records) {
1060
+ const liveRuntimes = [];
1061
+ const recoverySnapshots = [];
1062
+ const inactiveRecords = [];
1063
+ for (const record2 of records) {
1064
+ const kind = getSessionHostSurfaceKind(record2);
1065
+ if (kind === "live_runtime") {
1066
+ liveRuntimes.push(record2);
1067
+ } else if (kind === "recovery_snapshot") {
1068
+ recoverySnapshots.push(record2);
1069
+ } else {
1070
+ inactiveRecords.push(record2);
1071
+ }
1072
+ }
1073
+ return {
1074
+ liveRuntimes,
1075
+ recoverySnapshots,
1076
+ inactiveRecords
1077
+ };
1078
+ }
1079
+ function partitionSessionHostDiagnosticsSessions(records) {
1080
+ return partitionSessionHostRecords(records || []);
1081
+ }
1082
+ var LIVE_LIFECYCLES;
1083
+ var init_runtime_surface = __esm({
1084
+ "../../oss/packages/daemon-core/src/session-host/runtime-surface.ts"() {
1085
+ "use strict";
1086
+ LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
1087
+ }
1088
+ });
1089
+
1029
1090
  // ../../oss/packages/daemon-core/src/status/chat-tail-hot-sessions.ts
1030
1091
  function parseMessageTimestamp(value) {
1031
1092
  if (typeof value === "number" && Number.isFinite(value)) return value;
@@ -1035,6 +1096,23 @@ function parseMessageTimestamp(value) {
1035
1096
  }
1036
1097
  return 0;
1037
1098
  }
1099
+ function isDefinitelyNonLiveRuntimeSession(session) {
1100
+ const surfaceKind = String(session?.runtimeSurfaceKind || "").trim();
1101
+ if (surfaceKind === "live_runtime") return false;
1102
+ if (surfaceKind === "recovery_snapshot") return true;
1103
+ if (surfaceKind === "inactive_record") return false;
1104
+ const lifecycle = String(session?.runtimeLifecycle || "").trim();
1105
+ if (lifecycle && LIVE_RUNTIME_LIFECYCLES.has(lifecycle)) return false;
1106
+ const inferredSurfaceKind = getSessionHostSurfaceKind({
1107
+ lifecycle: lifecycle || null,
1108
+ meta: {
1109
+ restoredFromStorage: session?.runtimeRestoredFromStorage === true,
1110
+ ...session?.runtimeRecoveryState ? { runtimeRecoveryState: session.runtimeRecoveryState } : {}
1111
+ }
1112
+ });
1113
+ if (inferredSurfaceKind === "recovery_snapshot") return true;
1114
+ return false;
1115
+ }
1038
1116
  function classifyHotChatSessionsForSubscriptionFlush(sessions, previousHotSessionIds, options = {}) {
1039
1117
  const now = options.now ?? Date.now();
1040
1118
  const recentMessageGraceMs = Math.max(
@@ -1043,9 +1121,14 @@ function classifyHotChatSessionsForSubscriptionFlush(sessions, previousHotSessio
1043
1121
  );
1044
1122
  const activeStatuses = options.activeStatuses ?? DEFAULT_ACTIVE_CHAT_POLL_STATUSES;
1045
1123
  const active = /* @__PURE__ */ new Set();
1124
+ const excluded = /* @__PURE__ */ new Set();
1046
1125
  for (const session of sessions) {
1047
1126
  const sessionId = typeof session?.id === "string" ? session.id : "";
1048
1127
  if (!sessionId) continue;
1128
+ if (isDefinitelyNonLiveRuntimeSession(session)) {
1129
+ excluded.add(sessionId);
1130
+ continue;
1131
+ }
1049
1132
  const status = String(session?.status || "").toLowerCase();
1050
1133
  const lastMessageAt = parseMessageTimestamp(session?.lastMessageAt);
1051
1134
  const recentlyUpdated = lastMessageAt > 0 && now - lastMessageAt <= recentMessageGraceMs;
@@ -1054,20 +1137,22 @@ function classifyHotChatSessionsForSubscriptionFlush(sessions, previousHotSessio
1054
1137
  }
1055
1138
  }
1056
1139
  const finalizing = new Set(
1057
- Array.from(previousHotSessionIds).filter((sessionId) => !active.has(sessionId))
1140
+ Array.from(previousHotSessionIds).filter((sessionId) => !active.has(sessionId) && !excluded.has(sessionId))
1058
1141
  );
1059
1142
  return { active, finalizing };
1060
1143
  }
1061
- var DEFAULT_ACTIVE_CHAT_POLL_STATUSES, DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS;
1144
+ var DEFAULT_ACTIVE_CHAT_POLL_STATUSES, DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS, LIVE_RUNTIME_LIFECYCLES;
1062
1145
  var init_chat_tail_hot_sessions = __esm({
1063
1146
  "../../oss/packages/daemon-core/src/status/chat-tail-hot-sessions.ts"() {
1064
1147
  "use strict";
1148
+ init_runtime_surface();
1065
1149
  DEFAULT_ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
1066
1150
  "generating",
1067
1151
  "waiting_approval",
1068
1152
  "starting"
1069
1153
  ]);
1070
1154
  DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS = 8e3;
1155
+ LIVE_RUNTIME_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
1071
1156
  }
1072
1157
  });
1073
1158
 
@@ -6131,7 +6216,7 @@ function shouldIncludeSessionMetadata(profile) {
6131
6216
  return profile !== "live";
6132
6217
  }
6133
6218
  function shouldIncludeRuntimeMetadata(profile) {
6134
- return profile !== "live";
6219
+ return true;
6135
6220
  }
6136
6221
  function findCdpManager(cdpManagers, key) {
6137
6222
  const exact = cdpManagers.get(key);
@@ -6263,8 +6348,12 @@ function buildCliSession(state, options) {
6263
6348
  runtimeKey: state.runtime?.runtimeKey,
6264
6349
  runtimeDisplayName: state.runtime?.displayName,
6265
6350
  runtimeWorkspaceLabel: state.runtime?.workspaceLabel,
6351
+ runtimeLifecycle: state.runtime?.lifecycle ?? null,
6352
+ runtimeSurfaceKind: state.runtime?.surfaceKind,
6266
6353
  runtimeWriteOwner: state.runtime?.writeOwner || null,
6267
- runtimeAttachedClients: state.runtime?.attachedClients || []
6354
+ runtimeAttachedClients: state.runtime?.attachedClients || [],
6355
+ runtimeRestoredFromStorage: state.runtime?.restoredFromStorage === true,
6356
+ runtimeRecoveryState: state.runtime?.recoveryState ?? null
6268
6357
  },
6269
6358
  mode: state.mode,
6270
6359
  resume: state.resume,
@@ -12978,8 +13067,12 @@ var init_cli_provider_instance = __esm({
12978
13067
  runtimeKey: runtime.runtimeKey,
12979
13068
  displayName: runtime.displayName,
12980
13069
  workspaceLabel: runtime.workspaceLabel,
13070
+ lifecycle: runtime.lifecycle ?? null,
13071
+ surfaceKind: runtime.surfaceKind,
12981
13072
  writeOwner: runtime.writeOwner || null,
12982
- attachedClients: runtime.attachedClients || []
13073
+ attachedClients: runtime.attachedClients || [],
13074
+ restoredFromStorage: runtime.restoredFromStorage === true,
13075
+ recoveryState: runtime.recoveryState ?? null
12983
13076
  } : void 0,
12984
13077
  resume: this.provider.resume,
12985
13078
  controlValues: surface.controlValues,
@@ -35307,8 +35400,11 @@ function checkSize() {
35307
35400
  } catch {
35308
35401
  }
35309
35402
  }
35403
+ function shouldLogCommand(cmd) {
35404
+ return !SKIP_COMMANDS.has(cmd);
35405
+ }
35310
35406
  function logCommand(entry) {
35311
- if (SKIP_COMMANDS.has(entry.cmd)) return;
35407
+ if (!shouldLogCommand(entry.cmd)) return;
35312
35408
  try {
35313
35409
  if (++writeCount2 % 500 === 0) {
35314
35410
  checkRotation();
@@ -35384,73 +35480,14 @@ var init_command_log = __esm({
35384
35480
  writeCount2 = 0;
35385
35481
  SKIP_COMMANDS = /* @__PURE__ */ new Set([
35386
35482
  "heartbeat",
35387
- "status_report"
35483
+ "status_report",
35484
+ "read_chat",
35485
+ "mark_session_seen"
35388
35486
  ]);
35389
35487
  cleanOldFiles();
35390
35488
  }
35391
35489
  });
35392
35490
 
35393
- // ../../oss/packages/daemon-core/src/session-host/runtime-surface.ts
35394
- function isSessionHostLiveRuntime(record2) {
35395
- const lifecycle = String(record2?.lifecycle || "").trim();
35396
- return LIVE_LIFECYCLES.has(lifecycle);
35397
- }
35398
- function getSessionHostRecoveryLabel(meta3) {
35399
- const recoveryState = typeof meta3?.runtimeRecoveryState === "string" ? String(meta3.runtimeRecoveryState).trim() : "";
35400
- if (!recoveryState) return null;
35401
- if (recoveryState === "auto_resumed") return "restored after restart";
35402
- if (recoveryState === "resume_failed") return "restore failed";
35403
- if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
35404
- if (recoveryState === "orphan_snapshot") return "snapshot recovered";
35405
- return recoveryState.replace(/_/g, " ");
35406
- }
35407
- function isSessionHostRecoverySnapshot(record2) {
35408
- if (!record2) return false;
35409
- if (isSessionHostLiveRuntime(record2)) return false;
35410
- const lifecycle = String(record2.lifecycle || "").trim();
35411
- if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
35412
- return false;
35413
- }
35414
- const meta3 = record2.meta || void 0;
35415
- if (meta3?.restoredFromStorage === true) return true;
35416
- return getSessionHostRecoveryLabel(meta3) !== null;
35417
- }
35418
- function getSessionHostSurfaceKind(record2) {
35419
- if (isSessionHostLiveRuntime(record2)) return "live_runtime";
35420
- if (isSessionHostRecoverySnapshot(record2)) return "recovery_snapshot";
35421
- return "inactive_record";
35422
- }
35423
- function partitionSessionHostRecords(records) {
35424
- const liveRuntimes = [];
35425
- const recoverySnapshots = [];
35426
- const inactiveRecords = [];
35427
- for (const record2 of records) {
35428
- const kind = getSessionHostSurfaceKind(record2);
35429
- if (kind === "live_runtime") {
35430
- liveRuntimes.push(record2);
35431
- } else if (kind === "recovery_snapshot") {
35432
- recoverySnapshots.push(record2);
35433
- } else {
35434
- inactiveRecords.push(record2);
35435
- }
35436
- }
35437
- return {
35438
- liveRuntimes,
35439
- recoverySnapshots,
35440
- inactiveRecords
35441
- };
35442
- }
35443
- function partitionSessionHostDiagnosticsSessions(records) {
35444
- return partitionSessionHostRecords(records || []);
35445
- }
35446
- var LIVE_LIFECYCLES;
35447
- var init_runtime_surface = __esm({
35448
- "../../oss/packages/daemon-core/src/session-host/runtime-surface.ts"() {
35449
- "use strict";
35450
- LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
35451
- }
35452
- });
35453
-
35454
35491
  // ../../oss/packages/daemon-core/src/status/snapshot.ts
35455
35492
  function buildRecentReadDebugSignature(snapshot) {
35456
35493
  return [
@@ -43981,6 +44018,8 @@ var init_session_host_transport = __esm({
43981
44018
  runtimeKey: record2.runtimeKey,
43982
44019
  displayName: record2.displayName,
43983
44020
  workspaceLabel: record2.workspaceLabel,
44021
+ lifecycle: typeof record2.lifecycle === "string" ? record2.lifecycle : null,
44022
+ surfaceKind: record2.surfaceKind,
43984
44023
  writeOwner: record2.writeOwner ? {
43985
44024
  clientId: record2.writeOwner.clientId,
43986
44025
  ownerType: record2.writeOwner.ownerType
@@ -44032,20 +44071,32 @@ var init_session_host_transport = __esm({
44032
44071
  });
44033
44072
 
44034
44073
  // ../../oss/packages/daemon-core/src/session-host/app-name.ts
44035
- function validateStandaloneSessionHostAppName(explicit) {
44036
- if (explicit !== DEFAULT_SESSION_HOST_APP_NAME) return;
44037
- throw new Error(
44038
- `Standalone session-host namespace '${DEFAULT_SESSION_HOST_APP_NAME}' is reserved for the global daemon. Use '${DEFAULT_STANDALONE_SESSION_HOST_APP_NAME}' or another non-default namespace.`
44039
- );
44074
+ function getReservedStandaloneNamespaceWarning() {
44075
+ return `Standalone session-host namespace '${DEFAULT_SESSION_HOST_APP_NAME}' is reserved for the global daemon. Falling back to '${DEFAULT_STANDALONE_SESSION_HOST_APP_NAME}' for this standalone run.`;
44040
44076
  }
44041
- function resolveSessionHostAppName(options = {}) {
44077
+ function resolveSessionHostAppNameResolution(options = {}) {
44042
44078
  const env3 = options.env || process.env;
44043
44079
  const explicit = typeof env3.ADHDEV_SESSION_HOST_NAME === "string" ? env3.ADHDEV_SESSION_HOST_NAME.trim() : "";
44044
44080
  if (explicit) {
44045
- if (options.standalone) validateStandaloneSessionHostAppName(explicit);
44046
- return explicit;
44081
+ if (options.standalone && explicit === DEFAULT_SESSION_HOST_APP_NAME) {
44082
+ return {
44083
+ appName: DEFAULT_STANDALONE_SESSION_HOST_APP_NAME,
44084
+ warning: getReservedStandaloneNamespaceWarning(),
44085
+ source: "reserved-standalone-fallback"
44086
+ };
44087
+ }
44088
+ return {
44089
+ appName: explicit,
44090
+ source: "explicit"
44091
+ };
44047
44092
  }
44048
- return options.standalone ? DEFAULT_STANDALONE_SESSION_HOST_APP_NAME : DEFAULT_SESSION_HOST_APP_NAME;
44093
+ return {
44094
+ appName: options.standalone ? DEFAULT_STANDALONE_SESSION_HOST_APP_NAME : DEFAULT_SESSION_HOST_APP_NAME,
44095
+ source: "default"
44096
+ };
44097
+ }
44098
+ function resolveSessionHostAppName(options = {}) {
44099
+ return resolveSessionHostAppNameResolution(options).appName;
44049
44100
  }
44050
44101
  var DEFAULT_SESSION_HOST_APP_NAME, DEFAULT_STANDALONE_SESSION_HOST_APP_NAME;
44051
44102
  var init_app_name = __esm({
@@ -44758,6 +44809,7 @@ __export(src_exports, {
44758
44809
  resolveChatMessageKind: () => resolveChatMessageKind,
44759
44810
  resolveDebugRuntimeConfig: () => resolveDebugRuntimeConfig,
44760
44811
  resolveSessionHostAppName: () => resolveSessionHostAppName,
44812
+ resolveSessionHostAppNameResolution: () => resolveSessionHostAppNameResolution,
44761
44813
  runAsyncBatch: () => runAsyncBatch,
44762
44814
  saveConfig: () => saveConfig,
44763
44815
  saveState: () => saveState,
@@ -54111,7 +54163,7 @@ var init_adhdev_daemon = __esm({
54111
54163
  init_source2();
54112
54164
  init_version();
54113
54165
  init_src();
54114
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.76" });
54166
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.79" });
54115
54167
  AdhdevDaemon = class _AdhdevDaemon {
54116
54168
  localHttpServer = null;
54117
54169
  localWss = null;