@bakers-build/addon-codex 0.6.1-next.2 → 0.6.1-next.3
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/index.d.ts +2 -1
- package/dist/src/index.js +17 -29
- package/package.json +4 -4
package/dist/src/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare class CodexAgent implements BbAgent {
|
|
|
22
22
|
private readonly effort;
|
|
23
23
|
private readonly overrides;
|
|
24
24
|
private readonly security;
|
|
25
|
+
private readonly allowWrite;
|
|
25
26
|
readonly runEnvPolicy: RunEnvPolicy;
|
|
26
27
|
constructor(options?: CodexAgentOptions, home?: string);
|
|
27
28
|
/** The launch flags a security mode owns (`docs/addons/codex.md`). */
|
|
@@ -29,7 +30,7 @@ export declare class CodexAgent implements BbAgent {
|
|
|
29
30
|
private userMcpServers;
|
|
30
31
|
launchCommand(prompt: string, _run?: AgentRunIdentity, workspacePath?: string, tools?: {
|
|
31
32
|
url: string;
|
|
32
|
-
}): string;
|
|
33
|
+
}, env?: Readonly<Record<string, string>>): string;
|
|
33
34
|
getRunLog(worktreePath: string, run?: AgentRunIdentity): Promise<string>;
|
|
34
35
|
parseFootprint(log: string): AgentFootprint;
|
|
35
36
|
/** Codex brings its own sandbox runner; a missing binary fails at launch as before. */
|
package/dist/src/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
1
|
import { readFileSync } from 'node:fs';
|
|
3
2
|
import { readdir, readFile, stat } from 'node:fs/promises';
|
|
4
3
|
import { homedir } from 'node:os';
|
|
5
4
|
import { join } from 'node:path';
|
|
6
5
|
import { CONDUCTOR_TOKEN_ENV, CONDUCTOR_TOOLS_SERVER, lastLine, resolveAgentCliOptions, resolveSecurityOptions, systemSandboxHost, } from '@bakers-build/conductor/contract';
|
|
7
|
-
import { shellQuote } from '@bakers-build/core';
|
|
6
|
+
import { gitSandboxPaths, shellQuote, withoutGitDirs, } from '@bakers-build/core';
|
|
8
7
|
import { parseCodexTranscript } from './footprint.js';
|
|
9
8
|
export { parseCodexTranscript } from './footprint.js';
|
|
10
9
|
const CODEX_RESERVED = [
|
|
@@ -102,6 +101,7 @@ export class CodexAgent {
|
|
|
102
101
|
effort;
|
|
103
102
|
overrides;
|
|
104
103
|
security;
|
|
104
|
+
allowWrite;
|
|
105
105
|
runEnvPolicy;
|
|
106
106
|
constructor(options = {}, home = homedir()) {
|
|
107
107
|
this.home = home;
|
|
@@ -112,6 +112,7 @@ export class CodexAgent {
|
|
|
112
112
|
this.overrides = cli.overrides;
|
|
113
113
|
this.security = resolveSecurityOptions(options, SANDBOX_DEFAULTS);
|
|
114
114
|
this.runEnvPolicy = this.security.runEnvPolicy;
|
|
115
|
+
this.allowWrite = withoutGitDirs(this.security.sandbox.allow_write);
|
|
115
116
|
// Codex has no read deny or unsandboxed-command list to map these onto.
|
|
116
117
|
for (const key of ['trusted_commands', 'deny_read']) {
|
|
117
118
|
if (this.security.sandbox[key].length > 0) {
|
|
@@ -146,35 +147,15 @@ export class CodexAgent {
|
|
|
146
147
|
]);
|
|
147
148
|
if (mode === 'custom')
|
|
148
149
|
return pairs(Object.entries(config ?? {}));
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
const git = spawnSync('git', ['-C', workspacePath, 'rev-parse', '--path-format=absolute', option], { encoding: 'utf8', env: { ...process.env, LC_ALL: 'C' } });
|
|
152
|
-
if (git.error)
|
|
153
|
-
throw git.error;
|
|
154
|
-
if (git.status !== 0) {
|
|
155
|
-
if (git.stderr.includes('not a git repository'))
|
|
156
|
-
break;
|
|
157
|
-
throw new Error(`Cannot resolve Codex workspace Git directories: ${git.stderr.trim()}`);
|
|
158
|
-
}
|
|
159
|
-
gitDirs.add(git.stdout.replace(/\r?\n$/, ''));
|
|
160
|
-
}
|
|
161
|
-
const roots = sandbox.allow_write.map((dir) => `${JSON.stringify(dir.startsWith('~/') ? join(this.home, dir.slice(2)) : dir)} = true`);
|
|
150
|
+
const git = gitSandboxPaths(workspacePath);
|
|
151
|
+
const roots = this.allowWrite.map((dir) => `${JSON.stringify(dir.startsWith('~/') ? join(this.home, dir.slice(2)) : dir)} = true`);
|
|
162
152
|
// Filesystem overrides replace inherited entries, so retain workspace protections explicitly.
|
|
163
153
|
const filesystem = [
|
|
164
154
|
'":workspace_roots" = { ".git" = "read", ".agents" = "read", ".codex" = "read", ".aws" = "read" }',
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
'config',
|
|
170
|
-
'config.worktree',
|
|
171
|
-
'hooks',
|
|
172
|
-
'commondir',
|
|
173
|
-
'gitdir',
|
|
174
|
-
'modules',
|
|
175
|
-
'worktrees',
|
|
176
|
-
].map((name) => `${JSON.stringify(join(dir, name))} = "read"`),
|
|
177
|
-
]),
|
|
155
|
+
// Codex mounts a read-only `.git`, `.agents`, `.codex` and `.aws` into every
|
|
156
|
+
// writable entry and creates each missing one; inside Git metadata, grant them.
|
|
157
|
+
...git.write.flatMap((path) => ['', '/.git', '/.agents', '/.codex', '/.aws'].map((name) => `${JSON.stringify(path + name)} = "write"`)),
|
|
158
|
+
...git.protect.map((path) => `${JSON.stringify(path)} = "read"`),
|
|
178
159
|
];
|
|
179
160
|
const profile = `{ extends = ":workspace", filesystem = { ${filesystem.join(', ')} }, workspace_roots = { ${roots.join(', ')} }, network = { enabled = ${sandbox.network.length > 0} } }`;
|
|
180
161
|
const flags = [
|
|
@@ -205,10 +186,17 @@ export class CodexAgent {
|
|
|
205
186
|
}
|
|
206
187
|
return codexMcpServerIds(toml);
|
|
207
188
|
}
|
|
208
|
-
launchCommand(prompt, _run, workspacePath = process.cwd(), tools) {
|
|
189
|
+
launchCommand(prompt, _run, workspacePath = process.cwd(), tools, env = {}) {
|
|
209
190
|
// Quote at assembly; a plain word has nothing for the shell to expand.
|
|
210
191
|
const word = (t) => (/^[\w./=-]+$/.test(t) ? t : shellQuote(t));
|
|
211
192
|
const parts = ['codex', ...this.securityFlags(workspacePath).map(word)];
|
|
193
|
+
// Codex's default shell env filter drops `*KEY*` names; without its key a
|
|
194
|
+
// `GIT_CONFIG_COUNT` entry makes every git call fail.
|
|
195
|
+
for (const [name, value] of Object.entries(env)) {
|
|
196
|
+
if (/^GIT_CONFIG_KEY_\d+$/.test(name)) {
|
|
197
|
+
parts.push('-c', word(`shell_environment_policy.set.${name}=${JSON.stringify(value)}`));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
212
200
|
if (tools) {
|
|
213
201
|
// Codex reads the token from the run env, so it never enters argv.
|
|
214
202
|
const server = `mcp_servers.${CONDUCTOR_TOOLS_SERVER}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/addon-codex",
|
|
3
|
-
"version": "0.6.1-next.
|
|
3
|
+
"version": "0.6.1-next.3",
|
|
4
4
|
"description": "bakers.build agent plugin for the Codex CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"directory": "bakers-cli/addons/codex"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@bakers-build/conductor": "^0.6.1-next.
|
|
24
|
-
"@bakers-build/core": "^0.6.1-next.
|
|
23
|
+
"@bakers-build/conductor": "^0.6.1-next.3",
|
|
24
|
+
"@bakers-build/core": "^0.6.1-next.3"
|
|
25
25
|
},
|
|
26
26
|
"bakersBuild": {
|
|
27
|
-
"commit": "
|
|
27
|
+
"commit": "1531a0bb0d34ccf6b54a051fcb8b016902c31f0f",
|
|
28
28
|
"channel": "next"
|
|
29
29
|
}
|
|
30
30
|
}
|