@adhdev/daemon-core 0.8.76 → 0.8.78

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.mjs CHANGED
@@ -4271,6 +4271,61 @@ function getHostMemorySnapshot() {
4271
4271
  return { totalMem, freeMem, availableMem };
4272
4272
  }
4273
4273
 
4274
+ // src/session-host/runtime-surface.ts
4275
+ var LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
4276
+ function isSessionHostLiveRuntime(record) {
4277
+ const lifecycle = String(record?.lifecycle || "").trim();
4278
+ return LIVE_LIFECYCLES.has(lifecycle);
4279
+ }
4280
+ function getSessionHostRecoveryLabel(meta) {
4281
+ const recoveryState = typeof meta?.runtimeRecoveryState === "string" ? String(meta.runtimeRecoveryState).trim() : "";
4282
+ if (!recoveryState) return null;
4283
+ if (recoveryState === "auto_resumed") return "restored after restart";
4284
+ if (recoveryState === "resume_failed") return "restore failed";
4285
+ if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
4286
+ if (recoveryState === "orphan_snapshot") return "snapshot recovered";
4287
+ return recoveryState.replace(/_/g, " ");
4288
+ }
4289
+ function isSessionHostRecoverySnapshot(record) {
4290
+ if (!record) return false;
4291
+ if (isSessionHostLiveRuntime(record)) return false;
4292
+ const lifecycle = String(record.lifecycle || "").trim();
4293
+ if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
4294
+ return false;
4295
+ }
4296
+ const meta = record.meta || void 0;
4297
+ if (meta?.restoredFromStorage === true) return true;
4298
+ return getSessionHostRecoveryLabel(meta) !== null;
4299
+ }
4300
+ function getSessionHostSurfaceKind(record) {
4301
+ if (isSessionHostLiveRuntime(record)) return "live_runtime";
4302
+ if (isSessionHostRecoverySnapshot(record)) return "recovery_snapshot";
4303
+ return "inactive_record";
4304
+ }
4305
+ function partitionSessionHostRecords(records) {
4306
+ const liveRuntimes = [];
4307
+ const recoverySnapshots = [];
4308
+ const inactiveRecords = [];
4309
+ for (const record of records) {
4310
+ const kind = getSessionHostSurfaceKind(record);
4311
+ if (kind === "live_runtime") {
4312
+ liveRuntimes.push(record);
4313
+ } else if (kind === "recovery_snapshot") {
4314
+ recoverySnapshots.push(record);
4315
+ } else {
4316
+ inactiveRecords.push(record);
4317
+ }
4318
+ }
4319
+ return {
4320
+ liveRuntimes,
4321
+ recoverySnapshots,
4322
+ inactiveRecords
4323
+ };
4324
+ }
4325
+ function partitionSessionHostDiagnosticsSessions(records) {
4326
+ return partitionSessionHostRecords(records || []);
4327
+ }
4328
+
4274
4329
  // src/status/chat-tail-hot-sessions.ts
4275
4330
  var DEFAULT_ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
4276
4331
  "generating",
@@ -4278,6 +4333,7 @@ var DEFAULT_ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
4278
4333
  "starting"
4279
4334
  ]);
4280
4335
  var DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS = 8e3;
