@bakers-build/conductor 0.9.1-next.4 → 0.9.1-next.6
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.
- package/dist/src/cli/config-plan.d.ts +4 -1
- package/dist/src/cli/config-plan.js +73 -23
- package/dist/src/cli/config-templates.d.ts +3 -1
- package/dist/src/cli/config-templates.js +7 -9
- package/dist/src/cli/config-validation.d.ts +2 -11
- package/dist/src/cli/config-validation.js +18 -47
- package/dist/src/commands/conductor.js +27 -5
- package/dist/src/config.d.ts +6 -8
- package/dist/src/config.js +96 -22
- package/dist/src/contract.d.ts +3 -2
- package/dist/src/contract.js +1 -0
- package/dist/src/core/conductor.d.ts +11 -0
- package/dist/src/core/conductor.js +154 -17
- package/dist/src/core/mr-changes.d.ts +3 -1
- package/dist/src/core/mr-changes.js +9 -2
- package/dist/src/core/site-tools.js +6 -0
- package/dist/src/core/tool-server.d.ts +2 -0
- package/dist/src/core/tool-server.js +21 -8
- package/dist/src/core/ui-signal.d.ts +5 -2
- package/dist/src/core/ui-signal.js +7 -3
- package/dist/src/plugins/agent-args.js +4 -3
- package/dist/src/plugins/agent.d.ts +41 -2
- package/dist/src/plugins/host-commands.d.ts +9 -0
- package/dist/src/plugins/host-commands.js +35 -0
- package/dist/src/plugins/preset.d.ts +5 -1
- package/dist/src/plugins/remote.d.ts +4 -2
- package/dist/src/plugins/runtime.d.ts +58 -0
- package/dist/src/plugins/runtime.js +15 -0
- package/dist/src/plugins/sandbox-preflight.d.ts +1 -0
- package/dist/src/plugins/sandbox-preflight.js +5 -0
- package/dist/src/plugins/tools.d.ts +31 -8
- package/dist/src/plugins/tools.js +61 -39
- package/dist/src/plugins/workspace.d.ts +7 -0
- package/dist/src/types.d.ts +22 -1
- package/package.json +4 -4
|
@@ -3,6 +3,7 @@ import type { HookListener } from './executor.js';
|
|
|
3
3
|
import type { DiscoveredInbox, InboxMessages } from './message.js';
|
|
4
4
|
import type { AgentCandidate, ExecutorPlugin, RemotePlugin, WorkspacePlugin } from './plugins.js';
|
|
5
5
|
import type { Ticket } from './remote.js';
|
|
6
|
+
import type { RuntimePlugin } from './runtime.js';
|
|
6
7
|
import type { AddonTools, DiscoveredTools } from './tools.js';
|
|
7
8
|
/**
|
|
8
9
|
* The conductor surface's concrete contributions — the strongly-typed view of
|
|
@@ -17,6 +18,8 @@ export interface ConductorContributions {
|
|
|
17
18
|
agents: AgentCandidate[];
|
|
18
19
|
/** Lifecycle hook listeners, in accumulator order (BB-599). */
|
|
19
20
|
hooks: HookListener[];
|
|
21
|
+
/** Runtime plugins; the slot takes the last. */
|
|
22
|
+
runtimes: RuntimePlugin[];
|
|
20
23
|
/** Addon `inbox` exports with their package name and version (contract 2, BB-661). */
|
|
21
24
|
addonInbox: DiscoveredInbox[];
|
|
22
25
|
/** Addon `tools` exports with their package name and version. */
|
|
@@ -47,6 +50,7 @@ export interface Preset<O = unknown> extends BbPreset<O> {
|
|
|
47
50
|
worktrees?: (acc: WorkspacePlugin[], opts: O) => WorkspacePlugin[] | Promise<WorkspacePlugin[]>;
|
|
48
51
|
agents?: (acc: AgentCandidate[], opts: O) => AgentCandidate[] | Promise<AgentCandidate[]>;
|
|
49
52
|
hooks?: (acc: HookListener[], opts: O) => HookListener[] | Promise<HookListener[]>;
|
|
53
|
+
runtimes?: (acc: RuntimePlugin[], opts: O) => RuntimePlugin[] | Promise<RuntimePlugin[]>;
|
|
50
54
|
/** Addon inbox messages: contract 2, BB-661. */
|
|
51
55
|
inbox?: InboxMessages;
|
|
52
56
|
/** Agent tools served through the conductor's MCP server. */
|
|
@@ -59,4 +63,4 @@ export interface Preset<O = unknown> extends BbPreset<O> {
|
|
|
59
63
|
* {@link Preset}, and `resolveConductorSlots` still runs the runtime `.kind`
|
|
60
64
|
* guard on whatever actually landed in a singleton slot.
|
|
61
65
|
*/
|
|
62
|
-
export declare function narrowConductorContributions(discovered: Pick<DiscoveredContributions, 'servers' | 'executors' | 'worktrees' | 'agents' | 'hooks' | 'addonInbox' | 'addonTools'>): ConductorContributions;
|
|
66
|
+
export declare function narrowConductorContributions(discovered: Pick<DiscoveredContributions, 'servers' | 'executors' | 'worktrees' | 'agents' | 'hooks' | 'runtimes' | 'addonInbox' | 'addonTools'>): ConductorContributions;
|
|
@@ -452,10 +452,12 @@ export interface BbRemote {
|
|
|
452
452
|
appendRunNote(runUuid: string, note: string): Promise<void>;
|
|
453
453
|
/**
|
|
454
454
|
* Resolve a ticket identifier (e.g. "BB-134") to its uuid+title within a
|
|
455
|
-
* project, or null when no such ticket exists. Used by the
|
|
455
|
+
* project (name or explicit UUID), or null when no such ticket exists. Used by the
|
|
456
456
|
* `bakers deployment tickets` helper to turn commit-message identifiers into tickets.
|
|
457
457
|
*/
|
|
458
|
-
resolveTicketByIdentifier(project: string
|
|
458
|
+
resolveTicketByIdentifier(project: string | {
|
|
459
|
+
uuid: string;
|
|
460
|
+
}, identifier: string): Promise<{
|
|
459
461
|
uuid: string;
|
|
460
462
|
title: string;
|
|
461
463
|
} | null>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ConductorLogger } from '@bakers-build/core';
|
|
2
|
+
import type { ConductorFileConfig } from '../types.js';
|
|
3
|
+
import type { AgentRuntimeInfo, RunBind } from './agent.js';
|
|
4
|
+
/** The run a launch belongs to. */
|
|
5
|
+
export interface RuntimeRun {
|
|
6
|
+
uuid: string;
|
|
7
|
+
id: number;
|
|
8
|
+
}
|
|
9
|
+
/** The finished launch the conductor would hand to `executor.startRun`. */
|
|
10
|
+
export interface RuntimeLaunch extends AgentRuntimeInfo {
|
|
11
|
+
command: string;
|
|
12
|
+
/** The run env, run token included. */
|
|
13
|
+
env: Record<string, string>;
|
|
14
|
+
workspacePath: string;
|
|
15
|
+
run: RuntimeRun;
|
|
16
|
+
/** The run clone's Git directory, mounted as `<workspace>/.git`; absent: the run has no Git. */
|
|
17
|
+
gitDir?: string;
|
|
18
|
+
/** A `shared` clone's parent object store, mounted read-only at its own path. */
|
|
19
|
+
sharedObjects?: string;
|
|
20
|
+
/** The harness id of the chosen agent (`claude`, `codex`, …). */
|
|
21
|
+
harness: string;
|
|
22
|
+
homePath?: string;
|
|
23
|
+
readPaths?: string[];
|
|
24
|
+
writePaths?: string[];
|
|
25
|
+
/** Mounted read-write after the home; each target lies inside `homePath`. */
|
|
26
|
+
bindPaths?: RunBind[];
|
|
27
|
+
}
|
|
28
|
+
export interface BbRuntime {
|
|
29
|
+
id: string;
|
|
30
|
+
/** Allocate a private home before the agent prepares its command and files. */
|
|
31
|
+
prepareRun?(run: RuntimeRun, agent: AgentRuntimeInfo): Promise<{
|
|
32
|
+
homePath: string;
|
|
33
|
+
env?: Record<string, string>;
|
|
34
|
+
}>;
|
|
35
|
+
/** Rewrite the launch; a rejection fails the dispatch, never falls back to the host. */
|
|
36
|
+
wrap(launch: RuntimeLaunch): Promise<{
|
|
37
|
+
command: string;
|
|
38
|
+
env: Record<string, string>;
|
|
39
|
+
}>;
|
|
40
|
+
/** Remove what `wrap` left for this run; called after each `cleanupRun`. */
|
|
41
|
+
cleanup(run: RuntimeRun): Promise<void>;
|
|
42
|
+
/** URL the run uses for the tool server, given the host URL; absent = unchanged. */
|
|
43
|
+
toolsUrl?(hostUrl: string): string;
|
|
44
|
+
/** Extra addresses the tool server also listens on; absent = 127.0.0.1 only. */
|
|
45
|
+
toolServerHosts?(): Promise<string[]>;
|
|
46
|
+
}
|
|
47
|
+
export interface RuntimePlugin {
|
|
48
|
+
readonly kind: 'runtime';
|
|
49
|
+
readonly id: string;
|
|
50
|
+
/** True when runs are isolated from the host; agent permissions remain unchanged. */
|
|
51
|
+
readonly isolates: boolean;
|
|
52
|
+
readonly requiredModules: string[];
|
|
53
|
+
createRuntime(config: ConductorFileConfig, deps: {
|
|
54
|
+
logger: ConductorLogger;
|
|
55
|
+
}): Promise<BbRuntime>;
|
|
56
|
+
}
|
|
57
|
+
/** The default: runs start on the host exactly as the executor launches them. */
|
|
58
|
+
export declare const hostRuntime: RuntimePlugin;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// The `runtime` slot: WHERE an agent process runs. The executor still decides
|
|
2
|
+
// in which client the run appears; the runtime rewrites the finished launch
|
|
3
|
+
// (for example into `docker run …`) just before `executor.startRun`.
|
|
4
|
+
/** The default: runs start on the host exactly as the executor launches them. */
|
|
5
|
+
export const hostRuntime = {
|
|
6
|
+
kind: 'runtime',
|
|
7
|
+
id: 'host',
|
|
8
|
+
isolates: false,
|
|
9
|
+
requiredModules: [],
|
|
10
|
+
createRuntime: async () => ({
|
|
11
|
+
id: 'host',
|
|
12
|
+
wrap: async ({ command, env }) => ({ command, env }),
|
|
13
|
+
cleanup: async () => { },
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
@@ -17,6 +17,7 @@ export interface SandboxHost {
|
|
|
17
17
|
stderr: string;
|
|
18
18
|
}>;
|
|
19
19
|
}
|
|
20
|
+
export declare function runtimeSandboxWarning(runtime?: string): string | undefined;
|
|
20
21
|
export declare function systemSandboxHost(env?: NodeJS.ProcessEnv): SandboxHost;
|
|
21
22
|
/** The last non-empty line of a probe's stderr: the error, after any warnings. */
|
|
22
23
|
export declare function lastLine(text: string): string;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
2
|
import { accessSync, constants } from 'node:fs';
|
|
3
3
|
import { delimiter, join } from 'node:path';
|
|
4
|
+
export function runtimeSandboxWarning(runtime = 'host') {
|
|
5
|
+
if (runtime === 'host')
|
|
6
|
+
return;
|
|
7
|
+
return `Sandbox preflight checks the host only; runtime ${runtime} is not checked. Sandbox tools and namespace support must be available inside the runtime; permissions remain unchanged.`;
|
|
8
|
+
}
|
|
4
9
|
export function systemSandboxHost(env = process.env) {
|
|
5
10
|
return {
|
|
6
11
|
platform: process.platform,
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import type { ConductorLogger } from '@bakers-build/core';
|
|
2
2
|
import { type MessageInput } from '@bakers-build/message';
|
|
3
|
+
import type { ConductorEngineConfig } from '../types.js';
|
|
3
4
|
import type { Ticket } from './remote.js';
|
|
5
|
+
export type AgentCatalog = Pick<ConductorEngineConfig, 'agents' | 'enabled_agents' | 'disabled_agents' | 'default_agent' | 'routes'>;
|
|
6
|
+
export interface ToolHost {
|
|
7
|
+
agentCatalog(): AgentCatalog;
|
|
8
|
+
}
|
|
9
|
+
/** A message input whose properties may also be lists of strings (argv). */
|
|
10
|
+
export type ToolInput = Omit<MessageInput, 'properties'> & {
|
|
11
|
+
properties: Record<string, MessageInput['properties'][string] | {
|
|
12
|
+
type: 'array';
|
|
13
|
+
items: {
|
|
14
|
+
type: 'string';
|
|
15
|
+
};
|
|
16
|
+
description?: string;
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
4
19
|
export interface ToolDefinition {
|
|
5
20
|
description: string;
|
|
6
21
|
/** Absent means a parameterless tool. Unknown arguments are refused. */
|
|
7
|
-
input?:
|
|
22
|
+
input?: ToolInput;
|
|
8
23
|
}
|
|
9
24
|
export interface ToolResult {
|
|
10
25
|
text: string;
|
|
@@ -31,7 +46,7 @@ export interface AddonTools {
|
|
|
31
46
|
contract: 1;
|
|
32
47
|
tools: Record<string, ToolDefinition>;
|
|
33
48
|
/** Lazy: imported only when the conductor loads the addon. */
|
|
34
|
-
handlers: (options?: unknown) => Promise<Record<string, ToolHandler>>;
|
|
49
|
+
handlers: (options?: unknown, host?: ToolHost) => Promise<Record<string, ToolHandler>>;
|
|
35
50
|
}
|
|
36
51
|
/** One `tools` export as discovery found it. */
|
|
37
52
|
export interface DiscoveredTools {
|
|
@@ -65,21 +80,29 @@ type ShellResult = {
|
|
|
65
80
|
/** Provisioning runs the conductor owns, one per worktree and command. */
|
|
66
81
|
export interface ProvisionRuns {
|
|
67
82
|
/** Joins the running command of this worktree, or starts it. */
|
|
68
|
-
run(worktreePath: string, command: string): Promise<ShellResult>;
|
|
83
|
+
run(worktreePath: string, command: string, env?: Record<string, string>): Promise<ShellResult>;
|
|
69
84
|
/** Kills the runs of one worktree, or all; resolves once they closed. */
|
|
70
85
|
stop(worktreePath?: string): Promise<void>;
|
|
71
86
|
}
|
|
72
87
|
export declare function provisionRuns(timeoutMs?: number): ProvisionRuns;
|
|
88
|
+
export interface ProvisionOptions {
|
|
89
|
+
/** `hooks.provision_exec`: commands by key. */
|
|
90
|
+
exec?: Record<string, string>;
|
|
91
|
+
/** Whether the runtime isolates runs; exported to every host command. */
|
|
92
|
+
isolates?: boolean;
|
|
93
|
+
}
|
|
73
94
|
/**
|
|
74
|
-
* The core `provision_up(profile?)`
|
|
75
|
-
*
|
|
76
|
-
*
|
|
95
|
+
* The core `provision_up(profile?)` and `provision_exec(key, args?)` tools,
|
|
96
|
+
* each offered only when its hook is set. The agent picks when, which
|
|
97
|
+
* configured profile or key, and the arguments, never the command. A
|
|
98
|
+
* `provision_up` command outlives its caller: the call's signal is ignored on
|
|
99
|
+
* purpose.
|
|
77
100
|
*/
|
|
78
|
-
export declare function provisionTools(hook: ProvisionHook | undefined, runs?: ProvisionRuns): DiscoveredTools[];
|
|
101
|
+
export declare function provisionTools(hook: ProvisionHook | undefined, runs?: ProvisionRuns, options?: ProvisionOptions): DiscoveredTools[];
|
|
79
102
|
/**
|
|
80
103
|
* Resolves every addon's handlers and checks that handlers and declared tools
|
|
81
104
|
* match one to one. A tool name declared by two addons is an error, so the
|
|
82
105
|
* conductor never starts with an ambiguous tool.
|
|
83
106
|
*/
|
|
84
|
-
export declare function loadTools(found: readonly DiscoveredTools[]): Promise<ToolRegistry>;
|
|
107
|
+
export declare function loadTools(found: readonly DiscoveredTools[], host?: ToolHost): Promise<ToolRegistry>;
|
|
85
108
|
export {};
|
|
@@ -10,13 +10,13 @@ const OUTPUT_CAP = 64 * 1024;
|
|
|
10
10
|
export function provisionRuns(timeoutMs = PROVISION_TIMEOUT_MS) {
|
|
11
11
|
const running = new Map();
|
|
12
12
|
return {
|
|
13
|
-
run(worktreePath, command) {
|
|
13
|
+
run(worktreePath, command, env) {
|
|
14
14
|
const key = JSON.stringify([worktreePath, command]);
|
|
15
15
|
const current = running.get(key);
|
|
16
16
|
if (current)
|
|
17
17
|
return current.done;
|
|
18
18
|
const abort = new AbortController();
|
|
19
|
-
const done = shell(command, worktreePath, abort.signal, timeoutMs);
|
|
19
|
+
const done = shell(command, worktreePath, abort.signal, timeoutMs, env);
|
|
20
20
|
running.set(key, { worktreePath, abort, done });
|
|
21
21
|
const forget = () => running.delete(key);
|
|
22
22
|
done.then(forget, forget);
|
|
@@ -31,15 +31,19 @@ export function provisionRuns(timeoutMs = PROVISION_TIMEOUT_MS) {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* The core `provision_up(profile?)`
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* The core `provision_up(profile?)` and `provision_exec(key, args?)` tools,
|
|
35
|
+
* each offered only when its hook is set. The agent picks when, which
|
|
36
|
+
* configured profile or key, and the arguments, never the command. A
|
|
37
|
+
* `provision_up` command outlives its caller: the call's signal is ignored on
|
|
38
|
+
* purpose.
|
|
37
39
|
*/
|
|
38
|
-
export function provisionTools(hook, runs = provisionRuns()) {
|
|
39
|
-
|
|
40
|
+
export function provisionTools(hook, runs = provisionRuns(), options = {}) {
|
|
41
|
+
const exec = options.exec ?? {};
|
|
42
|
+
if (hook === undefined && Object.keys(exec).length === 0)
|
|
40
43
|
return [];
|
|
41
44
|
const profiles = typeof hook === 'string' ? undefined : hook;
|
|
42
|
-
if (
|
|
45
|
+
if (hook !== undefined &&
|
|
46
|
+
typeof hook !== 'string' &&
|
|
43
47
|
(typeof hook !== 'object' ||
|
|
44
48
|
hook === null ||
|
|
45
49
|
Object.values(hook).some((cmd) => typeof cmd !== 'string')))
|
|
@@ -53,37 +57,53 @@ export function provisionTools(hook, runs = provisionRuns()) {
|
|
|
53
57
|
// The input schema's enum has already refused an unknown profile.
|
|
54
58
|
return profiles[String(profile)];
|
|
55
59
|
};
|
|
60
|
+
// What a host script needs instead of asking Git in a workspace without one.
|
|
61
|
+
const envFor = (worktreePath) => ({
|
|
62
|
+
BAKERS_WORKTREE_PATH: worktreePath,
|
|
63
|
+
BAKERS_RUNTIME_ISOLATES: options.isolates ? '1' : '0',
|
|
64
|
+
});
|
|
65
|
+
const report = ({ exitCode, output }) => {
|
|
66
|
+
const text = `exit ${exitCode}\n${output}`;
|
|
67
|
+
if (exitCode !== 0)
|
|
68
|
+
throw new Error(text);
|
|
69
|
+
return { text };
|
|
70
|
+
};
|
|
71
|
+
const tools = {};
|
|
72
|
+
const handlers = {};
|
|
73
|
+
if (hook !== undefined) {
|
|
74
|
+
tools.provision_up = {
|
|
75
|
+
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.`,
|
|
76
|
+
input: {
|
|
77
|
+
type: 'object',
|
|
78
|
+
properties: {
|
|
79
|
+
profile: profiles
|
|
80
|
+
? { type: 'string', enum: Object.keys(profiles) }
|
|
81
|
+
: { type: 'string' },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
// shortcut: inherits the conductor's env, not the run's BAKERS_* env; pass it through the binding once a hook needs it.
|
|
86
|
+
handlers.provision_up = async (req) => report(await runs.run(req.worktreePath, commandFor(req.args.profile), envFor(req.worktreePath)));
|
|
87
|
+
}
|
|
88
|
+
if (Object.keys(exec).length > 0) {
|
|
89
|
+
tools.provision_exec = {
|
|
90
|
+
description: `Run one of the project's configured commands (${Object.keys(exec).join(', ')}) for this worktree, such as a command in its site container. \`args\` reach the command as separate arguments after \`--\`, never through a shell. Returns the exit code and the output tail.`,
|
|
91
|
+
input: {
|
|
92
|
+
type: 'object',
|
|
93
|
+
required: ['key'],
|
|
94
|
+
properties: {
|
|
95
|
+
key: { type: 'string', enum: Object.keys(exec) },
|
|
96
|
+
args: { type: 'array', items: { type: 'string' } },
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
handlers.provision_exec = async (req) => report(await shell(`${exec[String(req.args.key)]} -- "$@"`, req.worktreePath, req.signal, PROVISION_TIMEOUT_MS, envFor(req.worktreePath), req.args.args ?? []));
|
|
101
|
+
}
|
|
56
102
|
return [
|
|
57
103
|
{
|
|
58
104
|
name: 'conductor',
|
|
59
105
|
version: '1',
|
|
60
|
-
tools: {
|
|
61
|
-
contract: 1,
|
|
62
|
-
tools: {
|
|
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. 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
|
-
input: {
|
|
66
|
-
type: 'object',
|
|
67
|
-
properties: {
|
|
68
|
-
profile: profiles
|
|
69
|
-
? { type: 'string', enum: Object.keys(profiles) }
|
|
70
|
-
: { type: 'string' },
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
handlers: async () => ({
|
|
76
|
-
provision_up: async (req) => {
|
|
77
|
-
const command = commandFor(req.args.profile);
|
|
78
|
-
// shortcut: inherits the conductor's env, not the run's BAKERS_* env; pass it through the binding once a hook needs it.
|
|
79
|
-
const { exitCode, output } = await runs.run(req.worktreePath, command);
|
|
80
|
-
const text = `exit ${exitCode}\n${output}`;
|
|
81
|
-
if (exitCode !== 0)
|
|
82
|
-
throw new Error(text);
|
|
83
|
-
return { text };
|
|
84
|
-
},
|
|
85
|
-
}),
|
|
86
|
-
},
|
|
106
|
+
tools: { contract: 1, tools, handlers: async () => handlers },
|
|
87
107
|
},
|
|
88
108
|
];
|
|
89
109
|
}
|
|
@@ -91,10 +111,12 @@ export function provisionTools(hook, runs = provisionRuns()) {
|
|
|
91
111
|
* `sh -c` with stdout and stderr interleaved, the tail kept. Its own process
|
|
92
112
|
* group, killed whole at the timeout or abort, so no child outlives it.
|
|
93
113
|
*/
|
|
94
|
-
function shell(command, cwd, signal, timeoutMs) {
|
|
114
|
+
function shell(command, cwd, signal, timeoutMs, env = {}, args = []) {
|
|
95
115
|
return new Promise((done, fail) => {
|
|
96
|
-
|
|
116
|
+
// `args` become "$@": positional parameters, never shell text.
|
|
117
|
+
const child = spawn('sh', ['-c', command, 'sh', ...args], {
|
|
97
118
|
cwd,
|
|
119
|
+
env: { ...process.env, ...env },
|
|
98
120
|
detached: true,
|
|
99
121
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
100
122
|
});
|
|
@@ -143,13 +165,13 @@ const silent = {
|
|
|
143
165
|
* match one to one. A tool name declared by two addons is an error, so the
|
|
144
166
|
* conductor never starts with an ambiguous tool.
|
|
145
167
|
*/
|
|
146
|
-
export async function loadTools(found) {
|
|
168
|
+
export async function loadTools(found, host) {
|
|
147
169
|
const entries = new Map();
|
|
148
170
|
for (const addon of found) {
|
|
149
171
|
const fail = (msg) => new Error(`addon ${addon.name}: ${msg}`);
|
|
150
172
|
if (addon.tools.contract !== 1)
|
|
151
173
|
throw fail(`unsupported tools contract ${addon.tools.contract}`);
|
|
152
|
-
const handlers = await addon.tools.handlers(addon.options);
|
|
174
|
+
const handlers = await addon.tools.handlers(addon.options, host);
|
|
153
175
|
for (const [name, def] of Object.entries(addon.tools.tools)) {
|
|
154
176
|
const handler = handlers[name];
|
|
155
177
|
if (typeof handler !== 'function')
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RunClone } from '@bakers-build/core';
|
|
1
2
|
import type { WorktreeTeardown } from './executor.js';
|
|
2
3
|
export interface EnsuredWorkspace {
|
|
3
4
|
path: string;
|
|
@@ -20,6 +21,12 @@ export interface EnsuredWorkspace {
|
|
|
20
21
|
* keys still win.
|
|
21
22
|
*/
|
|
22
23
|
env?: Record<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Set when the workspace is a fresh clone for an isolated run instead of a
|
|
26
|
+
* linked worktree: its Git directory lies outside `path`, which has no
|
|
27
|
+
* `.git` on the host.
|
|
28
|
+
*/
|
|
29
|
+
clone?: RunClone;
|
|
23
30
|
}
|
|
24
31
|
export interface BbWorkspace {
|
|
25
32
|
/**
|
package/dist/src/types.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { HookListener } from './plugins/executor.js';
|
|
|
7
7
|
import type { LoadedInbox } from './plugins/message.js';
|
|
8
8
|
import type { AgentCandidate, ExecutorPlugin, RemotePlugin, ResolvedAgent, WorkspacePlugin } from './plugins/plugins.js';
|
|
9
9
|
import type { Ticket } from './plugins/remote.js';
|
|
10
|
+
import type { RuntimePlugin } from './plugins/runtime.js';
|
|
10
11
|
import type { ProvisionHook, ProvisionRuns, ToolRegistry } from './plugins/tools.js';
|
|
11
12
|
/** Normalized single conductor. */
|
|
12
13
|
export interface ConductorSettings {
|
|
@@ -69,6 +70,8 @@ export interface ConductorSettings {
|
|
|
69
70
|
on_resume?: string;
|
|
70
71
|
/** Never runs on its own: offered to runs as the `provision_up(profile?)` tool. */
|
|
71
72
|
provision_up?: ProvisionHook;
|
|
73
|
+
/** Never runs on its own: offered to runs as the `provision_exec(key, args?)` tool. */
|
|
74
|
+
provision_exec?: Record<string, string>;
|
|
72
75
|
};
|
|
73
76
|
/** Control-plane site settings used for dropsh and agent env. */
|
|
74
77
|
site: {
|
|
@@ -87,6 +90,17 @@ export interface ConductorSettings {
|
|
|
87
90
|
files: string[];
|
|
88
91
|
dirs: string[];
|
|
89
92
|
};
|
|
93
|
+
/** Where each slot's plugin came from, for `bakers conductor check`. */
|
|
94
|
+
slot_sources?: Partial<SlotSources>;
|
|
95
|
+
/** The package each slot named with `use`; addon-discovered slots have none. */
|
|
96
|
+
slot_packages?: Partial<Record<keyof SlotSources, string>>;
|
|
97
|
+
}
|
|
98
|
+
/** Where a resolved server, executor or worktree plugin came from. */
|
|
99
|
+
export type SlotSource = 'machine' | 'slot' | 'addons' | 'connection' | 'default';
|
|
100
|
+
export interface SlotSources {
|
|
101
|
+
server: SlotSource;
|
|
102
|
+
executor: SlotSource;
|
|
103
|
+
worktree: SlotSource;
|
|
90
104
|
}
|
|
91
105
|
/** Whole project.config.js (dropsh-superset): site + named plugin slots. */
|
|
92
106
|
export interface ConductorFileConfig extends ConductorSettings {
|
|
@@ -103,6 +117,10 @@ export interface ConductorFileConfig extends ConductorSettings {
|
|
|
103
117
|
/** Replaces the shipped label/default resolution for this project. */
|
|
104
118
|
selectAgent?: (candidates: ResolvedAgent[], ticket: Ticket) => ResolvedAgent;
|
|
105
119
|
workspace: WorkspacePlugin;
|
|
120
|
+
/** Where agent processes run (the `runtime` slot); absent means on the host. */
|
|
121
|
+
runtime?: RuntimePlugin;
|
|
122
|
+
/** The project's `runtime.read_only`: paths an isolated run sees read-only. */
|
|
123
|
+
readOnly?: string[];
|
|
106
124
|
/** The project's agent plugin marketplaces; empty when it declares none. */
|
|
107
125
|
marketplaces: MarketplaceDeclaration[];
|
|
108
126
|
/**
|
|
@@ -131,4 +149,7 @@ export interface ConductorFileConfig extends ConductorSettings {
|
|
|
131
149
|
* command composes it with the connection (`composeConductorConfig`) into the
|
|
132
150
|
* full `ConductorFileConfig` the engine consumes.
|
|
133
151
|
*/
|
|
134
|
-
export type ConductorEngineConfig = Omit<ConductorFileConfig, 'site' | 'plugins'
|
|
152
|
+
export type ConductorEngineConfig = Omit<ConductorFileConfig, 'site' | 'plugins' | 'remote'> & {
|
|
153
|
+
/** Absent when the project names no server; the connection or the default fills it. */
|
|
154
|
+
remote?: RemotePlugin;
|
|
155
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/conductor",
|
|
3
|
-
"version": "0.9.1-next.
|
|
3
|
+
"version": "0.9.1-next.6",
|
|
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.9.1-next.
|
|
36
|
-
"@bakers-build/message": "^0.9.1-next.
|
|
35
|
+
"@bakers-build/core": "^0.9.1-next.6",
|
|
36
|
+
"@bakers-build/message": "^0.9.1-next.6",
|
|
37
37
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
38
38
|
"commander": "^12.1.0",
|
|
39
39
|
"dropsh": "^0.8.2"
|
|
40
40
|
},
|
|
41
41
|
"bakersBuild": {
|
|
42
|
-
"commit": "
|
|
42
|
+
"commit": "e7d9921d51d5c045f29ca7e35d1e6a348e6ddf08",
|
|
43
43
|
"channel": "next"
|
|
44
44
|
}
|
|
45
45
|
}
|