@adhdev/daemon-standalone 0.9.82-rc.269 → 0.9.82-rc.270

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
@@ -29735,6 +29735,15 @@ var require_dist3 = __commonJS({
29735
29735
  mod
29736
29736
  ));
29737
29737
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
29738
+ function resolveDelegatedWorkerAutoApprove(meshPolicy, nodePolicy) {
29739
+ if (typeof nodePolicy?.delegatedWorkerAutoApprove === "boolean") {
29740
+ return nodePolicy.delegatedWorkerAutoApprove;
29741
+ }
29742
+ if (typeof meshPolicy?.delegatedWorkerAutoApprove === "boolean") {
29743
+ return meshPolicy.delegatedWorkerAutoApprove;
29744
+ }
29745
+ return true;
29746
+ }
29738
29747
  var DEFAULT_MESH_POLICY;
29739
29748
  var init_repo_mesh_types = __esm2({
29740
29749
  "src/repo-mesh-types.ts"() {
@@ -29748,6 +29757,7 @@ var require_dist3 = __commonJS({
29748
29757
  dirtyWorkspaceBehavior: "warn",
29749
29758
  maxParallelTasks: 2,
29750
29759
  spawnedSessionVisibility: "visible",
29760
+ delegatedWorkerAutoApprove: true,
29751
29761
  sessionCleanupOnNodeRemove: "preserve",
29752
29762
  autoFastForward: { enabled: true },
29753
29763
  maxTaskRetries: 1
@@ -29973,10 +29983,10 @@ var require_dist3 = __commonJS({
29973
29983
  }
29974
29984
  function getDaemonBuildInfo() {
29975
29985
  if (cached2) return cached2;
29976
- const commit = readInjected(true ? "025d8bef81a66e7b44a5ba5d5a04e063db46db4e" : void 0) ?? "unknown";
29977
- const commitShort = readInjected(true ? "025d8bef" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
29978
- const version2 = readInjected(true ? "0.9.82-rc.269" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
29979
- const builtAt = readInjected(true ? "2026-06-14T22:12:06.668Z" : void 0);
29986
+ const commit = readInjected(true ? "7004ebf6e270fbcb990f3fd66542fd77db0eeea0" : void 0) ?? "unknown";
29987
+ const commitShort = readInjected(true ? "7004ebf6" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
29988
+ const version2 = readInjected(true ? "0.9.82-rc.270" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
29989
+ const builtAt = readInjected(true ? "2026-06-14T23:52:34.807Z" : void 0);
29980
29990
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
29981
29991
  return cached2;
29982
29992
  }
@@ -35919,6 +35929,23 @@ ${rendered}`, "utf-8");
35919
35929
  const cb = canonicalDaemonId(b);
35920
35930
  return ca !== "" && ca === cb;
35921
35931
  }
35932
+ function buildMeshWorkerRelayStamp(currentSettings, meshContext) {
35933
+ if (!meshContext) return void 0;
35934
+ const settings = currentSettings && typeof currentSettings === "object" ? currentSettings : {};
35935
+ const stamp = {};
35936
+ const meshId = readNonEmptyString2(meshContext.meshId);
35937
+ if (meshId && !readNonEmptyString2(settings.meshNodeFor)) stamp.meshNodeFor = meshId;
35938
+ const nodeId = readNonEmptyString2(meshContext.nodeId);
35939
+ if (nodeId && !readNonEmptyString2(settings.meshNodeId)) stamp.meshNodeId = nodeId;
35940
+ const coordinatorDaemonId = readNonEmptyString2(meshContext.coordinatorDaemonId);
35941
+ if (coordinatorDaemonId && !readNonEmptyString2(settings.meshCoordinatorDaemonId)) {
35942
+ stamp.meshCoordinatorDaemonId = coordinatorDaemonId;
35943
+ }
35944
+ if ((meshId || nodeId || coordinatorDaemonId) && settings.launchedByCoordinator !== true) {
35945
+ stamp.launchedByCoordinator = true;
35946
+ }
35947
+ return Object.keys(stamp).length > 0 ? stamp : void 0;
35948
+ }
35922
35949
  function resolveEventSessionId(event, fallback) {
35923
35950
  return readNonEmptyString2(event.targetSessionId) || readNonEmptyString2(event.sessionId) || readNonEmptyString2(event.instanceId) || readNonEmptyString2(fallback);
35924
35951
  }
@@ -37236,7 +37263,14 @@ Next step: ${nextStep}`;
37236
37263
  try {
37237
37264
  const inst = components.instanceManager.getInstance(sessionId);
37238
37265
  if (inst && typeof inst.updateSettings === "function") {
37239
- inst.updateSettings({ meshNodeFor: meshId, meshNodeId: nodeId, launchedByCoordinator: true });
37266
+ const localDaemonId = readNonEmptyString2(loadConfig2().machineId);
37267
+ inst.updateSettings({
37268
+ meshNodeFor: meshId,
37269
+ meshNodeId: nodeId,
37270
+ launchedByCoordinator: true,
37271
+ autoApprove: resolveDelegatedWorkerAutoApprove(mesh?.policy, node?.policy),
37272
+ ...localDaemonId ? { meshCoordinatorDaemonId: localDaemonId } : {}
37273
+ });
37240
37274
  }
37241
37275
  } catch {
37242
37276
  }
@@ -37525,6 +37559,10 @@ Next step: ${nextStep}`;
37525
37559
  meshNodeFor: meshId,
37526
37560
  meshNodeId: nodeId,
37527
37561
  spawnedSessionVisibility: mesh?.policy?.spawnedSessionVisibility || "hidden",
37562
+ // Coordinator-dispatched worker: auto-approve unless mesh/node policy
37563
+ // opts out (default true). Lands in settingsOverride and beats the
37564
+ // global per-provider-type autoApprove config (see shouldAutoApprove).
37565
+ autoApprove: resolveDelegatedWorkerAutoApprove(mesh?.policy, node?.policy),
37528
37566
  launchedByCoordinator: true,
37529
37567
  autoLaunchedForQueueTaskId: task.id
37530
37568
  }
@@ -38065,6 +38103,9 @@ Next step: ${nextStep}`;
38065
38103
  meshNodeFor: args.meshId,
38066
38104
  meshNodeId: node.id,
38067
38105
  spawnedSessionVisibility: mesh?.policy?.spawnedSessionVisibility || "hidden",
38106
+ // Coordinator-dispatched recovery relaunch: same auto-approve
38107
+ // policy as the primary worker launch path.
38108
+ autoApprove: resolveDelegatedWorkerAutoApprove(mesh?.policy, node?.policy),
38068
38109
  launchedByCoordinator: true
38069
38110
  }
38070
38111
  }).catch((e) => LOG2.error("MeshRecovery", `Failed to auto-relaunch session for ${node.id}: ${e?.message}`));
@@ -38309,6 +38350,7 @@ Next step: ${nextStep}`;
38309
38350
  init_mesh_runtime_store();
38310
38351
  init_mesh_events_pending();
38311
38352
  init_mesh_routing();
38353
+ init_repo_mesh_types();
38312
38354
  init_mesh_events_stale();
38313
38355
  init_mesh_events_utils();
38314
38356
  REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
@@ -43428,25 +43470,36 @@ ${lastSnapshot}`;
43428
43470
  let to = total;
43429
43471
  if (sec.anchor !== void 0) {
43430
43472
  try {
43431
- const re = new RegExp(sec.anchor, sec.anchor_flags ?? "");
43432
- const prevRe = sec.anchor_context?.prev !== void 0 ? new RegExp(sec.anchor_context.prev, sec.anchor_context.prev_flags ?? "") : null;
43433
- const nextRe = sec.anchor_context?.next !== void 0 ? new RegExp(sec.anchor_context.next, sec.anchor_context.next_flags ?? "") : null;
43434
- const matches = (i) => re.test(lines[i]) && (prevRe === null || i > 0 && prevRe.test(lines[i - 1])) && (nextRe === null || i < total - 1 && nextRe.test(lines[i + 1]));
43473
+ const anchorPatterns = Array.isArray(sec.anchor) ? sec.anchor : [sec.anchor];
43474
+ const sharedCtx = Array.isArray(sec.anchor_context) ? null : sec.anchor_context ?? null;
43475
+ const ctxList = Array.isArray(sec.anchor_context) ? sec.anchor_context : anchorPatterns.map(() => sharedCtx);
43476
+ const candidates = anchorPatterns.map((pattern, k) => {
43477
+ const ctx = ctxList[k] ?? null;
43478
+ return {
43479
+ re: new RegExp(pattern, sec.anchor_flags ?? ""),
43480
+ prevRe: ctx?.prev !== void 0 ? new RegExp(ctx.prev, ctx.prev_flags ?? "") : null,
43481
+ nextRe: ctx?.next !== void 0 ? new RegExp(ctx.next, ctx.next_flags ?? "") : null
43482
+ };
43483
+ });
43484
+ const matchesCandidate = (c, i) => c.re.test(lines[i]) && (c.prevRe === null || i > 0 && c.prevRe.test(lines[i - 1])) && (c.nextRe === null || i < total - 1 && c.nextRe.test(lines[i + 1]));
43435
43485
  let idx = -1;
43436
- if (sec.anchor_last) {
43437
- for (let i = total - 1; i >= 0; i--) {
43438
- if (matches(i)) {
43439
- idx = i;
43440
- break;
43486
+ for (const c of candidates) {
43487
+ if (sec.anchor_last) {
43488
+ for (let i = total - 1; i >= 0; i--) {
43489
+ if (matchesCandidate(c, i)) {
43490
+ idx = i;
43491
+ break;
43492
+ }
43441
43493
  }
43442
- }
43443
- } else {
43444
- for (let i = 0; i < total; i++) {
43445
- if (matches(i)) {
43446
- idx = i;
43447
- break;
43494
+ } else {
43495
+ for (let i = 0; i < total; i++) {
43496
+ if (matchesCandidate(c, i)) {
43497
+ idx = i;
43498
+ break;
43499
+ }
43448
43500
  }
43449
43501
  }
43502
+ if (idx !== -1) break;
43450
43503
  }
43451
43504
  if (idx !== -1) {
43452
43505
  from = idx;
@@ -44542,6 +44595,7 @@ ${lastSnapshot}`;
44542
44595
  resolveChatMessageKind: () => resolveChatMessageKind,
44543
44596
  resolveCurrentGlobalInstallSurface: () => resolveCurrentGlobalInstallSurface,
44544
44597
  resolveDebugRuntimeConfig: () => resolveDebugRuntimeConfig,
44598
+ resolveDelegatedWorkerAutoApprove: () => resolveDelegatedWorkerAutoApprove,
44545
44599
  resolveDeliveryDecision: () => resolveDeliveryDecision,
44546
44600
  resolveGitRepository: () => resolveGitRepository,
44547
44601
  resolveMeshHostStatus: () => resolveMeshHostStatus,
@@ -59097,8 +59151,19 @@ ${formatManifestValidationIssues2(validation.issues)}`,
59097
59151
  this.stateEnteredAt = now;
59098
59152
  this.prevStateAt = now;
59099
59153
  this.adapter.start();
59154
+ this.scheduleSpawnPrime();
59100
59155
  this.scheduleWakeForState();
59101
59156
  }
59157
+ scheduleSpawnPrime() {
59158
+ const seqs = this.spec.send_on_spawn;
59159
+ if (!Array.isArray(seqs) || seqs.length === 0) return;
59160
+ const delay = Math.max(0, this.spec.send_on_spawn_delay_ms ?? 250);
59161
+ setTimeout(() => {
59162
+ for (const seq of seqs) {
59163
+ if (typeof seq === "string" && seq.length > 0) this.adapter.send_keys(seq);
59164
+ }
59165
+ }, delay);
59166
+ }
59102
59167
  dispatch(cmd) {
59103
59168
  switch (cmd.kind) {
59104
59169
  case "send_message":
@@ -59286,6 +59351,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
59286
59351
  this.commitTransition(ev.fired, now, ev);
59287
59352
  this.emitStateChanged(forceEmit);
59288
59353
  this.scheduleWakeForState();
59354
+ this.maybeMarkReady();
59289
59355
  return;
59290
59356
  }
59291
59357
  this.emitStateChanged(forceEmit);
@@ -69199,6 +69265,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
69199
69265
  init_mesh_coordinator();
69200
69266
  init_mesh_events();
69201
69267
  init_mesh_routing();
69268
+ init_mesh_events_utils();
69202
69269
  init_mesh_host_ownership();
69203
69270
  init_mesh_fast_forward();
69204
69271
  var import_node_child_process4 = require("child_process");
@@ -74087,6 +74154,27 @@ ${hintLines.join("\n")}` : "",
74087
74154
  return this.deps.cliManager.handleCliCommand(cmd, args);
74088
74155
  }
74089
74156
  case "agent_command": {
74157
+ {
74158
+ const dispatchSessionId = readStringValue(args?.targetSessionId, args?.sessionId, args?.instanceId);
74159
+ const dispatchMeshContext = args?.meshContext;
74160
+ if (dispatchSessionId && dispatchMeshContext) {
74161
+ try {
74162
+ const inst = this.deps.instanceManager.getInstance(dispatchSessionId);
74163
+ if (inst && typeof inst.updateSettings === "function") {
74164
+ const stamp = buildMeshWorkerRelayStamp(
74165
+ inst.getState?.()?.settings,
74166
+ {
74167
+ meshId: dispatchMeshContext.meshId,
74168
+ nodeId: dispatchMeshContext.nodeId,
74169
+ coordinatorDaemonId: dispatchMeshContext.coordinatorDaemonId
74170
+ }
74171
+ );
74172
+ if (stamp) inst.updateSettings(stamp);
74173
+ }
74174
+ } catch {
74175
+ }
74176
+ }
74177
+ }
74090
74178
  const agentResult = await this.deps.cliManager.handleCliCommand(cmd, args);
74091
74179
  const meshCtx = args?.meshContext;
74092
74180
  const dispatchNodeId = readStringValue(meshCtx?.nodeId);