@adhdev/daemon-standalone 1.0.58-rc.15 → 1.0.58-rc.16

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 ? "0b39364ac334ce9649b42e58d5bda606abe274ec" : void 0) ?? "unknown";
36886
- const commitShort = readInjected(true ? "0b39364a" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36887
- const version2 = readInjected(true ? "1.0.58-rc.15" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36888
- const builtAt = readInjected(true ? "2026-08-26T02:38:01.516Z" : void 0);
36885
+ const commit = readInjected(true ? "0ff2241634e4035f73e2d9a41eb69f223706ff3c" : void 0) ?? "unknown";
36886
+ const commitShort = readInjected(true ? "0ff22416" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36887
+ const version2 = readInjected(true ? "1.0.58-rc.16" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36888
+ const builtAt = readInjected(true ? "2026-08-26T06:35:36.671Z" : void 0);
36889
36889
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
36890
36890
  return cached2;
36891
36891
  }
@@ -38284,11 +38284,11 @@ var require_dist3 = __commonJS({
38284
38284
  const override = env2.ADHDEV_CONFIG_DIR;
38285
38285
  if (!override || !override.trim()) return false;
38286
38286
  const sibling = otherTrackConfigDir(env2, homeDir2);
38287
- const normalize5 = (p) => {
38287
+ const normalize6 = (p) => {
38288
38288
  const unified = p.trim().replace(/[\\/]+$/, "").replace(/\\/g, "/");
38289
38289
  return platform11 === "win32" ? unified.toLowerCase() : unified;
38290
38290
  };
38291
- return normalize5(override) === normalize5(sibling);
38291
+ return normalize6(override) === normalize6(sibling);
38292
38292
  }
38293
38293
  function configDirChannelMismatch(resolvedConfigDir, resolvedChannel, hasExplicitChannelSignal) {
38294
38294
  if (hasExplicitChannelSignal) return null;
@@ -52098,6 +52098,15 @@ The instruction it carried was never delivered to anyone. If it still matters, r
52098
52098
  const reclaims = (entry.strandedReclaimCount || 0) + 1;
52099
52099
  const prevNode = entry.assignedNodeId;
52100
52100
  const prevSession = entry.assignedSessionId;
52101
+ const prevProvider = entry.assignedProviderType;
52102
+ entry.lastReclaim = {
52103
+ ...prevProvider ? { providerType: prevProvider } : {},
52104
+ ...prevNode ? { nodeId: prevNode } : {},
52105
+ ...prevSession ? { sessionId: prevSession } : {},
52106
+ reason,
52107
+ reclaimCount: reclaims,
52108
+ at: now
52109
+ };
52101
52110
  delete entry.assignedNodeId;
52102
52111
  delete entry.assignedSessionId;
52103
52112
  delete entry.assignedProviderType;
@@ -52130,9 +52139,15 @@ The instruction it carried was never delivered to anyone. If it still matters, r
52130
52139
  kind: "task_reclaimed",
52131
52140
  nodeId: prevNode,
52132
52141
  sessionId: prevSession,
52142
+ // REDRIVE-PROVIDER-FLIP (a): name the provider being torn down. This is the
52143
+ // "before" half of the flip; the "after" half is the redriveProvenance block
52144
+ // on the next task_dispatched, so the comparison no longer needs a manual
52145
+ // two-entry join.
52146
+ ...prevProvider ? { providerType: prevProvider } : {},
52133
52147
  payload: {
52134
52148
  taskId,
52135
52149
  reason,
52150
+ ...prevProvider ? { providerType: prevProvider } : {},
52136
52151
  ...typeof opts?.ageMs === "number" ? { ageMs: opts.ageMs } : {},
52137
52152
  reclaimCount: reclaims,
52138
52153
  outcome: entry.status
@@ -59168,7 +59183,11 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
59168
59183
  "p2p_dispatch_failed",
59169
59184
  "dispatch_failed",
59170
59185
  "dispatch_duplicate_rebound",
59171
- "queue_hold_hard_deadline"
59186
+ "queue_hold_hard_deadline",
59187
+ // REDRIVE-PROVIDER-FLIP (a): joinable by kind+taskId alongside the task's
59188
+ // task_dispatched/task_reclaimed rows — the whole point is to read a task's
59189
+ // redrive history without an O(n) payload scan.
59190
+ "redrive_provider_changed"
59172
59191
  ]);
59173
59192
  LEDGER_DIR_NAME = "mesh-ledger";
59174
59193
  MAX_FILE_SIZE_BYTES = 10 * 1024 * 1024;
@@ -65199,7 +65218,22 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
65199
65218
  if (wb.confidence !== wa.confidence) return wb.confidence - wa.confidence;
65200
65219
  return wb.remainingPercent - wa.remainingPercent;
65201
65220
  });
65202
- return { clear, gated };
65221
+ const rankingEvidence = clear.map((providerType) => {
65222
+ const session = sessionByProvider?.get(providerType);
65223
+ const reading = session ?? weeklyByProvider.get(providerType);
65224
+ const axis = session ? "session" : "weekly";
65225
+ return {
65226
+ providerType,
65227
+ axis,
65228
+ ...reading ? {
65229
+ risk: reading.risk,
65230
+ confidence: reading.confidence,
65231
+ rankedRisk: rankedRisk(reading),
65232
+ remainingPercent: reading.remainingPercent
65233
+ } : {}
65234
+ };
65235
+ });
65236
+ return { clear, gated, sessionAxisActive, rankingEvidence };
65203
65237
  }
65204
65238
  function resolveRecoveryRelaunchProvider(node, failedProviderType, nodeProviderTypes = [], policy, now = Date.now(), context) {
65205
65239
  if (!failedProviderType) return { action: "block" };
@@ -66172,6 +66206,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
66172
66206
  providerType: candidate.providerType,
66173
66207
  ...candidate.slot.model ? { model: candidate.slot.model } : {},
66174
66208
  selectionRank,
66209
+ fitnessInputRank: selectionRank,
66175
66210
  capacitySortKey: selectionCapacity.available ? 1 : 0,
66176
66211
  capacityAvailable: selectionCapacity.available,
66177
66212
  capacity: taskCapacity,
@@ -66198,8 +66233,16 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
66198
66233
  ...args.ranked.clear,
66199
66234
  ...args.ranked.gated.map((entry) => entry.providerType)
66200
66235
  ]);
66236
+ const evidenceByProvider = new Map(
66237
+ (args.ranked.rankingEvidence ?? []).map((entry, clearOrderIndex) => {
66238
+ const { providerType, ...rest } = entry;
66239
+ return [providerType, { ...rest, clearOrderIndex }];
66240
+ })
66241
+ );
66201
66242
  const quotaDiagnostics = bonusDiagnostics.map((detail) => {
66202
66243
  const { providerType, ...bonus } = detail;
66244
+ const ranking = evidenceByProvider.get(detail.providerType);
66245
+ const withRanking = ranking ? { ranking } : {};
66203
66246
  const gated = args.ranked.gated.find((entry) => entry.providerType === detail.providerType);
66204
66247
  if (!rankedProviders.has(detail.providerType)) {
66205
66248
  return { providerType, bonus, gate: { outcome: "not-evaluated-floor" } };
@@ -66218,7 +66261,8 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
66218
66261
  return {
66219
66262
  providerType,
66220
66263
  bonus,
66221
- gate: failOpen ? { outcome: "fail-open", reason: detail.zeroReason } : { outcome: "clear" }
66264
+ gate: failOpen ? { outcome: "fail-open", reason: detail.zeroReason } : { outcome: "clear" },
66265
+ ...withRanking
66222
66266
  };
66223
66267
  });
66224
66268
  const previewOnly = args.unbounded ? {
@@ -68898,6 +68942,65 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
68898
68942
  init_chat_history();
68899
68943
  }
68900
68944
  });
