@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.
- package/dist/cli-runner.cjs +77 -11
- package/dist/cli-runner.cjs.map +1 -1
- package/dist/cli-runner.js +77 -11
- package/dist/cli-runner.js.map +1 -1
- package/dist/filedatabase.cjs.map +1 -1
- package/dist/filedatabase.js.map +1 -1
- package/dist/index.cjs +93 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +89 -11
- package/dist/index.js.map +1 -1
- package/dist/tasks.cjs +93 -11
- package/dist/tasks.cjs.map +1 -1
- package/dist/tasks.js +89 -11
- package/dist/tasks.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7230,6 +7230,9 @@ var DEFAULT_GROUP_MAX_INSTANCES = {
|
|
|
7230
7230
|
harvest: 1,
|
|
7231
7231
|
harvester: 0,
|
|
7232
7232
|
loader: 0,
|
|
7233
|
+
toolkit: 0,
|
|
7234
|
+
photocare: 0,
|
|
7235
|
+
/** @deprecated use photocare */
|
|
7233
7236
|
photos: 0,
|
|
7234
7237
|
photosprocessor: 0,
|
|
7235
7238
|
ingest: 0
|
|
@@ -8335,6 +8338,67 @@ var LOGGER_RUNTIME_KEYS = [
|
|
|
8335
8338
|
"progressWithTimes",
|
|
8336
8339
|
"progressThrottleMs"
|
|
8337
8340
|
];
|
|
8341
|
+
var DEFAULT_RUNTIME_PARAM_SPECS = [
|
|
8342
|
+
{
|
|
8343
|
+
key: "maxParallel",
|
|
8344
|
+
type: "number",
|
|
8345
|
+
label: "Max parallel",
|
|
8346
|
+
description: "Worker-lane concurrency (how many tasks claim at once)"
|
|
8347
|
+
},
|
|
8348
|
+
{
|
|
8349
|
+
key: "pollMs",
|
|
8350
|
+
type: "number",
|
|
8351
|
+
label: "Poll ms",
|
|
8352
|
+
description: "Idle poll interval between claim attempts"
|
|
8353
|
+
},
|
|
8354
|
+
{
|
|
8355
|
+
key: "claimJitterMs",
|
|
8356
|
+
type: "number",
|
|
8357
|
+
label: "Claim jitter ms",
|
|
8358
|
+
description: "Random delay before worker claims (0 = off)"
|
|
8359
|
+
},
|
|
8360
|
+
{
|
|
8361
|
+
key: "scanLimit",
|
|
8362
|
+
type: "number",
|
|
8363
|
+
label: "Scan limit",
|
|
8364
|
+
description: "Max idle rows scanned per claim attempt"
|
|
8365
|
+
}
|
|
8366
|
+
];
|
|
8367
|
+
function mergeRuntimeParamSpecs(extra) {
|
|
8368
|
+
const byKey = new Map(DEFAULT_RUNTIME_PARAM_SPECS.map((s) => [s.key, { ...s }]));
|
|
8369
|
+
if (Array.isArray(extra)) {
|
|
8370
|
+
for (const raw of extra) {
|
|
8371
|
+
if (!raw || typeof raw !== "object") continue;
|
|
8372
|
+
const key = String(raw.key ?? "").trim();
|
|
8373
|
+
if (!key) continue;
|
|
8374
|
+
const prev = byKey.get(key) ?? {};
|
|
8375
|
+
const type = ["number", "boolean", "string"].includes(raw.type) ? raw.type : prev.type ?? "string";
|
|
8376
|
+
byKey.set(key, {
|
|
8377
|
+
key,
|
|
8378
|
+
type,
|
|
8379
|
+
label: String(raw.label ?? prev.label ?? key),
|
|
8380
|
+
description: raw.description != null ? String(raw.description) : prev.description != null ? String(prev.description) : void 0
|
|
8381
|
+
});
|
|
8382
|
+
}
|
|
8383
|
+
}
|
|
8384
|
+
return Array.from(byKey.values());
|
|
8385
|
+
}
|
|
8386
|
+
function runtimeValuesForSpecs(context, specs = DEFAULT_RUNTIME_PARAM_SPECS) {
|
|
8387
|
+
const rt = ensureTasksRuntime(context);
|
|
8388
|
+
const out = {};
|
|
8389
|
+
for (const s of specs) {
|
|
8390
|
+
if (rt[s.key] !== void 0) out[s.key] = rt[s.key];
|
|
8391
|
+
}
|
|
8392
|
+
return out;
|
|
8393
|
+
}
|
|
8394
|
+
function runtimeParamSpecsFromMetadata(metadata) {
|
|
8395
|
+
const meta = metadata && typeof metadata === "object" ? metadata : null;
|
|
8396
|
+
const raw = meta?.runtimeParams;
|
|
8397
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
8398
|
+
return mergeRuntimeParamSpecs();
|
|
8399
|
+
}
|
|
8400
|
+
return mergeRuntimeParamSpecs(raw);
|
|
8401
|
+
}
|
|
8338
8402
|
var CONTROL_LANE_TASK_NAMES = [
|
|
8339
8403
|
"stopRunner",
|
|
8340
8404
|
"stop",
|
|
@@ -8431,12 +8495,15 @@ async function applyRuntimeParam(context, key, value) {
|
|
|
8431
8495
|
const reg = context.servicesRegistry;
|
|
8432
8496
|
if (reg?.rowId && reg?.registryTable) {
|
|
8433
8497
|
try {
|
|
8434
|
-
const
|
|
8498
|
+
const specs = Array.isArray(context.tasksRuntimeParamSpecs) ? context.tasksRuntimeParamSpecs : DEFAULT_RUNTIME_PARAM_SPECS;
|
|
8499
|
+
const runtimeSnapshot = runtimeValuesForSpecs(context, specs);
|
|
8435
8500
|
for (const lk of LOOP_RUNTIME_KEYS) {
|
|
8436
|
-
if (runtime[lk] !== void 0
|
|
8501
|
+
if (runtime[lk] !== void 0 && runtimeSnapshot[lk] === void 0) {
|
|
8502
|
+
runtimeSnapshot[lk] = runtime[lk];
|
|
8503
|
+
}
|
|
8437
8504
|
}
|
|
8438
8505
|
await updateServicesRegistryMetadata(context, reg, {
|
|
8439
|
-
runtime:
|
|
8506
|
+
runtime: runtimeSnapshot,
|
|
8440
8507
|
runtimeUpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8441
8508
|
});
|
|
8442
8509
|
applied.push("servicesRegistry");
|
|
@@ -9329,18 +9396,25 @@ async function runTasksLoop(context, options) {
|
|
|
9329
9396
|
if (hbGroup) {
|
|
9330
9397
|
const hbIntervalMs = options.runnerHeartbeatIntervalMs ?? 1e4;
|
|
9331
9398
|
const staleMs = options.runnerHeartbeatStaleMs ?? 45e3;
|
|
9332
|
-
const
|
|
9399
|
+
const runtimeParamSpecs = mergeRuntimeParamSpecs(options.runnerRuntimeParams);
|
|
9400
|
+
context.tasksRuntimeParamSpecs = runtimeParamSpecs;
|
|
9333
9401
|
const defaultMeta = {
|
|
9334
9402
|
component: "tasks-runner",
|
|
9335
9403
|
allowedTasks: allowedTasks?.length ? allowedTasks.join(",") : "all",
|
|
9336
9404
|
paused: false,
|
|
9337
|
-
|
|
9338
|
-
|
|
9339
|
-
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
}
|
|
9405
|
+
runtimeParams: runtimeParamSpecs,
|
|
9406
|
+
runtime: runtimeValuesForSpecs(context, runtimeParamSpecs)
|
|
9407
|
+
};
|
|
9408
|
+
const metadata = {
|
|
9409
|
+
...defaultMeta,
|
|
9410
|
+
...options.runnerMetadata && typeof options.runnerMetadata === "object" ? options.runnerMetadata : {}
|
|
9343
9411
|
};
|
|
9412
|
+
if (!Array.isArray(metadata.runtimeParams) || metadata.runtimeParams.length === 0) {
|
|
9413
|
+
metadata.runtimeParams = defaultMeta.runtimeParams;
|
|
9414
|
+
}
|
|
9415
|
+
if (!metadata.runtime || typeof metadata.runtime !== "object") {
|
|
9416
|
+
metadata.runtime = defaultMeta.runtime;
|
|
9417
|
+
}
|
|
9344
9418
|
registryReg = await registerInServicesRegistry(context, {
|
|
9345
9419
|
queueName,
|
|
9346
9420
|
target,
|
|
@@ -9350,7 +9424,7 @@ async function runTasksLoop(context, options) {
|
|
|
9350
9424
|
staleMs,
|
|
9351
9425
|
groupMaxInstances: options.runnerGroupMaxInstances,
|
|
9352
9426
|
enforceMaxInstances: options.runnerEnforceMaxInstances ?? true,
|
|
9353
|
-
metadata
|
|
9427
|
+
metadata
|
|
9354
9428
|
});
|
|
9355
9429
|
context.servicesRegistry = registryReg;
|
|
9356
9430
|
runnerIdentity = {
|
|
@@ -9669,6 +9743,7 @@ export {
|
|
|
9669
9743
|
BAR_THUMB,
|
|
9670
9744
|
BAR_TRACK,
|
|
9671
9745
|
Box5 as Box,
|
|
9746
|
+
DEFAULT_RUNTIME_PARAM_SPECS,
|
|
9672
9747
|
Db,
|
|
9673
9748
|
Divider,
|
|
9674
9749
|
FileDatabase,
|
|
@@ -9771,6 +9846,7 @@ export {
|
|
|
9771
9846
|
matchesParsedPattern,
|
|
9772
9847
|
memo,
|
|
9773
9848
|
mergeAllowedTasksWithServiceTasks,
|
|
9849
|
+
mergeRuntimeParamSpecs,
|
|
9774
9850
|
nextTimeMatch,
|
|
9775
9851
|
normalizeAllowedTasks,
|
|
9776
9852
|
npmEnv,
|
|
@@ -9807,6 +9883,8 @@ export {
|
|
|
9807
9883
|
runRemoteStatus,
|
|
9808
9884
|
runShell,
|
|
9809
9885
|
runTasksLoop,
|
|
9886
|
+
runtimeParamSpecsFromMetadata,
|
|
9887
|
+
runtimeValuesForSpecs,
|
|
9810
9888
|
scrollbarGlyphs,
|
|
9811
9889
|
scrubEnvContent,
|
|
9812
9890
|
servicePaths,
|