@whyshu/argent-engine 0.8.0-rc.9 → 0.13.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/MANIFEST.json +102 -40
  2. package/bin/runtime-install.mjs +92 -0
  3. package/engine/VERSION +1 -1
  4. package/engine/configs/billing-actions.json +30 -0
  5. package/engine/configs/mcp-tools.snapshot.json +47 -0
  6. package/engine/core/contracts/argent.contracts.json +2 -2
  7. package/engine/core/lib/account-token.mjs +37 -0
  8. package/engine/core/lib/redact.mjs +34 -0
  9. package/engine/core/mcp/billing-upload.mjs +77 -0
  10. package/engine/core/mcp/erp-server.mjs +300 -0
  11. package/engine/core/mcp/gateway.mjs +333 -0
  12. package/engine/core/mcp/meter.mjs +101 -0
  13. package/engine/core/mcp/server.mjs +245 -0
  14. package/engine/core/mcp/vault.mjs +78 -0
  15. package/engine/scripts/appointment-worker.mjs +456 -35
  16. package/engine/scripts/appointment_grab.py +1389 -264
  17. package/engine/scripts/appointment_rules.py +118 -0
  18. package/engine/scripts/argent-timers.mjs +227 -0
  19. package/engine/scripts/argent-web-preflight.mjs +123 -0
  20. package/engine/scripts/argent-web-verify.mjs +105 -0
  21. package/engine/scripts/billing-upload.mjs +26 -0
  22. package/engine/scripts/build-engine-package.mjs +7 -1
  23. package/engine/scripts/capability-packs.lock.json +323 -300
  24. package/engine/scripts/check-version-consistency.mjs +14 -1
  25. package/engine/scripts/collect-intel.mjs +108 -0
  26. package/engine/scripts/daily-report-timer-plist.sh +18 -4
  27. package/engine/scripts/daily-report-timers.sh +36 -3
  28. package/engine/scripts/daily-report.mjs +78 -2
  29. package/engine/scripts/dsh-web-doctor.mjs +84 -0
  30. package/engine/scripts/engine-manifest.mjs +90 -0
  31. package/engine/scripts/engine-runtime-install.mjs +92 -0
  32. package/engine/scripts/erp-ui-install.mjs +127 -0
  33. package/engine/scripts/erp-ui-preflight.mjs +104 -0
  34. package/engine/scripts/erp-ui-verify.mjs +135 -0
  35. package/engine/scripts/flow-requirements.json +122 -99
  36. package/engine/scripts/full-exec-worker.mjs +251 -0
  37. package/engine/scripts/gen-preset-rows.mjs +1 -1
  38. package/engine/scripts/invoice_lip_runner.py +1 -0
  39. package/engine/scripts/invoice_runner.py +17 -6
  40. package/engine/scripts/invoice_stageb.py +21 -4
  41. package/engine/scripts/lib/bootcheck-wiring.mjs +7 -5
  42. package/engine/scripts/lib/intel-card.mjs +43 -0
  43. package/engine/scripts/lib/invoice_names.py +23 -0
  44. package/engine/scripts/lib/ml-ads-core.mjs +100 -18
  45. package/engine/scripts/lib/ml-ads-rules.mjs +275 -0
  46. package/engine/scripts/lib/ml-bridge-auth.mjs +50 -0
  47. package/engine/scripts/lib/ml-category-core.mjs +120 -0
  48. package/engine/scripts/lib/ml-insight-core.mjs +621 -0
  49. package/engine/scripts/lib/ml-insight-facts.mjs +424 -0
  50. package/engine/scripts/lib/ml-items.mjs +40 -0
  51. package/engine/scripts/lib/ml-listing-core.mjs +342 -0
  52. package/engine/scripts/lib/ml-market-core.mjs +774 -0
  53. package/engine/scripts/lib/plugin-packages.mjs +13 -0
  54. package/engine/scripts/lib/webdriver_ipc.py +61 -1
  55. package/engine/scripts/line_pack.py +196 -0
  56. package/engine/scripts/mcp-gateway-switch.mjs +100 -0
  57. package/engine/scripts/migrate-providers.mjs +3 -3
  58. package/engine/scripts/ml-ads-advice.mjs +140 -0
  59. package/engine/scripts/ml-ads.mjs +40 -0
  60. package/engine/scripts/ml-category-baseline.mjs +174 -0
  61. package/engine/scripts/ml-insight-diagnose.mjs +247 -0
  62. package/engine/scripts/ml-insight-run.sh +183 -0
  63. package/engine/scripts/ml-insight-timers.sh +224 -0
  64. package/engine/scripts/ml-listing-audit.mjs +170 -0
  65. package/engine/scripts/ml-market-matrix.mjs +84 -0
  66. package/engine/scripts/ml-market-snapshot.mjs +261 -0
  67. package/engine/scripts/ml-messages.mjs +145 -0
  68. package/engine/scripts/npm-publish-argent.mjs +14 -0
  69. package/engine/scripts/ops-codefix-pr.mjs +87 -0
  70. package/engine/scripts/ops-codefix-queue.mjs +30 -0
  71. package/engine/scripts/ops-digest.mjs +98 -0
  72. package/engine/scripts/ops-verify.mjs +67 -0
  73. package/engine/scripts/orchestrator.py +410 -20
  74. package/engine/scripts/orchestrator_br.py +146 -4
  75. package/engine/scripts/plugin-bootcheck.mjs +50 -1
  76. package/engine/scripts/publish-engine.mjs +111 -0
  77. package/engine/scripts/restart-dsh-with-tunnel.sh +129 -0
  78. package/engine/scripts/skuflow_invoice_runner.py +43 -3
  79. package/engine/scripts/v0.9-acceptance.mjs +107 -0
  80. package/engine/scripts/vertical-lint.mjs +12 -1
  81. package/engine/scripts/web-switch.mjs +121 -0
  82. package/engine/scripts/wenyao_fill_template.py +52 -15
  83. package/engine/scripts/wenyao_run.py +2 -1
  84. package/engine/skills/README.md +3 -3
  85. package/engine/skills/bilibili-upload/SKILL.md +109 -0
  86. package/engine/skills/douyin-upload/SKILL.md +74 -0
  87. package/engine/skills/internal.json +28 -0
  88. package/engine/skills/kuaishou-upload/SKILL.md +109 -0
  89. package/engine/skills/ml-appointment-safety/SKILL.md +42 -0
  90. package/engine/skills/ml-full-appointment/SKILL.md +23 -0
  91. package/engine/skills/ml-invoice/SKILL.md +2 -2
  92. package/engine/skills/ml-invoice/references/template-fill-contract.md +1 -1
  93. package/engine/skills/ml-label-recovery/SKILL.md +43 -0
  94. package/engine/skills/ml-listing-audit/SKILL.md +66 -0
  95. package/engine/skills/ml-store-daily-report/SKILL.md +68 -0
  96. package/engine/skills/ml-store-daily-report/scripts/generate.js +35 -0
  97. package/engine/skills/ml-store-insight/SKILL.md +81 -0
  98. package/engine/skills/tencent-upload/SKILL.md +60 -0
  99. package/engine/skills/weibo-upload/SKILL.md +106 -0
  100. package/engine/skills/whyshu-social-ops/SKILL.md +136 -0
  101. package/engine/skills/xiaohongshu-upload/SKILL.md +122 -0
  102. package/engine/version.mjs +1 -1
  103. package/engine/verticals/README.md +7 -0
  104. package/engine/verticals/_engine-words.baseline.txt +27 -59
  105. package/engine/verticals/mercadolibre/manifest.json +132 -6
  106. package/package.json +5 -1
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 运维层验收脚本(问述内部):心跳新鲜度 / 版本 / 任务数 vs 标签页 / incident。
4
+ * 用法:node scripts/ops-verify.mjs [--min-version 0.12.5] [--max-heartbeat-age 180]
5
+ * 退出码:0 全部通过;1 有失败项(输出逐项结果)。
6
+ */
7
+ import { readFileSync } from 'node:fs'
8
+ import { homedir } from 'node:os'
9
+ import { join } from 'node:path'
10
+
11
+ const BASE = process.env.OPS_BASE || 'https://whyshu.com'
12
+ const args = process.argv.slice(2)
13
+ const opt = (n, d) => { const i = args.indexOf(`--${n}`); return i >= 0 ? args[i + 1] : d }
14
+ const MIN_VERSION = opt('min-version', '')
15
+ const ONLY_MACHINE = opt('machine', '')
16
+ const MAX_AGE = Number(opt('max-heartbeat-age', '180'))
17
+
18
+ function token() {
19
+ if (process.env.OPS_TOKEN) return process.env.OPS_TOKEN
20
+ try {
21
+ const raw = readFileSync(join(homedir(), '.dsh', 'argent', 'ops-token.env'), 'utf8')
22
+ const m = raw.match(/^OPS_TOKEN=(.+)$/m)
23
+ return m ? m[1].trim() : ''
24
+ } catch { return '' }
25
+ }
26
+ async function get(path) {
27
+ const res = await fetch(`${BASE}${path}`, { headers: { 'x-ops-token': token() }, signal: AbortSignal.timeout(15000) })
28
+ const j = await res.json().catch(() => ({}))
29
+ if (!res.ok) throw new Error(j?.error?.message || `HTTP ${res.status}`)
30
+ return j.data ?? j
31
+ }
32
+ const cmp = (a, b) => {
33
+ const pa = String(a || '').split('.').map(Number), pb = String(b || '').split('.').map(Number)
34
+ for (let i = 0; i < Math.max(pa.length, pb.length); i += 1) {
35
+ const x = pa[i] || 0, y = pb[i] || 0
36
+ if (x !== y) return x > y ? 1 : -1
37
+ }
38
+ return 0
39
+ }
40
+
41
+ const checks = []
42
+ const ok = (name, cond, detail = '') => checks.push({ name, ok: Boolean(cond), detail })
43
+ try {
44
+ const [overview, incs] = await Promise.all([get('/api/ops/v1/internal/overview'), get('/api/ops/v1/internal/incidents?status=open&limit=200')])
45
+ const allMachines = overview.machines || []
46
+ const machines = ONLY_MACHINE ? allMachines.filter((m) => String(m.machineId) === ONLY_MACHINE) : allMachines
47
+ ok('存在客户机心跳', machines.length > 0, `machines=${machines.length}`)
48
+ for (const m of machines) {
49
+ const ageMin = m.at ? Math.round((Date.now() - new Date(m.at).getTime()) / 60000) : null
50
+ ok(`心跳新鲜:${m.machineId}`, ageMin != null && ageMin <= MAX_AGE, `age=${ageMin}min`)
51
+ if (MIN_VERSION) ok(`插件版本:${m.machineId} >= ${MIN_VERSION}`, cmp(m.pluginVersion, MIN_VERSION) >= 0, `plugin=${m.pluginVersion}`)
52
+ for (const s of m.storeDetail || []) {
53
+ if (Number(s.claimed) > Number(s.appointmentTabs)) ok(`任务数<=标签页:${s.store}`, false, `claimed=${s.claimed} tabs=${s.appointmentTabs}`)
54
+ else ok(`任务数<=标签页:${s.store}`, true, `claimed=${s.claimed} tabs=${s.appointmentTabs}`)
55
+ ok(`窗口可连:${s.store}`, Boolean(s.cdpPort) || Number(s.claimed) === 0, `port=${s.cdpPort || 0}`)
56
+ }
57
+ }
58
+ const critical = (incs.incidents || []).filter((x) => x.level === 'critical')
59
+ ok('无 critical incident', critical.length === 0, critical.map((x) => `${x.rule}@${x.machineId}/${x.store || '-'}`).join('; '))
60
+ } catch (e) {
61
+ ok('拉取运维数据', false, e.message)
62
+ }
63
+
64
+ const failed = checks.filter((c) => !c.ok)
65
+ for (const c of checks) console.log(`${c.ok ? '✅' : '❌'} ${c.name}${c.detail ? `(${c.detail})` : ''}`)
66
+ console.log(`\n${failed.length ? `❌ ${failed.length} 项未通过` : '✅ 全部通过'}`)
67
+ process.exit(failed.length ? 1 : 0)