68945
+ function normalize3(value) {
68946
+ const trimmed = typeof value === "string" ? value.trim() : "";
68947
+ return trimmed ? trimmed : void 0;
68948
+ }
68949
+ function buildRedriveProvenance(lastReclaim, dispatchedProviderType) {
68950
+ if (!lastReclaim) return null;
68951
+ const previousProviderType = normalize3(lastReclaim.providerType);
68952
+ const providerType = normalize3(dispatchedProviderType) ?? dispatchedProviderType;
68953
+ const providerChanged = !!previousProviderType && !!normalize3(dispatchedProviderType) && previousProviderType !== providerType;
68954
+ return {
68955
+ reason: lastReclaim.reason,
68956
+ reclaimCount: lastReclaim.reclaimCount,
68957
+ ...previousProviderType ? { previousProviderType } : {},
68958
+ ...normalize3(lastReclaim.nodeId) ? { previousNodeId: normalize3(lastReclaim.nodeId) } : {},
68959
+ ...normalize3(lastReclaim.sessionId) ? { previousSessionId: normalize3(lastReclaim.sessionId) } : {},
68960
+ reclaimedAt: lastReclaim.at,
68961
+ providerType,
68962
+ providerChanged
68963
+ };
68964
+ }
68965
+ function describeRedriveProviderFlip(provenance, taskId, meshId) {
68966
+ return `Redrive of task ${taskId} on mesh ${meshId} CHANGED PROVIDER: ${provenance.previousProviderType ?? "?"} \u2192 ${provenance.providerType} (reason ${provenance.reason}, reclaim #${provenance.reclaimCount}, previous node=${provenance.previousNodeId ?? "?"} session=${provenance.previousSessionId ?? "?"}). The reclaim path re-claims an idle session WITHOUT recomputing routing, so the task is now running on a provider it was not routed to. Recorded for measurement; no behavior changed here.`;
68967
+ }
68968
+ var init_mesh_redrive_provenance = __esm2({
68969
+ "src/mesh/mesh-redrive-provenance.ts"() {
68970
+ "use strict";
68971
+ }
68972
+ });
68973
+ async function waitForRemoteSessionReady(meshId, nodeId, sessionId, opts) {
68974
+ if (!sessionId) return false;
68975
+ const timeoutMs = opts.timeoutMs ?? REMOTE_LAUNCH_READY_TIMEOUT_MS;
68976
+ const pollMs = opts.pollMs ?? REMOTE_LAUNCH_READY_POLL_MS;
68977
+ const now = opts.now ?? (() => Date.now());
68978
+ const sleep3 = opts.sleep ?? ((ms) => new Promise((resolve31) => setTimeout(resolve31, ms)));
68979
+ const deadline = now() + timeoutMs;
68980
+ for (; ; ) {
68981
+ let ready = false;
68982
+ try {
68983
+ ready = opts.isReady();
68984
+ } catch {
68985
+ return false;
68986
+ }
68987
+ if (ready) return true;
68988
+ if (now() >= deadline) break;
68989
+ await sleep3(pollMs);
68990
+ }
68991
+ LOG2.warn("MeshQueue", `Remote auto-launched session ${sessionId} on node ${nodeId} (mesh ${meshId}) did not report agent:ready within ${timeoutMs}ms; proceeding optimistically \u2014 unchanged behavior, the claim still fires via the normal event/reconcile path`);
68992
+ return false;
68993
+ }
68994
+ var REMOTE_LAUNCH_READY_TIMEOUT_MS;
68995
+ var REMOTE_LAUNCH_READY_POLL_MS;
68996
+ var init_mesh_remote_ready_wait = __esm2({
68997
+ "src/mesh/mesh-remote-ready-wait.ts"() {
68998
+ "use strict";
68999
+ init_logger();
69000
+ REMOTE_LAUNCH_READY_TIMEOUT_MS = 15e3;
69001
+ REMOTE_LAUNCH_READY_POLL_MS = 100;
69002
+ }
69003
+ });
68901
69004
  function isAnthropicProvider(providerType) {
68902
69005
  const p = typeof providerType === "string" ? providerType.trim().toLowerCase() : "";
68903
69006
  return p.length > 0 && ANTHROPIC_PROVIDER_TYPES.has(p);
@@ -70301,6 +70404,9 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
70301
70404
  }
