@leo000001/codex-mcp 2.1.6 → 2.1.7

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
@@ -204,7 +204,7 @@ Start a Codex agent session asynchronously. Returns immediately with `sessionId`
204
204
 
205
205
  </details>
206
206
 
207
- **Returns:** `{ sessionId, threadId, status, pollInterval?, execution?, interactionState?, recommendedNextAction? }`
207
+ **Returns:** `{ sessionId, threadId, status, pollInterval?, progress?, execution?, interactionState?, recommendedNextAction? }`
208
208
 
209
209
  ```json
210
210
  {
@@ -217,6 +217,40 @@ Start a Codex agent session asynchronously. Returns immediately with `sessionId`
217
217
  }
218
218
  ```
219
219
 
220
+ Structured output example:
221
+
222
+ ```json
223
+ {
224
+ "prompt": "Return a short health summary",
225
+ "approvalPolicy": "on-failure",
226
+ "sandbox": "workspace-write",
227
+ "advanced": {
228
+ "outputSchema": {
229
+ "type": "object",
230
+ "properties": {
231
+ "ok": { "type": "boolean" },
232
+ "summary": { "type": "string" }
233
+ },
234
+ "required": ["ok", "summary"]
235
+ }
236
+ }
237
+ }
238
+ ```
239
+
240
+ If the backend accepts the schema, the terminal `result` includes `structuredOutput`:
241
+
242
+ ```json
243
+ {
244
+ "result": {
245
+ "text": "Health check complete.",
246
+ "structuredOutput": {
247
+ "ok": true,
248
+ "summary": "Repository is healthy"
249
+ }
250
+ }
251
+ }
252
+ ```
253
+
220
254
  ### Resources
221
255
 
222
256
  If your MCP client supports resources, this server exposes a few **read-only** resources:
@@ -246,13 +280,14 @@ Send a follow-up message to an existing session.
246
280
  | `outputSchema` | object | No | JSON Schema for structured output |
247
281
  | `waitForResult` | number | No | Wait up to this many ms for the reply turn to complete and return the result directly. Max `300000` (5 min). Falls back to polling when the turn does not finish in time or needs interactive approval. |
248
282
 
249
- **Returns:** `{ sessionId, threadId, status, pollInterval?, result?, completedAt?, execution?, interactionState?, recommendedNextAction? }`
283
+ **Returns:** `{ sessionId, threadId, status, pollInterval?, progress?, result?, completedAt?, execution?, interactionState?, recommendedNextAction? }`
250
284
 
251
285
  Additional orchestration hints may be present in `codex`, `codex_reply`, and `codex_check` responses:
252
286
 
253
287
  - `execution`: whether foreground waiting was requested/effective, and whether it fell back to background polling
254
288
  - `interactionState`: `working`, `waiting_input`, or `finished`
255
289
  - `recommendedNextAction`: `poll`, `respond_permission`, `respond_user_input`, or `none`
290
+ - `progress`: normalized phase metadata, pending-action count, last observed method, and token totals when the backend exposes them
256
291
 
257
292
  ```json
258
293
  {
@@ -263,13 +298,17 @@ Additional orchestration hints may be present in `codex`, `codex_reply`, and `co
263
298
 
264
299
  ### `codex_session` — Manage sessions
265
300
 
266
- List, inspect, cancel, interrupt, fork sessions, or clean background terminals.
301
+ List, inspect, cancel, interrupt, fork, batch-clean sessions, or clean background terminals.
267
302
 
268
- | Parameter | Type | Required | Description |
269
- | ------------------ | ------- | -------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
270
- | `action` | string | Yes | `"list"`, `"get"`, `"cancel"`, `"interrupt"`, `"fork"`, or `"clean_background_terminals"` |
271
- | `sessionId` | string | For get/cancel/interrupt/fork/clean_background_terminals | Target session ID |
272
- | `includeSensitive` | boolean | No | Include `cwd`/`profile`/`config`/`threadId` in `get`. Default: `false` |
303
+ | Parameter | Type | Required | Description |
304
+ | ------------------ | -------- | -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
305
+ | `action` | string | Yes | `"list"`, `"get"`, `"cancel"`, `"interrupt"`, `"fork"`, `"clean"`, or `"clean_background_terminals"` |
306
+ | `sessionId` | string | For get/cancel/interrupt/fork/clean_background_terminals | Target session ID |
307
+ | `includeSensitive` | boolean | No | Include `cwd`/`profile`/`config`/`threadId` in `get`. Default: `false` |
308
+ | `statuses` | string[] | No | For `clean` only. Terminal statuses to remove: `"idle"`, `"error"`, `"cancelled"` |
309
+ | `olderThanMs` | number | No | For `clean` only. Only match sessions older than this many ms |
310
+ | `dryRun` | boolean | No | For `clean` only. Preview matches without deleting |
311
+ | `includeDisk` | boolean | No | For `clean` only. Default: `true`; also remove persisted session state |
273
312
 
274
313
  **Returns:**
275
314
 
@@ -277,6 +316,7 @@ List, inspect, cancel, interrupt, fork sessions, or clean background terminals.
277
316
  - `action="get"` → `PublicSessionInfo` (or `SensitiveSessionInfo` when `includeSensitive=true`)
278
317
  - `action="cancel"|"interrupt"` → `{ success: true, message }`
