@adhdev/daemon-standalone 0.9.82-rc.7 → 0.9.82-rc.8

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
@@ -45934,17 +45934,87 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
45934
45934
  const sessionId = readStringValue(fallbackSession.id, fallbackSession.sessionId, fallbackSession.session_id, node?.activeSessionId, node?.active_session_id, node?.sessionId, node?.session_id);
45935
45935
  return sessionId ? [sessionId] : [];
45936
45936
  }
45937
+ function readCachedInlineMeshActiveSessionDetails(node) {
45938
+ const cachedStatus = readObjectRecord(node?.cachedStatus);
45939
+ const activeSession = readObjectRecord(cachedStatus.activeSession);
45940
+ const fallbackSession = Object.keys(activeSession).length ? activeSession : readObjectRecord(node?.activeSession ?? node?.active_session);
45941
+ const sessionId = readStringValue(
45942
+ fallbackSession.id,
45943
+ fallbackSession.sessionId,
45944
+ fallbackSession.session_id,
45945
+ node?.activeSessionId,
45946
+ node?.active_session_id,
45947
+ node?.sessionId,
45948
+ node?.session_id
45949
+ );
45950
+ if (!sessionId) return [];
45951
+ return [{
45952
+ sessionId,
45953
+ providerType: readStringValue(
45954
+ fallbackSession.providerType,
45955
+ fallbackSession.provider_type,
45956
+ fallbackSession.cliType,
45957
+ fallbackSession.cli_type,
45958
+ fallbackSession.provider,
45959
+ node?.providerType,
45960
+ node?.provider_type
45961
+ ),
45962
+ state: readStringValue(fallbackSession.status, fallbackSession.state, fallbackSession.lifecycle),
45963
+ lifecycle: readStringValue(fallbackSession.lifecycle),
45964
+ title: readStringValue(fallbackSession.title, fallbackSession.displayName, fallbackSession.display_name) ?? null,
45965
+ workspace: readStringValue(fallbackSession.workspace, node?.workspace) ?? null,
45966
+ lastActivityAt: readStringValue(fallbackSession.lastActivityAt, fallbackSession.last_activity_at) ?? null,
45967
+ recoveryState: readStringValue(fallbackSession.recoveryState, fallbackSession.recovery_state) ?? null,
45968
+ isCached: true
45969
+ }];
45970
+ }
45971
+ function readLiveMeshSessionState(record2) {
45972
+ return readStringValue(
45973
+ record2?.meta?.sessionStatus,
45974
+ record2?.meta?.status,
45975
+ record2?.meta?.providerStatus,
45976
+ record2?.status,
45977
+ record2?.state,
45978
+ record2?.lifecycle
45979
+ );
45980
+ }
45981
+ function toIsoTimestamp(value) {
45982
+ if (typeof value === "number" && Number.isFinite(value)) return new Date(value).toISOString();
45983
+ const stringValue = readStringValue(value);
45984
+ return stringValue || null;
45985
+ }
45986
+ function summarizeMeshSessionRecord(record2) {
45987
+ return {
45988
+ sessionId: readStringValue(record2?.sessionId) || "unknown",
45989
+ providerType: readStringValue(record2?.providerType),
45990
+ state: readLiveMeshSessionState(record2),
45991
+ lifecycle: readStringValue(record2?.lifecycle),
45992
+ surfaceKind: getSessionHostSurfaceKind(record2),
45993
+ recoveryState: readStringValue(record2?.meta?.runtimeRecoveryState) ?? null,
45994
+ workspace: readStringValue(record2?.workspace) ?? null,
45995
+ title: readStringValue(record2?.displayName, record2?.workspaceLabel) ?? null,
45996
+ lastActivityAt: toIsoTimestamp(record2?.updatedAt ?? record2?.lastActivityAt ?? record2?.last_activity_at),
45997
+ isCached: false
45998
+ };
45999
+ }
45937
46000
  function applyCachedInlineMeshNodeStatus(status, node) {
45938
46001
  const cachedStatus = readObjectRecord(node?.cachedStatus);
45939
46002
  const git = buildCachedInlineMeshGitStatus(node);
45940
46003
  const error48 = readStringValue(cachedStatus.error, node?.error);
45941
46004
  const health = readStringValue(cachedStatus.health, node?.health);
45942
46005
  const machineStatus = readStringValue(cachedStatus.machineStatus, node?.machineStatus);
46006
+ const lastSeenAt = toIsoTimestamp(cachedStatus.lastSeenAt ?? cachedStatus.last_seen_at ?? node?.lastSeenAt ?? node?.last_seen_at);
46007
+ const updatedAt = toIsoTimestamp(cachedStatus.updatedAt ?? cachedStatus.updated_at ?? node?.updatedAt ?? node?.updated_at);
45943
46008
  const activeSessions = readCachedInlineMeshActiveSessions(node);
45944
- if (!git && !error48 && !health && !machineStatus && activeSessions.length === 0) return false;
46009
+ const activeSessionDetails = readCachedInlineMeshActiveSessionDetails(node);
46010
+ if (!git && !error48 && !health && !machineStatus && !lastSeenAt && !updatedAt && activeSessions.length === 0) return false;
45945
46011
  if (git) status.git = git;
45946
46012
  if (error48) status.error = error48;
46013
+ if (machineStatus) status.machineStatus = machineStatus;
46014
+ if (lastSeenAt) status.lastSeenAt = lastSeenAt;
46015
+ if (updatedAt) status.updatedAt = updatedAt;
45947
46016
  if (activeSessions.length > 0) status.activeSessions = activeSessions;
46017
+ if (activeSessionDetails.length > 0) status.activeSessionDetails = activeSessionDetails;
45948
46018
  if (health) {
45949
46019
  status.health = health;
45950
46020
  return true;
@@ -45953,7 +46023,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
45953
46023
  status.health = deriveMeshNodeHealthFromGit(git);
45954
46024
  return true;
45955
46025
  }
45956
- return activeSessions.length > 0 || !!machineStatus;
46026
+ return activeSessions.length > 0 || !!machineStatus || !!lastSeenAt || !!updatedAt;
45957
46027
  }
