@babylonjs-toolkit/agent 1.1.8 → 1.1.10

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.
@@ -0,0 +1,2 @@
1
+ [sandbox_workspace_write]
2
+ network_access = true
package/README.md CHANGED
@@ -16,8 +16,9 @@ npx @babylonjs-toolkit/agent install
16
16
  ```
17
17
 
18
18
  That installs **every skill** into every skills directory and the **Agent Persona** into every
19
- global instruction file, on macOS, Linux and Windows. Then restart your agent session — skills
20
- and instruction files are only read at session start.
19
+ global instruction file, on macOS, Linux and Windows. Codex targets also enable outbound
20
+ network access in their workspace-write configuration. Restart your agent session to pick
21
+ up the skills, instructions and configuration.
21
22
 
22
23
  ### Commands
23
24
 
@@ -76,6 +77,31 @@ Use `--no-self-update` to skip the npm check entirely.
76
77
  Gemini CLI is a separate entry on purpose: it reads `GEMINI.md`, **not** `AGENTS.md`, so
77
78
  `~/.agents/AGENTS.md` alone never reaches it.
78
79
 
80
+ Codex installs (the default `codex` target, or `codex-legacy`) also merge the shipped
81
+ [`.codex/config.toml`](.codex/config.toml) setting into `~/.codex/config.toml`, or
82
+ `<project>/.codex/config.toml` with `--project`:
83
+
84
+ ```toml
85
+ [sandbox_workspace_write]
86
+ network_access = true
87
+ ```
88
+
89
+ This allows outbound network access to all domains while using the workspace-write
90
+ sandbox, including fetching the Agent Reference from GitHub. It does not change the
91
+ sandbox mode, filesystem permissions or approval policy. Managed policies can override
92
+ this setting; project configuration applies only to trusted projects.
93
+
94
+ Install, update and the global npm postinstall hook apply this setting whenever a Codex
95
+ target is selected, including `--persona-only` and `--no-persona` runs. An existing
96
+ `network_access = false` is changed to `true`; other settings and comments are preserved.
97
+ Changed configurations are backed up to `config.toml.bak`; repeated installs are idempotent
98
+ and `--dry-run` writes nothing. Standard TOML sections and root dotted keys are supported;
99
+ an inline `sandbox_workspace_write = { ... }` table is left untouched with an actionable
100
+ error, so convert it to the section form above before retrying.
101
+ `bt-agent doctor` checks the setting, and `bt-agent targets` lists its destination.
102
+ Uninstall retains this configuration and its backup as user preferences. Selecting only
103
+ non-Codex targets leaves Codex configuration untouched.
104
+
79
105
  Your instruction files are never truncated. The persona goes in as a managed block:
80
106
 
81
107
  ```markdown
