Skip to content

Go implementation of DeepSeek Harness and self-hosted personal agent.

Go
80.9 KB
Raw Blame
openapi: 3.0.3
info:
  title: Go Bot HTTP API
  version: 0.1.0
  description: The local Controller selects an account through X-User-ID.
    Direct Host requests use the internal Host token instead.
servers:
- url: http://127.0.0.1:8080
paths:
  /assets/plugins/{pluginId}/{file}:
    get:
      summary: Read a catalog plugin image declared in plugin.json
      parameters:
        - {name: pluginId, in: path, required: true, schema: {type: string}}
        - {name: file, in: path, required: true, schema: {type: string}}
      responses:
        '200':
          description: Public plugin image; no running Host is required
          content:
            image/png:
              schema: {type: string, format: binary}
        '404': {description: Image not found}
  /v1/host/extensions/authorization:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    get:
      tags: [Extensions]
      summary: List plugin authorization flows without other clients' interaction details
      operationId: listPluginAuthorization
      responses:
        '200':
          description: Registered methods, in-flight state and account configuration reported by the native integration or Go credential store
          content:
            application/json:
              schema: {type: array, items: {$ref: '#/components/schemas/AuthorizationEntry'}}
        '409': {description: Host is not running}
        '503': {description: Plugin runtime is not running}
    delete:
      tags: [Extensions]
      summary: Cancel a key's active attempt even when its initiating page has closed
      operationId: cancelPluginAuthorizationKey
      description: Uses the original cancel(key) seam. No interaction details from another surface are returned; an admitted commit finishes before settlement.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [key]
              properties:
                key: {type: string}
      responses:
        '200':
          description: Settlement or a no-op when no attempt is running
          content:
            application/json:
              schema:
                type: object
                properties:
                  status: {type: string, enum: [authorized, cancelled, failed]}
    post:
      tags: [Extensions]
      summary: Start an explicit authorization using the bundled client's own interaction surface
      operationId: startPluginAuthorization
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [key]
              additionalProperties: false
              properties:
                key: {type: string, description: CredentialKey of the registered flow}
                method: {type: string, description: Defaults to the first declared method}
      responses:
        '202':
          description: An admitted attempt; this response is not an authorization success
          content:
            application/json:
              schema: {$ref: '#/components/schemas/AuthorizationAttempt'}
        '404': {description: No such registered flow}
        '409': {description: Host unavailable or this key already has an active attempt}
        '422': {description: Invalid method or key}
  /v1/host/extensions/authorization/disconnect:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    post:
      tags: [Extensions]
      summary: Disconnect an account using the integration's native logout
      operationId: disconnectPluginAuthorization
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [key]
              properties:
                key: {type: string}
      responses:
        '200':
          description: Native account is no longer configured
          content:
            application/json:
              schema:
                type: object
                properties:
                  configured: {type: boolean}
                  accountLabel: {type: string}
        '409': {description: Host unavailable or another authorization operation is in progress}
        '404': {description: No registered disconnect operation for this account}
        '422': {description: The native account is still configured}
  /v1/host/extensions/authorization/{attemptId}:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    - {name: attemptId, in: path, required: true, schema: {type: string, format: uuid}}
    get:
      tags: [Extensions]
      summary: Read notices and unanswered prompts using the initiating surface's transient handle
      operationId: getPluginAuthorization
      responses:
        '200':
          description: Current attempt; never contains entered answers or credential values
          content:
            application/json:
              schema: {$ref: '#/components/schemas/AuthorizationAttempt'}
        '404': {description: Unknown handle or runtime restarted}
        '409': {description: Host is not running}
    delete:
      tags: [Extensions]
      summary: Withdraw this attempt and wait for its authorization outcome
      operationId: cancelPluginAuthorization
      description: An admitted record commit finishes. Cancellation does not remove an earlier credential record. There is no framework-wide timeout.
      responses:
        '200':
          description: Settled outcome, including authorized when a commit was already admitted
          content:
            application/json:
              schema: {$ref: '#/components/schemas/AuthorizationAttempt'}
        '404': {description: Unknown handle or runtime restarted}
  /v1/host/extensions/authorization/{attemptId}/answer:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    - {name: attemptId, in: path, required: true, schema: {type: string, format: uuid}}
    post:
      tags: [Extensions]
      summary: Answer or decline one prompt in this authorization
      operationId: answerPluginAuthorization
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [promptId]
              additionalProperties: false
              properties:
                promptId: {type: string, format: uuid}
                answer: {type: string, maxLength: 16384, description: Sent only to the waiting flow; never echoed or stored by Controller}
                decline: {type: boolean, description: Reject this prompt with the original AuthorizationDeclinedError}
      responses:
        '200':
          description: Updated interaction; the flow can continue asynchronously
          content:
            application/json:
              schema: {$ref: '#/components/schemas/AuthorizationAttempt'}
        '404': {description: Unknown attempt or prompt no longer pending}
        '422': {description: Invalid answer or unoffered select option}
  /v1/host/mcp:
    get:
      tags: [Extensions]
      summary: Plugin-owned MCP runtime diagnostics; configured through the owning plugin
      operationId: getMCPStatus
      parameters:
        - {$ref: '#/components/parameters/AccountName'}
      responses:
        '200':
          description: Actual Host connection state without independent account settings
          content:
            application/json:
              schema: {$ref: '#/components/schemas/MCPView'}
  /v1/host/mcp/servers/{name}/restart:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    - name: name
      in: path
      required: true
      schema: {type: string, pattern: '^[A-Za-z0-9_-]{1,32}$'}
    post:
      summary: Reconnect a managed MCP server after completing prior cleanup
      operationId: restartMCPServer
      responses:
        '200':
          description: Actual state after the initial reconnect attempt.
          content:
            application/json:
              schema: {$ref: '#/components/schemas/MCPView'}
        '409': {description: Host is not running}
        '502': {description: Restart failed}
  /v1/host/mcp/servers/{name}/probe:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    - name: name
      in: path
      required: true
      schema: {type: string, pattern: '^[A-Za-z0-9_-]{1,32}$'}
    post:
      summary: Inspect and close a temporary MCP connection without publishing tools
      operationId: probeMCPServer
      responses:
        '200':
          description: Temporary probe state, independent of the managed server state. OAuth never starts implicitly.
          content:
            application/json:
              schema:
                type: object
                required: [name, source, state, toolCount, resources]
                properties:
                  name: {type: string}
                  source: {type: string, enum: [user, plugin]}
                  owner: {type: string}
                  state: {type: string, enum: [connected, failed, waiting-credentials, waiting-authorization, stopping]}
                  error: {type: string}
                  missing: {type: array, items: {type: string}}
                  toolCount: {type: integer, minimum: 0}
                  resources: {type: boolean}
                  protocolVersion: {type: string}
                  serverName: {type: string}
                  oauthEnabled: {type: boolean, description: The plugin declared standard MCP OAuth for this connection.}
        '409': {description: Host is not running}
        '502': {description: Host probe request or cleanup failed}
  /v1/host/mcp/servers/{name}/authorize:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    - name: name
      in: path
      required: true
      schema: {type: string, pattern: '^[A-Za-z0-9_-]{1,32}$'}
    post:
      summary: Start an explicit MCP OAuth authorization-code flow with PKCE
      operationId: authorizeMCPServer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                origin:
                  type: string
                  description: Visible Controller origin; must match the actual request Host. HTTPS or loopback HTTP only. Forwarded destination headers are not trusted.
      responses:
        '200':
          description: Authorization URL is ready, or the attempt completed without further browser interaction.
          content:
            application/json:
              schema: {$ref: '#/components/schemas/MCPOAuthAuthorization'}
        '400': {description: Invalid origin or callback requirements}
        '409': {description: Host is not running}
        '502': {description: Authorization preparation failed}
  /v1/host/mcp/servers/{name}/authorization:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    - name: name
      in: path
      required: true
      schema: {type: string, pattern: '^[A-Za-z0-9_-]{1,32}$'}
    delete:
      summary: Cancel a pending browser authorization without deleting an existing grant
      operationId: cancelMCPAuthorization
      parameters:
      - name: id
        in: query
        schema: {type: string, maxLength: 128}
        description: Select this attempt only; stale identities are ignored. Omission cancels the current attempt.
      responses:
        '200':
          description: Attempt cleanup completed; saved credentials remain independent.
          content:
            application/json:
              schema: {$ref: '#/components/schemas/MCPView'}
        '409': {description: Host is not running}
        '502': {description: Authorization cleanup failed}
  /v1/host/mcp/servers/{name}/grant:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    - name: name
      in: path
      required: true
      schema: {type: string, pattern: '^[A-Za-z0-9_-]{1,32}$'}
    delete:
      summary: Disconnect MCP and remove its local OAuth grant
      operationId: disconnectMCPOAuth
      responses:
        '200':
          description: Connection stopped and local grant removed; no remote provider revocation is implied.
          content:
            application/json:
              schema: {$ref: '#/components/schemas/MCPView'}
        '409': {description: Host is not running}
        '502': {description: Local cleanup or grant deletion failed}
  /v1/mcp/oauth/callback/{userId}:
    parameters:
    - name: userId
      in: path
      required: true
      schema: {type: string}
    - name: state
      in: query
      required: true
      schema: {type: string}
    - name: code
      in: query
      schema: {type: string}
    - name: iss
      in: query
      schema: {type: string}
    - name: error
      in: query
      schema: {type: string}
    get:
      summary: Forward a browser callback to the already-running account Host for one-time state validation
      operationId: completeMCPOAuthCallback
      description: No X-User-ID header is required. Only this callback is exempted from browser-origin checks. A stopped Host is never started by the callback.
      responses:
        '200':
          description: Fixed confirmation page, or a request to continue additional provider authorization in Go Bot. Does not echo codes, tokens or state.
          content:
            text/html:
              schema: {type: string}
        '400': {description: Invalid, expired, replayed or failed authorization}
        '404': {description: Account unavailable}
        '409': {description: Host is not running}
  /v1/plugins/authorization/callback/{userId}/{token}:
    get:
      tags: [Extensions]
      summary: Receive a single-use browser callback for an active plugin authorization
      operationId: receivePluginAuthorizationCallback
      parameters:
      - {in: path, name: userId, required: true, schema: {type: string}}
      - {in: path, name: token, required: true, schema: {type: string, format: uuid}}
      - {in: query, name: state, required: true, schema: {type: string}}
      description: Provider query parameters are forwarded privately to the current flow. Receipt does not mean authorization succeeded. This endpoint does not require X-User-ID and never starts a Host.
      responses:
        '200':
          description: Callback received; return to the app for the actual authorization outcome.
          content:
            text/html:
              schema: {type: string}
        '400': {description: Invalid, expired, replayed or rejected callback}
        '409': {description: The account has no running Host}
  /v1/settings/plugins:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    get:
      summary: Saved plugin settings and actual Host runtime state
      operationId: getPluginSettings
      responses:
        '200':
          description: Credential values are never returned; a stopped Host reports unavailable.
          content:
            application/json:
              schema: {$ref: '#/components/schemas/PluginView'}
  /v1/settings/plugins/packages:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    post:
      summary: Install a reviewed plugin and its dependencies; initially disabled
      operationId: installPluginPackage
      requestBody:
        required: true
        content:
          application/json:
            schema: {$ref: '#/components/schemas/PluginPackageInput'}
      responses:
        '200':
          description: Package and approved native installation scripts completed.
          content:
            application/json:
              schema: {$ref: '#/components/schemas/PluginView'}
        '409': {description: Host is stopped or package is already configured}
        '422': {description: Package preparation failed}
        '502': {description: Intent was saved but the Host could not confirm application}
  /v1/settings/plugins/packages/{name}:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    - {in: path, name: name, required: true, schema: {type: string}, description: URL-encode the complete npm package name as one segment.}
    put:
      summary: Enable or disable an installed plugin package
      operationId: setPluginEnabled
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [enabled]
              properties:
                enabled: {type: boolean}
      responses:
        '200':
          description: Saved selection and actual Host status
          content:
            application/json:
              schema: {$ref: '#/components/schemas/PluginView'}
        '400': {description: Invalid input}
        '404': {description: Plugin is not installed}
        '502': {description: Selection saved but activation failed}
    delete:
      summary: Remove package intent and stop its code before uninstalling
      operationId: removePluginPackage
      responses:
        '200':
          description: Credentials and workspace data are retained.
          content:
            application/json:
              schema: {$ref: '#/components/schemas/PluginView'}
        '404': {description: Package not configured}
        '409': {description: Host is not running}
        '502': {description: Intent was saved but Host removal failed}
  /v1/settings/plugins/packages/{name}/update:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    - {in: path, name: name, required: true, schema: {type: string}}
    post:
      summary: Prepare and explicitly apply a new package version
      operationId: updatePluginPackage
      requestBody:
        required: true
        content:
          application/json:
            schema: {$ref: '#/components/schemas/PluginPackageInput'}
      responses:
        '200':
          description: Actual state after applying the new saved source
          content:
            application/json:
              schema: {$ref: '#/components/schemas/PluginView'}
        '404': {description: Package not configured}
        '409': {description: Host is not running}
        '502': {description: New intent was saved but application failed}
  /v1/host/plugins/runtime/restart:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    post:
      summary: Apply saved intent and restart the Host extension process
      operationId: restartPlugins
      responses:
        '200':
          description: Actual state after cleanup and restart
          content:
            application/json:
              schema: {$ref: '#/components/schemas/PluginView'}
        '409': {description: Host is not running}
        '502': {description: Application or restart failed}
  /v1/settings/proactive:
    parameters:
    - $ref: '#/components/parameters/AccountName'
    get:
      summary: Read proactive assistance preference and Host status without starting a Host
      operationId: getProactiveSettings
      responses:
        '200':
          description: Account preference and current Host status, timestamps in Unix milliseconds
          content:
            application/json:
              schema: {$ref: '#/components/schemas/ProactiveStatus'}
        '404': {description: Account not found}
    put:
      summary: Save the proactive assistance preference and apply it to a running Host
      operationId: saveProactiveSettings
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [enabled]
              properties:
                enabled: {type: boolean}
      responses:
        '200':
          description: Saved preference and current Host status
          content:
            application/json:
              schema: {$ref: '#/components/schemas/ProactiveStatus'}
        '400': {description: Invalid settings}
        '404': {description: Account not found}
        '503': {description: Storage unavailable or settings_saved_host_apply_failed after a successful Redis save}
  /healthz:
    get:
      summary: Process liveness
      operationId: get__healthz
      responses:
        '200':
          description: Success
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
  /readyz:
    get:
      summary: Application readiness
      operationId: get__readyz
      responses:
        '200':
          description: Success
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
  /v1/capabilities:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Current Host capabilities
      operationId: get__v1_capabilities
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: &id001
                type: object
                additionalProperties: true
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
  /v1/accounts:
    post:
      summary: Create an account by name
      operationId: post__v1_accounts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [userId]
              properties:
                userId:
                  type: string
                  pattern: '^[a-z0-9][a-z0-9_-]{0,63}$'
      responses:
        '201':
          description: Account created
          content:
            application/json:
              schema:
                type: object
                required: [userId]
                properties:
                  userId:
                    type: string
        '400':
          description: Invalid account name
        '409':
          description: Account already exists
        '503':
          description: Account store unavailable
  /v1/settings/models:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Read the model catalog with redacted credentials
      responses:
        '200':
          description: Catalog containing defaultEndpointId and endpoints keyed by ID
        '404': {description: Account not found}
  /v1/settings/models/endpoints:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    post:
      summary: Add an OpenAI-compatible Responses endpoint
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
              - $ref: "#/components/schemas/ModelEndpointInput"
              - type: object
                required: [name, baseUrl, apiKey, models]
      responses:
        '201': {description: Endpoint saved, returning endpointId and status}
        '503': {description: Settings could not be saved or the running Host could not apply them}
        '400': {description: Invalid model endpoint}
  /v1/settings/models/endpoints/{endpointId}:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    - name: endpointId
      in: path
      required: true
      schema: {type: string, format: uuid}
    patch:
      summary: Edit supplied endpoint fields
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ModelEndpointInput"
      responses:
        '200': {description: Endpoint updated}
        '503': {description: Settings could not be saved or the running Host could not apply them}
        '400': {description: Invalid endpoint or API key missing for a new origin}
        '404': {description: Endpoint not found}
    delete:
      summary: Remove an endpoint and clear it if it was the default
      responses:
        '200': {description: Endpoint removed}
        '503': {description: Settings could not be saved or the running Host could not apply them}
        '404': {description: Endpoint not found}
  /v1/settings/models/default:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    put:
      summary: Change the default endpoint for new sessions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [endpointId]
              properties:
                endpointId:
                  type: string
                  description: Endpoint ID, or an empty string to clear the default
      responses:
        '200': {description: Default saved}
        '503': {description: Settings could not be saved or the running Host could not apply them}
        '400': {description: Invalid endpoint}
  /v1/host:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Controller runtime state
      operationId: get__v1_host
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: *id001
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
  /v1/host/schedules:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Read the Host task catalog without activating sessions
      responses:
        '200':
          description: Active tasks first, followed by paused and ended tasks
          content:
            application/json:
              schema:
                type: object
                required: [tasks]
                properties:
                  tasks:
                    type: array
                    items: {$ref: "#/components/schemas/ScheduleEntry"}
        '503': {description: Host or Schedule unavailable}
    post:
      summary: Create a scheduled task
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [title, prompt, timing]
              properties:
                title: {type: string, maxLength: 120}
                prompt: {type: string}
                timing: {$ref: "#/components/schemas/ScheduleTiming"}
                target: {$ref: "#/components/schemas/ScheduleTarget"}
      responses:
        '201':
          description: Task stored
          content:
            application/json:
              schema: {$ref: "#/components/schemas/ScheduleEntry"}
        '400': {description: Invalid rule or destination}
  /v1/host/schedules/list:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: List a page from the Host task catalog
      parameters:
      - {name: active, in: query, schema: {type: boolean}}
      - {name: limit, in: query, schema: {type: integer, minimum: 1, maximum: 500, default: 100}}
      - {name: offset, in: query, schema: {type: integer, minimum: 0, default: 0}}
      responses:
        '200': {description: Page with items, shown, total, limit and offset}
        '400': {description: Invalid page options}
  /v1/host/schedules/limits:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Read the per-task delivery interval for tasks that always create a new session
      responses:
        '200': {description: newSessionIntervalSeconds in seconds}
  /v1/host/schedules/ended:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    delete:
      summary: Remove all ended tasks and their delivery histories
      responses:
        '200': {description: Count of deleted tasks}
  /v1/host/stream:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    - $ref: "#/components/parameters/ControllerOrigin"
    get:
      summary: Stream all account session updates and task catalog changes over one SSE connection
      parameters:
      - name: cursors
        in: query
        description: URL-encoded JSON object mapping up to 20 cached session IDs to their last durable sequence or null
        schema: {type: string, maxLength: 8192}
      responses:
        '200':
          description: "event: host records containing sessionId (for session events), type and data; connection restores pending interactions"
          content:
            text/event-stream:
              schema: {type: string}
        '400': {description: Invalid session cursor map}
        '503': {description: Host unavailable}
  /v1/host/schedules/stream:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Invalidate a cached task catalog when task data or execution activity changes
      responses:
        '200':
          description: schedule/changed events
          content:
            text/event-stream:
              schema: {type: string}
  /v1/host/schedules/{scheduleId}:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    - &scheduleId {name: scheduleId, in: path, required: true, schema: {type: string}}
    get:
      summary: Read a task by ID
      responses:
        '200':
          description: Task details
          content:
            application/json:
              schema: {$ref: "#/components/schemas/ScheduleEntry"}
        '404': {description: Task missing}
    patch:
      summary: Edit or delete a scheduled task
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [action]
              properties:
                action: {type: string, enum: [update, delete]}
                expectedUpdatedAt: {type: string, format: date-time, nullable: true}
                patch:
                  type: object
                  properties:
                    title: {type: string, maxLength: 120}
                    prompt: {type: string}
                    target: {$ref: "#/components/schemas/ScheduleTarget"}
                    timing: {$ref: "#/components/schemas/ScheduleTiming"}
                    active: {type: boolean}
      responses:
        '200': {description: Updated task or deletion receipt}
        '400': {description: Invalid edit}
        '404': {description: Task missing}
        '409': {description: The task changed since the submitted revision}
  /v1/host/schedules/{scheduleId}/run:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    - *scheduleId
    post:
      summary: Deliver a task now without advancing its next occurrence
      responses:
        '200':
          description: Task with the accepted delivery receipt
          content:
            application/json:
              schema: {$ref: "#/components/schemas/ScheduleEntry"}
        '404': {description: Task missing}
        '409': {description: Execution is queued, running, or inside its minimum interval}
  /v1/host/schedules/{scheduleId}/history:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    - *scheduleId
    get:
      summary: Read durable deliveries without activating their sessions
      parameters:
      - {name: limit, in: query, required: true, schema: {type: integer, minimum: 1, maximum: 100}}
      - {name: before, in: query, schema: {type: string}, description: Exclusive delivery message ID}
      responses:
        '200': {description: Receipts in newest-first order, retention limits and optional nextBefore cursor}
        '404': {description: Task or cursor missing}
  /v1/host/files:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: List an account Host directory
      description: Read file metadata under /root/harness without starting a session.
      parameters:
      - name: path
        in: query
        description: Relative directory path. Omit it for the root.
        schema: {type: string}
      - name: offset
        in: query
        schema: {type: integer, minimum: 0, default: 0}
      responses:
        '200':
          description: Directory entries and the next offset, when available
          headers:
            X-Harness-Storage:
              schema: {type: string, enum: [docker-volume, nas, instance]}
            X-Harness-Storage-Source:
              description: Docker volume name or NAS subdirectory
              schema: {type: string}
          content:
            application/json:
              schema:
                type: object
                required: [rootPath, path, files, truncated]
                properties:
                  rootPath: {type: string, example: /root/harness}
                  path: {type: string}
                  truncated: {type: boolean}
                  nextOffset: {type: integer}
                  files:
                    type: array
                    items:
                      type: object
                      required: [name, path, isDir, size]
                      properties:
                        name: {type: string}
                        path: {type: string}
                        isDir: {type: boolean}
                        size: {type: integer, format: int64}
        '400':
          description: Invalid directory path or offset
        '404':
          description: Account or directory not found
        '503':
          description: Host unavailable
  /v1/host/instance:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    delete:
      summary: Delete precisely owned compute, retain external data
      operationId: delete__v1_host_instance
      responses:
        '204':
          description: Success
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
        '504':
          description: Runtime operation could not be confirmed before the deadline
  /v1/hosts/{hostId}:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Read an instance of the selected account
      operationId: get__v1_hosts_hostId
      parameters:
      - in: path
        name: hostId
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Host state
          content:
            application/json:
              schema: *id001
        '404':
          description: Instance absent or assigned to a different account
        '503':
          description: Service unavailable
  /v1/host/start:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    post:
      summary: Start Host and prepare its stable main chat without requiring an LLM
      operationId: post__v1_host_start
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                welcomeLocale:
                  type: string
                  enum: [en, zh-CN]
                  default: en
      responses:
        '200':
          description: Core Host ready; prepare selected plugins separately
          content:
            application/json:
              schema:
                type: object
                required: [mainSessionId]
                properties:
                  mainSessionId: {type: string, format: uuid}
        '400':
          description: Invalid request
        '404':
          description: Account not found
        '503':
          description: Host or main chat preparation failed
        '504':
          description: Runtime operation could not be confirmed before the deadline
  /v1/host/plugins/prepare:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    post:
      summary: Prepare missing selected packages and apply plugin enabled state
      operationId: post__v1_host_plugins_prepare
      responses:
        '200':
          description: Plugin catalog, settings and actual runtime status
        '409':
          description: Host is not running
        '422':
          description: Plugin preparation failed; successful packages remain usable
        '503':
          description: Account settings unavailable
  /v1/host/stop:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    post:
      summary: Stop Host
      operationId: post__v1_host_stop
      responses:
        '204':
          description: Success
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
        '504':
          description: Runtime operation could not be confirmed before the deadline
  /v1/settings/web-search:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Read account web search settings
      responses:
        '200':
          description: Available providers, current selection and saved settings with credentials redacted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ToolProviderSettings"
        '404':
          description: Account not found
    put:
      summary: Save settings or select an account web search provider
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                provider: {type: string, default: deepseek, enum: [deepseek, zhipu, doubao, tavily, brave]}
                activate:
                  type: boolean
                  description: Set false to save without changing the active provider. Set true to use this provider with a saved key. Omit for legacy save-and-select behavior.
                apiKey: {type: string, minLength: 1, maxLength: 4096, writeOnly: true}
      responses:
        '200':
          description: Settings saved
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ToolProviderSettings"
        '503':
          description: Settings could not be saved or the running Host could not apply them
        '400':
          description: Invalid provider settings
        '404':
          description: Account not found
    delete:
      summary: Remove the specified provider's API key
      parameters:
      - name: provider
        in: query
        schema: {type: string, default: deepseek}
      responses:
        '200':
          description: API key removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ToolProviderSettings"
        '503':
          description: Settings could not be saved or the running Host could not apply them
        '400':
          description: Unsupported provider
        '404':
          description: Account not found
  /v1/settings/image-generation:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Read account image generation settings
      responses:
        '200':
          description: Available providers, current selection and saved settings with credentials redacted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ToolProviderSettings"
        '404':
          description: Account not found
    put:
      summary: Save settings or select an account image generation provider
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                provider: {type: string, default: seedream, enum: [seedream, openai, nanobanana]}
                activate:
                  type: boolean
                  description: Set false to save without changing the active provider. Set true to use this provider with a saved key. Omit for legacy save-and-select behavior.
                model:
                  type: string
                  minLength: 1
                  maxLength: 256
                  description: Required on initial save and legacy writes. Selection can reuse the stored model.
                apiKey: {type: string, minLength: 1, maxLength: 4096, writeOnly: true}
      responses:
        '200':
          description: Settings saved
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ToolProviderSettings"
        '503':
          description: Settings could not be saved or the running Host could not apply them
        '400':
          description: Invalid provider settings
        '404':
          description: Account not found
    delete:
      summary: Remove the specified provider's API key
      parameters:
      - name: provider
        in: query
        schema: {type: string, default: seedream}
      responses:
        '200':
          description: API key removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ToolProviderSettings"
        '503':
          description: Settings could not be saved or the running Host could not apply them
        '400':
          description: Unsupported provider
        '404':
          description: Account not found
  /v1/sessions:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    post:
      summary: Create a top-level session
      operationId: post__v1_sessions
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                workspaceSessionId:
                  type: string
                  format: uuid
                  description: Reuse the recorded working directory of this session.
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                type: object
                required:
                - sessionId
                properties:
                  sessionId:
                    type: string
                    format: uuid
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: No valid account default model (model_default_required)
        '503':
          description: Service unavailable
    get:
      summary: List persisted and unarchived top-level sessions
      operationId: get__v1_sessions
      parameters:
      - name: latest
        in: query
        description: When true, return only the most recently created unarchived session, if one exists.
        schema:
          type: boolean
      - name: limit
        in: query
        schema:
          type: integer
      - name: cursor
        in: query
        schema:
          type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                required: [sessions]
                properties:
                  sessions:
                    type: array
                    items:
                      type: object
                      required: [sessionId, createdAt, mode]
                      properties:
                        sessionId:
                          type: string
                          format: uuid
                        createdAt:
                          type: string
                          format: date-time
                        mode:
                          type: string
                        title:
                          type: string
                        cwd:
                          type: string
                        isMain:
                          type: boolean
                          description: True for the account main chat
                  nextCursor:
                    type: string
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
  /v1/sessions/{id}:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    delete:
      summary: Archive a top-level session and retain its data on disk
      operationId: archiveSession
      parameters:
      - name: stopActivity
        in: query
        schema: {type: boolean, default: false}
        description: Stop running work and remove active schedules that deliver to this session.
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '204':
          description: Session archived, including a repeated request for the same session
        '404':
          description: Session not found
        '409':
          description: Session is busy or is the destination of a pending scheduled reminder
        '503':
          description: Archive storage is unavailable
    get:
      summary: Active session state
      operationId: get__v1_sessions_id
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: *id001
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
  /v1/sessions/{id}/model:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    - name: id
      in: path
      required: true
      schema: {type: string, format: uuid}
    get:
      summary: Read the selection and availability for one session
      responses:
        '200': {description: Session model selection and status}
        '404': {description: Session not found}
    put:
      summary: Switch this session's endpoint and model for its next turn
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [endpointId, modelId]
              properties:
                endpointId: {type: string, format: uuid}
                modelId: {type: string}
      responses:
        '200': {description: Session model updated}
        '503': {description: Settings could not be saved or the running Host could not apply them}
        '404': {description: Session not found}
        '409': {description: Model selection unavailable}
  /v1/sessions/{id}/messages:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    post:
      summary: Durably admit a new message
      operationId: post__v1_sessions_id_messages
      responses:
        '202':
          description: Success
          content:
            application/json:
              schema:
                type: object
                required:
                - messageId
                properties:
                  messageId:
                    type: string
                  files:
                    type: array
                    items: *id001
                  images:
                    type: array
                    items: *id001
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - content
              properties:
                content:
                  type: string
                  minLength: 1
          multipart/form-data:
            schema:
              type: object
              properties:
                content:
                  type: string
                files:
                  type: array
                  maxItems: 8
                  items:
                    type: string
                    format: binary
                images:
                  type: array
                  items:
                    type: string
                    format: binary
  /v1/sessions/{id}/events:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Durable event page
      operationId: get__v1_sessions_id_events
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  events:
                    type: array
                    items: *id001
                  nextCursor:
                    type: integer
                    nullable: true
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: after
        in: query
        schema:
          type: integer
      - name: limit
        in: query
        schema:
          type: integer
  /v1/sessions/{id}/transcript:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    - name: id
      in: path
      required: true
      schema: {type: string}
    get:
      summary: Web transcript page with whole turns
      description: The first page includes current queue and question snapshots and a durable SSE cursor.
      parameters:
      - name: limit
        in: query
        schema: {type: integer, minimum: 1, maximum: 100, default: 20}
      - name: before
        in: query
        schema: {type: integer, minimum: 0}
      responses:
        '200':
          description: Transcript page
          content:
            application/json:
              schema:
                type: object
                properties:
                  events:
                    type: array
                    items: *id001
                  before: {type: integer, nullable: true}
                  throughSeq: {type: integer, nullable: true}
                  queue:
                    type: array
                    items: {type: object}
                  questions:
                    type: array
                    nullable: true
                    items: {type: object}
        '400':
          description: Invalid turn cursor or limit
        '404':
          description: Session not found
        '503':
          description: Transcript unavailable
  /v1/sessions/{id}/queue/{messageId}:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    - name: id
      in: path
      required: true
      schema: {type: string}
    - name: messageId
      in: path
      required: true
      schema: {type: string}
    delete:
      summary: Remove one queued user message
      responses:
        '204':
          description: Message removed
        '404':
          description: Session or queued message not found
        '503':
          description: Queue unavailable
  /v1/sessions/{id}/queue/{messageId}/steer:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    - name: id
      in: path
      required: true
      schema: {type: string}
    - name: messageId
      in: path
      required: true
      schema: {type: string}
    post:
      summary: Move one queued user message into the active turn's next step
      responses:
        '204':
          description: Message moved
        '404':
          description: Session or queued message not found
        '409':
          description: No active turn for steering
        '503':
          description: Queue unavailable
  /v1/sessions/{id}/stream:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Live assistant chunks and replayable durable events
      operationId: get__v1_sessions_id_stream
      responses:
        '200':
          description: Success
          content:
            text/event-stream:
              schema:
                type: string
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: after
        in: query
        schema:
          type: integer
      - name: view
        in: query
        description: Select the Web transcript projection, queue and question snapshots. The default is the native view.
        schema: {type: string, enum: [chat]}
      - name: Last-Event-ID
        in: header
        schema:
          type: string
  /v1/sessions/{id}/turns/{turnId}/cancel:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    post:
      summary: Cancel queued or running turn
      operationId: post__v1_sessions_id_turns_turnId_cancel
      responses:
        '202':
          description: Success
          content:
            application/json:
              schema: *id001
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: turnId
        in: path
        required: true
        schema:
          type: string
  /v1/sessions/{id}/commands/compact:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    post:
      summary: Compact idle session
      operationId: post__v1_sessions_id_commands_compact
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: *id001
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
  /v1/sessions/{id}/files:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Page workspace directory entries
      operationId: get__v1_sessions_id_files
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: *id001
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: path
        in: query
        schema:
          type: string
      - name: offset
        in: query
        schema:
          type: integer
  /v1/sessions/{id}/files/content:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Download regular workspace file
      description: A present file block supplies the absolute Host path. The requested file must be inside the session workspace.
      operationId: get__v1_sessions_id_files_content
      responses:
        '200':
          description: Success
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: path
        in: query
        description: Workspace-relative path or absolute Host path within the workspace.
        schema:
          type: string
        required: true
  /v1/sessions/{id}/usage:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Read usage
      operationId: get__v1_sessions_id_usage
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: *id001
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
  /v1/sessions/{id}/goal:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Read goal
      operationId: get__v1_sessions_id_goal
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: *id001
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
  /v1/sessions/{id}/plan:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Read plan
      operationId: get__v1_sessions_id_plan
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: *id001
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
    post:
      summary: Set plan mode
      operationId: post__v1_sessions_id_plan
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: *id001
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - active
              properties:
                active:
                  type: boolean
  /v1/sessions/{id}/permissions:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    - name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
    get:
      summary: Read the session permission
      operationId: getSessionPermission
      responses:
        '200':
          description: Effective session permission
          content:
            application/json:
              schema: &sessionPermission
                type: object
                required: [mode, approval]
                properties:
                  mode: &permissionMode
                    type: string
                    enum: [danger-full-access, workspace-write, read-only]
                  approval:
                    type: string
                    enum: [ask, never]
        '404':
          description: Session not found
    post:
      summary: Change the permission of an idle session
      operationId: setSessionPermission
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [mode]
              properties:
                mode: *permissionMode
      responses:
        '200':
          description: Saved session permission
          content:
            application/json:
              schema: *sessionPermission
        '400':
          description: Invalid permission mode
        '404':
          description: Session not found
        '409':
          description: Turn or background work is active
        '503':
          description: Session or sandbox unavailable
  /v1/sessions/{id}/questions:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Read questions
      operationId: get__v1_sessions_id_questions
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: *id001
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
  /v1/sessions/{id}/goal/resume:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    post:
      summary: Resume a goal at its exact revision
      operationId: post__v1_sessions_id_goal_resume
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: *id001
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - goalId
              - revision
              properties:
                goalId:
                  type: string
                revision:
                  type: integer
                  minimum: 1
  /v1/sessions/{id}/questions/{callId}/answer:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    post:
      summary: Answer pending or continued questions and resolve a pending approval
      operationId: post__v1_sessions_id_questions_callId_answer
      responses:
        '204':
          description: Success
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: callId
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - answers
              properties:
                answers:
                  type: array
                  items:
                    type: object
                    required:
                    - id
                    properties:
                      id:
                        type: string
                      selected:
                        type: array
                        items:
                          type: string
                      custom:
                        type: string
  /v1/sessions/{id}/questions/{callId}/cancel:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    post:
      summary: Cancel a pending question
      operationId: post__v1_sessions_id_questions_callId_cancel
      responses:
        '204':
          description: Success
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: callId
        in: path
        required: true
        schema:
          type: string
  /v1/sessions/{id}/attachments/{attachmentId}:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Download an attachment referenced by this session
      operationId: get_session_attachment
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: attachmentId
        in: path
        required: true
        schema:
          type: string
          pattern: '^sha256:[0-9a-f]{64}$'
      - name: name
        in: query
        schema:
          type: string
      responses:
        '200':
          description: Verified attachment bytes
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
            image/*:
              schema:
                type: string
                format: binary
        '404':
          description: No available attachment with that identity in this session
        '503':
          description: Session history unavailable
  /v1/sessions/{id}/schedules/{scheduleId}/history:
    parameters:
    - $ref: "#/components/parameters/AccountName"
    get:
      summary: Read delivery receipts
      operationId: get__v1_sessions_id_schedules_scheduleId_history
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema: *id001
        '400':
          description: Invalid request
        '404':
          description: Not found
        '409':
          description: State conflict
        '503':
          description: Service unavailable
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: scheduleId
        in: path
        required: true
        schema:
          type: string
      - name: limit
        in: query
        schema:
          type: integer
      - name: before
        in: query
        schema:
          type: string
components:
  parameters:
    ControllerOrigin:
      in: header
      name: X-Go-Bot-Controller-Origin
      required: false
      description: Actual Controller origin visible to the client. Must match the request Host; HTTPS or loopback HTTP enables the Host's private OAuth callback channel. Bundled clients send this automatically, including when TLS terminates at a proxy.
      schema: {type: string, format: uri, maxLength: 4096}
    AccountName:
      in: header
      name: X-User-ID
      required: true
      description: Account name on Controller requests
      schema:
        type: string
        pattern: '^[a-z0-9][a-z0-9_-]{0,63}$'
  schemas:
    ProactiveStatus:
      type: object
      required: [enabled, phase]
      properties:
        enabled: {type: boolean}
        phase: {type: string, enum: [waiting, running, waiting-for-model, waiting-for-main, disabled, host-stopped, unavailable, error]}
        nextCheckAt: {type: integer, format: int64, description: Last successful AI decision's next check, in Unix milliseconds}
        nextCheckReason: {type: string}
        lastRunStartedAt: {type: integer, format: int64}
        lastCompletedAt: {type: integer, format: int64}
        error: {type: string, description: Safe status code without credentials or model response bodies}
    AuthorizationEntry:
      type: object
      required: [key, label, methods, inFlight, configured]
      properties:
        key: {type: string}
        label: {type: string}
        methods:
          type: array
          minItems: 1
          items:
            type: object
            required: [id, label]
            properties:
              id: {type: string}
              label: {type: string}
        inFlight: {type: boolean}
        configured: {type: boolean, description: Native integration or Go credential store reports an account; does not assert external service availability}
        canDisconnect: {type: boolean}
        accountLabel: {type: string}
        attemptId: {type: string, format: uuid, description: Latest resumable interaction handle retained by the Host surface.}
        attemptStatus: {type: string, enum: [running, authorized, cancelled, failed]}
    AuthorizationAttempt:
      type: object
      required: [id, key, label, method, status, notices, prompts]
      properties:
        id: {type: string, format: uuid, description: Transient Host interaction handle; absent from Redis and client storage}
        key: {type: string}
        label: {type: string}
        method: {type: string}
        status: {type: string, enum: [running, authorized, cancelled, failed]}
        notices:
          type: array
          items:
            type: object
            required: [message]
            properties:
              message: {type: string}
              url: {type: string}
              code: {type: string}
        prompts:
          type: array
          items:
            type: object
            required: [id, kind, message]
            properties:
              id: {type: string, format: uuid}
              kind: {type: string, enum: [text, secret, select]}
              message: {type: string}
              placeholder: {type: string}
              webInput: {type: string, enum: [json-file], description: "Optional Web file chooser hint; native clients retain the declared text/secret input."}
              options:
                type: array
                items:
                  type: object
                  required: [id, label]
                  properties:
                    id: {type: string}
                    label: {type: string}
                    description: {type: string}
        error: {type: string, description: Diagnostic with captured secret answers redacted}
    MCPServer:
      type: object
      required: [transport]
      additionalProperties: false
      description: Process and HTTP fields are mutually exclusive. Credential templates are resolved only in args, env and headers.
      properties:
        enabled: {type: boolean, default: true}
        transport: {type: string, enum: [stdio, streamable-http]}
        command: {type: string}
        args: {type: array, items: {type: string}}
        env: {type: object, additionalProperties: {type: string}}
        cwd: {type: string, description: Absolute Host directory for stdio}
        url: {type: string, description: HTTP(S) MCP endpoint for streamable-http}
        headers: {type: object, additionalProperties: {type: string}}
        toolLoading: {type: string, enum: [eager, on-demand], default: eager}
        oauth:
          type: object
          additionalProperties: false
          description: Explicit authorization code with PKCE. Omit clientId for dynamic registration; confidential clients use a static credential reference. Grants remain private Host files.
          properties:
            clientId: {type: string}
            clientSecretRef: {type: string}
            credentialKey: {type: string}
            scope: {type: string, description: Explicit scope; omission uses the server challenge}
            requestTimeoutMs: {type: integer, minimum: 1, maximum: 2147483647, default: 10000}
            authorizationTimeoutMs: {type: integer, minimum: 1, maximum: 2147483647, default: 600000}
            scopes: {type: array, items: {type: string}}
    MCPOAuthAuthorization:
      type: object
      required: [name, state]
      properties:
        name: {type: string}
        id: {type: string, description: Opaque attempt identity; distinct from OAuth state and PKCE values}
        phase: {type: string, enum: [starting, waiting-browser, exchanging, committing, authorized, cancelled, failed]}
        state: {type: string, enum: [preparing, pending, connecting, authorized, failed, cancelled, expired]}
        url: {type: string, description: Provider authorization URL, present only while user interaction is needed}
        expiresAt: {type: integer, format: int64, description: Authorization attempt expiry in Unix milliseconds}
        error: {type: string}
    MCPView:
      type: object
      required: [status]
      properties:
        status:
          type: object
          properties:
            error: {type: string}
            servers:
              type: array
              items:
                type: object
                properties:
                  name: {type: string}
                  source: {type: string, enum: [user, plugin]}
                  owner: {type: string}
                  state: {type: string, enum: [disabled, waiting-credentials, waiting-authorization, connecting, connected, reconnecting, stopping, failed]}
                  error: {type: string}
                  missing: {type: array, items: {type: string}}
                  toolCount: {type: integer}
                  resources: {type: boolean}
                  protocolVersion: {type: string}
                  serverName: {type: string}
                  oauthEnabled: {type: boolean, description: The plugin declared standard MCP OAuth for this connection.}
                  authorization: {$ref: '#/components/schemas/MCPOAuthAuthorization'}
    PluginSource:
      type: object
      required: [type, spec]
      properties:
        type: {type: string, enum: [registry, git, directory, tarball, bundled]}
        spec: {type: string, description: Fixed source snapshot resolved by the Controller and Host.}
        registry: {type: string}
        authRef: {type: string, description: Reference to an explicitly saved installation credential.}
        username: {type: string}
    PluginPackageInput:
      type: object
      additionalProperties: false
      required: [pluginId]
      properties:
        pluginId: {type: string, description: Stable ID from the Controller's built-in reviewed catalog.}
    PluginLocalized:
      type: object
      required: [en, zh-CN]
      properties:
        en: {type: string}
        zh-CN: {type: string}
    PluginCatalogEntry:
      type: object
      required: [pluginId, package, name, description, version, icon, maintainer, license]
      properties:
        pluginId: {type: string}
        package: {type: string}
        name: {type: string}
        description: {$ref: '#/components/schemas/PluginLocalized'}
        version: {type: string}
        icon: {type: string, description: Controller-relative image path declared by plugin.json}
        maintainer: {type: string}
        license: {type: string}
        tutorials:
          type: array
          items:
            type: object
            required: [language, title, video]
            properties:
              language: {type: string, enum: [en, zh-CN]}
              title: {type: string}
              video: {type: string, description: Backend-relative MP4 asset from plugin.json}
              poster: {type: string, description: Optional backend-relative poster image}
    PluginPackageInfo:
      type: object
      properties:
        name: {type: string}
        version: {type: string}
        description: {type: string}
        license: {type: string}
        source: {$ref: '#/components/schemas/PluginSource'}
        api: {type: string, enum: ['1']}
        title: {type: string}
        availableVersion: {type: string, description: Present only when the reviewed release is newer than the actual installed package.}
        configSchema: {type: object, additionalProperties: true}
        present: {type: boolean}
    PluginSettings:
      type: object
      additionalProperties: false
      required: [packages]
      properties:
        packages:
          type: object
          additionalProperties:
            type: object
            additionalProperties: false
            required: [catalogId, version, enabled]
            properties:
              catalogId: {type: string}
              version: {type: string}
              enabled: {type: boolean}
    PluginView:
      type: object
      required: [catalog, settings, status]
      properties:
        catalog: {type: array, items: {$ref: '#/components/schemas/PluginCatalogEntry'}}
        settings: {$ref: '#/components/schemas/PluginSettings'}
        status:
          type: object
          properties:
            runtime: {type: string, enum: [stopped, running, failed, unavailable]}
            packages: {type: array, items: {$ref: '#/components/schemas/PluginPackageInfo'}}
            instances:
              type: array
              items:
                type: object
                properties:
                  id: {type: string}
                  package: {type: string}
                  state: {type: string, enum: [ready, pending, loading, stopping, disposed, failed, disabled, unavailable]}
                  error: {type: string}
            error: {type: string}
    ScheduleEntry:
      type: object
      required: [record, status, scheduledAtLocal]
      properties:
        record:
          type: object
          required: [id, title, prompt, kind, scheduledAt]
          properties:
            id: {type: string}
            title: {type: string}
            prompt: {type: string}
            kind: {type: string, enum: [after, at, every, daily, weekly, cron, rrule]}
            scheduledAt: {type: string, format: date-time}
            afterSeconds: {type: integer}
            everySeconds: {type: integer}
            time: {type: string}
            timeZone: {type: string}
            weekdays: {type: array, items: {type: integer, minimum: 1, maximum: 7}}
            expression: {type: string}
            rrule: {type: string}
        status: {type: string, enum: [active, paused, ended]}
        sessionId: {type: string, description: Existing destination session}
        target: {$ref: "#/components/schemas/ScheduleTarget"}
        involvedSessionIds: {type: array, items: {type: string}}
        createdAt: {type: string, format: date-time}
        updatedAt: {type: string, format: date-time}
        scheduledAtLocal: {type: string, format: date-time}
        executionActive: {type: boolean}
        deliveryFloorEndsAt: {type: string, format: date-time}
        lastDelivery:
          type: object
          required: [scheduledAt, deliveredAt, messageId]
          properties:
            scheduledAt: {type: string, format: date-time}
            deliveredAt: {type: string, format: date-time}
            messageId: {type: string}
            targetSessionId: {type: string}
    ScheduleTarget:
      type: object
      required: [kind]
      properties:
        kind: {type: string, enum: [session, new_once, new]}
        sessionId: {type: string, description: Existing destination or a server-reserved new-once session ID in responses}
        create:
          type: object
          properties:
            cwd: {type: string}
            agentPreset: {type: string}
    ScheduleTiming:
      type: object
      required: [kind]
      description: Supply the one property matching kind. After and every use seconds.
      properties:
        kind: {type: string, enum: [after, at, every, daily, weekly, cron, rrule]}
        after_seconds: {type: integer, minimum: 1}
        every_seconds: {type: integer, minimum: 60}
        at:
          oneOf:
          - {type: string, format: date-time}
          - type: object
            required: [date, time, time_zone]
            properties:
              date: {type: string, format: date}
              time: {type: string}
              time_zone: {type: string}
        daily:
          type: object
          required: [time, time_zone]
          properties:
            time: {type: string}
            time_zone: {type: string}
        weekly:
          type: object
          required: [time, time_zone, weekdays]
          properties:
            time: {type: string}
            time_zone: {type: string}
            weekdays: {type: array, items: {type: integer, minimum: 1, maximum: 7}}
        cron:
          type: object
          required: [expression, time_zone]
          properties:
            expression: {type: string}
            time_zone: {type: string}
        rrule: {type: string}
    ToolProviderSettings:
      type: object
      required: [defaultProvider, provider, providers, entries, hasApiKey]
      properties:
        defaultProvider: {type: string}
        provider: {type: string}
        providers:
          type: array
          items:
            type: object
            required: [id, name]
            properties:
              id: {type: string}
              name: {type: string}
              defaultModel: {type: string}
        entries:
          type: object
          additionalProperties:
            type: object
            required: [hasApiKey]
            properties:
              hasApiKey: {type: boolean}
              model: {type: string}
        hasApiKey: {type: boolean}
    ModelEndpointInput:
      type: object
      properties:
        protocol:
          type: string
          enum: [responses, anthropic_messages]
          default: responses
          description: Endpoint API format; independent of the model name.
        name: {type: string}
        baseUrl: {type: string, format: uri}
        apiKey: {type: string, writeOnly: true}
        models:
          type: array
          minItems: 1
          uniqueItems: true
          description: Ordered model IDs. The first model is the endpoint default.
          items: {type: string}