api-config.json 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. {
  2. "name": "category-landscape",
  3. "displayName": "品类格局分析",
  4. "description": "品类全景分析,计算CR5/HHI市场集中度,生成风险预警汇总和优先行动清单,输出《品类认知校准表》",
  5. "category": "synthesis",
  6. "version": "1.3.0",
  7. "type": "orchestration",
  8. "parameters": {
  9. "keywords": {
  10. "type": "array",
  11. "items": {
  12. "type": "string"
  13. },
  14. "required": true,
  15. "description": "品类核心关键词列表"
  16. },
  17. "domain": {
  18. "type": "integer",
  19. "required": false,
  20. "default": 1,
  21. "description": "Amazon站点(1=美国)"
  22. },
  23. "topN": {
  24. "type": "integer",
  25. "required": false,
  26. "default": 100,
  27. "description": "分析的产品数量"
  28. }
  29. },
  30. "pipeline": [
  31. {
  32. "step": 1,
  33. "name": "搜索品类Top N产品",
  34. "forEach": "keywords",
  35. "api": {
  36. "service": "SorftimeApiService.searchProductsByQuery",
  37. "endpoint": "/api/ProductQuery",
  38. "method": "POST",
  39. "forwardUrl": "https://server.fmode.cn/api/voc-ecom/forward",
  40. "headers": {
  41. "Authorization": "Bearer {{vocToken}}"
  42. },
  43. "requestBody": {
  44. "Page": 1,
  45. "Query": "1",
  46. "QueryType": "7",
  47. "Pattern": "${keyword}"
  48. },
  49. "queryParams": {
  50. "domain": "${domain}"
  51. }
  52. },
  53. "output": "searchResults",
  54. "responseExtract": "Array<{ Asin, Title, Price, Rating, RatingsCount, MonthlySales, Brand, BSR, Photo }>"
  55. },
  56. {
  57. "step": 2,
  58. "name": "批量获取销量数据",
  59. "forEach": "searchResults[].Asin (去重)",
  60. "api": {
  61. "service": "SorftimeApiService.getAsinSalesVolume",
  62. "endpoint": "/api/AsinSalesVolume",
  63. "method": "POST",
  64. "requestBody": {
  65. "ASIN": "${asin}"
  66. },
  67. "queryParams": {
  68. "domain": "${domain}"
  69. }
  70. },
  71. "output": "salesData"
  72. },
  73. {
  74. "step": 3,
  75. "name": "定位品类类目",
  76. "api": {
  77. "service": "SorftimeApiService.getCategoryTree",
  78. "endpoint": "/api/CategoryTree",
  79. "method": "POST",
  80. "requestBody": {
  81. "keyword": "${keywords[0]}"
  82. },
  83. "queryParams": {
  84. "domain": "${domain}"
  85. }
  86. },
  87. "output": "categoryTree"
  88. },
  89. {
  90. "step": 4,
  91. "name": "获取核心关键词搜索量和竞争度",
  92. "forEach": "keywords",
  93. "api": {
  94. "service": "SorftimeApiService.searchKeywords",
  95. "endpoint": "/api/KeywordQuery",
  96. "method": "POST",
  97. "requestBody": {
  98. "Keyword": "${keyword}"
  99. },
  100. "queryParams": {
  101. "domain": "${domain}"
  102. }
  103. },
  104. "output": "keywordData"
  105. },
  106. {
  107. "step": 5,
  108. "name": "获取关键词趋势",
  109. "forEach": "keywords",
  110. "api": {
  111. "service": "SorftimeApiService.getKeywordTrend",
  112. "endpoint": "/api/KeywordSearchTrend",
  113. "method": "POST",
  114. "requestBody": {
  115. "Keyword": "${keyword}"
  116. },
  117. "queryParams": {
  118. "domain": "${domain}"
  119. }
  120. },
  121. "output": "keywordTrend"
  122. },
  123. {
  124. "step": 6,
  125. "name": "市场集中度+价格带+增长判断计算",
  126. "type": "compute",
  127. "logic": "analyzeMarket(searchResults, salesData, keywordData, keywordTrend)",
  128. "algorithm": {
  129. "cr5": "前5品牌销售额占品类总销售额的比例",
  130. "cr10": "前10品牌销售额占比",
  131. "hhi": "赫芬达尔-赫希曼指数(各品牌市场份额平方和 × 10000)",
  132. "marketSize": "品类月销量总和、月销售额总和",
  133. "priceBands": "按价格区间统计产品数量和销量占比",
  134. "brandConcentration": "Top 10 品牌的市场份额",
  135. "ratingDistribution": "品类整体评分水平",
  136. "growthStage": "基于搜索趋势判断品类处于增长/成熟/衰退期"
  137. },
  138. "output": "marketAnalysis"
  139. },
  140. {
  141. "step": 7,
  142. "name": "风险预警汇总",
  143. "type": "compute",
  144. "logic": "generateRiskAlerts(marketAnalysis)",
  145. "algorithm": {
  146. "brandConcentrationRisk": "品牌集中度风险",
  147. "lowSalesRisk": "低销量风险",
  148. "ratingRisk": "评分风险",
  149. "priceWarRisk": "价格战风险",
  150. "inventoryRisk": "库存风险",
  151. "complianceRisk": "合规风险",
  152. "levelLabels": "每项风险标注级别(high/medium/low)和具体描述"
  153. },
  154. "output": "riskAlerts"
  155. },
  156. {
  157. "step": 8,
  158. "name": "优先行动清单",
  159. "type": "compute",
  160. "logic": "generatePriorityActions(marketAnalysis, riskAlerts)",
  161. "algorithm": {
  162. "triggers": "条件触发式优先级: Listing优化→SKU聚焦→促销→产品迭代→库存→差异化"
  163. },
  164. "output": "priorityActions"
  165. }
  166. ],
  167. "response": {
  168. "type": "object",
  169. "properties": {
  170. "marketOverview": {
  171. "type": "object",
  172. "properties": {
  173. "totalProducts": {
  174. "type": "integer"
  175. },
  176. "totalMonthlySales": {
  177. "type": "integer"
  178. },
  179. "totalMonthlyRevenue": {
  180. "type": "number"
  181. },
  182. "avgPrice": {
  183. "type": "number"
  184. },
  185. "medianPrice": {
  186. "type": "number"
  187. },
  188. "avgRating": {
  189. "type": "number"
  190. },
  191. "categoryStage": {
  192. "type": "string"
  193. }
  194. }
  195. },
  196. "concentration": {
  197. "type": "object",
  198. "properties": {
  199. "cr5": {
  200. "type": "number"
  201. },
  202. "cr10": {
  203. "type": "number"
  204. },
  205. "hhi": {
  206. "type": "integer"
  207. },
  208. "interpretation": {
  209. "type": "string"
  210. }
  211. }
  212. },
  213. "topBrands": {
  214. "type": "array",
  215. "items": {
  216. "type": "object",
  217. "properties": {
  218. "brand": {
  219. "type": "string"
  220. },
  221. "marketShare": {
  222. "type": "number"
  223. },
  224. "productCount": {
  225. "type": "integer"
  226. },
  227. "avgPrice": {
  228. "type": "number"
  229. },
  230. "avgRating": {
  231. "type": "number"
  232. }
  233. }
  234. }
  235. },
  236. "priceBands": {
  237. "type": "array",
  238. "items": {
  239. "type": "object",
  240. "properties": {
  241. "range": {
  242. "type": "string"
  243. },
  244. "productCount": {
  245. "type": "integer"
  246. },
  247. "salesShare": {
  248. "type": "number"
  249. },
  250. "avgRating": {
  251. "type": "number"
  252. }
  253. }
  254. }
  255. },
  256. "searchTrend": {
  257. "type": "object",
  258. "properties": {
  259. "mainKeyword": {
  260. "type": "string"
  261. },
  262. "monthlySearchVolume": {
  263. "type": "integer"
  264. },
  265. "trendDirection": {
  266. "type": "string"
  267. },
  268. "growthRate": {
  269. "type": "number"
  270. }
  271. }
  272. },
  273. "calibrationTable": {
  274. "type": "string",
  275. "description": "品类认知校准表(Markdown格式)"
  276. },
  277. "riskAlerts": {
  278. "type": "array",
  279. "items": {
  280. "type": "object",
  281. "properties": {
  282. "level": {
  283. "type": "string",
  284. "enum": [
  285. "high",
  286. "medium",
  287. "low"
  288. ]
  289. },
  290. "title": {
  291. "type": "string"
  292. },
  293. "description": {
  294. "type": "string"
  295. }
  296. }
  297. }
  298. },
  299. "priorityActions": {
  300. "type": "array",
  301. "items": {
  302. "type": "object",
  303. "properties": {
  304. "action": {
  305. "type": "string"
  306. },
  307. "priority": {
  308. "type": "integer"
  309. },
  310. "trigger": {
  311. "type": "string"
  312. }
  313. }
  314. }
  315. }
  316. }
  317. },
  318. "timeout": 300000,
  319. "retry": {
  320. "maxAttempts": 2,
  321. "delay": 2000,
  322. "backoffMultiplier": 2
  323. },
  324. "tokenConfig": {
  325. "type": "bearer",
  326. "configFile": "~/.openclaw/voc-credentials.json",
  327. "tokenField": "vocToken",
  328. "resolutionOrder": [
  329. "configFile"
  330. ],
  331. "apigId": "7HwdQZk55B",
  332. "paymentUrlResolution": {
  333. "description": "动态构建充值URL:在已存在 session token 时查出用户 objectId,拼接到专属充值页面",
  334. "steps": [
  335. "1. 从 voc-credentials.json 获取当前 session token",
  336. "2. 调用 GET https://server.fmode.cn/parse/users/me (Header: X-Parse-Application-Id: ncloudmaster, X-Parse-Session-Token: {token})获取用户 objectId",
  337. "3. 拼接充值URL: https://app.fmode.cn/dev/apig-pay/?user={objectId}&apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  338. "4. 将该URL展示给用户,引导扫码支付"
  339. ],
  340. "userResolveEndpoint": "https://server.fmode.cn/parse/users/me",
  341. "userResolveHeaders": {
  342. "X-Parse-Application-Id": "ncloudmaster",
  343. "X-Parse-Session-Token": "{vocToken}"
  344. },
  345. "paymentBaseUrl": "https://app.fmode.cn/dev/apig-pay/",
  346. "paymentParams": {
  347. "user": "{resolvedUserId}",
  348. "apigid": "7HwdQZk55B",
  349. "fun_id": "HOkkX72PMF"
  350. },
  351. "balanceCheckEndpoint": "https://server.fmode.cn/api/apig/getApig"
  352. },
  353. "onMissing": {
  354. "action": "showPaymentQR",
  355. "qrCodeUrl": "https://app.fmode.cn/dev/apig-pay/?apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  356. "title": "扫码开通 VOC-AI 数据服务",
  357. "message": "此 Skill 需要有效的 API Token。请先打开充值页面完成登录和充值;当用户提供 session token 后,请由 OpenClaw 运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json 的 vocToken 字段,再重试当前 Skill。",
  358. "tokenSetupCommandTemplate": "node scripts/tools/set-voc-token.js {sessionToken}",
  359. "tokenSetupInstructions": "当用户完成登录和充值后,如果用户把 session token 发给你,请直接运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json,然后重试当前 Skill。"
  360. },
  361. "onBalanceInsufficient": {
  362. "action": "resolveUserThenShowPayment",
  363. "title": "VOC-AI Token 余额不足,请扫码充值",
  364. "message": "当前 Token 余额不足,我将为你生成专属充值链接,扫码支付后即可继续使用。"
  365. }
  366. },
  367. "errorHandling": {
  368. "balanceInsufficient": {
  369. "conditions": [
  370. {
  371. "responseField": "code",
  372. "operator": "in",
  373. "value": [
  374. -2,
  375. -3,
  376. -10,
  377. 402,
  378. 429
  379. ]
  380. },
  381. {
  382. "responseField": "msg",
  383. "operator": "contains",
  384. "value": [
  385. "余额不足",
  386. "insufficient",
  387. "balance",
  388. "quota",
  389. "没有开通",
  390. "权限或余额"
  391. ]
  392. },
  393. {
  394. "responseField": "mess",
  395. "operator": "contains",
  396. "value": [
  397. "余额不足",
  398. "insufficient",
  399. "balance",
  400. "quota",
  401. "没有开通",
  402. "权限或余额"
  403. ]
  404. },
  405. {
  406. "responseField": "message",
  407. "operator": "contains",
  408. "value": [
  409. "余额不足",
  410. "insufficient",
  411. "balance",
  412. "没有开通",
  413. "权限或余额"
  414. ]
  415. }
  416. ],
  417. "matchMode": "any",
  418. "trigger": "tokenConfig.onBalanceInsufficient"
  419. },
  420. "unauthorized": {
  421. "conditions": [
  422. {
  423. "responseField": "code",
  424. "operator": "in",
  425. "value": [
  426. 401,
  427. 403
  428. ]
  429. },
  430. {
  431. "responseField": "msg",
  432. "operator": "contains",
  433. "value": [
  434. "unauthorized",
  435. "token",
  436. "invalid",
  437. "auth"
  438. ]
  439. }
  440. ],
  441. "matchMode": "any",
  442. "trigger": "tokenConfig.onMissing"
  443. }
  444. }
  445. }