Files
syops/docs/openapi/file_check_tools_openapi.json
T

976 lines
26 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"openapi": "3.0.3",
"info": {
"title": "HXOPS File Check Tool API",
"description": "文件检核 Chatflow 显式 HTTP Tool API:检核任务列表、发起检核、查询检核批次、下载检核报告、检索历史检核报告。鉴权:Authorization Bearer 或 X-Integration-Key。",
"version": "1.0.0"
},
"servers": [
{
"url": "http://127.0.0.1:5052",
"description": "本地开发占位;部署环境请通过 GET /api/file-check/tools/openapi.json 导入"
}
],
"security": [
{
"BearerAuth": []
},
{
"IntegrationKey": []
}
],
"paths": {
"/api/file-check/tools/tasks": {
"get": {
"operationId": "list_file_check_tasks",
"summary": "查询指定文件检核任务",
"tags": [
"File Check"
],
"parameters": [
{
"name": "task_id",
"in": "query",
"required": true,
"schema": {
"type": "integer",
"example": 12
},
"description": "检核任务 ID(Agent 绑定的 schedule_task_id)"
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ListTasksResponse"
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/TaskNotFound"
},
"503": {
"$ref": "#/components/responses/MissingAuth"
}
}
}
},
"/api/file-check/tools/tasks/run": {
"post": {
"operationId": "run_file_check",
"summary": "异步启动 文件检核",
"tags": [
"File Check"
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RunCheckRequest"
}
}
}
},
"responses": {
"200": {
"description": "启动成功;或已有 文件检核进行中,返回 ok=false/error_code=check_running",
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/RunCheckSuccessResponse"
},
{
"$ref": "#/components/schemas/CheckRunningResponse"
}
]
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/TaskNotFound"
},
"503": {
"$ref": "#/components/responses/DataSourceUnavailable"
}
}
}
},
"/api/file-check/tools/runs": {
"get": {
"operationId": "list_file_check_runs",
"summary": "查询 文件检核批次列表",
"tags": [
"File Check"
],
"parameters": [
{
"name": "task_id",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"example": 12
},
"description": "可选;指定检核任务 ID 时只返回该任务批次"
},
{
"name": "limit",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 20
},
"description": "返回条数,最大 100"
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ListRunsResponse"
}
}
}
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/TaskNotFound"
}
}
}
},
"/api/file-check/tools/runs/{run_id}": {
"get": {
"operationId": "get_file_check_run",
"summary": "查询指定检核批次",
"tags": [
"File Check"
],
"parameters": [
{
"name": "run_id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"example": 88
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetRunResponse"
}
}
}
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/RunNotFound"
}
}
}
},
"/api/file-check/tools/tasks/{task_id}/latest-run": {
"get": {
"operationId": "get_latest_file_check_run",
"summary": "查询检核任务最近一次检核",
"tags": [
"File Check"
],
"parameters": [
{
"name": "task_id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"example": 12
}
},
{
"name": "hxops_turn_id",
"in": "query",
"required": false,
"schema": {
"type": "string"
},
"description": "当前 HXOPS 对话轮次 ID;传入后将最近批次绑定到该轮进度卡"
},
{
"name": "conversation_id",
"in": "query",
"required": false,
"schema": {
"type": "string"
},
"description": "当前 Dify 会话 ID,仅用于关联当前查询轮次"
},
{
"name": "user_message",
"in": "query",
"required": false,
"schema": {
"type": "string"
},
"description": "当前用户问题,仅用于关联当前查询轮次"
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetRunResponse"
}
}
}
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/RunNotFound"
}
}
}
},
"/api/file-check/tools/history/search": {
"post": {
"operationId": "search_file_check_history",
"summary": "检索历史检核报告",
"description": "按 task_id 解析 ScheduleTask → KbGroup → Dify Dataset,返回语义检索片段;供 Chatflow history_report_query 分支调用。",
"tags": [
"File Check"
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HistorySearchRequest"
}
}
}
},
"responses": {
"200": {
"description": "成功(count=0 表示未命中片段)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HistorySearchResponse"
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/TaskNotFound"
},
"503": {
"$ref": "#/components/responses/MissingAuth"
}
}
}
},
"/api/file-check/tools/runs/{run_id}/excel": {
"get": {
"operationId": "download_file_check_run_excel",
"summary": "下载检核报告 Excel(短期签名 token)",
"tags": [
"File Check"
],
"security": [],
"parameters": [
{
"name": "run_id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"example": 88
}
},
{
"name": "token",
"in": "query",
"required": true,
"description": "由 get_file_check_run 返回的 excel.download_url 中的 JWT,有效期 600 秒",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Excel 文件流",
"content": {
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
},
"409": {
"$ref": "#/components/responses/ExcelNotReady"
}
}
}
}
},
"components": {
"securitySchemes": {
"BearerAuth": {
"type": "http",
"scheme": "bearer",
"description": "FILE_CHECK_TOOL_API_KEY 或 INTEGRATION_API_KEY"
},
"IntegrationKey": {
"type": "apiKey",
"in": "header",
"name": "X-Integration-Key",
"description": "与 Bearer 二选一"
}
},
"schemas": {
"TaskSummary": {
"type": "object",
"properties": {
"task_id": {
"type": "integer",
"example": 12
},
"task_no": {
"type": "string",
"example": "CHK202606090001"
},
"name": {
"type": "string",
"example": "文件自动检核"
},
"enabled": {
"type": "boolean"
},
"last_status": {
"type": "string",
"nullable": true,
"example": "success"
},
"last_run_at": {
"type": "string",
"format": "date-time",
"nullable": true
},
"next_run_at": {
"type": "string",
"format": "date-time",
"nullable": true
}
}
},
"RunExcel": {
"type": "object",
"properties": {
"file_name": {
"type": "string",
"nullable": true,
"example": "RUN202606090001.xlsx"
},
"file_size": {
"type": "integer",
"nullable": true,
"example": 45678
},
"download_url": {
"type": "string",
"nullable": true,
"example": "https://your-hxops-host/api/file-check/tools/runs/88/excel?token=..."
}
}
},
"RunKnowledgeBase": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"sync_status": {
"type": "string",
"nullable": true,
"enum": [
"skipped",
"queued",
"cleaning",
"syncing",
"ready",
"success",
"failed"
]
},
"group_id": {
"type": "integer",
"nullable": true
},
"document_id": {
"type": "integer",
"nullable": true
},
"document_version_id": {
"type": "integer",
"nullable": true
},
"sync_job_id": {
"type": "integer",
"nullable": true
},
"error_message": {
"type": "string",
"nullable": true
}
}
},
"RunDetail": {
"type": "object",
"properties": {
"run_id": {
"type": "integer",
"example": 88
},
"run_no": {
"type": "string",
"example": "RUN202606090001"
},
"task_id": {
"type": "integer",
"example": 12
},
"task_name": {
"type": "string",
"example": "文件自动检核"
},
"status": {
"type": "string",
"enum": [
"running",
"success",
"partial_failed",
"failed",
"queued",
"cancelled"
]
},
"total_count": {
"type": "integer"
},
"success_count": {
"type": "integer"
},
"failed_count": {
"type": "integer"
},
"skipped_count": {
"type": "integer"
},
"started_at": {
"type": "string",
"format": "date-time",
"nullable": true
},
"finished_at": {
"type": "string",
"format": "date-time",
"nullable": true
},
"duration_ms": {
"type": "integer",
"nullable": true
},
"error_message": {
"type": "string",
"nullable": true
},
"excel": {
"$ref": "#/components/schemas/RunExcel"
},
"knowledge_base": {
"$ref": "#/components/schemas/RunKnowledgeBase"
}
}
},
"ListTasksResponse": {
"type": "object",
"required": [
"ok",
"tasks"
],
"properties": {
"ok": {
"type": "boolean",
"example": true
},
"tasks": {
"type": "array",
"items": {
"$ref": "#/components/schemas/TaskSummary"
}
}
}
},
"RunCheckRequest": {
"type": "object",
"properties": {
"task_id": {
"type": "integer",
"example": 12,
"description": "检核任务 ID(ScheduleTask.id);绑定 解析运行态上下文.task_id_int(Number),勿绑意图识别.task_id"
},
"trigger_source": {
"type": "string",
"default": "dify_chatflow"
},
"conversation_id": {
"type": "string",
"nullable": true
},
"user_message": {
"type": "string",
"nullable": true
},
"hxops_turn_id": {
"type": "string",
"nullable": true,
"description": "本轮对话唯一标识;须与 agent_runtime_context.refs.hxops_turn_id(经画布 §3.1A 解析)一致,Tool 原样回传"
},
"hxops_session_id": {
"type": "string",
"nullable": true,
"description": "HXOPS 会话 ID;可与 sys.conversation_id 二选一,优先显式传入"
},
"mode": {
"type": "string",
"nullable": true,
"enum": [
"incremental",
"force_all",
"single"
],
"description": "【Dify 推荐】运行模式(立账凭证检核读取;文件检核忽略)。incremental=增量 / force_all=全量 / single=单发票;单发票时须同时填 invoice_no"
},
"invoice_no": {
"type": "string",
"nullable": true,
"description": "【Dify 推荐】mode=single 时必填的发票号;来自意图识别.invoice_no"
},
"run_options": {
"type": "object",
"nullable": true,
"description": "可选嵌套写法(部分 Dify 版本不展示对象字段;优先用顶层 mode/invoice_no)。mode=incremental|force_all|single;single 时须带 invoice_no",
"properties": {
"mode": {
"type": "string",
"enum": [
"incremental",
"force_all",
"single"
],
"default": "incremental"
},
"invoice_no": {
"type": "string",
"nullable": true,
"description": "mode=single 时必填的发票号"
}
}
}
},
"required": [
"task_id"
],
"description": "Chatflow Tool 节点绑定 task_id(Integer,来源 解析运行态上下文.task_id_int)、hxops_turn_id(经 agent_runtime_context 解析后传入);立账凭证检核用顶层 mode/invoice_no(Dify 友好)或嵌套 run_options"
},
"RunCheckSuccessResponse": {
"type": "object",
"required": [
"ok",
"message",
"run"
],
"properties": {
"ok": {
"type": "boolean",
"example": true
},
"message": {
"type": "string",
"example": "检核已启动"
},
"run": {
"$ref": "#/components/schemas/RunDetail"
}
}
},
"CheckRunningResponse": {
"type": "object",
"required": [
"ok",
"error_code",
"message",
"run"
],
"properties": {
"ok": {
"type": "boolean",
"example": false
},
"error_code": {
"type": "string",
"example": "check_running"
},
"message": {
"type": "string",
"example": "该检核任务正在执行中,请稍后查询结果"
},
"run": {
"$ref": "#/components/schemas/RunDetail"
}
}
},
"GetRunResponse": {
"type": "object",
"required": [
"ok",
"run"
],
"properties": {
"ok": {
"type": "boolean",
"example": true
},
"run": {
"$ref": "#/components/schemas/RunDetail"
}
}
},
"ListRunsResponse": {
"type": "object",
"required": [
"ok",
"runs",
"count"
],
"properties": {
"ok": {
"type": "boolean",
"example": true
},
"count": {
"type": "integer",
"example": 2
},
"runs": {
"type": "array",
"items": {
"$ref": "#/components/schemas/RunDetail"
}
}
}
},
"HistorySearchRequest": {
"type": "object",
"required": [
"task_id",
"query"
],
"properties": {
"task_id": {
"type": "integer",
"example": 12,
"description": "检核任务 ID(Agent 绑定的 schedule_task_id)"
},
"query": {
"type": "string",
"example": "上周有哪些不合格项",
"description": "用户自然语言检索问题"
},
"top_k": {
"type": "integer",
"minimum": 1,
"maximum": 20,
"default": 5,
"description": "返回片段数,默认 5"
},
"score_threshold": {
"type": "number",
"minimum": 0,
"maximum": 1,
"default": 0.3,
"description": "相似度阈值,默认 0.3"
}
}
},
"HistorySearchSegment": {
"type": "object",
"properties": {
"content": {
"type": "string",
"description": "检索片段正文"
},
"score": {
"type": "number",
"nullable": true,
"description": "相似度分数"
},
"document_id": {
"type": "string",
"nullable": true
},
"document_title": {
"type": "string",
"nullable": true,
"example": "RoHS检核_RUN202606090001"
},
"run_no": {
"type": "string",
"nullable": true,
"example": "RUN202606090001"
},
"metadata": {
"type": "object",
"additionalProperties": true
}
}
},
"HistorySearchResponse": {
"type": "object",
"required": [
"ok",
"task_id",
"query",
"count",
"segments"
],
"properties": {
"ok": {
"type": "boolean",
"example": true
},
"task_id": {
"type": "integer",
"example": 12
},
"task_name": {
"type": "string",
"example": "RoHS 文件检核"
},
"kb_group_id": {
"type": "integer",
"example": 3
},
"kb_group_name": {
"type": "string",
"example": "RoHS 检核报告"
},
"dify_dataset_id": {
"type": "string",
"example": "ds-uuid"
},
"query": {
"type": "string",
"example": "上周有哪些不合格项"
},
"count": {
"type": "integer",
"example": 2
},
"segments": {
"type": "array",
"items": {
"$ref": "#/components/schemas/HistorySearchSegment"
}
}
}
},
"ErrorResponse": {
"type": "object",
"required": [
"ok",
"error_code",
"message"
],
"properties": {
"ok": {
"type": "boolean",
"example": false
},
"error_code": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
},
"responses": {
"Unauthorized": {
"description": "鉴权失败",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"examples": {
"missing_auth": {
"value": {
"ok": false,
"error_code": "missing_auth",
"message": "missing_auth"
}
},
"invalid_auth": {
"value": {
"ok": false,
"error_code": "invalid_auth",
"message": "invalid_auth"
}
}
}
}
}
},
"MissingAuth": {
"description": "服务端未配置 FILE_CHECK_TOOL_API_KEY / INTEGRATION_API_KEY",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "missing_auth",
"message": "FILE_CHECK_TOOL_API_KEY or INTEGRATION_API_KEY is not configured"
}
}
}
},
"BadRequest": {
"description": "请求参数无效",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "invalid_request",
"message": "invalid_request"
}
}
}
},
"TaskNotFound": {
"description": "检核任务不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "task_not_found",
"message": "task_not_found"
}
}
}
},
"RunNotFound": {
"description": "检核批次不存在",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "run_not_found",
"message": "run_not_found"
}
}
}
},
"ExcelNotReady": {
"description": "Excel 尚未生成",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "excel_not_ready",
"message": "excel_not_ready"
}
}
}
},
"DataSourceUnavailable": {
"description": "检核数据源不可用(ODBC/SQL Server 连接失败或 SRM 环境变量未配置)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"ok": false,
"error_code": "data_source_unavailable",
"message": "检核数据源不可用,请检查排程 SQL 配置、SRM_SQLSERVER_* 环境变量及本机 ODBC 驱动"
}
}
}
}
}
}
}