package/bin/bt-agent.js CHANGED
@@ -12,7 +12,8 @@ const USAGE = `
12
12
  @babylonjs-toolkit/agent ${version}
13
13
 
14
14
  Installs the Babylon Toolkit agent skills and Agent Persona for every
15
- supported AI client, on macOS, Linux and Windows.
15
+ supported AI client, on macOS, Linux and Windows. Codex targets also
16
+ enable outbound network access in their workspace-write configuration.
16
17
 
17
18
  Usage
18
19
  bt-agent [command] [options]
@@ -137,6 +138,11 @@ function printInstall(report) {
137
138
  }
138
139
  }
139
140
 
141
+ for (const entry of report.config) {
142
+ console.log(` config ${prettyPath(entry.file)} — ${entry.action} (network_access = true)`);
143
+ if (entry.backup) console.log(` backup: ${prettyPath(entry.backup)}`);
144
+ }
145
+
140
146
  if (report.pruned.length) {
141
147
  console.log('');
142
148
  for (const p of report.pruned) console.log(` pruned ${prettyPath(p)} (no longer shipped)`);
@@ -194,7 +200,8 @@ function restartNote(report) {
194
200
  const parts = [];
195
201
  if (report.skillsInstalled !== false) parts.push('skills');
196
202
  if (report.persona.length) parts.push('persona');
197
- const what = parts.length === 2 ? 'skills and persona are' : `${parts[0] || 'files'} ${parts[0] === 'skills' ? 'are' : 'is'}`;
203
+ if (report.config.length) parts.push('Codex configuration');
204
+ const what = parts.length > 1 ? `${parts.join(', ')} are` : `${parts[0] || 'files'} ${parts[0] === 'skills' ? 'are' : 'is'}`;
198
205
  console.log('\nRestart your agent session (Claude Code, Codex, Copilot, Gemini CLI)');
199
206
  console.log(`so the ${what} picked up.\n`);
200
207
  }
@@ -203,7 +210,7 @@ function printDoctor(result) {
203
210
  const { checked } = result;
204
211
  console.log(
205
212
  `\nChecked ${checked.skills} skills / ${checked.files} files across ` +
206
- `${checked.skillDirs.length} skill dir(s) and ${checked.instructionFiles.length} instruction file(s).\n`
213
+ `${checked.skillDirs.length} skill dir(s), ${checked.instructionFiles.length} instruction file(s) and ${checked.configFiles.length} config file(s).\n`
207
214
  );
208
215
  if (result.ok) {
209
216
  console.log('INSTALL OK');
@@ -222,6 +229,7 @@ function targetsJson(mode, projectRoot) {
222
229
  default: Boolean(t.default),
223
230
  skills: spec.skills ? resolveTargetPath(spec.skills, mode, projectRoot) : null,
224
231
  instructions: spec.instructions ? resolveTargetPath(spec.instructions, mode, projectRoot) : null,
232
+ config: spec.config ? resolveTargetPath(spec.config, mode, projectRoot) : null,
225
233
  };
226
234
  });
227
235
  }
@@ -234,6 +242,7 @@ function printTargets(mode) {
234
242
  console.log(` [${flag}] ${t.id.padEnd(13)} ${t.label}`);
235
243
  if (spec.skills) console.log(` skills: ${spec.skills}`);
236
244
  if (spec.instructions) console.log(` instructions: ${spec.instructions}`);
245
+ if (spec.config) console.log(` config: ${spec.config}`);
237
246
  }
238
247
  console.log('');
239
248
  }
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { PACKAGE_ROOT } = require('./paths');
6
+
7
+ const KEY = '(?:network_access|"network_access"|\'network_access\')';
8
+ const TABLE = '(?:sandbox_workspace_write|"sandbox_workspace_write"|\'sandbox_workspace_write\')';
9
+ const header = new RegExp(`^\\s*\\[\\s*${TABLE}\\s*\\]\\s*(?:#.*)?$`);
10
+ const setting = new RegExp(`^(\\s*${KEY}\\s*=\\s*)(true|false)(\\s*(?:#.*)?)$`);
11
+ const dotted = new RegExp(`^(\\s*${TABLE}\\s*\\.\\s*${KEY}\\s*=\\s*)(true|false)(\\s*(?:#.*)?)$`);
12
+
13
+ /** Ignore apparent settings inside TOML strings (including multiline strings). */
14
+ function codeLines(lines) {
15
+ let quote = null;
16
+ return lines.map((line) => {
17
+ const startsInString = quote !== null;
18
+ let code = '';
19
+ for (let i = 0; i < line.length; i += 1) {
20
+ const c = line[i];
21
+ if (quote) {
22
+ if (quote[0] === '"' && c === '\\') { i += 1; continue; }
23
+ if (line.startsWith(quote, i)) {
24
+ let end = i + quote.length;
25
+ // A multiline TOML string may end in four or five quotes.
26
+ if (quote.length === 3) while (end < i + 5 && line[end] === quote[0]) end += 1;
27
+ i = end - 1;
28
+ quote = null;
29
+ }
30
+ } else if (c === '#') {
31
+ break;
32
+ } else if (c === '"' || c === "'") {
33
+ quote = line.startsWith(c.repeat(3), i) ? c.repeat(3) : c;
34
+ i += quote.length - 1;
35
+ } else {
36
+ code += c;
37
+ }
38
+ }
39
+ return startsInString ? '' : code.trim();
40
+ });
41
+ }
42
+
43
+ /** Change only this boolean; keep comments, other settings and line endings. */
44
+ function enableNetwork(source) {
45
+ const eol = source.includes('\r\n') ? '\r\n' : '\n';
46
+ const lines = source.split(/\r?\n/);
47
+ const code = codeLines(lines);
48
+ let inTable = false;
49
+ let root = true;
50
+ let tableLine = -1;
51
+ let rootDottedSibling = false;
52
+ for (let i = 0; i < lines.length; i += 1) {
53
+ if (!code[i]) continue;
54
+ if (code[i].startsWith('[')) {
55
+ root = false;
56
+ inTable = header.test(lines[i]);
57
+ if (inTable) tableLine = i;
58
+ continue;
59
+ }
60
+ const match = (inTable ? setting : root ? dotted : /$^/).exec(lines[i]);
61
+ if (match) {
62
+ lines[i] = `${match[1]}true${match[3]}`;
63
+ return lines.join(eol);
64
+ }
65
+ if (root && new RegExp(`^\\s*${TABLE}\\s*\\.`).test(lines[i])) rootDottedSibling = true;
66
+ // Do not create duplicate TOML keys for an unsupported representation.
67
+ if ((root && new RegExp(`^\\s*${TABLE}\\s*=`).test(lines[i])) ||
68
+ (inTable && new RegExp(`^\\s*${KEY}\\s*=`).test(lines[i])) ||
69
+ (root && new RegExp(`^\\s*${TABLE}\\s*\\.\\s*${KEY}\\s*=`).test(lines[i]))) {
70
+ throw new Error('Cannot safely merge Codex network_access. Use [sandbox_workspace_write] with network_access = true or false.');
71
+ }
72
+ }
73
+ if (tableLine !== -1) {
74
+ lines.splice(tableLine + 1, 0, 'network_access = true');
75
+ return lines.join(eol);
76
+ }
77
+ // Dotted sibling keys define the table already; extend it at the root.
78
+ if (rootDottedSibling) {
79
+ return `sandbox_workspace_write.network_access = true${eol}${source}`;
80
+ }
81
+ const template = fs.readFileSync(path.join(PACKAGE_ROOT, '.codex', 'config.toml'), 'utf8').replace(/\r?\n/g, eol);
82
+ return source + (source && !source.endsWith('\n') ? eol : '') + (source ? eol : '') + template;
83
+ }
84
+
85
+ function applyCodexConfig(file, { dryRun = false } = {}) {
86
+ const exists = fs.existsSync(file);
87
+ const source = exists ? fs.readFileSync(file, 'utf8') : '';
88
+ const next = enableNetwork(source);
89
+ const action = !exists ? 'created' : next === source ? 'unchanged' : 'updated';
90
+ const backup = action === 'updated' ? `${file}.bak` : undefined;
91
+ if (!dryRun && action !== 'unchanged') {
92
+ fs.mkdirSync(path.dirname(file), { recursive: true });
93
+ if (backup) fs.copyFileSync(file, backup);
94
+ fs.writeFileSync(file, next, 'utf8');
95
+ }
96
+ return { file, action, ...(backup ? { backup } : {}) };
97
+ }
98
+
99
+ function hasCodexNetwork(file) {
100
+ try {
101
+ const source = fs.readFileSync(file, 'utf8');
102
+ return enableNetwork(source) === source;
103
+ } catch {
104
+ return false;
105
+ }
106
+ }
107
+
108
+ module.exports = { enableNetwork, applyCodexConfig, hasCodexNetwork };
package/lib/doctor.js CHANGED
@@ -6,6 +6,7 @@ const path = require('path');
6
6
  const { resolveTargets } = require('./targets');
7
7
  const { listSkills } = require('./payload');
8
8
  const { hasPersona } = require('./persona');
9
+ const { hasCodexNetwork } = require('./codex-config');
9
10
 
10
11
  /**
11
12
  * Verify an install.
@@ -44,6 +45,10 @@ function doctor(opts = {}) {
44
45
  }
45
46
  }
46
47
 
48
+ for (const { file } of resolved.configFiles) {
49
+ if (!hasCodexNetwork(file)) missing.push(`${file} (sandbox_workspace_write.network_access = true)`);
50
+ }
51
+
47
52
  return {
48
53
  ok: missing.length === 0,
49
54
  missing,
@@ -52,6 +57,7 @@ function doctor(opts = {}) {
52
57
  files: skills.reduce((n, s) => n + s.files.length, 0),
53
58
  skillDirs: checkSkills ? resolved.skillDirs.map((d) => d.dir) : [],
54
59
  instructionFiles: resolved.instructionFiles.map((f) => f.file),
60
+ configFiles: resolved.configFiles.map((f) => f.file),
55
61
  },
56
62
  };
57
63
  }
package/lib/install.js CHANGED
@@ -6,6 +6,7 @@ const path = require('path');
6
6
  const { resolveTargets } = require('./targets');
7
7
  const { listSkills, copyDir } = require('./payload');
8
8
  const { applyPersona, removePersona, personaText } = require('./persona');
9
+ const { applyCodexConfig } = require('./codex-config');
9
10
  const manifest = require('./manifest');
10
11
  const { manifestPath } = require('./paths');
11
12
 
@@ -48,10 +49,17 @@ function install(opts = {}) {
48
49
  skills: skills.map((s) => s.name),
49
50
  skillDirs: [],
50
51
  persona: [],
52
+ config: [],
51
53
  pruned: [],
52
54
  manifest: manifestPath(mode, projectRoot),
53
55
  };
54
56
 
57
+ // Preflight every merge before changing installed skills or instructions.
58
+ for (const { file } of resolved.configFiles) applyCodexConfig(file, { dryRun: true });
59
+ for (const { file, targets } of resolved.configFiles) {
60
+ report.config.push({ ...applyCodexConfig(file, { dryRun }), targets });
61
+ }
62
+
55
63
  for (const { dir, targets } of installSkills ? resolved.skillDirs : []) {
56
64
  if (!dryRun) fs.mkdirSync(dir, { recursive: true });
57
65
 
@@ -97,6 +105,7 @@ function install(opts = {}) {
97
105
  mode,
98
106
  projectRoot: mode === 'project' ? projectRoot : undefined,
99
107
  skillDirs,
108
+ config: report.config,
100
109
  persona: report.persona.map(({ file, action }) => ({ file, action })),
101
110
  });
102
111
  }
@@ -106,6 +115,7 @@ function install(opts = {}) {
106
115
 
107
116
  /**
108
117
  * Remove the skills this package installed, plus the managed persona block.
118
+ * Codex config is retained as a user preference, including its backup.
109
119
  * Manifest-scoped: anything the manifest does not list is left alone.
110
120
  */
111
121
  function uninstall(opts = {}) {
package/lib/targets.js CHANGED
@@ -32,8 +32,8 @@ const TARGETS = [
32
32
  id: 'codex',
33
33
  label: 'Codex chat clients (Codex CLI / Codex IDE)',
34
34
  default: true,
35
- global: { skills: null, instructions: '~/.codex/AGENTS.md' },
36
- project: { skills: null, instructions: 'AGENTS.md' },
35
+ global: { skills: null, instructions: '~/.codex/AGENTS.md', config: '~/.codex/config.toml' },
36
+ project: { skills: null, instructions: 'AGENTS.md', config: '.codex/config.toml' },
37
37
  },
38
38
  {
39
39
  id: 'gemini',
@@ -49,8 +49,8 @@ const TARGETS = [
49
49
  // Pre-`.agents` Codex CLI builds read ~/.codex/skills. Opt in with --legacy-codex.
50
50
  label: 'Legacy Codex CLI skills directory',
51
51
  default: false,
52
- global: { skills: '~/.codex/skills', instructions: null },
53
- project: { skills: '.codex/skills', instructions: null },
52
+ global: { skills: '~/.codex/skills', instructions: null, config: '~/.codex/config.toml' },
53
+ project: { skills: '.codex/skills', instructions: null, config: '.codex/config.toml' },
54
54
  },
55
55
  ];
56
56
 
@@ -76,10 +76,17 @@ function resolveTargets({ mode = 'global', projectRoot = process.cwd(), ids = nu
76
76
  const selected = TARGETS.filter((t) => wanted.has(t.id));
77
77
  const skillDirs = new Map();
78
78
  const instructionFiles = new Map();
79
+ const configFiles = new Map();
79
80
 
80
81
  for (const t of selected) {
81
82
  const spec = mode === 'project' ? t.project : t.global;
82
83
 
84
+ const config = resolveTargetPath(spec.config, mode, projectRoot);
85
+ if (config) {
86
+ if (!configFiles.has(config)) configFiles.set(config, { file: config, targets: [] });
87
+ configFiles.get(config).targets.push(t.id);
88
+ }
89
+
83
90
  const skillsDir = resolveTargetPath(spec.skills, mode, projectRoot);
84
91
  if (skillsDir) {
85
92
  if (!skillDirs.has(skillsDir)) skillDirs.set(skillsDir, { dir: skillsDir, targets: [] });
@@ -99,6 +106,7 @@ function resolveTargets({ mode = 'global', projectRoot = process.cwd(), ids = nu
99
106
  selected,
100
107
  skillDirs: [...skillDirs.values()],
101
108
  instructionFiles: [...instructionFiles.values()],
109
+ configFiles: [...configFiles.values()],
102
110
  };
103
111
  }
104
112
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs-toolkit/agent",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "description": "Installs the Babylon Toolkit agent skills and Agent Persona for Claude Code, Codex, GitHub Copilot, Gemini CLI and Antigravity.",
5
5
  "keywords": [
6
6
  "babylonjs",
@@ -28,11 +28,13 @@
28
28
  "bin",
29
29
  "lib",
30
30
  "scripts",
31
- "persona.md"
31
+ "persona.md",
32
+ ".codex/config.toml"
32
33
  ],
33
34
  "scripts": {
34
35
  "postinstall": "node scripts/postinstall.js",
35
- "deploy-all": "npm publish --access public"
36
+ "deploy-all": "npm publish --access public",
37
+ "test": "node --test tests/*.test.js"
36
38
  },
37
39
  "engines": {
38
40
  "node": ">=18"
@@ -34,8 +34,10 @@ function main() {
34
34
  for (const entry of report.skillDirs) console.log(` skills ${entry.dir}`);
35
35
  for (const p of report.persona) console.log(` persona ${p.file} — ${p.action}`);
36
36
 
37
+ for (const c of report.config) console.log(` config ${c.file} — ${c.action} (network_access = true)`);
38
+
37
39
  console.log(check.ok ? '\nINSTALL OK' : '\nINSTALL INCOMPLETE — run `bt-agent doctor` for details');
38
- console.log('\nRestart your agent session so the skills and persona are picked up.\n');
40
+ console.log('\nRestart your agent session so the skills, persona and Codex configuration are picked up.\n');
39
41
  }
40
42
 
41
43
  try {