@adhdev/daemon-standalone 1.0.58-rc.10 → 1.0.58-rc.12

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
@@ -36882,10 +36882,10 @@ var require_dist3 = __commonJS({
36882
36882
  }
36883
36883
  function getDaemonBuildInfo() {
36884
36884
  if (cached2) return cached2;
36885
- const commit = readInjected(true ? "d5a700991e9d580252c1191b7f2f4600e4915e3d" : void 0) ?? "unknown";
36886
- const commitShort = readInjected(true ? "d5a70099" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36887
- const version2 = readInjected(true ? "1.0.58-rc.10" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36888
- const builtAt = readInjected(true ? "2026-08-24T19:45:32.110Z" : void 0);
36885
+ const commit = readInjected(true ? "530605d8d33a09d5e072b440a9634ba8dc909737" : void 0) ?? "unknown";
36886
+ const commitShort = readInjected(true ? "530605d8" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36887
+ const version2 = readInjected(true ? "1.0.58-rc.12" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36888
+ const builtAt = readInjected(true ? "2026-08-25T05:36:54.741Z" : void 0);
36889
36889
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
36890
36890
  return cached2;
36891
36891
  }
@@ -39463,7 +39463,7 @@ var require_dist3 = __commonJS({
39463
39463
  init_types();
39464
39464
  init_deps();
39465
39465
  DEFAULT_BASE_URL = "https://daily-cloudcode-pa.googleapis.com/v1internal";
39466
- ANTIGRAVITY_USER_AGENT_VERSION = "1.1.16";
39466
+ ANTIGRAVITY_USER_AGENT_VERSION = "1.1.19";
39467
39467
  REQUEST_TIMEOUT_MS = 1e4;
39468
39468
  EXPIRY_SKEW_MS = 5e3;
39469
39469
  CRED_STORE_TIMEOUT_MS = 5e3;
@@ -44929,6 +44929,7 @@ ${error48.message || ""}`;
44929
44929
  normalizeCapabilityTags: () => normalizeCapabilityTags,
44930
44930
  normalizeMagiSlots: () => normalizeMagiSlots,
44931
44931
  normalizeRepoIdentity: () => normalizeRepoIdentity,
44932
+ readMeshConfigFromDisk: () => readMeshConfigFromDisk,
44932
44933
  removeMagiKindPanel: () => removeMagiKindPanel,
44933
44934
  removeNode: () => removeNode,
44934
44935
  resolveScopedMeshId: () => resolveScopedMeshId,
@@ -44936,6 +44937,7 @@ ${error48.message || ""}`;
44936
44937
  setMagiKindPanel: () => setMagiKindPanel,
44937
44938
  setMeshHostPin: () => setMeshHostPin,
44938
44939
  setMeshQuotaRouting: () => setMeshQuotaRouting,
44940
+ statMeshConfigFile: () => statMeshConfigFile,
44939
44941
  tokenIdForManualPairing: () => tokenIdForManualPairing,
44940
44942
  updateMesh: () => updateMesh,
44941
44943
  updateNode: () => updateNode
@@ -44987,17 +44989,28 @@ ${error48.message || ""}`;
44987
44989
  release2();
44988
44990
  }
44989
44991
  }
44990
- function readMeshConfigFile() {
44992
+ function readMeshConfigFromDisk() {
44991
44993
  const path63 = getMeshConfigPath();
44992
- if (!(0, import_fs5.existsSync)(path63)) return { meshes: [] };
44994
+ if (!(0, import_fs5.existsSync)(path63)) return null;
44993
44995
  try {
44994
44996
  const raw = JSON.parse((0, import_fs5.readFileSync)(path63, "utf-8"));
44995
- if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
44997
+ if (!raw || !Array.isArray(raw.meshes)) return null;
44996
44998
  return raw;
44997
44999
  } catch {
44998
- return { meshes: [] };
45000
+ return null;
44999
45001
  }
45000
45002
  }
45003
+ function statMeshConfigFile() {
45004
+ try {
45005
+ const stat2 = (0, import_fs5.statSync)(getMeshConfigPath());
45006
+ return { mtimeMs: stat2.mtimeMs, size: stat2.size };
45007
+ } catch {
45008
+ return null;
45009
+ }
45010
+ }
45011
+ function readMeshConfigFile() {
45012
+ return readMeshConfigFromDisk() ?? { meshes: [] };
45013
+ }
45001
45014
  function loadMeshConfig(options = {}) {
45002
45015
  const config2 = readMeshConfigFile();
45003
45016
  const migrated = migrateLoadedMeshConfig(config2);
@@ -52730,6 +52743,21 @@ The instruction it carried was never delivered to anyone. If it still matters, r
52730
52743
  ).all(meshId, limit);
52731
52744
  return rows.map(mapGraphRow);
52732
52745
  }
52746
+ /** Exact size of the same mesh/status window exposed by listGraphsByMesh. */
52747
+ countGraphsByMesh(meshId, opts) {
52748
+ const statuses = opts?.statuses;
52749
+ if (statuses && statuses.length > 0) {
52750
+ const placeholders = statuses.map(() => "?").join(",");
52751
+ const row2 = this.db.prepare(
52752
+ `SELECT COUNT(*) AS count FROM mesh_task_graphs WHERE mesh_id = ? AND status IN (${placeholders})`
52753
+ ).get(meshId, ...statuses);
52754
+ return row2.count;
52755
+ }
52756
+ const row = this.db.prepare(
52757
+ `SELECT COUNT(*) AS count FROM mesh_task_graphs WHERE mesh_id = ?`
52758
+ ).get(meshId);
52759
+ return row.count;
52760
+ }
52733
52761
  /**
52734
52762
  * Phase-E: replace the graph's normalized policy document. Used at plan-commit
52735
52763
  * time to attach the enqueue-decision provenance record next to the persisted
@@ -54594,6 +54622,8 @@ The instruction it carried was never delivered to anyone. If it still matters, r
54594
54622
  if (reporterDaemonBuildVersion) git3.reporterDaemonBuildVersion = reporterDaemonBuildVersion;
54595
54623
  const reporterMemberState = normalizeReportedMemberState(remoteResult?.reporterMemberState);
54596
54624
  if (reporterMemberState) git3.reporterMemberState = reporterMemberState;
54625
+ const reporterNodeFacts = normalizeMeshNodeFacts(remoteResult?.reporterNodeFacts);
54626
+ if (reporterNodeFacts) git3.reporterNodeFacts = reporterNodeFacts;
54597
54627
  return git3;
54598
54628
  }
54599
54629
  function readMeshConnectionState(connection) {
@@ -92255,6 +92285,17 @@ ${e?.stderr || ""}`;
92255
92285
  };
92256
92286
  });
92257
92287
  }
92288
+ function countMeshGraphViews(meshId, opts = {}) {
92289
+ const graphStore = MeshRuntimeStore.getInstance().graphStore();
92290
+ if (opts.graphId) {
92291
+ const graph = graphStore.getGraph(opts.graphId);
92292
+ return graph && graph.meshId === meshId ? 1 : 0;
92293
+ }
92294
+ if (opts.batchId) return graphStore.getGraphByBatchId(meshId, opts.batchId) ? 1 : 0;
92295
+ return graphStore.countGraphsByMesh(meshId, {
92296
+ ...opts.activeOnly === false ? {} : { statuses: IN_FLIGHT_GRAPH_STATUSES }
92297
+ });
92298
+ }
92258
92299
  function describeNodeFeatures(baseSpecJson) {
92259
92300
  let spec;
92260
92301
  try {
@@ -108443,8 +108484,10 @@ ${marker}`,
108443
108484
  * which is exactly the reported "1개일 때는 항상 동작, 2~3개일 때 꼬인다"
108444
108485
  * split. Set by writeRaw() when a keystroke arrives while the picker footer
108445
108486
  * is on screen; while set, no capture starts and any in-flight capture
108446
- * bails before its next injected key. Cleared once the picker footer leaves
108447
- * the screen (the next prompt may capture again).
108487
+ * bails before its next injected key. Cleared once the picker footer has
108488
+ * stayed off the screen across the repaint-grace window — a single
108489
+ * footer-less frame is claude mid-repaint, not a closed picker (the next
108490
+ * prompt may capture again after the grace elapses).
108448
108491
  */
108449
108492
  claudeTuiCaptureSuppressed = false;
108450
108493
  /**
@@ -108456,6 +108499,19 @@ ${marker}`,
108456
108499
  * the count resets when the picker leaves the screen.
108457
108500
  */
108458
108501
  claudeTuiCaptureFailures = null;
108502
+ /**
108503
+ * Wall clock of the first consecutive frame on which the picker footer was
108504
+ * absent. claude-cli repaints the picker across several PTY chunks (see
108505
+ * interactivePromptLostAt), so ONE footer-less frame is not proof the
108506
+ * picker left — clearing the owner-input latch on such a frame re-armed
108507
+ * capture mid-repaint and restarted Tab/Shift-Tab injection while the
108508
+ * owner was typing (the residual of the submit-tangle bug with the latch
108509
+ * already in place). The latch and the failure budget therefore re-arm
108510
+ * only after the footer has stayed absent for
108511
+ * INTERACTIVE_PROMPT_LOST_GRACE_MS — the same hysteresis the prompt-lost
108512
+ * path already uses.
108513
+ */
108514
+ claudeTuiCaptureFooterAbsentAt = null;
108459
108515
  /** Max capture attempts per prompt identity before giving up (one retry). */
108460
108516
  static CLAUDE_TUI_CAPTURE_MAX_ATTEMPTS = 2;
108461
108517
  /**
@@ -108800,7 +108856,7 @@ ${marker}`,
108800
108856
  }
108801
108857
  writeRaw(data) {
108802
108858
  try {
108803
- if (!this.claudeTuiCaptureSuppressed && this.interactivePromptScheme() === "claude_tui" && this.driver.snapshot().includes("Enter to select")) {
108859
+ if (!this.claudeTuiCaptureSuppressed && this.interactivePromptScheme() === "claude_tui" && (this.driver.snapshot().includes("Enter to select") || this.activeInteractivePrompt !== null || this.claudeTuiPromptCaptureInFlight)) {
108804
108860
  this.claudeTuiCaptureSuppressed = true;
108805
108861
  }
108806
108862
  } catch {
@@ -109384,10 +109440,15 @@ ${marker}`,
109384
109440
  if (this.interactivePromptScheme() !== "claude_tui" || this.activeInteractivePrompt || this.claudeTuiPromptCaptureInFlight) return;
109385
109441
  const screenText = this.driver.snapshot();
109386
109442
  if (!screenText.includes("Enter to select")) {
109387
- this.claudeTuiCaptureSuppressed = false;
109388
- this.claudeTuiCaptureFailures = null;
109443
+ const now = Date.now();
109444
+ if (this.claudeTuiCaptureFooterAbsentAt === null) this.claudeTuiCaptureFooterAbsentAt = now;
109445
+ if (now - this.claudeTuiCaptureFooterAbsentAt >= _SpecCliAdapter.INTERACTIVE_PROMPT_LOST_GRACE_MS) {
109446
+ this.claudeTuiCaptureSuppressed = false;
109447
+ this.claudeTuiCaptureFailures = null;
109448
+ }
109389
109449
  return;
109390
109450
  }
109451
+ this.claudeTuiCaptureFooterAbsentAt = null;
109391
109452
  const headers = this.readClaudeTuiHeaders(screenText);
109392
109453
  if (headers.length === 0) {
109393
109454
  const prompt = detectClaudeAskUserQuestionPromptFromTuiPages([{ screenText }], {
@@ -125952,12 +126013,14 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
125952
126013
  if (!meshId) return { success: false, error: "meshId is required" };
125953
126014
  const includeTerminal = args?.includeTerminal === true;
125954
126015
  try {
125955
- const graphs = buildMeshGraphViews(meshId, {
126016
+ const viewOptions = {
125956
126017
  activeOnly: !includeTerminal,
125957
126018
  ...typeof args?.limit === "number" && args.limit > 0 ? { limit: Math.min(100, args.limit) } : {}
125958
- });
126019
+ };
126020
+ const graphs = buildMeshGraphViews(meshId, viewOptions);
126021
+ const totalGraphCount = countMeshGraphViews(meshId, viewOptions);
125959
126022
  const pendingCoordinatorActions = graphs.flatMap((g) => (g.nextCoordinatorAction ?? []).map((a) => ({ graphId: g.graphId, ...a })));
125960
- return { success: true, meshId, graphCount: graphs.length, graphs, pendingCoordinatorActions };
126023
+ return { success: true, meshId, graphCount: graphs.length, totalGraphCount, graphs, pendingCoordinatorActions };
125961
126024
  } catch (e) {
125962
126025
  return { success: false, error: `graph overview failed: ${e?.message || e}` };
125963
126026
  }
@@ -127705,6 +127768,8 @@ ${ptyResult.output.slice(-2e3)}`);
127705
127768
  }
127706
127769
  init_debug_trace();
127707
127770
  init_mesh_host_ownership();
127771
+ init_repo_mesh_types();
127772
+ init_mesh_config();
127708
127773
  var fs58 = __toESM2(require("fs"));
127709
127774
  init_mesh_node_identity();
127710
127775
  init_router_refine();
@@ -128854,7 +128919,7 @@ ${ptyResult.output.slice(-2e3)}`);
128854
128919
  role: "member"
128855
128920
  };
128856
128921
  }
128857
- var DaemonCommandRouter = class {
128922
+ var DaemonCommandRouter = class _DaemonCommandRouter {
128858
128923
  /** Public (not private) so the extracted ./router-refine.ts orchestration can reach it via `self`. */
128859
128924
  deps;
128860
128925
  /** In-memory cache for cloud-originating meshes passed via inlineMesh.
@@ -128873,6 +128938,15 @@ ${ptyResult.output.slice(-2e3)}`);
128873
128938
  /** Coordinator-owned whole-mesh aggregate status snapshots. Browser callers read this by default.
128874
128939
  * Public (not private) so the extracted ./router-aggregate-status.ts orchestration can reach it via `self`. */
128875
128940
  aggregateMeshStatusCache = /* @__PURE__ */ new Map();
128941
+ /**
128942
+ * meshes.json policy resync state (see syncInlineMeshPoliciesFromDisk).
128943
+ * checkedAtMs throttles the stat; mtimeMs/size are the last-seen file
128944
+ * identity. -1 = no baseline recorded yet: the first check RECORDS the
128945
+ * baseline without applying, so a stale local file mirror can never
128946
+ * regress a fresher inline (cloud-coordinator) policy — only edits made
128947
+ * while this daemon is alive and watching are pulled into memory.
128948
+ */
128949
+ meshPolicyDiskSync = { checkedAtMs: 0, mtimeMs: -1, size: -1 };
128876
128950
  /** Shared per-peer git_status probe dedup + recently-probed reuse gate.
128877
128951
  * Spans separate mesh_status/get_mesh calls so the dashboard auto-retry
128878
128952
  * loop cannot storm a slow peer with back-to-back refreshUpstream probes. */
@@ -128916,7 +128990,67 @@ ${ptyResult.output.slice(-2e3)}`);
128916
128990
  rememberAggregateMeshStatus(meshId, snapshot, refreshReason) {
128917
128991
  return rememberAggregateMeshStatus(this, meshId, snapshot, refreshReason);
128918
128992
  }
128993
+ /**
128994
+ * meshes.json → inline-cache policy resync (mtime-triggered lazy reload).
128995
+ *
128996
+ * Out-of-band edits to meshes.json (an operator hand-editing a policy flag)
128997
+ * never reached the inline mesh cache: command-path updates (update_mesh)
128998
+ * rewrite BOTH disk and cache, but a direct file edit changed nothing in
128999
+ * memory, so mesh_status / refine gating kept serving the boot-time policy
129000
+ * until a daemon restart (live evidence 2026-08-25: requireApprovalForPush
129001
+ * flipped to false on disk 92 min after daemon boot; the daemon kept
129002
+ * reporting and enforcing true).
129003
+ *
129004
+ * Fix: on inline-cache reads, stat meshes.json (throttled — routing and
129005
+ * status polling are hot paths); when the file changed, re-apply ONLY each
129006
+ * cached mesh's `policy` block from disk. Policy-only, never nodes/meshHost:
129007
+ * the inline cache is the coordinator's live node truth, and the daemon's
129008
+ * own mutators read-modify-write through disk, so they already carry the
129009
+ * edit forward — overwriting the whole cached mesh here would clobber
129010
+ * in-flight node truth for zero benefit. A changed policy also busts the
129011
+ * aggregate status snapshot, whose scheduling projection is derived from it.
129012
+ *
129013
+ * Safety rules:
129014
+ * - unparseable file (torn mid-edit write) → keep the in-memory policy,
129015
+ * log only. Never fall back to defaults: that would silently LOOSEN
129016
+ * security flags (requireApprovalForPush / requireApprovalForDestructiveGit).
129017
+ * - mesh absent from disk (deleted, or inline-only cloud mesh) → keep the
129018
+ * cache entry untouched.
129019
+ */
129020
+ syncInlineMeshPoliciesFromDisk() {
129021
+ if (this.inlineMeshCache.size === 0) return;
129022
+ const now = Date.now();
129023
+ const sync = this.meshPolicyDiskSync;
129024
+ if (now - sync.checkedAtMs < _DaemonCommandRouter.MESH_POLICY_DISK_SYNC_THROTTLE_MS) return;
129025
+ sync.checkedAtMs = now;
129026
+ const stat2 = statMeshConfigFile();
129027
+ if (!stat2) return;
129028
+ if (stat2.mtimeMs === sync.mtimeMs && stat2.size === sync.size) return;
129029
+ const hadBaseline = sync.mtimeMs >= 0;
129030
+ sync.mtimeMs = stat2.mtimeMs;
129031
+ sync.size = stat2.size;
129032
+ if (!hadBaseline) return;
129033
+ const disk = readMeshConfigFromDisk();
129034
+ if (!disk) {
129035
+ console.warn("[mesh-config] meshes.json changed but is unparseable (mid-edit?) \u2014 keeping in-memory mesh policies");
129036
+ return;
129037
+ }
129038
+ const diskPolicyByMeshId = /* @__PURE__ */ new Map();
129039
+ for (const mesh of disk.meshes) {
129040
+ if (mesh?.id && mesh.policy && typeof mesh.policy === "object") diskPolicyByMeshId.set(mesh.id, mesh.policy);
129041
+ }
129042
+ for (const [meshId, cached5] of this.inlineMeshCache) {
129043
+ const diskPolicy = diskPolicyByMeshId.get(meshId);
129044
+ if (!diskPolicy) continue;
129045
+ const nextPolicy = mergeAndNormalizePolicy(void 0, diskPolicy);
129046
+ if (JSON.stringify(cached5?.policy ?? null) === JSON.stringify(nextPolicy)) continue;
129047
+ cached5.policy = nextPolicy;
129048
+ this.invalidateAggregateMeshStatus(meshId);
129049
+ }
129050
+ }
129051
+ static MESH_POLICY_DISK_SYNC_THROTTLE_MS = 250;
128919
129052
  getCachedInlineMeshNodes() {
129053
+ this.syncInlineMeshPoliciesFromDisk();
128920
129054
  const nodes = [];
128921
129055
  for (const mesh of this.inlineMeshCache.values()) {
128922
129056
  if (Array.isArray(mesh?.nodes)) {
@@ -128936,6 +129070,7 @@ ${ptyResult.output.slice(-2e3)}`);
128936
129070
  * the mesh policy is absent, matching the worker-launch stamp.
128937
129071
  */
128938
129072
  getCachedInlineMeshNodesWithVisibility() {
129073
+ this.syncInlineMeshPoliciesFromDisk();
128939
129074
  const out = [];
128940
129075
  for (const mesh of this.inlineMeshCache.values()) {
128941
129076
  const spawnedSessionVisibility = mesh?.policy?.spawnedSessionVisibility === "visible" ? "visible" : "hidden";
@@ -128956,6 +129091,7 @@ ${ptyResult.output.slice(-2e3)}`);
128956
129091
  return resolveRemoteMeshSessionOwnerDaemonId(this, sessionId, ownerNodeIdHint);
128957
129092
  }
128958
129093
  getCachedInlineMesh(meshId, inlineMesh) {
129094
+ this.syncInlineMeshPoliciesFromDisk();
128959
129095
  if (inlineMesh && typeof inlineMesh === "object") {
128960
129096
  return this.warmInlineMeshCache(meshId, inlineMesh);
128961
129097
  }