adhdev 0.9.82-rc.43 → 0.9.82-rc.44

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
@@ -45650,6 +45650,70 @@ function readBooleanValue(...values) {
45650
45650
  }
45651
45651
  return void 0;
45652
45652
  }
45653
+ function summarizeRepoMeshDebugGit(git) {
45654
+ const record2 = readObjectRecord(git);
45655
+ if (!Object.keys(record2).length) return null;
45656
+ const submodules = Array.isArray(record2.submodules) ? record2.submodules.map((entry) => ({
45657
+ path: readStringValue(entry?.path) ?? null,
45658
+ commit: readStringValue(entry?.commit)?.slice(0, 12) ?? null,
45659
+ dirty: readBooleanValue(entry?.dirty) ?? false,
45660
+ outOfSync: readBooleanValue(entry?.outOfSync, entry?.out_of_sync) ?? false
45661
+ })) : [];
45662
+ return {
45663
+ isGitRepo: readBooleanValue(record2.isGitRepo),
45664
+ workspace: readStringValue(record2.workspace) ?? null,
45665
+ repoRoot: readStringValue(record2.repoRoot, record2.repo_root) ?? null,
45666
+ branch: readStringValue(record2.branch) ?? null,
45667
+ upstream: readStringValue(record2.upstream) ?? null,
45668
+ upstreamStatus: readStringValue(record2.upstreamStatus, record2.upstream_status) ?? null,
45669
+ headCommit: readStringValue(record2.headCommit, record2.head_commit)?.slice(0, 12) ?? null,
45670
+ ahead: readNumberValue(record2.ahead) ?? null,
45671
+ behind: readNumberValue(record2.behind) ?? null,
45672
+ dirtyCounts: {
45673
+ staged: readNumberValue(record2.staged) ?? 0,
45674
+ modified: readNumberValue(record2.modified) ?? 0,
45675
+ untracked: readNumberValue(record2.untracked) ?? 0,
45676
+ deleted: readNumberValue(record2.deleted) ?? 0,
45677
+ renamed: readNumberValue(record2.renamed) ?? 0
45678
+ },
45679
+ lastCheckedAt: readNumberValue(record2.lastCheckedAt, record2.last_checked_at) ?? null,
45680
+ submoduleCount: submodules.length,
45681
+ submodules
45682
+ };
45683
+ }
45684
+ function summarizeRepoMeshStatusDebug(status) {
45685
+ const nodes = Array.isArray(status?.nodes) ? status.nodes : [];
45686
+ return {
45687
+ success: status?.success,
45688
+ meshId: readStringValue(status?.meshId, status?.mesh_id) ?? null,
45689
+ refreshedAt: readStringValue(status?.refreshedAt, status?.refreshed_at) ?? null,
45690
+ sourceOfTruth: status?.sourceOfTruth ?? null,
45691
+ nodeCount: nodes.length,
45692
+ nodes: nodes.map((node) => ({
45693
+ nodeId: readStringValue(node?.nodeId, node?.id) ?? null,
45694
+ daemonId: readStringValue(node?.daemonId, node?.daemon_id) ?? null,
45695
+ workspace: readStringValue(node?.workspace, node?.git?.workspace) ?? null,
45696
+ health: readStringValue(node?.health) ?? null,
45697
+ machineStatus: readStringValue(node?.machineStatus, node?.machine_status) ?? null,
45698
+ connection: node?.connection && typeof node.connection === "object" ? {
45699
+ state: readStringValue(node.connection.state) ?? null,
45700
+ transport: readStringValue(node.connection.transport) ?? null,
45701
+ source: readStringValue(node.connection.source) ?? null,
45702
+ reported: readBooleanValue(node.connection.reported) ?? null
45703
+ } : null,
45704
+ gitProbePending: node?.gitProbePending === true,
45705
+ launchReady: node?.launchReady === true,
45706
+ git: summarizeRepoMeshDebugGit(node?.git)
45707
+ }))
45708
+ };
45709
+ }
45710
+ function logRepoMeshStatusDebug(event, fields) {
45711
+ try {
45712
+ LOG.info("MeshStatusDebug", `[RepoMeshStatusDebug] ${JSON.stringify({ event, ...fields })}`);
45713
+ } catch {
45714
+ LOG.info("MeshStatusDebug", `[RepoMeshStatusDebug] ${event}`);
45715
+ }
45716
+ }
45653
45717
  function joinRepoPath(root, relativePath) {
45654
45718
  const normalizedRoot = typeof root === "string" ? root.trim().replace(/[\\/]+$/, "") : "";
45655
45719
  const normalizedPath = typeof relativePath === "string" ? relativePath.trim() : "";
@@ -48669,7 +48733,15 @@ ${block}`);
48669
48733
  const refreshRequested = args?.refresh === true || args?.forceRefresh === true;
48670
48734
  if (!refreshRequested) {
48671
48735
  const cachedStatus = this.getCachedAggregateMeshStatus(meshId);
48672
- if (cachedStatus) return cachedStatus;
48736
+ if (cachedStatus) {
48737
+ logRepoMeshStatusDebug("return_cached", {
48738
+ meshId,
48739
+ command: "mesh_status",
48740
+ refreshRequested,
48741
+ summary: summarizeRepoMeshStatusDebug(cachedStatus)
48742
+ });
48743
+ return cachedStatus;
48744
+ }
48673
48745
  }
48674
48746
  const refreshReason = refreshRequested ? "explicit_refresh" : "cold_cache_miss";
48675
48747
  const { getMeshQueueStats: getMeshQueueStats2, getQueue: getQueue2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
@@ -48697,7 +48769,7 @@ ${block}`);
48697
48769
  };