70302
70405
  LOG2.warn("MeshQueue", `Auto-launched session ${sessionId} not interactive after ${LOCAL_LAUNCH_READY_TIMEOUT_MS}ms; dispatching anyway (adapter queue-until-ready will buffer)`);
70303
70406
  }
70407
+ function remoteSessionReadyProbe(meshId, nodeId, sessionId) {
70408
+ return () => MeshRuntimeStore.getInstance().getRemoteIdleSessions(meshId).some((s2) => sessionIdsEquivalent(s2.sessionId, sessionId) && meshNodeIdMatches({ nodeId: s2.nodeId }, nodeId));
70409
+ }
70304
70410
  function recordTaskDispatchedLedger(ctx, deliveryId) {
70305
70411
  const task = ctx.task;
70306
70412
  const routing = ctx.routingDecision;
@@ -70327,6 +70433,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
70327
70433
  ...routing?.selectionTrajectory ? { selectionTrajectory: routing.selectionTrajectory } : {},
70328
70434
  ...routing?.reason ? { reason: routing.reason } : {}
70329
70435
  };
70436
+ const redriveProvenance = buildRedriveProvenance(task.lastReclaim, ctx.providerType);
70330
70437
  appendLedgerEntry(ctx.meshId, {
70331
70438
  kind: "task_dispatched",
70332
70439
  nodeId: ctx.nodeId,
@@ -70341,9 +70448,30 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
70341
70448
  ...ctx.sourceCoordinatorSessionId ? { coordinatorSessionId: ctx.sourceCoordinatorSessionId } : {},
70342
70449
  ...ctx.sourceCoordinatorDaemonId ? { coordinatorDaemonId: ctx.sourceCoordinatorDaemonId } : {},
70343
70450
  ...Array.isArray(task.requiredTags) && task.requiredTags.length ? { requiredTags: task.requiredTags } : {},
70344
- routingDecision
70451
+ routingDecision,
70452
+ ...redriveProvenance ? { redriveProvenance } : {}
70345
70453
  }
70346
70454
  });
