@bakers-build/conductor 0.5.1-next.858 → 0.6.1-next.1

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.
@@ -9,6 +9,7 @@ import { composeConductorConfig, loadConductorConfig } from '../config.js';
9
9
  import { Conductor, registrationOf } from '../core/conductor.js';
10
10
  import { selectAgents, selectExecutor, selectRemote, selectWorkspace, } from '../plugins/plugins.js';
11
11
  import { sandboxFailures } from '../plugins/sandbox-preflight.js';
12
+ import { ovenTools } from './oven-tools.js';
12
13
  /** Default host bases for connection/plugin resolution when none is injected. */
13
14
  function defaultHost() {
14
15
  return { resolveBases: [import.meta.url, `${process.cwd()}/`] };
@@ -918,6 +919,15 @@ Examples:
918
919
  .action(async () => {
919
920
  await cmdStatus(deps);
920
921
  });
922
+ conductor
923
+ .command('tools')
924
+ .description("list or call the conductor's addon tools from inside a run (exit 4 outside one)")
925
+ .argument('[name]', 'the tool to call; omitted, list the tools')
926
+ .option('--data <json>', 'arguments as a JSON object, or @<file>')
927
+ .option('--schema', "print the tool's input schema instead of calling it")
928
+ .action(async (name, opts) => {
929
+ process.exitCode = await ovenTools(name, opts);
930
+ });
921
931
  // `bakers conductor rm` is gone (BB-232). Its only job was deleting the local
922
932
  // registry entry; with no registry there is nothing to remove, and deleting
923
933
  // the control-plane record is explicitly not the model — a conductor that
@@ -0,0 +1,19 @@
1
+ export interface OvenToolsOptions {
2
+ /** JSON object, or `@<file>` holding one. */
3
+ data?: string;
4
+ schema?: boolean;
5
+ }
6
+ export interface OvenToolsIo {
7
+ out(line: string): void;
8
+ err(line: string): void;
9
+ }
10
+ /** Exit codes mirror `bakers tools`. */
11
+ export declare const EXIT: {
12
+ readonly ok: 0;
13
+ readonly toolError: 1;
14
+ readonly rejected: 3;
15
+ readonly invalid: 4;
16
+ readonly transport: 5;
17
+ };
18
+ /** List the tools, print one's schema, or call it; returns the exit code. */
19
+ export declare function ovenTools(name: string | undefined, opts: OvenToolsOptions, env?: NodeJS.ProcessEnv, io?: OvenToolsIo): Promise<number>;
@@ -0,0 +1,101 @@
1
+ // `bakers oven tools`: an MCP client for the run's own conductor tool server,
2
+ // for agents that cannot load `bakers-conductor` themselves. URL and bearer
3
+ // token come from the run env; the token never reaches argv or output.
4
+ import { readFileSync } from 'node:fs';
5
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
6
+ import { StreamableHTTPClientTransport, StreamableHTTPError, } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
7
+ import { CONDUCTOR_TOKEN_ENV, CONDUCTOR_URL_ENV } from '../plugins/agent.js';
8
+ const processIo = {
9
+ out: (line) => process.stdout.write(`${line}\n`),
10
+ err: (line) => process.stderr.write(`${line}\n`),
11
+ };
12
+ /** Exit codes mirror `bakers tools`. */
13
+ export const EXIT = {
14
+ ok: 0,
15
+ toolError: 1,
16
+ rejected: 3,
17
+ invalid: 4,
18
+ transport: 5,
19
+ };
20
+ function parseData(data) {
21
+ if (data === undefined)
22
+ return {};
23
+ try {
24
+ const text = data.startsWith('@')
25
+ ? readFileSync(data.slice(1), 'utf8')
26
+ : data;
27
+ const parsed = JSON.parse(text);
28
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
29
+ return parsed;
30
+ return '--data must be a JSON object';
31
+ }
32
+ catch (err) {
33
+ return `invalid --data: ${err instanceof Error ? err.message : String(err)}`;
34
+ }
35
+ }
36
+ /** List the tools, print one's schema, or call it; returns the exit code. */
37
+ export async function ovenTools(name, opts, env = process.env, io = processIo) {
38
+ const url = env[CONDUCTOR_URL_ENV];
39
+ const token = env[CONDUCTOR_TOKEN_ENV];
40
+ if (!url || !token) {
41
+ io.err(`no conductor tools in this shell: ${CONDUCTOR_URL_ENV} and ${CONDUCTOR_TOKEN_ENV} are set only inside a conductor run with a tool server`);
42
+ return EXIT.invalid;
43
+ }
44
+ if (!URL.canParse(url)) {
45
+ io.err(`${CONDUCTOR_URL_ENV} is not a URL: ${url}`);
46
+ return EXIT.invalid;
47
+ }
48
+ const args = parseData(opts.data);
49
+ if (typeof args === 'string') {
50
+ io.err(args);
51
+ return EXIT.invalid;
52
+ }
53
+ const client = new Client({ name: 'bakers-oven-tools', version: '1.0.0' });
54
+ try {
55
+ const transport = new StreamableHTTPClientTransport(new URL(url), {
56
+ requestInit: { headers: { authorization: `Bearer ${token}` } },
57
+ });
58
+ // The SDK's own types disagree under exactOptionalPropertyTypes.
59
+ await client.connect(transport);
60
+ const { tools } = await client.listTools();
61
+ if (!name) {
62
+ for (const t of tools)
63
+ io.out(`${t.name}\t${t.description ?? ''}`);
64
+ return EXIT.ok;
65
+ }
66
+ const tool = tools.find((t) => t.name === name);
67
+ if (!tool) {
68
+ io.err(`unknown conductor tool ${name}; available: ${tools.map((t) => t.name).join(', ') || '(none)'}`);
69
+ return EXIT.invalid;
70
+ }
71
+ if (opts.schema) {
72
+ io.out(JSON.stringify(tool.inputSchema, null, 2));
73
+ return EXIT.ok;
74
+ }
75
+ const result = await client.callTool({ name, arguments: args });
76
+ const text = result.structuredContent
77
+ ? JSON.stringify(result.structuredContent, null, 2)
78
+ : (result.content ?? [])
79
+ .filter((c) => c.type === 'text')
80
+ .map((c) => c.text)
81
+ .join('\n');
82
+ if (result.isError) {
83
+ io.err(text);
84
+ return EXIT.toolError;
85
+ }
86
+ io.out(text);
87
+ return EXIT.ok;
88
+ }
89
+ catch (err) {
90
+ if (err instanceof StreamableHTTPError &&
91
+ (err.code === 401 || err.code === 403)) {
92
+ io.err(`run token rejected by ${url}: ${err.message}`);
93
+ return EXIT.rejected;
94
+ }
95
+ io.err(`conductor tool server ${url}: ${err instanceof Error ? err.message : String(err)}`);
96
+ return EXIT.transport;
97
+ }
98
+ finally {
99
+ await client.close().catch(() => undefined);
100
+ }
101
+ }
@@ -1,5 +1,5 @@
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, 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 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, validateAgentArgs, validateOptionalBoolean, validateOptionalString, } from './plugins/agent-args.js';
4
4
  export type { BbExecutor, ExecutorCapabilities, HookContext, HookListener, HookListenerContext, HookListenerFn, HookName, HookResult, SpawnedSession, SpawnRunInput, WorktreeTeardown, } from './plugins/executor.js';
