@bakers-build/conductor 0.7.1-next.6 → 0.7.1-next.7

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.
@@ -4,6 +4,7 @@ import { pathToFileURL } from 'node:url';
4
4
  import { assertSchemaVersion1, discoverAddons, discoverScoped, findDefaultExportObject, machineContextPath, matchDelimiter, readMachineContext, resolveConductorSlots, resolveModuleEslintStyle, scanTopLevelProperties, scopeAddons, stemForConfigFile, warnIgnoredMaxParallel, } 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
+ import { validateMarketplaces } from './plugins/agent-home.js';
7
8
  import { loadInbox } from './plugins/message.js';
8
9
  import { narrowConductorContributions, } from './plugins/preset.js';
9
10
  import { loadTools, provisionRuns, provisionTools } from './plugins/tools.js';
@@ -350,7 +351,17 @@ export async function loadConductorConfig(configFile) {
350
351
  const restartOnChange = config.restart_on_change ?? true;
351
352
  if (typeof restartOnChange !== 'boolean')
352
353
  throw new Error(`${configPath}: restart_on_change must be a boolean`);
354
+ const marketplaces = (() => {
355
+ try {
356
+ return validateMarketplaces(config.marketplaces);
357
+ }
358
+ catch (error) {
359
+ throw new Error(`${configPath}: ${error.message}`);
360
+ }
361
+ })();
353
362
  const machineCtx = await readMachineContext();
363
+ if ('marketplaces' in machineCtx)
364
+ throw new Error(`${machineContextPath()}: marketplaces is declared per project, in its conductor.config.js; remove it from the machine config`);
354
365
  warnIgnoredMaxParallel(machineContextPath(), machineCtx);
355
366
  const tunnel = machineCtx.tunnel === true;
356
367
  const variant = stemForConfigFile(basename(configPath)) ?? 'conductor';
@@ -565,6 +576,7 @@ export async function loadConductorConfig(configFile) {
565
576
  }
566
577
  : {}),
567
578
  workspace,
579
+ marketplaces,
568
580
  hookListeners,
569
581
  ...(inboxAddons.length > 0 ? { inboxAddons } : {}),
570
582
  ...(tools !== undefined ? { tools } : {}),
@@ -1,6 +1,7 @@
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 RunEnvPolicy, } from './plugins/agent.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';
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
+ export { ensureHome, homeKey, homePath, type MarketplaceDeclaration, validateMarketplaces, } from './plugins/agent-home.js';
4
5
  export type { BbExecutor, ExecutorCapabilities, HookContext, HookListener, HookListenerContext, HookListenerFn, HookName, HookResult, OpenWorkspaceContext, SpawnedSession, SpawnRunInput, WorktreeTeardown, } from './plugins/executor.js';
5
6
  export type { DiscoveredInbox, InboxBinding, InboxMessageHandler, InboxMessageRequest, InboxMessages, LoadedInbox, } from './plugins/message.js';
6
7
  export { loadInbox, validateRequestPayload, } from './plugins/message.js';
@@ -14,6 +14,7 @@
14
14
  export { AmbiguousProjectNameError, resolveBbProjectContext, } from './bakers-project-context.js';