70455
+ if (redriveProvenance?.providerChanged) {
70456
+ LOG2.warn("MeshQueue", describeRedriveProviderFlip(redriveProvenance, task.id, ctx.meshId));
70457
+ traceMeshEventStage("redrive_provider_changed", {
70458
+ taskId: task.id,
70459
+ sessionId: ctx.sessionId,
70460
+ nodeId: ctx.nodeId,
70461
+ meshId: ctx.meshId
70462
+ }, `${redriveProvenance.previousProviderType} \u2192 ${redriveProvenance.providerType} (${redriveProvenance.reason}, reclaim #${redriveProvenance.reclaimCount})`);
70463
+ try {
70464
+ appendLedgerEntry(ctx.meshId, {
70465
+ kind: "redrive_provider_changed",
70466
+ nodeId: ctx.nodeId,
70467
+ sessionId: ctx.sessionId,
70468
+ providerType: ctx.providerType,
70469
+ taskId: task.id,
70470
+ payload: { taskId: task.id, deliveryId, transport: ctx.transport, ...redriveProvenance }
70471
+ });
70472
+ } catch {
70473
+ }
70474
+ }
70347
70475
  }
70348
70476
  function deliverTaskToSession(dispatchThunk, ctx, warmup) {
70349
70477
  const delivery = createSessionDelivery({
@@ -71320,6 +71448,11 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
71320
71448
  logAutoLaunchQuotaFallbackSuccess(resolved, task.id, nodeId, remoteSessionId || void 0);
71321
71449
  autoLaunchCooldownUntil.set(launchKey, Date.now() + AUTO_LAUNCH_COOLDOWN_MS);
71322
71450
  sweepExpiredCooldowns();
71451
+ if (remoteSessionId) {
71452
+ await waitForRemoteSessionReady(meshId, nodeId, remoteSessionId, {
71453
+ isReady: remoteSessionReadyProbe(meshId, nodeId, remoteSessionId)
71454
+ }).catch(() => false);
71455
+ }
71323
71456
  return true;
71324
71457
  }
71325
71458
  markAutoLaunch(meshId, task.id, { status: "started", nodeId, providerType: effectiveProviderType, ...effectiveModel ? { model: effectiveModel } : {}, ...effectiveThinkingLevel ? { thinkingLevel: effectiveThinkingLevel } : {} });
@@ -71577,6 +71710,8 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
71577
71710
  init_mesh_runtime_store();
71578
71711
  init_mesh_claim_refusal();
71579
71712
  init_mesh_event_trace();
71713
+ init_mesh_redrive_provenance();
71714
+ init_mesh_remote_ready_wait();
71580
71715
  init_mesh_warmup_deadline();
71581
71716
  init_repo_mesh_types();
71582
71717
  init_mesh_json_config();
@@ -79042,7 +79177,7 @@ ${cleanBody}`;
79042
79177
  nodeId: row.assignedNodeId,
79043
79178
  meshId,
79044
79179
  event: "agent:generating_started"
79045
- }, `delivered_not_consumed ${Math.round(ageMs2 / 1e3)}s \u2192 ${redriven.status}`);
79180
+ }, `delivered_not_consumed ${Math.round(ageMs2 / 1e3)}s \u2192 ${redriven.status}${row.assignedProviderType ? ` (provider ${row.assignedProviderType} released; the re-claim adopts an idle session without re-ranking, so it may differ)` : ""}`);
79046
79181
  continue;
79047
79182
  }
79048
79183
  }
@@ -92542,6 +92677,7 @@ ${e?.stderr || ""}`;
92542
92677
  init_mesh_routing_decision();
92543
92678
  init_mesh_scheduling_fitness();
92544
92679
  init_mesh_work_queue();
92680
+ var QUOTA_STAGE_NOTE = "fitnessOrder/fitnessWinner(=fitnessOrderHead) are the INPUT order to quota ranking, not a result. The selected provider is `winner`; per-candidate ranking numbers are in quotaDiagnostics[].ranking.";
92545
92681
  function providerReportedDisabled(node, providerType) {
92546
92682
  return node?.nodeFacts?.providerEnablement?.[providerType]?.enabled === false;
92547
92683
  }
@@ -92587,7 +92723,15 @@ ${e?.stderr || ""}`;
92587
92723
  stages: {
92588
92724
  difficultyFloor: { required: difficultyFloorRequired, admittedSlots: [], excludedSlots: [] },
92589
92725
  fitness: [],
92590
- quota: { fitnessOrder: [], clearOrder: [], gated: [], reordered: false }
92726
+ quota: {
92727
+ fitnessOrder: [],
92728
+ clearOrder: [],
92729
+ gated: [],
92730
+ reordered: false,
92731
+ note: QUOTA_STAGE_NOTE,
92732
+ axis: "weekly",
92733
+ sessionAxisActive: false
92734
+ }
92591
92735
  },
92592
92736
  quotaDiagnostics: []
92593
92737
  };
@@ -92615,7 +92759,7 @@ ${e?.stderr || ""}`;
92615
92759
  return { ...slotIdentity(candidate), reason: reason2 };
92616
92760
  });