48698
48770
  const directTruthSatisfied = meshRecord.source !== "inline_bootstrap" || directTruth.directEvidenceCount > 0;
48699
48771
  if (requireDirectPeerTruth && !directTruthSatisfied) {
48700
- return {
48772
+ const failureResult = {
48701
48773
  success: false,
48702
48774
  code: "mesh_direct_peer_truth_unavailable",
48703
48775
  error: "Selected coordinator could not confirm direct mesh truth yet. Bootstrap inventory stays unavailable until direct mesh_status probes succeed.",
@@ -48716,6 +48788,14 @@ ${block}`);
48716
48788
  }
48717
48789
  }
48718
48790
  };
48791
+ logRepoMeshStatusDebug("direct_truth_unavailable", {
48792
+ meshId,
48793
+ command: "mesh_status",
48794
+ refreshRequested,
48795
+ meshSource: meshRecord.source,
48796
+ directTruth
48797
+ });
48798
+ return failureResult;
48719
48799
  }
48720
48800
  const directTruthUnavailableNodeIds = new Set(directTruth.unavailableNodeIds);
48721
48801
  const selectedCoordinatorNodeId = readStringValue(
@@ -48923,7 +49003,17 @@ ${block}`);
48923
49003
  queue: { tasks: queue, summary: queueSummary },
48924
49004
  ledger: { entries: ledgerEntries, summary: ledgerSummary }
48925
49005
  };
48926
- return this.rememberAggregateMeshStatus(meshId, statusResult, refreshReason);
49006
+ const rememberedStatus = this.rememberAggregateMeshStatus(meshId, statusResult, refreshReason);
49007
+ logRepoMeshStatusDebug("return_live", {
49008
+ meshId,
49009
+ command: "mesh_status",
49010
+ refreshRequested,
49011
+ refreshReason,
49012
+ meshSource: meshRecord.source,
49013
+ directTruth,
49014
+ summary: summarizeRepoMeshStatusDebug(rememberedStatus)
49015
+ });
49016
+ return rememberedStatus;
48927
49017
  } catch (e) {
48928
49018
  return { success: false, error: e.message };
48929
49019
  }
@@ -67070,6 +67160,84 @@ var daemon_mesh_manager_exports = {};
67070
67160
  __export(daemon_mesh_manager_exports, {
67071
67161
  DaemonMeshManager: () => DaemonMeshManager
67072
67162
  });
