@itpay/cli 0.2.14 → 0.2.16

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
@@ -158,9 +158,12 @@ Before starting a new purchase, agents should inspect recoverable local state:
158
158
  itp status --refresh --host <client> --json
159
159
  ```
160
160
 
161
- Every non-doc command needs a client context. Use `--host codex`,
162
- `--host claude-code`, `--host terminal`, or `--host plain-chat`. For OpenClaw
163
- Telegram private/group chat, use `--host telegram --target <inbound_meta.chat_id>`.
161
+ Every non-doc command needs a client context. `--host` means the
162
+ human-visible client/surface, not where the shell command runs. Use
163
+ `--host codex` in Codex desktop chat even when you call `itp` through shell;
164
+ use `--host terminal` only when the human is directly reading a terminal. For
165
+ OpenClaw Telegram private/group chat, use
166
+ `--host telegram --target <inbound_meta.chat_id>`.
164
167
  If the CLI returns `client_context_required` or `client_target_required`, rerun
165
168
  the same command with the requested fields.
166
169
 
@@ -247,8 +250,9 @@ Payment QR rules:
247
250
  - Do not generate your own QR from payment URLs.
248
251
  - In OpenClaw Telegram, run root `agent_action.command` or `agent_action.argv` before replying; do not simulate buttons in normal prose.
249
252
  - Telegram native buttons require `presentation.blocks[].type="buttons"` with `text/url/callback_data`.
250
- - For Codex/Claude Code, send root `agent_instruction.markdown` before any next ItPay command.
251
- - If status is `payment_handoff_required`, `next` is the human reply step, not payment wait.
253
+ - For Codex/Claude Code app clients, send root `agent_action.markdown` first; once it is visible in the current chat, run `after_visible_action.command` once by default. Stop only if visibility is uncertain.
254
+ - For terminal clients, run root `agent_action.command` only when the human is directly watching that terminal. Do not use `--host terminal` merely because you invoke `itp` through shell.
255
+ - If status is `payment_handoff_required`, follow `next.type`: Codex/Claude app clients normally send-to-human then wait once; plain chat stops for the human.
252
256
  - Treat only `payment_intent.verified` as payment success.
253
257
 
254
258
  If the human wants the agent to analyze delivered content, the human must reveal
@@ -35,7 +35,7 @@
35
35
  }
36
36
  ],
37
37
  "agent_rules": [
38
- "Every non-doc ItPay command must include current client context. Use --host codex/claude-code/terminal/plain-chat, or for OpenClaw Telegram use --host telegram --target <inbound_meta.chat_id>.",
38
+ "Every non-doc ItPay command must include current client context. Use --host codex/claude-code/terminal/plain-chat, or for OpenClaw Telegram use --host telegram --target <inbound_meta.chat_id>. --host is the human-visible client/surface, not where the shell command runs; in Codex desktop chat use --host codex even when calling itp through shell.",
39
39
  "If ItPay returns client_context_required or client_target_required, rerun the same command with the requested --host/--target before doing anything else.",
40
40
  "If human_action.kind is auth_qr, present the ItPay first-purchase entry URL/QR and explain it starts account login/registration/profile authorization and should continue to payment for the same checkout after approval.",
41
41
  "For auth_qr, the ItPay auth entry is the primary handoff. oauth_start_url is fallback/debug and should not replace the ItPay orchestration page.",
@@ -43,16 +43,16 @@
43
43
  "Payment QR display requires both a valid/saved buyer session and payment_intent_id. If payment_intent_id appears before buyer_session is saved, run buyer checkout resume/status instead of showing payment QR.",
44
44
  "Do not stop after showing auth_qr unless the human explicitly asks you to pause. Keep waiting/resuming the same checkout so the post-auth payment handoff can continue.",
45
45
  "Do not describe auth_qr as payment success or payment proof. Only payment_intent.verified proves payment.",
46
- "If response.agent_action is present, it is the mandatory execution path. Execute response.agent_action.command or response.agent_action.argv before any normal prose reply or next ItPay command.",
46
+ "If response.agent_action is present, it is the mandatory execution path. Execute it before any normal prose reply or next ItPay command: command/argv for Telegram or terminal, markdown for Codex/Claude Code app clients.",
47
47
  "In OpenClaw Telegram, response.agent_action is already the exact openclaw message send command. Do not rebuild it, do not summarize it, and do not rewrite it into a custom table.",
48
- "If response.agent_action cannot be executed, stop and tell the human this agent lacks OpenClaw native message-send capability. Do not fall back to Markdown.",
48
+ "If response.agent_action cannot be executed or made visible to the human, stop and tell the human what capability is missing. Do not fall back to handmade prose.",
49
49
  "response.agent_instruction is natural-language reinforcement for the agent; it does not replace response.agent_action.",
50
50
  "Telegram native buttons require openclaw message send --presentation; presentation.blocks[].type=\"buttons\" uses native text/url/callback_data. Do not simulate buttons in normal prose.",
51
51
  "If agent_instruction links/buttons include URLs, include the real URL. Do not only show the link label.",
52
- "In Codex or Claude Code app clients, send response.agent_instruction.markdown first. Do not start a hidden long wait before the human-visible message is sent.",
52
+ "In Codex or Claude Code app clients, send response.agent_action.markdown first. Once it is visible in the current chat, immediately run response.after_visible_action.command once; do not start a hidden wait before the human-visible message is sent.",
53
53
  "For Telegram-style message clients, send photo media first, include links, and expose native buttons for refresh/status when the adapter supports them.",
54
54
  "For plain chat clients, show response.agent_instruction.message/links and stop unless the human asks you to check status or returns with a payment question.",
55
- "When response.status is payment_handoff_required, response.next is the human reply step, not payment wait.",
55
+ "When response.status is payment_handoff_required, response.next describes the current client handoff. For Codex/Claude Code, send the markdown and then run after_visible_action once if visible; for plain chat, stop for the human.",
56
56
  "MUST show local_qr_path first when present. Many agent clients do not reliably render remote QR images; local_qr_path is the most reliable desktop/chat display artifact.",
57
57
  "If local_qr_path is not present, show qr_png_url or preferred_qr_url as the primary scannable QR. This is an ItPay-hosted human QR image; it may render the native provider payment code for scanner reliability, but the agent must not request or decode the raw provider payload.",
58
58
  "Use qr_image_url/SVG only as a fallback when PNG/local rendering is unavailable.",
@@ -60,8 +60,8 @@
60
60
  "payment_entry_url is the stable ItPay status/payment page. qr_png_url/local_qr_path is usually the better desktop scanner artifact.",
61
61
  "The provider can briefly show order not found even after precreate succeeded. Tell the human to wait 30-60 seconds and retry the same QR/page. Do not create a new checkout, do not create a new payment intent, and do not repeatedly refresh unless the ItPay page or CLI explicitly asks for recovery.",
62
62
  "Opening the payment page must not be treated as paid.",
63
- "Do not run payment wait before the QR/link has been sent to the human. Without an explicit short timeout, CLI returns payment_handoff_required instead of blocking.",
64
- "After the human says they paid or clicks a platform status button, run response.after_human_response.check_payment_command for the same payment_intent_id."
63
+ "Do not run payment wait before the QR/link has been sent to the human. If response.after_visible_action.command exists and you can confirm the handoff is visible, run it once by default; if unsure, stop and wait for the human.",
64
+ "If response.after_visible_action was not run, or after the human says they paid/clicks a platform status button later, run response.after_human_response.check_payment_command for the same payment_intent_id."
65
65
  ],
66
66
  "forbidden": [
67
67
  "Do not encode payment_entry_url into a new QR yourself when qr_png_url/local_qr_path is available.",
@@ -36,12 +36,12 @@
36
36
  ],
37
37
  "agent_rules": [
38
38
  "Every payment wait/status command must include the same client context as the handoff command. For OpenClaw Telegram, keep --host telegram --target <same chat_id>.",
39
- "If payment wait returns payment_handoff_required with response.agent_action, execute response.agent_action.command or response.agent_action.argv before any later status check. If only response.agent_instruction is present, follow it exactly before any later status check.",
40
- "Start payment status checks only after the QR image/link has already been sent to the human or the human asks to check status.",
39
+ "If payment wait returns payment_handoff_required with response.agent_action, execute it before any later status check: command/argv for Telegram or terminal, markdown for Codex/Claude Code app clients. If only response.agent_instruction is present, follow it exactly before any later status check.",
40
+ "Start payment status checks only after the QR image/link has already been sent to the human. In Codex/Claude Code app clients, after_visible_action.command is the default one-round status check once the handoff is visible.",
41
41
  "If you run payment wait without a short timeout while payment is still pending, CLI returns payment_handoff_required and the human handoff instruction instead of long-polling.",
42
42
  "Payment wait/status check is a recovery loop around the same payment_intent_id, not a one-shot command.",
43
43
  "wait.timeout is a heartbeat, not a payment failure.",
44
- "In Codex or Claude Code app clients, after showing QR, use a short status check first. If the human still has not paid, explain that the same QR/link remains valid and pause for their reply.",
44
+ "In Codex or Claude Code app clients, after showing QR and confirming it is visible, run after_visible_action.command once. If it times out, explain that the same QR/link remains valid and pause for the human or continue only if they ask.",
45
45
  "Continue checking the same payment_intent_id unless the user explicitly cancels or asks you to pause.",
46
46
  "If the network drops, the process is interrupted, or there is no response, rerun payment wait with the same payment_intent_id or run checkout status/resume with the same checkout_id.",
47
47
  "If status is unclear, tell the human it is unclear and continue querying the same payment_intent_id/checkout_id. Do not create a new checkout.",
@@ -45,12 +45,12 @@
45
45
  {
46
46
  "intent": "buy a selected variant with the high-level cart-first flow",
47
47
  "command": "itp buy <variant_id> --email <buyer_email> --phone <buyer_phone> --display agent --no-wait-payment --host <client> --json",
48
- "success_signal": "response.status becomes waiting_human_auth or payment_handoff_required; in OpenClaw Telegram, if agent_action is present, execute response.agent_action.command or response.agent_action.argv before any normal reply or payment status check"
48
+ "success_signal": "response.status becomes waiting_human_auth or payment_handoff_required; if agent_action is present, execute it before any normal reply or payment status check"
49
49
  }
50
50
  ],
51
51
  "agent_rules": [
52
52
  "Use --json for every ItPay command.",
53
- "Every non-doc ItPay command must include the current client context: --host codex, --host claude-code, --host terminal, --host plain-chat, or for OpenClaw/Telegram use --host telegram --target <inbound_meta.chat_id>.",
53
+ "Every non-doc ItPay command must include the current client context: --host codex, --host claude-code, --host terminal, --host plain-chat, or for OpenClaw/Telegram use --host telegram --target <inbound_meta.chat_id>. --host is the human-visible client/surface, not where the shell command runs; in Codex desktop chat use --host codex even when calling itp through shell.",
54
54
  "Do not rely on the CLI to guess Telegram, Discord, WhatsApp, Codex, or Claude Code. If ItPay returns client_context_required or client_target_required, rerun the same command with the required --host/--target fields before continuing.",
55
55
  "For Telegram group chat or @mention flows, pass the group/private chat target from OpenClaw inbound metadata, for example --target telegram:-1001234567890. ItPay only echoes the target into agent_action; OpenClaw owns group allowlist/mention policy.",
56
56
  "Use `itp status --refresh --host <client> --json` before account, order, refund, or repeat-purchase decisions. Plain local memory is not identity.",
@@ -65,12 +65,12 @@
65
65
  "After showing auth_qr, keep running/resuming the same checkout unless the human explicitly asks you to pause. Do not stop merely because a QR was displayed.",
66
66
  "When a buyer command returns buyer_session.status=buyer_session_saved, the CLI has stored the buyer account session for this agent device. You may continue with checkout/payment or `buyer vault` commands without asking the human for a token.",
67
67
  "Vault grants are only for reading approved delivered artifacts. They are not buyer session credentials and do not authorize refunds or account/order management.",
68
- "Use high-level itp buy when possible, but in agent app clients split payment into two visible steps: first return and send the human handoff instruction, then only check status after the human responds or uses a platform button.",
69
- "If response.agent_action is present, it is the mandatory execution path for the current client. Execute response.agent_action.command or response.agent_action.argv before any normal prose reply.",
68
+ "Use high-level itp buy when possible. In Codex/Claude Code app clients, the default payment flow is one round: send response.agent_action.markdown to the current chat, then immediately run response.after_visible_action.command once if the QR/link is visible.",
69
+ "If response.agent_action is present, it is the mandatory execution path for the current client. Execute it before any normal prose reply: command/argv for Telegram or terminal, markdown for Codex/Claude Code app clients.",
70
70
  "In OpenClaw Telegram, response.agent_action is already the exact openclaw message send command. It includes target, QR media, exact message, and native button presentation.",
71
- "If response.agent_action cannot be executed, stop and tell the human this agent lacks OpenClaw native message-send capability. Do not fall back to Markdown or handwritten prose.",
71
+ "If response.agent_action cannot be executed or made visible to the human, stop and tell the human what capability is missing. Do not fall back to handwritten prose.",
72
72
  "response.agent_instruction is natural-language reinforcement for the agent; it does not replace response.agent_action.",
73
- "If response.status is payment_handoff_required, do not run payment wait from next.command; next is the human-visible reply. Only after the human asks to check payment should you run after_human_response.check_payment_command.",
73
+ "If response.status is payment_handoff_required, do not run payment wait before the QR/link is visible. If response.next.type is send_to_human_then_wait_once_if_visible, send agent_action first, then run after_visible_action.command once. Stop only when visibility is uncertain.",
74
74
  "Show the returned payment QR exactly as provided before starting payment wait.",
75
75
  "Payment truth comes only from payment_intent.verified.",
76
76
  "Secure delivery goes to the human first; report redacted delivery status only.",
package/lib/buyer.js CHANGED
@@ -1155,14 +1155,14 @@ function isTelegramBuyerHost(flags = {}) {
1155
1155
  }
1156
1156
 
1157
1157
  function paymentHandoffAgentNextActions() {
1158
- return ["send_agent_instruction_to_human"];
1158
+ return ["send_agent_instruction_to_human", "run_after_visible_action_once_if_visible"];
1159
1159
  }
1160
1160
 
1161
1161
  function paymentHandoffNext() {
1162
1162
  return {
1163
- type: "reply_to_human",
1164
- safe_for_agent: false,
1165
- instruction: "Send agent_instruction to the human now. Do not run payment wait until this message is visible to the human."
1163
+ type: "send_to_human_then_wait_once_if_visible",
1164
+ safe_for_agent: true,
1165
+ instruction: "Send agent_instruction to the human first. If it is visible, run after_visible_action once; otherwise stop and wait for the human."
1166
1166
  };
1167
1167
  }
1168
1168
 
@@ -1650,13 +1650,26 @@ function telegramAgentAction(commandArgs = {}) {
1650
1650
  function markdownBuyerInstruction(value = {}, flags = {}, platform = "codex_app", markdown = "") {
1651
1651
  const plan = value.render_plan || {};
1652
1652
  const summary = buyerOrderSummary(value, plan.kind);
1653
+ const instruction = markdownBuyerInstructionText(platform);
1653
1654
  return handoffInstructionOutput(value, flags, {
1654
1655
  type: plan.kind === "auth_qr" ? "send_markdown_auth_handoff" : "send_markdown_payment_handoff",
1655
1656
  platform,
1656
1657
  proof_rule: plan.proof_rule,
1657
- instruction: "必须先把 markdown 原样发给用户;不要先运行 wait/status。只有 payment_intent.verified 才算付款成功。",
1658
+ instruction,
1658
1659
  markdown
1659
- }, summary);
1660
+ }, summary, {
1661
+ instruction,
1662
+ preferred_flow: "send_agent_action_then_wait_once",
1663
+ agent_action: markdownAgentAction(platform, markdown),
1664
+ after_visible_action: afterVisibleAction(value, flags, summary),
1665
+ after_human_response_fallback: true,
1666
+ agent_next_actions: ["send_agent_action_to_human", "run_after_visible_action_once_if_visible"],
1667
+ next: {
1668
+ type: "send_to_human_then_wait_once_if_visible",
1669
+ safe_for_agent: true,
1670
+ instruction: "先把 agent_action.markdown 原样发到当前聊天;确认二维码、摘要和链接可见后,立刻执行 after_visible_action.command 等一次。只有无法确认可见时才停下等人类。"
1671
+ }
1672
+ });
1660
1673
  }
1661
1674
 
1662
1675
  function plainChatBuyerInstruction(value = {}, flags = {}, selected = {}) {
@@ -1675,31 +1688,103 @@ function plainChatBuyerInstruction(value = {}, flags = {}, selected = {}) {
1675
1688
  function terminalBuyerInstruction(value = {}, flags = {}) {
1676
1689
  const plan = value.render_plan || {};
1677
1690
  const summary = buyerOrderSummary(value, plan.kind);
1691
+ const instruction = "必须先执行 agent_action.command,让 CLI 在人类正在看的终端里打印二维码、链接和摘要;不要把 terminal 当成 Codex 桌面端。如果人类不是直接看这个终端,改用 --host codex 重跑。";
1678
1692
  return handoffInstructionOutput(value, flags, {
1679
1693
  type: plan.kind === "auth_qr" ? "terminal_auth_handoff" : "terminal_payment_handoff",
1680
1694
  platform: "terminal",
1681
1695
  proof_rule: plan.proof_rule,
1682
- instruction: "CLI 已负责终端展示;用户回复后再运行 after_human_response 里的命令。",
1696
+ instruction,
1683
1697
  print_terminal_qr: true
1684
- }, summary);
1698
+ }, summary, {
1699
+ instruction,
1700
+ preferred_flow: "execute_agent_action_then_wait_once",
1701
+ agent_action: terminalAgentAction(summary, flags, plan.kind),
1702
+ after_visible_action: afterVisibleAction(value, flags, summary),
1703
+ after_human_response_fallback: true,
1704
+ agent_next_actions: ["execute_agent_action", "run_after_visible_action_once_if_visible"],
1705
+ next: {
1706
+ type: "execute_terminal_handoff_then_wait_once_if_visible",
1707
+ safe_for_agent: true,
1708
+ instruction: "先执行 agent_action.command,让人类正在看的终端显示二维码和链接;确认可见后,立刻执行 after_visible_action.command 等一次。若人类不是直接看终端,停止并用正确 --host 重跑。"
1709
+ }
1710
+ });
1685
1711
  }
1686
1712
 
1687
- function handoffInstructionOutput(value = {}, flags = {}, agentInstruction = {}, summary = {}) {
1713
+ function handoffInstructionOutput(value = {}, flags = {}, agentInstruction = {}, summary = {}, extra = {}) {
1714
+ const afterHumanResponse = genericAfterHumanResponse(value, flags, summary);
1715
+ if (extra.after_human_response_fallback) {
1716
+ afterHumanResponse.fallback = true;
1717
+ afterHumanResponse.instruction = "Fallback only: use check_status_command when after_visible_action was not run, or when the human later replies/clicks status. User text is not proof.";
1718
+ }
1688
1719
  return compactObject({
1689
1720
  status: value.status,
1721
+ instruction: extra.instruction,
1690
1722
  must_send_to_human_before_next_command: true,
1723
+ preferred_flow: extra.preferred_flow,
1691
1724
  order_summary: summary,
1725
+ agent_action: extra.agent_action,
1692
1726
  agent_instruction: agentInstruction,
1693
- after_human_response: genericAfterHumanResponse(value, flags, summary),
1694
- agent_next_actions: ["send_agent_instruction_to_human"],
1695
- next: {
1727
+ after_visible_action: extra.after_visible_action,
1728
+ after_human_response: afterHumanResponse,
1729
+ agent_next_actions: extra.agent_next_actions || ["send_agent_instruction_to_human"],
1730
+ next: extra.next || {
1696
1731
  type: "reply_to_human",
1697
1732
  safe_for_agent: false,
1698
- instruction: "先把 agent_instruction 发送给用户;用户点击按钮或回复后,再运行 after_human_response 里的命令。"
1733
+ instruction: extra.next_instruction || "先把 agent_instruction 发送给用户;用户点击按钮或回复后,再运行 after_human_response 里的命令。"
1699
1734
  }
1700
1735
  });
1701
1736
  }
1702
1737
 
1738
+ function markdownBuyerInstructionText(platform = "codex_app") {
1739
+ const label = platform === "claude_code" ? "Claude Code app" : "Codex desktop app";
1740
+ return `你在 ${label}。必须先把顶层 agent_action.markdown 原样发到当前聊天,让人类真正看到二维码、订单摘要和链接;不要因为你用 shell 跑 itp 就改用 --host terminal。发出后,如果你能确认消息已经对人类可见,默认立刻执行 after_visible_action.command 等 30 秒;只有不能确认可见时才停止等人类回复。`;
1741
+ }
1742
+
1743
+ function markdownAgentAction(platform = "codex_app", markdown = "") {
1744
+ const label = platform === "claude_code" ? "Claude Code app" : "Codex desktop app";
1745
+ return {
1746
+ type: "markdown_reply",
1747
+ platform,
1748
+ instruction: `现在立刻把 markdown 原样发送到当前聊天。${label} 可以用绝对路径 Markdown 图片显示本地二维码。不要只贴文件路径,不要先运行 wait/status。`,
1749
+ markdown,
1750
+ if_unavailable: "如果当前客户端不能让这段 Markdown 对人类可见,停止并说明无法展示二维码;不要先运行 wait/status。"
1751
+ };
1752
+ }
1753
+
1754
+ function terminalAgentAction(summary = {}, flags = {}, kind = "") {
1755
+ const args = kind === "auth_qr" && summary.checkout_id
1756
+ ? ["buyer", "checkout", "resume", summary.checkout_id, ...clientCommandArgs(flags), "--no-wait-auth"]
1757
+ : summary.payment_intent_id
1758
+ ? ["buyer", "payment", "wait", summary.payment_intent_id, ...clientCommandArgs(flags)]
1759
+ : [];
1760
+ if (!args.length) return undefined;
1761
+ return {
1762
+ type: "terminal_handoff_command",
1763
+ tool: "shell",
1764
+ instruction: "只有当人类直接看这个终端窗口时才执行。它会让 CLI 打印二维码和链接。若你在 Codex 桌面聊天里,请改用 --host codex 重跑原命令。",
1765
+ command: cliCommand(...args),
1766
+ if_unavailable: "如果不能确认人类正在看该终端,停止并用正确的 --host 重跑;不要把终端输出当成 Codex 桌面端回复。"
1767
+ };
1768
+ }
1769
+
1770
+ function afterVisibleAction(value = {}, flags = {}, summary = {}) {
1771
+ if (summary.payment_intent_id) {
1772
+ return {
1773
+ recommended: true,
1774
+ command: cliCommand("buyer", "payment", "wait", summary.payment_intent_id, "--timeout", "30", ...clientCommandArgs(flags), "--json"),
1775
+ instruction: "只有在二维码、订单摘要和链接已经对人类可见后才能执行。用户说已付款不算证明,只有 payment_intent.verified 算付款成功。"
1776
+ };
1777
+ }
1778
+ if (summary.checkout_id) {
1779
+ return {
1780
+ recommended: true,
1781
+ command: cliCommand("buyer", "checkout", "resume", summary.checkout_id, ...clientCommandArgs(flags), "--json"),
1782
+ instruction: "只有在授权入口已经对人类可见后才能执行;继续同一个 checkout,不要新建 checkout。"
1783
+ };
1784
+ }
1785
+ return undefined;
1786
+ }
1787
+
1703
1788
  function buyerOrderSummary(value = {}, kind = "") {
1704
1789
  const cart = value.cart || {};
1705
1790
  const checkout = value.checkout || {};
@@ -52,7 +52,7 @@ function clientContextRequired() {
52
52
  schema_version: "itp.client_context.v1",
53
53
  status: "client_context_required",
54
54
  must_rerun: true,
55
- instruction: "Rerun the same itp command with --host <client>. ItPay will not guess the current chat/app client.",
55
+ instruction: "Rerun the same itp command with --host <client>. --host means the human-visible client/surface, not where the shell command runs. In Codex desktop chat use --host codex even when calling itp through shell; use --host terminal only when the human is directly reading a terminal.",
56
56
  allowed_hosts: Array.from(SUPPORTED_HOSTS),
57
57
  examples: {
58
58
  codex: "itp ... --host codex --json",
@@ -84,7 +84,7 @@ function unsupportedClientContext(host) {
84
84
  status: "unsupported_client_context",
85
85
  must_rerun: true,
86
86
  host,
87
- instruction: "Use one supported --host value so ItPay can return a single executable human-output instruction.",
87
+ instruction: "Use one supported --host value so ItPay can return a single executable human-output instruction. --host means the human-visible client/surface, not the shell execution environment.",
88
88
  allowed_hosts: Array.from(SUPPORTED_HOSTS)
89
89
  };
90
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itpay/cli",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "ItPay CLI, buyer skill, and agent-readable docs for agent-native commerce.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,9 +20,12 @@ protocol from this file. Use the CLI docs graph whenever you need details.
20
20
 
21
21
  ## Start Here
22
22
 
23
- Every non-doc ItPay command must include the current client context. The CLI
24
- will stop with `client_context_required` or `client_target_required` rather
25
- than guess.
23
+ Every non-doc ItPay command must include the current client context. `--host`
24
+ means the human-visible client/surface, not where the shell command runs. In
25
+ Codex desktop chat use `--host codex` even when calling `itp` through shell;
26
+ use `--host terminal` only when the human is directly reading a terminal. The
27
+ CLI will stop with `client_context_required` or `client_target_required`
28
+ rather than guess.
26
29
 
27
30
  ```text
