chore: align patch flow with repo-side contracts / 對齊 patch 流程與 repo-side contracts
This commit is contained in:
@@ -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);'
|
||||
|
||||
@@ -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", ""),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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/)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user