4336
+ var LIVE_RUNTIME_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
4281
4337
  function parseMessageTimestamp(value) {
4282
4338
  if (typeof value === "number" && Number.isFinite(value)) return value;
4283
4339
  if (typeof value === "string") {
@@ -4286,6 +4342,23 @@ function parseMessageTimestamp(value) {
4286
4342
  }
4287
4343
  return 0;
4288
4344
  }
4345
+ function isDefinitelyNonLiveRuntimeSession(session) {
4346
+ const surfaceKind = String(session?.runtimeSurfaceKind || "").trim();
4347
+ if (surfaceKind === "live_runtime") return false;
4348
+ if (surfaceKind === "recovery_snapshot") return true;
4349
+ if (surfaceKind === "inactive_record") return false;
4350
+ const lifecycle = String(session?.runtimeLifecycle || "").trim();
4351
+ if (lifecycle && LIVE_RUNTIME_LIFECYCLES.has(lifecycle)) return false;
4352
+ const inferredSurfaceKind = getSessionHostSurfaceKind({
4353
+ lifecycle: lifecycle || null,
4354
+ meta: {
4355
+ restoredFromStorage: session?.runtimeRestoredFromStorage === true,
4356
+ ...session?.runtimeRecoveryState ? { runtimeRecoveryState: session.runtimeRecoveryState } : {}
4357
+ }
4358
+ });
4359
+ if (inferredSurfaceKind === "recovery_snapshot") return true;
4360
+ return false;
4361
+ }
4289
4362
  function classifyHotChatSessionsForSubscriptionFlush(sessions, previousHotSessionIds, options = {}) {
4290
4363
  const now = options.now ?? Date.now();
4291
4364
  const recentMessageGraceMs = Math.max(
@@ -4294,9 +4367,14 @@ function classifyHotChatSessionsForSubscriptionFlush(sessions, previousHotSessio
4294
4367
  );
4295
4368
  const activeStatuses = options.activeStatuses ?? DEFAULT_ACTIVE_CHAT_POLL_STATUSES;
4296
4369
  const active = /* @__PURE__ */ new Set();
4370
+ const excluded = /* @__PURE__ */ new Set();
4297
4371
  for (const session of sessions) {
4298
4372
  const sessionId = typeof session?.id === "string" ? session.id : "";
4299
4373
  if (!sessionId) continue;
4374
+ if (isDefinitelyNonLiveRuntimeSession(session)) {
4375
+ excluded.add(sessionId);
4376
+ continue;
4377
+ }
4300
4378
  const status = String(session?.status || "").toLowerCase();
4301
4379
  const lastMessageAt = parseMessageTimestamp(session?.lastMessageAt);
4302
4380
  const recentlyUpdated = lastMessageAt > 0 && now - lastMessageAt <= recentMessageGraceMs;
@@ -4305,7 +4383,7 @@ function classifyHotChatSessionsForSubscriptionFlush(sessions, previousHotSessio
4305
4383
  }
4306
4384
  }
4307
4385
  const finalizing = new Set(
4308
- Array.from(previousHotSessionIds).filter((sessionId) => !active.has(sessionId))
4386
+ Array.from(previousHotSessionIds).filter((sessionId) => !active.has(sessionId) && !excluded.has(sessionId))
4309
4387
  );
4310
4388
  return { active, finalizing };
4311
4389
  }
@@ -8562,7 +8640,7 @@ function shouldIncludeSessionMetadata(profile) {
8562
8640
  return profile !== "live";
8563
8641
  }
8564
8642
  function shouldIncludeRuntimeMetadata(profile) {
8565
- return profile !== "live";
8643
+ return true;
8566
8644
  }
8567
8645
  function findCdpManager(cdpManagers, key) {
8568
8646
  const exact = cdpManagers.get(key);
@@ -8717,8 +8795,12 @@ function buildCliSession(state, options) {
8717
8795
  runtimeKey: state.runtime?.runtimeKey,
8718
8796
  runtimeDisplayName: state.runtime?.displayName,
8719
8797
  runtimeWorkspaceLabel: state.runtime?.workspaceLabel,
8798
+ runtimeLifecycle: state.runtime?.lifecycle ?? null,
8799
+ runtimeSurfaceKind: state.runtime?.surfaceKind,
8720
8800
  runtimeWriteOwner: state.runtime?.writeOwner || null,
8721
- runtimeAttachedClients: state.runtime?.attachedClients || []
8801
+ runtimeAttachedClients: state.runtime?.attachedClients || [],
8802
+ runtimeRestoredFromStorage: state.runtime?.restoredFromStorage === true,
8803
+ runtimeRecoveryState: state.runtime?.recoveryState ?? null
8722
8804
  },
8723
8805
  mode: state.mode,
8724
8806
  resume: state.resume,
@@ -12003,8 +12085,12 @@ var CliProviderInstance = class {
12003
12085
  runtimeKey: runtime.runtimeKey,
12004
12086
  displayName: runtime.displayName,
12005
12087
  workspaceLabel: runtime.workspaceLabel,
12088
+ lifecycle: runtime.lifecycle ?? null,
12089
+ surfaceKind: runtime.surfaceKind,
12006
12090
  writeOwner: runtime.writeOwner || null,
12007
- attachedClients: runtime.attachedClients || []
12091
+ attachedClients: runtime.attachedClients || [],
12092
+ restoredFromStorage: runtime.restoredFromStorage === true,
12093
+ recoveryState: runtime.recoveryState ?? null
12008
12094
  } : void 0,
12009
12095
  resume: this.provider.resume,
12010
12096
  controlValues: surface.controlValues,
@@ -16262,10 +16348,15 @@ function checkSize() {
16262
16348
  }
16263
16349
  var SKIP_COMMANDS = /* @__PURE__ */ new Set([
16264
16350
  "heartbeat",
16265
- "status_report"
16351
+ "status_report",
16352
+ "read_chat",
16353
+ "mark_session_seen"
16266
16354
  ]);
16355
+ function shouldLogCommand(cmd) {
16356
+ return !SKIP_COMMANDS.has(cmd);
16357
+ }
16267
16358
  function logCommand(entry) {
16268
- if (SKIP_COMMANDS.has(entry.cmd)) return;
16359
+ if (!shouldLogCommand(entry.cmd)) return;
16269
16360
  try {
16270
16361
  if (++writeCount2 % 500 === 0) {
16271
16362
  checkRotation();
@@ -16316,61 +16407,6 @@ cleanOldFiles();
16316
16407
  // src/commands/router.ts
16317
16408
  init_logger();
16318
16409
 
16319
- // src/session-host/runtime-surface.ts
16320
- var LIVE_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
16321
- function isSessionHostLiveRuntime(record) {
16322
- const lifecycle = String(record?.lifecycle || "").trim();
16323
- return LIVE_LIFECYCLES.has(lifecycle);
16324
- }
16325
- function getSessionHostRecoveryLabel(meta) {
16326
- const recoveryState = typeof meta?.runtimeRecoveryState === "string" ? String(meta.runtimeRecoveryState).trim() : "";
16327
- if (!recoveryState) return null;
16328
- if (recoveryState === "auto_resumed") return "restored after restart";
16329
- if (recoveryState === "resume_failed") return "restore failed";
16330
- if (recoveryState === "host_restart_interrupted") return "host restart interrupted";
16331
- if (recoveryState === "orphan_snapshot") return "snapshot recovered";
16332
- return recoveryState.replace(/_/g, " ");
16333
- }
16334
- function isSessionHostRecoverySnapshot(record) {
16335
- if (!record) return false;
16336
- if (isSessionHostLiveRuntime(record)) return false;
16337
- const lifecycle = String(record.lifecycle || "").trim();
16338
- if (lifecycle && lifecycle !== "stopped" && lifecycle !== "failed") {
16339
- return false;
16340
- }
16341
- const meta = record.meta || void 0;
16342
- if (meta?.restoredFromStorage === true) return true;
16343
- return getSessionHostRecoveryLabel(meta) !== null;
16344
- }
16345
- function getSessionHostSurfaceKind(record) {
16346
- if (isSessionHostLiveRuntime(record)) return "live_runtime";
16347
- if (isSessionHostRecoverySnapshot(record)) return "recovery_snapshot";
16348
- return "inactive_record";
16349
- }
16350
- function partitionSessionHostRecords(records) {
16351
- const liveRuntimes = [];
16352
- const recoverySnapshots = [];
16353
- const inactiveRecords = [];
16354
- for (const record of records) {
16355
- const kind = getSessionHostSurfaceKind(record);
16356
- if (kind === "live_runtime") {
16357
- liveRuntimes.push(record);
16358
- } else if (kind === "recovery_snapshot") {
16359
- recoverySnapshots.push(record);
16360
- } else {
16361
- inactiveRecords.push(record);
16362
- }
16363
- }
16364
- return {
16365
- liveRuntimes,
16366
- recoverySnapshots,
16367
- inactiveRecords
16368
- };
16369
- }
16370
- function partitionSessionHostDiagnosticsSessions(records) {
16371
- return partitionSessionHostRecords(records || []);
16372
- }
16373
-
16374
16410
  // src/status/snapshot.ts
16375
16411
  init_config();
16376
16412
  import * as os16 from "os";
@@ -24747,6 +24783,8 @@ var SessionHostRuntimeTransport = class {
24747
24783
  runtimeKey: record.runtimeKey,
24748
24784
  displayName: record.displayName,
24749
24785
  workspaceLabel: record.workspaceLabel,
24786
+ lifecycle: typeof record.lifecycle === "string" ? record.lifecycle : null,
24787
+ surfaceKind: record.surfaceKind,
24750
24788
  writeOwner: record.writeOwner ? {
24751
24789
  clientId: record.writeOwner.clientId,
24752
24790
  ownerType: record.writeOwner.ownerType