api-config.json 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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": { "type": "string" },
  12. "required": true,
  13. "description": "品类核心关键词列表"
  14. },
  15. "domain": {
  16. "type": "integer",
  17. "required": false,
  18. "default": 1,
  19. "description": "Amazon站点(1=美国)"
  20. },
  21. "topN": {
  22. "type": "integer",
  23. "required": false,
  24. "default": 100,
  25. "description": "分析的产品数量"
  26. }
  27. },
  28. "pipeline": [
  29. {
  30. "step": 1,
  31. "name": "搜索品类Top N产品",
  32. "forEach": "keywords",
  33. "api": {
  34. "service": "SorftimeApiService.searchProductsByQuery",
  35. "endpoint": "/api/ProductQuery",
  36. "method": "POST",
  37. "forwardUrl": "https://server.fmode.cn/api/voc-ecom/forward",
  38. "headers": { "Authorization": "Bearer {{vocToken}}" },
  39. "requestBody": { "Page": 1, "Query": "1", "QueryType": "7", "Pattern": "${keyword}" },
  40. "queryParams": { "domain": "${domain}" }
  41. },
  42. "output": "searchResults",
  43. "responseExtract": "Array<{ Asin, Title, Price, Rating, RatingsCount, MonthlySales, Brand, BSR, Photo }>"
  44. },
  45. {
  46. "step": 2,
  47. "name": "批量获取销量数据",
  48. "forEach": "searchResults[].Asin (去重)",
  49. "api": {
  50. "service": "SorftimeApiService.getAsinSalesVolume",
  51. "endpoint": "/api/AsinSalesVolume",
  52. "method": "POST",
  53. "requestBody": { "ASIN": "${asin}" },
  54. "queryParams": { "domain": "${domain}" }
  55. },
  56. "output": "salesData"
  57. },
  58. {
  59. "step": 3,
  60. "name": "定位品类类目",
  61. "api": {
  62. "service": "SorftimeApiService.getCategoryTree",
  63. "endpoint": "/api/CategoryTree",
  64. "method": "POST",
  65. "requestBody": { "keyword": "${keywords[0]}" },
  66. "queryParams": { "domain": "${domain}" }
  67. },
  68. "output": "categoryTree"
  69. },
  70. {
  71. "step": 4,
  72. "name": "获取核心关键词搜索量和竞争度",
  73. "forEach": "keywords",
  74. "api": {
  75. "service": "SorftimeApiService.searchKeywords",
  76. "endpoint": "/api/KeywordQuery",
  77. "method": "POST",
  78. "requestBody": { "Keyword": "${keyword}" },
  79. "queryParams": { "domain": "${domain}" }
  80. },
  81. "output": "keywordData"
  82. },
  83. {
  84. "step": 5,
  85. "name": "获取关键词趋势",
  86. "forEach": "keywords",
  87. "api": {
  88. "service": "SorftimeApiService.getKeywordTrend",
  89. "endpoint": "/api/KeywordSearchTrend",
  90. "method": "POST",
  91. "requestBody": { "Keyword": "${keyword}" },
  92. "queryParams": { "domain": "${domain}" }
  93. },
  94. "output": "keywordTrend"
  95. },
  96. {
  97. "step": 6,
  98. "name": "市场集中度+价格带+增长判断计算",
  99. "type": "compute",
  100. "logic": "analyzeMarket(searchResults, salesData, keywordData, keywordTrend)",
  101. "algorithm": {
  102. "cr5": "前5品牌销售额占品类总销售额的比例",
  103. "cr10": "前10品牌销售额占比",
  104. "hhi": "赫芬达尔-赫希曼指数(各品牌市场份额平方和 × 10000)",
  105. "marketSize": "品类月销量总和、月销售额总和",
  106. "priceBands": "按价格区间统计产品数量和销量占比",
  107. "brandConcentration": "Top 10 品牌的市场份额",
  108. "ratingDistribution": "品类整体评分水平",
  109. "growthStage": "基于搜索趋势判断品类处于增长/成熟/衰退期"
  110. },
  111. "output": "marketAnalysis"
  112. },
  113. {
  114. "step": 7,
  115. "name": "风险预警汇总",
  116. "type": "compute",
  117. "logic": "generateRiskAlerts(marketAnalysis)",
  118. "algorithm": {
  119. "brandConcentrationRisk": "品牌集中度风险",
  120. "lowSalesRisk": "低销量风险",
  121. "ratingRisk": "评分风险",
  122. "priceWarRisk": "价格战风险",
  123. "inventoryRisk": "库存风险",
  124. "complianceRisk": "合规风险",
  125. "levelLabels": "每项风险标注级别(high/medium/low)和具体描述"
  126. },
  127. "output": "riskAlerts"
  128. },
  129. {
  130. "step": 8,
  131. "name": "优先行动清单",
  132. "type": "compute",
  133. "logic": "generatePriorityActions(marketAnalysis, riskAlerts)",
  134. "algorithm": {
  135. "triggers": "条件触发式优先级: Listing优化→SKU聚焦→促销→产品迭代→库存→差异化"
  136. },
  137. "output": "priorityActions"
  138. }
  139. ],
  140. "response": {
  141. "type": "object",
  142. "properties": {
  143. "marketOverview": {
  144. "type": "object",
  145. "properties": {
  146. "totalProducts": { "type": "integer" },
  147. "totalMonthlySales": { "type": "integer" },
  148. "totalMonthlyRevenue": { "type": "number" },
  149. "avgPrice": { "type": "number" },
  150. "medianPrice": { "type": "number" },
  151. "avgRating": { "type": "number" },
  152. "categoryStage": { "type": "string" }
  153. }
  154. },
  155. "concentration": {
  156. "type": "object",
  157. "properties": {
  158. "cr5": { "type": "number" },
  159. "cr10": { "type": "number" },
  160. "hhi": { "type": "integer" },
  161. "interpretation": { "type": "string" }
  162. }
  163. },
  164. "topBrands": {
  165. "type": "array",
  166. "items": {
  167. "type": "object",
  168. "properties": {
  169. "brand": { "type": "string" },
  170. "marketShare": { "type": "number" },
  171. "productCount": { "type": "integer" },
  172. "avgPrice": { "type": "number" },
  173. "avgRating": { "type": "number" }
  174. }
  175. }
  176. },
  177. "priceBands": {
  178. "type": "array",
  179. "items": {
  180. "type": "object",
  181. "properties": {
  182. "range": { "type": "string" },
  183. "productCount": { "type": "integer" },
  184. "salesShare": { "type": "number" },
  185. "avgRating": { "type": "number" }
  186. }
  187. }
  188. },
  189. "searchTrend": {
  190. "type": "object",
  191. "properties": {
  192. "mainKeyword": { "type": "string" },
  193. "monthlySearchVolume": { "type": "integer" },
  194. "trendDirection": { "type": "string" },
  195. "growthRate": { "type": "number" }
  196. }
  197. },
  198. "calibrationTable": { "type": "string", "description": "品类认知校准表(Markdown格式)" },
  199. "riskAlerts": {
  200. "type": "array",
  201. "items": {
  202. "type": "object",
  203. "properties": {
  204. "level": { "type": "string", "enum": ["high", "medium", "low"] },
  205. "title": { "type": "string" },
  206. "description": { "type": "string" }
  207. }
  208. }
  209. },
  210. "priorityActions": {
  211. "type": "array",
  212. "items": {
  213. "type": "object",
  214. "properties": {
  215. "action": { "type": "string" },
  216. "priority": { "type": "integer" },
  217. "trigger": { "type": "string" }
  218. }
  219. }
  220. }
  221. }
  222. },
  223. "timeout": 300000,
  224. "retry": {
  225. "maxAttempts": 2,
  226. "delay": 2000,
  227. "backoffMultiplier": 2
  228. },
  229. "tokenConfig": {
  230. "type": "bearer",
  231. "configFile": "~/.openclaw/voc-credentials.json",
  232. "tokenField": "vocToken",
  233. "currentToken": "r:858b3ee92314d5447d1fc3cdc10462d7",
  234. "resolutionOrder": ["configFile", "currentToken"],
  235. "onMissing": {
  236. "action": "showPaymentQR",
  237. "qrCodeUrl": "https://payment.brainhack.cn/apig-pay.html?authid=T0iOotHcDX",
  238. "paymentCheckEndpoint": "https://server.fmode.cn/api/apig/getApig",
  239. "pollingIntervalMs": 3000,
  240. "pollingTimeoutMs": 300000,
  241. "onPaymentSuccess": "retrySkillWithNewToken",
  242. "title": "扫码开通 VOC-AI 数据服务",
  243. "message": "请扫描下方二维码完成支付,支付成功后将自动获取 Token 并继续执行。"
  244. },
  245. "onBalanceInsufficient": {
  246. "action": "showPaymentQR",
  247. "qrCodeUrl": "https://payment.brainhack.cn/apig-pay.html?authid=T0iOotHcDX",
  248. "paymentCheckEndpoint": "https://server.fmode.cn/api/apig/getApig",
  249. "pollingIntervalMs": 3000,
  250. "pollingTimeoutMs": 300000,
  251. "onPaymentSuccess": "retrySkillWithNewToken",
  252. "title": "VOC-AI Token 余额不足,请扫码充值",
  253. "message": "当前 Token 余额不足,请扫描二维码充值,支付完成后将自动继续执行。"
  254. }
  255. },
  256. "errorHandling": {
  257. "balanceInsufficient": {
  258. "conditions": [
  259. { "responseField": "code", "operator": "in", "value": [-2, -3, -10, 402, 429] },
  260. { "responseField": "msg", "operator": "contains", "value": ["余额不足", "insufficient", "balance", "quota"] },
  261. { "responseField": "message", "operator": "contains", "value": ["余额不足", "insufficient", "balance"] }
  262. ],
  263. "matchMode": "any",
  264. "trigger": "tokenConfig.onBalanceInsufficient"
  265. },
  266. "unauthorized": {
  267. "conditions": [
  268. { "responseField": "code", "operator": "in", "value": [401, 403] },
  269. { "responseField": "msg", "operator": "contains", "value": ["unauthorized", "token", "invalid", "auth"] }
  270. ],
  271. "matchMode": "any",
  272. "trigger": "tokenConfig.onMissing"
  273. }
  274. }
  275. }