28
31
  Codex app: --host codex
@@ -37,11 +40,11 @@ For Telegram groups or @mention flows, use the same OpenClaw inbound
37
40
  OpenClaw owns group allowlists and mention policy; ItPay only echoes the target
38
41
  into the returned `agent_action`.
39
42
 
40
- If a response contains `agent_action`, run `agent_action.command` or
41
- `agent_action.argv` before writing any normal reply. Do not summarize it, do
42
- not rewrite it as Markdown, and do not run wait/status first. If the command
43
- cannot run, stop and tell the human the agent lacks the required OpenClaw
44
- message tool.
43
+ If a response contains `agent_action`, execute that action before writing any
44
+ normal reply or running wait/status. For Telegram/terminal this may be
45
+ `agent_action.command` or `agent_action.argv`; for Codex/Claude Code this may
46
+ be `agent_action.markdown`, which must be sent exactly to the current chat.
47
+ If the action cannot be made visible to the human, stop and say why.
45
48
 
46
49
  Run these commands before buying:
47
50
 
@@ -147,7 +150,7 @@ be unlocked again by the ItPay backend.
147
150
 
148
151
  ## Non-Negotiable Rules
149
152
 
150
- 1. Use `--json` and current client context for every non-doc ItPay command. Use `--host codex`, `--host claude-code`, `--host terminal`, `--host plain-chat`, or for OpenClaw Telegram use `--host telegram --target <inbound_meta.chat_id>`.
153
+ 1. Use `--json` and current client context for every non-doc ItPay command. Use `--host codex`, `--host claude-code`, `--host terminal`, `--host plain-chat`, or for OpenClaw Telegram use `--host telegram --target <inbound_meta.chat_id>`. `--host` is the human-visible client, not the shell execution environment.
151
154
  2. Do not invent service IDs, variant IDs, checkout IDs, payment URLs, QR URLs,
