@bakers-build/conductor 0.8.0 → 0.8.1-next.10

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.
Files changed (35) hide show
  1. package/dist/src/cli/config-plan.js +14 -29
  2. package/dist/src/cli/config-schema.d.ts +4 -4
  3. package/dist/src/cli/config-schema.js +5 -5
  4. package/dist/src/cli/config-templates.js +18 -24
  5. package/dist/src/cli/config-validation.d.ts +1 -1
  6. package/dist/src/cli/config-validation.js +27 -131
  7. package/dist/src/cli/project-context.d.ts +5 -8
  8. package/dist/src/cli/project-context.js +25 -68
  9. package/dist/src/commands/conductor.d.ts +2 -2
  10. package/dist/src/commands/conductor.js +24 -24
  11. package/dist/src/commands/oven-tools.js +1 -1
  12. package/dist/src/config.d.ts +16 -17
  13. package/dist/src/config.js +70 -136
  14. package/dist/src/contract.d.ts +2 -2
  15. package/dist/src/contract.js +1 -1
  16. package/dist/src/core/conductor.d.ts +3 -3
  17. package/dist/src/core/conductor.js +67 -35
  18. package/dist/src/core/mr-changes.js +3 -1
  19. package/dist/src/core/start-hooks.d.ts +3 -0
  20. package/dist/src/core/start-hooks.js +58 -0
  21. package/dist/src/core/tool-server.d.ts +1 -1
  22. package/dist/src/plugins/agent.d.ts +10 -3
  23. package/dist/src/plugins/agent.js +11 -3
  24. package/dist/src/plugins/executor.d.ts +12 -1
  25. package/dist/src/plugins/plugins.d.ts +2 -2
  26. package/dist/src/plugins/preset.d.ts +5 -5
  27. package/dist/src/plugins/remote.d.ts +9 -6
  28. package/dist/src/plugins/tools.d.ts +1 -0
  29. package/dist/src/plugins/tools.js +3 -3
  30. package/dist/src/plugins/workspace.d.ts +1 -1
  31. package/dist/src/preset.js +3 -2
  32. package/dist/src/types.d.ts +5 -4
  33. package/package.json +5 -5
  34. package/dist/src/core/required-skills.d.ts +0 -7
  35. package/dist/src/core/required-skills.js +0 -157
@@ -1,8 +1,8 @@
1
1
  export { AmbiguousProjectNameError, type ResolvedBbProjectContext, resolveBbProjectContext, } from './bakers-project-context.js';
2
- export { type AgentFootprint, type AgentRunIdentity, type BbAgent, CONDUCTOR_TOKEN_ENV, CONDUCTOR_TOOLS_SERVER, CONDUCTOR_URL_ENV, DEFAULT_ENV_DENY, emptyAgentFootprint, matchesEnvDeny, type PluginLaunch, type RunEnvPolicy, } from './plugins/agent.js';
2
+ export { type AgentFootprint, type AgentRunIdentity, type BbAgent, CONDUCTOR_TOKEN_ENV, CONDUCTOR_TOOL_TIMEOUT_MS, CONDUCTOR_TOOLS_SERVER, CONDUCTOR_URL_ENV, DEFAULT_ENV_DENY, emptyAgentFootprint, matchesEnvDeny, type PluginLaunch, type RunEnvPolicy, } from './plugins/agent.js';
3
3
  export { detectKnownOverrides, type KnownOptionSpec, type KnownOverrides, type KnownScalarKind, type ResolvedSecurity, resolveAgentCliOptions, resolveSecurityOptions, type SandboxOptions, SECURITY_MODES, type SecurityMode, type SecurityOptions, type SecurityReport, SHARED_SECURITY_KEY, type SharedListKey, type SharedSecurity, validateAgentArgs, validateOptionalBoolean, validateOptionalString, validateSharedSecurity, } from './plugins/agent-args.js';
4
4
  export { ensureHome, homeKey, homePath, type MarketplaceDeclaration, validateMarketplaces, } from './plugins/agent-home.js';
5
- export type { BbExecutor, ExecutorCapabilities, HookContext, HookListener, HookListenerContext, HookListenerFn, HookName, HookResult, OpenWorkspaceContext, SpawnedSession, SpawnRunInput, WorktreeTeardown, } from './plugins/executor.js';
5
+ export type { BbExecutor, ConductorStartContext, ExecutorCapabilities, HookContext, HookListener, HookListenerContext, HookListenerFn, HookName, HookResult, MachineRegistrationData, OpenWorkspaceContext, SpawnedSession, SpawnRunInput, WorktreeTeardown, } from './plugins/executor.js';
6
6
  export type { DiscoveredInbox, InboxBinding, InboxMessageHandler, InboxMessageRequest, InboxMessages, LoadedInbox, } from './plugins/message.js';
7
7
  export { loadInbox, validateRequestPayload, } from './plugins/message.js';
8
8
  export type { AgentCandidate, AgentPlugin, ExecutorDeps, ExecutorPlugin, RemotePlugin, ResolvedAgent, WorkspacePlugin, } from './plugins/plugins.js';
@@ -12,7 +12,7 @@
12
12
  // The package main re-exports everything here too, so `import type { BbRemote }
13
13
  // from '@bakers-build/conductor'` keeps working for type-only consumers.
14
14
  export { AmbiguousProjectNameError, resolveBbProjectContext, } from './bakers-project-context.js';
