refactor: derive apply patch values from patch contract / 讓 apply patch 值來自 patch contract

This commit is contained in:
Alice (OpenClaw)
2026-05-13 19:51:55 +08:00
parent 136ff7400a
commit 5708ef8858
2 changed files with 18 additions and 7 deletions

View File

@@ -10,6 +10,10 @@ DIST_DIR="$1"
SEND_JS="${DIST_DIR}/send-sxDwUGaO.js" SEND_JS="${DIST_DIR}/send-sxDwUGaO.js"
BOT_JS="${DIST_DIR}/bot-Ce301bOE.js" BOT_JS="${DIST_DIR}/bot-Ce301bOE.js"
CONFIG_PATH="$(dirname "$0")/../config/reply-end-controls.json" CONFIG_PATH="$(dirname "$0")/../config/reply-end-controls.json"
PATCH_CONTRACT_PATH="$(dirname "$0")/../generated/openclaw-telegram-patch-contract.json"
mkdir -p "$(dirname "${PATCH_CONTRACT_PATH}")"
npx -p tsx@4.20.6 -p typescript@5.9.3 tsx "$(dirname "$0")/render-openclaw-patch-contract.mjs" > "${PATCH_CONTRACT_PATH}"
if [[ ! -f "${SEND_JS}" || ! -f "${BOT_JS}" ]]; then if [[ ! -f "${SEND_JS}" || ! -f "${BOT_JS}" ]]; then
echo "expected runtime files not found under: ${DIST_DIR}" >&2 echo "expected runtime files not found under: ${DIST_DIR}" >&2
@@ -19,7 +23,7 @@ fi
cp "${SEND_JS}" "${SEND_JS}.reply-end-controls.bak" cp "${SEND_JS}" "${SEND_JS}.reply-end-controls.bak"
cp "${BOT_JS}" "${BOT_JS}.reply-end-controls.bak" cp "${BOT_JS}" "${BOT_JS}.reply-end-controls.bak"
python3 - <<'PY' "${SEND_JS}" "${BOT_JS}" "${CONFIG_PATH}" python3 - <<'PY' "${SEND_JS}" "${BOT_JS}" "${CONFIG_PATH}" "${PATCH_CONTRACT_PATH}"
from pathlib import Path from pathlib import Path
import json import json
import sys import sys
@@ -27,16 +31,18 @@ import sys
send_js = Path(sys.argv[1]) send_js = Path(sys.argv[1])
bot_js = Path(sys.argv[2]) bot_js = Path(sys.argv[2])
config_path = Path(sys.argv[3]) config_path = Path(sys.argv[3])
patch_contract_path = Path(sys.argv[4])
cfg = json.loads(config_path.read_text(encoding='utf-8')) cfg = json.loads(config_path.read_text(encoding='utf-8'))
contract = json.loads(patch_contract_path.read_text(encoding='utf-8'))
cb_continue = cfg['callbacks']['continue'] cb_continue = cfg['callbacks']['continue']
cb_stop = cfg['callbacks']['stop'] cb_stop = cfg['callbacks']['stop']
label_continue = cfg['labels']['continue'] label_continue = contract['defaultButtons'][0][0]['text']
label_stop = cfg['labels']['stop'] label_stop = contract['defaultButtons'][0][1]['text']
resolved_continue = cfg['resolvedLabels']['continue'] resolved_continue = contract['resolved']['continue']['buttons'][0][0]['text']
resolved_stop = cfg['resolvedLabels']['stop'] resolved_stop = contract['resolved']['stop']['buttons'][0][1]['text']
ack_continue = cfg['ack']['continue'] ack_continue = contract['resolved']['continue']['acknowledgement']
ack_stop = cfg['ack']['stop'] ack_stop = contract['resolved']['stop']['acknowledgement']
stop_policy = cfg['stopPolicyText'] stop_policy = cfg['stopPolicyText']
send_text = send_js.read_text(encoding='utf-8') send_text = send_js.read_text(encoding='utf-8')

View File

@@ -0,0 +1,5 @@
import { buildOpenClawTelegramPatchContract } from "../src/runtime/openclaw-telegram-patch-contract.ts"
const contract = buildOpenClawTelegramPatchContract()
process.stdout.write(`${JSON.stringify(contract, null, 2)}\n`)