@flinbein/pappai-runner-codex 0.2.13 → 0.2.14

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
@@ -57,7 +57,7 @@ For a manual import, place a Codex `auth.json` in a directory the caller can rea
57
57
 
58
58
  The runner supports API keys and imported ChatGPT subscription credentials. Each installation stores its connection at `profiles/<profileId>/<runnerName>/` and coordinates token refresh across its APPs. The default installation named `codex` keeps its existing history under `state/`. Other installations keep their history under `state/instances/<runnerName>/`. Each subscription worker receives only short-lived credentials. The rotation test uses the native Codex CLI and a local OAuth test server.
59
59
 
60
- Each key in `run` names a complete variant with `settings` and `executors`. In a one-shot variant, define methods under `settings.methods` with optional `inputSchema` and `outputSchema`. The model receives the JSON input as its user message. Each invocation uses its own temporary thread. To process subscribed events, add `settings.events`, for example `{"instructions":"Summarize each incident."}`. This one handler receives the event name, source, subscription and data. Without it the runner acknowledges events without starting a model turn.
60
+ Each key in `run` names a complete variant with `settings` and `executors`. In a one-shot variant, define methods under `settings.methods` with optional `inputSchema` and `outputSchema`. The model receives the JSON input as its user message. Each invocation uses its own temporary thread. To process subscribed events, add `settings.events`, for example `{"cwd":"/tmp","instructions":"Summarize each incident."}`. This one handler receives the event name, source, subscription and data. Without it the runner acknowledges events without starting a model turn.
61
61
 
62
62
  Set `model`, `effort` and `instructions` in settings for APP defaults. Each method or event handler can override individual fields. For example, a method can set `"instructions":{"select":"/prompt","from":"options"}`. An explicitly empty instructions string clears the default for that handler. The controller resolves Patterns in the context of the assignment.
63
63
 
@@ -71,7 +71,7 @@ To authorize administrative chat requests, list the trusted USER node IDs in the
71
71
 
72
72
  ## Manifest templates
73
73
 
74
- In the APP manifest menu, **Persistent agent** edits instructions, model and reasoning effort. **Agent tasks** configures independent methods, their optional JSON schemas and an optional incoming-event handler. The runner obtains models and supported efforts from the installed CLI's `model/list` response and caches the catalog for one minute. **Default** omits the setting. If the catalog is unavailable, only Default is offered.
74
+ In the APP manifest menu, **Persistent agent** edits the working directory, instructions, model and reasoning effort. **Agent tasks** configures independent methods, their optional JSON schemas and an optional incoming-event handler. The runner obtains models and supported efforts from the installed CLI's `model/list` response and caches the catalog for one minute. **Default** omits the setting. If the catalog is unavailable, only Default is offered.
75
75
 
76
76
  The form reads the manifest with the initiator's permissions. Applying saves inline JSON. A compatible named variant retains its executor settings and MCP configuration. The form warns when converting Pattern instructions to plain text. To inspect a running worker's live diagnostics, use the APP's `$.app.executors.stderr` pipe method.
77
77
 
