openapi: 3.1.0
info:
  title: Warden runtime API
  version: 1.0.0
  description: Implemented simplified Warden gateway contract. The real company backend
    is infraoptimal-operations and exposes checked public.ops_* PostgREST RPCs. Durable
    mappings require inspected signatures, current delegated authorization, and verified
    responses. This API is not a claim that missing company capabilities exist or
    that E2E acceptance passed. Folder-backed boards are implemented in source but
    not yet deployment-qualified. No task enforcement, arbitrary topic boards, or
    live transcript subscriptions. Reads never mark messages read. Runtime calls currently
    reach Supabase; a shared live cache/hub is not implemented.
servers:
- url: https://api.ycwarden.com
  description: Intended production origin; verify /v1/readiness before use.
security:
- bearerAuth: []
paths:
  /v1/spend/projects/{project_id}:
    parameters:
    - name: project_id
      in: path
      required: true
      schema: {type: string, format: uuid}
    get:
      operationId: getGuardedProjectSpend
      summary: Read the project tool budget and recent charges
      responses:
        '200':
          description: Current authorized state
          content:
            application/json:
              schema: {$ref: '#/components/schemas/GuardedProjectSpend'}
        default:
          description: Validation, version conflict or authorization error
          content:
            application/json:
              schema: {$ref: '#/components/schemas/Error'}
  /v1/spend/projects/{project_id}/limit:
    parameters:
    - name: project_id
      in: path
      required: true
      schema: {type: string, format: uuid}
    put:
      operationId: setGuardedProjectLimit
      summary: Set the project spending limit as its organization owner
      requestBody:
        required: true
        content:
          application/json:
            schema: {$ref: '#/components/schemas/GuardedLimitUpdate'}
      responses:
        '200':
          description: Current authorized state
          content:
            application/json:
              schema: {$ref: '#/components/schemas/GuardedProjectSpend'}
        default:
          description: Validation, version conflict or authorization error
          content:
            application/json:
              schema: {$ref: '#/components/schemas/Error'}
  /v1/spend/employees/{employee_id}:
    parameters:
    - name: employee_id
      in: path
      required: true
      schema: {type: string, format: uuid}
    get:
      operationId: getGuardedToolGrants
      summary: Read employee spending permissions
      responses:
        '200':
          description: Current authorized state
          content:
            application/json:
              schema: {$ref: '#/components/schemas/GuardedEmployeeGrants'}
        default:
          description: Validation, version conflict or authorization error
          content:
            application/json:
              schema: {$ref: '#/components/schemas/Error'}
  /v1/spend/employees/{employee_id}/grants:
    parameters:
    - name: employee_id
      in: path
      required: true
      schema: {type: string, format: uuid}
    put:
      operationId: setGuardedToolGrants
      summary: Replace employee spending permissions as organization owner
      requestBody:
        required: true
        content:
          application/json:
            schema: {$ref: '#/components/schemas/GuardedGrantUpdate'}
      responses:
        '200':
          description: Current authorized state
          content:
            application/json:
              schema: {$ref: '#/components/schemas/GuardedEmployeeGrants'}
        default:
          description: Validation, version conflict or authorization error
          content:
            application/json:
              schema: {$ref: '#/components/schemas/Error'}
  /v1/tools/{tool}/context-boards:
    parameters:
    - name: tool
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/CatalogToolName'
    - name: cursor
      in: query
      required: false
      schema:
        type: string
        format: uuid
    get:
      operationId: listToolContextBoards
      summary: List board sources linked to this tool
      description: Organization-owner management of advisory context. Blocking is not
        implemented.
      responses:
        '200':
          description: Checked current state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolContextBindingPage'
        default:
          description: Authorization or validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/tools/{tool}/context-boards/{board_id}:
    parameters:
    - name: tool
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/CatalogToolName'
    - name: board_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
    - name: project_id
      in: query
      required: false
      schema:
        type: string
        format: uuid
    get:
      operationId: getToolContextBoard
      summary: Inspect a source and its invocation rule
      description: Organization-owner management of advisory context. Blocking is not
        implemented.
      responses:
        '200':
          description: Checked current state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolContextBindingResult'
        default:
          description: Authorization or validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    put:
      operationId: putToolContextBoard
      summary: Attach a board and set its invocation rule
      description: Organization-owner management of advisory context. Blocking is not
        implemented.
      responses:
        '200':
          description: Checked current state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolContextBindingResult'
        default:
          description: Authorization or validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                on_invoke:
                  type: boolean
              required:
              - on_invoke
              additionalProperties: false
    delete:
      operationId: deleteToolContextBoard
      summary: Remove the selected source association
      description: Organization-owner management of advisory context. Blocking is not
        implemented.
      responses:
        '200':
          description: Checked current state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolContextBindingResult'
        default:
          description: Authorization or validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/boards/{board_id}/reminders:
    parameters:
    - name: board_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
    - name: cursor
      in: query
      required: false
      schema:
        type: string
        format: uuid
    get:
      operationId: listBoardReminders
      summary: List active board reminder subjects
      description: Organization-owner management of advisory context. Blocking is not
        implemented.
      responses:
        '200':
          description: Checked current state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BoardReminderPage'
        default:
          description: Authorization or validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/boards/{board_id}/reminders/{message_id}:
    parameters:
    - name: board_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
    - name: message_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
    put:
      operationId: activateBoardReminder
      summary: Designate a board message as an active reminder
      description: Organization-owner management of advisory context. Blocking is not
        implemented.
      responses:
        '200':
          description: Checked current state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BoardReminderUpdate'
        default:
          description: Authorization or validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    delete:
      operationId: deactivateBoardReminder
      summary: Retire the reminder designation
      description: Organization-owner management of advisory context. Blocking is not
        implemented.
      responses:
        '200':
          description: Checked current state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BoardReminderUpdate'
        default:
          description: Authorization or validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/users/{employee_id}/provider-connections/{provider}:
    parameters:
    - name: employee_id
      in: path
      required: true
      schema: {type: string, format: uuid}
    - name: provider
      in: path
      required: true
      schema: {type: string}
    get:
      operationId: getEmployeeProviderConnection
      summary: Read employee connection status and current action grants
      responses:
        '200':
          $ref: '#/components/responses/EmployeeConnectionMetadata'
    put:
      operationId: configureEmployeeProviderConnection
      summary: Configure or rotate the connection and replace its grants
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [tools, expected_version]
              properties:
                tools:
                  type: array
                  items:
                    $ref: '#/components/schemas/CatalogToolName'
                expected_version: {type: integer, minimum: 0}
                token: {type: string, writeOnly: true}
      responses:
        '200':
          $ref: '#/components/responses/EmployeeConnectionMetadata'
    delete:
      operationId: disconnectEmployeeProvider
      summary: Revoke the credential and associated action grants
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [expected_version]
              properties:
                expected_version: {type: integer, minimum: 0}
      responses:
        '200':
          $ref: '#/components/responses/EmployeeConnectionMetadata'
  /v1/tool-context:
    get:
      operationId: getToolContext
      summary: "Read the authenticated employee\u2019s favorites and logical session\u2019s selected actions"
      responses:
        '200':
          description: Checked tool selection.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolContext'
        default:
          description: Validation, permission, or capacity failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      parameters:
      - name: session_id
        in: query
        schema:
          type: string
          format: uuid
        description: Explicit logical Warden session. An agent with exactly one eligible session may omit it.
  /v1/tool-favorites/{tool_id}:
    parameters:
    - $ref: '#/components/parameters/CatalogToolId'
    - $ref: '#/components/parameters/IdempotencyKey'
    put:
      operationId: favoriteTool
      summary: Add an employee favorite
      responses:
        '200':
          description: Checked tool selection.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FavoriteToolSet'
        default:
          description: Validation, permission, or capacity failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    delete:
      operationId: unfavoriteTool
      summary: Remove an employee favorite
      responses:
        '200':
          description: Checked tool selection.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FavoriteToolSet'
        default:
          description: Validation, permission, or capacity failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/hot-tools/{tool_id}:
    parameters:
    - $ref: '#/components/parameters/ToolSessionId'
    - $ref: '#/components/parameters/CatalogToolId'
    - $ref: '#/components/parameters/IdempotencyKey'
    put:
      operationId: selectHotTool
      summary: Select an action for this logical session
      responses:
        '200':
          description: Checked tool selection.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionHotToolSet'
        default:
          description: Validation, permission, or capacity failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    delete:
      operationId: removeHotTool
      summary: Remove a session selection
      responses:
        '200':
          description: Checked tool selection.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionHotToolSet'
        default:
          description: Validation, permission, or capacity failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/children/{child_session_id}/hot-tools:
    parameters:
    - $ref: '#/components/parameters/ToolSessionId'
    - $ref: '#/components/parameters/ToolChildSessionId'
    - $ref: '#/components/parameters/IdempotencyKey'
    post:
      operationId: passHotTools
      summary: Pass named actions to an authorized immediate child session
      responses:
        '200':
          description: Checked tool selection.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionHotToolSet'
        default:
          description: Validation, permission, or capacity failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
              - tool_ids
              properties:
                tool_ids:
                  $ref: '#/components/schemas/ToolHandoff'
  /v1/sessions/{session_id}/workspace-observations:
    post:
      operationId: appendWorkspaceObservations
      summary: Append automatically observed workspace lifecycle facts
      description: Own bound agent session only. The machine, attached project and
        registered root must belong to the current delegating human. Creator is derived
        from authentication. Runtime must verify actual published Git state; the database
        cannot inspect remote filesystems. Ownership is responsibility metadata, never
        a permission grant. Version mismatch returns workspace_version_conflict; a
        deleted incarnation returns workspace_deleted. CAS versions and stable event
        IDs prevent stale updates, duplicate observations and resurrection of deleted
        incarnations. A batch is atomic.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 8
          maxLength: 200
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkspaceObservationBatch'
      responses:
        '200':
          description: Checked operation succeeded.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required:
                - observations
                properties:
                  observations:
                    type: array
                    items:
                      $ref: '#/components/schemas/WorkspaceObservationResult'
        default:
          description: Authentication, current authority, validation, concurrency
            or transport error. Reconcile uncertain mutations with the same idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/workspaces:
    get:
      operationId: listOwnedWorkspaces
      summary: List the agent’s own and verified subagent worktrees and branches
      description: Current bound agent or owning human only; project permissions are
        checked before pagination. Absolute paths remain private to the owning user.
        Resume uses the same durable agent ownership. Merged entries stay active until
        deletion; branch and worktree deletion are independent.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: include_deleted
        in: query
        required: false
        schema:
          type: boolean
          default: false
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
          description: Opaque cursor bound to owner agent and query filters.
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      responses:
        '200':
          description: Checked operation succeeded.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required:
                - workspaces
                - next_cursor
                - heading
                - retention
                properties:
                  workspaces:
                    type: array
                    items:
                      $ref: '#/components/schemas/WorkspaceArtifact'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                  heading:
                    type: string
                    const: 'you own these worktrees and branches:'
                  retention:
                    type: string
        default:
          description: Authentication, current authority, validation, concurrency
            or transport error. Reconcile uncertain mutations with the same idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/workspace-events:
    get:
      operationId: listWorkspaceHistory
      summary: Read retained workspace lifecycle observations
      description: Same owner/session/project boundaries as workspace listing. History
        remains queryable after deletion. Reading never changes ownership or Git state.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: artifact_id
        in: query
        required: false
        schema:
          type: string
          format: uuid
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
          description: Opaque cursor bound to owner agent and query filters.
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      responses:
        '200':
          description: Checked operation succeeded.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required:
                - events
                - next_cursor
                properties:
                  events:
                    type: array
                    items:
                      $ref: '#/components/schemas/WorkspaceHistoryEvent'
                  next_cursor:
                    type:
                    - string
                    - 'null'
        default:
          description: Authentication, current authority, validation, concurrency
            or transport error. Reconcile uncertain mutations with the same idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/users/{user_id}/agent-lineage:
    put:
      operationId: bindNativeAgentLineage
      summary: Bind provider-observed native parent lineage through the human enrollment
        manager
      description: Authenticated owning human only; ordinary agent credentials are
        refused. The child alias must resolve to a bound nonrevoked enrollment; the
        parent must resolve uniquely to an owned enrollment or a server-bound spawn
        identity and native session alias owned by that human. A root-origin hint
        is not proof of an immediate parent. The native manager must supply provider-observed
        parent evidence. Parent binding is immutable with compare-and-set, rejects
        cycles, and backfills existing descendant ownership. It never grants execution
        capabilities or replaces service-bound Warden spawn authority.
      parameters:
      - name: user_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 8
          maxLength: 200
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NativeAgentLineageInput'
      responses:
        '200':
          description: Checked operation succeeded.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                required:
                - lineage
                properties:
                  lineage:
                    $ref: '#/components/schemas/NativeAgentLineage'
        default:
          description: Authentication, current authority, validation, concurrency
            or transport error. Reconcile uncertain mutations with the same idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/board-subjects:
    get:
      operationId: validateBoardSubjects
      summary: Revalidate cached board subjects before presenting them
      description: Checks one current authorization, subscription and read-state snapshot
        for an owned agent session. Returns only eligible requested message IDs, without
        message content or receipt mutations. Delivered-but-unread messages may remain
        eligible. Read, unsubscribed, unauthorized, unknown and direct-message IDs
        are omitted. Recheck before each presentation; this snapshot cannot recall
        text already emitted before a later permission change.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: message_ids
        in: query
        required: true
        description: One to 100 comma-separated UUIDs. The decoded query value is
          limited to 3699 characters.
        schema:
          type: string
          minLength: 36
          maxLength: 3699
          pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}(,[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}){0,99}$
      responses:
        '200':
          description: Eligible requested IDs in first-requested order, with duplicates
            removed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  eligible_message_ids:
                    type: array
                    maxItems: 100
                    uniqueItems: true
                    items:
                      type: string
                      format: uuid
                required:
                - eligible_message_ids
        default:
          description: Validation, authorization or backend failure. Failure is not
            permission to emit cached subjects.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/boards/register:
    post:
      operationId: registerFolderBoard
      summary: Register an existing .warden folder under a private project root
      description: One board per organization/project/folder. The local runtime verifies
        marker existence; the server checks authority and private root mapping, not
        the remote filesystem. Repeated and cross-machine registrations resolve to
        the same board. New root boards also require this operation with folder_path
        set to dot and a valid private folder mapping. Project attachment, session
        registration project lists and root-board posting do not create missing roots;
        they return HTTP 409 instead. Historical root boards remain available.
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                project_id:
                  type: string
                  format: uuid
                machine_id:
                  type: string
                  format: uuid
                folder_path:
                  type: string
                  minLength: 1
                  maxLength: 2048
                  description: Normalized project-relative directory; dot identifies
                    the root. No absolute paths, dot segments, trailing/repeated separators,
                    backslashes or control characters.
                path:
                  type: string
                  minLength: 1
                  maxLength: 4096
                  writeOnly: true
                  description: Private absolute directory containing .warden; must
                    match this owner's registered project root plus folder_path.
              required:
              - project_id
              - machine_id
              - folder_path
              - path
              additionalProperties: false
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  board:
                    $ref: '#/components/schemas/FolderBoard'
                required:
                - board
        default:
          description: Validation, authorization, conflict or backend failure. Reconcile
            uncertain mutations with the original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/projects/{project_id}/boards:
    get:
      operationId: listFolderBoards
      summary: List a project's folder boards without private machine paths
      parameters:
      - name: project_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: cursor
        in: query
        schema:
          type: string
          pattern: ^[0-9]+$
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  boards:
                    type: array
                    items:
                      $ref: '#/components/schemas/FolderBoard'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - boards
                - next_cursor
        default:
          description: Validation, authorization, conflict or backend failure. Reconcile
            uncertain mutations with the original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/boards/{board_id}/messages:
    get:
      operationId: listFolderBoardMessages
      summary: Browse one folder board's authorized history
      description: History requires current project access; browsing does not subscribe
        or mark messages read. Cursor is the last organization sequence, not an offset.
      parameters:
      - name: board_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: cursor
        in: query
        schema:
          type: string
          pattern: ^[0-9]+$
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  messages:
                    type: array
                    items:
                      $ref: '#/components/schemas/Message'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - messages
                - next_cursor
        default:
          description: Validation, authorization, conflict or backend failure. Reconcile
            uncertain mutations with the original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/boards:
    get:
      operationId: listBoardSubscriptions
      summary: List active subscription sources for an owned session
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: cursor
        in: query
        schema:
          type: string
          pattern: ^[0-9]+$
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  subscriptions:
                    type: array
                    items:
                      $ref: '#/components/schemas/BoardSubscription'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - subscriptions
                - next_cursor
        default:
          description: Validation, authorization, conflict or backend failure. Reconcile
            uncertain mutations with the original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/boards/{board_id}:
    put:
      operationId: subscribeFolderBoard
      summary: Subscribe to future folder-board posts without replay
      description: Subscribing also attaches project awareness without subscribing
        to its root board. An active repeated source keeps its original cutoff; re-subscribing
        a removed source starts at the current sequence.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: board_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                source:
                  type: string
                  enum:
                  - folder
                  - explicit
                  default: explicit
              required: []
              additionalProperties: false
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  subscription:
                    $ref: '#/components/schemas/BoardSubscription'
                required:
                - subscription
        default:
          description: Validation, authorization, conflict or backend failure. Reconcile
            uncertain mutations with the original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    delete:
      operationId: unsubscribeFolderBoard
      summary: Remove one subscription source while preserving other sources
      description: Queued notifications are suppressed when no eligible session subscription
        remains. Removing an absent source succeeds with subscribed=false.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: board_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: source
        in: query
        schema:
          type: string
          enum:
          - folder
          - explicit
          default: explicit
      - $ref: '#/components/parameters/IdempotencyKey'
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  subscription:
                    $ref: '#/components/schemas/BoardSubscription'
                required:
                - subscription
        default:
          description: Validation, authorization, conflict or backend failure. Reconcile
            uncertain mutations with the original idempotency key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/agents/{agent_id}/webhook:
    get:
      operationId: agentWebhook
      summary: Read an owned agent's webhook metadata
      description: Human owner only. No URL, Bearer key, ciphertext or dispatcher
        credentials are returned.
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Current checked metadata, without secrets or message bodies.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookConfiguration'
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    put:
      operationId: configureAgentWebhook
      summary: Configure or disable an owned agent's GrokBot notifications
      description: Human owner only, with version checking and idempotent retries.
        An unapproved hostname returns 409 webhook_host_not_approved; approve an exact
        public hostname separately. Disable clears credentials and suppresses queued
        attempts; an in-flight request cannot be recalled. Only future direct and
        board messages enqueue notifications. Attachment itself is silent and does
        not replay old posts.
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookConfigurationInput'
      responses:
        '200':
          description: Current checked metadata, without secrets or message bodies.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookConfiguration'
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/webhook-hosts:
    get:
      operationId: webhookHosts
      summary: Read approved exact webhook hostnames
      description: Organization-owner human only; organization is inferred from verified
        authentication.
      responses:
        '200':
          description: Current checked metadata, without secrets or message bodies.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookHosts'
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    put:
      operationId: approveWebhookHost
      summary: Approve an exact public webhook hostname
      description: Organization-owner human only, with optimistic version checking.
        Wildcards, IP literals, private destinations and credentials are rejected.
        DNS is checked on approval and before attempts; this is not a DNS-pinning
        guarantee.
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                hostname:
                  type: string
                  minLength: 1
                  maxLength: 253
                expected_version:
                  type: integer
                  minimum: 0
              required:
              - hostname
              - expected_version
              additionalProperties: false
      responses:
        '200':
          description: Current checked metadata, without secrets or message bodies.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookHosts'
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/agents/{agent_id}/webhook/deliveries:
    get:
      operationId: agentWebhookDeliveries
      summary: List an owned agent's durable webhook delivery outcomes
      description: Human owner only. Ordered by creation time and ID; cursor is bound
        to organization, agent and state. Accepted means exactly HTTP 200, not completed
        work or a read message. Webhook delivery never changes Warden receipts. Direct
        notifications take priority over informational board backlog; dispatch permits
        at most one attempt per endpoint per minute and eight attempts per event.
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: state
        in: query
        schema:
          type: string
          enum:
          - all
          - queued
          - leased
          - accepted
          - suppressed
          - failed
          default: all
      - name: cursor
        in: query
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      responses:
        '200':
          description: Current checked metadata, without secrets or message bodies.
          content:
            application/json:
              schema:
                type: object
                properties:
                  deliveries:
                    type: array
                    items:
                      $ref: '#/components/schemas/WebhookDelivery'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - deliveries
                - next_cursor
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/delivery:
    get:
      operationId: pollSessionDelivery
      summary: Retrieve pending direct messages independently of incremental board
        subjects
      description: Checked own-session bound-agent access only. The direct queue uses
        intended-session lookup and is independent of the board cursor/backlog. Subjects
        contain board summaries only; no message bodies or read acknowledgements.
        Persist cursor even when next_cursor is null. limit=0 polls direct messages
        without scanning board rows or advancing the board cursor.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
      - name: cursor
        in: query
        schema:
          type: string
          pattern: ^[0-9]+$
          default: '0'
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 0
          maximum: 100
          default: 100
      responses:
        '200':
          description: Current pending/unavailable direct summaries and incremental
            undelivered board subjects.
          content:
            application/json:
              schema:
                type: object
                required:
                - direct_messages
                - subjects
                - cursor
                - next_cursor
                properties:
                  direct_messages:
                    type: array
                    maxItems: 50
                    items:
                      $ref: '#/components/schemas/DeliverySummary'
                  subjects:
                    type: array
                    maxItems: 100
                    items:
                      $ref: '#/components/schemas/DeliverySummary'
                  cursor:
                    type: string
                    pattern: ^[0-9]+$
                  next_cursor:
                    type:
                    - string
                    - 'null'
        default:
          description: Current authorization, validation, or backend failure; never
            an empty success placeholder.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /auth/code:
    post:
      operationId: issueRemoteAgentCode
      summary: Issue a client-bound, single-use authorization code for a distinct
        agent
      description: Requires the human's current Supabase JWT. The gateway reuses stable
        enrollment and stores only the separately bound agent credentials in its internal
        credential vault. The five-minute code is bound to the explicit OAuth client
        ID. Tokens are never returned here. Current company delegation expiry bounds
        the remote authorization; human reauthorization uses the same runtime/native
        session identity to preserve history.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
              - client_id
              - runtime
              - native_session_id
              - name
              - work
              properties:
                client_id:
                  type: string
                  minLength: 1
                  maxLength: 2048
                runtime:
                  enum:
                  - claude
                  - codex
                  - gemini
                  - cursor
                  - grok
                native_session_id:
                  type: string
                  minLength: 1
                  maxLength: 256
                resume_session_id:
                  type: string
                  minLength: 1
                  maxLength: 256
                name:
                  type: string
                  minLength: 1
                  maxLength: 160
                work:
                  type: string
                  minLength: 1
                  maxLength: 2000
      responses:
        '200':
          description: Secret code for the human consent form only; no-store. Does
            not itself authenticate an OAuth client.
          content:
            application/json:
              schema:
                type: object
                required:
                - code
                - expires_at
                - delegation_expires_at
                - authorization_expires_at
                - agent_id
                - enrollment_id
                - reauthorization
                properties:
                  code:
                    type: string
                    pattern: ^[a-f0-9]{64}$
                  expires_at:
                    type: string
                    format: date-time
                  delegation_expires_at:
                    type: string
                    format: date-time
                  authorization_expires_at:
                    type: string
                    format: date-time
                  agent_id:
                    type: string
                  enrollment_id:
                    type: string
                  session_id:
                    type: string
                  reauthorization:
                    type: string
        default:
          description: Invalid or non-human identity, unregistered client, absent
            vault, expired delegation, or backend failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /health:
    get:
      operationId: health
      summary: Inspect gateway configuration without claiming durable readiness
      description: Does not connect to the company backend or prove authorization/storage
        access.
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Health'
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security: []
  /v1/readiness:
    get:
      operationId: readiness
      summary: Verify the authenticated company-backend pathway
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Readiness'
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      description: Checks real caller authority, schema/version, and required runtime
        capability availability. A reachable RPC or configured endpoint alone is not
        full readiness. Version/capability fields must reflect the actual backend
        contract.
  /v1/auth/session:
    get:
      operationId: authSession
      summary: Resolve the authenticated user and organizations
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthSession'
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/projects:
    get:
      operationId: listProjects
      summary: List accessible registered projects
      description: Never creates a company project.
      parameters:
      - name: organization_id
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: remote
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Projects'
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/machines/register:
    post:
      operationId: registerMachine
      summary: Register an authenticated user's machine
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MachineRegistration'
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  machine:
                    $ref: '#/components/schemas/Machine'
                required:
                - machine
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/register:
    post:
      operationId: registerSession
      summary: Register a native runtime session
      description: The native conversation maps to the same authorized logical session
        across token refresh, process restart, and machine restart. runtime_instance_key
        distinguishes process incarnation; resume_session_id explicitly continues
        an authorized prior session when the native identifier changes. Neither token
        refresh nor a new process alone creates a new logical session. Forks remain
        distinct. Startup contains only compact roster/naming guidance. Canonical
        registration input prevents retry drift from later name/project changes.
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SessionRegistration'
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Registration'
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/agents/{agent_id}:
    patch:
      operationId: updateAgent
      summary: Set the descriptive name and current work
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentUpdate'
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  agent:
                    $ref: '#/components/schemas/Agent'
                required:
                - agent
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/attachments:
    post:
      operationId: attachProject
      summary: Attach a session to an existing project
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                project_id:
                  type: string
                  minLength: 1
                  maxLength: 256
                subscribe_board:
                  type: boolean
                  default: true
                  description: Subscribe to an existing root board; false attaches
                    project awareness only. A missing root returns HTTP 409 and must
                    first be created by folder registration.
              required:
              - project_id
              additionalProperties: false
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  project_ids:
                    type: array
                    items:
                      type: string
                      minLength: 1
                      maxLength: 256
                required:
                - project_ids
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/attachments/{project_id}:
    delete:
      operationId: detachProject
      summary: Detach one project relationship
      description: Removes an attachment, not the session, project, or history. Requires
        current authority.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: project_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - $ref: '#/components/parameters/IdempotencyKey'
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  project_ids:
                    type: array
                    items:
                      type: string
                      minLength: 1
                      maxLength: 256
                required:
                - project_ids
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/runs:
    get:
      operationId: sessionRuns
      summary: Query durable execution and resume history for a logical session
      description: Runs reuse runtime-instance identities. Transcript boundaries are
        observed snapshots, not an assertion that all provider output falls between
        hook invocations.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
      - name: cursor
        in: query
        schema:
          type: string
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Authorized run history with explicit predecessor, timing and
            closure provenance
          content:
            application/json:
              schema:
                type: object
                required:
                - runs
                - next_cursor
                properties:
                  runs:
                    type: array
                    items:
                      $ref: '#/components/schemas/RuntimeRun'
                  next_cursor:
                    type:
                    - string
                    - 'null'
  /v1/sessions/{session_id}/runs/{run_id}/observations:
    post:
      operationId: observeRunBoundary
      summary: Record an immutable native start or end observation
      description: Each run/phase retains its first observation. Identical retries
        succeed; conflicting observations fail. A process disappearance or lease expiry
        is not a native end event. Pending observations may be delivered after a newer
        run starts.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
      - name: run_id
        in: path
        required: true
        schema:
          type: string
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 8
          maxLength: 200
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
              - phase
              - observed_at
              properties:
                phase:
                  type: string
                  enum:
                  - start
                  - end
                observed_at:
                  type: string
                  format: date-time
                observation_source:
                  type: string
                  enum:
                  - native_hook
                  - process_exit
                  description: Process exit is allowed only for end observations from
                    a controller that owns and reaped the actual child. Omitted legacy
                    provenance remains unknown.
                exit_code:
                  type:
                  - integer
                  - 'null'
                  minimum: 0
                  description: Allowed only with process_exit. At most one of exit_code
                    and exit_signal may be non-null.
                exit_signal:
                  type:
                  - integer
                  - 'null'
                  minimum: 1
                  description: Allowed only with process_exit.
                source_offset:
                  type: integer
                  minimum: 0
                  maximum: 9007199254740991
                source_anchor:
                  type: string
                  pattern: ^[a-f0-9]{64}$
                  description: SHA-256 of up to the final 4096 source bytes ending
                    at source_offset. Must accompany source_offset.
                archive_generation:
                  type: string
                  minLength: 1
                  maxLength: 256
      responses:
        '200':
          description: Recorded or identically retried observation
          content:
            application/json:
              schema:
                type: object
                required:
                - run
                properties:
                  run:
                    $ref: '#/components/schemas/RuntimeRun'
  /v1/sessions/{session_id}/presence:
    post:
      operationId: updatePresence
      summary: Report observed runtime presence
      description: Current generation required. The backend rejects stale reports
        and establishes lease freshness using server time.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PresenceUpdate'
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  presence:
                    enum:
                    - active
                    - idle
                    - disconnected
                  lease_expires_at:
                    type: string
                    format: date-time
                required:
                - presence
                - lease_expires_at
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/context:
    get:
      operationId: sessionContext
      summary: Read the compact roster and permitted unread subjects
      description: startup=true returns an empty messages array. Reading does not
        acknowledge delivery or read state.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: startup
        in: query
        required: false
        schema:
          type: boolean
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Context'
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/messages:
    post:
      operationId: postMessage
      summary: Post an informational board note or direct message
      description: Exactly one project or direct recipient. No task semantics, automatic
        spawning, or custom boards. Success requires durable commit.
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MessagePost'
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: object
                    properties:
                      id:
                        type: string
                        minLength: 1
                        maxLength: 256
                      subject:
                        type: string
                      kind:
                        enum:
                        - board
                        - direct
                      created_at:
                        type: string
                        format: date-time
                    required:
                    - id
                    - subject
                    - kind
                    - created_at
                required:
                - message
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/messages/{message_id}:
    get:
      operationId: getMessage
      summary: Read permitted message content
      parameters:
      - name: message_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    $ref: '#/components/schemas/Message'
                required:
                - message
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/messages/{message_id}/receipts:
    get:
      operationId: listMessageReceipts
      summary: Inspect authorized durable delivery and read history
      parameters:
      - name: message_id
        in: path
        required: true
        schema:
          type: string
      - name: cursor
        in: query
        schema:
          type: string
      - name: limit
        in: query
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Current receipts. Reading does not mark read or complete work.
          content:
            application/json:
              schema:
                type: object
                required:
                - receipts
                - next_cursor
                properties:
                  receipts:
                    type: array
                    items:
                      $ref: '#/components/schemas/RecipientReceipt'
                  next_cursor:
                    type:
                    - string
                    - 'null'
    post:
      operationId: ackMessage
      summary: Record delivered or read state
      description: Only intended recipients can acknowledge. Read never means accepted
        or completed.
      parameters:
      - name: message_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                session_id:
                  type: string
                  minLength: 1
                  maxLength: 256
                state:
                  enum:
                  - delivered
                  - read
              required:
              - session_id
              - state
              additionalProperties: false
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  receipt:
                    $ref: '#/components/schemas/Receipt'
                required:
                - receipt
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/projects/{project_id}/messages:
    get:
      operationId: projectMessages
      summary: Read default project-board history
      parameters:
      - name: project_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  messages:
                    type: array
                    items:
                      $ref: '#/components/schemas/Message'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - messages
                - next_cursor
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/archives/segments/authorize:
    post:
      operationId: authorizeArchiveSegment
      summary: Authorize a scoped immutable object upload
      description: The signed object request carries only returned upload headers.
        If a previous immutable upload succeeded but its response was lost, a matching
        existing object is reused only after fresh compressed/raw byte verification
        under current caller authority. This response does not commit the archive
        manifest; both variants require the normal checked finalize call. Never overwrite
        an existing object.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Segment'
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                oneOf:
                - type: object
                  properties:
                    upload:
                      $ref: '#/components/schemas/SignedUpload'
                    expires_at:
                      type: string
                      format: date-time
                  required:
                  - upload
                  - expires_at
                - type: object
                  properties:
                    upload:
                      type: 'null'
                    existing:
                      const: true
                    segment_id:
                      type: string
                      minLength: 1
                      maxLength: 256
                    verification:
                      const: gateway_readback
                    expires_at:
                      type: 'null'
                  required:
                  - upload
                  - existing
                  - segment_id
                  - verification
                  - expires_at
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/archives/segments/finalize:
    post:
      operationId: commitArchiveSegment
      summary: Verify the object and commit its archive descriptor
      description: Identical retry succeeds; conflicting content fails. Commit metadata
        only after storage identity, size, and integrity verification.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Segment'
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  committed:
                    const: true
                  segment_id:
                    type: string
                    minLength: 1
                    maxLength: 256
                  contiguous_sequence:
                    type: integer
                    minimum: 0
                required:
                - committed
                - segment_id
                - contiguous_sequence
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/archive-usage/candidates:
    get:
      operationId: listArchiveUsageCandidates
      summary: Discover finalized native archive generations for token accounting
      description: Returns only snapshots readable by the current archive caller. The project
        is null when the session has no unique historically attached project visible to the caller.
        A resumed session can finalize again at a later last_sequence.
      parameters:
      - {name: cursor, in: query, schema: {type: string}}
      - {name: limit, in: query, schema: {type: integer, minimum: 1, maximum: 100, default: 50}}
      responses:
        '200':
          description: Authorized finalized archives in stable session and generation order.
          content:
            application/json:
              schema:
                type: object
                required: [candidates, next_cursor]
                properties:
                  candidates:
                    type: array
                    items:
                      type: object
                      required: [organization_id, owner_user_id, session_id, generation, last_sequence, agent_id, project_id, runtime, native_session_id, native_aliases]
                      properties:
                        organization_id: {type: string, format: uuid}
                        owner_user_id: {type: [string, 'null'], format: uuid}
                        session_id: {type: string, format: uuid}
                        generation: {type: string}
                        last_sequence: {type: integer, minimum: 0}
                        agent_id: {type: string, format: uuid}
                        project_id: {type: [string, 'null'], format: uuid}
                        runtime: {type: string, enum: [claude, codex]}
                        native_session_id: {type: string}
                        native_aliases: {type: [array, 'null'], items: {type: string}}
                  next_cursor: {type: [string, 'null']}
        default:
          description: Validation, authorization, or backend failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/archives:
    get:
      operationId: listArchives
      summary: Read archive manifests
      description: Read compact manifests with a pinned current-generation checkpoint
        across every page. Follow opaque next_cursor without changing the snapshot.
        Concurrent commits must not change later pages' checkpoint. Cold recovery
        verifies old source bytes against source_sha256, sequence/range continuity
        and final source_anchor before appending. No transcript-entry indexes or live
        viewing.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  archives:
                    type: array
                    items:
                      $ref: '#/components/schemas/Archive'
                  checkpoint:
                    anyOf:
                    - $ref: '#/components/schemas/ArchiveCheckpoint'
                    - type: 'null'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - archives
                - checkpoint
                - next_cursor
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/archives/finalize:
    post:
      operationId: finalizeArchive
      summary: Finalize a capture generation and report gaps
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                generation:
                  type: string
                  minLength: 1
                  maxLength: 256
                last_sequence:
                  type: integer
                  minimum: 0
              required:
              - generation
              - last_sequence
              additionalProperties: false
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  complete:
                    type: boolean
                  gaps:
                    type: array
                    items:
                      $ref: '#/components/schemas/Gap'
                required:
                - complete
                - gaps
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/spawn-requests:
    post:
      operationId: requestSpawn
      summary: Persist explicit delegate launch intent
      description: Only permitted owner/delegate authority. No process runs merely
        because a board note exists.
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SpawnPost'
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  request:
                    $ref: '#/components/schemas/SpawnRequest'
                required:
                - request
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/machines/{machine_id}/spawn-requests:
    get:
      operationId: pendingSpawns
      summary: List launch requests for an owning machine
      description: Claim before executing. List visibility alone is not authorization
        to launch.
      parameters:
      - name: machine_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: state
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  requests:
                    type: array
                    items:
                      $ref: '#/components/schemas/SpawnRequest'
                required:
                - requests
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/spawn-requests/{request_id}/claim:
    post:
      operationId: claimSpawn
      summary: Acquire the exclusive launch lease
      parameters:
      - name: request_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                machine_id:
                  type: string
                  minLength: 1
                  maxLength: 256
              required:
              - machine_id
              additionalProperties: false
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  request:
                    $ref: '#/components/schemas/SpawnRequest'
                  lease_token:
                    type: string
                    minLength: 1
                    maxLength: 256
                required:
                - request
                - lease_token
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/spawn-requests/{request_id}/result:
    post:
      operationId: reportSpawn
      summary: Report a launch outcome
      description: ready requires a registered attached session, not a process ID.
        Reconcile uncertain launches before retrying.
      parameters:
      - name: request_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SpawnResult'
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  request:
                    $ref: '#/components/schemas/SpawnRequest'
                required:
                - request
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/spawn-requests/{request_id}:
    get:
      operationId: getSpawn
      summary: Read a launch request outcome
      parameters:
      - name: request_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  request:
                    $ref: '#/components/schemas/SpawnRequest'
                required:
                - request
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/organizations/{organization_id}/users:
    get:
      operationId: organizationUsers
      summary: List authorized organization users
      parameters:
      - name: organization_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  users:
                    type: array
                    items:
                      $ref: '#/components/schemas/User'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - users
                - next_cursor
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/organizations/{organization_id}/projects:
    get:
      operationId: organizationProjects
      summary: List projects within an organization
      parameters:
      - name: organization_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: remote
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Projects'
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/organizations/{organization_id}/agents:
    get:
      operationId: organizationAgents
      summary: List agents within an organization
      parameters:
      - name: organization_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: presence
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  agents:
                    type: array
                    items:
                      $ref: '#/components/schemas/RosterEntry'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - agents
                - next_cursor
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/organizations/{organization_id}/events:
    get:
      operationId: organizationEvents
      summary: Query permitted activity history
      description: Historical queries need not be low latency. Results are permission
        filtered, and cursors must not skip late-committing events.
      parameters:
      - name: organization_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: project_id
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: agent_id
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: user_id
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: type
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: after
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: before
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  events:
                    type: array
                    items:
                      $ref: '#/components/schemas/Event'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - events
                - next_cursor
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/users/{user_id}/machines:
    get:
      operationId: userMachines
      summary: List a user's permitted machines
      parameters:
      - name: user_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  machines:
                    type: array
                    items:
                      $ref: '#/components/schemas/Machine'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - machines
                - next_cursor
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/users/{user_id}/project-locations:
    get:
      operationId: userProjectLocations
      summary: List private project locations
      description: Private to the owning user and explicitly delegated agents; organization
        ownership does not automatically grant access.
      parameters:
      - name: user_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: project_id
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: machine_id
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  locations:
                    type: array
                    items:
                      $ref: '#/components/schemas/Location'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - locations
                - next_cursor
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    post:
      operationId: putProjectLocation
      summary: Record a private machine/project path
      parameters:
      - name: user_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                project_id:
                  type: string
                  minLength: 1
                  maxLength: 256
                machine_id:
                  type: string
                  minLength: 1
                  maxLength: 256
                path:
                  type: string
                  minLength: 1
                  maxLength: 4096
              required:
              - project_id
              - machine_id
              - path
              additionalProperties: false
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  location:
                    $ref: '#/components/schemas/Location'
                required:
                - location
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/users/{user_id}/delegate:
    put:
      operationId: setUserDelegate
      summary: Explicitly select or clear this human user's delegate
      description: Human self only. Compare-and-set requires current authority. Enabling
        grants only spawn/delegate capabilities; clearing preserves unrelated grants
        and history.
      parameters:
      - name: user_id
        in: path
        required: true
        schema:
          type: string
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
              - agent_id
              - expected_agent_id
              properties:
                agent_id:
                  type:
                  - string
                  - 'null'
                expected_agent_id:
                  type:
                  - string
                  - 'null'
      responses:
        '200':
          description: Confirmed designation.
          content:
            application/json:
              schema:
                type: object
                required:
                - delegate
                properties:
                  delegate:
                    type:
                    - object
                    - 'null'
    get:
      operationId: getUserDelegate
      summary: Read a user's designated delegate
      parameters:
      - name: user_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  delegate:
                    anyOf:
                    - $ref: '#/components/schemas/Agent'
                    - type: 'null'
                required:
                - delegate
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/projects/{project_id}/members:
    get:
      operationId: projectMembers
      summary: List permitted project members
      parameters:
      - name: project_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  members:
                    type: array
                    items:
                      $ref: '#/components/schemas/Member'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - members
                - next_cursor
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/projects/{project_id}/agents:
    get:
      operationId: projectAgents
      summary: List attached project agents
      parameters:
      - name: project_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: presence
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  agents:
                    type: array
                    items:
                      $ref: '#/components/schemas/RosterEntry'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - agents
                - next_cursor
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/agents/{agent_id}/messages:
    get:
      operationId: agentMessages
      summary: Enumerate an agent's sent and received message history
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
        description: Opaque cursor bound to organization, target agent, direction
          and kind.
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 50
      - name: direction
        in: query
        schema:
          type: string
          enum:
          - sent
          - received
          - all
          default: all
      - name: kind
        in: query
        schema:
          type: string
          enum:
          - direct
          - board
          default: direct
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                required:
                - messages
                - next_cursor
                properties:
                  messages:
                    type: array
                    items:
                      $ref: '#/components/schemas/AgentMessageHistoryEntry'
                  next_cursor:
                    type:
                    - string
                    - 'null'
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      description: Only the target agent or its owning human can query this history.
        Current per-message visibility is checked before pagination. Read receipts
        remain enumerable; self-addressed messages occur once. GET changes no delivery
        or read state. Bodies use the individual message endpoint. Results use ascending
        organization sequence.
  /v1/agents/{agent_id}/sessions:
    get:
      operationId: agentSessions
      summary: List an agent's permitted runtime sessions
      parameters:
      - name: agent_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: cursor
        in: query
        required: false
        schema:
          type: string
          maxLength: 2048
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  sessions:
                    type: array
                    items:
                      $ref: '#/components/schemas/Session'
                  next_cursor:
                    type:
                    - string
                    - 'null'
                required:
                - sessions
                - next_cursor
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/sessions/{session_id}/archives/{generation}/segments/{segment_id}/download:
    get:
      operationId: downloadArchiveSegment
      summary: Authorize retrieval of one archived segment
      description: Explicit permission check. Signed URLs are temporary and must not
        be cached publicly. Response shape may additionally include expires_at.
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: generation
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - name: segment_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      responses:
        '200':
          description: Confirmed successful operation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  download:
                    $ref: '#/components/schemas/SignedDownload'
                required:
                - download
        default:
          description: Validation, authorization, conflict, backend, or delivery failure.
            Unknown mutation outcomes require reconciliation with the original idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/spawn-requests/{request_id}/credentials:
    post:
      operationId: issueSpawnCredentials
      summary: Obtain a separately provisioned child identity from the approved broker
      description: Deployed broker route. Requires current owning-machine launch lease
        and idempotency key. Tokens are returned only to that connector, never written
        to SQL idempotency response logs. Retry/reissue preserves the same child identity.
        Broker absence fails visibly; never inherit parent/human/service credentials.
      parameters:
      - name: request_id
        in: path
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 256
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                machine_id:
                  type: string
                  minLength: 1
                  maxLength: 256
                lease_token:
                  type: string
                  minLength: 1
                  maxLength: 256
              required:
              - machine_id
              - lease_token
              additionalProperties: false
      responses:
        '200':
          description: Child credentials issued to the owning connector; no-store
            and secret redaction required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpawnCredentials'
        default:
          description: Unauthorized lease, broker missing/unavailable, conflict, or
            unknown outcome.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /v1/enrollments:
    post:
      operationId: enrollNativeAgent
      summary: Reconcile a human-authorized native conversation identity
      description: Human bearer only. Stable organization/user/runtime/native ID mapping;
        explicit resume aliases the prior session. Returns fresh distinct child credentials
        on every reconciliation, never cached token replay. The gateway verifies actual
        child Auth identity and current delegation.
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
              - runtime
              - native_session_id
              properties:
                runtime:
                  enum:
                  - claude
                  - codex
                  - gemini
                  - cursor
                  - grok
                native_session_id:
                  type: string
                  minLength: 1
                  maxLength: 256
                resume_session_id:
                  type: string
                  minLength: 1
                  maxLength: 256
                name:
                  type: string
                  minLength: 1
                  maxLength: 160
                work:
                  type: string
                  minLength: 1
                  maxLength: 2000
      responses:
        '200':
          description: Stable enrollment identity and newly issued child credentials.
            No-store; never log tokens.
          content:
            application/json:
              schema:
                type: object
                required:
                - enrollment_id
                - child
                - supabase_url
                - publishable_key
                properties:
                  enrollment_id:
                    type: string
                  session_id:
                    type: string
                  child:
                    $ref: '#/components/schemas/SpawnCredentials/properties/child'
                  supabase_url:
                    type: string
                    format: uri
                  publishable_key:
                    type: string
  /v1/machines/{machine_id}/controller:
    post:
      operationId: setMachineController
      summary: Explicitly select the human user's machine controller
      description: Human self authority only. Compare-and-set selection never permits
        impersonating children.
      parameters:
      - name: machine_id
        in: path
        required: true
        schema:
          type: string
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
              - agent_id
              - expected_controller_agent_id
              properties:
                agent_id:
                  type:
                  - string
                  - 'null'
                expected_controller_agent_id:
                  type:
                  - string
                  - 'null'
      responses:
        '200':
          description: Confirmed assignment.
          content:
            application/json:
              schema:
                type: object
                required:
                - machine_id
                - controller_agent_id
                properties:
                  machine_id:
                    type: string
                  controller_agent_id:
                    type:
                    - string
                    - 'null'
  /v1/messages/{message_id}/delivery-attempts:
    post:
      operationId: recordDeliveryAttempt
      summary: Record durable native delivery observation
      description: Accepted means adapter-confirmed acceptance, never completion of
        requested work. Ambiguous native outcomes remain unconfirmed.
      parameters:
      - name: message_id
        in: path
        required: true
        schema:
          type: string
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
              - session_id
              - generation
              - state
              properties:
                session_id:
                  type: string
                generation:
                  type: string
                state:
                  enum:
                  - unavailable
                  - unconfirmed
                  - accepted
                reason:
                  type: string
                  maxLength: 2000
                native_reference:
                  type: string
                  maxLength: 512
      responses:
        '200':
          description: Durable observation recorded.
          content:
            application/json:
              schema:
                type: object
                required:
                - attempt
                properties:
                  attempt:
                    type: object
  /v1/users/{user_id}/workspace-assignments:
    post:
      operationId: assignExistingWorkspace
      summary: Assign responsibility for an existing branch or worktree as its human
        owner
      description: Human only. The target agent must be bound to the same owning user.
        Unknown original creators remain null; known creators and existing Git facts
        are preserved. Assignment is separate auditable provenance, never a claimed
        Git creation. Exact expected_version and a stable idempotency key are required.
        Verified parent responsibility is inherited without granting capabilities.
      parameters:
      - name: user_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 8
          maxLength: 200
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkspaceAssignmentRequest'
      responses:
        '200':
          description: Assignment recorded or replayed
          content:
            application/json:
              schema:
                type: object
                required:
                - assignment
                properties:
                  assignment:
                    $ref: '#/components/schemas/WorkspaceAssignmentResult'
        default:
          description: Authentication, current authority, validation, concurrency
            or transport error. Reconcile uncertain mutations with the same idempotency
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  responses:
    EmployeeConnectionMetadata:
      description: Employee connection metadata available to the authenticated caller.
      content:
        application/json:
          schema:
            type: object
            required: [employee_id, provider, configured, version, tools]
            properties:
              employee_id: {type: string, format: uuid}
              provider: {type: string}
              configured: {type: boolean}
              credential_store_ready: {type: boolean, description: Whether the gateway has a credential encryption key configured.}
              unavailable_tools:
                type: array
                description: Actions whose private execution service is unconfigured at this gateway.
                items:
                  $ref: '#/components/schemas/CatalogToolName'
              version: {type: integer, minimum: 0}
              tools:
                type: array
                items:
                  $ref: '#/components/schemas/CatalogToolName'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: This caller's own Supabase JWT, origin-bound to the configured
        company backend. Agents use distinct Auth identities under live human delegation;
        never a human JWT or service-role credential. Legacy Warden wd_ tokens require
        explicit identity migration and are not silently accepted as Supabase authority.
        Never forward this bearer to arbitrary signed object URLs.
  parameters:
    CatalogToolId:
      name: tool_id
      in: path
      required: true
      schema:
        type: string
        pattern: ^[a-z][a-z0-9_]{0,63}$
    ToolSessionId:
      name: session_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
    ToolChildSessionId:
      name: child_session_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      schema:
        type: string
        minLength: 8
        maxLength: 200
        pattern: ^[A-Za-z0-9._:-]+$
      description: Reuse for retries of the same mutation. Conflicting reuse must
        fail. A timeout can mean unknown outcome; reconcile before creating new intent.
  schemas:
    GuardedLimitUpdate:
      type: object
      required: [expected_version, limit_minor]
      properties:
        expected_version: {type: integer, minimum: 0}
        limit_minor:
          anyOf:
          - {type: string, pattern: '^(0|[1-9][0-9]{0,29})$'}
          - {type: 'null'}
          description: USD cents. A null limit blocks ordinary capped spending.
      additionalProperties: false
    GuardedGrantUpdate:
      type: object
      required: [expected_version, tools]
      properties:
        expected_version: {type: integer, minimum: 0}
        tools:
          type: array
          maxItems: 256
          items:
            type: object
            required: [tool_id, enabled, unlimited, indefinite]
            properties:
              tool_id: {$ref: '#/components/schemas/CatalogToolName'}
              enabled: {type: boolean}
              unlimited: {type: boolean}
              indefinite: {type: boolean}
            additionalProperties: false
      additionalProperties: false
    GuardedEmployeeGrants:
      type: object
      required: [employee_id, version, tools]
      properties:
        employee_id: {type: string, format: uuid}
        version: {type: integer, minimum: 0}
        tools:
          type: array
          items:
            type: object
            required: [tool_id, enabled, unlimited, indefinite, currency, amount_minor, cadence]
            properties:
              tool_id: {$ref: '#/components/schemas/CatalogToolName'}
              enabled: {type: boolean}
              unlimited: {type: boolean}
              indefinite: {type: boolean}
              currency: {type: string}
              amount_minor: {type: string, pattern: '^(0|[1-9][0-9]{0,29})$'}
              cadence:
                type: string
                enum: [once, hourly]
    GuardedCharge:
      type: object
      required: [id, resource_id, project_id, tool_id, currency, amount_minor, action, state, indefinite,
        window_start, window_end, paid_until, reason]
      properties:
        id: {type: string, format: uuid}
        resource_id: {type: string, format: uuid}
        project_id: {type: string, format: uuid}
        tool_id: {$ref: '#/components/schemas/CatalogToolName'}
        currency: {type: string}
        amount_minor: {type: string, pattern: '^(0|[1-9][0-9]{0,29})$'}
        action:
          type: string
          enum: [charge, start, renew, stop]
        state:
          type: string
          enum: [reserved, settled, released, denied]
        indefinite: {type: boolean}
        window_start: {type: string, format: date-time}
        window_end:
          anyOf:
          - {type: string, format: date-time}
          - {type: 'null'}
        paid_until:
          anyOf:
          - {type: string, format: date-time}
          - {type: 'null'}
        reason:
          anyOf:
          - {type: string}
          - {type: 'null'}
        user_id:
          anyOf:
          - {type: string, format: uuid}
          - {type: 'null'}
        agent_id:
          anyOf:
          - {type: string, format: uuid}
          - {type: 'null'}
        session_id:
          anyOf:
          - {type: string, format: uuid}
          - {type: 'null'}
        call_id:
          anyOf:
          - {type: string, format: uuid}
          - {type: 'null'}
        created_at: {type: string, format: date-time}
        finalized_at:
          anyOf:
          - {type: string, format: date-time}
          - {type: 'null'}
        applied_at:
          anyOf:
          - {type: string, format: date-time}
          - {type: 'null'}
    GuardedProjectSpend:
      type: object
      required: [project_id, currency, limit_minor, spent_minor, reserved_minor, available_minor, version,
        charges]
      properties:
        project_id: {type: string, format: uuid}
        currency: {type: string}
        limit_minor:
          anyOf:
          - {type: string, pattern: '^(0|[1-9][0-9]{0,29})$'}
          - {type: 'null'}
        spent_minor: {type: string, pattern: '^(0|[1-9][0-9]{0,29})$'}
        reserved_minor: {type: string, pattern: '^(0|[1-9][0-9]{0,29})$'}
        available_minor:
          anyOf:
          - {type: string, pattern: '^-?[0-9]+$'}
          - {type: 'null'}
        version: {type: integer, minimum: 0}
        charges:
          type: array
          items: {$ref: '#/components/schemas/GuardedCharge'}
    ToolContextBinding:
      type: object
      properties:
        id:
          type: string
          format: uuid
        board_id:
          type: string
          format: uuid
        project_id:
          type:
          - string
          - 'null'
          format: uuid
        on_invoke:
          type: boolean
      required:
      - id
      - board_id
      - project_id
      - on_invoke
    ToolContextBindingPage:
      type: object
      properties:
        bindings:
          type: array
          items:
            $ref: '#/components/schemas/ToolContextBinding'
        next_cursor:
          type:
          - string
          - 'null'
          format: uuid
      required:
      - bindings
      - next_cursor
    ToolContextBindingResult:
      type: object
      properties:
        binding:
          oneOf:
          - $ref: '#/components/schemas/ToolContextBinding'
          - type: 'null'
      required:
      - binding
    BoardReminderPage:
      type: object
      properties:
        reminders:
          type: array
          items:
            type: object
            properties:
              message_id:
                type: string
                format: uuid
              subject:
                type: string
            required:
            - message_id
            - subject
        next_cursor:
          type:
          - string
          - 'null'
          format: uuid
      required:
      - reminders
      - next_cursor
    BoardReminderUpdate:
      type: object
      properties:
        message_id:
          type: string
          format: uuid
        board_id:
          type: string
          format: uuid
        active:
          type: boolean
      required:
      - message_id
      - board_id
      - active
    CatalogToolName:
      type: string
      pattern: ^[a-z][a-z0-9_]{0,63}$
    FavoriteToolSet:
      type: object
      required:
      - favorites
      properties:
        favorites:
          type: array
          uniqueItems: true
          items:
            $ref: '#/components/schemas/CatalogToolName'
    SessionHotToolSet:
      type: object
      required:
      - hot_tools
      properties:
        hot_tools:
          type: array
          uniqueItems: true
          items:
            $ref: '#/components/schemas/CatalogToolName'
    ToolHandoff:
      type: array
      uniqueItems: true
      items:
        $ref: '#/components/schemas/CatalogToolName'
      minItems: 1
    ToolContext:
      type: object
      required:
      - session_id
      - principal_kind
      - permissions
      - is_delegate
      - allowed_tools
      - favoriteable_tools
      - favorites
      - hot_tools
      properties:
        session_id:
          type:
          - string
          - 'null'
          format: uuid
        principal_kind:
          enum:
          - human
          - agent
        permissions:
          type: array
          items:
            type: string
        is_delegate:
          type: boolean
        allowed_tools:
          type: array
          items:
            $ref: '#/components/schemas/CatalogToolName'
        favoriteable_tools:
          type: array
          items:
            $ref: '#/components/schemas/CatalogToolName'
        favorites:
          type: array
          uniqueItems: true
          items:
            $ref: '#/components/schemas/CatalogToolName'
        hot_tools:
          type: array
          uniqueItems: true
          items:
            $ref: '#/components/schemas/CatalogToolName'
    WorkspaceRepositoryInput:
      type: object
      additionalProperties: false
      required:
      - repository_key
      - machine_id
      - project_id
      - root_path
      properties:
        repository_key:
          type: string
          format: uuid
        machine_id:
          type: string
          format: uuid
        project_id:
          type: string
          format: uuid
        root_path:
          type: string
          minLength: 1
          maxLength: 4096
          description: Canonical absolute local repository root; must exactly match
            an owned registered project location.
    WorkspaceMergeObservation:
      type: object
      additionalProperties: false
      required:
      - target_ref
      - target_oid
      - source_oid
      - method
      properties:
        target_ref:
          type: string
          minLength: 1
          maxLength: 256
        target_oid:
          type: string
          pattern: ^([0-9a-f]{40}|[0-9a-f]{64})$
        source_oid:
          type: string
          pattern: ^([0-9a-f]{40}|[0-9a-f]{64})$
        method:
          type: string
          enum:
          - ancestry
          - observed_squash
          - observed_rebase
    WorkspaceObservation:
      type: object
      additionalProperties: false
      required:
      - event_id
      - artifact_key
      - kind
      - operation
      - expected_version
      - name
      - head_oid
      - branch_name
      - dirty
      - merged_into
      - observed_at
      - evidence
      properties:
        event_id:
          type: string
          format: uuid
        artifact_key:
          type: string
          format: uuid
        kind:
          type: string
          enum:
          - branch
          - worktree
        operation:
          type: string
          enum:
          - create
          - observe
          - delete
        expected_version:
          type: integer
          minimum: 0
          maximum: 9007199254740990
          description: Zero for creation; exact current version for updates/deletion.
            Deleted incarnations cannot be revived.
        name:
          type: string
          minLength: 1
          maxLength: 4096
          description: Branch reference/name (maximum256 characters), or canonical
            absolute worktree path.
        head_oid:
          type:
          - string
          - 'null'
          pattern: ^([0-9a-f]{40}|[0-9a-f]{64})$
        branch_name:
          type:
          - string
          - 'null'
          minLength: 1
          maxLength: 256
        dirty:
          type:
          - boolean
          - 'null'
        merged_into:
          type: array
          maxItems: 16
          items:
            $ref: '#/components/schemas/WorkspaceMergeObservation'
          description: Every source_oid must equal this observation head_oid. Merging
            does not delete ownership.
        observed_at:
          type: string
          format: date-time
        evidence:
          type: object
          additionalProperties: false
          required:
          - source
          - invocation_id
          - publication
          properties:
            source:
              type: string
              const: git-observer
            invocation_id:
              type: string
              format: uuid
            publication:
              type: string
              const: verified
    WorkspaceObservationBatch:
      type: object
      additionalProperties: false
      required:
      - repository
      - observations
      properties:
        repository:
          $ref: '#/components/schemas/WorkspaceRepositoryInput'
        observations:
          type: array
          minItems: 1
          maxItems: 32
          items:
            $ref: '#/components/schemas/WorkspaceObservation'
    WorkspaceObservationResult:
      type: object
      additionalProperties: false
      required:
      - event_id
      - artifact_id
      - artifact_key
      - version
      - state
      properties:
        event_id:
          type: string
          format: uuid
        artifact_id:
          type: string
          format: uuid
        artifact_key:
          type: string
          format: uuid
        version:
          type: integer
          minimum: 1
        state:
          type: string
          enum:
          - present
          - deleted
    WorkspaceArtifact:
      type: object
      additionalProperties: false
      required:
      - artifact_key
      - kind
      - name
      - head_oid
      - branch_name
      - dirty
      - merged_into
      - observed_at
      - id
      - repository_key
      - state
      - version
      - creator_agent_id
      - owner_agent_ids
      - ownership_role
      - created_at
      - deleted_at
      - repository
      properties:
        artifact_key:
          type: string
          format: uuid
        kind:
          type: string
          enum:
          - branch
          - worktree
        name:
          type: string
          minLength: 1
          maxLength: 4096
          description: Branch reference/name (maximum256 characters), or canonical
            absolute worktree path.
        head_oid:
          type:
          - string
          - 'null'
          pattern: ^([0-9a-f]{40}|[0-9a-f]{64})$
        branch_name:
          type:
          - string
          - 'null'
          minLength: 1
          maxLength: 256
        dirty:
          type:
          - boolean
          - 'null'
        merged_into:
          type: array
          maxItems: 16
          items:
            $ref: '#/components/schemas/WorkspaceMergeObservation'
          description: Every source_oid must equal this observation head_oid. Merging
            does not delete ownership.
        observed_at:
          type: string
          format: date-time
        id:
          type: string
          format: uuid
        repository_key:
          type: string
          format: uuid
        state:
          type: string
          enum:
          - present
          - deleted
        version:
          type: integer
          minimum: 1
        creator_agent_id:
          type:
          - string
          - 'null'
          format: uuid
        owner_agent_ids:
          type: array
          items:
            type: string
            format: uuid
        ownership_role:
          type: string
          enum:
          - creator
          - orchestrator
          - assignee
        created_at:
          type: string
          format: date-time
        deleted_at:
          type:
          - string
          - 'null'
          format: date-time
        repository:
          type: object
          additionalProperties: false
          required:
          - id
          - repository_key
          - machine_id
          - project_id
          - root_path
          properties:
            id:
              type: string
              format: uuid
            repository_key:
              type: string
              format: uuid
            machine_id:
              type: string
              format: uuid
            project_id:
              type: string
              format: uuid
            root_path:
              type: string
              minLength: 1
              maxLength: 4096
              description: Canonical absolute local repository root; must exactly
                match an owned registered project location.
    NativeAgentLineageInput:
      type: object
      additionalProperties: false
      required:
      - child_runtime
      - child_native_session_id
      - parent_runtime
      - parent_native_session_id
      - expected_parent_agent_id
      properties:
        child_runtime:
          type: string
          enum:
          - claude
          - codex
          - gemini
          - cursor
          - grok
        child_native_session_id:
          type: string
          minLength: 1
          maxLength: 256
        parent_runtime:
          type: string
          enum:
          - claude
          - codex
          - gemini
          - cursor
          - grok
        parent_native_session_id:
          type: string
          minLength: 1
          maxLength: 256
        expected_parent_agent_id:
          type:
          - string
          - 'null'
          format: uuid
    NativeAgentLineage:
      type: object
      additionalProperties: false
      required:
      - organization_id
      - child_agent_id
      - parent_agent_id
      - owner_user_id
      - source
      - created_at
      properties:
        organization_id:
          type: string
          format: uuid
        child_agent_id:
          type: string
          format: uuid
        parent_agent_id:
          type: string
          format: uuid
        owner_user_id:
          type: string
          format: uuid
        source:
          type: string
          const: native-provider-parent
        created_at:
          type: string
          format: date-time
    WorkspaceHistoryEvent:
      type: object
      additionalProperties: false
      required:
      - id
      - organization_id
      - event_id
      - artifact_id
      - actor_agent_id
      - actor_session_id
      - observation
      - result
      - observed_at
      - recorded_at
      - actor_user_id
      properties:
        id:
          type: integer
          minimum: 1
        organization_id:
          type: string
          format: uuid
        event_id:
          type: string
          format: uuid
        artifact_id:
          type: string
          format: uuid
        actor_agent_id:
          type:
          - string
          - 'null'
          format: uuid
        actor_session_id:
          type:
          - string
          - 'null'
          format: uuid
        observation:
          oneOf:
          - $ref: '#/components/schemas/WorkspaceObservation'
          - $ref: '#/components/schemas/WorkspaceAssignment'
        result:
          oneOf:
          - $ref: '#/components/schemas/WorkspaceObservationResult'
          - $ref: '#/components/schemas/WorkspaceAssignmentResult'
        observed_at:
          type: string
          format: date-time
        recorded_at:
          type: string
          format: date-time
        actor_user_id:
          type: string
          format: uuid
    FolderBoard:
      type: object
      properties:
        id:
          type: string
          format: uuid
        organization_id:
          type: string
          format: uuid
        project_id:
          type: string
          format: uuid
        folder_path:
          type: string
          minLength: 1
          maxLength: 2048
        created_at:
          type: string
          format: date-time
      required:
      - id
      - organization_id
      - project_id
      - folder_path
      - created_at
      additionalProperties: false
    BoardSubscription:
      type: object
      properties:
        session_id:
          type: string
          format: uuid
        board_id:
          type: string
          format: uuid
        source:
          type: string
          enum:
          - folder
          - explicit
        subscribed:
          type: boolean
        start_sequence:
          type: integer
          minimum: 0
          description: Subscription cutoff; only later committed messages notify this
            source.
        subscribed_at:
          type: string
          format: date-time
        detached_at:
          type:
          - string
          - 'null'
          format: date-time
        board:
          $ref: '#/components/schemas/FolderBoard'
      required:
      - session_id
      - board_id
      - source
      - subscribed
      description: List results include board metadata and active rows. Mutation results
        include stored timestamps/cutoff when a row exists; unsubscribing a never-present
        source returns only identity, source and subscribed=false.
    WebhookNotification:
      type: object
      properties:
        schema:
          const: warden.webhook/1
        event_id:
          type: string
          format: uuid
        event_type:
          enum:
          - message.direct
          - message.board
        occurred_at:
          type: string
          format: date-time
        organization_id:
          type: string
          format: uuid
        agent_id:
          type: string
          format: uuid
        informational:
          type: boolean
        message:
          type: object
          properties:
            id:
              type: string
              format: uuid
            subject:
              type: string
              maxLength: 160
            sender_agent_id:
              type: string
              format: uuid
            sender_session_id:
              type: string
              format: uuid
            project_id:
              type:
              - string
              - 'null'
              format: uuid
            board_id:
              type:
              - string
              - 'null'
              format: uuid
          required:
          - id
          - subject
          - sender_agent_id
          - sender_session_id
          - project_id
          additionalProperties: false
      required:
      - schema
      - event_id
      - event_type
      - occurred_at
      - organization_id
      - agent_id
      - informational
      - message
      additionalProperties: false
      description: Outbound HTTPS notification. A 200 response acknowledges receiver
        acceptance, not reading or completing work. board_id identifies the folder
        board; direct messages have no board.
    DeliverySummary:
      allOf:
      - $ref: '#/components/schemas/MessageSummary'
      - type: object
        properties:
          delivery_state:
            type:
            - string
            - 'null'
          delivered_at:
            type:
            - string
            - 'null'
            format: date-time
          last_attempt:
            type:
            - object
            - 'null'
            properties:
              state:
                enum:
                - unavailable
                - unconfirmed
                - accepted
              at:
                type: string
                format: date-time
              native_reference:
                type:
                - string
                - 'null'
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
        retryable:
          type: boolean
        outcome:
          enum:
          - not_attempted
          - unknown
        reference:
          type: string
      required:
      - error
      - message
      - retryable
    User:
      type: object
      properties:
        id:
          type: string
          minLength: 1
          maxLength: 256
        name:
          type: string
      required:
      - id
      - name
    Organization:
      type: object
      properties:
        id:
          type: string
          minLength: 1
          maxLength: 256
        name:
          type: string
        role:
          enum:
          - owner
          - admin
          - member
      required:
      - id
      - name
      - role
    Project:
      type: object
      properties:
        id:
          type: string
          minLength: 1
          maxLength: 256
        organization_id:
          type: string
          minLength: 1
          maxLength: 256
        name:
          type: string
        description:
          type: string
        remotes:
          type: array
          items:
            type: string
      required:
      - id
      - organization_id
      - name
      - description
      - remotes
    Machine:
      type: object
      properties:
        id:
          type: string
          minLength: 1
          maxLength: 256
        name:
          type: string
        platform:
          type: string
        last_seen_at:
          type:
          - string
          - 'null'
          format: date-time
        controller_agent_id:
          type:
          - string
          - 'null'
          format: uuid
      required:
      - id
      - name
    Agent:
      type: object
      properties:
        owner_user_id:
          type: string
          format: uuid
          description: Delegating human owner derived from the creating membership,
            not the agent Auth user.
        id:
          type: string
          minLength: 1
          maxLength: 256
        name:
          type:
          - string
          - 'null'
        work:
          type:
          - string
          - 'null'
      required:
      - owner_user_id
      - id
      - name
      - work
    Session:
      type: object
      properties:
        id:
          type: string
          minLength: 1
          maxLength: 256
        agent_id:
          type: string
          minLength: 1
          maxLength: 256
        project_ids:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 256
        presence:
          enum:
          - active
          - idle
          - disconnected
        generation:
          type:
          - string
          - 'null'
          minLength: 1
          maxLength: 256
          description: Null until an explicit native execution is registered. Provisional
            registration never creates a run.
        runtime:
          type:
          - string
          - 'null'
        native_session_id:
          type:
          - string
          - 'null'
        machine_id:
          type:
          - string
          - 'null'
        board_ids:
          type: array
          items:
            type: string
            format: uuid
      required:
      - id
      - agent_id
      - project_ids
      - presence
      - generation
    RosterEntry:
      type: object
      properties:
        owner_user_id:
          type: string
          format: uuid
          description: Delegating human owner derived from the creating membership,
            not the agent Auth user.
        agent_id:
          type: string
          minLength: 1
          maxLength: 256
        session_id:
          type: string
          minLength: 1
          maxLength: 256
        name:
          type:
          - string
          - 'null'
        work:
          type:
          - string
          - 'null'
        presence:
          enum:
          - active
          - idle
          - disconnected
        project_ids:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 256
      required:
      - owner_user_id
      - agent_id
      - session_id
      - name
      - work
      - presence
      - project_ids
    MessageSummary:
      type: object
      properties:
        id:
          type: string
          minLength: 1
          maxLength: 256
        subject:
          type: string
        sender_agent_id:
          type: string
          minLength: 1
          maxLength: 256
        project_id:
          type:
          - string
          - 'null'
          minLength: 1
          maxLength: 256
        kind:
          enum:
          - board
          - direct
        board_id:
          type:
          - string
          - 'null'
          format: uuid
      required:
      - id
      - subject
      - sender_agent_id
      - kind
    Message:
      type: object
      properties:
        id:
          type: string
          minLength: 1
          maxLength: 256
        subject:
          type: string
        body:
          type: string
        sender_agent_id:
          type: string
          minLength: 1
          maxLength: 256
        sender_session_id:
          type: string
          minLength: 1
          maxLength: 256
        project_id:
          type:
          - string
          - 'null'
          minLength: 1
          maxLength: 256
        recipient_agent_id:
          type:
          - string
          - 'null'
          minLength: 1
          maxLength: 256
        created_at:
          type: string
          format: date-time
        kind:
          enum:
          - board
          - direct
        sequence:
          type: string
          pattern: ^[0-9]+$
          description: Organization commit-order cursor; preserve as text.
        board_id:
          type:
          - string
          - 'null'
          format: uuid
      required:
      - id
      - subject
      - body
      - sender_agent_id
      - sender_session_id
      - created_at
    Receipt:
      type: object
      properties:
        message_id:
          type: string
          minLength: 1
          maxLength: 256
        agent_id:
          type: string
          minLength: 1
          maxLength: 256
        state:
          enum:
          - delivered
          - read
        at:
          type: string
          format: date-time
      required:
      - message_id
      - agent_id
      - state
      - at
    RecipientReceipt:
      type: object
      description: Recipient state from GET receipts. Delivery and explicit reading
        are independent timestamps, not task completion.
      properties:
        message_id:
          type: string
          format: uuid
        agent_id:
          type: string
          format: uuid
        intended_session_id:
          type:
          - string
          - 'null'
          format: uuid
        delivered_at:
          type:
          - string
          - 'null'
          format: date-time
        read_at:
          type:
          - string
          - 'null'
          format: date-time
        last_attempt:
          type:
          - object
          - 'null'
          description: Retained native delivery-attempt metadata, when present.
      required:
      - message_id
      - agent_id
      - intended_session_id
      - delivered_at
      - read_at
      - last_attempt
    SegmentDescriptor:
      type: object
      properties:
        segment_id:
          type: string
          minLength: 1
          maxLength: 256
        sequence:
          type: integer
          minimum: 0
        source_offset:
          type: integer
          minimum: 0
        source_bytes:
          type: integer
          minimum: 0
          maximum: 16777216
        sha256:
          type: string
          pattern: ^[a-f0-9]{64}$
        bytes:
          type: integer
          minimum: 1
          maximum: 16777216
        encoding:
          const: gzip
        format:
          const: native-jsonl
        generation:
          type: string
          minLength: 1
          maxLength: 256
        source_sha256:
          type: string
          pattern: ^[a-f0-9]{64}$
          description: SHA-256 of this segment's uncompressed source bytes; verifies
            cold-resume prefix continuity.
        source_anchor:
          type: string
          pattern: ^[a-f0-9]{64}$
          description: SHA-256 of up to the final 4096 source bytes ending at source_offset
            + source_bytes. May include preceding segment bytes when this segment
            is shorter than 4096 bytes.
      required:
      - segment_id
      - sequence
      - source_offset
      - source_bytes
      - sha256
      - bytes
      - encoding
      - format
      - generation
      - source_sha256
      - source_anchor
    Segment:
      allOf:
      - $ref: '#/components/schemas/SegmentDescriptor'
      unevaluatedProperties: false
      description: Strict client-supplied descriptor; server storage locations are
        not accepted as input.
    StoredSegment:
      allOf:
      - $ref: '#/components/schemas/SegmentDescriptor'
      properties:
        bucket:
          type: string
        key:
          type: string
      required:
      - bucket
      - key
      unevaluatedProperties: false
      description: Descriptor with server-assigned private storage location. Metadata
        alone does not establish byte verification.
    Gap:
      description: Missing inclusive segment sequence range.
      type: object
      properties:
        first:
          type: integer
          minimum: 0
        last:
          type: integer
          minimum: 0
      required:
      - first
      - last
    Archive:
      type: object
      properties:
        generation:
          type: string
          minLength: 1
          maxLength: 256
        segments:
          type: array
          items:
            $ref: '#/components/schemas/StoredSegment'
        complete:
          type: boolean
        gaps:
          type: array
          items:
            $ref: '#/components/schemas/Gap'
      required:
      - generation
      - segments
      - complete
      - gaps
    SignedUpload:
      type: object
      properties:
        url:
          type: string
          format: uri
        method:
          const: PUT
        headers:
          type: object
          additionalProperties:
            type: string
      required:
      - url
      - method
      - headers
    SignedDownload:
      type: object
      properties:
        url:
          type: string
          format: uri
        method:
          const: GET
        headers:
          type: object
          additionalProperties:
            type: string
      required:
      - url
      - method
      - headers
    SpawnRequest:
      type: object
      properties:
        id:
          type: string
          minLength: 1
          maxLength: 256
        state:
          enum:
          - requested
          - claimed
          - starting
          - ready
          - failed
        machine_id:
          type: string
          minLength: 1
          maxLength: 256
        project_id:
          type: string
          minLength: 1
          maxLength: 256
        runtime:
          enum:
          - claude
          - codex
          - gemini
          - cursor
          - grok
        name:
          type: string
        work:
          type: string
        prompt:
          type: string
        session_id:
          type:
          - string
          - 'null'
          minLength: 1
          maxLength: 256
        error:
          type:
          - string
          - 'null'
      required:
      - id
      - state
    Location:
      type: object
      properties:
        project_id:
          type: string
          minLength: 1
          maxLength: 256
        machine_id:
          type: string
          minLength: 1
          maxLength: 256
        path:
          type: string
        id:
          type: string
          format: uuid
        organization_id:
          type: string
          format: uuid
        owner_user_id:
          type: string
          format: uuid
      required:
      - project_id
      - machine_id
      - path
    Member:
      type: object
      properties:
        user_id:
          type: string
          minLength: 1
          maxLength: 256
        role:
          type: string
      required:
      - user_id
    Event:
      type: object
      properties:
        subject_agent_id:
          type:
          - string
          - 'null'
          description: Agent whose description or project attachment changed; distinct
            from the actor.
        change:
          type:
          - object
          - 'null'
          description: Compact historical facts for agent_description or project_attachment
            changes. Description before/after values contain name and work. Attachment
            values contain attached_at and detached_at. A null before value means
            no earlier state was recorded, not that a historical state was reconstructed.
            Current permissions filter these events.
          properties:
            kind:
              type: string
              enum:
              - agent_description
              - project_attachment
            agent_id:
              type:
              - string
              - 'null'
            session_id:
              type:
              - string
              - 'null'
            project_id:
              type:
              - string
              - 'null'
            baseline:
              type:
              - boolean
              - 'null'
            before:
              type:
              - object
              - 'null'
            after:
              type: object
        id:
          type: integer
          format: int64
          minimum: 1
        type:
          type: string
        at:
          type: string
          format: date-time
        project_id:
          type:
          - string
          - 'null'
          minLength: 1
          maxLength: 256
        sequence:
          type: string
          pattern: ^[0-9]+$
        user_id:
          type:
          - string
          - 'null'
          format: uuid
        agent_id:
          type:
          - string
          - 'null'
          format: uuid
        resource_id:
          type:
          - string
          - 'null'
          format: uuid
      required:
      - id
      - type
      - at
      description: Permission-filtered activity. user_id and agent_id identify the
        actor; subject_agent_id identifies an affected agent when distinct.
    AuthSession:
      type: object
      properties:
        user:
          $ref: '#/components/schemas/User'
        organizations:
          type: array
          items:
            $ref: '#/components/schemas/Organization'
        service_version:
          type:
          - string
          - 'null'
          description: Actual Cloudflare Worker deployment version ID; null when local
            runtime lacks version metadata.
        company_schema_version:
          type: string
          minLength: 1
          description: Version read from the actual company schema contract.
        principal:
          $ref: '#/components/schemas/AuthPrincipal'
      required:
      - user
      - organizations
      - principal
      - service_version
      - company_schema_version
    Projects:
      type: object
      properties:
        projects:
          type: array
          items:
            $ref: '#/components/schemas/Project'
        next_cursor:
          type:
          - string
          - 'null'
      required:
      - projects
      - next_cursor
    Registration:
      type: object
      properties:
        registration_kind:
          type: string
          enum:
          - execution
          - provisional
          description: A supplied per-execution runtime key registers an execution;
            keyless enrollment/attachment is provisional and does not manufacture
            a runtime.
        agent:
          $ref: '#/components/schemas/Agent'
        session:
          $ref: '#/components/schemas/Session'
        roster:
          type: array
          items:
            $ref: '#/components/schemas/RosterEntry'
        guidance:
          type: array
          items:
            type: string
      required:
      - registration_kind
      - agent
      - session
      - roster
      - guidance
    Context:
      type: object
      properties:
        agent:
          $ref: '#/components/schemas/Agent'
        session:
          $ref: '#/components/schemas/Session'
        roster:
          type: array
          items:
            $ref: '#/components/schemas/RosterEntry'
        messages:
          type: array
          items:
            $ref: '#/components/schemas/MessageSummary'
        next_cursor:
          type:
          - string
          - 'null'
        guidance:
          type: array
          items:
            type: string
      required:
      - agent
      - session
      - roster
      - messages
      - next_cursor
      - guidance
    Readiness:
      type: object
      properties:
        ready:
          const: true
        protocol:
          const: warden-company/1
          description: Warden adapter contract version, not a generic company dispatch
            endpoint.
        authorization_checked:
          const: true
        storage:
          const: configured
        storage_verified:
          const: false
        database:
          const: connected
        identity_broker:
          const: ready
        company_schema_version:
          type: string
          minLength: 1
          description: Version read from the actual company schema contract.
        capabilities:
          type: object
          properties:
            projects:
              const: true
            sessions:
              const: true
            messaging:
              const: true
            archives:
              const: true
            spawning:
              const: true
            permissions:
              const: true
          required:
          - projects
          - sessions
          - messaging
          - archives
          - spawning
          - permissions
          description: Actual checked required runtime capabilities. Missing capability
            fails readiness.
        service_version:
          type:
          - string
          - 'null'
          description: Actual Cloudflare Worker deployment version ID; null when local
            runtime lacks version metadata.
      required:
      - ready
      - protocol
      - authorization_checked
      - storage
      - company_schema_version
      - capabilities
      - service_version
    Health:
      type: object
      properties:
        protocol:
          const: warden-runtime/1
        backend_configured:
          type: boolean
        version:
          type:
          - string
          - 'null'
      required:
      - protocol
      - backend_configured
    MachineRegistration:
      type: object
      properties:
        machine_key:
          type: string
          minLength: 1
          maxLength: 256
        name:
          type: string
          minLength: 1
          maxLength: 160
        platform:
          type: string
          minLength: 1
          maxLength: 160
      required:
      - machine_key
      - name
      - platform
      additionalProperties: false
    SessionRegistration:
      type: object
      properties:
        machine_id:
          type: string
          minLength: 1
          maxLength: 256
        runtime:
          enum:
          - claude
          - codex
          - gemini
          - cursor
          - grok
        native_session_id:
          type: string
          minLength: 1
          maxLength: 256
        name:
          type: string
          minLength: 1
          maxLength: 160
        work:
          type: string
          minLength: 1
          maxLength: 2000
        project_ids:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 256
          maxItems: 100
        parent_session_id:
          type: string
          minLength: 1
          maxLength: 256
        runtime_instance_key:
          type: string
          minLength: 1
          maxLength: 256
          description: Stable identity of a native process incarnation. Replacement
            changes presence generation, not logical session.
        resume_session_id:
          type: string
          minLength: 1
          maxLength: 256
          description: Explicit authorized logical session to continue when provider
            native identifiers change. Forking is distinct.
        expected_generation:
          type:
          - string
          - 'null'
          format: uuid
          description: Optional recovery compare-and-set checked under the logical
            session's mutation lock. Supply the predecessor generation observed before
            recovery; a different current generation returns HTTP 409 without superseding
            the newer execution. Null expects no prior execution generation (a provisional
            or new session). Omission preserves ordinary explicit registration.
      required:
      - machine_id
      - runtime
      - native_session_id
      - project_ids
      additionalProperties: false
    AgentUpdate:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 160
        work:
          type: string
          minLength: 1
          maxLength: 2000
      required:
      - name
      - work
      additionalProperties: false
    RuntimeRun:
      type: object
      description: One execution incarnation of a logical session. Unknown historical
        boundaries remain null. Server receipt timestamps are retained separately
        from client observations; observed end never means successful task completion.
      properties:
        id:
          type: string
          format: uuid
        session_id:
          type: string
          format: uuid
        predecessor_run_id:
          type:
          - string
          - 'null'
          format: uuid
        is_resume:
          type:
          - boolean
          - 'null'
          description: Null when legacy history cannot establish whether this execution
            was a resume.
        registered_at:
          type: string
          format: date-time
        started_at:
          type: string
          format: date-time
        start_time_source:
          type: string
        instance_identity_source:
          type: string
          enum:
          - explicit_key
          - legacy_session_fallback
          - legacy_unknown
          description: Only an explicit per-execution key distinguishes reconnect
            from a new run. Legacy fallback and unknown records do not establish that
            distinction.
        ended_at:
          type:
          - string
          - 'null'
          format: date-time
        closure_kind:
          type:
          - string
          - 'null'
        closed_detected_at:
          type:
          - string
          - 'null'
          format: date-time
        last_observed_at:
          type:
          - string
          - 'null'
          format: date-time
        lease_expires_at:
          type:
          - string
          - 'null'
          format: date-time
        start_boundary:
          $ref: '#/components/schemas/RunBoundary'
        end_boundary:
          $ref: '#/components/schemas/RunBoundary'
    RunBoundary:
      type:
      - object
      - 'null'
      properties:
        observed_at:
          type: string
          format: date-time
        received_at:
          type: string
          format: date-time
        boundary_attribution:
          type: string
          enum:
          - observed_snapshot
        observation_source:
          type: string
          enum:
          - native_hook
          - process_exit
        exit_code:
          type:
          - integer
          - 'null'
          minimum: 0
        exit_signal:
          type:
          - integer
          - 'null'
          minimum: 1
        source_offset:
          type: integer
          minimum: 0
        source_anchor:
          type: string
          pattern: ^[a-f0-9]{64}$
        archive_generation:
          type: string
    PresenceUpdate:
      type: object
      properties:
        state:
          enum:
          - active
          - idle
          - disconnected
        generation:
          type: string
          minLength: 1
          maxLength: 256
        pid:
          type: integer
          minimum: 1
        observation_kind:
          type: string
          enum:
          - process_missing
          - transport_disconnected
          description: Disconnection evidence only; it does not establish an observed
            native end timestamp.
      required:
      - state
      - generation
      additionalProperties: false
    MessagePost:
      type: object
      properties:
        sender_session_id:
          type: string
          minLength: 1
          maxLength: 256
        project_id:
          type: string
          minLength: 1
          maxLength: 256
        recipient_agent_id:
          type: string
          minLength: 1
          maxLength: 256
        subject:
          type: string
          minLength: 1
          maxLength: 160
        body:
          type: string
          maxLength: 65536
        board_id:
          type: string
          format: uuid
      required:
      - sender_session_id
      - subject
      - body
      additionalProperties: false
      oneOf:
      - required:
        - project_id
        not:
          anyOf:
          - required:
            - board_id
          - required:
            - recipient_agent_id
      - required:
        - board_id
        not:
          anyOf:
          - required:
            - project_id
          - required:
            - recipient_agent_id
      - required:
        - recipient_agent_id
        not:
          anyOf:
          - required:
            - project_id
          - required:
            - board_id
    SpawnPost:
      type: object
      dependentRequired:
        tool_ids: [parent_session_id]
      properties:
        tool_ids:
          type: array
          items:
            $ref: '#/components/schemas/CatalogToolName'
        parent_session_id:
          type: string
          format: uuid
        machine_id:
          type: string
          minLength: 1
          maxLength: 256
        project_id:
          type: string
          minLength: 1
          maxLength: 256
        runtime:
          enum:
          - claude
          - codex
          - gemini
          - cursor
          - grok
        name:
          type: string
          minLength: 1
          maxLength: 160
        work:
          type: string
          minLength: 1
          maxLength: 2000
        prompt:
          type: string
          minLength: 1
          maxLength: 65536
      required:
      - machine_id
      - project_id
      - runtime
      - name
      - work
      - prompt
      additionalProperties: false
    SpawnResult:
      type: object
      properties:
        machine_id:
          type: string
          minLength: 1
          maxLength: 256
        lease_token:
          type: string
          minLength: 1
          maxLength: 256
        state:
          enum:
          - starting
          - ready
          - failed
        session_id:
          type: string
          minLength: 1
          maxLength: 256
        error:
          type: string
          maxLength: 2000
      required:
      - machine_id
      - lease_token
      - state
      additionalProperties: false
      allOf:
      - if:
          properties:
            state:
              const: ready
        then:
          required:
          - session_id
    AuthPrincipal:
      type: object
      properties:
        kind:
          enum:
          - human
          - agent
        subject:
          type: string
          description: Verified human/agent Supabase Auth subject, stable across JWT
            refresh; not an agent's delegator.
        agent_id:
          type: string
          minLength: 1
          maxLength: 256
      required:
      - subject
    ArchiveCheckpoint:
      type: object
      properties:
        generation:
          type: string
          minLength: 1
          maxLength: 256
        next_sequence:
          type: integer
          minimum: 1
        source_offset:
          type: integer
          minimum: 1
        source_anchor:
          type: string
          pattern: ^[a-f0-9]{64}$
      required:
      - generation
      - next_sequence
      - source_offset
      - source_anchor
      description: Pinned current-generation checkpoint, identical across all pages
        of one archive enumeration. Offset is next source byte and next_sequence is
        next segment index. Null only when no committed archive exists.
    SpawnCredentials:
      type: object
      properties:
        request_id:
          type: string
          minLength: 1
          maxLength: 256
        publishable_key:
          type: string
        supabase_url:
          type: string
          format: uri
        child:
          type: object
          properties:
            access_token:
              type: string
              readOnly: true
              description: Secret returned only to the authorized owning connector;
                never log or persist in SQL response journals.
            refresh_token:
              type: string
              readOnly: true
              description: Secret stored only in protected child credential storage;
                never expose in normal command output.
            agent_id:
              type: string
            auth_user_id:
              type: string
            expires_at:
              type: integer
              description: Unix-seconds credential expiry. Reconciliation issues fresh
                credentials for the same child identity.
          required:
          - access_token
          - refresh_token
          - agent_id
          - auth_user_id
          - expires_at
      required:
      - request_id
      - publishable_key
      - child
      - supabase_url
    AgentMessageHistoryEntry:
      allOf:
      - $ref: '#/components/schemas/MessageSummary'
      - type: object
        required:
        - sender_session_id
        - created_at
        - sequence
        - relation
        - receipt
        properties:
          relation:
            type: object
            required:
            - sent
            - received
            properties:
              sent:
                type: boolean
              received:
                type: boolean
          receipt:
            oneOf:
            - type: 'null'
            - type: object
              required:
              - intended_session_id
              - delivered_at
              - read_at
              properties:
                intended_session_id:
                  type:
                  - string
                  - 'null'
                  format: uuid
                delivered_at:
                  type:
                  - string
                  - 'null'
                  format: date-time
                read_at:
                  type:
                  - string
                  - 'null'
                  format: date-time
    WebhookMetadata:
      type: object
      properties:
        id:
          type: string
          format: uuid
        agent_id:
          type: string
          format: uuid
        hostname:
          type:
          - string
          - 'null'
        enabled:
          type: boolean
        version:
          type: integer
          minimum: 1
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
      - id
      - agent_id
      - hostname
      - enabled
      - version
      - created_at
      - updated_at
    WebhookHosts:
      type: object
      properties:
        hostnames:
          type: array
          items:
            type: string
            maxLength: 253
        version:
          type: integer
          minimum: 0
      required:
      - hostnames
      - version
    WebhookConfiguration:
      type: object
      properties:
        webhook:
          oneOf:
          - $ref: '#/components/schemas/WebhookMetadata'
          - type: 'null'
      required:
      - webhook
    WebhookConfigurationInput:
      description: HTTPS routine URL and Bearer key are write-only. Disable without
        credentials. Zero expected_version creates the initial configuration.
      oneOf:
      - type: object
        properties:
          enabled:
            const: true
          url:
            type: string
            format: uri
            minLength: 1
            maxLength: 2048
            writeOnly: true
          key:
            type: string
            minLength: 1
            maxLength: 4096
            pattern: ^[!-~]+$
            writeOnly: true
          expected_version:
            type: integer
            minimum: 0
        required:
        - enabled
        - url
        - key
        - expected_version
        additionalProperties: false
      - type: object
        properties:
          enabled:
            const: false
          expected_version:
            type: integer
            minimum: 0
        required:
        - enabled
        - expected_version
        additionalProperties: false
    WebhookDelivery:
      type: object
      properties:
        id:
          type: string
          format: uuid
        event_type:
          enum:
          - message.direct
          - message.board
        state:
          enum:
          - queued
          - leased
          - accepted
          - suppressed
          - failed
        attempts:
          type: integer
          minimum: 0
          maximum: 8
        outcome_unknown:
          type: boolean
          description: An attempt may have reached the receiver without a confirmed
            durable outcome. Retries can duplicate remote runs; event_id stays stable.
        next_attempt_at:
          type: string
          format: date-time
        last_http_status:
          type:
          - integer
          - 'null'
        last_error_code:
          type:
          - string
          - 'null'
        created_at:
          type: string
          format: date-time
        occurred_at:
          type: string
          format: date-time
        accepted_at:
          type:
          - string
          - 'null'
          format: date-time
        finished_at:
          type:
          - string
          - 'null'
          format: date-time
        endpoint_version:
          type: integer
          minimum: 1
        content_visible:
          type: boolean
          description: Whether current permissions allow linked message references.
            Otherwise message_id, session_id and project_id are null.
        message_id:
          type:
          - string
          - 'null'
          format: uuid
        session_id:
          type:
          - string
          - 'null'
          format: uuid
        project_id:
          type:
          - string
          - 'null'
          format: uuid
      required:
      - id
      - event_type
      - state
      - attempts
      - outcome_unknown
      - next_attempt_at
      - last_http_status
      - last_error_code
      - created_at
      - occurred_at
      - accepted_at
      - finished_at
      - endpoint_version
      - content_visible
      - message_id
      - session_id
      - project_id
    WorkspaceAssignment:
      type: object
      additionalProperties: false
      required:
      - event_id
      - artifact_key
      - kind
      - expected_version
      - name
      - head_oid
      - branch_name
      - dirty
      - merged_into
      - observed_at
      - agent_id
      - source
      properties:
        event_id:
          type: string
          format: uuid
        artifact_key:
          type: string
          format: uuid
        kind:
          type: string
          enum:
          - branch
          - worktree
        expected_version:
          type: integer
          minimum: 0
          maximum: 9007199254740990
          description: Zero for creation; exact current version for updates/deletion.
            Deleted incarnations cannot be revived.
        name:
          type: string
          minLength: 1
          maxLength: 4096
          description: Branch reference/name (maximum256 characters), or canonical
            absolute worktree path.
        head_oid:
          type:
          - string
          - 'null'
          pattern: ^([0-9a-f]{40}|[0-9a-f]{64})$
        branch_name:
          type:
          - string
          - 'null'
          minLength: 1
          maxLength: 256
        dirty:
          type:
          - boolean
          - 'null'
        merged_into:
          type: array
          maxItems: 16
          items:
            $ref: '#/components/schemas/WorkspaceMergeObservation'
          description: Every source_oid must equal this observation head_oid. Merging
            does not delete ownership.
        observed_at:
          type: string
          format: date-time
        agent_id:
          type: string
          format: uuid
        source:
          type: string
          const: owner-assignment
    WorkspaceAssignmentRequest:
      type: object
      additionalProperties: false
      required:
      - repository
      - assignment
      properties:
        repository:
          $ref: '#/components/schemas/WorkspaceRepositoryInput'
        assignment:
          $ref: '#/components/schemas/WorkspaceAssignment'
    WorkspaceAssignmentResult:
      type: object
      additionalProperties: false
      required:
      - event_id
      - artifact_id
      - artifact_key
      - version
      - state
      - agent_id
      - ownership_role
      properties:
        event_id:
          type: string
          format: uuid
        artifact_id:
          type: string
          format: uuid
        artifact_key:
          type: string
          format: uuid
        version:
          type: integer
          minimum: 1
        state:
          type: string
          enum:
          - present
          - deleted
        agent_id:
          type: string
          format: uuid
        ownership_role:
          type: string
          enum:
          - creator
          - orchestrator
          - assignee
