@sabaiway/agent-workflow-kit 22.2.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 +49 -1
- package/README.md +1 -1
- 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 +81 -63
- 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 +4 -5
- package/bridges/antigravity-cli-bridge/references/models-and-flags.md +3 -3
- package/bridges/antigravity-cli-bridge/service-facts.txt +11 -0
- 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 +7 -8
- 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/service-facts.txt +9 -0
- package/bridges/codex-cli-bridge/setup/README.md +3 -3
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/modes/recommendations.md +3 -3
- package/references/modes/velocity.md +1 -1
- package/tools/bridge-sandbox-recipe.mjs +9 -6
- package/tools/bridge-state-dirs.mjs +2 -2
- package/tools/detect-backends.mjs +23 -15
- package/tools/manifest/schema.md +28 -47
- package/tools/manifest/validate.mjs +22 -60
- package/tools/procedures.mjs +1 -1
- package/tools/services/antigravity.json +17 -0
- package/tools/services/codex.json +15 -0
- package/tools/services/index.mjs +127 -0
- package/tools/services/jev.json +12 -0
|
@@ -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`, () => {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# - codex may edit the repo and the temp dirs, nothing else: on Linux with codex-cli 0.160.0 or
|
|
13
13
|
# newer, from a repository outside every temp root and off a codex version and profile digest
|
|
14
14
|
# recorded as refused, the run carries the permissions profile `jev` (workspace write, network to
|
|
15
|
-
#
|
|
15
|
+
# the run hosts its service-facts.txt lists); elsewhere today's workspace-write sandbox with network off. The banner's
|
|
16
16
|
# jev= field says which; new dependencies / network installs are done by a human
|
|
17
17
|
# - approval_policy=never: there is no TTY in exec; anything needing escalation
|
|
18
18
|
# is refused and reported, then handled by hand
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
#
|
|
31
31
|
# Auth: SUBSCRIPTION ONLY. Uses the cached ChatGPT login under CODEX_HOME
|
|
32
32
|
# (~/.codex). The wrapper unsets OPENAI_BASE_URL and every *_API_KEY except
|
|
33
|
-
#
|
|
33
|
+
# the passed variables its service-facts.txt lists, and passes --ignore-user-config, so a stray
|
|
34
34
|
# key or a personal ~/.codex/config.toml can never silently switch billing or change
|
|
35
35
|
# behaviour. No credentials are bundled.
|
|
36
36
|
#
|
|
@@ -44,14 +44,90 @@
|
|
|
44
44
|
# CODEX_PROBE=1 CODEX_MODEL=<slug> codex-exec <file> # throwaway probe (the one route to a one-off)
|
|
45
45
|
set -euo pipefail
|
|
46
46
|
|
|
47
|
+
aw_script_dir() {
|
|
48
|
+
local src="${BASH_SOURCE[0]}" dir hops=0 max_hops=16
|
|
49
|
+
while :; do
|
|
50
|
+
case "$src" in */*) dir="${src%/*}"; dir="${dir:-/}" ;; *) dir=. ;; esac
|
|
51
|
+
dir="$(CDPATH= builtin cd -P -- "$dir" 2>/dev/null && builtin pwd -P)" || break
|
|
52
|
+
[[ -L "$src" ]] || { printf '%s\n' "$dir"; return 0; }
|
|
53
|
+
if (( hops >= max_hops )); then
|
|
54
|
+
printf 'error: exceeded %s symlink hops; could not resolve its OWN directory\n' "$max_hops" >&2
|
|
55
|
+
return 127
|
|
56
|
+
fi
|
|
57
|
+
hops=$((hops + 1))
|
|
58
|
+
src="$(command readlink -- "$src" 2>/dev/null)" || break
|
|
59
|
+
case "$src" in /*) ;; *) src="$dir/$src" ;; esac
|
|
60
|
+
done
|
|
61
|
+
printf 'error: could not resolve its OWN directory\n' >&2
|
|
62
|
+
return 127
|
|
63
|
+
}
|
|
64
|
+
aw_read_service_facts() {
|
|
65
|
+
local path="${1%/*}/service-facts.txt" line key value entry number=0 bad=0 valid seen=() run_lines=()
|
|
66
|
+
local host_re='^(\*\.)?[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-]*[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])?(\.[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-]*[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])?)+$'
|
|
67
|
+
local variable_re='^[ABCDEFGHIJKLMNOPQRSTUVWXYZ][ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*$'
|
|
68
|
+
local command_re='^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._-]* \*$'
|
|
69
|
+
local env directory segments LC_ALL=C
|
|
70
|
+
AW_FACT_HOST=() AW_FACT_RUN_HOST=() AW_FACT_PASSED_VARIABLE=()
|
|
71
|
+
if [[ -f "$path" && -r "$path" ]]; then
|
|
72
|
+
while IFS= read -r line; do
|
|
73
|
+
number=$((number + 1)); valid=1
|
|
74
|
+
if (( number == 1 )); then
|
|
75
|
+
[[ "$line" == "# generated from the kit's service fragments (agent-workflow-kit/tools/services/); do not edit" ]] || bad=1
|
|
76
|
+
continue
|
|
77
|
+
fi
|
|
78
|
+
key="${line%%=*}"; value="${line#*=}"
|
|
79
|
+
[[ "$line" == *=* ]] || valid=0
|
|
80
|
+
case "$key" in
|
|
81
|
+
HOST|RUN_HOST) [[ "$value" =~ $host_re ]] || valid=0
|
|
82
|
+
if [[ "$key" == RUN_HOST && "$value" == '*.'* ]]; then valid=0; fi ;;
|
|
83
|
+
PASSED_VARIABLE) [[ "$value" =~ $variable_re && "$value" != OPENAI_BASE_URL ]] || valid=0 ;;
|
|
84
|
+
EXCLUDED_COMMAND) [[ "$value" =~ $command_re ]] || valid=0 ;;
|
|
85
|
+
WRITABLE_DIR)
|
|
86
|
+
env="${value%%:*}"; directory="${value#*:}"; segments="/${directory//\\//}/"
|
|
87
|
+
[[ "$value" == *:* && ( -z "$env" || "$env" =~ $variable_re ) &&
|
|
88
|
+
( "$directory" == '~/'* || "$directory" == /* ) && "$directory" != */ &&
|
|
89
|
+
"$directory" != *[\*\?\[\]]* && ! "$directory" =~ [[:cntrl:]] && "$segments" != */../* ]] || valid=0 ;;
|
|
90
|
+
*) valid=0 ;;
|
|
91
|
+
esac
|
|
92
|
+
for entry in ${seen[@]+"${seen[@]}"}; do [[ "$entry" != "$line" ]] || valid=0; done
|
|
93
|
+
if (( ! valid )); then (( bad )) || bad=$number; continue; fi
|
|
94
|
+
seen+=("$line")
|
|
95
|
+
case "$key" in
|
|
96
|
+
HOST) AW_FACT_HOST+=("$value") ;; RUN_HOST) AW_FACT_RUN_HOST+=("$value"); run_lines+=("$number") ;;
|
|
97
|
+
PASSED_VARIABLE) AW_FACT_PASSED_VARIABLE+=("$value") ;;
|
|
98
|
+
esac
|
|
99
|
+
done <"$path"
|
|
100
|
+
if (( ! number )); then bad=1; fi
|
|
101
|
+
if [[ -n "$line" ]] && (( ! bad )); then bad=$((number + 1)); fi
|
|
102
|
+
for ((number=0; number<${#AW_FACT_RUN_HOST[@]}; number++)); do
|
|
103
|
+
valid=0
|
|
104
|
+
for entry in ${AW_FACT_HOST[@]+"${AW_FACT_HOST[@]}"}; do [[ "$entry" != "${AW_FACT_RUN_HOST[number]}" ]] || valid=1; done
|
|
105
|
+
if (( ! valid && (! bad || run_lines[number] < bad) )); then bad=${run_lines[number]}; fi
|
|
106
|
+
done
|
|
107
|
+
(( bad )) || return 0
|
|
108
|
+
printf 'error: %s: invalid facts at line %s; remove whatever is at that path and run /agent-workflow-kit upgrade to write it again\n' "$path" "$bad" >&2
|
|
109
|
+
else
|
|
110
|
+
printf 'error: %s: not a readable regular file; remove whatever is at that path and run /agent-workflow-kit upgrade to write it again\n' "$path" >&2
|
|
111
|
+
fi
|
|
112
|
+
exit 127
|
|
113
|
+
}
|
|
114
|
+
HERE="$(aw_script_dir)" || exit 127
|
|
115
|
+
aw_read_service_facts "$HERE"
|
|
116
|
+
|
|
47
117
|
# --- --help / -h (pre-preflight: no codex, no login, no git tree needed) -------
|
|
48
118
|
# Keyed ONLY on the FIRST argument — never a scan of all args, else a passthrough
|
|
49
119
|
# payload like `codex-exec f - -- --help` would be intercepted.
|
|
50
120
|
# The contract below is drift-guarded against capability.json roles.execute.contract.
|
|
51
121
|
case "${1:-}" in
|
|
52
122
|
--help|-h)
|
|
123
|
+
aw_help_network="network off"
|
|
124
|
+
if (( ${#AW_FACT_RUN_HOST[@]} )); then
|
|
125
|
+
aw_help_hosts=""
|
|
126
|
+
for aw_host in "${AW_FACT_RUN_HOST[@]}"; do aw_help_hosts+="${aw_help_hosts:+, }$aw_host"; done
|
|
127
|
+
aw_help_network="network where the profile runs (the reachable host list is $aw_help_hosts) and off elsewhere"
|
|
128
|
+
fi
|
|
129
|
+
printf '%s\n' "codex-exec — delegate plan/instruction EXECUTION to the OpenAI Codex CLI (subscription-only; writes to the repository and the temp dirs only, $aw_help_network, git writes blocked — the orchestrator commits)."
|
|
53
130
|
cat <<'HELP'
|
|
54
|
-
codex-exec — delegate plan/instruction EXECUTION to the OpenAI Codex CLI (subscription-only; writes to the repository and the temp dirs only, network to api.typesafe.ai and docs.typesafe.ai where the profile runs and off elsewhere, git writes blocked — the orchestrator commits).
|
|
55
131
|
|
|
56
132
|
Usage:
|
|
57
133
|
codex-exec [--nonce <n>] <plan-file|->
|
|
@@ -125,39 +201,42 @@ Notes:
|
|
|
125
201
|
nested inside a harness sandbox (the FS turns read-only) — route it OUTSIDE the harness sandbox
|
|
126
202
|
(excludedCommands / a per-run consented bypass) on the OBSERVED bwrap/EPERM failure, never a
|
|
127
203
|
preemptive blanket
|
|
128
|
-
exec posture banner: ONE stderr line before dispatch states the ACTUAL run posture —
|
|
129
|
-
|
|
130
|
-
from RESOLVED post-validation values; the resume id is validated
|
|
131
|
-
a model, effort, tier or timeout value refuse pre-spend, and a jev=
|
|
204
|
+
exec posture banner: ONE stderr line before dispatch states the ACTUAL run posture — exec
|
|
205
|
+
posture: model=… effort=… tier=… sandbox=jev-profile|workspace-write session=fresh|resume:<id>
|
|
206
|
+
jev=… source=… timeout=… — from RESOLVED post-validation values; the resume id is validated
|
|
207
|
+
pre-spend, control bytes in a model, effort, tier or timeout value refuse pre-spend, and a jev=
|
|
208
|
+
reason shows a control byte as ?
|
|
132
209
|
threat model: the sidecar byte and grammar screens detect corrupted input under a trusted parent
|
|
133
210
|
environment. A hostile parent environment — including exported shell functions or PATH
|
|
134
211
|
substitution of core/backend commands — is outside the threat model and can substitute the
|
|
135
|
-
backend itself. Targeted shadow-proof resolution protects banner/dispatch honesty from
|
|
136
|
-
shadowing; it is not an environment security boundary
|
|
137
|
-
the exec posture banner states what the run reaches in a jev= field:
|
|
138
|
-
when the run carries the permissions profile `jev` (Linux, codex-cli
|
|
139
|
-
outside every temp root, a version and profile digest not
|
|
140
|
-
jev=unreachable (<reason>) on today's workspace-write flags with
|
|
141
|
-
refuses the profile exits 72 with no success receipt and, for a
|
|
142
|
-
version and digest when the state file can be written, so the
|
|
143
|
-
source=model:<s>,effort:<s> field —
|
|
144
|
-
|
|
145
|
-
uncapped
|
|
146
|
-
|
|
212
|
+
backend itself. Targeted shadow-proof resolution protects banner/dispatch honesty from
|
|
213
|
+
accidental shadowing; it is not an environment security boundary
|
|
214
|
+
the exec posture banner states what the run reaches in a jev= field: the run hosts its
|
|
215
|
+
service-facts.txt lists when the run carries the permissions profile `jev` (Linux, codex-cli
|
|
216
|
+
0.160.0 or newer, a repository outside every temp root, a version and profile digest not
|
|
217
|
+
recorded as refused), else jev=unreachable (<reason>) on today's workspace-write flags with
|
|
218
|
+
network off; a run whose codex refuses the profile exits 72 with no success receipt and, for a
|
|
219
|
+
refused profile key, records its version and digest when the state file can be written, so the
|
|
220
|
+
next run on them takes today's flags; then a banner-only source=model:<s>,effort:<s> field —
|
|
221
|
+
where each value came from: default, setting or environment — then a banner-only
|
|
222
|
+
timeout=<duration|uncapped> field — exactly the duration handed to timeout(1), uncapped when no
|
|
223
|
+
timeout/gtimeout binary caps the run; INFORMATIONAL only: none of the three is persisted in a
|
|
224
|
+
receipt or session sidecar
|
|
147
225
|
quote the posture banner verbatim when labeling this dispatch — the banner is the machine-stated
|
|
148
226
|
posture; a prose re-type drifts
|
|
149
227
|
every-run nested-sandbox scan (DUAL policy, deliberately two different rules): the scan runs on
|
|
150
|
-
EVERY completed run, not only a failed one, because a run that SURVIVES the nested-sandbox
|
|
151
|
-
exits 0 with an ungrounded answer and nothing said so. Failed run (rc != 0): the
|
|
152
|
-
whole-trace combination rule prints the recovery hint. Successful run (rc == 0):
|
|
153
|
-
ONLY on precise per-item evidence — both a sandbox-mechanism token AND a
|
|
154
|
-
failure token inside the aggregated_output of ONE command_execution item
|
|
155
|
-
(a nonzero exit_code, or the serialized status "failed"); a null
|
|
156
|
-
itself, tokens split across two items never fire, and a successful
|
|
157
|
-
The answer is printed FIRST on stdout, then the warning on stderr.
|
|
158
|
-
status does NOT change on that lane (a distinct nonzero exit would
|
|
159
|
-
polarity, refusing real work whenever the scan over-warns), so an
|
|
160
|
-
status alone can still bank an ungrounded answer — the stderr
|
|
228
|
+
EVERY completed run, not only a failed one, because a run that SURVIVES the nested-sandbox
|
|
229
|
+
failure exits 0 with an ungrounded answer and nothing said so. Failed run (rc != 0): the
|
|
230
|
+
existing loose whole-trace combination rule prints the recovery hint. Successful run (rc == 0):
|
|
231
|
+
a warning fires ONLY on precise per-item evidence — both a sandbox-mechanism token AND a
|
|
232
|
+
permission/read-only failure token inside the aggregated_output of ONE command_execution item
|
|
233
|
+
whose failure is PROVEN (a nonzero exit_code, or the serialized status "failed"); a null
|
|
234
|
+
exit_code is never failure by itself, tokens split across two items never fire, and a successful
|
|
235
|
+
command's output never fires. The answer is printed FIRST on stdout, then the warning on stderr.
|
|
236
|
+
HONEST RESIDUAL: the exit status does NOT change on that lane (a distinct nonzero exit would
|
|
237
|
+
give a heuristic scan DENY polarity, refusing real work whenever the scan over-warns), so an
|
|
238
|
+
orchestrator keying on exit status alone can still bank an ungrounded answer — the stderr
|
|
239
|
+
warning is the signal
|
|
161
240
|
|
|
162
241
|
Settings file (KEY=VALUE, parsed never sourced; env wins over file, file wins over built-in default):
|
|
163
242
|
${XDG_CONFIG_HOME:-~/.config}/agent-workflow/bridge-settings.conf
|
|
@@ -367,15 +446,15 @@ aw_resolve_timeout_bin() {
|
|
|
367
446
|
printf '%s' "$bin"
|
|
368
447
|
}
|
|
369
448
|
aw_scrub_billing_keys() {
|
|
370
|
-
|
|
371
|
-
# switch a run to paid billing; TYPESAFE_API_KEY is neither read nor set, so it reaches the CLI exactly as given.
|
|
372
|
-
local name
|
|
449
|
+
local name passed keep
|
|
373
450
|
unset OPENAI_BASE_URL 2>/dev/null || true
|
|
374
451
|
for name in $(compgen -v); do
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
452
|
+
[[ "$name" == *_API_KEY ]] || continue
|
|
453
|
+
keep=0
|
|
454
|
+
for passed in ${AW_FACT_PASSED_VARIABLE[@]+"${AW_FACT_PASSED_VARIABLE[@]}"}; do
|
|
455
|
+
[[ "$name" != "$passed" ]] || keep=1
|
|
456
|
+
done
|
|
457
|
+
if (( ! keep )); then unset "$name" 2>/dev/null || true; fi
|
|
379
458
|
done
|
|
380
459
|
return 0
|
|
381
460
|
}
|
|
@@ -430,7 +509,7 @@ CHATGPT_LOGIN_GUARD="Logged in using ChatGPT"
|
|
|
430
509
|
# receipt this wrapper mints; scripts/release/version-sync.mjs bumps it under the one-anchor-per-file
|
|
431
510
|
# rule, so a release can never leave it behind (the AD-053 drift class).
|
|
432
511
|
AW_RECEIPT_BACKEND="codex"
|
|
433
|
-
AW_BRIDGE_VERSION="
|
|
512
|
+
AW_BRIDGE_VERSION="6.0.0" # aw-version-anchor
|
|
434
513
|
# The kill grace handed to timeout(1) as --kill-after, and recorded in the receipt as killGraceS:
|
|
435
514
|
# ONE constant, so the number the ledger checks against the dispatch deadline is the number the run
|
|
436
515
|
# actually applied.
|
|
@@ -496,15 +575,16 @@ if [[ ! -f AGENTS.md ]]; then
|
|
|
496
575
|
fi
|
|
497
576
|
|
|
498
577
|
# --- The permissions profile `jev` (spec jev-every-run) — byte-identical in codex-exec.sh and codex-review.sh ---
|
|
499
|
-
#
|
|
500
|
-
# --sandbox nor sandbox_mode beside them: its filesystem part is this wrapper's AW_PROFILE_FILESYSTEM, and its
|
|
501
|
-
# network reaches api.typesafe.ai and docs.typesafe.ai and no other host (a literal of this bridge, which never
|
|
502
|
-
# imports the kit). Elsewhere, and on a codex version and profile digest recorded as refused, the run keeps
|
|
503
|
-
# today's flags and its banner says jev=unreachable (<reason>). Each run, a resume included, chooses afresh.
|
|
578
|
+
# The run hosts come from service-facts.txt.
|
|
504
579
|
AW_PROFILE_FLOOR="0.160.0"
|
|
505
|
-
|
|
580
|
+
aw_profile_domains="" aw_run_hosts="" aw_reachable_hosts=""
|
|
581
|
+
for aw_host in ${AW_FACT_RUN_HOST[@]+"${AW_FACT_RUN_HOST[@]}"}; do
|
|
582
|
+
aw_profile_domains+="${aw_profile_domains:+,}\"$aw_host\"=\"allow\""
|
|
583
|
+
aw_run_hosts+="${aw_run_hosts:+,}$aw_host"
|
|
584
|
+
aw_reachable_hosts+="${aw_reachable_hosts:+, }$aw_host"
|
|
585
|
+
done
|
|
506
586
|
AW_PROFILE_FLAGS=(-c default_permissions=jev -c permissions.jev.network.enabled=true
|
|
507
|
-
-c
|
|
587
|
+
-c "permissions.jev.network.domains={$aw_profile_domains}"
|
|
508
588
|
-c "permissions.jev.filesystem=$AW_PROFILE_FILESYSTEM")
|
|
509
589
|
# The version on the first line of `codex --version` ("codex-cli X.Y.Z[-pre]"); nothing when unreadable.
|
|
510
590
|
aw_codex_version() { # $1 = the timeout binary or ""
|
|
@@ -571,7 +651,9 @@ aw_profile_choose() { # $1 = the timeout binary or "", $2 = the repository's t
|
|
|
571
651
|
profile_version="$(aw_codex_version "$1")"
|
|
572
652
|
profile_digest="$(aw_profile_digest)"
|
|
573
653
|
os="$(uname -s 2>/dev/null)" || os=""
|
|
574
|
-
if
|
|
654
|
+
if (( ! ${#AW_FACT_RUN_HOST[@]} )); then
|
|
655
|
+
profile_reason="no run host in service-facts.txt"
|
|
656
|
+
elif [[ "$os" != "Linux" ]]; then
|
|
575
657
|
profile_reason="not linux (${os:-unreadable})"
|
|
576
658
|
elif [[ -z "$profile_version" ]]; then
|
|
577
659
|
profile_reason="codex version unreadable"
|
|
@@ -584,7 +666,7 @@ aw_profile_choose() { # $1 = the timeout binary or "", $2 = the repository's t
|
|
|
584
666
|
else
|
|
585
667
|
profile_on=1
|
|
586
668
|
fi
|
|
587
|
-
if (( profile_on )); then profile_label="$
|
|
669
|
+
if (( profile_on )); then profile_label="$aw_run_hosts"; else profile_label="unreachable ($profile_reason)"; fi
|
|
588
670
|
profile_label="${profile_label//[$'\x01'-$'\x1f'$'\x7f']/?}"
|
|
589
671
|
return 0
|
|
590
672
|
}
|
|
@@ -650,13 +732,12 @@ aw_profile_choose "$timeout_bin" "$(aw_repo_temp_root)"
|
|
|
650
732
|
network_flags=()
|
|
651
733
|
if (( profile_on )); then
|
|
652
734
|
aw_sandbox_label="jev-profile"
|
|
653
|
-
read -r -d '' aw_network_item <<
|
|
654
|
-
5. Do NOT commit. Network: the
|
|
655
|
-
reachable; network access to any other host is an escalation: STOP and report.
|
|
735
|
+
read -r -d '' aw_network_item <<ITEM || true
|
|
736
|
+
5. Do NOT commit. Network: the reachable host list is $aw_reachable_hosts; network access to any other host is an escalation: STOP and report.
|
|
656
737
|
If you hit another blocker needing escalation (writes outside the repo, a live
|
|
657
738
|
approval, or an ambiguous decision), STOP and report it clearly — never guess.
|
|
658
739
|
ITEM
|
|
659
|
-
aw_network_line="Network, as of this run (it replaces any earlier statement): the
|
|
740
|
+
aw_network_line="Network, as of this run (it replaces any earlier statement): the reachable host list is $aw_reachable_hosts; network access to any other host is an escalation: STOP and report."
|
|
660
741
|
else
|
|
661
742
|
aw_sandbox_label="workspace-write"
|
|
662
743
|
network_flags=(-c sandbox_workspace_write.network_access=false)
|
|
@@ -683,7 +764,7 @@ ORCHESTRATOR EXECUTION CONTRACT — read before the task, follow it exactly:
|
|
|
683
764
|
task). If the project declares NO gate set, STOP and report — do NOT invent
|
|
684
765
|
checks. Fix every failure before finishing.
|
|
685
766
|
DIRECTIVE
|
|
686
|
-
# Item 5 states this run's posture (spec jev-every-run): the
|
|
767
|
+
# Item 5 states this run's posture (spec jev-every-run): the run hosts on a profile run, network access whole on a fallback run.
|
|
687
768
|
ORCHESTRATOR_DIRECTIVE="$ORCHESTRATOR_DIRECTIVE"$'\n'"$aw_network_item"$'\n\nTASK:'
|
|
688
769
|
|
|
689
770
|
read -r -d '' RESUME_REMINDER <<'REMINDER' || true
|