@flinbein/pappai-runner-codex 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -24
- package/examples/oneShot.json +2 -2
- package/examples/persistent.json +4 -4
- package/package.json +1 -1
- package/src/http-mcp.mjs +2 -1
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# @flinbein/pappai-runner-codex
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This external runner delivers [pappai](https://github.com/flinbein/pappai) events and method calls to the Codex CLI through `app-server`. A one-shot executor creates an ephemeral thread for a single assignment. A persistent executor processes turns sequentially in one thread and resumes it after a process restart.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The runner requires a pappai controller that supports PROFILE nodes and administrator-supplied runner configuration, Linux x86_64 with working bubblewrap, Node.js 24.2+, and the native musl distribution of the Codex CLI. Compatibility tests use Codex `0.170.0`. Install the CLI separately on a persistent volume. Set `codexExecutablePath` to the executable itself.
|
|
8
8
|
|
|
9
|
-
1.
|
|
10
|
-
2.
|
|
11
|
-
3.
|
|
9
|
+
1. Mount a persistent private volume at `/run/pappai/private`. Create `profiles` and `state` directories there, owned by the pappai process user with mode `0700`. Only the administrator should have write access to the runner code and CLI installation.
|
|
10
|
+
2. Install the package, for example with `npm install --prefix /run/pappai/private/runners --omit=dev @flinbein/pappai-runner-codex`.
|
|
11
|
+
3. Use `call` to invoke `$.runners.add` on the workspace (`node: "~"`) with the following arguments. To have the controller validate APP settings, supply the [settings schema](examples/settings-schema.json) in the `settingsSchema` field when registering the runner.
|
|
12
12
|
|
|
13
13
|
```json
|
|
14
14
|
{
|
|
@@ -22,29 +22,31 @@
|
|
|
22
22
|
}
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
##
|
|
25
|
+
## First call
|
|
26
26
|
|
|
27
|
-
1.
|
|
28
|
-
2.
|
|
29
|
-
3.
|
|
30
|
-
4.
|
|
31
|
-
5.
|
|
27
|
+
1. Call `$.profile.create` on the workspace or a TEAM with a name and permissions. Save the returned ID.
|
|
28
|
+
2. Sign in with the Codex CLI and place the resulting `auth.json` in a directory the caller can read. Call `codex.setup` on the PROFILE with `{"authFile":"/tmp/codex-auth.json"}`. The controller reads the regular file as the caller. After import, `codex.status({})` returns `{"configured":true}`. Use `codex.remove({})` to remove the stored connection.
|
|
29
|
+
3. Call `$.app.create` on the workspace or a TEAM with `name`, `profile`, `permissions` and `source.manifest`. Use the [one-shot](examples/oneShot.json) or [persistent](examples/persistent.json) manifest.
|
|
30
|
+
4. Call `$.profile.scope.set({"scope":["APP_ID"]})` on the PROFILE using the new APP's ID, then call `$.profile.enable({})`. Call `$.app.start({})` on the APP.
|
|
31
|
+
5. Call `agent.execute` on the APP with `{"input":"Translate into Russian: the build passed"}`. The example method declares a string result. You can declare a different output JSON Schema for your own method. The runner validates the result before replying.
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
The controller checks assignment access before an event reaches the model. Each executor obtains model credentials from its assigned profile at startup. APPs that share a profile keep separate conversation histories. Set `idleTimeoutMs` on a persistent APP to release its process between assignments.
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
The runner supports API keys and imported ChatGPT subscription credentials. A single runner host owns the profiles directory and coordinates token refresh across its APPs. Each subscription worker receives only short-lived credentials. Give each runner host exclusive use of its profile storage. The rotation test uses the native Codex CLI and a local OAuth test server.
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
A persistent APP can also declare `agent.getHistory` and `agent.interrupt` under `features`. History returns user messages and final assistant replies with a pagination cursor. Interrupt targets the active turn and requires permission to call the method. If no turn is active, the controller returns an error. Both methods run without a model call.
|
|
38
38
|
|
|
39
|
-
##
|
|
39
|
+
## Executor permissions
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
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
|
+
|
|
43
|
+
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.
|
|
42
44
|
|
|
43
45
|
## HTTP MCP
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
To configure a shared server, call `codex.mcp.set({"name":"tasks","url":"https://tasks.example.org/mcp","bearerFile":"/tmp/tasks-token"})` on the PROFILE. The optional file contains one bearer token. Each call replaces the entire entry. Omitting `bearerFile` removes any previous token. `codex.mcp.get({})` lists URLs and indicates which entries have credentials. `codex.mcp.delete({"name":"tasks"})` deletes an entry. Changes apply on the next executor launch. Disable the profile to revoke access immediately.
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
In the APP's `run.settings`, select shared servers by name under `mcp.profile`, and declare APP-owned HTTP endpoints under `mcp.servers`. This example selects the PROFILE's authenticated task service and an APP-local calendar endpoint that accepts unauthenticated requests.
|
|
48
50
|
|
|
49
51
|
```json
|
|
50
52
|
{
|
|
@@ -55,12 +57,19 @@
|
|
|
55
57
|
}
|
|
56
58
|
```
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
| Connection | Effective network permission required at launch |
|
|
61
|
+
|---|---|
|
|
62
|
+
| APP endpoint in `mcp.servers` | The APP allows network access. |
|
|
63
|
+
| Selected endpoint in `mcp.profile` | Both the APP and its assigned PROFILE allow network access for this APP. |
|
|
64
|
+
|
|
65
|
+
The runner omits denied endpoints and their credentials before Codex initializes. Servers enabled together must have distinct names. A suppressed PROFILE entry never supplies credentials to an APP endpoint, even when their names match. Controllers that omit the `profileMcpNetwork` grant can still supply APP endpoints subject to the network permission they dispatch. Upgrade the controller and runner together for the full permission model.
|
|
66
|
+
|
|
67
|
+
External endpoints require HTTPS. Loopback tests may use HTTP on `127.0.0.1` or `[::1]`. URLs cannot include credentials, a query, or a fragment. The runner supports HTTP endpoints only. MCP OAuth login, stdio commands, and raw Codex configuration for managed servers are unsupported. [MCP design and protocol probes](https://github.com/flinbein/pappai/blob/master/docs/dev/runners/mcp.md)
|
|
59
68
|
|
|
60
|
-
##
|
|
69
|
+
## Development and publishing
|
|
61
70
|
|
|
62
|
-
|
|
71
|
+
Run `npm ci --ignore-scripts` and `npm test`. On Linux, create `/run/pappai/private` with write access for the test user. To run tests with the real CLI, set `PAPPAI_TEST_CODEX_CLI` to the absolute path of the native executable. Linux integration tests require bubblewrap. The [controller acceptance test](https://github.com/flinbein/pappai/blob/master/tests/codex-package.test.ts) exercises the installed npm archive through pappai.
|
|
63
72
|
|
|
64
|
-
|
|
73
|
+
Each push to `master` runs the tests and publishes to the public npm registry. The workflow adds its run number minus one to the base patch version. Re-running a published build verifies the archive checksum. The first build of the `0.1` series uses version `0.1.0`.
|
|
65
74
|
|
|
66
|
-
|
|
75
|
+
In npm Trusted Publisher settings, choose GitHub, owner `flinbein`, repository `pappai-runner-codex`, and workflow `publish.yml`. Enable direct publication (`npm publish`). To create the package, the scope owner can publish the verified archive locally after signing in through the browser, or supply a short-lived granular token through the Actions secret `NPM_TOKEN`. Remove the secret once OIDC publishing is configured. [npm trusted publisher setup](https://docs.npmjs.com/trusted-publishers/)
|
package/examples/oneShot.json
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"run": {
|
|
3
3
|
"type": "codex",
|
|
4
4
|
"settings": {
|
|
5
|
-
"developerInstructions": "
|
|
5
|
+
"developerInstructions": "Complete the task in data.input. Reply in the user's language.",
|
|
6
6
|
"features": {
|
|
7
7
|
"agent.execute": {
|
|
8
8
|
"type": "method",
|
|
9
|
-
"description": "
|
|
9
|
+
"description": "Complete a text assignment",
|
|
10
10
|
"version": "1",
|
|
11
11
|
"schema": {
|
|
12
12
|
"input": {
|
package/examples/persistent.json
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"run": {
|
|
3
3
|
"type": "codex",
|
|
4
4
|
"settings": {
|
|
5
|
-
"developerInstructions": "
|
|
5
|
+
"developerInstructions": "Complete the task in data.input. Reply in the user's language.",
|
|
6
6
|
"features": {
|
|
7
7
|
"agent.execute": {
|
|
8
8
|
"type": "method",
|
|
9
|
-
"description": "
|
|
9
|
+
"description": "Complete a text assignment",
|
|
10
10
|
"version": "1",
|
|
11
11
|
"schema": {
|
|
12
12
|
"input": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"agent.getHistory": {
|
|
31
31
|
"type": "method",
|
|
32
32
|
"version": "1",
|
|
33
|
-
"description": "
|
|
33
|
+
"description": "Return a page of conversation history",
|
|
34
34
|
"schema": {
|
|
35
35
|
"input": {
|
|
36
36
|
"type": "object",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"agent.interrupt": {
|
|
52
52
|
"type": "method",
|
|
53
53
|
"version": "1",
|
|
54
|
-
"description": "
|
|
54
|
+
"description": "Interrupt the active turn",
|
|
55
55
|
"schema": {
|
|
56
56
|
"input": {
|
|
57
57
|
"type": "object",
|
package/package.json
CHANGED
package/src/http-mcp.mjs
CHANGED
|
@@ -84,7 +84,8 @@ export async function resolveHttpMcp(config,job) {
|
|
|
84
84
|
const mcp=job.settings?.mcp;
|
|
85
85
|
if (!mcp || (job.sandbox!==null && job.sandbox?.network!==true)) return denied;
|
|
86
86
|
keys(mcp,['profile','servers']);
|
|
87
|
-
|
|
87
|
+
// Older controllers omit this grant. Ignore denied selections before reading profile storage.
|
|
88
|
+
const selected=job.profileMcpNetwork===true ? (mcp.profile ?? []) : [];
|
|
88
89
|
if (!Array.isArray(selected) || selected.length>64) throw Error('Invalid MCP profile selection');
|
|
89
90
|
const local=mcp.servers ?? {};
|
|
90
91
|
if (!local || typeof local!=='object' || Array.isArray(local) || Object.keys(local).length+selected.length>64) throw Error('Invalid MCP servers');
|