@nmakarov/cli-toolkit 0.70.0 → 0.72.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.
@@ -4365,6 +4365,9 @@ var DEFAULT_GROUP_MAX_INSTANCES = {
4365
4365
  harvest: 1,
4366
4366
  harvester: 0,
4367
4367
  loader: 0,
4368
+ toolkit: 0,
4369
+ photocare: 0,
4370
+ /** @deprecated use photocare */
4368
4371
  photos: 0,
4369
4372
  photosprocessor: 0,
4370
4373
  ingest: 0
@@ -6507,6 +6510,59 @@ var LOGGER_RUNTIME_KEYS = [
6507
6510
  "progressWithTimes",
6508
6511
  "progressThrottleMs"
6509
6512
  ];
6513
+ var DEFAULT_RUNTIME_PARAM_SPECS = [
6514
+ {
6515
+ key: "maxParallel",
6516
+ type: "number",
6517
+ label: "Max parallel",
6518
+ description: "Worker-lane concurrency (how many tasks claim at once)"
6519
+ },
6520
+ {
6521
+ key: "pollMs",
6522
+ type: "number",
6523
+ label: "Poll ms",
6524
+ description: "Idle poll interval between claim attempts"
6525
+ },
6526
+ {
6527
+ key: "claimJitterMs",
6528
+ type: "number",
6529
+ label: "Claim jitter ms",
6530
+ description: "Random delay before worker claims (0 = off)"
6531
+ },
6532
+ {
6533
+ key: "scanLimit",
6534
+ type: "number",
6535
+ label: "Scan limit",
6536
+ description: "Max idle rows scanned per claim attempt"
6537
+ }
6538
+ ];
6539
+ function mergeRuntimeParamSpecs(extra) {
6540
+ const byKey = new Map(DEFAULT_RUNTIME_PARAM_SPECS.map((s) => [s.key, { ...s }]));
6541
+ if (Array.isArray(extra)) {
6542
+ for (const raw of extra) {
6543
+ if (!raw || typeof raw !== "object") continue;
6544
+ const key = String(raw.key ?? "").trim();
6545
+ if (!key) continue;
6546
+ const prev = byKey.get(key) ?? {};
6547
+ const type = ["number", "boolean", "string"].includes(raw.type) ? raw.type : prev.type ?? "string";
6548
+ byKey.set(key, {
6549
+ key,
6550
+ type,
6551
+ label: String(raw.label ?? prev.label ?? key),
6552
+ description: raw.description != null ? String(raw.description) : prev.description != null ? String(prev.description) : void 0
6553
+ });
6554
+ }
6555
+ }
6556
+ return Array.from(byKey.values());
6557
+ }
6558
+ function runtimeValuesForSpecs(context, specs = DEFAULT_RUNTIME_PARAM_SPECS) {
6559
+ const rt = ensureTasksRuntime(context);
6560
+ const out = {};
6561
+ for (const s of specs) {
6562
+ if (rt[s.key] !== void 0) out[s.key] = rt[s.key];
6563
+ }
6564
+ return out;
6565
+ }
6510
6566
  var CONTROL_LANE_TASK_NAMES = [
6511
6567
  "stopRunner",
6512
6568
  "stop",
@@ -6603,12 +6659,15 @@ async function applyRuntimeParam(context, key, value) {
6603
6659
  const reg = context.servicesRegistry;
6604
6660
  if (reg?.rowId && reg?.registryTable) {
6605
6661
  try {
6606
- const loopSnapshot = {};
6662
+ const specs = Array.isArray(context.tasksRuntimeParamSpecs) ? context.tasksRuntimeParamSpecs : DEFAULT_RUNTIME_PARAM_SPECS;
6663
+ const runtimeSnapshot = runtimeValuesForSpecs(context, specs);
6607
6664
  for (const lk of LOOP_RUNTIME_KEYS) {
6608
- if (runtime[lk] !== void 0) loopSnapshot[lk] = runtime[lk];
6665
+ if (runtime[lk] !== void 0 && runtimeSnapshot[lk] === void 0) {
6666
+ runtimeSnapshot[lk] = runtime[lk];
6667
+ }
6609
6668
  }
6610
6669
  await updateServicesRegistryMetadata(context, reg, {
6611
- runtime: loopSnapshot,
6670
+ runtime: runtimeSnapshot,
6612
6671
  runtimeUpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
6613
6672
  });
6614
6673
  applied.push("servicesRegistry");
@@ -7291,18 +7350,25 @@ async function runTasksLoop(context, options) {
7291
7350
  if (hbGroup) {
7292
7351
  const hbIntervalMs = options.runnerHeartbeatIntervalMs ?? 1e4;
7293
7352
  const staleMs = options.runnerHeartbeatStaleMs ?? 45e3;
7294
- const loop0 = readLoopRuntime(context);
7353
+ const runtimeParamSpecs = mergeRuntimeParamSpecs(options.runnerRuntimeParams);
7354
+ context.tasksRuntimeParamSpecs = runtimeParamSpecs;
7295
7355
  const defaultMeta = {
7296
7356
  component: "tasks-runner",
7297
7357
  allowedTasks: allowedTasks?.length ? allowedTasks.join(",") : "all",
7298
7358
  paused: false,
7299
- runtime: {
7300
- maxParallel: loop0.maxParallel,
7301
- pollMs: loop0.pollMs,
7302
- claimJitterMs: loop0.claimJitterMs,
7303
- scanLimit: loop0.scanLimit
7304
- }
7359
+ runtimeParams: runtimeParamSpecs,
7360
+ runtime: runtimeValuesForSpecs(context, runtimeParamSpecs)
7305
7361
  };
7362
+ const metadata = {
7363
+ ...defaultMeta,
7364
+ ...options.runnerMetadata && typeof options.runnerMetadata === "object" ? options.runnerMetadata : {}
7365
+ };
7366
+ if (!Array.isArray(metadata.runtimeParams) || metadata.runtimeParams.length === 0) {
7367
+ metadata.runtimeParams = defaultMeta.runtimeParams;
7368
+ }
7369
+ if (!metadata.runtime || typeof metadata.runtime !== "object") {
7370
+ metadata.runtime = defaultMeta.runtime;
7371
+ }
7306
7372
  registryReg = await registerInServicesRegistry(context, {
7307
7373
  queueName,
7308
7374
  target,
@@ -7312,7 +7378,7 @@ async function runTasksLoop(context, options) {
7312
7378
  staleMs,
7313
7379
  groupMaxInstances: options.runnerGroupMaxInstances,
7314
7380
  enforceMaxInstances: options.runnerEnforceMaxInstances ?? true,
7315
- metadata: options.runnerMetadata ?? defaultMeta
7381
+ metadata
7316
7382
  });
7317
7383
  context.servicesRegistry = registryReg;
7318
7384
  runnerIdentity = {