{
  "siteId": "wechat_channels",
  "taskType": "save_video_draft",
  "platform": "wechat",
  "name": "保存微信视频号草稿",
  "description": "在微信视频号创作者中心保存视频草稿",
  "requiredFields": [
    {
      "name": "video",
      "type": "string",
      "description": "视频文件路径（绝对路径）"
    }
  ],
  "optionalFields": [
    {
      "name": "title",
      "type": "string",
      "description": "视频标题（最多16字）"
    },
    {
      "name": "content",
      "type": "string",
      "description": "视频描述（正文+话题合计最多1000字）"
    },
    {
      "name": "topics",
      "type": "array",
      "description": "话题标签数组，最多10个，例如 [\"话题1\", \"话题2\"]"
    }
  ],
  "nodes": [
    {
      "nodeId": "ensure_publish_ready",
      "name": "ensure_publish_ready",
      "tool": "ensure_publish_ready",
      "args": {
        "initialDelayMs": 2000
      }
    },
    {
      "nodeId": "wait_page_ready",
      "name": "wait_page_ready",
      "tool": "wait",
      "args": {
        "delayMs": 3000,
        "message": "等待发布页面完全加载"
      }
    },
    {
      "nodeId": "upload_video",
      "name": "upload_video",
      "tool": "upload_assets",
      "args": {
        "field": "video",
        "assets": [
          "{{data.video}}"
        ],
        "timeoutMs": 300000
      }
    },
    {
      "nodeId": "fill_content",
      "name": "fill_content",
      "when": "exists(payload.content)",
      "tool": "fill_field",
      "args": {
        "field": "content",
        "value": "{{data.content}}"
      }
    },
    {
      "nodeId": "fill_title",
      "name": "fill_title",
      "when": "exists(payload.title)",
      "tool": "fill_field",
      "args": {
        "field": "title",
        "value": "{{data.title}}"
      }
    },
    {
      "nodeId": "wait_publish_btn_ready",
      "name": "wait_publish_btn_ready",
      "tool": "wait_for_condition",
      "args": {
        "condition": {
          "type": "logical_and",
          "conditions": [
            {
              "type": "element_exists",
              "selector": ".video-wrap video[src^='blob:']",
              "shadowHost": "wujie-app"
            },
            {
              "type": "element_visible",
              "selector": ".vertical-cover-wrap img[src^='https://']",
              "shadowHost": "wujie-app"
            }
          ]
        },
        "timeoutMs": 300000,
        "pollIntervalMs": 3000,
        "message": "等待视频预览和封面出现（视频上传完成）"
      }
    },
    {
      "nodeId": "save_draft",
      "name": "save_draft",
      "tool": "trigger_action",
      "args": {
        "action": "saveDraft"
      }
    },
    {
      "nodeId": "navigate_home",
      "name": "navigate_home",
      "tool": "trigger_action",
      "args": {
        "action": "navigateHome"
      }
    },
    {
      "nodeId": "close_tab",
      "name": "close_tab",
      "tool": "close_tab",
      "args": {
        "delayMs": 1500,
        "message": "草稿保存成功，页面即将关闭",
        "showCountdown": true,
        "activateOptional": true
      }
    }
  ],
  "validation": [
    {
      "rule": "video.length >= 1",
      "message": "需要提供视频文件路径"
    },
    {
      "rule": "!title || title.length <= 16",
      "message": "视频标题不能超过16字"
    },
    {
      "rule": "!topics || topics.length <= 10",
      "message": "话题数量不能超过10个"
    },
    {
      "rule": "(content ? content.length : 0) + (topics && topics.length > 0 ? 2 + topics.reduce((s,t)=>s+(t.startsWith('#')?t.length:t.length+1),0) + topics.length - 1 : 0) <= 1000",
      "message": "视频描述与话题合计不能超过1000字"
    }
  ]
}