@sabaiway/agent-workflow-kit 23.0.0 → 23.1.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/CHANGELOG.md +24 -0
- package/SKILL.md +1 -1
- package/bridges/antigravity-cli-bridge/SKILL.md +11 -10
- package/bridges/antigravity-cli-bridge/bin/agy-jev.test.mjs +56 -7
- package/bridges/antigravity-cli-bridge/bin/agy-review.sh +80 -62
- package/bridges/antigravity-cli-bridge/bin/agy-review.test.mjs +0 -21
- package/bridges/antigravity-cli-bridge/bin/agy.sh +86 -12
- package/bridges/antigravity-cli-bridge/capability.json +2 -2
- package/bridges/antigravity-cli-bridge/references/models-and-flags.md +3 -3
- package/bridges/antigravity-cli-bridge/setup/README.md +1 -1
- package/bridges/codex-cli-bridge/SKILL.md +23 -24
- package/bridges/codex-cli-bridge/bin/codex-exec-jev.test.mjs +82 -47
- package/bridges/codex-cli-bridge/bin/codex-exec.sh +133 -52
- package/bridges/codex-cli-bridge/bin/codex-review-jev.test.mjs +44 -14
- package/bridges/codex-cli-bridge/bin/codex-review.sh +103 -30
- package/bridges/codex-cli-bridge/capability.json +6 -6
- package/bridges/codex-cli-bridge/references/driving-codex.md +6 -7
- package/bridges/codex-cli-bridge/references/sandbox-and-flags.md +8 -11
- package/bridges/codex-cli-bridge/setup/README.md +3 -3
- package/capability.json +1 -1
- package/package.json +1 -1
- package/tools/detect-backends.mjs +22 -14
- package/tools/services/index.mjs +5 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: codex-cli-bridge
|
|
3
3
|
description: Delegate work to the OpenAI Codex CLI (`codex`) under a ChatGPT subscription — run plan/instruction EXECUTION in a sandboxed workspace, or get a read-only ADVISORY review of a plan or working-tree diff — as a second delegated-execution backend beside Antigravity. Use when the user wants to hand a bounded coding task or plan to `codex exec`, get a second-opinion review from codex, install or authenticate Codex CLI, understand its sandbox/network/approval policy, drive codex efficiently from the main agent (exec vs review, resume, the commit boundary), bridge project context (`AGENTS.md`) into codex, or troubleshoot codex flags, models, auth, or its no-TTY headless behaviour.
|
|
4
4
|
metadata:
|
|
5
|
-
version: '
|
|
5
|
+
version: '6.0.0'
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# codex-cli-bridge
|
|
@@ -19,7 +19,7 @@ or a working-tree diff and only emits findings (`codex-review`).
|
|
|
19
19
|
Use this skill when the user wants to:
|
|
20
20
|
|
|
21
21
|
- Delegate plan or instruction EXECUTION to `codex` in a workspace-write sandbox (network to
|
|
22
|
-
|
|
22
|
+
the run hosts its service-facts.txt lists where the permissions profile `jev` runs, off elsewhere).
|
|
23
23
|
- Get a second-opinion ADVISORY review of an implementation plan or the current diff.
|
|
24
24
|
- Install, authenticate, smoke-test, or troubleshoot `codex`, or understand its sandbox/flags/models.
|
|
25
25
|
- Drive codex efficiently from the main agent (exec vs review, `resume`, the commit boundary).
|
|
@@ -40,9 +40,8 @@ binary, run `codex login` once under a ChatGPT subscription, then expose this sk
|
|
|
40
40
|
print, copy, commit, or package `~/.codex/auth.json` — it is personal and is **never bundled** with
|
|
41
41
|
this skill. Both wrappers enforce the subscription path before invoking codex:
|
|
42
42
|
|
|
43
|
-
- they **unset `OPENAI_BASE_URL` and every `*_API_KEY` except
|
|
44
|
-
|
|
45
|
-
switch you to paid api-key billing;
|
|
43
|
+
- they **unset `OPENAI_BASE_URL` and every `*_API_KEY` except the passed variables its service-facts.txt lists**
|
|
44
|
+
(those variables pass as given) so a stray key can never silently switch you to paid api-key billing;
|
|
46
45
|
- they pass **`--ignore-user-config`** so a personal `~/.codex/config.toml` cannot change model,
|
|
47
46
|
sandbox, or approval behaviour (auth still works — codex reads the login from `CODEX_HOME`
|
|
48
47
|
regardless of that flag);
|
|
@@ -99,7 +98,7 @@ waste, never lowering quality. Full knob list: [§ Environment knobs](#environme
|
|
|
99
98
|
Drive codex only through the two wrappers (installed on `PATH`), run from the target project root:
|
|
100
99
|
|
|
101
100
|
```bash
|
|
102
|
-
# EXECUTION (workspace writes; network to
|
|
101
|
+
# EXECUTION (workspace writes; network to the run hosts its service-facts.txt lists under the profile `jev`, else off; never prompts):
|
|
103
102
|
codex-exec docs/plans/<slug>.md # drive a plan file
|
|
104
103
|
echo "apply review fix: ..." | codex-exec - # ad-hoc instruction from stdin
|
|
105
104
|
codex-exec <file|-> -- <extra codex flags...> # GUARDED passthrough after `--` (policy/model/capture flags rejected; some relaxed only under CODEX_PROBE=1)
|
|
@@ -125,7 +124,7 @@ receipt records the same `posture {model, effort, tier}` (tier `null` on the sta
|
|
|
125
124
|
bytes in a posture value refuse pre-spend in every mode. `codex-exec` states its posture the same way —
|
|
126
125
|
ONE `exec posture: model=… effort=… tier=… sandbox=jev-profile|workspace-write session=fresh|resume:<id>
|
|
127
126
|
jev=… source=… timeout=…` stderr line before dispatch (the resume id validated pre-spend). The `jev=`
|
|
128
|
-
field says what the run reaches:
|
|
127
|
+
field says what the run reaches: the run hosts its service-facts.txt lists under the permissions profile `jev`
|
|
129
128
|
(Linux, codex-cli 0.160.0 or newer, for `codex-exec` a repository outside every temp root, a codex
|
|
130
129
|
version and profile digest not recorded as refused), else `jev=unreachable (<reason>)` on today's flags.
|
|
131
130
|
A run whose codex refuses the profile (a profile error before the turn starts, or `bwrap: execvp` in a
|
|
@@ -182,9 +181,9 @@ anything that would defeat a policy is guarded — see [§ Models](#models-the-h
|
|
|
182
181
|
| `CODEX_REVIEW_SCHEMA` | unset | `codex-review`: `=1` returns findings as a validated JSON object (`--output-schema`), with a raw-text fallback. Default off. |
|
|
183
182
|
| `CODEX_PROBE` | unset | `=1` ⇒ throwaway-probe mode: the one route to a one-off model or effort, and it relaxes the tier-2 passthrough guard (echoed loudly); a probe review's receipt never attests. Never for real work. |
|
|
184
183
|
|
|
185
|
-
The git-write shim, `--ignore-user-config`, the key rule (`OPENAI_BASE_URL` and every `*_API_KEY`
|
|
186
|
-
|
|
187
|
-
they are fixed invariants.
|
|
184
|
+
The git-write shim, `--ignore-user-config`, the key rule (unset `OPENAI_BASE_URL` and every `*_API_KEY`
|
|
185
|
+
except the passed variables its service-facts.txt lists) and the choice between the profile and today's
|
|
186
|
+
flags are NOT env-tunable — they are fixed invariants.
|
|
188
187
|
|
|
189
188
|
### Dispatch identity — the accounted exec lane
|
|
190
189
|
|
|
@@ -251,14 +250,14 @@ you truly mean it.
|
|
|
251
250
|
|
|
252
251
|
**The Jev skill in a delegated run.** A `codex-exec` or `codex-review` run loads the vendor's Jev skill from the
|
|
253
252
|
user root the kit's `jev-skill` command fills, `~/.agents/skills` (a run under `--ignore-user-config` listed its
|
|
254
|
-
skills, measured 2026-10-02; `codex-review` links that root into its fence home), and `TYPESAFE_API_KEY` passes
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
writes nothing, and the banner
|
|
259
|
-
flags with network off and
|
|
260
|
-
`web_search` reaches pages outside the profile, and the key now sits in every run's environment,
|
|
261
|
-
|
|
253
|
+
skills, measured 2026-10-02; `codex-review` links that root into its fence home), and `TYPESAFE_API_KEY` passes as
|
|
254
|
+
given under the shared key rule: every `*_API_KEY` except the passed variables its service-facts.txt lists is unset.
|
|
255
|
+
With run hosts in that file, on Linux with codex-cli 0.160.0 or newer, off a recorded version and profile digest
|
|
256
|
+
refusal and, for `codex-exec`, outside every temp root, the profile `jev` reaches the run hosts its service-facts.txt
|
|
257
|
+
lists; a review still writes nothing, and the banner's `jev=` field lists those hosts. Elsewhere the run keeps
|
|
258
|
+
today's flags with network off and `jev=unreachable (<reason>)`. Two residuals stand: codex's server-side
|
|
259
|
+
`web_search` reaches pages outside the profile, and the key now sits in every run's environment, that channel
|
|
260
|
+
included. A codex release that stops recognizing a profile key costs one run per version and profile digest
|
|
262
261
|
(exit 72), while the state file can be written, before the recorded fallback takes over.
|
|
263
262
|
|
|
264
263
|
## How the main agent drives `codex` efficiently
|
|
@@ -283,9 +282,9 @@ See [`references/driving-codex.md`](references/driving-codex.md) for the full pl
|
|
|
283
282
|
sets `approval_policy=never` and the run's own posture explicitly — the profile `jev`'s four overrides,
|
|
284
283
|
or `sandbox_mode=workspace-write` + `sandbox_workspace_write.network_access=false` — chosen afresh on
|
|
285
284
|
each resume. It reads the session id from the sidecar (`--resume-last`) or takes it as an argument.
|
|
286
|
-
- **Network
|
|
287
|
-
|
|
288
|
-
|
|
285
|
+
- **Network in exec.** Under the profile `jev` a run reaches the run hosts its service-facts.txt lists;
|
|
286
|
+
under today's flags none. New dependencies and any other network step are installed by hand, then
|
|
287
|
+
codex is re-dispatched.
|
|
289
288
|
- **`codex-review code` precomputes the diff.** The wrapper assembles the change set (repo map, status,
|
|
290
289
|
staged + unstaged diff, untracked file contents) and feeds it in, so codex does not roam the
|
|
291
290
|
filesystem rediscovering it; a clean tree exits 0 before a run is spent. Native `codex review` is
|
|
@@ -311,9 +310,9 @@ The wrappers work in any git repo where `codex` is installed and authenticated.
|
|
|
311
310
|
|
|
312
311
|
## Known limitations
|
|
313
312
|
|
|
314
|
-
- **Network
|
|
315
|
-
|
|
316
|
-
|
|
313
|
+
- **Network** in `codex-exec` — the profile `jev` reaches the run hosts its service-facts.txt lists,
|
|
314
|
+
today's flags (`sandbox_workspace_write.network_access=false`) none: codex cannot install dependencies
|
|
315
|
+
— do that by hand, then re-dispatch. The profile runs only on Linux with
|
|
317
316
|
codex-cli 0.160.0 or newer; Windows and macOS keep today's flags until its round-trip is probed there.
|
|
318
317
|
- **No live approvals** — `codex exec` has no TTY, so `approval_policy=never`; an action that would
|
|
319
318
|
need escalation is reported, not approved interactively.
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
// codex-exec-jev.test.mjs — spec jev-every-run on codex-exec: the shared key rule, the posture the wrapper chooses
|
|
2
|
-
// (the jev permissions profile or today's flags), the loud failure, the banner, the directive and the probe
|
|
3
|
-
// passthrough. Standalone harness with its own fake codex and a fake uname.
|
|
4
1
|
import { describe, it, after } from 'node:test';
|
|
5
2
|
import assert from 'node:assert/strict';
|
|
6
|
-
import { mkdirSync, mkdtempSync, writeFileSync, readFileSync, existsSync, rmSync, cpSync, chmodSync, realpathSync, statSync } from 'node:fs';
|
|
3
|
+
import { mkdirSync, mkdtempSync, writeFileSync, readFileSync, existsSync, rmSync, cpSync, chmodSync, realpathSync, statSync, symlinkSync } from 'node:fs';
|
|
7
4
|
import { tmpdir } from 'node:os';
|
|
8
5
|
import { join, dirname } from 'node:path';
|
|
9
6
|
import { fileURLToPath } from 'node:url';
|
|
10
7
|
import { spawnSync } from 'node:child_process';
|
|
11
|
-
|
|
8
|
+
const stripGitLocationEnv = (env) => Object.fromEntries(Object.entries(env).filter(([key]) => !/^[Gg][Ii][Tt]_/.test(key)));
|
|
12
9
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
13
10
|
const EXEC = join(HERE, 'codex-exec.sh');
|
|
14
11
|
const HOSTS = 'api.typesafe.ai,docs.typesafe.ai';
|
|
15
|
-
|
|
12
|
+
const childEnv = (home, env = {}) => ({ ...stripGitLocationEnv(env), HOME: home, XDG_CONFIG_HOME: join(home, '.config'),
|
|
13
|
+
GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_SYSTEM: '/dev/null', GIT_CONFIG_NOSYSTEM: '1', GIT_ATTR_NOSYSTEM: '1', LC_ALL: 'C' });
|
|
16
14
|
const FIXTURES = join(HERE, '..', 'node_modules', '.aw-fixtures');
|
|
17
15
|
const TMP = join(FIXTURES, 'tmp');
|
|
18
16
|
mkdirSync(TMP, { recursive: true });
|
|
@@ -20,22 +18,17 @@ mkdirSync(join(FIXTURES, 'repos'), { recursive: true });
|
|
|
20
18
|
const ROOT = mkdtempSync(join(FIXTURES, 'repos', 'exec-jev-'));
|
|
21
19
|
after(() => rmSync(ROOT, { recursive: true, force: true }));
|
|
22
20
|
const REAL_UNAME = spawnSync('bash', ['-c', 'type -P uname'], { encoding: 'utf8' }).stdout.trim();
|
|
23
|
-
|
|
24
|
-
// Every spawn of the CLI appends one line: its kind and the state of each key ([value] or unset).
|
|
25
21
|
const FAKE_CODEX = [
|
|
26
|
-
'#!/usr/bin/env bash',
|
|
27
|
-
'set -u',
|
|
22
|
+
'#!/usr/bin/env bash', 'set -u',
|
|
28
23
|
'st() { if [[ -n "${!1+x}" ]]; then printf "[%s]" "${!1}"; else printf unset; fi; }',
|
|
29
|
-
'rec() { echo "$1 key=$(st TYPESAFE_API_KEY) openai=$(st OPENAI_API_KEY) codex=$(st CODEX_API_KEY) foo=$(st FOO_API_KEY) base=$(st OPENAI_BASE_URL)" >>"$CODEX_FAKE_LOG"; }',
|
|
24
|
+
'rec() { echo "$1 key=$(st TYPESAFE_API_KEY) openai=$(st OPENAI_API_KEY) codex=$(st CODEX_API_KEY) foo=$(st FOO_API_KEY) base=$(st OPENAI_BASE_URL) bar=$(st BAR_API_KEY)" >>"$CODEX_FAKE_LOG"; }',
|
|
30
25
|
'case "${1:-}" in',
|
|
31
26
|
' login) rec login; echo "Logged in using ChatGPT"; exit 0 ;;',
|
|
32
27
|
' --version) rec version; echo "${CODEX_FAKE_VERSION-codex-cli 0.160.0}"; exit 0 ;;',
|
|
33
28
|
' debug) rec catalog; cat <<EOF',
|
|
34
29
|
'{"models":[{"slug":"gpt-6.1-sol","priority":1,"visibility":"list","default_reasoning_level":"low","supported_reasoning_levels":[{"effort":"low"},{"effort":"medium"},{"effort":"high"}]}]}',
|
|
35
|
-
'EOF',
|
|
36
|
-
'
|
|
37
|
-
'esac',
|
|
38
|
-
'rec run',
|
|
30
|
+
'EOF', ' exit 0 ;;',
|
|
31
|
+
'esac', 'rec run',
|
|
39
32
|
'{ for a in "$@"; do echo "$a"; done; } >"$CODEX_FAKE_ARGV"',
|
|
40
33
|
'cat >"$CODEX_FAKE_STDIN"',
|
|
41
34
|
'out=""; prev=""; for a in "$@"; do if [[ "$prev" == "-o" ]]; then out="$a"; fi; prev="$a"; done',
|
|
@@ -51,10 +44,9 @@ const FAKE_CODEX = [
|
|
|
51
44
|
const FAKE_UNAME = ['#!/usr/bin/env bash', 'if [[ $# -eq 0 || "$1" == "-s" ]]; then echo "${CODEX_FAKE_UNAME:-Linux}"; exit 0; fi',
|
|
52
45
|
`exec "${REAL_UNAME}" "$@"`, ''].join('\n');
|
|
53
46
|
const CONTRACT = '# dispatch\n\n```aw-dispatch-contract\n{"nonce":"n1","scope":"probe"}\n```\n';
|
|
54
|
-
|
|
55
47
|
const initRepo = (repo) => {
|
|
56
48
|
mkdirSync(repo, { recursive: true });
|
|
57
|
-
const git = (...args) => spawnSync('git', args, { cwd: repo, encoding: 'utf8' });
|
|
49
|
+
const git = (...args) => spawnSync('git', args, { cwd: repo, encoding: 'utf8', env: childEnv(join(ROOT, 'template', 'home'), { PATH: process.env.PATH }) });
|
|
58
50
|
git('init', '-q');
|
|
59
51
|
git('config', 'user.email', 'probe@example.com');
|
|
60
52
|
git('config', 'user.name', 'probe');
|
|
@@ -69,10 +61,8 @@ mkdirSync(join(TEMPLATE, 'home'));
|
|
|
69
61
|
writeFileSync(join(TEMPLATE, 'bin', 'codex'), FAKE_CODEX);
|
|
70
62
|
writeFileSync(join(TEMPLATE, 'bin', 'uname'), FAKE_UNAME);
|
|
71
63
|
initRepo(join(TEMPLATE, 'repo'));
|
|
72
|
-
|
|
73
|
-
let sequence = 0;
|
|
74
64
|
const sandbox = () => {
|
|
75
|
-
const dir = join(ROOT,
|
|
65
|
+
const dir = mkdtempSync(join(ROOT, 'sb-'));
|
|
76
66
|
cpSync(TEMPLATE, dir, { recursive: true });
|
|
77
67
|
for (const name of ['codex', 'uname']) chmodSync(join(dir, 'bin', name), 0o755);
|
|
78
68
|
return { dir, bin: join(dir, 'bin'), home: join(dir, 'home'), repo: join(dir, 'repo'),
|
|
@@ -81,25 +71,25 @@ const sandbox = () => {
|
|
|
81
71
|
const drive = (sb, args, env = {}, cwd = sb.repo) => {
|
|
82
72
|
const cap = (name) => join(sb.dir, name);
|
|
83
73
|
for (const name of ['log', 'argv', 'stdin']) rmSync(cap(name), { force: true });
|
|
84
|
-
const r = spawnSync('bash', [EXEC, ...args], {
|
|
74
|
+
const r = spawnSync('bash', [sb.wrapper ?? EXEC, ...args], {
|
|
85
75
|
cwd, input: 'do the thing', encoding: 'utf8', timeout: 60000,
|
|
86
|
-
env: { PATH: `${sb.bin}:${process.env.PATH}`,
|
|
87
|
-
CODEX_FAKE_ARGV: cap('argv'), CODEX_FAKE_STDIN: cap('stdin'), ...env },
|
|
76
|
+
env: childEnv(sb.home, { PATH: `${sb.bin}:${process.env.PATH}`, TMPDIR: TMP, CODEX_FAKE_LOG: cap('log'),
|
|
77
|
+
CODEX_FAKE_ARGV: cap('argv'), CODEX_FAKE_STDIN: cap('stdin'), ...env }),
|
|
88
78
|
});
|
|
79
|
+
assert.ifError(r.error);
|
|
80
|
+
assert.equal(r.signal, null, r.stderr);
|
|
89
81
|
const read = (name) => (existsSync(cap(name)) ? readFileSync(cap(name), 'utf8') : '');
|
|
90
82
|
return { status: r.status, stdout: r.stdout, stderr: r.stderr, log: read('log'), argv: read('argv').split('\n').slice(0, -1),
|
|
91
83
|
prompt: read('stdin').replace(/\s+/g, ' ') };
|
|
92
84
|
};
|
|
93
|
-
|
|
94
|
-
// -c key=value pairs of the run's argv, and a reader for the TOML inline tables a profile override carries.
|
|
95
85
|
const overrides = (argv) => Object.fromEntries(argv.flatMap((arg, i) => (argv[i - 1] === '-c'
|
|
96
86
|
? [[arg.slice(0, arg.indexOf('=')), arg.slice(arg.indexOf('=') + 1)]] : [])));
|
|
97
87
|
const inline = (text) => {
|
|
98
|
-
|
|
88
|
+
const cursor = { at: 0 };
|
|
99
89
|
const eat = (re) => {
|
|
100
|
-
const m = re.exec(text.slice(at));
|
|
90
|
+
const m = re.exec(text.slice(cursor.at));
|
|
101
91
|
assert.ok(m, `an inline table: ${text}`);
|
|
102
|
-
at += m[0].length;
|
|
92
|
+
cursor.at += m[0].length;
|
|
103
93
|
return m;
|
|
104
94
|
};
|
|
105
95
|
const value = () => {
|
|
@@ -114,7 +104,7 @@ const inline = (text) => {
|
|
|
114
104
|
return table;
|
|
115
105
|
};
|
|
116
106
|
const parsed = value();
|
|
117
|
-
assert.equal(text.slice(at).trim(), '', `nothing after the inline table: ${text}`);
|
|
107
|
+
assert.equal(text.slice(cursor.at).trim(), '', `nothing after the inline table: ${text}`);
|
|
118
108
|
return parsed;
|
|
119
109
|
};
|
|
120
110
|
const EXEC_FS = { ':root': 'read', ':tmpdir': 'write', ':slash_tmp': 'write', ':workspace_roots': { '.': 'write' } };
|
|
@@ -142,7 +132,7 @@ const banner = (sandboxValue, jev, session = 'fresh') => 'exec posture: model=gp
|
|
|
142
132
|
+ `sandbox=${sandboxValue} session=${session} jev=${jev} source=model:default,effort:default timeout=3600s`;
|
|
143
133
|
const unreachable = (reason) => banner('workspace-write', `unreachable (${reason})`);
|
|
144
134
|
const KEYS = { TYPESAFE_API_KEY: 'jev-key', OPENAI_API_KEY: 'sk-live', CODEX_API_KEY: 'ck', FOO_API_KEY: 'foo', OPENAI_BASE_URL: 'http://proxy' };
|
|
145
|
-
const PASSED = 'key=[jev-key] openai=unset codex=unset foo=unset base=unset';
|
|
135
|
+
const PASSED = 'key=[jev-key] openai=unset codex=unset foo=unset base=unset bar=unset';
|
|
146
136
|
const spawnsOf = (r) => r.log.split('\n').filter(Boolean).map((line) => [line.slice(0, line.indexOf(' ')), line.slice(line.indexOf(' ') + 1)]);
|
|
147
137
|
const runEnv = (r) => (spawnsOf(r).find(([kind]) => kind === 'run') ?? [])[1];
|
|
148
138
|
const item = (body) => JSON.stringify({ type: 'item.completed', item: body });
|
|
@@ -156,7 +146,6 @@ const receiptOf = (sb) => JSON.parse(readFileSync(join(sb.repo, '.git', 'agent-w
|
|
|
156
146
|
const RECEIPT_KEYS = ['schema', 'kind', 'state', 'backend', 'nonce', 'owner', 'contractDigest', 'wrapperVersion', 'posture', 'capS',
|
|
157
147
|
'killGraceS', 'sessionId', 'exitStatus', 'outcome', 'reportDigest', 'reportLength', 'timestamp'];
|
|
158
148
|
const stateLines = (sb) => (existsSync(sb.state) ? readFileSync(sb.state, 'utf8').split('\n').filter(Boolean) : []);
|
|
159
|
-
|
|
160
149
|
describe('the key rule on codex-exec — spec:jev-every-run/S1', () => {
|
|
161
150
|
it('a fresh run hands codex only TYPESAFE_API_KEY of the keys, and the login, version and catalog spawns see the same env', () => {
|
|
162
151
|
const r = drive(sandbox(), ['-'], KEYS);
|
|
@@ -165,7 +154,6 @@ describe('the key rule on codex-exec — spec:jev-every-run/S1', () => {
|
|
|
165
154
|
for (const [kind, env] of spawnsOf(r)) assert.equal(env, PASSED, `${kind} spawn`);
|
|
166
155
|
});
|
|
167
156
|
});
|
|
168
|
-
|
|
169
157
|
describe('a resumed run — spec:jev-every-run/S2', () => {
|
|
170
158
|
it('keeps the key rule and carries the profile overrides with no sandbox_mode', () => {
|
|
171
159
|
const r = drive(sandbox(), ['--resume', 'sess-1', '-'], KEYS);
|
|
@@ -174,7 +162,6 @@ describe('a resumed run — spec:jev-every-run/S2', () => {
|
|
|
174
162
|
for (const [kind, env] of spawnsOf(r)) assert.equal(env, PASSED, `${kind} spawn`);
|
|
175
163
|
});
|
|
176
164
|
});
|
|
177
|
-
|
|
178
165
|
describe('an empty key and an unset key — spec:jev-every-run/S5', () => {
|
|
179
166
|
it('an empty TYPESAFE_API_KEY reaches codex empty, an unset one stays unset, and the argv is the same with the key set', () => {
|
|
180
167
|
const runs = ['jev-key', '', undefined].map((value) => drive(sandbox(), ['-'], { TYPESAFE_API_KEY: value }));
|
|
@@ -185,7 +172,6 @@ describe('an empty key and an unset key — spec:jev-every-run/S5', () => {
|
|
|
185
172
|
assertProfile(runs[0]);
|
|
186
173
|
});
|
|
187
174
|
});
|
|
188
|
-
|
|
189
175
|
describe('the exec profile on Linux from codex-cli 0.160.0 — spec:jev-every-run/S7', () => {
|
|
190
176
|
for (const version of ['0.160.0', '0.161.0', '1.0.0']) {
|
|
191
177
|
it(`codex-cli ${version}: the exec profile exactly, neither --sandbox nor sandbox_mode`, () => {
|
|
@@ -193,7 +179,6 @@ describe('the exec profile on Linux from codex-cli 0.160.0 — spec:jev-every-ru
|
|
|
193
179
|
});
|
|
194
180
|
}
|
|
195
181
|
});
|
|
196
|
-
|
|
197
182
|
describe('the fallback by OS and by temp root — spec:jev-every-run/S9', () => {
|
|
198
183
|
it('a uname other than Linux runs today\'s flags with the key passed and names the reason', () => {
|
|
199
184
|
const r = drive(sandbox(), ['-'], { ...KEYS, CODEX_FAKE_UNAME: 'Darwin' });
|
|
@@ -216,7 +201,7 @@ describe('the fallback by OS and by temp root — spec:jev-every-run/S9', () =>
|
|
|
216
201
|
const sb = sandbox();
|
|
217
202
|
const root = join(sb.dir, 'tmproot');
|
|
218
203
|
cpSync(sb.repo, join(root, 'main'), { recursive: true });
|
|
219
|
-
spawnSync('git', ['worktree', 'add', '-q', join(sb.dir, 'wt')], { cwd: join(root, 'main'), encoding: 'utf8' });
|
|
204
|
+
spawnSync('git', ['worktree', 'add', '-q', join(sb.dir, 'wt')], { cwd: join(root, 'main'), encoding: 'utf8', env: childEnv(sb.home, { PATH: process.env.PATH }) });
|
|
220
205
|
writeFileSync(join(sb.dir, 'wt', 'task.md'), CONTRACT);
|
|
221
206
|
const r = drive(sb, ['-'], { TMPDIR: root }, join(sb.dir, 'wt'));
|
|
222
207
|
assertFallback(r);
|
|
@@ -243,7 +228,6 @@ describe('the fallback by OS and by temp root — spec:jev-every-run/S9', () =>
|
|
|
243
228
|
}
|
|
244
229
|
});
|
|
245
230
|
});
|
|
246
|
-
|
|
247
231
|
describe('the fallback by version and by the refused record — spec:jev-every-run/S10', () => {
|
|
248
232
|
const cases = [['codex-cli 0.159.0', 'codex 0.159.0 below 0.160.0'], ['codex-cli 0.160.0-alpha.1', 'codex 0.160.0-alpha.1 below 0.160.0'],
|
|
249
233
|
['codex-cli', 'codex version unreadable']];
|
|
@@ -271,7 +255,6 @@ describe('the fallback by version and by the refused record — spec:jev-every-r
|
|
|
271
255
|
}
|
|
272
256
|
});
|
|
273
257
|
});
|
|
274
|
-
|
|
275
258
|
describe('the profile error item before the turn — spec:jev-every-run/S11', () => {
|
|
276
259
|
for (const [label, shape] of [['the P13 shape', P13], ['the P1 shape', P1]]) {
|
|
277
260
|
it(`${label}, printed twice before turn.started: exit 72, one entry appended, a transport-failure receipt`, () => {
|
|
@@ -305,7 +288,6 @@ describe('the profile error item before the turn — spec:jev-every-run/S11', ()
|
|
|
305
288
|
assert.equal(receiptOf(sb).outcome, 'transport-failure');
|
|
306
289
|
});
|
|
307
290
|
});
|
|
308
|
-
|
|
309
291
|
describe('bwrap: execvp in a failed command — spec:jev-every-run/S12', () => {
|
|
310
292
|
it('exits 72 without touching the state file', () => {
|
|
311
293
|
const sb = sandbox();
|
|
@@ -316,7 +298,6 @@ describe('bwrap: execvp in a failed command — spec:jev-every-run/S12', () => {
|
|
|
316
298
|
assert.equal(receiptOf(sb).outcome, 'transport-failure');
|
|
317
299
|
});
|
|
318
300
|
});
|
|
319
|
-
|
|
320
301
|
describe('the same strings where they never fire — spec:jev-every-run/S13', () => {
|
|
321
302
|
it('inside a successful command\'s output and in the final message: exit 0, a success receipt, no state file', () => {
|
|
322
303
|
const sb = sandbox();
|
|
@@ -328,7 +309,6 @@ describe('the same strings where they never fire — spec:jev-every-run/S13', ()
|
|
|
328
309
|
assert.equal(existsSync(sb.state), false);
|
|
329
310
|
});
|
|
330
311
|
});
|
|
331
|
-
|
|
332
312
|
describe('the exec banner and the receipt — spec:jev-every-run/S14', () => {
|
|
333
313
|
it('a profile run reads sandbox=jev-profile and the two hosts before source=, the receipt keys unchanged', () => {
|
|
334
314
|
const sb = sandbox();
|
|
@@ -343,13 +323,12 @@ describe('the exec banner and the receipt — spec:jev-every-run/S14', () => {
|
|
|
343
323
|
assert.equal(bannerOf(r), banner('workspace-write', 'unreachable (codex 0.159.0 below 0.160.0)', 'resume:sess-1'));
|
|
344
324
|
});
|
|
345
325
|
});
|
|
346
|
-
|
|
347
326
|
describe('the execution directive and the resume reminder — spec:jev-every-run/S17', () => {
|
|
348
|
-
const HOST_LINE = 'the
|
|
327
|
+
const HOST_LINE = 'the reachable host list is api.typesafe.ai, docs.typesafe.ai; network access to any other host is an escalation: STOP and report.';
|
|
349
328
|
it('a fresh profile run names the two hosts and the other-host escalation; a fallback run keeps network access whole', () => {
|
|
350
329
|
const profile = drive(sandbox(), ['-']);
|
|
351
330
|
assertProfile(profile);
|
|
352
|
-
assert.ok(profile.prompt.includes(HOST_LINE), profile.prompt);
|
|
331
|
+
assert.ok(profile.prompt.includes(`5. Do NOT commit. Network: ${HOST_LINE}`), profile.prompt);
|
|
353
332
|
const fallback = drive(sandbox(), ['-'], { CODEX_FAKE_UNAME: 'Darwin' });
|
|
354
333
|
assert.ok(fallback.prompt.includes('escalation (network access, writes outside the repo'), fallback.prompt);
|
|
355
334
|
assert.doesNotMatch(fallback.prompt, /typesafe/);
|
|
@@ -358,14 +337,70 @@ describe('the execution directive and the resume reminder — spec:jev-every-run
|
|
|
358
337
|
const sb = sandbox();
|
|
359
338
|
const profile = drive(sb, ['--resume', 'sess-1', '-']);
|
|
360
339
|
assertProfile(profile);
|
|
361
|
-
assert.ok(profile.prompt.includes(HOST_LINE), profile.prompt);
|
|
340
|
+
assert.ok(profile.prompt.includes(`Network, as of this run (it replaces any earlier statement): ${HOST_LINE}`), profile.prompt);
|
|
362
341
|
const fallback = drive(sb, ['--resume', 'sess-1', '-'], { CODEX_FAKE_UNAME: 'Darwin' });
|
|
363
342
|
assertFallback(fallback);
|
|
364
|
-
assert.
|
|
343
|
+
assert.ok(fallback.prompt.includes('Network, as of this run (it replaces any earlier statement): network access is an escalation: STOP and report.'), fallback.prompt);
|
|
365
344
|
assert.doesNotMatch(fallback.prompt, /typesafe/);
|
|
366
345
|
});
|
|
367
346
|
});
|
|
368
|
-
|
|
347
|
+
const copyBridge = (sb, transform = (lines) => lines) => {
|
|
348
|
+
const directory = join(sb.dir, 'bridge');
|
|
349
|
+
cpSync(HERE, join(directory, 'bin'), { recursive: true });
|
|
350
|
+
cpSync(join(HERE, '..', 'capability.json'), join(directory, 'capability.json'));
|
|
351
|
+
const shipped = readFileSync(join(HERE, '..', 'service-facts.txt'), 'utf8').trimEnd().split('\n');
|
|
352
|
+
writeFileSync(join(directory, 'service-facts.txt'), `${transform(shipped).join('\n')}\n`);
|
|
353
|
+
const wrapper = join(directory, 'bin', 'linked-exec');
|
|
354
|
+
symlinkSync('codex-exec.sh', wrapper);
|
|
355
|
+
return { ...sb, wrapper };
|
|
356
|
+
};
|
|
357
|
+
describe('injected facts through a symlink — spec:jev-every-run/S26', () => {
|
|
358
|
+
it('renders only the injected hosts and passes exactly the listed variables, including empty values', () => {
|
|
359
|
+
const sb = copyBridge(sandbox(), (lines) => [lines[0], 'HOST=a.example', 'HOST=b.example', 'RUN_HOST=a.example', 'RUN_HOST=b.example', lines.find((line) => line.startsWith('WRITABLE_DIR=')), 'PASSED_VARIABLE=FOO_API_KEY', 'PASSED_VARIABLE=BAR_API_KEY']);
|
|
360
|
+
const env = { ...KEYS, BAR_API_KEY: '' };
|
|
361
|
+
const fresh = drive(sb, ['-'], env), resume = drive(sb, ['--resume', 'sess-1', '-'], env), help = drive(sb, ['--help'], env);
|
|
362
|
+
for (const result of [fresh, resume, help]) { assert.equal(result.status, 0, result.stderr); assert.doesNotMatch([result.argv.join(' '), result.prompt, result.stderr, result.stdout].join('\n'), /typesafe\.ai/i); }
|
|
363
|
+
for (const result of [fresh, resume]) {
|
|
364
|
+
assert.equal(overrides(result.argv)['permissions.jev.network.domains'], '{"a.example"="allow","b.example"="allow"}');
|
|
365
|
+
assert.equal(bannerOf(result), banner('jev-profile', 'a.example,b.example', result === resume ? 'resume:sess-1' : 'fresh'));
|
|
366
|
+
assert.ok(spawnsOf(result).length > 0, result.log);
|
|
367
|
+
for (const [kind, keys] of spawnsOf(result)) assert.equal(keys, 'key=unset openai=unset codex=unset foo=[foo] base=unset bar=[]', kind);
|
|
368
|
+
}
|
|
369
|
+
const phrase = 'the reachable host list is a.example, b.example; network access to any other host is an escalation: STOP and report.';
|
|
370
|
+
assert.ok(fresh.prompt.includes(`5. Do NOT commit. Network: ${phrase}`), fresh.prompt);
|
|
371
|
+
assert.ok(resume.prompt.includes(`Network, as of this run (it replaces any earlier statement): ${phrase}`), resume.prompt);
|
|
372
|
+
assert.ok(help.stdout.includes('network where the profile runs (the reachable host list is a.example, b.example) and off elsewhere'), help.stdout);
|
|
373
|
+
});
|
|
374
|
+
it('an empty passed-variable list unsets every billing key and OPENAI_BASE_URL', () => {
|
|
375
|
+
const result = drive(copyBridge(sandbox(), (lines) => lines.filter((line) => !line.startsWith('PASSED_VARIABLE='))), ['-'], { ...KEYS, BAR_API_KEY: 'bar' });
|
|
376
|
+
assert.equal(result.status, 0, result.stderr);
|
|
377
|
+
assert.ok(spawnsOf(result).length > 0, result.log);
|
|
378
|
+
for (const [kind, keys] of spawnsOf(result)) assert.equal(keys, 'key=unset openai=unset codex=unset foo=unset base=unset bar=unset', kind);
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
describe('run hosts choose posture and preserve the shipped profile — spec:jev-every-run/S27', () => {
|
|
382
|
+
it('no RUN_HOST takes fallback before the OS reason and makes help say network off', () => {
|
|
383
|
+
const sb = copyBridge(sandbox(), (lines) => lines.filter((line) => !line.startsWith('RUN_HOST=')));
|
|
384
|
+
for (const env of [{}, { CODEX_FAKE_UNAME: 'Darwin' }]) {
|
|
385
|
+
const result = drive(sb, ['-'], env);
|
|
386
|
+
assertFallback(result);
|
|
387
|
+
assert.equal(bannerOf(result), unreachable('no run host in service-facts.txt'));
|
|
388
|
+
}
|
|
389
|
+
const help = drive(sb, ['--help']);
|
|
390
|
+
assert.equal(help.status, 0, help.stderr);
|
|
391
|
+
assert.match(help.stdout.split('\n')[0], /network off/);
|
|
392
|
+
});
|
|
393
|
+
it('characterize-first: both shipped profiles retain the exact overrides and recorded refusal digest', () => {
|
|
394
|
+
const common = ['default_permissions=jev', 'permissions.jev.network.enabled=true', 'permissions.jev.network.domains={"api.typesafe.ai"="allow","docs.typesafe.ai"="allow"}'];
|
|
395
|
+
for (const [wrapper, filesystem, digest] of [['codex-exec.sh', 'permissions.jev.filesystem={":root"="read",":tmpdir"="write",":slash_tmp"="write",":workspace_roots"={"."="write"}}', 'f693ef134a9c6d5b41042b91260726d4179d99ccadc149270f1ddba09cdc99e8'], ['codex-review.sh', 'permissions.jev.filesystem={":root"="read"}', 'c68a3f5f7be241f7cecf5328a3541063e1f25365f216798aff42b719164f9159']]) {
|
|
396
|
+
const sb = { ...sandbox(), wrapper: join(HERE, wrapper) };
|
|
397
|
+
const result = drive(sb, wrapper === 'codex-exec.sh' ? ['-'] : ['plan', 'task.md'], { CODEX_FAKE_PRE: P13 });
|
|
398
|
+
assert.equal(result.status, 72, result.stderr);
|
|
399
|
+
assert.deepEqual(result.argv.flatMap((arg, index) => result.argv[index - 1] === '-c' && /^(default_permissions|permissions\.)/.test(arg) ? ['-c', arg] : []), [...common, filesystem].flatMap((arg) => ['-c', arg]));
|
|
400
|
+
assert.deepEqual(stateLines(sb), [`0.160.0 ${digest}`]);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
});
|
|
369
404
|
describe('the probe passthrough under the profile — spec:jev-every-run/S18', () => {
|
|
370
405
|
for (const flag of [['--add-dir', '/x'], ['-C', '/x'], ['--cd', '/x'], ['--enable', 'foo'], ['--disable', 'foo']]) {
|
|
371
406
|
it(`CODEX_PROBE=1 with ${flag[0]}: refused pre-spend under the profile, admitted under the fallback`, () => {
|