@bakers-build/conductor 0.10.1-next.1 → 0.10.1-next.11
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.
|
@@ -69,6 +69,10 @@ export interface BbCliDeps {
|
|
|
69
69
|
checkConfig?: () => Promise<string | undefined>;
|
|
70
70
|
/** Replaces this process (`process.execve`). A test MUST inject a fake. */
|
|
71
71
|
execve?: Execve;
|
|
72
|
+
/** Reads the installed CLI version from disk, uncached. */
|
|
73
|
+
readCliVersion?: () => string;
|
|
74
|
+
/** Migrates the config with the installed CLI; resolves an error message, or undefined. */
|
|
75
|
+
migrateConfig?: () => Promise<string | undefined>;
|
|
72
76
|
}
|
|
73
77
|
type Execve = (file: string, args: string[], env: NodeJS.ProcessEnv) => void;
|
|
74
78
|
/**
|
|
@@ -2,7 +2,7 @@ import { execFile, spawnSync } from 'node:child_process';
|
|
|
2
2
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
3
3
|
import { createInterface } from 'node:readline';
|
|
4
4
|
import { promisify } from 'node:util';
|
|
5
|
-
import { CommandRunner, checkForUpdate, configHomeOf, createBbConnectionClient, createLogger, declineUpdate, defaultProcProbe, deriveCheckoutRoot, deriveConductorLiveness, homeBbDir, loadReadyBbConnection, printVersionLine, readMachineContext, resolveConfigPath, setDefaultCommandRunner, signalVerifiedProcess, stemForConfigFile, updateNotice, verifyConductorProcess, } from '@bakers-build/core';
|
|
5
|
+
import { CommandRunner, checkForUpdate, configHomeOf, createBbConnectionClient, createLogger, declineUpdate, defaultProcProbe, deriveCheckoutRoot, deriveConductorLiveness, homeBbDir, loadReadyBbConnection, printVersionLine, readCliVersion, readMachineContext, resolveCliVersion, resolveConfigPath, setDefaultCommandRunner, signalVerifiedProcess, stemForConfigFile, UNKNOWN_VERSION, updateNotice, verifyConductorProcess, } from '@bakers-build/core';
|
|
6
6
|
import { Command } from 'commander';
|
|
7
7
|
import { authStatus } from 'dropsh';
|
|
8
8
|
import { resolveBbProjectContext } from '../bakers-project-context.js';
|
|
@@ -13,29 +13,49 @@ import { selectAgents, selectExecutor, selectRemote, selectWorkspace, } from '..
|
|
|
13
13
|
import { runtimeSandboxWarning, sandboxFailures, } from '../plugins/sandbox-preflight.js';
|
|
14
14
|
import { spawnDetachedConductor, } from '../process/detached-spawn.js';
|
|
15
15
|
import { ovenTools } from './oven-tools.js';
|
|
16
|
+
/**
|
|
17
|
+
* `config upgrade --scope all --yes` with the installed CLI in a child: the
|
|
18
|
+
* new files migrate the config, never the modules this process still holds.
|
|
19
|
+
*/
|
|
20
|
+
async function defaultMigrateConfig() {
|
|
21
|
+
return runChild([
|
|
22
|
+
...process.execArgv,
|
|
23
|
+
process.argv[1],
|
|
24
|
+
'config',
|
|
25
|
+
'upgrade',
|
|
26
|
+
'--scope',
|
|
27
|
+
'all',
|
|
28
|
+
'--yes',
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
16
31
|
/**
|
|
17
32
|
* `oven start --dry-run` in a child with this process's own runtime and argv:
|
|
18
33
|
* the changed files are imported fresh there, never into this process.
|
|
19
34
|
*/
|
|
20
35
|
async function defaultCheckConfig() {
|
|
21
|
-
|
|
36
|
+
return runChild([
|
|
22
37
|
...process.execArgv,
|
|
23
38
|
...process.argv
|
|
24
39
|
.slice(1)
|
|
25
40
|
.map((a) => (a === '--foreground' ? '--dry-run' : a)),
|
|
26
|
-
];
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
/** Runs node with `args`; resolves the error output, or undefined on success. */
|
|
44
|
+
async function runChild(args) {
|
|
27
45
|
try {
|
|
28
46
|
await promisify(execFile)(process.execPath, args, {
|
|
29
47
|
cwd: process.cwd(),
|
|
30
48
|
env: process.env,
|
|
31
|
-
// A hung
|
|
49
|
+
// A hung child would block every later restart; a timeout fails it.
|
|
32
50
|
timeout: 60_000,
|
|
33
51
|
});
|
|
34
52
|
return undefined;
|
|
35
53
|
}
|
|
36
54
|
catch (err) {
|
|
37
|
-
const { stderr, message } = err;
|
|
38
|
-
|
|
55
|
+
const { stderr, stdout, message } = err;
|
|
56
|
+
// `config upgrade` reports a blocked migration on stdout, not stderr.
|
|
57
|
+
const output = stderr?.trim() || stdout?.trim();
|
|
58
|
+
return output?.split('\n').slice(-20).join('\n') || message;
|
|
39
59
|
}
|
|
40
60
|
}
|
|
41
61
|
/**
|
|
@@ -389,12 +409,18 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
389
409
|
process.once('SIGTERM', onSignal);
|
|
390
410
|
const execve = deps.execve ?? process.execve?.bind(process);
|
|
391
411
|
let watcher;
|
|
412
|
+
const check = deps.checkConfig ?? defaultCheckConfig;
|
|
413
|
+
const restartNow = () => {
|
|
414
|
+
restart = true;
|
|
415
|
+
watcher?.close();
|
|
416
|
+
clearInterval(versionTimer);
|
|
417
|
+
controller.abort();
|
|
418
|
+
};
|
|
392
419
|
if (config.restart_on_change !== false && config.watch_paths) {
|
|
393
420
|
if (!execve) {
|
|
394
421
|
logger.warn({ node: process.version }, 'restart_on_change needs process.execve (Node >= 22.15); the conductor does not restart itself on config changes');
|
|
395
422
|
}
|
|
396
423
|
else {
|
|
397
|
-
const check = deps.checkConfig ?? defaultCheckConfig;
|
|
398
424
|
watcher = (deps.watchForRestart ?? watchForRestart)(config.watch_paths, async (path) => {
|
|
399
425
|
if (controller.signal.aborted)
|
|
400
426
|
return;
|
|
@@ -408,17 +434,70 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
408
434
|
return;
|
|
409
435
|
}
|
|
410
436
|
logger.info({ path }, 'config check passed; restarting conductor');
|
|
411
|
-
|
|
412
|
-
watcher?.close();
|
|
413
|
-
controller.abort();
|
|
437
|
+
restartNow();
|
|
414
438
|
});
|
|
415
439
|
}
|
|
416
440
|
}
|
|
441
|
+
// An upgrade replaces the installed files under this running process: once
|
|
442
|
+
// two polls read the same new version, migrate, check and come back on it.
|
|
443
|
+
const startVersion = resolveCliVersion();
|
|
444
|
+
const readVersion = deps.readCliVersion ?? readCliVersion;
|
|
445
|
+
const migrate = deps.migrateConfig ?? defaultMigrateConfig;
|
|
446
|
+
const prefix = process.env.BAKERS_CONDUCTOR
|
|
447
|
+
? `bakers --conductor ${process.env.BAKERS_CONDUCTOR}`
|
|
448
|
+
: 'bakers';
|
|
449
|
+
let lastRead;
|
|
450
|
+
let settled; // the new version already handled or refused
|
|
451
|
+
let busy = false;
|
|
452
|
+
const versionTimer = setInterval(async () => {
|
|
453
|
+
if (busy || controller.signal.aborted)
|
|
454
|
+
return;
|
|
455
|
+
const read = readVersion();
|
|
456
|
+
const previous = lastRead;
|
|
457
|
+
lastRead = read;
|
|
458
|
+
if (read === UNKNOWN_VERSION || read === startVersion)
|
|
459
|
+
return;
|
|
460
|
+
// A half-written install reads differently on the next poll.
|
|
461
|
+
if (read !== previous || read === settled)
|
|
462
|
+
return;
|
|
463
|
+
settled = read;
|
|
464
|
+
const changed = `CLI version changed ${startVersion} → ${read}`;
|
|
465
|
+
if (config.restart_on_change === false) {
|
|
466
|
+
logger.warn({ from: startVersion, to: read }, `${changed}; restart_on_change is off, restart with \`${prefix} oven start --force\``);
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (!execve) {
|
|
470
|
+
logger.error({ from: startVersion, to: read, node: process.version }, `${changed}; restarting needs process.execve (Node >= 22.15), restart with \`${prefix} oven start --force\``);
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
logger.info({ from: startVersion, to: read }, `${changed}; upgrading config`);
|
|
474
|
+
busy = true;
|
|
475
|
+
try {
|
|
476
|
+
for (const [step, run] of [
|
|
477
|
+
['config upgrade', migrate],
|
|
478
|
+
['config check', check],
|
|
479
|
+
]) {
|
|
480
|
+
const error = await run();
|
|
481
|
+
if (controller.signal.aborted)
|
|
482
|
+
return;
|
|
483
|
+
if (error !== undefined) {
|
|
484
|
+
logger.error({ from: startVersion, to: read, step, err: error }, `${step} failed; keeping the running conductor on ${startVersion}: ${error}. Recover with \`${prefix} config upgrade --scope all --yes\`, then \`${prefix} oven start --force\``);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
finally {
|
|
490
|
+
busy = false;
|
|
491
|
+
}
|
|
492
|
+
logger.info({ to: read }, 'config check passed; restarting conductor');
|
|
493
|
+
restartNow();
|
|
494
|
+
}, config.poll_interval_ms);
|
|
417
495
|
try {
|
|
418
496
|
await conductor.serve(controller.signal);
|
|
419
497
|
}
|
|
420
498
|
finally {
|
|
421
499
|
watcher?.close();
|
|
500
|
+
clearInterval(versionTimer);
|
|
422
501
|
await conductor.stopTools();
|
|
423
502
|
process.removeListener('SIGINT', onSignal);
|
|
424
503
|
process.removeListener('SIGTERM', onSignal);
|
|
@@ -554,7 +633,7 @@ async function cmdStart(deps, log = {}, updateCheck = true, body = cmdStartBody,
|
|
|
554
633
|
const interactive = !foreground && isInteractive(deps);
|
|
555
634
|
if (notice && interactive && result.declined !== true) {
|
|
556
635
|
console.log('Installing accepts the newer release and runs configuration migration.');
|
|
557
|
-
console.log('After a successful install this start
|
|
636
|
+
console.log('After a successful install this start continues on the new release.');
|
|
558
637
|
const question = `A new bakers version is available (${current} → ${result.latestVersion}). Install it now? [Y/n]`;
|
|
559
638
|
const ask = deps.askUpdate ?? defaultAskUpdate;
|
|
560
639
|
let accepted;
|
|
@@ -594,7 +673,6 @@ async function cmdStart(deps, log = {}, updateCheck = true, body = cmdStartBody,
|
|
|
594
673
|
const prefix = env.BAKERS_CONDUCTOR
|
|
595
674
|
? `bakers --conductor ${env.BAKERS_CONDUCTOR}`
|
|
596
675
|
: 'bakers';
|
|
597
|
-
const rerun = `${prefix} conductor start${force ? ' --force' : ''}`;
|
|
598
676
|
if (accepted) {
|
|
599
677
|
try {
|
|
600
678
|
await runBb(['update']);
|
|
@@ -611,13 +689,26 @@ async function cmdStart(deps, log = {}, updateCheck = true, body = cmdStartBody,
|
|
|
611
689
|
catch (err) {
|
|
612
690
|
console.error(`bakers config upgrade failed: ${String(err)}`);
|
|
613
691
|
console.error(`Retry with: ${prefix} config upgrade --scope all --yes`);
|
|
614
|
-
console.error(`Then
|
|
692
|
+
console.error(`Then run \`${prefix} conductor start${force ? ' --force' : ''}\`.`);
|
|
615
693
|
process.exitCode = 1;
|
|
616
694
|
return;
|
|
617
695
|
}
|
|
618
696
|
console.log('bakers update and configuration migration completed.');
|
|
619
|
-
|
|
620
|
-
|
|
697
|
+
// This process still holds the previous modules: continue as a fresh
|
|
698
|
+
// process of the same command on the new release, without asking again.
|
|
699
|
+
const again = [...process.argv.slice(1), '--no-update-check'];
|
|
700
|
+
const execve = deps.execve ?? process.execve?.bind(process);
|
|
701
|
+
if (execve) {
|
|
702
|
+
execve(process.execPath, [process.execPath, ...process.execArgv, ...again], env);
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
try {
|
|
706
|
+
await runBb(again.slice(1));
|
|
707
|
+
}
|
|
708
|
+
catch (err) {
|
|
709
|
+
console.error(String(err));
|
|
710
|
+
process.exitCode = 1;
|
|
711
|
+
}
|
|
621
712
|
return;
|
|
622
713
|
}
|
|
623
714
|
if (!(await declineUpdate(result, options))) {
|
package/dist/src/config.d.ts
CHANGED
|
@@ -15,16 +15,9 @@ export { findBbDir, resolveConfigPath, } from '@bakers-build/core';
|
|
|
15
15
|
* ticket content into a single typed pane line overran the PTY canonical line
|
|
16
16
|
* cap and truncated the dispatch command. Instead the prompt is a bounded,
|
|
17
17
|
* constant-size pointer and the agent reads the ticket at run start. That read
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* read-ticket.md).
|
|
21
|
-
*
|
|
22
|
-
* That read goes through the bakers tool `bakers_ticket_read`, the same path
|
|
23
|
-
* every skill step uses, so the run does not read its ticket twice in two
|
|
24
|
-
* formats. The prompt names both transports because the agent has not loaded
|
|
25
|
-
* a skill yet: the MCP tool, else `bakers tools`, which itself goes to the
|
|
26
|
-
* run's conductor (run token, no site credential) inside a run and to the site
|
|
27
|
-
* outside one; why a CLI call must run alone lives in bb-workflow's tools.md.
|
|
18
|
+
* goes through `bakers_ticket_read`, the same path every skill step uses. The
|
|
19
|
+
* prompt names no tool or arguments: the loaded skill (bb-workflow's
|
|
20
|
+
* read-ticket.md) owns which comment types the state's first read loads.
|
|
28
21
|
*
|
|
29
22
|
* herdr no longer types this into the pane: the launch command goes to a file
|
|
30
23
|
* that a short `sh '<file>'` line runs (BB-635), so its length is not bound
|
|
@@ -95,7 +88,7 @@ export declare function listConductorConfigFiles(bakersDir: string): string[];
|
|
|
95
88
|
/**
|
|
96
89
|
* Remove the obsolete `states:` array property from a conductor-config JS
|
|
97
90
|
* source (BB-207 made `states` optional — empty ⇒ serve all claimable
|
|
98
|
-
* states — so `@bakers-build/bb-
|
|
91
|
+
* states — so `@bakers-build/bb-init-project` drops the now-dead key). Pure string
|
|
99
92
|
* transform: it strips the `states: [ ... ]` property (line form or inline in
|
|
100
93
|
* an object literal) with its trailing comma, and rewrites nothing else. A
|
|
101
94
|
* `substates:`/other key containing "states" is not matched.
|
package/dist/src/config.js
CHANGED
|
@@ -27,16 +27,9 @@ export { findBbDir, resolveConfigPath, } from '@bakers-build/core';
|
|
|
27
27
|
* ticket content into a single typed pane line overran the PTY canonical line
|
|
28
28
|
* cap and truncated the dispatch command. Instead the prompt is a bounded,
|
|
29
29
|
* constant-size pointer and the agent reads the ticket at run start. That read
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* read-ticket.md).
|
|
33
|
-
*
|
|
34
|
-
* That read goes through the bakers tool `bakers_ticket_read`, the same path
|
|
35
|
-
* every skill step uses, so the run does not read its ticket twice in two
|
|
36
|
-
* formats. The prompt names both transports because the agent has not loaded
|
|
37
|
-
* a skill yet: the MCP tool, else `bakers tools`, which itself goes to the
|
|
38
|
-
* run's conductor (run token, no site credential) inside a run and to the site
|
|
39
|
-
* outside one; why a CLI call must run alone lives in bb-workflow's tools.md.
|
|
30
|
+
* goes through `bakers_ticket_read`, the same path every skill step uses. The
|
|
31
|
+
* prompt names no tool or arguments: the loaded skill (bb-workflow's
|
|
32
|
+
* read-ticket.md) owns which comment types the state's first read loads.
|
|
40
33
|
*
|
|
41
34
|
* herdr no longer types this into the pane: the launch command goes to a file
|
|
42
35
|
* that a short `sh '<file>'` line runs (BB-635), so its length is not bound
|
|
@@ -68,7 +61,7 @@ export { findBbDir, resolveConfigPath, } from '@bakers-build/core';
|
|
|
68
61
|
export const DEFAULT_AGENT_PROMPT = `You are working ticket {identifier}, current state: {state}. Read ./WORKFLOW.md first and ` +
|
|
69
62
|
`load the bakers.build entry skill named there. ` +
|
|
70
63
|
`Do not call ticket or service tools before reading both files. ` +
|
|
71
|
-
`Read
|
|
64
|
+
`Read ticket {ticket_uuid} as the loaded skill says. ` +
|
|
72
65
|
`Follow the loaded skill for tool discovery, transport and fallback, ` +
|
|
73
66
|
`and execute only that skill's {state} section. ` +
|
|
74
67
|
`Do not start or prepare a later state. ` +
|
|
@@ -671,7 +664,7 @@ export function listConductorConfigFiles(bakersDir) {
|
|
|
671
664
|
/**
|
|
672
665
|
* Remove the obsolete `states:` array property from a conductor-config JS
|
|
673
666
|
* source (BB-207 made `states` optional — empty ⇒ serve all claimable
|
|
674
|
-
* states — so `@bakers-build/bb-
|
|
667
|
+
* states — so `@bakers-build/bb-init-project` drops the now-dead key). Pure string
|
|
675
668
|
* transform: it strips the `states: [ ... ]` property (line form or inline in
|
|
676
669
|
* an object literal) with its trailing comma, and rewrites nothing else. A
|
|
677
670
|
* `substates:`/other key containing "states" is not matched.
|
|
@@ -1168,6 +1168,10 @@ export class Conductor {
|
|
|
1168
1168
|
const core = {
|
|
1169
1169
|
BAKERS_URL: this.config.site.base_url,
|
|
1170
1170
|
BAKERS_ID: t.uuid,
|
|
1171
|
+
// The agent finds its own conductor in bakers_user_read by this id.
|
|
1172
|
+
...(this.config.conductor_id
|
|
1173
|
+
? { BAKERS_CONDUCTOR_ID: this.config.conductor_id }
|
|
1174
|
+
: {}),
|
|
1171
1175
|
// BB-569: lets a launch wrapper key off the ticket and the run's
|
|
1172
1176
|
// start state without parsing the prompt (addon-claude `measure`).
|
|
1173
1177
|
...(t.identifier ? { BAKERS_TICKET_IDENTIFIER: t.identifier } : {}),
|
|
@@ -1495,6 +1499,10 @@ export class Conductor {
|
|
|
1495
1499
|
: {}),
|
|
1496
1500
|
...(chosen.agent.modelApi ? { modelApi: chosen.agent.modelApi } : {}),
|
|
1497
1501
|
};
|
|
1502
|
+
const isolates = this.config.runtime?.isolates === true;
|
|
1503
|
+
// Without it the run starts in an empty private home and cannot sign in.
|
|
1504
|
+
if (isolates && !chosen.agent.prepareRun)
|
|
1505
|
+
throw new Error(`agent ${chosen.alias ?? chosen.id}: the runtime isolates runs, but the agent has no prepareRun to prepare its login and configuration`);
|
|
1498
1506
|
const runtimeContext = await runtime.prepareRun?.({
|
|
1499
1507
|
uuid: run.runUuid,
|
|
1500
1508
|
id: run.runId,
|
|
@@ -1510,7 +1518,6 @@ export class Conductor {
|
|
|
1510
1518
|
: undefined;
|
|
1511
1519
|
if (preparation)
|
|
1512
1520
|
Object.assign(env, preparation.env);
|
|
1513
|
-
const isolates = this.config.runtime?.isolates === true;
|
|
1514
1521
|
// An isolated run without its own clone would share the parent's Git data.
|
|
1515
1522
|
if (isolates && !ws.clone)
|
|
1516
1523
|
throw new Error('the runtime isolates runs, but the workspace provides no run clone');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/conductor",
|
|
3
|
-
"version": "0.10.1-next.
|
|
3
|
+
"version": "0.10.1-next.11",
|
|
4
4
|
"description": "bakers.build conductor engine + CLI: registers, claims tickets via JSON:API, dispatches agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@dropsh/plugin-jsonapi-schema": "^0.8.2",
|
|
34
34
|
"@dropsh/plugin-oauth2": "^0.8.2",
|
|
35
|
-
"@bakers-build/core": "^0.10.1-next.
|
|
36
|
-
"@bakers-build/message": "^0.10.1-next.
|
|
35
|
+
"@bakers-build/core": "^0.10.1-next.11",
|
|
36
|
+
"@bakers-build/message": "^0.10.1-next.11",
|
|
37
37
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
38
38
|
"commander": "^12.1.0",
|
|
39
39
|
"dropsh": "^0.8.2"
|
|
40
40
|
},
|
|
41
41
|
"bakersBuild": {
|
|
42
|
-
"commit": "
|
|
42
|
+
"commit": "a17110983f32ae027848c103b31ddb07fbf21a8e",
|
|
43
43
|
"channel": "next"
|
|
44
44
|
}
|
|
45
45
|
}
|