{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "http://json-schema.org/draft-07/schema#",
  "info": {
    "title": "DesireCore Agent Service — public HTTP subset",
    "version": "1.4.0",
    "description": "Selected externally callable endpoints for an administrator-provided standalone instance. This document is a subset of the service, and is not an application release declaration. Consult the linked guides for deployment, authorization and asynchronous results."
  },
  "servers": [
    {
      "url": "https://{instanceHost}",
      "description": "Replace with the HTTPS address supplied by the administrator. This is not the public documentation site.",
      "variables": {
        "instanceHost": {
          "default": "your-instance.example",
          "description": "Actual instance host, including a nonstandard port when required."
        }
      }
    }
  ],
  "tags": [
    {
      "name": "Connection",
      "description": "Instance identity and authenticated connection checks."
    },
    {
      "name": "Webhook",
      "description": "Administrator-configured external event triggers."
    },
    {
      "name": "Read-only",
      "description": "Owner read-only metadata and user-owned receipts."
    },
    {
      "name": "Conversations",
      "description": "HTTP submission and admission lookup; asynchronous messages use Socket.IO."
    },
    {
      "name": "Webhook management",
      "description": "Owner configuration, selected Tool grants and dedicated secret rotation."
    },
    {
      "name": "Attachments and media",
      "description": "Authenticated uploads and attachment downloads; short-lived signed media access."
    },
    {
      "name": "Session history",
      "description": "Owner-scoped historical messages and bounded conversation-matter reads."
    },
    {
      "name": "Observability",
      "description": "Upstream connectivity, user-scoped recent tool calls and recorded usage. Observations do not authorize or replay work."
    },
    {
      "name": "TaskBoard",
      "description": "Owner-authorized task boards, query pages, handoff evidence and fixed-prefix task activity."
    },
    {
      "name": "Object storage",
      "description": "Read connection summaries, provider object lists, links and bytes through existing S3 compatible connections."
    },
    {
      "name": "Workers",
      "description": "Owner-scoped temporary Worker records; valid-entry pagination and public field projection."
    },
    {
      "name": "Instance management",
      "description": "Explicit deployment-owner archive restoration and exact Workflow binding management."
    }
  ],
  "paths": {
    "/api/client-handshake": {
      "get": {
        "operationId": "getAgentServiceClientHandshake",
        "tags": [
          "Connection"
        ],
        "summary": "Verify an existing instance credential and identify the service",
        "description": "Does not issue credentials. A 200 response does not establish that every optional capability is configured. Extension headers only request metadata; they do not grant permissions.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/connection-and-auth"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "x-desirecore-handshake-extensions",
            "in": "header",
            "required": false,
            "description": "Optional comma-separated extensions: product-identity, query-dispatch, deployment-capabilities. Unrecognized names are ignored.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authenticated service identity and capability metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientHandshake"
                },
                "example": {
                  "service": "desirecore-agent-service",
                  "apiProtocolVersion": "1",
                  "serverVersion": "10.0.180",
                  "instanceId": "inst_0123456789abcdefghijklmnopqrstuv",
                  "deploymentMode": "external",
                  "clientCompatibility": {
                    "minimumVersion": "0.0.0",
                    "maximumVersion": null
                  },
                  "capabilities": {
                    "workflow": false,
                    "mediaSignedUrl": true,
                    "pdfRendering": false,
                    "localPairing": true,
                    "queryRequestIdEcho": true
                  },
                  "authentication": {
                    "kind": "instance-token",
                    "scopes": [
                      "owner"
                    ]
                  },
                  "serverTime": "2026-10-14T08:00:00.000Z"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store, private"
                }
              },
              "Vary": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "A browser Origin is not allowed by this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginRejection"
                }
              }
            }
          },
          "500": {
            "description": "Service identity cannot be read or another server failure occurred; the response does not expose the data-directory path.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FrameworkError"
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/webhook/{agent_id}": {
      "post": {
        "operationId": "triggerAgentWebhook",
        "tags": [
          "Webhook"
        ],
        "summary": "Trigger an administrator-configured Agent event",
        "description": "The Agent and event must already be enabled and configured. Receives an event and starts background processing. A 200 acknowledgement contains no Run ID or final result. There is no public idempotency key; repeated requests may trigger repeated executions.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/agent-webhook"
        },
        "security": [
          {
            "WebhookSecret": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "description": "The administrator-provided Agent ID, not its display name.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "x-max-body-bytes": 1048576,
        "requestBody": {
          "required": true,
          "description": "The complete JSON body must be at most 1 MiB. Only event and payload are accepted at the top level.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookRequest"
              },
              "example": {
                "event": "demo.ping",
                "payload": {
                  "message": "Test event: please confirm receipt."
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The event was accepted; background execution may subsequently fail.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookAccepted"
                },
                "example": {
                  "accepted": true,
                  "agentId": "your-agent-id",
                  "event": "demo.ping"
                }
              }
            }
          },
          "400": {
            "description": "Request Schema, unknown event, or JSON parsing error.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/WebhookInvalidBody"
                    },
                    {
                      "$ref": "#/components/schemas/WebhookUnknownEvent"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "The configured dedicated Webhook secret was not supplied correctly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "The target Agent has no required external secret, or the browser Origin is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/WebhookSecretRequired"
                    },
                    {
                      "$ref": "#/components/schemas/OriginRejection"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "The Agent does not exist or its Webhook is disabled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookNotFound"
                }
              }
            }
          },
          "413": {
            "description": "The JSON request body exceeds 1 MiB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FrameworkError"
                }
              }
            }
          },
          "415": {
            "description": "The request Content-Type is unsupported.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FrameworkError"
                }
              }
            }
          },
          "500": {
            "description": "The Agent configuration cannot be parsed or another server failure occurred.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/WebhookConfigurationError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/agents": {
      "get": {
        "operationId": "listAgents",
        "tags": [
          "Read-only"
        ],
        "summary": "List Agent summaries",
        "description": "Read-only instance-owner access. Returns summaries visible to the current trusted user.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/conversations-and-runs#list-agents"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Agent summary list.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentList"
                },
                "example": {
                  "agents": [
                    {
                      "id": "your-agent-id",
                      "name": "Example Agent",
                      "skillsCount": 0,
                      "toolsCount": 0,
                      "heartbeatEnabled": false,
                      "hasGit": false,
                      "isCoreAgent": false,
                      "status": "idle"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "A browser Origin is not allowed by this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginRejection"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected server failure occurred.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationsError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/runs": {
      "get": {
        "operationId": "listRuns",
        "tags": [
          "Read-only"
        ],
        "summary": "List Run metadata",
        "description": "Owner access to instance-level Run metadata. Filters combine with AND before limit is applied. This endpoint has no offset or total field and does not promise per-user isolation.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/conversations-and-runs#list-runs"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991,
              "default": 50
            },
            "description": "Single positive decimal safe integer. Repeated, empty, fractional and mixed values are rejected."
          },
          {
            "name": "agent_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional exact filter; combined with the other supplied filters using AND."
          },
          {
            "name": "delegated_by",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional exact filter; combined with the other supplied filters using AND."
          },
          {
            "name": "parent_run_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional exact filter; combined with the other supplied filters using AND."
          }
        ],
        "responses": {
          "200": {
            "description": "Run metadata list; no total or offset wrapper.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunList"
                },
                "example": {
                  "runs": [
                    {
                      "run_id": "00000000-0000-4000-8000-000000000001",
                      "user_id": "example-owner",
                      "agent_id": "your-agent-id",
                      "started_at": "2026-10-14T01:00:00.000Z",
                      "status": "idle"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The limit query value is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsError"
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "A browser Origin is not allowed by this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginRejection"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected server failure occurred.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationsError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/runs/{id}": {
      "get": {
        "operationId": "getRun",
        "tags": [
          "Read-only"
        ],
        "summary": "Read Run metadata",
        "description": "Returns the RunMeta object directly. This owner endpoint reads instance-level metadata and does not promise per-user isolation.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/conversations-and-runs#get-run"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Run ID."
          }
        ],
        "responses": {
          "200": {
            "description": "Run metadata without an enclosing run field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunMeta"
                },
                "example": {
                  "run_id": "00000000-0000-4000-8000-000000000001",
                  "user_id": "example-owner",
                  "agent_id": "your-agent-id",
                  "started_at": "2026-10-14T01:00:00.000Z",
                  "status": "idle"
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "A browser Origin is not allowed by this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginRejection"
                }
              }
            }
          },
          "404": {
            "description": "The Run was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsError"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected server failure occurred.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationsError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/runs/{id}/runtime-state": {
      "get": {
        "operationId": "getRunRuntimeState",
        "tags": [
          "Read-only"
        ],
        "summary": "Read the current raw Run state",
        "description": "Preserves running, idle, completed and failed states. idle does not prove success of a particular submitted turn. A snapshot cannot replace authoritative checks performed by a mutating operation.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/conversations-and-runs#get-run-runtime-state"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "description": "Run ID."
          }
        ],
        "responses": {
          "200": {
            "description": "Raw Run identity and status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunRuntimeState"
                },
                "example": {
                  "run_id": "00000000-0000-4000-8000-000000000001",
                  "agent_id": "your-agent-id",
                  "status": "idle"
                }
              }
            }
          },
          "400": {
            "description": "The Run ID is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsError"
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "A browser Origin is not allowed by this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginRejection"
                }
              }
            }
          },
          "404": {
            "description": "No readable supported runtime state. A handed_off Run currently also returns 404; this does not establish absence, failure, or completion.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsError"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected server failure occurred.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationsError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/runs/{id}/receipt": {
      "get": {
        "operationId": "listRunReceipts",
        "tags": [
          "Read-only"
        ],
        "summary": "Read receipts belonging to the trusted user",
        "description": "The service checks trusted user ownership; a missing or foreign Run returns 404. Without offset and limit, returns all valid receipts in stored order. Supplying either parameter enables pagination from the newest receipts; effective limit is capped at 100 and offset at 10000.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/conversations-and-runs#list-run-receipts"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "description": "Run ID."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991,
              "default": 20
            },
            "description": "Single positive safe integer. In paginated mode the effective value is capped at 100; omission defaults to 20 only when offset or limit enables pagination."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991,
              "default": 0
            },
            "description": "Single non-negative safe integer; enables pagination and skips receipts backward from the newest. Effective value is capped at 10000."
          }
        ],
        "responses": {
          "200": {
            "description": "Run receipts; pagination fields appear when pagination is requested.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunReceipts"
                },
                "example": {
                  "run_id": "00000000-0000-4000-8000-000000000001",
                  "receipts": [
                    {
                      "receipt_id": "example-receipt-id",
                      "run_id": "00000000-0000-4000-8000-000000000001",
                      "goal": "Reply to the test message",
                      "input": "Please say hello.",
                      "output": "Hello.",
                      "tool_calls": [],
                      "outcome": {
                        "status": "success",
                        "auto_completed": true
                      },
                      "started_at": "2026-10-14T01:00:00.000Z",
                      "completed_at": "2026-10-14T01:00:01.000Z"
                    }
                  ],
                  "total": 1,
                  "offset": 0,
                  "limit": 20,
                  "has_more": false,
                  "skipped": 0
                }
              }
            }
          },
          "400": {
            "description": "The Run ID or pagination parameter is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsError"
                }
              }
            }
          },
          "401": {
            "description": "Authentication failed or no trusted user identity could be resolved.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationsError"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceAuthenticationError"
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "A browser Origin is not allowed by this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginRejection"
                }
              }
            }
          },
          "404": {
            "description": "The Run is missing or belongs to another trusted user.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsError"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected server failure occurred.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationsError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/query/start": {
      "post": {
        "operationId": "startAgentQuery",
        "tags": [
          "Conversations"
        ],
        "summary": "Submit a new query",
        "description": "Connect Socket.IO and subscribe to events first. Use its current socket.id as originSocketId; stable clientInstanceId belongs to Socket auth. HTTP 202 may precede durable commit and query:started.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/conversations-and-runs"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueryStartRequest"
              },
              "example": {
                "prompt": "Please reply with a short greeting.",
                "options": {
                  "agentId": "your-agent-id",
                  "conversationId": "integration-demo"
                },
                "clientRequestId": "demo-start-1",
                "userMessageId": "demo-message-1",
                "originSocketId": "replace-with-current-socket-id"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Transport/admission acknowledgement, not proof of durable commit, execution start or completion.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryAdmission"
                },
                "example": {
                  "ok": true,
                  "clientRequestId": "demo-start-1"
                }
              }
            }
          },
          "400": {
            "description": "Body validation, missing current origin socket, or query admission failed.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/QueryAdmission"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "HTTP/socket principal mismatch, UI-context rejection, or an unapproved Origin.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/QueryAdmission"
                    },
                    {
                      "$ref": "#/components/schemas/OriginRejection"
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conversation clear is in progress, or the request ID was reused with a different request digest. Follow retryable/busy/code rather than retrying all conflicts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryAdmission"
                }
              }
            }
          },
          "503": {
            "description": "The socket or handler is unavailable, request admission is still reserved/unknown, or the service is starting.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/QueryAdmission"
                    },
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/query/follow-up": {
      "post": {
        "operationId": "followUpAgentQuery",
        "tags": [
          "Conversations"
        ],
        "summary": "Submit a follow-up turn",
        "description": "Use the live sessionId from query:started and the current connected socket.id. Listen for query:followUpAccepted, query:message and the terminal event. Keep the same clientRequestId and frozen business body for eligible transport retries.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/conversations-and-runs"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueryFollowUpRequest"
              },
              "example": {
                "sessionId": "replace-with-query-started-session-id",
                "originSocketId": "replace-with-current-socket-id",
                "clientRequestId": "demo-follow-up-1",
                "message": {
                  "id": "demo-message-2",
                  "role": "user",
                  "content": "Please continue briefly."
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Transport/admission acknowledgement, not proof of durable commit, execution start or completion.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryAdmission"
                },
                "example": {
                  "ok": true,
                  "sessionId": "replace-with-query-started-session-id",
                  "clientRequestId": "demo-follow-up-1"
                }
              }
            }
          },
          "400": {
            "description": "Body validation, missing current origin socket, or query admission failed.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/QueryAdmission"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "HTTP/socket principal mismatch, UI-context rejection, or an unapproved Origin.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/QueryAdmission"
                    },
                    {
                      "$ref": "#/components/schemas/OriginRejection"
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conversation clear is in progress, or the request ID was reused with a different request digest. Follow retryable/busy/code rather than retrying all conflicts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryAdmission"
                }
              }
            }
          },
          "503": {
            "description": "The socket or handler is unavailable, request admission is still reserved/unknown, or the service is starting.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/QueryAdmission"
                    },
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/query/client-requests/lookup": {
      "post": {
        "operationId": "lookupQueryAdmissions",
        "tags": [
          "Conversations"
        ],
        "summary": "Reconcile query admission by stable request IDs",
        "description": "Read-only admission lookup scoped to the trusted user and Agent. committed is a durable submission, not completion; reserved is an in-process reservation; absent is an observation and does not justify resending with a new ID; unknown requires reconciliation. Retention windows are returned by the service.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/conversations-and-runs"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientRequestLookupRequest"
              },
              "example": {
                "agentId": "your-agent-id",
                "conversationId": "integration-demo",
                "requests": [
                  {
                    "clientRequestId": "demo-start-1",
                    "userMessageId": "demo-message-1"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Read-only admission and execution-witness observations.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientRequestLookupResponse"
                },
                "example": {
                  "protocolVersion": 1,
                  "serverInstanceId": "example-process-generation",
                  "observedAt": "2026-10-14T08:00:00.000Z",
                  "autoReplayRetentionMs": 86400000,
                  "tombstoneRetentionMs": 604800000,
                  "results": [
                    {
                      "clientRequestId": "demo-start-1",
                      "status": "committed",
                      "committedAt": "2026-10-14T07:59:59.000Z",
                      "sessionId": "example-session-id",
                      "committedServerInstance": "current",
                      "executionWitness": "user-message"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The lookup request does not match the Schema.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsError"
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "A browser Origin is not allowed by this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginRejection"
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/agents/{id}/webhooks": {
      "get": {
        "operationId": "getAgentWebhookConfiguration",
        "tags": [
          "Webhook management"
        ],
        "summary": "Read Webhook configuration and available Tools",
        "description": "Requires capabilities.webhookManagement === true from the authenticated handshake and the existing instance-owner credential. Lists event settings and Tool IDs the owner can select. Does not disclose the current secret value.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/agent-webhook"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID from the instance, not its display name."
          }
        ],
        "responses": {
          "200": {
            "description": "Read Webhook configuration and available Tools",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookManagement"
                },
                "example": {
                  "enabled": false,
                  "hasSecret": false,
                  "events": [],
                  "availableTools": []
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store, private"
                }
              }
            }
          },
          "400": {
            "description": "Invalid Agent/event ID, malformed management body, unavailable Tool ID, or no configured event/secret when enabling. Stable reason appears in error; no separate code field is required.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "An instance-owner management credential is required, or the Origin is not allowed. A trigger secret cannot manage this configuration.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/OriginRejection"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "The Agent or event was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManagementError"
                }
              }
            }
          },
          "409": {
            "description": "Existing Webhook configuration is invalid; repair it before modifying events.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManagementError"
                }
              }
            }
          },
          "500": {
            "description": "The configuration could not be read or saved.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "setAgentWebhookEnabled",
        "tags": [
          "Webhook management"
        ],
        "summary": "Enable or pause existing Webhook events",
        "description": "Requires capabilities.webhookManagement === true from the authenticated handshake and the existing instance-owner credential. Enabling requires configured events and a dedicated secret. Pausing stops new trigger admission; it does not cancel work already accepted.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/agent-webhook"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID from the instance, not its display name."
          }
        ],
        "responses": {
          "200": {
            "description": "Enable or pause existing Webhook events",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEnabledResponse"
                },
                "example": {
                  "success": true,
                  "enabled": false
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store, private"
                }
              }
            }
          },
          "400": {
            "description": "Invalid Agent/event ID, malformed management body, unavailable Tool ID, or no configured event/secret when enabling. Stable reason appears in error; no separate code field is required.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "An instance-owner management credential is required, or the Origin is not allowed. A trigger secret cannot manage this configuration.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/OriginRejection"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "The Agent or event was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManagementError"
                }
              }
            }
          },
          "409": {
            "description": "Existing Webhook configuration is invalid; repair it before modifying events.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManagementError"
                }
              }
            }
          },
          "500": {
            "description": "The configuration could not be read or saved.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEnabledRequest"
              },
              "example": {
                "enabled": false
              }
            }
          }
        }
      }
    },
    "/api/agents/{id}/webhooks/events/{event}": {
      "put": {
        "operationId": "upsertAgentWebhookEvent",
        "tags": [
          "Webhook management"
        ],
        "summary": "Create or replace an event using selected available Tool IDs",
        "description": "Requires capabilities.webhookManagement === true from the authenticated handshake and the existing instance-owner credential. The service captures current Tool and file access limits. The caller cannot submit a permission snapshot. Saving enables Webhook and returns secret only when it was first generated; preserve it securely. An existing event is replaced.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/agent-webhook"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID from the instance, not its display name."
          },
          {
            "name": "event",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$",
              "not": {
                "enum": [
                  "constructor",
                  "prototype",
                  "__proto__"
                ]
              }
            },
            "description": "Case-sensitive event name; reserved prototype names are rejected."
          }
        ],
        "responses": {
          "200": {
            "description": "Create or replace an event using selected available Tool IDs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEventWritten"
                },
                "example": {
                  "success": true,
                  "enabled": true,
                  "event": "demo.ping",
                  "secret": "example-secret-placeholder-do-not-use-12345"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store, private"
                }
              }
            }
          },
          "400": {
            "description": "Invalid Agent/event ID, malformed management body, unavailable Tool ID, or no configured event/secret when enabling. Stable reason appears in error; no separate code field is required.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "An instance-owner management credential is required, or the Origin is not allowed. A trigger secret cannot manage this configuration.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/OriginRejection"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "The Agent or event was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManagementError"
                }
              }
            }
          },
          "409": {
            "description": "Agent configuration changed while preparing the permission snapshot (webhook_configuration_changed), or existing configuration is malformed (webhook_configuration_invalid). Reload configuration and available tools, review permissions, then retry; repair malformed configuration first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManagementError"
                }
              }
            }
          },
          "413": {
            "description": "The management body exceeds 128 KiB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FrameworkError"
                }
              }
            }
          },
          "415": {
            "description": "Use Content-Type: application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FrameworkError"
                }
              }
            }
          },
          "500": {
            "description": "The configuration could not be read or saved.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "x-max-body-bytes": 131072,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEventWrite"
              },
              "example": {
                "promptTemplate": "Confirm receipt of {{message}} without using any tools.",
                "toolIds": [],
                "maxTurns": 5
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteAgentWebhookEvent",
        "tags": [
          "Webhook management"
        ],
        "summary": "Delete one configured event",
        "description": "Requires capabilities.webhookManagement === true from the authenticated handshake and the existing instance-owner credential. Removes an existing event key, including historical keys outside the new-event naming rule. URL-encode the key. Removing the final event also disables Webhook. The response reports whether Webhook remains enabled.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/agent-webhook"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID from the instance, not its display name."
          },
          {
            "name": "event",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Existing event key, URL-encoded. Historical keys can be deleted even if they do not satisfy the new-event naming rule."
          }
        ],
        "responses": {
          "200": {
            "description": "Delete one configured event",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEnabledResponse"
                },
                "example": {
                  "success": true,
                  "enabled": false
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store, private"
                }
              }
            }
          },
          "400": {
            "description": "Invalid Agent/event ID, malformed management body, unavailable Tool ID, or no configured event/secret when enabling. Stable reason appears in error; no separate code field is required.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "An instance-owner management credential is required, or the Origin is not allowed. A trigger secret cannot manage this configuration.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/OriginRejection"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "The Agent or event was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManagementError"
                }
              }
            }
          },
          "409": {
            "description": "Existing Webhook configuration is invalid; repair it before modifying events.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManagementError"
                }
              }
            }
          },
          "500": {
            "description": "The configuration could not be read or saved.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/agents/{id}/webhooks/secret/rotate": {
      "post": {
        "operationId": "rotateAgentWebhookSecret",
        "tags": [
          "Webhook management"
        ],
        "summary": "Rotate the Agent dedicated Webhook secret",
        "description": "Requires capabilities.webhookManagement === true from the authenticated handshake and the existing instance-owner credential. Send no request body. The new secret applies to all events for this Agent. Save the returned value and update external senders; ordinary configuration reads cannot recover it.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/agent-webhook"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID from the instance, not its display name."
          }
        ],
        "responses": {
          "200": {
            "description": "Rotate the Agent dedicated Webhook secret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSecretRotation"
                },
                "example": {
                  "secret": "example-secret-placeholder-do-not-use-12345"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store, private"
                }
              }
            }
          },
          "400": {
            "description": "Invalid Agent/event ID, malformed management body, unavailable Tool ID, or no configured event/secret when enabling. Stable reason appears in error; no separate code field is required.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "An instance-owner management credential is required, or the Origin is not allowed. A trigger secret cannot manage this configuration.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/OriginRejection"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "The Agent or event was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManagementError"
                }
              }
            }
          },
          "409": {
            "description": "Existing Webhook configuration is invalid; repair it before modifying events.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManagementError"
                }
              }
            }
          },
          "500": {
            "description": "The configuration could not be read or saved.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ManagementError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/agents/{agentId}/schedule-messages": {
      "get": {
        "operationId": "listAgentScheduleMessages",
        "tags": [
          "Read-only"
        ],
        "summary": "Read visible persisted background messages",
        "description": "Returns only messages visible to the trusted user, filtering recipient and source ACL before pagination. Webhook delivery rows contain explicit SendUserMessage output, not every final model response or a per-request terminal result. Items are sorted newest first; limit defaults to 50 and is capped at 200.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/agent-webhook"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]+$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991,
              "default": 50
            },
            "description": "Positive safe integer; effective page size is capped at 200."
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Visible background messages and effective pagination.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduleMessagePage"
                },
                "example": {
                  "items": [],
                  "total": 0,
                  "limit": 50,
                  "offset": 0
                }
              }
            }
          },
          "400": {
            "description": "Pagination or source authorization failed; use the returned error message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsError"
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "Pagination or source authorization failed; use the returned error message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsError"
                }
              }
            }
          },
          "500": {
            "description": "Pagination or source authorization failed; use the returned error message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsError"
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/attachments": {
      "post": {
        "operationId": "uploadAttachment",
        "tags": [
          "Attachments and media"
        ],
        "summary": "Upload a general attachment",
        "description": "One non-empty multipart file, at most 20 MiB. Stores bytes without extraction or execution. Per-user retained-directory limit 256, total retained data limit 512 MiB. Each successful POST creates a new attachment; no automatic retry/idempotency contract. The receipt fileReference is passed unchanged in Query options.fileReferences on this instance and does not grant tool or cross-user permission.",
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "One general file, 1–20,971,520 bytes. MIME is descriptive, not restricted to the media MIME list."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Complete persisted attachment receipt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentReceipt"
                },
                "example": {
                  "attachmentId": "00000000-0000-4000-8000-000000000001",
                  "name": "report.txt",
                  "mimeType": "text/plain",
                  "size": 18,
                  "sha256": "0932d7133fdafd99d58020fca2539266aa11731a72f741067b1009c4c8c66553",
                  "fileReference": "/srv/desirecore/attachments/owner/00000000-0000-4000-8000-000000000001/data"
                }
              }
            }
          },
          "400": {
            "description": "attachment_file_required or attachment_empty; malformed multipart may use framework errors.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or unresolved user identity.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "403": {
            "description": "Configured Origin/application authority or resource ownership rejects the request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "413": {
            "description": "attachment_too_large or multipart parser size rejection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "429": {
            "description": "attachment_limit or attachment_storage_limit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "503": {
            "description": "attachment_storage_unavailable, service not ready, or instance credential unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          }
        }
      }
    },
    "/api/attachments/{attachmentId}": {
      "get": {
        "operationId": "downloadAttachment",
        "tags": [
          "Attachments and media"
        ],
        "summary": "Download an attachment owned by the authenticated user",
        "description": "Returns original bytes as an attachment, not JSON. The user is resolved from instance authentication. IDs do not confer cross-user permission. This route has no media byte-Range contract.",
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "attachmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Original file bytes with no-store and nosniff.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "Attachment download filename."
              },
              "Content-Length": {
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "no-store"
              },
              "X-Content-Type-Options": {
                "schema": {
                  "type": "string",
                  "const": "nosniff"
                }
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or unresolved user identity.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "403": {
            "description": "Configured Origin/application authority or resource ownership rejects the request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "404": {
            "description": "attachment_not_found for invalid, absent, other-user, or unreadable files/metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "503": {
            "description": "Service not ready, credential not initialized, or endpoint-specific service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          }
        }
      }
    },
    "/api/media/upload": {
      "post": {
        "operationId": "uploadMedia",
        "tags": [
          "Attachments and media"
        ],
        "summary": "Upload an image, audio, or video",
        "description": "Single multipart file with an allowed MIME. Service multipart limit is 2 GiB; deployment/proxy limits may be smaller. Empty files are rejected. New files retain authenticated owner metadata. Metadata may be passed in top-level Query mediaRefs; model support is a separate condition.",
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "Non-empty media, at most 2,147,483,648 bytes at the service multipart layer. Allowed MIME: image/jpeg, image/png, image/gif, image/webp, audio/mpeg, audio/mp3, audio/opus, audio/aac, audio/flac, audio/wav, audio/ogg, video/mp4, video/webm."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Direct media metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MediaMetadata"
                },
                "example": {
                  "type": "image",
                  "mediaId": "00000000-0000-4000-8000-000000000004.png",
                  "name": "diagram.png",
                  "mimeType": "image/png",
                  "size": 68,
                  "width": 1,
                  "height": 1
                }
              }
            }
          },
          "400": {
            "description": "No file uploaded or empty content.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or unresolved user identity.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "403": {
            "description": "Configured Origin/application authority or resource ownership rejects the request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "413": {
            "description": "Multipart size rejection. Parser errors may differ from the route error shape.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "415": {
            "description": "Unsupported MIME type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "500": {
            "description": "media_internal_error; includes unexpected upload/parser failures caught by the route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "503": {
            "description": "Service not ready, credential not initialized, or endpoint-specific service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          }
        }
      }
    },
    "/api/media/access-urls": {
      "post": {
        "operationId": "createMediaAccessUrls",
        "tags": [
          "Attachments and media"
        ],
        "summary": "Issue short-lived media read URLs",
        "description": "Normal instance authentication is required to mint five-minute links. Validates new-media ownership and actual media content. Legacy media without owner metadata retains read compatibility. Existing objects forbidden to the user reject the request. The signing service requires an initialized instance token.",
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MediaAccessUrlsRequest"
              },
              "example": {
                "mediaIds": [
                  "00000000-0000-4000-8000-000000000004.png"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Links and missing IDs; no universal success/data wrapper.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MediaAccessUrlsResponse"
                },
                "example": {
                  "items": [
                    {
                      "mediaId": "00000000-0000-4000-8000-000000000004.png",
                      "url": "/media/00000000-0000-4000-8000-000000000004.png?expires=1792112700&signature=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
                      "expiresAt": "2026-10-16T01:05:00.000Z"
                    }
                  ],
                  "missing": []
                }
              }
            }
          },
          "400": {
            "description": "Schema validation, invalid_media_id, or invalid_media_ref.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or unresolved user identity.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "403": {
            "description": "media_owner_forbidden or configured Origin/application authority rejection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected media service failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "503": {
            "description": "media_signing_unavailable or common service readiness/credential rejection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          }
        }
      }
    },
    "/media/{filename}": {
      "get": {
        "operationId": "getSignedMedia",
        "tags": [
          "Attachments and media"
        ],
        "summary": "Read media using its issued signed URL",
        "description": "Only GET/HEAD on the single-segment /media/:filename path bypass normal instance-token authentication, after the application authority fence. The handler requires the signed expires/signature pair; /api/media/*, other methods, and multi-segment paths do not inherit this exemption. Configured Origin policy and service readiness still apply. Anyone holding a valid complete link can read until expiry; owner is checked at issuance, not re-resolved from the unsigned reader. Supports one byte range, open-ended/suffix ranges, and private caching bounded by remaining TTL. The implementation also supplies HEAD with the same validation and no body; HEAD is not selected as another public catalog operation.",
        "security": [
          {
            "SignedMediaSignature": []
          }
        ],
        "parameters": [
          {
            "name": "filename",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9-]+\\.\\w+$",
              "description": "Service-issued media filename. Values containing two consecutive dots are rejected."
            }
          },
          {
            "name": "expires",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,12}$"
            },
            "description": "Positive Unix epoch seconds from the issued URL. Bound to signature; must be in the future."
          },
          {
            "name": "Range",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "One bytes range, e.g. bytes=0-1023, bytes=1024-, or bytes=-1024; no multipart ranges."
          }
        ],
        "responses": {
          "200": {
            "description": "Full media bytes.",
            "headers": {
              "Accept-Ranges": {
                "schema": {
                  "type": "string",
                  "const": "bytes"
                }
              },
              "Content-Length": {
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "private, max-age=<remaining signature lifetime in seconds>"
              },
              "X-Content-Type-Options": {
                "schema": {
                  "type": "string",
                  "const": "nosniff"
                }
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/gif": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/webp": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/opus": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/aac": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/flac": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/wav": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/ogg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "video/mp4": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "video/webm": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "206": {
            "description": "Requested single media range.",
            "headers": {
              "Accept-Ranges": {
                "schema": {
                  "type": "string",
                  "const": "bytes"
                }
              },
              "Content-Length": {
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "private, max-age=<remaining signature lifetime in seconds>"
              },
              "X-Content-Type-Options": {
                "schema": {
                  "type": "string",
                  "const": "nosniff"
                }
              },
              "Content-Range": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/gif": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/webp": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/opus": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/aac": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/flac": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/wav": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "audio/ogg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "video/mp4": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "video/webm": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "invalid_media_id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "401": {
            "description": "invalid_media_signature or media_signature_expired. This is signed URL authentication, not an InstanceToken requirement.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "403": {
            "description": "Configured Origin policy or application authority rejects the request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "404": {
            "description": "media_not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "416": {
            "description": "range_not_satisfiable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            },
            "headers": {
              "Content-Range": {
                "schema": {
                  "type": "string"
                },
                "description": "bytes */<complete file length>"
              }
            }
          },
          "500": {
            "description": "media_internal_error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          },
          "503": {
            "description": "media_signing_unavailable or service not ready.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentMediaError"
                }
              }
            }
          }
        }
      }
    },
    "/api/sessions": {
      "get": {
        "operationId": "listSessionHistory",
        "tags": [
          "Session history"
        ],
        "summary": "List the owner user's session-history branches",
        "description": "Lists ordinary user-visible history by updatedAt descending. Excludes delegated, manual and dedicated schedule/Webhook/Mention timelines. Preserves fork generations; do not concatenate branches as a deduplicated transcript. Pagination is not an immutable snapshot.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/session-history-and-messages#list-sessions"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "agentId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional exact Agent filter."
          },
          {
            "name": "includeArchived",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Only the wire string true includes archived sessions."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 20
            },
            "description": "Send a positive decimal integer. No fixed maximum is declared by this route."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 0
            },
            "description": "Source/page offset. Send a nonnegative decimal integer; the route uses compatibility integer parsing."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful public read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistorySessionPage"
                },
                "example": {
                  "sessions": [
                    {
                      "runId": "run-example",
                      "agentId": "your-agent-id",
                      "status": "idle",
                      "messageCount": 1,
                      "createdAt": "2026-10-15T08:00:00Z",
                      "updatedAt": "2026-10-15T08:00:00Z",
                      "preview": "Please review the release notes"
                    }
                  ],
                  "total": 1,
                  "hasMore": false
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid instance credential, or unavailable user profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or endpoint-specific access restriction.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or its instance credential is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/sessions/{runId}": {
      "get": {
        "operationId": "getSessionSnapshot",
        "tags": [
          "Session history"
        ],
        "summary": "Read an owned ordinary session snapshot",
        "description": "Checks trusted user ownership before body/image reads. Missing, cleared and unowned Runs return 404. Delegated Runs return 403 delegated_run_requires_inspect_view; use the messages inspection view instead. pendingAssistant is temporary and separate from durable messages. Returned configuration is not execution authority. Returns a display projection: sensitive tool results may be withheld and their body references removed. Do not infer success, reconstruct private protocol or automatically rerun work from placeholder text.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/session-history-and-messages#get-session"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "runId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "description": "Actual owned Run ID, not a runtime session ID."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful public read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistorySessionSnapshot"
                },
                "example": {
                  "runId": "run-example",
                  "agentId": "your-agent-id",
                  "userId": "your-instance-user-id",
                  "engine": "desirecore-engine",
                  "messages": [
                    {
                      "id": "d8d53a7a-478e-4d96-970e-657dece814f7",
                      "role": "user",
                      "content": "Please review the release notes",
                      "timestamp": 1792051200000
                    }
                  ],
                  "options": {},
                  "status": "idle",
                  "createdAt": "2026-10-15T08:00:00Z",
                  "updatedAt": "2026-10-15T08:00:00Z"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "private, no-store"
                },
                "description": "Private history read."
              }
            }
          },
          "401": {
            "description": "Missing or invalid instance credential, or unavailable user profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or endpoint-specific access restriction.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or its instance credential is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid Run ID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "404": {
            "description": "Session unavailable or not owned by the trusted user.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          }
        }
      }
    },
    "/api/sessions/{runId}/messages": {
      "get": {
        "operationId": "listSessionMessages",
        "tags": [
          "Session history"
        ],
        "summary": "Read a source-record window from an owned Run",
        "description": "Checks ownership before content reads. Delegated Runs require view=inspect-run. total counts source rows, not returned messages; advance offset by the requested limit and stop at total, even if a page is empty. Optional live is a temporary delegated display checkpoint, not a durable message or terminal. There is no cross-page consistency revision. Returns a display projection: sensitive tool results may be withheld and their body references removed. Do not infer success, reconstruct private protocol or automatically rerun work from placeholder text.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/session-history-and-messages#session-messages"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "runId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "description": "Actual owned Run ID, not a runtime session ID."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 0
            },
            "description": "Source/page offset. Send a nonnegative decimal integer; the route uses compatibility integer parsing."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 100
            },
            "description": "Requested source-record window. Advance by this limit even if the returned array is shorter or empty."
          },
          {
            "name": "view",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "inspect-run"
              ]
            },
            "description": "Explicit delegated inspection view; does not bypass ownership."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful public read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryMessagePage"
                },
                "examples": {
                  "durablePage": {
                    "value": {
                      "messages": [
                        {
                          "id": "d8d53a7a-478e-4d96-970e-657dece814f7",
                          "role": "user",
                          "content": "Please review the release notes",
                          "timestamp": 1792051200000,
                          "lineIndex": 0,
                          "offset": 0
                        }
                      ],
                      "total": 1
                    }
                  },
                  "delegatedInspectView": {
                    "summary": "Optional live snapshot; request view=inspect-run.",
                    "value": {
                      "messages": [],
                      "total": 0,
                      "live": {
                        "turnId": "turn-example",
                        "text": "Working on the delegated task",
                        "toolCalls": [],
                        "timestamp": 1792051200000
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "private, no-store"
                },
                "description": "Private history read."
              }
            }
          },
          "401": {
            "description": "Missing or invalid instance credential, or unavailable user profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or endpoint-specific access restriction.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or its instance credential is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid Run ID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "404": {
            "description": "Session unavailable or not owned by the trusted user.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          }
        }
      }
    },
    "/api/sessions/messages/search": {
      "get": {
        "operationId": "searchSessionMessages",
        "tags": [
          "Session history"
        ],
        "summary": "Search visible messages for one Agent",
        "description": "Matches extracted message text case-insensitively, newest timestamp first. Includes independent manual conversations; excludes archived and delegated Runs. Default-conversation fork families select the visible history window. preferredRunId is neither a credential nor an exact-Run filter. limit/offset and their sum must be safe nonnegative integers. limit=0 returns all remaining hits and hasMore=false. Match original text before cropping previews.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/session-history-and-messages#search-messages"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "agentId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "Required Agent ID."
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional case-insensitive substring; omitted means no text filter."
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "image",
                "file",
                "tool"
              ],
              "default": "all"
            },
            "description": "Other wire values fall back to all."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991,
              "default": 50
            },
            "description": "0 returns every remaining hit from offset; prefer bounded pages."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991,
              "default": 0
            },
            "description": "Hit offset, not a returned message's byte position."
          },
          {
            "name": "preferredRunId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional default-conversation history window; independent manual conversations remain included."
          },
          {
            "name": "previewChars",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 8000
            },
            "description": "Optional preview budget; matching happens before cropping."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful public read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistorySearchPage"
                },
                "example": {
                  "items": [
                    {
                      "runId": "run-example",
                      "messageIndex": 0,
                      "offset": 0,
                      "messageId": "d8d53a7a-478e-4d96-970e-657dece814f7",
                      "role": "user",
                      "text": "Please review the release notes",
                      "timestamp": 1792051200000,
                      "hasImages": false,
                      "hasFiles": false,
                      "hasToolUse": false
                    }
                  ],
                  "total": 1,
                  "hasMore": false
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid instance credential, or unavailable user profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or endpoint-specific access restriction.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or its instance credential is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "agentId is required or history page parameters are invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          }
        }
      }
    },
    "/api/conversation/{agentId}/overview": {
      "get": {
        "operationId": "getConversationOverview",
        "tags": [
          "Session history"
        ],
        "summary": "Read the instance owner's conversation-matter overview",
        "description": "Reads the instance's current local profile, not a caller-supplied tenant ID. Intended for the deployment owner. Returns all active matters and at most ten recent entries, not a complete transcript. No pagination. An empty overview does not establish Agent existence or absence of history.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/session-history-and-messages#conversation-overview"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID belonging to the instance owner."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful public read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationMatterOverview"
                },
                "example": {
                  "agentId": "your-agent-id",
                  "activeMatters": [
                    {
                      "id": "mat_example",
                      "title": "Release review",
                      "type": "task"
                    }
                  ],
                  "recentMatters": [],
                  "totalMatters": 1,
                  "totalArchived": 0
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid instance credential, or unavailable user profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or endpoint-specific access restriction.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or its instance credential is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/conversation/{agentId}/matters/{id}/full": {
      "get": {
        "operationId": "getConversationMatterMessages",
        "tags": [
          "Session history"
        ],
        "summary": "Read bounded public source entries for one matter",
        "description": "Reads the instance owner's local-profile conversation memory. Supports active, recent and archived source data. Underlying Run reads recheck that user and Agent ownership. Reads at most 120 source messages and sets truncated=true if more exist; projection may omit entries. No pagination or limit-override parameter. Entries are not guaranteed to have the per-Run message shape. Returns a display projection: sensitive tool results may be withheld and their body references removed. Do not infer success, reconstruct private protocol or automatically rerun work from placeholder text.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/session-history-and-messages#matter-messages"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID belonging to the instance owner."
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Actual matter ID returned by the overview."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful public read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationMatterMessages"
                },
                "example": {
                  "matterId": "mat_example",
                  "messages": [
                    {
                      "role": "user",
                      "content": "Please review the release notes",
                      "timestamp": 1792051200000
                    }
                  ],
                  "truncated": true
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid instance credential, or unavailable user profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or endpoint-specific access restriction.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or its instance credential is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Matter source messages unavailable, invalid or not owned by this user and Agent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          }
        }
      }
    },
    "/api/network/health": {
      "get": {
        "operationId": "getNetworkHealth",
        "tags": [
          "Observability"
        ],
        "summary": "Read the current upstream network observation",
        "description": "Instance-owner observation. No body or query parameters. unknown is not offline; state can be stale while idle or monitoring is disabled. online does not prove every provider or a particular query succeeded. Authenticated Socket.IO network:health uses the same payload. Install a listener before fetching a snapshot; compare seq only within the same monitor and establish a fresh baseline after reconnection or service restart. No event replay.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/observability#network-health"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Read the current upstream network observation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NetworkHealthState"
                },
                "example": {
                  "status": "unknown",
                  "reason": "init",
                  "since": "2026-10-25T00:00:00.000Z",
                  "seq": 0
                }
              }
            }
          },
          "401": {
            "description": "Authentication failed or no trusted user identity could be resolved.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationsError"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceAuthenticationError"
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "A browser Origin is not allowed by this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginRejection"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected server failure occurred.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationsError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/runs/recent-calls": {
      "get": {
        "operationId": "listRecentToolCalls",
        "tags": [
          "Observability"
        ],
        "summary": "Read recent tool-call metadata for the trusted user",
        "description": "Filters Runs by the trusted user before reading a bounded recent window. Does not return tool inputs or outputs, offset, cursor or total. Preserve opaque call IDs; use the separate runId for Run reads. Explicit tool status/time takes precedence; older receipts may fall back to receipt outcome/time. Missing duration is represented as zero, not a measured zero. A usable upgraded index and receipt fallback share field projection; without one only the latest 100 user Runs are scanned. This is neither complete audit export nor proof of a query terminal.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/observability#recent-tool-calls"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991,
              "default": 30
            },
            "description": "Single positive decimal safe integer; no additional route item cap. Empty, repeated, mixed-text, fractional or unsafe values return 400."
          }
        ],
        "responses": {
          "200": {
            "description": "Read recent tool-call metadata for the trusted user.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsRecentCallsResponse"
                },
                "example": {
                  "calls": [
                    {
                      "id": "example-tool-invocation",
                      "timestamp": "2026-10-25T00:00:01.000Z",
                      "agentId": "your-agent-id",
                      "runId": "run-example",
                      "toolName": "Read",
                      "status": "success",
                      "durationMs": 12
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is invalid or no trusted user identity could be resolved.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationsError"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceAuthenticationError"
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "A browser Origin is not allowed by this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginRejection"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected server failure occurred.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationsError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid limit; use a single positive decimal safe integer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsError"
                }
              }
            }
          }
        }
      }
    },
    "/api/runs/usage/summary": {
      "get": {
        "operationId": "getRunUsageSummary",
        "tags": [
          "Observability"
        ],
        "summary": "Read recorded usage aggregates for the trusted user",
        "description": "Returns total/byModel/byDate/byAgent without conversation bodies. since filters Run start time, not each receipt; invalid since is ignored. Filtered/fallback scans may cover only the latest 1000 owner Runs; cleared Runs may retain usage. Cached for about 30 seconds. queryCount counts receipt queries carrying usage, not all submissions. costUsd is recorded cost, not a final invoice. byDate maps existing UTC date buckets using UTC midday for timezone; it does not regroup individual events into exact local days. Invalid timezone retains UTC. A read can trigger background index rebuilding; it does not issue a model request.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/observability#usage-summary"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Recommended ISO timestamp with timezone; filters Run started_at. Invalid values are ignored rather than rejected."
          },
          {
            "name": "agentId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional associated Agent ID; does not select another user."
          },
          {
            "name": "timezone",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "IANA zone such as UTC. Maps UTC date buckets, not individual events; invalid values retain UTC dates."
          }
        ],
        "responses": {
          "200": {
            "description": "Read recorded usage aggregates for the trusted user.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsUsageSummaryResponse"
                },
                "example": {
                  "total": {
                    "inputTokens": 0,
                    "outputTokens": 0,
                    "cacheReadTokens": 0,
                    "cacheWriteTokens": 0,
                    "costUsd": 0,
                    "queryCount": 0
                  },
                  "byModel": [],
                  "byDate": [],
                  "byAgent": []
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is invalid or no trusted user identity could be resolved.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationsError"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceAuthenticationError"
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "A browser Origin is not allowed by this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginRejection"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected server failure occurred.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationsError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready; retry the read-only request after this many seconds."
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/agents/{id}/input-config": {
      "get": {
        "operationId": "getAgentInputConfig",
        "tags": [
          "Read-only"
        ],
        "summary": "Read lightweight Agent input configuration",
        "description": "Available in client v10.0.180+. Instance-owner read; no per-tenant isolation. Reads fresh configuration without creating a session. Verify version=1 and the returned Agent ID. A valid omitted manual mode defaults to false; failures must not be replaced with false. configRevision compares content equality only: it is not execution permission, a lock, a timestamp, or an event sequence.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/conversations-and-runs#agent-input-config"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "description": "Selected actual Agent ID."
          }
        ],
        "responses": {
          "200": {
            "description": "Fresh lightweight input configuration.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "no-store"
                },
                "description": "Do not cache this input configuration read."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentInputConfig"
                },
                "example": {
                  "version": 1,
                  "agentId": "your-agent-id",
                  "manual": true,
                  "configRevision": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                }
              }
            }
          },
          "400": {
            "description": "Invalid Agent ID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentInputConfigError"
                },
                "example": {
                  "code": "AGENT_INPUT_CONFIG_INVALID_ID",
                  "error": "Invalid agent ID"
                }
              }
            }
          },
          "401": {
            "description": "The instance credential is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "A browser Origin is not allowed by this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OriginRejection"
                }
              }
            }
          },
          "404": {
            "description": "Agent unavailable or missing. AGENT_NOT_FOUND is a business result; do not treat it as an older service lacking this route. A route-unavailable 404 is not this DTO.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentInputConfigError"
                },
                "example": {
                  "code": "AGENT_NOT_FOUND",
                  "error": "Agent not found"
                }
              }
            }
          },
          "409": {
            "description": "Configuration changed during the read; read again before updating the input UI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentInputConfigError"
                },
                "example": {
                  "code": "AGENT_INPUT_CONFIG_CHANGED",
                  "error": "Agent input config unavailable"
                }
              }
            }
          },
          "503": {
            "description": "Input configuration is invalid or unreadable, or the service is not ready. Preserve the error code; never substitute manual=false.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/AgentInputConfigError"
                    },
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/sessions/messages/all": {
      "get": {
        "operationId": "listMergedHistoryMessages",
        "tags": [
          "Session history"
        ],
        "summary": "Read a revision-checked merged public history page",
        "description": "Filters trusted user ownership before content reads and selects visible fork branches. Excludes archived, cleared, delegated, schedule/Webhook, and Mention execution timelines; visible Conversation-owned Mention sources may appear. Without conversationId, separate manual conversations join the default timeline only when manual mode is disabled; an explicit conversationId selects that lineage. preferredRunId selects a history window, not an exact-Run filter or permission. items wrap public messages. Synthetic __mention_source: IDs are display-only source references, not Run IDs for execution or recovery. Keep scope/order fixed and send the first historyRevision as expectedRevision on later pages. On 409, discard all pages of the attempt and reread from offset=0 without rerunning execution. The revision hashes the current complete public view; it is not a persistent cursor, transaction snapshot, incremental log, or backup. Each page may read and sort the entire visible history.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/session-history-and-messages#merged-history"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "agentId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "Required target Agent ID."
          },
          {
            "name": "conversationId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact conversation lineage within the Agent; does not grant cross-conversation access."
          },
          {
            "name": "preferredRunId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional visible branch window; not an exact-Run filter or access credential."
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            },
            "description": "Order by message timestamp. Other wire values fall back to desc."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000,
              "default": 100
            },
            "description": "0 returns empty items, total and revision with hasMore=false, not all results. Send canonical decimal integers; the route accepts compatibility integer-prefix parsing."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991,
              "default": 0
            },
            "description": "Position in the merged public view, not an item byte offset or source messageIndex. Send a canonical decimal integer."
          },
          {
            "name": "expectedRevision",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^h1:[0-9a-f]{64}$"
            },
            "description": "First page historyRevision, required by clients on later pages to detect a changed public view."
          }
        ],
        "responses": {
          "200": {
            "description": "Merged public history page, including an empty page when no owned visible history matches.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MergedHistoryPage"
                },
                "examples": {
                  "page": {
                    "value": {
                      "items": [
                        {
                          "runId": "run-example",
                          "messageIndex": 0,
                          "offset": 0,
                          "sessionTime": "2026-10-15T08:00:00Z",
                          "message": {
                            "id": "d8d53a7a-478e-4d96-970e-657dece814f7",
                            "role": "user",
                            "content": "Please review the release notes",
                            "timestamp": 1792051200000
                          }
                        }
                      ],
                      "total": 1,
                      "hasMore": false,
                      "historyRevision": "h1:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                    }
                  },
                  "sourceOnly": {
                    "summary": "A Conversation source reference, not an actual Run.",
                    "value": {
                      "items": [
                        {
                          "runId": "__mention_source:source-example",
                          "messageIndex": 0,
                          "sessionTime": "2026-10-15T08:00:00Z",
                          "message": {
                            "id": "source-example",
                            "role": "user",
                            "content": "Please review the release notes",
                            "timestamp": 1792051200000,
                            "mentionSourceOnly": true,
                            "mentionSource": {
                              "kind": "conversation_message",
                              "source_id": "source-example",
                              "source_revision": 1,
                              "conversation_id": "your-agent-id"
                            },
                            "mentionOccurrences": [],
                            "mentionRecipientAgentIds": [
                              "another-agent"
                            ],
                            "mentionDeliveryIds": []
                          }
                        }
                      ],
                      "total": 1,
                      "hasMore": false,
                      "historyRevision": "h1:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                    }
                  },
                  "metadataOnly": {
                    "summary": "limit=0 does not return messages.",
                    "value": {
                      "items": [],
                      "total": 42,
                      "hasMore": false,
                      "historyRevision": "h1:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing agentId or invalid merged page/revision parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                },
                "examples": {
                  "missingAgent": {
                    "value": {
                      "error": "agentId is required"
                    }
                  },
                  "invalidPage": {
                    "value": {
                      "error": "invalid_history_page"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid instance credential, or unavailable user profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or endpoint-specific access restriction.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                }
              }
            }
          },
          "409": {
            "description": "The complete public view changed. Discard the attempt and restart at offset=0 with no expectedRevision.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryError"
                },
                "example": {
                  "error": "history_revision_changed"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or its instance credential is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures. Preserve the HTTP status, Content-Type and response body; formats are not uniform.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/taskboards": {
      "get": {
        "operationId": "listTaskBoards",
        "tags": [
          "TaskBoard"
        ],
        "summary": "List visible TaskBoard summaries",
        "description": "No pagination. Can include archived boards; counts exclude archived/deleted tasks. Team and owner visibility is rechecked. Requires the authenticated deployment owner's global TaskBoard capability and current Board/Team access; HTTP acts as the authenticated human actor. No Task execution is started.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/taskboards"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized synchronous read result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardListResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, cursor, filter/sort combination or activity range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity. Authentication errors can use the common service error shape."
          },
          "403": {
            "description": "TaskBoard capability disabled or Board access denied. Arbitrary missing Board IDs can also return forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "500": {
            "description": "TaskBoard internal read failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "503": {
            "description": "Storage migration/readiness failure. General service readiness errors can use the common service error shape."
          }
        }
      }
    },
    "/api/taskboards/query": {
      "post": {
        "operationId": "queryTaskBoards",
        "tags": [
          "TaskBoard"
        ],
        "summary": "Query visible tasks across boards",
        "description": "Read-only POST. Default pageSize 50 (1..200), updatedAt desc, active boards/tasks. Opaque nextCursor must retain filters/sort. 409 versionConflict requires discarding old pages and restarting. Claim tokens are always omitted; current liveness can change without invalidating the cursor. Missing/invisible boardIds are silently omitted. Requires the authenticated deployment owner's global TaskBoard capability and current Board/Team access; HTTP acts as the authenticated human actor. No Task execution is started.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/taskboards"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized synchronous read result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardQueryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, cursor, filter/sort combination or activity range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity. Authentication errors can use the common service error shape."
          },
          "403": {
            "description": "TaskBoard capability disabled or Board access denied. Arbitrary missing Board IDs can also return forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "409": {
            "description": "Visible canonical data changed; discard all old pages and restart from the first page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "500": {
            "description": "TaskBoard internal read failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "503": {
            "description": "Storage migration/readiness failure. General service readiness errors can use the common service error shape."
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskBoardQueryRequest"
              }
            }
          }
        }
      }
    },
    "/api/taskboards/{id}": {
      "get": {
        "operationId": "getTaskBoard",
        "tags": [
          "TaskBoard"
        ],
        "summary": "Read an authorized board",
        "description": "Actor-specific projection. Deleted tasks excluded; archived tasks may remain. Redacted comment bodies and private claim tokens are withheld as documented. Direct arbitrary missing/invisible Board IDs normally return 403. Authorized missing scope aliases can return exists:false. Requires the authenticated deployment owner's global TaskBoard capability and current Board/Team access; HTTP acts as the authenticated human actor. No Task execution is started.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/taskboards"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized synchronous read result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardDetailResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, cursor, filter/sort combination or activity range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity. Authentication errors can use the common service error shape."
          },
          "403": {
            "description": "TaskBoard capability disabled or Board access denied. Arbitrary missing Board IDs can also return forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "500": {
            "description": "TaskBoard internal read failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "503": {
            "description": "Storage migration/readiness failure. General service readiness errors can use the common service error shape."
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Opaque id returned by this instance; encode as one path segment.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ]
      }
    },
    "/api/taskboards/{id}/tasks/{taskId}": {
      "get": {
        "operationId": "getTaskBoardTask",
        "tags": [
          "TaskBoard"
        ],
        "summary": "Read one authorized task",
        "description": "Board access check runs first. A missing/deleted task within an authorized Board returns 200 exists:false. Available actions are a current actor snapshot, not a grant. Requires the authenticated deployment owner's global TaskBoard capability and current Board/Team access; HTTP acts as the authenticated human actor. No Task execution is started.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/taskboards"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized synchronous read result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskDirectReadResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, cursor, filter/sort combination or activity range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity. Authentication errors can use the common service error shape."
          },
          "403": {
            "description": "TaskBoard capability disabled or Board access denied. Arbitrary missing Board IDs can also return forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "500": {
            "description": "TaskBoard internal read failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "503": {
            "description": "Storage migration/readiness failure. General service readiness errors can use the common service error shape."
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Opaque id returned by this instance; encode as one path segment.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "description": "Opaque taskId returned by this instance; encode as one path segment.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ]
      }
    },
    "/api/taskboards/{id}/activity": {
      "get": {
        "operationId": "listTaskBoardHandoffEvidence",
        "tags": [
          "TaskBoard"
        ],
        "summary": "Read task handoff evidence on a board",
        "description": "Only handoff evidence; not a complete Board activity log. Optional taskId restricts visible tasks; no pagination. Requires the authenticated deployment owner's global TaskBoard capability and current Board/Team access; HTTP acts as the authenticated human actor. No Task execution is started.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/taskboards"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized synchronous read result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardHandoffEvidenceResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, cursor, filter/sort combination or activity range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity. Authentication errors can use the common service error shape."
          },
          "403": {
            "description": "TaskBoard capability disabled or Board access denied. Arbitrary missing Board IDs can also return forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "500": {
            "description": "TaskBoard internal read failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "503": {
            "description": "Storage migration/readiness failure. General service readiness errors can use the common service error shape."
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Opaque id returned by this instance; encode as one path segment.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "taskId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "Restrict handoff evidence to a currently visible task; no pagination."
          }
        ]
      }
    },
    "/api/taskboards/{id}/tasks/{taskId}/activity": {
      "get": {
        "operationId": "getTaskBoardTaskActivity",
        "tags": [
          "TaskBoard"
        ],
        "summary": "Read a fixed prefix of task event history",
        "description": "Canonical task events use Board revision continuation. First page captures throughRevision; preserve it with nextAfterRevision on all later pages. Positive afterRevision requires throughRevision. null nextAfterRevision means complete, even if items is empty earlier. pageSize bounds candidate scans, not total returned items. Owner projections are current summaries, can repeat/change on every page, and are not frozen by throughRevision. Requires the authenticated deployment owner's global TaskBoard capability and current Board/Team access; HTTP acts as the authenticated human actor. No Task execution is started.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/taskboards"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized synchronous read result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskActivityResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, cursor, filter/sort combination or activity range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity. Authentication errors can use the common service error shape."
          },
          "403": {
            "description": "TaskBoard capability disabled or Board access denied. Arbitrary missing Board IDs can also return forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "404": {
            "description": "Task or Board no longer available after Board authorization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "500": {
            "description": "TaskBoard internal read failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "503": {
            "description": "Storage migration/readiness failure. General service readiness errors can use the common service error shape."
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Opaque id returned by this instance; encode as one path segment.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "description": "Opaque taskId returned by this instance; encode as one path segment.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "本页最多扫描的canonical事件候选数，缺省50；Owner当前摘要另行返回。"
            },
            "description": "本页最多扫描的canonical事件候选数，缺省50；Owner当前摘要另行返回。"
          },
          {
            "name": "afterRevision",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991,
              "default": 0,
              "description": "排除此Board revision及之前的事件；首请求缺省0，续页使用上一响应nextAfterRevision。"
            },
            "description": "排除此Board revision及之前的事件；首请求缺省0，续页使用上一响应nextAfterRevision。"
          },
          {
            "name": "throughRevision",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991,
              "description": "本次浏览固定的Board历史前缀；首请求缺省冻结当前revision，续页与回首页保留该值。"
            },
            "description": "本次浏览固定的Board历史前缀；首请求缺省冻结当前revision，续页与回首页保留该值。"
          }
        ]
      }
    },
    "/api/taskboards/session-board/resolve": {
      "post": {
        "operationId": "resolveSessionTaskBoard",
        "tags": [
          "TaskBoard"
        ],
        "summary": "Resolve the default board for a conversation",
        "description": "Read-only POST, 4 KiB body limit. Requires runId or sessionId; accepts no claimed session list. Current session with exactly one visible board wins, including archived boards; multiple current boards have no default. Otherwise choose newest unarchived board from another persisted session of the same Run. No default returns 200 exists:false. IDs do not expand current visibility. Requires the authenticated deployment owner's global TaskBoard capability and current Board/Team access; HTTP acts as the authenticated human actor. No Task execution is started.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/taskboards"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized synchronous read result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardDetailResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, cursor, filter/sort combination or activity range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity. Authentication errors can use the common service error shape."
          },
          "403": {
            "description": "TaskBoard capability disabled or Board access denied. Arbitrary missing Board IDs can also return forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 4 KiB."
          },
          "500": {
            "description": "TaskBoard internal read failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskBoardReadError"
                }
              }
            }
          },
          "503": {
            "description": "Storage migration/readiness failure. General service readiness errors can use the common service error shape."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskBoardSessionBoardResolveRequest"
              }
            }
          }
        }
      }
    },
    "/api/s3/connections": {
      "get": {
        "operationId": "listS3Connections",
        "tags": [
          "Object storage"
        ],
        "summary": "Read configured S3 connection summaries",
        "description": "Requires the current user Object Storage capability. This is not an anonymous API. Summaries do not contain access keys or secrets and do not verify credentials or provider reachability. No per-object or prefix scoped token is issued.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/object-storage#connections"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Configured connection summaries; an empty configuration returns an empty connections array.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/S3ConnectionSummaries"
                }
              }
            }
          },
          "401": {
            "description": "Instance authentication failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "Object Storage is disabled, uninstalled or availability is uncertain; or browser Origin is denied. Capability errors have no success field.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ObjectStorageCapabilityDisabled"
                    },
                    {
                      "$ref": "#/components/schemas/OriginRejection"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Domain operation failed or an unexpected service error occurred.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/S3ReadError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures; preserve status and Content-Type.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/s3/list": {
      "get": {
        "operationId": "listS3Objects",
        "tags": [
          "Object storage"
        ],
        "summary": "Browse objects using an existing connection",
        "description": "Requires the current user Object Storage capability and configured provider credentials with list access. Keep connection, prefix, delimiter and page size unchanged when passing opaque continuation tokens. No fixed snapshot or total count.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/object-storage#list-objects"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "connection_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Existing connection ID. When omitted or empty: default, then first connected, then first connection. An unusable selected connection returns NO_CONNECTION without trying alternatives."
          },
          {
            "name": "prefix",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Object key prefix; empty or absent prefix is omitted from the response."
          },
          {
            "name": "delimiter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "/"
            },
            "description": "Grouping delimiter; empty string disables common-prefix grouping."
          },
          {
            "name": "max_keys",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "100"
            },
            "description": "Recommended decimal integer 1–1000. Number(value) or 100, then clamped to 1–1000; malformed values and zero use 100. Not strict integer validation."
          },
          {
            "name": "continuation_token",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Pass the previous next_continuation_token unchanged."
          }
        ],
        "responses": {
          "200": {
            "description": "One provider page. Final pages omit a missing continuation token rather than returning null.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/S3ObjectList"
                }
              }
            }
          },
          "401": {
            "description": "Instance authentication failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "Object Storage is disabled, uninstalled or availability is uncertain; or browser Origin is denied. Capability errors have no success field.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ObjectStorageCapabilityDisabled"
                    },
                    {
                      "$ref": "#/components/schemas/OriginRejection"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Domain operation failed or an unexpected service error occurred.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/S3ReadError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures; preserve status and Content-Type.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "NO_CONNECTION: no selected connection with usable configuration and credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/S3ReadError"
                }
              }
            }
          }
        }
      }
    },
    "/api/s3/download": {
      "get": {
        "operationId": "downloadS3Object",
        "tags": [
          "Object storage"
        ],
        "summary": "Obtain an S3 download link or object bytes",
        "description": "Requires Object Storage capability and configured provider read permissions. Only exact mode=binary returns bytes; all other values use link mode. Public URL reachability is checked before falling back to a presigned URL. The instance token must not be forwarded to returned S3/CDN URLs. Binary reads buffer the object on the server; no Range or resume contract.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/object-storage#download-object"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "parameters": [
          {
            "name": "connection_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Existing connection ID. When omitted or empty: default, then first connected, then first connection. An unusable selected connection returns NO_CONNECTION without trying alternatives."
          },
          {
            "name": "key",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "Complete nonempty object key, preserving case and slashes."
          },
          {
            "name": "mode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "link"
            },
            "description": "Use link or binary. Only exact binary changes the response to raw object bytes; other values use link mode."
          },
          {
            "name": "expires_in",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "3600"
            },
            "description": "Link mode: recommended integer 60–604800 seconds. Number(value) or 3600, then clamped to 60–604800. Public URLs omit expires_in."
          }
        ],
        "responses": {
          "200": {
            "description": "Link mode returns JSON; binary mode returns arbitrary object bytes, which can themselves contain JSON or HTML. Check HTTP status before saving. Optional link metadata can be absent (including content_length for an empty object).",
            "headers": {
              "Content-Disposition": {
                "description": "Binary mode: attachment filename from the final key segment; use an explicit safe local filename.",
                "schema": {
                  "type": "string"
                }
              },
              "Content-Length": {
                "description": "Binary mode byte count.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "description": "In link mode, use the S3DownloadLink component. In binary mode an application/json object may contain any bytes, including arbitrary JSON objects, arrays or scalars; do not parse it as an API wrapper based on MIME type. OpenAPI cannot choose a response schema by the mode query parameter."
                },
                "examples": {
                  "publicLink": {
                    "summary": "Link mode with a public URL; expires_in is absent.",
                    "value": {
                      "success": true,
                      "key": "reports/summary.txt",
                      "download_url": "https://files.example.com/reports/summary.txt",
                      "url_type": "public",
                      "content_type": "text/plain",
                      "content_length": 120
                    }
                  },
                  "presignedLink": {
                    "summary": "Link mode with a signed URL.",
                    "value": {
                      "success": true,
                      "key": "reports/summary.txt",
                      "download_url": "https://s3.example.com/reports/summary.txt?signature=example",
                      "url_type": "presigned",
                      "expires_in": 3600
                    }
                  }
                }
              },
              "*/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Instance authentication failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAuthenticationError"
                }
              }
            }
          },
          "403": {
            "description": "Object Storage is disabled, uninstalled or availability is uncertain; or browser Origin is denied. Capability errors have no success field.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ObjectStorageCapabilityDisabled"
                    },
                    {
                      "$ref": "#/components/schemas/OriginRejection"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Domain operation failed or an unexpected service error occurred.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/S3ReadError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Startup is incomplete or instance authentication is not initialized.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                },
                "description": "Present for service_not_ready."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other service or reverse-proxy failures; preserve status and Content-Type.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "INVALID_REQUEST for missing/empty key; NO_CONNECTION for unresolved connection, missing configuration or credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/S3ReadError"
                }
              }
            }
          },
          "404": {
            "description": "Link mode NOT_FOUND when the metadata HEAD does not succeed. This can include a provider denial and is not proof of deletion. Binary mode missing objects instead use 500 DOWNLOAD_FAILED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/S3ReadError"
                }
              }
            }
          }
        }
      }
    },
    "/api/runs/{id}/workers": {
      "get": {
        "operationId": "listRunWorkers",
        "tags": [
          "Workers"
        ],
        "summary": "List user-owned parent Run Workers",
        "description": "Owner of the parent Run. Foreign/missing parent both return 404. No independent Worker Run. Status is derived on read.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/subagent-records"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Operation succeeded; interpret lifecycle/management facts using the guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkerListResponse"
                },
                "example": {
                  "run_id": "parent-run",
                  "workers": []
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or resource authority rejected. A valid instance credential does not replace resource ownership checks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Referenced owned resource/record is missing or unavailable. Worker/Run reads do not distinguish a foreign owner.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected local read or management error; preserve actual status and Content-Type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or a required preparation/owner service failed. Error envelopes differ.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationError"
                    },
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other framework or reverse-proxy response; preserve status/body type.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "Use the instance-returned ID and encode one path segment."
          }
        ]
      }
    },
    "/api/runs/{id}/workers/{workerId}/transcript": {
      "get": {
        "operationId": "getWorkerTranscript",
        "tags": [
          "Workers"
        ],
        "summary": "Page valid Worker record entries",
        "description": "Offset/total count valid entries, not seq or messages. parseInt/clamp query handling. Sensitive/unknown call results and extra fields are projected before paging; truncated means recording cap, not hasMore.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/subagent-records"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Operation succeeded; interpret lifecycle/management facts using the guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkerTranscriptPage"
                },
                "example": {
                  "run_id": "parent-run",
                  "workerId": "worker-example",
                  "status": "unknown",
                  "entries": [],
                  "total": 0,
                  "offset": 0,
                  "limit": 500,
                  "truncated": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters/body or incompatible resource/definition requirements.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or resource authority rejected. A valid instance credential does not replace resource ownership checks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Referenced owned resource/record is missing or unavailable. Worker/Run reads do not distinguish a foreign owner.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected local read or management error; preserve actual status and Content-Type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or a required preparation/owner service failed. Error envelopes differ.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationError"
                    },
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other framework or reverse-proxy response; preserve status/body type.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "Use the instance-returned ID and encode one path segment."
          },
          {
            "name": "workerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "Use the instance-returned ID and encode one path segment."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "0"
            },
            "description": "parseInt position; invalid/nonpositive becomes 0. Not seq."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "500"
            },
            "description": "parseInt limit; invalid defaults to 500, clamped to 1..2000."
          }
        ]
      }
    },
    "/api/manual-topics/archived": {
      "get": {
        "operationId": "listArchivedManualTopics",
        "tags": [
          "Session history"
        ],
        "summary": "List current owner archived topics across Agents",
        "description": "Fresh current-owner projection. Numeric query values are converted with Number then checked as safe integers. Unreadable/importing sources may be omitted; no snapshot revision.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/session-history-and-messages"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Operation succeeded; interpret lifecycle/management facts using the guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArchivedManualTopicPage"
                },
                "example": {
                  "items": [],
                  "total": 0,
                  "hasMore": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters/body or incompatible resource/definition requirements.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or resource authority rejected. A valid instance credential does not replace resource ownership checks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected local read or management error; preserve actual status and Content-Type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or a required preparation/owner service failed. Error envelopes differ.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationError"
                    },
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other framework or reverse-proxy response; preserve status/body type.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "50"
            },
            "description": "Number(value), safe integer in 1..200."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "0"
            },
            "description": "Number(value), safe nonnegative integer."
          }
        ]
      }
    },
    "/api/sessions/{runId}/runtime-state": {
      "get": {
        "operationId": "getSessionRuntimeReference",
        "tags": [
          "Session history"
        ],
        "summary": "Read a persistent recovery reference",
        "description": "Does not report live Run state. Foreign/missing Run returns 404. runtimeSession:null is a legitimate absent reference; verified local recovery failure returns 500 SESSION_RESTORE_FAILED instead.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/session-history-and-messages"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Operation succeeded; interpret lifecycle/management facts using the guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersistentSessionReference"
                },
                "example": {
                  "runId": "run-example",
                  "teamId": null,
                  "runtimeSession": null
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "const": "private, no-store"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters/body or incompatible resource/definition requirements.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or resource authority rejected. A valid instance credential does not replace resource ownership checks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Referenced owned resource/record is missing or unavailable. Worker/Run reads do not distinguish a foreign owner.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Verified local recovery failure, not an absent reference. Do not replay input.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/SessionRecoveryError"
                    },
                    {
                      "$ref": "#/components/schemas/FrameworkError"
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or a required preparation/owner service failed. Error envelopes differ.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationError"
                    },
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other framework or reverse-proxy response; preserve status/body type.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "runId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "Use the instance-returned ID and encode one path segment."
          }
        ]
      }
    },
    "/api/compute/preparation/retry": {
      "post": {
        "operationId": "retryComputePreparation",
        "tags": [
          "Observability"
        ],
        "summary": "Explicitly retry instance compute preparation",
        "description": "Owner management action. No query parameters and no body (including {}). Pending requests join the same attempt; failed preparation may retry; ready is idempotent. Does not replay business requests or prove model/provider success.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/observability"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Operation succeeded; interpret lifecycle/management facts using the guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ComputePreparationReady"
                },
                "example": {
                  "status": "ready"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters/body or incompatible resource/definition requirements.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or management authority rejected. Remote/standalone uses the deployment owner token; embedded management requires official renderer authority.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected local read or management error; preserve actual status and Content-Type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or a required preparation/owner service failed. Error envelopes differ.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationError"
                    },
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other framework or reverse-proxy response; preserve status/body type.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/team-archive": {
      "get": {
        "operationId": "listTeamArchives",
        "tags": [
          "Instance management"
        ],
        "summary": "List local team archive summaries",
        "description": "Deployment-owner read with management authority; includes local paths and member facts. Current summary, no reservation or pagination.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/instance-management"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Operation succeeded; interpret lifecycle/management facts using the guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamArchiveList"
                },
                "example": {
                  "success": true,
                  "data": {
                    "archives": []
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or management authority rejected. Remote/standalone uses the deployment owner token; embedded management requires official renderer authority.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Referenced owned resource/record is missing or unavailable. Worker/Run reads do not distinguish a foreign owner.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected local read or management error; preserve actual status and Content-Type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or a required preparation/owner service failed. Error envelopes differ.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationError"
                    },
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other framework or reverse-proxy response; preserve status/body type.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/team-archive/{archiveId}/restore": {
      "post": {
        "operationId": "restoreTeamArchive",
        "tags": [
          "Instance management"
        ],
        "summary": "Explicitly restore one archived team",
        "description": "Changes persistent team state. Cannot overwrite an occupied ID; use newName. A missing supervisor requires a replacement. Inspect warnings/approval/workdir; no public idempotency key, no automatic retry.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/instance-management"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Operation succeeded; interpret lifecycle/management facts using the guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamRestoreResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters/body or incompatible resource/definition requirements.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or management authority rejected. Remote/standalone uses the deployment owner token; embedded management requires official renderer authority.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Referenced owned resource/record is missing or unavailable. Worker/Run reads do not distinguish a foreign owner.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "409": {
            "description": "Resource/version/idempotency or archive conflict; reconcile before changing the request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "Framework request body limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FrameworkError"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected local read or management error; preserve actual status and Content-Type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or a required preparation/owner service failed. Error envelopes differ.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationError"
                    },
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other framework or reverse-proxy response; preserve status/body type.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "archiveId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "Use the instance-returned ID and encode one path segment."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/TeamRestoreRequest"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/api/workflow-definitions/{workflowId}/taskboard-bindings": {
      "post": {
        "operationId": "createGovernedWorkflowBinding",
        "tags": [
          "Instance management"
        ],
        "summary": "Bind an exact owned Workflow definition to a Board or Task",
        "description": "Agent Service gateway with an existing connected Workflow Service. Request limit: 16 KiB, 128 nodes, depth 8. Requires an exact owned definition ref and resource CAS. Trigger requires a Task and required typed outputs.task_ref without defaults. Stable idempotency key; does not start execution or issue a grant. Owner rejection status/body is preserved.",
        "externalDocs": {
          "url": "https://docs.desirecore.com/api/instance-management"
        },
        "security": [
          {
            "InstanceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Operation succeeded; interpret lifecycle/management facts using the guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GovernedWorkflowBindingResult"
                }
              }
            }
          },
          "201": {
            "description": "Operation succeeded; interpret lifecycle/management facts using the guide.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GovernedWorkflowBindingResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters/body or incompatible resource/definition requirements.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "Missing/invalid instance credential or trusted user identity.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "Origin or resource authority rejected. A valid instance credential does not replace resource ownership checks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Referenced owned resource/record is missing or unavailable. Worker/Run reads do not distinguish a foreign owner.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "409": {
            "description": "Resource/version/idempotency or archive conflict; reconcile before changing the request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "413": {
            "description": "Binding request exceeds 16 KiB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FrameworkError"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected local read or management error; preserve actual status and Content-Type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "503": {
            "description": "Service is not ready or a required preparation/owner service failed. Error envelopes differ.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OperationError"
                    },
                    {
                      "$ref": "#/components/schemas/ServiceStarting"
                    },
                    {
                      "$ref": "#/components/schemas/InstanceTokenUninitialized"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Other framework or reverse-proxy response; preserve status/body type.",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "workflowId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "description": "Use the instance-returned ID and encode one path segment."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GovernedWorkflowBindingWriteRequest"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "InstanceToken": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Agent-Service-Token",
        "description": "Existing owner credential supplied by the instance administrator."
      },
      "WebhookSecret": {
        "type": "http",
        "scheme": "bearer",
        "description": "Dedicated secret for the target Agent Webhook; not a provider API key or JWT."
      },
      "SignedMediaSignature": {
        "type": "apiKey",
        "in": "query",
        "name": "signature",
        "description": "Five-minute HMAC-SHA-256 capability issued by POST /api/media/access-urls. 43-character canonical base64url signature bound to the filename and required expires query value. Reusable until expiry; no instance header required for this GET. Expired/invalid links return 401. Application authority, configured Origin restrictions, and readiness are checked separately."
      }
    },
    "schemas": {
      "ClientHandshake": {
        "type": "object",
        "required": [
          "service",
          "apiProtocolVersion",
          "serverVersion",
          "instanceId",
          "deploymentMode",
          "clientCompatibility",
          "capabilities",
          "authentication",
          "serverTime"
        ],
        "properties": {
          "service": {
            "type": "string",
            "const": "desirecore-agent-service",
            "description": "固定服务标记，用于拒绝非 DesireCore Agent Service 目标。"
          },
          "apiProtocolVersion": {
            "type": "string",
            "const": "1",
            "description": "客户端握手和实例连接协议版本；不等同于应用版本。"
          },
          "serverVersion": {
            "type": "string",
            "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$",
            "description": "当前 Agent Service 随客户端发布的语义版本号。"
          },
          "instanceId": {
            "type": "string",
            "pattern": "^inst_[A-Za-z0-9_-]{32}$",
            "description": "Agent Service 数据空间的稳定不透明身份。由服务端随机生成并持久化，不得由路径、用户、设备或 token 推导。"
          },
          "deploymentMode": {
            "type": "string",
            "enum": [
              "embedded",
              "owner",
              "external"
            ],
            "description": "Agent Service 运行形态：embedded=Electron 内嵌；owner=standalone owner 模式；external=standalone external 模式。"
          },
          "clientCompatibility": {
            "type": "object",
            "required": [
              "minimumVersion",
              "maximumVersion"
            ],
            "properties": {
              "minimumVersion": {
                "type": "string",
                "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$",
                "description": "允许连接本服务的最低 DesireCore 客户端版本（含）。"
              },
              "maximumVersion": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$",
                "description": "允许连接本服务的最高 DesireCore 客户端版本（含）；null 表示不设上限。"
              }
            },
            "additionalProperties": false
          },
          "capabilities": {
            "type": "object",
            "required": [
              "workflow",
              "mediaSignedUrl"
            ],
            "properties": {
              "workflow": {
                "type": "boolean",
                "description": "当前部署是否具备可用且完整配置的 Workflow Service 能力。"
              },
              "pdfRendering": {
                "type": "boolean",
                "description": "服务端宿主是否提供 HTML 转 PDF 引擎；缺席表示未知，不代表客户端具有打印传输。"
              },
              "mediaSignedUrl": {
                "type": "boolean",
                "description": "当前实例是否可以签发供原生媒体标签使用的短期 HTTPS URL。"
              },
              "queryRequestIdEcho": {
                "type": "boolean",
                "description": "服务端是否回显客户端 query 的 clientRequestId；缺席表示未知，客户端只能按实际事件观察，禁止按版本推断。"
              },
              "webhookManagement": {
                "type": "boolean",
                "description": "是否支持所有者通过 Webhook 管理 API 配置事件、选择现有工具和轮换 secret；缺席或 false 表示该配置入口不可用。"
              },
              "localPairing": {
                "type": "boolean"
              },
              "localAttachSecret": {
                "type": "boolean"
              },
              "objectStorageCapability": {
                "type": "boolean"
              },
              "mailCapability": {
                "type": "boolean"
              }
            },
            "additionalProperties": {
              "type": "boolean",
              "description": "未来新增的布尔能力位；旧客户端应忽略不认识的能力名。"
            }
          },
          "authentication": {
            "type": "object",
            "required": [
              "kind",
              "scopes"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "embedded-capability",
                  "instance-token"
                ],
                "description": "本次服务形态使用的客户端鉴权类型：embedded-capability 或 standalone instance-token。"
              },
              "scopes": {
                "type": "array",
                "minItems": 1,
                "maxItems": 1,
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "enum": [
                    "owner"
                  ]
                },
                "description": "认证凭据授予的实例作用域；第一版固定为 owner。"
              }
            },
            "additionalProperties": false
          },
          "serverTime": {
            "type": "string",
            "format": "date-time",
            "description": "服务端生成响应时的 ISO 8601 时间，用于诊断时钟偏差，不参与身份判断。"
          },
          "product": {
            "type": "object",
            "required": [
              "editionId",
              "appId",
              "productName",
              "buildKind",
              "appVersion"
            ],
            "properties": {
              "editionId": {
                "type": "string",
                "pattern": "^[a-z0-9][a-z0-9-]*$",
                "maxLength": 128,
                "description": "服务所在应用的发行版 ID；同机接入发现据此标注候选实例属于哪个发行版。"
              },
              "appId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "服务所在应用的 appId（macOS bundle id、Windows AUMID 前缀）。"
              },
              "productName": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128,
                "description": "服务所在应用的显示名。"
              },
              "buildKind": {
                "type": "string",
                "enum": [
                  "dev",
                  "prod"
                ],
                "description": "服务所在应用的构建形态：Electron 打包版为 prod，开发版为 dev；standalone 按运行环境判断。"
              },
              "appVersion": {
                "type": "string",
                "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$",
                "description": "服务所在应用的版本号，与 serverVersion 相同。"
              }
            },
            "additionalProperties": false
          },
          "capabilityDiagnostics": {
            "type": "object",
            "required": [
              "pdfRendering"
            ],
            "properties": {
              "pdfRendering": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "pdf_renderer_unavailable",
                  null
                ]
              }
            },
            "additionalProperties": false,
            "description": "仅协商 deployment-capabilities 时返回；原因是部署能力事实，不含配置、路径或凭据。"
          },
          "queryDispatch": {
            "type": "object",
            "required": [
              "serverInstanceId"
            ],
            "properties": {
              "serverInstanceId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128,
                "description": "当前服务进程启动代际，与 recovery.serverInstanceId 同源；重启即变化，不能当持久 instanceId 或认证凭证。"
              }
            },
            "additionalProperties": false,
            "description": "仅协商 query-dispatch 扩展时返回；旧服务缺席本字段时不得伪造进程身份。"
          }
        },
        "additionalProperties": false
      },
      "WebhookRequest": {
        "type": "object",
        "required": [
          "event"
        ],
        "properties": {
          "event": {
            "type": "string",
            "description": "事件标识，如 \"github.push\""
          },
          "payload": {
            "type": "object",
            "additionalProperties": {},
            "description": "事件负载，prompt_template 中的 {{key}} 从此处提取"
          }
        },
        "additionalProperties": false
      },
      "WebhookAccepted": {
        "type": "object",
        "properties": {
          "accepted": {
            "type": "boolean",
            "const": true
          },
          "agentId": {
            "type": "string"
          },
          "event": {
            "type": "string"
          }
        },
        "required": [
          "accepted",
          "agentId",
          "event"
        ],
        "additionalProperties": false
      },
      "InstanceAuthenticationError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "const": "unauthorized"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "message"
        ],
        "additionalProperties": false
      },
      "OriginRejection": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "const": "origin_not_allowed"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": true
      },
      "ServiceStarting": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "const": "starting"
          },
          "service": {
            "type": "string",
            "const": "agent-service"
          },
          "code": {
            "type": "string",
            "const": "service_not_ready"
          }
        },
        "required": [
          "status",
          "service",
          "code"
        ],
        "additionalProperties": false
      },
      "InstanceTokenUninitialized": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "const": "instance_token_uninitialized"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "message"
        ],
        "additionalProperties": false
      },
      "WebhookAuthenticationError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "Invalid webhook secret",
              "Invalid embedded instance token"
            ]
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "WebhookSecretRequired": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "const": "webhook_secret_required"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "message"
        ],
        "additionalProperties": false
      },
      "WebhookNotFound": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "Agent not found",
              "Webhook not enabled for this agent"
            ]
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "WebhookInvalidBody": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "const": "Invalid request body"
          },
          "details": {
            "type": "array",
            "items": {}
          }
        },
        "required": [
          "error",
          "details"
        ],
        "additionalProperties": false
      },
      "WebhookUnknownEvent": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "pattern": "^Unknown event type: "
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "WebhookConfigurationError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "const": "Failed to parse agent.json"
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "FrameworkError": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer"
          },
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        },
        "required": [
          "statusCode",
          "error",
          "message"
        ],
        "additionalProperties": true
      },
      "AgentSummary": {
        "type": "object",
        "required": [
          "id",
          "name",
          "skillsCount",
          "toolsCount",
          "heartbeatEnabled",
          "hasGit",
          "isCoreAgent"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "智能体 ID（目录名）"
          },
          "name": {
            "type": "string",
            "description": "智能体显示名称"
          },
          "description": {
            "type": "string",
            "description": "智能体描述"
          },
          "ui": {
            "type": "object",
            "description": "该智能体的界面呈现配置，仅作用于其会话，不改变平台设置",
            "properties": {
              "chat_bubble_mode": {
                "type": "string",
                "enum": [
                  "flat",
                  "classic"
                ],
                "description": "消息样式：flat 为通栏，classic 为气泡；省略时跟随平台消息样式"
              }
            },
            "additionalProperties": false
          },
          "isCoreAgent": {
            "type": "boolean"
          },
          "skillsCount": {
            "type": "number",
            "description": "技能数量",
            "minimum": 0
          },
          "toolsCount": {
            "type": "number",
            "description": "工具数量",
            "minimum": 0
          },
          "heartbeatEnabled": {
            "type": "boolean",
            "description": "心跳是否启用"
          },
          "engine": {
            "type": "string",
            "description": "运行时引擎"
          },
          "hasGit": {
            "type": "boolean",
            "description": "是否有 git 仓库"
          },
          "hasRemote": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "description": "Agent 运行时状态（从 AgentRegistry 获取）",
            "enum": [
              "online",
              "busy",
              "idle",
              "offline",
              "error",
              "recovery",
              "shutdown"
            ]
          },
          "metadataError": {
            "type": "string",
            "enum": [
              "missing",
              "unreadable",
              "invalid_json",
              "invalid_shape"
            ]
          },
          "syncStatus": {
            "type": "string",
            "description": "Git 同步状态：synced（已同步）、ahead（本地有未推送提交）、behind（远程有更新）、conflict（存在冲突）、local_only（纯本地，无远程仓库）、uninitialized（未初始化 Git）",
            "enum": [
              "synced",
              "ahead",
              "behind",
              "conflict",
              "local_only",
              "uninitialized"
            ]
          },
          "avatar": {
            "type": "object",
            "description": "头像配置（来自 agent.json）",
            "properties": {
              "char": {
                "type": "string",
                "description": "显示字符"
              },
              "color": {
                "type": "string",
                "description": "色系键名",
                "enum": [
                  "green",
                  "blue",
                  "purple",
                  "orange",
                  "red"
                ]
              },
              "image": {
                "type": "object",
                "description": "图片头像配置（agent.json 原样透传）。**这里只说明配置存在，不代表文件可用**——判断能否渲染图片请看顶层 avatarImage",
                "required": [
                  "path"
                ],
                "properties": {
                  "path": {
                    "type": "string",
                    "description": "相对于 Agent 根目录的图片路径"
                  }
                },
                "additionalProperties": false
              },
              "model": {
                "type": "object",
                "description": "沉浸式交互使用的 Agent 自定义 3D 模型配置",
                "required": [
                  "path"
                ],
                "properties": {
                  "path": {
                    "type": "string",
                    "description": "相对于 Agent 根目录的 GLB 文件路径"
                  },
                  "body": {
                    "type": "string",
                    "description": "TalkingHead 模型体型提示",
                    "enum": [
                      "F",
                      "M"
                    ]
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          },
          "avatarImage": {
            "type": "object",
            "required": [
              "version"
            ],
            "properties": {
              "version": {
                "type": "string",
                "description": "缓存版本戳（`${size}-${mtimeMs}`），与该端点的 ETag 同源。值变化即表示图片已更换，客户端应丢弃旧缓存重新取图。不写进 agent.json：那会产生 git diff 噪声，且 Agent 直接覆盖图片文件时字段不会变，必然漂移。"
              },
              "mimeType": {
                "type": "string",
                "description": "经 magic bytes 嗅探确认的真实 MIME 类型（不信任扩展名）",
                "enum": [
                  "image/png",
                  "image/jpeg",
                  "image/webp"
                ]
              }
            },
            "additionalProperties": false
          },
          "unread": {
            "type": "number",
            "description": "该 Agent 当前未读消息计数（手动多会话模式下为各话题未读之和，非手动模式为单会话计数）；无未读时不返回此字段"
          },
          "pinned": {
            "type": "boolean",
            "description": "该 Agent 是否被用户置顶在侧栏最上方（来自用户级 preferences/agent-list.json）；未置顶时不返回此字段"
          },
          "pinnedAt": {
            "type": "string",
            "description": "置顶时间 ISO 8601，多个置顶 Agent 之间的排序依据；未置顶时不返回此字段"
          },
          "folded": {
            "type": "boolean",
            "description": "该 Agent 是否被收进侧栏的「折叠的聊天」分组（来自用户级 preferences/agent-list.json）；未折叠时不返回此字段"
          },
          "groupOverride": {
            "type": "string",
            "enum": [
              "general",
              "specialist"
            ],
            "description": "用户手动指定的侧栏分组，覆盖默认派生（默认派生 = 团队组长自动提升为通用，其余按 Agent 自身性质）；未手动指定时不返回此字段"
          },
          "nestMembers": {
            "type": "boolean",
            "description": "该 Agent 作为团队组长时，其成员是否收纳到组长名下；用户级 preferences/agent-list.json 的显式选择优先，否则遵循团队 memberDisplay 默认值。未开启时不返回此字段"
          }
        },
        "additionalProperties": false
      },
      "RunMeta": {
        "type": "object",
        "required": [
          "run_id",
          "user_id",
          "agent_id",
          "started_at",
          "status"
        ],
        "properties": {
          "run_id": {
            "type": "string",
            "description": "Run UUID，全局唯一标识符，用于查询和关联 Receipt"
          },
          "user_id": {
            "type": "string",
            "description": "发起用户 ID"
          },
          "agent_id": {
            "type": "string",
            "description": "Agent ID（对应 AgentFS 中的目录名）"
          },
          "conversation_id": {
            "type": "string",
            "description": "对话 ID，用于关联同一对话的多次 Run（支持多轮对话场景）"
          },
          "title": {
            "type": "string",
            "description": "会话标题（手动多会话模式下使用）：用户重命名后的自定义标题，或系统据首条消息生成的摘要标题"
          },
          "title_source": {
            "type": "string",
            "enum": [
              "custom",
              "auto"
            ],
            "description": "title 的来源：custom=用户手动重命名，auto=系统据首条用户消息自动生成（截断或 LLM 摘要）"
          },
          "origin": {
            "type": "string",
            "enum": [
              "user",
              "delegation"
            ],
            "description": "会话创建来源（手动多会话模式下使用）：user=用户手动新建，delegation=被其他 Agent 委派时自动新建"
          },
          "background": {
            "type": "boolean"
          },
          "inbound": {
            "type": "boolean",
            "description": "这一轮是不是「另一个 Agent 发来的消息」（SendMessage 来信）。**与 background 正交**：background 回答「该不该抢会话的前台控制槽」，本字段回答「这一轮在做什么」。来信已回归前台语义（与用户消息同路径），因此不再带 background；但「对方正在处理别人的来信」与「对方正在与用户对话」对**是否该打断**的判断截然不同，需要一个独立标记（见 agent/agent-activity.ts 的 kind 派生）。同 background，它描述的是**当前这一轮**，同一条 run 被复用时按当轮改写。"
          },
          "started_at": {
            "type": "string",
            "description": "开始时间（ISO 8601 格式，如 2024-01-15T10:30:00Z）",
            "format": "date-time"
          },
          "turn_started_at": {
            "type": "string",
            "description": "**当前这一轮**开始执行的时间（ISO 8601）。同一条 run 会跨轮复用，started_at 停在第一次创建的时刻——一条聊了三天的会话，它的 started_at 就是三天前，拿来算「已运行多久」会报出「已运行 3 天」这种荒谬值，并把忙碌载荷的等待/打断建议带偏。每次把 run 置为 running 的路径（创建、复用、activateRun、activateSessionMetaRun）都要刷新它。updatedAt 不能替代：它会被每次 appendMessage 推后，代表的是「最后一次活动」而非「本轮起点」。",
            "format": "date-time"
          },
          "completed_at": {
            "type": "string",
            "description": "完成时间（ISO 8601 格式），仅 status 为 completed 或 failed 时有值",
            "format": "date-time"
          },
          "status": {
            "type": "string",
            "description": "Run lifecycle state. handed_off means the conversation was handed off, not that the target completed or the submitted turn succeeded.",
            "enum": [
              "running",
              "idle",
              "completed",
              "failed",
              "handed_off"
            ]
          },
          "failure_reason": {
            "type": "string",
            "description": "失败原因（仅 status=failed 时有值）：process_restart=进程重启时被回收的孤儿 run；timeout=执行超时被强制终结；stale=历史兼容值（旧版本曾把超过复用窗口的 idle run 错标为失败）；error=查询过程抛出错误",
            "enum": [
              "process_restart",
              "timeout",
              "stale",
              "error"
            ]
          },
          "interruption_reason": {
            "type": "string",
            "description": "最近一次未完成轮次的主动中止原因。Run 会回到 idle 以保留多轮会话复用能力，完整审计信息同时写入 Receipt",
            "enum": [
              "user_abort",
              "agent_interrupt",
              "reset",
              "system_suspend",
              "process_shutdown",
              "process_restart",
              "orphan_reclaimed",
              "background_timeout"
            ]
          },
          "interrupted_at": {
            "type": "string",
            "description": "最近一次主动中止发生时间（ISO 8601）。仅 interruption_reason 存在时有值",
            "format": "date-time"
          },
          "pending_synthesis": {
            "type": "object",
            "required": [
              "status",
              "interruption_reason",
              "created_at",
              "completed_tool_calls"
            ],
            "properties": {
              "status": {
                "type": "string",
                "const": "required",
                "description": "固定为 required：已完成工具事实存在，但最终业务解释尚未正常收口"
              },
              "interruption_reason": {
                "type": "string",
                "enum": [
                  "user_abort",
                  "agent_interrupt",
                  "reset",
                  "system_suspend",
                  "process_shutdown",
                  "process_restart",
                  "orphan_reclaimed",
                  "background_timeout"
                ]
              },
              "created_at": {
                "type": "string",
                "format": "date-time",
                "description": "待综合状态创建时间（ISO 8601）"
              },
              "completed_tool_calls": {
                "type": "array",
                "minItems": 1,
                "maxItems": 128,
                "items": {
                  "type": "object",
                  "required": [
                    "invocation_id",
                    "tool_name"
                  ],
                  "properties": {
                    "invocation_id": {
                      "type": "string",
                      "maxLength": 256,
                      "description": "已经成功完成的工具调用 ID，用于恢复时识别既成事实并避免重复执行"
                    },
                    "tool_name": {
                      "type": "string",
                      "maxLength": 256,
                      "description": "已经成功完成的模型可见工具名称，供审计和恢复提示使用"
                    }
                  },
                  "additionalProperties": false
                },
                "description": "恢复时必须复用、不得仅为重取同一结果而再次执行的成功工具调用"
              }
            },
            "additionalProperties": false,
            "description": "系统中断发生在工具成功之后、最终解释完成之前时持久化的恢复状态；正常综合成功后清除"
          },
          "interrupted_turn_facts": {
            "type": "object",
            "required": [
              "interruption_reason",
              "recorded_at",
              "deliveries"
            ],
            "properties": {
              "interruption_reason": {
                "type": "string",
                "description": "被记录轮次的中止原因（与 interruption_reason 字段同一枚举）。user_abort 时消费方可下「被用户停止」断言，其余原因只能弱化归因",
                "enum": [
                  "user_abort",
                  "agent_interrupt",
                  "reset",
                  "system_suspend",
                  "process_shutdown",
                  "process_restart",
                  "orphan_reclaimed",
                  "background_timeout"
                ]
              },
              "recorded_at": {
                "type": "string",
                "format": "date-time"
              },
              "deliveries": {
                "type": "array",
                "maxItems": 64,
                "items": {
                  "type": "object",
                  "required": [
                    "tool_name",
                    "preview",
                    "attachment_count",
                    "delivery_status"
                  ],
                  "properties": {
                    "tool_name": {
                      "type": "string",
                      "maxLength": 256,
                      "description": "交付类工具的模型可见名称（builtin-tools/tool-effects 的 effect.class===\"delivery\" 派生名单成员，含历史 alias）"
                    },
                    "preview": {
                      "type": "string",
                      "maxLength": 200,
                      "description": "已投递内容的开头片段（取调用 input.message / input.content 的前 50 字符）。空串表示 input 缺失或非字符串（如 MailOperations 这类通用代理），消费方必须按「无法确认实际送达」的弱化措辞处理，不得下已送达断言"
                    },
                    "attachment_count": {
                      "type": "integer",
                      "minimum": 0,
                      "description": "调用 input.attachments 数组长度；0 表示无附件"
                    },
                    "delivery_status": {
                      "type": "string",
                      "enum": [
                        "completed",
                        "failed",
                        "interrupted"
                      ]
                    }
                  },
                  "additionalProperties": false
                },
                "description": "被中断轮内交付类工具调用的终态清单（tool-effects 派生名单 + 已结算终态；同 toolCallId 去重；超上限时保留最近的条目）。空数组是权威事实「该轮没有任何交付」，消费方不得再退回尾窗启发式反推"
              }
            },
            "additionalProperties": false
          },
          "engine": {
            "type": "string",
            "description": "运行时引擎"
          },
          "session_id": {
            "type": "string",
            "description": "关联的 Socket.IO session ID，用于实时通信和中断控制"
          },
          "messageCount": {
            "type": "number",
            "description": "消息总数（由 SessionStore 维护）"
          },
          "updatedAt": {
            "type": "string",
            "description": "最后更新时间（由 SessionStore 维护）"
          },
          "cleared": {
            "type": "boolean",
            "description": "Tombstone 标记：用户清除对话后置为 true。会话列表和恢复逻辑会过滤掉此类 run，但 receipts/ 子目录保留，活动记录仍能读到该 run 的真实 token 消耗凭据（审计用）"
          },
          "cleared_at": {
            "type": "string",
            "description": "Tombstone 写入时间（ISO 8601）。检查点清理按此时间计算 deletedRunRetentionMinutes；旧数据缺失时兼容 cleared=true",
            "format": "date-time"
          },
          "archived_at": {
            "type": "string",
            "description": "会话归档时间（ISO 8601）。归档是独立于运行 status 的历史生命周期，归档 run 不再自动恢复，但消息和审计记录仍保留",
            "format": "date-time"
          },
          "handoffFrom": {
            "type": "string",
            "readOnly": true,
            "description": "Source Run ID for this handoff. A link grants no access or continuation permission."
          },
          "handoffTo": {
            "type": "string",
            "readOnly": true,
            "description": "Target Run ID for this handoff. Target admission and completion require their own evidence."
          },
          "team_id": {
            "type": "string",
            "description": "本 run 执行时所处的团队作用域。委派续跑（DelegateControl action=\"resume\"）必须按它重建执行环境——用调用方**当前**的 teamId 会让续跑落进另一个团队的 prompt 与共享工作目录，带着旧团队的历史在新环境里接力；缺省表示该 run 不属于任何团队。"
          },
          "work_context_id": {
            "type": "string",
            "minLength": 1,
            "description": "本 Run 所属的稳定 Work Context ID。continue/resume 必须沿用，isolated/fork 必须记录新建结果；旧 Run 可缺省并由幂等 legacy backfill 建段。"
          },
          "execution_attachment": {
            "type": "object",
            "required": [
              "userId",
              "agentId",
              "runId"
            ],
            "properties": {
              "userId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "pattern": "^\\S+$"
              },
              "agentId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "pattern": "^\\S+$",
                "description": "执行该 Run 的权威 Agent ID。"
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "pattern": "^\\S+$",
                "description": "承载本次执行的 DesireCore Run ID。"
              },
              "conversationId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "pattern": "^\\S+$",
                "description": "可选的用户可见 Conversation ID；缺失表示该 Run 不属于对话时间线。"
              },
              "workContextId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "pattern": "^\\S+$",
                "description": "可选的稳定 Work Context ID，用于跨续跑保持同一工作语境。"
              },
              "workflowRunId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "pattern": "^\\S+$",
                "description": "可选的 Workflow Run ID；与 DesireCore Run ID 正交。"
              },
              "cellId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "pattern": "^\\S+$",
                "description": "可选的执行 Cell ID，表示服务实例所在的逻辑隔离单元。"
              },
              "serviceInstanceId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "pattern": "^\\S+$",
                "description": "可选的 Agent Service 实例 ID；出现时必须同时提供其所属 cellId。"
              },
              "jobId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "pattern": "^\\S+$"
              },
              "attemptId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "pattern": "^\\S+$"
              },
              "capsuleId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "pattern": "^\\S+$"
              }
            },
            "allOf": [
              {
                "if": {
                  "required": [
                    "serviceInstanceId"
                  ]
                },
                "then": {
                  "required": [
                    "cellId"
                  ]
                }
              },
              {
                "if": {
                  "required": [
                    "attemptId"
                  ]
                },
                "then": {
                  "required": [
                    "jobId"
                  ]
                }
              },
              {
                "if": {
                  "required": [
                    "capsuleId"
                  ]
                },
                "then": {
                  "required": [
                    "jobId",
                    "attemptId"
                  ]
                }
              }
            ],
            "additionalProperties": false,
            "description": "本 Run 的权威执行归属；新 Run 由服务端构造，旧 Run 可缺失。其 user/agent/run/conversation/work-context 必须与外围 RunMeta 一致。"
          },
          "work_context_selection": {
            "type": "object",
            "required": [
              "context_mode",
              "origin"
            ],
            "properties": {
              "context_mode": {
                "type": "string",
                "enum": [
                  "continue",
                  "isolated",
                  "fork"
                ],
                "description": "必填且无默认值：continue=继续明确存在的同一任务上下文；isolated=不同新任务；fork=同一任务有意分叉。"
              },
              "origin": {
                "type": "string",
                "enum": [
                  "delegate",
                  "mention",
                  "task",
                  "workflow",
                  "schedule",
                  "webhook",
                  "decision",
                  "legacy"
                ]
              },
              "work_context_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
                "description": "continue 必填：要继续的稳定 Work Context ID；禁止回退到目标 Agent 最近一次会话。"
              },
              "source_work_context_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
                "description": "fork 必填：有意分叉的来源 Work Context ID。"
              },
              "task_ref": {
                "type": "object",
                "required": [
                  "board_id",
                  "task_id"
                ],
                "properties": {
                  "board_id": {
                    "type": "string",
                    "minLength": 1
                  },
                  "task_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "TaskBoard 内稳定 Task ID。"
                  },
                  "task_version": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "选择时观察到的 Task 版本快照；身份查重只使用 board_id + task_id。"
                  }
                },
                "additionalProperties": false
              },
              "intent_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "context_reason": {
                "type": "string",
                "minLength": 1,
                "maxLength": 2000,
                "description": "isolated/fork 必填：说明为何这是不同新任务或为何允许对同一 Task 有意分叉。"
              }
            },
            "allOf": [
              {
                "if": {
                  "properties": {
                    "context_mode": {
                      "const": "continue"
                    }
                  },
                  "required": [
                    "context_mode"
                  ]
                },
                "then": {
                  "required": [
                    "work_context_id"
                  ],
                  "not": {
                    "anyOf": [
                      {
                        "required": [
                          "source_work_context_id"
                        ]
                      },
                      {
                        "required": [
                          "intent_id"
                        ]
                      }
                    ]
                  }
                }
              },
              {
                "if": {
                  "properties": {
                    "context_mode": {
                      "const": "isolated"
                    }
                  },
                  "required": [
                    "context_mode"
                  ]
                },
                "then": {
                  "required": [
                    "context_reason"
                  ],
                  "anyOf": [
                    {
                      "required": [
                        "task_ref"
                      ]
                    },
                    {
                      "required": [
                        "intent_id"
                      ]
                    }
                  ],
                  "not": {
                    "anyOf": [
                      {
                        "required": [
                          "work_context_id"
                        ]
                      },
                      {
                        "required": [
                          "source_work_context_id"
                        ]
                      }
                    ]
                  }
                }
              },
              {
                "if": {
                  "properties": {
                    "context_mode": {
                      "const": "fork"
                    }
                  },
                  "required": [
                    "context_mode"
                  ]
                },
                "then": {
                  "required": [
                    "source_work_context_id",
                    "task_ref",
                    "context_reason"
                  ],
                  "not": {
                    "anyOf": [
                      {
                        "required": [
                          "work_context_id"
                        ]
                      },
                      {
                        "required": [
                          "intent_id"
                        ]
                      }
                    ]
                  }
                }
              }
            ],
            "additionalProperties": false,
            "description": "启动此 Run 时调用方显式提交并经 preflight/commit 接受的 Work Context 选择快照。"
          },
          "work_context_task_ref": {
            "type": "object",
            "required": [
              "board_id",
              "task_id"
            ],
            "properties": {
              "board_id": {
                "type": "string",
                "minLength": 1
              },
              "task_id": {
                "type": "string",
                "minLength": 1,
                "description": "TaskBoard 内稳定 Task ID。"
              },
              "task_version": {
                "type": "integer",
                "minimum": 1,
                "description": "选择时观察到的 Task 版本快照；身份查重只使用 board_id + task_id。"
              }
            },
            "additionalProperties": false
          },
          "work_context_intent_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "work_context_origin": {
            "type": "string",
            "enum": [
              "delegate",
              "mention",
              "task",
              "workflow",
              "schedule",
              "webhook",
              "decision",
              "legacy"
            ],
            "description": "此 Run 进入 Work Context 的权威入口快照。"
          },
          "child_context": {
            "type": "object",
            "description": "原委派对子 Agent 上下文组装施加的**收紧**覆盖（Delegate 的 childContext 解析结果）。续跑必须按它重建，否则「只传 run_id 的裸续跑」会让原本被刻意收窄的上下文（memoryScope: none、关掉的能力、section 过滤）在续跑时全部放开——收紧只能保持或更严。形状与 ContextAssemblyOptions 的对应覆盖字段一致；缺省表示原委派未收紧。",
            "additionalProperties": true
          },
          "child_tool_ceiling": {
            "type": "object",
            "description": "委派执行时的工具键与文件访问范围快照。tools 仅记录执行方当时的工具作为审计证据，不是父智能体的授权上限；持久 Agent 续跑使用执行方当前工具权限，并保留防递归限制。allowedReadDirs / allowedReadPaths / allowedWriteDirs 继续与调用方当前范围取交集；缺省的文件维度表示无限制。旧快照的工具键同样不再裁剪目标工具，形状错误仍拒绝恢复。",
            "additionalProperties": true
          },
          "work_dir": {
            "type": "string",
            "description": "本 run 起跑时解析出的**基准**工作目录（团队共享目录 > 手动话题 Project > Agent/全局 effectiveCwd；不含运行时 worktree 绑定那层派生覆盖）。委派续跑据此确认「原来那次是在哪个目录里跑的」：承接来的历史里全是对旧目录中文件的读写，工作目录偏好在两次之间改过的话，续跑就会带着旧上下文在另一个项目里接力。⚠ 与 worktree_cwd 同一约定：**空字符串表示「起跑时确实没解析出工作目录」，字段缺席表示「该 run 创建于本字段引入之前」**——两者混为一谈的话，「当初没配、现在配了工作目录」会被闸门当成老数据跳过，而承接来的历史其实来自当时的进程默认目录。"
          },
          "worktree_cwd": {
            "type": "string",
            "description": "本 run 起跑时实际附着的 Owner worktree 目录（`work_dir` 之上的派生覆盖）。与 work_dir 分开记：前者是用户偏好解析出的基准目录，这一条是运行时按 Owner 绑定的链接工作树。委派续跑两者都要一致——只比基准目录的话，源 run 当初挂在某个 worktree 上、而绑定后来被退出或改挂时闸门会放行，续跑于是回到主 checkout 或另一个工作树里接力。⚠ **空字符串表示「起跑时确实没有附着任何 worktree」，字段缺席表示「该 run 创建于本字段引入之前，无从得知」**——两者必须可区分：都写成缺席的话，「当初没挂、现在挂上了」这一格会被当成老数据跳过比较，而它恰恰是要拦的（历史来自主 checkout，续跑却跑进新工作树）。因此起跑路径**总是**写这个字段。"
          },
          "resumedFrom": {
            "type": "string",
            "description": "同一执行连续性的来源 Run ID：由 DelegateControl(action=\"resume\") 或已接纳 Work Context continue 承接该 run。承接来的历史只作为运行时上下文喂给模型，**不落进本 run 的 messages.jsonl**，因此二次续跑必须沿这条链回溯收集，否则每续一次就丢掉更早那一段的历史与工具结果。与 handoffFrom 的区别：那是会话转交（用户换了对话对象），这是同一委派任务/Work Context 的接力。"
          },
          "delegation": {
            "type": "object",
            "description": "委派溯源：仅由 Delegate 工具创建/复用的 run 有值，记录本 run 由哪个 Agent 的哪个父 run 委派产生。async 场景下父消息 metadata.delegate.children 在工具返回时为空，可通过此字段反查委派链（InspectRuns 工具 action=list 依赖它过滤子 run）",
            "required": [
              "fromAgentId"
            ],
            "properties": {
              "fromAgentId": {
                "type": "string",
                "description": "发起委派的 Agent ID（delegation.fromAgentId，用户直接发起时为 owner）"
              },
              "parentRunId": {
                "type": "string",
                "description": "委派方发起委派时所在的父 run ID。由父 sessionId 经 getRunIdBySession 反查；反查失败时缺省"
              },
              "parentClientRequestId": {
                "type": "string",
                "minLength": 1,
                "description": "委派子 Run 创建时，由 ToolExecutor 从父 Agent **当前轮次**注入的可信 clientRequestId。它与可复用的 parentRunId 分开记录，用于证明子 Run 确实由父 Run 的这一轮产生；旧 Run 可缺省，但需要轮次级授权的新入口必须在缺失时失败关闭。"
              },
              "mode": {
                "type": "string",
                "enum": [
                  "sync",
                  "async",
                  "via-messaging",
                  "fan-out",
                  "subtask"
                ],
                "description": "委派模式（handoff 不写 delegation，走 handoffFrom/handoffTo 链路；worker 无独立 run）。subtask=继承发起方会话上下文的子体，历史来源另记在 subtask_inherited_from。"
              }
            },
            "additionalProperties": false
          },
          "delivery_routing": {
            "type": "object",
            "required": [
              "group",
              "audience"
            ],
            "properties": {
              "group": {
                "type": "string",
                "enum": [
                  "delegator-governed",
                  "user-handoff",
                  "run-inherited"
                ],
                "description": "委派交付路由分组：delegator-governed=先回委派方；user-handoff=目标会话直接服务用户；run-inherited=沿用目标 Run 已冻结受众。"
              },
              "audience": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "type",
                      "conversationId"
                    ],
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "user",
                        "description": "交付给当前用户可见会话。"
                      },
                      "conversationId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 512,
                        "description": "用户接收交付的稳定会话 ID。"
                      }
                    },
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "required": [
                      "type",
                      "agentId"
                    ],
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "delegator",
                        "description": "交付给发起委派的主 Agent。"
                      },
                      "agentId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256,
                        "description": "委派方规范 Agent ID。"
                      },
                      "parentRunId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256,
                        "description": "发起委派时的父 Run ID。"
                      },
                      "conversationId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 512,
                        "description": "异步结果必须回到的父会话 ID。"
                      },
                      "correlationId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256,
                        "description": "请求与最终交付的稳定关联 ID。"
                      }
                    },
                    "additionalProperties": false
                  }
                ],
                "description": "准入时冻结的真实交付受众；只允许用户会话或委派方 Agent。"
              }
            },
            "additionalProperties": false,
            "allOf": [
              {
                "if": {
                  "properties": {
                    "group": {
                      "const": "delegator-governed"
                    }
                  },
                  "required": [
                    "group"
                  ]
                },
                "then": {
                  "properties": {
                    "audience": {
                      "type": "object",
                      "required": [
                        "type",
                        "agentId"
                      ],
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "delegator",
                          "description": "交付给发起委派的主 Agent。"
                        },
                        "agentId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256,
                          "description": "委派方规范 Agent ID。"
                        },
                        "parentRunId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256,
                          "description": "发起委派时的父 Run ID。"
                        },
                        "conversationId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 512,
                          "description": "异步结果必须回到的父会话 ID。"
                        },
                        "correlationId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256,
                          "description": "请求与最终交付的稳定关联 ID。"
                        }
                      },
                      "additionalProperties": false
                    }
                  }
                }
              },
              {
                "if": {
                  "properties": {
                    "group": {
                      "const": "user-handoff"
                    }
                  },
                  "required": [
                    "group"
                  ]
                },
                "then": {
                  "properties": {
                    "audience": {
                      "type": "object",
                      "required": [
                        "type",
                        "conversationId"
                      ],
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "user",
                          "description": "交付给当前用户可见会话。"
                        },
                        "conversationId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 512,
                          "description": "用户接收交付的稳定会话 ID。"
                        }
                      },
                      "additionalProperties": false
                    }
                  }
                }
              }
            ],
            "description": "本 Run 在准入时冻结的交付路由分组与真实受众。委派/异步恢复/interject 不得根据当前激活会话重新推断；旧 Run 可缺省并按受控兼容规则只读派生。"
          },
          "subtask_inherited_from": {
            "type": "object",
            "description": "本 run 作为 subtask 子体时，继承的那份对话历史的来源坐标。与 resumedFrom 是**两条不同的边**：resumedFrom 是「同一委派任务的接力」（承接子 run 自己的历史），本字段是「继承发起方会话的上下文」（历史来自另一条时间线）。混用会让委派续跑的链校验把 subtask 的来源当成祖先去比对归属五元组，而两者的归属口径本就不同。与 resumedFrom 同一约定：继承来的历史只作为运行时上下文喂给模型，**不落进本 run 的 messages.jsonl**，因此这是事后追溯「这条 run 看过谁的上下文」的唯一依据。",
            "properties": {
              "conversation_id": {
                "type": "string",
                "description": "历史来源会话 ID（发起方有话题时用这条；跨 run 归并后的规范视图）"
              },
              "run_id": {
                "type": "string",
                "description": "历史来源 run ID（发起方本身是委派子 run、不属于任何会话时用这条）"
              }
            },
            "additionalProperties": false
          },
          "handoff_pending": {
            "type": "string",
            "readOnly": true,
            "description": "Server-recorded marker for a pending handoff. Not an access credential or a replay token."
          },
          "handoff_attempted": {
            "type": "boolean",
            "readOnly": true,
            "description": "Target startup reached a stage that may have side effects. Does not establish target completion."
          },
          "handoff_accepted": {
            "type": "boolean",
            "readOnly": true,
            "description": "The target runtime accepted the handoff. Does not establish target business completion."
          }
        },
        "additionalProperties": false
      },
      "RunRuntimeState": {
        "type": "object",
        "required": [
          "run_id",
          "agent_id",
          "status"
        ],
        "properties": {
          "run_id": {
            "type": "string",
            "description": "被查询的 Run ID；兼容普通 snake_case Run 与 checkpoint/rewind 产生的 camelCase fork Run"
          },
          "agent_id": {
            "type": "string",
            "description": "该 Run 的权威 Agent 归属，用于审阅等破坏性操作在客户端预检时核对来源"
          },
          "status": {
            "type": "string",
            "description": "Raw state returned by this HTTP endpoint: running, idle, completed or failed. A handed_off Run currently returns 404 because the route filters that state; do not infer missing data, failure or completion from 404.",
            "enum": [
              "running",
              "idle",
              "completed",
              "failed"
            ]
          }
        },
        "additionalProperties": false
      },
      "RunReceipts": {
        "type": "object",
        "required": [
          "run_id",
          "receipts"
        ],
        "properties": {
          "run_id": {
            "type": "string",
            "minLength": 1,
            "description": "当前可信用户有权读取的 Run ID。"
          },
          "receipts": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "run_id",
                "goal",
                "input",
                "output",
                "tool_calls",
                "outcome",
                "started_at",
                "completed_at"
              ],
              "properties": {
                "receipt_id": {
                  "type": "string",
                  "minLength": 1
                },
                "run_id": {
                  "type": "string",
                  "description": "关联的 Run ID"
                },
                "execution_attachment": {
                  "type": "object",
                  "required": [
                    "userId",
                    "agentId",
                    "runId"
                  ],
                  "properties": {
                    "userId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256,
                      "pattern": "^\\S+$"
                    },
                    "agentId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256,
                      "pattern": "^\\S+$",
                      "description": "执行该 Run 的权威 Agent ID。"
                    },
                    "runId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256,
                      "pattern": "^\\S+$",
                      "description": "承载本次执行的 DesireCore Run ID。"
                    },
                    "conversationId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256,
                      "pattern": "^\\S+$",
                      "description": "可选的用户可见 Conversation ID；缺失表示该 Run 不属于对话时间线。"
                    },
                    "workContextId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256,
                      "pattern": "^\\S+$",
                      "description": "可选的稳定 Work Context ID，用于跨续跑保持同一工作语境。"
                    },
                    "workflowRunId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256,
                      "pattern": "^\\S+$",
                      "description": "可选的 Workflow Run ID；与 DesireCore Run ID 正交。"
                    },
                    "cellId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256,
                      "pattern": "^\\S+$",
                      "description": "可选的执行 Cell ID，表示服务实例所在的逻辑隔离单元。"
                    },
                    "serviceInstanceId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256,
                      "pattern": "^\\S+$",
                      "description": "可选的 Agent Service 实例 ID；出现时必须同时提供其所属 cellId。"
                    },
                    "jobId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256,
                      "pattern": "^\\S+$"
                    },
                    "attemptId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256,
                      "pattern": "^\\S+$"
                    },
                    "capsuleId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256,
                      "pattern": "^\\S+$"
                    }
                  },
                  "allOf": [
                    {
                      "if": {
                        "required": [
                          "serviceInstanceId"
                        ]
                      },
                      "then": {
                        "required": [
                          "cellId"
                        ]
                      }
                    },
                    {
                      "if": {
                        "required": [
                          "attemptId"
                        ]
                      },
                      "then": {
                        "required": [
                          "jobId"
                        ]
                      }
                    },
                    {
                      "if": {
                        "required": [
                          "capsuleId"
                        ]
                      },
                      "then": {
                        "required": [
                          "jobId",
                          "attemptId"
                        ]
                      }
                    }
                  ],
                  "additionalProperties": false,
                  "description": "生成本回执的完整 ID-only 执行归属；旧回执可缺失。"
                },
                "goal": {
                  "type": "string",
                  "description": "执行目标（从用户输入中提取的任务描述）"
                },
                "input": {
                  "type": "string",
                  "description": "用户原始输入（完整的用户消息）"
                },
                "output": {
                  "type": "string",
                  "description": "最终输出文本（Agent 的完整响应）"
                },
                "tool_calls": {
                  "type": "array",
                  "description": "工具调用列表（按执行顺序排列）",
                  "items": {
                    "type": "object",
                    "required": [
                      "name"
                    ],
                    "properties": {
                      "invocation_id": {
                        "type": "string",
                        "maxLength": 256,
                        "description": "工具调用的全局唯一标识；用于在同名、重复或并行调用中准确关联开始与结束记录"
                      },
                      "name": {
                        "type": "string",
                        "description": "工具名称（如 read_file、execute_command）"
                      },
                      "input": {
                        "description": "工具输入审计摘要；新记录仅保存 param_keys，不保存参数值或凭据，旧回执可保留原结构"
                      },
                      "output_summary": {
                        "type": "string",
                        "description": "工具输出摘要（用于快速了解工具执行结果，非完整输出）"
                      },
                      "duration_ms": {
                        "type": "number",
                        "description": "执行耗时（毫秒），用于性能分析",
                        "minimum": 0
                      },
                      "started_at": {
                        "type": "string",
                        "description": "该工具调用开始时间（ISO 8601）",
                        "format": "date-time"
                      },
                      "completed_at": {
                        "type": "string",
                        "description": "该工具调用结束时间（ISO 8601）",
                        "format": "date-time"
                      },
                      "status": {
                        "type": "string",
                        "description": "工具调用执行结果：success（成功）、error（执行出错）",
                        "enum": [
                          "success",
                          "error"
                        ]
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "evidence": {
                  "type": "string",
                  "description": "决策依据（来自 thinking 或 reasoning 过程，解释 Agent 为何做出某些决策）"
                },
                "outcome": {
                  "type": "object",
                  "required": [
                    "status",
                    "auto_completed"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "description": "结果状态：success（成功完成）、partial（部分完成）、failed（执行失败）",
                      "enum": [
                        "success",
                        "partial",
                        "failed"
                      ]
                    },
                    "auto_completed": {
                      "type": "boolean",
                      "description": "是否无人工干预完成（true 表示完全自动执行，false 表示需要用户确认或修正）"
                    },
                    "user_edit_count": {
                      "type": "number",
                      "minimum": 0
                    },
                    "partial_result_available": {
                      "type": "boolean",
                      "description": "partial 回执是否包含可直接展示的已完成阶段结果，而不是空占位"
                    },
                    "pending_synthesis": {
                      "type": "boolean",
                      "description": "是否仍需基于已完成工具事实生成最终业务解释；恢复时不得因此重复执行成功工具"
                    }
                  },
                  "additionalProperties": false
                },
                "started_at": {
                  "type": "string",
                  "description": "开始时间（ISO 8601 格式）",
                  "format": "date-time"
                },
                "completed_at": {
                  "type": "string",
                  "description": "完成时间（ISO 8601 格式）",
                  "format": "date-time"
                },
                "duration_ms": {
                  "type": "number",
                  "description": "总耗时（毫秒），从开始到完成的完整时间",
                  "minimum": 0
                },
                "usage": {
                  "type": "object",
                  "properties": {
                    "input_tokens": {
                      "type": "number",
                      "description": "本次查询的非缓存输入 token 数（不含 cache_read / cache_write；per-query delta，不累计）",
                      "minimum": 0
                    },
                    "output_tokens": {
                      "type": "number",
                      "description": "本次查询的输出 token 数（per-query delta，不累计）",
                      "minimum": 0
                    },
                    "cost_usd": {
                      "type": "number",
                      "description": "本次查询的成本（美元，已包含缓存费用；per-query delta，不累计）",
                      "minimum": 0
                    },
                    "provider": {
                      "type": "string",
                      "description": "使用的提供商标识（如 openai、anthropic）"
                    },
                    "model": {
                      "type": "string",
                      "description": "使用的模型 ID（如 gpt-5-mini、claude-sonnet-4）"
                    },
                    "cache_read_tokens": {
                      "type": "number",
                      "description": "本次查询从 prompt 缓存读取的 token 数（per-query delta，不累计）",
                      "minimum": 0
                    },
                    "cache_write_tokens": {
                      "type": "number",
                      "description": "本次查询写入 prompt 缓存的 token 数（per-query delta，不累计）",
                      "minimum": 0
                    }
                  },
                  "additionalProperties": false
                },
                "route_decision": {
                  "type": "object",
                  "additionalProperties": true
                },
                "interruption_reason": {
                  "type": "string",
                  "description": "本条 partial 回执对应的主动中止原因。旧回执无此字段，保持向后兼容",
                  "enum": [
                    "user_abort",
                    "agent_interrupt",
                    "reset",
                    "system_suspend",
                    "process_shutdown",
                    "process_restart",
                    "orphan_reclaimed",
                    "background_timeout"
                  ]
                }
              },
              "additionalProperties": false
            },
            "description": "该 Run 的结构化回执，按写入顺序。"
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "description": "分页读取时该 Run 的有效 Receipt 总数。"
          },
          "offset": {
            "type": "integer",
            "minimum": 0,
            "description": "从最新 Receipt 向前跳过的数量。"
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "description": "本页最多返回的 Receipt 数。"
          },
          "has_more": {
            "type": "boolean",
            "description": "是否仍有更早的 Receipt 可按需加载。"
          },
          "skipped": {
            "type": "integer",
            "minimum": 0,
            "description": "流式读取中跳过的损坏或超大行数。"
          }
        },
        "additionalProperties": false,
        "description": "单个用户可见 Run 的 Receipt 响应。"
      },
      "AgentList": {
        "type": "object",
        "required": [
          "agents"
        ],
        "properties": {
          "agents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentSummary"
            }
          }
        },
        "additionalProperties": false
      },
      "RunList": {
        "type": "object",
        "required": [
          "runs"
        ],
        "properties": {
          "runs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RunMeta"
            }
          }
        },
        "additionalProperties": false
      },
      "OperationsError": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "QueryStartRequest": {
        "type": "object",
        "anyOf": [
          {
            "required": [
              "prompt"
            ],
            "properties": {
              "prompt": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          {
            "required": [
              "mediaRefs"
            ],
            "properties": {
              "mediaRefs": {
                "type": "array",
                "minItems": 1
              }
            }
          }
        ],
        "properties": {
          "prompt": {
            "type": "string",
            "description": "当前用户提交的提示词。"
          },
          "options": {
            "type": "object",
            "properties": {
              "routingMode": {
                "type": "string",
                "enum": [
                  "smart",
                  "fixed"
                ],
                "description": "模型路由模式。"
              },
              "cwd": {
                "type": "string",
                "description": "当前轮授权工作目录。"
              },
              "systemPrompt": {
                "type": "string",
                "description": "调用方附加的系统提示词。"
              },
              "allowedTools": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "允许的工具 ID。"
              },
              "disallowedTools": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "禁止的工具 ID。"
              },
              "maxTurns": {
                "type": "number",
                "description": "最大 Agent 回合数。"
              },
              "model": {
                "type": "string",
                "description": "模型名称。"
              },
              "engine": {
                "const": "desirecore-engine",
                "description": "运行时引擎。"
              },
              "provider": {
                "type": "string",
                "description": "Provider 协议族。"
              },
              "providerId": {
                "type": "string",
                "description": "Provider 唯一 ID。"
              },
              "apiKey": {
                "type": "string",
                "deprecated": true,
                "description": "Compatibility-only provider credential override. Configure provider credentials on the instance; this field does not authenticate the HTTP request."
              },
              "reasoning": {
                "type": "string",
                "description": "本轮 reasoning 模式。"
              },
              "reasoningDefault": {
                "type": "string"
              },
              "suppressThinking": {
                "type": "boolean",
                "description": "仅隐藏公开思考展示，不改变模型思考强度或服务端私有协议回放。"
              },
              "immersiveVoice": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "modelSource",
                  "reasoning"
                ],
                "properties": {
                  "modelSource": {
                    "type": "string",
                    "enum": [
                      "conversation",
                      "fast",
                      "specified"
                    ],
                    "description": "当前对话、低延迟默认映射或人类指定的精确模型；低延迟不代表低费用。"
                  },
                  "providerId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256,
                    "description": "specified 时使用的本地 Provider 接入面 ID。"
                  },
                  "modelName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256,
                    "description": "specified 时使用的精确模型 ID。"
                  },
                  "reasoning": {
                    "type": "string",
                    "enum": [
                      "follow",
                      "low-latency",
                      "auto",
                      "off",
                      "minimal",
                      "low",
                      "medium",
                      "high",
                      "xhigh",
                      "max"
                    ],
                    "description": "follow 沿用对话；low-latency 只选择模型显式支持的最低档位；其他值为独立思考强度，不受显示思考开关影响。"
                  }
                }
              },
              "voiceSelectionRef": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "agentId": {
                "type": "string",
                "description": "当前 Agent ID。"
              },
              "conversationHistory": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/QueryStartRequest/definitions/conversationMessage"
                },
                "description": "多轮连续性使用的结构化历史。"
              },
              "conversationId": {
                "type": "string",
                "description": "对话稳定 ID。"
              },
              "resumeFromDisk": {
                "type": "boolean",
                "description": "是否优先从磁盘恢复权威结构化历史。"
              },
              "preferredRunId": {
                "type": "string",
                "description": "用户显式选择的恢复分支 run ID。"
              },
              "excludeMessageIds": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "恢复时剔除的本轮重发消息 ID。"
              },
              "channel": {
                "type": "string",
                "description": "消息来源渠道。"
              },
              "skillIds": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "本轮显式选择的 Skill ID。"
              },
              "skillArgs": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "本轮 Skill 命令参数。"
              },
              "fileReferences": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "用户引用的文件路径。"
              },
              "activeDocPath": {
                "type": "string",
                "description": "本次请求的可选文件参考路径。自动采集仅来自本窗口、属于当前会话的可见文档；显式传入或重试沿用已冻结的引用，不按当下界面重选。读取仍须授权，引用本身不表示编辑或附件交付请求。"
              },
              "file": {
                "type": "object",
                "required": [
                  "name",
                  "size",
                  "type"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "附件名称。"
                  },
                  "size": {
                    "type": "string",
                    "description": "附件展示大小。"
                  },
                  "type": {
                    "type": "string",
                    "description": "附件类型。"
                  }
                },
                "additionalProperties": false
              },
              "teamId": {
                "type": "string",
                "description": "当前团队 ID。"
              }
            },
            "additionalProperties": false
          },
          "agentReferences": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "occurrence_id",
                "target",
                "range"
              ],
              "properties": {
                "occurrence_id": {
                  "type": "string",
                  "minLength": 8,
                  "maxLength": 256,
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$",
                  "description": "客户端生成、在一次来源 revision 内稳定的 occurrence ID；同一 Agent 可出现多次。"
                },
                "target": {
                  "type": "object",
                  "required": [
                    "agent_id",
                    "display_name_snapshot"
                  ],
                  "properties": {
                    "agent_id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128,
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$",
                      "description": "目标 Agent 的稳定语义 ID；仅允许 ASCII 字母、数字、下划线和连字符。"
                    },
                    "display_name_snapshot": {
                      "type": "string",
                      "minLength": 1,
                      "description": "服务端按 agent_id 从可信 Agent Registry 重建的显示快照；客户端同名字段只用于提交时 range 校验，不参与身份或 system prompt。"
                    }
                  },
                  "additionalProperties": false,
                  "description": "稳定 Agent 引用；是否执行由来源契约决定，显示名不能单独触发投递。"
                },
                "range": {
                  "type": "object",
                  "required": [
                    "start",
                    "end"
                  ],
                  "properties": {
                    "start": {
                      "type": "integer",
                      "minimum": 0,
                      "description": "正文 UTF-16 code unit 的起始偏移，包含。"
                    },
                    "end": {
                      "type": "integer",
                      "minimum": 1,
                      "description": "正文 UTF-16 code unit 的结束偏移，不包含。"
                    }
                  },
                  "additionalProperties": false,
                  "description": "结构化 token 在来源正文中的半开区间；服务端校验 start < end 且与正文匹配。"
                }
              },
              "additionalProperties": false,
              "description": "picker 生成的结构化 Agent token；聊天中为非执行引用，看板中可由来源 owner 形成 Mention。"
            },
            "description": "非执行 Agent 引用。"
          },
          "mentionOccurrences": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "occurrence_id",
                "target",
                "range"
              ],
              "properties": {
                "occurrence_id": {
                  "type": "string",
                  "minLength": 8,
                  "maxLength": 256,
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$",
                  "description": "客户端生成、在一次来源 revision 内稳定的 occurrence ID；同一 Agent 可出现多次。"
                },
                "target": {
                  "type": "object",
                  "required": [
                    "agent_id",
                    "display_name_snapshot"
                  ],
                  "properties": {
                    "agent_id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128,
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$",
                      "description": "目标 Agent 的稳定语义 ID；仅允许 ASCII 字母、数字、下划线和连字符。"
                    },
                    "display_name_snapshot": {
                      "type": "string",
                      "minLength": 1,
                      "description": "服务端按 agent_id 从可信 Agent Registry 重建的显示快照；客户端同名字段只用于提交时 range 校验，不参与身份或 system prompt。"
                    }
                  },
                  "additionalProperties": false,
                  "description": "稳定 Agent 引用；是否执行由来源契约决定，显示名不能单独触发投递。"
                },
                "range": {
                  "type": "object",
                  "required": [
                    "start",
                    "end"
                  ],
                  "properties": {
                    "start": {
                      "type": "integer",
                      "minimum": 0,
                      "description": "正文 UTF-16 code unit 的起始偏移，包含。"
                    },
                    "end": {
                      "type": "integer",
                      "minimum": 1,
                      "description": "正文 UTF-16 code unit 的结束偏移，不包含。"
                    }
                  },
                  "additionalProperties": false,
                  "description": "结构化 token 在来源正文中的半开区间；服务端校验 start < end 且与正文匹配。"
                }
              },
              "additionalProperties": false,
              "description": "picker 生成的结构化 Agent token；聊天中为非执行引用，看板中可由来源 owner 形成 Mention。"
            },
            "description": "Retired execution input; the HTTP route rejects this field. Use non-executable agentReferences.",
            "deprecated": true
          },
          "mentionRecipientRequests": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "occurrence_ids",
                "recipient_agent_id",
                "route"
              ],
              "properties": {
                "occurrence_ids": {
                  "type": "array",
                  "minItems": 1,
                  "uniqueItems": true,
                  "items": {
                    "type": "string",
                    "minLength": 8,
                    "maxLength": 256
                  },
                  "description": "同一来源 revision 中指向该 recipient 的全部 occurrence IDs；只产生一个 delivery。"
                },
                "recipient_agent_id": {
                  "type": "string",
                  "minLength": 1,
                  "description": "必须与 occurrence.target.agent_id 一致的稳定 Agent ID。"
                },
                "route": {
                  "type": "string",
                  "enum": [
                    "current_conversation",
                    "external_agent"
                  ],
                  "description": "当前 Agent 走普通 conversation；非当前 Agent 走独立 Mention delivery。"
                },
                "context_selection": {
                  "allOf": [
                    {
                      "type": "object",
                      "required": [
                        "context_mode",
                        "origin"
                      ],
                      "properties": {
                        "context_mode": {
                          "type": "string",
                          "enum": [
                            "continue",
                            "isolated",
                            "fork"
                          ],
                          "description": "必填且无默认值：continue=继续明确存在的同一任务上下文；isolated=不同新任务；fork=同一任务有意分叉。"
                        },
                        "origin": {
                          "type": "string",
                          "enum": [
                            "delegate",
                            "mention",
                            "task",
                            "workflow",
                            "schedule",
                            "webhook",
                            "decision",
                            "legacy"
                          ]
                        },
                        "work_context_id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256,
                          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
                          "description": "continue 必填：要继续的稳定 Work Context ID；禁止回退到目标 Agent 最近一次会话。"
                        },
                        "source_work_context_id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256,
                          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
                          "description": "fork 必填：有意分叉的来源 Work Context ID。"
                        },
                        "task_ref": {
                          "type": "object",
                          "required": [
                            "board_id",
                            "task_id"
                          ],
                          "properties": {
                            "board_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "task_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "TaskBoard 内稳定 Task ID。"
                            },
                            "task_version": {
                              "type": "integer",
                              "minimum": 1,
                              "description": "选择时观察到的 Task 版本快照；身份查重只使用 board_id + task_id。"
                            }
                          },
                          "additionalProperties": false
                        },
                        "intent_id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "context_reason": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 2000,
                          "description": "isolated/fork 必填：说明为何这是不同新任务或为何允许对同一 Task 有意分叉。"
                        }
                      },
                      "allOf": [
                        {
                          "if": {
                            "properties": {
                              "context_mode": {
                                "const": "continue"
                              }
                            },
                            "required": [
                              "context_mode"
                            ]
                          },
                          "then": {
                            "required": [
                              "work_context_id"
                            ],
                            "not": {
                              "anyOf": [
                                {
                                  "required": [
                                    "source_work_context_id"
                                  ]
                                },
                                {
                                  "required": [
                                    "intent_id"
                                  ]
                                }
                              ]
                            }
                          }
                        },
                        {
                          "if": {
                            "properties": {
                              "context_mode": {
                                "const": "isolated"
                              }
                            },
                            "required": [
                              "context_mode"
                            ]
                          },
                          "then": {
                            "required": [
                              "context_reason"
                            ],
                            "anyOf": [
                              {
                                "required": [
                                  "task_ref"
                                ]
                              },
                              {
                                "required": [
                                  "intent_id"
                                ]
                              }
                            ],
                            "not": {
                              "anyOf": [
                                {
                                  "required": [
                                    "work_context_id"
                                  ]
                                },
                                {
                                  "required": [
                                    "source_work_context_id"
                                  ]
                                }
                              ]
                            }
                          }
                        },
                        {
                          "if": {
                            "properties": {
                              "context_mode": {
                                "const": "fork"
                              }
                            },
                            "required": [
                              "context_mode"
                            ]
                          },
                          "then": {
                            "required": [
                              "source_work_context_id",
                              "task_ref",
                              "context_reason"
                            ],
                            "not": {
                              "anyOf": [
                                {
                                  "required": [
                                    "work_context_id"
                                  ]
                                },
                                {
                                  "required": [
                                    "intent_id"
                                  ]
                                }
                              ]
                            }
                          }
                        }
                      ],
                      "additionalProperties": false,
                      "description": "一次执行如何选择 Work Context；调用方必须显式提交，系统只能推荐不能代填。"
                    },
                    {
                      "type": "object",
                      "required": [
                        "origin"
                      ],
                      "properties": {
                        "origin": {
                          "type": "string",
                          "const": "mention",
                          "description": "Mention 外部投递只能创建 origin=mention 的 Work Context lineage。"
                        }
                      }
                    }
                  ],
                  "description": "非当前 recipient 单独提交的显式 Work Context selection；没有默认模式。"
                },
                "retry_of_delivery_id": {
                  "type": "string",
                  "minLength": 1,
                  "description": "用户显式重新呼叫时引用旧 delivery；普通传输重试不得填写。"
                }
              },
              "allOf": [
                {
                  "if": {
                    "properties": {
                      "route": {
                        "const": "current_conversation"
                      }
                    },
                    "required": [
                      "route"
                    ]
                  },
                  "then": {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "context_selection"
                          ]
                        },
                        {
                          "required": [
                            "retry_of_delivery_id"
                          ]
                        }
                      ]
                    }
                  }
                },
                {
                  "if": {
                    "properties": {
                      "route": {
                        "const": "external_agent"
                      }
                    },
                    "required": [
                      "route"
                    ]
                  },
                  "then": {
                    "required": [
                      "context_selection"
                    ]
                  }
                }
              ],
              "additionalProperties": false,
              "description": "每个唯一 recipient 的确定性路由；多个显示 occurrence 共用一套显式 selection。"
            },
            "description": "Retired execution input; the HTTP route rejects this field.",
            "deprecated": true
          },
          "mediaRefs": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "type",
                "mediaId",
                "name",
                "mimeType",
                "size"
              ],
              "properties": {
                "type": {
                  "type": "string",
                  "description": "媒体业务类型。"
                },
                "mediaId": {
                  "type": "string",
                  "description": "媒体存储引用。"
                },
                "name": {
                  "type": "string",
                  "description": "原始文件名。"
                },
                "mimeType": {
                  "type": "string",
                  "description": "媒体 MIME 类型。"
                },
                "size": {
                  "type": "number",
                  "description": "媒体字节数。"
                }
              },
              "additionalProperties": true
            },
            "description": "本轮媒体附件引用。"
          },
          "images": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "data",
                "mimeType"
              ],
              "properties": {
                "data": {
                  "type": "string",
                  "description": "已废弃 Base64 图片数据。"
                },
                "mimeType": {
                  "type": "string",
                  "description": "图片 MIME 类型。"
                }
              },
              "additionalProperties": false
            },
            "description": "已废弃内联图片附件。"
          },
          "clientRequestId": {
            "type": "string",
            "description": "客户端一次提交及其传输重试的稳定 ID。"
          },
          "userMessageId": {
            "type": "string"
          },
          "requestDigest": {
            "type": "string",
            "maxLength": 128,
            "description": "Optional digest produced by the shared request-body algorithm. The service recomputes it to reject reuse of a request ID with a changed business body."
          },
          "originSocketId": {
            "type": "string",
            "description": "Current connected Socket.IO socket.id for precise event delivery; HTTP and Socket authentication must identify the same principal."
          },
          "uiContextAdmission": {
            "type": "object",
            "required": [
              "version",
              "admissionRef"
            ],
            "properties": {
              "version": {
                "type": "integer",
                "const": 1,
                "description": "Version of the durable UI context admission-reference envelope."
              },
              "admissionRef": {
                "type": "string",
                "minLength": 56,
                "maxLength": 56,
                "pattern": "^ui_admission_[A-Za-z0-9_-]{43}$",
                "description": "Opaque durable reference to an immutable admitted turn-context sidecar; it contains no snapshot, token, host identity, path, URL, or user text."
              }
            },
            "additionalProperties": false,
            "description": "A valid context admission reference from an authorized UI flow. Ordinary standalone scripts omit it."
          },
          "appWorkAdmissionRef": {
            "type": "string",
            "pattern": "^apa_[A-Za-z0-9_-]{43}$",
            "maxLength": 512,
            "description": "Opaque reference supplied by an authorized application proposal flow. Standalone integration examples omit it; an arbitrary reference does not grant authority."
          }
        },
        "definitions": {
          "conversationContentBlock": {
            "type": "object",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "text",
                  "tool_use",
                  "tool_result",
                  "image",
                  "thinking"
                ],
                "description": "结构化历史内容块类型。"
              },
              "text": {
                "type": "string",
                "description": "文本块正文。"
              },
              "id": {
                "type": "string",
                "description": "tool_use 块 ID。"
              },
              "name": {
                "type": "string",
                "description": "工具名称。"
              },
              "input": {
                "description": "工具输入 JSON。"
              },
              "tool_use_id": {
                "type": "string",
                "description": "tool_result 对应的 tool_use ID。"
              },
              "content": {
                "description": "工具结果文本或嵌套结构化内容块。",
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/QueryStartRequest/definitions/conversationContentBlock"
                    }
                  }
                ]
              },
              "is_error": {
                "type": "boolean",
                "description": "工具结果是否表示错误。"
              },
              "source": {
                "type": "object",
                "required": [
                  "type",
                  "media_type",
                  "data"
                ],
                "properties": {
                  "type": {
                    "const": "base64",
                    "description": "图片数据编码类型。"
                  },
                  "media_type": {
                    "type": "string",
                    "description": "图片 MIME 类型。"
                  },
                  "data": {
                    "type": "string",
                    "description": "Base64 图片数据。"
                  }
                },
                "additionalProperties": false
              },
              "thinking": {
                "type": "string",
                "description": "Provider thinking 正文。"
              }
            },
            "additionalProperties": false,
            "description": "Query conversationHistory 中的结构化内容块。"
          },
          "conversationMessage": {
            "type": "object",
            "required": [
              "role",
              "content"
            ],
            "properties": {
              "role": {
                "type": "string",
                "enum": [
                  "user",
                  "assistant",
                  "system"
                ],
                "description": "消息角色；system 仅用于受控上下文边界 marker。"
              },
              "content": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/QueryStartRequest/definitions/conversationContentBlock"
                },
                "description": "结构化消息内容。"
              },
              "timestamp": {
                "type": "number",
                "description": "消息时间戳（毫秒）。"
              },
              "id": {
                "type": "string",
                "description": "SessionMessage 空间中的稳定消息 ID。"
              },
              "compactCutoff": {
                "type": "boolean",
                "description": "压缩摘要边界 marker。"
              },
              "summarizedCount": {
                "type": "number",
                "description": "本次摘要覆盖的消息数。"
              },
              "compactedAt": {
                "type": "string",
                "format": "date-time",
                "description": "压缩发生时间。"
              },
              "compactAnchorMessageId": {
                "type": "string",
                "description": "压缩后保留区第一条消息 ID。"
              },
              "compactKeptTurns": {
                "type": "number",
                "description": "压缩后保留的对话轮数。"
              },
              "compactCoverStartMessageId": {
                "type": "string",
                "description": "本 marker 覆盖区第一条消息 ID。"
              },
              "compactRunId": {
                "type": "string",
                "description": "老 marker 的覆盖 run。"
              },
              "compactMerged": {
                "type": "boolean",
                "description": "是否为摘要链二级合并产物。"
              },
              "compactSupersedes": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "被本 marker 取代的 marker ID 列表。"
              },
              "compactTrigger": {
                "type": "string",
                "enum": [
                  "auto",
                  "manual"
                ],
                "description": "压缩由自动阈值还是用户显式触发。"
              },
              "compactWindow": {
                "type": "number",
                "description": "生成自动压缩 marker 时的有效上下文窗口。"
              },
              "contextReset": {
                "type": "boolean",
                "description": "不携带摘要的显式遗忘边界。"
              },
              "resetAnchorMessageId": {
                "type": "string",
                "description": "触发 reset 的 user 消息 ID。"
              },
              "resetReason": {
                "type": "string",
                "description": "reset 的用户可见原因。"
              },
              "fileReferences": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "用户引用的文件路径。"
              },
              "mediaRefs": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "mediaId"
                  ],
                  "properties": {
                    "mediaId": {
                      "type": "string",
                      "description": "媒体存储中的稳定引用。"
                    },
                    "mimeType": {
                      "type": "string",
                      "description": "媒体 MIME 类型。"
                    },
                    "type": {
                      "type": "string",
                      "description": "媒体业务类型。"
                    }
                  },
                  "additionalProperties": false
                },
                "description": "历史消息引用的媒体。"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false,
        "not": {
          "anyOf": [
            {
              "required": [
                "mentionOccurrences"
              ]
            },
            {
              "required": [
                "mentionRecipientRequests"
              ]
            }
          ]
        }
      },
      "QueryAdmission": {
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "description": "请求是否已被准入。"
          },
          "clientRequestId": {
            "type": "string",
            "description": "对应的客户端请求 ID。"
          },
          "duplicate": {
            "type": "boolean",
            "description": "是否命中幂等重复请求。"
          },
          "busy": {
            "type": "boolean",
            "description": "准入被竞争挡下而非失败，仅两种来源：会话清除窗口（query:start、HTTP start、follow-up；清除结束后可用同一 clientRequestId 重试）与同一 session 已有 continue 在执行（仅 query:continue）。start 准入只有清除窗口会置位，客户端据此区分清除与其它 retryable 拒绝；缺省或 false 不代表清除。"
          },
          "error": {
            "type": "string",
            "description": "拒绝时的稳定错误说明。"
          },
          "code": {
            "type": "string",
            "description": "稳定拒绝码，如 CLIENT_REQUEST_BODY_MISMATCH（同 ID 不同请求体，不可重试）。"
          },
          "retryable": {
            "type": "boolean",
            "description": "是否允许用同一 clientRequestId 重试。"
          },
          "uiContextFaultCode": {
            "type": "string",
            "enum": [
              "snapshot_missing",
              "snapshot_stale",
              "surface_mismatch",
              "auth_required",
              "human_required",
              "redaction_blocked",
              "adapter_invalid",
              "snapshot_conflict",
              "protocol_unsupported",
              "host_unavailable",
              "action_unavailable",
              "action_failed",
              "action_outcome_unknown",
              "action_capacity_exceeded"
            ],
            "description": "Stable fail-closed UI context protocol fault code."
          },
          "sessionId": {
            "type": "string",
            "description": "已建立或已存在的 session ID。"
          }
        },
        "additionalProperties": false,
        "description": "Socket.IO query:start 与 HTTP start 的准入响应。"
      },
      "QueryFollowUpRequest": {
        "type": "object",
        "required": [
          "sessionId",
          "originSocketId",
          "message"
        ],
        "properties": {
          "sessionId": {
            "type": "string"
          },
          "originSocketId": {
            "type": "string",
            "minLength": 1,
            "description": "Current connected socket.id, authenticated as the same principal as the HTTP request."
          },
          "message": {
            "type": "object",
            "required": [
              "role",
              "content"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "role": {
                "type": "string",
                "enum": [
                  "user",
                  "assistant"
                ]
              },
              "content": {
                "type": "string"
              },
              "timestamp": {
                "type": "number"
              }
            },
            "additionalProperties": true
          },
          "clientRequestId": {
            "type": "string"
          },
          "requestDigest": {
            "type": "string"
          },
          "mediaRefs": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "type",
                "mediaId",
                "name",
                "mimeType",
                "size"
              ],
              "properties": {
                "type": {
                  "type": "string",
                  "description": "媒体业务类型。"
                },
                "mediaId": {
                  "type": "string",
                  "description": "媒体存储引用。"
                },
                "name": {
                  "type": "string",
                  "description": "原始文件名。"
                },
                "mimeType": {
                  "type": "string",
                  "description": "媒体 MIME 类型。"
                },
                "size": {
                  "type": "number",
                  "description": "媒体字节数。"
                }
              },
              "additionalProperties": true
            },
            "description": "本轮媒体附件引用。"
          },
          "images": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "data",
                "mimeType"
              ],
              "properties": {
                "data": {
                  "type": "string",
                  "description": "已废弃 Base64 图片数据。"
                },
                "mimeType": {
                  "type": "string",
                  "description": "图片 MIME 类型。"
                }
              },
              "additionalProperties": false
            },
            "description": "已废弃内联图片附件。"
          },
          "fileReferences": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "activeDocPath": {
            "type": "string"
          },
          "reasoning": {
            "type": "string"
          },
          "agentReferences": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "occurrence_id",
                "target",
                "range"
              ],
              "properties": {
                "occurrence_id": {
                  "type": "string",
                  "minLength": 8,
                  "maxLength": 256,
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$",
                  "description": "客户端生成、在一次来源 revision 内稳定的 occurrence ID；同一 Agent 可出现多次。"
                },
                "target": {
                  "type": "object",
                  "required": [
                    "agent_id",
                    "display_name_snapshot"
                  ],
                  "properties": {
                    "agent_id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128,
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$",
                      "description": "目标 Agent 的稳定语义 ID；仅允许 ASCII 字母、数字、下划线和连字符。"
                    },
                    "display_name_snapshot": {
                      "type": "string",
                      "minLength": 1,
                      "description": "服务端按 agent_id 从可信 Agent Registry 重建的显示快照；客户端同名字段只用于提交时 range 校验，不参与身份或 system prompt。"
                    }
                  },
                  "additionalProperties": false,
                  "description": "稳定 Agent 引用；是否执行由来源契约决定，显示名不能单独触发投递。"
                },
                "range": {
                  "type": "object",
                  "required": [
                    "start",
                    "end"
                  ],
                  "properties": {
                    "start": {
                      "type": "integer",
                      "minimum": 0,
                      "description": "正文 UTF-16 code unit 的起始偏移，包含。"
                    },
                    "end": {
                      "type": "integer",
                      "minimum": 1,
                      "description": "正文 UTF-16 code unit 的结束偏移，不包含。"
                    }
                  },
                  "additionalProperties": false,
                  "description": "结构化 token 在来源正文中的半开区间；服务端校验 start < end 且与正文匹配。"
                }
              },
              "additionalProperties": false,
              "description": "picker 生成的结构化 Agent token；聊天中为非执行引用，看板中可由来源 owner 形成 Mention。"
            },
            "description": "非执行 Agent 引用。"
          },
          "uiContextAdmission": {
            "type": "object",
            "required": [
              "version",
              "admissionRef"
            ],
            "properties": {
              "version": {
                "type": "integer",
                "const": 1,
                "description": "Version of the durable UI context admission-reference envelope."
              },
              "admissionRef": {
                "type": "string",
                "minLength": 56,
                "maxLength": 56,
                "pattern": "^ui_admission_[A-Za-z0-9_-]{43}$",
                "description": "Opaque durable reference to an immutable admitted turn-context sidecar; it contains no snapshot, token, host identity, path, URL, or user text."
              }
            },
            "additionalProperties": false,
            "description": "Only UI context object allowed on an actual query or pending record; omitting the entire field preserves the legacy no-context path."
          }
        },
        "additionalProperties": true,
        "description": "Documented request subset from the route interface. Additional fields do not imply authorization or guaranteed support.",
        "not": {
          "anyOf": [
            {
              "required": [
                "mentionOccurrences"
              ]
            },
            {
              "required": [
                "mentionRecipientRequests"
              ]
            }
          ]
        }
      },
      "ClientRequestLookupRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "agentId",
          "requests"
        ],
        "description": "按 clientRequestId 只读查询服务端接纳状态；不占位、不清理、不产生任何副作用。",
        "properties": {
          "agentId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "\\S"
          },
          "conversationId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "\\S"
          },
          "requests": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "description": "要查询的提交列表，每项一个 clientRequestId。",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "clientRequestId"
              ],
              "properties": {
                "clientRequestId": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256,
                  "pattern": "\\S",
                  "description": "客户端一次提交及其全部重发共用的稳定 ID。"
                },
                "userMessageId": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256,
                  "pattern": "\\S"
                }
              }
            }
          }
        }
      },
      "ClientRequestLookupResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "protocolVersion",
          "serverInstanceId",
          "observedAt",
          "autoReplayRetentionMs",
          "tombstoneRetentionMs",
          "results"
        ],
        "description": "只读接纳查询结果。",
        "properties": {
          "protocolVersion": {
            "type": "integer",
            "const": 1,
            "description": "查询协议版本。"
          },
          "serverInstanceId": {
            "type": "string",
            "description": "当前 Agent Service 进程代际 ID；与恢复快照同源，重启即变化。"
          },
          "observedAt": {
            "type": "string",
            "format": "date-time",
            "description": "服务端观察时刻（ISO 8601），客户端用于抵御本地墙钟回拨。"
          },
          "autoReplayRetentionMs": {
            "type": "integer",
            "minimum": 0,
            "description": "客户端同 ID 自动重放窗口（毫秒）。"
          },
          "tombstoneRetentionMs": {
            "type": "integer",
            "minimum": 0,
            "description": "服务端幂等 tombstone 保护窗口（毫秒）；超出后查询结论不可信。"
          },
          "results": {
            "type": "array",
            "description": "与请求一一对应（按 clientRequestId）。",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "clientRequestId",
                "status"
              ],
              "properties": {
                "clientRequestId": {
                  "type": "string",
                  "description": "被查询的 clientRequestId。"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "committed",
                    "reserved",
                    "absent",
                    "unknown"
                  ],
                  "description": "committed=已持久提交（至多一次，原 ID 不会再执行）；reserved=当前服务进程内占位中（排队或正在做提交前复检）；absent=截至此刻既无提交也无占位（原请求可能仍在路上，必须同 ID 重发由服务端裁决）；unknown=无法判定（旧版无作用域记录、存储不可读或注册表 fail closed）。"
                },
                "committedAt": {
                  "type": "string",
                  "format": "date-time",
                  "description": "status=committed 时的持久提交时刻。"
                },
                "sessionId": {
                  "type": "string"
                },
                "committedServerInstance": {
                  "type": "string",
                  "enum": [
                    "current",
                    "previous",
                    "unknown"
                  ]
                },
                "executionWitness": {
                  "type": "string",
                  "enum": [
                    "user-message",
                    "none",
                    "unknown"
                  ],
                  "description": "user-message=磁盘已有该提交的用户消息（执行过）；none=没有；unknown=无法查证（缺 userMessageId 或存储不可读）。"
                }
              }
            }
          }
        }
      },
      "WebhookManagement": {
        "type": "object",
        "required": [
          "enabled",
          "hasSecret",
          "events",
          "availableTools"
        ],
        "additionalProperties": false,
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "hasSecret": {
            "type": "boolean",
            "description": "是否已有非空 secret；读取不返回其值。"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "event",
                "promptTemplate",
                "maxTurns",
                "toolIds"
              ],
              "additionalProperties": false,
              "properties": {
                "event": {
                  "type": "string"
                },
                "promptTemplate": {
                  "type": "string"
                },
                "maxTurns": {
                  "type": "number"
                },
                "toolIds": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "availableTools": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "id",
                "name",
                "riskLevel",
                "requiresConfirmation"
              ],
              "additionalProperties": false,
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "riskLevel": {
                  "type": "string",
                  "enum": [
                    "low",
                    "medium",
                    "high"
                  ]
                },
                "requiresConfirmation": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      },
      "WebhookEventWrite": {
        "type": "object",
        "required": [
          "promptTemplate",
          "toolIds"
        ],
        "properties": {
          "promptTemplate": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32768,
            "pattern": "\\S",
            "description": "事件提示模板，{{key}} 从 payload 的顶层字段取值。"
          },
          "toolIds": {
            "type": "array",
            "maxItems": 512,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "description": "从管理读取返回的 availableTools 中选择工具 ID；空数组表示不授权任何工具。"
          },
          "maxTurns": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "description": "事件最多执行的模型轮次数，省略时为 5。",
            "default": 5
          }
        },
        "additionalProperties": false
      },
      "WebhookEventWritten": {
        "type": "object",
        "required": [
          "success",
          "event",
          "enabled"
        ],
        "additionalProperties": false,
        "properties": {
          "success": {
            "const": true
          },
          "event": {
            "type": "string"
          },
          "enabled": {
            "const": true
          },
          "secret": {
            "type": "string",
            "description": "仅在本次首次生成 secret 时返回；保存修改已有事件不会再次返回。"
          }
        }
      },
      "WebhookEnabledRequest": {
        "type": "object",
        "required": [
          "enabled"
        ],
        "additionalProperties": false,
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "开启或暂停该智能体已有 Webhook 事件。"
          }
        }
      },
      "WebhookEnabledResponse": {
        "type": "object",
        "required": [
          "success",
          "enabled"
        ],
        "additionalProperties": false,
        "properties": {
          "success": {
            "const": true
          },
          "enabled": {
            "type": "boolean"
          }
        }
      },
      "WebhookSecretRotation": {
        "type": "object",
        "required": [
          "secret"
        ],
        "additionalProperties": false,
        "properties": {
          "secret": {
            "type": "string",
            "minLength": 43,
            "maxLength": 43
          }
        }
      },
      "ManagementError": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "details": {
            "type": "array",
            "items": {}
          }
        },
        "additionalProperties": false
      },
      "ScheduleMessage": {
        "type": "object",
        "additionalProperties": false,
        "description": "完整的可见调度消息契约；授权快照、正文、附件引用和收件人均接受运行时验证。",
        "required": [
          "id",
          "scheduleId",
          "authorizationScope",
          "text",
          "isError",
          "timestamp"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "description": "可信结果路由给出的稳定、非授权标识。"
          },
          "recipientUserId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "description": "可信结果路由给出的稳定、非授权标识。"
          },
          "origin": {
            "enum": [
              "schedule",
              "webhook"
            ],
            "description": "旧记录未声明时按 schedule 显示。"
          },
          "scheduleId": {
            "type": "string",
            "description": "所属调度标识；不是执行授权。"
          },
          "occurrenceId": {
            "type": "string",
            "description": "结果所属稳定发生标识，不能单凭它重新执行。"
          },
          "authorizationScope": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind"
                ],
                "properties": {
                  "kind": {
                    "const": "agent",
                    "description": "Agent 作用域；结果还需精确收件人校验。"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "boardId",
                  "bindingId"
                ],
                "properties": {
                  "kind": {
                    "const": "taskboard",
                    "description": "保持原 TaskBoard 来源 ACL，不能退化为普通 Agent 作用域。"
                  },
                  "boardId": {
                    "type": "string",
                    "description": "来源 TaskBoard 标识。"
                  },
                  "bindingId": {
                    "type": "string",
                    "description": "冻结的资源绑定标识。"
                  }
                }
              }
            ],
            "description": "不可变来源授权快照；读取和清除都重新核验当前权限。"
          },
          "displayName": {
            "type": "string",
            "description": "可选任务显示名。"
          },
          "text": {
            "type": "string",
            "description": "受存储边界截断的可见摘要，不是执行指令。"
          },
          "isError": {
            "type": "boolean",
            "description": "是否为失败结果；不会改变脚本真实终态。"
          },
          "timestamp": {
            "type": "number",
            "description": "冻结的原交付时间，重放不得使用当前时间替换。"
          },
          "delivery": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "message",
              "status",
              "sentAt"
            ],
            "description": "既有 SendUserMessage 用户交付形状，仅保存附件引用。",
            "properties": {
              "message": {
                "type": "string",
                "description": "受存储边界截断的用户交付正文。"
              },
              "status": {
                "enum": [
                  "normal",
                  "proactive"
                ],
                "description": "普通回复或主动告知。"
              },
              "sentAt": {
                "type": "string",
                "description": "工具侧原交付时刻。"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "附件解析降级告警。"
              },
              "attachments": {
                "type": "array",
                "description": "引用型附件，不存二进制正文。",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "path",
                    "name",
                    "mimeType",
                    "size",
                    "isImage"
                  ],
                  "properties": {
                    "path": {
                      "type": "string",
                      "description": "已解析的附件路径，读取仍受资源准入限制。"
                    },
                    "name": {
                      "type": "string",
                      "description": "附件文件名。"
                    },
                    "mimeType": {
                      "type": "string",
                      "description": "附件 MIME 类型。"
                    },
                    "size": {
                      "type": "number",
                      "description": "附件字节数。"
                    },
                    "isImage": {
                      "type": "boolean",
                      "description": "是否为图片。"
                    },
                    "mediaId": {
                      "type": "string",
                      "description": "可选媒体存储引用。"
                    },
                    "width": {
                      "type": "number",
                      "description": "可选图片宽度。"
                    },
                    "height": {
                      "type": "number",
                      "description": "可选图片高度。"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "ScheduleMessagePage": {
        "type": "object",
        "required": [
          "items",
          "total",
          "limit",
          "offset"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScheduleMessage"
            }
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 200
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          }
        },
        "additionalProperties": false
      },
      "AttachmentReceipt": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "attachmentId",
          "name",
          "mimeType",
          "size",
          "sha256",
          "fileReference"
        ],
        "properties": {
          "attachmentId": {
            "type": "string",
            "format": "uuid",
            "description": "服务端随机签发的附件ID。"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 240,
            "description": "不含路径分隔符/控制符的显示文件名。"
          },
          "mimeType": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "description": "上传时的内容类型，只作描述，下载禁止嗅探执行。"
          },
          "size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20971520,
            "description": "完整已持久化的字节数。"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "文件内容摘要；未完成上传不返回成功。"
          },
          "fileReference": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048,
            "description": "Server-side file reference. Pass unchanged to options.fileReferences of a Query start request on the same instance; it is not a public URL or a local client path."
          }
        }
      },
      "AttachmentMediaError": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        },
        "description": "Route error. Framework, origin, readiness, and proxy errors may carry additional fields; there is no universal response wrapper."
      },
      "MediaMetadata": {
        "type": "object",
        "required": [
          "type",
          "mediaId",
          "name",
          "mimeType",
          "size"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "image",
              "audio",
              "video"
            ]
          },
          "mediaId": {
            "type": "string",
            "pattern": "^[a-f0-9-]+\\.\\w+$",
            "description": "Service-issued media filename. Values containing two consecutive dots are rejected."
          },
          "name": {
            "type": "string"
          },
          "mimeType": {
            "type": "string",
            "enum": [
              "image/jpeg",
              "image/png",
              "image/gif",
              "image/webp",
              "audio/mpeg",
              "audio/mp3",
              "audio/opus",
              "audio/aac",
              "audio/flac",
              "audio/wav",
              "audio/ogg",
              "video/mp4",
              "video/webm"
            ]
          },
          "size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483648
          },
          "width": {
            "type": "number"
          },
          "height": {
            "type": "number"
          }
        },
        "description": "Direct upload response, manually represented from MediaMeta and saveAuthorizedMediaRaw. Dimensions are optional; no additional response wrapper."
      },
      "MediaAccessUrlsRequest": {
        "type": "object",
        "required": [
          "mediaIds"
        ],
        "additionalProperties": false,
        "properties": {
          "mediaIds": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "type": "string"
            },
            "description": "Duplicates removed in first-occurrence order; IDs are validated by the route."
          }
        }
      },
      "MediaAccessUrlsResponse": {
        "type": "object",
        "required": [
          "items",
          "missing"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "mediaId",
                "url",
                "expiresAt"
              ],
              "properties": {
                "mediaId": {
                  "type": "string",
                  "pattern": "^[a-f0-9-]+\\.\\w+$",
                  "description": "Service-issued media filename. Values containing two consecutive dots are rejected."
                },
                "url": {
                  "type": "string",
                  "description": "Service-relative URL with expires and signature. Use only the actual returned link."
                },
                "expiresAt": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          },
          "missing": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "description": "Missing files do not prevent other readable IDs from receiving links. Any ownership failure for an existing object rejects the request rather than returning partial items."
      },
      "HistoryError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": true
      },
      "HistorySessionSummary": {
        "type": "object",
        "properties": {
          "runId": {
            "type": "string"
          },
          "agentId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "idle",
              "completed",
              "failed",
              "handed_off"
            ],
            "description": "Historical display status, not live Run execution state or a request terminal."
          },
          "messageCount": {
            "type": "number"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "preview": {
            "type": "string"
          },
          "archivedAt": {
            "type": "string"
          },
          "forkedFrom": {
            "type": "string"
          },
          "conversationId": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "titleSource": {
            "type": "string",
            "enum": [
              "custom",
              "auto"
            ]
          },
          "origin": {
            "type": "string",
            "enum": [
              "user",
              "delegation"
            ]
          },
          "background": {
            "type": "boolean"
          },
          "delegated": {
            "type": "boolean"
          }
        },
        "required": [
          "runId",
          "agentId",
          "status",
          "messageCount",
          "createdAt",
          "updatedAt"
        ],
        "additionalProperties": true,
        "description": "Known SessionSummary fields from sessionSummarySchema. This HTTP projection is intentionally open."
      },
      "HistoryMessage": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "user",
              "assistant",
              "system"
            ]
          },
          "content": {
            "description": "Display content; commonly a string or content-block array. Do not reconstruct Provider protocol from it."
          },
          "timestamp": {
            "type": "number",
            "description": "Unix milliseconds when present."
          },
          "lineIndex": {
            "type": "integer",
            "minimum": 0,
            "description": "Source row position, not stable identity."
          },
          "offset": {
            "type": "integer",
            "minimum": 0,
            "description": "Byte position, not a pagination query offset."
          },
          "toolUse": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "summary": {
                  "type": "string",
                  "description": "Display summary. Sensitive results may be replaced by a placeholder; running/interrupted summaries may be absent. Do not parse outcome or replay instructions from this text."
                },
                "summaryRef": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true,
                  "description": "Optional body reference for public output. Withheld results omit this reference; its absence does not mean the tool did not run."
                },
                "isError": {
                  "type": "boolean",
                  "description": "When present, preserve the actual tool error fact even if its summary is withheld."
                },
                "status": {
                  "type": "string",
                  "description": "Tool-call state when present. Preserve this independently from display summaries; it is not the Query terminal or a child Run/Worker status."
                },
                "modelOutput": {
                  "$ref": "#/components/schemas/ModelToolOutputProjection"
                },
                "modelOutputRefs": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ModelToolOutputReference"
                  },
                  "description": "Harness 签发的模型文本完整引用；独立 modelOutput 保存模型预览和文本位置，UI summary/summaryRef 继续承载原结果。冷模型恢复不自动回填 UI 全文。引用只在当前 Run 归属/隐私授权下可读，fork 保留对应内容文件。"
                }
              },
              "additionalProperties": true
            }
          },
          "images": {
            "type": "array",
            "items": {}
          },
          "media": {
            "type": "array",
            "items": {}
          },
          "file": {},
          "thinking": {
            "type": "string"
          },
          "mentionSourceOnly": {
            "type": "boolean",
            "description": "true marks a Conversation source without current-Agent Run ownership. Display only; do not feed into model replay."
          },
          "mentionSource": {
            "type": "object",
            "description": "Conversation-owned Mention source reference, when present.",
            "additionalProperties": true
          },
          "mentionOccurrences": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "Structured Mention occurrences, when present."
          },
          "mentionRecipientAgentIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "uniqueItems": true
          },
          "mentionDeliveryIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "uniqueItems": true,
            "description": "Delivery references, not proof of successful execution."
          }
        },
        "additionalProperties": true,
        "description": "Known fields of the public SessionMessage projection, derived from sessionMessageSchema. Runtime-private recovery fields are not part of this contract. Additional public fields remain allowed. Sensitive tool results and unverifiable protocol results may be withheld; privacy placeholders are display text, not execution outcomes. Body references may be omitted."
      },
      "HistoryLiveInspectionTool": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 256
          },
          "name": {
            "type": "string",
            "maxLength": 256
          },
          "isError": {
            "type": "boolean"
          },
          "activity": {
            "description": "Optional bounded public Tool activity; no Tool input or output."
          }
        },
        "required": [
          "id",
          "name",
          "isError"
        ],
        "additionalProperties": true
      },
      "HistoryLiveInspection": {
        "type": "object",
        "properties": {
          "turnId": {
            "type": "string",
            "maxLength": 256
          },
          "text": {
            "type": "string",
            "maxLength": 16384
          },
          "toolCalls": {
            "type": "array",
            "maxItems": 128,
            "items": {
              "$ref": "#/components/schemas/HistoryLiveInspectionTool"
            }
          },
          "timestamp": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "text",
          "toolCalls",
          "timestamp"
        ],
        "additionalProperties": true,
        "description": "Temporary delegated-Run display checkpoint. It is not durable history, a receipt or proof of completion; replace it instead of appending it to messages."
      },
      "HistorySessionSnapshot": {
        "type": "object",
        "properties": {
          "runId": {
            "type": "string"
          },
          "agentId": {
            "type": "string"
          },
          "userId": {
            "type": "string"
          },
          "engine": {
            "type": "string",
            "enum": [
              "desirecore-engine"
            ]
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryMessage"
            }
          },
          "options": {
            "type": "object",
            "additionalProperties": true,
            "description": "Display/recovery configuration. Returned configuration grants no execution authority."
          },
          "status": {
            "type": "string",
            "enum": [
              "idle",
              "completed",
              "failed",
              "handed_off"
            ],
            "description": "Historical display status, not live Run execution state or a request terminal."
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "conversationId": {
            "type": "string"
          },
          "forkedFrom": {
            "type": "string"
          },
          "teamId": {
            "type": "string"
          },
          "workDir": {
            "type": "string"
          },
          "worktreeCwd": {
            "type": "string"
          },
          "pendingAssistant": {
            "$ref": "#/components/schemas/HistoryMessage"
          },
          "runtimeSession": {
            "type": "object",
            "properties": {
              "sessionId": {
                "type": "string"
              },
              "revision": {
                "type": "integer",
                "minimum": 1
              },
              "scopeEpoch": {
                "type": "integer",
                "minimum": 0
              },
              "scopeSequence": {
                "type": "integer",
                "minimum": 0
              },
              "boundModel": {
                "type": "object",
                "additionalProperties": true
              }
            },
            "additionalProperties": true
          }
        },
        "required": [
          "runId",
          "agentId",
          "userId",
          "engine",
          "messages",
          "options",
          "status",
          "createdAt",
          "updatedAt"
        ],
        "additionalProperties": true,
        "description": "Known public fields derived from sessionSnapshotSchema and the public session projection; additional public fields are allowed. Images may be expanded to data URLs. Tool summaries and result blocks may be replaced by privacy placeholders with body references removed."
      },
      "HistorySessionPage": {
        "type": "object",
        "properties": {
          "sessions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistorySessionSummary"
            }
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "required": [
          "sessions",
          "total",
          "hasMore"
        ],
        "additionalProperties": true
      },
      "HistoryMessagePage": {
        "type": "object",
        "properties": {
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryMessage"
            }
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "description": "Source-record row count. Omitted or damaged rows mean returned messages can be fewer than the requested window."
          },
          "live": {
            "$ref": "#/components/schemas/HistoryLiveInspection"
          }
        },
        "required": [
          "messages",
          "total"
        ],
        "additionalProperties": true
      },
      "HistorySearchHit": {
        "type": "object",
        "properties": {
          "runId": {
            "type": "string"
          },
          "messageIndex": {
            "type": "integer",
            "minimum": 0,
            "description": "Source row position within this Run."
          },
          "offset": {
            "type": "integer",
            "minimum": 0,
            "description": "Byte position, not the next search-page offset."
          },
          "messageId": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "user",
              "assistant",
              "system"
            ]
          },
          "text": {
            "type": "string"
          },
          "timestamp": {
            "type": "number"
          },
          "hasImages": {
            "type": "boolean",
            "description": "Based on legacy images or media fields; not proof that every attachment is an image."
          },
          "hasFiles": {
            "type": "boolean"
          },
          "hasToolUse": {
            "type": "boolean"
          },
          "toolNames": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "conversationId": {
            "type": "string"
          }
        },
        "required": [
          "runId",
          "messageIndex",
          "offset",
          "messageId",
          "role",
          "text",
          "timestamp",
          "hasImages",
          "hasFiles",
          "hasToolUse"
        ],
        "additionalProperties": true
      },
      "HistorySearchPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistorySearchHit"
            }
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "required": [
          "items",
          "total",
          "hasMore"
        ],
        "additionalProperties": true
      },
      "ConversationMatterOverview": {
        "type": "object",
        "properties": {
          "agentId": {
            "type": "string"
          },
          "activeMatters": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "title",
                "type"
              ],
              "additionalProperties": true
            }
          },
          "recentMatters": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "completedAt": {
                  "type": "string"
                },
                "summary": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "title",
                "type"
              ],
              "additionalProperties": true
            }
          },
          "totalMatters": {
            "type": "integer",
            "minimum": 0
          },
          "totalArchived": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "agentId",
          "activeMatters",
          "recentMatters",
          "totalMatters",
          "totalArchived"
        ],
        "additionalProperties": true
      },
      "ConversationMatterMessages": {
        "type": "object",
        "properties": {
          "matterId": {
            "type": "string"
          },
          "messages": {
            "type": "array",
            "maxItems": 120,
            "items": {},
            "description": "Public source entries; not guaranteed to have the per-Run SessionMessage shape. Sensitive or unverifiable tool-result bodies may be replaced and external result references removed."
          },
          "truncated": {
            "type": "boolean",
            "const": true,
            "description": "Present and true when the source read exceeded 120 messages. Public projection may return fewer entries."
          }
        },
        "required": [
          "matterId",
          "messages"
        ],
        "additionalProperties": true
      },
      "NetworkHealthState": {
        "type": "object",
        "required": [
          "status",
          "reason",
          "since",
          "seq"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "online",
              "degraded",
              "offline",
              "unknown"
            ],
            "description": "网络健康状态：online=上游请求或探测成功；degraded=出现网络类失败但未确认公网断开（或仅个别 Provider 不可达）；offline=通用连通性探测失败且近期失败的上游也探测不通，或多 host DNS 失败，确认网络不可达；unknown=启动后尚无样本（或休眠唤醒后待重新确认），UI 不应据此显示异常"
          },
          "scope": {
            "type": "string",
            "enum": [
              "global",
              "provider"
            ],
            "description": "异常范围（仅 degraded/offline 时有意义）：global=公网整体不可达；provider=公网通但个别模型服务商不可达（通用探测成功、Provider origin 探测失败）"
          },
          "affectedProviders": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "scope=provider 时受影响的 Provider ID 列表（供前端展示\"服务商暂不可达\"）"
          },
          "reason": {
            "type": "string",
            "enum": [
              "init",
              "request_ok",
              "probe_ok",
              "request_failed",
              "probe_failed",
              "stream_stall",
              "multi_host_dns",
              "suspend_resume"
            ],
            "description": "进入当前状态的原因：init=启动初始；request_ok/probe_ok=真实请求或探测成功；request_failed=上游请求网络类失败；probe_failed=通用连通性探测失败；stream_stall=流式空闲超时；multi_host_dns=窗口期内多个不同 host DNS 失败（最强离线证据）；suspend_resume=系统唤醒后重置待确认"
          },
          "subcategory": {
            "type": "string",
            "enum": [
              "dns",
              "tls",
              "tcp_reset",
              "refused",
              "unreachable",
              "timeout",
              "stream_interrupted"
            ],
            "description": "触发本次状态变化的网络错误子类（若有），供前端给出针对性提示（如 dns → 检查 DNS/代理设置）"
          },
          "since": {
            "type": "string",
            "description": "进入当前状态的 ISO 8601 时间；消费方据此判断状态新鲜度（无活跃请求时状态允许 stale）"
          },
          "seq": {
            "type": "number",
            "minimum": 0,
            "description": "单调递增序号；前端用于拒绝乱序/迟到的旧状态事件（快照与实时事件以 seq 大者为准）"
          }
        },
        "additionalProperties": false
      },
      "OperationsRecentCallsResponse": {
        "type": "object",
        "required": [
          "calls"
        ],
        "properties": {
          "calls": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "id",
                "timestamp",
                "agentId",
                "runId",
                "toolName",
                "status",
                "durationMs"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "description": "不透明的稳定调用 ID；优先 invocation_id，旧记录由 Run/Receipt 身份和工具序号确定。不得解析为 Run ID，也不是恢复或授权凭据。"
                },
                "timestamp": {
                  "type": "string",
                  "format": "date-time",
                  "description": "优先工具 started_at；旧记录缺失时回退 Receipt started_at，再回退 Run started_at。不是保证精确的工具开始时间。"
                },
                "agentId": {
                  "type": "string",
                  "minLength": 1,
                  "description": "执行 Agent ID。"
                },
                "runId": {
                  "type": "string",
                  "minLength": 1,
                  "description": "关联 Run ID；详情跳转不得从展示 ID 猜测。"
                },
                "toolName": {
                  "type": "string",
                  "minLength": 1,
                  "description": "工具名称。"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "success",
                    "warning",
                    "error"
                  ],
                  "description": "优先工具 success/error；旧记录缺失时按 Receipt outcome 的 failed→error、partial→warning、其他→success 投影，不代表 Query 或 Run 终态。"
                },
                "durationMs": {
                  "type": "number",
                  "minimum": 0,
                  "description": "已记录工具耗时（毫秒）；旧记录缺失时为 0，不表示真实零耗时。"
                }
              },
              "additionalProperties": false
            },
            "description": "当前可信用户最近的工具调用，按时间倒序。"
          }
        },
        "additionalProperties": false,
        "description": "运行中心活动分区的用户隔离工具调用列表。"
      },
      "OperationsUsageSummaryResponse": {
        "type": "object",
        "required": [
          "total",
          "byModel",
          "byDate",
          "byAgent"
        ],
        "properties": {
          "total": {
            "type": "object",
            "required": [
              "inputTokens",
              "outputTokens",
              "cacheReadTokens",
              "cacheWriteTokens",
              "costUsd",
              "queryCount"
            ],
            "properties": {
              "inputTokens": {
                "type": "number",
                "minimum": 0,
                "description": "非缓存输入 Token 总数。"
              },
              "outputTokens": {
                "type": "number",
                "minimum": 0,
                "description": "输出 Token 总数。"
              },
              "cacheReadTokens": {
                "type": "number",
                "minimum": 0,
                "description": "缓存读取 Token 总数。"
              },
              "cacheWriteTokens": {
                "type": "number",
                "minimum": 0,
                "description": "缓存写入 Token 总数。"
              },
              "costUsd": {
                "type": "number",
                "minimum": 0,
                "description": "已记录的美元成本总额。"
              },
              "queryCount": {
                "type": "number",
                "minimum": 0,
                "description": "带用量数据的查询次数。"
              }
            },
            "additionalProperties": false,
            "description": "当前可信用户的用量汇总。"
          },
          "byModel": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "inputTokens",
                "outputTokens",
                "cacheReadTokens",
                "cacheWriteTokens",
                "costUsd",
                "queryCount",
                "provider",
                "model"
              ],
              "properties": {
                "provider": {
                  "type": "string",
                  "description": "模型 Provider 标识。"
                },
                "model": {
                  "type": "string",
                  "description": "模型 ID。"
                },
                "inputTokens": {
                  "type": "number",
                  "minimum": 0,
                  "description": "非缓存输入 Token 总数。"
                },
                "outputTokens": {
                  "type": "number",
                  "minimum": 0,
                  "description": "输出 Token 总数。"
                },
                "cacheReadTokens": {
                  "type": "number",
                  "minimum": 0,
                  "description": "缓存读取 Token 总数。"
                },
                "cacheWriteTokens": {
                  "type": "number",
                  "minimum": 0,
                  "description": "缓存写入 Token 总数。"
                },
                "costUsd": {
                  "type": "number",
                  "minimum": 0,
                  "description": "已记录的美元成本总额。"
                },
                "queryCount": {
                  "type": "number",
                  "minimum": 0,
                  "description": "带用量数据的查询次数。"
                }
              },
              "additionalProperties": false
            },
            "description": "按 Provider/模型聚合的用量。"
          },
          "byDate": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "inputTokens",
                "outputTokens",
                "cacheReadTokens",
                "cacheWriteTokens",
                "costUsd",
                "queryCount",
                "date"
              ],
              "properties": {
                "date": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "description": "聚合日期（YYYY-MM-DD）；UTC 日桶可按其中点映射到请求时区，不是逐事件的精确本地日结。"
                },
                "inputTokens": {
                  "type": "number",
                  "minimum": 0,
                  "description": "非缓存输入 Token 总数。"
                },
                "outputTokens": {
                  "type": "number",
                  "minimum": 0,
                  "description": "输出 Token 总数。"
                },
                "cacheReadTokens": {
                  "type": "number",
                  "minimum": 0,
                  "description": "缓存读取 Token 总数。"
                },
                "cacheWriteTokens": {
                  "type": "number",
                  "minimum": 0,
                  "description": "缓存写入 Token 总数。"
                },
                "costUsd": {
                  "type": "number",
                  "minimum": 0,
                  "description": "已记录的美元成本总额。"
                },
                "queryCount": {
                  "type": "number",
                  "minimum": 0,
                  "description": "带用量数据的查询次数。"
                }
              },
              "additionalProperties": false
            },
            "description": "按 UTC 日桶聚合的用量；有效 timezone 将桶的 UTC 12:00 映射到本地日期，无法恢复桶内每条记录的本地日界。"
          },
          "byAgent": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "inputTokens",
                "outputTokens",
                "cacheReadTokens",
                "cacheWriteTokens",
                "costUsd",
                "queryCount",
                "agentId"
              ],
              "properties": {
                "agentId": {
                  "type": "string",
                  "minLength": 1,
                  "description": "关联 Agent ID。"
                },
                "inputTokens": {
                  "type": "number",
                  "minimum": 0,
                  "description": "非缓存输入 Token 总数。"
                },
                "outputTokens": {
                  "type": "number",
                  "minimum": 0,
                  "description": "输出 Token 总数。"
                },
                "cacheReadTokens": {
                  "type": "number",
                  "minimum": 0,
                  "description": "缓存读取 Token 总数。"
                },
                "cacheWriteTokens": {
                  "type": "number",
                  "minimum": 0,
                  "description": "缓存写入 Token 总数。"
                },
                "costUsd": {
                  "type": "number",
                  "minimum": 0,
                  "description": "已记录的美元成本总额。"
                },
                "queryCount": {
                  "type": "number",
                  "minimum": 0,
                  "description": "带用量数据的查询次数。"
                }
              },
              "additionalProperties": false
            },
            "description": "按 Agent 聚合的用量。"
          }
        },
        "additionalProperties": false,
        "description": "运行中心活动分区的用户隔离用量摘要。"
      },
      "AgentInputConfig": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "version",
          "agentId",
          "manual",
          "configRevision"
        ],
        "properties": {
          "version": {
            "type": "integer",
            "const": 1,
            "description": "Projection protocol version; unknown versions do not unlock ordinary input."
          },
          "agentId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]+$",
            "description": "Actual Agent read; match it against the selected target."
          },
          "manual": {
            "type": "boolean",
            "description": "Current separate-conversation manual mode. Valid omission in Agent configuration defaults to false."
          },
          "configRevision": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$",
            "description": "Opaque digest of configuration content. Equality only; not a permission, lock, timestamp or sequence."
          }
        }
      },
      "AgentInputConfigError": {
        "type": "object",
        "required": [
          "code",
          "error"
        ],
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "AGENT_INPUT_CONFIG_INVALID_ID",
              "AGENT_NOT_FOUND",
              "AGENT_INPUT_CONFIG_CHANGED",
              "AGENT_INPUT_CONFIG_INVALID",
              "AGENT_INPUT_CONFIG_UNREADABLE"
            ]
          },
          "error": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "MergedHistoryItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "runId",
          "messageIndex",
          "sessionTime",
          "message"
        ],
        "properties": {
          "runId": {
            "type": "string",
            "description": "Owned source Run ID, or __mention_source:SOURCE_ID for a Conversation source-only entry. Synthetic IDs cannot be used with Run, follow-up or recovery APIs."
          },
          "messageIndex": {
            "type": "number",
            "description": "Source row navigation position; source-only entries use 0. Not the merged page offset."
          },
          "offset": {
            "type": "number",
            "minimum": 0,
            "description": "Optional source byte position for persisted Run messages. Not a page offset."
          },
          "sessionTime": {
            "type": "string",
            "description": "Source session creation time or source creation time, in ISO 8601 form."
          },
          "message": {
            "$ref": "#/components/schemas/HistoryMessage"
          }
        }
      },
      "MergedHistoryPage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "items",
          "total",
          "hasMore",
          "historyRevision"
        ],
        "properties": {
          "items": {
            "type": "array",
            "maxItems": 1000,
            "items": {
              "$ref": "#/components/schemas/MergedHistoryItem"
            },
            "description": "Public display projection; sensitive result bodies and references may be withheld."
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "description": "Total entries in this complete merged public view, not source rows across Runs."
          },
          "hasMore": {
            "type": "boolean",
            "description": "Whether more entries remain for a positive limit. Always false for limit=0."
          },
          "historyRevision": {
            "type": "string",
            "pattern": "^h1:[0-9a-f]{64}$",
            "description": "Current complete public view digest including read scope and order. Later pages send expectedRevision; changes yield 409. Not a persistent cursor or transaction snapshot."
          }
        }
      },
      "TaskBoardListResponse": {
        "description": "全局看板使用的授权 TaskBoard 聚合列表。",
        "type": "object",
        "required": [
          "schemaVersion",
          "generatedAt",
          "boards"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 3,
            "description": "全局任务板列表响应版本。"
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "boards": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskBoardSummary"
            },
            "description": "当前请求主体有权查看的 TaskBoard；global 视图只聚合此列表。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardDetailResponse": {
        "description": "TaskBoard 的权威详情和服务端可用动作。",
        "type": "object",
        "required": [
          "schemaVersion",
          "exists"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 3,
            "description": "TaskBoard 详情响应版本。"
          },
          "exists": {
            "type": "boolean",
            "description": "false 表示授权作用域内不存在此 TaskBoard。"
          },
          "meta": {
            "$ref": "#/components/schemas/TaskBoardMeta"
          },
          "tasks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskBoardPublicTaskItem"
            },
            "description": "当前请求主体有权读取的 Task 列表。"
          },
          "comments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskBoardPublicComment"
            },
            "description": "当前 TaskBoard 的基础评论列表。"
          },
          "resourceBindings": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "schemaVersion",
                "bindingId",
                "taskIdentity",
                "taskVersionAtMutation",
                "role",
                "resourceRef",
                "version",
                "lifecycle",
                "createdByCommandId",
                "createdAt",
                "updatedByCommandId",
                "updatedAt"
              ],
              "properties": {
                "schemaVersion": {
                  "type": "integer",
                  "const": 1,
                  "description": "TaskResourceBinding 契约版本；当前固定为 1。"
                },
                "bindingId": {
                  "type": "string",
                  "minLength": 47,
                  "maxLength": 47,
                  "pattern": "^trb_[A-Za-z0-9_-]{43}$",
                  "description": "绑定的 ID，由 TaskBoard 生成，不能自行构造或从显示内容推出。"
                },
                "taskIdentity": {
                  "type": "object",
                  "required": [
                    "boardId",
                    "taskId"
                  ],
                  "properties": {
                    "boardId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 512,
                      "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
                      "description": "Task 所在 TaskBoard 的 ID。"
                    },
                    "taskId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 512,
                      "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
                      "description": "Task 的 ID。"
                    }
                  },
                  "additionalProperties": false,
                  "description": "用 {boardId, taskId} 指明 Task，不带版本，Task 版本变化后仍然有效；写入时另传带版本的 taskTarget。"
                },
                "taskVersionAtMutation": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991,
                  "description": "最后一次关系提交所观察到的 exact Task version；它是审计锚点，不属于稳定父身份，也不会把后续 Task 版本推进变成失联。"
                },
                "role": {
                  "type": "string",
                  "enum": [
                    "navigation",
                    "attention",
                    "input",
                    "output",
                    "evidence",
                    "decision",
                    "execution",
                    "workspace",
                    "view"
                  ],
                  "description": "资源在这个 Task 上的用途。navigation、attention 是导航链接，resourceRef 可用 current pin（跟随最新版本）；其余角色必须用 exact pin。"
                },
                "resourceRef": {
                  "description": "外部 owner 的窄引用；不包含正文、权限或运行态，并且每次读取/导航/执行仍须由 owner 重鉴权。",
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/CurrentGovernedResourceRef"
                    },
                    {
                      "$ref": "#/components/schemas/ExactGovernedResourceRef"
                    }
                  ]
                },
                "version": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991,
                  "description": "关系记录自身的单调 CAS version，与 Task version 和资源 revision 相互独立。"
                },
                "lifecycle": {
                  "type": "string",
                  "enum": [
                    "active",
                    "removed"
                  ],
                  "description": "active=关系有效；removed=不可变删除墓碑，保留完整因果与最后引用。"
                },
                "createdByCommandId": {
                  "type": "string",
                  "minLength": 48,
                  "maxLength": 48,
                  "pattern": "^gcmd_[A-Za-z0-9_-]{43}$",
                  "description": "首次建立关系的 S18 GovernedCommand ID；不复制 actor/channel/approval。"
                },
                "createdAt": {
                  "type": "string",
                  "format": "date-time",
                  "description": "由 TaskBoard 关系 owner 记录的带时区 ISO 8601 时间。"
                },
                "updatedByCommandId": {
                  "type": "string",
                  "minLength": 48,
                  "maxLength": 48,
                  "pattern": "^gcmd_[A-Za-z0-9_-]{43}$",
                  "description": "最后一次更新或移除关系的 S18 GovernedCommand ID；不复制 actor/channel/approval。"
                },
                "updatedAt": {
                  "type": "string",
                  "format": "date-time",
                  "description": "由 TaskBoard 关系 owner 记录的带时区 ISO 8601 时间。"
                },
                "removedAt": {
                  "type": "string",
                  "format": "date-time",
                  "description": "removed 墓碑的发生时间，必须与该版本 updatedAt 相同。"
                },
                "removalReasonCode": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128,
                  "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
                  "description": "有界、非正文的移除原因代码；不可承载用户内容或资源摘要。"
                }
              },
              "additionalProperties": false,
              "description": "TaskBoard 拥有的关系事实。它只记录 Task↔resource 的角色、版本和 S18 命令因果，不复制资源正文、权限、运行态或 actor。"
            },
            "description": "TaskBoard-owned narrow resource relationship facts; external owner bodies and authority are not copied."
          },
          "availableActions": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "taskRef",
                "actions"
              ],
              "properties": {
                "taskRef": {
                  "$ref": "#/components/schemas/TaskRef"
                },
                "actions": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskAvailableAction"
                  },
                  "description": "该 Task 的服务端可用动作。"
                }
              },
              "additionalProperties": false,
              "description": "单个 Task 的动作投影。"
            },
            "description": "服务端按当前 actor 计算的动作；前端不得自行猜权限。"
          },
          "fanOutDispatches": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskFanOutDispatch"
            },
            "description": "当前 TaskBoard 中已授权 fan-out intents 的持久投递状态；不包含秘密 claim token。"
          },
          "allDone": {
            "type": "boolean",
            "description": "是否不存在任何开放中的 Task。"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "exists": {
                  "const": true
                }
              },
              "required": [
                "exists"
              ]
            },
            "then": {
              "required": [
                "meta",
                "tasks",
                "comments",
                "resourceBindings",
                "availableActions",
                "allDone"
              ]
            }
          }
        ],
        "additionalProperties": false
      },
      "TaskDirectReadResponse": {
        "description": "稳定 Task 深链使用的精确授权读取，不要求客户端先加载整板。",
        "type": "object",
        "required": [
          "schemaVersion",
          "exists"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 3,
            "description": "TaskBoard contract 版本。"
          },
          "exists": {
            "type": "boolean",
            "description": "false 对调用方不区分不存在与不可见的细节。"
          },
          "board": {
            "$ref": "#/components/schemas/TaskBoardMeta"
          },
          "task": {
            "$ref": "#/components/schemas/TaskBoardPublicTaskItem"
          },
          "comments": {
            "type": "array",
            "description": "此 Task 的 canonical 评论最新投影。",
            "items": {
              "$ref": "#/components/schemas/TaskBoardPublicComment"
            }
          },
          "resourceBindings": {
            "type": "array",
            "description": "此 Task 的 owner-issued resource binding 事实；引用不是 capability。",
            "items": {
              "type": "object",
              "required": [
                "schemaVersion",
                "bindingId",
                "taskIdentity",
                "taskVersionAtMutation",
                "role",
                "resourceRef",
                "version",
                "lifecycle",
                "createdByCommandId",
                "createdAt",
                "updatedByCommandId",
                "updatedAt"
              ],
              "properties": {
                "schemaVersion": {
                  "type": "integer",
                  "const": 1,
                  "description": "TaskResourceBinding 契约版本；当前固定为 1。"
                },
                "bindingId": {
                  "type": "string",
                  "minLength": 47,
                  "maxLength": 47,
                  "pattern": "^trb_[A-Za-z0-9_-]{43}$",
                  "description": "绑定的 ID，由 TaskBoard 生成，不能自行构造或从显示内容推出。"
                },
                "taskIdentity": {
                  "type": "object",
                  "required": [
                    "boardId",
                    "taskId"
                  ],
                  "properties": {
                    "boardId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 512,
                      "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
                      "description": "Task 所在 TaskBoard 的 ID。"
                    },
                    "taskId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 512,
                      "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
                      "description": "Task 的 ID。"
                    }
                  },
                  "additionalProperties": false,
                  "description": "用 {boardId, taskId} 指明 Task，不带版本，Task 版本变化后仍然有效；写入时另传带版本的 taskTarget。"
                },
                "taskVersionAtMutation": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991,
                  "description": "最后一次关系提交所观察到的 exact Task version；它是审计锚点，不属于稳定父身份，也不会把后续 Task 版本推进变成失联。"
                },
                "role": {
                  "type": "string",
                  "enum": [
                    "navigation",
                    "attention",
                    "input",
                    "output",
                    "evidence",
                    "decision",
                    "execution",
                    "workspace",
                    "view"
                  ],
                  "description": "资源在这个 Task 上的用途。navigation、attention 是导航链接，resourceRef 可用 current pin（跟随最新版本）；其余角色必须用 exact pin。"
                },
                "resourceRef": {
                  "description": "外部 owner 的窄引用；不包含正文、权限或运行态，并且每次读取/导航/执行仍须由 owner 重鉴权。",
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/CurrentGovernedResourceRef"
                    },
                    {
                      "$ref": "#/components/schemas/ExactGovernedResourceRef"
                    }
                  ]
                },
                "version": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991,
                  "description": "关系记录自身的单调 CAS version，与 Task version 和资源 revision 相互独立。"
                },
                "lifecycle": {
                  "type": "string",
                  "enum": [
                    "active",
                    "removed"
                  ],
                  "description": "active=关系有效；removed=不可变删除墓碑，保留完整因果与最后引用。"
                },
                "createdByCommandId": {
                  "type": "string",
                  "minLength": 48,
                  "maxLength": 48,
                  "pattern": "^gcmd_[A-Za-z0-9_-]{43}$",
                  "description": "首次建立关系的 S18 GovernedCommand ID；不复制 actor/channel/approval。"
                },
                "createdAt": {
                  "type": "string",
                  "format": "date-time",
                  "description": "由 TaskBoard 关系 owner 记录的带时区 ISO 8601 时间。"
                },
                "updatedByCommandId": {
                  "type": "string",
                  "minLength": 48,
                  "maxLength": 48,
                  "pattern": "^gcmd_[A-Za-z0-9_-]{43}$",
                  "description": "最后一次更新或移除关系的 S18 GovernedCommand ID；不复制 actor/channel/approval。"
                },
                "updatedAt": {
                  "type": "string",
                  "format": "date-time",
                  "description": "由 TaskBoard 关系 owner 记录的带时区 ISO 8601 时间。"
                },
                "removedAt": {
                  "type": "string",
                  "format": "date-time",
                  "description": "removed 墓碑的发生时间，必须与该版本 updatedAt 相同。"
                },
                "removalReasonCode": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128,
                  "pattern": "^[a-z][a-z0-9]*(?:[._:-][a-z0-9]+)*$",
                  "description": "有界、非正文的移除原因代码；不可承载用户内容或资源摘要。"
                }
              },
              "additionalProperties": false,
              "description": "TaskBoard 拥有的关系事实。它只记录 Task↔resource 的角色、版本和 S18 命令因果，不复制资源正文、权限、运行态或 actor。"
            }
          },
          "availableActions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskAvailableAction"
            },
            "description": "当前 principal 对此 Task 的服务端动作。"
          },
          "archiveAction": {
            "$ref": "#/components/schemas/TaskArchiveAction"
          },
          "deepLink": {
            "$ref": "#/components/schemas/TaskDeepLink"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "exists": {
                  "const": true
                }
              },
              "required": [
                "exists"
              ]
            },
            "then": {
              "required": [
                "board",
                "task",
                "comments",
                "resourceBindings",
                "availableActions",
                "archiveAction",
                "deepLink"
              ]
            }
          }
        ],
        "additionalProperties": false
      },
      "TaskBoardQueryRequest": {
        "description": "Global/List/Board 共用的授权 Task 查询请求。",
        "type": "object",
        "properties": {
          "filter": {
            "$ref": "#/components/schemas/TaskBoardQueryFilter"
          },
          "sort": {
            "$ref": "#/components/schemas/TaskBoardQuerySort"
          },
          "pageSize": {
            "type": "integer",
            "minimum": 1,
            "maximum": 200,
            "description": "单页数量；省略时服务端使用 50。"
          },
          "cursor": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4096,
            "description": "上一次响应返回的不透明 keyset 游标；不得跨筛选/排序请求复用。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardQueryResponse": {
        "description": "授权、稳定分页的 TaskBoard 查询结果。",
        "type": "object",
        "required": [
          "schemaVersion",
          "generatedAt",
          "items",
          "pageSize",
          "hasMore",
          "totalCount",
          "statusCounts"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 3,
            "description": "TaskBoard contract 版本。"
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskBoardQueryItem"
            },
            "description": "当前页授权结果。"
          },
          "pageSize": {
            "type": "integer",
            "minimum": 1,
            "maximum": 200,
            "description": "本次采用的页大小。"
          },
          "hasMore": {
            "type": "boolean",
            "description": "是否还有下一页。"
          },
          "totalCount": {
            "type": "integer",
            "minimum": 0,
            "description": "当前组合过滤命中的授权 Task 总数。"
          },
          "statusCounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskStatusCount"
            },
            "description": "当前组合过滤命中结果按状态的总数；不受当前分页截断影响。"
          },
          "nextCursor": {
            "type": "string",
            "minLength": 1,
            "description": "下一页不透明游标；无下一页时省略。"
          },
          "indexGeneration": {
            "type": "string",
            "minLength": 1,
            "description": "可重建索引的内容代号，仅用于诊断，不是 canonical revision。"
          }
        },
        "additionalProperties": false
      },
      "TaskActivityResponse": {
        "description": "Task workspace Activity 列表；canonical TaskEvent 与 owner projection 共享 envelope。",
        "type": "object",
        "required": [
          "schemaVersion",
          "taskRef",
          "generatedAt",
          "items"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "Activity response 契约版本。"
          },
          "taskRef": {
            "$ref": "#/components/schemas/TaskRef"
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskActivityEnvelope"
            },
            "description": "当前Owner摘要优先；带page时canonical事件按Board revision升序，未分页历史响应仍按occurredAt排序。"
          },
          "page": {
            "$ref": "#/components/schemas/TaskActivityPage"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardSessionBoardResolveRequest": {
        "description": "按会话解析聊天悬浮面板的会话看板（只读）。选择规则与 Task 工具默认选板一致：当前 session 的看板优先，当前 session 没有看板时沿用同一 Run 其他代际 session 中未归档、最近更新的一块。run→session 归属只取服务端会话持久状态，不接受客户端自报的 session 列表；鉴权沿用请求主体，不扩权。",
        "type": "object",
        "properties": {
          "runId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$",
            "description": "会话所属 Run ID（会话级，session 轮换时不变）。服务端据此列出该 Run 历代已持久化的 runtime session。"
          },
          "sessionId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$",
            "description": "客户端当前前台 runtime session（可选），只决定「当前 session 的看板优先」；服务端证明它属于另一个 Run 时不作为当前代际。未给 runId 时按会话持久状态索引反查其 Run（兼容旧 session-<id> 别名）。"
          }
        },
        "anyOf": [
          {
            "required": [
              "runId"
            ]
          },
          {
            "required": [
              "sessionId"
            ]
          }
        ],
        "additionalProperties": false
      },
      "TaskBoardReadError": {
        "description": "HTTP 与 Task tools 共用的失败 mutation result。",
        "type": "object",
        "required": [
          "ok",
          "error"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": false,
            "description": "写事务是否成功。"
          },
          "error": {
            "$ref": "#/components/schemas/TaskBoardError"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardSummary": {
        "description": "全局看板列表中的单个授权 TaskBoard 摘要。",
        "type": "object",
        "required": [
          "meta",
          "statusCounts",
          "openCount"
        ],
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/TaskBoardMeta"
          },
          "statusCounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskStatusCount"
            },
            "description": "按状态聚合的授权任务数。"
          },
          "openCount": {
            "type": "integer",
            "minimum": 0,
            "description": "未进入 terminal/hidden 类别的任务数。"
          },
          "archiveAction": {
            "$ref": "#/components/schemas/TaskBoardArchiveAction"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardMeta": {
        "description": "TaskBoard V3 的作用域、策略和提交 revision 元数据。",
        "type": "object",
        "required": [
          "schemaVersion",
          "id",
          "name",
          "scope",
          "ownerUserId",
          "policy",
          "revision",
          "createdBy",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 3,
            "description": "TaskBoard 数据格式版本。"
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "description": "稳定 TaskBoard ID。"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "description": "任务板展示名称。"
          },
          "scope": {
            "$ref": "#/components/schemas/TaskBoardScope"
          },
          "ownerUserId": {
            "type": "string",
            "minLength": 1,
            "description": "拥有此数据根的用户 ID；所有入口必须据请求身份校验。"
          },
          "policy": {
            "$ref": "#/components/schemas/TaskBoardPolicy"
          },
          "workdirRef": {
            "description": "Board 默认工作目录的 owner 验证引用；目录/worktree 生命周期仍由 WorkDir owner 管理。",
            "type": "object",
            "required": [
              "workdirId",
              "ownerScope"
            ],
            "properties": {
              "workdirId": {
                "type": "string",
                "minLength": 1,
                "description": "WorkDir owner 中的稳定 ID。"
              },
              "ownerScope": {
                "type": "object",
                "required": [
                  "type",
                  "id"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "user",
                      "agent",
                      "team"
                    ],
                    "description": "WorkDir 配置的 owner scope。"
                  },
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "用户、Agent 或 Team 的稳定 owner ID。"
                  }
                },
                "additionalProperties": false,
                "description": "解析 workdirId 所需的 owner scope；不包含绝对路径。"
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "授权写入时的安全展示快照。"
              },
              "repositoryId": {
                "type": "string",
                "minLength": 1,
                "description": "可选的 CodeRepo owner 稳定仓库 ID。"
              }
            },
            "additionalProperties": false
          },
          "revision": {
            "type": "integer",
            "minimum": 0,
            "description": "任务板提交序号，每个原子写事务递增一次。"
          },
          "createdBy": {
            "$ref": "#/components/schemas/ActorRef"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "archivedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Board 归档时间；归档后默认查询隐藏，但 canonical Task 和审计历史保留。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardPublicTaskItem": {
        "description": "Canonical Task V3 权威事实。",
        "type": "object",
        "required": [
          "schemaVersion",
          "id",
          "boardId",
          "subject",
          "description",
          "status",
          "priority",
          "position",
          "labels",
          "blockedBy",
          "blocks",
          "runRefs",
          "receiptRefs",
          "workContextRefs",
          "review",
          "createdBy",
          "createdAt",
          "updatedAt",
          "version"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 3,
            "description": "Task 数据格式版本。"
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "description": "TaskBoard 内稳定 Task ID。"
          },
          "boardId": {
            "type": "string",
            "minLength": 1,
            "description": "所属 canonical TaskBoard ID。"
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "description": "面向执行和列表展示的短标题。"
          },
          "description": {
            "type": "string",
            "description": "任务目标、边界和验收信息。"
          },
          "activeForm": {
            "type": "string",
            "minLength": 1,
            "description": "进行中展示文案。"
          },
          "status": {
            "type": "string",
            "enum": [
              "backlog",
              "pending",
              "inProgress",
              "blocked",
              "inReview",
              "completed",
              "failed",
              "canceled",
              "deleted"
            ],
            "description": "策略状态机中的当前状态。"
          },
          "priority": {
            "type": "string",
            "enum": [
              "high",
              "normal",
              "low"
            ],
            "description": "任务优先级。"
          },
          "position": {
            "type": "number",
            "description": "同状态列内的稳定排序值。"
          },
          "labels": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1,
              "description": "用于筛选的标签。"
            },
            "description": "任务标签列表。"
          },
          "assignee": {
            "$ref": "#/components/schemas/TaskParticipantRef"
          },
          "responsibilityEpoch": {
            "type": "integer",
            "minimum": 1,
            "description": "每次 assign/handoff 递增的责任世代；旧 owner 的动作不得跨 epoch 生效。"
          },
          "contributors": {
            "type": "array",
            "maxItems": 128,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/TaskParticipantRef"
            },
            "description": "参与者可评论/处理自己的 child task，不自动获得主 Task 完成权。"
          },
          "watchers": {
            "type": "array",
            "maxItems": 256,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/TaskParticipantRef"
            },
            "description": "订阅者投影；通知与评论权每次按当前 scope/policy 重新鉴权。"
          },
          "claim": {
            "$ref": "#/components/schemas/TaskClaim"
          },
          "parent": {
            "$ref": "#/components/schemas/TaskRef"
          },
          "blockedBy": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskRef"
            },
            "description": "必须先完成的 canonical Task 引用。"
          },
          "blocks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskRef"
            },
            "description": "被此 Task 阻塞的 canonical Task 引用。"
          },
          "relatedTo": {
            "type": "array",
            "maxItems": 256,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/TaskRef"
            },
            "description": "同 board 中无向 related 关系的对端 Task 引用。"
          },
          "attachmentRefs": {
            "type": "array",
            "maxItems": 128,
            "items": {
              "$ref": "#/components/schemas/TaskAttachmentRef"
            },
            "description": "MediaStore 拥有的附件引用；读取/下载时重新鉴权。"
          },
          "approvalRefs": {
            "type": "array",
            "maxItems": 64,
            "items": {
              "$ref": "#/components/schemas/TaskApprovalRef"
            },
            "description": "Approval owner 拥有的审批引用；TaskBoard 只投影不伪造结果。"
          },
          "runRefs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RunRef"
            },
            "description": "按 Run ID 去重的来源/执行导航引用，保留首次关联快照；不授予 claim 权限。逐轮归属见 TaskEvent.runRef。"
          },
          "receiptRefs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ReceiptRef"
            },
            "description": "Receipt owner 中的关联回执引用。"
          },
          "workContextRefs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkContextRef"
            },
            "description": "Context/Session domain 拥有的 Work Context 引用；写入时重新鉴权并校验 canonical Task 一致性。"
          },
          "sourceRef": {
            "$ref": "#/components/schemas/TaskSourceRef"
          },
          "automationBindingRefs": {
            "type": "array",
            "maxItems": 64,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/TaskAutomationBindingRef"
            },
            "description": "Automation/Scheduler owner 验证后的 bindings；时间规则和运行状态不在 TaskBoard 复制。"
          },
          "workflowRefs": {
            "type": "array",
            "maxItems": 64,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/TaskWorkflowRef"
            },
            "description": "Workflow owner 验证后的稳定引用。"
          },
          "conversationRefs": {
            "type": "array",
            "maxItems": 64,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/TaskConversationRef"
            },
            "description": "Conversation owner 验证后的稳定引用。"
          },
          "workdirRef": {
            "$ref": "#/components/schemas/TaskWorkDirRef"
          },
          "mentionOccurrences": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskBoardMentionOccurrence"
            },
            "description": "Task description 当前 revision 的 camelCase Mention occurrence read projection。"
          },
          "mentionDeliveryRefs": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            },
            "description": "Mention domain 拥有的 description delivery IDs；不复制状态、Run 或正文。"
          },
          "review": {
            "$ref": "#/components/schemas/TaskReviewState"
          },
          "resultSummary": {
            "type": "string",
            "description": "已完成、失败或取消后的结果摘要。"
          },
          "dueAt": {
            "type": "string",
            "format": "date-time",
            "description": "计划到期时间；PR1 仅持久化，不提供自动调度。"
          },
          "recurrenceRef": {
            "type": "string",
            "minLength": 1,
            "readOnly": true,
            "description": "旧版只读兼容引用；新写入必须使用 Automation/Scheduler owner 的 typed binding，禁止发展成第二套调度器。"
          },
          "archivedAt": {
            "type": "string",
            "format": "date-time",
            "description": "归档时间；归档不改变审计事实。"
          },
          "deletedAt": {
            "type": "string",
            "format": "date-time",
            "description": "软删除时间。"
          },
          "createdBy": {
            "$ref": "#/components/schemas/ActorRef"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "Task 乐观并发版本，每次成功写入递增。"
          },
          "acceptanceCriteria": {
            "$ref": "#/components/schemas/TaskAcceptanceCriteria"
          },
          "progress": {
            "$ref": "#/components/schemas/TaskProgress"
          },
          "wakeRequest": {
            "$ref": "#/components/schemas/TaskWakeRequest"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardPublicComment": {
        "description": "TaskBoard domain 拥有的基础协作或 review 评论。",
        "type": "object",
        "required": [
          "schemaVersion",
          "id",
          "taskRef",
          "kind",
          "body",
          "actor",
          "version",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 3,
            "description": "Task comment 数据格式版本。"
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "description": "TaskBoard 内稳定 comment ID。"
          },
          "taskRef": {
            "$ref": "#/components/schemas/TaskRef"
          },
          "kind": {
            "type": "string",
            "enum": [
              "comment",
              "review"
            ],
            "description": "普通协作评论或验收/返工评论。"
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 65536,
            "description": "评论正文；只有结构化 occurrence 才触发 Mention，裸 @name 始终是普通文本。"
          },
          "actor": {
            "$ref": "#/components/schemas/ActorRef"
          },
          "attachmentRefs": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/TaskAttachmentRef"
            },
            "description": "当前 comment revision 的 MediaStore owner-safe 附件引用。"
          },
          "revisionHistory": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/TaskCommentRevision"
            },
            "description": "按 version 升序保存的不可变正文历史；旧快照缺失时读取层可按 version=1 兼容。"
          },
          "runRef": {
            "$ref": "#/components/schemas/RunRef"
          },
          "receiptRef": {
            "$ref": "#/components/schemas/ReceiptRef"
          },
          "workContextRef": {
            "$ref": "#/components/schemas/WorkContextRef"
          },
          "mentionOccurrences": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskBoardMentionOccurrence"
            },
            "description": "Comment 当前 revision 的 camelCase Mention occurrence read projection。"
          },
          "mentionDeliveryRefs": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1,
              "description": "Mention domain 拥有的 delivery ID。"
            },
            "description": "此来源 comment 发出的 delivery IDs；状态、Run 与 receipt 仍由各 owner 持有。"
          },
          "originMentionDeliveryId": {
            "type": "string",
            "minLength": 1,
            "description": "Agent 自动回评来自哪个 Mention delivery；与本评论向外发出的 delivery refs 分离。"
          },
          "originMentionSource": {
            "type": "object",
            "required": [
              "kind",
              "sourceId",
              "sourceRevision",
              "taskRef"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "taskDescription",
                  "taskComment"
                ],
                "description": "TaskBoard 公开来源类型。"
              },
              "sourceId": {
                "type": "string",
                "minLength": 1,
                "description": "Task ID 或 Task comment ID。"
              },
              "sourceRevision": {
                "type": "integer",
                "minimum": 1,
                "description": "不可变来源 revision。"
              },
              "taskRef": {
                "type": "object",
                "required": [
                  "boardId",
                  "taskId"
                ],
                "properties": {
                  "boardId": {
                    "type": "string",
                    "minLength": 1,
                    "description": "canonical Board ID。"
                  },
                  "taskId": {
                    "type": "string",
                    "minLength": 1,
                    "description": "canonical Task ID。"
                  },
                  "taskVersion": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "可选 Task version 快照。"
                  }
                },
                "additionalProperties": false,
                "description": "TaskBoard 公开来源的 canonical TaskRef。"
              }
            },
            "additionalProperties": false,
            "description": "Agent 自动回评来源的 camelCase TaskBoard read projection。"
          },
          "replyToCommentId": {
            "type": "string",
            "minLength": 1,
            "description": "仅 task_comment 来源的 Agent 回评必填；Task description 来源没有伪造 comment ID。"
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "Comment 乐观并发版本。"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "redactedAt": {
            "type": "string",
            "format": "date-time",
            "description": "普通 UI 开始隐藏正文的审计撤回时间。"
          },
          "redactedBy": {
            "$ref": "#/components/schemas/ActorRef"
          },
          "redactionReason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000,
            "description": "不包含被撤回正文的安全原因。"
          },
          "deletedAt": {
            "type": "string",
            "format": "date-time",
            "description": "评论软删除时间。"
          }
        },
        "allOf": [
          {
            "if": {
              "required": [
                "originMentionSource"
              ],
              "properties": {
                "originMentionSource": {
                  "required": [
                    "kind"
                  ],
                  "properties": {
                    "kind": {
                      "const": "taskComment"
                    }
                  }
                }
              }
            },
            "then": {
              "required": [
                "replyToCommentId"
              ]
            }
          },
          {
            "if": {
              "required": [
                "originMentionSource"
              ],
              "properties": {
                "originMentionSource": {
                  "required": [
                    "kind"
                  ],
                  "properties": {
                    "kind": {
                      "const": "taskDescription"
                    }
                  }
                }
              }
            },
            "then": {
              "not": {
                "required": [
                  "replyToCommentId"
                ]
              }
            }
          },
          {
            "if": {
              "properties": {
                "originMentionDeliveryId": {}
              },
              "required": [
                "originMentionDeliveryId"
              ]
            },
            "then": {
              "properties": {
                "originMentionSource": {},
                "runRef": {},
                "receiptRef": {},
                "workContextRef": {}
              },
              "required": [
                "originMentionSource",
                "runRef",
                "receiptRef",
                "workContextRef"
              ]
            }
          },
          {
            "if": {
              "properties": {
                "originMentionSource": {}
              },
              "required": [
                "originMentionSource"
              ]
            },
            "then": {
              "properties": {
                "originMentionDeliveryId": {}
              },
              "required": [
                "originMentionDeliveryId"
              ]
            }
          },
          {
            "if": {
              "properties": {
                "replyToCommentId": {}
              },
              "required": [
                "replyToCommentId"
              ]
            },
            "then": {
              "properties": {
                "originMentionDeliveryId": {}
              },
              "required": [
                "originMentionDeliveryId"
              ]
            }
          },
          {
            "if": {
              "properties": {
                "redactedAt": {}
              },
              "required": [
                "redactedAt"
              ]
            },
            "then": {
              "properties": {
                "redactedBy": {}
              },
              "required": [
                "redactedBy"
              ]
            }
          },
          {
            "if": {
              "properties": {
                "redactedBy": {}
              },
              "required": [
                "redactedBy"
              ]
            },
            "then": {
              "properties": {
                "redactedAt": {}
              },
              "required": [
                "redactedAt"
              ]
            }
          }
        ],
        "additionalProperties": false
      },
      "TaskRef": {
        "description": "跨会话和 Agent 稳定引用一个 canonical Task。",
        "type": "object",
        "required": [
          "boardId",
          "taskId"
        ],
        "properties": {
          "boardId": {
            "type": "string",
            "minLength": 1,
            "description": "Task 所属 canonical TaskBoard ID。"
          },
          "taskId": {
            "type": "string",
            "minLength": 1,
            "description": "TaskBoard 内稳定 Task ID。"
          },
          "taskVersion": {
            "type": "integer",
            "minimum": 1,
            "description": "可选的 Task CAS 版本；TaskCreate 返回时提供，可直接传给 Delegate。"
          }
        },
        "additionalProperties": false
      },
      "TaskAvailableAction": {
        "description": "服务端针对当前 actor 计算的 Task 动作。",
        "type": "object",
        "required": [
          "action",
          "enabled",
          "expectedVersion"
        ],
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "create",
              "update",
              "publish",
              "claim",
              "release",
              "submitForReview",
              "accept",
              "requestChanges",
              "fail",
              "cancel",
              "reopen",
              "delete",
              "addComment",
              "editAcceptanceCriteria",
              "assign",
              "addContributor",
              "removeContributor",
              "addWatcher",
              "removeWatcher",
              "forceRelease",
              "handoff",
              "fanOut",
              "assignReviewer",
              "reviewAccept",
              "reviewRequestChanges",
              "addRelation",
              "removeRelation",
              "addAttachment",
              "removeAttachment"
            ],
            "description": "服务端评估的基础状态机或 PR4 责任动作。"
          },
          "enabled": {
            "type": "boolean",
            "description": "当前 actor、scope、状态和 claim 下是否可执行。"
          },
          "expectedVersion": {
            "type": "integer",
            "minimum": 1,
            "description": "执行动作必须回传的 Task version。"
          },
          "targetStatus": {
            "type": "string",
            "enum": [
              "backlog",
              "pending",
              "inProgress",
              "blocked",
              "inReview",
              "completed",
              "failed",
              "canceled",
              "deleted"
            ],
            "description": "动作成功后的目标状态。"
          },
          "reasonCode": {
            "type": "string",
            "enum": [
              "invalidRequest",
              "taskContextMismatch",
              "taskContextUnavailable",
              "unauthenticated",
              "forbidden",
              "boardNotFound",
              "taskNotFound",
              "commentNotFound",
              "versionConflict",
              "claimConflict",
              "invalidTransition",
              "dependencyBlocked",
              "reviewRequired",
              "reviewRoundConflict",
              "commandAuthorityDenied",
              "taskPlanRequired",
              "claimLivenessUnknown",
              "claimStillActive",
              "relationConflict",
              "relationCycle",
              "attachmentRejected",
              "fanOutConflict",
              "capabilityDisabled",
              "capabilityUnavailable",
              "migrationFailed",
              "internalError"
            ],
            "description": "动作不可用时的稳定原因码。"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "description": "面向用户的安全动作说明。"
          },
          "requiredInputs": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "claimToken",
                "expectedClaimEpoch",
                "expectedResponsibilityEpoch",
                "targetActor",
                "reason",
                "reviewer",
                "expectedReviewRound",
                "expectedReviewerEpoch",
                "comment",
                "operationId",
                "fanOutTargets",
                "relation",
                "attachmentRef",
                "criteriaChecks"
              ],
              "description": "UI 只按服务端声明采集的输入类型。"
            },
            "description": "该动作还需要的结构化输入；前端不根据状态自行猜测。"
          }
        },
        "additionalProperties": false
      },
      "TaskFanOutDispatch": {
        "description": "一个 canonical taskFannedOut intent 的持久投递状态；child Task 已提交不等于 Agent Run 已启动。",
        "type": "object",
        "required": [
          "intentId",
          "operationId",
          "parentTaskRef",
          "childTaskRef",
          "targetAgentId",
          "state",
          "attempt",
          "retryable",
          "updatedAt"
        ],
        "properties": {
          "intentId": {
            "type": "string",
            "minLength": 1,
            "description": "由 canonical source event 冻结的 Delegate intent ID。"
          },
          "operationId": {
            "type": "string",
            "pattern": "^fanout-operation:[a-f0-9]{64}$",
            "description": "一次用户 fan-out 操作的稳定 ID；刷新和重试沿用，显式新操作才更换。"
          },
          "parentTaskRef": {
            "description": "发起 fan-out 的 canonical parent Task。",
            "type": "object",
            "required": [
              "boardId",
              "taskId"
            ],
            "properties": {
              "boardId": {
                "type": "string",
                "minLength": 1,
                "description": "Task 所属 canonical TaskBoard ID。"
              },
              "taskId": {
                "type": "string",
                "minLength": 1,
                "description": "TaskBoard 内稳定 Task ID。"
              },
              "taskVersion": {
                "type": "integer",
                "minimum": 1,
                "description": "可选的 Task CAS 版本；TaskCreate 返回时提供，可直接传给 Delegate。"
              }
            },
            "additionalProperties": false
          },
          "childTaskRef": {
            "$ref": "#/components/schemas/TaskRef"
          },
          "targetAgentId": {
            "type": "string",
            "minLength": 1,
            "description": "该 intent 的稳定目标 Agent ID。"
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "dispatching",
              "dispatched",
              "failed"
            ],
            "description": "pending/dispatching 可恢复；dispatched 已获 owner Run；failed 由 retryable 决定是否重试。"
          },
          "attempt": {
            "type": "integer",
            "minimum": 0,
            "description": "dispatcher 获得有效 lease 并尝试 owner 投递的次数。"
          },
          "retryable": {
            "type": "boolean",
            "description": "当前状态能否由同一 intent 自动或显式重试；不允许据此创建新 child Task。"
          },
          "runRef": {
            "$ref": "#/components/schemas/RunRef"
          },
          "receiptRef": {
            "$ref": "#/components/schemas/ReceiptRef"
          },
          "errorCode": {
            "type": "string",
            "minLength": 1,
            "description": "最近失败的稳定 owner/dispatcher 错误码。"
          },
          "errorMessage": {
            "type": "string",
            "minLength": 1,
            "maxLength": 8192,
            "description": "不含 claim token、路径或上下文正文的最近失败说明。"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "state": {
                  "const": "dispatched"
                }
              },
              "required": [
                "state"
              ]
            },
            "then": {
              "required": [
                "runRef"
              ]
            }
          }
        ],
        "additionalProperties": false
      },
      "TaskArchiveAction": {
        "description": "服务端为当前 principal 计算的 Task 归档/恢复动作。",
        "type": "object",
        "required": [
          "enabled",
          "archived",
          "expectedVersion"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "当前 principal 是否可执行归档或恢复。"
          },
          "archived": {
            "type": "boolean",
            "description": "当前 Task 是否归档。"
          },
          "expectedVersion": {
            "type": "integer",
            "minimum": 1,
            "description": "动作必须回传的 Task version。"
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "description": "不可用时的安全说明。"
          }
        },
        "additionalProperties": false
      },
      "TaskDeepLink": {
        "description": "不依赖展示名称、可复制并可在刷新后恢复的 TaskBoard 内部深链。",
        "type": "object",
        "required": [
          "taskRef",
          "route"
        ],
        "properties": {
          "taskRef": {
            "$ref": "#/components/schemas/TaskRef"
          },
          "route": {
            "type": "string",
            "pattern": "^/taskboards/[^/]+/tasks/[^/]+$",
            "description": "应用内稳定 route；board/task ID 必须按 path segment 编码。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardQueryFilter": {
        "description": "服务端在已授权 canonical boards 上执行的组合过滤条件。",
        "type": "object",
        "properties": {
          "keyword": {
            "type": "string",
            "maxLength": 512,
            "description": "大小写不敏感匹配 Task ID、标题、描述、标签和安全 owner 引用 ID。"
          },
          "boardIds": {
            "type": "array",
            "maxItems": 256,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            },
            "description": "限制到指定 canonical Board IDs；无权读取的 ID 静默不返回。"
          },
          "scopeTypes": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "user",
                "team",
                "agent",
                "session"
              ]
            },
            "description": "按 Board scope 类型过滤。"
          },
          "statuses": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "backlog",
                "pending",
                "inProgress",
                "blocked",
                "inReview",
                "completed",
                "failed",
                "canceled",
                "deleted"
              ]
            },
            "description": "按 policy 状态过滤。"
          },
          "priorities": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "high",
                "normal",
                "low"
              ]
            },
            "description": "按优先级过滤。"
          },
          "labels": {
            "type": "array",
            "maxItems": 128,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            },
            "description": "按标签过滤。"
          },
          "labelMatch": {
            "type": "string",
            "enum": [
              "any",
              "all"
            ],
            "description": "labels 是命中任一还是全部；省略等价 any。"
          },
          "participantIds": {
            "type": "array",
            "maxItems": 256,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            },
            "description": "匹配 assignee、claim actor、reviewer、contributors 或 watchers 的稳定 ID。"
          },
          "reviewStates": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "notSubmitted",
                "awaitingReview",
                "accepted",
                "changesRequested"
              ]
            },
            "description": "按 TaskBoard review projection 过滤。"
          },
          "due": {
            "type": "string",
            "enum": [
              "overdue",
              "upcoming",
              "none",
              "any"
            ],
            "description": "到期筛选；overdue/upcoming 以请求处理时刻为界，不启动调度。"
          },
          "sourceOwnerTypes": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "automation",
                "workflow",
                "conversation",
                "connector",
                "import",
                "manual"
              ]
            },
            "description": "按中性 sourceRef owner 类型过滤。"
          },
          "integrationTypes": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "automation",
                "workflow",
                "conversation",
                "workdir",
                "run"
              ]
            },
            "description": "只返回具有相应 owner 引用的 Task。"
          },
          "boardArchive": {
            "type": "string",
            "enum": [
              "active",
              "archived",
              "any"
            ],
            "description": "Board 归档筛选；省略时只返回 active Board。"
          },
          "taskArchive": {
            "type": "string",
            "enum": [
              "active",
              "archived",
              "any"
            ],
            "description": "Task 归档筛选；省略时只返回 active Task。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardQuerySort": {
        "description": "稳定 keyset 分页排序；最终始终以 boardId/taskId 消歧。",
        "type": "object",
        "required": [
          "field",
          "direction"
        ],
        "properties": {
          "field": {
            "type": "string",
            "enum": [
              "updatedAt",
              "createdAt",
              "dueAt",
              "priority",
              "position",
              "subject"
            ],
            "description": "主排序字段。"
          },
          "direction": {
            "type": "string",
            "enum": [
              "asc",
              "desc"
            ],
            "description": "主排序方向。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardQueryItem": {
        "description": "由 canonical Board/Task 即时授权并从可重建索引定位的查询行。",
        "type": "object",
        "required": [
          "board",
          "task",
          "commentCount",
          "deepLink",
          "availableActions",
          "archiveAction"
        ],
        "properties": {
          "board": {
            "$ref": "#/components/schemas/TaskBoardMeta"
          },
          "task": {
            "description": "当前 principal 可见的 Task 读投影。有认领时 claim.liveness 是本次查询读取时 RunManager 给出的执行存活判定（terminal 表示执行已结束，unknown 不应据此提示）；claim.token 在查询结果中一律省略。liveness 不参与索引与游标比较，仅 checkedAt 变化不会让翻页报 versionConflict。",
            "type": "object",
            "required": [
              "schemaVersion",
              "id",
              "boardId",
              "subject",
              "description",
              "status",
              "priority",
              "position",
              "labels",
              "blockedBy",
              "blocks",
              "runRefs",
              "receiptRefs",
              "workContextRefs",
              "review",
              "createdBy",
              "createdAt",
              "updatedAt",
              "version"
            ],
            "properties": {
              "schemaVersion": {
                "type": "integer",
                "const": 3,
                "description": "Task 数据格式版本。"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "TaskBoard 内稳定 Task ID。"
              },
              "boardId": {
                "type": "string",
                "minLength": 1,
                "description": "所属 canonical TaskBoard ID。"
              },
              "subject": {
                "type": "string",
                "minLength": 1,
                "description": "面向执行和列表展示的短标题。"
              },
              "description": {
                "type": "string",
                "description": "任务目标、边界和验收信息。"
              },
              "activeForm": {
                "type": "string",
                "minLength": 1,
                "description": "进行中展示文案。"
              },
              "status": {
                "type": "string",
                "enum": [
                  "backlog",
                  "pending",
                  "inProgress",
                  "blocked",
                  "inReview",
                  "completed",
                  "failed",
                  "canceled",
                  "deleted"
                ],
                "description": "策略状态机中的当前状态。"
              },
              "priority": {
                "type": "string",
                "enum": [
                  "high",
                  "normal",
                  "low"
                ],
                "description": "任务优先级。"
              },
              "position": {
                "type": "number",
                "description": "同状态列内的稳定排序值。"
              },
              "labels": {
                "type": "array",
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "description": "用于筛选的标签。"
                },
                "description": "任务标签列表。"
              },
              "assignee": {
                "$ref": "#/components/schemas/TaskParticipantRef"
              },
              "responsibilityEpoch": {
                "type": "integer",
                "minimum": 1,
                "description": "每次 assign/handoff 递增的责任世代；旧 owner 的动作不得跨 epoch 生效。"
              },
              "contributors": {
                "type": "array",
                "maxItems": 128,
                "uniqueItems": true,
                "items": {
                  "$ref": "#/components/schemas/TaskParticipantRef"
                },
                "description": "参与者可评论/处理自己的 child task，不自动获得主 Task 完成权。"
              },
              "watchers": {
                "type": "array",
                "maxItems": 256,
                "uniqueItems": true,
                "items": {
                  "$ref": "#/components/schemas/TaskParticipantRef"
                },
                "description": "订阅者投影；通知与评论权每次按当前 scope/policy 重新鉴权。"
              },
              "claim": {
                "$ref": "#/components/schemas/TaskClaim"
              },
              "parent": {
                "$ref": "#/components/schemas/TaskRef"
              },
              "blockedBy": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/TaskRef"
                },
                "description": "必须先完成的 canonical Task 引用。"
              },
              "blocks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/TaskRef"
                },
                "description": "被此 Task 阻塞的 canonical Task 引用。"
              },
              "relatedTo": {
                "type": "array",
                "maxItems": 256,
                "uniqueItems": true,
                "items": {
                  "$ref": "#/components/schemas/TaskRef"
                },
                "description": "同 board 中无向 related 关系的对端 Task 引用。"
              },
              "attachmentRefs": {
                "type": "array",
                "maxItems": 128,
                "items": {
                  "$ref": "#/components/schemas/TaskAttachmentRef"
                },
                "description": "MediaStore 拥有的附件引用；读取/下载时重新鉴权。"
              },
              "approvalRefs": {
                "type": "array",
                "maxItems": 64,
                "items": {
                  "$ref": "#/components/schemas/TaskApprovalRef"
                },
                "description": "Approval owner 拥有的审批引用；TaskBoard 只投影不伪造结果。"
              },
              "runRefs": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RunRef"
                },
                "description": "按 Run ID 去重的来源/执行导航引用，保留首次关联快照；不授予 claim 权限。逐轮归属见 TaskEvent.runRef。"
              },
              "receiptRefs": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ReceiptRef"
                },
                "description": "Receipt owner 中的关联回执引用。"
              },
              "workContextRefs": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/WorkContextRef"
                },
                "description": "Context/Session domain 拥有的 Work Context 引用；写入时重新鉴权并校验 canonical Task 一致性。"
              },
              "sourceRef": {
                "$ref": "#/components/schemas/TaskSourceRef"
              },
              "automationBindingRefs": {
                "type": "array",
                "maxItems": 64,
                "uniqueItems": true,
                "items": {
                  "$ref": "#/components/schemas/TaskAutomationBindingRef"
                },
                "description": "Automation/Scheduler owner 验证后的 bindings；时间规则和运行状态不在 TaskBoard 复制。"
              },
              "workflowRefs": {
                "type": "array",
                "maxItems": 64,
                "uniqueItems": true,
                "items": {
                  "$ref": "#/components/schemas/TaskWorkflowRef"
                },
                "description": "Workflow owner 验证后的稳定引用。"
              },
              "conversationRefs": {
                "type": "array",
                "maxItems": 64,
                "uniqueItems": true,
                "items": {
                  "$ref": "#/components/schemas/TaskConversationRef"
                },
                "description": "Conversation owner 验证后的稳定引用。"
              },
              "workdirRef": {
                "$ref": "#/components/schemas/TaskWorkDirRef"
              },
              "mentionOccurrences": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/TaskBoardMentionOccurrence"
                },
                "description": "Task description 当前 revision 的 camelCase Mention occurrence read projection。"
              },
              "mentionDeliveryRefs": {
                "type": "array",
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "description": "Mention domain 拥有的 description delivery IDs；不复制状态、Run 或正文。"
              },
              "review": {
                "$ref": "#/components/schemas/TaskReviewState"
              },
              "resultSummary": {
                "type": "string",
                "description": "已完成、失败或取消后的结果摘要。"
              },
              "dueAt": {
                "type": "string",
                "format": "date-time",
                "description": "计划到期时间；PR1 仅持久化，不提供自动调度。"
              },
              "recurrenceRef": {
                "type": "string",
                "minLength": 1,
                "readOnly": true,
                "description": "旧版只读兼容引用；新写入必须使用 Automation/Scheduler owner 的 typed binding，禁止发展成第二套调度器。"
              },
              "archivedAt": {
                "type": "string",
                "format": "date-time",
                "description": "归档时间；归档不改变审计事实。"
              },
              "deletedAt": {
                "type": "string",
                "format": "date-time",
                "description": "软删除时间。"
              },
              "createdBy": {
                "$ref": "#/components/schemas/ActorRef"
              },
              "createdAt": {
                "type": "string",
                "format": "date-time",
                "description": "ISO 8601 日期时间。"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time",
                "description": "ISO 8601 日期时间。"
              },
              "version": {
                "type": "integer",
                "minimum": 1,
                "description": "Task 乐观并发版本，每次成功写入递增。"
              },
              "acceptanceCriteria": {
                "$ref": "#/components/schemas/TaskAcceptanceCriteria"
              },
              "progress": {
                "$ref": "#/components/schemas/TaskProgress"
              },
              "wakeRequest": {
                "$ref": "#/components/schemas/TaskWakeRequest"
              }
            },
            "additionalProperties": false
          },
          "commentCount": {
            "type": "integer",
            "minimum": 0,
            "description": "canonical comments 中当前 Task 的未删除评论数量。"
          },
          "deepLink": {
            "$ref": "#/components/schemas/TaskDeepLink"
          },
          "availableActions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskAvailableAction"
            },
            "description": "查询时针对当前 principal 重新计算的 canonical Task 可用动作。"
          },
          "archiveAction": {
            "$ref": "#/components/schemas/TaskArchiveAction"
          }
        },
        "additionalProperties": false
      },
      "TaskStatusCount": {
        "description": "一个 Task 状态的授权聚合数量。",
        "type": "object",
        "required": [
          "status",
          "count"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "backlog",
              "pending",
              "inProgress",
              "blocked",
              "inReview",
              "completed",
              "failed",
              "canceled",
              "deleted"
            ],
            "description": "被统计的 Task 状态。"
          },
          "count": {
            "type": "integer",
            "minimum": 0,
            "description": "授权范围内该状态的 Task 数量。"
          }
        },
        "additionalProperties": false
      },
      "TaskActivityEnvelope": {
        "description": "Task workspace Activity 的统一展示 envelope；canonical event 与 owner projection 明确分流。",
        "type": "object",
        "required": [
          "activityId",
          "taskRef",
          "source",
          "occurredAt",
          "title"
        ],
        "properties": {
          "activityId": {
            "type": "string",
            "minLength": 1,
            "description": "UI 去重和稳定排序使用的活动 ID。"
          },
          "taskRef": {
            "$ref": "#/components/schemas/TaskRef"
          },
          "source": {
            "type": "string",
            "enum": [
              "taskEvent",
              "ownerProjection"
            ],
            "description": "事实来自哪个边界。"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "description": "本地化前的安全展示标题。"
          },
          "actor": {
            "$ref": "#/components/schemas/ActorRef"
          },
          "taskEvent": {
            "$ref": "#/components/schemas/TaskEvent"
          },
          "ownerProjection": {
            "$ref": "#/components/schemas/TaskActivityProjection"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "source": {
                  "const": "taskEvent"
                }
              },
              "required": [
                "source"
              ]
            },
            "then": {
              "required": [
                "taskEvent"
              ],
              "not": {
                "required": [
                  "ownerProjection"
                ]
              }
            }
          },
          {
            "if": {
              "properties": {
                "source": {
                  "const": "ownerProjection"
                }
              },
              "required": [
                "source"
              ]
            },
            "then": {
              "required": [
                "ownerProjection"
              ],
              "not": {
                "required": [
                  "taskEvent"
                ]
              }
            }
          }
        ],
        "additionalProperties": false
      },
      "TaskActivityPage": {
        "description": "当前历史页的范围与后页位置；追加新事件不扩大throughRevision，刷新重新取当前前缀。",
        "type": "object",
        "required": [
          "pageSize",
          "afterRevision",
          "throughRevision",
          "nextAfterRevision"
        ],
        "properties": {
          "pageSize": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "description": "本页canonical候选数量上限。"
          },
          "afterRevision": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "当前页排除的前序revision。"
          },
          "throughRevision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "本次浏览固定的Board历史前缀。"
          },
          "nextAfterRevision": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "下一页排除到的已扫描revision；null表示固定前缀已读完。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardError": {
        "description": "TaskBoard 稳定错误和可选权威冲突快照。",
        "type": "object",
        "required": [
          "code",
          "message",
          "retryable"
        ],
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "invalidRequest",
              "taskContextMismatch",
              "taskContextUnavailable",
              "unauthenticated",
              "forbidden",
              "boardNotFound",
              "taskNotFound",
              "commentNotFound",
              "versionConflict",
              "claimConflict",
              "invalidTransition",
              "dependencyBlocked",
              "reviewRequired",
              "reviewRoundConflict",
              "commandAuthorityDenied",
              "taskPlanRequired",
              "claimLivenessUnknown",
              "claimStillActive",
              "relationConflict",
              "relationCycle",
              "attachmentRejected",
              "fanOutConflict",
              "capabilityDisabled",
              "capabilityUnavailable",
              "migrationFailed",
              "internalError"
            ],
            "description": "稳定错误码。"
          },
          "message": {
            "type": "string",
            "minLength": 1,
            "description": "不含敏感数据的错误说明。"
          },
          "retryable": {
            "type": "boolean",
            "description": "客户端刷新权威状态后是否可以重试。"
          },
          "taskRef": {
            "$ref": "#/components/schemas/TaskRef"
          },
          "expectedVersion": {
            "type": "integer",
            "minimum": 0,
            "description": "请求提交的 Task version 或 board revision。"
          },
          "actualVersion": {
            "type": "integer",
            "minimum": 0,
            "description": "服务端当前 Task version 或 board revision。"
          },
          "capability": {
            "type": "string",
            "minLength": 1,
            "description": "capabilityDisabled 或 capabilityUnavailable 对应的稳定能力 ID。"
          },
          "claimLiveness": {
            "$ref": "#/components/schemas/TaskClaimLiveness"
          },
          "deniedAction": {
            "type": "string",
            "enum": [
              "assign",
              "addContributor",
              "removeContributor",
              "addWatcher",
              "removeWatcher",
              "forceRelease",
              "handoff",
              "fanOut",
              "assignReviewer",
              "reviewAccept",
              "reviewRequestChanges",
              "addRelation",
              "removeRelation",
              "addAttachment",
              "removeAttachment"
            ],
            "description": "commandAuthorityDenied 对应的责任动作。"
          },
          "latest": {
            "type": "object",
            "required": [
              "boardRevision"
            ],
            "properties": {
              "boardRevision": {
                "type": "integer",
                "minimum": 0,
                "description": "冲突发生时的最新 TaskBoard revision。"
              },
              "task": {
                "$ref": "#/components/schemas/TaskBoardPublicTaskItem"
              },
              "comment": {
                "$ref": "#/components/schemas/TaskBoardPublicComment"
              },
              "availableActions": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/TaskAvailableAction"
                },
                "description": "针对最新 Task 重新计算的可用动作。"
              }
            },
            "additionalProperties": false,
            "description": "versionConflict 时供客户端立即回滚/重绘的权威最小快照。"
          },
          "criteriaChecks": {
            "type": "object",
            "required": [
              "criteriaRevision",
              "missingCriterionIds",
              "unknownCriterionIds",
              "duplicateCriterionIds",
              "invalidAttachmentMediaIds",
              "invalidCommentIds"
            ],
            "properties": {
              "criteriaRevision": {
                "type": "integer",
                "minimum": 1,
                "description": "校验时任务验收标准的 revision。"
              },
              "missingCriterionIds": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "还没有自评的当前条目。"
              },
              "unknownCriterionIds": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "不在当前标准里的条目 ID。"
              },
              "duplicateCriterionIds": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "自评了不止一次的条目 ID。"
              },
              "invalidAttachmentMediaIds": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "不在本任务附件里的 mediaId。"
              },
              "invalidCommentIds": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "不属于本任务或已撤回的评论 ID。"
              }
            },
            "additionalProperties": false,
            "description": "提交时逐条自评没通过结构校验的明细，执行者据此补齐重试（ADR-311）。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardArchiveAction": {
        "description": "服务端为当前 principal 计算的 Board 归档/恢复动作；UI 不根据 owner 字段猜权限。",
        "type": "object",
        "required": [
          "enabled",
          "archived",
          "expectedBoardRevision"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "当前 principal 是否可执行归档或恢复。"
          },
          "archived": {
            "type": "boolean",
            "description": "当前 Board 是否已归档；动作会切换到相反状态。"
          },
          "expectedBoardRevision": {
            "type": "integer",
            "minimum": 1,
            "description": "动作必须回传的 Board revision。"
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "description": "不可用时的安全说明。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardScope": {
        "description": "TaskBoard 的持久化和授权作用域。",
        "type": "object",
        "required": [
          "type",
          "id"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "user",
              "team",
              "agent",
              "session"
            ],
            "description": "TaskBoard 的授权作用域类型；global 仅是授权聚合视图，不是持久化作用域。"
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "description": "作用域稳定 ID：用户、团队、Agent 或 Session ID。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardPolicy": {
        "description": "控制状态、流转、认领、验收和能力边界的数据驱动策略。",
        "type": "object",
        "required": [
          "id",
          "version",
          "description",
          "claimMode",
          "review",
          "statuses",
          "transitions",
          "capabilities"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "description": "策略稳定 ID。"
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "策略数据版本。"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "description": "策略目标与适用边界。"
          },
          "claimMode": {
            "type": "string",
            "enum": [
              "singleActiveClaim"
            ],
            "description": "同一 Task 同时只允许一个活动 claim。"
          },
          "review": {
            "$ref": "#/components/schemas/TaskReviewPolicy"
          },
          "statuses": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/TaskStatusDefinition"
            },
            "description": "由服务端返回、供通用 UI 渲染的状态定义。"
          },
          "transitions": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/TaskTransitionDefinition"
            },
            "description": "服务端执行并返回给 UI 的状态流转规则。"
          },
          "capabilities": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/TaskBoardCapability"
            },
            "description": "当前版本真实可用或明确不可用的能力清单。"
          },
          "projections": {
            "$ref": "#/components/schemas/TaskBoardProjections"
          }
        },
        "additionalProperties": false
      },
      "ActorRef": {
        "description": "记录事实执行者的稳定身份和可选展示快照。",
        "type": "object",
        "required": [
          "type",
          "id"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "human",
              "agent",
              "system"
            ],
            "description": "事实执行者类型；授权必须按稳定 ID 重新判定，不能信任展示名称。"
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "description": "用户 ID、Agent ID 或系统主体 ID。"
          },
          "displayName": {
            "type": "string",
            "minLength": 1,
            "description": "写入事实时的展示名称快照，不参与身份唯一性或授权。"
          }
        },
        "additionalProperties": false
      },
      "TaskParticipantRef": {
        "description": "可承担 Task 责任、参与或订阅的 human/agent 稳定身份；system 不能成为责任主体。",
        "type": "object",
        "required": [
          "type",
          "id"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "human",
              "agent"
            ],
            "description": "责任主体只能是 human 或 agent。"
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "description": "用户 ID、Agent ID 或系统主体 ID。"
          },
          "displayName": {
            "type": "string",
            "minLength": 1,
            "description": "写入事实时的展示名称快照，不参与身份唯一性或授权。"
          }
        },
        "additionalProperties": false
      },
      "TaskClaim": {
        "description": "Task 当前唯一活动认领事实。",
        "type": "object",
        "required": [
          "actor",
          "epoch",
          "claimedAt"
        ],
        "properties": {
          "actor": {
            "$ref": "#/components/schemas/TaskParticipantRef"
          },
          "token": {
            "type": "string",
            "minLength": 16,
            "description": "不可预测的活动 claim token；持久事实必填，但非 claim actor 的读投影必须省略。"
          },
          "epoch": {
            "type": "integer",
            "minimum": 1,
            "description": "每次重新认领递增的 claim 世代。"
          },
          "claimedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "runRef": {
            "$ref": "#/components/schemas/RunRef"
          },
          "workContextRef": {
            "$ref": "#/components/schemas/WorkContextRef"
          },
          "liveness": {
            "$ref": "#/components/schemas/TaskClaimLiveness"
          },
          "execution": {
            "$ref": "#/components/schemas/TaskClaimExecution"
          }
        },
        "additionalProperties": false
      },
      "TaskAttachmentRef": {
        "description": "MediaStore 拥有的安全附件引用；TaskBoard 不保存原始字节或本地路径。",
        "type": "object",
        "required": [
          "mediaId",
          "name",
          "mimeType",
          "sizeBytes"
        ],
        "properties": {
          "mediaId": {
            "type": "string",
            "minLength": 1,
            "description": "MediaStore 中稳定且重新鉴权的媒体 ID。"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "description": "写入时的安全文件名快照。"
          },
          "mimeType": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "description": "MediaStore 校验后的 MIME 快照。"
          },
          "sizeBytes": {
            "type": "integer",
            "minimum": 0,
            "description": "MediaStore 校验后的字节数快照。"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$",
            "description": "可选的内容完整性摘要。"
          }
        },
        "additionalProperties": false
      },
      "TaskApprovalRef": {
        "description": "Approval domain 拥有的审批引用及可审计快照。",
        "type": "object",
        "required": [
          "approvalId"
        ],
        "properties": {
          "approvalId": {
            "type": "string",
            "minLength": 1,
            "description": "Approval owner 中的稳定 ID。"
          },
          "stateSnapshot": {
            "type": "string",
            "enum": [
              "pending",
              "approved",
              "rejected",
              "expired",
              "canceled"
            ],
            "description": "写入时的状态快照；执行 gate 必须回 Approval owner 重新读取。"
          }
        },
        "additionalProperties": false
      },
      "RunRef": {
        "description": "引用 RunManager 拥有的执行事实。",
        "type": "object",
        "required": [
          "runId"
        ],
        "properties": {
          "runId": {
            "type": "string",
            "minLength": 1,
            "description": "RunManager 拥有的稳定 Run ID。"
          },
          "sessionId": {
            "type": "string",
            "minLength": 1,
            "description": "Run 所属 Session ID，便于授权后跳转。"
          },
          "agentId": {
            "type": "string",
            "minLength": 1,
            "description": "执行 Run 的 Agent ID 快照。"
          },
          "clientRequestId": {
            "type": "string",
            "minLength": 1,
            "description": "工具调用起点冻结的轮次 ID；Run/Session 可复用，禁止从其最新状态反推。旧记录可缺失。"
          },
          "sourceMessageId": {
            "type": "string",
            "minLength": 1,
            "description": "同次调用冻结的已持久化用户消息锚点；旧记录或未持久化消息可缺失。"
          }
        },
        "additionalProperties": false
      },
      "ReceiptRef": {
        "description": "引用 Receipt owner 拥有的执行回执。",
        "type": "object",
        "required": [
          "receiptId"
        ],
        "properties": {
          "receiptId": {
            "type": "string",
            "minLength": 1,
            "description": "Receipt owner 中的稳定回执 ID。"
          },
          "runId": {
            "type": "string",
            "minLength": 1,
            "description": "生成该回执的 Run ID 快照。"
          }
        },
        "additionalProperties": false
      },
      "WorkContextRef": {
        "description": "引用 Context/Session domain 拥有的 Work Context。",
        "type": "object",
        "required": [
          "workContextId"
        ],
        "properties": {
          "workContextId": {
            "type": "string",
            "minLength": 1,
            "description": "Context/Session domain 拥有的稳定 Work Context ID。"
          },
          "agentId": {
            "type": "string",
            "minLength": 1,
            "description": "该 Work Context 的目标 Agent ID 快照。"
          },
          "mode": {
            "type": "string",
            "enum": [
              "continue",
              "isolated",
              "fork"
            ],
            "description": "创建该上下文时显式选择的模式；V2 不提供默认值。"
          }
        },
        "additionalProperties": false
      },
      "TaskSourceRef": {
        "description": "外部 owner 中产生此 Task 的稳定来源身份；TaskBoard 仅用于幂等、筛选和跳转。",
        "type": "object",
        "required": [
          "ownerType",
          "ownerId",
          "sourceKey"
        ],
        "properties": {
          "ownerType": {
            "type": "string",
            "enum": [
              "automation",
              "workflow",
              "conversation",
              "connector",
              "import",
              "manual"
            ],
            "description": "来源 owner 类型；manual 表示由用户或 Agent 通过公开 Task API 创建。"
          },
          "ownerId": {
            "type": "string",
            "minLength": 1,
            "description": "来源 owner 中的稳定资源 ID。"
          },
          "sourceKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "description": "owner 作用域内稳定幂等键；相同 ownerType/ownerId/sourceKey 不应创建第二个 Task。"
          },
          "occurrenceAt": {
            "type": "string",
            "format": "date-time",
            "description": "周期或外部事件的 nominal occurrence 时间；不是 TaskBoard 调度时间。"
          },
          "sourceUrl": {
            "type": "string",
            "format": "uri",
            "pattern": "^https?://",
            "maxLength": 4096,
            "description": "来源对象的安全 HTTP(S) 深链；只用于导航，不参与来源身份、授权或幂等。"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "description": "安全展示快照，不参与授权。"
          }
        },
        "additionalProperties": false
      },
      "TaskAutomationBindingRef": {
        "description": "Automation/Scheduler owner 的 typed resource binding；TaskBoard 不保存 cron、RRULE、重试或执行历史。",
        "type": "object",
        "required": [
          "agentId",
          "scheduleId"
        ],
        "properties": {
          "agentId": {
            "type": "string",
            "minLength": 1,
            "description": "Scheduler 中拥有该 Schedule 的稳定 Agent ID。"
          },
          "scheduleId": {
            "type": "string",
            "minLength": 1,
            "description": "Scheduler owner 中的稳定 Schedule ID。"
          },
          "automationRecipeId": {
            "type": "string",
            "minLength": 1,
            "description": "可选的 Automation recipe/template ID；不是第二份 Schedule identity。"
          },
          "bindingId": {
            "type": "string",
            "minLength": 1,
            "description": "Automation owner 中绑定此 Task/Board 的稳定 binding ID。"
          },
          "occurrenceAt": {
            "type": "string",
            "format": "date-time",
            "description": "产生当前 Task 的 nominal occurrence 时间；真正 next/last run 从 owner 实时读取。"
          }
        },
        "additionalProperties": false
      },
      "TaskWorkflowRef": {
        "description": "Workflow Service 拥有的定义或运行引用。",
        "type": "object",
        "required": [
          "workflowId"
        ],
        "properties": {
          "workflowId": {
            "type": "string",
            "minLength": 1,
            "description": "Workflow Service 中的稳定 Workflow ID。"
          },
          "workflowRunId": {
            "type": "string",
            "minLength": 1,
            "description": "可选的稳定 Workflow Run ID。"
          },
          "nodeId": {
            "type": "string",
            "minLength": 1,
            "description": "可选的 Workflow 节点 ID 快照。"
          }
        },
        "additionalProperties": false
      },
      "TaskConversationRef": {
        "description": "Conversation/Run owner 中与 Task 协作相关的稳定会话引用。",
        "type": "object",
        "required": [
          "conversationId"
        ],
        "properties": {
          "conversationId": {
            "type": "string",
            "minLength": 1,
            "description": "Conversation owner 中的稳定 Conversation ID。"
          },
          "agentId": {
            "type": "string",
            "minLength": 1,
            "description": "会话当前 Agent ID 快照，仅用于展示和跳转提示。"
          },
          "runId": {
            "type": "string",
            "minLength": 1,
            "description": "可选的关联 Run ID；Run 生命周期仍由 RunManager 拥有。"
          }
        },
        "additionalProperties": false
      },
      "TaskWorkDirRef": {
        "description": "WorkDir owner 中的稳定工作目录引用；TaskBoard 不管理目录或 worktree 生命周期。",
        "type": "object",
        "required": [
          "workdirId",
          "ownerScope"
        ],
        "properties": {
          "workdirId": {
            "type": "string",
            "minLength": 1,
            "description": "WorkDir owner 中的稳定 ID。"
          },
          "ownerScope": {
            "type": "object",
            "required": [
              "type",
              "id"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "user",
                  "agent",
                  "team"
                ],
                "description": "WorkDir 配置的 owner scope。"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "用户、Agent 或 Team 的稳定 owner ID。"
              }
            },
            "additionalProperties": false,
            "description": "解析 workdirId 所需的 owner scope；不包含绝对路径。"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "description": "授权写入时的安全展示快照。"
          },
          "repositoryId": {
            "type": "string",
            "minLength": 1,
            "description": "可选的 CodeRepo owner 稳定仓库 ID。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardMentionOccurrence": {
        "type": "object",
        "required": [
          "schemaVersion",
          "occurrenceId",
          "target",
          "source",
          "range",
          "actor",
          "createdAt"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "Mention occurrence 格式版本。"
          },
          "occurrenceId": {
            "type": "string",
            "minLength": 8,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$",
            "description": "当前 Task description/comment revision 内稳定的 occurrence ID。"
          },
          "target": {
            "type": "object",
            "required": [
              "agentId",
              "displayNameSnapshot"
            ],
            "properties": {
              "agentId": {
                "type": "string",
                "minLength": 1,
                "description": "Registry 中稳定的 Agent ID。"
              },
              "displayNameSnapshot": {
                "type": "string",
                "minLength": 1,
                "description": "仅用于展示的名称快照。"
              }
            },
            "additionalProperties": false,
            "description": "canonical recipient Agent 快照。"
          },
          "source": {
            "$ref": "#/components/schemas/TaskBoardMentionSourceRef"
          },
          "range": {
            "type": "object",
            "required": [
              "start",
              "end"
            ],
            "properties": {
              "start": {
                "type": "integer",
                "minimum": 0,
                "description": "UTF-16 半开区间起点。"
              },
              "end": {
                "type": "integer",
                "minimum": 1,
                "description": "UTF-16 半开区间终点。"
              }
            },
            "additionalProperties": false,
            "description": "token 在正文中的 UTF-16 半开区间。"
          },
          "actor": {
            "type": "object",
            "required": [
              "type",
              "id"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "human",
                  "agent",
                  "system"
                ],
                "description": "来源写入 actor 类型。"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "来源写入 actor 稳定 ID。"
              },
              "displayNameSnapshot": {
                "type": "string",
                "minLength": 1,
                "description": "可选展示名称快照。"
              }
            },
            "additionalProperties": false,
            "description": "TaskBoard 对外公开的来源 actor。"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "occurrence 创建时间。"
          }
        },
        "additionalProperties": false,
        "description": "TaskBoard read DTO 中的 camelCase Mention occurrence。"
      },
      "TaskReviewState": {
        "description": "Task 当前验收轮次、提交和决定。",
        "type": "object",
        "required": [
          "state",
          "round"
        ],
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "notSubmitted",
              "awaitingReview",
              "accepted",
              "changesRequested"
            ],
            "description": "当前验收事实；Task status 仍是列表和流转主状态。"
          },
          "round": {
            "type": "integer",
            "minimum": 0,
            "description": "提交验收的轮次；每次重新提交递增。"
          },
          "submission": {
            "$ref": "#/components/schemas/TaskSubmission"
          },
          "decision": {
            "$ref": "#/components/schemas/TaskReviewDecision"
          },
          "stageIndex": {
            "type": "integer",
            "minimum": 0,
            "description": "当前 multi-stage policy 中的 stage 索引。"
          },
          "assignment": {
            "$ref": "#/components/schemas/TaskReviewAssignment"
          },
          "history": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskReviewHistoryEntry"
            },
            "description": "已结束 stage/round 的审计投影；不代替 append-only Task event。"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "state": {
                  "const": "notSubmitted"
                }
              },
              "required": [
                "state"
              ]
            },
            "then": {
              "properties": {
                "round": {
                  "const": 0
                }
              },
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "submission"
                    ]
                  },
                  {
                    "required": [
                      "decision"
                    ]
                  },
                  {
                    "required": [
                      "stageIndex"
                    ]
                  },
                  {
                    "required": [
                      "assignment"
                    ]
                  }
                ]
              }
            }
          },
          {
            "if": {
              "properties": {
                "state": {
                  "const": "awaitingReview"
                }
              },
              "required": [
                "state"
              ]
            },
            "then": {
              "required": [
                "submission"
              ],
              "properties": {
                "round": {
                  "minimum": 1
                }
              },
              "not": {
                "required": [
                  "decision"
                ]
              }
            }
          },
          {
            "if": {
              "properties": {
                "state": {
                  "const": "accepted"
                }
              },
              "required": [
                "state"
              ]
            },
            "then": {
              "required": [
                "submission",
                "decision"
              ],
              "properties": {
                "round": {
                  "minimum": 1
                },
                "decision": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/TaskReviewDecision"
                    },
                    {
                      "properties": {
                        "outcome": {
                          "const": "accepted"
                        }
                      }
                    }
                  ]
                }
              },
              "not": {
                "required": [
                  "assignment"
                ]
              }
            }
          },
          {
            "if": {
              "properties": {
                "state": {
                  "const": "changesRequested"
                }
              },
              "required": [
                "state"
              ]
            },
            "then": {
              "required": [
                "submission",
                "decision"
              ],
              "properties": {
                "round": {
                  "minimum": 1
                },
                "decision": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/TaskReviewDecision"
                    },
                    {
                      "properties": {
                        "outcome": {
                          "const": "changesRequested"
                        }
                      }
                    }
                  ]
                }
              },
              "not": {
                "required": [
                  "assignment"
                ]
              }
            }
          },
          {
            "if": {
              "required": [
                "assignment"
              ]
            },
            "then": {
              "properties": {
                "state": {
                  "const": "awaitingReview"
                }
              },
              "required": [
                "submission"
              ]
            }
          }
        ],
        "additionalProperties": false
      },
      "TaskCommentRevision": {
        "description": "Comment 的不可变正文 revision；最新投影仍保留在 TaskComment.body。",
        "type": "object",
        "required": [
          "version",
          "body",
          "actor",
          "occurredAt"
        ],
        "properties": {
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "Comment revision 版本，从 1 单调递增。"
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 65536,
            "description": "此 revision 的完整正文。"
          },
          "actor": {
            "$ref": "#/components/schemas/ActorRef"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000,
            "description": "可选修订原因。"
          },
          "attachmentRefs": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/TaskAttachmentRef"
            },
            "description": "此 revision 引用的 MediaStore owner-safe 附件快照。"
          }
        },
        "additionalProperties": false
      },
      "TaskEvent": {
        "description": "TaskBoard 原子提交产生的 append-only 审计事件。",
        "type": "object",
        "required": [
          "schemaVersion",
          "eventId",
          "boardId",
          "boardRevision",
          "type",
          "actor",
          "occurredAt",
          "data"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 3,
            "description": "Task event 数据格式版本。"
          },
          "eventId": {
            "type": "string",
            "minLength": 1,
            "description": "幂等且稳定的事件 ID。"
          },
          "boardId": {
            "type": "string",
            "minLength": 1,
            "description": "事件所属 TaskBoard ID。"
          },
          "boardRevision": {
            "type": "integer",
            "minimum": 1,
            "description": "提交此事件后的 TaskBoard revision。"
          },
          "type": {
            "type": "string",
            "enum": [
              "boardCreated",
              "boardArchived",
              "boardRestored",
              "boardPolicyChanged",
              "taskCreated",
              "taskArchived",
              "taskRestored",
              "taskUpdated",
              "taskPublished",
              "taskClaimed",
              "taskReleased",
              "taskSubmitted",
              "reviewAccepted",
              "reviewChangesRequested",
              "taskFailed",
              "taskCanceled",
              "taskReopened",
              "taskDeleted",
              "commentAdded",
              "commentRevised",
              "commentRedacted",
              "mentionDispatched",
              "taskAssigned",
              "contributorAdded",
              "contributorRemoved",
              "watcherAdded",
              "watcherRemoved",
              "claimForceReleased",
              "taskHandedOff",
              "taskFannedOut",
              "reviewerAssigned",
              "claimExecutionEnded",
              "reviewStageAccepted",
              "reviewStageChangesRequested",
              "taskRelationAdded",
              "taskRelationRemoved",
              "taskAttachmentAdded",
              "taskAttachmentRemoved",
              "taskResourceBound",
              "taskResourceReplaced",
              "taskResourceRemoved",
              "taskApprovalBound",
              "taskApprovalUnbound",
              "workflowTriggerReserved",
              "workflowTriggerMaterialized",
              "workflowTriggerAcknowledged"
            ],
            "description": "事件事实类型。"
          },
          "taskRef": {
            "$ref": "#/components/schemas/TaskRef"
          },
          "commentId": {
            "type": "string",
            "minLength": 1,
            "description": "关联 comment ID。"
          },
          "taskVersion": {
            "type": "integer",
            "minimum": 1,
            "description": "提交此事件后的 Task version。"
          },
          "runRef": {
            "description": "本次写入起点由可信 runtime 冻结的 Run/轮次来源；与任务原子提交，不代表 claim 授权。旧事件可缺失。",
            "type": "object",
            "required": [
              "runId"
            ],
            "properties": {
              "runId": {
                "type": "string",
                "minLength": 1,
                "description": "RunManager 拥有的稳定 Run ID。"
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "description": "Run 所属 Session ID，便于授权后跳转。"
              },
              "agentId": {
                "type": "string",
                "minLength": 1,
                "description": "执行 Run 的 Agent ID 快照。"
              },
              "clientRequestId": {
                "type": "string",
                "minLength": 1,
                "description": "工具调用起点冻结的轮次 ID；Run/Session 可复用，禁止从其最新状态反推。旧记录可缺失。"
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "description": "同次调用冻结的已持久化用户消息锚点；旧记录或未持久化消息可缺失。"
              }
            },
            "additionalProperties": false
          },
          "actor": {
            "$ref": "#/components/schemas/ActorRef"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "data": {
            "type": "object",
            "description": "事件类型特有的非敏感事实；稳定身份和 owner 事实使用顶层引用。",
            "additionalProperties": true
          }
        },
        "allOf": [
          {
            "if": {
              "required": [
                "type"
              ],
              "properties": {
                "type": {
                  "const": "boardPolicyChanged"
                }
              }
            },
            "then": {
              "properties": {
                "data": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "expectedBoardRevision",
                    "previousPolicy",
                    "nextPolicy"
                  ],
                  "properties": {
                    "expectedBoardRevision": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 9007199254740991,
                      "description": "调用者观察的原Board正安全整数revision；不自动替换为latest。"
                    },
                    "previousPolicy": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "version",
                        "hash"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 512,
                          "description": "原注册策略族ID，不是新owner或权限。"
                        },
                        "version": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 9007199254740991,
                          "description": "此不可变策略快照的版本。"
                        },
                        "hash": {
                          "type": "string",
                          "pattern": "^[a-f0-9]{64}$",
                          "description": "完整不可变policy的canonical JSON SHA-256；不只比较id/version。"
                        }
                      },
                      "description": "策略快照的窄审计身份；完整快照仍在同一canonical Board revision中。"
                    },
                    "nextPolicy": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "version",
                        "hash"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 512,
                          "description": "原注册策略族ID，不是新owner或权限。"
                        },
                        "version": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 9007199254740991,
                          "description": "此不可变策略快照的版本。"
                        },
                        "hash": {
                          "type": "string",
                          "pattern": "^[a-f0-9]{64}$",
                          "description": "完整不可变policy的canonical JSON SHA-256；不只比较id/version。"
                        }
                      },
                      "description": "策略快照的窄审计身份；完整快照仍在同一canonical Board revision中。"
                    }
                  },
                  "description": "boardPolicyChanged原子审计数据；actor/时间/事件ID沿TaskEvent来源，不由请求自报。"
                },
                "actor": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "const": "human"
                    }
                  }
                }
              },
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "taskRef"
                    ]
                  },
                  {
                    "required": [
                      "taskVersion"
                    ]
                  },
                  {
                    "required": [
                      "commentId"
                    ]
                  }
                ]
              }
            }
          }
        ],
        "additionalProperties": false
      },
      "TaskActivityProjection": {
        "description": "非 TaskBoard owner 的授权活动摘要；原 owner 事实不复制到 canonical commit。",
        "type": "object",
        "required": [
          "ownerType",
          "ownerId",
          "occurrenceId",
          "kind",
          "occurredAt",
          "summary"
        ],
        "properties": {
          "ownerType": {
            "type": "string",
            "enum": [
              "automation",
              "workflow",
              "conversation",
              "run",
              "workContext",
              "approval",
              "notification"
            ],
            "description": "投影事实的权威 owner。"
          },
          "ownerId": {
            "type": "string",
            "minLength": 1,
            "description": "owner 中稳定资源 ID。"
          },
          "occurrenceId": {
            "type": "string",
            "minLength": 1,
            "description": "owner 中稳定事件/运行/发生 ID。"
          },
          "kind": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "description": "owner 定义的安全活动类型。"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "summary": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000,
            "description": "通过 owner 授权后的安全摘要。"
          },
          "deepLink": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048,
            "description": "授权后可访问的 owner 内部深链。"
          }
        },
        "additionalProperties": false
      },
      "TaskClaimLiveness": {
        "description": "RunManager/Agent Activity 在读取时给出的 claim liveness 投影；TaskBoard 不成为真源。",
        "type": "object",
        "required": [
          "state",
          "checkedAt",
          "source"
        ],
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "alive",
              "terminal",
              "unknown"
            ],
            "description": "alive=权威 owner 确认活跃，terminal=确认终止，unknown=无法安全判定。"
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "source": {
            "type": "string",
            "enum": [
              "runManager",
              "agentActivity",
              "noRuntimeRef",
              "executionRecord"
            ],
            "description": "本次校验使用的权威 owner 或明确无 Runtime 引用；executionRecord 表示读取认领上已写回的执行结束记录（ADR-309）。"
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "description": "安全的非敏感判定说明。"
          }
        },
        "additionalProperties": false
      },
      "TaskReviewPolicy": {
        "description": "Task 提交结果后的验收策略。",
        "type": "object",
        "required": [
          "mode",
          "reviewer",
          "changesRequestedStatus"
        ],
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "none",
              "agentReview",
              "supervisorReview",
              "humanAcceptance",
              "approvalRef",
              "multiStage"
            ],
            "description": "默认/legacy 审核模式；multiStage 时以 stages 为权威顺序。"
          },
          "reviewer": {
            "type": "string",
            "enum": [
              "none",
              "explicitActor",
              "teamSupervisor",
              "ownerUser",
              "approvalOwner",
              "stageDefined"
            ],
            "description": "默认/legacy reviewer 解析策略；multiStage 使用 stageDefined。"
          },
          "changesRequestedStatus": {
            "type": "string",
            "enum": [
              "pending",
              "inProgress"
            ],
            "description": "返工后 Task 回到的状态；legacy 允许 inProgress，PR4 新 policy 必须使用 pending。"
          },
          "stages": {
            "type": "array",
            "minItems": 1,
            "maxItems": 8,
            "items": {
              "$ref": "#/components/schemas/TaskReviewStagePolicy"
            },
            "description": "multiStage 按顺序执行的审核 gate；每个 stage 都重新鉴权。"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "mode": {
                  "const": "multiStage"
                }
              },
              "required": [
                "mode"
              ]
            },
            "then": {
              "required": [
                "stages"
              ],
              "properties": {
                "reviewer": {
                  "const": "stageDefined"
                },
                "changesRequestedStatus": {
                  "const": "pending"
                }
              }
            }
          }
        ],
        "additionalProperties": false
      },
      "TaskStatusDefinition": {
        "description": "供 policy 和通用 UI 共用的状态自描述数据。",
        "type": "object",
        "required": [
          "status",
          "label",
          "description",
          "category"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "backlog",
              "pending",
              "inProgress",
              "blocked",
              "inReview",
              "completed",
              "failed",
              "canceled",
              "deleted"
            ],
            "description": "状态机中的稳定状态值。"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "description": "由服务端策略提供的默认展示名称。"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "description": "该状态代表的事实语义。"
          },
          "category": {
            "type": "string",
            "enum": [
              "notStarted",
              "active",
              "review",
              "terminal",
              "hidden"
            ],
            "description": "用于通用视图分组的状态类别，不替代具体状态。"
          }
        },
        "additionalProperties": false
      },
      "TaskTransitionDefinition": {
        "description": "Task 状态机中的一个服务端执行流转。",
        "type": "object",
        "required": [
          "action",
          "from",
          "to",
          "actorTypes",
          "description"
        ],
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "create",
              "update",
              "publish",
              "claim",
              "release",
              "submitForReview",
              "accept",
              "requestChanges",
              "fail",
              "cancel",
              "reopen",
              "delete",
              "addComment",
              "editAcceptanceCriteria"
            ],
            "description": "触发此流转的稳定动作。"
          },
          "from": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "backlog",
                "pending",
                "inProgress",
                "blocked",
                "inReview",
                "completed",
                "failed",
                "canceled",
                "deleted"
              ],
              "description": "允许的起始状态。"
            },
            "description": "动作可接受的起始状态集合。"
          },
          "to": {
            "type": "string",
            "enum": [
              "backlog",
              "pending",
              "inProgress",
              "blocked",
              "inReview",
              "completed",
              "failed",
              "canceled",
              "deleted"
            ],
            "description": "动作成功后的目标状态。"
          },
          "actorTypes": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "human",
                "agent",
                "system"
              ],
              "description": "可请求此动作的 actor 类型。"
            },
            "description": "类型级门槛；服务端仍须校验具体 actor、scope 与 claim。"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "description": "流转的产品语义与限制。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardCapability": {
        "description": "公开声明一个 TaskBoard 能力是否真实可用。",
        "type": "object",
        "required": [
          "id",
          "level",
          "description"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "description": "可被 API、Tool 和 UI 共同识别的能力 ID。"
          },
          "level": {
            "type": "string",
            "enum": [
              "available",
              "unavailable"
            ],
            "description": "当前客户端真正实现的能力等级；unavailable 不得伪装成功。"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "description": "能力语义及当前边界说明。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardProjections": {
        "type": "object",
        "additionalProperties": false,
        "description": "显式不可变来源投影合同；不代表owner端口已安装，不改变Task完成或审核规则。缺省不授权任何投影。",
        "properties": {
          "relation": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "mappingVersion",
              "eventTypes"
            ],
            "description": "仅允许指定Task事件到私有Relation owner，仍须真实source、当前capability和owner发布见证。",
            "properties": {
              "mappingVersion": {
                "const": 1,
                "description": "同commit typed Actor Relation映射版本，未知版本不可投递。"
              },
              "eventTypes": {
                "type": "array",
                "uniqueItems": true,
                "minItems": 1,
                "maxItems": 3,
                "items": {
                  "enum": [
                    "taskClaimed",
                    "taskHandedOff",
                    "reviewAccepted"
                  ]
                },
                "description": "明确列出的来源事件；非列表事件不投递。"
              }
            }
          },
          "notification": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "mappingVersion",
              "eventTypes",
              "recipientStrategy"
            ],
            "description": "仅声明通知来源合同，不接受subject/body模板或自报收件人，不代表通知端口已经实现。",
            "properties": {
              "mappingVersion": {
                "const": 1,
                "description": "可信Notification来源映射版本。"
              },
              "eventTypes": {
                "type": "array",
                "uniqueItems": true,
                "minItems": 1,
                "maxItems": 6,
                "items": {
                  "enum": [
                    "taskAssigned",
                    "taskHandedOff",
                    "taskSubmitted",
                    "reviewAccepted",
                    "reviewChangesRequested",
                    "claimExecutionEnded"
                  ]
                },
                "description": "分配、移交、提交、最终接受、要求返工，以及认领执行结束未提交（claimExecutionEnded，只通知不可在原会话继续的结局）；不包含阶段事件，返工不等于拒绝。"
              },
              "recipientStrategy": {
                "const": "ownerUser",
                "description": "收件人只能由同commit ownerUserId派生，仍需当前收件权限验证。"
              }
            }
          }
        }
      },
      "TaskBoardMentionSourceRef": {
        "type": "object",
        "required": [
          "kind",
          "sourceId",
          "sourceRevision",
          "taskRef"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "taskDescription",
              "taskComment"
            ],
            "description": "TaskBoard 公开来源类型。"
          },
          "sourceId": {
            "type": "string",
            "minLength": 1,
            "description": "Task ID 或 Task comment ID。"
          },
          "sourceRevision": {
            "type": "integer",
            "minimum": 1,
            "description": "不可变来源 revision。"
          },
          "taskRef": {
            "type": "object",
            "required": [
              "boardId",
              "taskId"
            ],
            "properties": {
              "boardId": {
                "type": "string",
                "minLength": 1,
                "description": "canonical Board ID。"
              },
              "taskId": {
                "type": "string",
                "minLength": 1,
                "description": "canonical Task ID。"
              },
              "taskVersion": {
                "type": "integer",
                "minimum": 1,
                "description": "可选 Task version 快照。"
              }
            },
            "additionalProperties": false,
            "description": "TaskBoard 公开来源的 canonical TaskRef。"
          }
        },
        "additionalProperties": false,
        "description": "TaskBoard read DTO 中的 camelCase Mention source；进入 Mention owner 前显式转换。"
      },
      "TaskSubmission": {
        "description": "负责人提交给人类验收的结果事实。",
        "type": "object",
        "required": [
          "submittedBy",
          "submittedAt",
          "summary"
        ],
        "properties": {
          "submittedBy": {
            "$ref": "#/components/schemas/TaskParticipantRef"
          },
          "submittedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "summary": {
            "type": "string",
            "minLength": 1,
            "description": "供验收者判断结果的有界摘要。"
          },
          "runRef": {
            "$ref": "#/components/schemas/RunRef"
          },
          "receiptRef": {
            "$ref": "#/components/schemas/ReceiptRef"
          },
          "workContextRef": {
            "$ref": "#/components/schemas/WorkContextRef"
          },
          "criteriaRevision": {
            "type": "integer",
            "minimum": 1,
            "description": "提交时验收标准的 revision；之后修改过的条目在面板上标为提交后修改。"
          },
          "criteriaChecks": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "$ref": "#/components/schemas/TaskCriterionCheck"
            },
            "description": "执行智能体按提交时的标准顺序逐条自评；只是说明，不是判定。"
          }
        },
        "additionalProperties": false
      },
      "TaskReviewDecision": {
        "description": "人类对一次 Task 提交作出的验收决定。",
        "type": "object",
        "required": [
          "outcome",
          "decidedBy",
          "decidedAt"
        ],
        "properties": {
          "outcome": {
            "type": "string",
            "enum": [
              "accepted",
              "changesRequested"
            ],
            "description": "本轮验收结果。"
          },
          "decidedBy": {
            "$ref": "#/components/schemas/TaskParticipantRef"
          },
          "decidedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "commentId": {
            "type": "string",
            "minLength": 1,
            "description": "验收或返工说明对应的 Task comment ID。"
          },
          "unmetCriterionIds": {
            "type": "array",
            "minItems": 1,
            "maxItems": 20,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            },
            "description": "返工时审核人标出的未满足条目 ID；只出现在返工决定上。"
          }
        },
        "additionalProperties": false
      },
      "TaskReviewAssignment": {
        "description": "某 review round/stage 当前唯一有效的 reviewer 授权投影。",
        "type": "object",
        "required": [
          "stageId",
          "round",
          "assignmentEpoch",
          "reviewer",
          "assignedAt"
        ],
        "properties": {
          "stageId": {
            "type": "string",
            "minLength": 1,
            "description": "当前 policy stage ID。"
          },
          "round": {
            "type": "integer",
            "minimum": 1,
            "description": "本 assignment 所属的 submission round。"
          },
          "assignmentEpoch": {
            "type": "integer",
            "minimum": 1,
            "description": "每次重新分配 reviewer 均递增，使旧 reviewer 投影失效。"
          },
          "reviewer": {
            "$ref": "#/components/schemas/TaskParticipantRef"
          },
          "assignedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          }
        },
        "additionalProperties": false
      },
      "TaskReviewHistoryEntry": {
        "description": "已结束 review stage 的不可变审计投影。",
        "type": "object",
        "required": [
          "stageId",
          "round",
          "assignmentEpoch",
          "decision"
        ],
        "properties": {
          "stageId": {
            "type": "string",
            "minLength": 1,
            "description": "已结束的 policy stage ID。"
          },
          "round": {
            "type": "integer",
            "minimum": 1,
            "description": "对应 submission round。"
          },
          "assignmentEpoch": {
            "type": "integer",
            "minimum": 1,
            "description": "对应 reviewer assignment epoch。"
          },
          "decision": {
            "$ref": "#/components/schemas/TaskReviewDecision"
          }
        },
        "additionalProperties": false
      },
      "TaskReviewStagePolicy": {
        "description": "多 Agent 审核流中一个按顺序执行的权威 gate。",
        "type": "object",
        "required": [
          "id",
          "mode",
          "reviewerStrategy",
          "description"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "description": "在 policy 内稳定的 review stage ID。"
          },
          "mode": {
            "type": "string",
            "enum": [
              "agentReview",
              "supervisorReview",
              "humanAcceptance",
              "approvalRef"
            ],
            "description": "本 gate 的权威事实来源。"
          },
          "reviewerStrategy": {
            "type": "string",
            "enum": [
              "explicitActor",
              "teamSupervisor",
              "ownerUser",
              "approvalOwner"
            ],
            "description": "服务端如何解析当前 round 的 reviewer；UI 不得自行猜测。"
          },
          "selfReviewAllowed": {
            "type": "boolean",
            "description": "是否允许本轮 submission actor 审核自己；多 Agent 默认应为 false。"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "description": "审核 gate 的产品语义和授权边界。"
          }
        },
        "additionalProperties": false
      },
      "TaskBoardHandoffEvidenceResponse": {
        "type": "object",
        "required": [
          "evidence"
        ],
        "properties": {
          "evidence": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskBoardHandoffEvidence"
            }
          }
        },
        "additionalProperties": false
      },
      "TaskBoardHandoffEvidence": {
        "description": "仅由已授权 append-only taskHandedOff TaskEvent 投影的关系图证据。",
        "type": "object",
        "required": [
          "eventId",
          "kind",
          "taskRef",
          "fromActor",
          "toActor",
          "occurredAt"
        ],
        "properties": {
          "eventId": {
            "type": "string",
            "minLength": 1,
            "description": "真实 TaskEvent.eventId。"
          },
          "kind": {
            "type": "string",
            "const": "handoff",
            "description": "关系证据类型。"
          },
          "taskRef": {
            "$ref": "#/components/schemas/TaskRef"
          },
          "fromActor": {
            "$ref": "#/components/schemas/ActorRef"
          },
          "toActor": {
            "$ref": "#/components/schemas/ActorRef"
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "description": "handoff 命令记录的可选理由。"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          }
        },
        "additionalProperties": false
      },
      "S3ConnectionSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "bucket": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "is_default": {
            "type": "boolean"
          },
          "has_public_url": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "label",
          "bucket",
          "region",
          "status",
          "is_default",
          "has_public_url"
        ],
        "additionalProperties": false,
        "description": "Saved connection summary without credentials. Status and has_public_url are not fresh reachability checks."
      },
      "S3ConnectionSummaries": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "connections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/S3ConnectionSummary"
            }
          }
        },
        "required": [
          "success",
          "connections"
        ],
        "additionalProperties": false
      },
      "S3ObjectList": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "objects": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "size": {
                  "type": "number"
                },
                "last_modified": {
                  "type": "string",
                  "description": "Provider timestamp string; can be empty when unavailable."
                }
              },
              "required": [
                "key",
                "size",
                "last_modified"
              ],
              "additionalProperties": false
            }
          },
          "common_prefixes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "prefix": {
                  "type": "string"
                }
              },
              "required": [
                "prefix"
              ],
              "additionalProperties": false
            }
          },
          "key_count": {
            "type": "number",
            "description": "Provider page count, which may count common prefixes; not a total or guaranteed objects.length."
          },
          "is_truncated": {
            "type": "boolean"
          },
          "next_continuation_token": {
            "type": "string",
            "description": "Opaque provider token when provided; absent rather than null without a token. Stop if a truncated page lacks a usable token."
          },
          "bucket": {
            "type": "string"
          },
          "prefix": {
            "type": "string",
            "description": "Omitted for an empty or absent prefix."
          }
        },
        "required": [
          "success",
          "objects",
          "common_prefixes",
          "key_count",
          "is_truncated",
          "bucket"
        ],
        "additionalProperties": false
      },
      "S3PublicDownloadLink": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "key": {
            "type": "string"
          },
          "download_url": {
            "type": "string"
          },
          "url_type": {
            "const": "public",
            "type": "string"
          },
          "content_type": {
            "type": "string"
          },
          "content_length": {
            "type": "number"
          }
        },
        "required": [
          "success",
          "key",
          "download_url",
          "url_type"
        ],
        "additionalProperties": false
      },
      "S3PresignedDownloadLink": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "key": {
            "type": "string"
          },
          "download_url": {
            "type": "string"
          },
          "url_type": {
            "const": "presigned",
            "type": "string"
          },
          "content_type": {
            "type": "string"
          },
          "content_length": {
            "type": "number"
          },
          "expires_in": {
            "type": "number",
            "description": "Requested lifetime in seconds after server conversion and clamping; credentials or provider policy can invalidate the URL sooner."
          }
        },
        "required": [
          "success",
          "key",
          "download_url",
          "url_type",
          "expires_in"
        ],
        "additionalProperties": false
      },
      "S3DownloadLink": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/S3PublicDownloadLink"
          },
          {
            "$ref": "#/components/schemas/S3PresignedDownloadLink"
          }
        ],
        "description": "A public URL has no expires_in. A presigned URL includes expires_in; neither guarantees a future successful download."
      },
      "S3ReadError": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": false
          },
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "NO_CONNECTION",
              "INVALID_REQUEST",
              "NOT_FOUND",
              "LIST_FAILED",
              "DOWNLOAD_FAILED"
            ]
          }
        },
        "required": [
          "success",
          "error",
          "code"
        ],
        "additionalProperties": false
      },
      "ObjectStorageCapabilityDisabled": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "const": "capabilityDisabled"
          },
          "capability": {
            "type": "string",
            "const": "object-storage"
          },
          "retryable": {
            "type": "boolean",
            "const": false
          }
        },
        "required": [
          "error",
          "code",
          "capability",
          "retryable"
        ],
        "additionalProperties": false
      },
      "WorkerSummary": {
        "type": "object",
        "required": [
          "workerId",
          "startedAt",
          "status"
        ],
        "properties": {
          "workerId": {
            "type": "string",
            "description": "临时子智能体 id。**必须等于** ctx.onProtocolMessage({type:\"subagent\"}) 里的 agent_id——前端 active-workers.store 的主键就是它，两处不同源会导致\"运行中列表\"与\"历史记录\"无法 join。同时用作文件名，必须过 isSafeId 且不得为 \"index\"。"
          },
          "at": {
            "type": "number",
            "description": "本条补丁的写入时间（Unix 毫秒）"
          },
          "kind": {
            "type": "string",
            "enum": [
              "delegate-worker",
              "spawn-agent"
            ],
            "description": "产生来源，区分 Delegate(mode=\"worker\") 与遗留 spawn_agent"
          },
          "agentType": {
            "type": "string",
            "description": "展示名：preset 派生的 \"<preset>-worker\"、\"delegate-worker\" 或 spawn_agent 的 agent_name"
          },
          "preset": {
            "type": "string",
            "description": "worker 预设名（defaults/worker-presets），无预设时缺省"
          },
          "thoroughness": {
            "type": "string",
            "description": "彻底程度档位（仅 preset 场景）"
          },
          "task": {
            "type": "string",
            "description": "委派任务原文（截断）；完整输入见 transcript 的 kind=prompt 行"
          },
          "callerAgentId": {
            "type": "string",
            "description": "发起委派的 Agent id"
          },
          "sessionId": {
            "type": "string",
            "description": "worker 的 runtime 子会话 id（onSessionStarted 回填）"
          },
          "startedAt": {
            "type": "number",
            "description": "启动时间（Unix 毫秒）"
          },
          "endedAt": {
            "type": "number",
            "description": "结束时间（Unix 毫秒），未结束时缺省"
          },
          "status": {
            "$ref": "#/components/schemas/WorkerStatus"
          },
          "summary": {
            "type": "string",
            "description": "最终产出摘要"
          },
          "error": {
            "type": "string",
            "description": "失败原因"
          },
          "entryCount": {
            "type": "number",
            "description": "transcript 已写入条目数，供列表判断是否有内容可看"
          },
          "routeDecision": {
            "type": "object",
            "required": [
              "mode",
              "providerId",
              "tier",
              "provider",
              "model",
              "reasoning",
              "capabilities",
              "requiredCapabilities",
              "reasonCodes",
              "decidedBy",
              "temporary"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "smart",
                  "fixed"
                ],
                "description": "本地模型选择模式：smart=每个新 Run 启动前按本地策略解析真实模型；fixed=始终使用用户显式选择的模型。"
              },
              "tier": {
                "type": "string",
                "enum": [
                  "flagship",
                  "balanced",
                  "lightweight"
                ],
                "description": "智能路由量级：flagship=最高能力，balanced=质量与成本平衡，lightweight=最快最省。"
              },
              "providerId": {
                "type": "string",
                "minLength": 1,
                "description": "最终命中的本地 Provider 唯一 ID。"
              },
              "provider": {
                "type": "string",
                "minLength": 1,
                "description": "最终命中的 Provider 协议标识。"
              },
              "model": {
                "type": "string",
                "minLength": 1,
                "description": "最终传给 runtime 的真实 modelName。"
              },
              "reasoning": {
                "type": "string",
                "enum": [
                  "auto",
                  "off",
                  "minimal",
                  "low",
                  "medium",
                  "high",
                  "xhigh",
                  "max"
                ],
                "description": "智能路由意图或本次 Run 的思考深度；最终值仍受目标 Provider × Model 能力矩阵约束。"
              },
              "reasoningEffort": {
                "type": "object",
                "required": [
                  "supportedEfforts"
                ],
                "properties": {
                  "supportedEfforts": {
                    "type": "array",
                    "minItems": 0,
                    "uniqueItems": true,
                    "items": {
                      "type": "string",
                      "enum": [
                        "none",
                        "minimal",
                        "low",
                        "medium",
                        "high",
                        "xhigh",
                        "max"
                      ]
                    },
                    "description": "本次 Run 协商后可发送的显式 effort 集合。空集合表示已知只允许 auto，不得恢复未知接入的兼容档位；原始 Provider 声明仍要求非空。"
                  },
                  "defaultEffort": {
                    "type": "string",
                    "enum": [
                      "minimal",
                      "low",
                      "medium",
                      "high",
                      "xhigh",
                      "max"
                    ],
                    "description": "此接入面推荐的显式默认档位；仅当仍属于 ModelSpec 合同时生效，且必须同时存在于 supportedEfforts。运行时在持久化档位不受支持时用它确定性回退。"
                  },
                  "defaultMode": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "off",
                      "minimal",
                      "low",
                      "medium",
                      "high",
                      "xhigh",
                      "max"
                    ],
                    "description": "协商后仍有效的模式默认值，仅属于本次运行合同。auto 始终可用；off 要求 none，其余档位必须在 supportedEfforts 中。原始接入声明与云目录不接受此字段。"
                  }
                },
                "allOf": [
                  {
                    "if": {
                      "required": [
                        "defaultEffort"
                      ],
                      "properties": {
                        "defaultEffort": {
                          "const": "minimal"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "minimal"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultEffort"
                      ],
                      "properties": {
                        "defaultEffort": {
                          "const": "low"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "low"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultEffort"
                      ],
                      "properties": {
                        "defaultEffort": {
                          "const": "medium"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "medium"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultEffort"
                      ],
                      "properties": {
                        "defaultEffort": {
                          "const": "high"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "high"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultEffort"
                      ],
                      "properties": {
                        "defaultEffort": {
                          "const": "xhigh"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "xhigh"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultEffort"
                      ],
                      "properties": {
                        "defaultEffort": {
                          "const": "max"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "max"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "off"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "none"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "minimal"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "minimal"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "low"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "low"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "medium"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "medium"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "high"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "high"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "xhigh"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "xhigh"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "max"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "max"
                          }
                        }
                      }
                    }
                  }
                ],
                "additionalProperties": false,
                "description": "本次 Smart 选模时固定的 ModelSpec 与 Provider 接入面推理合同；空集合表示已知只允许 auto。仅供该 Run 的 runtime 透传，避免热更新后重新猜测能力。"
              },
              "capabilities": {
                "type": "array",
                "maxItems": 64,
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "description": "模型目录或当前 assignment 记录的能力标签（如 vision/code/tool_use/agent）。"
                },
                "description": "最终模型的能力快照，用于本次 Run、UI 运行详情和审计。"
              },
              "providerPolicy": {
                "type": "object",
                "required": [
                  "restricted",
                  "allowedProviderIds"
                ],
                "properties": {
                  "restricted": {
                    "type": "boolean",
                    "description": "本次 Run 是否受到显式 Provider 白名单限制。"
                  },
                  "allowedProviderIds": {
                    "type": "array",
                    "maxItems": 128,
                    "uniqueItems": true,
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "description": "本次 Run 生效的精确 Provider ID 快照；restricted=false 时为空数组。"
                  }
                },
                "additionalProperties": false,
                "description": "本次 Run 生效的人类 Provider 限制快照；字段可选以兼容旧 Run/Receipt。"
              },
              "diagnostics": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "policyVersion",
                  "providerPriorities",
                  "skippedCandidates"
                ],
                "properties": {
                  "policyVersion": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "本次选路实际应用的策略版本，供历史回执解释"
                  },
                  "providerPriorities": {
                    "type": "array",
                    "maxItems": 128,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "providerId",
                        "priority",
                        "source"
                      ],
                      "properties": {
                        "providerId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200,
                          "description": "本机 Provider 实例标识"
                        },
                        "priority": {
                          "type": "integer",
                          "minimum": -10000,
                          "maximum": 10000,
                          "description": "本次生效的同模型档位来源优先级"
                        },
                        "source": {
                          "type": "string",
                          "enum": [
                            "default",
                            "user"
                          ],
                          "description": "优先级来自默认策略或用户显式覆盖；数值相同也保留归属"
                        }
                      }
                    },
                    "description": "本次 Provider 允许范围内的来源优先级快照，未设置允许范围时覆盖全部配置来源，包含因资格不满足被跳过的来源；按配置顺序最多保留 128 项，超限时替换末项以保留当前决策选中的 Provider，不包含凭据或端点"
                  },
                  "skippedCandidates": {
                    "type": "array",
                    "maxItems": 200,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "providerId",
                        "model",
                        "reason"
                      ],
                      "properties": {
                        "providerId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200,
                          "description": "被排除候选的本机 Provider 实例标识，不包含凭据或端点"
                        },
                        "provider": {
                          "type": "string",
                          "maxLength": 120,
                          "description": "被排除候选的 Provider 协议标识"
                        },
                        "model": {
                          "type": "string",
                          "maxLength": 300,
                          "description": "被排除候选的公开模型代码"
                        },
                        "reason": {
                          "type": "string",
                          "enum": [
                            "provider_not_allowed",
                            "provider_unavailable",
                            "model_unselectable",
                            "not_chat",
                            "model_spec_missing",
                            "model_ineligible",
                            "capability_mismatch",
                            "context_too_small",
                            "model_blocked",
                            "model_cooling",
                            "credential_invalid",
                            "identity_changed",
                            "resolve_failed"
                          ],
                          "description": "封闭排除原因；展示路由资格、能力、状态或发送前绑定失败，不包含上游原始错误"
                        },
                        "availabilityReason": {
                          "type": "string",
                          "enum": [
                            "unverified",
                            "success",
                            "transient",
                            "rate_limit",
                            "auth",
                            "quota",
                            "withdrawn",
                            "unsupported",
                            "protocol",
                            "recovering",
                            "permission",
                            "model_not_found",
                            "capability",
                            "disabled",
                            "configuration",
                            "credentials",
                            "deprecated",
                            "tls_certificate"
                          ],
                          "description": "封闭原因码；不返回上游原始错误或提示词"
                        },
                        "retryAt": {
                          "type": "number",
                          "description": "当前候选可再次尝试的最早时间（epoch ms）；仅有明确冷却证据时提供"
                        }
                      },
                      "description": "本次路由排除候选的有界诊断回执，不用于改变选路排序"
                    },
                    "description": "按检查顺序记录被排除的候选；有界截取避免目录规模无限放大审计载荷"
                  }
                },
                "description": "可解释路由诊断，仅保存策略和资格事实，不包含思维链或敏感接入信息"
              },
              "requiredCapabilities": {
                "type": "array",
                "maxItems": 8,
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "pattern": "^[a-z0-9_]+$",
                  "description": "路由硬能力标签，例如 vision、reasoning、code、tool_use、agent、long_context。"
                },
                "description": "任务必须具备的模型能力。缺少任一硬能力时该候选必须淘汰。"
              },
              "reasonCodes": {
                "type": "array",
                "minItems": 1,
                "maxItems": 12,
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "enum": [
                    "baseline_default",
                    "provider_default",
                    "tier_match",
                    "tier_promoted",
                    "tier_relaxed",
                    "vision_required",
                    "reasoning_required",
                    "agent_selected",
                    "context_fit",
                    "cost_balanced",
                    "resume_reused",
                    "route_reselected"
                  ]
                },
                "description": "结构化的路由原因代码，用于 UI、日志和 Receipt，不包含思维链。"
              },
              "decidedBy": {
                "type": "string",
                "enum": [
                  "default",
                  "query",
                  "agent",
                  "user",
                  "plan",
                  "delegation",
                  "team",
                  "capability",
                  "resume",
                  "fallback"
                ],
                "description": "决策来源：默认分配、直接对话预检、编排 Agent、Plan、委派、团队、恢复复用或失效回退。"
              },
              "temporary": {
                "type": "boolean",
                "description": "是否仅对当前执行身份生效；持久 Agent 必须为 false，只有无 AgentFS 身份的临时 worker 为 true。"
              },
              "reason": {
                "type": "string",
                "maxLength": 500,
                "description": "编排 Agent 给出的简短选择理由，仅用于可解释审计，不作为可信能力声明。"
              }
            },
            "additionalProperties": false,
            "description": "Delegate worker 实际生效的脱敏路由决策；后写补丁覆盖先写。"
          },
          "bytes": {
            "type": "number",
            "description": "transcript 文件字节数"
          },
          "truncated": {
            "type": "boolean",
            "description": "transcript 是否因触达上限被截断"
          }
        },
        "additionalProperties": false
      },
      "WorkerTranscriptEntry": {
        "type": "object",
        "required": [
          "seq",
          "at",
          "kind"
        ],
        "properties": {
          "seq": {
            "type": "integer",
            "minimum": 0,
            "description": "本 worker 内单调递增的写入序号（从 0 起），可用于折叠 patch 与观察缺口；不是 HTTP offset 或 tail 游标。offset/total 按成功解析且格式有效的 entry 位置计数，损坏行被跳过。"
          },
          "at": {
            "type": "number",
            "description": "产生时间（Unix 毫秒），与 SessionMessage.timestamp 同量纲"
          },
          "kind": {
            "type": "string",
            "enum": [
              "route",
              "prompt",
              "text",
              "thinking",
              "tool",
              "tool_patch",
              "artifact",
              "truncated",
              "end"
            ],
            "description": "route=worker 实际生效的脱敏智能路由决策；prompt=worker 收到的完整输入；text=一段已封口的助手正文；thinking=一段思考过程；tool=首次观察到的工具调用；tool_patch=对已写 tool 的字段补全（input/summary 迟到时产生，读取侧按 toolId 合并，后写覆盖先写）；artifact=服务端校验过的文件产物快照；truncated=触达体积上限，其后除 end 外不再记录；end=终局（缺失表示进程在 worker 结束前退出）。"
          },
          "text": {
            "type": "string",
            "description": "正文（kind=prompt/text/thinking）。逐 token 的 text_delta 已聚合成整块后才落盘，不会一个增量一行；超过 WORKER_TRANSCRIPT_TEXT_LIMIT 时尾部截断。"
          },
          "toolPhase": {
            "enum": [
              "requested",
              "executing",
              "completed",
              "failed",
              "interrupted",
              "unknown"
            ],
            "description": "Tool lifecycle for tool/tool_patch, independent of worker end.status."
          },
          "startedAt": {
            "type": "number",
            "description": "Observed tool execution start in milliseconds."
          },
          "completedAt": {
            "type": "number",
            "description": "Observed tool terminal time in milliseconds."
          },
          "toolId": {
            "type": "string",
            "description": "工具调用 id（kind=tool/tool_patch）。读取侧按它把 tool 与其后的 tool_patch 合并"
          },
          "name": {
            "type": "string",
            "description": "工具名（kind=tool）"
          },
          "input": {
            "description": "工具入参（kind=tool/tool_patch）：按工具声明脱敏敏感字段，剥离带类型的媒体内嵌载荷，保留普通 JSON 业务参数及媒体引用；序列化超限时截断为字符串预览。读时重新投影旧数据。"
          },
          "summary": {
            "type": "string",
            "description": "kind=tool/tool_patch：工具结果摘要（截断后的短文本；worker transcript 刻意**不做**结果外置，避免在父 run 下再造一套需要单独清理的文件）。写入和旧记录读取均按本次调用身份投影敏感结果；执行中不输出敏感进度正文，失败占位保留失败语义。kind=end：worker 最终产出摘要。"
          },
          "isError": {
            "type": "boolean",
            "description": "该次工具调用是否以失败终态结束（kind=tool/tool_patch）"
          },
          "category": {
            "type": "string",
            "enum": [
              "internal",
              "api",
              "mcp"
            ],
            "description": "工具分类，与 SessionToolUse.category 同口径（kind=tool）"
          },
          "status": {
            "type": "string",
            "enum": [
              "completed",
              "failed",
              "detached",
              "stopped",
              "aborted"
            ],
            "description": "终局状态（kind=end）。completed=正常结束；failed=抛错；detached=同步等待超时但任务仍在后台跑（此后若收到子会话最终结果会再补一条 end）；stopped=被 DelegateControl(action=\"terminate\") 显式中止；aborted=父会话被中止。"
          },
          "error": {
            "type": "string",
            "description": "失败原因（kind=end 且 status=failed/aborted）"
          },
          "reason": {
            "type": "string",
            "description": "截断原因（kind=truncated），如 byte-limit / entry-limit"
          },
          "routeDecision": {
            "type": "object",
            "required": [
              "mode",
              "providerId",
              "tier",
              "provider",
              "model",
              "reasoning",
              "capabilities",
              "requiredCapabilities",
              "reasonCodes",
              "decidedBy",
              "temporary"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "smart",
                  "fixed"
                ],
                "description": "本地模型选择模式：smart=每个新 Run 启动前按本地策略解析真实模型；fixed=始终使用用户显式选择的模型。"
              },
              "tier": {
                "type": "string",
                "enum": [
                  "flagship",
                  "balanced",
                  "lightweight"
                ],
                "description": "智能路由量级：flagship=最高能力，balanced=质量与成本平衡，lightweight=最快最省。"
              },
              "providerId": {
                "type": "string",
                "minLength": 1,
                "description": "最终命中的本地 Provider 唯一 ID。"
              },
              "provider": {
                "type": "string",
                "minLength": 1,
                "description": "最终命中的 Provider 协议标识。"
              },
              "model": {
                "type": "string",
                "minLength": 1,
                "description": "最终传给 runtime 的真实 modelName。"
              },
              "reasoning": {
                "type": "string",
                "enum": [
                  "auto",
                  "off",
                  "minimal",
                  "low",
                  "medium",
                  "high",
                  "xhigh",
                  "max"
                ],
                "description": "智能路由意图或本次 Run 的思考深度；最终值仍受目标 Provider × Model 能力矩阵约束。"
              },
              "reasoningEffort": {
                "type": "object",
                "required": [
                  "supportedEfforts"
                ],
                "properties": {
                  "supportedEfforts": {
                    "type": "array",
                    "minItems": 0,
                    "uniqueItems": true,
                    "items": {
                      "type": "string",
                      "enum": [
                        "none",
                        "minimal",
                        "low",
                        "medium",
                        "high",
                        "xhigh",
                        "max"
                      ]
                    },
                    "description": "本次 Run 协商后可发送的显式 effort 集合。空集合表示已知只允许 auto，不得恢复未知接入的兼容档位；原始 Provider 声明仍要求非空。"
                  },
                  "defaultEffort": {
                    "type": "string",
                    "enum": [
                      "minimal",
                      "low",
                      "medium",
                      "high",
                      "xhigh",
                      "max"
                    ],
                    "description": "此接入面推荐的显式默认档位；仅当仍属于 ModelSpec 合同时生效，且必须同时存在于 supportedEfforts。运行时在持久化档位不受支持时用它确定性回退。"
                  },
                  "defaultMode": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "off",
                      "minimal",
                      "low",
                      "medium",
                      "high",
                      "xhigh",
                      "max"
                    ],
                    "description": "协商后仍有效的模式默认值，仅属于本次运行合同。auto 始终可用；off 要求 none，其余档位必须在 supportedEfforts 中。原始接入声明与云目录不接受此字段。"
                  }
                },
                "allOf": [
                  {
                    "if": {
                      "required": [
                        "defaultEffort"
                      ],
                      "properties": {
                        "defaultEffort": {
                          "const": "minimal"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "minimal"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultEffort"
                      ],
                      "properties": {
                        "defaultEffort": {
                          "const": "low"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "low"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultEffort"
                      ],
                      "properties": {
                        "defaultEffort": {
                          "const": "medium"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "medium"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultEffort"
                      ],
                      "properties": {
                        "defaultEffort": {
                          "const": "high"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "high"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultEffort"
                      ],
                      "properties": {
                        "defaultEffort": {
                          "const": "xhigh"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "xhigh"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultEffort"
                      ],
                      "properties": {
                        "defaultEffort": {
                          "const": "max"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "max"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "off"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "none"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "minimal"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "minimal"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "low"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "low"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "medium"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "medium"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "high"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "high"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "xhigh"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "xhigh"
                          }
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "defaultMode"
                      ],
                      "properties": {
                        "defaultMode": {
                          "const": "max"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "supportedEfforts": {
                          "contains": {
                            "const": "max"
                          }
                        }
                      }
                    }
                  }
                ],
                "additionalProperties": false,
                "description": "本次 Smart 选模时固定的 ModelSpec 与 Provider 接入面推理合同；空集合表示已知只允许 auto。仅供该 Run 的 runtime 透传，避免热更新后重新猜测能力。"
              },
              "capabilities": {
                "type": "array",
                "maxItems": 64,
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "description": "模型目录或当前 assignment 记录的能力标签（如 vision/code/tool_use/agent）。"
                },
                "description": "最终模型的能力快照，用于本次 Run、UI 运行详情和审计。"
              },
              "providerPolicy": {
                "type": "object",
                "required": [
                  "restricted",
                  "allowedProviderIds"
                ],
                "properties": {
                  "restricted": {
                    "type": "boolean",
                    "description": "本次 Run 是否受到显式 Provider 白名单限制。"
                  },
                  "allowedProviderIds": {
                    "type": "array",
                    "maxItems": 128,
                    "uniqueItems": true,
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "description": "本次 Run 生效的精确 Provider ID 快照；restricted=false 时为空数组。"
                  }
                },
                "additionalProperties": false,
                "description": "本次 Run 生效的人类 Provider 限制快照；字段可选以兼容旧 Run/Receipt。"
              },
              "diagnostics": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "policyVersion",
                  "providerPriorities",
                  "skippedCandidates"
                ],
                "properties": {
                  "policyVersion": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "本次选路实际应用的策略版本，供历史回执解释"
                  },
                  "providerPriorities": {
                    "type": "array",
                    "maxItems": 128,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "providerId",
                        "priority",
                        "source"
                      ],
                      "properties": {
                        "providerId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200,
                          "description": "本机 Provider 实例标识"
                        },
                        "priority": {
                          "type": "integer",
                          "minimum": -10000,
                          "maximum": 10000,
                          "description": "本次生效的同模型档位来源优先级"
                        },
                        "source": {
                          "type": "string",
                          "enum": [
                            "default",
                            "user"
                          ],
                          "description": "优先级来自默认策略或用户显式覆盖；数值相同也保留归属"
                        }
                      }
                    },
                    "description": "本次 Provider 允许范围内的来源优先级快照，未设置允许范围时覆盖全部配置来源，包含因资格不满足被跳过的来源；按配置顺序最多保留 128 项，超限时替换末项以保留当前决策选中的 Provider，不包含凭据或端点"
                  },
                  "skippedCandidates": {
                    "type": "array",
                    "maxItems": 200,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "providerId",
                        "model",
                        "reason"
                      ],
                      "properties": {
                        "providerId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200,
                          "description": "被排除候选的本机 Provider 实例标识，不包含凭据或端点"
                        },
                        "provider": {
                          "type": "string",
                          "maxLength": 120,
                          "description": "被排除候选的 Provider 协议标识"
                        },
                        "model": {
                          "type": "string",
                          "maxLength": 300,
                          "description": "被排除候选的公开模型代码"
                        },
                        "reason": {
                          "type": "string",
                          "enum": [
                            "provider_not_allowed",
                            "provider_unavailable",
                            "model_unselectable",
                            "not_chat",
                            "model_spec_missing",
                            "model_ineligible",
                            "capability_mismatch",
                            "context_too_small",
                            "model_blocked",
                            "model_cooling",
                            "credential_invalid",
                            "identity_changed",
                            "resolve_failed"
                          ],
                          "description": "封闭排除原因；展示路由资格、能力、状态或发送前绑定失败，不包含上游原始错误"
                        },
                        "availabilityReason": {
                          "type": "string",
                          "enum": [
                            "unverified",
                            "success",
                            "transient",
                            "rate_limit",
                            "auth",
                            "quota",
                            "withdrawn",
                            "unsupported",
                            "protocol",
                            "recovering",
                            "permission",
                            "model_not_found",
                            "capability",
                            "disabled",
                            "configuration",
                            "credentials",
                            "deprecated",
                            "tls_certificate"
                          ],
                          "description": "封闭原因码；不返回上游原始错误或提示词"
                        },
                        "retryAt": {
                          "type": "number",
                          "description": "当前候选可再次尝试的最早时间（epoch ms）；仅有明确冷却证据时提供"
                        }
                      },
                      "description": "本次路由排除候选的有界诊断回执，不用于改变选路排序"
                    },
                    "description": "按检查顺序记录被排除的候选；有界截取避免目录规模无限放大审计载荷"
                  }
                },
                "description": "可解释路由诊断，仅保存策略和资格事实，不包含思维链或敏感接入信息"
              },
              "requiredCapabilities": {
                "type": "array",
                "maxItems": 8,
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "pattern": "^[a-z0-9_]+$",
                  "description": "路由硬能力标签，例如 vision、reasoning、code、tool_use、agent、long_context。"
                },
                "description": "任务必须具备的模型能力。缺少任一硬能力时该候选必须淘汰。"
              },
              "reasonCodes": {
                "type": "array",
                "minItems": 1,
                "maxItems": 12,
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "enum": [
                    "baseline_default",
                    "provider_default",
                    "tier_match",
                    "tier_promoted",
                    "tier_relaxed",
                    "vision_required",
                    "reasoning_required",
                    "agent_selected",
                    "context_fit",
                    "cost_balanced",
                    "resume_reused",
                    "route_reselected"
                  ]
                },
                "description": "结构化的路由原因代码，用于 UI、日志和 Receipt，不包含思维链。"
              },
              "decidedBy": {
                "type": "string",
                "enum": [
                  "default",
                  "query",
                  "agent",
                  "user",
                  "plan",
                  "delegation",
                  "team",
                  "capability",
                  "resume",
                  "fallback"
                ],
                "description": "决策来源：默认分配、直接对话预检、编排 Agent、Plan、委派、团队、恢复复用或失效回退。"
              },
              "temporary": {
                "type": "boolean",
                "description": "是否仅对当前执行身份生效；持久 Agent 必须为 false，只有无 AgentFS 身份的临时 worker 为 true。"
              },
              "reason": {
                "type": "string",
                "maxLength": 500,
                "description": "编排 Agent 给出的简短选择理由，仅用于可解释审计，不作为可信能力声明。"
              }
            },
            "additionalProperties": false,
            "description": "kind=route 时的实际 Provider、模型、有效 reasoning 与原因码；不包含 key/baseUrl。"
          },
          "artifact": {
            "type": "object",
            "required": [
              "displayPath",
              "action",
              "kind",
              "resourceRef"
            ],
            "properties": {
              "displayPath": {
                "type": "string",
                "maxLength": 4096,
                "pattern": "^[^\\u0000-\\u001F\\u007F]*$",
                "description": "清单展示用路径：位于工作目录内时为相对工作目录的路径，否则回落绝对路径。限制长度并禁止控制字符，避免 transcript/服务端报告注入。"
              },
              "action": {
                "type": "string",
                "enum": [
                  "create",
                  "update"
                ],
                "description": "可供主 Agent 检查或展示的文件产物动作；delete/noop 不进入产物清单。"
              },
              "kind": {
                "type": "string",
                "description": "内容类型：text 文本文件（可有行级增删统计）/ binary 二进制产物（图片、PDF、Office 文档等，无行数）",
                "enum": [
                  "text",
                  "binary"
                ]
              },
              "stats": {
                "type": "object",
                "description": "行级变更统计。仅 kind=text 且成功生成 diff 时存在；create 场景 deletions 为 0",
                "required": [
                  "additions",
                  "deletions"
                ],
                "properties": {
                  "additions": {
                    "type": "number",
                    "description": "新增行数"
                  },
                  "deletions": {
                    "type": "number",
                    "description": "删除行数"
                  }
                },
                "additionalProperties": false
              },
              "size": {
                "type": "number",
                "description": "写入后的文件字节数，供 UI 展示二进制产物体积"
              },
              "diffSkipped": {
                "type": "boolean",
                "description": "为 true 表示文件确有变更但因超出 diff 体积阈值未生成 diff，故 stats 缺失。UI 应展示\"已变更\"而非\"0 行改动\""
              },
              "resourceRef": {
                "type": "object",
                "required": [
                  "schemaVersion",
                  "instanceId",
                  "agentId",
                  "rootId",
                  "path"
                ],
                "properties": {
                  "schemaVersion": {
                    "type": "integer",
                    "const": 1,
                    "description": "文件资源引用格式版本；当前固定为 1。"
                  },
                  "instanceId": {
                    "type": "string",
                    "pattern": "^inst_[A-Za-z0-9_-]{32}$",
                    "description": "签发并解析该资源引用的 Agent Service 稳定实例身份。"
                  },
                  "agentId": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]+$",
                    "description": "解析该资源时使用的 Agent 权限上下文；不是显示名称。"
                  },
                  "rootId": {
                    "type": "string",
                    "minLength": 16,
                    "description": "目标实例为当前已登记工作目录签发的不透明根目录 ID。"
                  },
                  "path": {
                    "type": "string",
                    "description": "相对 rootId 的规范 POSIX 路径；根目录为空字符串，不允许绝对路径、反斜线、空段、`.`、`..` 或 NUL。"
                  }
                },
                "additionalProperties": false,
                "description": "服务端签发的文件资源身份；不是授权凭据，消费时必须重新校验。"
              }
            },
            "additionalProperties": false,
            "description": "kind=artifact 时的服务端校验文件产物；同一资源多条记录按 seq 后写覆盖先写。"
          }
        },
        "additionalProperties": false
      },
      "ArchivedManualTopicPage": {
        "type": "object",
        "description": "GET /api/manual-topics/archived 的响应：当前用户在本机全部 Agent 下的已归档话题，按归档时间倒序分页",
        "required": [
          "items",
          "total",
          "hasMore"
        ],
        "additionalProperties": false,
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ArchivedManualTopic"
            },
            "description": "本页条目"
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "description": "已归档话题总数"
          },
          "hasMore": {
            "type": "boolean",
            "description": "offset + limit 之后是否还有条目"
          }
        }
      },
      "PersistentSessionReference": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "runId",
          "runtimeSession"
        ],
        "properties": {
          "runId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "description": "持久归属 ID，不是文件路径。"
          },
          "teamId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "description": "原 Run.meta 的真实团队归属；null 明确表示个人作用域。旧服务端缺省此字段时归属未知，客户端不得据此恢复执行身份。"
          },
          "runtimeSession": {
            "anyOf": [
              {
                "type": "null",
                "description": "不可原位续聊的归档/父分支或尚无可恢复状态。"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "sessionId",
                  "revision",
                  "scopeEpoch",
                  "scopeSequence"
                ],
                "properties": {
                  "sessionId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256,
                    "description": "持久归属 ID，不是文件路径。"
                  },
                  "boundModel": {
                    "$ref": "#/components/schemas/PersistentBoundModel"
                  },
                  "revision": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "持久运行态版本。"
                  },
                  "scopeEpoch": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "作用域清除代际。"
                  },
                  "scopeSequence": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "已提交作用域的序号高水位。"
                  }
                }
              }
            ],
            "description": "原会话身份与版本；读取不执行模型或重发输入。"
          }
        }
      },
      "SessionRecoveryError": {
        "type": "object",
        "required": [
          "code",
          "error"
        ],
        "additionalProperties": false,
        "properties": {
          "code": {
            "type": "string",
            "const": "SESSION_RESTORE_FAILED",
            "description": "本地会话恢复失败；不能自动重发旧输入或把失败伪装为无恢复状态。"
          },
          "error": {
            "type": "string",
            "maxLength": 2000,
            "description": "安全的用户提示，不包含原始JSON、绝对路径或凭据。"
          },
          "hint": {
            "type": "string",
            "maxLength": 2000,
            "description": "可选处置说明和诊断编号，不包含业务正文。"
          }
        },
        "description": "在已验证历史读取归属后返回的本地恢复失败；与确实无需恢复时的runtimeSession:null区分。"
      },
      "ArchivedTeamSummary": {
        "type": "object",
        "description": "归档列表中的一条。只读投影，每次请求从归档目录与清单重新推导",
        "required": [
          "archiveId",
          "teamId",
          "name",
          "archivedAt",
          "reason",
          "archivedDir",
          "supervisor",
          "supervisorExists",
          "memberCount",
          "missingMembers",
          "originalIdOccupied",
          "hasManifest",
          "gitRecorded",
          "restorable"
        ],
        "additionalProperties": false,
        "properties": {
          "archiveId": {
            "type": "string",
            "description": "归档标识，恢复时原样传入"
          },
          "teamId": {
            "type": "string",
            "description": "解散前的团队 ID"
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "团队名称；team.json 与清单都读不到时为 null"
          },
          "archivedAt": {
            "type": [
              "string",
              "null"
            ],
            "description": "归档时间；无清单时由归档目录名中的 UTC 时间推导，推导不出为 null"
          },
          "reason": {
            "type": "string",
            "enum": [
              "disband",
              "leader_deleted",
              "unknown"
            ],
            "description": "归档原因；无清单的存量归档为 unknown"
          },
          "archivedDir": {
            "type": "string",
            "description": "归档目录绝对路径"
          },
          "supervisor": {
            "type": [
              "string",
              "null"
            ],
            "description": "组长 Agent ID"
          },
          "supervisorExists": {
            "type": "boolean",
            "description": "组长 Agent 当前是否存在于本机；false 时恢复必须指定新组长"
          },
          "memberCount": {
            "type": "integer",
            "minimum": 0,
            "description": "名册成员数（不含组长）"
          },
          "missingMembers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "名册中本机已不存在的成员"
          },
          "originalIdOccupied": {
            "type": "boolean",
            "description": "原团队 ID 是否已被占用；true 时恢复必须提供新名称"
          },
          "hasManifest": {
            "type": "boolean",
            "description": "是否有归档清单；无清单时不能绑回原工作目录，规则需重新核准"
          },
          "gitRecorded": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "归档时是否打了 Git tag；无清单时为 null（未知）"
          },
          "restorable": {
            "type": "boolean",
            "description": "归档内 team.json 可读且结构合法时为 true"
          }
        }
      },
      "TeamRestoreRequest": {
        "type": "object",
        "description": "恢复一份团队归档。原 ID 被占用时必须提供 newName；组长已不存在时必须提供 supervisor",
        "additionalProperties": false,
        "properties": {
          "newName": {
            "type": "string",
            "minLength": 1,
            "description": "恢复后的团队名称。原 ID 被占用时必填，新 ID 由名称生成；原 ID 空闲时只改名、不换 ID"
          },
          "supervisor": {
            "type": "string",
            "minLength": 1,
            "description": "新组长 Agent ID。原组长已不存在时必填；提供时按更换组长处理"
          }
        }
      },
      "TeamRestoreResult": {
        "type": "object",
        "description": "恢复回执。成功只表示团队已回到活动目录；approval、workdir、missingMembers 与 warnings 说明还需处理的事项",
        "required": [
          "teamId",
          "restoredFromArchiveId",
          "idChanged",
          "approval",
          "workdir",
          "reattachedChildren",
          "missingMembers",
          "warnings"
        ],
        "additionalProperties": false,
        "properties": {
          "teamId": {
            "type": "string",
            "description": "恢复后的团队 ID"
          },
          "restoredFromArchiveId": {
            "type": "string",
            "description": "来源归档标识"
          },
          "idChanged": {
            "type": "boolean",
            "description": "是否因原 ID 被占用而以新 ID 恢复"
          },
          "approval": {
            "type": "string",
            "enum": [
              "reinstated",
              "pending"
            ],
            "description": "reinstated=归档时的核准记录已原样装回（内容被改过时消费端照常拦下）；pending=规则待用户审阅"
          },
          "workdir": {
            "type": "object",
            "required": [
              "path",
              "rebound"
            ],
            "additionalProperties": false,
            "description": "共享工作目录的绑定结果",
            "properties": {
              "path": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "当前绑定的共享工作目录；没有用户档案或绑定失败时为 null"
              },
              "rebound": {
                "type": "boolean",
                "description": "true=绑回了解散前的目录；false=改绑了默认工作目录或未绑定"
              }
            }
          },
          "reattachedChildren": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "挂回本团队的原直属子团队"
          },
          "missingMembers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "名册中本机已不存在的成员；可用 install_members 补装或 remove_members 移除"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "收尾异常；团队已恢复，这些事项需另行处理"
          }
        }
      },
      "GovernedWorkflowBindingWriteRequest": {
        "description": "通过公开 TaskBoard/Workflow adapter 建立稳定绑定的 CAS 请求。",
        "type": "object",
        "required": [
          "resourceRef",
          "workflowRef",
          "role",
          "expectedVersion",
          "idempotencyKey"
        ],
        "properties": {
          "resourceRef": {
            "$ref": "#/components/schemas/TaskBoardWorkflowResourceRef"
          },
          "workflowRef": {
            "$ref": "#/components/schemas/ExactWorkflowDefinitionResourceRef"
          },
          "role": {
            "type": "string",
            "enum": [
              "reference",
              "trigger"
            ],
            "description": "本次建立的是导航引用还是可触发绑定。"
          },
          "expectedVersion": {
            "type": "integer",
            "minimum": 0,
            "description": "Board 目标为当前 revision，Task 目标为当前 version；不匹配必须返回冲突。"
          },
          "idempotencyKey": {
            "type": "string",
            "minLength": 8,
            "maxLength": 256,
            "description": "调用方稳定重试键；响应丢失后不得创建第二条 binding。"
          }
        },
        "allOf": [
          {
            "if": {
              "required": [
                "resourceRef"
              ],
              "properties": {
                "resourceRef": {
                  "type": "object",
                  "required": [
                    "resourceType"
                  ],
                  "properties": {
                    "resourceType": {
                      "const": "task"
                    }
                  }
                }
              }
            },
            "then": {
              "properties": {
                "expectedVersion": {
                  "minimum": 1,
                  "description": "Task binding 必须携带大于等于 1 的 Task version。"
                }
              }
            }
          },
          {
            "if": {
              "required": [
                "role"
              ],
              "properties": {
                "role": {
                  "const": "trigger"
                }
              }
            },
            "then": {
              "properties": {
                "resourceRef": {
                  "type": "object",
                  "required": [
                    "resourceType"
                  ],
                  "properties": {
                    "resourceType": {
                      "const": "task"
                    }
                  }
                }
              },
              "description": "typed TaskRef trigger binding 只能绑定 canonical Task；Board binding 仅作 reference。"
            }
          }
        ],
        "additionalProperties": false
      },
      "GovernedWorkflowBinding": {
        "description": "Workflow owner 验证后返回的 Task/Board 双向链接事实。",
        "type": "object",
        "required": [
          "schemaVersion",
          "bindingId",
          "resourceRef",
          "workflowRef",
          "role",
          "createdBy",
          "createdAt"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "TaskBoard/Workflow binding 契约版本。"
          },
          "bindingId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "description": "Workflow owner 中稳定且可用于幂等解除绑定的 binding ID。"
          },
          "resourceRef": {
            "$ref": "#/components/schemas/TaskBoardWorkflowResourceRef"
          },
          "workflowRef": {
            "$ref": "#/components/schemas/ExactWorkflowDefinitionResourceRef"
          },
          "role": {
            "type": "string",
            "enum": [
              "reference",
              "trigger"
            ],
            "description": "reference 仅导航关联；trigger 允许从该资源显式启动 Workflow。"
          },
          "createdBy": {
            "description": "创建绑定的稳定主体快照；授权仍需 owner 重新判定。",
            "type": "object",
            "required": [
              "type",
              "id"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "human",
                  "agent",
                  "system"
                ],
                "description": "事实执行者类型；授权必须按稳定 ID 重新判定，不能信任展示名称。"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "用户 ID、Agent ID 或系统主体 ID。"
              },
              "displayName": {
                "type": "string",
                "minLength": 1,
                "description": "写入事实时的展示名称快照，不参与身份唯一性或授权。"
              }
            },
            "additionalProperties": false
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          }
        },
        "additionalProperties": false
      },
      "CurrentGovernedResourceRef": {
        "description": "只允许导航到 owner 当前版本的封闭 GovernedResourceRef 联合。",
        "oneOf": [
          {
            "$ref": "#/components/schemas/CurrentTaskResourceRef"
          },
          {
            "$ref": "#/components/schemas/CurrentWorkContextResourceRef"
          },
          {
            "$ref": "#/components/schemas/CurrentWorkflowDefinitionResourceRef"
          },
          {
            "$ref": "#/components/schemas/CurrentDecisionWorkspaceResourceRef"
          },
          {
            "$ref": "#/components/schemas/CurrentFileResourceRef"
          },
          {
            "$ref": "#/components/schemas/CurrentDecisionTreeResourceRef"
          },
          {
            "$ref": "#/components/schemas/CurrentBoardResourceRef"
          },
          {
            "$ref": "#/components/schemas/CurrentViewDocumentResourceRef"
          }
        ]
      },
      "ExactGovernedResourceRef": {
        "description": "可用于精确读取、绑定或受治理命令的封闭 GovernedResourceRef 联合。",
        "oneOf": [
          {
            "$ref": "#/components/schemas/ExactTaskResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactWorkContextResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactWorkflowDefinitionResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactDecisionWorkspaceResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactFileResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactWorkDirResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactBoundWorktreeResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactRunResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactReceiptResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactDecisionTreeResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactDecisionTreeRunResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactBoardResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactViewDocumentResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactApplicationObjectResourceRef"
          },
          {
            "$ref": "#/components/schemas/ExactApplicationWorkResourceRef"
          }
        ]
      },
      "WorkerStatus": {
        "type": "string",
        "enum": [
          "running",
          "completed",
          "failed",
          "detached",
          "stopped",
          "aborted",
          "interrupted"
        ],
        "description": "落盘的 running 只表示\"写这条补丁时还在跑\"——进程被杀不会留下终局补丁，读取侧在父 run 已非 running 时把它派生为 interrupted。"
      },
      "ArchivedManualTopic": {
        "type": "object",
        "description": "一条已归档的手动话题。只读投影，每次请求从话题偏好与 Run 元数据重新推导",
        "required": [
          "agentId",
          "conversationId",
          "title",
          "archivedAt"
        ],
        "additionalProperties": false,
        "properties": {
          "agentId": {
            "type": "string",
            "description": "话题所属 Agent ID；界面按它分组并取头像与名称"
          },
          "conversationId": {
            "type": "string",
            "description": "话题 ID（__manual:<uuid>）；恢复时原样用于 PUT /api/agents/:agentId/manual-topics/:conversationId/archive"
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "description": "话题标题：用户命名优先，其次取谱系内最近一个带标题的 Run；都没有时为 null"
          },
          "projectId": {
            "type": "string",
            "description": "话题绑定的 Project ID；独立话题省略"
          },
          "projectName": {
            "type": "string",
            "description": "所绑定 Project 的名称；Project 已不存在或读取失败时省略，projectId 照常返回"
          },
          "archivedAt": {
            "type": "string",
            "description": "归档时间（ISO 8601），列表按它倒序"
          }
        }
      },
      "PersistentBoundModel": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "provider",
          "model"
        ],
        "properties": {
          "providerId": {
            "type": "string",
            "description": "创建本轮的 Provider 引用，不含凭据。"
          },
          "provider": {
            "type": "string",
            "description": "本轮开始时的 Provider 类型。"
          },
          "model": {
            "type": "string",
            "description": "本轮开始时的模型；自动回退不覆盖，用于识别用户主动换模。"
          },
          "routingMode": {
            "type": "string",
            "enum": [
              "smart",
              "fixed"
            ],
            "description": "本轮模型选择模式。"
          }
        }
      },
      "TaskBoardWorkflowResourceRef": {
        "description": "Workflow binding 指向的 canonical Board 或 Task；展示名称不参与身份。",
        "oneOf": [
          {
            "type": "object",
            "required": [
              "resourceType",
              "boardId"
            ],
            "properties": {
              "resourceType": {
                "type": "string",
                "const": "board",
                "description": "绑定目标为整个 canonical TaskBoard。"
              },
              "boardId": {
                "type": "string",
                "minLength": 1,
                "description": "canonical TaskBoard 的稳定 ID。"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "resourceType",
              "taskRef"
            ],
            "properties": {
              "resourceType": {
                "type": "string",
                "const": "task",
                "description": "绑定目标为一个 canonical Task。"
              },
              "taskRef": {
                "description": "绑定目标的 canonical TaskRef。",
                "type": "object",
                "required": [
                  "boardId",
                  "taskId"
                ],
                "properties": {
                  "boardId": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Task 所属 canonical TaskBoard ID。"
                  },
                  "taskId": {
                    "type": "string",
                    "minLength": 1,
                    "description": "TaskBoard 内稳定 Task ID。"
                  },
                  "taskVersion": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "可选的 Task CAS 版本；TaskCreate 返回时提供，可直接传给 Delegate。"
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          }
        ]
      },
      "ExactWorkflowDefinitionResourceRef": {
        "type": "object",
        "description": "绑定到 Workflow 定义精确 revision/hash 的 portable 引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "workflowId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "workflow-definition",
            "description": "资源由 Workflow Service 持有。"
          },
          "workflowId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Workflow Service 中的稳定 Workflow 定义 ID。"
          },
          "pin": {
            "type": "object",
            "description": "固定可迁移 Workflow 定义的 revision 与内容摘要；canonical 文件路径属于 owner 解析结果，不进入 portable ref。",
            "required": [
              "mode",
              "definitionRevision",
              "contentHash"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "const": "exact",
                "description": "精确 Workflow 定义版本。"
              },
              "definitionRevision": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991,
                "description": "Workflow owner 的正安全整数定义 revision。"
              },
              "contentHash": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$",
                "description": "Owner 对 canonical 内容计算的 64 个小写十六进制字符（SHA-256）。"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "TaskAcceptanceCriteria": {
        "description": "委派人设定的结构化验收标准。只有委派人能改；执行智能体提交时逐条自评，人整体判定。",
        "type": "object",
        "required": [
          "revision",
          "items",
          "updatedBy",
          "updatedAt"
        ],
        "properties": {
          "revision": {
            "type": "integer",
            "minimum": 1,
            "description": "每次修改递增；提交审核时记录当时的 revision。"
          },
          "items": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "$ref": "#/components/schemas/TaskAcceptanceCriterion"
            },
            "description": "按委派人排定的顺序排列；空数组表示已清空。"
          },
          "updatedBy": {
            "description": "最后一次修改标准的委派人。",
            "type": "object",
            "required": [
              "type",
              "id"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "human",
                  "agent",
                  "system"
                ],
                "description": "事实执行者类型；授权必须按稳定 ID 重新判定，不能信任展示名称。"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "用户 ID、Agent ID 或系统主体 ID。"
              },
              "displayName": {
                "type": "string",
                "minLength": 1,
                "description": "写入事实时的展示名称快照，不参与身份唯一性或授权。"
              }
            },
            "additionalProperties": false
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "最后一次修改标准的时间。"
          }
        },
        "additionalProperties": false
      },
      "TaskProgress": {
        "description": "执行智能体自报的步骤进度：已完成几步、共几步。只是执行者的自述，不是计划，也不是完成判定；平台不推断、不核实。",
        "type": "object",
        "required": [
          "completed",
          "total",
          "reportedAt",
          "reportedBy"
        ],
        "properties": {
          "completed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 99,
            "description": "执行者自报已完成的步骤数；不大于 total。"
          },
          "total": {
            "type": "integer",
            "minimum": 1,
            "maximum": 99,
            "description": "执行者当前计划的总步骤数；重新规划时可以改大或改小。"
          },
          "reportedAt": {
            "type": "string",
            "format": "date-time",
            "description": "服务端写入的上报时间，即进度最后一次变化的时间。"
          },
          "reportedBy": {
            "description": "服务端按可信身份写入的上报智能体。",
            "type": "object",
            "required": [
              "type",
              "id"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "human",
                  "agent"
                ],
                "description": "责任主体只能是 human 或 agent。"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "用户 ID、Agent ID 或系统主体 ID。"
              },
              "displayName": {
                "type": "string",
                "minLength": 1,
                "description": "写入事实时的展示名称快照，不参与身份唯一性或授权。"
              }
            },
            "additionalProperties": false
          },
          "claimEpoch": {
            "type": "integer",
            "minimum": 1,
            "description": "上报时任务的认领世代，由服务端写入。与任务当前认领世代不一致即视为过期；没有认领的会话任务省略。"
          }
        },
        "additionalProperties": false
      },
      "TaskWakeRequest": {
        "description": "新委派、改派、移交或指定审核人后，等待派单服务唤醒负责人或审核智能体的登记；唤醒评论写入后清除。",
        "type": "object",
        "required": [
          "requestId",
          "target",
          "role",
          "requestedBy",
          "requestedAt"
        ],
        "properties": {
          "requestId": {
            "type": "string",
            "minLength": 1,
            "description": "本次唤醒的稳定 ID，也是唤醒评论的幂等依据。"
          },
          "target": {
            "description": "要唤醒的智能体，即新的负责人或审核人。",
            "type": "object",
            "required": [
              "type",
              "id"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "human",
                  "agent"
                ],
                "description": "责任主体只能是 human 或 agent。"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "用户 ID、Agent ID 或系统主体 ID。"
              },
              "displayName": {
                "type": "string",
                "minLength": 1,
                "description": "写入事实时的展示名称快照，不参与身份唯一性或授权。"
              }
            },
            "additionalProperties": false
          },
          "role": {
            "type": "string",
            "enum": [
              "assignee",
              "reviewer"
            ],
            "description": "assignee=交给它负责执行；reviewer=请它审核提交。"
          },
          "requestedBy": {
            "description": "发起责任变更的人或智能体；唤醒评论以它的名义写入。",
            "type": "object",
            "required": [
              "type",
              "id"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "human",
                  "agent",
                  "system"
                ],
                "description": "事实执行者类型；授权必须按稳定 ID 重新判定，不能信任展示名称。"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "用户 ID、Agent ID 或系统主体 ID。"
              },
              "displayName": {
                "type": "string",
                "minLength": 1,
                "description": "写入事实时的展示名称快照，不参与身份唯一性或授权。"
              }
            },
            "additionalProperties": false
          },
          "requestedRunId": {
            "type": "string",
            "minLength": 1,
            "description": "发起者是智能体时它当时所在的运行，用于以智能体身份写评论时的来源授权。"
          },
          "requestedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "note": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000,
            "description": "发起人写给目标的说明，原样带进唤醒评论。"
          },
          "failure": {
            "type": "object",
            "required": [
              "code",
              "message",
              "failedAt"
            ],
            "properties": {
              "code": {
                "type": "string",
                "minLength": 1,
                "description": "稳定失败码，如目标无法被派单。"
              },
              "message": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500,
                "description": "面向用户的失败原因。"
              },
              "failedAt": {
                "type": "string",
                "format": "date-time",
                "description": "ISO 8601 日期时间。"
              }
            },
            "additionalProperties": false,
            "description": "唤醒失败时记录的原因；存在时派单服务不再自动重试。"
          }
        },
        "additionalProperties": false
      },
      "CurrentTaskResourceRef": {
        "type": "object",
        "description": "指向 Task 最新版本的引用，只用于导航。",
        "required": [
          "schemaVersion",
          "resourceType",
          "boardId",
          "taskId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "task",
            "description": "资源类型：TaskBoard 上的 Task。"
          },
          "boardId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Task 所在 TaskBoard 的 ID。"
          },
          "taskId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Task 的 ID。"
          },
          "pin": {
            "$ref": "#/components/schemas/CurrentResourcePin"
          }
        },
        "additionalProperties": false
      },
      "CurrentWorkContextResourceRef": {
        "type": "object",
        "description": "导航到 Work Context 当前版本的引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "ownerUserId",
          "targetAgentId",
          "workContextId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "work-context",
            "description": "资源由 Context/Session owner 持有。"
          },
          "ownerUserId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "拥有此 Work Context 数据根的用户 ID。"
          },
          "targetAgentId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "执行此 Work Context 的稳定 Agent ID。"
          },
          "workContextId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Context/Session owner 中的稳定 Work Context ID。"
          },
          "pin": {
            "$ref": "#/components/schemas/CurrentResourcePin"
          }
        },
        "additionalProperties": false
      },
      "CurrentWorkflowDefinitionResourceRef": {
        "type": "object",
        "description": "导航到 Workflow 定义当前版本的 portable 引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "workflowId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "workflow-definition",
            "description": "资源由 Workflow Service 持有。"
          },
          "workflowId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Workflow Service 中的稳定 Workflow 定义 ID。"
          },
          "pin": {
            "$ref": "#/components/schemas/CurrentResourcePin"
          }
        },
        "additionalProperties": false
      },
      "CurrentDecisionWorkspaceResourceRef": {
        "type": "object",
        "description": "导航到 DecisionWorkspace 当前 revision 的引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "scope",
          "workspaceId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "decision-workspace",
            "description": "资源由 DecisionWorkspace owner 持有。"
          },
          "scope": {
            "description": "解析 workspace 时必须重新鉴权的 user/team scope。",
            "type": "object",
            "required": [
              "type",
              "id"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "user",
                  "team"
                ],
                "description": "user=个人，team=Agent 团队。项目级可信 principal 尚未接入前不公开 project 假能力。"
              },
              "id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$",
                "description": "稳定 ID；仅允许字母、数字、点、下划线和短横线，且不得用作展示名称。"
              }
            },
            "additionalProperties": false
          },
          "workspaceId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "DecisionWorkspace owner 中的稳定 workspace ID。"
          },
          "pin": {
            "$ref": "#/components/schemas/CurrentResourcePin"
          }
        },
        "additionalProperties": false
      },
      "CurrentFileResourceRef": {
        "type": "object",
        "description": "导航到已登记文件资源当前内容的引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "fileRef",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "file",
            "description": "资源由 WorkDir/FileWorkbench owner 持有。"
          },
          "fileRef": {
            "type": "object",
            "required": [
              "schemaVersion",
              "instanceId",
              "agentId",
              "rootId",
              "path"
            ],
            "properties": {
              "schemaVersion": {
                "type": "integer",
                "const": 1,
                "description": "文件资源引用格式版本；当前固定为 1。"
              },
              "instanceId": {
                "type": "string",
                "pattern": "^inst_[A-Za-z0-9_-]{32}$",
                "description": "签发并解析该资源引用的 Agent Service 稳定实例身份。"
              },
              "agentId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]+$",
                "description": "解析该资源时使用的 Agent 权限上下文；不是显示名称。"
              },
              "rootId": {
                "type": "string",
                "minLength": 16,
                "description": "目标实例为当前已登记工作目录签发的不透明根目录 ID。"
              },
              "path": {
                "type": "string",
                "description": "相对 rootId 的规范 POSIX 路径；根目录为空字符串，不允许绝对路径、反斜线、空段、`.`、`..` 或 NUL。"
              }
            },
            "additionalProperties": false,
            "description": "FileWorkbench 已签发的实例、Agent、root 与 canonical relative path；resolver 仍须重新检查实例、根、realpath 与 containment。"
          },
          "pin": {
            "$ref": "#/components/schemas/CurrentResourcePin"
          }
        },
        "additionalProperties": false
      },
      "CurrentDecisionTreeResourceRef": {
        "type": "object",
        "description": "为 DecisionTree owner 预留的 current 导航引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "scope",
          "treeId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "decision-tree",
            "description": "资源由 DecisionTree owner 持有。"
          },
          "scope": {
            "$ref": "#/components/schemas/GovernedDocumentScope"
          },
          "treeId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "DecisionTree owner 中的稳定 tree ID。"
          },
          "pin": {
            "$ref": "#/components/schemas/CurrentResourcePin"
          }
        },
        "additionalProperties": false
      },
      "CurrentBoardResourceRef": {
        "type": "object",
        "description": "为自由 Board owner 预留的 current 导航引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "boardId",
          "fileRef",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "board",
            "description": "资源由 Board/FileWorkbench owner 持有。"
          },
          "boardId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Board sidecar 中的稳定 board ID。"
          },
          "fileRef": {
            "type": "object",
            "required": [
              "schemaVersion",
              "instanceId",
              "agentId",
              "rootId",
              "path"
            ],
            "properties": {
              "schemaVersion": {
                "type": "integer",
                "const": 1,
                "description": "文件资源引用格式版本；当前固定为 1。"
              },
              "instanceId": {
                "type": "string",
                "pattern": "^inst_[A-Za-z0-9_-]{32}$",
                "description": "签发并解析该资源引用的 Agent Service 稳定实例身份。"
              },
              "agentId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]+$",
                "description": "解析该资源时使用的 Agent 权限上下文；不是显示名称。"
              },
              "rootId": {
                "type": "string",
                "minLength": 16,
                "description": "目标实例为当前已登记工作目录签发的不透明根目录 ID。"
              },
              "path": {
                "type": "string",
                "description": "相对 rootId 的规范 POSIX 路径；根目录为空字符串，不允许绝对路径、反斜线、空段、`.`、`..` 或 NUL。"
              }
            },
            "additionalProperties": false,
            "description": "承载 `.drawnix` 字节的 owner-issued FileResourceRef；裸绝对路径不进入 Board identity。"
          },
          "pin": {
            "$ref": "#/components/schemas/CurrentResourcePin"
          }
        },
        "additionalProperties": false
      },
      "CurrentViewDocumentResourceRef": {
        "type": "object",
        "description": "导航到持久 ViewDocument 当前 revision 的引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "scope",
          "viewId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "view-document",
            "description": "资源由 Projection ViewDocument owner 持有。"
          },
          "scope": {
            "$ref": "#/components/schemas/GovernedDocumentScope"
          },
          "viewId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Projection ViewDocument owner 中的稳定 view ID；source resource ref 不进入 view identity。"
          },
          "pin": {
            "$ref": "#/components/schemas/CurrentResourcePin"
          }
        },
        "additionalProperties": false
      },
      "ExactTaskResourceRef": {
        "type": "object",
        "description": "固定到 Task 某个版本的引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "boardId",
          "taskId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "task",
            "description": "资源类型：TaskBoard 上的 Task。"
          },
          "boardId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Task 所在 TaskBoard 的 ID。"
          },
          "taskId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Task 的 ID。"
          },
          "pin": {
            "type": "object",
            "description": "固定到 Task 的一个确定版本。",
            "required": [
              "mode",
              "taskVersion"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "const": "exact",
                "description": "固定到 taskVersion 指定的版本。"
              },
              "taskVersion": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991,
                "description": "Task 的版本号，即读取 Task 时返回的 version。"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "ExactWorkContextResourceRef": {
        "type": "object",
        "description": "绑定到 Work Context 精确 version 的引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "ownerUserId",
          "targetAgentId",
          "workContextId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "work-context",
            "description": "资源由 Context/Session owner 持有。"
          },
          "ownerUserId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "拥有此 Work Context 数据根的用户 ID。"
          },
          "targetAgentId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "执行此 Work Context 的稳定 Agent ID。"
          },
          "workContextId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Context/Session owner 中的稳定 Work Context ID。"
          },
          "pin": {
            "type": "object",
            "description": "固定 Work Context owner 中的精确乐观并发版本。",
            "required": [
              "mode",
              "workContextVersion"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "const": "exact",
                "description": "精确 Work Context 版本。"
              },
              "workContextVersion": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991,
                "description": "Work Context owner 的正安全整数 version。"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "ExactDecisionWorkspaceResourceRef": {
        "type": "object",
        "description": "绑定到 DecisionWorkspace 精确 revision/hash 的引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "scope",
          "workspaceId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "decision-workspace",
            "description": "资源由 DecisionWorkspace owner 持有。"
          },
          "scope": {
            "description": "解析 workspace 时必须重新鉴权的 user/team scope。",
            "type": "object",
            "required": [
              "type",
              "id"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "user",
                  "team"
                ],
                "description": "user=个人，team=Agent 团队。项目级可信 principal 尚未接入前不公开 project 假能力。"
              },
              "id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$",
                "description": "稳定 ID；仅允许字母、数字、点、下划线和短横线，且不得用作展示名称。"
              }
            },
            "additionalProperties": false
          },
          "workspaceId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "DecisionWorkspace owner 中的稳定 workspace ID。"
          },
          "pin": {
            "type": "object",
            "description": "固定版本化领域文档的不可变 revision 与 canonical 内容摘要。",
            "required": [
              "mode",
              "revision",
              "contentHash"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "const": "exact",
                "description": "精确不可变 revision。"
              },
              "revision": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991,
                "description": "领域 owner 的正安全整数单调 revision。"
              },
              "contentHash": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$",
                "description": "Owner 对 canonical 内容计算的 64 个小写十六进制字符（SHA-256）。"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "ExactFileResourceRef": {
        "type": "object",
        "description": "绑定到已登记文件资源精确内容 ETag 的引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "fileRef",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "file",
            "description": "资源由 WorkDir/FileWorkbench owner 持有。"
          },
          "fileRef": {
            "type": "object",
            "required": [
              "schemaVersion",
              "instanceId",
              "agentId",
              "rootId",
              "path"
            ],
            "properties": {
              "schemaVersion": {
                "type": "integer",
                "const": 1,
                "description": "文件资源引用格式版本；当前固定为 1。"
              },
              "instanceId": {
                "type": "string",
                "pattern": "^inst_[A-Za-z0-9_-]{32}$",
                "description": "签发并解析该资源引用的 Agent Service 稳定实例身份。"
              },
              "agentId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]+$",
                "description": "解析该资源时使用的 Agent 权限上下文；不是显示名称。"
              },
              "rootId": {
                "type": "string",
                "minLength": 16,
                "description": "目标实例为当前已登记工作目录签发的不透明根目录 ID。"
              },
              "path": {
                "type": "string",
                "description": "相对 rootId 的规范 POSIX 路径；根目录为空字符串，不允许绝对路径、反斜线、空段、`.`、`..` 或 NUL。"
              }
            },
            "additionalProperties": false,
            "description": "FileWorkbench 已签发的实例、Agent、root 与 canonical relative path；resolver 仍须重新检查实例、根、realpath 与 containment。"
          },
          "pin": {
            "type": "object",
            "description": "固定 FileWorkbench 已读取文件字节的强内容 ETag。",
            "required": [
              "mode",
              "etag"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "const": "exact",
                "description": "精确文件内容版本。"
              },
              "etag": {
                "type": "string",
                "pattern": "^\"sha256-[A-Za-z0-9_-]{43}\"$",
                "description": "FileWorkbench 对文件内容签发的强 SHA-256 ETag；stat-only 弱标识不能作为 exact pin。"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "ExactWorkDirResourceRef": {
        "type": "object",
        "description": "由 WorkDir owner 的不可变 workdirId 标识的资源；路径可变化但不进入 identity，owner 每次按当前配置重新解析。",
        "required": [
          "schemaVersion",
          "resourceType",
          "instanceId",
          "ownerScope",
          "workdirId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "workdir",
            "description": "资源由 WorkDir 配置 owner 持有。"
          },
          "instanceId": {
            "type": "string",
            "pattern": "^inst_[A-Za-z0-9_-]{32}$",
            "description": "签发此本机 WorkDir 引用的 Agent Service 数据空间。"
          },
          "ownerScope": {
            "$ref": "#/components/schemas/GovernedWorkDirOwnerScope"
          },
          "workdirId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "WorkDir owner 分配且在删除前保持稳定的 ID。"
          },
          "pin": {
            "$ref": "#/components/schemas/ImmutableIdentityPin"
          }
        },
        "additionalProperties": false
      },
      "ExactBoundWorktreeResourceRef": {
        "type": "object",
        "description": "精确指向当前仍存活的 owner-level Git worktree binding；Exit 或 replacement 后同一 ref 必须失效。",
        "required": [
          "schemaVersion",
          "resourceType",
          "instanceId",
          "owner",
          "bindingId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "bound-worktree",
            "description": "资源由 Worktree binding owner 持有。"
          },
          "instanceId": {
            "type": "string",
            "pattern": "^inst_[A-Za-z0-9_-]{32}$",
            "description": "持有该 worktree binding 的 Agent Service 数据空间。"
          },
          "owner": {
            "oneOf": [
              {
                "type": "object",
                "description": "默认会话管理模式下的 Agent 级 worktree 归属",
                "required": [
                  "type",
                  "userId",
                  "agentId"
                ],
                "properties": {
                  "type": {
                    "const": "agent",
                    "description": "归属类型：Agent"
                  },
                  "userId": {
                    "type": "string",
                    "minLength": 1,
                    "description": "拥有该 Agent 的用户 ID"
                  },
                  "agentId": {
                    "type": "string",
                    "minLength": 1,
                    "description": "worktree 绑定的 Agent ID"
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "description": "手动会话管理模式下的独立会话级 worktree 归属",
                "required": [
                  "type",
                  "userId",
                  "agentId",
                  "conversationId"
                ],
                "properties": {
                  "type": {
                    "const": "manual-conversation",
                    "description": "归属类型：手动会话"
                  },
                  "userId": {
                    "type": "string",
                    "minLength": 1,
                    "description": "拥有该会话的用户 ID"
                  },
                  "agentId": {
                    "type": "string",
                    "minLength": 1,
                    "description": "该手动会话所属的 Agent ID"
                  },
                  "conversationId": {
                    "type": "string",
                    "pattern": "^__manual:.+",
                    "description": "跨 Run 稳定的手动会话 ID，必须使用 __manual: 前缀"
                  }
                },
                "additionalProperties": false
              }
            ],
            "description": "绑定的完整稳定 owner；不能用当前 Run/session 推测。"
          },
          "bindingId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "绑定随机稳定 ID；用于拒绝同 owner 在旧绑定退出后创建的 replacement。"
          },
          "pin": {
            "$ref": "#/components/schemas/ImmutableIdentityPin"
          }
        },
        "additionalProperties": false
      },
      "ExactRunResourceRef": {
        "type": "object",
        "description": "精确 Run identity；状态变化不改变 Run ID。",
        "required": [
          "schemaVersion",
          "resourceType",
          "ownerUserId",
          "agentId",
          "runId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "run",
            "description": "资源由 RunManager 持有。"
          },
          "ownerUserId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Run meta 中的权威 user owner，resolver 必须与可信 principal 比对。"
          },
          "agentId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Run meta 中的权威 Agent ID。"
          },
          "runId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "RunManager 中全局稳定的 Run ID。"
          },
          "pin": {
            "$ref": "#/components/schemas/ImmutableIdentityPin"
          }
        },
        "additionalProperties": false
      },
      "ExactReceiptResourceRef": {
        "type": "object",
        "description": "精确 Receipt identity；Receipt owner 必须先复验父 Run 的 user/Agent 归属。",
        "required": [
          "schemaVersion",
          "resourceType",
          "ownerUserId",
          "agentId",
          "runId",
          "receiptId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "receipt",
            "description": "资源由 Receipt owner 持有。"
          },
          "ownerUserId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "父 Run meta 中的权威 user owner。"
          },
          "agentId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "父 Run meta 中的权威 Agent ID。"
          },
          "runId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "保存该 Receipt 的父 Run ID。"
          },
          "receiptId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "父 Run 的 Receipt owner 中的稳定回执 ID。"
          },
          "pin": {
            "$ref": "#/components/schemas/ImmutableIdentityPin"
          }
        },
        "additionalProperties": false
      },
      "ExactDecisionTreeResourceRef": {
        "type": "object",
        "description": "为 DecisionTree owner 预留的精确 revision/hash 引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "scope",
          "treeId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "decision-tree",
            "description": "资源由 DecisionTree owner 持有。"
          },
          "scope": {
            "$ref": "#/components/schemas/GovernedDocumentScope"
          },
          "treeId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "DecisionTree owner 中的稳定 tree ID。"
          },
          "pin": {
            "type": "object",
            "description": "固定版本化领域文档的不可变 revision 与 canonical 内容摘要。",
            "required": [
              "mode",
              "revision",
              "contentHash"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "const": "exact",
                "description": "精确不可变 revision。"
              },
              "revision": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991,
                "description": "领域 owner 的正安全整数单调 revision。"
              },
              "contentHash": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$",
                "description": "Owner 对 canonical 内容计算的 64 个小写十六进制字符（SHA-256）。"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "ExactDecisionTreeRunResourceRef": {
        "type": "object",
        "required": [
          "schemaVersion",
          "resourceType",
          "treeRef",
          "runId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "decision-tree-run",
            "description": "DecisionTree Run Owner 持有的只读不可变事件前缀；与聊天Run独立。"
          },
          "treeRef": {
            "type": "object",
            "description": "此Run启动时固定的定义修订与内容哈希；不随定义当前版本变化。",
            "required": [
              "schemaVersion",
              "resourceType",
              "scope",
              "treeId",
              "pin"
            ],
            "properties": {
              "schemaVersion": {
                "type": "integer",
                "const": 1,
                "description": "GovernedResourceRef 契约版本；当前固定为 1。"
              },
              "resourceType": {
                "type": "string",
                "const": "decision-tree",
                "description": "资源由 DecisionTree owner 持有。"
              },
              "scope": {
                "$ref": "#/components/schemas/GovernedDocumentScope"
              },
              "treeId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 512,
                "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
                "description": "DecisionTree owner 中的稳定 tree ID。"
              },
              "pin": {
                "type": "object",
                "description": "固定版本化领域文档的不可变 revision 与 canonical 内容摘要。",
                "required": [
                  "mode",
                  "revision",
                  "contentHash"
                ],
                "properties": {
                  "mode": {
                    "type": "string",
                    "const": "exact",
                    "description": "精确不可变 revision。"
                  },
                  "revision": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 9007199254740991,
                    "description": "领域 owner 的正安全整数单调 revision。"
                  },
                  "contentHash": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$",
                    "description": "Owner 对 canonical 内容计算的 64 个小写十六进制字符（SHA-256）。"
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          },
          "runId": {
            "type": "string",
            "pattern": "^dtrun_[A-Za-z0-9_-]{43}$",
            "description": "DecisionTree Owner签发的持久Run ID，不接受聊天Run ID。"
          },
          "pin": {
            "type": "object",
            "required": [
              "mode",
              "sequence",
              "runChainHash"
            ],
            "additionalProperties": false,
            "properties": {
              "mode": {
                "type": "string",
                "const": "exact",
                "description": "只支持精确事件前缀，不隐式追随当前tip。"
              },
              "sequence": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991,
                "description": "本次读取最后一个已提交事件的序号；后续追加不改变此前缀。"
              },
              "runChainHash": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$",
                "description": "截至sequence的权威事件链哈希；Owner读取时必须核对。"
              }
            },
            "description": "固定已提交事件前缀，仅用于只读投影，不作为追加事件或回答的命令授权。"
          }
        },
        "additionalProperties": false,
        "description": "决策树Run不可变前缀的独立精确资源引用；不携带答案、事件正文或执行权限。"
      },
      "ExactBoardResourceRef": {
        "type": "object",
        "description": "为自由 Board owner 预留的精确 sidecar revision/hash/file ETag 引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "boardId",
          "fileRef",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "board",
            "description": "资源由 Board/FileWorkbench owner 持有。"
          },
          "boardId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Board sidecar 中的稳定 board ID。"
          },
          "fileRef": {
            "type": "object",
            "required": [
              "schemaVersion",
              "instanceId",
              "agentId",
              "rootId",
              "path"
            ],
            "properties": {
              "schemaVersion": {
                "type": "integer",
                "const": 1,
                "description": "文件资源引用格式版本；当前固定为 1。"
              },
              "instanceId": {
                "type": "string",
                "pattern": "^inst_[A-Za-z0-9_-]{32}$",
                "description": "签发并解析该资源引用的 Agent Service 稳定实例身份。"
              },
              "agentId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]+$",
                "description": "解析该资源时使用的 Agent 权限上下文；不是显示名称。"
              },
              "rootId": {
                "type": "string",
                "minLength": 16,
                "description": "目标实例为当前已登记工作目录签发的不透明根目录 ID。"
              },
              "path": {
                "type": "string",
                "description": "相对 rootId 的规范 POSIX 路径；根目录为空字符串，不允许绝对路径、反斜线、空段、`.`、`..` 或 NUL。"
              }
            },
            "additionalProperties": false,
            "description": "承载 `.drawnix` 字节的 owner-issued FileResourceRef；裸绝对路径不进入 Board identity。"
          },
          "pin": {
            "type": "object",
            "description": "固定 Board sidecar revision、canonical Drawnix 内容摘要与对应文件字节。",
            "required": [
              "mode",
              "revision",
              "contentHash",
              "etag"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "const": "exact",
                "description": "精确 Board revision。"
              },
              "revision": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991,
                "description": "Board owner 的正安全整数单调 sidecar revision。"
              },
              "contentHash": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$",
                "description": "Owner 对 canonical 内容计算的 64 个小写十六进制字符（SHA-256）。"
              },
              "etag": {
                "type": "string",
                "pattern": "^\"sha256-[A-Za-z0-9_-]{43}\"$",
                "description": "与此 Board revision 一致的 `.drawnix` 文件强内容 ETag。"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "ExactViewDocumentResourceRef": {
        "type": "object",
        "description": "绑定到持久 ViewDocument 精确 revision/hash 的引用。",
        "required": [
          "schemaVersion",
          "resourceType",
          "scope",
          "viewId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "type": "string",
            "const": "view-document",
            "description": "资源由 Projection ViewDocument owner 持有。"
          },
          "scope": {
            "$ref": "#/components/schemas/GovernedDocumentScope"
          },
          "viewId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Projection ViewDocument owner 中的稳定 view ID；source resource ref 不进入 view identity。"
          },
          "pin": {
            "type": "object",
            "description": "固定版本化领域文档的不可变 revision 与 canonical 内容摘要。",
            "required": [
              "mode",
              "revision",
              "contentHash"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "const": "exact",
                "description": "精确不可变 revision。"
              },
              "revision": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991,
                "description": "领域 owner 的正安全整数单调 revision。"
              },
              "contentHash": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$",
                "description": "Owner 对 canonical 内容计算的 64 个小写十六进制字符（SHA-256）。"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "ExactApplicationObjectResourceRef": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "resourceType",
          "objectRef",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "const": "application-object",
            "description": "应用业务owner的精确对象；引用不授予全文访问。"
          },
          "objectRef": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "schemaVersion",
              "sourceId",
              "appId",
              "installationId",
              "namespace",
              "objectId",
              "revision"
            ],
            "properties": {
              "schemaVersion": {
                "const": 1,
                "description": "应用对象引用版本。"
              },
              "sourceId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
                "description": "对象所属应用的真实来源。"
              },
              "appId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
                "description": "逻辑产品身份，不用显示名。"
              },
              "installationId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
                "description": "对象所属精确实例。"
              },
              "namespace": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
                "description": "业务owner定义的对象命名空间。"
              },
              "objectId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200,
                "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
                "description": "稳定业务对象身份。"
              },
              "revision": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "业务owner核验的版本，不是UI epoch或可见采集时间。"
              }
            },
            "description": "业务对象身份，不授予读取全文/修改权限；owner每次重新鉴权并CAS。"
          },
          "pin": {
            "type": "object",
            "required": [
              "mode",
              "revision"
            ],
            "additionalProperties": false,
            "description": "精确业务对象版本；revision 必须与 objectRef.revision 相同，引用仍须原 owner 重新鉴权。",
            "properties": {
              "mode": {
                "const": "exact",
                "description": "固定业务对象版本，不随UI选择切换。"
              },
              "revision": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "业务owner核验的版本，不是UI epoch或可见采集时间。"
              }
            }
          }
        },
        "description": "正式应用对象的有限owner资源适配；所有字段由业务owner重新核验。"
      },
      "ExactApplicationWorkResourceRef": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "resourceType",
          "ownerUserId",
          "hostInstanceId",
          "sourceId",
          "appId",
          "scope",
          "proposalRef",
          "clientRequestId",
          "agentId",
          "pin"
        ],
        "properties": {
          "schemaVersion": {
            "type": "integer",
            "const": 1,
            "description": "GovernedResourceRef 契约版本；当前固定为 1。"
          },
          "resourceType": {
            "const": "application-work",
            "description": "应用提案owner已冻结的精确用户工作意图，不是新Task。"
          },
          "ownerUserId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Owner 域内的稳定资源 ID；不得使用显示名称代替，不接受首尾空白或 ASCII 控制字符。"
          },
          "hostInstanceId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Owner 域内的稳定资源 ID；不得使用显示名称代替，不接受首尾空白或 ASCII 控制字符。"
          },
          "sourceId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Owner 域内的稳定资源 ID；不得使用显示名称代替，不接受首尾空白或 ASCII 控制字符。"
          },
          "appId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Owner 域内的稳定资源 ID；不得使用显示名称代替，不接受首尾空白或 ASCII 控制字符。"
          },
          "scope": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "kind",
                  "installationId",
                  "installationRevision"
                ],
                "additionalProperties": false,
                "properties": {
                  "kind": {
                    "const": "installation",
                    "description": "正式安装运行。"
                  },
                  "installationId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
                    "description": "有界稳定身份；来源、实例、对象和请求不得相互替代。"
                  },
                  "installationRevision": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$",
                    "description": "真实当前安装 CAS 修订，不能使用 none。"
                  }
                }
              },
              {
                "type": "object",
                "required": [
                  "kind",
                  "previewId",
                  "draftId",
                  "previewRevision"
                ],
                "additionalProperties": false,
                "properties": {
                  "kind": {
                    "const": "preview",
                    "description": "独立开发运行。"
                  },
                  "previewId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
                    "description": "有界稳定身份；来源、实例、对象和请求不得相互替代。"
                  },
                  "draftId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
                    "description": "有界稳定身份；来源、实例、对象和请求不得相互替代。"
                  },
                  "previewRevision": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
                    "description": "预览 owner 的当前修订。"
                  }
                }
              }
            ],
            "description": "当前可信运行所绑定的精确版本作用域。"
          },
          "proposalRef": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Owner 域内的稳定资源 ID；不得使用显示名称代替，不接受首尾空白或 ASCII 控制字符。"
          },
          "clientRequestId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Owner 域内的稳定资源 ID；不得使用显示名称代替，不接受首尾空白或 ASCII 控制字符。"
          },
          "agentId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "Owner 域内的稳定资源 ID；不得使用显示名称代替，不接受首尾空白或 ASCII 控制字符。"
          },
          "pin": {
            "type": "object",
            "required": [
              "mode",
              "bodyDigest"
            ],
            "additionalProperties": false,
            "description": "固定原 owner 冻结提案的 bodyDigest；只接纳该提案的真实用户动作，不授予其他执行权限。",
            "properties": {
              "mode": {
                "const": "exact",
                "description": "最终动作绑定精确提案摘要。"
              },
              "bodyDigest": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$",
                "description": "Owner 对 canonical 内容计算的 64 个小写十六进制字符（SHA-256）。"
              }
            }
          }
        },
        "description": "真实宿主human-interaction的窄目标，只支持该原提案request操作。"
      },
      "TaskAcceptanceCriterion": {
        "description": "一条验收标准。",
        "type": "object",
        "required": [
          "id",
          "text",
          "addedBy",
          "sinceRevision"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^ac-[A-Za-z0-9_-]{6,64}$",
            "description": "服务端生成的条目 ID；同一任务内不复用，修改文字不改变 ID。"
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "description": "标准正文：一条可以检查的要求。"
          },
          "evidenceHint": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300,
            "description": "委派人期望的证据形式，仅供执行者参考，系统不校验。"
          },
          "addedBy": {
            "description": "首次添加这一条的委派人。",
            "type": "object",
            "required": [
              "type",
              "id"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "human",
                  "agent",
                  "system"
                ],
                "description": "事实执行者类型；授权必须按稳定 ID 重新判定，不能信任展示名称。"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "用户 ID、Agent ID 或系统主体 ID。"
              },
              "displayName": {
                "type": "string",
                "minLength": 1,
                "description": "写入事实时的展示名称快照，不参与身份唯一性或授权。"
              }
            },
            "additionalProperties": false
          },
          "sinceRevision": {
            "type": "integer",
            "minimum": 1,
            "description": "这一条最后一次新增或修改所在的标准 revision；大于提交时的 revision 即为提交后修改。"
          }
        },
        "additionalProperties": false
      },
      "TaskClaimExecution": {
        "description": "认领所绑定执行的结束事实，由执行 owner 写回；同一认领只记录一次。",
        "type": "object",
        "required": [
          "outcome",
          "resumable",
          "runId",
          "endedAt",
          "recordedAt",
          "source"
        ],
        "properties": {
          "outcome": {
            "type": "string",
            "enum": [
              "endedWithoutSubmit",
              "interrupted",
              "failed",
              "canceled"
            ],
            "description": "endedWithoutSubmit=一轮正常结束但没有提交验收；interrupted=执行被中断；failed=执行失败；canceled=执行被取消。"
          },
          "resumable": {
            "type": "boolean",
            "description": "执行能否在原会话继续。派单运行不可续聊（ADR-090），恒为 false；为 true 时存活判定仍为 unknown。"
          },
          "runId": {
            "type": "string",
            "minLength": 1,
            "description": "结束的运行 ID，与认领的 runRef.runId 一致。"
          },
          "endedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "recordedAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 日期时间。"
          },
          "source": {
            "type": "object",
            "required": [
              "kind",
              "id"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "mentionDelivery",
                  "run"
                ],
                "description": "结束事实的来源 owner。"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "description": "来源 owner 内的稳定 ID，如 delivery_id。"
              }
            },
            "additionalProperties": false,
            "description": "结束事实的来源，用于幂等去重与审计。"
          }
        },
        "additionalProperties": false
      },
      "CurrentResourcePin": {
        "type": "object",
        "description": "解析 owner 当前版本的导航 pin；只能用于导航，不能作为绑定、修改、执行或 decision-grade 输入。",
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "type": "string",
            "const": "current",
            "description": "显式选择 owner 当前版本。"
          }
        },
        "additionalProperties": false
      },
      "GovernedDocumentScope": {
        "type": "object",
        "description": "新版本化共管文档的长期 user/team scope；授权由领域 owner 实时判定。",
        "required": [
          "type",
          "id"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "user",
              "team"
            ],
            "description": "共管文档的 owner scope 类型。"
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "用户或 Team 的稳定 scope ID。"
          }
        },
        "additionalProperties": false
      },
      "GovernedWorkDirOwnerScope": {
        "type": "object",
        "description": "WorkDir owner 的稳定作用域；不包含绝对路径。",
        "required": [
          "type",
          "id"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "user",
              "agent",
              "team"
            ],
            "description": "WorkDir 配置的 owner scope 类型。"
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "pattern": "^(?!.*[\\u0000-\\u001F\\u007F])\\S(?:.*\\S)?$",
            "description": "用户、Agent 或 Team 的稳定 owner ID。"
          }
        },
        "additionalProperties": false
      },
      "ImmutableIdentityPin": {
        "type": "object",
        "description": "资源 ID 本身已指向不可变事实或唯一活动绑定时使用的 exact pin。",
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "type": "string",
            "const": "exact",
            "description": "精确引用，不解析为同 owner 的其他资源。"
          }
        },
        "additionalProperties": false
      },
      "TaskCriterionCheck": {
        "description": "执行智能体对一条验收标准的自评，不是判定。",
        "type": "object",
        "required": [
          "criterionId",
          "selfAssessment",
          "evidence"
        ],
        "properties": {
          "criterionId": {
            "type": "string",
            "minLength": 1,
            "description": "被自评的标准条目 ID。"
          },
          "selfAssessment": {
            "type": "string",
            "enum": [
              "met",
              "notMet",
              "notApplicable"
            ],
            "description": "执行者自评：已满足、未满足、不适用。由人整体决定是否通过。"
          },
          "evidence": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000,
            "description": "支撑自评的说明：做了什么、在哪里可以核对；未满足或不适用时写明原因。"
          },
          "attachmentMediaIds": {
            "type": "array",
            "maxItems": 10,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            },
            "description": "引用本任务已有附件（Task.attachmentRefs）的 mediaId。"
          },
          "commentIds": {
            "type": "array",
            "maxItems": 10,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            },
            "description": "引用本任务评论的 ID。"
          }
        },
        "additionalProperties": false
      },
      "WorkerListResponse": {
        "type": "object",
        "properties": {
          "run_id": {
            "type": "string"
          },
          "workers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkerSummary"
            }
          }
        },
        "required": [
          "run_id",
          "workers"
        ],
        "additionalProperties": false
      },
      "WorkerTranscriptPage": {
        "type": "object",
        "properties": {
          "run_id": {
            "type": "string"
          },
          "workerId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "running",
              "completed",
              "failed",
              "detached",
              "stopped",
              "aborted",
              "interrupted",
              "unknown"
            ]
          },
          "worker": {
            "$ref": "#/components/schemas/WorkerSummary"
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkerTranscriptEntry"
            }
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2000
          },
          "truncated": {
            "type": "boolean"
          },
          "corruptLines": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "run_id",
          "workerId",
          "status",
          "entries",
          "total",
          "offset",
          "limit",
          "truncated"
        ],
        "additionalProperties": false
      },
      "TeamArchiveList": {
        "type": "object",
        "properties": {
          "success": {
            "const": true
          },
          "data": {
            "type": "object",
            "properties": {
              "archives": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ArchivedTeamSummary"
                }
              }
            },
            "required": [
              "archives"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "success",
          "data"
        ],
        "additionalProperties": false
      },
      "TeamRestoreResponse": {
        "type": "object",
        "properties": {
          "success": {
            "const": true
          },
          "data": {
            "$ref": "#/components/schemas/TeamRestoreResult"
          }
        },
        "required": [
          "success",
          "data"
        ],
        "additionalProperties": false
      },
      "GovernedWorkflowBindingResult": {
        "type": "object",
        "properties": {
          "binding": {
            "$ref": "#/components/schemas/GovernedWorkflowBinding"
          },
          "changed": {
            "type": "boolean"
          },
          "revision": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "binding",
          "changed",
          "revision"
        ],
        "additionalProperties": false
      },
      "ComputePreparationReady": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "const": "ready"
          }
        },
        "required": [
          "status"
        ],
        "additionalProperties": false
      },
      "OperationError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "ModelToolOutputProjection": {
        "type": "object",
        "additionalProperties": false,
        "description": "Harness 保存的模型结果投影；只含原本模型可见的 text/image，排除 details 与 UI metadata。普通恢复保持预览；无合法 Read 的已授权继承按 blockIndex 精确回填原文。",
        "required": [
          "schemaVersion",
          "content",
          "references"
        ],
        "properties": {
          "schemaVersion": {
            "const": 1,
            "description": "模型结果投影格式版本。"
          },
          "content": {
            "type": "array",
            "description": "投影后按原顺序保留的模型内容，不包含工具 UI 字段。",
            "items": {
              "anyOf": [
                {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "type",
                    "text"
                  ],
                  "properties": {
                    "type": {
                      "const": "text",
                      "description": "模型文本块。"
                    },
                    "text": {
                      "type": "string",
                      "description": "内联正文或明确带内容地址的预览。"
                    }
                  }
                },
                {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "type",
                    "data",
                    "mimeType"
                  ],
                  "properties": {
                    "type": {
                      "const": "image",
                      "description": "模型原本可见的图片块。"
                    },
                    "data": {
                      "type": "string",
                      "description": "模型图片的原始 base64 数据，不从 UI metadata 补充。"
                    },
                    "mimeType": {
                      "type": "string",
                      "description": "模型图片 MIME 类型。"
                    }
                  }
                }
              ]
            }
          },
          "references": {
            "type": "array",
            "minItems": 1,
            "description": "已外置文本在 content 中的真实位置，引用完整信息位于同条记录的 modelOutputRefs。",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "blockIndex",
                "sha256"
              ],
              "properties": {
                "blockIndex": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991,
                  "description": "原模型内容数组中的 text 块索引；不搜索或替换 URI 字符串。"
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$",
                  "description": "对应 modelOutputRefs 中已核验全文的内容摘要。"
                }
              }
            }
          }
        }
      },
      "ModelToolOutputReference": {
        "type": "object",
        "additionalProperties": false,
        "description": "模型工具结果的完整 UTF-8 文本；在当前 Run 的 sessions/outputs 中按内容寻址，读取仍校验 Run 归属和隐私。不是 FileResourceRef，也不授予一般文件访问权限。",
        "required": [
          "schemaVersion",
          "uri",
          "sha256",
          "bytes",
          "encoding",
          "representation"
        ],
        "properties": {
          "schemaVersion": {
            "const": 1,
            "description": "引用格式版本。"
          },
          "uri": {
            "type": "string",
            "pattern": "^dc-tool-output:[a-f0-9]{64}$",
            "description": "当前 Run 内的稳定内容地址；可通过已有 Read 工具按 UTF-8 字节分页读取。"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$",
            "description": "完整原始 UTF-8 字节的 SHA-256，读取时从同一文件描述符验证。"
          },
          "bytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "完整文本的实际 UTF-8 字节数，不是字符数。"
          },
          "encoding": {
            "const": "utf8",
            "description": "完整文本的 UTF-8 编码；不额外添加 BOM，原文中的 U+FEFF 和其它字符原样保留。"
          },
          "representation": {
            "const": "model-visible-text",
            "description": "仅保存本次原本模型可见的文本，不包含 UI metadata 或敏感结果。"
          }
        }
      }
    }
  },
  "x-service": "agent-service",
  "x-source": {
    "repository": "desirecore/desirecore",
    "revision": "724d8fe87c2e01a7495c3e22f1910e1b4486caa9"
  }
}