279
318
  - `action="fork"` → `{ sessionId, threadId, status: "idle", pollInterval }`
319
+ - `action="clean"` → `{ matchedSessionIds, removedSessionIds, removedCount, diskSessionsRemoved, dryRun }`
280
320
  - `action="clean_background_terminals"` → `{ success: true, message }`
281
321
 
282
322
  ```json
@@ -285,6 +325,7 @@ List, inspect, cancel, interrupt, fork sessions, or clean background terminals.
285
325
  { "action": "cancel", "sessionId": "sess_abc123" }
286
326
  { "action": "interrupt", "sessionId": "sess_abc123" }
287
327
  { "action": "fork", "sessionId": "sess_abc123" }
328
+ { "action": "clean", "statuses": ["cancelled"], "olderThanMs": 3600000 }
288
329
  { "action": "clean_background_terminals", "sessionId": "sess_abc123" }
289
330
  ```
290
331
 
@@ -299,7 +340,7 @@ Query a running session for events, respond to approval requests, or answer user
299
340
  | `cursor` | number | No | Event cursor for incremental polling (`action="poll"`). For `respond_*`, codex-mcp applies monotonic cursor progression: `max(cursor, sessionLastCursor)`. |
300
341
  | `maxEvents` | number | No | Keep this small. `poll` default: `1` (minimum `1`; increase only for catch-up). `respond_*` default: `0` (recommended; compact ACK, no event replay). |
301
342
  | `responseMode` | string | No | Response shaping mode: `minimal` (default), `delta_compact`, `full` |
302
- | `pollOptions` | object | No | Optional controls: `includeEvents` (default `true`), `includeActions` (default `true`), `includeResult` (default `true`), `maxBytes` (default unlimited) |
343
+ | `pollOptions` | object | No | Optional controls: `includeEvents` (default `true`), `includeActions` (default `true`), `includeResult` (default `true`), `skipDeltas`, `finalOnly`, `maxBytes` (default unlimited) |
303
344
  | `requestId` | string | For respond_permission/user_input | Request ID from `actions[]` |
304
345
  | `decision` | string | For respond_permission | For command approvals: `"accept"`, `"acceptForSession"`, `"acceptWithExecpolicyAmendment"`, `"applyNetworkPolicyAmendment"`, `"decline"`, `"cancel"`; for file changes: `"accept"`, `"acceptForSession"`, `"decline"`, `"cancel"` |
305
346
  | `execpolicy_amendment` | string[] | For acceptWithExecpolicyAmendment | Exec policy amendment list (required when `decision="acceptWithExecpolicyAmendment"`) |
@@ -307,7 +348,7 @@ Query a running session for events, respond to approval requests, or answer user
307
348
  | `denyMessage` | string | No | Internal note on deny (not sent to app-server) |
308
349
  | `answers` | object | For respond_user_input | For `respond_user_input`: `question-id -> { answers: string[] }` |
309
350
 
310
- **Returns (poll and respond\_\*):** `{ sessionId, status, pollInterval?, interactionState?, recommendedNextAction?, cursorResetTo?, events, nextCursor, actions?, result? }`
351
+ **Returns (poll and respond\_\*):** `{ sessionId, status, pollInterval?, progress?, interactionState?, recommendedNextAction?, cursorResetTo?, events, nextCursor, actions?, result? }`
311
352
 
312
353
  ```json
313
354
  { "action": "poll", "sessionId": "sess_abc123", "cursor": 0 }
@@ -336,7 +377,11 @@ Query a running session for events, respond to approval requests, or answer user
336
377
  - If `cursor` is omitted, codex-mcp continues from that session's last consumed cursor.
337
378
  - If `responseMode` is omitted, codex-mcp uses `minimal`.
338
379
  - `pollOptions.includeEvents/includeActions/includeResult` default to `true`.
380
+ - `pollOptions.skipDeltas=true` drops streaming delta events but still advances the cursor past them.
381
+ - `pollOptions.finalOnly=true` omits `events[]`, focuses on `actions[]` plus terminal `result`, and advances the cursor past hidden events.
339
382
  - `pollOptions.maxBytes` is optional and enforces best-effort payload truncation (`truncated`, `truncatedFields`).
383
+ - `progress.phase` gives a coarse execution snapshot (`starting`, `reasoning`, `acting`, `waiting_approval`, `finished`, etc.).
384
+ - `progress.tokens` is populated when the backend exposes token counts.
340
385
  - `respond_*` defaults to compact ACK (`events: []`, no cursor advance) unless you explicitly pass `maxEvents`.
341
386
  - `poll` defaults to `maxEvents=1` to keep payloads small; increase temporarily (for example `10-20`) when you need to catch up faster.
342
387
  - If `poll` is called with `maxEvents=0`, codex-mcp treats it as `1` to avoid no-op polling loops.
@@ -345,6 +390,7 @@ Query a running session for events, respond to approval requests, or answer user
345
390
 
346
391
  Event types include `output`, `progress`, `approval_request`, `approval_result`, `result`, `error`.
347
392
  Approvals/results/errors are pinned to reduce eviction risk.
393
+ When a turn completes, `result.text` provides a stable final assistant message. It falls back to the last completed `agentMessage` item when the backend omits `turn.output`. `result.output` remains the raw backend `turn.output` value when present.
348
394
 
349
395
  ## Approvals & User Input
350
396