{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "ThreadStartResponse",
  "type": "object",
  "required": [
    "approvalPolicy",
    "approvalsReviewer",
    "cwd",
    "model",
    "modelProvider",
    "sandbox",
    "thread"
  ],
  "properties": {
    "activePermissionProfile": {
      "description": "Named or implicit built-in profile that produced the active permissions, when known.",
      "default": null,
      "anyOf": [
        {
          "$ref": "#/definitions/ActivePermissionProfile"
        },
        {
          "type": "null"
        }
      ]
    },
    "approvalPolicy": {
      "$ref": "#/definitions/AskForApproval"
    },
    "approvalsReviewer": {
      "description": "Reviewer currently used for approval requests on this thread.",
      "allOf": [
        {
          "$ref": "#/definitions/ApprovalsReviewer"
        }
      ]
    },
    "cwd": {
      "$ref": "#/definitions/AbsolutePathBuf"
    },
    "instructionSources": {
      "description": "Instruction source files currently loaded for this thread.",
      "default": [],
      "type": "array",
      "items": {
        "$ref": "#/definitions/AbsolutePathBuf"
      }
    },
    "model": {
      "type": "string"
    },
    "modelProvider": {
      "type": "string"
    },
    "permissionProfile": {
      "description": "Full active permissions for this thread. `activePermissionProfile` carries display/provenance metadata for this runtime profile.",
      "default": null,
      "anyOf": [
        {
          "$ref": "#/definitions/PermissionProfile"
        },
        {
          "type": "null"
        }
      ]
    },
    "reasoningEffort": {
      "anyOf": [
        {
          "$ref": "#/definitions/ReasoningEffort"
        },
        {
          "type": "null"
        }
      ]
    },
    "sandbox": {
      "description": "Legacy sandbox policy retained for compatibility. Experimental clients should prefer `permissionProfile` when they need exact runtime permissions.",
      "allOf": [
        {
          "$ref": "#/definitions/SandboxPolicy"
        }
      ]
    },
    "serviceTier": {
      "anyOf": [
        {
          "$ref": "#/definitions/ServiceTier"
        },
        {
          "type": "null"
        }
      ]
    },
    "thread": {
      "$ref": "#/definitions/Thread"
    }
  },
  "definitions": {
    "AbsolutePathBuf": {
      "description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
      "type": "string"
    },
    "ActivePermissionProfile": {
      "type": "object",
      "required": ["id"],
      "properties": {
        "extends": {
          "description": "Parent profile identifier once permissions profiles support inheritance. This is currently always `null`.",
          "default": null,
          "type": ["string", "null"]
        },
        "id": {
          "description": "Identifier from `default_permissions` or the implicit built-in default, such as `:workspace` or a user-defined `[permissions.<id>]` profile.",
          "type": "string"
        },
        "modifications": {
          "description": "Bounded user-requested modifications applied on top of the named profile, if any.",
          "default": [],
          "type": "array",
          "items": {
            "$ref": "#/definitions/ActivePermissionProfileModification"
          }
        }
      }
    },
    "ActivePermissionProfileModification": {
      "oneOf": [
        {
          "description": "Additional concrete directory that should be writable.",
          "type": "object",
          "required": ["path", "type"],
          "properties": {
            "path": {
              "$ref": "#/definitions/AbsolutePathBuf"
            },
            "type": {
              "type": "string",
              "enum": ["additionalWritableRoot"],
              "title": "AdditionalWritableRootActivePermissionProfileModificationType"
            }
          },
          "title": "AdditionalWritableRootActivePermissionProfileModification"
        }
      ]
    },
    "AgentPath": {
      "type": "string"
    },
    "ApprovalsReviewer": {
      "description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
      "type": "string",
      "enum": ["user", "auto_review", "guardian_subagent"]
    },
    "AskForApproval": {
      "oneOf": [
        {
          "type": "string",
          "enum": ["untrusted", "on-failure", "on-request", "never"]
        },
        {
          "type": "object",
          "required": ["granular"],
          "properties": {
            "granular": {
              "type": "object",
              "required": ["mcp_elicitations", "rules", "sandbox_approval"],
              "properties": {
                "mcp_elicitations": {
                  "type": "boolean"
                },
                "request_permissions": {
                  "default": false,
                  "type": "boolean"
                },
                "rules": {
                  "type": "boolean"
                },
                "sandbox_approval": {
                  "type": "boolean"
                },
                "skill_approval": {
                  "default": false,
                  "type": "boolean"
                }
              }
            }
          },
          "additionalProperties": false,
          "title": "GranularAskForApproval"
        }
      ]
    },
    "ByteRange": {
      "type": "object",
      "required": ["end", "start"],
      "properties": {
        "end": {
          "type": "integer",
          "format": "uint",
          "minimum": 0.0
        },
        "start": {
          "type": "integer",
          "format": "uint",
          "minimum": 0.0
        }
      }
    },
    "CodexErrorInfo": {
      "description": "This translation layer make sure that we expose codex error code in camel case.\n\nWhen an upstream HTTP status is available (for example, from the Responses API or a provider), it is forwarded in `httpStatusCode` on the relevant `codexErrorInfo` variant.",
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "contextWindowExceeded",
            "usageLimitExceeded",
            "serverOverloaded",
            "cyberPolicy",
            "internalServerError",
            "unauthorized",
            "badRequest",
            "threadRollbackFailed",
            "sandboxError",
            "other"
          ]
        },
        {
          "type": "object",
          "required": ["httpConnectionFailed"],
          "properties": {
            "httpConnectionFailed": {
              "type": "object",
              "properties": {
                "httpStatusCode": {
                  "type": ["integer", "null"],
                  "format": "uint16",
                  "minimum": 0.0
                }
              }
            }
          },
          "additionalProperties": false,
          "title": "HttpConnectionFailedCodexErrorInfo"
        },
        {
          "description": "Failed to connect to the response SSE stream.",
          "type": "object",
          "required": ["responseStreamConnectionFailed"],
          "properties": {
            "responseStreamConnectionFailed": {
              "type": "object",
              "properties": {
                "httpStatusCode": {
                  "type": ["integer", "null"],
                  "format": "uint16",
                  "minimum": 0.0
                }
              }
            }
          },
          "additionalProperties": false,
          "title": "ResponseStreamConnectionFailedCodexErrorInfo"
        },
        {
          "description": "The response SSE stream disconnected in the middle of a turn before completion.",
          "type": "object",
          "required": ["responseStreamDisconnected"],
          "properties": {
            "responseStreamDisconnected": {
              "type": "object",
              "properties": {
                "httpStatusCode": {
                  "type": ["integer", "null"],
                  "format": "uint16",
                  "minimum": 0.0
                }
              }
            }
          },
          "additionalProperties": false,
          "title": "ResponseStreamDisconnectedCodexErrorInfo"
        },
        {
          "description": "Reached the retry limit for responses.",
          "type": "object",
          "required": ["responseTooManyFailedAttempts"],
          "properties": {
            "responseTooManyFailedAttempts": {
              "type": "object",
              "properties": {
                "httpStatusCode": {
                  "type": ["integer", "null"],
                  "format": "uint16",
                  "minimum": 0.0
                }
              }
            }
          },
          "additionalProperties": false,
          "title": "ResponseTooManyFailedAttemptsCodexErrorInfo"
        },
        {
          "description": "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
          "type": "object",
          "required": ["activeTurnNotSteerable"],
          "properties": {
            "activeTurnNotSteerable": {
              "type": "object",
              "required": ["turnKind"],
              "properties": {
                "turnKind": {
                  "$ref": "#/definitions/NonSteerableTurnKind"
                }
              }
            }
          },
          "additionalProperties": false,
          "title": "ActiveTurnNotSteerableCodexErrorInfo"
        }
      ]
    },
    "CollabAgentState": {
      "type": "object",
      "required": ["status"],
      "properties": {
        "message": {
          "type": ["string", "null"]
        },
        "status": {
          "$ref": "#/definitions/CollabAgentStatus"
        }
      }
    },
    "CollabAgentStatus": {
      "type": "string",
      "enum": [
        "pendingInit",
        "running",
        "interrupted",
        "completed",
        "errored",
        "shutdown",
        "notFound"
      ]
    },
    "CollabAgentTool": {
      "type": "string",
      "enum": ["spawnAgent", "sendInput", "resumeAgent", "wait", "closeAgent"]
    },
    "CollabAgentToolCallStatus": {
      "type": "string",
      "enum": ["inProgress", "completed", "failed"]
    },
    "CommandAction": {
      "oneOf": [
        {
          "type": "object",
          "required": ["command", "name", "path", "type"],
          "properties": {
            "command": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "path": {
              "$ref": "#/definitions/AbsolutePathBuf"
            },
            "type": {
              "type": "string",
              "enum": ["read"],
              "title": "ReadCommandActionType"
            }
          },
          "title": "ReadCommandAction"
        },
        {
          "type": "object",
          "required": ["command", "type"],
          "properties": {
            "command": {
              "type": "string"
            },
            "path": {
              "type": ["string", "null"]
            },
            "type": {
              "type": "string",
              "enum": ["listFiles"],
              "title": "ListFilesCommandActionType"
            }
          },
          "title": "ListFilesCommandAction"
        },
        {
          "type": "object",
          "required": ["command", "type"],
          "properties": {
            "command": {
              "type": "string"
            },
            "path": {
              "type": ["string", "null"]
            },
            "query": {
              "type": ["string", "null"]
            },
            "type": {
              "type": "string",
              "enum": ["search"],
              "title": "SearchCommandActionType"
            }
          },
          "title": "SearchCommandAction"
        },
        {
          "type": "object",
          "required": ["command", "type"],
          "properties": {
            "command": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["unknown"],
              "title": "UnknownCommandActionType"
            }
          },
          "title": "UnknownCommandAction"
        }
      ]
    },
    "CommandExecutionSource": {
      "type": "string",
      "enum": ["agent", "userShell", "unifiedExecStartup", "unifiedExecInteraction"]
    },
    "CommandExecutionStatus": {
      "type": "string",
      "enum": ["inProgress", "completed", "failed", "declined"]
    },
    "DynamicToolCallOutputContentItem": {
      "oneOf": [
        {
          "type": "object",
          "required": ["text", "type"],
          "properties": {
            "text": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["inputText"],
              "title": "InputTextDynamicToolCallOutputContentItemType"
            }
          },
          "title": "InputTextDynamicToolCallOutputContentItem"
        },
        {
          "type": "object",
          "required": ["imageUrl", "type"],
          "properties": {
            "imageUrl": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["inputImage"],
              "title": "InputImageDynamicToolCallOutputContentItemType"
            }
          },
          "title": "InputImageDynamicToolCallOutputContentItem"
        }
      ]
    },
    "DynamicToolCallStatus": {
      "type": "string",
      "enum": ["inProgress", "completed", "failed"]
    },
    "FileSystemAccessMode": {
      "type": "string",
      "enum": ["read", "write", "none"]
    },
    "FileSystemPath": {
      "oneOf": [
        {
          "type": "object",
          "required": ["path", "type"],
          "properties": {
            "path": {
              "$ref": "#/definitions/AbsolutePathBuf"
            },
            "type": {
              "type": "string",
              "enum": ["path"],
              "title": "PathFileSystemPathType"
            }
          },
          "title": "PathFileSystemPath"
        },
        {
          "type": "object",
          "required": ["pattern", "type"],
          "properties": {
            "pattern": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["glob_pattern"],
              "title": "GlobPatternFileSystemPathType"
            }
          },
          "title": "GlobPatternFileSystemPath"
        },
        {
          "type": "object",
          "required": ["type", "value"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["special"],
              "title": "SpecialFileSystemPathType"
            },
            "value": {
              "$ref": "#/definitions/FileSystemSpecialPath"
            }
          },
          "title": "SpecialFileSystemPath"
        }
      ]
    },
    "FileSystemSandboxEntry": {
      "type": "object",
      "required": ["access", "path"],
      "properties": {
        "access": {
          "$ref": "#/definitions/FileSystemAccessMode"
        },
        "path": {
          "$ref": "#/definitions/FileSystemPath"
        }
      }
    },
    "FileSystemSpecialPath": {
      "oneOf": [
        {
          "type": "object",
          "required": ["kind"],
          "properties": {
            "kind": {
              "type": "string",
              "enum": ["root"]
            }
          },
          "title": "RootFileSystemSpecialPath"
        },
        {
          "type": "object",
          "required": ["kind"],
          "properties": {
            "kind": {
              "type": "string",
              "enum": ["minimal"]
            }
          },
          "title": "MinimalFileSystemSpecialPath"
        },
        {
          "type": "object",
          "required": ["kind"],
          "properties": {
            "kind": {
              "type": "string",
              "enum": ["project_roots"]
            },
            "subpath": {
              "type": ["string", "null"]
            }
          },
          "title": "KindFileSystemSpecialPath"
        },
        {
          "type": "object",
          "required": ["kind"],
          "properties": {
            "kind": {
              "type": "string",
              "enum": ["tmpdir"]
            }
          },
          "title": "TmpdirFileSystemSpecialPath"
        },
        {
          "type": "object",
          "required": ["kind"],
          "properties": {
            "kind": {
              "type": "string",
              "enum": ["slash_tmp"]
            }
          },
          "title": "SlashTmpFileSystemSpecialPath"
        },
        {
          "type": "object",
          "required": ["kind", "path"],
          "properties": {
            "kind": {
              "type": "string",
              "enum": ["unknown"]
            },
            "path": {
              "type": "string"
            },
            "subpath": {
              "type": ["string", "null"]
            }
          }
        }
      ]
    },
    "FileUpdateChange": {
      "type": "object",
      "required": ["diff", "kind", "path"],
      "properties": {
        "diff": {
          "type": "string"
        },
        "kind": {
          "$ref": "#/definitions/PatchChangeKind"
        },
        "path": {
          "type": "string"
        }
      }
    },
    "GitInfo": {
      "type": "object",
      "properties": {
        "branch": {
          "type": ["string", "null"]
        },
        "originUrl": {
          "type": ["string", "null"]
        },
        "sha": {
          "type": ["string", "null"]
        }
      }
    },
    "HookPromptFragment": {
      "type": "object",
      "required": ["hookRunId", "text"],
      "properties": {
        "hookRunId": {
          "type": "string"
        },
        "text": {
          "type": "string"
        }
      }
    },
    "McpToolCallError": {
      "type": "object",
      "required": ["message"],
      "properties": {
        "message": {
          "type": "string"
        }
      }
    },
    "McpToolCallResult": {
      "type": "object",
      "required": ["content"],
      "properties": {
        "_meta": true,
        "content": {
          "type": "array",
          "items": true
        },
        "structuredContent": true
      }
    },
    "McpToolCallStatus": {
      "type": "string",
      "enum": ["inProgress", "completed", "failed"]
    },
    "MemoryCitation": {
      "type": "object",
      "required": ["entries", "threadIds"],
      "properties": {
        "entries": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/MemoryCitationEntry"
          }
        },
        "threadIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "MemoryCitationEntry": {
      "type": "object",
      "required": ["lineEnd", "lineStart", "note", "path"],
      "properties": {
        "lineEnd": {
          "type": "integer",
          "format": "uint32",
          "minimum": 0.0
        },
        "lineStart": {
          "type": "integer",
          "format": "uint32",
          "minimum": 0.0
        },
        "note": {
          "type": "string"
        },
        "path": {
          "type": "string"
        }
      }
    },
    "MessagePhase": {
      "description": "Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as \"phase unknown\" and keep compatibility behavior for legacy models.",
      "oneOf": [
        {
          "description": "Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
          "type": "string",
          "enum": ["commentary"]
        },
        {
          "description": "The assistant's terminal answer text for the current turn.",
          "type": "string",
          "enum": ["final_answer"]
        }
      ]
    },
    "NetworkAccess": {
      "type": "string",
      "enum": ["restricted", "enabled"]
    },
    "NonSteerableTurnKind": {
      "type": "string",
      "enum": ["review", "compact"]
    },
    "PatchApplyStatus": {
      "type": "string",
      "enum": ["inProgress", "completed", "failed", "declined"]
    },
    "PatchChangeKind": {
      "oneOf": [
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["add"],
              "title": "AddPatchChangeKindType"
            }
          },
          "title": "AddPatchChangeKind"
        },
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["delete"],
              "title": "DeletePatchChangeKindType"
            }
          },
          "title": "DeletePatchChangeKind"
        },
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "move_path": {
              "type": ["string", "null"]
            },
            "type": {
              "type": "string",
              "enum": ["update"],
              "title": "UpdatePatchChangeKindType"
            }
          },
          "title": "UpdatePatchChangeKind"
        }
      ]
    },
    "PermissionProfile": {
      "oneOf": [
        {
          "description": "Codex owns sandbox construction for this profile.",
          "type": "object",
          "required": ["fileSystem", "network", "type"],
          "properties": {
            "fileSystem": {
              "$ref": "#/definitions/PermissionProfileFileSystemPermissions"
            },
            "network": {
              "$ref": "#/definitions/PermissionProfileNetworkPermissions"
            },
            "type": {
              "type": "string",
              "enum": ["managed"],
              "title": "ManagedPermissionProfileType"
            }
          },
          "title": "ManagedPermissionProfile"
        },
        {
          "description": "Do not apply an outer sandbox.",
          "type": "object",
          "required": ["type"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["disabled"],
              "title": "DisabledPermissionProfileType"
            }
          },
          "title": "DisabledPermissionProfile"
        },
        {
          "description": "Filesystem isolation is enforced by an external caller.",
          "type": "object",
          "required": ["network", "type"],
          "properties": {
            "network": {
              "$ref": "#/definitions/PermissionProfileNetworkPermissions"
            },
            "type": {
              "type": "string",
              "enum": ["external"],
              "title": "ExternalPermissionProfileType"
            }
          },
          "title": "ExternalPermissionProfile"
        }
      ]
    },
    "PermissionProfileFileSystemPermissions": {
      "oneOf": [
        {
          "type": "object",
          "required": ["entries", "type"],
          "properties": {
            "entries": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/FileSystemSandboxEntry"
              }
            },
            "globScanMaxDepth": {
              "type": ["integer", "null"],
              "format": "uint",
              "minimum": 1.0
            },
            "type": {
              "type": "string",
              "enum": ["restricted"],
              "title": "RestrictedPermissionProfileFileSystemPermissionsType"
            }
          },
          "title": "RestrictedPermissionProfileFileSystemPermissions"
        },
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["unrestricted"],
              "title": "UnrestrictedPermissionProfileFileSystemPermissionsType"
            }
          },
          "title": "UnrestrictedPermissionProfileFileSystemPermissions"
        }
      ]
    },
    "PermissionProfileNetworkPermissions": {
      "type": "object",
      "required": ["enabled"],
      "properties": {
        "enabled": {
          "type": "boolean"
        }
      }
    },
    "ReasoningEffort": {
      "description": "See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#get-started-with-reasoning",
      "type": "string",
      "enum": ["none", "minimal", "low", "medium", "high", "xhigh"]
    },
    "SandboxPolicy": {
      "oneOf": [
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["dangerFullAccess"],
              "title": "DangerFullAccessSandboxPolicyType"
            }
          },
          "title": "DangerFullAccessSandboxPolicy"
        },
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "networkAccess": {
              "default": false,
              "type": "boolean"
            },
            "type": {
              "type": "string",
              "enum": ["readOnly"],
              "title": "ReadOnlySandboxPolicyType"
            }
          },
          "title": "ReadOnlySandboxPolicy"
        },
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "networkAccess": {
              "default": "restricted",
              "allOf": [
                {
                  "$ref": "#/definitions/NetworkAccess"
                }
              ]
            },
            "type": {
              "type": "string",
              "enum": ["externalSandbox"],
              "title": "ExternalSandboxSandboxPolicyType"
            }
          },
          "title": "ExternalSandboxSandboxPolicy"
        },
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "excludeSlashTmp": {
              "default": false,
              "type": "boolean"
            },
            "excludeTmpdirEnvVar": {
              "default": false,
              "type": "boolean"
            },
            "networkAccess": {
              "default": false,
              "type": "boolean"
            },
            "type": {
              "type": "string",
              "enum": ["workspaceWrite"],
              "title": "WorkspaceWriteSandboxPolicyType"
            },
            "writableRoots": {
              "default": [],
              "type": "array",
              "items": {
                "$ref": "#/definitions/AbsolutePathBuf"
              }
            }
          },
          "title": "WorkspaceWriteSandboxPolicy"
        }
      ]
    },
    "ServiceTier": {
      "type": "string",
      "enum": ["fast", "flex"]
    },
    "SessionSource": {
      "oneOf": [
        {
          "type": "string",
          "enum": ["cli", "vscode", "exec", "appServer", "unknown"]
        },
        {
          "type": "object",
          "required": ["custom"],
          "properties": {
            "custom": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "title": "CustomSessionSource"
        },
        {
          "type": "object",
          "required": ["subAgent"],
          "properties": {
            "subAgent": {
              "$ref": "#/definitions/SubAgentSource"
            }
          },
          "additionalProperties": false,
          "title": "SubAgentSessionSource"
        }
      ]
    },
    "SubAgentSource": {
      "oneOf": [
        {
          "type": "string",
          "enum": ["review", "compact", "memory_consolidation"]
        },
        {
          "type": "object",
          "required": ["thread_spawn"],
          "properties": {
            "thread_spawn": {
              "type": "object",
              "required": ["depth", "parent_thread_id"],
              "properties": {
                "agent_nickname": {
                  "default": null,
                  "type": ["string", "null"]
                },
                "agent_path": {
                  "default": null,
                  "anyOf": [
                    {
                      "$ref": "#/definitions/AgentPath"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "agent_role": {
                  "default": null,
                  "type": ["string", "null"]
                },
                "depth": {
                  "type": "integer",
                  "format": "int32"
                },
                "parent_thread_id": {
                  "$ref": "#/definitions/ThreadId"
                }
              }
            }
          },
          "additionalProperties": false,
          "title": "ThreadSpawnSubAgentSource"
        },
        {
          "type": "object",
          "required": ["other"],
          "properties": {
            "other": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "title": "OtherSubAgentSource"
        }
      ]
    },
    "TextElement": {
      "type": "object",
      "required": ["byteRange"],
      "properties": {
        "byteRange": {
          "description": "Byte range in the parent `text` buffer that this element occupies.",
          "allOf": [
            {
              "$ref": "#/definitions/ByteRange"
            }
          ]
        },
        "placeholder": {
          "description": "Optional human-readable placeholder for the element, displayed in the UI.",
          "type": ["string", "null"]
        }
      }
    },
    "Thread": {
      "type": "object",
      "required": [
        "cliVersion",
        "createdAt",
        "cwd",
        "ephemeral",
        "id",
        "modelProvider",
        "preview",
        "source",
        "status",
        "turns",
        "updatedAt"
      ],
      "properties": {
        "agentNickname": {
          "description": "Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
          "type": ["string", "null"]
        },
        "agentRole": {
          "description": "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
          "type": ["string", "null"]
        },
        "cliVersion": {
          "description": "Version of the CLI that created the thread.",
          "type": "string"
        },
        "createdAt": {
          "description": "Unix timestamp (in seconds) when the thread was created.",
          "type": "integer",
          "format": "int64"
        },
        "cwd": {
          "description": "Working directory captured for the thread.",
          "allOf": [
            {
              "$ref": "#/definitions/AbsolutePathBuf"
            }
          ]
        },
        "ephemeral": {
          "description": "Whether the thread is ephemeral and should not be materialized on disk.",
          "type": "boolean"
        },
        "forkedFromId": {
          "description": "Source thread id when this thread was created by forking another thread.",
          "type": ["string", "null"]
        },
        "gitInfo": {
          "description": "Optional Git metadata captured when the thread was created.",
          "anyOf": [
            {
              "$ref": "#/definitions/GitInfo"
            },
            {
              "type": "null"
            }
          ]
        },
        "id": {
          "type": "string"
        },
        "modelProvider": {
          "description": "Model provider used for this thread (for example, 'openai').",
          "type": "string"
        },
        "name": {
          "description": "Optional user-facing thread title.",
          "type": ["string", "null"]
        },
        "path": {
          "description": "[UNSTABLE] Path to the thread on disk.",
          "type": ["string", "null"]
        },
        "preview": {
          "description": "Usually the first user message in the thread, if available.",
          "type": "string"
        },
        "source": {
          "description": "Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.).",
          "allOf": [
            {
              "$ref": "#/definitions/SessionSource"
            }
          ]
        },
        "status": {
          "description": "Current runtime status for the thread.",
          "allOf": [
            {
              "$ref": "#/definitions/ThreadStatus"
            }
          ]
        },
        "turns": {
          "description": "Only populated on `thread/resume`, `thread/rollback`, `thread/fork`, and `thread/read` (when `includeTurns` is true) responses. For all other responses and notifications returning a Thread, the turns field will be an empty list.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/Turn"
          }
        },
        "updatedAt": {
          "description": "Unix timestamp (in seconds) when the thread was last updated.",
          "type": "integer",
          "format": "int64"
        }
      }
    },
    "ThreadActiveFlag": {
      "type": "string",
      "enum": ["waitingOnApproval", "waitingOnUserInput"]
    },
    "ThreadId": {
      "type": "string"
    },
    "ThreadItem": {
      "oneOf": [
        {
          "type": "object",
          "required": ["content", "id", "type"],
          "properties": {
            "content": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/UserInput"
              }
            },
            "id": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["userMessage"],
              "title": "UserMessageThreadItemType"
            }
          },
          "title": "UserMessageThreadItem"
        },
        {
          "type": "object",
          "required": ["fragments", "id", "type"],
          "properties": {
            "fragments": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/HookPromptFragment"
              }
            },
            "id": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["hookPrompt"],
              "title": "HookPromptThreadItemType"
            }
          },
          "title": "HookPromptThreadItem"
        },
        {
          "type": "object",
          "required": ["id", "text", "type"],
          "properties": {
            "id": {
              "type": "string"
            },
            "memoryCitation": {
              "default": null,
              "anyOf": [
                {
                  "$ref": "#/definitions/MemoryCitation"
                },
                {
                  "type": "null"
                }
              ]
            },
            "phase": {
              "default": null,
              "anyOf": [
                {
                  "$ref": "#/definitions/MessagePhase"
                },
                {
                  "type": "null"
                }
              ]
            },
            "text": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["agentMessage"],
              "title": "AgentMessageThreadItemType"
            }
          },
          "title": "AgentMessageThreadItem"
        },
        {
          "description": "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
          "type": "object",
          "required": ["id", "text", "type"],
          "properties": {
            "id": {
              "type": "string"
            },
            "text": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["plan"],
              "title": "PlanThreadItemType"
            }
          },
          "title": "PlanThreadItem"
        },
        {
          "type": "object",
          "required": ["id", "type"],
          "properties": {
            "content": {
              "default": [],
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "id": {
              "type": "string"
            },
            "summary": {
              "default": [],
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "type": {
              "type": "string",
              "enum": ["reasoning"],
              "title": "ReasoningThreadItemType"
            }
          },
          "title": "ReasoningThreadItem"
        },
        {
          "type": "object",
          "required": ["command", "commandActions", "cwd", "id", "status", "type"],
          "properties": {
            "aggregatedOutput": {
              "description": "The command's output, aggregated from stdout and stderr.",
              "type": ["string", "null"]
            },
            "command": {
              "description": "The command to be executed.",
              "type": "string"
            },
            "commandActions": {
              "description": "A best-effort parsing of the command to understand the action(s) it will perform. This returns a list of CommandAction objects because a single shell command may be composed of many commands piped together.",
              "type": "array",
              "items": {
                "$ref": "#/definitions/CommandAction"
              }
            },
            "cwd": {
              "description": "The command's working directory.",
              "allOf": [
                {
                  "$ref": "#/definitions/AbsolutePathBuf"
                }
              ]
            },
            "durationMs": {
              "description": "The duration of the command execution in milliseconds.",
              "type": ["integer", "null"],
              "format": "int64"
            },
            "exitCode": {
              "description": "The command's exit code.",
              "type": ["integer", "null"],
              "format": "int32"
            },
            "id": {
              "type": "string"
            },
            "processId": {
              "description": "Identifier for the underlying PTY process (when available).",
              "type": ["string", "null"]
            },
            "source": {
              "default": "agent",
              "allOf": [
                {
                  "$ref": "#/definitions/CommandExecutionSource"
                }
              ]
            },
            "status": {
              "$ref": "#/definitions/CommandExecutionStatus"
            },
            "type": {
              "type": "string",
              "enum": ["commandExecution"],
              "title": "CommandExecutionThreadItemType"
            }
          },
          "title": "CommandExecutionThreadItem"
        },
        {
          "type": "object",
          "required": ["changes", "id", "status", "type"],
          "properties": {
            "changes": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/FileUpdateChange"
              }
            },
            "id": {
              "type": "string"
            },
            "status": {
              "$ref": "#/definitions/PatchApplyStatus"
            },
            "type": {
              "type": "string",
              "enum": ["fileChange"],
              "title": "FileChangeThreadItemType"
            }
          },
          "title": "FileChangeThreadItem"
        },
        {
          "type": "object",
          "required": ["arguments", "id", "server", "status", "tool", "type"],
          "properties": {
            "arguments": true,
            "durationMs": {
              "description": "The duration of the MCP tool call in milliseconds.",
              "type": ["integer", "null"],
              "format": "int64"
            },
            "error": {
              "anyOf": [
                {
                  "$ref": "#/definitions/McpToolCallError"
                },
                {
                  "type": "null"
                }
              ]
            },
            "id": {
              "type": "string"
            },
            "mcpAppResourceUri": {
              "type": ["string", "null"]
            },
            "result": {
              "anyOf": [
                {
                  "$ref": "#/definitions/McpToolCallResult"
                },
                {
                  "type": "null"
                }
              ]
            },
            "server": {
              "type": "string"
            },
            "status": {
              "$ref": "#/definitions/McpToolCallStatus"
            },
            "tool": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["mcpToolCall"],
              "title": "McpToolCallThreadItemType"
            }
          },
          "title": "McpToolCallThreadItem"
        },
        {
          "type": "object",
          "required": ["arguments", "id", "status", "tool", "type"],
          "properties": {
            "arguments": true,
            "contentItems": {
              "type": ["array", "null"],
              "items": {
                "$ref": "#/definitions/DynamicToolCallOutputContentItem"
              }
            },
            "durationMs": {
              "description": "The duration of the dynamic tool call in milliseconds.",
              "type": ["integer", "null"],
              "format": "int64"
            },
            "id": {
              "type": "string"
            },
            "namespace": {
              "type": ["string", "null"]
            },
            "status": {
              "$ref": "#/definitions/DynamicToolCallStatus"
            },
            "success": {
              "type": ["boolean", "null"]
            },
            "tool": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["dynamicToolCall"],
              "title": "DynamicToolCallThreadItemType"
            }
          },
          "title": "DynamicToolCallThreadItem"
        },
        {
          "type": "object",
          "required": [
            "agentsStates",
            "id",
            "receiverThreadIds",
            "senderThreadId",
            "status",
            "tool",
            "type"
          ],
          "properties": {
            "agentsStates": {
              "description": "Last known status of the target agents, when available.",
              "type": "object",
              "additionalProperties": {
                "$ref": "#/definitions/CollabAgentState"
              }
            },
            "id": {
              "description": "Unique identifier for this collab tool call.",
              "type": "string"
            },
            "model": {
              "description": "Model requested for the spawned agent, when applicable.",
              "type": ["string", "null"]
            },
            "prompt": {
              "description": "Prompt text sent as part of the collab tool call, when available.",
              "type": ["string", "null"]
            },
            "reasoningEffort": {
              "description": "Reasoning effort requested for the spawned agent, when applicable.",
              "anyOf": [
                {
                  "$ref": "#/definitions/ReasoningEffort"
                },
                {
                  "type": "null"
                }
              ]
            },
            "receiverThreadIds": {
              "description": "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "senderThreadId": {
              "description": "Thread ID of the agent issuing the collab request.",
              "type": "string"
            },
            "status": {
              "description": "Current status of the collab tool call.",
              "allOf": [
                {
                  "$ref": "#/definitions/CollabAgentToolCallStatus"
                }
              ]
            },
            "tool": {
              "description": "Name of the collab tool that was invoked.",
              "allOf": [
                {
                  "$ref": "#/definitions/CollabAgentTool"
                }
              ]
            },
            "type": {
              "type": "string",
              "enum": ["collabAgentToolCall"],
              "title": "CollabAgentToolCallThreadItemType"
            }
          },
          "title": "CollabAgentToolCallThreadItem"
        },
        {
          "type": "object",
          "required": ["id", "query", "type"],
          "properties": {
            "action": {
              "anyOf": [
                {
                  "$ref": "#/definitions/WebSearchAction"
                },
                {
                  "type": "null"
                }
              ]
            },
            "id": {
              "type": "string"
            },
            "query": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["webSearch"],
              "title": "WebSearchThreadItemType"
            }
          },
          "title": "WebSearchThreadItem"
        },
        {
          "type": "object",
          "required": ["id", "path", "type"],
          "properties": {
            "id": {
              "type": "string"
            },
            "path": {
              "$ref": "#/definitions/AbsolutePathBuf"
            },
            "type": {
              "type": "string",
              "enum": ["imageView"],
              "title": "ImageViewThreadItemType"
            }
          },
          "title": "ImageViewThreadItem"
        },
        {
          "type": "object",
          "required": ["id", "result", "status", "type"],
          "properties": {
            "id": {
              "type": "string"
            },
            "result": {
              "type": "string"
            },
            "revisedPrompt": {
              "type": ["string", "null"]
            },
            "savedPath": {
              "anyOf": [
                {
                  "$ref": "#/definitions/AbsolutePathBuf"
                },
                {
                  "type": "null"
                }
              ]
            },
            "status": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["imageGeneration"],
              "title": "ImageGenerationThreadItemType"
            }
          },
          "title": "ImageGenerationThreadItem"
        },
        {
          "type": "object",
          "required": ["id", "review", "type"],
          "properties": {
            "id": {
              "type": "string"
            },
            "review": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["enteredReviewMode"],
              "title": "EnteredReviewModeThreadItemType"
            }
          },
          "title": "EnteredReviewModeThreadItem"
        },
        {
          "type": "object",
          "required": ["id", "review", "type"],
          "properties": {
            "id": {
              "type": "string"
            },
            "review": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["exitedReviewMode"],
              "title": "ExitedReviewModeThreadItemType"
            }
          },
          "title": "ExitedReviewModeThreadItem"
        },
        {
          "type": "object",
          "required": ["id", "type"],
          "properties": {
            "id": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["contextCompaction"],
              "title": "ContextCompactionThreadItemType"
            }
          },
          "title": "ContextCompactionThreadItem"
        }
      ]
    },
    "ThreadStatus": {
      "oneOf": [
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["notLoaded"],
              "title": "NotLoadedThreadStatusType"
            }
          },
          "title": "NotLoadedThreadStatus"
        },
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["idle"],
              "title": "IdleThreadStatusType"
            }
          },
          "title": "IdleThreadStatus"
        },
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["systemError"],
              "title": "SystemErrorThreadStatusType"
            }
          },
          "title": "SystemErrorThreadStatus"
        },
        {
          "type": "object",
          "required": ["activeFlags", "type"],
          "properties": {
            "activeFlags": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/ThreadActiveFlag"
              }
            },
            "type": {
              "type": "string",
              "enum": ["active"],
              "title": "ActiveThreadStatusType"
            }
          },
          "title": "ActiveThreadStatus"
        }
      ]
    },
    "Turn": {
      "type": "object",
      "required": ["id", "items", "status"],
      "properties": {
        "completedAt": {
          "description": "Unix timestamp (in seconds) when the turn completed.",
          "type": ["integer", "null"],
          "format": "int64"
        },
        "durationMs": {
          "description": "Duration between turn start and completion in milliseconds, if known.",
          "type": ["integer", "null"],
          "format": "int64"
        },
        "error": {
          "description": "Only populated when the Turn's status is failed.",
          "anyOf": [
            {
              "$ref": "#/definitions/TurnError"
            },
            {
              "type": "null"
            }
          ]
        },
        "id": {
          "type": "string"
        },
        "items": {
          "description": "Only populated on a `thread/resume` or `thread/fork` response. For all other responses and notifications returning a Turn, the items field will be an empty list.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/ThreadItem"
          }
        },
        "startedAt": {
          "description": "Unix timestamp (in seconds) when the turn started.",
          "type": ["integer", "null"],
          "format": "int64"
        },
        "status": {
          "$ref": "#/definitions/TurnStatus"
        }
      }
    },
    "TurnError": {
      "type": "object",
      "required": ["message"],
      "properties": {
        "additionalDetails": {
          "default": null,
          "type": ["string", "null"]
        },
        "codexErrorInfo": {
          "anyOf": [
            {
              "$ref": "#/definitions/CodexErrorInfo"
            },
            {
              "type": "null"
            }
          ]
        },
        "message": {
          "type": "string"
        }
      }
    },
    "TurnStatus": {
      "type": "string",
      "enum": ["completed", "interrupted", "failed", "inProgress"]
    },
    "UserInput": {
      "oneOf": [
        {
          "type": "object",
          "required": ["text", "type"],
          "properties": {
            "text": {
              "type": "string"
            },
            "text_elements": {
              "description": "UI-defined spans within `text` used to render or persist special elements.",
              "default": [],
              "type": "array",
              "items": {
                "$ref": "#/definitions/TextElement"
              }
            },
            "type": {
              "type": "string",
              "enum": ["text"],
              "title": "TextUserInputType"
            }
          },
          "title": "TextUserInput"
        },
        {
          "type": "object",
          "required": ["type", "url"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["image"],
              "title": "ImageUserInputType"
            },
            "url": {
              "type": "string"
            }
          },
          "title": "ImageUserInput"
        },
        {
          "type": "object",
          "required": ["path", "type"],
          "properties": {
            "path": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["localImage"],
              "title": "LocalImageUserInputType"
            }
          },
          "title": "LocalImageUserInput"
        },
        {
          "type": "object",
          "required": ["name", "path", "type"],
          "properties": {
            "name": {
              "type": "string"
            },
            "path": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["skill"],
              "title": "SkillUserInputType"
            }
          },
          "title": "SkillUserInput"
        },
        {
          "type": "object",
          "required": ["name", "path", "type"],
          "properties": {
            "name": {
              "type": "string"
            },
            "path": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": ["mention"],
              "title": "MentionUserInputType"
            }
          },
          "title": "MentionUserInput"
        }
      ]
    },
    "WebSearchAction": {
      "oneOf": [
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "queries": {
              "type": ["array", "null"],
              "items": {
                "type": "string"
              }
            },
            "query": {
              "type": ["string", "null"]
            },
            "type": {
              "type": "string",
              "enum": ["search"],
              "title": "SearchWebSearchActionType"
            }
          },
          "title": "SearchWebSearchAction"
        },
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["openPage"],
              "title": "OpenPageWebSearchActionType"
            },
            "url": {
              "type": ["string", "null"]
            }
          },
          "title": "OpenPageWebSearchAction"
        },
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "pattern": {
              "type": ["string", "null"]
            },
            "type": {
              "type": "string",
              "enum": ["findInPage"],
              "title": "FindInPageWebSearchActionType"
            },
            "url": {
              "type": ["string", "null"]
            }
          },
          "title": "FindInPageWebSearchAction"
        },
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["other"],
              "title": "OtherWebSearchActionType"
            }
          },
          "title": "OtherWebSearchAction"
        }
      ]
    }
  }
}
