@bakers-build/addon-codex 0.10.1-next.4 → 0.10.1-next.5
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 +4 -0
- package/dist/src/run.d.ts +3 -0
- package/dist/src/run.js +67 -0
- package/package.json +4 -4
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentFootprint, type AgentPlugin, type AgentRunIdentity, type BbAgent, type MarketplaceDeclaration, type PluginLaunch, type ResolvedSecurity, type RunEnvPolicy, type SandboxHost, type SandboxPreflight, type SecurityOptions } from '@bakers-build/conductor/contract';
|
|
1
|
+
import { type AgentFootprint, type AgentPlugin, type AgentRunContext, type AgentRunIdentity, type BbAgent, type MarketplaceDeclaration, type PluginLaunch, type ResolvedSecurity, type RunEnvPolicy, type SandboxHost, type SandboxPreflight, type SecurityOptions } from '@bakers-build/conductor/contract';
|
|
2
2
|
export { parseCodexTranscript } from './footprint.js';
|
|
3
3
|
export interface CodexAgentOptions extends SecurityOptions {
|
|
4
4
|
model?: string;
|
|
@@ -44,6 +44,7 @@ export declare class CodexAgent implements BbAgent {
|
|
|
44
44
|
/** Point this agent at the agent home of the project's declared marketplaces. */
|
|
45
45
|
useMarketplaces(marketplaces: readonly MarketplaceDeclaration[]): void;
|
|
46
46
|
installPlugins(marketplaces: readonly MarketplaceDeclaration[], home: string): Promise<PluginLaunch>;
|
|
47
|
+
prepareRun(context: AgentRunContext): import("@bakers-build/conductor/contract").AgentRunPreparation;
|
|
47
48
|
/** A `config.toml` server the conductor's own replaces, named once per dispatch. */
|
|
48
49
|
get launchWarnings(): readonly string[];
|
|
49
50
|
/** The launch flags a security mode owns (`docs/addons/codex.md`). */
|
package/dist/src/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { promisify } from 'node:util';
|
|
|
8
8
|
import { CONDUCTOR_TOKEN_ENV, CONDUCTOR_TOOL_TIMEOUT_MS, CONDUCTOR_TOOLS_SERVER, ensureHome, homeKey, homePath, lastLine, resolveAgentCliOptions, resolveSecurityOptions, systemSandboxHost, validateOptionalBoolean, } from '@bakers-build/conductor/contract';
|
|
9
9
|
import { gitSandboxPaths, shellQuote, withoutGitDirs, } from '@bakers-build/core';
|
|
10
10
|
import { parseCodexTranscript } from './footprint.js';
|
|
11
|
+
import { prepareCodexRun } from './run.js';
|
|
11
12
|
export { parseCodexTranscript } from './footprint.js';
|
|
12
13
|
const run = promisify(execFile);
|
|
13
14
|
/** Run `codex <args>` in `codexHome`; a failure names `what` and the CLI's output. */
|
|
@@ -220,6 +221,9 @@ export class CodexAgent {
|
|
|
220
221
|
trust_bypass: ['hook trust'],
|
|
221
222
|
};
|
|
222
223
|
}
|
|
224
|
+
prepareRun(context) {
|
|
225
|
+
return prepareCodexRun(context, this.configDir);
|
|
226
|
+
}
|
|
223
227
|
/** A `config.toml` server the conductor's own replaces, named once per dispatch. */
|
|
224
228
|
get launchWarnings() {
|
|
225
229
|
return this.userMcpServers().includes(CONDUCTOR_TOOLS_SERVER)
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AgentRunContext, AgentRunPreparation } from '@bakers-build/conductor/contract';
|
|
2
|
+
/** Prepare Codex's files in the home supplied by any execution backend. */
|
|
3
|
+
export declare function prepareCodexRun(context: AgentRunContext, configDir: string, hostEnv?: Readonly<Record<string, string | undefined>>): AgentRunPreparation;
|
package/dist/src/run.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, readdirSync, realpathSync, symlinkSync, writeFileSync, } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
/** Entries prepared below, and those Codex writes while it runs. */
|
|
4
|
+
const NOT_LINKED = new Set([
|
|
5
|
+
'auth.json',
|
|
6
|
+
'sessions',
|
|
7
|
+
'config.toml',
|
|
8
|
+
'rules',
|
|
9
|
+
'log',
|
|
10
|
+
'shell_snapshots',
|
|
11
|
+
'tmp',
|
|
12
|
+
]);
|
|
13
|
+
/** Prepare Codex's files in the home supplied by any execution backend. */
|
|
14
|
+
export function prepareCodexRun(context, configDir, hostEnv = process.env) {
|
|
15
|
+
const source = context.env.CODEX_HOME ?? configDir;
|
|
16
|
+
const home = join(context.homePath, '.codex');
|
|
17
|
+
mkdirSync(home, { recursive: true });
|
|
18
|
+
// Transcripts land in the source home, where the conductor reads them.
|
|
19
|
+
const sessions = join(source, 'sessions');
|
|
20
|
+
mkdirSync(sessions, { recursive: true });
|
|
21
|
+
symlinkSync(sessions, join(home, 'sessions'));
|
|
22
|
+
// Writable copies: Codex records project trust in config.toml, skips linked
|
|
23
|
+
// .rules files, and the trusted-commands launcher adds a rule beside them.
|
|
24
|
+
if (existsSync(join(source, 'config.toml')))
|
|
25
|
+
copyFileSync(join(source, 'config.toml'), join(home, 'config.toml'));
|
|
26
|
+
if (existsSync(join(source, 'rules')))
|
|
27
|
+
cpSync(join(source, 'rules'), join(home, 'rules'), {
|
|
28
|
+
recursive: true,
|
|
29
|
+
dereference: true,
|
|
30
|
+
});
|
|
31
|
+
// Directories (plugins, marketplaces, skills) are shared read-only, each on
|
|
32
|
+
// its own: the runtimes refuse a write path inside a read path.
|
|
33
|
+
// shortcut: files such as the state DB and history start empty in the
|
|
34
|
+
// private home and are discarded with it; link one if it must persist.
|
|
35
|
+
const readPaths = [];
|
|
36
|
+
for (const name of readdirSync(source)) {
|
|
37
|
+
const path = join(source, name);
|
|
38
|
+
if (NOT_LINKED.has(name) || !lstatSync(path).isDirectory())
|
|
39
|
+
continue;
|
|
40
|
+
symlinkSync(path, join(home, name));
|
|
41
|
+
readPaths.push(path);
|
|
42
|
+
}
|
|
43
|
+
const keys = ['CODEX_API_KEY', 'OPENAI_API_KEY'];
|
|
44
|
+
const env = { CODEX_HOME: home };
|
|
45
|
+
const bindPaths = [];
|
|
46
|
+
if (!keys.some((key) => context.env[key])) {
|
|
47
|
+
const key = keys.find((name) => hostEnv[name]);
|
|
48
|
+
if (key)
|
|
49
|
+
env[key] = hostEnv[key];
|
|
50
|
+
else if (existsSync(join(source, 'auth.json'))) {
|
|
51
|
+
// The run shares the host's login file, never a copy: a refresh in one
|
|
52
|
+
// copy rotates the token and logs every other copy out.
|
|
53
|
+
const login = join(home, 'auth.json');
|
|
54
|
+
writeFileSync(login, '', { mode: 0o600 });
|
|
55
|
+
bindPaths.push({
|
|
56
|
+
source: realpathSync(join(source, 'auth.json')),
|
|
57
|
+
target: login,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
env,
|
|
63
|
+
readPaths,
|
|
64
|
+
writePaths: [sessions],
|
|
65
|
+
...(bindPaths.length ? { bindPaths } : {}),
|
|
66
|
+
};
|
|
67
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/addon-codex",
|
|
3
|
-
"version": "0.10.1-next.
|
|
3
|
+
"version": "0.10.1-next.5",
|
|
4
4
|
"description": "bakers.build agent plugin for the Codex CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"directory": "bakers-cli/addons/codex"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@bakers-build/conductor": "^0.10.1-next.
|
|
26
|
-
"@bakers-build/core": "^0.10.1-next.
|
|
25
|
+
"@bakers-build/conductor": "^0.10.1-next.5",
|
|
26
|
+
"@bakers-build/core": "^0.10.1-next.5"
|
|
27
27
|
},
|
|
28
28
|
"bakersBuild": {
|
|
29
|
-
"commit": "
|
|
29
|
+
"commit": "25319ae2b9b63c102ea4e73efd55f6e6ac27b921",
|
|
30
30
|
"channel": "next"
|
|
31
31
|
}
|
|
32
32
|
}
|