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