@bakers-build/conductor 0.10.1-next.10 → 0.10.1-next.12
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.
|
@@ -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, readCliVersion, readMachineContext, resolveCliVersion, resolveConfigPath, setDefaultCommandRunner, signalVerifiedProcess, stemForConfigFile, UNKNOWN_VERSION, updateNotice, verifyConductorProcess, } from '@bakers-build/core';
|
|
5
|
+
import { CommandRunner, checkForUpdate, configHomeOf, createBbConnectionClient, createLogger, declineUpdate, defaultProcProbe, deriveCheckoutRoot, deriveConductorLiveness, homeBbDir, loadReadyBbConnection, loadSecretsFile, 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';
|
|
@@ -161,6 +161,24 @@ function logOptsOf(cmd) {
|
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
/** Create the conductor logger (with CLI log overrides) and route all exec logging through it. */
|
|
164
|
+
/**
|
|
165
|
+
* `~/.bakers/.bakers.env`, or undefined after printing why it was refused and
|
|
166
|
+
* setting exit 1. The log names the loaded keys, never their values.
|
|
167
|
+
*/
|
|
168
|
+
function loadSecretsOrFail(logger) {
|
|
169
|
+
try {
|
|
170
|
+
const secrets = loadSecretsFile();
|
|
171
|
+
const names = Object.keys(secrets);
|
|
172
|
+
if (names.length)
|
|
173
|
+
logger?.info({ secrets: names }, `secrets file: ${names.join(', ')} set`);
|
|
174
|
+
return secrets;
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
178
|
+
process.exitCode = 1;
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
164
182
|
function loggerFor(checkoutRoot, log = {}) {
|
|
165
183
|
const logger = createLogger({ checkoutRoot, ...log });
|
|
166
184
|
setDefaultCommandRunner(new CommandRunner(logger));
|
|
@@ -256,13 +274,16 @@ async function cmdPoll(deps, log = {}) {
|
|
|
256
274
|
const config = await resolveConfig(deps, undefined, true);
|
|
257
275
|
const checkoutRoot = await checkoutRootOf(config);
|
|
258
276
|
const logger = loggerFor(checkoutRoot, log);
|
|
277
|
+
const secrets = loadSecretsOrFail(logger);
|
|
278
|
+
if (!secrets)
|
|
279
|
+
return;
|
|
259
280
|
if (!(await ensureAuthenticated(config, logger)))
|
|
260
281
|
return;
|
|
261
282
|
const remote = await resolveRemote(deps, config);
|
|
262
283
|
const executor = deps.executor ?? (await selectExecutor(config, logger));
|
|
263
284
|
const workspace = deps.workspace ?? (await selectWorkspace(config, logger));
|
|
264
285
|
const agents = deps.agents ?? (await selectAgents(config));
|
|
265
|
-
const conductor = new Conductor(config, remote, executor, workspace, agents, logger, checkoutRoot, frozenStateFileOf(config), undefined, readMachineContext);
|
|
286
|
+
const conductor = new Conductor(config, remote, executor, workspace, agents, logger, checkoutRoot, frozenStateFileOf(config), undefined, readMachineContext, secrets);
|
|
266
287
|
await conductor.start();
|
|
267
288
|
await conductor.tick();
|
|
268
289
|
}
|
|
@@ -373,6 +394,10 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
373
394
|
const config = await resolveConfig(deps, undefined, true);
|
|
374
395
|
const checkoutRoot = await checkoutRootOf(config);
|
|
375
396
|
const logger = loggerFor(checkoutRoot, log);
|
|
397
|
+
// Every start path ends here: detached child, self-restart and update re-exec.
|
|
398
|
+
const secrets = loadSecretsOrFail(logger);
|
|
399
|
+
if (!secrets)
|
|
400
|
+
return;
|
|
376
401
|
if (!(await ensureAuthenticated(config, logger)))
|
|
377
402
|
return;
|
|
378
403
|
const remote = await resolveRemote(deps, config);
|
|
@@ -390,7 +415,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
390
415
|
const executor = deps.executor ?? (await selectExecutor(config, logger));
|
|
391
416
|
const workspace = deps.workspace ?? (await selectWorkspace(config, logger));
|
|
392
417
|
const agents = deps.agents ?? (await selectAgents(config));
|
|
393
|
-
const conductor = new Conductor(config, remote, executor, workspace, agents, logger, checkoutRoot, frozenStateFileOf(config), undefined, readMachineContext);
|
|
418
|
+
const conductor = new Conductor(config, remote, executor, workspace, agents, logger, checkoutRoot, frozenStateFileOf(config), undefined, readMachineContext, secrets);
|
|
394
419
|
// This process IS the conductor, so it may report its own pid and config
|
|
395
420
|
// name — the two values a cockpit needs to stop it later. poll/reap build a
|
|
396
421
|
// Conductor too but never claim, so they cannot overwrite this pid.
|
|
@@ -617,6 +642,9 @@ async function settleTakeover(deps, remote, registration, choice) {
|
|
|
617
642
|
}
|
|
618
643
|
async function cmdStart(deps, log = {}, updateCheck = true, body = cmdStartBody, force = false, foreground = false) {
|
|
619
644
|
const current = printVersionLine();
|
|
645
|
+
// The detached child loads it again; checking here shows a refusal in this shell.
|
|
646
|
+
if (!foreground && !loadSecretsOrFail())
|
|
647
|
+
return;
|
|
620
648
|
if (updateCheck) {
|
|
621
649
|
const options = {
|
|
622
650
|
fetchImpl: deps.fetch ?? globalThis.fetch,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ConductorLogger, type MachineContext } from '@bakers-build/core';
|
|
1
|
+
import { type ConductorLogger, type MachineContext, type Secrets } from '@bakers-build/core';
|
|
2
2
|
import { type RunEnvPolicy } from '../plugins/agent.js';
|
|
3
3
|
import type { BbExecutor } from '../plugins/executor.js';
|
|
4
4
|
import { type ResolvedAgent } from '../plugins/plugins.js';
|
|
@@ -38,6 +38,8 @@ export declare class Conductor {
|
|
|
38
38
|
private readonly runHook;
|
|
39
39
|
/** Re-reads machine.config.js per run; absent, `config.tunnel` stays. */
|
|
40
40
|
private readonly readMachine?;
|
|
41
|
+
/** `~/.bakers/.bakers.env`, loaded at start; runs get declared names only. */
|
|
42
|
+
private readonly secrets;
|
|
41
43
|
private uuid;
|
|
42
44
|
/**
|
|
43
45
|
* Frozen tickets seen on the last poll, by uuid, with the worktree their
|
|
@@ -60,7 +62,9 @@ export declare class Conductor {
|
|
|
60
62
|
private tunnel;
|
|
61
63
|
constructor(config: ConductorFileConfig, remote: BbRemote, executor: BbExecutor, workspace: BbWorkspace, agents: ResolvedAgent[], logger: ConductorLogger, checkoutRoot?: string, frozenStateFile?: string | undefined, runHook?: HookRunner,
|
|
62
64
|
/** Re-reads machine.config.js per run; absent, `config.tunnel` stays. */
|
|
63
|
-
readMachine?: (() => Promise<Partial<MachineContext>>) | undefined
|
|
65
|
+
readMachine?: (() => Promise<Partial<MachineContext>>) | undefined,
|
|
66
|
+
/** `~/.bakers/.bakers.env`, loaded at start; runs get declared names only. */
|
|
67
|
+
secrets?: Secrets);
|
|
64
68
|
private serialGit;
|
|
65
69
|
/**
|
|
66
70
|
* `conductor_id` is derived by the loader from the machine UUID, project and
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { basename, dirname, join } from 'node:path';
|
|
3
|
-
import { killRunProcesses, loadRunClone, protectedProjectPaths, saveRunClone, shellQuote, stemForConfigFile, transferIsolatedCommit, } from '@bakers-build/core';
|
|
3
|
+
import { killRunProcesses, loadRunClone, pickSecrets, protectedProjectPaths, saveRunClone, shellQuote, stemForConfigFile, transferIsolatedCommit, } from '@bakers-build/core';
|
|
4
4
|
import { CONDUCTOR_TOKEN_ENV, CONDUCTOR_URL_ENV, DEFAULT_ENV_DENY, matchesEnvDeny, } from '../plugins/agent.js';
|
|
5
5
|
import { homeKey, homePath } from '../plugins/agent-home.js';
|
|
6
6
|
import { resolveAgent } from '../plugins/plugins.js';
|
|
@@ -197,6 +197,7 @@ export class Conductor {
|
|
|
197
197
|
frozenStateFile;
|
|
198
198
|
runHook;
|
|
199
199
|
readMachine;
|
|
200
|
+
secrets;
|
|
200
201
|
uuid = null;
|
|
201
202
|
/**
|
|
202
203
|
* Frozen tickets seen on the last poll, by uuid, with the worktree their
|
|
@@ -219,7 +220,9 @@ export class Conductor {
|
|
|
219
220
|
tunnel;
|
|
220
221
|
constructor(config, remote, executor, workspace, agents, logger, checkoutRoot = process.cwd(), frozenStateFile, runHook = shellHookRunner(config.hooks, logger),
|
|
221
222
|
/** Re-reads machine.config.js per run; absent, `config.tunnel` stays. */
|
|
222
|
-
readMachine
|
|
223
|
+
readMachine,
|
|
224
|
+
/** `~/.bakers/.bakers.env`, loaded at start; runs get declared names only. */
|
|
225
|
+
secrets = {}) {
|
|
223
226
|
this.config = config;
|
|
224
227
|
this.remote = remote;
|
|
225
228
|
this.executor = executor;
|
|
@@ -230,6 +233,7 @@ export class Conductor {
|
|
|
230
233
|
this.frozenStateFile = frozenStateFile;
|
|
231
234
|
this.runHook = runHook;
|
|
232
235
|
this.readMachine = readMachine;
|
|
236
|
+
this.secrets = secrets;
|
|
233
237
|
this.tunnel = config.tunnel === true;
|
|
234
238
|
this.inboxAddons = new InboxRuntime(config.inboxAddons ?? [], remote, logger, (ticket) => this.runEnv(ticket, undefined, ticket.state), config.tools);
|
|
235
239
|
this.queue = new ActionQueue(logger);
|
|
@@ -1493,11 +1497,14 @@ export class Conductor {
|
|
|
1493
1497
|
: undefined;
|
|
1494
1498
|
const plugins = await this.installPlugins(chosen, t, run);
|
|
1495
1499
|
Object.assign(env, plugins.env);
|
|
1500
|
+
// Only the names the agent declares; a value exported in the shell wins.
|
|
1501
|
+
const secrets = pickSecrets(chosen.agent.secretEnv ?? [], this.secrets);
|
|
1496
1502
|
const agentInfo = {
|
|
1497
1503
|
...(chosen.agent.installCommand
|
|
1498
1504
|
? { installCommand: chosen.agent.installCommand }
|
|
1499
1505
|
: {}),
|
|
1500
1506
|
...(chosen.agent.modelApi ? { modelApi: chosen.agent.modelApi } : {}),
|
|
1507
|
+
secrets,
|
|
1501
1508
|
};
|
|
1502
1509
|
const isolates = this.config.runtime?.isolates === true;
|
|
1503
1510
|
// Without it the run starts in an empty private home and cannot sign in.
|
|
@@ -1514,10 +1521,16 @@ export class Conductor {
|
|
|
1514
1521
|
...runtimeContext,
|
|
1515
1522
|
workspacePath: ws.path,
|
|
1516
1523
|
env,
|
|
1524
|
+
secrets,
|
|
1517
1525
|
})
|
|
1518
1526
|
: undefined;
|
|
1519
1527
|
if (preparation)
|
|
1520
1528
|
Object.assign(env, preparation.env);
|
|
1529
|
+
// A host run inherits the shell's values; it lacks only the file's.
|
|
1530
|
+
if (!runtimeContext)
|
|
1531
|
+
for (const [name, value] of Object.entries(secrets))
|
|
1532
|
+
if (!process.env[name])
|
|
1533
|
+
env[name] = value;
|
|
1521
1534
|
// An isolated run without its own clone would share the parent's Git data.
|
|
1522
1535
|
if (isolates && !ws.clone)
|
|
1523
1536
|
throw new Error('the runtime isolates runs, but the workspace provides no run clone');
|
|
@@ -112,6 +112,8 @@ export interface AgentRunContext {
|
|
|
112
112
|
homePath: string;
|
|
113
113
|
workspacePath: string;
|
|
114
114
|
env: Readonly<Record<string, string>>;
|
|
115
|
+
/** The agent's declared `secretEnv` values the conductor hands this run. */
|
|
116
|
+
secrets?: Readonly<Record<string, string>>;
|
|
115
117
|
}
|
|
116
118
|
/** Files and environment an agent needs, independent of its execution backend. */
|
|
117
119
|
export interface AgentRunPreparation {
|
|
@@ -141,6 +143,13 @@ export interface AgentModelApi {
|
|
|
141
143
|
export interface AgentRuntimeInfo {
|
|
142
144
|
readonly installCommand?: string;
|
|
143
145
|
readonly modelApi?: AgentModelApi;
|
|
146
|
+
/**
|
|
147
|
+
* Env names this agent's runs may receive from `~/.bakers/.bakers.env` or
|
|
148
|
+
* the conductor's shell; no other secrets-file value reaches a run.
|
|
149
|
+
*/
|
|
150
|
+
readonly secretEnv?: readonly string[];
|
|
151
|
+
/** The declared values the conductor hands this run; never logged. */
|
|
152
|
+
readonly secrets?: Readonly<Record<string, string>>;
|
|
144
153
|
}
|
|
145
154
|
export interface BbAgent extends AgentRuntimeInfo {
|
|
146
155
|
/** Stable id, e.g. 'claude'. */
|
|
@@ -43,6 +43,8 @@ export interface AgentPlugin extends DropSHPlugin {
|
|
|
43
43
|
readonly requiredModules: string[];
|
|
44
44
|
/** The effective run permissions and their source layers (`bakers agents`). */
|
|
45
45
|
readonly permissions?: SecurityReport;
|
|
46
|
+
/** The secrets-file names its runs may receive (`bakers agents`). */
|
|
47
|
+
readonly secretEnv?: readonly string[];
|
|
46
48
|
createAgent(config: ConductorFileConfig): Promise<BbAgent>;
|
|
47
49
|
}
|
|
48
50
|
/** Resolves the remote from its named config slot. */
|
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.12",
|
|
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.12",
|
|
36
|
+
"@bakers-build/message": "^0.10.1-next.12",
|
|
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": "460f5570442a0b09af52a1d4450b879075302e57",
|
|
43
43
|
"channel": "next"
|
|
44
44
|
}
|
|
45
45
|
}
|