15
15
  export { CONDUCTOR_TOKEN_ENV, 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
+ export { ensureHome, homeKey, homePath, validateMarketplaces, } from './plugins/agent-home.js';
17
18
  export { loadInbox, validateRequestPayload, } from './plugins/message.js';
18
19
  export { resolveAgent, selectAgent, selectAgents, selectExecutor, selectRemote, selectWorkspace, } from './plugins/plugins.js';
19
20
  export { narrowConductorContributions, } from './plugins/preset.js';
@@ -235,6 +235,11 @@ export declare class Conductor {
235
235
  private currentTunnel;
236
236
  /** Dispatches one claimed run; a failure terminalises it (BB-149). */
237
237
  private dispatchOrFail;
238
+ /**
239
+ * Install the project's `marketplaces` into the run's agent home and log
240
+ * one `plugins` entry. A failed install throws, failing the run start.
241
+ */
242
+ private installPlugins;
238
243
  /** `at.worktree` is set once the workspace exists, so a failure can signal it. */
239
244
  private dispatch;
240
245
  /**
@@ -2,6 +2,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { basename, dirname, join } from 'node:path';
3
3
  import { killRunProcesses, shellQuote, stemForConfigFile, } from '@bakers-build/core';
4
4
  import { CONDUCTOR_TOKEN_ENV, CONDUCTOR_URL_ENV, DEFAULT_ENV_DENY, matchesEnvDeny, } from '../plugins/agent.js';
5
+ import { homeKey, homePath } from '../plugins/agent-home.js';
5
6
  import { resolveAgent } from '../plugins/plugins.js';
6
7
  import { sandboxFailures } from '../plugins/sandbox-preflight.js';
7
8
  import { loadTools } from '../plugins/tools.js';
@@ -10,6 +11,7 @@ import { attemptFamily } from './attempt.js';
10
11
  import { shellHookRunner } from './hook-runner.js';
11
12
  import { InboxRuntime, runInbox } from './inbox-runtime.js';
12
13
  import { measureMrChanges, mrChangesRows } from './mr-changes.js';
14
+ import { checkRequiredSkills } from './required-skills.js';
13
15
  import { startToolServer } from './tool-server.js';
14
16
  import { signalUi } from './ui-signal.js';
15
17
  function sleep(ms, signal) {
@@ -1142,6 +1144,62 @@ export class Conductor {
1142
1144
  }
1143
1145
  }
1144
1146
  }
1147
+ /**
1148
+ * Install the project's `marketplaces` into the run's agent home and log
1149
+ * one `plugins` entry. A failed install throws, failing the run start.
1150
+ */
1151
+ async installPlugins(chosen, t, run, worktree) {
1152
+ const marketplaces = this.config.marketplaces ?? [];
1153
+ const harness = chosen.agent.id;
1154
+ const entry = {
1155
+ harness,
1156
+ alias: chosen.alias ?? chosen.id,
1157
+ mode: chosen.permissions,
1158
+ };
1159
+ const log = () => this.logger.info({ ticket: t.identifier, run: run.runUuid, plugins: entry }, 'plugins');
1160
+ const off = marketplaces.length === 0
1161
+ ? 'none declared'
1162
+ : chosen.agent.pluginsDisabled
1163
+ ? 'disabled'
1164
+ : !chosen.agent.installPlugins
1165
+ ? 'unsupported'
1166
+ : undefined;
1167
+ if (off || !chosen.agent.installPlugins) {
1168
+ 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
+ log();
1172
+ return { env: {}, args: [] };
1173
+ }
1174
+ const hash = homeKey(marketplaces);
1175
+ const home = homePath(harness, hash);
1176
+ Object.assign(entry, { state: 'on', hash, home, marketplaces });
1177
+ let launch;
1178
+ try {
1179
+ launch = await chosen.agent.installPlugins(marketplaces, home);
1180
+ Object.assign(entry, {
1181
+ outcome: launch.home,
1182
+ ...(launch.trust_bypass?.length
1183
+ ? { trust_bypass: launch.trust_bypass }
1184
+ : {}),
1185
+ ...(launch.gaps?.length ? { gaps: launch.gaps } : {}),
1186
+ });
1187
+ }
1188
+ catch (err) {
1189
+ entry.failure = err instanceof Error ? err.message : String(err);
1190
+ log();
1191
+ throw new Error(`plugins: ${harness} install failed: ${entry.failure}`);
1192
+ }
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
+ log();
1201
+ return { env: launch.env, args: launch.args };
1202
+ }
1145
1203
  /** `at.worktree` is set once the workspace exists, so a failure can signal it. */
1146
1204
  async dispatch(run, at = {}) {
1147
1205
  const t = await this.remote.getTicket(run.ticketUuid);
@@ -1323,7 +1381,9 @@ export class Conductor {
1323
1381
  const tools = chosen.agent.withoutConductorTools
1324
1382
  ? undefined
1325
1383
  : this.issueRunTools(run.runUuid, { worktreePath: ws.path, ticket: t });
1326
- const command = chosen.agent.launchCommand(prompt, identity, ws.path, tools ? { url: tools.url } : undefined, env);
1384
+ const plugins = await this.installPlugins(chosen, t, run, ws.path);
1385
+ Object.assign(env, plugins.env);
1386
+ const command = chosen.agent.launchCommand(prompt, identity, ws.path, tools ? { url: tools.url } : undefined, env, plugins.args);
1327
1387
  // Read after launchCommand: a warning may depend on what this launch got.
1328
1388
  const warnings = chosen.agent.launchWarnings;
1329
1389
  if (warnings?.length) {
@@ -0,0 +1,7 @@
1
+ export declare function checkRequiredSkills(worktree: string, home: string, ticket: {
2
+ type?: string;
3
+ recipe?: string;
4
+ }): {
5
+ required: string[];
6
+ missing: string[];
7
+ };
@@ -0,0 +1,157 @@
1
+ /**
2
+ * The skills a run must be able to load: every skill named in the worktree's
3
+ * `WORKFLOW.md` › `## bb-phase-work`, the ticket's recipe skill
4
+ * `bb-recipe-<recipe>`, and the recipe's `metadata.requires` for the ticket's
5
+ * type. Available are the worktree's own skills and the plugins installed in
6
+ * the run's agent home; the user's own agent home never counts.
7
+ */
8
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
9
+ import { basename, dirname, join } from 'node:path';
10
+ const read = (path) => {
11
+ try {
12
+ return readFileSync(path, 'utf8');
13
+ }
14
+ catch {
15
+ return '';
16
+ }
17
+ };
18
+ const frontmatter = (text) => /^---\n([\s\S]*?)\n---/.exec(text)?.[1] ?? '';
19
+ /** Skill directories (holding a SKILL.md) directly under `dir`, by their frontmatter name. */
20
+ function skillsIn(dir) {
21
+ let entries;
22
+ try {
23
+ entries = readdirSync(dir);
24
+ }
25
+ catch {
26
+ return [];
27
+ }
28
+ return entries.flatMap((entry) => skillAt(join(dir, entry), entry));
29
+ }
30
+ /** A skill directory's SKILL.md by its frontmatter name, if it holds one. */
31
+ function skillAt(dir, fallback) {
32
+ const path = join(dir, 'SKILL.md');
33
+ if (!existsSync(path))
34
+ return [];
35
+ const name = /^name:\s*(\S+)\s*$/m.exec(frontmatter(read(path)))?.[1];
36
+ return [[name ?? fallback, path]];
37
+ }
38
+ /** Every SKILL.md at or below `dir`, by its frontmatter name. */
39
+ function skillsBelow(dir) {
40
+ let files;
41
+ try {
42
+ files = readdirSync(dir, { recursive: true, encoding: 'utf8' });
43
+ }
44
+ catch {
45
+ return [];
46
+ }
47
+ return files
48
+ .filter((file) => basename(file) === 'SKILL.md')
49
+ .filter((file) => !file.includes('node_modules/'))
50
+ .flatMap((file) => {
51
+ const skillDir = join(dir, dirname(file));
52
+ return skillAt(skillDir, basename(skillDir));
53
+ });
54
+ }
55
+ /**
56
+ * `<plugin>:<skill>` for each skill of the plugin rooted at `root`. The
57
+ * manifest names the plugin and its `skills` paths (one or a list); without
58
+ * one, the plugin is `fallback` with `skills/`. Like the harnesses, every
59
+ * SKILL.md below a skills path counts.
60
+ */
61
+ function pluginSkills(root, fallback) {
62
+ let manifest = {};
63
+ for (const kind of ['.claude-plugin', '.codex-plugin']) {
64
+ try {
65
+ manifest = JSON.parse(read(join(root, kind, 'plugin.json')));
66
+ break;
67
+ }
68
+ catch { }
69
+ }
70
+ const plugin = typeof manifest.name === 'string' ? manifest.name : fallback;
71
+ const paths = (Array.isArray(manifest.skills)
72
+ ? manifest.skills
73
+ : [manifest.skills ?? 'skills']).filter((path) => typeof path === 'string');
74
+ return paths
75
+ .flatMap((path) => skillsBelow(join(root, path)))
76
+ .map(([name, path]) => [`${plugin}:${name}`, path]);
77
+ }
78
+ const dirs = (dir) => {
79
+ try {
80
+ return readdirSync(dir, { withFileTypes: true })
81
+ .filter((entry) => entry.isDirectory())
82
+ .map((entry) => entry.name);
83
+ }
84
+ catch {
85
+ return [];
86
+ }
87
+ };
88
+ function availableSkills(worktree, home) {
89
+ const found = new Map();
90
+ const add = (pairs) => {
91
+ for (const [name, path] of pairs)
92
+ if (!found.has(name))
93
+ found.set(name, path);
94
+ };
95
+ for (const root of ['.claude/skills', '.agents/skills']) {
96
+ const dir = join(worktree, root);
97
+ add(skillsIn(dir));
98
+ // A skills-directory plugin, such as the `bakers` skills of this repository.
99
+ for (const entry of dirs(dir))
100
+ if (existsSync(join(dir, entry, '.claude-plugin', 'plugin.json')) ||
101
+ existsSync(join(dir, entry, '.codex-plugin', 'plugin.json')))
102
+ add(pluginSkills(join(dir, entry), entry));
103
+ }
104
+ // Both harnesses install to plugins/cache/<marketplace>/<plugin>/<version>.
105
+ const cache = join(home, 'plugins', 'cache');
106
+ for (const marketplace of dirs(cache))
107
+ for (const plugin of dirs(join(cache, marketplace)))
108
+ for (const version of dirs(join(cache, marketplace, plugin)))
109
+ add(pluginSkills(join(cache, marketplace, plugin, version), plugin));
110
+ return found;
111
+ }
112
+ /** The backticked names in the last column of the `## bb-phase-work` table. */
113
+ function workflowSkills(worktree) {
114
+ const section = /^## bb-phase-work\s*$([\s\S]*?)(?=^## |(?![\s\S]))/m.exec(read(join(worktree, 'WORKFLOW.md')))?.[1] ?? '';
115
+ return section
116
+ .split('\n')
117
+ .filter((line) => line.trim().startsWith('|'))
118
+ .flatMap((line) => {
119
+ const cells = line
120
+ .trim()
121
+ .replace(/^\||\|$/g, '')
122
+ .split('|');
123
+ return [...(cells.at(-1) ?? '').matchAll(/`([^`]+)`/g)].map((m) => m[1]);
124
+ });
125
+ }
126
+ /**
127
+ * A recipe's `metadata.requires` (space-separated skill names), replaced by
128
+ * `requires-<type>` when the recipe declares one for the ticket's type.
129
+ */
130
+ function recipeRequires(skillFile, type) {
131
+ const lists = new Map();
132
+ for (const m of frontmatter(read(skillFile)).matchAll(/^\s+requires(?:-([\w-]+))?:\s*"?([^"\n]*)"?\s*$/gm))
133
+ lists.set(m[1] ?? 'default', m[2]);
134
+ const list = (type && lists.get(type)) ?? lists.get('default') ?? '';
135
+ return list.split(/\s+/).filter(Boolean);
136
+ }
137
+ function lookup(found, name) {
138
+ if (name.includes(':'))
139
+ return found.get(name);
140
+ return (found.get(name) ?? [...found].find(([key]) => key.endsWith(`:${name}`))?.[1]);
141
+ }
142
+ export function checkRequiredSkills(worktree, home, ticket) {
143
+ const found = availableSkills(worktree, home);
144
+ const required = workflowSkills(worktree);
145
+ if (ticket.recipe) {
146
+ const recipe = `bb-recipe-${ticket.recipe}`;
147
+ required.push(recipe);
148
+ const path = lookup(found, recipe);
149
+ if (path)
150
+ required.push(...recipeRequires(path, ticket.type));
151
+ }
152
+ const unique = [...new Set(required)];
153
+ return {
154
+ required: unique,
155
+ missing: unique.filter((name) => !lookup(found, name)),
156
+ };
157
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * A project's agent plugins: the `marketplaces` declaration of its committed
3
+ * conductor config, and the per-harness agent home they are installed into.
4
+ */
5
+ /** One Git marketplace at a branch or tag, and the plugins to install from it. */
6
+ export interface MarketplaceDeclaration {
7
+ url: string;
8
+ ref: string;
9
+ plugins: string[];
10
+ }
11
+ /** Validate the `marketplaces` key of a project conductor config. */
12
+ export declare function validateMarketplaces(value: unknown): MarketplaceDeclaration[];
13
+ /** The first 16 hex chars of the sha256 of the normalized declaration. */
14
+ export declare function homeKey(marketplaces: MarketplaceDeclaration[]): string;
15
+ /** `~/.cache/bakers/agent-homes/<harness>/<key>`, outside the sandbox-hidden `~/.bakers`. */
16
+ export declare function homePath(harness: string, key: string): string;
17
+ /**
18
+ * Make `path` a complete agent home: `reused` when a previous build finished,
19
+ * else `build(path)` runs under the lock and the home is `built`. A failed
20
+ * build leaves no home behind.
21
+ */
22
+ export declare function ensureHome(path: string, build: (path: string) => Promise<void>): Promise<'built' | 'reused'>;
@@ -0,0 +1,118 @@
1
+ /**
2
+ * A project's agent plugins: the `marketplaces` declaration of its committed
3
+ * conductor config, and the per-harness agent home they are installed into.
4
+ */
5
+ import { createHash } from 'node:crypto';
6
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, } from 'node:fs';
7
+ import { homedir } from 'node:os';
8
+ import { join } from 'node:path';
9
+ import { setTimeout as sleep } from 'node:timers/promises';
10
+ // Both harnesses fetch only remote Git sources (no file://, no local path).
11
+ const GIT_URL = /^(?:https?:\/\/|ssh:\/\/|git@[^:\s]+:)\S+$/;
12
+ const nonEmpty = (value) => typeof value === 'string' && value.trim() !== '';
13
+ /** Validate the `marketplaces` key of a project conductor config. */
14
+ export function validateMarketplaces(value) {
15
+ if (value === undefined)
16
+ return [];
17
+ if (!Array.isArray(value))
18
+ throw new Error('marketplaces must be an array');
19
+ return value.map((entry, index) => {
20
+ const at = `marketplaces[${index}]`;
21
+ const raw = (entry ?? {});
22
+ if (!nonEmpty(raw.url) || !GIT_URL.test(raw.url))
23
+ throw new Error(`${at}.url must be a remote Git URL (https, ssh or git@)`);
24
+ if (!nonEmpty(raw.ref))
25
+ throw new Error(`${at}.ref must name a branch or tag`);
26
+ if (!Array.isArray(raw.plugins) ||
27
+ raw.plugins.length === 0 ||
28
+ !raw.plugins.every(nonEmpty))
29
+ throw new Error(`${at}.plugins must be a non-empty list of plugin names`);
30
+ return {
31
+ url: raw.url,
32
+ ref: raw.ref,
33
+ plugins: raw.plugins,
34
+ };
35
+ });
36
+ }
37
+ /** The first 16 hex chars of the sha256 of the normalized declaration. */
38
+ export function homeKey(marketplaces) {
39
+ const canonical = marketplaces.map(({ url, ref, plugins }) => ({
40
+ url,
41
+ ref,
42
+ plugins,
43
+ }));
44
+ return createHash('sha256')
45
+ .update(JSON.stringify(canonical))
46
+ .digest('hex')
47
+ .slice(0, 16);
48
+ }
49
+ /** `~/.cache/bakers/agent-homes/<harness>/<key>`, outside the sandbox-hidden `~/.bakers`. */
50
+ export function homePath(harness, key) {
51
+ const cache = process.env.XDG_CACHE_HOME || join(homedir(), '.cache');
52
+ return join(cache, 'bakers', 'agent-homes', harness, key);
53
+ }
54
+ const READY = '.bakers-ready';
55
+ function alive(pid) {
56
+ try {
57
+ process.kill(pid, 0);
58
+ return true;
59
+ }
60
+ catch (error) {
61
+ return error.code === 'EPERM';
62
+ }
63
+ }
64
+ /** Take `<home>.lock`; a lock whose owner process is gone is taken over. */
65
+ async function lock(path) {
66
+ const file = `${path}.lock`;
67
+ const owner = `${process.pid}:${Math.random()}`;
68
+ for (;;) {
69
+ try {
70
+ writeFileSync(file, owner, { flag: 'wx' });
71
+ return () => rmSync(file, { force: true });
72
+ }
73
+ catch (error) {
74
+ if (error.code !== 'EEXIST')
75
+ throw error;
76
+ }
77
+ let held = '';
78
+ try {
79
+ held = readFileSync(file, 'utf8');
80
+ }
81
+ catch { }
82
+ // shortcut: two waiters reaping the same stale lock at once can both win; upgrade to an fcntl lock if that is ever seen.
83
+ const pid = Number.parseInt(held, 10);
84
+ if (Number.isInteger(pid) && !alive(pid))
85
+ rmSync(file, { force: true });
86
+ else
87
+ await sleep(100);
88
+ }
89
+ }
90
+ /**
91
+ * Make `path` a complete agent home: `reused` when a previous build finished,
92
+ * else `build(path)` runs under the lock and the home is `built`. A failed
93
+ * build leaves no home behind.
94
+ */
95
+ export async function ensureHome(path, build) {
96
+ if (existsSync(join(path, READY)))
97
+ return 'reused';
98
+ mkdirSync(join(path, '..'), { recursive: true });
99
+ const release = await lock(path);
100
+ try {
101
+ if (existsSync(join(path, READY)))
102
+ return 'reused';
103
+ rmSync(path, { recursive: true, force: true });
104
+ mkdirSync(path);
105
+ try {
106
+ await build(path);
107
+ }
108
+ catch (error) {
109
+ rmSync(path, { recursive: true, force: true });
110
+ throw error;
111
+ }
112
+ writeFileSync(join(path, READY), new Date().toISOString());
113
+ return 'built';
114
+ }
115
+ finally {
116
+ release();
117
+ }
118
+ }
@@ -1,3 +1,4 @@
1
+ import type { MarketplaceDeclaration } from './agent-home.js';
1
2
  import type { SandboxHost, SandboxPreflight } from './sandbox-preflight.js';
2
3
  /**
3
4
  * Per-agent effort footprint parsed from that agent's run transcript
@@ -86,9 +87,31 @@ export declare const CONDUCTOR_TOOLS_SERVER = "bakers";
86
87
  export declare const CONDUCTOR_TOKEN_ENV = "BB_CONDUCTOR_TOKEN";
87
88
  /** The run env var holding that server's URL, for `bakers oven tools`. */
88
89
  export declare const CONDUCTOR_URL_ENV = "BB_CONDUCTOR_URL";
90
+ /** What {@link BbAgent.installPlugins} hands the run's launch. */
91
+ export interface PluginLaunch {
92
+ /** Merged into the run env: the harness's config-dir variable, never `HOME`. */
93
+ env: Record<string, string>;
94
+ /** Passed to `launchCommand` as its `args`. */
95
+ args: string[];
96
+ /** `built` when this call built the home, `reused` when it was complete. */
97
+ home: 'built' | 'reused';
98
+ /** Trust checks this run skips, for the run's `plugins` log entry. */
99
+ trust_bypass?: string[];
100
+ /** Declared plugins the harness cannot load, for the same entry. */
101
+ gaps?: string[];
102
+ }
89
103
  export interface BbAgent {
90
104
  /** Stable id, e.g. 'claude'. */
91
105
  readonly id: string;
106
+ /** True when the catalog entry sets `plugins: false`: the run uses the user's own agent home. */
107
+ readonly pluginsDisabled?: boolean;
108
+ /**
109
+ * Install the project's plugin marketplaces into `home` with the harness's
110
+ * own commands (once; see `ensureHome`) and return how a run in it
111
+ * launches. Called before every launch, in every security mode. Throws,
112
+ * naming the plugin and the harness output, when the install fails.
113
+ */
114
+ installPlugins?(marketplaces: readonly MarketplaceDeclaration[], home: string): Promise<PluginLaunch>;
92
115
  /**
93
116
  * How the conductor treats ticket/project env_vars whose names match
94
117
  * `deny`: dropped when `drop`, kept (and still logged) otherwise. Omitted →
@@ -126,10 +149,12 @@ export interface BbAgent {
126
149
  * `env` is the run env the command starts in, for an agent whose harness
127
150
  * filters it (Codex). Its values may be secret: never put them in argv
128
151
  * unless the harness drops them otherwise.
152
+ *
153
+ * `args` are the {@link PluginLaunch} args of this run, when plugins are on.
129
154
  */
130
155
  launchCommand(prompt: string, run?: AgentRunIdentity, workspacePath?: string, tools?: {
131
156
  url: string;
132
- }, env?: Readonly<Record<string, string>>): string;
157
+ }, env?: Readonly<Record<string, string>>, args?: readonly string[]): string;
133
158
  /**
134
159
  * Locate and read this agent's run transcript for a run that executed in
135
160
  * `worktreePath`. MUST return '' (never throw) when nothing is found.
@@ -2,7 +2,7 @@ import type { AgentRoutes, ConductorLogger } from '@bakers-build/core';
2
2
  import type { DropSHPlugin } from 'dropsh/plugin';
3
3
  import type { ConductorFileConfig } from '../types.js';
4
4
  import type { BbAgent } from './agent.js';
5
- import type { SecurityReport } from './agent-args.js';
5
+ import type { SecurityMode, SecurityReport } from './agent-args.js';
6
6
  import type { BbExecutor } from './executor.js';
7
7
  import type { BbRemote, Ticket } from './remote.js';
8
8
  import type { BbWorkspace } from './workspace.js';
@@ -80,6 +80,8 @@ export interface ResolvedAgent {
80
80
  * used instead. */
81
81
  modelVersion?: string;
82
82
  id: string;
83
+ /** The candidate's effective permissions mode, for the run's `plugins` log entry. */
84
+ permissions?: SecurityMode;
83
85
  agent: BbAgent;
84
86
  priority?: (ticket: Ticket) => number;
85
87
  }
@@ -43,6 +43,9 @@ export async function selectAgents(config) {
43
43
  ...(c.description !== undefined ? { description: c.description } : {}),
44
44
  ...(c.model !== undefined ? { model: c.model } : {}),
45
45
  ...(c.modelVersion !== undefined ? { modelVersion: c.modelVersion } : {}),
46
+ ...(c.agent.permissions
47
+ ? { permissions: c.agent.permissions.mode.value }
48
+ : {}),
46
49
  agent: await c.agent.createAgent(config),
47
50
  ...(c.priority ? { priority: c.priority } : {}),
48
51
  })));
@@ -90,6 +90,10 @@ export interface Ticket {
90
90
  */
91
91
  workspaceId?: string;
92
92
  workspaceName?: string;
93
+ /** The ticket type term name (`feature`, `bug`, …), sideloaded for the required-skills check. */
94
+ type?: string;
95
+ /** The recipe term name (`matt`, …): the run requires the skill `bb-recipe-<recipe>`. */
96
+ recipe?: string;
93
97
  /** Ticket label term names (`label` bundle), sideloaded for agent selection. Empty when none. */
94
98
  labels: string[];
95
99
  /** Ticket environments (bb_environment refs), each as name + tier, sideloaded for agent selection. Empty when none. */
@@ -2,6 +2,7 @@ import type { AgentRoutes } from '@bakers-build/core';
2
2
  import type { DropSHPlugin } from 'dropsh/plugin';
3
3
  import type { ResolvedBbProjectContext } from './bakers-project-context.js';
4
4
  import type { BbProjectSelection } from './cli/project-context.js';
5
+ import type { MarketplaceDeclaration } from './plugins/agent-home.js';
5
6
  import type { HookListener } from './plugins/executor.js';
6
7
  import type { LoadedInbox } from './plugins/message.js';
7
8
  import type { AgentCandidate, ExecutorPlugin, RemotePlugin, ResolvedAgent, WorkspacePlugin } from './plugins/plugins.js';
@@ -101,6 +102,8 @@ export interface ConductorFileConfig extends ConductorSettings {
101
102
  /** Replaces the shipped label/default resolution for this project. */
102
103
  selectAgent?: (candidates: ResolvedAgent[], ticket: Ticket) => ResolvedAgent;
103
104
  workspace: WorkspacePlugin;
105
+ /** The project's agent plugin marketplaces; empty when it declares none. */
106
+ marketplaces: MarketplaceDeclaration[];
104
107
  /**
105
108
  * Addon lifecycle listeners from the conductor `addons[]` `hooks`
106
109
  * accumulator (BB-599), validated at load. Kept apart from the shell
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/conductor",
3
- "version": "0.7.1-next.6",
3
+ "version": "0.7.1-next.7",
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.7.1-next.6",
36
- "@bakers-build/message": "^0.7.1-next.6",
35
+ "@bakers-build/core": "^0.7.1-next.7",
36
+ "@bakers-build/message": "^0.7.1-next.7",
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": "269bb0ea2c27fca3b5ff3ac553df9c81b6179f5f",
42
+ "commit": "082d8c57436f78e751f5a9a26a4446cec42209ce",
43
43
  "channel": "next"
44
44
  }
45
45
  }