92617
92761
  const fitnessOrder = selection.candidates.map((candidate) => candidate.providerType);
92618
- const fitnessWinner = fitnessOrder[0];
92762
+ const fitnessOrderHead = fitnessOrder[0];
92619
92763
  const winner = selection.winner?.providerType;
92620
92764
  const winnerIndex = selection.winner ? usableSlots.indexOf(selection.winner) : -1;
92621
92765
  const winnerScore = winnerIndex >= 0 ? scores[winnerIndex] : void 0;
@@ -92645,10 +92789,13 @@ ${e?.stderr || ""}`;
92645
92789
  providerType: entry.providerType,
92646
92790
  reason: entry.block.reason
92647
92791
  })),
92648
- ...fitnessWinner ? { fitnessWinner } : {},
92792
+ ...fitnessOrderHead ? { fitnessWinner: fitnessOrderHead, fitnessOrderHead } : {},
92793
+ note: QUOTA_STAGE_NOTE,
92649
92794
  ...winner ? { winner } : {},
92650
- reordered: !!winner && !!fitnessWinner && winner !== fitnessWinner,
92651
- ...winner && fitnessWinner && winner !== fitnessWinner ? { displacedFitnessWinner: fitnessWinner } : {}
92795
+ reordered: !!winner && !!fitnessOrderHead && winner !== fitnessOrderHead,
92796
+ ...winner && fitnessOrderHead && winner !== fitnessOrderHead ? { displacedFitnessWinner: fitnessOrderHead } : {},
92797
+ axis: selection.ranked.sessionAxisActive ? "session" : "weekly",
92798
+ sessionAxisActive: selection.ranked.sessionAxisActive === true
92652
92799
  }
92653
92800
  },
92654
92801
  quotaDiagnostics: selection.diagnostics.quotaDiagnostics ?? []
@@ -109883,8 +110030,8 @@ ${marker}`,
109883
110030
  const landedQuestion = readFocusedClaudeTuiQuestion(landed.screenText);
