@bakers-build/conductor 0.16.0 → 0.16.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.
@@ -300,6 +300,12 @@ async function cmdCheck(deps) {
300
300
  const source = sources[slot];
301
301
  console.log(`${slot}: ${packages[slot] ?? plugin.id}${source ? ` (${source})` : ''}`);
302
302
  }
303
+ // A key the machine leaves to the project is the repository's to choose.
304
+ const block = (slot) => (slot === 'agent' ? 'agents' : slot);
305
+ for (const { slot, key, value, source, readers } of config.slot_options ?? [])
306
+ console.log(`${block(slot)}.${key} = ${JSON.stringify(value)} (${source}) — read by ${readers.join(', ') || 'none'}`);
307
+ for (const { slot, key, value } of config.slot_options_rejected ?? [])
308
+ console.log(`rejected: project ${block(slot)}.${key} = ${JSON.stringify(value)} (not in ${block(slot)}.allow)`);
303
309
  const warning = runtimeSandboxWarning(config.runtime?.id);
304
310
  if (warning)
305
311
  console.warn(`warning: ${warning}`);
@@ -1,7 +1,7 @@
1
1
  import { readdirSync } from 'node:fs';
2
2
  import { basename, dirname, isAbsolute, resolve } from 'node:path';
3
3
  import { pathToFileURL } from 'node:url';
4
- import { assertSchemaVersion, assertValidConfig, discoverAddons, discoverScoped, findDefaultExportObject, loadRunClone, machineContextPath, matchDelimiter, readMachineContext, resolveConductorSlots, resolveModuleEslintStyle, scanTopLevelProperties, scopeAddons, secretsFilePath, stemForConfigFile, } from '@bakers-build/core';
4
+ import { addonOptionKeys, assertSchemaVersion, assertValidConfig, discoverAddons, discoverScoped, findDefaultExportObject, loadAddonPreset, loadRunClone, machineContextPath, matchDelimiter, normalizeEntry, readMachineContext, resolveConductorSlots, resolveModuleEslintStyle, scanTopLevelProperties, scopeAddons, secretsFilePath, slotKeys, slotOptions, stemForConfigFile, } from '@bakers-build/core';
5
5
  import { readBbProjectSelection } from './cli/project-context.js';
6
6
  import { SHARED_SECURITY_KEY, validateSharedSecurity, } from './plugins/agent-args.js';
7
7
  import { validateMarketplaces } from './plugins/agent-home.js';
@@ -97,6 +97,95 @@ function warnProjectLoosening(path, project) {
97
97
  for (const grant of grants)
98
98
  console.warn(`warning: ${path} permissions ${grant} — the committed project config loosens the agent sandbox on every machine that runs it; see bakers agents`);
99
99
  }
100
+ /** One deprecation warning per config file with a top-level `permissions` block. */
101
+ function warnPermissionsDeprecated(path, block) {
102
+ if (block !== undefined)
103
+ console.warn(`warning: ${path}: the top-level permissions block is deprecated; set permissions and sandbox in the machine's agents block (a project's agents block applies only for keys in the machine's agents.allow). Until it is removed, a project permissions block still applies without agents.allow`);
104
+ }
105
+ const pick = (block, keys) => typeof block === 'object' && block !== null
106
+ ? Object.fromEntries(Object.entries(block).filter(([key]) => keys.has(key)))
107
+ : undefined;
108
+ /**
109
+ * Slot keys (`agents` and `runtime` blocks) for the addon instances of each
110
+ * slot, the warnings for project values the machine's `allow` does not list,
111
+ * and the report `bakers conductor check` prints.
112
+ */
113
+ function slotKeysOf(machine, project, paths) {
114
+ const blocks = {
115
+ agent: { name: 'agents', machine: machine.agents, project: project.agents },
116
+ runtime: {
117
+ name: 'runtime',
118
+ machine: machine.runtime,
119
+ project: project.runtime,
120
+ },
121
+ };
122
+ const keys = { agent: slotKeys('agent'), runtime: slotKeys('runtime') };
123
+ const readers = {
124
+ agent: new Map(),
125
+ runtime: new Map(),
126
+ };
127
+ const input = (slot) => {
128
+ const { machine: m, project: p } = blocks[slot];
129
+ return {
130
+ machine: pick(m, keys[slot]),
131
+ project: pick(p, keys[slot]),
132
+ ...(m?.allow ? { allow: m.allow } : {}),
133
+ };
134
+ };
135
+ return {
136
+ /** The `with` of one instance of `slot`: its own `with` and the slot keys it reads. */
137
+ with(slot, spec, bases, own) {
138
+ const declared = addonOptionKeys(spec, bases);
139
+ // An agent addon without a schema still gets every agent key, so a
140
+ // machine `permissions` is never silently dropped.
141
+ const reads = [...keys[slot].keys()].filter((key) => declared ? declared.has(key) : slot === 'agent');
142
+ for (const key of reads) {
143
+ const set = readers[slot].get(key) ?? new Set();
144
+ readers[slot].set(key, set.add(spec));
145
+ }
146
+ return slotOptions({ keys: reads, entry: own, ...input(slot) }).value;
147
+ },
148
+ /** Warn once per rejected project value; the per-key report. */
149
+ report() {
150
+ const values = [];
151
+ const rejected = [];
152
+ for (const slot of ['agent', 'runtime']) {
153
+ const view = slotOptions({
154
+ keys: [...keys[slot].keys()],
155
+ ...input(slot),
156
+ });
157
+ const { name } = blocks[slot];
158
+ for (const { key, value } of view.rejected) {
159
+ console.warn(`warning: ${paths.project}: ${name}.${key} = ${JSON.stringify(value)} is not applied — ${paths.machine} ${name}.allow does not list ${key}`);
160
+ rejected.push({ slot, key, value });
161
+ }
162
+ for (const [key, fallback] of keys[slot]) {
163
+ const set = view.value?.[key];
164
+ const by = [...(readers[slot].get(key) ?? [])].sort();
165
+ if (set === undefined && (fallback === undefined || by.length === 0))
166
+ continue;
167
+ values.push({
168
+ slot,
169
+ key,
170
+ value: set ?? fallback,
171
+ source: set === undefined
172
+ ? 'default'
173
+ : view.sources[key] === 'project'
174
+ ? 'project'
175
+ : 'machine',
176
+ readers: by,
177
+ });
178
+ }
179
+ }
180
+ return { values, rejected };
181
+ },
182
+ };
183
+ }
184
+ /** `entry` carrying `value` as its `with` (none when undefined). */
185
+ function withReplaced(entry, value) {
186
+ const { with: _with, ...rest } = typeof entry === 'string' ? { use: entry } : entry;
187
+ return value === undefined ? rest : { ...rest, with: value };
188
+ }
100
189
  /** One warning per shared sandbox key a harness cannot express. */