67163
+ function asRecord(value) {
67164
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
67165
+ }
67166
+ function summarizeMeshCommandArgs(command, args) {
67167
+ if (command === "git_status") {
67168
+ return {
67169
+ workspace: typeof args.workspace === "string" ? args.workspace : null,
67170
+ refreshUpstream: args.refreshUpstream === true,
67171
+ includeSubmodules: args.includeSubmodules === true
67172
+ };
67173
+ }
67174
+ if (command === "mesh_status" || command === "get_mesh") {
67175
+ const inlineMesh = asRecord(args.inlineMesh);
67176
+ const inlineNodes = Array.isArray(inlineMesh.nodes) ? inlineMesh.nodes : [];
67177
+ return {
67178
+ meshId: typeof args.meshId === "string" ? args.meshId : null,
67179
+ requireDirectPeerTruth: args.requireDirectPeerTruth === true,
67180
+ refresh: args.refresh === true,
67181
+ inlineMeshNodes: inlineNodes.length
67182
+ };
67183
+ }
67184
+ return { keys: Object.keys(args).sort() };
67185
+ }
67186
+ function summarizeMeshCommandGitResult(result) {
67187
+ const envelope = asRecord(result);
67188
+ const nestedResult = asRecord(envelope.result);
67189
+ const status = Object.keys(asRecord(envelope.status)).length ? asRecord(envelope.status) : Object.keys(asRecord(nestedResult.status)).length ? asRecord(nestedResult.status) : Object.keys(envelope).length ? envelope : {};
67190
+ if (!Object.keys(status).length) return null;
67191
+ const submodules = Array.isArray(status.submodules) ? status.submodules.map((entry) => ({
67192
+ path: typeof entry?.path === "string" ? entry.path : null,
67193
+ commit: typeof entry?.commit === "string" ? entry.commit.slice(0, 12) : null,
67194
+ dirty: entry?.dirty === true,
67195
+ outOfSync: entry?.outOfSync === true
67196
+ })) : [];
67197
+ return {
67198
+ workspace: typeof status.workspace === "string" ? status.workspace : null,
67199
+ repoRoot: typeof status.repoRoot === "string" ? status.repoRoot : null,
67200
+ isGitRepo: status.isGitRepo,
67201
+ branch: status.branch ?? null,
67202
+ upstream: status.upstream ?? null,
67203
+ upstreamStatus: status.upstreamStatus ?? null,
67204
+ headCommit: typeof status.headCommit === "string" ? status.headCommit.slice(0, 12) : status.headCommit ?? null,
67205
+ ahead: status.ahead ?? null,
67206
+ behind: status.behind ?? null,
67207
+ dirtyCounts: {
67208
+ staged: status.staged ?? 0,
67209
+ modified: status.modified ?? 0,
67210
+ untracked: status.untracked ?? 0,
67211
+ deleted: status.deleted ?? 0,
67212
+ renamed: status.renamed ?? 0
67213
+ },
67214
+ lastCheckedAt: status.lastCheckedAt ?? null,
67215
+ submoduleCount: submodules.length,
67216
+ submodules
67217
+ };
67218
+ }
67219
+ function summarizeMeshCommandResult(command, result) {
67220
+ if (command === "git_status") return summarizeMeshCommandGitResult(result);
67221
+ const record2 = asRecord(result);
67222
+ if (command === "mesh_status") {
67223
+ const nodes = Array.isArray(record2.nodes) ? record2.nodes : [];
67224
+ return {
67225
+ success: record2.success,
67226
+ meshId: record2.meshId ?? null,
67227
+ sourceOfTruth: record2.sourceOfTruth ?? null,
67228
+ nodeCount: nodes.length,
67229
+ nodes: nodes.map((node) => ({
67230
+ nodeId: node?.nodeId ?? node?.id ?? null,
67231
+ daemonId: node?.daemonId ?? null,
67232
+ workspace: node?.workspace ?? node?.git?.workspace ?? null,
67233
+ health: node?.health ?? null,
67234
+ gitProbePending: node?.gitProbePending === true,
67235
+ git: summarizeMeshCommandGitResult({ status: node?.git })
67236
+ }))
67237
+ };
67238
+ }
67239
+ return null;
67240
+ }
67073
67241
  function interpolateArgs(args, context) {
67074
67242
  const result = {};
67075
67243
  for (const [k, v] of Object.entries(args)) {
@@ -67259,7 +67427,9 @@ var init_daemon_mesh_manager = __esm({
67259
67427
  targetDaemonId,
67260
67428
  sentAt: (/* @__PURE__ */ new Date()).toISOString(),
67261
67429
  peerState: peer.state,
67262
- success: !error48
67430
+ success: !error48,
67431
+ resultSummary: !error48 ? summarizeMeshCommandGitResult(result) : null,
67432
+ error: error48
67263
67433
  });
67264
67434
  } catch (err) {
67265
67435
  LOG.warn("Mesh", `[Mesh] Failed to send command result: ${err.message}`);
@@ -67353,7 +67523,8 @@ var init_daemon_mesh_manager = __esm({
67353
67523
  queuedAt,
67354
67524
  sentAt,
67355
67525
  peerState: peer.state,
67356
- transport: peer.isRelay === true ? "relay" : peer.isRelay === false ? "direct" : "unknown"
67526
+ transport: peer.isRelay === true ? "relay" : peer.isRelay === false ? "direct" : "unknown",
67527
+ argsSummary: summarizeMeshCommandArgs(command, args)
67357
67528
  });
67358
67529
  try {
67359
67530
  peer.dataChannel.sendMessage(JSON.stringify(payload));
@@ -67381,7 +67552,8 @@ var init_daemon_mesh_manager = __esm({
67381
67552
  targetDaemonId,
67382
67553
  queuedAt,
67383
67554
  peerState: peer.state,
67384
- transport: peer.isRelay === true ? "relay" : peer.isRelay === false ? "direct" : "unknown"
67555
+ transport: peer.isRelay === true ? "relay" : peer.isRelay === false ? "direct" : "unknown",
67556
+ argsSummary: summarizeMeshCommandArgs(command, args)
67385
67557
  });
67386
67558
  if (!peer.commandQueue) {
67387
67559
  peer.commandQueue = [];
@@ -67568,7 +67740,8 @@ var init_daemon_mesh_manager = __esm({
67568
67740
  sentAt,
67569
67741
  peerState: entry.state,
67570
67742
  transport: entry.isRelay === true ? "relay" : entry.isRelay === false ? "direct" : "unknown",
67571
- flushed: true
67743
+ flushed: true,
67744
+ argsSummary: summarizeMeshCommandArgs(item.command, item.args)
67572
67745
  });
67573
67746
  dc.sendMessage(JSON.stringify({
67574
67747
  type: "mesh_command",
@@ -67603,7 +67776,8 @@ var init_daemon_mesh_manager = __esm({
67603
67776
  requestId: data.requestId,
67604
67777
  command: data.command,
67605
67778
  senderDaemonId: targetDaemonId,
67606
- receivedAt: (/* @__PURE__ */ new Date()).toISOString()
67779
+ receivedAt: (/* @__PURE__ */ new Date()).toISOString(),
67780
+ argsSummary: summarizeMeshCommandArgs(data.command, asRecord(data.args))
67607
67781
  });
67608
67782
  if (this.commandCallback) {
67609
67783
  this.commandCallback(targetDaemonId, data.command, data.args, data.requestId).catch((e) => {
@@ -67620,7 +67794,9 @@ var init_daemon_mesh_manager = __esm({
67620
67794
  queuedAt: pending.queuedAt,
67621
67795
  sentAt: pending.sentAt,
67622
67796
  receivedAt: (/* @__PURE__ */ new Date()).toISOString(),
67623
- success: data.success === true
67797
+ success: data.success === true,
67798
+ resultSummary: data.success === true ? summarizeMeshCommandResult(pending.command, data.result) : null,
67799
+ error: data.success === true ? void 0 : data.error
67624
67800
  });
67625
67801
  if (data.success) {
67626
67802
  pending.resolve(data.result);
@@ -67890,7 +68066,7 @@ var init_adhdev_daemon = __esm({
67890
68066
  init_version();
67891
68067
  init_src();
67892
68068
  init_runtime_defaults();
67893
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.43" });
68069
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.44" });
67894
68070
  AdhdevDaemon = class _AdhdevDaemon {
67895
68071
  localHttpServer = null;
67896
68072
  localWss = null;