@itpay/cli 0.2.13 → 0.2.14
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
|
@@ -245,7 +245,7 @@ Payment QR rules:
|
|
|
245
245
|
- Otherwise render the ItPay-hosted `qr_png_url` / `preferred_qr_url`.
|
|
246
246
|
- Use `mobile_wallet_url` only as a human mobile fallback.
|
|
247
247
|
- Do not generate your own QR from payment URLs.
|
|
248
|
-
- In OpenClaw Telegram,
|
|
248
|
+
- In OpenClaw Telegram, run root `agent_action.command` or `agent_action.argv` before replying; do not simulate buttons in normal prose.
|
|
249
249
|
- Telegram native buttons require `presentation.blocks[].type="buttons"` with `text/url/callback_data`.
|
|
250
250
|
- For Codex/Claude Code, send root `agent_instruction.markdown` before any next ItPay command.
|
|
251
251
|
- If status is `payment_handoff_required`, `next` is the human reply step, not payment wait.
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
{
|
|
27
27
|
"intent": "create payment intent through the high-level buy flow",
|
|
28
28
|
"command": "itp buy <variant_id> --email <buyer_email> --phone <buyer_phone> --display agent --no-wait-payment --host <client> --json",
|
|
29
|
-
"success_signal": "response.status is payment_handoff_required; for OpenClaw Telegram,
|
|
29
|
+
"success_signal": "response.status is payment_handoff_required; for OpenClaw Telegram, execute response.agent_action.command or response.agent_action.argv before any normal reply or status check"
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"intent": "recover a scanner order-not-found display problem",
|
|
@@ -43,8 +43,10 @@
|
|
|
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.
|
|
47
|
-
"In OpenClaw Telegram,
|
|
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.",
|
|
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.",
|
|
49
|
+
"response.agent_instruction is natural-language reinforcement for the agent; it does not replace response.agent_action.",
|
|
48
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.",
|
|
49
51
|
"If agent_instruction links/buttons include URLs, include the real URL. Do not only show the link label.",
|
|
50
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.",
|
|
@@ -36,7 +36,7 @@
|
|
|
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.
|
|
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
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.",
|
|
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.",
|
|
@@ -45,14 +45,14 @@
|
|
|
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
|
|
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"
|
|
49
49
|
}
|
|
50
50
|
],
|
|
51
51
|
"agent_rules": [
|
|
52
52
|
"Use --json for every ItPay command.",
|
|
53
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>.",
|
|
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
|
-
"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
|
|
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.",
|
|
57
57
|
"If `status --refresh` returns `recoverable_context.found=true`, do not blindly resume or blindly ignore it. Decide whether the old task is related to the current user intent; continue related tasks, ignore clearly unrelated tasks, and ask the human when unsure.",
|
|
58
58
|
"If the catalog is unclear, read catalog-search docs and use buyer shelf manifest/snapshot as the shopping-list view before guessing keywords.",
|
|
@@ -66,13 +66,15 @@
|
|
|
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
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.
|
|
70
|
-
"In OpenClaw Telegram,
|
|
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.",
|
|
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.",
|
|
72
|
+
"response.agent_instruction is natural-language reinforcement for the agent; it does not replace response.agent_action.",
|
|
71
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.",
|
|
72
74
|
"Show the returned payment QR exactly as provided before starting payment wait.",
|
|
73
75
|
"Payment truth comes only from payment_intent.verified.",
|
|
74
76
|
"Secure delivery goes to the human first; report redacted delivery status only.",
|
|
75
|
-
"For OpenClaw Telegram, root
|
|
77
|
+
"For OpenClaw Telegram, root agent_action is the execution path. Do not use handwritten prose when agent_action is present."
|
|
76
78
|
],
|
|
77
79
|
"forbidden": [
|
|
78
80
|
"Do not call ops commands from the buyer path.",
|
package/lib/buyer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
appendURLQuery, booleanFlag, cliCommand, cryptoRandom, csvValues, deleteSessionCredential, intFlag, output, positional, readConfig, readCredentials,
|
|
3
3
|
readSessionToken, readState, safeErrorMessage, sleep, splitCSV, stripInternalBuyerFields, updateRun, writeConfig,
|
|
4
|
-
writeCredentials, writeSessionCredentials, writeState
|
|
4
|
+
writeCredentials, writeSessionCredentials, writeState, shellQuote
|
|
5
5
|
} from "./env.js";
|
|
6
6
|
import { clientCommandArgs, clientHost, clientTarget } from "./client-context.js";
|
|
7
7
|
import { coreApi, coreApiBase } from "./http.js";
|
|
@@ -1592,38 +1592,61 @@ function telegramBuyerInstruction(value = {}, flags = {}) {
|
|
|
1592
1592
|
const hasHumanEntry = Boolean(media || presentation.blocks?.some((block) => block.type === "buttons" && block.buttons?.some((button) => button.url)));
|
|
1593
1593
|
const text = telegramBuyerInstructionText(plan.kind, summary, hasHumanEntry);
|
|
1594
1594
|
const callbacks = rawMessage.callbacks || {};
|
|
1595
|
+
const commandArgs = compactObject({
|
|
1596
|
+
channel: "telegram",
|
|
1597
|
+
target: clientTarget(flags) || undefined,
|
|
1598
|
+
message: text,
|
|
1599
|
+
media: media || undefined,
|
|
1600
|
+
presentation
|
|
1601
|
+
});
|
|
1602
|
+
const action = telegramAgentAction(commandArgs);
|
|
1603
|
+
const instruction = "必须先执行顶层 agent_action.command 或 agent_action.argv,把二维码、说明和 Telegram 原生按钮发给用户。不要手写 Markdown 表格,不要只贴链接,不要先运行 wait/status;如果不能执行 openclaw message send,就停止并说明工具缺失。";
|
|
1595
1604
|
return compactObject({
|
|
1596
1605
|
status: value.status,
|
|
1606
|
+
instruction,
|
|
1597
1607
|
must_send_to_human_before_next_command: true,
|
|
1608
|
+
must_execute_agent_action_before_reply: true,
|
|
1598
1609
|
order_summary: summary,
|
|
1610
|
+
agent_action: action,
|
|
1599
1611
|
agent_instruction: {
|
|
1600
1612
|
type: plan.kind === "auth_qr" ? "send_telegram_auth_handoff" : "send_telegram_payment_handoff",
|
|
1601
1613
|
platform: "telegram",
|
|
1602
1614
|
proof_rule: plan.proof_rule,
|
|
1603
|
-
instruction
|
|
1615
|
+
instruction,
|
|
1604
1616
|
openclaw_message: {
|
|
1605
1617
|
command: "openclaw message send",
|
|
1606
|
-
command_args:
|
|
1607
|
-
channel: "telegram",
|
|
1608
|
-
target: clientTarget(flags) || undefined,
|
|
1609
|
-
message: text,
|
|
1610
|
-
media: media || undefined,
|
|
1611
|
-
presentation
|
|
1612
|
-
}),
|
|
1618
|
+
command_args: commandArgs,
|
|
1613
1619
|
telegram_rule: "Telegram 原生按钮必须通过 openclaw message send --presentation 发送;presentation.blocks[].type=\"buttons\" 才会生成 Inline Keyboard。",
|
|
1614
1620
|
callbacks
|
|
1615
1621
|
}
|
|
1616
1622
|
},
|
|
1617
1623
|
after_human_response: telegramAfterHumanResponse(value, callbacks),
|
|
1618
|
-
agent_next_actions: ["
|
|
1624
|
+
agent_next_actions: ["execute_agent_action"],
|
|
1619
1625
|
next: {
|
|
1620
1626
|
type: "reply_to_human",
|
|
1621
1627
|
safe_for_agent: false,
|
|
1622
|
-
instruction: "
|
|
1628
|
+
instruction: "先执行 agent_action.command/argv;用户点击按钮或回复后,再运行 after_human_response 里的命令。"
|
|
1623
1629
|
}
|
|
1624
1630
|
});
|
|
1625
1631
|
}
|
|
1626
1632
|
|
|
1633
|
+
function telegramAgentAction(commandArgs = {}) {
|
|
1634
|
+
const argv = ["openclaw", "message", "send"];
|
|
1635
|
+
if (commandArgs.channel) argv.push("--channel", commandArgs.channel);
|
|
1636
|
+
if (commandArgs.target) argv.push("--target", commandArgs.target);
|
|
1637
|
+
if (commandArgs.message) argv.push("--message", commandArgs.message);
|
|
1638
|
+
if (commandArgs.media) argv.push("--media", commandArgs.media);
|
|
1639
|
+
if (commandArgs.presentation) argv.push("--presentation", JSON.stringify(commandArgs.presentation));
|
|
1640
|
+
return {
|
|
1641
|
+
type: "openclaw_message_send",
|
|
1642
|
+
tool: "shell",
|
|
1643
|
+
instruction: "现在立刻执行这个 shell 命令发送 Telegram 原生消息;不要改写为普通聊天回复。执行成功后再简短告诉用户已发出。",
|
|
1644
|
+
command: argv.map((item) => shellQuote(String(item))).join(" "),
|
|
1645
|
+
argv,
|
|
1646
|
+
if_unavailable: "如果当前 agent 不能执行 openclaw message send,停止并告诉用户:当前 agent 缺少 Telegram 原生按钮发送工具;不要降级成 Markdown 表格或普通链接。"
|
|
1647
|
+
};
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1627
1650
|
function markdownBuyerInstruction(value = {}, flags = {}, platform = "codex_app", markdown = "") {
|
|
1628
1651
|
const plan = value.render_plan || {};
|
|
1629
1652
|
const summary = buyerOrderSummary(value, plan.kind);
|
package/package.json
CHANGED
|
@@ -35,7 +35,13 @@ OpenClaw Telegram private/group chat: --host telegram --target <inbound_meta.cha
|
|
|
35
35
|
For Telegram groups or @mention flows, use the same OpenClaw inbound
|
|
36
36
|
`chat_id` as the target, for example `--target telegram:-1001234567890`.
|
|
37
37
|
OpenClaw owns group allowlists and mention policy; ItPay only echoes the target
|
|
38
|
-
into
|
|
38
|
+
into the returned `agent_action`.
|
|
39
|
+
|
|
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.
|
|
39
45
|
|
|
40
46
|
Run these commands before buying:
|
|
41
47
|
|
|
@@ -229,13 +235,12 @@ itp buy <variant_id> --email <buyer_email> --phone <buyer_phone> --display agent
|
|
|
229
235
|
This keeps JSON output machine-readable while allowing the CLI to prepare a
|
|
230
236
|
local QR image path for clients that cannot render remote SVG reliably. In
|
|
231
237
|
agent/chat clients, prefer `--no-wait-payment`. In OpenClaw Telegram, if
|
|
232
|
-
`
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
command.
|
|
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.
|
|
239
244
|
|
|
240
245
|
If a response has `status=payment_handoff_required`, `next` is the user-visible
|
|
241
246
|
reply step, not payment wait. Do not run `buyer payment wait` until the human
|