{
  "openapi": "3.1.0",
  "info": {
    "title": "Baijimu Bundle Capability API",
    "version": "2.0.0",
    "description": "Hosted Service Capability 的权威方法目录。源文件随服务审查与发布；CLI 按 operationId 通用读取，不维护方法或 scope 枚举。目录描述接口合同，不授予调用权限。"
  },
  "servers": [
    {
      "url": "/",
      "description": "当前平台环境的公开 API 根地址。"
    }
  ],
  "security": [
    {
      "bundleCapabilityToken": []
    }
  ],
  "paths": {
    "/capability/bundle-runtime/bundle/resources/query": {
      "post": {
        "operationId": "queryBundleResources",
        "summary": "查询当前 Bundle 的已验证资源",
        "x-baijimu-scope": "bundle.resources.read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueryBundleResourcesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "检查 errorCode；HTTP 200 也可能是业务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "errorCode": {
                          "const": "0"
                        },
                        "data": {
                          "$ref": "#/components/schemas/BundleResources"
                        },
                        "contractVersion": {
                          "const": "1.0.0"
                        }
                      },
                      "required": [
                        "errorCode",
                        "data"
                      ],
                      "additionalProperties": true
                    },
                    {
                      "$ref": "#/components/schemas/CapabilityError"
                    }
                  ]
                },
                "examples": {}
              }
            }
          },
          "default": {
            "description": "认证、参数、资源状态或服务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapabilityError"
                }
              }
            }
          }
        },
        "x-baijimu-side-effect": "read",
        "x-baijimu-response-data-schema": {
          "$ref": "#/components/schemas/BundleResources"
        }
      }
    },
    "/capability/bundle-workflow/workflows/query": {
      "post": {
        "operationId": "queryBundleWorkflows",
        "summary": "查询当前 Bundle 的工作流",
        "x-baijimu-scope": "workflow.definition.read",
        "requestBody": {
          "$ref": "#/components/requestBodies/ApplicationRuntimeRequest"
        },
        "responses": {
          "200": {
            "description": "检查 errorCode；HTTP 200 也可能是业务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "errorCode": {
                          "const": "0"
                        },
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/WorkflowDefinition"
                          }
                        },
                        "contractVersion": {
                          "const": "1.0.0"
                        }
                      },
                      "required": [
                        "errorCode",
                        "data"
                      ],
                      "additionalProperties": true
                    },
                    {
                      "$ref": "#/components/schemas/CapabilityError"
                    }
                  ]
                },
                "examples": {
                  "success": {
                    "summary": "定义使用 code 字段",
                    "value": {
                      "errorCode": "0",
                      "data": [
                        {
                          "id": "workflow-example",
                          "workspaceId": "workspace-example",
                          "code": "exampleFlow",
                          "name": "示例流程",
                          "revision": 1,
                          "recompilationRequired": false,
                          "description": null,
                          "status": "active",
                          "startNodeId": "start",
                          "inputSchema": [],
                          "outputSchema": null,
                          "nodes": [],
                          "edges": [],
                          "graphLayout": null,
                          "tags": [],
                          "createdAt": "2026-01-01T00:00:00Z",
                          "updatedAt": "2026-01-01T00:00:00Z"
                        }
                      ],
                      "contractVersion": "1.0.0"
                    }
                  },
                  "failure": {
                    "summary": "错误示例，按 data.message 与 data.retryable 处理",
                    "value": {
                      "contractVersion": "1.0.0",
                      "errorCode": "WORKFLOW_ENGINE_INVALID_REQUEST",
                      "data": {
                        "message": "请求参数无效",
                        "retryable": false
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "认证、参数、资源状态或服务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapabilityError"
                }
              }
            }
          }
        },
        "x-baijimu-side-effect": "read",
        "description": "返回 WorkflowDefinition，编码字段为 code。旧消费端读取 definitionCode 会失败。resourceLocator 必须从 queryBundleResources 返回的资源账本取得；定义列表没有 Locator。",
        "x-baijimu-response-data-schema": {
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/WorkflowDefinition"
          }
        }
      }
    },
    "/capability/bundle-workflow/workflows/definition": {
      "post": {
        "operationId": "getBundleWorkflowDefinition",
        "summary": "读取工作流定义",
        "x-baijimu-scope": "workflow.definition.read",
        "requestBody": {
          "$ref": "#/components/requestBodies/ResourceRequest"
        },
        "responses": {
          "200": {
            "description": "检查 errorCode；HTTP 200 也可能是业务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "errorCode": {
                          "const": "0"
                        },
                        "data": {
                          "$ref": "#/components/schemas/WorkflowDefinition"
                        },
                        "contractVersion": {
                          "const": "1.0.0"
                        }
                      },
                      "required": [
                        "errorCode",
                        "data"
                      ],
                      "additionalProperties": true
                    },
                    {
                      "$ref": "#/components/schemas/CapabilityError"
                    }
                  ]
                },
                "examples": {
                  "success": {
                    "summary": "定义使用 code 字段",
                    "value": {
                      "errorCode": "0",
                      "data": {
                        "id": "workflow-example",
                        "workspaceId": "workspace-example",
                        "code": "exampleFlow",
                        "name": "示例流程",
                        "revision": 1,
                        "recompilationRequired": false,
                        "description": null,
                        "status": "active",
                        "startNodeId": "start",
                        "inputSchema": [],
                        "outputSchema": null,
                        "nodes": [],
                        "edges": [],
                        "graphLayout": null,
                        "tags": [],
                        "createdAt": "2026-01-01T00:00:00Z",
                        "updatedAt": "2026-01-01T00:00:00Z"
                      },
                      "contractVersion": "1.0.0"
                    }
                  },
                  "failure": {
                    "summary": "错误示例，按 data.message 与 data.retryable 处理",
                    "value": {
                      "contractVersion": "1.0.0",
                      "errorCode": "WORKFLOW_ENGINE_INVALID_REQUEST",
                      "data": {
                        "message": "请求参数无效",
                        "retryable": false
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "认证、参数、资源状态或服务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapabilityError"
                }
              }
            }
          }
        },
        "x-baijimu-side-effect": "read",
        "description": "返回 WorkflowDefinition，编码字段为 code。旧消费端读取 definitionCode 会失败。resourceLocator 必须从 queryBundleResources 返回的资源账本取得；定义列表没有 Locator。",
        "x-baijimu-response-data-schema": {
          "$ref": "#/components/schemas/WorkflowDefinition"
        }
      }
    },
    "/capability/bundle-workflow/workflows/instances/start": {
      "post": {
        "operationId": "startBundleWorkflowInstance",
        "summary": "启动工作流实例",
        "x-baijimu-scope": "workflow.execution.create",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartWorkflowRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "检查 errorCode；HTTP 200 也可能是业务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "errorCode": {
                          "const": "0"
                        },
                        "data": {
                          "$ref": "#/components/schemas/WorkflowInstance"
                        },
                        "contractVersion": {
                          "const": "1.0.0"
                        }
                      },
                      "required": [
                        "errorCode",
                        "data"
                      ],
                      "additionalProperties": true
                    },
                    {
                      "$ref": "#/components/schemas/CapabilityError"
                    }
                  ]
                },
                "examples": {
                  "failure": {
                    "summary": "错误示例，按 data.message 与 data.retryable 处理",
                    "value": {
                      "contractVersion": "1.0.0",
                      "errorCode": "WORKFLOW_ENGINE_INVALID_REQUEST",
                      "data": {
                        "message": "请求参数无效",
                        "retryable": false
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "认证、参数、资源状态或服务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapabilityError"
                }
              }
            }
          }
        },
        "x-baijimu-side-effect": "write",
        "description": "requestId 在请求顶层必填，用于启动幂等性；metadata.requestId 不能替代。执行权限仍由服务端独立校验。",
        "x-baijimu-response-data-schema": {
          "$ref": "#/components/schemas/WorkflowInstance"
        }
      }
    },
    "/capability/bundle-workflow/workflows/instances/query": {
      "post": {
        "operationId": "queryBundleWorkflowInstances",
        "summary": "查询工作流实例",
        "x-baijimu-scope": "workflow.execution.read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueryWorkflowInstancesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "检查 errorCode；HTTP 200 也可能是业务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "errorCode": {
                          "const": "0"
                        },
                        "data": {
                          "$ref": "#/components/schemas/WorkflowInstancePage"
                        },
                        "contractVersion": {
                          "const": "1.0.0"
                        }
                      },
                      "required": [
                        "errorCode",
                        "data"
                      ],
                      "additionalProperties": true
                    },
                    {
                      "$ref": "#/components/schemas/CapabilityError"
                    }
                  ]
                },
                "examples": {
                  "failure": {
                    "summary": "错误示例，按 data.message 与 data.retryable 处理",
                    "value": {
                      "contractVersion": "1.0.0",
                      "errorCode": "WORKFLOW_ENGINE_INVALID_REQUEST",
                      "data": {
                        "message": "请求参数无效",
                        "retryable": false
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "认证、参数、资源状态或服务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapabilityError"
                }
              }
            }
          }
        },
        "x-baijimu-side-effect": "read",
        "x-baijimu-response-data-schema": {
          "$ref": "#/components/schemas/WorkflowInstancePage"
        }
      }
    },
    "/capability/bundle-workflow/workflows/instances/detail": {
      "post": {
        "operationId": "getBundleWorkflowInstance",
        "summary": "读取工作流实例详情",
        "x-baijimu-scope": "workflow.execution.read",
        "requestBody": {
          "$ref": "#/components/requestBodies/WorkflowInstanceRequest"
        },
        "responses": {
          "200": {
            "description": "检查 errorCode；HTTP 200 也可能是业务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "errorCode": {
                          "const": "0"
                        },
                        "data": {
                          "$ref": "#/components/schemas/WorkflowInstanceDetail"
                        },
                        "contractVersion": {
                          "const": "1.0.0"
                        }
                      },
                      "required": [
                        "errorCode",
                        "data"
                      ],
                      "additionalProperties": true
                    },
                    {
                      "$ref": "#/components/schemas/CapabilityError"
                    }
                  ]
                },
                "examples": {
                  "failure": {
                    "summary": "错误示例，按 data.message 与 data.retryable 处理",
                    "value": {
                      "contractVersion": "1.0.0",
                      "errorCode": "WORKFLOW_ENGINE_INVALID_REQUEST",
                      "data": {
                        "message": "请求参数无效",
                        "retryable": false
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "认证、参数、资源状态或服务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapabilityError"
                }
              }
            }
          }
        },
        "x-baijimu-side-effect": "read",
        "x-baijimu-response-data-schema": {
          "$ref": "#/components/schemas/WorkflowInstanceDetail"
        }
      }
    },
    "/capability/bundle-workflow/workflows/instances/executions/query": {
      "post": {
        "operationId": "queryBundleWorkflowExecutions",
        "summary": "读取工作流实例执行详情",
        "x-baijimu-scope": "workflow.execution.read",
        "requestBody": {
          "$ref": "#/components/requestBodies/WorkflowInstanceRequest"
        },
        "responses": {
          "200": {
            "description": "检查 errorCode；HTTP 200 也可能是业务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "errorCode": {
                          "const": "0"
                        },
                        "data": {
                          "$ref": "#/components/schemas/WorkflowNodeHistory"
                        },
                        "contractVersion": {
                          "const": "1.0.0"
                        }
                      },
                      "required": [
                        "errorCode",
                        "data"
                      ],
                      "additionalProperties": true
                    },
                    {
                      "$ref": "#/components/schemas/CapabilityError"
                    }
                  ]
                },
                "examples": {
                  "failure": {
                    "summary": "错误示例，按 data.message 与 data.retryable 处理",
                    "value": {
                      "contractVersion": "1.0.0",
                      "errorCode": "WORKFLOW_ENGINE_INVALID_REQUEST",
                      "data": {
                        "message": "请求参数无效",
                        "retryable": false
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "认证、参数、资源状态或服务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapabilityError"
                }
              }
            }
          }
        },
        "x-baijimu-side-effect": "read",
        "x-baijimu-response-data-schema": {
          "$ref": "#/components/schemas/WorkflowNodeHistory"
        }
      }
    },
    "/capability/bundle-timer/timers/query": {
      "post": {
        "operationId": "queryBundleTimers",
        "summary": "查询当前 Bundle 的定时任务",
        "x-baijimu-scope": "timer.definition.read",
        "requestBody": {
          "$ref": "#/components/requestBodies/ApplicationRuntimeRequest"
        },
        "responses": {
          "200": {
            "description": "检查 errorCode；HTTP 200 也可能是业务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "errorCode": {
                          "const": "0"
                        },
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/TimerDefinition"
                          }
                        },
                        "contractVersion": {
                          "const": "1.0.0"
                        }
                      },
                      "required": [
                        "errorCode",
                        "data"
                      ],
                      "additionalProperties": true
                    },
                    {
                      "$ref": "#/components/schemas/CapabilityError"
                    }
                  ]
                },
                "examples": {}
              }
            }
          },
          "default": {
            "description": "认证、参数、资源状态或服务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapabilityError"
                }
              }
            }
          }
        },
        "x-baijimu-side-effect": "read",
        "x-baijimu-response-data-schema": {
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/TimerDefinition"
          }
        }
      }
    },
    "/capability/bundle-timer/timers/definition": {
      "post": {
        "operationId": "getBundleTimerDefinition",
        "summary": "读取定时任务定义",
        "x-baijimu-scope": "timer.definition.read",
        "requestBody": {
          "$ref": "#/components/requestBodies/ResourceRequest"
        },
        "responses": {
          "200": {
            "description": "检查 errorCode；HTTP 200 也可能是业务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "errorCode": {
                          "const": "0"
                        },
                        "data": {
                          "$ref": "#/components/schemas/TimerDefinition"
                        },
                        "contractVersion": {
                          "const": "1.0.0"
                        }
                      },
                      "required": [
                        "errorCode",
                        "data"
                      ],
                      "additionalProperties": true
                    },
                    {
                      "$ref": "#/components/schemas/CapabilityError"
                    }
                  ]
                },
                "examples": {}
              }
            }
          },
          "default": {
            "description": "认证、参数、资源状态或服务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapabilityError"
                }
              }
            }
          }
        },
        "x-baijimu-side-effect": "read",
        "x-baijimu-response-data-schema": {
          "$ref": "#/components/schemas/TimerDefinition"
        }
      }
    },
    "/capability/bundle-timer/timers/executions/query": {
      "post": {
        "operationId": "queryBundleTimerExecutions",
        "summary": "查询定时任务执行记录",
        "x-baijimu-scope": "timer.execution.read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueryTimerExecutionsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "检查 errorCode；HTTP 200 也可能是业务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "errorCode": {
                          "const": "0"
                        },
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/TimerExecution"
                          }
                        },
                        "contractVersion": {
                          "const": "1.0.0"
                        }
                      },
                      "required": [
                        "errorCode",
                        "data"
                      ],
                      "additionalProperties": true
                    },
                    {
                      "$ref": "#/components/schemas/CapabilityError"
                    }
                  ]
                },
                "examples": {}
              }
            }
          },
          "default": {
            "description": "认证、参数、资源状态或服务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapabilityError"
                }
              }
            }
          }
        },
        "x-baijimu-side-effect": "read",
        "x-baijimu-response-data-schema": {
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/TimerExecution"
          }
        }
      }
    },
    "/capability/bundle-timer/timers/executions/trigger": {
      "post": {
        "operationId": "triggerBundleTimerExecution",
        "summary": "触发一次定时任务执行",
        "x-baijimu-scope": "timer.execution.create",
        "requestBody": {
          "$ref": "#/components/requestBodies/ResourceRequest"
        },
        "responses": {
          "200": {
            "description": "检查 errorCode；HTTP 200 也可能是业务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "errorCode": {
                          "const": "0"
                        },
                        "data": {
                          "$ref": "#/components/schemas/TimerTriggerReceipt"
                        },
                        "contractVersion": {
                          "const": "1.0.0"
                        }
                      },
                      "required": [
                        "errorCode",
                        "data"
                      ],
                      "additionalProperties": true
                    },
                    {
                      "$ref": "#/components/schemas/CapabilityError"
                    }
                  ]
                },
                "examples": {}
              }
            }
          },
          "default": {
            "description": "认证、参数、资源状态或服务失败。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapabilityError"
                }
              }
            }
          }
        },
        "x-baijimu-side-effect": "write",
        "x-baijimu-response-data-schema": {
          "$ref": "#/components/schemas/TimerTriggerReceipt"
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bundleCapabilityToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "由 Hosted 环境的受管 Bundle Capability 绑定签发并自动交付，业务后端读取 BUNDLE_CAPABILITY_TOKEN；平台负责轮换与撤销。"
      }
    },
    "requestBodies": {
      "ApplicationRuntimeRequest": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApplicationRuntimeRequest"
            }
          }
        }
      },
      "ResourceRequest": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ResourceRequest"
            }
          }
        }
      },
      "WorkflowInstanceRequest": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/WorkflowInstanceRequest"
            }
          }
        }
      }
    },
    "schemas": {
      "ApplicationRuntimeId": {
        "type": "string",
        "minLength": 1,
        "maxLength": 128,
        "description": "目标 Application Runtime 的稳定 ID。"
      },
      "ResourceLocator": {
        "type": "string",
        "minLength": 1,
        "description": "由资源查询返回的稳定 Locator；调用方不得自行构造。"
      },
      "ApplicationRuntimeRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "applicationRuntimeId"
        ],
        "properties": {
          "applicationRuntimeId": {
            "$ref": "#/components/schemas/ApplicationRuntimeId"
          }
        }
      },
      "ResourceRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "applicationRuntimeId",
          "resourceLocator"
        ],
        "properties": {
          "applicationRuntimeId": {
            "$ref": "#/components/schemas/ApplicationRuntimeId"
          },
          "resourceLocator": {
            "$ref": "#/components/schemas/ResourceLocator"
          }
        }
      },
      "WorkflowInstanceRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "applicationRuntimeId",
          "resourceLocator",
          "instanceId"
        ],
        "properties": {
          "applicationRuntimeId": {
            "$ref": "#/components/schemas/ApplicationRuntimeId"
          },
          "resourceLocator": {
            "$ref": "#/components/schemas/ResourceLocator"
          },
          "instanceId": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "QueryBundleResourcesRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "applicationRuntimeId"
        ],
        "properties": {
          "applicationRuntimeId": {
            "$ref": "#/components/schemas/ApplicationRuntimeId"
          },
          "resourceType": {
            "type": "string",
            "minLength": 1,
            "description": "资源类型来自当前环境目录；新增类型无需更新客户端。"
          }
        }
      },
      "StartWorkflowRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "applicationRuntimeId",
          "resourceLocator",
          "requestId"
        ],
        "properties": {
          "applicationRuntimeId": {
            "$ref": "#/components/schemas/ApplicationRuntimeId"
          },
          "resourceLocator": {
            "$ref": "#/components/schemas/ResourceLocator"
          },
          "input": {
            "type": "object",
            "additionalProperties": true
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "requestId": {
            "type": "string",
            "minLength": 1,
            "description": "同一次启动请求的稳定幂等标识，必填；与 metadata.requestId 无关。"
          }
        }
      },
      "QueryWorkflowInstancesRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "applicationRuntimeId",
          "resourceLocator"
        ],
        "properties": {
          "applicationRuntimeId": {
            "$ref": "#/components/schemas/ApplicationRuntimeId"
          },
          "resourceLocator": {
            "$ref": "#/components/schemas/ResourceLocator"
          },
          "status": {
            "type": "string",
            "minLength": 1
          },
          "pageNum": {
            "type": "integer",
            "minimum": 1,
            "default": 1
          },
          "pageSize": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 20
          }
        }
      },
      "QueryTimerExecutionsRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "applicationRuntimeId",
          "resourceLocator"
        ],
        "properties": {
          "applicationRuntimeId": {
            "$ref": "#/components/schemas/ApplicationRuntimeId"
          },
          "resourceLocator": {
            "$ref": "#/components/schemas/ResourceLocator"
          },
          "status": {
            "type": "string",
            "minLength": 1
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000,
            "default": 50
          },
          "offset": {
            "type": "integer",
            "minimum": 0,
            "default": 0
          }
        }
      },
      "ResourceVersion": {
        "type": "object",
        "properties": {
          "resourceLocator": {
            "$ref": "#/components/schemas/ResourceLocator"
          },
          "semanticVersion": {
            "type": "string"
          }
        },
        "required": [
          "resourceLocator",
          "semanticVersion"
        ],
        "additionalProperties": true
      },
      "BundleIdentity": {
        "type": "object",
        "properties": {
          "environmentKey": {
            "type": "string"
          },
          "bundleId": {
            "type": "string"
          }
        },
        "required": [
          "environmentKey",
          "bundleId"
        ],
        "additionalProperties": true
      },
      "BundleResources": {
        "type": "object",
        "properties": {
          "contractVersion": {
            "type": "string"
          },
          "workspaceId": {
            "type": "integer"
          },
          "applicationRuntimeId": {
            "$ref": "#/components/schemas/ApplicationRuntimeId"
          },
          "bundle": {
            "$ref": "#/components/schemas/BundleIdentity"
          },
          "resources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceVersion"
            }
          }
        },
        "required": [
          "contractVersion",
          "workspaceId",
          "applicationRuntimeId",
          "bundle",
          "resources"
        ],
        "additionalProperties": true
      },
      "WorkflowDefinition": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "description": "工作流定义的稳定编码。查询定义时读取此字段；definitionCode 属于执行实例等其他对象。"
          },
          "name": {
            "type": "string"
          },
          "revision": {
            "type": "integer"
          },
          "currentPlanId": {
            "type": "string"
          },
          "recompilationRequired": {
            "type": "boolean"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "active",
              "disabled"
            ]
          },
          "startNodeId": {
            "type": "string"
          },
          "inputSchema": {
            "type": "array",
            "items": {
              "type": "object",
              "description": "平台低代码参数定义。"
            }
          },
          "outputSchema": {
            "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
          },
          "nodes": {
            "type": "array",
            "items": {
              "type": "object",
              "description": "已安装资源版本的工作流节点定义。"
            }
          },
          "edges": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "graphLayout": {
            "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "workspaceId",
          "code",
          "name",
          "revision",
          "status",
          "startNodeId",
          "nodes",
          "edges",
          "recompilationRequired",
          "description",
          "inputSchema",
          "outputSchema",
          "graphLayout",
          "tags",
          "createdAt",
          "updatedAt"
        ],
        "additionalProperties": true,
        "description": "已安装的 Workflow 定义，直接位于 data（单项）或 data[]（列表）。不包含编译计划外层 definitionCode/planId/definition；resourceLocator 与 semanticVersion 从 Bundle 资源账本取得。"
      },
      "WorkflowInstance": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "workspaceId": {
            "type": [
              "string",
              "null"
            ]
          },
          "applicationRuntimeId": {
            "type": [
              "string",
              "null"
            ]
          },
          "executionSnapshotId": {
            "type": "string"
          },
          "definitionId": {
            "type": "string"
          },
          "definitionCode": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "resourceVersion": {
            "$ref": "#/components/schemas/ResourceVersion"
          },
          "input": {
            "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
          },
          "output": {
            "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
          },
          "context": {
            "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
          },
          "metadata": {
            "type": "object"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "tenantId": {
            "type": "string"
          },
          "concurrencyGroupKey": {
            "type": "string"
          },
          "partitionKey": {
            "type": "string"
          },
          "runtimeProjectionId": {
            "type": "string"
          },
          "planId": {
            "type": [
              "string",
              "null"
            ]
          },
          "failedNodeId": {
            "type": [
              "string",
              "null"
            ]
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "currentNodeIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "waitingNodeIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "executionSubjectUserId": {
            "type": "integer"
          },
          "definitionSnapshot": {
            "$ref": "#/components/schemas/WorkflowDefinition"
          },
          "nodeStates": {
            "type": "object",
            "additionalProperties": {
              "type": "object"
            }
          }
        },
        "required": [
          "id",
          "tenantId",
          "concurrencyGroupKey",
          "executionSnapshotId",
          "definitionId",
          "definitionCode",
          "status",
          "input",
          "context",
          "output",
          "metadata",
          "currentNodeIds",
          "waitingNodeIds",
          "nodeStates",
          "createdAt",
          "updatedAt"
        ],
        "additionalProperties": true
      },
      "WorkflowInstanceDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/WorkflowInstance"
          },
          {
            "type": "object",
            "properties": {
              "plan": {
                "type": [
                  "object",
                  "null"
                ],
                "description": "该执行冻结的运行计划，可能为空。"
              },
              "synchronization": {
                "$ref": "#/components/schemas/ExecutionSynchronization"
              }
            },
            "required": [
              "plan",
              "synchronization"
            ],
            "additionalProperties": true
          }
        ]
      },
      "WorkflowInstancePage": {
        "type": "object",
        "properties": {
          "list": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkflowInstanceSummary"
            }
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "statusCounts": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "synchronization": {
            "$ref": "#/components/schemas/ExecutionSynchronization"
          }
        },
        "required": [
          "list",
          "total",
          "statusCounts",
          "synchronization"
        ],
        "additionalProperties": true
      },
      "NodeExecution": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "instanceId": {
            "type": "string"
          },
          "nodeId": {
            "type": "string"
          },
          "nodeType": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "input": {
            "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
          },
          "output": {
            "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "description": "由工作流或业务对象自己的类型合同定义的 JSON 值。"
          },
          "startedAt": {
            "type": "string",
            "format": "date-time"
          },
          "finishedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "trigger": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "instanceId",
          "nodeId",
          "nodeType",
          "status",
          "trigger",
          "startedAt"
        ],
        "additionalProperties": true
      },
      "WorkflowNodeHistory": {
        "type": "object",
        "properties": {
          "list": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NodeExecution"
            }
          },
          "synchronization": {
            "$ref": "#/components/schemas/ExecutionSynchronization"
          }
        },
        "required": [
          "list",
          "synchronization"
        ],
        "additionalProperties": true
      },
      "TimerDefinition": {
        "type": "object",
        "properties": {
          "resourceVersion": {
            "$ref": "#/components/schemas/ResourceVersion"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "schedule": {
            "type": "object",
            "description": "Timer 版本自己的调度合同。"
          },
          "target": {
            "type": "object",
            "description": "Timer 版本自己的执行目标合同。"
          },
          "nextFireAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "resourceVersion",
          "name",
          "description",
          "enabled",
          "schedule",
          "target",
          "nextFireAt",
          "createdAt",
          "updatedAt"
        ],
        "additionalProperties": true
      },
      "TimerExecution": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "executionId": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "attemptNumber": {
            "type": "integer"
          },
          "requestBody": {
            "type": [
              "string",
              "null"
            ]
          },
          "responseBody": {
            "type": [
              "string",
              "null"
            ]
          },
          "errorMessage": {
            "type": [
              "string",
              "null"
            ]
          },
          "errorType": {
            "type": [
              "string",
              "null"
            ]
          },
          "traceId": {
            "type": [
              "string",
              "null"
            ]
          },
          "responseStatusCode": {
            "type": [
              "integer",
              "null"
            ]
          },
          "responseSizeBytes": {
            "type": [
              "integer",
              "null"
            ]
          },
          "durationMs": {
            "type": [
              "integer",
              "null"
            ]
          },
          "scheduledAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "startedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "executionId",
          "status",
          "attemptNumber",
          "requestBody",
          "responseBody",
          "errorMessage",
          "errorType",
          "traceId",
          "responseStatusCode",
          "responseSizeBytes",
          "durationMs",
          "scheduledAt",
          "createdAt",
          "startedAt",
          "completedAt"
        ],
        "additionalProperties": true
      },
      "TimerTriggerReceipt": {
        "type": "object",
        "properties": {
          "applicationRuntimeId": {
            "type": "string"
          },
          "resourceLocator": {
            "$ref": "#/components/schemas/ResourceLocator"
          },
          "mode": {
            "const": "trigger"
          },
          "triggeredAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "applicationRuntimeId",
          "resourceLocator",
          "mode",
          "triggeredAt"
        ],
        "additionalProperties": true
      },
      "CapabilityError": {
        "type": "object",
        "required": [
          "errorCode",
          "data"
        ],
        "properties": {
          "contractVersion": {
            "const": "1.0.0"
          },
          "errorCode": {
            "type": "string",
            "maxLength": 128,
            "pattern": "^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$"
          },
          "data": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/CapabilityFailureData"
              }
            ]
          }
        },
        "additionalProperties": true
      },
      "ExecutionSynchronization": {
        "type": "object",
        "properties": {
          "generation": {
            "type": "integer",
            "minimum": 1
          },
          "rebuilding": {
            "type": "boolean"
          },
          "sourceObservedAt": {
            "type": "string",
            "format": "date-time"
          },
          "appliedAt": {
            "type": "string",
            "format": "date-time"
          },
          "caughtUpAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "generation",
          "rebuilding",
          "sourceObservedAt",
          "appliedAt",
          "caughtUpAt"
        ],
        "additionalProperties": true
      },
      "WorkflowInstanceSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "runtimeProjectionId": {
            "type": [
              "string",
              "null"
            ]
          },
          "executionSnapshotId": {
            "type": "string"
          },
          "applicationRuntimeId": {
            "type": [
              "string",
              "null"
            ]
          },
          "resourceVersion": {
            "$ref": "#/components/schemas/ResourceVersion"
          },
          "planId": {
            "type": [
              "string",
              "null"
            ]
          },
          "definitionId": {
            "type": "string"
          },
          "definitionCode": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "currentNodeIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "waitingNodeIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "failedNodeId": {
            "type": [
              "string",
              "null"
            ]
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "hasOutput": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "workspaceId",
          "runtimeProjectionId",
          "executionSnapshotId",
          "applicationRuntimeId",
          "planId",
          "definitionId",
          "definitionCode",
          "status",
          "currentNodeIds",
          "waitingNodeIds",
          "failedNodeId",
          "lastError",
          "createdAt",
          "updatedAt",
          "completedAt",
          "hasOutput"
        ],
        "additionalProperties": true
      },
      "CapabilityFailureData": {
        "type": "object",
        "required": [
          "message",
          "retryable"
        ],
        "properties": {
          "message": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512
          },
          "retryable": {
            "type": "boolean"
          }
        },
        "additionalProperties": true
      }
    }
  }
}