5
5
  export type { DiscoveredInbox, InboxBinding, InboxMessageHandler, InboxMessageRequest, InboxMessages, LoadedInbox, } from './plugins/message.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, DEFAULT_ENV_DENY, emptyAgentFootprint, matchesEnvDeny, } from './plugins/agent.js';
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, validateAgentArgs, validateOptionalBoolean, validateOptionalString, } from './plugins/agent-args.js';
17
17
  export { loadInbox, validateRequestPayload, } from './plugins/message.js';
18
18
  export { resolveAgent, selectAgent, selectAgents, selectExecutor, selectRemote, selectWorkspace, } from './plugins/plugins.js';
@@ -1,7 +1,7 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { basename, dirname, join } from 'node:path';
3
3
  import { shellQuote, stemForConfigFile, } from '@bakers-build/core';
4
- import { DEFAULT_ENV_DENY, matchesEnvDeny, } from '../plugins/agent.js';
4
+ import { CONDUCTOR_TOKEN_ENV, CONDUCTOR_URL_ENV, DEFAULT_ENV_DENY, matchesEnvDeny, } from '../plugins/agent.js';
5
5
  import { resolveAgent } from '../plugins/plugins.js';
6
6
  import { sandboxFailures } from '../plugins/sandbox-preflight.js';
