adhdev 0.9.82-rc.17 → 0.9.82-rc.19

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/cli/index.js CHANGED
@@ -46664,6 +46664,36 @@ function summarizeMeshSessionRecord(record2) {
46664
46664
  isCached: false
46665
46665
  };
46666
46666
  }
46667
+ function readLiveMeshNodeWorkspace(args) {
46668
+ const directNodeWorkspace = args.liveSessionRecords.find((record2) => readStringValue(record2?.meta?.meshNodeId) === args.nodeId && readStringValue(record2?.workspace));
46669
+ if (directNodeWorkspace) {
46670
+ return readStringValue(directNodeWorkspace.workspace) || "";
46671
+ }
46672
+ if (args.allowCoordinatorSession) {
46673
+ const coordinatorWorkspace = args.liveSessionRecords.find((record2) => readStringValue(record2?.meta?.meshCoordinatorFor) === args.meshId && readStringValue(record2?.workspace));
46674
+ if (coordinatorWorkspace) {
46675
+ return readStringValue(coordinatorWorkspace.workspace) || "";
46676
+ }
46677
+ }
46678
+ return "";
46679
+ }
46680
+ function collectLiveMeshSessionRecords(args) {
46681
+ const matches = args.liveSessionRecords.filter((record2) => {
46682
+ if (readStringValue(record2?.meta?.meshNodeId) === args.nodeId) return true;
46683
+ const recordWorkspace = readStringValue(record2?.workspace);
46684
+ const nodeWorkspace = readStringValue(args.node?.workspace);
46685
+ return !!recordWorkspace && !!nodeWorkspace && recordWorkspace === nodeWorkspace;
46686
+ });
46687
+ if (args.allowCoordinatorSession) {
46688
+ for (const record2 of args.liveSessionRecords) {
46689
+ if (readStringValue(record2?.meta?.meshCoordinatorFor) !== args.meshId) continue;
46690
+ const sessionId = readStringValue(record2?.sessionId);
46691
+ if (sessionId && matches.some((entry) => readStringValue(entry?.sessionId) === sessionId)) continue;
46692
+ matches.push(record2);
46693
+ }
46694
+ }
46695
+ return matches;
46696
+ }
46667
46697
  function applyCachedInlineMeshNodeStatus(status, node) {
46668
46698
  const cachedStatus = readObjectRecord(node?.cachedStatus);
46669
46699
  const git = buildCachedInlineMeshGitStatus(node);
@@ -47125,25 +47155,35 @@ var init_router = __esm({
47125
47155
  }
47126
47156
  getCachedInlineMesh(meshId, inlineMesh) {
47127
47157
  if (inlineMesh && typeof inlineMesh === "object") {
47128
- this.inlineMeshCache.set(meshId, inlineMesh);
47129
- return inlineMesh;
47158
+ return this.warmInlineMeshCache(meshId, inlineMesh);
47130
47159
  }
47131
47160
  return this.inlineMeshCache.get(meshId);
47132
47161
  }
47162
+ warmInlineMeshCache(meshId, inlineMesh) {
47163
+ if (!inlineMesh || typeof inlineMesh !== "object") return void 0;
47164
+ const cached2 = this.inlineMeshCache.get(meshId);
47165
+ if (cached2) return cached2;
47166
+ this.inlineMeshCache.set(meshId, inlineMesh);
47167
+ return inlineMesh;
47168
+ }
47133
47169
  async getMeshForCommand(meshId, inlineMesh, options) {
47134
47170
  const preferInline = options?.preferInline === true;
47135
47171
  if (preferInline) {
47136
- const cached3 = this.getCachedInlineMesh(meshId, inlineMesh);
47137
- if (cached3) return { mesh: cached3, inline: true };
47172
+ const cached3 = this.getCachedInlineMesh(meshId);
47173
+ if (cached3) return { mesh: cached3, inline: true, source: "inline_cache" };
47174
+ const warmedInline2 = this.warmInlineMeshCache(meshId, inlineMesh);
47175
+ if (warmedInline2) return { mesh: warmedInline2, inline: true, source: "inline_bootstrap" };
47138
47176
  }
47139
47177
  try {
47140
47178
  const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
47141
47179
  const mesh = getMesh3(meshId);
47142
- if (mesh) return { mesh, inline: false };
47180
+ if (mesh) return { mesh, inline: false, source: "local_config" };
47143
47181
  } catch {
47144
47182
  }
47145
- const cached2 = this.getCachedInlineMesh(meshId, inlineMesh);
47146
- return cached2 ? { mesh: cached2, inline: true } : null;
47183
+ const cached2 = this.getCachedInlineMesh(meshId);
47184
+ if (cached2) return { mesh: cached2, inline: true, source: "inline_cache" };
47185
+ const warmedInline = this.warmInlineMeshCache(meshId, inlineMesh);
47186
+ return warmedInline ? { mesh: warmedInline, inline: true, source: "inline_bootstrap" } : null;
47147
47187
  }
47148
47188
  updateInlineMeshNode(meshId, mesh, node) {
47149
47189
  if (!mesh || !Array.isArray(mesh.nodes) || !node?.id) return;
@@ -47372,6 +47412,7 @@ var init_router = __esm({
47372
47412
  const deletedSessionIds = [];
47373
47413
  const skippedSessionIds = [];
47374
47414
  const skippedLiveSessionIds = [];
47415
+ const skippedCoordinatorSessionIds = [];
47375
47416
  const deleteUnsupportedSessionIds = [];
47376
47417
  const recordsRemainSessionIds = [];
47377
47418
  const errors = [];
@@ -47404,6 +47445,12 @@ var init_router = __esm({
47404
47445
  const completed = this.isCompletedHostedSession(record2);
47405
47446
  const surfaceKind = getSessionHostSurfaceKind(record2);
47406
47447
  const liveRuntime = surfaceKind === "live_runtime";
47448
+ const coordinatorSession = readStringValue(record2?.meta?.meshCoordinatorFor) === args.meshId;
47449
+ if (!hasExplicitSessionIds && coordinatorSession) {
47450
+ skippedSessionIds.push(sessionId);
47451
+ skippedCoordinatorSessionIds.push(sessionId);
47452
+ continue;
47453
+ }
47407
47454
  if (!hasExplicitSessionIds && liveRuntime) {
47408
47455
  skippedSessionIds.push(sessionId);
47409
47456
  skippedLiveSessionIds.push(sessionId);
@@ -47469,6 +47516,7 @@ var init_router = __esm({
47469
47516
  deletedSessionIds,
47470
47517
  skippedSessionIds,
47471
47518
  skippedLiveSessionIds,
47519
+ skippedCoordinatorSessionIds,
47472
47520
  ...deleteUnsupported ? {
47473
47521
  deleteUnsupported: true,
47474
47522
  effectiveCleanup: args.mode === "stop_and_delete" ? "stopped_only_records_remain" : "delete_unsupported_records_remain",
@@ -48653,7 +48701,14 @@ var init_router = __esm({
48653
48701
  cliType
48654
48702
  };
48655
48703
  }
48656
- const workspace = typeof coordinatorNode.workspace === "string" ? coordinatorNode.workspace.trim() : "";
48704
+ const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
48705
+ const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
48706
+ const workspace = readLiveMeshNodeWorkspace({
48707
+ meshId,
48708
+ nodeId: String(coordinatorNode.id || coordinatorNode.nodeId || preferredCoordinatorNodeId || ""),
48709
+ liveSessionRecords: liveMeshSessions,
48710
+ allowCoordinatorSession: true
48711
+ }) || (typeof coordinatorNode.workspace === "string" ? coordinatorNode.workspace.trim() : "");
48657
48712
  if (!workspace) return { success: false, error: "Coordinator node workspace required", meshId, cliType };
48658
48713
  if (!cliType) {
48659
48714
  const resolved = await resolveProviderTypeFromPriority({
@@ -48964,7 +49019,12 @@ ${block}`);
48964
49019
  const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
48965
49020
  const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
48966
49021
  const localMachineId = loadConfig().machineId || "";
48967
- const inlineCoordinatorNodeId = meshRecord?.inline && Array.isArray(mesh.nodes) ? readStringValue(mesh.nodes[0]?.id, mesh.nodes[0]?.nodeId) : void 0;
49022
+ const selectedCoordinatorNodeId = readStringValue(
49023
+ mesh.coordinator?.preferredNodeId,
49024
+ mesh.nodes?.[0]?.id,
49025
+ mesh.nodes?.[0]?.nodeId
49026
+ );
49027
+ const inlineCoordinatorNodeId = meshRecord?.inline && Array.isArray(mesh.nodes) ? selectedCoordinatorNodeId : void 0;
48968
49028
  const refreshedAt = (/* @__PURE__ */ new Date()).toISOString();
48969
49029
  const nodeStatuses = [];
48970
49030
  for (const [nodeIndex, node] of (mesh.nodes || []).entries()) {
@@ -49023,7 +49083,20 @@ ${block}`);
49023
49083
  reason: "Node has no daemon id, so mesh transport cannot be reported from the selected coordinator."
49024
49084
  };
49025
49085
  }
49026
- const matchedLiveSessionRecords = liveMeshSessions.filter((record2) => this.sessionMatchesMeshNode(record2, node, nodeId));
49086
+ const matchedLiveSessionRecords = collectLiveMeshSessionRecords({
49087
+ meshId,
49088
+ node,
49089
+ nodeId,
49090
+ liveSessionRecords: liveMeshSessions,
49091
+ allowCoordinatorSession: nodeId === selectedCoordinatorNodeId
49092
+ });
49093
+ const workspace = readLiveMeshNodeWorkspace({
49094
+ meshId,
49095
+ nodeId,
49096
+ liveSessionRecords: matchedLiveSessionRecords,
49097
+ allowCoordinatorSession: nodeId === selectedCoordinatorNodeId
49098
+ }) || (typeof node.workspace === "string" ? node.workspace : "");
49099
+ status.workspace = workspace || node.workspace;
49027
49100
  if (matchedLiveSessionRecords.length > 0) {
49028
49101
  const sessionIds = matchedLiveSessionRecords.map((record2) => typeof record2?.sessionId === "string" ? record2.sessionId : "").filter(Boolean);
49029
49102
  const providerTypes = matchedLiveSessionRecords.map((record2) => readStringValue(record2?.providerType)).filter(Boolean);
@@ -49033,14 +49106,14 @@ ${block}`);
49033
49106
  status.providers = Array.from(/* @__PURE__ */ new Set([...Array.isArray(status.providers) ? status.providers : [], ...providerTypes]));
49034
49107
  }
49035
49108
  }
49036
- if (node.workspace && typeof node.workspace === "string") {
49037
- if (!fs10.existsSync(node.workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
49109
+ if (workspace) {
49110
+ if (!fs10.existsSync(workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
49038
49111
  status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || isSelfNode);
49039
49112
  nodeStatuses.push(status);
49040
49113
  continue;
49041
49114
  }
49042
49115
  try {
49043
- const gitStatus = await getGitRepoStatus(node.workspace, { timeoutMs: 1e4, refreshUpstream: true });
49116
+ const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
49044
49117
  status.git = gitStatus;
49045
49118
  if (gitStatus.isGitRepo) {
49046
49119
  status.health = deriveMeshNodeHealthFromGit(gitStatus);
@@ -49066,6 +49139,11 @@ ${block}`);
49066
49139
  repoIdentity: mesh.repoIdentity,
49067
49140
  defaultBranch: mesh.defaultBranch,
49068
49141
  refreshedAt: (/* @__PURE__ */ new Date()).toISOString(),
49142
+ sourceOfTruth: {
49143
+ membership: meshRecord?.source === "inline_cache" ? "coordinator_inline_mesh_cache" : meshRecord?.source === "local_config" ? "local_mesh_config" : "inline_bootstrap_snapshot",
49144
+ coordinatorOwnsLiveTruth: meshRecord?.source !== "inline_bootstrap",
49145
+ historicalEvidenceOnly: ["recoveryHints", "ledger.summary", "queue.summary"]
49146
+ },
49069
49147
  nodes: nodeStatuses,
49070
49148
  queue: { tasks: queue, summary: queueSummary },
49071
49149
  ledger: { entries: ledgerEntries, summary: ledgerSummary }
@@ -57903,7 +57981,7 @@ var require_yoctocolors_cjs = __commonJS({
57903
57981
  }
57904
57982
  });
57905
57983
 
57906
- // ../../node_modules/@inquirer/figures/dist/esm/index.mjs
57984
+ // ../../node_modules/@inquirer/figures/dist/esm/index.js
57907
57985
  function isUnicodeSupported() {
57908
57986
  if (import_node_process3.default.platform !== "win32") {
57909
57987
  return import_node_process3.default.env["TERM"] !== "linux";
@@ -57915,7 +57993,7 @@ function isUnicodeSupported() {
57915
57993
  }
57916
57994
  var import_node_process3, common2, specialMainSymbols, specialFallbackSymbols, mainSymbols, fallbackSymbols, shouldUseMain, figures, esm_default, replacements;
57917
57995
  var init_esm3 = __esm({
57918
- "../../node_modules/@inquirer/figures/dist/esm/index.mjs"() {
57996
+ "../../node_modules/@inquirer/figures/dist/esm/index.js"() {
57919
57997
  "use strict";
57920
57998
  import_node_process3 = __toESM(require("process"), 1);
57921
57999
  common2 = {
@@ -58186,7 +58264,10 @@ var init_esm3 = __esm({
58186
58264
  oneNinth: "1/9",
58187
58265
  oneTenth: "1/10"
58188
58266
  };
58189
- mainSymbols = { ...common2, ...specialMainSymbols };
58267
+ mainSymbols = {
58268
+ ...common2,
58269
+ ...specialMainSymbols
58270
+ };
58190
58271
  fallbackSymbols = {
58191
58272
  ...common2,
58192
58273
  ...specialFallbackSymbols
@@ -98091,7 +98172,7 @@ var init_adhdev_daemon = __esm({
98091
98172
  init_version();
98092
98173
  init_src();
98093
98174
  init_runtime_defaults();
98094
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.17" });
98175
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.19" });
98095
98176
  AdhdevDaemon = class _AdhdevDaemon {
98096
98177
  localHttpServer = null;
98097
98178
  localWss = null;