@flinbein/pappai-runner-codex 0.1.5 → 0.1.6

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/README.md CHANGED
@@ -22,6 +22,12 @@ The runner requires a pappai controller that supports PROFILE nodes and administ
22
22
  }
23
23
  ```
24
24
 
25
+ ## Updating an existing registration
26
+
27
+ Find the installed entry point with `$.runners.get({})` on the workspace. Wait for active Codex turns to finish, then use the administrator terminal to install the desired package version under the same npm prefix as the registered entry point. For example, for an entry point under `/run/pappai/private/runners/node_modules/`, use `npm install --prefix /run/pappai/private/runners --omit=dev --ignore-scripts --save-exact @flinbein/pappai-runner-codex@VERSION`. Replace `VERSION` with the release number.
28
+
29
+ Call `$.runners.restart({"name":"codex"})` on the workspace to load the installed package with its saved configuration. Restart affects all active Codex workers. Use the same procedure with the previous package version to roll back.
30
+
25
31
  ## First call
26
32
 
27
33
  1. Call `$.profile.create` on the workspace or a TEAM with a name and permissions. Save the returned ID.
@@ -40,6 +46,8 @@ A persistent APP can also declare `agent.getHistory` and `agent.interrupt` under
40
46
 
41
47
  The executor runs in an isolated directory. Its connection to the model is a service channel. For workspace operations, the model receives the `pappai_dir`, `pappai_help`, `pappai_call` and `pappai_publish` tools. The controller authorizes calls as the assigned APP using its effective permissions. The PROFILE supplies the model credentials, and its scope controls which APPs may use them.
42
48
 
49
+ Workers support Code Mode. For example, `functions.exec` can run `text(await tools.pappai_dir({}))`. Keep the native `bin/codex-code-mode-host` beside `bin/codex` in the trusted CLI distribution. The runner mounts that helper read-only for APP workers. The separate credential refresh process keeps Code Mode disabled. The helper shares the app-server's network namespace. The JavaScript environment exposes the selected tools, and nested pappai calls undergo the usual controller permission checks.
50
+
43
51
  Shell, native Codex file tools and user configuration from the working directory are disabled. Use `run.settings` to select the model, reasoning effort and developer instructions. The administrator sets the CLI and storage paths when registering the runner.
44
52
 
45
53
  ## HTTP MCP
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flinbein/pappai-runner-codex",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Codex app-server runner for pappai",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
package/src/policy.mjs CHANGED
@@ -35,7 +35,7 @@ async function privateDir(path) {
35
35
  return path;
36
36
  }
37
37
 
38
- function configToml(modelBaseUrl) {
38
+ function configToml(modelBaseUrl, codeMode) {
39
39
  const lines = [
40
40
  'approval_policy="never"', 'default_permissions="pappai"', 'web_search="disabled"',
41
41
  'cli_auth_credentials_store="file"', 'mcp_oauth_credentials_store="file"',
@@ -54,7 +54,8 @@ function configToml(modelBaseUrl) {
54
54
  return [...lines,
55
55
  '[permissions.pappai.filesystem]', '"/work"="read"', '"/state"="deny"', '"/proc"="deny"',
56
56
  '[permissions.pappai.network]', 'enabled=false',
57
- '[features]', ...['apps','browser_use','browser_use_external','code_mode','code_mode_host',
57
+ '[features]', `code_mode=${codeMode}`, `code_mode_host=${codeMode}`,
58
+ ...['apps','browser_use','browser_use_external',
58
59
  'computer_use','goals','hooks','image_generation','in_app_browser','memories','multi_agent_v2',
59
60
  'plugins','remote_plugin','shell_snapshot','shell_tool','skill_search','unified_exec','view_image',
60
61
  'workspace_dependencies'].map(key => `${key}=false`),
@@ -68,19 +69,20 @@ function configToml(modelBaseUrl) {
68
69
  async function namespace(config, state, profileOwner, mcp) {
69
70
  const binary = await canonicalFile(config.codexExecutablePath, 'Codex executable');
70
71
  const bwrap = await canonicalFile(join(dirname(dirname(binary)), 'codex-resources', 'bwrap'), 'bundled Codex bubblewrap');
72
+ const codeModeHost = profileOwner ? null : await canonicalFile(join(dirname(binary), 'codex-code-mode-host'), 'bundled Codex Code Mode host');
71
73
  const mounts = (await readFile('/proc/self/mountinfo', 'utf8')).trim().split('\n').map(line => {
72
74
  const fields = line.split(' ');
73
75
  const target = fields[4].replace(/\\([0-7]{3})/g, (_, octal) => String.fromCharCode(parseInt(octal, 8)));
74
76
  return {target, readonly:fields[5].split(',').includes('ro')};
75
77
  });
76
- if (![binary,bwrap].every(path => protectedBinary(path,mounts))) {
78
+ if (![binary,bwrap,...(codeModeHost ? [codeModeHost] : [])].every(path => protectedBinary(path,mounts))) {
77
79
  throw Error('Codex distribution must be on a read-only mount or below /run/pappai/private');
78
80
  }
79
81
  if (typeof config.stateDir !== 'string' || !config.stateDir.startsWith('/run/pappai/private/')) {
80
82
  throw new Error('Runner state must be below /run/pappai/private');
81
83
  }
82
84
  const root = await privateDir(config.stateDir);
83
- const toml = configToml(config.modelBaseUrl);
85
+ const toml = configToml(config.modelBaseUrl, codeModeHost !== null);
84
86
  const run = await mkdtemp(join(root, 'run-'));
85
87
  const cleanup = () => rm(run, { recursive: true, force: true });
86
88
  try {
@@ -96,6 +98,7 @@ async function namespace(config, state, profileOwner, mcp) {
96
98
  '--die-with-parent', '--new-session', '--dev', '/dev', '--proc', '/proc', '--tmpfs', '/tmp',
97
99
  '--dir', work, '--tmpfs', '/state', '--dir', home, '--dir', '/state/home', '--ro-bind', binary, cliPath,
98
100
  '--ro-bind', bwrap, '/opt/codex/bin/bwrap'];
101
+ if (codeModeHost) args.push('--ro-bind', codeModeHost, '/opt/codex/bin/codex-code-mode-host');
99
102
  if (profileOwner) args.push('--bind', dirname(profileOwner.authPath), home);
100
103
  args.push('--ro-bind', configFile, home + '/config.toml', '--ro-bind', requirements, '/etc/codex/requirements.toml');
101
104
  for (const path of ['/etc/resolv.conf','/etc/hosts','/etc/ssl/certs/ca-certificates.crt']) {