7
7
  import { ActionQueue } from './action-queue.js';
@@ -1262,10 +1262,9 @@ export class Conductor {
1262
1262
  }, `${chosen.agent.id}/${alias}: ${warning}`);
1263
1263
  }
1264
1264
  }
1265
- const tools = this.issueRunTools(run.runUuid, {
1266
- worktreePath: ws.path,
1267
- ticket: t,
1268
- });
1265
+ const tools = chosen.agent.withoutConductorTools
1266
+ ? undefined
1267
+ : this.issueRunTools(run.runUuid, { worktreePath: ws.path, ticket: t });
1269
1268
  const command = chosen.agent.launchCommand(prompt, identity, ws.path, tools ? { url: tools.url } : undefined);
1270
1269
  await this.executor.startRun({
1271
1270
  ticket: {
@@ -1281,7 +1280,13 @@ export class Conductor {
1281
1280
  instructions: ws.instructions,
1282
1281
  command,
1283
1282
  // The token travels in the env, never in argv or the launch log.
1284
- env: tools ? { ...env, BB_CONDUCTOR_TOKEN: tools.token } : env,
1283
+ env: tools
1284
+ ? {
1285
+ ...env,
1286
+ [CONDUCTOR_URL_ENV]: tools.url,
1287
+ [CONDUCTOR_TOKEN_ENV]: tools.token,
1288
+ }
1289
+ : env,
1285
1290
  });
1286
1291
  launch.started = true;
1287
1292
  this.logger.info({
@@ -84,6 +84,8 @@ export interface AgentRunIdentity {
84
84
  export declare const CONDUCTOR_TOOLS_SERVER = "bakers-conductor";
85
85
  /** The run env var holding the run's bearer token for that server. */
86
86
  export declare const CONDUCTOR_TOKEN_ENV = "BB_CONDUCTOR_TOKEN";
87
+ /** The run env var holding that server's URL, for `bakers oven tools`. */
88
+ export declare const CONDUCTOR_URL_ENV = "BB_CONDUCTOR_URL";
87
89
  export interface BbAgent {
88
90
  /** Stable id, e.g. 'claude'. */
89
91
  readonly id: string;
@@ -99,6 +101,12 @@ export interface BbAgent {
99
101
  * the current producer. Omitted when there is nothing to say.
100
102
  */
101
103
  readonly launchWarnings?: readonly string[];
104
+ /**
105
+ * True when this agent's runs must not reach the conductor's tools (a
106
+ * measured claude run): the conductor issues no token and sets neither
107
+ * {@link CONDUCTOR_URL_ENV} nor {@link CONDUCTOR_TOKEN_ENV}.
108
+ */
109
+ readonly withoutConductorTools?: boolean;
102
110
  /**
103
111
  * Build the full agent CLI invocation for a bakers.build prompt. With an empty
104
112
  * prompt, returns the bare launch command (no prompt argument).
@@ -41,3 +41,5 @@ export function matchesEnvDeny(name, patterns) {
41
41
  export const CONDUCTOR_TOOLS_SERVER = 'bakers-conductor';
42
42
  /** The run env var holding the run's bearer token for that server. */
43
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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/conductor",
3
- "version": "0.5.1-next.858",
3
+ "version": "0.6.1-next.1",
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.5.1-next.858",
36
- "@bakers-build/message": "^0.5.1-next.858",
35
+ "@bakers-build/core": "^0.6.1-next.1",
36
+ "@bakers-build/message": "^0.6.1-next.1",
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": "b031fba904f60f6ef154c28e69696bad51cadebc",
42
+ "commit": "a92b86267d70b1d4bc469e62ef3c6964807c7dd0",
43
43
  "channel": "next"
44
44
  }
45
45
  }