@adhdev/daemon-core 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.d.ts CHANGED
@@ -8,7 +8,7 @@ export type { SessionEntry, CompactSessionEntry, CompactDaemonEntry, CloudDaemon
8
8
  export type { InteractivePrompt, InteractiveQuestion, InteractiveOption, InteractivePromptResponse, InteractiveAnswer, } from './providers/types/interactive-prompt.js';
9
9
  export { normalizeInteractivePrompt, normalizeInteractivePromptResponse, buildClaudeInteractiveToolResult, interactivePromptFromClaudeAskUserQuestion, detectClaudeAskUserQuestionPromptFromJson, } from './providers/types/interactive-prompt.js';
10
10
  export type { RepoMesh, RepoMeshDaemonRole, RepoMeshHostMetadata, RepoMeshHostPairingMetadata, RepoMeshHostStatus, RepoMeshNode, RepoMeshNodeHealth, RepoMeshPolicy, RepoMeshNodePolicy, RepoMeshRelatedRepo, RepoMeshNodeCapabilities, DetectedCommand, ProjectContextSnapshot, ProjectContextSource, RepoMeshCoordinatorConfig, LocalMeshConfig, LocalMeshEntry, LocalMeshNodeEntry, RepoMeshStatus, RepoMeshNodeStatus, RepoMeshSessionStatus, RepoMeshQueueTask, RepoMeshQueueTaskStatus, RepoMeshQueueSummary, RepoMeshQueueStatus, RepoMeshLedgerEntryStatus, RepoMeshLedgerSummaryStatus, RepoMeshLedgerStatus, MeshAsyncJobLifecycle, } from './repo-mesh-types.js';
11
- export { DEFAULT_MESH_POLICY } from './repo-mesh-types.js';
11
+ export { DEFAULT_MESH_POLICY, resolveDelegatedWorkerAutoApprove } from './repo-mesh-types.js';
12
12
  export * from './git/index.js';
13
13
  import type { RuntimeWriteOwner as _RuntimeWriteOwner } from './shared-types-extra.js';
14
14
  import type { RuntimeAttachedClient as _RuntimeAttachedClient } from './shared-types-extra.js';
package/dist/index.js CHANGED
@@ -31,6 +31,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
33
  // src/repo-mesh-types.ts
34
+ function resolveDelegatedWorkerAutoApprove(meshPolicy, nodePolicy) {
35
+ if (typeof nodePolicy?.delegatedWorkerAutoApprove === "boolean") {
36
+ return nodePolicy.delegatedWorkerAutoApprove;
37
+ }
38
+ if (typeof meshPolicy?.delegatedWorkerAutoApprove === "boolean") {
39
+ return meshPolicy.delegatedWorkerAutoApprove;
40
+ }
41
+ return true;
42
+ }
34
43
  var DEFAULT_MESH_POLICY;
35
44
  var init_repo_mesh_types = __esm({
36
45
  "src/repo-mesh-types.ts"() {
@@ -44,6 +53,7 @@ var init_repo_mesh_types = __esm({
44
53
  dirtyWorkspaceBehavior: "warn",
45
54
  maxParallelTasks: 2,
46
55
  spawnedSessionVisibility: "visible",
56
+ delegatedWorkerAutoApprove: true,
47
57
  sessionCleanupOnNodeRemove: "preserve",
48
58
  autoFastForward: { enabled: true },
49
59
  maxTaskRetries: 1
@@ -265,10 +275,10 @@ function readInjected(value) {
265
275
  }
266
276
  function getDaemonBuildInfo() {
267
277
  if (cached) return cached;
268
- const commit = readInjected(true ? "025d8bef81a66e7b44a5ba5d5a04e063db46db4e" : void 0) ?? "unknown";
269
- const commitShort = readInjected(true ? "025d8bef" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
270
- const version = readInjected(true ? "0.9.82-rc.269" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
271
- const builtAt = readInjected(true ? "2026-06-14T22:11:38.134Z" : void 0);
278
+ const commit = readInjected(true ? "7004ebf6e270fbcb990f3fd66542fd77db0eeea0" : void 0) ?? "unknown";
279
+ const commitShort = readInjected(true ? "7004ebf6" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
280
+ const version = readInjected(true ? "0.9.82-rc.270" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
281
+ const builtAt = readInjected(true ? "2026-06-14T23:52:09.523Z" : void 0);
272
282
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
273
283
  return cached;
274
284
  }
@@ -6160,6 +6170,23 @@ function sameDaemonId(a, b) {
6160
6170
  const cb = canonicalDaemonId(b);
6161
6171
  return ca !== "" && ca === cb;
6162
6172
  }
6173
+ function buildMeshWorkerRelayStamp(currentSettings, meshContext) {
6174
+ if (!meshContext) return void 0;
6175
+ const settings = currentSettings && typeof currentSettings === "object" ? currentSettings : {};
6176
+ const stamp = {};
6177
+ const meshId = readNonEmptyString2(meshContext.meshId);
6178
+ if (meshId && !readNonEmptyString2(settings.meshNodeFor)) stamp.meshNodeFor = meshId;
6179
+ const nodeId = readNonEmptyString2(meshContext.nodeId);
6180
+ if (nodeId && !readNonEmptyString2(settings.meshNodeId)) stamp.meshNodeId = nodeId;
6181
+ const coordinatorDaemonId = readNonEmptyString2(meshContext.coordinatorDaemonId);
6182
+ if (coordinatorDaemonId && !readNonEmptyString2(settings.meshCoordinatorDaemonId)) {
6183
+ stamp.meshCoordinatorDaemonId = coordinatorDaemonId;
6184
+ }
6185
+ if ((meshId || nodeId || coordinatorDaemonId) && settings.launchedByCoordinator !== true) {
6186
+ stamp.launchedByCoordinator = true;
6187
+ }
6188
+ return Object.keys(stamp).length > 0 ? stamp : void 0;
6189
+ }
6163
6190
  function resolveEventSessionId(event, fallback) {
6164
6191
  return readNonEmptyString2(event.targetSessionId) || readNonEmptyString2(event.sessionId) || readNonEmptyString2(event.instanceId) || readNonEmptyString2(fallback);
6165
6192
  }
@@ -7475,7 +7502,14 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
7475
7502
  try {
7476
7503
  const inst = components.instanceManager.getInstance(sessionId);
7477
7504
  if (inst && typeof inst.updateSettings === "function") {
7478
- inst.updateSettings({ meshNodeFor: meshId, meshNodeId: nodeId, launchedByCoordinator: true });
7505
+ const localDaemonId = readNonEmptyString2(loadConfig().machineId);
7506
+ inst.updateSettings({
7507
+ meshNodeFor: meshId,
7508
+ meshNodeId: nodeId,
7509
+ launchedByCoordinator: true,
7510
+ autoApprove: resolveDelegatedWorkerAutoApprove(mesh?.policy, node?.policy),
7511
+ ...localDaemonId ? { meshCoordinatorDaemonId: localDaemonId } : {}
7512
+ });
7479
7513
  }
7480
7514
  } catch {
7481
7515
  }
@@ -7764,6 +7798,10 @@ async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
7764
7798
  meshNodeFor: meshId,
7765
7799
  meshNodeId: nodeId,
7766
7800
  spawnedSessionVisibility: mesh?.policy?.spawnedSessionVisibility || "hidden",
7801
+ // Coordinator-dispatched worker: auto-approve unless mesh/node policy
7802
+ // opts out (default true). Lands in settingsOverride and beats the
7803
+ // global per-provider-type autoApprove config (see shouldAutoApprove).
7804
+ autoApprove: resolveDelegatedWorkerAutoApprove(mesh?.policy, node?.policy),
7767
7805
  launchedByCoordinator: true,
7768
7806
  autoLaunchedForQueueTaskId: task.id
7769
7807
  }
@@ -8304,6 +8342,9 @@ function injectMeshSystemMessage(components, args) {
8304
8342
  meshNodeFor: args.meshId,
8305
8343
  meshNodeId: node.id,
8306
8344
  spawnedSessionVisibility: mesh?.policy?.spawnedSessionVisibility || "hidden",
8345
+ // Coordinator-dispatched recovery relaunch: same auto-approve
8346
+ // policy as the primary worker launch path.
8347
+ autoApprove: resolveDelegatedWorkerAutoApprove(mesh?.policy, node?.policy),
8307
8348
  launchedByCoordinator: true
8308
8349
  }
8309
8350
  }).catch((e) => LOG.error("MeshRecovery", `Failed to auto-relaunch session for ${node.id}: ${e?.message}`));
@@ -8535,6 +8576,7 @@ var init_mesh_events_coordinator = __esm({
8535
8576
  init_mesh_runtime_store();
8536
8577
  init_mesh_events_pending();
8537
8578
  init_mesh_routing();
8579
+ init_repo_mesh_types();
8538
8580
  init_mesh_events_stale();
8539
8581
  init_mesh_events_utils();
8540
8582
  REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
@@ -13662,25 +13704,36 @@ function resolveSections(sectionsObj, lines) {
13662
13704
  let to = total;
13663
13705
  if (sec.anchor !== void 0) {
13664
13706
  try {
13665
- const re = new RegExp(sec.anchor, sec.anchor_flags ?? "");
13666
- const prevRe = sec.anchor_context?.prev !== void 0 ? new RegExp(sec.anchor_context.prev, sec.anchor_context.prev_flags ?? "") : null;
13667
- const nextRe = sec.anchor_context?.next !== void 0 ? new RegExp(sec.anchor_context.next, sec.anchor_context.next_flags ?? "") : null;
13668
- 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]));
13707
+ const anchorPatterns = Array.isArray(sec.anchor) ? sec.anchor : [sec.anchor];
13708
+ const sharedCtx = Array.isArray(sec.anchor_context) ? null : sec.anchor_context ?? null;
13709
+ const ctxList = Array.isArray(sec.anchor_context) ? sec.anchor_context : anchorPatterns.map(() => sharedCtx);
13710
+ const candidates = anchorPatterns.map((pattern, k) => {
13711
+ const ctx = ctxList[k] ?? null;
13712
+ return {
13713
+ re: new RegExp(pattern, sec.anchor_flags ?? ""),
13714
+ prevRe: ctx?.prev !== void 0 ? new RegExp(ctx.prev, ctx.prev_flags ?? "") : null,
13715
+ nextRe: ctx?.next !== void 0 ? new RegExp(ctx.next, ctx.next_flags ?? "") : null
13716
+ };
13717
+ });
13718
+ 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]));
13669
13719
  let idx = -1;
13670
- if (sec.anchor_last) {
13671
- for (let i = total - 1; i >= 0; i--) {
13672
- if (matches(i)) {
13673
- idx = i;
13674
- break;
13720
+ for (const c of candidates) {
13721
+ if (sec.anchor_last) {
13722
+ for (let i = total - 1; i >= 0; i--) {
13723
+ if (matchesCandidate(c, i)) {
13724
+ idx = i;
13725
+ break;
13726
+ }
13675
13727
  }
13676
- }
13677
- } else {
13678
- for (let i = 0; i < total; i++) {
13679
- if (matches(i)) {
13680
- idx = i;
13681
- break;
13728
+ } else {
13729
+ for (let i = 0; i < total; i++) {
13730
+ if (matchesCandidate(c, i)) {
13731
+ idx = i;
13732
+ break;
13733
+ }
13682
13734
  }
13683
13735
  }
13736
+ if (idx !== -1) break;
13684
13737
  }
13685
13738
  if (idx !== -1) {
13686
13739
  from = idx;
@@ -14769,6 +14822,7 @@ __export(index_exports, {
14769
14822
  resolveChatMessageKind: () => resolveChatMessageKind,
14770
14823
  resolveCurrentGlobalInstallSurface: () => resolveCurrentGlobalInstallSurface,
14771
14824
  resolveDebugRuntimeConfig: () => resolveDebugRuntimeConfig,
14825
+ resolveDelegatedWorkerAutoApprove: () => resolveDelegatedWorkerAutoApprove,
14772
14826
  resolveDeliveryDecision: () => resolveDeliveryDecision,
14773
14827
  resolveGitRepository: () => resolveGitRepository,
14774
14828
  resolveMeshHostStatus: () => resolveMeshHostStatus,
@@ -29486,8 +29540,19 @@ var FsmDriver = class {
29486
29540
  this.stateEnteredAt = now;
29487
29541
  this.prevStateAt = now;
29488
29542
  this.adapter.start();
29543
+ this.scheduleSpawnPrime();
29489
29544
  this.scheduleWakeForState();
29490
29545
  }
29546
+ scheduleSpawnPrime() {
29547
+ const seqs = this.spec.send_on_spawn;
29548
+ if (!Array.isArray(seqs) || seqs.length === 0) return;
29549
+ const delay = Math.max(0, this.spec.send_on_spawn_delay_ms ?? 250);
29550
+ setTimeout(() => {
29551
+ for (const seq of seqs) {
29552
+ if (typeof seq === "string" && seq.length > 0) this.adapter.send_keys(seq);
29553
+ }
29554
+ }, delay);
29555
+ }
29491
29556
  dispatch(cmd) {
29492
29557
  switch (cmd.kind) {
29493
29558
  case "send_message":
@@ -29675,6 +29740,7 @@ var FsmDriver = class {
29675
29740
  this.commitTransition(ev.fired, now, ev);
29676
29741
  this.emitStateChanged(forceEmit);
29677
29742
  this.scheduleWakeForState();
29743
+ this.maybeMarkReady();
29678
29744
  return;
29679
29745
  }
29680
29746
  this.emitStateChanged(forceEmit);
@@ -39644,6 +39710,7 @@ init_logger();
39644
39710
  init_mesh_coordinator();
39645
39711
  init_mesh_events();
39646
39712
  init_mesh_routing();
39713
+ init_mesh_events_utils();
39647
39714
  init_mesh_host_ownership();
39648
39715
  init_mesh_fast_forward();
39649
39716
 
@@ -44546,6 +44613,27 @@ ${hintLines.join("\n")}` : "",
44546
44613
  return this.deps.cliManager.handleCliCommand(cmd, args);
44547
44614
  }
44548
44615
  case "agent_command": {
44616
+ {
44617
+ const dispatchSessionId = readStringValue(args?.targetSessionId, args?.sessionId, args?.instanceId);
44618
+ const dispatchMeshContext = args?.meshContext;
44619
+ if (dispatchSessionId && dispatchMeshContext) {
44620
+ try {
44621
+ const inst = this.deps.instanceManager.getInstance(dispatchSessionId);
44622
+ if (inst && typeof inst.updateSettings === "function") {
44623
+ const stamp = buildMeshWorkerRelayStamp(
44624
+ inst.getState?.()?.settings,
44625
+ {
44626
+ meshId: dispatchMeshContext.meshId,
44627
+ nodeId: dispatchMeshContext.nodeId,
44628
+ coordinatorDaemonId: dispatchMeshContext.coordinatorDaemonId
44629
+ }
44630
+ );
44631
+ if (stamp) inst.updateSettings(stamp);
44632
+ }
44633
+ } catch {
44634
+ }
44635
+ }
44636
+ }
44549
44637
  const agentResult = await this.deps.cliManager.handleCliCommand(cmd, args);
44550
44638
  const meshCtx = args?.meshContext;
44551
44639
  const dispatchNodeId = readStringValue(meshCtx?.nodeId);
@@ -56155,6 +56243,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
56155
56243
  resolveChatMessageKind,
56156
56244
  resolveCurrentGlobalInstallSurface,
56157
56245
  resolveDebugRuntimeConfig,
56246
+ resolveDelegatedWorkerAutoApprove,
56158
56247
  resolveDeliveryDecision,
56159
56248
  resolveGitRepository,
56160
56249
  resolveMeshHostStatus,