@adhdev/daemon-standalone 1.0.37-rc.2 → 1.0.37-rc.3

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
@@ -33318,10 +33318,10 @@ var require_dist3 = __commonJS({
33318
33318
  }
33319
33319
  function getDaemonBuildInfo() {
33320
33320
  if (cached2) return cached2;
33321
- const commit = readInjected(true ? "a86f0e1d7667ccd2aaadbdeebda2d5c3507fb489" : void 0) ?? "unknown";
33322
- const commitShort = readInjected(true ? "a86f0e1d" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
33323
- const version2 = readInjected(true ? "1.0.37-rc.2" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
33324
- const builtAt = readInjected(true ? "2026-08-05T10:31:16.400Z" : void 0);
33321
+ const commit = readInjected(true ? "7f1c20b94c404bc36baed33fd980cf3bf937c103" : void 0) ?? "unknown";
33322
+ const commitShort = readInjected(true ? "7f1c20b9" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
33323
+ const version2 = readInjected(true ? "1.0.37-rc.3" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
33324
+ const builtAt = readInjected(true ? "2026-08-05T14:31:28.346Z" : void 0);
33325
33325
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
33326
33326
  return cached2;
33327
33327
  }
@@ -34569,6 +34569,15 @@ var require_dist3 = __commonJS({
34569
34569
  };
34570
34570
  }
34571
34571
  });
34572
+ var DEFAULT_DAEMON_PORT2;
34573
+ var DAEMON_WS_PATH2;
34574
+ var init_ipc_protocol = __esm2({
34575
+ "src/ipc-protocol.ts"() {
34576
+ "use strict";
34577
+ DEFAULT_DAEMON_PORT2 = 19222;
34578
+ DAEMON_WS_PATH2 = "/ipc";
34579
+ }
34580
+ });
34572
34581
  function setLogLevel(level) {
34573
34582
  currentLevel = level;
34574
34583
  daemonLog("Logger", `Log level set to: ${level}`, "info");
@@ -34590,13 +34599,25 @@ var require_dist3 = __commonJS({
34590
34599
  function getDateStr() {
34591
34600
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
34592
34601
  }
34602
+ function setLogInstancePort2(port) {
34603
+ const next = Number.isFinite(port) && port > 0 && port !== DEFAULT_DAEMON_PORT2 ? String(Math.floor(port)) : null;
34604
+ if (next === logInstanceTag) return;
34605
+ logInstanceTag = next;
34606
+ currentLogFile = path32.join(currentLogDir, daemonLogFileName(currentDate));
34607
+ }
34608
+ function getLogInstanceTag() {
34609
+ return logInstanceTag;
34610
+ }
34611
+ function daemonLogFileName(dateStr) {
34612
+ return logInstanceTag ? `daemon-${logInstanceTag}-${dateStr}.log` : `daemon-${dateStr}.log`;
34613
+ }
34593
34614
  function getDaemonLogDir() {
34594
34615
  const dir = resolveLogDir();
34595
34616
  prepareLogDirOnce(dir);
34596
34617
  return dir;
34597
34618
  }
34598
34619
  function getCurrentDaemonLogPath(date5 = /* @__PURE__ */ new Date()) {
34599
- return path32.join(getDaemonLogDir(), `daemon-${date5.toISOString().slice(0, 10)}.log`);
34620
+ return path32.join(getDaemonLogDir(), daemonLogFileName(date5.toISOString().slice(0, 10)));
34600
34621
  }
34601
34622
  function refreshCurrentLogFile() {
34602
34623
  const today = getDateStr();
@@ -34607,7 +34628,7 @@ var require_dist3 = __commonJS({
34607
34628
  currentDate = today;
34608
34629
  currentLogDir = dir;
34609
34630
  currentLogDirEnv = process.env.ADHDEV_CONFIG_DIR;
34610
- currentLogFile = path32.join(dir, `daemon-${today}.log`);
34631
+ currentLogFile = path32.join(dir, daemonLogFileName(today));
34611
34632
  if (dirChanged) prepareLogDirOnce(dir);
34612
34633
  else if (dateChanged) cleanOldLogs(dir);
34613
34634
  return true;
@@ -34622,7 +34643,7 @@ var require_dist3 = __commonJS({
34622
34643
  cutoff.setDate(cutoff.getDate() - MAX_LOG_DAYS);
34623
34644
  const cutoffStr = cutoff.toISOString().slice(0, 10);
34624
34645
  for (const file2 of files) {
34625
- const dateMatch = file2.match(/daemon-(\d{4}-\d{2}-\d{2})/);
34646
+ const dateMatch = file2.match(/^daemon-(?:\d+-)?(\d{4}-\d{2}-\d{2})/);
34626
34647
  if (dateMatch && dateMatch[1] < cutoffStr) {
34627
34648
  try {
34628
34649
  fs22.unlinkSync(path32.join(logDir, file2));
@@ -34788,6 +34809,7 @@ var require_dist3 = __commonJS({
34788
34809
  var MAX_LOG_SIZE;
34789
34810
  var MAX_LOG_DAYS;
34790
34811
  var MAX_SIZE_ROTATION_GENERATIONS;
34812
+ var logInstanceTag;
34791
34813
  var currentDate;
34792
34814
  var currentLogDir;
34793
34815
  var currentLogFile;
@@ -34808,15 +34830,17 @@ var require_dist3 = __commonJS({
34808
34830
  path32 = __toESM2(require("path"));
34809
34831
  os6 = __toESM2(require("os"));
34810
34832
  init_async_batch_writer();
34833
+ init_ipc_protocol();
34811
34834
  LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
34812
34835
  LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
34813
34836
  currentLevel = "info";
34814
34837
  MAX_LOG_SIZE = 5 * 1024 * 1024;
34815
34838
  MAX_LOG_DAYS = 7;
34816
34839
  MAX_SIZE_ROTATION_GENERATIONS = 3;
34840
+ logInstanceTag = null;
34817
34841
  currentDate = getDateStr();
34818
34842
  currentLogDir = resolveLogDir();
34819
- currentLogFile = path32.join(currentLogDir, `daemon-${currentDate}.log`);
34843
+ currentLogFile = path32.join(currentLogDir, daemonLogFileName(currentDate));
34820
34844
  preparedLogDirs = /* @__PURE__ */ new Set();
34821
34845
  writeCount = 0;
34822
34846
  currentLogDirEnv = process.env.ADHDEV_CONFIG_DIR;
@@ -36334,6 +36358,9 @@ child.on('exit', () => process.exit(0));
36334
36358
  QUOTA_CACHE_VERSION = 1;
36335
36359
  }
36336
36360
  });
36361
+ function quotaProviderEnabledFromLoader(loader2) {
36362
+ return (provider) => loader2.isMachineProviderEnabled(provider);
36363
+ }
36337
36364
  function toWireQuota(quota) {
36338
36365
  return quota;
36339
36366
  }
@@ -36347,7 +36374,7 @@ child.on('exit', () => process.exit(0));
36347
36374
  }
36348
36375
  return false;
36349
36376
  }
36350
- function hydrateQuotaCacheFromDisk(env2 = process.env) {
36377
+ function hydrateQuotaCacheFromDisk(env2 = process.env, isEnabled) {
36351
36378
  if (hydrated) return 0;
36352
36379
  hydrated = true;
36353
36380
  let restored;
@@ -36361,6 +36388,7 @@ child.on('exit', () => process.exit(0));
36361
36388
  let count = 0;
36362
36389
  for (const [provider, quota] of Object.entries(restored)) {
36363
36390
  if (cache.has(provider)) continue;
36391
+ if (isEnabled && !isEnabled(provider)) continue;
36364
36392
  cache.set(provider, quota);
36365
36393
  hydratedOnly.add(provider);
36366
36394
  count += 1;
@@ -36368,9 +36396,18 @@ child.on('exit', () => process.exit(0));
36368
36396
  if (count > 0) LOG2.info("Quota", `Restored ${count} provider quota snapshot(s) from the on-disk cache`);
36369
36397
  return count;
36370
36398
  }
36371
- async function refreshQuotaCacheOnce(fetchers = REFRESHERS) {
36399
+ async function refreshQuotaCacheOnce(fetchers = REFRESHERS, isEnabled) {
36400
+ const active = isEnabled ? fetchers.filter(({ provider }) => isEnabled(provider)) : fetchers;
36401
+ if (isEnabled) {
36402
+ for (const { provider } of fetchers) {
36403
+ if (!isEnabled(provider)) {
36404
+ cache.delete(provider);
36405
+ hydratedOnly.delete(provider);
36406
+ }
36407
+ }
36408
+ }
36372
36409
  await Promise.all(
36373
- fetchers.map(async ({ provider, fetch: fetch2 }) => {
36410
+ active.map(async ({ provider, fetch: fetch2 }) => {
36374
36411
  try {
36375
36412
  cache.set(provider, toWireQuota(await fetch2()));
36376
36413
  hydratedOnly.delete(provider);
@@ -36401,6 +36438,7 @@ child.on('exit', () => process.exit(0));
36401
36438
  }
36402
36439
  function startQuotaRefreshLoop(options) {
36403
36440
  const intervalMs = options.intervalMs ?? QUOTA_REFRESH_INTERVAL_MS;
36441
+ const fetchers = options.fetchers ?? REFRESHERS;
36404
36442
  let running = false;
36405
36443
  const timer = setInterval(() => {
36406
36444
  if (running) return;
@@ -36410,9 +36448,10 @@ child.on('exit', () => process.exit(0));
36410
36448
  } catch {
36411
36449
  active = false;
36412
36450
  }
36413
- if (!active) return;
36451
+ const needsBackfill = options.isEnabled ? fetchers.some(({ provider }) => options.isEnabled(provider) && !cache.has(provider)) : false;
36452
+ if (!active && !needsBackfill) return;
36414
36453
  running = true;
36415
- void refreshQuotaCacheOnce(options.fetchers).catch((e) => LOG2.warn("Quota", `Quota refresh tick error: ${e?.message || e}`)).finally(() => {
36454
+ void refreshQuotaCacheOnce(fetchers, options.isEnabled).catch((e) => LOG2.warn("Quota", `Quota refresh tick error: ${e?.message || e}`)).finally(() => {
36416
36455
  running = false;
36417
36456
  });
36418
36457
  }, intervalMs);
@@ -36427,13 +36466,14 @@ child.on('exit', () => process.exit(0));
36427
36466
  }
36428
36467
  function setupQuotaRefreshLoop(components) {
36429
36468
  return startQuotaRefreshLoop({
36430
- hasRecentCliActivity: () => hasRecentCliActivity(components.instanceManager.collectHotChatSessionStates())
36469
+ hasRecentCliActivity: () => hasRecentCliActivity(components.instanceManager.collectHotChatSessionStates()),
36470
+ isEnabled: components.providerLoader ? quotaProviderEnabledFromLoader(components.providerLoader) : void 0
36431
36471
  });
36432
36472
  }
36433
- function refreshQuotaCacheOnBoot() {
36473
+ function refreshQuotaCacheOnBoot(isEnabled) {
36434
36474
  if (bootRefreshInFlight || hasFreshlyMeasuredQuota()) return;
36435
36475
  bootRefreshInFlight = true;
36436
- void refreshQuotaCacheOnce().catch((e) => LOG2.warn("Quota", `Boot quota refresh failed: ${e?.message || e}`)).finally(() => {
36476
+ void refreshQuotaCacheOnce(REFRESHERS, isEnabled).catch((e) => LOG2.warn("Quota", `Boot quota refresh failed: ${e?.message || e}`)).finally(() => {
36437
36477
  bootRefreshInFlight = false;
36438
36478
  });
36439
36479
  }
@@ -43483,13 +43523,21 @@ Next step: ${nextStep}`;
43483
43523
  const maxRetries = typeof opts?.maxRetries === "number" && Number.isFinite(opts.maxRetries) && opts.maxRetries >= 0 ? Math.floor(opts.maxRetries) : void 0;
43484
43524
  let effectiveModel = typeof opts?.model === "string" && opts.model.trim() ? opts.model.trim() : void 0;
43485
43525
  let effectiveThinkingLevel = typeof opts?.thinkingLevel === "string" && opts.thinkingLevel.trim() ? opts.thinkingLevel.trim() : void 0;
43526
+ let modelSource = effectiveModel ? "explicit" : void 0;
43527
+ let thinkingLevelSource = effectiveThinkingLevel ? "explicit" : void 0;
43486
43528
  const taskDifficulty = isMeshTaskDifficulty(opts?.difficulty) ? opts.difficulty : void 0;
43487
43529
  if (isMeshTaskDifficulty(opts?.difficulty)) {
43488
43530
  try {
43489
43531
  const preset = getDifficultyBrains(meshId)[opts.difficulty];
43490
43532
  if (preset) {
43491
- if (!effectiveModel && preset.model) effectiveModel = preset.model;
43492
- if (!effectiveThinkingLevel && preset.thinkingLevel) effectiveThinkingLevel = preset.thinkingLevel;
43533
+ if (!effectiveModel && preset.model) {
43534
+ effectiveModel = preset.model;
43535
+ modelSource = "preset";
43536
+ }
43537
+ if (!effectiveThinkingLevel && preset.thinkingLevel) {
43538
+ effectiveThinkingLevel = preset.thinkingLevel;
43539
+ thinkingLevelSource = "preset";
43540
+ }
43493
43541
  }
43494
43542
  } catch {
43495
43543
  }
@@ -43525,8 +43573,8 @@ Next step: ${nextStep}`;
43525
43573
  ...maxRetries !== void 0 ? { maxRetries } : {},
43526
43574
  ...typeof opts?.missionId === "string" && opts.missionId.trim() ? { missionId: opts.missionId.trim() } : {},
43527
43575
  ...typeof opts?.consensusGroupId === "string" && opts.consensusGroupId.trim() ? { consensusGroupId: opts.consensusGroupId.trim() } : {},
43528
- ...effectiveModel ? { model: effectiveModel } : {},
43529
- ...effectiveThinkingLevel ? { thinkingLevel: effectiveThinkingLevel } : {},
43576
+ ...effectiveModel && modelSource ? { model: effectiveModel, modelSource } : {},
43577
+ ...effectiveThinkingLevel && thinkingLevelSource ? { thinkingLevel: effectiveThinkingLevel, thinkingLevelSource } : {},
43530
43578
  ...taskDifficulty ? { difficulty: taskDifficulty } : {},
43531
43579
  ...typeof opts?.sourceCoordinatorSessionId === "string" && opts.sourceCoordinatorSessionId.trim() ? { sourceCoordinatorSessionId: opts.sourceCoordinatorSessionId.trim() } : {},
43532
43580
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -57191,6 +57239,18 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
57191
57239
  function nodeFitnessForTask(node, task, meshId) {
57192
57240
  return bestSlotForTask(node, task, meshId)?.score ?? 0;
57193
57241
  }
57242
+ function slotCoversTaskDifficulty(slot, difficulty) {
57243
+ if (!slot) return false;
57244
+ if (!isMeshTaskDifficulty(difficulty)) return false;
57245
+ if (!slot.difficulty?.length) return true;
57246
+ return slot.difficulty.includes(difficulty);
57247
+ }
57248
+ function resolveLaunchAxis(taskValue, taskSource, slotValue, slotCoversDifficulty) {
57249
+ const stamped = typeof taskValue === "string" && taskValue.trim() ? taskValue.trim() : void 0;
57250
+ if (!stamped) return slotValue;
57251
+ if (taskSource !== "preset") return stamped;
57252
+ return slotCoversDifficulty && slotValue ? slotValue : stamped;
57253
+ }
57194
57254
  function orderEligibleNodes(meshId, strategy, nodes, opts) {
57195
57255
  if (strategy === "first_eligible" || nodes.length <= 1) {
57196
57256
  return nodes;
@@ -57644,8 +57704,9 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
57644
57704
  markSkip(nodeId, resolved.reason || "provider_unusable");
57645
57705
  continue;
57646
57706
  }
57647
- const requestedModel = typeof task.model === "string" && task.model.trim() ? task.model.trim() : resolved.model;
57648
- const effectiveThinkingLevel = typeof task.thinkingLevel === "string" && task.thinkingLevel.trim() ? task.thinkingLevel.trim() : resolved.thinkingLevel;
57707
+ const slotCoversDifficulty = slotCoversTaskDifficulty(resolved.slot, task.difficulty);
57708
+ const requestedModel = resolveLaunchAxis(task.model, task.modelSource, resolved.model, slotCoversDifficulty);
57709
+ const effectiveThinkingLevel = resolveLaunchAxis(task.thinkingLevel, task.thinkingLevelSource, resolved.thinkingLevel, slotCoversDifficulty);
57649
57710
  const slotDecision = decideSlotForModel({
57650
57711
  requestedModel,
57651
57712
  slots: resolveNodeCapabilitySlots(node, meshId).map((slot) => ({
@@ -73710,6 +73771,7 @@ ${lastSnapshot}`;
73710
73771
  getLastDisplayMessage: () => getLastDisplayMessage,
73711
73772
  getLedgerDir: () => getLedgerDir,
73712
73773
  getLedgerSummary: () => getLedgerSummary,
73774
+ getLogInstanceTag: () => getLogInstanceTag,
73713
73775
  getLogLevel: () => getLogLevel,
73714
73776
  getMagiKindPanel: () => getMagiKindPanel,
73715
73777
  getMesh: () => getMesh,
@@ -73930,6 +73992,7 @@ ${lastSnapshot}`;
73930
73992
  serializeMeshJsonConfigScaffold: () => serializeMeshJsonConfigScaffold,
73931
73993
  serializeV2EnvelopeToWire: () => serializeV2EnvelopeToWire,
73932
73994
  setDebugRuntimeConfig: () => setDebugRuntimeConfig,
73995
+ setLogInstancePort: () => setLogInstancePort2,
73933
73996
  setLogLevel: () => setLogLevel,
73934
73997
  setMagiKindPanel: () => setMagiKindPanel,
73935
73998
  setQuotaShowAccountEmail: () => setQuotaShowAccountEmail,
@@ -107353,18 +107416,17 @@ ${ptyResult.output.slice(-2e3)}`);
107353
107416
  branchConvergenceSummary: summarizeInlineMeshBranchConvergence(nodeStatuses),
107354
107417
  ...previewFreshness ? { previewFreshness, deployFreshness: previewFreshness } : {},
107355
107418
  nodes: nodeStatuses,
107356
- // Mesh-level scheduling rollup (strategy + global cap consumption). Mirrors
107357
- // the MCP `mesh_status` tool's `scheduling` block field-for-field so both
107358
- // surfaces read the same runtime; per-node detail lives on each
107359
- // nodes[].scheduling above.
107419
+ // Mesh-level scheduling rollup (strategy only). Mirrors the MCP
107420
+ // `mesh_status` tool's `scheduling` block field-for-field the global-cap
107421
+ // numbers (maxParallelTasks/maxReadonlyParallelTasks/activeWriteAssigned/
107422
+ // activeReadonlyAssigned/globalWriteCapReached/globalReadonlyCapReached)
107423
+ // are deliberately not surfaced: real concurrency is governed per-node/
107424
+ // per-slot (nodes[].scheduling.providerRoles/capReasons above), and the
107425
+ // global number does not represent actual capacity. Exposure-only —
107426
+ // buildMeshSchedulingRuntime still computes these internally for
107427
+ // maybeAutoLaunchOneQueueSession's own gating.
107360
107428
  scheduling: {
107361
- strategy: schedulingRuntime.strategy,
107362
- maxParallelTasks: schedulingRuntime.maxParallelTasks,
107363
- maxReadonlyParallelTasks: schedulingRuntime.maxReadonlyParallelTasks,
107364
- activeWriteAssigned: schedulingRuntime.activeWriteAssigned,
107365
- activeReadonlyAssigned: schedulingRuntime.activeReadonlyAssigned,
107366
- globalWriteCapReached: schedulingRuntime.globalWriteCapReached,
107367
- globalReadonlyCapReached: schedulingRuntime.globalReadonlyCapReached
107429
+ strategy: schedulingRuntime.strategy
107368
107430
  },
107369
107431
  queue: { tasks: queue, summary: queueSummary },
107370
107432
  ledger: { entries: ledgerEntries, summary: ledgerSummary },
@@ -113122,8 +113184,7 @@ ${e?.stderr || ""}`;
113122
113184
  init_logger();
113123
113185
  init_debug_config();
113124
113186
  init_debug_trace();
113125
- var DEFAULT_DAEMON_PORT2 = 19222;
113126
- var DAEMON_WS_PATH2 = "/ipc";
113187
+ init_ipc_protocol();
113127
113188
  init_runtime_defaults();
113128
113189
  init_chat_history();
113129
113190
  init_normalize();
@@ -120916,11 +120977,12 @@ data: ${JSON.stringify(msg.data)}
120916
120977
  components.meshReconcileLoop = setupMeshReconcileLoop(components);
120917
120978
  components.quotaRefreshLoop = setupQuotaRefreshLoop(components);
120918
120979
  setImmediate(() => {
120980
+ const isQuotaProviderEnabled = quotaProviderEnabledFromLoader(components.providerLoader);
120919
120981
  try {
120920
- hydrateQuotaCacheFromDisk();
120982
+ hydrateQuotaCacheFromDisk(process.env, isQuotaProviderEnabled);
120921
120983
  } catch {
120922
120984
  }
120923
- refreshQuotaCacheOnBoot();
120985
+ refreshQuotaCacheOnBoot(isQuotaProviderEnabled);
120924
120986
  });
120925
120987
  setImmediate(() => void router.resumePendingRefineJobsOnStartup());
120926
120988
  setImmediate(() => router.resumeDeferredRestartsOnStartup());
@@ -120996,6 +121058,7 @@ data: ${JSON.stringify(msg.data)}
120996
121058
  var import_http2 = require("http");
120997
121059
  var import_ws22 = require("ws");
120998
121060
  init_logger();
121061
+ init_ipc_protocol();
120999
121062
  function buildIpcStatusHttpResponse(method, url2, payload) {
121000
121063
  if (method && method.toUpperCase() !== "GET") {
121001
121064
  return { statusCode: 405, body: { ok: false, error: "method not allowed" } };
@@ -122832,6 +122895,7 @@ var StandaloneServer = class {
122832
122895
  saveStandaloneBindHostPreference(persistedStandaloneBindHost);
122833
122896
  }
122834
122897
  const port = options.port || DEFAULT_PORT;
122898
+ (0, import_daemon_core3.setLogInstancePort)(port);
122835
122899
  process.env.ADHDEV_COORDINATOR_MCP_TRANSPORT = "local";
122836
122900
  process.env.ADHDEV_COORDINATOR_MCP_PORT = String(port);
122837
122901
  if (!process.env.ADHDEV_COORDINATOR_MCP_ENTRY_PATH?.trim()) {