@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.cjs
CHANGED
|
@@ -1319,6 +1319,7 @@ __export(src_exports, {
|
|
|
1319
1319
|
BAR_THUMB: () => BAR_THUMB,
|
|
1320
1320
|
BAR_TRACK: () => BAR_TRACK,
|
|
1321
1321
|
Box: () => import_ink6.Box,
|
|
1322
|
+
DEFAULT_RUNTIME_PARAM_SPECS: () => DEFAULT_RUNTIME_PARAM_SPECS,
|
|
1322
1323
|
Db: () => Db,
|
|
1323
1324
|
Divider: () => Divider,
|
|
1324
1325
|
FileDatabase: () => FileDatabase,
|
|
@@ -1421,6 +1422,7 @@ __export(src_exports, {
|
|
|
1421
1422
|
matchesParsedPattern: () => matchesParsedPattern,
|
|
1422
1423
|
memo: () => import_react6.memo,
|
|
1423
1424
|
mergeAllowedTasksWithServiceTasks: () => mergeAllowedTasksWithServiceTasks,
|
|
1425
|
+
mergeRuntimeParamSpecs: () => mergeRuntimeParamSpecs,
|
|
1424
1426
|
nextTimeMatch: () => nextTimeMatch,
|
|
1425
1427
|
normalizeAllowedTasks: () => normalizeAllowedTasks,
|
|
1426
1428
|
npmEnv: () => npmEnv,
|
|
@@ -1457,6 +1459,8 @@ __export(src_exports, {
|
|
|
1457
1459
|
runRemoteStatus: () => runRemoteStatus,
|
|
1458
1460
|
runShell: () => runShell,
|
|
1459
1461
|
runTasksLoop: () => runTasksLoop,
|
|
1462
|
+
runtimeParamSpecsFromMetadata: () => runtimeParamSpecsFromMetadata,
|
|
1463
|
+
runtimeValuesForSpecs: () => runtimeValuesForSpecs,
|
|
1460
1464
|
scrollbarGlyphs: () => scrollbarGlyphs,
|
|
1461
1465
|
scrubEnvContent: () => scrubEnvContent,
|
|
1462
1466
|
servicePaths: () => servicePaths,
|
|
@@ -7407,6 +7411,9 @@ var DEFAULT_GROUP_MAX_INSTANCES = {
|
|
|
7407
7411
|
harvest: 1,
|
|
7408
7412
|
harvester: 0,
|
|
7409
7413
|
loader: 0,
|
|
7414
|
+
toolkit: 0,
|
|
7415
|
+
photocare: 0,
|
|
7416
|
+
/** @deprecated use photocare */
|
|
7410
7417
|
photos: 0,
|
|
7411
7418
|
photosprocessor: 0,
|
|
7412
7419
|
ingest: 0
|
|
@@ -8512,6 +8519,67 @@ var LOGGER_RUNTIME_KEYS = [
|
|
|
8512
8519
|
"progressWithTimes",
|
|
8513
8520
|
"progressThrottleMs"
|
|
8514
8521
|
];
|
|
8522
|
+
var DEFAULT_RUNTIME_PARAM_SPECS = [
|
|
8523
|
+
{
|
|
8524
|
+
key: "maxParallel",
|
|
8525
|
+
type: "number",
|
|
8526
|
+
label: "Max parallel",
|
|
8527
|
+
description: "Worker-lane concurrency (how many tasks claim at once)"
|
|
8528
|
+
},
|
|
8529
|
+
{
|
|
8530
|
+
key: "pollMs",
|
|
8531
|
+
type: "number",
|
|
8532
|
+
label: "Poll ms",
|
|
8533
|
+
description: "Idle poll interval between claim attempts"
|
|
8534
|
+
},
|
|
8535
|
+
{
|
|
8536
|
+
key: "claimJitterMs",
|
|
8537
|
+
type: "number",
|
|
8538
|
+
label: "Claim jitter ms",
|
|
8539
|
+
description: "Random delay before worker claims (0 = off)"
|
|
8540
|
+
},
|
|
8541
|
+
{
|
|
8542
|
+
key: "scanLimit",
|
|
8543
|
+
type: "number",
|
|
8544
|
+
label: "Scan limit",
|
|
8545
|
+
description: "Max idle rows scanned per claim attempt"
|
|
8546
|
+
}
|
|
8547
|
+
];
|
|
8548
|
+
function mergeRuntimeParamSpecs(extra) {
|
|
8549
|
+
const byKey = new Map(DEFAULT_RUNTIME_PARAM_SPECS.map((s) => [s.key, { ...s }]));
|
|
8550
|
+
if (Array.isArray(extra)) {
|
|
8551
|
+
for (const raw of extra) {
|
|
8552
|
+
if (!raw || typeof raw !== "object") continue;
|
|
8553
|
+
const key = String(raw.key ?? "").trim();
|
|
8554
|
+
if (!key) continue;
|
|
8555
|
+
const prev = byKey.get(key) ?? {};
|
|
8556
|
+
const type = ["number", "boolean", "string"].includes(raw.type) ? raw.type : prev.type ?? "string";
|
|
8557
|
+
byKey.set(key, {
|
|
8558
|
+
key,
|
|
8559
|
+
type,
|
|
8560
|
+
label: String(raw.label ?? prev.label ?? key),
|
|
8561
|
+
description: raw.description != null ? String(raw.description) : prev.description != null ? String(prev.description) : void 0
|
|
8562
|
+
});
|
|
8563
|
+
}
|
|
8564
|
+
}
|
|
8565
|
+
return Array.from(byKey.values());
|
|
8566
|
+
}
|
|
8567
|
+
function runtimeValuesForSpecs(context, specs = DEFAULT_RUNTIME_PARAM_SPECS) {
|
|
8568
|
+
const rt = ensureTasksRuntime(context);
|
|
8569
|
+
const out = {};
|
|
8570
|
+
for (const s of specs) {
|
|
8571
|
+
if (rt[s.key] !== void 0) out[s.key] = rt[s.key];
|
|
8572
|
+
}
|
|
8573
|
+
return out;
|
|
8574
|
+
}
|
|
8575
|
+
function runtimeParamSpecsFromMetadata(metadata) {
|
|
8576
|
+
const meta = metadata && typeof metadata === "object" ? metadata : null;
|
|
8577
|
+
const raw = meta?.runtimeParams;
|
|
8578
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
8579
|
+
return mergeRuntimeParamSpecs();
|
|
8580
|
+
}
|
|
8581
|
+
return mergeRuntimeParamSpecs(raw);
|
|
8582
|
+
}
|
|
8515
8583
|
var CONTROL_LANE_TASK_NAMES = [
|
|
8516
8584
|
"stopRunner",
|
|
8517
8585
|
"stop",
|
|
@@ -8608,12 +8676,15 @@ async function applyRuntimeParam(context, key, value) {
|
|
|
8608
8676
|
const reg = context.servicesRegistry;
|
|
8609
8677
|
if (reg?.rowId && reg?.registryTable) {
|
|
8610
8678
|
try {
|
|
8611
|
-
const
|
|
8679
|
+
const specs = Array.isArray(context.tasksRuntimeParamSpecs) ? context.tasksRuntimeParamSpecs : DEFAULT_RUNTIME_PARAM_SPECS;
|
|
8680
|
+
const runtimeSnapshot = runtimeValuesForSpecs(context, specs);
|
|
8612
8681
|
for (const lk of LOOP_RUNTIME_KEYS) {
|
|
8613
|
-
if (runtime[lk] !== void 0
|
|
8682
|
+
if (runtime[lk] !== void 0 && runtimeSnapshot[lk] === void 0) {
|
|
8683
|
+
runtimeSnapshot[lk] = runtime[lk];
|
|
8684
|
+
}
|
|
8614
8685
|
}
|
|
8615
8686
|
await updateServicesRegistryMetadata(context, reg, {
|
|
8616
|
-
runtime:
|
|
8687
|
+
runtime: runtimeSnapshot,
|
|
8617
8688
|
runtimeUpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8618
8689
|
});
|
|
8619
8690
|
applied.push("servicesRegistry");
|
|
@@ -9506,18 +9577,25 @@ async function runTasksLoop(context, options) {
|
|
|
9506
9577
|
if (hbGroup) {
|
|
9507
9578
|
const hbIntervalMs = options.runnerHeartbeatIntervalMs ?? 1e4;
|
|
9508
9579
|
const staleMs = options.runnerHeartbeatStaleMs ?? 45e3;
|
|
9509
|
-
const
|
|
9580
|
+
const runtimeParamSpecs = mergeRuntimeParamSpecs(options.runnerRuntimeParams);
|
|
9581
|
+
context.tasksRuntimeParamSpecs = runtimeParamSpecs;
|
|
9510
9582
|
const defaultMeta = {
|
|
9511
9583
|
component: "tasks-runner",
|
|
9512
9584
|
allowedTasks: allowedTasks?.length ? allowedTasks.join(",") : "all",
|
|
9513
9585
|
paused: false,
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
|
|
9517
|
-
|
|
9518
|
-
|
|
9519
|
-
}
|
|
9586
|
+
runtimeParams: runtimeParamSpecs,
|
|
9587
|
+
runtime: runtimeValuesForSpecs(context, runtimeParamSpecs)
|
|
9588
|
+
};
|
|
9589
|
+
const metadata = {
|
|
9590
|
+
...defaultMeta,
|
|
9591
|
+
...options.runnerMetadata && typeof options.runnerMetadata === "object" ? options.runnerMetadata : {}
|
|
9520
9592
|
};
|
|
9593
|
+
if (!Array.isArray(metadata.runtimeParams) || metadata.runtimeParams.length === 0) {
|
|
9594
|
+
metadata.runtimeParams = defaultMeta.runtimeParams;
|
|
9595
|
+
}
|
|
9596
|
+
if (!metadata.runtime || typeof metadata.runtime !== "object") {
|
|
9597
|
+
metadata.runtime = defaultMeta.runtime;
|
|
9598
|
+
}
|
|
9521
9599
|
registryReg = await registerInServicesRegistry(context, {
|
|
9522
9600
|
queueName,
|
|
9523
9601
|
target,
|
|
@@ -9527,7 +9605,7 @@ async function runTasksLoop(context, options) {
|
|
|
9527
9605
|
staleMs,
|
|
9528
9606
|
groupMaxInstances: options.runnerGroupMaxInstances,
|
|
9529
9607
|
enforceMaxInstances: options.runnerEnforceMaxInstances ?? true,
|
|
9530
|
-
metadata
|
|
9608
|
+
metadata
|
|
9531
9609
|
});
|
|
9532
9610
|
context.servicesRegistry = registryReg;
|
|
9533
9611
|
runnerIdentity = {
|
|
@@ -9847,6 +9925,7 @@ var TasksManager = class _TasksManager {
|
|
|
9847
9925
|
BAR_THUMB,
|
|
9848
9926
|
BAR_TRACK,
|
|
9849
9927
|
Box,
|
|
9928
|
+
DEFAULT_RUNTIME_PARAM_SPECS,
|
|
9850
9929
|
Db,
|
|
9851
9930
|
Divider,
|
|
9852
9931
|
FileDatabase,
|
|
@@ -9949,6 +10028,7 @@ var TasksManager = class _TasksManager {
|
|
|
9949
10028
|
matchesParsedPattern,
|
|
9950
10029
|
memo,
|
|
9951
10030
|
mergeAllowedTasksWithServiceTasks,
|
|
10031
|
+
mergeRuntimeParamSpecs,
|
|
9952
10032
|
nextTimeMatch,
|
|
9953
10033
|
normalizeAllowedTasks,
|
|
9954
10034
|
npmEnv,
|
|
@@ -9985,6 +10065,8 @@ var TasksManager = class _TasksManager {
|
|
|
9985
10065
|
runRemoteStatus,
|
|
9986
10066
|
runShell,
|
|
9987
10067
|
runTasksLoop,
|
|
10068
|
+
runtimeParamSpecsFromMetadata,
|
|
10069
|
+
runtimeValuesForSpecs,
|
|
9988
10070
|
scrollbarGlyphs,
|
|
9989
10071
|
scrubEnvContent,
|
|
9990
10072
|
servicePaths,
|