45958
46028
  async function resolveProviderTypeFromPriority(args) {
45959
46029
  if (!args.providerPriority.length) {
@@ -48195,28 +48265,79 @@ ${block}`);
48195
48265
  const ledgerSummary = getLedgerSummary2(meshId);
48196
48266
  const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
48197
48267
  const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
48268
+ const localMachineId = loadConfig2().machineId || "";
48269
+ const inlineCoordinatorNodeId = meshRecord?.inline && Array.isArray(mesh.nodes) ? readStringValue(mesh.nodes[0]?.id, mesh.nodes[0]?.nodeId) : void 0;
48270
+ const refreshedAt = (/* @__PURE__ */ new Date()).toISOString();
48198
48271
  const nodeStatuses = [];
48199
- for (const node of mesh.nodes || []) {
48272
+ for (const [nodeIndex, node] of (mesh.nodes || []).entries()) {
48273
+ const nodeId = String(node.id || node.nodeId || "");
48274
+ const daemonId = readStringValue(node.daemonId);
48275
+ const providerPriority = readProviderPriorityFromPolicy(node.policy);
48276
+ const isSelfNode = Boolean(
48277
+ nodeId && inlineCoordinatorNodeId && nodeId === inlineCoordinatorNodeId
48278
+ ) || Boolean(
48279
+ daemonId && (daemonId === localMachineId || daemonId === this.deps.statusInstanceId)
48280
+ ) || Boolean(meshRecord?.inline && nodeIndex === 0);
48200
48281
  const status = {
48201
- nodeId: node.id || node.nodeId,
48282
+ nodeId,
48202
48283
  machineLabel: node.machineLabel || node.id || node.nodeId,
48203
48284
  workspace: node.workspace,
48204
48285
  repoRoot: node.repoRoot,
48205
48286
  isLocalWorktree: node.isLocalWorktree,
48206
48287
  worktreeBranch: node.worktreeBranch,
48207
- daemonId: node.daemonId,
48288
+ daemonId,
48208
48289
  machineId: node.machineId,
48290
+ machineStatus: node.machineStatus,
48209
48291
  health: "unknown",
48210
48292
  providers: node.providers || [],
48211
- activeSessions: []
48293
+ providerPriority,
48294
+ activeSessions: [],
48295
+ activeSessionDetails: [],
48296
+ launchReady: false
48212
48297
  };
48213
- const nodeId = String(node.id || node.nodeId || "");
48214
- const matchedLiveSessions = liveMeshSessions.filter((record2) => this.sessionMatchesMeshNode(record2, node, nodeId)).map((record2) => typeof record2?.sessionId === "string" ? record2.sessionId : "").filter(Boolean);
48215
- if (matchedLiveSessions.length > 0) {
48216
- status.activeSessions = matchedLiveSessions;
48298
+ if (isSelfNode) {
48299
+ status.connection = {
48300
+ perspective: "selected_coordinator",
48301
+ source: "mesh_peer_status",
48302
+ state: "self",
48303
+ transport: "local",
48304
+ reported: true,
48305
+ reason: "Selected coordinator daemon",
48306
+ lastStateChangeAt: refreshedAt
48307
+ };
48308
+ } else if (daemonId) {
48309
+ const connection = this.deps.getMeshPeerConnectionStatus?.(daemonId);
48310
+ status.connection = connection ?? {
48311
+ perspective: "selected_coordinator",
48312
+ source: "not_reported",
48313
+ state: "unknown",
48314
+ transport: "unknown",
48315
+ reported: false,
48316
+ reason: "No live mesh peer telemetry reported by the selected coordinator yet."
48317
+ };
48318
+ } else {
48319
+ status.connection = {
48320
+ perspective: "selected_coordinator",
48321
+ source: "not_reported",
48322
+ state: "unknown",
48323
+ transport: "unknown",
48324
+ reported: false,
48325
+ reason: "Node has no daemon id, so mesh transport cannot be reported from the selected coordinator."
48326
+ };
48327
+ }
48328
+ const matchedLiveSessionRecords = liveMeshSessions.filter((record2) => this.sessionMatchesMeshNode(record2, node, nodeId));
48329
+ if (matchedLiveSessionRecords.length > 0) {
48330
+ const sessionIds = matchedLiveSessionRecords.map((record2) => typeof record2?.sessionId === "string" ? record2.sessionId : "").filter(Boolean);
48331
+ const providerTypes = matchedLiveSessionRecords.map((record2) => readStringValue(record2?.providerType)).filter(Boolean);
48332
+ status.activeSessions = sessionIds;
48333
+ status.activeSessionDetails = matchedLiveSessionRecords.map(summarizeMeshSessionRecord);
48334
+ if (providerTypes.length > 0) {
48335
+ status.providers = Array.from(/* @__PURE__ */ new Set([...Array.isArray(status.providers) ? status.providers : [], ...providerTypes]));
48336
+ }
48217
48337
  }
48218
48338
  if (node.workspace && typeof node.workspace === "string") {
48219
48339
  if (!fs10.existsSync(node.workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
48340
+ status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
48220
48341
  nodeStatuses.push(status);
48221
48342
  continue;
48222
48343
  }
@@ -48237,6 +48358,7 @@ ${block}`);
48237
48358
  } else {
48238
48359
  applyCachedInlineMeshNodeStatus(status, node);
48239
48360
  }
48361
+ status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
48240
48362
  nodeStatuses.push(status);
48241
48363
  }
48242
48364
  return {
@@ -48245,6 +48367,7 @@ ${block}`);
48245
48367
  meshName: mesh.name,
48246
48368
  repoIdentity: mesh.repoIdentity,
48247
48369
  defaultBranch: mesh.defaultBranch,
48370
+ refreshedAt: (/* @__PURE__ */ new Date()).toISOString(),
48248
48371
  nodes: nodeStatuses,
48249
48372
  queue: { tasks: queue, summary: queueSummary },
48250
48373
  ledger: { entries: ledgerEntries, summary: ledgerSummary }
@@ -56120,6 +56243,7 @@ data: ${JSON.stringify(msg.data)}
56120
56243
  sessionHostControl: config2.sessionHostControl,
56121
56244
  statusInstanceId: config2.statusInstanceId,
56122
56245
  statusVersion: config2.statusVersion,
56246
+ getMeshPeerConnectionStatus: config2.getMeshPeerConnectionStatus,
56123
56247
  getCdpLogFn: config2.getCdpLogFn || ((ideType) => LOG2.forComponent(`CDP:${ideType}`).asLogFn())
56124
56248
  });
56125
56249
  poller = new AgentStreamPoller({