@bakers-build/addon-runtime-docker 0.10.1-next.8 → 0.11.0
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/args.js +32 -0
- package/dist/src/backend.d.ts +5 -2
- package/dist/src/backend.js +12 -8
- package/package.json +5 -5
package/dist/src/args.js
CHANGED
|
@@ -3,6 +3,37 @@ export const RUN_PATH = `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin
|
|
|
3
3
|
export const PROXY_PORTS = { egress: 3128, api: 8081, tools: 8082 };
|
|
4
4
|
/** What the run sends as its API key in allowlist mode; the proxy swaps in the real one. */
|
|
5
5
|
export const API_KEY_PLACEHOLDER = 'bb-runtime-placeholder';
|
|
6
|
+
/**
|
|
7
|
+
* The pane's terminal and locale variables, passed by name so the docker client
|
|
8
|
+
* forwards only those set in its shell. Docker has no wildcard, hence the glibc
|
|
9
|
+
* `LC_*` categories. shortcut: kept apart from runtime-bwrap's regex, move into
|
|
10
|
+
* core if a third runtime needs it.
|
|
11
|
+
*/
|
|
12
|
+
const TERMINAL = [
|
|
13
|
+
'TERM',
|
|
14
|
+
'COLORTERM',
|
|
15
|
+
'TERM_PROGRAM',
|
|
16
|
+
'TERM_PROGRAM_VERSION',
|
|
17
|
+
'LANG',
|
|
18
|
+
'LANGUAGE',
|
|
19
|
+
'NO_COLOR',
|
|
20
|
+
'FORCE_COLOR',
|
|
21
|
+
...[
|
|
22
|
+
'ALL',
|
|
23
|
+
'CTYPE',
|
|
24
|
+
'NUMERIC',
|
|
25
|
+
'TIME',
|
|
26
|
+
'COLLATE',
|
|
27
|
+
'MONETARY',
|
|
28
|
+
'MESSAGES',
|
|
29
|
+
'PAPER',
|
|
30
|
+
'NAME',
|
|
31
|
+
'ADDRESS',
|
|
32
|
+
'TELEPHONE',
|
|
33
|
+
'MEASUREMENT',
|
|
34
|
+
'IDENTIFICATION',
|
|
35
|
+
].map((category) => `LC_${category}`),
|
|
36
|
+
];
|
|
6
37
|
/** Keys whose host value means nothing inside the container. */
|
|
7
38
|
const HOST_ONLY = (key) => key === 'PATH' ||
|
|
8
39
|
key === 'HOME' ||
|
|
@@ -36,6 +67,7 @@ export function dockerArgs(input, opts, where) {
|
|
|
36
67
|
!overridden.has(k) &&
|
|
37
68
|
// Allowlist mode keeps the model credential in the proxy only.
|
|
38
69
|
!(allowlist && credentials.includes(k)));
|
|
70
|
+
forwarded.push(...TERMINAL.filter((k) => !forwarded.includes(k)));
|
|
39
71
|
const ro = (path) => bind(path, path, ':ro');
|
|
40
72
|
const argv = [
|
|
41
73
|
opts.docker,
|
package/dist/src/backend.d.ts
CHANGED
|
@@ -15,10 +15,13 @@ export interface RuntimeDockerOptions {
|
|
|
15
15
|
shared?: boolean;
|
|
16
16
|
}
|
|
17
17
|
export interface BackendDeps {
|
|
18
|
-
|
|
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
|
|
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. */
|
package/dist/src/backend.js
CHANGED
|
@@ -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
|
|
116
|
-
|
|
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
|
-
:
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "0.11.0",
|
|
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.
|
|
27
|
-
"@bakers-build/core": "^0.
|
|
26
|
+
"@bakers-build/conductor": "^0.11.0",
|
|
27
|
+
"@bakers-build/core": "^0.11.0"
|
|
28
28
|
},
|
|
29
29
|
"bakersBuild": {
|
|
30
|
-
"commit": "
|
|
31
|
-
"channel": "
|
|
30
|
+
"commit": "4e1d1a59439a6a0019f3b5b213d9cc9f09d14381",
|
|
31
|
+
"channel": "latest"
|
|
32
32
|
}
|
|
33
33
|
}
|