refactor: derive apply patch values from patch contract / 讓 apply patch 值來自 patch contract
This commit is contained in:
@@ -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')
|
||||
|
||||
5
scripts/render-openclaw-patch-contract.mjs
Normal file
5
scripts/render-openclaw-patch-contract.mjs
Normal 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`)
|
||||
Reference in New Issue
Block a user