codex-codes 0.129.3

A tightly typed Rust interface for the OpenAI Codex CLI JSON protocol
Documentation
// AUTO-GENERATED by scripts/codegen_protocol.py — DO NOT EDIT BY HAND.

use serde_json::{json, Value};

/// Notification samples keyed by JSON-RPC method.
pub fn server_notification_samples() -> Vec<(&'static str, Value)> {
    vec![
        ("account/login/completed", json!({"success": false})),
        ("account/rateLimits/updated", json!({"rateLimits": {}})),
        ("account/updated", json!({})),
        ("app/list/updated", json!({"data": []})),
        (
            "command/exec/outputDelta",
            json!({"capReached": false, "deltaBase64": "x", "processId": "x", "stream": null}),
        ),
        ("configWarning", json!({"summary": "x"})),
        ("deprecationNotice", json!({"summary": "x"})),
        (
            "error",
            json!({"error": {"message": "x"}, "threadId": "x", "turnId": "x", "willRetry": false}),
        ),
        ("externalAgentConfig/import/completed", json!({})),
        ("fs/changed", json!({"changedPaths": [], "watchId": "x"})),
        (
            "fuzzyFileSearch/sessionCompleted",
            json!({"sessionId": "x"}),
        ),
        (
            "fuzzyFileSearch/sessionUpdated",
            json!({"files": [], "query": "x", "sessionId": "x"}),
        ),
        ("guardianWarning", json!({"message": "x", "threadId": "x"})),
        (
            "hook/completed",
            json!({"run": {"displayOrder": 0, "entries": [], "eventName": "preToolUse", "executionMode": "sync", "handlerType": "command", "id": "x", "scope": "thread", "sourcePath": "x", "startedAt": 0, "status": "running"}, "threadId": "x"}),
        ),
        (
            "hook/started",
            json!({"run": {"displayOrder": 0, "entries": [], "eventName": "preToolUse", "executionMode": "sync", "handlerType": "command", "id": "x", "scope": "thread", "sourcePath": "x", "startedAt": 0, "status": "running"}, "threadId": "x"}),
        ),
        (
            "item/agentMessage/delta",
            json!({"delta": "x", "itemId": "x", "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/autoApprovalReview/completed",
            json!({"action": {"command": "x", "cwd": "x", "source": "shell", "type": "command"}, "completedAtMs": 0, "decisionSource": "agent", "review": {"status": "inProgress"}, "reviewId": "x", "startedAtMs": 0, "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/autoApprovalReview/started",
            json!({"action": {"command": "x", "cwd": "x", "source": "shell", "type": "command"}, "review": {"status": "inProgress"}, "reviewId": "x", "startedAtMs": 0, "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/commandExecution/outputDelta",
            json!({"delta": "x", "itemId": "x", "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/commandExecution/terminalInteraction",
            json!({"itemId": "x", "processId": "x", "stdin": "x", "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/completed",
            json!({"completedAtMs": 0, "item": {"content": [], "id": "x", "type": "userMessage"}, "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/fileChange/outputDelta",
            json!({"delta": "x", "itemId": "x", "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/fileChange/patchUpdated",
            json!({"changes": [], "itemId": "x", "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/mcpToolCall/progress",
            json!({"itemId": "x", "message": "x", "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/plan/delta",
            json!({"delta": "x", "itemId": "x", "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/reasoning/summaryPartAdded",
            json!({"itemId": "x", "summaryIndex": 0, "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/reasoning/summaryTextDelta",
            json!({"delta": "x", "itemId": "x", "summaryIndex": 0, "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/reasoning/textDelta",
            json!({"contentIndex": 0, "delta": "x", "itemId": "x", "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/started",
            json!({"item": {"content": [], "id": "x", "type": "userMessage"}, "startedAtMs": 0, "threadId": "x", "turnId": "x"}),
        ),
        (
            "mcpServer/oauthLogin/completed",
            json!({"name": "x", "success": false}),
        ),
        (
            "mcpServer/startupStatus/updated",
            json!({"name": "x", "status": "starting"}),
        ),
        (
            "model/rerouted",
            json!({"fromModel": "x", "reason": "highRiskCyberActivity", "threadId": "x", "toModel": "x", "turnId": "x"}),
        ),
        (
            "model/verification",
            json!({"threadId": "x", "turnId": "x", "verifications": []}),
        ),
        (
            "process/exited",
            json!({"exitCode": 0, "processHandle": "x", "stderr": "x", "stderrCapReached": false, "stdout": "x", "stdoutCapReached": false}),
        ),
        (
            "process/outputDelta",
            json!({"capReached": false, "deltaBase64": "x", "processHandle": "x", "stream": null}),
        ),
        (
            "remoteControl/status/changed",
            json!({"installationId": "x", "status": "disabled"}),
        ),
        (
            "serverRequest/resolved",
            json!({"requestId": "x", "threadId": "x"}),
        ),
        ("skills/changed", json!({})),
        ("thread/archived", json!({"threadId": "x"})),
        ("thread/closed", json!({"threadId": "x"})),
        ("thread/compacted", json!({"threadId": "x", "turnId": "x"})),
        ("thread/goal/cleared", json!({"threadId": "x"})),
        (
            "thread/goal/updated",
            json!({"goal": {"createdAt": 0, "objective": "x", "status": "active", "threadId": "x", "timeUsedSeconds": 0, "tokensUsed": 0, "updatedAt": 0}, "threadId": "x"}),
        ),
        ("thread/name/updated", json!({"threadId": "x"})),
        ("thread/realtime/closed", json!({"threadId": "x"})),
        (
            "thread/realtime/error",
            json!({"message": "x", "threadId": "x"}),
        ),
        (
            "thread/realtime/itemAdded",
            json!({"item": null, "threadId": "x"}),
        ),
        (
            "thread/realtime/outputAudio/delta",
            json!({"audio": {"data": "x", "numChannels": 0, "sampleRate": 0}, "threadId": "x"}),
        ),
        ("thread/realtime/sdp", json!({"sdp": "x", "threadId": "x"})),
        (
            "thread/realtime/started",
            json!({"threadId": "x", "version": "v1"}),
        ),
        (
            "thread/realtime/transcript/delta",
            json!({"delta": "x", "role": "x", "threadId": "x"}),
        ),
        (
            "thread/realtime/transcript/done",
            json!({"role": "x", "text": "x", "threadId": "x"}),
        ),
        (
            "thread/started",
            json!({"thread": {"cliVersion": "x", "createdAt": 0, "cwd": null, "ephemeral": false, "id": "x", "modelProvider": "x", "preview": "x", "sessionId": "x", "source": null, "status": null, "turns": [], "updatedAt": 0}}),
        ),
        (
            "thread/status/changed",
            json!({"status": {"type": "notLoaded"}, "threadId": "x"}),
        ),
        (
            "thread/tokenUsage/updated",
            json!({"threadId": "x", "tokenUsage": {"last": {"cachedInputTokens": 0, "inputTokens": 0, "outputTokens": 0, "reasoningOutputTokens": 0, "totalTokens": 0}, "total": {"cachedInputTokens": 0, "inputTokens": 0, "outputTokens": 0, "reasoningOutputTokens": 0, "totalTokens": 0}}, "turnId": "x"}),
        ),
        ("thread/unarchived", json!({"threadId": "x"})),
        (
            "turn/completed",
            json!({"threadId": "x", "turn": {"id": "x", "items": [], "status": "completed"}}),
        ),
        (
            "turn/diff/updated",
            json!({"diff": "x", "threadId": "x", "turnId": "x"}),
        ),
        (
            "turn/plan/updated",
            json!({"plan": [], "threadId": "x", "turnId": "x"}),
        ),
        (
            "turn/started",
            json!({"threadId": "x", "turn": {"id": "x", "items": [], "status": "completed"}}),
        ),
        ("warning", json!({"message": "x"})),
        (
            "windows/worldWritableWarning",
            json!({"extraCount": 0, "failedScan": false, "samplePaths": []}),
        ),
        (
            "windowsSandbox/setupCompleted",
            json!({"mode": "elevated", "success": false}),
        ),
    ]
}

/// Client-request samples keyed by JSON-RPC method.
pub fn client_request_samples() -> Vec<(&'static str, Value)> {
    vec![
        ("account/login/cancel", json!({"loginId": "x"})),
        (
            "account/login/start",
            json!({"apiKey": "x", "type": "apiKey"}),
        ),
        ("account/logout", json!({})),
        ("account/rateLimits/read", json!({})),
        ("account/read", json!({})),
        (
            "account/sendAddCreditsNudgeEmail",
            json!({"creditType": "credits"}),
        ),
        ("app/list", json!({})),
        ("command/exec", json!({"command": []})),
        (
            "command/exec/resize",
            json!({"processId": "x", "size": null}),
        ),
        ("command/exec/terminate", json!({"processId": "x"})),
        ("command/exec/write", json!({"processId": "x"})),
        ("config/batchWrite", json!({"edits": []})),
        ("config/mcpServer/reload", json!({})),
        ("config/read", json!({})),
        (
            "config/value/write",
            json!({"keyPath": "x", "mergeStrategy": "replace", "value": null}),
        ),
        ("configRequirements/read", json!({})),
        (
            "experimentalFeature/enablement/set",
            json!({"enablement": {}}),
        ),
        ("experimentalFeature/list", json!({})),
        ("externalAgentConfig/detect", json!({})),
        ("externalAgentConfig/import", json!({"migrationItems": []})),
        (
            "feedback/upload",
            json!({"classification": "x", "includeLogs": false}),
        ),
        (
            "fs/copy",
            json!({"destinationPath": null, "sourcePath": null}),
        ),
        ("fs/createDirectory", json!({"path": null})),
        ("fs/getMetadata", json!({"path": null})),
        ("fs/readDirectory", json!({"path": null})),
        ("fs/readFile", json!({"path": null})),
        ("fs/remove", json!({"path": null})),
        ("fs/unwatch", json!({"watchId": "x"})),
        ("fs/watch", json!({"path": null, "watchId": "x"})),
        ("fs/writeFile", json!({"dataBase64": "x", "path": null})),
        ("fuzzyFileSearch", json!({"query": "x", "roots": []})),
        ("hooks/list", json!({})),
        (
            "initialize",
            json!({"clientInfo": {"name": "x", "version": "x"}}),
        ),
        ("marketplace/add", json!({"source": "x"})),
        ("marketplace/remove", json!({"marketplaceName": "x"})),
        ("marketplace/upgrade", json!({})),
        ("mcpServer/oauth/login", json!({"name": "x"})),
        (
            "mcpServer/resource/read",
            json!({"server": "x", "uri": "x"}),
        ),
        (
            "mcpServer/tool/call",
            json!({"server": "x", "threadId": "x", "tool": "x"}),
        ),
        ("mcpServerStatus/list", json!({})),
        ("model/list", json!({})),
        ("modelProvider/capabilities/read", json!({})),
        ("plugin/install", json!({"pluginName": "x"})),
        ("plugin/list", json!({})),
        ("plugin/read", json!({"pluginName": "x"})),
        ("plugin/share/checkout", json!({"remotePluginId": "x"})),
        ("plugin/share/delete", json!({"remotePluginId": "x"})),
        ("plugin/share/list", json!({})),
        ("plugin/share/save", json!({"pluginPath": "x"})),
        (
            "plugin/share/updateTargets",
            json!({"discoverability": "UNLISTED", "remotePluginId": "x", "shareTargets": []}),
        ),
        (
            "plugin/skill/read",
            json!({"remoteMarketplaceName": "x", "remotePluginId": "x", "skillName": "x"}),
        ),
        ("plugin/uninstall", json!({"pluginId": "x"})),
        (
            "review/start",
            json!({"target": {"type": "uncommittedChanges"}, "threadId": "x"}),
        ),
        ("skills/config/write", json!({"enabled": false})),
        ("skills/list", json!({})),
        (
            "thread/approveGuardianDeniedAction",
            json!({"event": null, "threadId": "x"}),
        ),
        ("thread/archive", json!({"threadId": "x"})),
        ("thread/compact/start", json!({"threadId": "x"})),
        ("thread/fork", json!({"threadId": "x"})),
        ("thread/inject_items", json!({"items": [], "threadId": "x"})),
        ("thread/list", json!({})),
        ("thread/loaded/list", json!({})),
        ("thread/metadata/update", json!({"threadId": "x"})),
        ("thread/name/set", json!({"name": "x", "threadId": "x"})),
        ("thread/read", json!({"threadId": "x"})),
        ("thread/resume", json!({"threadId": "x"})),
        ("thread/rollback", json!({"numTurns": 0, "threadId": "x"})),
        (
            "thread/shellCommand",
            json!({"command": "x", "threadId": "x"}),
        ),
        ("thread/start", json!({})),
        ("thread/unarchive", json!({"threadId": "x"})),
        ("thread/unsubscribe", json!({"threadId": "x"})),
        ("turn/interrupt", json!({"threadId": "x", "turnId": "x"})),
        ("turn/start", json!({"input": [], "threadId": "x"})),
        (
            "turn/steer",
            json!({"expectedTurnId": "x", "input": [], "threadId": "x"}),
        ),
        ("windowsSandbox/readiness", json!({})),
        ("windowsSandbox/setupStart", json!({"mode": "elevated"})),
    ]
}

/// Server-request (approval flow) samples keyed by JSON-RPC method.
pub fn server_request_samples() -> Vec<(&'static str, Value)> {
    vec![
        (
            "account/chatgptAuthTokens/refresh",
            json!({"reason": "unauthorized"}),
        ),
        (
            "applyPatchApproval",
            json!({"callId": "x", "conversationId": "x", "fileChanges": {}}),
        ),
        ("attestation/generate", json!({})),
        (
            "execCommandApproval",
            json!({"callId": "x", "command": [], "conversationId": "x", "cwd": "x", "parsedCmd": []}),
        ),
        (
            "item/commandExecution/requestApproval",
            json!({"itemId": "x", "startedAtMs": 0, "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/fileChange/requestApproval",
            json!({"itemId": "x", "startedAtMs": 0, "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/permissions/requestApproval",
            json!({"cwd": "x", "itemId": "x", "permissions": {}, "startedAtMs": 0, "threadId": "x", "turnId": "x"}),
        ),
        (
            "item/tool/call",
            json!({"arguments": null, "callId": "x", "threadId": "x", "tool": "x", "turnId": "x"}),
        ),
        (
            "item/tool/requestUserInput",
            json!({"itemId": "x", "questions": [], "threadId": "x", "turnId": "x"}),
        ),
        (
            "mcpServer/elicitation/request",
            json!({"message": "x", "mode": "form", "requestedSchema": {"properties": {}, "type": "object"}}),
        ),
    ]
}