@whyshu/argent-engine 0.0.0-stage → 0.6.0
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.
- package/MANIFEST.json +307 -0
- package/engine/VERSION +1 -0
- package/engine/agents/catalog.json +454 -0
- package/engine/configs/_aliases.proposed.json +651 -0
- package/engine/configs/_migration-plan.proposed.json +899 -0
- package/engine/configs/account.json +272 -0
- package/engine/configs/advanced.json +205 -0
- package/engine/configs/host.json +149 -0
- package/engine/configs/hr.json +27 -0
- package/engine/configs/notify.json +264 -0
- package/engine/core/cli/argent.mjs +277 -0
- package/engine/core/contracts/argent.contracts.json +1065 -0
- package/engine/core/contracts/verbs.schema.json +2539 -0
- package/engine/core/lib/argent-datadir.mjs +223 -0
- package/engine/core/lib/audit.mjs +187 -0
- package/engine/core/lib/claim.mjs +258 -0
- package/engine/core/lib/config-catalog.mjs +1172 -0
- package/engine/core/lib/doctor-customer.mjs +577 -0
- package/engine/core/lib/flow-list.mjs +138 -0
- package/engine/core/lib/flow-registry.mjs +48 -0
- package/engine/core/lib/init.mjs +247 -0
- package/engine/core/lib/ledger.mjs +124 -0
- package/engine/core/lib/license-activate.mjs +813 -0
- package/engine/core/lib/license-device.mjs +314 -0
- package/engine/core/lib/license-file.mjs +349 -0
- package/engine/core/lib/license-guard.mjs +123 -0
- package/engine/core/lib/license-ops.mjs +1645 -0
- package/engine/core/lib/license-verdict.mjs +133 -0
- package/engine/core/lib/license.mjs +577 -0
- package/engine/core/lib/notify/dedup.mjs +101 -0
- package/engine/core/lib/notify/feishu.mjs +38 -0
- package/engine/core/lib/notify/index.mjs +95 -0
- package/engine/core/lib/notify/verb.mjs +327 -0
- package/engine/core/lib/notify/webhook.mjs +135 -0
- package/engine/core/lib/notify/wecom.mjs +36 -0
- package/engine/core/lib/python.mjs +145 -0
- package/engine/core/lib/sop.mjs +116 -0
- package/engine/core/lib/versions.mjs +205 -0
- package/engine/core/mcp/client.mjs +67 -0
- package/engine/core/mcp/http.mjs +138 -0
- package/engine/core/mcp/server.mjs +702 -0
- package/engine/scripts/_engine_rules_probe.py +15 -0
- package/engine/scripts/analyze-full-day.py +568 -0
- package/engine/scripts/archive/feishu-bridge.js +246 -0
- package/engine/scripts/argent-agents.mjs +527 -0
- package/engine/scripts/argent-capabilities.mjs +776 -0
- package/engine/scripts/argent-catalog.mjs +186 -0
- package/engine/scripts/argent-datadir.py +62 -0
- package/engine/scripts/argent-doctor.mjs +624 -0
- package/engine/scripts/argent-env-write.mjs +302 -0
- package/engine/scripts/argent-schedule.mjs +620 -0
- package/engine/scripts/argent-setup-check.mjs +369 -0
- package/engine/scripts/argent-upgrade.mjs +1046 -0
- package/engine/scripts/base-bootstrap.sh +575 -0
- package/engine/scripts/billing-mode-daily.sh +12 -0
- package/engine/scripts/build-engine-package.mjs +123 -0
- package/engine/scripts/capability-packs.lock.json +484 -0
- package/engine/scripts/capability_pack.py +1242 -0
- package/engine/scripts/check-1.0-criteria.mjs +355 -0
- package/engine/scripts/check-agent-catalog.mjs +141 -0
- package/engine/scripts/check-billing-mode.sh +377 -0
- package/engine/scripts/check-child-sessions.mjs +83 -0
- package/engine/scripts/check-config-catalog.mjs +677 -0
- package/engine/scripts/check-docs-drift.mjs +522 -0
- package/engine/scripts/check-dsh-web-expose.sh +98 -0
- package/engine/scripts/check-judgment-drift.mjs +403 -0
- package/engine/scripts/check-license.mjs +199 -0
- package/engine/scripts/check-model-auth.py +443 -0
- package/engine/scripts/check-pack-closure.mjs +661 -0
- package/engine/scripts/check-portable-symbols.mjs +116 -0
- package/engine/scripts/check-preset-landing.mjs +124 -0
- package/engine/scripts/check-production-home.mjs +602 -0
- package/engine/scripts/check-role-mapping.mjs +461 -0
- package/engine/scripts/check-sample-redaction.mjs +320 -0
- package/engine/scripts/check-skill-classification.mjs +188 -0
- package/engine/scripts/check-sop-consistency.mjs +431 -0
- package/engine/scripts/check-test-env-safety.mjs +627 -0
- package/engine/scripts/check-version-consistency.mjs +452 -0
- package/engine/scripts/ci-run.sh +558 -0
- package/engine/scripts/config-explain.mjs +278 -0
- package/engine/scripts/configure-provider.rb +29 -0
- package/engine/scripts/customer-config-migrate.mjs +179 -0
- package/engine/scripts/customer-preflight.py +892 -0
- package/engine/scripts/customer-readiness.sh +134 -0
- package/engine/scripts/daily-report-inbox.py +242 -0
- package/engine/scripts/daily-report-reconcile.mjs +312 -0
- package/engine/scripts/daily-report.mjs +1310 -0
- package/engine/scripts/daily-report.sh +46 -0
- package/engine/scripts/data/lip-product-dict.json +306 -0
- package/engine/scripts/deliver-customer.mjs +932 -0
- package/engine/scripts/delivery-faces.txt +31 -0
- package/engine/scripts/desktop-trial.sh +146 -0
- package/engine/scripts/dev-window.sh +260 -0
- package/engine/scripts/drill-clean-machine.sh +315 -0
- package/engine/scripts/dsh-api-client.mjs +215 -0
- package/engine/scripts/dsh-backup-scope.sh +83 -0
- package/engine/scripts/dsh-offline-pack.mjs +77 -0
- package/engine/scripts/dsh-overlay-pin.sh +87 -0
- package/engine/scripts/dsh-plane.mjs +153 -0
- package/engine/scripts/dsh-portforward.py +223 -0
- package/engine/scripts/dsh-preflight.mjs +179 -0
- package/engine/scripts/dsh-release-watch-daily.sh +19 -0
- package/engine/scripts/dsh-release-watch.mjs +458 -0
- package/engine/scripts/dsh-remote-check.sh +99 -0
- package/engine/scripts/dsh-restart.sh +179 -0
- package/engine/scripts/dsh-restore.sh +111 -0
- package/engine/scripts/dsh-scope-rewire.mjs +803 -0
- package/engine/scripts/dsh-snapshot.mjs +116 -0
- package/engine/scripts/dsh-upgrade-readiness.mjs +165 -0
- package/engine/scripts/dsh-upgrade.mjs +612 -0
- package/engine/scripts/dsh-url.sh +86 -0
- package/engine/scripts/dsh-web-launch.mjs +155 -0
- package/engine/scripts/ensure-store-windows.py +509 -0
- package/engine/scripts/entitlements.py +458 -0
- package/engine/scripts/env_probe.py +411 -0
- package/engine/scripts/feishu-card.mjs +252 -0
- package/engine/scripts/fix-skill-frontmatter.py +209 -0
- package/engine/scripts/flow-auto-retry.py +454 -0
- package/engine/scripts/flow-requirements.json +720 -0
- package/engine/scripts/flow-scaffold.py +275 -0
- package/engine/scripts/flow-timers-plist.sh +86 -0
- package/engine/scripts/flow-timers.sh +182 -0
- package/engine/scripts/flow-trigger-wake.mjs +284 -0
- package/engine/scripts/flow-trigger.sh +571 -0
- package/engine/scripts/flow_billing.py +354 -0
- package/engine/scripts/flow_capability_stats.py +314 -0
- package/engine/scripts/flow_case.py +194 -0
- package/engine/scripts/flow_claim.py +497 -0
- package/engine/scripts/flow_config.py +1024 -0
- package/engine/scripts/flow_failure.py +588 -0
- package/engine/scripts/flow_learn.py +105 -0
- package/engine/scripts/flow_ledger.py +235 -0
- package/engine/scripts/flow_policy.py +238 -0
- package/engine/scripts/flow_preflight.py +339 -0
- package/engine/scripts/flow_registry.py +341 -0
- package/engine/scripts/flow_retry.py +304 -0
- package/engine/scripts/flow_return_to_ops.py +191 -0
- package/engine/scripts/flow_source.py +315 -0
- package/engine/scripts/flow_sources/__init__.py +53 -0
- package/engine/scripts/flow_sources/cases_json.py +106 -0
- package/engine/scripts/flow_sources/common.py +428 -0
- package/engine/scripts/flow_sources/feishu_base.py +273 -0
- package/engine/scripts/flow_stale.py +185 -0
- package/engine/scripts/flow_status_reconcile.py +344 -0
- package/engine/scripts/flow_triage.py +849 -0
- package/engine/scripts/flow_write_verify.py +496 -0
- package/engine/scripts/fulfillment.js +586 -0
- package/engine/scripts/gen-agent-bundles.mjs +276 -0
- package/engine/scripts/gen-preset-rows.mjs +259 -0
- package/engine/scripts/init-ml.sh +2275 -0
- package/engine/scripts/install-internal-role.sh +190 -0
- package/engine/scripts/install-license.mjs +641 -0
- package/engine/scripts/install-one-shot.mjs +665 -0
- package/engine/scripts/integration_contract.py +220 -0
- package/engine/scripts/integrations/wenyao/adapter.py +98 -0
- package/engine/scripts/integrations/xzh/adapter.py +75 -0
- package/engine/scripts/invoice-mapping.example.json +40 -0
- package/engine/scripts/invoice-table.sh +194 -0
- package/engine/scripts/invoice_carrier_notice.py +279 -0
- package/engine/scripts/invoice_fail_closeout.py +297 -0
- package/engine/scripts/invoice_lip_runner.py +1508 -0
- package/engine/scripts/invoice_lip_runner.py.bak-20260922-1710-freready +1090 -0
- package/engine/scripts/invoice_ready_audit.py +191 -0
- package/engine/scripts/invoice_runner.py +675 -0
- package/engine/scripts/invoice_stageb.py +516 -0
- package/engine/scripts/launchd/com.whyshu.argent-bridge.plist.example +42 -0
- package/engine/scripts/launchd/com.whyshu.fulfillment-poll.plist.example +29 -0
- package/engine/scripts/lease.py +377 -0
- package/engine/scripts/lib/agent-install.mjs +649 -0
- package/engine/scripts/lib/argent-datadir.mjs +16 -0
- package/engine/scripts/lib/argent_datadir.py +262 -0
- package/engine/scripts/lib/argent_filelock.py +507 -0
- package/engine/scripts/lib/bootcheck-wiring.mjs +510 -0
- package/engine/scripts/lib/cdp_ports.py +197 -0
- package/engine/scripts/lib/customer-env.mjs +102 -0
- package/engine/scripts/lib/daily-report-core.mjs +517 -0
- package/engine/scripts/lib/dep-declaration.mjs +81 -0
- package/engine/scripts/lib/deps-migrate.mjs +310 -0
- package/engine/scripts/lib/dsh-host-resolve.mjs +109 -0
- package/engine/scripts/lib/dsh-scope.mjs +500 -0
- package/engine/scripts/lib/dsh-snapshot-path.mjs +35 -0
- package/engine/scripts/lib/dsh-versions.mjs +96 -0
- package/engine/scripts/lib/dsh-web-probe.mjs +214 -0
- package/engine/scripts/lib/is-direct-run.mjs +61 -0
- package/engine/scripts/lib/patch-compose.mjs +241 -0
- package/engine/scripts/lib/patch-target.mjs +35 -0
- package/engine/scripts/lib/plugin-lifecycle.mjs +128 -0
- package/engine/scripts/lib/plugin-packages.mjs +332 -0
- package/engine/scripts/lib/preset-compat.mjs +127 -0
- package/engine/scripts/lib/preset-install.mjs +575 -0
- package/engine/scripts/lib/preset-mechanism.mjs +56 -0
- package/engine/scripts/lib/preset-sync.mjs +59 -0
- package/engine/scripts/lib/profile-retire.mjs +97 -0
- package/engine/scripts/lib/python-runtime.mjs +190 -0
- package/engine/scripts/lib/registry.mjs +72 -0
- package/engine/scripts/lib/repo-root.sh +56 -0
- package/engine/scripts/lib/schedule-mechanism.mjs +659 -0
- package/engine/scripts/lib/schedule-probe.mjs +835 -0
- package/engine/scripts/lib/scope-pointer.mjs +164 -0
- package/engine/scripts/lib/settings-panels.mjs +816 -0
- package/engine/scripts/lib/stdio_utf8.py +86 -0
- package/engine/scripts/lib/wake-auth.mjs +392 -0
- package/engine/scripts/lib/webdriver_ipc.py +264 -0
- package/engine/scripts/lib/zstd-frames.mjs +104 -0
- package/engine/scripts/license-e2e-drill.mjs +426 -0
- package/engine/scripts/license-gate.mjs +245 -0
- package/engine/scripts/lip_backlog.py +171 -0
- package/engine/scripts/lip_table.py +185 -0
- package/engine/scripts/local-usage.mjs +214 -0
- package/engine/scripts/migrate-providers.mjs +127 -0
- package/engine/scripts/migrate-skills.sh +65 -0
- package/engine/scripts/ml-oauth-setup.mjs +550 -0
- package/engine/scripts/ml-store-ids.json +26 -0
- package/engine/scripts/ml_artifact_attribution.py +333 -0
- package/engine/scripts/ml_capacity_probe.py +1158 -0
- package/engine/scripts/ml_hub_status.py +1556 -0
- package/engine/scripts/ml_schema_check.py +115 -0
- package/engine/scripts/ml_store_ids.py +139 -0
- package/engine/scripts/npm-publish-argent.mjs +499 -0
- package/engine/scripts/npm-publish-argent.sh +20 -0
- package/engine/scripts/orchestrator.py +13811 -0
- package/engine/scripts/pack-plugins.mjs +140 -0
- package/engine/scripts/patches/dsh-llm-deepseek--transport-diagnostics.patch +297 -0
- package/engine/scripts/patches/dsh-session--append-message-shape.patch +15 -0
- package/engine/scripts/patches/dsh-session--tool-result-block-017.patch +28 -0
- package/engine/scripts/patches/dsh-session-format-v0-to-v1--permission-preset-origin.patch +11 -0
- package/engine/scripts/patches/dsh-session-format-v3-to-v4--turn-outside-replace.patch +20 -0
- package/engine/scripts/patches/dsh-session-persistence-jsonl--worker-bundled-migrators.patch +39 -0
- package/engine/scripts/patches/dsh-tools--render-return-shape.patch +50 -0
- package/engine/scripts/patches/verify-bundled-migrators.mjs +79 -0
- package/engine/scripts/patches/verify-hardening.mjs +167 -0
- package/engine/scripts/patches/verify-session-migration.mjs +149 -0
- package/engine/scripts/patches/verify-transport-diagnostics.mjs +227 -0
- package/engine/scripts/plan-role-rename.mjs +125 -0
- package/engine/scripts/plugin-bootcheck.mjs +451 -0
- package/engine/scripts/plugin-composition.json +15 -0
- package/engine/scripts/poc-mcp-host.mjs +455 -0
- package/engine/scripts/poll-fulfillment.sh +293 -0
- package/engine/scripts/poll-invoice.sh +74 -0
- package/engine/scripts/profile-doctor.mjs +686 -0
- package/engine/scripts/provider-select.sh +70 -0
- package/engine/scripts/provider-switch.sh +146 -0
- package/engine/scripts/provider-sync-target.check.mjs +64 -0
- package/engine/scripts/python-runtime.sh +78 -0
- package/engine/scripts/query_runner.py +310 -0
- package/engine/scripts/release-argent.sh +574 -0
- package/engine/scripts/repair-unresolved-tools.mjs +178 -0
- package/engine/scripts/run-tests.sh +256 -0
- package/engine/scripts/self-sign-license.mjs +179 -0
- package/engine/scripts/session-health-scan.mjs +63 -0
- package/engine/scripts/session-repair-tool-result-content.mjs +181 -0
- package/engine/scripts/setup.sh +22 -0
- package/engine/scripts/skill-install.mjs +629 -0
- package/engine/scripts/sku_translate.py +148 -0
- package/engine/scripts/sync-plugins.sh +90 -0
- package/engine/scripts/sync-presets.sh +27 -0
- package/engine/scripts/sync-scripts.sh +445 -0
- package/engine/scripts/telemetry.py +873 -0
- package/engine/scripts/ui-copy-count.mjs +220 -0
- package/engine/scripts/usage-anchor.sh +136 -0
- package/engine/scripts/usage_report.py +531 -0
- package/engine/scripts/validate-preset-schema.mjs +208 -0
- package/engine/scripts/vertical-init.mjs +323 -0
- package/engine/scripts/vertical-lint.mjs +482 -0
- package/engine/scripts/wenyao-browser.sh +73 -0
- package/engine/scripts/wenyao-fixture-export.py +116 -0
- package/engine/scripts/wenyao-invoice-writeback.mjs +540 -0
- package/engine/scripts/wenyao-login.sh +34 -0
- package/engine/scripts/wenyao-template-map.json +292 -0
- package/engine/scripts/wenyao_attach.py +131 -0
- package/engine/scripts/wenyao_download_template.py +144 -0
- package/engine/scripts/wenyao_fill_template.py +568 -0
- package/engine/scripts/wenyao_login.py +145 -0
- package/engine/scripts/wenyao_portal.py +633 -0
- package/engine/scripts/wenyao_recon.py +230 -0
- package/engine/scripts/wenyao_run.py +503 -0
- package/engine/scripts/wenyao_shadow_diff.py +160 -0
- package/engine/scripts/wenyao_skill_contract.py +156 -0
- package/engine/scripts/wenyao_template_fetch.py +175 -0
- package/engine/scripts/win/dsh-web-autostart.ps1 +372 -0
- package/engine/scripts/ziniao-auth-probe.sh +268 -0
- package/engine/scripts/ziniao-keepalive.sh +216 -0
- package/engine/scripts/ziniao-post-upgrade-check.sh +120 -0
- package/engine/scripts/ziniao-windows.sh +153 -0
- package/engine/version.mjs +1 -0
- package/engine/verticals/README.md +103 -0
- package/engine/verticals/_engine-words.baseline.txt +237 -0
- package/engine/verticals/_engine-words.json +19 -0
- package/engine/verticals/mercadolibre/README.md +43 -0
- package/engine/verticals/mercadolibre/config.json +709 -0
- package/engine/verticals/mercadolibre/flows.json +706 -0
- package/engine/verticals/mercadolibre/manifest.json +538 -0
- package/engine/verticals/mercadolibre/migrate-machine-state.mjs +138 -0
- package/engine/verticals/mercadolibre/preflight.py +143 -0
- package/engine/verticals/mercadolibre/prompts/daily-report.failure.md +69 -0
- package/engine/verticals/mercadolibre/prompts/daily-report.md +47 -0
- package/engine/verticals/mercadolibre/prompts/daily-report.scheduled.md +79 -0
- package/engine/verticals/mercadolibre/prompts/full.failure.md +125 -0
- package/engine/verticals/mercadolibre/prompts/full.md +91 -0
- package/engine/verticals/mercadolibre/prompts/wenyao-invoice.failure.md +88 -0
- package/engine/verticals/mercadolibre/prompts/wenyao-invoice.md +64 -0
- package/engine/verticals/mercadolibre/prompts/xzh-invoice.failure.md +91 -0
- package/engine/verticals/mercadolibre/prompts/xzh-invoice.md +46 -0
- package/package.json +21 -4
- package/README.md +0 -3
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""wenyao_recon.py — 登录态下的**只读**界面侦察(2026-09-10)
|
|
3
|
+
|
|
4
|
+
安全边界(务必遵守):
|
|
5
|
+
· **只点开弹窗看结构,绝不提交**(不选文件、不点「确定/导入」、不点导出/取消订单);
|
|
6
|
+
· 打开弹窗后一律用「取消 / × / Esc」关闭;
|
|
7
|
+
· 不下载任何文件(下载会改对方系统的导出任务记录)。
|
|
8
|
+
|
|
9
|
+
用途:为上海文鳐 workflow 的 ④⑤⑥⑦ 步找稳定选择器,并找《上海文鳐发票模版》的下载入口
|
|
10
|
+
(用户提示:登录后在系统里可能能下到模板 —— 通常在「导入订单」弹窗里)。
|
|
11
|
+
|
|
12
|
+
用法(需先 bash scripts/wenyao-browser.sh start 且已登录):
|
|
13
|
+
python3 scripts/wenyao_recon.py --toolbar # 工具栏按钮选择器 + 状态页签
|
|
14
|
+
python3 scripts/wenyao_recon.py --import-dialog # 点开「导入订单」看弹窗(含模板下载链接)后关闭
|
|
15
|
+
python3 scripts/wenyao_recon.py --menus # 顶部菜单/个人中心条目
|
|
16
|
+
"""
|
|
17
|
+
import argparse
|
|
18
|
+
import json
|
|
19
|
+
import os
|
|
20
|
+
import sys
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
from playwright.sync_api import sync_playwright
|
|
23
|
+
|
|
24
|
+
HOME = Path.home()
|
|
25
|
+
# 数据目录:**唯一判据**在 `scripts/lib/argent_datadir.py`(三级链,与 JS 内核同语义)
|
|
26
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent / 'lib'))
|
|
27
|
+
from argent_datadir import resolve_data_dir # noqa: E402 —— 勿在此复制判据
|
|
28
|
+
DATA = Path(resolve_data_dir()['dir'])
|
|
29
|
+
OUT = DATA / "wenyao-probe"
|
|
30
|
+
CDP = os.environ.get("WENYAO_CDP", "http://127.0.0.1:9333")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def shot(page, name):
|
|
34
|
+
OUT.mkdir(parents=True, exist_ok=True)
|
|
35
|
+
try:
|
|
36
|
+
page.screenshot(path=str(OUT / f"{name}.png"), full_page=True)
|
|
37
|
+
except Exception:
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def dump_buttons(page):
|
|
42
|
+
js = """() => Array.from(document.querySelectorAll('button,a,[role=button],.next-btn')).map(e => {
|
|
43
|
+
const r = e.getBoundingClientRect();
|
|
44
|
+
return {t:(e.innerText||'').trim().slice(0,20), cls:(e.className&&e.className.toString()||'').slice(0,80),
|
|
45
|
+
href:e.getAttribute && (e.getAttribute('href')||''), x:Math.round(r.x), y:Math.round(r.y),
|
|
46
|
+
w:Math.round(r.width), h:Math.round(r.height), vis: !!(r.width&&r.height)};
|
|
47
|
+
}).filter(x => x.vis && x.t).slice(0,60)"""
|
|
48
|
+
try:
|
|
49
|
+
return page.evaluate(js)
|
|
50
|
+
except Exception as e:
|
|
51
|
+
return [{"err": str(e)[:120]}]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def dump_modal(page):
|
|
55
|
+
js = """() => {
|
|
56
|
+
const out = {modals: [], links: [], inputs: [], texts: []};
|
|
57
|
+
document.querySelectorAll('.next-dialog, .next-overlay-inner, [class*=modal], [class*=dialog]').forEach(m => {
|
|
58
|
+
const r = m.getBoundingClientRect();
|
|
59
|
+
if (!r.width || !r.height) return;
|
|
60
|
+
out.modals.push({cls:(m.className||'').toString().slice(0,80), x:Math.round(r.x), y:Math.round(r.y),
|
|
61
|
+
w:Math.round(r.width), h:Math.round(r.height), text:(m.innerText||'').replace(/\\s+/g,' ').slice(0,600)});
|
|
62
|
+
m.querySelectorAll('a').forEach(a => out.links.push({t:(a.innerText||'').trim().slice(0,40), href:a.getAttribute('href')||'', down:a.getAttribute('download')||''}));
|
|
63
|
+
m.querySelectorAll('input').forEach(i => out.inputs.push({type:i.type||'', accept:i.getAttribute('accept')||'', name:i.name||'', id:i.id||''}));
|
|
64
|
+
m.querySelectorAll('button,.next-btn').forEach(b => out.texts.push({btn:(b.innerText||'').trim().slice(0,20), cls:(b.className||'').toString().slice(0,70)}));
|
|
65
|
+
});
|
|
66
|
+
// 全页搜索"模板/模版/下载"关键字
|
|
67
|
+
out.template_hits = Array.from(document.querySelectorAll('*')).map(e => (e.innerText||'').trim())
|
|
68
|
+
.filter(t => t && t.length < 40 && /模板|模版|下载|示例|样例/.test(t)).filter((v,i,a)=>a.indexOf(v)===i).slice(0,20);
|
|
69
|
+
return out;
|
|
70
|
+
}"""
|
|
71
|
+
try:
|
|
72
|
+
return page.evaluate(js)
|
|
73
|
+
except Exception as e:
|
|
74
|
+
return {"err": str(e)[:150]}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def dump_menu(page):
|
|
78
|
+
"""导出类按钮的下拉菜单:**只 hover 不点击**(点击可能真触发导出,属写操作)。"""
|
|
79
|
+
js = """() => {
|
|
80
|
+
const out = {items: [], opened: false};
|
|
81
|
+
document.querySelectorAll('.next-menu, .next-overlay-inner, [class*=menu-popup], [role=menu]').forEach(m => {
|
|
82
|
+
const r = m.getBoundingClientRect();
|
|
83
|
+
if (!r.width || !r.height) return;
|
|
84
|
+
out.opened = true;
|
|
85
|
+
m.querySelectorAll('li,.next-menu-item,a,[role=menuitem]').forEach(li => {
|
|
86
|
+
const t = (li.innerText||'').trim().slice(0,30);
|
|
87
|
+
if (t) out.items.push({t, cls:(li.className||'').toString().slice(0,70)});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
out.items = out.items.filter((v,i,a)=>a.findIndex(x=>x.t===v.t)===i);
|
|
91
|
+
return out;
|
|
92
|
+
}"""
|
|
93
|
+
try:
|
|
94
|
+
return page.evaluate(js)
|
|
95
|
+
except Exception as e:
|
|
96
|
+
return {"err": str(e)[:150]}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def dump_grid(page):
|
|
100
|
+
"""列表/查询栏/状态页签的结构(纯 DOM 读取)。
|
|
101
|
+
|
|
102
|
+
注意:列表是 **react-base-table 虚拟化表格**(`.BaseTable__*`),不是原生 <table>,
|
|
103
|
+
所以 tbody/tr 选择器拿不到行,必须用 `.BaseTable__row` / `.BaseTable__row-cell`。
|
|
104
|
+
"""
|
|
105
|
+
js = """() => {
|
|
106
|
+
const out = {tableKind: null, tabs: [], queryFields: [], columns: [], firstRow: {cells: [], checkbox: null, detailBtn: null}};
|
|
107
|
+
out.tableKind = document.querySelector('.BaseTable__table') ? 'react-base-table' : (document.querySelector('table') ? 'html-table' : 'unknown');
|
|
108
|
+
document.querySelectorAll('[class*=tab]').forEach(e => {
|
|
109
|
+
const t = (e.innerText||'').trim(); const r = e.getBoundingClientRect();
|
|
110
|
+
if (t && r.width && t.length < 24 && e.children.length <= 3) out.tabs.push({t, cls:(e.className||'').toString().slice(0,70)});
|
|
111
|
+
});
|
|
112
|
+
out.tabs = out.tabs.filter((v,i,a)=>a.findIndex(x=>x.t===v.t)===i).slice(0,20);
|
|
113
|
+
// 查询栏:label + 最近输入框
|
|
114
|
+
document.querySelectorAll('label').forEach(l => {
|
|
115
|
+
const t = (l.innerText||'').trim(); if (!t || t.length > 16) return;
|
|
116
|
+
let box = l.closest('[class*=form-item],[class*=query],[class*=field]') || l.parentElement;
|
|
117
|
+
const inp = box ? box.querySelector('input') : null;
|
|
118
|
+
const r = (box||l).getBoundingClientRect(); if (!r.width) return;
|
|
119
|
+
out.queryFields.push({label:t, ph:inp?inp.placeholder||'':'', id:inp?inp.id||'':'',
|
|
120
|
+
cls:box?(box.className||'').toString().slice(0,60):''});
|
|
121
|
+
});
|
|
122
|
+
out.queryFields = out.queryFields.filter((v,i,a)=>a.findIndex(x=>x.label===v.label)===i).slice(0,25);
|
|
123
|
+
// 表头 / 行(兼容两种表)
|
|
124
|
+
document.querySelectorAll('.BaseTable__header-cell, thead th, .next-table-header th').forEach(th => {
|
|
125
|
+
const t=(th.innerText||'').replace(/\\s+/g,' ').trim(); if (t) out.columns.push(t.slice(0,24));
|
|
126
|
+
});
|
|
127
|
+
out.columns = out.columns.slice(0, 20);
|
|
128
|
+
const row = document.querySelector('.BaseTable__row, tbody tr, .next-table-row');
|
|
129
|
+
if (row) {
|
|
130
|
+
const sel = row.querySelectorAll('.BaseTable__row-cell, td, .next-table-cell').length
|
|
131
|
+
? '.BaseTable__row-cell, td, .next-table-cell' : '*';
|
|
132
|
+
row.querySelectorAll(sel).forEach(td => {
|
|
133
|
+
const t=(td.innerText||'').replace(/\\s+/g,' ').trim();
|
|
134
|
+
if (t) out.firstRow.cells.push(t.slice(0,50));
|
|
135
|
+
});
|
|
136
|
+
const cb = row.querySelector('input[type=checkbox],.next-checkbox,.BaseTable__row-checkbox');
|
|
137
|
+
out.firstRow.checkbox = cb ? {cls:(cb.className||'').toString().slice(0,70), tag:cb.tagName} : null;
|
|
138
|
+
const btn = Array.from(row.querySelectorAll('button,.next-btn')).find(b => (b.innerText||'').includes('详情'));
|
|
139
|
+
out.firstRow.detailBtn = btn ? {t:(btn.innerText||'').trim(), cls:(btn.className||'').toString().slice(0,70)} : null;
|
|
140
|
+
out.firstRow.rowCls = (row.className||'').toString().slice(0,80);
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}"""
|
|
144
|
+
try:
|
|
145
|
+
return page.evaluate(js)
|
|
146
|
+
except Exception as e:
|
|
147
|
+
return {"err": str(e)[:150]}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def main():
|
|
151
|
+
ap = argparse.ArgumentParser()
|
|
152
|
+
ap.add_argument("--toolbar", action="store_true")
|
|
153
|
+
ap.add_argument("--import-dialog", action="store_true")
|
|
154
|
+
ap.add_argument("--menus", action="store_true")
|
|
155
|
+
ap.add_argument("--grid", action="store_true", help="列表/查询栏/状态页签结构(只读)")
|
|
156
|
+
ap.add_argument("--export-menu", action="store_true", help="只看「导出进仓单」下拉(hover,不点击)")
|
|
157
|
+
a = ap.parse_args()
|
|
158
|
+
res = {}
|
|
159
|
+
with sync_playwright() as p:
|
|
160
|
+
browser = p.chromium.connect_over_cdp(CDP, timeout=8000)
|
|
161
|
+
pages = [pg for c in browser.contexts for pg in c.pages]
|
|
162
|
+
page = next((pg for pg in pages if "ffl-tech" in (pg.url or "")), pages[0])
|
|
163
|
+
res["url"] = page.url
|
|
164
|
+
if a.grid:
|
|
165
|
+
res["grid"] = dump_grid(page)
|
|
166
|
+
shot(page, "65-grid")
|
|
167
|
+
if a.export_menu:
|
|
168
|
+
el = None
|
|
169
|
+
for sel in ["button:has-text('导出进仓单')", ".next-menu-btn:has-text('导出进仓单')", "text=导出进仓单"]:
|
|
170
|
+
try:
|
|
171
|
+
el = page.query_selector(sel)
|
|
172
|
+
if el and el.is_visible():
|
|
173
|
+
break
|
|
174
|
+
except Exception:
|
|
175
|
+
el = None
|
|
176
|
+
res["export_btn_found"] = bool(el)
|
|
177
|
+
if el:
|
|
178
|
+
try:
|
|
179
|
+
el.hover() # ← 只 hover;绝不 click(点击可能真触发导出)
|
|
180
|
+
page.wait_for_timeout(1200)
|
|
181
|
+
except Exception as e:
|
|
182
|
+
res["hover_err"] = str(e)[:120]
|
|
183
|
+
res["menu"] = dump_menu(page)
|
|
184
|
+
shot(page, "66-export-menu")
|
|
185
|
+
try:
|
|
186
|
+
page.keyboard.press("Escape")
|
|
187
|
+
except Exception:
|
|
188
|
+
pass
|
|
189
|
+
if a.toolbar:
|
|
190
|
+
res["buttons"] = dump_buttons(page)
|
|
191
|
+
res["tabs"] = [b["t"] for b in res["buttons"] if b["t"] in ("全部", "待拼箱", "已完成", "待送达集货仓")]
|
|
192
|
+
shot(page, "60-toolbar")
|
|
193
|
+
if a.menus:
|
|
194
|
+
res["menus"] = dump_buttons(page)
|
|
195
|
+
if a.import_dialog:
|
|
196
|
+
opened = False
|
|
197
|
+
for sel in ["button:has-text('导入订单')", "text=导入订单"]:
|
|
198
|
+
try:
|
|
199
|
+
el = page.query_selector(sel)
|
|
200
|
+
if el and el.is_visible():
|
|
201
|
+
el.click(); opened = True; break
|
|
202
|
+
except Exception:
|
|
203
|
+
continue
|
|
204
|
+
page.wait_for_timeout(2500)
|
|
205
|
+
res["import_dialog_opened"] = opened
|
|
206
|
+
res["modal"] = dump_modal(page)
|
|
207
|
+
shot(page, "61-import-dialog")
|
|
208
|
+
# 关闭(只关不提交)
|
|
209
|
+
closed = False
|
|
210
|
+
for sel in ["button:has-text('取消')", ".next-dialog-close", "text=取消"]:
|
|
211
|
+
try:
|
|
212
|
+
el = page.query_selector(sel)
|
|
213
|
+
if el and el.is_visible():
|
|
214
|
+
el.click(); closed = True; break
|
|
215
|
+
except Exception:
|
|
216
|
+
continue
|
|
217
|
+
if not closed:
|
|
218
|
+
try:
|
|
219
|
+
page.keyboard.press("Escape")
|
|
220
|
+
except Exception:
|
|
221
|
+
pass
|
|
222
|
+
page.wait_for_timeout(1200)
|
|
223
|
+
res["closed"] = closed
|
|
224
|
+
res["url_after"] = page.url
|
|
225
|
+
print(json.dumps(res, ensure_ascii=False, indent=1))
|
|
226
|
+
return 0
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
if __name__ == "__main__":
|
|
230
|
+
raise SystemExit(main())
|