152
155
  payment intent IDs, delivery IDs, or claim links.
153
156
  3. When the user asks for several compatible services, use one cart and one
@@ -234,18 +237,19 @@ itp buy <variant_id> --email <buyer_email> --phone <buyer_phone> --display agent
234
237
 
235
238
  This keeps JSON output machine-readable while allowing the CLI to prepare a
236
239
  local QR image path for clients that cannot render remote SVG reliably. In
237
- agent/chat clients, prefer `--no-wait-payment`. In OpenClaw Telegram, if
238
- `agent_action` is present, execute `agent_action.command` or `agent_action.argv`
239
- exactly. It already contains `openclaw message send`, the chat target, QR
240
- media, exact human text, and `presentation.blocks[].type="buttons"` for
241
- Telegram native inline buttons. Do not rewrite it as a table or normal prose.
242
- In Codex or Claude Code app clients, send `agent_instruction.markdown` exactly
243
- before any next ItPay command.
244
-
245
- If a response has `status=payment_handoff_required`, `next` is the user-visible
246
- reply step, not payment wait. Do not run `buyer payment wait` until the human
247
- has seen the QR/link and asks to check status; then use
248
- `after_human_response.check_payment_command`.
240
+ agent/chat clients, prefer `--no-wait-payment`. If `agent_action` is present,
241
+ execute it exactly before normal prose. In OpenClaw Telegram it contains
242
+ `openclaw message send`, the chat target, QR media, exact human text, and
243
+ `presentation.blocks[].type="buttons"` for Telegram native inline buttons. In
244
+ Codex or Claude Code app clients, send `agent_action.markdown` exactly to the
245
+ current chat. In terminal, run `agent_action.command` only when the human is
246
+ directly watching that terminal.
247
+
248
+ If a response has `status=payment_handoff_required`, follow `next.type`.
249
+ For Codex/Claude Code app clients, send `agent_action.markdown` first; once it
250
+ is visible in the current chat, run `after_visible_action.command` once by
251
+ default. Do not run payment wait before the human-visible QR/link is sent. If
252
+ visibility is uncertain, stop and wait for the human.
249
253
 
250
254
  For first-purchase auth, treat the returned ItPay authorization entry as a
251
255
  single human orchestration entry. It may open Alipay login/registration first