@whyshu/argent-engine 0.14.2 → 0.14.4
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 +6 -4
- package/engine/VERSION +1 -1
- package/engine/core/contracts/argent.contracts.json +2 -2
- package/engine/scripts/argent-timers.mjs +1 -0
- package/engine/scripts/platform-appointment-scan.py +42 -28
- package/engine/scripts/platform-scan-run.sh +46 -0
- package/engine/scripts/platform-scan-timers.sh +77 -0
- package/engine/version.mjs +1 -1
- package/package.json +1 -1
package/MANIFEST.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"package": "@whyshu/argent-engine",
|
|
4
4
|
"files": {
|
|
5
|
-
"VERSION": "
|
|
5
|
+
"VERSION": "c78c310b641231eb31cf7f005d8defa7d36327d421e9b20903fec67a0de982bc",
|
|
6
6
|
"agents/catalog.json": "5356a812f2554dfd3115370363d4c3f787a82c9e5928a85d05b2a07c9e4b324d",
|
|
7
7
|
"configs/_aliases.proposed.json": "3a59edf80563bcc20d410d488decad6fd787bd3de9489321367b0783904cd3e5",
|
|
8
8
|
"configs/_migration-plan.proposed.json": "dd9f90b0b9b2f217dd23367a618402e57997d44f7fddcfa88a7cadf52e056c0d",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"configs/mcp-tools.snapshot.json": "cfa94a6ba64a7ae9d133a4a878ce3d5e0e85e554ccd3e3ebaf0d51ad750acf6a",
|
|
15
15
|
"configs/notify.json": "cb9ef11c1c498fcf99af99ec50271b8a2598061b77ed73a6099032e837474ef0",
|
|
16
16
|
"core/cli/argent.mjs": "9a8977324c238ca4e20435f9817eb7ec76157da32b1d510977dc03e0feb416a9",
|
|
17
|
-
"core/contracts/argent.contracts.json": "
|
|
17
|
+
"core/contracts/argent.contracts.json": "5ab37d2cb1c6b0a6760fe2e99950e66beabb7924aa77a5ea1804bc169780e357",
|
|
18
18
|
"core/contracts/verbs.schema.json": "54d726181c11536eb30bd25090584a7af103e4c0462f8ef078053c8177e19dcb",
|
|
19
19
|
"core/lib/account-token.mjs": "35faad2c34e67755c1867f74a74885f0f268d5daabe01d339cf30dc747f86501",
|
|
20
20
|
"core/lib/argent-datadir.mjs": "1fdd799c933382c4f9e36bd4af33d51b8ac4a466a9d67a8f2296bb267b5251ac",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"scripts/argent-runner.mjs": "a4996d382cddc16d77cd760715eb89daf6fc38115df31d98a9a706d828009f15",
|
|
71
71
|
"scripts/argent-schedule.mjs": "4d2485f454094ae7d9978334e0ee995aef22fdc7058f3694c1f7d363e8a51f09",
|
|
72
72
|
"scripts/argent-setup-check.mjs": "44d3558ae6eebd5cc2dd25752019d3386190e63006b544e1ceee3f4f1c526aff",
|
|
73
|
-
"scripts/argent-timers.mjs": "
|
|
73
|
+
"scripts/argent-timers.mjs": "bed030b80972f447fec4d13eaa6fd63b6ebe462f2a2fa47aec6388dc6bb4c50f",
|
|
74
74
|
"scripts/argent-upgrade.mjs": "ba75148cb3c27b4aab2b184d1320d4b57a203adf8b90214fa3d62880685a0d81",
|
|
75
75
|
"scripts/argent-web-preflight.mjs": "7aa67912098b23cab2dec68d78830f7e5dc1d6c9cb915f4e00628fcd47bb694d",
|
|
76
76
|
"scripts/argent-web-verify.mjs": "9690885f7b379da87d879018e254e563ad6631b56381ee293ee06796ce605694",
|
|
@@ -311,7 +311,9 @@
|
|
|
311
311
|
"scripts/patches/verify-session-migration.mjs": "0f6b3a177306fd4cbbe87b4423b7ff5f0d18e4e77bfa50b385ecc354dea90c17",
|
|
312
312
|
"scripts/patches/verify-turn-outside-replace.mjs": "eeff9c907e8509652759fb3d1ce864e828a68ec882c977c8d819be165817f96d",
|
|
313
313
|
"scripts/plan-role-rename.mjs": "63a52ddaeb1ca2a246fcbf069318166fe5d0abee6003e5304b3e771defb43da2",
|
|
314
|
-
"scripts/platform-appointment-scan.py": "
|
|
314
|
+
"scripts/platform-appointment-scan.py": "7cab576e0d596c5f03386dac65455b2d74bd974d97af5f4b50383bd08ed9c3a0",
|
|
315
|
+
"scripts/platform-scan-run.sh": "f6934bd484deca5f654faea1a39de8411ddfecad34e68ca9dd7223b0b803126a",
|
|
316
|
+
"scripts/platform-scan-timers.sh": "7848ed280261d1651f5ff66cd6be6d6aedf967f6c3e205fd1eca3930dec32a03",
|
|
315
317
|
"scripts/plugin-bootcheck.mjs": "bbfbfc9ec0fa409f9ca52012ecdd3b7b068bb4c0b31d49da491f1efc8784d977",
|
|
316
318
|
"scripts/plugin-composition.json": "99c545b56828d81882bc126eac3c3826e04146c3bb68be288a2b3c3e4ed11b9d",
|
|
317
319
|
"scripts/poc-mcp-host.mjs": "5c4befdc95f98bf9c84f94bb525b245248c751e08e3fc09bb987781e9e4859cb",
|
package/engine/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.14.
|
|
1
|
+
0.14.4
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"argentVersion": "0.14.
|
|
3
|
-
"_syncNote": "argentVersion 必须与仓库根 VERSION 同批更新:发布前置校验 scripts/check-version-consistency.mjs;2026-11-24 按 VERSION=0.14.
|
|
2
|
+
"argentVersion": "0.14.4",
|
|
3
|
+
"_syncNote": "argentVersion 必须与仓库根 VERSION 同批更新:发布前置校验 scripts/check-version-consistency.mjs;2026-11-24 按 VERSION=0.14.4 校正。",
|
|
4
4
|
"principle": "宿主无关:宿主只依赖 `argent <verb>`;确定性逻辑在 CLI/MCP,不在提示词里。",
|
|
5
5
|
"verbs": {
|
|
6
6
|
"version": {
|
|
@@ -37,6 +37,7 @@ export const KNOWN_LABELS = Object.freeze({
|
|
|
37
37
|
'com.whyshu.fulfillment-poll': { desc: '旧轮询(已退役,应清理)', kind: 'retired' },
|
|
38
38
|
// 2026-11-27:客户机实测清单里出现但我们漏收录的(截图里显示"未知"的正是这些)
|
|
39
39
|
'com.whyshu.ml-insight-timer': { desc: '店铺诊断(每小时 :20 跟随日报快照)', kind: 'insight', statusFile: 'ml-insight-diagnose-status.json' },
|
|
40
|
+
'com.whyshu.platform-appointment-scan': { desc: '平台预约只读扫描(每 30 分钟)', kind: 'insight', statusFile: 'platform-scan-status.json' },
|
|
40
41
|
'com.whyshu.ziniao-keepalive': { desc: '紫鸟浏览器保活(每 3 分钟)', kind: 'host' },
|
|
41
42
|
'com.whyshu.caffeinate': { desc: '防休眠(常驻)', kind: 'host' },
|
|
42
43
|
'com.whyshu.xzh-browser': { desc: '鑫中航浏览器(常驻,旧流程遗留)', kind: 'host' },
|
|
@@ -14,6 +14,7 @@ import json
|
|
|
14
14
|
import os
|
|
15
15
|
import pathlib
|
|
16
16
|
import re
|
|
17
|
+
import socket
|
|
17
18
|
import sys
|
|
18
19
|
import time
|
|
19
20
|
import urllib.request
|
|
@@ -111,39 +112,34 @@ def parse_row(texts: dict[str, str], store: str, page_no: int) -> dict[str, Any]
|
|
|
111
112
|
|
|
112
113
|
|
|
113
114
|
def _rows_from_page(page: Any, store: str, page_no: int) -> list[dict[str, Any]]:
|
|
114
|
-
|
|
115
|
+
# 一次 evaluate 取回整张表:避免逐 cell Playwright timeout 叠加(店铺忙时尤其慢)。
|
|
116
|
+
try:
|
|
117
|
+
raw = page.evaluate("""() => Array.from(document.querySelectorAll('table tr')).map((row) => {
|
|
118
|
+
const tds = Array.from(row.querySelectorAll('td'));
|
|
119
|
+
const texts = {};
|
|
120
|
+
for (const td of tds) {
|
|
121
|
+
const title = td.getAttribute('data-title') || '';
|
|
122
|
+
if (title) texts[title] = td.innerText || '';
|
|
123
|
+
}
|
|
124
|
+
const wh = row.querySelector('.inbound-warehouse-name');
|
|
125
|
+
return { texts, warehouse: wh ? (wh.innerText || '') : '' };
|
|
126
|
+
})""")
|
|
127
|
+
except Exception:
|
|
128
|
+
return []
|
|
115
129
|
out: list[dict[str, Any]] = []
|
|
116
|
-
for row in
|
|
117
|
-
|
|
118
|
-
if not
|
|
119
|
-
continue
|
|
120
|
-
texts: dict[str, str] = {}
|
|
121
|
-
for cell in cells:
|
|
122
|
-
title = cell.get_attribute("data-title") or ""
|
|
123
|
-
if not title:
|
|
124
|
-
continue
|
|
125
|
-
try:
|
|
126
|
-
text = cell.inner_text(timeout=3000)
|
|
127
|
-
except Exception:
|
|
128
|
-
text = ""
|
|
129
|
-
# 列表页的预约/仓库/状态在同一行;保留完整文本供解析。
|
|
130
|
-
texts[title] = text
|
|
131
|
-
if "Envío" not in texts:
|
|
130
|
+
for row in raw or []:
|
|
131
|
+
texts = row.get("texts") if isinstance(row, dict) else None
|
|
132
|
+
if not isinstance(texts, dict) or "Envío" not in texts:
|
|
132
133
|
continue
|
|
133
134
|
item = parse_row(texts, store, page_no)
|
|
134
135
|
if not item:
|
|
135
136
|
continue
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if wh:
|
|
140
|
-
item["warehouse"] = wh[:200]
|
|
141
|
-
except Exception:
|
|
142
|
-
pass
|
|
137
|
+
wh = str((row or {}).get("warehouse") or "").strip()
|
|
138
|
+
if wh:
|
|
139
|
+
item["warehouse"] = wh[:200]
|
|
143
140
|
out.append(item)
|
|
144
141
|
return out
|
|
145
142
|
|
|
146
|
-
|
|
147
143
|
def post_snapshot(*, api_base: str, tenant_app: str, machine_id: str, machine_token: str, result: dict[str, Any], complete: bool = False) -> dict[str, Any]:
|
|
148
144
|
url = f"{str(api_base).rstrip('/')}/api/argent/v1/tenants/{tenant_app}/machines/{machine_id}/platform-appointments/scan"
|
|
149
145
|
body = json.dumps({
|
|
@@ -171,13 +167,22 @@ def scan(store: str, cdp_port: int, *, base_url: str, max_pages: int = 20, wait_
|
|
|
171
167
|
seen: set[str] = set()
|
|
172
168
|
pages: list[int] = []
|
|
173
169
|
with sync_playwright() as p:
|
|
174
|
-
browser = p.chromium.connect_over_cdp(f"http://127.0.0.1:{int(cdp_port)}")
|
|
170
|
+
browser = p.chromium.connect_over_cdp(f"http://127.0.0.1:{int(cdp_port)}", timeout=15_000)
|
|
175
171
|
ctx = browser.contexts[0] if browser.contexts else browser.new_context()
|
|
172
|
+
# 清掉上一次被 SIGKILL/超时留下的列表页,避免每轮扫描无限堆标签页;
|
|
173
|
+
# 只关 shipping/inbounds 列表页,绝不碰 /inbounds/<货件号>/... 的预约/执行页。
|
|
174
|
+
for old_page in list(ctx.pages):
|
|
175
|
+
try:
|
|
176
|
+
old_url = old_page.url or ""
|
|
177
|
+
if "/shipping/inbounds" in old_url and "/inbounds/" not in old_url:
|
|
178
|
+
old_page.close()
|
|
179
|
+
except Exception:
|
|
180
|
+
pass
|
|
176
181
|
page = ctx.new_page()
|
|
177
|
-
page.set_default_timeout(
|
|
182
|
+
page.set_default_timeout(12_000)
|
|
178
183
|
try:
|
|
179
184
|
for page_no in range(1, max_pages + 1):
|
|
180
|
-
page.goto(str(base_url).rstrip("/") + INBOUNDS_PATH.format(page=page_no), wait_until="domcontentloaded", timeout=
|
|
185
|
+
page.goto(str(base_url).rstrip("/") + INBOUNDS_PATH.format(page=page_no), wait_until="domcontentloaded", timeout=20_000)
|
|
181
186
|
time.sleep(wait_sec)
|
|
182
187
|
page_rows = _rows_from_page(page, store, page_no)
|
|
183
188
|
fresh = [x for x in page_rows if x["shipmentNo"] not in seen]
|
|
@@ -214,10 +219,19 @@ def scan_all(*, cdp_map: str, base_url: str, max_pages: int, wait_sec: float) ->
|
|
|
214
219
|
stores = sorted(set(stores))
|
|
215
220
|
results = []
|
|
216
221
|
for name, port in stores:
|
|
222
|
+
# 先做 TCP 探针:窗口没开就立即跳过,避免 Playwright 在死端口上等很久。
|
|
223
|
+
try:
|
|
224
|
+
with socket.create_connection(("127.0.0.1", int(port)), timeout=1.5):
|
|
225
|
+
pass
|
|
226
|
+
except Exception as e: # noqa: BLE001
|
|
227
|
+
results.append({"ok": False, "store": name, "cdpPort": port, "count": 0, "error": f"CDP 端口未监听:{str(e)[:120]}"})
|
|
228
|
+
continue
|
|
229
|
+
print(f"[scan] store={name} cdp={port} start", flush=True)
|
|
217
230
|
try:
|
|
218
231
|
r = scan(name, port, base_url=base_url, max_pages=max_pages, wait_sec=wait_sec)
|
|
219
232
|
except Exception as e: # noqa: BLE001
|
|
220
233
|
r = {"ok": False, "store": name, "cdpPort": port, "error": str(e)[:300]}
|
|
234
|
+
print(f"[scan] store={name} done ok={r.get('ok')} count={r.get('count', 0)}", flush=True)
|
|
221
235
|
results.append(r)
|
|
222
236
|
return {"ok": True, "mode": "all_stores", "stores": len(stores), "results": results, "scannedAt": datetime.now(timezone.utc).isoformat()}
|
|
223
237
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# platform-scan-run.sh —— 只读平台预约扫描器的定时入口(launchd 直跑)。
|
|
3
|
+
# 由 platform-scan-timers.sh 安装;不预约、不取消、不占 FULL 槽位。
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
. "$SCRIPT_DIR/lib/argent-datadir.sh"
|
|
7
|
+
DATA_HOME="${ARGENT_DATA_DIR_RESOLVED:?数据根解析失败:请显式给 ARGENT_DATA_DIR}"
|
|
8
|
+
REPORT="$DATA_HOME/agent-report.json"
|
|
9
|
+
ENV_FILE="$DATA_HOME/daily-report.env"
|
|
10
|
+
STATUS="$DATA_HOME/platform-scan-status.json"
|
|
11
|
+
LOG_DIR="$DATA_HOME/platform-scan-logs"
|
|
12
|
+
LOCK="$DATA_HOME/platform-scan.lock"
|
|
13
|
+
mkdir -p "$LOG_DIR"
|
|
14
|
+
now() { date -u '+%Y-%m-%dT%H:%M:%SZ'; }
|
|
15
|
+
write_status() { # $1=exit $2=error
|
|
16
|
+
/usr/bin/python3 - "$STATUS" "$1" "${2:-}" "$STARTED" <<'PYEOF' 2>/dev/null || true
|
|
17
|
+
import json,sys,datetime
|
|
18
|
+
path,code,err,started=sys.argv[1:5]
|
|
19
|
+
now=datetime.datetime.now(datetime.timezone.utc)
|
|
20
|
+
try: doc=json.load(open(path))
|
|
21
|
+
except Exception: doc={}
|
|
22
|
+
doc.update({"lastRunAt":doc.get("lastRunAt") or started,"lastFinishAt":now.isoformat().replace("+00:00","Z"),"lastExit":int(code) if str(code).lstrip("-").isdigit() else 1,"lastError":err,"nextDueAt":(now+datetime.timedelta(minutes=30)).isoformat().replace("+00:00","Z")})
|
|
23
|
+
open(path,"w").write(json.dumps(doc,ensure_ascii=False,indent=2)+"\n")
|
|
24
|
+
PYEOF
|
|
25
|
+
}
|
|
26
|
+
env_get() { [ -f "$ENV_FILE" ] || return 0; grep -E "^[[:space:]]*$1=" "$ENV_FILE" 2>/dev/null | tail -1 | cut -d= -f2- | tr -d '"' | tr -d "'" | sed 's/[[:space:]]*$//'; }
|
|
27
|
+
if [ -f "$DATA_HOME/platform-scan.env" ]; then . "$DATA_HOME/platform-scan.env"; fi
|
|
28
|
+
if [ "$(env_get PLATFORM_SCAN_ENABLED)" != "true" ]; then exit 0; fi
|
|
29
|
+
if [ -d "$LOCK" ]; then exit 0; fi
|
|
30
|
+
mkdir "$LOCK" 2>/dev/null || exit 0
|
|
31
|
+
trap 'rmdir "$LOCK" 2>/dev/null || true' EXIT
|
|
32
|
+
if [ ! -f "$REPORT" ]; then write_status 1 "agent-report.json 缺失"; exit 1; fi
|
|
33
|
+
TOKEN="$("/usr/bin/python3" -c 'import json,sys; print(json.load(open(sys.argv[1])).get("machineToken",""))' "$REPORT" 2>/dev/null || true)"
|
|
34
|
+
APP="$("/usr/bin/python3" -c 'import json,sys; print(json.load(open(sys.argv[1])).get("tenantAppId","ly-0001"))' "$REPORT" 2>/dev/null || true)"
|
|
35
|
+
MID="$("/usr/bin/python3" -c 'import json,sys; print(json.load(open(sys.argv[1])).get("machineId",""))' "$REPORT" 2>/dev/null || true)"
|
|
36
|
+
BASE="${SELLER_CENTER_BASE:-$(env_get SELLER_CENTER_BASE)}"
|
|
37
|
+
if [ -z "$BASE" ]; then echo "缺少 SELLER_CENTER_BASE:请在 $DATA_HOME/platform-scan.env 配置" >&2; write_status 1 "SELLER_CENTER_BASE 未配置"; exit 1; fi
|
|
38
|
+
PYBIN="$HOME/.dsh/argent/venv/bin/python3"; [ -x "$PYBIN" ] || PYBIN="$("/usr/bin/which" python3)"
|
|
39
|
+
STARTED="$(now)"
|
|
40
|
+
set +e
|
|
41
|
+
ARGENT_MACHINE_TOKEN="$TOKEN" ARGENT_ERP_BASE="${ARGENT_ERP_BASE:-https://whyshu.com}" ARGENT_TENANT_APP_ID="$APP" ARGENT_MACHINE_ID="$MID" SELLER_CENTER_BASE="$BASE" \
|
|
42
|
+
"$PYBIN" "$SCRIPT_DIR/platform-appointment-scan.py" --all-stores --max-pages 5 --wait 6 >>"$LOG_DIR/platform-scan.log" 2>&1
|
|
43
|
+
CODE=$?
|
|
44
|
+
set -e
|
|
45
|
+
write_status "$CODE" ""
|
|
46
|
+
exit "$CODE"
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# platform-scan-timers.sh —— 只读平台预约扫描器的 launchd 安装/卸载/状态。
|
|
3
|
+
# bash scripts/platform-scan-timers.sh install [--force] [--allow-non-production]
|
|
4
|
+
# bash scripts/platform-scan-timers.sh uninstall
|
|
5
|
+
# bash scripts/platform-scan-timers.sh status
|
|
6
|
+
# bash scripts/platform-scan-timers.sh run-now
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
9
|
+
. "$SCRIPT_DIR/lib/argent-datadir.sh"
|
|
10
|
+
LABEL="com.whyshu.platform-appointment-scan"
|
|
11
|
+
AGENTS="$HOME/Library/LaunchAgents"
|
|
12
|
+
DATA_HOME="${ARGENT_DATA_DIR_RESOLVED:?数据根解析失败:请显式给 ARGENT_DATA_DIR}"
|
|
13
|
+
RUNNER="$SCRIPT_DIR/platform-scan-run.sh"
|
|
14
|
+
LOG_DIR="$DATA_HOME/platform-scan-logs"
|
|
15
|
+
PLIST="$AGENTS/$LABEL.plist"
|
|
16
|
+
ENV_FILE="$DATA_HOME/platform-scan.env"
|
|
17
|
+
|
|
18
|
+
usage() { sed -n '2,9p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; }
|
|
19
|
+
is_production() {
|
|
20
|
+
/usr/bin/python3 - "$DATA_HOME/config.json" <<'PYEOF' 2>/dev/null || exit 1
|
|
21
|
+
import json,sys
|
|
22
|
+
try:
|
|
23
|
+
d=json.load(open(sys.argv[1])); r=(d.get('dailyReport') or {}).get('role',''); a=len((d.get('dailyReport') or {}).get('allowedChatIds') or [])
|
|
24
|
+
raise SystemExit(0 if r=='production' or a>0 else 1)
|
|
25
|
+
except SystemExit: raise
|
|
26
|
+
except Exception: raise SystemExit(1)
|
|
27
|
+
PYEOF
|
|
28
|
+
}
|
|
29
|
+
gen() {
|
|
30
|
+
cat <<PLIST
|
|
31
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
32
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
33
|
+
<plist version="1.0">
|
|
34
|
+
<dict>
|
|
35
|
+
<key>Label</key><string>$LABEL</string>
|
|
36
|
+
<key>ProgramArguments</key><array><string>/bin/bash</string><string>$RUNNER</string></array>
|
|
37
|
+
<key>StartInterval</key><integer>1800</integer>
|
|
38
|
+
<key>RunAtLoad</key><false/>
|
|
39
|
+
<key>AbandonProcessGroup</key><true/>
|
|
40
|
+
<key>EnvironmentVariables</key><dict>
|
|
41
|
+
<key>ARGENT_DATA_DIR</key><string>$DATA_HOME</string>
|
|
42
|
+
<key>PATH</key><string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
|
|
43
|
+
</dict>
|
|
44
|
+
<key>StandardOutPath</key><string>$LOG_DIR/platform-scan.out.log</string>
|
|
45
|
+
<key>StandardErrorPath</key><string>$LOG_DIR/platform-scan.err.log</string>
|
|
46
|
+
<key>WorkingDirectory</key><string>$HOME</string>
|
|
47
|
+
</dict>
|
|
48
|
+
</plist>
|
|
49
|
+
PLIST
|
|
50
|
+
}
|
|
51
|
+
do_install() {
|
|
52
|
+
local allow=0
|
|
53
|
+
for a in "$@"; do case "$a" in --allow-non-production) allow=1;; --force) :;; *) echo "未知参数 $a" >&2; exit 2;; esac; done
|
|
54
|
+
if [ "$allow" = 0 ] && ! is_production; then echo "❌ 拒绝安装:本机不是生产机(需 config.json dailyReport.role=production 或 --allow-non-production)" >&2; exit 3; fi
|
|
55
|
+
mkdir -p "$AGENTS" "$LOG_DIR" "$DATA_HOME"
|
|
56
|
+
if [ -n "${SELLER_CENTER_BASE:-}" ]; then printf 'SELLER_CENTER_BASE=%s\n' "$SELLER_CENTER_BASE" > "$ENV_FILE"; chmod 600 "$ENV_FILE"; fi
|
|
57
|
+
gen > "$PLIST"; chmod 644 "$PLIST"
|
|
58
|
+
launchctl bootout "gui/$(id -u)" "$PLIST" 2>/dev/null || true
|
|
59
|
+
launchctl bootstrap "gui/$(id -u)" "$PLIST"
|
|
60
|
+
echo "✅ 已安装 ${LABEL}(每 30 分钟)"
|
|
61
|
+
}
|
|
62
|
+
do_uninstall() {
|
|
63
|
+
if [ -f "$PLIST" ]; then launchctl bootout "gui/$(id -u)" "$PLIST" 2>/dev/null || true; rm -f "$PLIST"; echo "✅ 已卸载 $LABEL"; fi
|
|
64
|
+
}
|
|
65
|
+
do_status() {
|
|
66
|
+
if launchctl list 2>/dev/null | grep -q "[[:space:]]$LABEL\$"; then echo "$LABEL: loaded"; else echo "$LABEL: missing"; fi
|
|
67
|
+
cat "$DATA_HOME/platform-scan-status.json" 2>/dev/null || true
|
|
68
|
+
}
|
|
69
|
+
cmd="${1:-}"; shift || true
|
|
70
|
+
case "$cmd" in
|
|
71
|
+
install) do_install "$@" ;;
|
|
72
|
+
uninstall) do_uninstall ;;
|
|
73
|
+
status) do_status ;;
|
|
74
|
+
run-now) bash "$RUNNER" ;;
|
|
75
|
+
print-plist) gen ;;
|
|
76
|
+
*) usage; exit 2 ;;
|
|
77
|
+
esac
|
package/engine/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.14.
|
|
1
|
+
export const VERSION = "0.14.4"
|