109884
110031
  const rereadQuestion = readFocusedClaudeTuiQuestion(reread);
109885
110032
  if (!landedQuestion || !rereadQuestion) return true;
109886
- const normalize5 = (text) => text.replace(/\s+/g, " ").trim();
109887
- return normalize5(landedQuestion.question) === normalize5(rereadQuestion.question);
110033
+ const normalize6 = (text) => text.replace(/\s+/g, " ").trim();
110034
+ return normalize6(landedQuestion.question) === normalize6(rereadQuestion.question);
109888
110035
  }
109889
110036
  async captureClaudeTuiPrompt(firstScreen, headers) {
109890
110037
  if (this.claudeTuiCaptureSuppressed) return;
@@ -110101,8 +110248,8 @@ ${marker}`,
110101
110248
  };
110102
110249
  }
110103
110250
  function isPathInsideWorkspace(configPath, workspace) {
110104
- const normalize5 = (value) => value.replace(/[\\/]+$/, "");
110105
- const ws = normalize5(workspace);
110251
+ const normalize6 = (value) => value.replace(/[\\/]+$/, "");
110252
+ const ws = normalize6(workspace);
110106
110253
  if (!ws) return false;
110107
110254
  const separatorAgnostic = (value) => value.replace(/\\/g, "/");
110108
110255
  const normalizedPath = separatorAgnostic(configPath);
@@ -123469,9 +123616,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
123469
123616
  }
123470
123617
  }
123471
123618
  compareVersions(a, b) {
123472
- const normalize5 = (v) => v.split(/[-_+]/)[0].split(".").map((x) => parseInt(x, 10) || 0);
123473
- const pa = normalize5(a);
123474
- const pb = normalize5(b);
123619
+ const normalize6 = (v) => v.split(/[-_+]/)[0].split(".").map((x) => parseInt(x, 10) || 0);
123620
+ const pa = normalize6(a);
123621
+ const pb = normalize6(b);
123475
123622
  for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
123476
123623
  const va = pa[i] || 0;
123477
123624
  const vb = pb[i] || 0;