{
  "components": {
    "responses": {
      "Error": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "错误"
      },
      "OAuthError": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/OAuthError"
            }
          }
        },
        "description": "OAuth 协议错误（RFC 6749 第 5.2 节 / RFC 7591 第 3.2.2 节），不使用 Cloud Error 信封"
      }
    },
    "schemas": {
      "AuthorizationServerMetadata": {
        "additionalProperties": false,
        "description": "RFC 8414 Authorization Server Metadata；issuer 是 Cloud public URL",
        "properties": {
          "authorization_endpoint": {
            "type": "string"
          },
          "code_challenge_methods_supported": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "device_authorization_endpoint": {
            "type": "string"
          },
          "grant_types_supported": {
            "items": {
              "enum": [
                "authorization_code",
                "refresh_token",
                "urn:ietf:params:oauth:grant-type:device_code"
              ],
              "type": "string"
            },
            "type": "array"
          },
          "issuer": {
            "type": "string"
          },
          "registration_endpoint": {
            "type": "string"
          },
          "resource_indicators_supported": {
            "type": "boolean"
          },
          "response_types_supported": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "revocation_endpoint": {
            "type": "string"
          },
          "revocation_endpoint_auth_methods_supported": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "scopes_supported": {
            "items": {
              "enum": [
                "mcp",
                "integrations"
              ],
              "type": "string"
            },
            "type": "array"
          },
          "token_endpoint": {
            "type": "string"
          },
          "token_endpoint_auth_methods_supported": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "issuer",
          "authorization_endpoint",
          "token_endpoint",
          "registration_endpoint",
          "revocation_endpoint",
          "device_authorization_endpoint",
          "response_types_supported",
          "grant_types_supported",
          "code_challenge_methods_supported",
          "token_endpoint_auth_methods_supported",
          "revocation_endpoint_auth_methods_supported",
          "scopes_supported",
          "resource_indicators_supported"
        ],
        "type": "object"
      },
      "ClientRegistration": {
        "additionalProperties": false,
        "properties": {
          "client_id": {
            "type": "string"
          },
          "client_id_issued_at": {
            "type": "integer"
          },
          "client_name": {
            "type": "string"
          },
          "grant_types": {
            "items": {
              "enum": [
                "authorization_code",
                "refresh_token",
                "urn:ietf:params:oauth:grant-type:device_code"
              ],
              "type": "string"
            },
            "type": "array"
          },
          "redirect_uris": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "response_types": {
            "items": {
              "enum": [
                "code"
              ],
              "type": "string"
            },
            "type": "array"
          },
          "token_endpoint_auth_method": {
            "enum": [
              "none"
            ],
            "type": "string"
          }
        },
        "required": [
          "client_id",
          "client_id_issued_at",
          "client_name",
          "redirect_uris",
          "grant_types",
          "response_types",
          "token_endpoint_auth_method"
        ],
        "type": "object"
      },
      "ClientRegistrationRequest": {
        "description": "RFC 7591 公开客户端注册。authorization_code 客户端必须提供 redirect_uris；device_code-only 客户端可以没有回调地址。",
        "properties": {
          "client_name": {
            "maxLength": 120,
            "type": "string"
          },
          "grant_types": {
            "items": {
              "enum": [
                "authorization_code",
                "refresh_token",
                "urn:ietf:params:oauth:grant-type:device_code"
              ],
              "type": "string"
            },
            "type": "array"
          },
          "redirect_uris": {
            "description": "https、loopback http，或已知桌面客户端固定回调",
            "items": {
              "type": "string"
            },
            "maxItems": 16,
            "minItems": 0,
            "type": "array"
          },
          "response_types": {
            "items": {
              "enum": [
                "code"
              ],
              "type": "string"
            },
            "type": "array"
          },
          "token_endpoint_auth_method": {
            "enum": [
              "none"
            ],
            "type": "string"
          }
        },
        "required": [],
        "type": "object"
      },
      "CreateIntegrationExecutionRequest": {
        "additionalProperties": false,
        "properties": {
          "capability_id": {
            "type": "string"
          },
          "contract_hash": {
            "type": "string"
          },
          "input": {
            "additionalProperties": true,
            "type": "object"
          },
          "timeout_ms": {
            "maximum": 1800000,
            "minimum": 1000,
            "type": "integer"
          }
        },
        "required": [
          "capability_id",
          "contract_hash",
          "input"
        ],
        "type": "object"
      },
      "DeviceAuthorizationRequest": {
        "additionalProperties": false,
        "properties": {
          "client_id": {
            "type": "string"
          },
          "resource": {
            "description": "省略时默认为 {public_url}/v1/integrations；提供时必须与其等价。",
            "type": "string"
          },
          "scope": {
            "enum": [
              "integrations"
            ],
            "type": "string"
          }
        },
        "required": [
          "client_id"
        ],
        "type": "object"
      },
      "DeviceAuthorizationResponse": {
        "additionalProperties": false,
        "properties": {
          "device_code": {
            "description": "只交给客户端保存的高熵秘密；不得展示给用户。",
            "type": "string"
          },
          "expires_in": {
            "minimum": 1,
            "type": "integer"
          },
          "interval": {
            "minimum": 1,
            "type": "integer"
          },
          "user_code": {
            "pattern": "^[A-Z2-9]{4}-[A-Z2-9]{4}$",
            "type": "string"
          },
          "verification_uri": {
            "type": "string"
          },
          "verification_uri_complete": {
            "type": "string"
          }
        },
        "required": [
          "device_code",
          "user_code",
          "verification_uri",
          "verification_uri_complete",
          "expires_in",
          "interval"
        ],
        "type": "object"
      },
      "Error": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "additionalProperties": false,
            "properties": {
              "code": {
                "enum": [
                  "ADMIN_FORBIDDEN",
                  "ADMIN_QUERY_INVALID",
                  "ADMIN_USER_NOT_FOUND",
                  "AGENTDOCK_DIAGNOSTICS_UNSUPPORTED",
                  "AGENTDOCK_RESOURCE_LIBRARY_PACKAGE_INVALID",
                  "AGENTDOCK_RESOURCE_LIBRARY_UNSUPPORTED",
                  "AGENTDOCK_RUNTIME_BAD_RESPONSE",
                  "AGENTDOCK_RUNTIME_REQUEST_FAILED",
                  "AGENTDOCK_RUNTIME_UNAVAILABLE",
                  "ARTIFACT_DOWNLOAD_BUSY",
                  "ARTIFACT_LINK_EXPIRED",
                  "ARTIFACT_LINK_INVALID",
                  "ARTIFACT_NODE_RESPONSE_INVALID",
                  "ARTIFACT_PROXY_FAILED",
                  "ARTIFACT_TOO_LARGE",
                  "BILLING_CUSTOMER_MISSING",
                  "BILLING_INTERVAL_INVALID",
                  "BILLING_PREPAID_UNAVAILABLE",
                  "BILLING_PROVIDER_UNAVAILABLE",
                  "BILLING_PURCHASE_INVALID",
                  "BILLING_RENEWAL_TOO_EARLY",
                  "BILLING_SUBSCRIPTION_EXISTS",
                  "BILLING_UNAVAILABLE",
                  "CAPABILITY_NOT_FOUND",
                  "CAPACITY_EXHAUSTED",
                  "CSRF_TOKEN_INVALID",
                  "DEV_LOGIN_NOT_ALLOWED",
                  "DIRECTORY_UNAVAILABLE",
                  "DISK_SPACE_LOW",
                  "EMAIL_CODE_INVALID",
                  "EMAIL_UNAVAILABLE",
                  "INTERNAL_ERROR",
                  "INVALID_CAPABILITY_TYPE",
                  "INVALID_DEVICE_TOKEN",
                  "INVALID_EMAIL",
                  "INVALID_JSON",
                  "INVALID_MCP_ACTION",
                  "INVALID_MCP_AUTH_CALLBACK",
                  "INVALID_MCP_CREDENTIAL",
                  "INVALID_MCP_NAME",
                  "INVALID_NODE",
                  "INVALID_PLUGIN_NAME",
                  "INVALID_RUNTIME_QUERY",
                  "INVALID_SKILL_FILE",
                  "INVALID_SKILL_ID",
                  "INVALID_TASK_ID",
                  "INVALID_WORKFLOW_TEMPLATE",
                  "LIBRARY_BUSY",
                  "LIBRARY_CONFIRM_INVALID",
                  "LIBRARY_IDEMPOTENCY_CONFLICT",
                  "LIBRARY_INVALID_PACKAGE",
                  "LIBRARY_NOT_FOUND",
                  "LIBRARY_QUOTA",
                  "LIBRARY_REVIEW_REJECTED",
                  "LIBRARY_UNAVAILABLE",
                  "MARKET_CHANGED",
                  "MARKET_CONFLICT",
                  "MARKET_INVALID",
                  "MARKET_NOT_FOUND",
                  "MARKET_UNAVAILABLE",
                  "MCP_APPS_ENABLED_REQUIRED",
                  "MCP_SETTINGS_READ_FAILED",
                  "MCP_SETTINGS_UPDATE_FAILED",
                  "NODE_ENABLED_LIMIT",
                  "NODE_EXISTS",
                  "NODE_NOT_FOUND",
                  "NODE_QUOTA_EXCEEDED",
                  "NODE_REQUEST_FAILED",
                  "NODE_UNAVAILABLE",
                  "NODE_UNREACHABLE",
                  "NOT_READY",
                  "OAUTH_GRANT_NOT_FOUND",
                  "OAUTH_DEVICE_CODE_INVALID",
                  "OAUTH_REQUEST_INVALID",
                  "PAIRING_CODE_INVALID",
                  "PLUS_TRIAL_NOT_ELIGIBLE",
                  "RATE_LIMITED",
                  "RECALL_CONFIRMATION_REQUIRED",
                  "RECALL_CONTENT_INVALID",
                  "RECALL_FILE_EXISTS",
                  "RECALL_NOT_FOUND",
                  "RECALL_PATH_INVALID",
                  "RECALL_QUERY_INVALID",
                  "RECALL_QUOTA_EXCEEDED",
                  "RECALL_SEMANTIC_PLUS_REQUIRED",
                  "RECALL_SEMANTIC_UNAVAILABLE",
                  "RECALL_UNAVAILABLE",
                  "REDEEM_CODE_INVALID",
                  "REFERRAL_ALREADY_BOUND",
                  "REFERRAL_BIND_EXPIRED",
                  "REFERRAL_CODE_INVALID",
                  "REFERRAL_SELF_INVITE",
                  "REQUEST_TOO_LARGE",
                  "STRIPE_WEBHOOK_INVALID",
                  "UNAUTHENTICATED",
                  "UNSUPPORTED_MEDIA_TYPE",
                  "WORKFLOW_QUOTA_EXCEEDED",
                  "WORKFLOW_SUBSCRIPTION_REQUIRED",
                  "WORKFLOW_TEMPLATE_NOT_ACTIVE",
                  "WORKFLOW_TEMPLATE_NOT_FOUND",
                  "WORKFLOW_UNAVAILABLE",
                  "WORKFLOW_VERSION_IMMUTABLE",
                  "WORKSPACE_BUSY",
                  "WORKSPACE_LIMIT_REACHED",
                  "WORKSPACE_NOT_ACTIVE",
                  "WORKSPACE_NOT_FOUND",
                  "WORKSPACE_PROVISIONING_FAILED",
                  "WORKSPACE_UNAVAILABLE",
                  "CAPABILITY_SCHEMA_CHANGED",
                  "EXECUTION_ARGUMENTS_INVALID",
                  "EXECUTION_LIMIT_REACHED",
                  "EXECUTION_NOT_FOUND",
                  "EXECUTION_RATE_LIMITED",
                  "EXECUTION_UNAVAILABLE",
                  "IDEMPOTENCY_KEY_REQUIRED",
                  "IDEMPOTENCY_KEY_REUSED",
                  "INVALID_EXECUTION_QUERY",
                  "INVALID_EXECUTION_REQUEST",
                  "INVALID_EXECUTION_STATUS",
                  "INVALID_LAST_EVENT_ID",
                  "NODE_OFFLINE"
                ],
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          },
          "request_id": {
            "description": "与响应头 X-Request-Id 相同，用于报障定位。",
            "type": "string"
          }
        },
        "required": [
          "error",
          "request_id"
        ],
        "type": "object"
      },
      "IntegrationCapability": {
        "additionalProperties": false,
        "properties": {
          "contract_hash": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "input_schema": {
            "additionalProperties": true,
            "type": "object"
          },
          "name": {
            "type": "string"
          },
          "node_id": {
            "type": "string"
          },
          "observed_at": {
            "format": "date-time",
            "type": "string"
          },
          "online": {
            "type": "boolean"
          },
          "output_schema": {
            "additionalProperties": true,
            "type": "object"
          },
          "reference": {
            "type": "string"
          },
          "source_type": {
            "type": "string"
          },
          "stale": {
            "type": "boolean"
          },
          "status": {
            "type": "string"
          },
          "type": {
            "enum": [
              "tool",
              "skill",
              "mcp",
              "plugin"
            ],
            "type": "string"
          }
        },
        "required": [
          "id",
          "node_id",
          "type",
          "name",
          "online",
          "observed_at",
          "stale"
        ],
        "type": "object"
      },
      "IntegrationCapabilityList": {
        "additionalProperties": false,
        "properties": {
          "count": {
            "type": "integer"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/IntegrationCapability"
            },
            "type": "array"
          }
        },
        "required": [
          "items",
          "count"
        ],
        "type": "object"
      },
      "IntegrationCapabilityResponse": {
        "additionalProperties": false,
        "properties": {
          "capability": {
            "$ref": "#/components/schemas/IntegrationCapability"
          }
        },
        "required": [
          "capability"
        ],
        "type": "object"
      },
      "IntegrationDevice": {
        "additionalProperties": false,
        "properties": {
          "agent_version": {
            "type": "string"
          },
          "arch": {
            "type": "string"
          },
          "description": {
            "description": "设备用途描述，未填写时为空字符串",
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "online": {
            "type": "boolean"
          },
          "os": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "description",
          "online",
          "os",
          "arch",
          "agent_version"
        ],
        "type": "object"
      },
      "IntegrationDeviceList": {
        "additionalProperties": false,
        "properties": {
          "devices": {
            "items": {
              "$ref": "#/components/schemas/IntegrationDevice"
            },
            "type": "array"
          }
        },
        "required": [
          "devices"
        ],
        "type": "object"
      },
      "IntegrationExecution": {
        "additionalProperties": false,
        "properties": {
          "cancel_requested_at": {
            "format": "date-time",
            "type": "string"
          },
          "capability_id": {
            "type": "string"
          },
          "contract_hash": {
            "type": "string"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "finished_at": {
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "pattern": "^exec_[0-9a-f]{32}$",
            "type": "string"
          },
          "node_id": {
            "type": "string"
          },
          "started_at": {
            "format": "date-time",
            "type": "string"
          },
          "status": {
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed",
              "cancelled",
              "unknown"
            ],
            "type": "string"
          },
          "timeout_ms": {
            "maximum": 1800000,
            "minimum": 1000,
            "type": "integer"
          },
          "tool_name": {
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          },
          "version": {
            "minimum": 1,
            "type": "integer"
          }
        },
        "required": [
          "id",
          "status",
          "node_id",
          "capability_id",
          "tool_name",
          "contract_hash",
          "timeout_ms",
          "version",
          "created_at",
          "updated_at"
        ],
        "type": "object"
      },
      "IntegrationExecutionDetail": {
        "additionalProperties": false,
        "properties": {
          "cancel_requested_at": {
            "format": "date-time",
            "type": "string"
          },
          "capability_id": {
            "type": "string"
          },
          "contract_hash": {
            "type": "string"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "error": {
            "$ref": "#/components/schemas/IntegrationExecutionError"
          },
          "finished_at": {
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "pattern": "^exec_[0-9a-f]{32}$",
            "type": "string"
          },
          "node_id": {
            "type": "string"
          },
          "result": {
            "additionalProperties": true,
            "type": "object"
          },
          "started_at": {
            "format": "date-time",
            "type": "string"
          },
          "status": {
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed",
              "cancelled",
              "unknown"
            ],
            "type": "string"
          },
          "timeout_ms": {
            "maximum": 1800000,
            "minimum": 1000,
            "type": "integer"
          },
          "tool_name": {
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          },
          "version": {
            "minimum": 1,
            "type": "integer"
          }
        },
        "required": [
          "id",
          "status",
          "node_id",
          "capability_id",
          "tool_name",
          "contract_hash",
          "timeout_ms",
          "version",
          "created_at",
          "updated_at"
        ],
        "type": "object"
      },
      "IntegrationExecutionError": {
        "additionalProperties": false,
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      },
      "IntegrationExecutionList": {
        "additionalProperties": false,
        "properties": {
          "before": {
            "type": "string"
          },
          "count": {
            "minimum": 0,
            "type": "integer"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/IntegrationExecution"
            },
            "type": "array"
          }
        },
        "required": [
          "items",
          "count"
        ],
        "type": "object"
      },
      "IntegrationExecutionResponse": {
        "additionalProperties": false,
        "properties": {
          "execution": {
            "$ref": "#/components/schemas/IntegrationExecutionDetail"
          }
        },
        "required": [
          "execution"
        ],
        "type": "object"
      },
      "OAuthError": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "enum": [
              "invalid_request",
              "invalid_client",
              "invalid_grant",
              "unauthorized_client",
              "unsupported_grant_type",
              "invalid_target",
              "invalid_client_metadata",
              "invalid_redirect_uri",
              "temporarily_unavailable",
              "server_error",
              "invalid_scope",
              "authorization_pending",
              "slow_down",
              "access_denied",
              "expired_token"
            ],
            "type": "string"
          },
          "error_description": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "error_description"
        ],
        "type": "object"
      },
      "OAuthToken": {
        "additionalProperties": false,
        "properties": {
          "access_token": {
            "description": "ndoa_ 前缀，1 小时",
            "type": "string"
          },
          "expires_in": {
            "type": "integer"
          },
          "refresh_token": {
            "description": "ndor_ 前缀；每次刷新轮换。只有注册了 refresh_token grant 的客户端返回。",
            "type": "string"
          },
          "scope": {
            "enum": [
              "mcp",
              "integrations"
            ],
            "type": "string"
          },
          "sub": {
            "description": "经过 membership 校验的 NexusDock user_id；refresh 后保持不变。",
            "type": "string"
          },
          "token_type": {
            "enum": [
              "Bearer"
            ],
            "type": "string"
          }
        },
        "required": [
          "sub",
          "access_token",
          "token_type",
          "expires_in",
          "scope"
        ],
        "type": "object"
      },
      "ProtectedResourceMetadata": {
        "additionalProperties": false,
        "description": "RFC 9728 Protected Resource Metadata；resource/scopes_supported 由具体受保护资源决定。",
        "properties": {
          "authorization_servers": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "bearer_methods_supported": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "resource": {
            "type": "string"
          },
          "scopes_supported": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "resource",
          "authorization_servers",
          "bearer_methods_supported",
          "scopes_supported"
        ],
        "type": "object"
      },
      "RevokeRequest": {
        "properties": {
          "client_id": {
            "type": "string"
          },
          "token": {
            "type": "string"
          },
          "token_type_hint": {
            "type": "string"
          }
        },
        "required": [
          "client_id",
          "token"
        ],
        "type": "object"
      },
      "TokenRequest": {
        "description": "authorization_code 需要 code、redirect_uri、code_verifier；refresh_token 需要 refresh_token；Device Grant 需要 device_code。resource 可省略；提供时必须是已支持的 NexusDock Integration resource。",
        "properties": {
          "client_id": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "code_verifier": {
            "type": "string"
          },
          "device_code": {
            "type": "string"
          },
          "grant_type": {
            "enum": [
              "authorization_code",
              "refresh_token",
              "urn:ietf:params:oauth:grant-type:device_code"
            ],
            "type": "string"
          },
          "redirect_uri": {
            "type": "string"
          },
          "refresh_token": {
            "type": "string"
          },
          "resource": {
            "type": "string"
          },
          "scope": {
            "enum": [
              "mcp",
              "integrations"
            ],
            "type": "string"
          }
        },
        "required": [
          "grant_type",
          "client_id"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "mcpToken": {
        "description": "Workspace Integration PAT（ndc_ 前缀）或 Integration OAuth access token（ndoa_ 前缀）。PAT 可访问 /mcp 与 /v1/integrations；OAuth token 必须与当前 resource/scope 匹配。",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "description": "Public third-party REST contract for NexusDock Cloud Integrations. Covers OAuth 2.0 Device Authorization Grant / PAT authentication, online device and live Tool schema discovery with contract_hash, idempotent durable executions, SSE/polling observation, cancellation, and signed artifact downloads.",
    "title": "NexusDock Integrations API",
    "version": "0.1.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/.well-known/oauth-authorization-server": {
      "get": {
        "operationId": "getAuthorizationServerMetadata",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthorizationServerMetadata"
                }
              }
            },
            "description": "元数据"
          }
        },
        "summary": "Authorization Server Metadata（RFC 8414）",
        "tags": [
          "Authentication"
        ],
        "x-identity": "public"
      }
    },
    "/.well-known/oauth-protected-resource/v1/integrations": {
      "get": {
        "operationId": "getIntegrationsProtectedResourceMetadata",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProtectedResourceMetadata"
                }
              }
            },
            "description": "元数据"
          }
        },
        "summary": "REST Integration Protected Resource Metadata（RFC 9728）",
        "tags": [
          "Authentication"
        ],
        "x-identity": "public"
      }
    },
    "/artifacts/public/{node_id}/{artifact_id}/{filename}": {
      "get": {
        "operationId": "downloadNodeArtifact",
        "parameters": [
          {
            "description": "产出该 artifact 的节点 ID，被签名覆盖",
            "in": "path",
            "name": "node_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "节点本地的 artifact ID，被签名覆盖",
            "in": "path",
            "name": "artifact_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "文件名，被签名覆盖",
            "in": "path",
            "name": "filename",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "过期时间（Unix 秒），被签名覆盖",
            "in": "query",
            "name": "expires",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "文件内容的小写十六进制 SHA-256，被签名覆盖",
            "in": "query",
            "name": "sha256",
            "required": true,
            "schema": {
              "pattern": "^[0-9a-f]{64}$",
              "type": "string"
            }
          },
          {
            "description": "HMAC-SHA256 签名（十六进制），覆盖 node_id、artifact_id、filename、sha256、expires",
            "in": "query",
            "name": "sig",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "条件缓存校验头；仅在签名、有效期与节点在线检查全部通过后与强 ETag `\"\u003csha256\u003e\"` 做弱比较匹配",
            "in": "header",
            "name": "If-None-Match",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "*/*": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "文件正文：不超过 2 MiB 的不可变小文件经 singleflight 合并回源并在整包 SHA-256 校验通过后可命中服务端有界内存缓存；超过 2 MiB 的大文件按 512 KiB 分块流式读取，长度或 SHA-256 与签名不符时中断连接且不放出最后一块",
            "headers": {
              "Cache-Control": {
                "description": "受链接剩余有效期约束的私有不可变缓存：`private, max-age=\u003cmin(expires-now, 86400)\u003e, immutable`（不足 1 秒时退回 `private, no-store`）",
                "schema": {
                  "type": "string"
                }
              },
              "Content-Disposition": {
                "description": "attachment; filename=...",
                "schema": {
                  "type": "string"
                }
              },
              "Content-Length": {
                "schema": {
                  "type": "integer"
                }
              },
              "Content-Security-Policy": {
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "description": "基于签名 SHA-256 的强实体标签 `\"\u003csha256\u003e\"`",
                "schema": {
                  "type": "string"
                }
              },
              "X-Content-Type-Options": {
                "schema": {
                  "enum": [
                    "nosniff"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "304": {
            "description": "Not Modified：签名、有效期与节点状态校验通过且 If-None-Match 匹配强 ETag `\"\u003csha256\u003e\"`，不返回正文",
            "headers": {
              "Cache-Control": {
                "description": "受链接剩余有效期约束的私有不可变缓存：`private, max-age=\u003cmin(expires-now, 86400)\u003e, immutable`（不足 1 秒时退回 `private, no-store`）",
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "description": "基于签名 SHA-256 的强实体标签 `\"\u003csha256\u003e\"`",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "ARTIFACT_LINK_INVALID：链接形状非法或签名不符（包括替换路径中的 node_id）；NODE_UNAVAILABLE：节点不存在、已移除、已禁用、离线或 Workspace 不是 active"
          },
          "410": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "ARTIFACT_LINK_EXPIRED：签名有效但已过期"
          },
          "413": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "ARTIFACT_TOO_LARGE：文件超过 512 MiB 代理上限"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "ARTIFACT_DOWNLOAD_BUSY：该节点并发下载已达上限（8 个）且短排队超时或队列已满；Retry-After 给出等待秒数",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "INTERNAL_ERROR"
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "ARTIFACT_NODE_RESPONSE_INVALID：节点返回的元数据与签名不符；ARTIFACT_PROXY_FAILED：节点读取失败"
          },
          "504": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "ARTIFACT_PROXY_FAILED：等待节点分块超时"
          }
        },
        "summary": "节点 artifact 的签名下载链接（架构第 6.6 节）：签名先于任何查询校验，只经由该节点的连接读取该节点的文件，不访问 Workspace 数据；携带的 Cookie、Authorization 不参与授权；签名参数与正文不进入日志",
        "tags": [
          "Artifacts"
        ],
        "x-identity": "public"
      },
      "head": {
        "operationId": "headNodeArtifact",
        "parameters": [
          {
            "description": "产出该 artifact 的节点 ID，被签名覆盖",
            "in": "path",
            "name": "node_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "节点本地的 artifact ID，被签名覆盖",
            "in": "path",
            "name": "artifact_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "文件名，被签名覆盖",
            "in": "path",
            "name": "filename",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "过期时间（Unix 秒），被签名覆盖",
            "in": "query",
            "name": "expires",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "文件内容的小写十六进制 SHA-256，被签名覆盖",
            "in": "query",
            "name": "sha256",
            "required": true,
            "schema": {
              "pattern": "^[0-9a-f]{64}$",
              "type": "string"
            }
          },
          {
            "description": "HMAC-SHA256 签名（十六进制），覆盖 node_id、artifact_id、filename、sha256、expires",
            "in": "query",
            "name": "sig",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "条件缓存校验头；仅在签名、有效期与节点在线检查全部通过后与强 ETag `\"\u003csha256\u003e\"` 做弱比较匹配",
            "in": "header",
            "name": "If-None-Match",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "文件元数据，不向节点请求正文",
            "headers": {
              "Cache-Control": {
                "description": "受链接剩余有效期约束的私有不可变缓存：`private, max-age=\u003cmin(expires-now, 86400)\u003e, immutable`（不足 1 秒时退回 `private, no-store`）",
                "schema": {
                  "type": "string"
                }
              },
              "Content-Disposition": {
                "description": "attachment; filename=...",
                "schema": {
                  "type": "string"
                }
              },
              "Content-Length": {
                "schema": {
                  "type": "integer"
                }
              },
              "Content-Security-Policy": {
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "description": "基于签名 SHA-256 的强实体标签 `\"\u003csha256\u003e\"`",
                "schema": {
                  "type": "string"
                }
              },
              "X-Content-Type-Options": {
                "schema": {
                  "enum": [
                    "nosniff"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "304": {
            "description": "Not Modified：签名、有效期与节点状态校验通过且 If-None-Match 匹配强 ETag `\"\u003csha256\u003e\"`（HEAD 不返回正文）",
            "headers": {
              "Cache-Control": {
                "description": "受链接剩余有效期约束的私有不可变缓存：`private, max-age=\u003cmin(expires-now, 86400)\u003e, immutable`（不足 1 秒时退回 `private, no-store`）",
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "description": "基于签名 SHA-256 的强实体标签 `\"\u003csha256\u003e\"`",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "ARTIFACT_LINK_INVALID：链接形状非法或签名不符（包括替换路径中的 node_id）；NODE_UNAVAILABLE：节点不存在、已移除、已禁用、离线或 Workspace 不是 active（HEAD 不返回正文）"
          },
          "410": {
            "description": "ARTIFACT_LINK_EXPIRED：签名有效但已过期（HEAD 不返回正文）"
          },
          "413": {
            "description": "ARTIFACT_TOO_LARGE：文件超过 512 MiB 代理上限（HEAD 不返回正文）"
          },
          "500": {
            "description": "INTERNAL_ERROR（HEAD 不返回正文）"
          },
          "502": {
            "description": "ARTIFACT_NODE_RESPONSE_INVALID：节点返回的元数据与签名不符；ARTIFACT_PROXY_FAILED：节点读取失败（HEAD 不返回正文）"
          },
          "504": {
            "description": "ARTIFACT_PROXY_FAILED：等待节点分块超时（HEAD 不返回正文）"
          }
        },
        "summary": "与 GET 相同的校验，只返回文件元数据",
        "tags": [
          "Artifacts"
        ],
        "x-identity": "public"
      }
    },
    "/oauth/device_authorization": {
      "post": {
        "operationId": "startOAuthDeviceAuthorization",
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/DeviceAuthorizationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceAuthorizationResponse"
                }
              }
            },
            "description": "待用户确认的 device authorization"
          },
          "400": {
            "$ref": "#/components/responses/OAuthError"
          },
          "401": {
            "$ref": "#/components/responses/OAuthError"
          },
          "429": {
            "$ref": "#/components/responses/OAuthError"
          },
          "500": {
            "$ref": "#/components/responses/OAuthError"
          }
        },
        "summary": "启动 OAuth 2.0 Device Authorization Grant（RFC 8628）",
        "tags": [
          "Authentication"
        ],
        "x-identity": "public"
      }
    },
    "/oauth/register": {
      "post": {
        "operationId": "registerOAuthClient",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientRegistrationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientRegistration"
                }
              }
            },
            "description": "已注册"
          },
          "400": {
            "$ref": "#/components/responses/OAuthError"
          },
          "429": {
            "$ref": "#/components/responses/OAuthError"
          },
          "500": {
            "$ref": "#/components/responses/OAuthError"
          },
          "503": {
            "$ref": "#/components/responses/OAuthError"
          }
        },
        "summary": "RFC 7591 动态注册公开客户端；按客户端 IP 限流",
        "tags": [
          "Authentication"
        ],
        "x-identity": "public"
      }
    },
    "/oauth/revoke": {
      "post": {
        "operationId": "revokeOAuthToken",
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/RevokeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "已处理"
          },
          "400": {
            "$ref": "#/components/responses/OAuthError"
          },
          "401": {
            "$ref": "#/components/responses/OAuthError"
          },
          "500": {
            "$ref": "#/components/responses/OAuthError"
          }
        },
        "summary": "RFC 7009 撤销 token 所属 grant；token 无效时同样返回 200",
        "tags": [
          "Authentication"
        ],
        "x-identity": "public"
      }
    },
    "/oauth/token": {
      "post": {
        "operationId": "issueOAuthToken",
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TokenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthToken"
                }
              }
            },
            "description": "token"
          },
          "400": {
            "$ref": "#/components/responses/OAuthError"
          },
          "401": {
            "$ref": "#/components/responses/OAuthError"
          },
          "500": {
            "$ref": "#/components/responses/OAuthError"
          }
        },
        "summary": "authorization_code（必须带 PKCE verifier）或 refresh_token（轮换）；不接受 Session 或客户端密钥",
        "tags": [
          "Authentication"
        ],
        "x-identity": "public"
      }
    },
    "/v1/integrations/capabilities": {
      "get": {
        "operationId": "listIntegrationCapabilities",
        "parameters": [
          {
            "in": "query",
            "name": "node_id",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "type",
            "schema": {
              "enum": [
                "tool",
                "skill",
                "mcp",
                "plugin"
              ],
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "q",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationCapabilityList"
                }
              }
            },
            "description": "能力元数据快照"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        },
        "security": [
          {
            "mcpToken": []
          }
        ],
        "summary": "跨设备搜索已缓存的 Tool、Skill、MCP 与 Plugin 目录",
        "tags": [
          "Discovery"
        ],
        "x-identity": "integration"
      }
    },
    "/v1/integrations/capabilities/{id}": {
      "get": {
        "operationId": "getIntegrationCapability",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationCapabilityResponse"
                }
              }
            },
            "description": "能力元数据"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        },
        "security": [
          {
            "mcpToken": []
          }
        ],
        "summary": "获取当前授权 Workspace 内指定缓存能力详情",
        "tags": [
          "Discovery"
        ],
        "x-identity": "integration"
      }
    },
    "/v1/integrations/devices": {
      "get": {
        "operationId": "listIntegrationDevices",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationDeviceList"
                }
              }
            },
            "description": "设备元数据"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        },
        "security": [
          {
            "mcpToken": []
          }
        ],
        "summary": "第三方读取当前授权 Workspace 的已启用设备目录",
        "tags": [
          "Discovery"
        ],
        "x-identity": "integration"
      }
    },
    "/v1/integrations/executions": {
      "get": {
        "operationId": "listIntegrationExecutions",
        "parameters": [
          {
            "in": "query",
            "name": "status",
            "schema": {
              "enum": [
                "queued",
                "running",
                "succeeded",
                "failed",
                "cancelled",
                "unknown"
              ],
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "before",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationExecutionList"
                }
              }
            },
            "description": "Execution summaries"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        },
        "security": [
          {
            "mcpToken": []
          }
        ],
        "summary": "List recent durable executions in the authorized Workspace",
        "tags": [
          "Executions"
        ],
        "x-identity": "integration"
      },
      "post": {
        "operationId": "createIntegrationExecution",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "maxLength": 200,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateIntegrationExecutionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationExecutionResponse"
                }
              }
            },
            "description": "Idempotent replay of an existing Execution",
            "headers": {
              "Idempotency-Replayed": {
                "schema": {
                  "enum": [
                    "true"
                  ],
                  "type": "string"
                }
              }
            }
          },
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationExecutionResponse"
                }
              }
            },
            "description": "Execution queued",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "413": {
            "$ref": "#/components/responses/Error"
          },
          "415": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Execution creation is rate or active-capacity limited",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        },
        "security": [
          {
            "mcpToken": []
          }
        ],
        "summary": "Create a durable execution for one current AgentDock tool capability",
        "tags": [
          "Executions"
        ],
        "x-identity": "integration"
      }
    },
    "/v1/integrations/executions/{id}": {
      "get": {
        "operationId": "getIntegrationExecution",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "pattern": "^exec_[0-9a-f]{32}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationExecutionResponse"
                }
              }
            },
            "description": "Execution detail"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        },
        "security": [
          {
            "mcpToken": []
          }
        ],
        "summary": "Get one durable execution and its terminal result",
        "tags": [
          "Executions"
        ],
        "x-identity": "integration"
      }
    },
    "/v1/integrations/executions/{id}/cancel": {
      "post": {
        "operationId": "cancelIntegrationExecution",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "pattern": "^exec_[0-9a-f]{32}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationExecutionResponse"
                }
              }
            },
            "description": "Execution already terminal or queued cancellation completed"
          },
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationExecutionResponse"
                }
              }
            },
            "description": "Cancellation sent to a running execution"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        },
        "security": [
          {
            "mcpToken": []
          }
        ],
        "summary": "Request cancellation of a queued or running execution",
        "tags": [
          "Executions"
        ],
        "x-identity": "integration"
      }
    },
    "/v1/integrations/executions/{id}/events": {
      "get": {
        "operationId": "watchIntegrationExecution",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "pattern": "^exec_[0-9a-f]{32}$",
              "type": "string"
            }
          },
          {
            "in": "header",
            "name": "Last-Event-ID",
            "schema": {
              "pattern": "^[0-9]+$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Execution status event stream"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        },
        "security": [
          {
            "mcpToken": []
          }
        ],
        "summary": "Watch execution status changes over SSE",
        "tags": [
          "Executions"
        ],
        "x-identity": "integration"
      }
    }
  },
  "servers": [
    {
      "description": "NexusDock Cloud",
      "url": "https://mcp.nexusdock.co"
    }
  ],
  "tags": [
    {
      "description": "OAuth 2.0 metadata discovery and RFC 8628 Device Authorization Grant endpoints for third-party REST integrations.",
      "name": "Authentication"
    },
    {
      "description": "Discover online devices and inspect live Tool JSON Schemas with contract_hash before execution.",
      "name": "Discovery"
    },
    {
      "description": "Create idempotent durable Tool executions, observe state transitions via polling or SSE, and request best-effort cancellation.",
      "name": "Executions"
    },
    {
      "description": "Download signed public artifacts produced by AgentDock tools.",
      "name": "Artifacts"
    }
  ]
}
