@bakers-build/conductor 0.21.1-next.1 → 0.21.1-next.2
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/src/cli/config-templates.js +2 -2
- package/dist/src/commands/conductor.d.ts +2 -2
- package/dist/src/commands/conductor.js +62 -62
- package/dist/src/commands/oven-tools.js +3 -3
- package/dist/src/config.js +2 -2
- package/dist/src/core/conductor.d.ts +1 -1
- package/dist/src/core/conductor.js +7 -7
- package/dist/src/core/tool-server.js +2 -2
- package/dist/src/preset.js +3 -3
- package/dist/src/process/detached-spawn.d.ts +1 -1
- package/dist/src/process/detached-spawn.js +1 -1
- package/dist/src/types.d.ts +1 -1
- package/package.json +4 -4
|
@@ -49,7 +49,7 @@ ${inputs.label ? ` label: ${JSON.stringify(inputs.label)},\n` : ''}};
|
|
|
49
49
|
}
|
|
50
50
|
export function renderCommittedConfig(inputs) {
|
|
51
51
|
return `// The project's bakers.build configuration — committed and identical for
|
|
52
|
-
// everyone. A
|
|
52
|
+
// everyone. A runner is this machine (machine.config.js) + this project +
|
|
53
53
|
// the variant (project.<name>.config.js). Connections are private files.
|
|
54
54
|
//
|
|
55
55
|
// Each addon in \`addons\` fills its slots through its preset: herdr supplies
|
|
@@ -61,7 +61,7 @@ export default {
|
|
|
61
61
|
project: { name: ${JSON.stringify(inputs.project)}${inputs.bakersWorkspace ? `, workspace: ${JSON.stringify(inputs.bakersWorkspace)}` : ''} },
|
|
62
62
|
// The run budget (max_parallel) is set on the machine in the backend.
|
|
63
63
|
// Transcripts upload only where the server's run-log storage allows it.
|
|
64
|
-
// Set to false to keep this
|
|
64
|
+
// Set to false to keep this runner's transcripts local even then.
|
|
65
65
|
// Metrics are unaffected either way.
|
|
66
66
|
capture_logs: true,
|
|
67
67
|
${inputs.hooks?.after_create || inputs.hooks?.after_done
|
|
@@ -110,7 +110,7 @@ export declare function classify(hub: ConductorStatus, thisHostKey?: string, pro
|
|
|
110
110
|
* provider); otherwise logs a single clear line and returns false.
|
|
111
111
|
*/
|
|
112
112
|
export declare function ensureAuthenticated(config: ConductorFileConfig, logger: ConductorLogger): Promise<boolean>;
|
|
113
|
-
/** `
|
|
113
|
+
/** `runner start --adopt <uuid>` / `--new`: the takeover decision, given up front. */
|
|
114
114
|
export interface TakeoverChoice {
|
|
115
115
|
adopt?: string;
|
|
116
116
|
createNew?: boolean;
|
|
@@ -123,7 +123,7 @@ export interface TakeoverChoice {
|
|
|
123
123
|
*/
|
|
124
124
|
export declare function strayConductorsOf(rows: ConductorStatus[], own: ConductorStatus): ConductorStatus[];
|
|
125
125
|
/** Prompt for the developer Kürzel / user id on an interactive terminal. */
|
|
126
|
-
/** Build the `
|
|
126
|
+
/** Build the `runner` subcommand tree (lifecycle + registry). */
|
|
127
127
|
export declare function createConductorCommand(deps: BbCliDeps): Command;
|
|
128
128
|
/** The `conductor` command plugin the host mounts (BB-201). BB-224
|
|
129
129
|
* (Finding 7): the `bakers deployment` batch helper is no longer registered here —
|
|
@@ -31,7 +31,7 @@ async function defaultMigrateConfig() {
|
|
|
31
31
|
]);
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* `
|
|
34
|
+
* `runner start --dry-run` in a child with this process's own runtime and argv:
|
|
35
35
|
* the changed files are imported fresh there, never into this process.
|
|
36
36
|
*/
|
|
37
37
|
async function defaultCheckConfig() {
|
|
@@ -61,7 +61,7 @@ async function runChild(args) {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* `
|
|
64
|
+
* `runner start --dry-run`: load what a start would load — config with project
|
|
65
65
|
* resolution, executor, workspace and agents — then stop before registering.
|
|
66
66
|
*/
|
|
67
67
|
async function cmdDryRun(deps) {
|
|
@@ -255,7 +255,7 @@ async function buildLsRows(remote, config, onlyId, probe) {
|
|
|
255
255
|
}
|
|
256
256
|
function printRows(rows) {
|
|
257
257
|
if (rows.length === 0) {
|
|
258
|
-
console.log('no
|
|
258
|
+
console.log('no runners on the control plane');
|
|
259
259
|
return;
|
|
260
260
|
}
|
|
261
261
|
for (const r of rows) {
|
|
@@ -366,7 +366,7 @@ async function refuseIfAlreadyRunning(remote, id, thisHostKey, force, deps) {
|
|
|
366
366
|
return false;
|
|
367
367
|
if (!force) {
|
|
368
368
|
const age = heartbeatAgeSeconds(existing);
|
|
369
|
-
console.log(`
|
|
369
|
+
console.log(`runner ${id} already running (pid ${existing.lastPid ?? 'unknown'}, ` +
|
|
370
370
|
`heartbeat ${age === undefined ? 'age unknown' : `${age}s old`})`);
|
|
371
371
|
return true;
|
|
372
372
|
}
|
|
@@ -378,7 +378,7 @@ async function refuseIfAlreadyRunning(remote, id, thisHostKey, force, deps) {
|
|
|
378
378
|
probe,
|
|
379
379
|
});
|
|
380
380
|
if (!stopOutcome.ok) {
|
|
381
|
-
console.log(`failed to restart
|
|
381
|
+
console.log(`failed to restart runner ${id}: could not stop the running runner — ${stopOutcome.message}`);
|
|
382
382
|
process.exitCode = 1;
|
|
383
383
|
return true;
|
|
384
384
|
}
|
|
@@ -391,17 +391,17 @@ async function refuseIfAlreadyRunning(remote, id, thisHostKey, force, deps) {
|
|
|
391
391
|
probe,
|
|
392
392
|
});
|
|
393
393
|
if (!killOutcome.ok) {
|
|
394
|
-
console.log(`failed to restart
|
|
394
|
+
console.log(`failed to restart runner ${id}: still running after the grace period, and could not force-stop it — ${killOutcome.message}`);
|
|
395
395
|
process.exitCode = 1;
|
|
396
396
|
return true;
|
|
397
397
|
}
|
|
398
398
|
if (!(await waitForNotRunning(probe, killOutcome.pid, deps))) {
|
|
399
|
-
console.log(`failed to restart
|
|
399
|
+
console.log(`failed to restart runner ${id}: sent SIGKILL but it is still reported running — refusing a second spawn`);
|
|
400
400
|
process.exitCode = 1;
|
|
401
401
|
return true;
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
|
-
console.log(`stopped
|
|
404
|
+
console.log(`stopped runner ${id} for restart (--force)`);
|
|
405
405
|
return false;
|
|
406
406
|
}
|
|
407
407
|
async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
@@ -427,7 +427,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
427
427
|
if (execve)
|
|
428
428
|
return reExec(env);
|
|
429
429
|
delete process.env.BAKERS_RUN_UUID;
|
|
430
|
-
logger.warn({ node: process.version }, 'without process.execve (Node >= 22.15) the run cleanup can still end this
|
|
430
|
+
logger.warn({ node: process.version }, 'without process.execve (Node >= 22.15) the run cleanup can still end this runner');
|
|
431
431
|
}
|
|
432
432
|
delete process.env.BAKERS_RESTART_SINCE;
|
|
433
433
|
// Every start path ends here: detached child, self-restart and update re-exec.
|
|
@@ -465,7 +465,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
465
465
|
let restart = false;
|
|
466
466
|
let reason = 'serve ended';
|
|
467
467
|
let signalled = false;
|
|
468
|
-
// A stop wins over a restart already decided: `
|
|
468
|
+
// A stop wins over a restart already decided: `runner stop` must stay a stop.
|
|
469
469
|
const onSignal = (signal) => {
|
|
470
470
|
restart = false;
|
|
471
471
|
signalled = true;
|
|
@@ -484,7 +484,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
484
484
|
return loadEnvFiles();
|
|
485
485
|
}
|
|
486
486
|
catch (err) {
|
|
487
|
-
logger.error({ path: secretsFilePath() }, `${err.message}; keeping the running
|
|
487
|
+
logger.error({ path: secretsFilePath() }, `${err.message}; keeping the running runner on its last good secrets`);
|
|
488
488
|
cancelRestart();
|
|
489
489
|
return undefined;
|
|
490
490
|
}
|
|
@@ -522,7 +522,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
522
522
|
const readVersion = deps.readCliVersion ?? readCliVersion;
|
|
523
523
|
const migrate = deps.migrateConfig ?? defaultMigrateConfig;
|
|
524
524
|
const prefix = process.env.BAKERS_CONDUCTOR
|
|
525
|
-
? `bakers --
|
|
525
|
+
? `bakers --runner ${process.env.BAKERS_CONDUCTOR}`
|
|
526
526
|
: 'bakers';
|
|
527
527
|
let lastRead;
|
|
528
528
|
let settled; // the new version already handled or refused
|
|
@@ -532,7 +532,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
532
532
|
mkdirSync(join(envsDir(), level), { recursive: true, mode: 0o700 });
|
|
533
533
|
if (config.restart_on_change !== false && config.watch_paths) {
|
|
534
534
|
if (!execve && !supervised()) {
|
|
535
|
-
logger.warn({ node: process.version }, 'restart_on_change needs process.execve (Node >= 22.15); the
|
|
535
|
+
logger.warn({ node: process.version }, 'restart_on_change needs process.execve (Node >= 22.15); the runner does not restart itself on config changes');
|
|
536
536
|
}
|
|
537
537
|
else {
|
|
538
538
|
watcher = (deps.watchForRestart ?? watchForRestart)({
|
|
@@ -563,10 +563,10 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
563
563
|
if (read !== UNKNOWN_VERSION && read !== startVersion) {
|
|
564
564
|
// A new CLI starts only after migrate and check: retry the upgrade on the next poll.
|
|
565
565
|
settled = undefined;
|
|
566
|
-
logger.info({ path: envPath, to: read }, 'secrets file changed; the pending CLI upgrade restarts the
|
|
566
|
+
logger.info({ path: envPath, to: read }, 'secrets file changed; the pending CLI upgrade restarts the runner');
|
|
567
567
|
return;
|
|
568
568
|
}
|
|
569
|
-
logger.info({ path: envPath }, 'secrets file changed; restarting
|
|
569
|
+
logger.info({ path: envPath }, 'secrets file changed; restarting runner');
|
|
570
570
|
requestRestart(cut);
|
|
571
571
|
return;
|
|
572
572
|
}
|
|
@@ -577,11 +577,11 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
577
577
|
if (controller.signal.aborted)
|
|
578
578
|
return;
|
|
579
579
|
if (error !== undefined) {
|
|
580
|
-
logger.error({ path, err: error }, `config check failed; keeping the running
|
|
580
|
+
logger.error({ path, err: error }, `config check failed; keeping the running runner: ${error}`);
|
|
581
581
|
cancelRestart();
|
|
582
582
|
return;
|
|
583
583
|
}
|
|
584
|
-
logger.info({ path }, 'config check passed; restarting
|
|
584
|
+
logger.info({ path }, 'config check passed; restarting runner');
|
|
585
585
|
requestRestart(cut);
|
|
586
586
|
}, undefined, loadedAt);
|
|
587
587
|
}
|
|
@@ -623,11 +623,11 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
623
623
|
settled = read;
|
|
624
624
|
const changed = `CLI version changed ${startVersion} → ${read}`;
|
|
625
625
|
if (config.restart_on_change === false) {
|
|
626
|
-
logger.warn({ from: startVersion, to: read }, `${changed}; restart_on_change is off, restart with \`${prefix}
|
|
626
|
+
logger.warn({ from: startVersion, to: read }, `${changed}; restart_on_change is off, restart with \`${prefix} runner start --force\``);
|
|
627
627
|
return;
|
|
628
628
|
}
|
|
629
629
|
if (!execve && !supervised()) {
|
|
630
|
-
logger.error({ from: startVersion, to: read, node: process.version }, `${changed}; restarting needs process.execve (Node >= 22.15), restart with \`${prefix}
|
|
630
|
+
logger.error({ from: startVersion, to: read, node: process.version }, `${changed}; restarting needs process.execve (Node >= 22.15), restart with \`${prefix} runner start --force\``);
|
|
631
631
|
return;
|
|
632
632
|
}
|
|
633
633
|
logger.info({ from: startVersion, to: read }, `${changed}; upgrading config`);
|
|
@@ -643,7 +643,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
643
643
|
if (controller.signal.aborted)
|
|
644
644
|
return;
|
|
645
645
|
if (error !== undefined) {
|
|
646
|
-
logger.error({ from: startVersion, to: read, step, err: error }, `${step} failed; keeping the running
|
|
646
|
+
logger.error({ from: startVersion, to: read, step, err: error }, `${step} failed; keeping the running runner on ${startVersion}: ${error}. Recover with \`${prefix} config upgrade --scope all --yes\`, then \`${prefix} runner start --force\``);
|
|
647
647
|
cancelRestart();
|
|
648
648
|
return;
|
|
649
649
|
}
|
|
@@ -652,7 +652,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
652
652
|
finally {
|
|
653
653
|
busy = false;
|
|
654
654
|
}
|
|
655
|
-
logger.info({ to: read }, 'config check passed; restarting
|
|
655
|
+
logger.info({ to: read }, 'config check passed; restarting runner');
|
|
656
656
|
requestRestart();
|
|
657
657
|
}, config.poll_interval_ms);
|
|
658
658
|
try {
|
|
@@ -660,7 +660,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
660
660
|
}
|
|
661
661
|
catch (err) {
|
|
662
662
|
reason = 'error';
|
|
663
|
-
logger.error({ err: String(err) }, `
|
|
663
|
+
logger.error({ err: String(err) }, `runner failed: ${err}`);
|
|
664
664
|
throw err;
|
|
665
665
|
}
|
|
666
666
|
finally {
|
|
@@ -687,7 +687,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
687
687
|
logger.warn({ conductorId: conductor.id, err: String(err) }, 'could not write offline status on shutdown; the lease reaper will');
|
|
688
688
|
}
|
|
689
689
|
}
|
|
690
|
-
logger.info({ reason }, '
|
|
690
|
+
logger.info({ reason }, 'runner stopped');
|
|
691
691
|
}
|
|
692
692
|
if (restart && supervised()) {
|
|
693
693
|
logger.info({ reason }, `restart requested; exiting for supervisor (${reason})`);
|
|
@@ -851,7 +851,7 @@ async function cmdStart(deps, log = {}, updateCheck = true, body = cmdStartBody,
|
|
|
851
851
|
throw new Error(`bakers ${args[0]} exited ${status}`);
|
|
852
852
|
});
|
|
853
853
|
const prefix = env.BAKERS_CONDUCTOR
|
|
854
|
-
? `bakers --
|
|
854
|
+
? `bakers --runner ${env.BAKERS_CONDUCTOR}`
|
|
855
855
|
: 'bakers';
|
|
856
856
|
if (accepted) {
|
|
857
857
|
try {
|
|
@@ -869,7 +869,7 @@ async function cmdStart(deps, log = {}, updateCheck = true, body = cmdStartBody,
|
|
|
869
869
|
catch (err) {
|
|
870
870
|
console.error(`bakers config upgrade failed: ${String(err)}`);
|
|
871
871
|
console.error(`Retry with: ${prefix} config upgrade --scope all --yes`);
|
|
872
|
-
console.error(`Then run \`${prefix}
|
|
872
|
+
console.error(`Then run \`${prefix} runner start${force ? ' --force' : ''}\`.`);
|
|
873
873
|
process.exitCode = 1;
|
|
874
874
|
return;
|
|
875
875
|
}
|
|
@@ -1049,12 +1049,12 @@ async function cmdStartBody(deps, log, force = false, choice = {}) {
|
|
|
1049
1049
|
// this host (same proof as `ls`) is offline: its offline write was lost.
|
|
1050
1050
|
const recordOnline = existing !== undefined && classify(existing) === 'online';
|
|
1051
1051
|
if (recordOnline && classify(existing, thisHostKey, probe) !== 'online') {
|
|
1052
|
-
console.log(`
|
|
1052
|
+
console.log(`runner ${id}: recorded pid ${existing.lastPid} is not running here; starting`);
|
|
1053
1053
|
}
|
|
1054
1054
|
else if (recordOnline) {
|
|
1055
1055
|
if (!force) {
|
|
1056
1056
|
const age = heartbeatAgeSeconds(existing);
|
|
1057
|
-
console.log(`
|
|
1057
|
+
console.log(`runner ${id} already running (pid ${existing.lastPid ?? 'unknown'}, ` +
|
|
1058
1058
|
`heartbeat ${age === undefined ? 'age unknown' : `${age}s old`})`);
|
|
1059
1059
|
return;
|
|
1060
1060
|
}
|
|
@@ -1066,7 +1066,7 @@ async function cmdStartBody(deps, log, force = false, choice = {}) {
|
|
|
1066
1066
|
probe,
|
|
1067
1067
|
});
|
|
1068
1068
|
if (!stopOutcome.ok) {
|
|
1069
|
-
console.log(`failed to restart
|
|
1069
|
+
console.log(`failed to restart runner ${id}: could not stop the running runner — ${stopOutcome.message}`);
|
|
1070
1070
|
process.exitCode = 1;
|
|
1071
1071
|
return;
|
|
1072
1072
|
}
|
|
@@ -1079,17 +1079,17 @@ async function cmdStartBody(deps, log, force = false, choice = {}) {
|
|
|
1079
1079
|
probe,
|
|
1080
1080
|
});
|
|
1081
1081
|
if (!killOutcome.ok) {
|
|
1082
|
-
console.log(`failed to restart
|
|
1082
|
+
console.log(`failed to restart runner ${id}: still running after the grace period, and could not force-stop it — ${killOutcome.message}`);
|
|
1083
1083
|
process.exitCode = 1;
|
|
1084
1084
|
return;
|
|
1085
1085
|
}
|
|
1086
1086
|
if (!(await waitForNotRunning(probe, killOutcome.pid, deps))) {
|
|
1087
|
-
console.log(`failed to restart
|
|
1087
|
+
console.log(`failed to restart runner ${id}: sent SIGKILL but it is still reported running — refusing a second spawn`);
|
|
1088
1088
|
process.exitCode = 1;
|
|
1089
1089
|
return;
|
|
1090
1090
|
}
|
|
1091
1091
|
}
|
|
1092
|
-
console.log(`stopped
|
|
1092
|
+
console.log(`stopped runner ${id} for restart (--force)`);
|
|
1093
1093
|
}
|
|
1094
1094
|
// The detached child has no terminal, so a takeover is settled here first.
|
|
1095
1095
|
if (!existing &&
|
|
@@ -1102,8 +1102,8 @@ async function cmdStartBody(deps, log, force = false, choice = {}) {
|
|
|
1102
1102
|
const argv = [
|
|
1103
1103
|
process.execPath,
|
|
1104
1104
|
process.argv[1], // the running bakers entry script
|
|
1105
|
-
...(stem && stem !== 'conductor' ? ['--
|
|
1106
|
-
'
|
|
1105
|
+
...(stem && stem !== 'conductor' ? ['--runner', stem] : []),
|
|
1106
|
+
'runner',
|
|
1107
1107
|
...(log.level ? ['--log-level', log.level] : []),
|
|
1108
1108
|
// No --log-sink: the child's stdout is the log file, pinned by BAKERS_CONDUCTOR_LOG=file.
|
|
1109
1109
|
'start',
|
|
@@ -1119,10 +1119,10 @@ async function cmdStartBody(deps, log, force = false, choice = {}) {
|
|
|
1119
1119
|
env: { ...process.env, BAKERS_CONDUCTOR_LOG: 'file' },
|
|
1120
1120
|
logPath,
|
|
1121
1121
|
});
|
|
1122
|
-
logger.info({ id, pid: child.pid }, 'started
|
|
1122
|
+
logger.info({ id, pid: child.pid }, 'started runner detached');
|
|
1123
1123
|
}
|
|
1124
1124
|
catch (err) {
|
|
1125
|
-
console.log(`failed to start
|
|
1125
|
+
console.log(`failed to start runner ${id}: could not spawn — ${err.message} — see ${logPath}`);
|
|
1126
1126
|
process.exitCode = 1;
|
|
1127
1127
|
return;
|
|
1128
1128
|
}
|
|
@@ -1135,17 +1135,17 @@ async function cmdStartBody(deps, log, force = false, choice = {}) {
|
|
|
1135
1135
|
waitForFreshHeartbeat(remote, id, priorPid, priorLastSeen, deps, () => exited).then((row) => ({ row })),
|
|
1136
1136
|
]);
|
|
1137
1137
|
if ('code' in outcome) {
|
|
1138
|
-
console.log(`failed to start
|
|
1138
|
+
console.log(`failed to start runner ${id}: exited with code ${outcome.code} before its first heartbeat — see ${logPath}`);
|
|
1139
1139
|
process.exitCode = 1;
|
|
1140
1140
|
return;
|
|
1141
1141
|
}
|
|
1142
1142
|
const started = outcome.row;
|
|
1143
1143
|
if (!started) {
|
|
1144
|
-
console.log(`failed to start
|
|
1144
|
+
console.log(`failed to start runner ${id}: spawned, but no fresh heartbeat arrived — see ${logPath}`);
|
|
1145
1145
|
process.exitCode = 1;
|
|
1146
1146
|
return;
|
|
1147
1147
|
}
|
|
1148
|
-
console.log(`started
|
|
1148
|
+
console.log(`started runner ${id} (pid ${started.lastPid ?? 'unknown'}, host ${started.hostKey ?? thisHostKey})`);
|
|
1149
1149
|
}
|
|
1150
1150
|
/**
|
|
1151
1151
|
* Other conductor records that name the SAME checkout as `own` (BB-450 D6,
|
|
@@ -1185,12 +1185,12 @@ async function cmdStop(deps, now) {
|
|
|
1185
1185
|
const rows = await remote.listConductors('me');
|
|
1186
1186
|
const row = rows.find((c) => c.id === id);
|
|
1187
1187
|
if (!row) {
|
|
1188
|
-
console.log(`no
|
|
1188
|
+
console.log(`no runner ${id} on the control plane — nothing to stop (it may never have started)`);
|
|
1189
1189
|
return;
|
|
1190
1190
|
}
|
|
1191
1191
|
// BB-450 D6: report a stray record naming this checkout, never touch it.
|
|
1192
1192
|
for (const stray of strayConductorsOf(rows, row)) {
|
|
1193
|
-
console.log(`note:
|
|
1193
|
+
console.log(`note: runner ${stray.id} also names this checkout (${stray.workspaceRoot}) — left untouched`);
|
|
1194
1194
|
}
|
|
1195
1195
|
const signal = now ? 'SIGKILL' : 'SIGTERM';
|
|
1196
1196
|
const outcome = signalVerifiedProcess({
|
|
@@ -1201,12 +1201,12 @@ async function cmdStop(deps, now) {
|
|
|
1201
1201
|
...(deps.procProbe ? { probe: deps.procProbe } : {}),
|
|
1202
1202
|
});
|
|
1203
1203
|
if (!outcome.ok) {
|
|
1204
|
-
console.log(`could not stop
|
|
1204
|
+
console.log(`could not stop runner ${id}: ${outcome.message}`);
|
|
1205
1205
|
return;
|
|
1206
1206
|
}
|
|
1207
1207
|
console.log(now
|
|
1208
|
-
? `hard-stopped
|
|
1209
|
-
: `stopped
|
|
1208
|
+
? `hard-stopped runner ${id} (SIGKILL to pid ${outcome.pid}); a killed process writes no offline, so the status follows on lease expiry`
|
|
1209
|
+
: `stopped runner ${id} (SIGTERM to pid ${outcome.pid}); it writes its own offline as it exits`);
|
|
1210
1210
|
}
|
|
1211
1211
|
async function cmdLs(deps) {
|
|
1212
1212
|
const config = deps.config ?? (await tryConfig(deps));
|
|
@@ -1235,9 +1235,9 @@ async function tryConfig(deps) {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
/** Prompt for the developer Kürzel / user id on an interactive terminal. */
|
|
1237
1237
|
// --- the conductor command tree --------------------------------------------
|
|
1238
|
-
/** Build the `
|
|
1238
|
+
/** Build the `runner` subcommand tree (lifecycle + registry). */
|
|
1239
1239
|
export function createConductorCommand(deps) {
|
|
1240
|
-
const conductor = new Command('
|
|
1240
|
+
const conductor = new Command('runner')
|
|
1241
1241
|
.description('node-agent lifecycle + local registry')
|
|
1242
1242
|
.option('--log-level <level>', 'log verbosity: debug | info | warn | error (overrides BAKERS_LOG_LEVEL)')
|
|
1243
1243
|
.option('--log-sink <sink>', 'log sink: stdout | file | both (overrides BAKERS_CONDUCTOR_LOG)')
|
|
@@ -1252,19 +1252,19 @@ Logging (precedence: CLI flag > env var > default):
|
|
|
1252
1252
|
BAKERS_CONDUCTOR_LOG env fallback for --log-sink.
|
|
1253
1253
|
|
|
1254
1254
|
Examples:
|
|
1255
|
-
bakers
|
|
1256
|
-
bakers
|
|
1257
|
-
BAKERS_LOG_LEVEL=debug bakers
|
|
1255
|
+
bakers runner --log-level debug start --foreground
|
|
1256
|
+
bakers runner --log-level debug once
|
|
1257
|
+
BAKERS_LOG_LEVEL=debug bakers runner once`);
|
|
1258
1258
|
conductor
|
|
1259
1259
|
.command('start')
|
|
1260
|
-
.description('start the
|
|
1260
|
+
.description('start the runner loop (a detached background process by default)')
|
|
1261
1261
|
.option('--foreground', 'run the loop in this process', false)
|
|
1262
1262
|
.option('--no-update-check', 'skip the daily CLI update check')
|
|
1263
|
-
.option('--force', 'restart: verify-stop the already-running
|
|
1263
|
+
.option('--force', 'restart: verify-stop the already-running runner (SIGTERM, a grace ' +
|
|
1264
1264
|
'period, then SIGKILL) and start a new one. Fails rather than starting ' +
|
|
1265
|
-
'a second
|
|
1266
|
-
.option('--adopt <uuid>', 'take over the
|
|
1267
|
-
.option('--new', 'register a new
|
|
1265
|
+
'a second runner if the running one cannot be verified or stopped.', false)
|
|
1266
|
+
.option('--adopt <uuid>', 'take over the runner this machine, project and variant already have')
|
|
1267
|
+
.option('--new', 'register a new runner instead of taking one over')
|
|
1268
1268
|
.option('--dry-run', 'load the config, executor, workspace and agents, then exit (0 when they load, 1 with the error)', false)
|
|
1269
1269
|
.action(async function (opts) {
|
|
1270
1270
|
if (opts.dryRun) {
|
|
@@ -1285,7 +1285,7 @@ Examples:
|
|
|
1285
1285
|
});
|
|
1286
1286
|
conductor
|
|
1287
1287
|
.command('once')
|
|
1288
|
-
.description('run one
|
|
1288
|
+
.description('run one runner cycle then exit')
|
|
1289
1289
|
.action(async function () {
|
|
1290
1290
|
await cmdPoll(deps, logOptsOf(this));
|
|
1291
1291
|
});
|
|
@@ -1297,32 +1297,32 @@ Examples:
|
|
|
1297
1297
|
});
|
|
1298
1298
|
conductor
|
|
1299
1299
|
.command('clean')
|
|
1300
|
-
.description('tear down herdr worktrees of finished-but-uncleaned tickets (recovers orphans a live tick missed:
|
|
1300
|
+
.description('tear down herdr worktrees of finished-but-uncleaned tickets (recovers orphans a live tick missed: runner was down at done, restarted, or reassigned)')
|
|
1301
1301
|
.action(async function () {
|
|
1302
1302
|
await cmdReap(deps, logOptsOf(this));
|
|
1303
1303
|
});
|
|
1304
1304
|
conductor
|
|
1305
1305
|
.command('stop')
|
|
1306
|
-
.description('stop the
|
|
1306
|
+
.description('stop the runner: graceful offline (default) or hard kill (--now)')
|
|
1307
1307
|
.option('--now', 'hard-kill via host and let the cron reaper mark it offline', false)
|
|
1308
1308
|
.action(async (opts) => {
|
|
1309
1309
|
await cmdStop(deps, opts.now);
|
|
1310
1310
|
});
|
|
1311
1311
|
conductor
|
|
1312
1312
|
.command('ls')
|
|
1313
|
-
.description('list
|
|
1313
|
+
.description('list runners on this machine + status')
|
|
1314
1314
|
.action(async () => {
|
|
1315
1315
|
await cmdLs(deps);
|
|
1316
1316
|
});
|
|
1317
1317
|
conductor
|
|
1318
1318
|
.command('status')
|
|
1319
|
-
.description('status of the
|
|
1319
|
+
.description('status of the runner for this checkout')
|
|
1320
1320
|
.action(async () => {
|
|
1321
1321
|
await cmdStatus(deps);
|
|
1322
1322
|
});
|
|
1323
1323
|
conductor
|
|
1324
1324
|
.command('tools')
|
|
1325
|
-
.description("list or call the
|
|
1325
|
+
.description("list or call the runner's addon tools from inside a run (exit 4 outside one)")
|
|
1326
1326
|
.argument('[name]', 'the tool to call; omitted, list the tools')
|
|
1327
1327
|
.option('--data <json>', 'arguments as a JSON object, or @<file>')
|
|
1328
1328
|
.option('--schema', "print the tool's input schema instead of calling it")
|
|
@@ -1340,8 +1340,8 @@ Examples:
|
|
|
1340
1340
|
* it is its own command addon, `@bakers-build/addon-deployment`. */
|
|
1341
1341
|
const conductorCommandPlugin = {
|
|
1342
1342
|
kind: 'command',
|
|
1343
|
-
name: '
|
|
1344
|
-
describe: '
|
|
1343
|
+
name: 'runner',
|
|
1344
|
+
describe: 'runner lifecycle + local registry',
|
|
1345
1345
|
register(program, host) {
|
|
1346
1346
|
program.addCommand(createConductorCommand({ host }));
|
|
1347
1347
|
},
|
|
@@ -1353,7 +1353,7 @@ export default conductorCommandPlugin;
|
|
|
1353
1353
|
*/
|
|
1354
1354
|
export function buildConductorProgram(deps = {}) {
|
|
1355
1355
|
const program = new Command();
|
|
1356
|
-
program.name('bakers').description('bakers.build
|
|
1356
|
+
program.name('bakers').description('bakers.build runner + client CLI');
|
|
1357
1357
|
program.addCommand(createConductorCommand(deps));
|
|
1358
1358
|
return program;
|
|
1359
1359
|
}
|
|
@@ -38,7 +38,7 @@ export async function ovenTools(name, opts, env = process.env, io = processIo) {
|
|
|
38
38
|
const url = env[CONDUCTOR_URL_ENV];
|
|
39
39
|
const token = env[CONDUCTOR_TOKEN_ENV];
|
|
40
40
|
if (!url || !token) {
|
|
41
|
-
io.err(`no
|
|
41
|
+
io.err(`no runner tools in this shell: ${CONDUCTOR_URL_ENV} and ${CONDUCTOR_TOKEN_ENV} are set only inside a runner run with a tool server`);
|
|
42
42
|
return EXIT.invalid;
|
|
43
43
|
}
|
|
44
44
|
if (!URL.canParse(url)) {
|
|
@@ -65,7 +65,7 @@ export async function ovenTools(name, opts, env = process.env, io = processIo) {
|
|
|
65
65
|
}
|
|
66
66
|
const tool = tools.find((t) => t.name === name);
|
|
67
67
|
if (!tool) {
|
|
68
|
-
io.err(`unknown
|
|
68
|
+
io.err(`unknown runner tool ${name}; available: ${tools.map((t) => t.name).join(', ') || '(none)'}`);
|
|
69
69
|
return EXIT.invalid;
|
|
70
70
|
}
|
|
71
71
|
if (opts.schema) {
|
|
@@ -95,7 +95,7 @@ export async function ovenTools(name, opts, env = process.env, io = processIo) {
|
|
|
95
95
|
io.err(`run token rejected by ${url}: ${err.message}`);
|
|
96
96
|
return EXIT.rejected;
|
|
97
97
|
}
|
|
98
|
-
io.err(`
|
|
98
|
+
io.err(`runner tool server ${url}: ${err instanceof Error ? err.message : String(err)}`);
|
|
99
99
|
return EXIT.transport;
|
|
100
100
|
}
|
|
101
101
|
finally {
|
package/dist/src/config.js
CHANGED
|
@@ -230,7 +230,7 @@ async function loadInboxAddons(found, toolNames) {
|
|
|
230
230
|
*/
|
|
231
231
|
function validateHookListeners(value) {
|
|
232
232
|
if (!Array.isArray(value))
|
|
233
|
-
throw new Error('
|
|
233
|
+
throw new Error('runner addons[] hooks must accumulate an array');
|
|
234
234
|
for (const [index, listener] of value.entries()) {
|
|
235
235
|
if (!isRecord(listener))
|
|
236
236
|
throw new Error(`hooks[${index}] must be a listener object`);
|
|
@@ -245,7 +245,7 @@ function validateHookListeners(value) {
|
|
|
245
245
|
}
|
|
246
246
|
function requirePlugin(value, kind) {
|
|
247
247
|
if (!isRecord(value) || value.kind !== kind) {
|
|
248
|
-
throw new Error(`
|
|
248
|
+
throw new Error(`runner config requires a ${kind} plugin in the "${kind}" slot`);
|
|
249
249
|
}
|
|
250
250
|
return value;
|
|
251
251
|
}
|
|
@@ -21,7 +21,7 @@ export declare function resolveRunEnv(effectiveEnvVars: string | undefined, core
|
|
|
21
21
|
}): Record<string, string>;
|
|
22
22
|
/**
|
|
23
23
|
* A conductor's registration payload, built from its config: what the engine
|
|
24
|
-
* heartbeats with, and what `
|
|
24
|
+
* heartbeats with, and what `runner start` registers before it spawns one.
|
|
25
25
|
* `conductor_name` is the variant (the config stem, derived through core's
|
|
26
26
|
* own mapping), which the control plane matches a takeover on.
|
|
27
27
|
*/
|
|
@@ -173,7 +173,7 @@ function renderPrompt(template, values) {
|
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
175
|
* A conductor's registration payload, built from its config: what the engine
|
|
176
|
-
* heartbeats with, and what `
|
|
176
|
+
* heartbeats with, and what `runner start` registers before it spawns one.
|
|
177
177
|
* `conductor_name` is the variant (the config stem, derived through core's
|
|
178
178
|
* own mapping), which the control plane matches a takeover on.
|
|
179
179
|
*/
|
|
@@ -342,7 +342,7 @@ export class Conductor {
|
|
|
342
342
|
...new Set((await Promise.all(runtimes.map((r) => r.toolServerHosts?.() ?? []))).flat()),
|
|
343
343
|
];
|
|
344
344
|
const registry = this.config.tools ?? (await loadTools([]));
|
|
345
|
-
// Runs closed while no server ran (`
|
|
345
|
+
// Runs closed while no server ran (`runner once`, a crash) lose their grant here.
|
|
346
346
|
const openRuns = await this.remote.fetchActiveRuns(this.id).then((runs) => runs.map((r) => r.runUuid), (err) => {
|
|
347
347
|
this.logger.warn({ err: String(err) }, 'active runs unreadable, keeping every persisted run grant');
|
|
348
348
|
return undefined;
|
|
@@ -468,7 +468,7 @@ export class Conductor {
|
|
|
468
468
|
...rest,
|
|
469
469
|
});
|
|
470
470
|
}
|
|
471
|
-
this.logger.info({ conductorId: this.id, uuid: this.uuid, project: this.config.project }, '
|
|
471
|
+
this.logger.info({ conductorId: this.id, uuid: this.uuid, project: this.config.project }, 'runner started');
|
|
472
472
|
try {
|
|
473
473
|
await this.inboxAddons.register(this.id);
|
|
474
474
|
}
|
|
@@ -555,7 +555,7 @@ export class Conductor {
|
|
|
555
555
|
active: count,
|
|
556
556
|
machineLoad,
|
|
557
557
|
capacity: maxParallel,
|
|
558
|
-
}, '
|
|
558
|
+
}, 'runner tick');
|
|
559
559
|
if (capacity && machineLoad > maxParallel) {
|
|
560
560
|
// BB-464 D4: a breach is its own signal, not merely the reason no
|
|
561
561
|
// further claim was made — this server-side ceiling (TicketClaimService)
|
|
@@ -1881,8 +1881,8 @@ export class Conductor {
|
|
|
1881
1881
|
/** The run's slot choices as a run note, and a ticket comment when a label put it on a runtime that does not isolate. Never fails the run. */
|
|
1882
1882
|
async recordChoices(runUuid, t, agent, agentWhy, runtime, isolates) {
|
|
1883
1883
|
const owner = t.conductorOwner
|
|
1884
|
-
? `
|
|
1885
|
-
: '
|
|
1884
|
+
? `runner owner ${t.conductorOwner}`
|
|
1885
|
+
: 'runner owner unknown';
|
|
1886
1886
|
try {
|
|
1887
1887
|
await this.remote.appendRunNote(runUuid, `agent ${agent} (${agentWhy}); runtime ${runtime.alias} (${runtime.reason}); ${owner}`);
|
|
1888
1888
|
}
|
|
@@ -1952,7 +1952,7 @@ export class Conductor {
|
|
|
1952
1952
|
// reaper flips status to offline on lease expiry, same as any crash.
|
|
1953
1953
|
// Deliberately NOT an offline write from here: the loop never owns that
|
|
1954
1954
|
// transition (see the note at the end of this method).
|
|
1955
|
-
this.logger.error({ conductorId: this.id, workspace: this.checkoutRoot }, 'checkout is gone — stopping
|
|
1955
|
+
this.logger.error({ conductorId: this.id, workspace: this.checkoutRoot }, 'checkout is gone — stopping runner instead of claiming runs it cannot dispatch');
|
|
1956
1956
|
await this.queue.drain();
|
|
1957
1957
|
return;
|
|
1958
1958
|
}
|
|
@@ -133,7 +133,7 @@ export async function startToolServer(options) {
|
|
|
133
133
|
if (!options.workspaceRoot ||
|
|
134
134
|
!isInside(options.workspaceRoot, body.worktree))
|
|
135
135
|
return send(res, 403, {
|
|
136
|
-
error: `${body.worktree} is not under the
|
|
136
|
+
error: `${body.worktree} is not under the runner's workspace root ${options.workspaceRoot ?? '(none)'}`,
|
|
137
137
|
});
|
|
138
138
|
try {
|
|
139
139
|
const result = await registry.call(body.tool, body.args, {
|
|
@@ -157,7 +157,7 @@ export async function startToolServer(options) {
|
|
|
157
157
|
const binding = bindingOf(bearer(req));
|
|
158
158
|
if (!binding)
|
|
159
159
|
return send(res, 401, {
|
|
160
|
-
error: 'unknown run token —
|
|
160
|
+
error: 'unknown run token — runner restarted?',
|
|
161
161
|
});
|
|
162
162
|
// Stateless (no session id generator): one server and transport per request.
|
|
163
163
|
const server = mcpServer(binding);
|
package/dist/src/preset.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const commands = (acc) => [
|
|
2
2
|
...acc,
|
|
3
3
|
{
|
|
4
|
-
name: '
|
|
5
|
-
aliases: ['
|
|
4
|
+
name: 'runner',
|
|
5
|
+
aliases: ['conductor'],
|
|
6
6
|
plugin: '@bakers-build/conductor/commands/conductor',
|
|
7
|
-
describe: '
|
|
7
|
+
describe: 'runner lifecycle + local registry',
|
|
8
8
|
},
|
|
9
9
|
];
|
|
@@ -12,7 +12,7 @@ export interface DetachedChild {
|
|
|
12
12
|
exited: Promise<number | null>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Starts `
|
|
15
|
+
* Starts `runner start --foreground` as a detached conductor: its own session
|
|
16
16
|
* (no controlling terminal, untouched by the starting shell's SIGHUP), stdin
|
|
17
17
|
* closed, stdout and stderr appended to the conductor log, and unref'd so the
|
|
18
18
|
* starting process can exit while it runs.
|
|
@@ -2,7 +2,7 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import { closeSync, mkdirSync, openSync } from 'node:fs';
|
|
3
3
|
import { dirname } from 'node:path';
|
|
4
4
|
/**
|
|
5
|
-
* Starts `
|
|
5
|
+
* Starts `runner start --foreground` as a detached conductor: its own session
|
|
6
6
|
* (no controlling terminal, untouched by the starting shell's SIGHUP), stdin
|
|
7
7
|
* closed, stdout and stderr appended to the conductor log, and unref'd so the
|
|
8
8
|
* starting process can exit while it runs.
|
package/dist/src/types.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ export interface ConductorSettings {
|
|
|
82
82
|
/** Absolute path of the loaded config. */
|
|
83
83
|
config_path: string;
|
|
84
84
|
/**
|
|
85
|
-
* `
|
|
85
|
+
* `runner start --foreground` restarts itself when a file in `watch_paths`
|
|
86
86
|
* changes. Default true.
|
|
87
87
|
*/
|
|
88
88
|
restart_on_change?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/conductor",
|
|
3
|
-
"version": "0.21.1-next.
|
|
3
|
+
"version": "0.21.1-next.2",
|
|
4
4
|
"description": "bakers.build, the open source AI software factory: conductor engine + CLI: registers, claims tickets via JSON:API, dispatches agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@dropsh/plugin-jsonapi-schema": "^0.8.2",
|
|
45
45
|
"@dropsh/plugin-oauth2": "^0.8.2",
|
|
46
|
-
"@bakers-build/core": "^0.21.1-next.
|
|
47
|
-
"@bakers-build/message": "^0.21.1-next.
|
|
46
|
+
"@bakers-build/core": "^0.21.1-next.2",
|
|
47
|
+
"@bakers-build/message": "^0.21.1-next.2",
|
|
48
48
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
49
49
|
"commander": "^12.1.0",
|
|
50
50
|
"dropsh": "^0.8.2"
|
|
51
51
|
},
|
|
52
52
|
"bakersBuild": {
|
|
53
|
-
"commit": "
|
|
53
|
+
"commit": "a87e7555360eb6a9ec167dc172c66d8e98293e34",
|
|
54
54
|
"channel": "next"
|
|
55
55
|
}
|
|
56
56
|
}
|