adhdev 0.8.76 → 0.8.77

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,
@@ -35390,67 +35483,6 @@ var init_command_log = __esm({
35390
35483
  }
35391
35484
  });
35392
35485
 
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
35486
  // ../../oss/packages/daemon-core/src/status/snapshot.ts
35455
35487
  function buildRecentReadDebugSignature(snapshot) {
35456
35488
  return [
@@ -43981,6 +44013,8 @@ var init_session_host_transport = __esm({
43981
44013
  runtimeKey: record2.runtimeKey,
43982
44014
  displayName: record2.displayName,
43983
44015
  workspaceLabel: record2.workspaceLabel,
44016
+ lifecycle: typeof record2.lifecycle === "string" ? record2.lifecycle : null,
44017
+ surfaceKind: record2.surfaceKind,
43984
44018
  writeOwner: record2.writeOwner ? {
43985
44019
  clientId: record2.writeOwner.clientId,
43986
44020
  ownerType: record2.writeOwner.ownerType
@@ -54111,7 +54145,7 @@ var init_adhdev_daemon = __esm({
54111
54145
  init_source2();
54112
54146
  init_version();
54113
54147
  init_src();
54114
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.76" });
54148
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.77" });
54115
54149
  AdhdevDaemon = class _AdhdevDaemon {
54116
54150
  localHttpServer = null;
54117
54151
  localWss = null;