diff --git a/scripts/apply-openclaw-poc-patch.sh b/scripts/apply-openclaw-poc-patch.sh index a517bad..e357045 100644 --- a/scripts/apply-openclaw-poc-patch.sh +++ b/scripts/apply-openclaw-poc-patch.sh @@ -9,7 +9,6 @@ fi 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}")" @@ -23,27 +22,25 @@ 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}" "${PATCH_CONTRACT_PATH}" +python3 - <<'PY' "${SEND_JS}" "${BOT_JS}" "${PATCH_CONTRACT_PATH}" from pathlib import Path import json 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')) +patch_contract_path = Path(sys.argv[3]) contract = json.loads(patch_contract_path.read_text(encoding='utf-8')) -cb_continue = cfg['callbacks']['continue'] -cb_stop = cfg['callbacks']['stop'] +cb_continue = contract['defaultButtons'][0][0]['callback_data'] +cb_stop = contract['defaultButtons'][0][1]['callback_data'] 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'] +stop_policy = contract['stopPolicyText'] send_text = send_js.read_text(encoding='utf-8') send_old = 'const replyMarkup = buildInlineKeyboard(opts.buttons);' diff --git a/src/runtime/openclaw-telegram-patch-contract.ts b/src/runtime/openclaw-telegram-patch-contract.ts index d5f7180..2b21091 100644 --- a/src/runtime/openclaw-telegram-patch-contract.ts +++ b/src/runtime/openclaw-telegram-patch-contract.ts @@ -1,5 +1,5 @@ import type { ReplyEndChoice, TelegramInlineButton } from "../types.js" -import { buildTelegramReplyEndAck, buildTelegramReplyEndButtonsForReply, buildTelegramReplyEndButtonsForResolvedChoice } from "./openclaw-telegram-bridge.js" +import { applyTelegramReplyEndStopPolicy, buildTelegramReplyEndAck, buildTelegramReplyEndButtonsForReply, buildTelegramReplyEndButtonsForResolvedChoice } from "./openclaw-telegram-bridge.js" export type OpenClawTelegramPatchContract = { defaultButtons: TelegramInlineButton[][] @@ -7,6 +7,7 @@ export type OpenClawTelegramPatchContract = { buttons: TelegramInlineButton[][] acknowledgement: string }> + stopPolicyText: string } export function buildOpenClawTelegramPatchContract(): OpenClawTelegramPatchContract { @@ -22,5 +23,12 @@ export function buildOpenClawTelegramPatchContract(): OpenClawTelegramPatchContr acknowledgement: buildTelegramReplyEndAck("stop"), }, }, + stopPolicyText: applyTelegramReplyEndStopPolicy("__BASE__", { + lastChoice: "stop", + lastChoiceAt: "1970-01-01T00:00:00Z", + sourceMessageId: "0", + sourceCallbackId: "0", + active: true, + }).replace("__BASE__\n\n", ""), } } diff --git a/tests/runtime-patch-contract.test.mjs b/tests/runtime-patch-contract.test.mjs index c2518b4..ea9cf42 100644 --- a/tests/runtime-patch-contract.test.mjs +++ b/tests/runtime-patch-contract.test.mjs @@ -11,4 +11,5 @@ test("patch contract exposes default and resolved callback behavior from shared assert.match(contract.resolved.stop.buttons[0][1].text, /^⏹/) assert.equal(contract.resolved.continue.acknowledgement, "reply-end-controls: continue received") assert.equal(contract.resolved.stop.acknowledgement, "reply-end-controls: stop received") + assert.match(contract.stopPolicyText, /reply-end-controls Stop/) })