refactor: drive verify script from patch contract / 讓 verify script 讀 patch contract
This commit is contained in:
26
scripts/render-openclaw-verify-targets.mjs
Normal file
26
scripts/render-openclaw-verify-targets.mjs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import fs from "node:fs"
|
||||||
|
import path from "node:path"
|
||||||
|
|
||||||
|
const contractPath = path.join(import.meta.dirname, "..", "generated", "openclaw-telegram-patch-contract.json")
|
||||||
|
const contract = JSON.parse(fs.readFileSync(contractPath, "utf-8"))
|
||||||
|
|
||||||
|
const targets = {
|
||||||
|
send: {
|
||||||
|
defaultButtonsInjected: "buildInlineKeyboard(opts.buttons ??",
|
||||||
|
continueCallback: contract.defaultButtons[0][0].callback_data,
|
||||||
|
stopCallback: contract.defaultButtons[0][1].callback_data,
|
||||||
|
continueLabel: contract.defaultButtons[0][0].text,
|
||||||
|
stopLabel: contract.defaultButtons[0][1].text,
|
||||||
|
},
|
||||||
|
bot: {
|
||||||
|
stateFilePath: "reply-end-controls.json",
|
||||||
|
debugLogPath: "reply-end-debug.log",
|
||||||
|
continueAck: contract.resolved.continue.acknowledgement,
|
||||||
|
stopAck: contract.resolved.stop.acknowledgement,
|
||||||
|
stopPolicy: contract.stopPolicyText,
|
||||||
|
resolvedContinueLabel: contract.resolved.continue.buttons[0][0].text,
|
||||||
|
resolvedStopLabel: contract.resolved.stop.buttons[0][1].text,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
process.stdout.write(`${JSON.stringify(targets, null, 2)}\n`)
|
||||||
@@ -9,6 +9,11 @@ fi
|
|||||||
STATE_DIR="$1"
|
STATE_DIR="$1"
|
||||||
DIST_DIR="$2"
|
DIST_DIR="$2"
|
||||||
MANIFEST_PATH="$(dirname "$0")/../reports/live-openclawtest-manifest.json"
|
MANIFEST_PATH="$(dirname "$0")/../reports/live-openclawtest-manifest.json"
|
||||||
|
VERIFY_TARGETS_PATH="$(dirname "$0")/../generated/openclaw-verify-targets.json"
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "${VERIFY_TARGETS_PATH}")"
|
||||||
|
npx -p tsx@4.20.6 -p typescript@5.9.3 tsx "$(dirname "$0")/render-openclaw-patch-contract.mjs" > "$(dirname "$0")/../generated/openclaw-telegram-patch-contract.json"
|
||||||
|
npx -p tsx@4.20.6 -p typescript@5.9.3 tsx "$(dirname "$0")/render-openclaw-verify-targets.mjs" > "${VERIFY_TARGETS_PATH}"
|
||||||
|
|
||||||
echo "== reply-end-controls PoC verify =="
|
echo "== reply-end-controls PoC verify =="
|
||||||
echo "state_dir=${STATE_DIR}"
|
echo "state_dir=${STATE_DIR}"
|
||||||
@@ -29,23 +34,15 @@ done
|
|||||||
|
|
||||||
echo
|
echo
|
||||||
echo "== patch markers =="
|
echo "== patch markers =="
|
||||||
sudo python3 - <<'PY' "$DIST_DIR"
|
sudo python3 - <<'PY' "$DIST_DIR" "$VERIFY_TARGETS_PATH"
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import json, sys
|
import json, sys
|
||||||
|
|
||||||
live_dist = Path(sys.argv[1])
|
live_dist = Path(sys.argv[1])
|
||||||
|
targets = json.loads(Path(sys.argv[2]).read_text(encoding='utf-8'))
|
||||||
checks = {
|
checks = {
|
||||||
'send-sxDwUGaO.js': {
|
'send-sxDwUGaO.js': targets['send'],
|
||||||
'defaultButtonsInjected': 'buildInlineKeyboard(opts.buttons ??',
|
'bot-Ce301bOE.js': targets['bot'],
|
||||||
'continueCallback': 'rec:continue',
|
|
||||||
'stopCallback': 'rec:stop',
|
|
||||||
},
|
|
||||||
'bot-Ce301bOE.js': {
|
|
||||||
'stateFilePath': 'reply-end-controls.json',
|
|
||||||
'continueAck': 'reply-end-controls: continue received',
|
|
||||||
'stopAck': 'reply-end-controls: stop received',
|
|
||||||
'stopPolicy': 'Treat the previous thread as closed',
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
for name, markers in checks.items():
|
for name, markers in checks.items():
|
||||||
path = live_dist / name
|
path = live_dist / name
|
||||||
|
|||||||
Reference in New Issue
Block a user