@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.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,
|
|
@@ -8512,6 +8516,67 @@ var LOGGER_RUNTIME_KEYS = [
|
|
|
8512
8516
|
"progressWithTimes",
|
|
8513
8517
|
"progressThrottleMs"
|
|
8514
8518
|
];
|
|
8519
|
+
var DEFAULT_RUNTIME_PARAM_SPECS = [
|
|
8520
|
+
{
|
|
8521
|
+
key: "maxParallel",
|
|
8522
|
+
type: "number",
|
|
8523
|
+
label: "Max parallel",
|
|
8524
|
+
description: "Worker-lane concurrency (how many tasks claim at once)"
|
|
8525
|
+
},
|
|
8526
|
+
{
|
|
8527
|
+
key: "pollMs",
|
|
8528
|
+
type: "number",
|
|
8529
|
+
label: "Poll ms",
|
|
8530
|
+
description: "Idle poll interval between claim attempts"
|
|
8531
|
+
},
|
|
8532
|
+
{
|
|
8533
|
+
key: "claimJitterMs",
|
|
8534
|
+
type: "number",
|
|
8535
|
+
label: "Claim jitter ms",
|
|
8536
|
+
description: "Random delay before worker claims (0 = off)"
|
|
8537
|
+
},
|
|
8538
|
+
{
|
|
8539
|
+
key: "scanLimit",
|
|
8540
|
+
type: "number",
|
|
8541
|
+
label: "Scan limit",
|
|
8542
|
+
description: "Max idle rows scanned per claim attempt"
|
|
8543
|
+
}
|
|
8544
|
+
];
|
|
8545
|
+
function mergeRuntimeParamSpecs(extra) {
|
|
8546
|
+
const byKey = new Map(DEFAULT_RUNTIME_PARAM_SPECS.map((s) => [s.key, { ...s }]));
|
|
8547
|
+
if (Array.isArray(extra)) {
|
|
8548
|
+
for (const raw of extra) {
|
|
8549
|
+
if (!raw || typeof raw !== "object") continue;
|
|
8550
|
+
const key = String(raw.key ?? "").trim();
|
|
8551
|
+
if (!key) continue;
|
|
8552
|
+
const prev = byKey.get(key) ?? {};
|
|
8553
|
+
const type = ["number", "boolean", "string"].includes(raw.type) ? raw.type : prev.type ?? "string";
|
|
8554
|
+
byKey.set(key, {
|
|
8555
|
+
key,
|
|
8556
|
+
type,
|
|
8557
|
+
label: String(raw.label ?? prev.label ?? key),
|
|
8558
|
+
description: raw.description != null ? String(raw.description) : prev.description != null ? String(prev.description) : void 0
|
|
8559
|
+
});
|
|
8560
|
+
}
|
|
8561
|
+
}
|
|
8562
|
+
return Array.from(byKey.values());
|
|
8563
|
+
}
|
|
8564
|
+
function runtimeValuesForSpecs(context, specs = DEFAULT_RUNTIME_PARAM_SPECS) {
|
|
8565
|
+
const rt = ensureTasksRuntime(context);
|
|
8566
|
+
const out = {};
|
|
8567
|
+
for (const s of specs) {
|
|
8568
|
+
if (rt[s.key] !== void 0) out[s.key] = rt[s.key];
|
|
8569
|
+
}
|
|
8570
|
+
return out;
|
|
8571
|
+
}
|
|
8572
|
+
function runtimeParamSpecsFromMetadata(metadata) {
|
|
8573
|
+
const meta = metadata && typeof metadata === "object" ? metadata : null;
|
|
8574
|
+
const raw = meta?.runtimeParams;
|
|
8575
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
8576
|
+
return mergeRuntimeParamSpecs();
|
|
8577
|
+
}
|
|
8578
|
+
return mergeRuntimeParamSpecs(raw);
|
|
8579
|
+
}
|
|
8515
8580
|
var CONTROL_LANE_TASK_NAMES = [
|
|
8516
8581
|
"stopRunner",
|
|
8517
8582
|
"stop",
|
|
@@ -8608,12 +8673,15 @@ async function applyRuntimeParam(context, key, value) {
|
|
|
8608
8673
|
const reg = context.servicesRegistry;
|
|
8609
8674
|
if (reg?.rowId && reg?.registryTable) {
|
|
8610
8675
|
try {
|
|
8611
|
-
const
|
|
8676
|
+
const specs = Array.isArray(context.tasksRuntimeParamSpecs) ? context.tasksRuntimeParamSpecs : DEFAULT_RUNTIME_PARAM_SPECS;
|
|
8677
|
+
const runtimeSnapshot = runtimeValuesForSpecs(context, specs);
|
|
8612
8678
|
for (const lk of LOOP_RUNTIME_KEYS) {
|
|
8613
|
-
if (runtime[lk] !== void 0
|
|
8679
|
+
if (runtime[lk] !== void 0 && runtimeSnapshot[lk] === void 0) {
|
|
8680
|
+
runtimeSnapshot[lk] = runtime[lk];
|
|
8681
|
+
}
|
|
8614
8682
|
}
|
|
8615
8683
|
await updateServicesRegistryMetadata(context, reg, {
|
|
8616
|
-
runtime:
|
|
8684
|
+
runtime: runtimeSnapshot,
|
|
8617
8685
|
runtimeUpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8618
8686
|
});
|
|
8619
8687
|
applied.push("servicesRegistry");
|
|
@@ -9506,18 +9574,25 @@ async function runTasksLoop(context, options) {
|
|
|
9506
9574
|
if (hbGroup) {
|
|
9507
9575
|
const hbIntervalMs = options.runnerHeartbeatIntervalMs ?? 1e4;
|
|
9508
9576
|
const staleMs = options.runnerHeartbeatStaleMs ?? 45e3;
|
|
9509
|
-
const
|
|
9577
|
+
const runtimeParamSpecs = mergeRuntimeParamSpecs(options.runnerRuntimeParams);
|
|
9578
|
+
context.tasksRuntimeParamSpecs = runtimeParamSpecs;
|
|
9510
9579
|
const defaultMeta = {
|
|
9511
9580
|
component: "tasks-runner",
|
|
9512
9581
|
allowedTasks: allowedTasks?.length ? allowedTasks.join(",") : "all",
|
|
9513
9582
|
paused: false,
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
|
|
9517
|
-
|
|
9518
|
-
|
|
9519
|
-
}
|
|
9583
|
+
runtimeParams: runtimeParamSpecs,
|
|
9584
|
+
runtime: runtimeValuesForSpecs(context, runtimeParamSpecs)
|
|
9585
|
+
};
|
|
9586
|
+
const metadata = {
|
|
9587
|
+
...defaultMeta,
|
|
9588
|
+
...options.runnerMetadata && typeof options.runnerMetadata === "object" ? options.runnerMetadata : {}
|
|
9520
9589
|
};
|
|
9590
|
+
if (!Array.isArray(metadata.runtimeParams) || metadata.runtimeParams.length === 0) {
|
|
9591
|
+
metadata.runtimeParams = defaultMeta.runtimeParams;
|
|
9592
|
+
}
|
|
9593
|
+
if (!metadata.runtime || typeof metadata.runtime !== "object") {
|
|
9594
|
+
metadata.runtime = defaultMeta.runtime;
|
|
9595
|
+
}
|
|
9521
9596
|
registryReg = await registerInServicesRegistry(context, {
|
|
9522
9597
|
queueName,
|
|
9523
9598
|
target,
|
|
@@ -9527,7 +9602,7 @@ async function runTasksLoop(context, options) {
|
|
|
9527
9602
|
staleMs,
|
|
9528
9603
|
groupMaxInstances: options.runnerGroupMaxInstances,
|
|
9529
9604
|
enforceMaxInstances: options.runnerEnforceMaxInstances ?? true,
|
|
9530
|
-
metadata
|
|
9605
|
+
metadata
|
|
9531
9606
|
});
|
|
9532
9607
|
context.servicesRegistry = registryReg;
|
|
9533
9608
|
runnerIdentity = {
|
|
@@ -9847,6 +9922,7 @@ var TasksManager = class _TasksManager {
|
|
|
9847
9922
|
BAR_THUMB,
|
|
9848
9923
|
BAR_TRACK,
|
|
9849
9924
|
Box,
|
|
9925
|
+
DEFAULT_RUNTIME_PARAM_SPECS,
|
|
9850
9926
|
Db,
|
|
9851
9927
|
Divider,
|
|
9852
9928
|
FileDatabase,
|
|
@@ -9949,6 +10025,7 @@ var TasksManager = class _TasksManager {
|
|
|
9949
10025
|
matchesParsedPattern,
|
|
9950
10026
|
memo,
|
|
9951
10027
|
mergeAllowedTasksWithServiceTasks,
|
|
10028
|
+
mergeRuntimeParamSpecs,
|
|
9952
10029
|
nextTimeMatch,
|
|
9953
10030
|
normalizeAllowedTasks,
|
|
9954
10031
|
npmEnv,
|
|
@@ -9985,6 +10062,8 @@ var TasksManager = class _TasksManager {
|
|
|
9985
10062
|
runRemoteStatus,
|
|
9986
10063
|
runShell,
|
|
9987
10064
|
runTasksLoop,
|
|
10065
|
+
runtimeParamSpecsFromMetadata,
|
|
10066
|
+
runtimeValuesForSpecs,
|
|
9988
10067
|
scrollbarGlyphs,
|
|
9989
10068
|
scrubEnvContent,
|
|
9990
10069
|
servicePaths,
|