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