@itpay/cli 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -240,6 +240,7 @@ Payment QR rules:
240
240
  - Use `mobile_wallet_url` only as a human mobile fallback.
241
241
  - Do not generate your own QR from payment URLs.
242
242
  - In agent app clients, execute `render_plan.selected` first. Send its media, text/markdown, real links, and native buttons when the adapter supports them.
243
+ - In OpenClaw Telegram, send `render_plan.selected.openclaw_message` with OpenClaw `message send --media ... --presentation ...`; do not put legacy inline media directives inside human prose.
243
244
  - Do not rewrite `render_plan.selected` into a custom table or omit the real URL.
244
245
  - If status is `payment_handoff_required`, `next` is the human reply step, not payment wait.
245
246
  - Treat only `payment_intent.verified` as payment success.
@@ -45,6 +45,7 @@
45
45
  "Do not rewrite response.render_plan.selected into a custom table. Use selected.text/markdown, selected.media, selected.links, and selected.buttons as provided.",
46
46
  "If selected.links exists, include the real URL. Do not only show the link label.",
47
47
  "If selected.buttons exists but the current adapter cannot render native buttons, degrade to selected.links plus short text; do not fake payment success or skip the status check.",
48
+ "In OpenClaw Telegram, prefer selected.openclaw_message: send its message/media/presentation through OpenClaw message send. Do not place legacy inline media directives inside prose; that fallback cannot render inline buttons.",
48
49
  "In Codex or Claude Code app clients, send response.human_visible_markdown or response.render_plan.platforms.codex_app.markdown to the human first. Do not start a hidden long wait before the human-visible message is sent.",
49
50
  "For Telegram-style message clients, use response.render_plan.platforms.telegram: send photo media first, include links, and expose native buttons for refresh/status when the adapter supports them.",
50
51
  "For plain chat clients, show response.human_visible_markdown and stop unless the human asks you to check status or returns with a payment question.",
@@ -68,7 +68,7 @@
68
68
  "Show the returned payment QR exactly as provided before starting payment wait.",
69
69
  "Payment truth comes only from payment_intent.verified.",
70
70
  "Secure delivery goes to the human first; report redacted delivery status only.",
71
- "When a response includes render_plan.selected, execute that selected plan first; do not make the model choose a different platform branch or rewrite the payment/auth UI."
71
+ "When a response includes render_plan.selected, execute that selected plan first; do not make the model choose a different platform branch or rewrite the payment/auth UI. In OpenClaw Telegram, use selected.openclaw_message instead of handwritten legacy media directive prose."
72
72
  ],
73
73
  "forbidden": [
74
74
  "Do not call ops commands from the buyer path.",
package/lib/buyer.js CHANGED
@@ -1649,6 +1649,7 @@ function compactHumanAction(action = null) {
1649
1649
  qr_image_url: action.qr_image_url,
1650
1650
  preferred_qr_url: action.preferred_qr_url,
1651
1651
  mobile_wallet_url: action.mobile_wallet_url,
1652
+ presentation: action.presentation,
1652
1653
  agent_display_hint: action.agent_display_hint,
1653
1654
  expires_at: action.expires_at
1654
1655
  });
@@ -377,10 +377,50 @@ function telegramRenderPlan(action = {}, { localQRPath = "", preferredQRURL = ""
377
377
  ? "请扫码或点击链接完成支付。付款后点“我已付款,查询状态”。"
378
378
  : "请打开 ItPay 授权入口,完成后回到当前对话。",
379
379
  links,
380
- buttons
380
+ buttons,
381
+ openclaw_message: openclawTelegramMessage({ action, media, links, buttons })
381
382
  };
382
383
  }
383
384
 
385
+ function openclawTelegramMessage({ action = {}, media = [], links = [], buttons = [] } = {}) {
386
+ const mediaURL = media[0]?.local_path || media[0]?.fallback_url || "";
387
+ const text = action.kind === "payment_qr"
388
+ ? "请扫码或点击链接完成支付。付款完成后点“我已付款,查询状态”,或直接回复“我已付款”。"
389
+ : "请打开 ItPay 授权入口,完成后回到当前对话。";
390
+ const presentationButtons = links.map((link) => ({ label: link.label, url: link.url }));
391
+ if (action.kind === "payment_qr") {
392
+ presentationButtons.push(
393
+ { label: "支付遇到问题 / 刷新", action: { type: "command", command: "刷新付款二维码" } },
394
+ { label: "我已付款,查询状态", action: { type: "command", command: "我已付款,查询状态" } }
395
+ );
396
+ } else {
397
+ for (const button of buttons) {
398
+ if (button.url && !presentationButtons.some((item) => item.url === button.url)) {
399
+ presentationButtons.push({ label: button.text || "打开链接", url: button.url });
400
+ }
401
+ }
402
+ }
403
+ const presentation = {
404
+ blocks: [
405
+ { type: "text", text },
406
+ ...(presentationButtons.length ? [{ type: "buttons", buttons: presentationButtons }] : [])
407
+ ]
408
+ };
409
+ return compactObject({
410
+ adapter: "openclaw",
411
+ channel: "telegram",
412
+ use: "message send --media/--presentation; do not use legacy inline media directives",
413
+ message: text,
414
+ media: mediaURL || undefined,
415
+ presentation,
416
+ command_args: compactObject({
417
+ message: text,
418
+ media: mediaURL || undefined,
419
+ presentation
420
+ })
421
+ });
422
+ }
423
+
384
424
  function selectedRenderPlatform(host = "") {
385
425
  const normalized = String(host || "").toLowerCase().replaceAll("-", "_");
386
426
  if (["codex", "codex_app", "codex_cli"].includes(normalized)) return "codex_app";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itpay/cli",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "ItPay CLI, buyer skill, and agent-readable docs for agent-native commerce.",
5
5
  "type": "module",
6
6
  "bin": {