101
190
  function warnNotApplied(candidates) {
102
191
  const seen = new Set();
@@ -275,17 +364,20 @@ export function singleEntryCatalog(slot, plugins) {
275
364
  * preset under its id, then the machine entries (an alias equal to the preset
276
365
  * id replaces it). The project only restricts it and names its default.
277
366
  */
278
- async function loadRuntimeCatalog(preset, machine, project, bases) {
367
+ async function loadRuntimeCatalog(preset, machine, project, bases,
368
+ /** An entry's `with` with the runtime slot keys it reads. */
369
+ slotWith) {
279
370
  const entries = { system: hostRuntime };
280
371
  if (preset)
281
372
  entries[preset.id] = preset;
282
373
  for (const [index, entry] of (machine?.catalog ?? []).entries()) {
283
374
  if (entry.alias === 'system')
284
375
  throw new Error("runtime catalog: alias 'system' is reserved for the built-in host runtime");
376
+ const options = slotWith(entry.use, entry.with);
285
377
  const found = narrowConductorContributions(await discoverAddons([
286
378
  {
287
379
  use: entry.use,
288
- ...(entry.with !== undefined ? { with: entry.with } : {}),
380
+ ...(options !== undefined ? { with: options } : {}),
289
381
  },
290
382
  ], 'conductor', bases, { only: ['runtimes'] })).runtimes.at(-1);
291
383
  if (found?.kind !== 'runtime')
@@ -426,6 +518,12 @@ export async function loadConductorConfig(configFile) {
426
518
  machine: sharedSecurityOf(machineCtx, 'machine', machineContextPath()),
427
519
  };
428
520
  warnProjectLoosening(configPath, sharedSecurity.project);
521
+ warnPermissionsDeprecated(configPath, config.permissions);
522
+ warnPermissionsDeprecated(machineContextPath(), machineCtx.permissions);
523
+ const slotKeyOptions = slotKeysOf(machineCtx, config, {
524
+ machine: machineContextPath(),
525
+ project: configPath,
526
+ });
429
527
  const agentGlobals = { [SHARED_SECURITY_KEY]: sharedSecurity };
430
528
  const { addons: effectiveAddons } = await scopeAddons([
431
529
  {
@@ -441,12 +539,31 @@ export async function loadConductorConfig(configFile) {
441
539
  bases: addonBases,
442
540
  },
443
541
  ]);
444
- const discovered = narrowConductorContributions(await discoverScoped(effectiveAddons, 'conductor', { agentGlobals }));
542
+ // Each agent and runtime addon gets the slot keys it reads in its `with`.
543
+ // shortcut: an addon a preset brings along nested gets none; pass them on
544
+ // when a bundle preset ships an agent or runtime.
545
+ const slotted = await Promise.all(effectiveAddons.map(async (addon) => {
546
+ // A retired entry keeps its spec as key; discovery warns and skips it.
547
+ if (!isAbsolute(addon.key))
548
+ return addon;
549
+ const { spec, opts } = normalizeEntry(addon.entry);
550
+ const { preset } = await loadAddonPreset(spec, addon.bases);
551
+ const slot = typeof preset.agents === 'function'
552
+ ? 'agent'
553
+ : typeof preset.runtimes === 'function'
554
+ ? 'runtime'
555
+ : undefined;
556
+ if (!slot)
557
+ return addon;
558
+ const options = slotKeyOptions.with(slot, spec, addon.bases, opts);
559
+ return { ...addon, entry: withReplaced(addon.entry, options) };
560
+ }));
561
+ const discovered = narrowConductorContributions(await discoverScoped(slotted, 'conductor', { agentGlobals }));
445
562
  const wired = resolveConductorSlots(discovered);
446
563
  // The schema has checked the shape; the list is the project's alone.
447
564
  const projectRuntime = config.runtime;
448
565
  const readOnly = projectRuntime?.read_only;
449
- const runtimes = await loadRuntimeCatalog(wired.runtime, machineCtx.runtime, projectRuntime, machineBases).catch((error) => {
566
+ const runtimes = await loadRuntimeCatalog(wired.runtime, machineCtx.runtime, projectRuntime, machineBases, (use, own) => slotKeyOptions.with('runtime', use, machineBases, own)).catch((error) => {
450
567
  throw new Error(`${configPath}: ${error.message}`);
451
568
  });
452
569
  const defaultRuntime = runtimes.entries[runtimes.default];
@@ -547,10 +664,11 @@ export async function loadConductorConfig(configFile) {
547
664
  if (entry.alias !== undefined &&
548
665
  (typeof entry.alias !== 'string' || !entry.alias.trim()))
549
666
  throw new Error(`agents.catalog[${index}].alias must be non-empty`);
667
+ const options = slotKeyOptions.with('agent', harness, machineBases, entry.with);
550
668
  const contribution = narrowConductorContributions(await discoverAddons([
551
669
  {
552
670
  use: harness,
553
- ...(entry.with !== undefined ? { with: entry.with } : {}),
671
+ ...(options !== undefined ? { with: options } : {}),
554
672
  },
555
673
  ], 'conductor', machineBases, { only: ['agents'], agentGlobals })).agents;
556
674
  const alias = typeof entry.alias === 'string' ? entry.alias.trim() : undefined;
@@ -633,10 +751,15 @@ export async function loadConductorConfig(configFile) {
633
751
  };
634
752
  if (typeof config.select_agent === 'function')
635
753
  console.warn("select_agent in the project config is deprecated; the machine config's select replaces it.");
754
+ const slotReport = slotKeyOptions.report();
636
755
  return {
637
756
  ...(remote ? { remote } : {}),
638
757
  slot_sources: slotSources,
639
758
  slot_packages: slotPackages,
759
+ slot_options: slotReport.values,
760
+ ...(slotReport.rejected.length > 0
761
+ ? { slot_options_rejected: slotReport.rejected }
762
+ : {}),
640
763
  executor,
641
764
  agents: candidates,
642
765
  enabled_agents: enabledAgents,
@@ -95,6 +95,23 @@ export interface ConductorSettings {
95
95
  slot_sources?: Partial<SlotSources>;
96
96
  /** The package each slot named with `use`; addon-discovered slots have none. */
97
97
  slot_packages?: Partial<Record<keyof SlotSources, string>>;
98
+ /** Each slot key's value, its source and the addons that read it (`bakers conductor check`). */
99
+ slot_options?: SlotKeyReport[];
100
+ /** Project slot values the machine's `allow` does not list. */
101
+ slot_options_rejected?: {
102
+ slot: OptionSlot;
103
+ key: string;
104
+ value: unknown;
105
+ }[];
106
+ }
107
+ export type OptionSlot = 'agent' | 'runtime';
108
+ export interface SlotKeyReport {
109
+ slot: OptionSlot;
110
+ key: string;
111
+ value: unknown;
112
+ source: 'machine' | 'project' | 'default';
113
+ /** The active addons whose options schema declares the key. */
114
+ readers: string[];
98
115
  }
99
116
  /** Where a resolved server, executor or worktree plugin came from. */
100
117
  export type SlotSource = 'machine' | 'slot' | 'addons' | 'connection' | 'default';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/conductor",
3
- "version": "0.16.0",
3
+ "version": "0.16.1-next.2",
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.16.0",
36
- "@bakers-build/message": "^0.16.0",
35
+ "@bakers-build/core": "^0.16.1-next.2",
36
+ "@bakers-build/message": "^0.16.1-next.2",
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": "b77840d87a7d64cd9f3eaefc20323bc693e12495",
43
- "channel": "latest"
42
+ "commit": "f75e5bb1044ee13f5b00953a2ae038fcec624024",
43
+ "channel": "next"
44
44
  }
45
45
  }