diff --git a/scripts/apply-openclaw-poc-patch.sh b/scripts/apply-openclaw-poc-patch.sh index 7d44b31..a517bad 100644 --- a/scripts/apply-openclaw-poc-patch.sh +++ b/scripts/apply-openclaw-poc-patch.sh @@ -10,6 +10,10 @@ DIST_DIR="$1" SEND_JS="${DIST_DIR}/send-sxDwUGaO.js" BOT_JS="${DIST_DIR}/bot-Ce301bOE.js" 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 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 "${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 import json import sys @@ -27,16 +31,18 @@ import sys send_js = Path(sys.argv[1]) bot_js = Path(sys.argv[2]) config_path = Path(sys.argv[3]) +patch_contract_path = Path(sys.argv[4]) 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_stop = cfg['callbacks']['stop'] -label_continue = cfg['labels']['continue'] -label_stop = cfg['labels']['stop'] -resolved_continue = cfg['resolvedLabels']['continue'] -resolved_stop = cfg['resolvedLabels']['stop'] -ack_continue = cfg['ack']['continue'] -ack_stop = cfg['ack']['stop'] +label_continue = contract['defaultButtons'][0][0]['text'] +label_stop = contract['defaultButtons'][0][1]['text'] +resolved_continue = contract['resolved']['continue']['buttons'][0][0]['text'] +resolved_stop = contract['resolved']['stop']['buttons'][0][1]['text'] +ack_continue = contract['resolved']['continue']['acknowledgement'] +ack_stop = contract['resolved']['stop']['acknowledgement'] stop_policy = cfg['stopPolicyText'] send_text = send_js.read_text(encoding='utf-8') diff --git a/scripts/render-openclaw-patch-contract.mjs b/scripts/render-openclaw-patch-contract.mjs new file mode 100644 index 0000000..7682784 --- /dev/null +++ b/scripts/render-openclaw-patch-contract.mjs @@ -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`)