@bakers-build/addon-runtime-docker 0.10.1-next.11 → 0.10.1-next.12

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.
@@ -15,10 +15,13 @@ export interface RuntimeDockerOptions {
15
15
  shared?: boolean;
16
16
  }
17
17
  export interface BackendDeps {
18
- exec(file: string, args: string[]): Promise<{
18
+ /** `opts.env` is merged over the conductor's env for that one command. */
19
+ exec(file: string, args: string[], opts?: {
20
+ env?: Record<string, string>;
21
+ }): Promise<{
19
22
  stdout: string;
20
23
  }>;
21
- /** The conductor's own environment (the model credential lives here). */
24
+ /** The conductor's own environment; the credential source without `agent.secrets`. */
22
25
  env: Record<string, string | undefined>;
23
26
  logger: ConductorLogger;
24
27
  /** The bakers CLI build, mounted read-only at its host path. */
@@ -10,7 +10,7 @@ const EGRESS_NETWORK = 'bb-runtime-egress';
10
10
  /** The first 12 hex chars of the sha256 of `text`. */
11
11
  export const shortHash = (text) => createHash('sha256').update(text).digest('hex').slice(0, 12);
12
12
  const run = promisify(execFile);
13
- export const realExec = (file, args) => run(file, args);
13
+ export const realExec = (file, args, opts) => run(file, args, opts?.env ? { env: { ...process.env, ...opts.env } } : {});
14
14
  export function dockerRuntime(options, deps) {
15
15
  const docker = options.docker ?? 'docker';
16
16
  const opts = {
@@ -82,6 +82,7 @@ export function dockerRuntime(options, deps) {
82
82
  return;
83
83
  if (current !== undefined)
84
84
  await deps.exec(docker, ['rm', '-f', proxyName]);
85
+ // Names in argv, values in the docker CLI's env: argv is visible in ps.
85
86
  await deps.exec(docker, [
86
87
  'run',
87
88
  '-d',
@@ -93,7 +94,7 @@ export function dockerRuntime(options, deps) {
93
94
  `build.bakers.proxy=${hash}`,
94
95
  '--network',
95
96
  EGRESS_NETWORK,
96
- ...credentials.flatMap((k) => ['-e', k]),
97
+ ...Object.keys(credentials).flatMap((k) => ['-e', k]),
97
98
  '-e',
98
99
  `BB_ALLOW=${(options.allow ?? []).join(',')}`,
99
100
  '-e',
@@ -105,15 +106,19 @@ export function dockerRuntime(options, deps) {
105
106
  image,
106
107
  'node',
107
108
  '/opt/bb-runtime/proxy.mjs',
108
- ]);
109
+ ], { env: credentials });
109
110
  await deps.exec(docker, ['network', 'connect', opts.runNetwork, proxyName]);
110
111
  };
111
112
  const credentialsFor = (agent) => {
112
113
  const api = agent.modelApi;
113
114
  if (allowlist && !api)
114
115
  throw new Error('runtime-docker: allowlist mode requires model API metadata');
115
- const credentials = Object.keys(api?.auth ?? {}).filter((k) => deps.env[k]);
116
- if (api && credentials.length === 0)
116
+ const source = agent.secrets ?? deps.env;
117
+ const credentials = {};
118
+ for (const k of Object.keys(api?.auth ?? {}))
119
+ if (source[k])
120
+ credentials[k] = source[k];
121
+ if (api && Object.keys(credentials).length === 0)
117
122
  throw new Error(`runtime-docker: ${api.credentialHint}`);
118
123
  return credentials;
119
124
  };
@@ -125,7 +130,7 @@ export function dockerRuntime(options, deps) {
125
130
  mkdirSync(homePath, { recursive: true, mode: 0o700 });
126
131
  const env = allowlist
127
132
  ? { [agent.modelApi.keyEnv]: API_KEY_PLACEHOLDER }
128
- : Object.fromEntries(credentials.map((k) => [k, deps.env[k]]));
133
+ : credentials;
129
134
  return { homePath, env };
130
135
  },
131
136
  async wrap(launch) {
@@ -211,8 +216,7 @@ export function dockerRuntime(options, deps) {
211
216
  const env = { ...launch.env };
212
217
  // Allowlist mode: the credential stays with the proxy sidecar.
213
218
  if (!allowlist)
214
- for (const k of credentials)
215
- env[k] = deps.env[k];
219
+ Object.assign(env, credentials);
216
220
  const { argv, env: runEnv } = dockerArgs({ ...launch, env }, { ...opts, image }, {
217
221
  ...(runGitDir ? { runGitDir } : {}),
218
222
  ...(launch.sharedObjects
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/addon-runtime-docker",
3
- "version": "0.10.1-next.11",
3
+ "version": "0.10.1-next.12",
4
4
  "description": "Start each agent run in its own Docker or Podman container.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,11 +23,11 @@
23
23
  "directory": "bakers-cli/addons/runtime-docker"
24
24
  },
25
25
  "peerDependencies": {
26
- "@bakers-build/conductor": "^0.10.1-next.11",
27
- "@bakers-build/core": "^0.10.1-next.11"
26
+ "@bakers-build/conductor": "^0.10.1-next.12",
27
+ "@bakers-build/core": "^0.10.1-next.12"
28
28
  },
29
29
  "bakersBuild": {
30
- "commit": "a17110983f32ae027848c103b31ddb07fbf21a8e",
30
+ "commit": "460f5570442a0b09af52a1d4450b879075302e57",
31
31
  "channel": "next"
32
32
  }
33
33
  }