@nmakarov/cli-toolkit 0.70.0 → 0.71.0

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.
@@ -6523,6 +6523,59 @@ var LOGGER_RUNTIME_KEYS = [
6523
6523
  "progressWithTimes",
6524
6524
  "progressThrottleMs"
6525
6525
  ];
6526
+ var DEFAULT_RUNTIME_PARAM_SPECS = [
6527
+ {
6528
+ key: "maxParallel",
6529
+ type: "number",
6530
+ label: "Max parallel",
6531
+ description: "Worker-lane concurrency (how many tasks claim at once)"
6532
+ },
6533
+ {
6534
+ key: "pollMs",
6535
+ type: "number",
6536
+ label: "Poll ms",
6537
+ description: "Idle poll interval between claim attempts"
6538
+ },
6539
+ {
6540
+ key: "claimJitterMs",
6541
+ type: "number",
6542
+ label: "Claim jitter ms",
6543
+ description: "Random delay before worker claims (0 = off)"
6544
+ },
6545
+ {
6546
+ key: "scanLimit",
6547
+ type: "number",
6548
+ label: "Scan limit",
6549
+ description: "Max idle rows scanned per claim attempt"
6550
+ }
6551
+ ];
6552
+ function mergeRuntimeParamSpecs(extra) {
6553
+ const byKey = new Map(DEFAULT_RUNTIME_PARAM_SPECS.map((s) => [s.key, { ...s }]));
6554
+ if (Array.isArray(extra)) {
6555
+ for (const raw of extra) {
6556
+ if (!raw || typeof raw !== "object") continue;
6557
+ const key = String(raw.key ?? "").trim();
6558
+ if (!key) continue;
6559
+ const prev = byKey.get(key) ?? {};
6560
+ const type = ["number", "boolean", "string"].includes(raw.type) ? raw.type : prev.type ?? "string";
6561
+ byKey.set(key, {
6562
+ key,
6563
+ type,
6564
+ label: String(raw.label ?? prev.label ?? key),
6565
+ description: raw.description != null ? String(raw.description) : prev.description != null ? String(prev.description) : void 0
6566
+ });
6567
+ }
6568
+ }
6569
+ return Array.from(byKey.values());
6570
+ }
6571
+ function runtimeValuesForSpecs(context, specs = DEFAULT_RUNTIME_PARAM_SPECS) {
6572
+ const rt = ensureTasksRuntime(context);
6573
+ const out = {};
6574
+ for (const s of specs) {
6575
+ if (rt[s.key] !== void 0) out[s.key] = rt[s.key];
6576
+ }
6577
+ return out;
6578
+ }
6526
6579
  var CONTROL_LANE_TASK_NAMES = [
6527
6580
  "stopRunner",
6528
6581
  "stop",
@@ -6619,12 +6672,15 @@ async function applyRuntimeParam(context, key, value) {
6619
6672
  const reg = context.servicesRegistry;
6620
6673
  if (reg?.rowId && reg?.registryTable) {
6621
6674
  try {
6622
- const loopSnapshot = {};
6675
+ const specs = Array.isArray(context.tasksRuntimeParamSpecs) ? context.tasksRuntimeParamSpecs : DEFAULT_RUNTIME_PARAM_SPECS;
6676
+ const runtimeSnapshot = runtimeValuesForSpecs(context, specs);
6623
6677
  for (const lk of LOOP_RUNTIME_KEYS) {
6624
- if (runtime[lk] !== void 0) loopSnapshot[lk] = runtime[lk];
6678
+ if (runtime[lk] !== void 0 && runtimeSnapshot[lk] === void 0) {
6679
+ runtimeSnapshot[lk] = runtime[lk];
6680
+ }
6625
6681
  }
6626
6682
  await updateServicesRegistryMetadata(context, reg, {
6627
- runtime: loopSnapshot,
6683
+ runtime: runtimeSnapshot,
6628
6684
  runtimeUpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
6629
6685
  });
6630
6686
  applied.push("servicesRegistry");
@@ -7307,18 +7363,25 @@ async function runTasksLoop(context, options) {
7307
7363
  if (hbGroup) {
7308
7364
  const hbIntervalMs = options.runnerHeartbeatIntervalMs ?? 1e4;
7309
7365
  const staleMs = options.runnerHeartbeatStaleMs ?? 45e3;
7310
- const loop0 = readLoopRuntime(context);
7366
+ const runtimeParamSpecs = mergeRuntimeParamSpecs(options.runnerRuntimeParams);
7367
+ context.tasksRuntimeParamSpecs = runtimeParamSpecs;
7311
7368
  const defaultMeta = {
7312
7369
  component: "tasks-runner",
7313
7370
  allowedTasks: allowedTasks?.length ? allowedTasks.join(",") : "all",
7314
7371
  paused: false,
7315
- runtime: {
7316
- maxParallel: loop0.maxParallel,
7317
- pollMs: loop0.pollMs,
7318
- claimJitterMs: loop0.claimJitterMs,
7319
- scanLimit: loop0.scanLimit
7320
- }
7372
+ runtimeParams: runtimeParamSpecs,
7373
+ runtime: runtimeValuesForSpecs(context, runtimeParamSpecs)
7321
7374
  };
7375
+ const metadata = {
7376
+ ...defaultMeta,
7377
+ ...options.runnerMetadata && typeof options.runnerMetadata === "object" ? options.runnerMetadata : {}
7378
+ };
7379
+ if (!Array.isArray(metadata.runtimeParams) || metadata.runtimeParams.length === 0) {
7380
+ metadata.runtimeParams = defaultMeta.runtimeParams;
7381
+ }
7382
+ if (!metadata.runtime || typeof metadata.runtime !== "object") {
7383
+ metadata.runtime = defaultMeta.runtime;
7384
+ }
7322
7385
  registryReg = await registerInServicesRegistry(context, {
7323
7386
  queueName,
7324
7387
  target,
@@ -7328,7 +7391,7 @@ async function runTasksLoop(context, options) {
7328
7391
  staleMs,
7329
7392
  groupMaxInstances: options.runnerGroupMaxInstances,
7330
7393
  enforceMaxInstances: options.runnerEnforceMaxInstances ?? true,
7331
- metadata: options.runnerMetadata ?? defaultMeta
7394
+ metadata
7332
7395
  });
7333
7396
  context.servicesRegistry = registryReg;
7334
7397
  runnerIdentity = {