@@ -83,7 +83,7 @@ To use a terminal or pipe method, call `pappai_stream_open({node,method,input,mo
83
83
 
84
84
  Workers support Code Mode. For example, `functions.exec` can run `text(await tools.pappai_discover({}))`. 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.
85
85
 
86
- 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.
86
+ Use pappai_shell for commands. The controller runs each command in the APP sandbox with its configured working directory and private temporary directory. Inline manifests require an absolute cwd for every launch; file manifests resolve relative paths against the manifest directory. The Codex control process keeps its own isolated working directory. Use `run.settings` to select the model, reasoning effort and developer instructions.
87
87
 
88
88
  ## HTTP MCP
89
89
 
@@ -5,6 +5,7 @@
5
5
  "instructions": "Complete the assignment in the input field. Reply in the user's language.",
6
6
  "methods": {
7
7
  "agent.execute": {
8
+ "cwd": "/tmp",
8
9
  "description": "Complete a text assignment",
9
10
  "version": "1",
10
11
  "inputSchema": {
@@ -2,6 +2,7 @@
2
2
  "run": {
3
3
  "asAgent": {
4
4
  "settings": {
5
+ "cwd": "/tmp",
5
6
  "instructions": "Read each workspace event and summarize the change."
6
7
  },
7
8
  "executors": {
@@ -2,6 +2,7 @@
2
2
  "type": "object",
3
3
  "additionalProperties": false,
4
4
  "properties": {
5
+ "cwd": {"type":"string","minLength":1},
5
6
  "model": {
6
7
  "type": "string",
7
8
  "minLength": 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flinbein/pappai-runner-codex",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "Codex app-server runner for pappai",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
@@ -17,22 +17,23 @@ const modelSettings = {
17
17
  effort:patterned(settingsSchema.properties.effort),
18
18
  instructions:patternRef,
19
19
  }
20
+ const launchSettings = {...modelSettings,cwd:{type:'string',minLength:1}}
20
21
  const common = {...modelSettings,mcp:settingsSchema.properties.mcp}
21
22
  const method = object({
22
- ...modelSettings,
23
+ ...launchSettings,
23
24
  description:{type:'string',maxLength:255},version:{type:'string',minLength:1},doc:string,
24
25
  inputSchema:schema,outputSchema:schema,
25
26
  })
26
27
  const methods = {type:'object',minProperties:1,maxProperties:512,propertyNames:{
27
28
  pattern:'^[A-Za-z0-9_-]+(?:\\.[A-Za-z0-9_-]+)*$',not:{enum:['agent.getHistory','agent.interrupt','agent.sendMessage']},
28
29
  },additionalProperties:method}
29
- const oneShotSettings = {...object({...common,methods,events:object(modelSettings)}),
30
+ const oneShotSettings = {...object({...common,methods,events:object(launchSettings)}),
30
31
  anyOf:[{properties:{methods:{}},required:['methods']},{properties:{events:{}},required:['events']}]}
31
32
  const variant = (settings,executors) => object({settings,executors},['settings','executors'])
32
33
  export const runConfigurationSchema = {
33
34
  type:'object',$defs:{pattern},oneOf:[
34
35
  variant(oneShotSettings,object({mode:{const:'oneShot'},poolSize:{type:'integer',minimum:1,maximum:20},maxLifetimeMs:duration},['mode'])),
35
- variant(object(common),object({mode:{const:'persistent'},idleTimeoutMs:{anyOf:[duration,{type:'null'}]},
36
+ variant(object({...common,cwd:launchSettings.cwd}),object({mode:{const:'persistent'},idleTimeoutMs:{anyOf:[duration,{type:'null'}]},
36
37
  maxRestarts:{type:'integer',minimum:0,maximum:10}},['mode'])),
37
38
  ],
38
39
  }
package/src/templates.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import {posix} from 'node:path'
1
2
  import Ajv2020 from 'ajv/dist/2020.js'
2
3
  import addFormats from 'ajv-formats'
3
4
  import {runConfigurationSchema} from './run-configuration.mjs'
@@ -13,7 +14,7 @@ const matches=ajv.compile(runConfigurationSchema)
13
14
  const object=(properties,required=[])=>({type:'object',properties,required,additionalProperties:false})
14
15
  const field=(type,key,label,required=false)=>({type,key,label,required})
15
16
  const warning=text=>({type:'paragraph',level:'warning',text})
16
- const empty={instructions:'',model:'',effort:''}
17
+ const empty={instructions:'',cwd:'',model:'',effort:''}
17
18
  const dialect='https://json-schema.org/draft/2020-12/schema'
18
19
  const methodName={type:'string',pattern:'^[A-Za-z0-9_-]+(?:\\.[A-Za-z0-9_-]+)*$',
19
20
  not:{enum:['agent.sendMessage','agent.getHistory','agent.interrupt']}}
@@ -50,10 +51,10 @@ function modelFields(models) {
50
51
  const allowed=new Map([['',defaultEfforts],...[...catalog].map(([key,m])=>[key,m.efforts])])
51
52
  const choices=[{value:'',label:'Default'},...[...catalog].map(([value,m])=>({value,label:m.label}))]
52
53
  const efforts=[...new Set([...allowed.values()].flat())]
53
- const elements=[field('textarea','instructions','Instructions'),{...field('select','model','Model'),choices},
54
+ const elements=[field('textarea','instructions','Instructions'),field('directory','cwd','Working directory',true),{...field('select','model','Model'),choices},
54
55
  {...field('select','effort','Reasoning effort'),choices:[{value:'',label:'Default'},...efforts.map(value=>({
55
56
  value,label:value,visibleWhen:{select:'/model',in:[...allowed].filter(([,list])=>list.includes(value)).map(([key])=>key)}}))]}]
56
- const properties={instructions:{type:'string'},model:{enum:[...allowed.keys()]},effort:{enum:['',...efforts]}}
57
+ const properties={cwd:{type:'string',pattern:'^/',minLength:1},instructions:{type:'string'},model:{enum:[...allowed.keys()]},effort:{enum:['',...efforts]}}
57
58
  const allOf=[...allowed].map(([key,list])=>({if:key==='' ? {properties:{model:{const:''}}} :
58
59
  {properties:{model:{const:key}},required:['model']},then:{properties:{effort:{enum:['',...list]}}}}))
59
60
  return {elements,properties,allOf}
@@ -74,6 +75,7 @@ function descriptor(template,context,models) {
74
75
  if (typeof value[key]==='string') data[key]=value[key]
75
76
  else if (key==='instructions' && typeof value.instructions?.value==='string') data.instructions=value.instructions.value
76
77
  }
78
+ if (context.file) data.cwd=posix.resolve(posix.dirname(context.file),data.cwd || '.')
77
79
  return data
78
80
  }
79
81
  const patternWarning=warning('Applying this form replaces Pattern instructions with plain text and removes substitutions.')
@@ -81,14 +83,14 @@ function descriptor(template,context,models) {
81
83
  const handlers=[settings,...Object.values(settings.methods ?? {}),settings.events].filter(Boolean)
82
84
  if (handlers.some(h=>['model','effort'].some(k=>typeof h[k]==='object')))
83
85
  elements.push(warning('Applying replaces model and reasoning effort Patterns in the edited fields.'))
84
- const handlerSchema={...object(properties),allOf}
86
+ const handlerSchema={...object(properties,['cwd']),allOf}
85
87
  if (template==='persistentAgent') {
86
88
  elements.push(fields[0],...(isPattern(settings) ? [patternWarning] : []),...fields.slice(1))
87
89
  return {elements,formData:handler(settings),schema:handlerSchema}
88
90
  }
89
91
  const schemaValue={anyOf:[{type:'object'},{type:'boolean'}]}
90
92
  const rowSchema={...object({name:methodName,description:{type:'string',maxLength:255},...properties,
91
- inputSchema:schemaValue,outputSchema:schemaValue},['name']),allOf}
93
+ inputSchema:schemaValue,outputSchema:schemaValue},['name','cwd']),allOf}
92
94
  const methods=Object.entries(settings.methods ?? {}).map(([name,m])=>({name,description:m.description ?? '',...handler(m),
93
95
  ...(m.inputSchema!==undefined && {inputSchema:m.inputSchema}),...(m.outputSchema!==undefined && {outputSchema:m.outputSchema})}))
94
96
  const newItem={name:'',description:'',...empty}
@@ -100,7 +102,7 @@ function descriptor(template,context,models) {
100
102
  visibleWhen:{select:'/handleIncomingEvents',in:[true]},elements:[fields[0],...(isPattern(settings.events) ? [patternWarning] : []),...fields.slice(1)]})
101
103
  const formData={methods:old ? methods : [{...newItem,name:'run'}],handleIncomingEvents:!!settings.events,events:handler(settings.events)}
102
104
  const schema={...object({methods:{type:'array',items:rowSchema,maxItems:512},handleIncomingEvents:{type:'boolean'},events:{}},['methods','handleIncomingEvents']),
103
- if:{properties:{handleIncomingEvents:{const:true}}},then:{properties:{events:handlerSchema}},
105
+ if:{properties:{handleIncomingEvents:{const:true}}},then:{required:['events'],properties:{events:handlerSchema}},
104
106
  else:{properties:{methods:{type:'array',minItems:1}}}}
105
107
  return {elements,formData,schema}
106
108
  }
package/src/tools.mjs CHANGED
@@ -4,6 +4,7 @@ const timeoutMs = {type:'integer',minimum:1,maximum:86400000}
4
4
  const size = {type:'integer',minimum:1,maximum:1000}
5
5
  const streamId = {id:string}
6
6
  const definitions = [
7
+ ['shell','Run a shell command in the configured APP working directory inside its pappai filesystem sandbox. Returns exitCode, stdout and stderr.',{command:{type:'string',minLength:1,maxLength:65536}},['command']],
7
8
  ['me','Return the id, parentId, type and name of the APP making this request.',{},[]],
8
9
  ['discover','List workspace nodes that this APP can discover. Use their IDs with pappai_help.',{},[]],
9
10
  ['help','Read the public contract of a visible node. Set features to true for all names, or select names and request their schema and documentation.',{node:string,