15
- export { CONDUCTOR_TOKEN_ENV, CONDUCTOR_TOOLS_SERVER, CONDUCTOR_URL_ENV, DEFAULT_ENV_DENY, emptyAgentFootprint, matchesEnvDeny, } from './plugins/agent.js';
15
+ export { CONDUCTOR_TOKEN_ENV, CONDUCTOR_TOOL_TIMEOUT_MS, CONDUCTOR_TOOLS_SERVER, CONDUCTOR_URL_ENV, DEFAULT_ENV_DENY, emptyAgentFootprint, matchesEnvDeny, } from './plugins/agent.js';
16
16
  export { detectKnownOverrides, resolveAgentCliOptions, resolveSecurityOptions, SECURITY_MODES, SHARED_SECURITY_KEY, validateAgentArgs, validateOptionalBoolean, validateOptionalString, validateSharedSecurity, } from './plugins/agent-args.js';
17
17
  export { ensureHome, homeKey, homePath, validateMarketplaces, } from './plugins/agent-home.js';
18
18
  export { loadInbox, validateRequestPayload, } from './plugins/message.js';
@@ -80,7 +80,7 @@ export declare class Conductor {
80
80
  *
81
81
  * Only `cmdStartForeground` calls this. `cmdPoll` and `cmdReap` also build a
82
82
  * Conductor and call start() + tick(), then exit; if they reported a pid,
83
- * every `bakers oven once` would overwrite the running conductor's pid
83
+ * every `bakers conductor once` would overwrite the running conductor's pid
84
84
  * with its own short-lived one and the next stop would signal a dead — or
85
85
  * recycled — process. Making the report opt-in means those two commands
86
86
  * cannot do so even by accident.
@@ -102,7 +102,7 @@ export declare class Conductor {
102
102
  /** Never throws: a failed state write leaves the grant on disk, and the next start prunes it. */
103
103
  private revokeRunTools;
104
104
  start(): Promise<void>;
105
- /** One tick that also waits for its actions: `bakers oven once`, tests. */
105
+ /** One tick that also waits for its actions: `bakers conductor once`, tests. */
106
106
  tick(): Promise<void>;
107
107
  /** A failing list query must not stop the other steps or the claims. */
108
108
  private step;
@@ -175,7 +175,7 @@ export declare class Conductor {
175
175
  * whose workspace still lingers (BB-89). Driven by the durable `cleaned_up`
176
176
  * flag via {@link BbRemote.fetchUncleanedTickets}: every ticket the server
177
177
  * has already closed but not yet cleaned. The SAME reconciliation runs on
178
- * every tick AND standalone as `bakers oven clean`, and the query is
178
+ * every tick AND standalone as `bakers conductor clean`, and the query is
179
179
  * scoped to THIS conductor (BB-121) — so it catches the orphans a
180
180
  * live-tick-only path structurally cannot (the conductor was down when the
181
181
  * ticket closed, or crashed mid-cleanup) for its OWN tickets. A foreign
@@ -11,7 +11,7 @@ import { attemptFamily } from './attempt.js';
11
11
  import { shellHookRunner } from './hook-runner.js';
12
12
  import { InboxRuntime, runInbox } from './inbox-runtime.js';
13
13
  import { measureMrChanges, mrChangesRows } from './mr-changes.js';
14
- import { checkRequiredSkills } from './required-skills.js';
14
+ import { runStartHooks } from './start-hooks.js';
15
15
  import { startToolServer } from './tool-server.js';
16
16
  import { signalUi } from './ui-signal.js';
17
17
  function sleep(ms, signal) {
@@ -33,11 +33,15 @@ function sleep(ms, signal) {
33
33
  }
34
34
  /**
35
35
  * A run-env key is reserved when it names a conductor-provided core variable:
36
- * any `BB_*`, `WORKSPACE_ROOT`, or `TICKET_URL`. User `env_vars` may not
37
- * clobber these — the core vars always win (BB-99).
36
+ * any `BAKERS_*`, `WORKSPACE_ROOT`, or `TICKET_URL`. User `env_vars` may not
37
+ * clobber these — the core vars always win (BB-99). `BB_*` stays reserved: a
38
+ * retired name in the run env would make the agent's `bakers` refuse to start.
38
39
  */
39
40
  function isReservedEnvKey(key) {
40
- return (key.startsWith('BB_') || key === 'WORKSPACE_ROOT' || key === 'TICKET_URL');
41
+ return (key.startsWith('BAKERS_') ||
42
+ key.startsWith('BB_') ||
43
+ key === 'WORKSPACE_ROOT' ||
44
+ key === 'TICKET_URL');
41
45
  }
42
46
  /** A portable environment variable name. */
43
47
  const ENV_KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;
@@ -157,8 +161,8 @@ function renderPrompt(template, values) {
157
161
  return template
158
162
  .replaceAll('{identifier}', values.identifier)
159
163
  .replaceAll('{state}', values.state)
160
- .replaceAll('{runUuid}', values.runUuid)
161
- .replaceAll('{ticketUuid}', values.ticketUuid);
164
+ .replaceAll('{run_uuid}', values.runUuid)
165
+ .replaceAll('{ticket_uuid}', values.ticketUuid);
162
166
  }
163
167
  /**
164
168
  * A conductor's registration payload, built from its config: what the engine
@@ -260,7 +264,7 @@ export class Conductor {
260
264
  *
261
265
  * Only `cmdStartForeground` calls this. `cmdPoll` and `cmdReap` also build a
262
266
  * Conductor and call start() + tick(), then exit; if they reported a pid,
263
- * every `bakers oven once` would overwrite the running conductor's pid
267
+ * every `bakers conductor once` would overwrite the running conductor's pid
264
268
  * with its own short-lived one and the next stop would signal a dead — or
265
269
  * recycled — process. Making the report opt-in means those two commands
266
270
  * cannot do so even by accident.
@@ -334,7 +338,44 @@ export class Conductor {
334
338
  }
335
339
  }
336
340
  async start() {
337
- this.uuid = await this.remote.registerConductor(this.registration());
341
+ const registration = this.registration();
342
+ const machine = this.ownsServeProcess
343
+ ? await runStartHooks(this.config.hookListeners ?? [], {
344
+ ...(registration.host_key !== undefined
345
+ ? { host_key: registration.host_key }
346
+ : {}),
347
+ ...(registration.machine_label !== undefined
348
+ ? { machine_label: registration.machine_label }
349
+ : {}),
350
+ ...(this.config.connection_url !== undefined
351
+ ? { connection_url: this.config.connection_url }
352
+ : {}),
353
+ }, {
354
+ id: registration.id,
355
+ project: registration.project,
356
+ variant: registration.conductor_name ?? this.config.variant,
357
+ }, (reason) => this.logger.warn({ conductorId: this.id }, reason))
358
+ : {};
359
+ try {
360
+ this.uuid = await this.remote.registerConductor({
361
+ ...registration,
362
+ ...machine,
363
+ });
364
+ }
365
+ catch (err) {
366
+ if (typeof machine.connection_url !== 'string')
367
+ throw err;
368
+ // A server that refuses the address must not stop the start; without
369
+ // the field the stored address stays unchanged.
370
+ // Value-free: the error may quote the address.
371
+ this.logger.warn({ conductorId: this.id }, 'registration failed with the connection URL; retrying without it');
372
+ const rest = { ...machine };
373
+ delete rest.connection_url;
374
+ this.uuid = await this.remote.registerConductor({
375
+ ...registration,
376
+ ...rest,
377
+ });
378
+ }
338
379
  this.logger.info({ conductorId: this.id, uuid: this.uuid, project: this.config.project }, 'conductor started');
339
380
  try {
340
381
  await this.inboxAddons.register(this.id);
@@ -349,7 +390,7 @@ export class Conductor {
349
390
  this.logger.error({ conductorId: this.id }, line);
350
391
  }
351
392
  }
352
- /** One tick that also waits for its actions: `bakers oven once`, tests. */
393
+ /** One tick that also waits for its actions: `bakers conductor once`, tests. */
353
394
  async tick() {
354
395
  await this.produce();
355
396
  await this.queue.drain();
@@ -837,7 +878,7 @@ export class Conductor {
837
878
  * whose workspace still lingers (BB-89). Driven by the durable `cleaned_up`
838
879
  * flag via {@link BbRemote.fetchUncleanedTickets}: every ticket the server
839
880
  * has already closed but not yet cleaned. The SAME reconciliation runs on
840
- * every tick AND standalone as `bakers oven clean`, and the query is
881
+ * every tick AND standalone as `bakers conductor clean`, and the query is
841
882
  * scoped to THIS conductor (BB-121) — so it catches the orphans a
842
883
  * live-tick-only path structurally cannot (the conductor was down when the
843
884
  * ticket closed, or crashed mid-cleanup) for its OWN tickets. A foreign
@@ -1071,24 +1112,24 @@ export class Conductor {
1071
1112
  workspaceIds = ids.join(',');
1072
1113
  }
1073
1114
  catch (err) {
1074
- this.logger.warn({ ticket: t.identifier, err: String(err) }, 'could not resolve reachable workspaces for BB_WORKSPACE_IDS');
1115
+ this.logger.warn({ ticket: t.identifier, err: String(err) }, 'could not resolve reachable workspaces for BAKERS_WORKSPACE_IDS');
1075
1116
  }
1076
1117
  const core = {
1077
- BB_URL: this.config.site.base_url,
1078
- BB_ID: t.uuid,
1118
+ BAKERS_URL: this.config.site.base_url,
1119
+ BAKERS_ID: t.uuid,
1079
1120
  // BB-569: lets a launch wrapper key off the ticket and the run's
1080
1121
  // start state without parsing the prompt (addon-claude `measure`).
1081
- ...(t.identifier ? { BB_TICKET_IDENTIFIER: t.identifier } : {}),
1082
- ...(state ? { BB_STATE: state } : {}),
1083
- ...(runUuid ? { BB_RUN_UUID: runUuid } : {}),
1084
- BB_TUNNEL: (await this.currentTunnel()) ? '1' : '0',
1122
+ ...(t.identifier ? { BAKERS_TICKET_IDENTIFIER: t.identifier } : {}),
1123
+ ...(state ? { BAKERS_STATE: state } : {}),
1124
+ ...(runUuid ? { BAKERS_RUN_UUID: runUuid } : {}),
1125
+ BAKERS_TUNNEL: (await this.currentTunnel()) ? '1' : '0',
1085
1126
  WORKSPACE_ROOT: this.checkoutRoot,
1086
1127
  ...(t.issueUrl ? { TICKET_URL: t.issueUrl } : {}),
1087
- ...(t.projectName ? { BB_PROJECT: t.projectName } : {}),
1088
- ...(t.projectId ? { BB_PROJECT_ID: t.projectId } : {}),
1089
- ...(t.workspaceName ? { BB_WORKSPACE: t.workspaceName } : {}),
1090
- ...(t.workspaceId ? { BB_WORKSPACE_ID: t.workspaceId } : {}),
1091
- ...(workspaceIds ? { BB_WORKSPACE_IDS: workspaceIds } : {}),
1128
+ ...(t.projectName ? { BAKERS_PROJECT: t.projectName } : {}),
1129
+ ...(t.projectId ? { BAKERS_PROJECT_ID: t.projectId } : {}),
1130
+ ...(t.workspaceName ? { BAKERS_WORKSPACE: t.workspaceName } : {}),
1131
+ ...(t.workspaceId ? { BAKERS_WORKSPACE_ID: t.workspaceId } : {}),
1132
+ ...(workspaceIds ? { BAKERS_WORKSPACE_IDS: workspaceIds } : {}),
1092
1133
  };
1093
1134
  return resolveRunEnv(t.effectiveEnvVars, core, this.logger, {
1094
1135
  ticket: t.identifier,
@@ -1148,7 +1189,7 @@ export class Conductor {
1148
1189
  * Install the project's `marketplaces` into the run's agent home and log
1149
1190
  * one `plugins` entry. A failed install throws, failing the run start.
1150
1191
  */
1151
- async installPlugins(chosen, t, run, worktree) {
1192
+ async installPlugins(chosen, t, run) {
1152
1193
  const marketplaces = this.config.marketplaces ?? [];
1153
1194
  const harness = chosen.agent.id;
1154
1195
  const entry = {
@@ -1166,8 +1207,6 @@ export class Conductor {
1166
1207
  : undefined;
1167
1208
  if (off || !chosen.agent.installPlugins) {
1168
1209
  entry.state = `off (${off})`;
1169
- // Without the agent home, which skills the run gets is the user's own setup.
1170
- entry.required_skills = 'skipped (plugins off)';
1171
1210
  log();
1172
1211
  return { env: {}, args: [] };
1173
1212
  }
@@ -1190,13 +1229,6 @@ export class Conductor {
1190
1229
  log();
1191
1230
  throw new Error(`plugins: ${harness} install failed: ${entry.failure}`);
1192
1231
  }
1193
- const skills = checkRequiredSkills(worktree, home, t);
1194
- entry.required_skills = skills;
1195
- if (skills.missing.length > 0) {
1196
- entry.failure = `missing required skills: ${skills.missing.join(', ')}`;
1197
- log();
1198
- throw new Error(`plugins: ${harness}: ${entry.failure}`);
1199
- }
1200
1232
  log();
1201
1233
  return { env: launch.env, args: launch.args };
1202
1234
  }
@@ -1216,7 +1248,7 @@ export class Conductor {
1216
1248
  if (unavailable)
1217
1249
  throw new Error(unavailable);
1218
1250
  const baseRef = t.baseBranch ? `origin/${t.baseBranch}` : undefined;
1219
- // Resolve the run env once (per-ticket env_vars + core BB_* vars) and
1251
+ // Resolve the run env once (per-ticket env_vars + core BAKERS_* vars) and
1220
1252
  // inject it into BOTH the lifecycle hooks AND the agent run
1221
1253
  // env (BB-99). Reserved core keys always win; values may be sensitive so
1222
1254
  // only key names are ever logged.
@@ -1381,7 +1413,7 @@ export class Conductor {
1381
1413
  const tools = chosen.agent.withoutConductorTools
1382
1414
  ? undefined
1383
1415
  : this.issueRunTools(run.runUuid, { worktreePath: ws.path, ticket: t });
1384
- const plugins = await this.installPlugins(chosen, t, run, ws.path);
1416
+ const plugins = await this.installPlugins(chosen, t, run);
1385
1417
  Object.assign(env, plugins.env);
1386
1418
  const command = chosen.agent.launchCommand(prompt, identity, ws.path, tools ? { url: tools.url } : undefined, env, plugins.args);
1387
1419
  // Read after launchCommand: a warning may depend on what this launch got.
@@ -1504,7 +1536,7 @@ export class Conductor {
1504
1536
  }
1505
1537
  await this.queue.drain();
1506
1538
  // NB: the poll loop never writes status=offline itself. A graceful stop
1507
- // (`bakers oven stop`) writes offline directly server-side; a crash or
1539
+ // (`bakers conductor stop`) writes offline directly server-side; a crash or
1508
1540
  // hard-kill leaves a stale lease that the Drupal cron reaper flips to
1509
1541
  // offline (bb_core cron → ConductorReaper). Liveness is thus always
1510
1542
  // derived from status + last_seen/lease_expires_at, never from the loop.
@@ -41,7 +41,9 @@ export function mrChangesRows(v, recorded) {
41
41
  * shows. `HEAD`, not the remote branch: a merge deletes the remote branch.
42
42
  */
43
43
  export async function measureMrChanges(worktreePath, baseBranch) {
44
- await exec('git', ['fetch', 'origin', baseBranch], { cwd: worktreePath });
44
+ await exec('git', ['fetch', 'origin', '--', baseBranch], {
45
+ cwd: worktreePath,
46
+ });
45
47
  const out = await exec('git', ['diff', '--numstat', '-M', `origin/${baseBranch}...HEAD`], { cwd: worktreePath });
46
48
  return parseNumstat(out);
47
49
  }
@@ -0,0 +1,3 @@
1
+ import type { ConductorStartContext, HookListener, MachineRegistrationData } from '../plugins/executor.js';
2
+ /** Dispatch atomically: failures retain the validated baseline, never partial data. */
3
+ export declare function runStartHooks(listeners: readonly HookListener[], machine: MachineRegistrationData, conductor: Readonly<ConductorStartContext>, warn: (reason: string) => void): Promise<MachineRegistrationData>;
@@ -0,0 +1,58 @@
1
+ import { isValidMachineConnectionUrl } from '@bakers-build/core';
2
+ /** Dispatch atomically: failures retain the validated baseline, never partial data. */
3
+ export async function runStartHooks(listeners, machine, conductor, warn) {
4
+ const baseline = { ...machine };
5
+ if (baseline.connection_url !== undefined &&
6
+ baseline.connection_url !== null &&
7
+ !isValidMachineConnectionUrl(baseline.connection_url)) {
8
+ delete baseline.connection_url;
9
+ warn('invalid manual connection URL; start hooks skipped');
10
+ return baseline;
11
+ }
12
+ const shared = { ...baseline };
13
+ const context = Object.freeze({ ...conductor });
14
+ let closed = false;
15
+ let timer;
16
+ const validate = () => {
17
+ if (Reflect.ownKeys(shared).some((key) => !['host_key', 'machine_label', 'connection_url'].includes(String(key))) ||
18
+ shared.host_key !== baseline.host_key ||
19
+ (shared.machine_label !== undefined &&
20
+ (typeof shared.machine_label !== 'string' ||
21
+ !shared.machine_label.trim() ||
22
+ shared.machine_label.length > 255)) ||
23
+ (shared.connection_url !== undefined &&
24
+ shared.connection_url !== null &&
25
+ !isValidMachineConnectionUrl(shared.connection_url)) ||
26
+ (baseline.connection_url !== undefined &&
27
+ shared.connection_url !== baseline.connection_url))
28
+ throw new Error('invalid start hook data');
29
+ };
30
+ try {
31
+ return await Promise.race([
32
+ (async () => {
33
+ for (const listener of listeners) {
34
+ await listener.before_conductor_start?.(shared, context);
35
+ if (closed)
36
+ return baseline;
37
+ validate();
38
+ }
39
+ validate();
40
+ return { ...shared };
41
+ })(),
42
+ new Promise((_, reject) => {
43
+ timer = setTimeout(() => {
44
+ closed = true;
45
+ reject(new Error('deadline'));
46
+ }, 5000);
47
+ }),
48
+ ]);
49
+ }
50
+ catch {
51
+ warn('start hooks discarded after failure, invalid data or timeout');
52
+ return baseline;
53
+ }
54
+ finally {
55
+ closed = true;
56
+ clearTimeout(timer);
57
+ }
58
+ }
@@ -18,7 +18,7 @@ export interface ToolServerEndpoint {
18
18
  }
19
19
  export interface ToolServerOptions {
20
20
  registry: ToolRegistry;
21
- /** `<BB_HOME>/conductors/<conductor_id>.json`; absent: no operator access. */
21
+ /** `<BAKERS_HOME>/conductors/<conductor_id>.json`; absent: no operator access. */
22
22
  endpointFile?: string;
23
23
  /** The operator may only name worktrees below this directory. */
24
24
  workspaceRoot?: string;
@@ -83,10 +83,17 @@ export interface AgentRunIdentity {
83
83
  }
84
84
  /** The MCP server name agents see for the conductor's addon tools. */
85
85
  export declare const CONDUCTOR_TOOLS_SERVER = "bakers";
86
+ /**
87
+ * The tool-call timeout a launch sets on that server, past the longest
88
+ * provision. Without it Claude Code's HTTP MCP client cuts a call at 60 s
89
+ * (per-server `timeout`, else `MCP_TOOL_TIMEOUT`) and Codex at
90
+ * `tool_timeout_sec` (60 s default).
91
+ */
92
+ export declare const CONDUCTOR_TOOL_TIMEOUT_MS: number;
86
93
  /** The run env var holding the run's bearer token for that server. */
87
- export declare const CONDUCTOR_TOKEN_ENV = "BB_CONDUCTOR_TOKEN";
88
- /** The run env var holding that server's URL, for `bakers oven tools`. */
89
- export declare const CONDUCTOR_URL_ENV = "BB_CONDUCTOR_URL";
94
+ export declare const CONDUCTOR_TOKEN_ENV = "BAKERS_CONDUCTOR_TOKEN";
95
+ /** The run env var holding that server's URL, for `bakers conductor tools`. */
96
+ export declare const CONDUCTOR_URL_ENV = "BAKERS_CONDUCTOR_URL";
90
97
  /** What {@link BbAgent.installPlugins} hands the run's launch. */
91
98
  export interface PluginLaunch {
92
99
  /** Merged into the run env: the harness's config-dir variable, never `HOME`. */
@@ -1,3 +1,4 @@
1
+ import { PROVISION_TIMEOUT_MS } from './tools.js';
1
2
  /** An all-zero footprint — the honest result for an empty/absent transcript. */
2
3
  export function emptyAgentFootprint() {
3
4
  return {
@@ -39,7 +40,14 @@ export function matchesEnvDeny(name, patterns) {
39
40
  }
40
41
  /** The MCP server name agents see for the conductor's addon tools. */
41
42
  export const CONDUCTOR_TOOLS_SERVER = 'bakers';
43
+ /**
44
+ * The tool-call timeout a launch sets on that server, past the longest
45
+ * provision. Without it Claude Code's HTTP MCP client cuts a call at 60 s
46
+ * (per-server `timeout`, else `MCP_TOOL_TIMEOUT`) and Codex at
47
+ * `tool_timeout_sec` (60 s default).
48
+ */
49
+ export const CONDUCTOR_TOOL_TIMEOUT_MS = PROVISION_TIMEOUT_MS + 60_000;
42
50
  /** The run env var holding the run's bearer token for that server. */
43
- export const CONDUCTOR_TOKEN_ENV = 'BB_CONDUCTOR_TOKEN';
44
- /** The run env var holding that server's URL, for `bakers oven tools`. */
45
- export const CONDUCTOR_URL_ENV = 'BB_CONDUCTOR_URL';
51
+ export const CONDUCTOR_TOKEN_ENV = 'BAKERS_CONDUCTOR_TOKEN';
52
+ /** The run env var holding that server's URL, for `bakers conductor tools`. */
53
+ export const CONDUCTOR_URL_ENV = 'BAKERS_CONDUCTOR_URL';
@@ -34,7 +34,7 @@ export type HookName = 'after_create' | 'before_run' | 'after_run' | 'after_done
34
34
  * What an addon hook listener receives (BB-599). One context object is
35
35
  * shared by every listener of one dispatch, so a key a `before_run` listener
36
36
  * adds to `env` reaches the next listener, that slot's shell hook and the
37
- * agent launch. Reserved keys (`BB_*`, `WORKSPACE_ROOT`, `TICKET_URL`) and
37
+ * agent launch. Reserved keys (`BAKERS_*`, `BB_*`, `WORKSPACE_ROOT`, `TICKET_URL`) and
38
38
  * invalid entries are restored after each listener. `env` values may be
39
39
  * secret: never log them.
40
40
  *
@@ -57,6 +57,16 @@ export interface HookListenerContext {
57
57
  }
58
58
  /** A listener's callback for one slot. Awaited; a failure is logged, never fatal. */
59
59
  export type HookListenerFn = (ctx: HookListenerContext) => void | Promise<void>;
60
+ export interface MachineRegistrationData {
61
+ host_key?: string;
62
+ machine_label?: string;
63
+ connection_url?: string | null;
64
+ }
65
+ export interface ConductorStartContext {
66
+ id: string;
67
+ project: string;
68
+ variant: string;
69
+ }
60
70
  /**
61
71
  * One addon contribution to the conductor `hooks` accumulator (BB-599): an
62
72
  * object with an optional function per lifecycle slot. Listeners run in
@@ -65,6 +75,7 @@ export type HookListenerFn = (ctx: HookListenerContext) => void | Promise<void>;
65
75
  export type HookListener = {
66
76
  [K in HookName]?: HookListenerFn;
67
77
  } & {
78
+ before_conductor_start?: (machine: MachineRegistrationData, conductor: Readonly<ConductorStartContext>) => void | Promise<void>;
68
79
  /** Names the listener in conductor logs. */
69
80
  id?: string;
70
81
  };
@@ -12,7 +12,7 @@ export interface ExecutorDeps {
12
12
  logger: ConductorLogger;
13
13
  }
14
14
  export interface RemotePlugin extends DropSHPlugin {
15
- readonly kind: 'remote';
15
+ readonly kind: 'server';
16
16
  readonly id: string;
17
17
  readonly requiredModules: string[];
18
18
  createRemote(config: ConductorFileConfig): Promise<BbRemote>;
@@ -24,7 +24,7 @@ export interface ExecutorPlugin extends DropSHPlugin {
24
24
  createExecutor(config: ConductorFileConfig, deps: ExecutorDeps): Promise<BbExecutor>;
25
25
  }
26
26
  export interface WorkspacePlugin extends DropSHPlugin {
27
- readonly kind: 'workspace';
27
+ readonly kind: 'worktree';
28
28
  readonly id: string;
29
29
  readonly requiredModules: string[];
30
30
  /**
@@ -11,9 +11,9 @@ import type { AddonTools, DiscoveredTools } from './tools.js';
11
11
  * the discovery call site (see {@link narrowConductorContributions}).
12
12
  */
13
13
  export interface ConductorContributions {
14
- remotes: RemotePlugin[];
14
+ servers: RemotePlugin[];
15
15
  executors: ExecutorPlugin[];
16
- workspaces: WorkspacePlugin[];
16
+ worktrees: WorkspacePlugin[];
17
17
  agents: AgentCandidate[];
18
18
  /** Lifecycle hook listeners, in accumulator order (BB-599). */
19
19
  hooks: HookListener[];
@@ -42,9 +42,9 @@ export type ConductorAddonEntry = string | (Exclude<AddonEntry, string> & {
42
42
  * silently drifting apart.
43
43
  */
44
44
  export interface Preset<O = unknown> extends BbPreset<O> {
45
- remotes?: (acc: RemotePlugin[], opts: O) => RemotePlugin[] | Promise<RemotePlugin[]>;
45
+ servers?: (acc: RemotePlugin[], opts: O) => RemotePlugin[] | Promise<RemotePlugin[]>;
46
46
  executors?: (acc: ExecutorPlugin[], opts: O) => ExecutorPlugin[] | Promise<ExecutorPlugin[]>;
47
- workspaces?: (acc: WorkspacePlugin[], opts: O) => WorkspacePlugin[] | Promise<WorkspacePlugin[]>;
47
+ worktrees?: (acc: WorkspacePlugin[], opts: O) => WorkspacePlugin[] | Promise<WorkspacePlugin[]>;
48
48
  agents?: (acc: AgentCandidate[], opts: O) => AgentCandidate[] | Promise<AgentCandidate[]>;
49
49
  hooks?: (acc: HookListener[], opts: O) => HookListener[] | Promise<HookListener[]>;
50
50
  /** Addon inbox messages: contract 2, BB-661. */
@@ -59,4 +59,4 @@ export interface Preset<O = unknown> extends BbPreset<O> {
59
59
  * {@link Preset}, and `resolveConductorSlots` still runs the runtime `.kind`
60
60
  * guard on whatever actually landed in a singleton slot.
61
61
  */
62
- export declare function narrowConductorContributions(discovered: Pick<DiscoveredContributions, 'remotes' | 'executors' | 'workspaces' | 'agents' | 'hooks' | 'addonInbox' | 'addonTools'>): ConductorContributions;
62
+ export declare function narrowConductorContributions(discovered: Pick<DiscoveredContributions, 'servers' | 'executors' | 'worktrees' | 'agents' | 'hooks' | 'addonInbox' | 'addonTools'>): ConductorContributions;
@@ -15,6 +15,7 @@ export interface ConductorRegistration {
15
15
  host_key?: string;
16
16
  /** This machine's display label; names a newly created bb_machine. */
17
17
  machine_label?: string;
18
+ connection_url?: string | null;
18
19
  project: string;
19
20
  /** Empty = serve all claimable states in the project (BB-207). */
20
21
  states: string[];
@@ -31,7 +32,7 @@ export interface ConductorRegistration {
31
32
  last_pid?: number;
32
33
  /**
33
34
  * The stem of the config file this conductor was started from (`conductor`
34
- * for the default, `shop` for `shop.conductor.config.js`) — what
35
+ * for the default, `shop` for `shop.project.config.js`) — what
35
36
  * `--conductor <name>` selects. Together with `workspace` it identifies one
36
37
  * conductor in a repo that holds several.
37
38
  */
@@ -72,10 +73,12 @@ export interface Ticket {
72
73
  branchName: string;
73
74
  /** Branch the ticket's work is based on (computed server-side): parent branch, project default, or 'main'. */
74
75
  baseBranch?: string;
76
+ /** Branch the ticket's work merges into (computed server-side): a deployment's environment branch, else baseBranch. */
77
+ targetBranch?: string;
75
78
  /**
76
79
  * Effective environment variables (BB-99), resolved server-side along the
77
80
  * parent_id chain (child wins) as canonical `.env`-style `KEY=value` lines.
78
- * The conductor parses this, strips reserved keys, overlays the core BB_*
81
+ * The conductor parses this, strips reserved keys, overlays the core BAKERS_*
79
82
  * vars, and injects the result into the agent run env AND the workspace hooks.
80
83
  * Omitted when the ticket (and its ancestors) set none. Values may be secret.
81
84
  */
@@ -90,9 +93,9 @@ export interface Ticket {
90
93
  */
91
94
  workspaceId?: string;
92
95
  workspaceName?: string;
93
- /** The ticket type term name (`feature`, `bug`, …), sideloaded for the required-skills check. */
96
+ /** The ticket type term name (`feature`, `bug`, …), sideloaded for agent selection. */
94
97
  type?: string;
95
- /** The recipe term name (`matt`, …): the run requires the skill `bb-recipe-<recipe>`. */
98
+ /** The recipe term name (`matt`, …), sideloaded for agent selection. */
96
99
  recipe?: string;
97
100
  /** Ticket label term names (`label` bundle), sideloaded for agent selection. Empty when none. */
98
101
  labels: string[];
@@ -365,7 +368,7 @@ export interface BbRemote {
365
368
  getTicket(ticketUuid: string): Promise<Ticket>;
366
369
  /**
367
370
  * BB-495: every `bb_workspace` uuid the dispatching identity can reach —
368
- * dispatch exports this as `BB_WORKSPACE_IDS` so the agent knows the full
371
+ * dispatch exports this as `BAKERS_WORKSPACE_IDS` so the agent knows the full
369
372
  * radius it may name, not only the point it starts standing on.
370
373
  */
371
374
  getReachableWorkspaces(): Promise<string[]>;
@@ -415,7 +418,7 @@ export interface BbRemote {
415
418
  * tickets assigned to `conductorId` are loaded, so every ticket on the list
416
419
  * is unambiguously this conductor's — a missing worktree means "already torn
417
420
  * down on this host", not "belongs to another host". The same query backs
418
- * the live tick and the standalone `bakers oven clean`. Empty once every
421
+ * the live tick and the standalone `bakers conductor clean`. Empty once every
419
422
  * closed ticket this conductor owns is cleaned.
420
423
  */
421
424
  fetchUncleanedTickets(conductorId: string): Promise<UncleanTicket[]>;
@@ -57,6 +57,7 @@ export interface ToolRegistry {
57
57
  }
58
58
  /** `hooks.provision_up`: one command, or a command per profile. */
59
59
  export type ProvisionHook = string | Record<string, string>;
60
+ export declare const PROVISION_TIMEOUT_MS: number;
60
61
  type ShellResult = {
61
62
  exitCode: number;
62
63
  output: string;
@@ -5,7 +5,7 @@
5
5
  // Every call is bound to one worktree by the caller, never by an argument.
6
6
  import { spawn } from 'node:child_process';
7
7
  import { payloadSchema, validateArgs, } from '@bakers-build/message';
8
- const PROVISION_TIMEOUT_MS = 30 * 60_000;
8
+ export const PROVISION_TIMEOUT_MS = 30 * 60_000;
9
9
  const OUTPUT_CAP = 64 * 1024;
10
10
  export function provisionRuns(timeoutMs = PROVISION_TIMEOUT_MS) {
11
11
  const running = new Map();
@@ -61,7 +61,7 @@ export function provisionTools(hook, runs = provisionRuns()) {
61
61
  contract: 1,
62
62
  tools: {
63
63
  provision_up: {
64
- description: `Bring this worktree's environment up${profiles ? ` with a configured profile (${keys})` : ''}; the project's command reuses a ready environment. Returns the command's output, including the base URL.`,
64
+ description: `Bring this worktree's environment up${profiles ? ` with a configured profile (${keys})` : ''}; the project's command reuses a ready environment. Returns the command's output, including the base URL. The first call on a new worktree can take minutes; the call waits until the command ends, for up to 30 minutes. On a client timeout the command keeps running: call again with the same profile to join it and receive its result, without starting a second one.`,
65
65
  input: {
66
66
  type: 'object',
67
67
  properties: {
@@ -75,7 +75,7 @@ export function provisionTools(hook, runs = provisionRuns()) {
75
75
  handlers: async () => ({
76
76
  provision_up: async (req) => {
77
77
  const command = commandFor(req.args.profile);
78
- // shortcut: inherits the conductor's env, not the run's BB_* env; pass it through the binding once a hook needs it.
78
+ // shortcut: inherits the conductor's env, not the run's BAKERS_* env; pass it through the binding once a hook needs it.
79
79
  const { exitCode, output } = await runs.run(req.worktreePath, command);
80
80
  const text = `exit ${exitCode}\n${output}`;
81
81
  if (exitCode !== 0)
@@ -16,7 +16,7 @@ export interface EnsuredWorkspace {
16
16
  created: boolean;
17
17
  /**
18
18
  * Variables the run needs from its workspace backend (e.g. Git config via
19
- * `GIT_CONFIG_COUNT`). The conductor adds them to the run env; core `BB_*`
19
+ * `GIT_CONFIG_COUNT`). The conductor adds them to the run env; core `BAKERS_*`
20
20
  * keys still win.
21
21
  */
22
22
  env?: Record<string, string>;
@@ -1,8 +1,9 @@
1
1
  export const commands = (acc) => [
2
2
  ...acc,
3
3
  {
4
- name: 'oven',
4
+ name: 'conductor',
5
+ aliases: ['oven'],
5
6
  plugin: '@bakers-build/conductor/commands/conductor',
6
- describe: 'node-agent lifecycle + local registry',
7
+ describe: 'conductor lifecycle + local registry',
7
8
  },
8
9
  ];
@@ -18,10 +18,11 @@ export interface ConductorSettings {
18
18
  * Absent until `bakers init` gave the machine its UUID.
19
19
  */
20
20
  conductor_id?: string;
21
- /** The selected config file's stem: `conductor` for `conductor.config.js`. */
21
+ /** The selected config file's stem: `conductor` for `project.config.js`. */
22
22
  variant: string;
23
23
  /** This machine's display label (`machine.config.js` label). */
24
24
  machine_label?: string;
25
+ connection_url?: string | null;
25
26
  /** Project name (bb_project.name); resolved at registration. */
26
27
  project: string;
27
28
  /**
@@ -87,7 +88,7 @@ export interface ConductorSettings {
87
88
  dirs: string[];
88
89
  };
89
90
  }
90
- /** Whole conductor.config.js (dropsh-superset): site + named plugin slots. */
91
+ /** Whole project.config.js (dropsh-superset): site + named plugin slots. */
91
92
  export interface ConductorFileConfig extends ConductorSettings {
92
93
  bakers: BbProjectSelection;
93
94
  resolved_bakers?: ResolvedBbProjectContext;
@@ -124,8 +125,8 @@ export interface ConductorFileConfig extends ConductorSettings {
124
125
  }
125
126
  /**
126
127
  * BB-201 split config model: the ENGINE half of a conductor config —
127
- * everything a `conductor.config.js` carries EXCEPT the connection (`site`) and
128
- * the auth `plugins`, which now live in a separate `bakers.config.js`
128
+ * everything a `project.config.js` carries EXCEPT the connection (`site`) and
129
+ * the auth `plugins`, which now live in a separate connection file
129
130
  * (`BbConnectionConfig`). `loadConductorConfig` returns this; the conductor
130
131
  * command composes it with the connection (`composeConductorConfig`) into the
131
132
  * full `ConductorFileConfig` the engine consumes.