@itpay/cli 0.2.16 → 2.0.0-rc.1

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.
Files changed (69) hide show
  1. package/README.md +148 -447
  2. package/bin/itp +1 -150
  3. package/dist/src/client/backend.js +154 -0
  4. package/dist/src/client/http.js +76 -0
  5. package/dist/src/client/types.js +4 -0
  6. package/dist/src/commands/buy.js +351 -0
  7. package/dist/src/commands/cart.js +264 -0
  8. package/dist/src/commands/catalog.js +26 -0
  9. package/dist/src/commands/checkout.js +106 -0
  10. package/dist/src/commands/docs.js +61 -0
  11. package/dist/src/commands/guidance.js +422 -0
  12. package/dist/src/commands/install.js +95 -0
  13. package/dist/src/commands/order.js +78 -0
  14. package/dist/src/commands/orders.js +22 -0
  15. package/dist/src/commands/pay.js +26 -0
  16. package/dist/src/commands/readyz.js +8 -0
  17. package/dist/src/commands/refund.js +20 -0
  18. package/dist/src/commands/services.js +317 -0
  19. package/dist/src/main.js +606 -0
  20. package/dist/src/render/feishu.js +201 -0
  21. package/dist/src/render/ide.js +321 -0
  22. package/dist/src/render/index.js +57 -0
  23. package/dist/src/render/interaction.js +49 -0
  24. package/dist/src/render/markdown.js +83 -0
  25. package/dist/src/render/output.js +42 -0
  26. package/dist/src/render/plain_chat.js +60 -0
  27. package/dist/src/render/plan.js +31 -0
  28. package/dist/src/render/qr.js +32 -0
  29. package/dist/src/render/sink.js +6 -0
  30. package/dist/src/render/status.js +37 -0
  31. package/dist/src/render/telegram.js +172 -0
  32. package/dist/src/render/terminal.js +148 -0
  33. package/dist/src/render/terminal_image.js +19 -0
  34. package/dist/src/state/cart_session.js +151 -0
  35. package/dist/src/state/client_context.js +73 -0
  36. package/dist/src/state/config.js +82 -0
  37. package/dist/src/state/device_authority.js +217 -0
  38. package/dist/src/state/operation_journal.js +80 -0
  39. package/docs/agent/buyer/cart-checkout.json +56 -94
  40. package/docs/agent/buyer/catalog-list.json +47 -0
  41. package/docs/agent/buyer/install-and-setup.json +82 -0
  42. package/docs/agent/buyer/orders-refunds.json +76 -0
  43. package/docs/agent/buyer/payment-flow.json +77 -0
  44. package/docs/agent/buyer/quickstart.json +143 -75
  45. package/docs/agent/buyer/render-hosts.json +79 -0
  46. package/package.json +32 -13
  47. package/skills/itpay-buyer/SKILL.md +107 -238
  48. package/docs/agent/buyer/account-portal.json +0 -81
  49. package/docs/agent/buyer/catalog-search.json +0 -106
  50. package/docs/agent/buyer/human-claim-ui.json +0 -77
  51. package/docs/agent/buyer/payment-qr.json +0 -97
  52. package/docs/agent/buyer/payment-wait.json +0 -84
  53. package/docs/agent/buyer/product-recommendation.json +0 -80
  54. package/docs/agent/buyer/qr-refresh.json +0 -67
  55. package/docs/agent/buyer/recovery.json +0 -85
  56. package/docs/agent/buyer/safety-policy.json +0 -70
  57. package/docs/agent/buyer/secure-delivery.json +0 -90
  58. package/docs/agent/buyer/vault-agent-read.json +0 -95
  59. package/install.ps1 +0 -65
  60. package/install.sh +0 -66
  61. package/lib/account-status.js +0 -157
  62. package/lib/buyer.js +0 -2332
  63. package/lib/client-context.js +0 -126
  64. package/lib/docs.js +0 -200
  65. package/lib/env.js +0 -723
  66. package/lib/http.js +0 -151
  67. package/lib/ops.js +0 -135
  68. package/lib/render-human.js +0 -718
  69. package/lib/runtime.js +0 -1456
@@ -1,281 +1,150 @@
1
1
  ---
2
2
  name: itpay-buyer
3
3
  description: >
4
- Use this skill when an AI agent helps a human discover, choose, buy, pay for,
5
- or receive an ItPay service through the `itp` CLI. This is a quick-start
6
- directory and safety boundary for buyer agents; detailed flow guidance lives
7
- in `itp docs ... --role buyer --json`.
4
+ Use the ItPay V3 CLI when a human asks an AI agent to discover services,
5
+ use a free capability, buy a paid result, show an ItPay checkout QR, recover
6
+ an interrupted purchase, or read a result covered by a temporary human grant.
8
7
  ---
9
8
 
10
- # ItPay Buyer Agent Skill
9
+ # ItPay V3 Buyer
11
10
 
12
- You are acting as an ItPay buyer agent. Your job is to help the human discover
13
- services, choose a purchase option, add the selected purchase option to cart, create checkout,
14
- show first-purchase account authorization when required, show the returned
15
- payment QR, wait for verified payment, and report redacted secure delivery
16
- status.
11
+ Use the CLI as the control surface. Do not recreate ItPay API calls or invent a
12
+ service-specific workflow. The backend returns the next valid actions for each
13
+ catalog item and Service Execution.
17
14
 
18
- This skill is intentionally short. Do not try to memorize the entire ItPay
19
- protocol from this file. Use the CLI docs graph whenever you need details.
15
+ ## Bootstrap
20
16
 
21
- ## Start Here
17
+ ```bash
18
+ npm install -g @itpay/cli
19
+ itpay readyz
20
+ itpay docs show quickstart
21
+ ```
22
+
23
+ This prerelease defaults to `https://test.itpay.ai`. Set `ITPAY_BACKEND_URL`
24
+ only for an intentional override.
22
25
 
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
+ Every commerce flow must identify the real runtime. Pass the global option
27
+ immediately after `itpay`, or set `ITPAY_AGENT_TYPE` once:
29
28
 
30
- ```text
31
- Codex app: --host codex
32
- Claude Code app: --host claude-code
33
- Terminal: --host terminal
34
- Plain chat: --host plain-chat
35
- OpenClaw Telegram private/group chat: --host telegram --target <inbound_meta.chat_id>
29
+ ```bash
30
+ itpay --agent-type codex-desktop catalog list --json
36
31
  ```
37
32
 
38
- For Telegram groups or @mention flows, use the same OpenClaw inbound
39
- `chat_id` as the target, for example `--target telegram:-1001234567890`.
40
- OpenClaw owns group allowlists and mention policy; ItPay only echoes the target
41
- into the returned `agent_action`.
33
+ Examples include `codex-desktop`, `codex-cli`, `claude-code-desktop`,
34
+ `claude-code-cli`, and the actual WorkBuddy/OpenClaw runtime name. Never rotate
35
+ the type or local device files to obtain more free quota. The CLI enrolls one
36
+ signed device under `~/.itpay-v3/device` and registers each runtime on it.
42
37
 
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.
38
+ ## Golden Flow
48
39
 
49
- Run these commands before buying:
40
+ 1. Discover, then use IDs returned by the CLI:
50
41
 
51
42
  ```bash
52
- itp status --refresh --host <client> --json
53
- itp docs show quickstart --role buyer --json
54
- itp docs list --role buyer --json
43
+ itpay --agent-type <agent_type> catalog list --json
44
+ itpay --agent-type <agent_type> services start <service_id>
55
45
  ```
56
46
 
57
- If you are confused, search the agent docs instead of guessing:
47
+ 2. Ask the server for the next step:
58
48
 
59
49
  ```bash
60
- itp docs search "<what you need to know>" --role buyer --json
50
+ itpay --agent-type <agent_type> services next <service_execution_id> --json
61
51
  ```
62
52
 
63
- ## Standard Buyer Flow
64
-
65
- ```text
66
- read this skill
67
- -> read quickstart doc
68
- -> run status --refresh; follow next.command if unauthenticated, and if recoverable_context.found=true decide whether the old task matches the current user intent
69
- -> read catalog-search doc and shelf when the service catalog is unclear
70
- -> search catalog with structured query/category/facets
71
- -> explain/recommend a purchase option
72
- -> collect required service input and buyer delivery email
73
- -> create cart with selected UCP Variant.id
74
- -> show the full cart contents and get human confirmation
75
- -> create checkout from cart_id
76
- -> if auth_qr is returned, show it for Alipay login/registration consent
77
- -> poll/resume checkout until payment_intent_id appears
78
- -> show returned payment QR exactly
79
- -> wait for payment_intent.verified
80
- -> check redacted delivery status
81
- -> tell the human to check email / ItPay secure claim UI
82
- -> if the human grants agent-readable access with Passkey, discover and read only the approved vault fields
83
- ```
53
+ 3. Execute the first applicable command from `next_actions` unchanged. Typical
54
+ commands are `services invoke`, `services action`, or `services checkout`.
55
+ Do not infer a capability ID or hardcode one service's sequence.
84
56
 
85
- The high-level command can wrap this flow:
57
+ 4. For a paid result, collect only contact fields requested by the CLI. Create
58
+ the checkout with the exact server-selected capability:
86
59
 
87
60
  ```bash
88
- itp buy <variant_id> --email <buyer_email> --phone <buyer_phone> --display agent --no-wait-payment --host <client> --json
61
+ itpay --agent-type <agent_type> services checkout <service_execution_id> \
62
+ --capability <capability_id> --email <human_email> --host <host> --json
89
63
  ```
90
64
 
91
- For step-by-step testing:
65
+ 5. Show both handoff forms to the human:
92
66
 
93
- ```bash
94
- itp buyer catalog search --query "<user request>" --host <client> --json
95
- itp buyer catalog search --query "企业工商信息 查询" --category business_data_api --provider itpay_enterprise_data --service-type ai_api --host <client> --json
96
- itp buyer catalog get --variant <variant_id> --host <client> --json
97
- itp buyer cart create --variant <variant_id> --host <client> --json
98
- itp buyer cart create --variants <variant_id_1>,<variant_id_2> --quantities 1,1 --host <client> --json
99
- itp buyer cart show <cart_id> --host <client> --json
100
- itp buyer cart add <cart_id> --variant <variant_id> --input key=value --quantity 1 --host <client> --json
101
- itp buyer cart remove <cart_id> --line <cart_line_item_id> --host <client> --json
102
- itp buyer checkout create --cart <cart_id> --email <buyer_email> --phone <buyer_phone> --host <client> --json
103
- itp buyer checkout resume <checkout_id> --host <client> --json
104
- itp buyer payment wait <payment_intent_id> --timeout 1 --host <client> --json
105
- itp buyer checkout status <checkout_id> --host <client> --json
106
- itp buyer refund create --order <order_id> --amount-minor <minor_units> --currency CNY --reason buyer_requested --host <client> --json
107
- itp buyer refund list --order <order_id> --host <client> --json
108
- itp buyer refund show <refund_id> --host <client> --json
109
- itp buyer refund cancel <refund_id> --reason buyer_changed_mind --host <client> --json
110
- itp buyer vault grants list --checkout <checkout_id> --host <client> --json
111
- itp buyer vault read --order <order_id> --artifact <vault_artifact_id> --host <client> --json
112
- ```
67
+ - Attach `brand_qr_local_path` when `brand_qr_status` is `downloaded`.
68
+ - Print `checkout_url` as a clickable link.
69
+ - Keep `checkout_id`, `display_token`, and `service_execution_id` for recovery.
70
+ - Do not substitute a provider QR or call `itpay pay` in the normal buyer flow.
113
71
 
114
- For API products, read the product metadata input schema before cart creation.
115
- Enterprise data products require query input at cart time:
72
+ 6. After the human pays, claims, or grants access, re-read server state:
116
73
 
117
74
  ```bash
118
- itp buyer cart create --variant var_itpay_enterprise_fuzzy_search_cny01 --input company_name=京东 --host <client> --json
119
- itp buyer cart show <cart_id> --host <client> --json
120
- itp buyer cart add <cart_id> --variant var_itpay_enterprise_fuzzy_search_cny01 --input company_name=美团 --host <client> --json
121
- itp buyer cart create --variant var_itpay_enterprise_precise_lookup_cny05 --input company_name_or_credit_no=北京京东世纪贸易有限公司 --host <client> --json
122
- itp buy var_itpay_enterprise_fuzzy_search_cny01 --email <buyer_email> --input company_name=京东 --display agent --no-wait-payment --host <client> --json
75
+ itpay --agent-type <agent_type> services next <service_execution_id> --json
76
+ itpay --agent-type <agent_type> services get <service_execution_id> --json
123
77
  ```
124
78
 
125
- For cart edits, always read the server cart first with `buyer cart show`.
126
- Cart line identity includes the variant, offer, price, provider product, and
127
- normalized input. A fully identical line increments quantity; a different
128
- company name, exact name, page number, setting, or other input must stay as a
129
- separate line.
130
-
131
- Use fuzzy search when the user gives a short name, brand, keyword, or uncertain
132
- entity. Use precise lookup only after you have the exact China mainland
133
- registered company name or unified social credit code. If the user says
134
- "京东" or "那个京东商城", do not buy precise lookup until you resolve the exact
135
- registered name or run fuzzy search first.
136
-
137
- Refund commands use ItPay shared order state. If `itp buyer refund create`
138
- returns `policy_risk_confirmation_required`, explain the returned
139
- `refund_eligibility.policy` and `agent_guidance` to the human first. Only retry
140
- with `--confirm-policy-risk true` after explicit human confirmation.
141
- Do not guess `order_id`; if missing, run `buyer checkout status <checkout_id> --host <client> --json`.
142
- Refund amounts use minor units: CNY 1000 means CNY 10.00.
143
- Refund commands require a server-verified buyer session, not a vault grant. If
144
- the CLI says the buyer session is required or expired, run
145
- `itp status --refresh --host <client> --json` and follow the returned `next.command`.
146
- Current buyer refunds are whole-order only; do not use line-item refund scope.
147
- If the human cancels a refund before provider or money movement starts, use
148
- `buyer refund cancel <refund_id> --host <client> --json`; after cancel, the delivery claim can
149
- be unlocked again by the ItPay backend.
150
-
151
- ## Non-Negotiable Rules
152
-
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.
154
- 2. Do not invent service IDs, variant IDs, checkout IDs, payment URLs, QR URLs,
155
- payment intent IDs, delivery IDs, or claim links.
156
- 3. When the user asks for several compatible services, use one cart and one
157
- checkout. Prefer `buyer cart create` for the first line, then `buyer cart
158
- show` and `buyer cart add` for each additional query line so each service
159
- input is locked to the correct cart line. Split only when ItPay rejects the
160
- cart or explicitly says split checkout is required.
161
- 4. Before checkout, make sure a buyer delivery email is available. If the CLI
162
- has no known buyer email, ask the human for the email; do not invent one,
163
- do not use placeholders, and do not proceed to checkout without it. The
164
- email is used for human-first secure delivery and account/order access.
165
- 5. Do not rewrite, shorten, re-encode, translate, or replace QR URLs. For
166
- payment QR display, you must show `local_qr_path` when the CLI provides it;
167
- remote QR images may not render in every agent client. If no local file is
168
- present, use `qr_png_url` / `preferred_qr_url`, and use `qr_image_url` only
169
- as fallback. These are ItPay-hosted human QR images; they may render a
170
- native provider payment code for scanner reliability, but you must not
171
- request, decode, or expose the raw provider payload.
172
- 6. If `human_action.kind=auth_qr`, it is account login/registration consent,
173
- not payment. Show the ItPay auth entry (`url`, `web_url`, or local/PNG QR)
174
- as the primary human action, then poll/resume checkout until payment QR
175
- appears. `oauth_start_url` is provider fallback/debug, not the primary agent
176
- handoff.
177
- 7. Do not treat QR display, page open, or user text like "I paid" as payment
178
- proof. Payment proof for the agent is `payment_intent.verified`.
179
- 8. Do not ask the human to paste raw keys, redeem codes, claim links, claim
180
- tokens, session tokens, provider payloads, or secrets into chat.
181
- 9. Do not call ops commands, worker routes, provider query recovery, or fixture
182
- evidence routes from the buyer flow.
183
- 10. Secure delivery is human-first. The agent may report
184
- `delivery_claimable`, `check_email`, and `claim_link_sent`, but must not
185
- fetch or reveal protected content.
186
- 11. If the human uses Passkey to authorize agent-readable vault access, do not
187
- ask them to paste content, portal text, claim links, session tokens, auth
188
- session IDs, display tokens, or grant IDs. Run
189
- `itp buyer vault grants list ...` and then `itp buyer vault read ...`.
190
- The CLI automatically restores the buyer agent session from the checkout
191
- auth handoff when possible. If the JSON includes
192
- `buyer_session.status=buyer_session_saved`, continue with the returned
193
- grants; the session token is intentionally stored locally and not printed.
194
- Use only the fields returned by that command.
195
- 12. If the user asks you to analyze, compare, summarize, install, or otherwise
196
- use a delivered result, you may ask them to open the ItPay claim/account
197
- page, click "Give to Agent / 一键给 Agent", choose fields, and confirm with
198
- Passkey. After they approve, probe with `itp buyer vault grants list ...`;
199
- do not ask them to copy a grant id.
200
- 13. Prefer resume/wait over creating duplicate checkouts.
201
- 14. Do not create a cart for an API service until all required service input
202
- fields are known. For enterprise fuzzy search, `company_name` can be a
203
- broad keyword. For enterprise precise lookup, `company_name_or_credit_no`
204
- must be exact; otherwise warn the user that the query may waste the paid
205
- lookup.
206
- 15. Do not operate ItPay by opening the human web UI yourself. Use the CLI for
207
- catalog, cart, checkout, payment wait, delivery status, grant discovery,
208
- and vault reads. Browser/UI pages are for the human to scan, pay, claim,
209
- reveal, and approve.
210
-
211
- ## Docs Directory
212
-
213
- Use these docs pages as needed:
79
+ 7. Read protected output only when `next_actions` says the human grant is
80
+ active:
214
81
 
215
82
  ```bash
216
- itp docs show catalog-search --role buyer --json
217
- itp docs show product-recommendation --role buyer --json
218
- itp docs show cart-checkout --role buyer --json
219
- itp docs show payment-qr --role buyer --json
220
- itp docs show payment-wait --role buyer --json
221
- itp docs show qr-refresh --role buyer --json
222
- itp docs show secure-delivery --role buyer --json
223
- itp docs show human-claim-ui --role buyer --json
224
- itp docs show account-portal --role buyer --json
225
- itp docs show vault-agent-read --role buyer --json
226
- itp docs show recovery --role buyer --json
227
- itp docs show safety-policy --role buyer --json
83
+ itpay --agent-type <agent_type> services read-result <service_execution_id>
228
84
  ```
229
85
 
230
- Each docs page includes `next_docs`. Follow those links as the state changes.
86
+ The grant is scoped to one Service Execution and expires after 15 minutes. It
87
+ does not expose the buyer's other Vault artifacts, orders, or executions.
88
+
89
+ ## Recovery
231
90
 
232
- For payment creation in an agent/chat client, prefer:
91
+ Use server-backed recovery before creating anything again:
233
92
 
234
93
  ```bash
235
- itp buy <variant_id> --email <buyer_email> --phone <buyer_phone> --display agent --no-wait-payment --host <client> --json
94
+ itpay --agent-type <agent_type> next --json
95
+ itpay --agent-type <agent_type> services list --json
96
+ itpay --agent-type <agent_type> services next <service_execution_id> --json
97
+ itpay --agent-type <agent_type> services checkout <service_execution_id> --resume --json
98
+ itpay checkout --id <checkout_id> --token <display_token>
236
99
  ```
237
100
 
238
- This keeps JSON output machine-readable while allowing the CLI to prepare a
239
- local QR image path for clients that cannot render remote SVG reliably. In
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.
253
-
254
- For first-purchase auth, treat the returned ItPay authorization entry as a
255
- single human orchestration entry. It may open Alipay login/registration first
256
- and then payment after ItPay receives the OAuth callback. Do not call
257
- `oauth_start_url` directly unless the ItPay auth page asks for fallback.
258
- If the payment page says provider entry is stabilizing/preparing,
259
- or if the payment provider says "order not found", tell the human to wait 30-60
260
- seconds and use the same page/QR again. Do not ask them to refresh repeatedly,
261
- and do not create another checkout or payment intent. Use
262
- `itp buyer payment refresh-qr ... --reason order-not-found` only after the
263
- same QR/page has been retried and still fails; ItPay may safely return the same
264
- valid QR rather than creating a new provider order.
265
-
266
- ## Safe User Message Pattern
267
-
268
- When reporting progress, keep it short:
269
-
270
- ```text
271
- I found the service and selected the matching variant.
272
- I created the cart and checkout.
273
- Please open the returned ItPay authorization link and approve Alipay login.
274
- I am waiting for ItPay account authorization.
275
- Please scan the returned ItPay-hosted QR image with the payment provider.
276
- I am waiting for ItPay payment verification.
277
- Payment is verified.
278
- Delivery is claimable by the human buyer. Please check your email.
279
- ```
101
+ `--resume` reissues the handoff for the existing unpaid checkout. It must not
102
+ create a second order. Local files cache recovery handles; canonical cart,
103
+ quota, execution, checkout, delivery, and grant state comes from the backend.
104
+
105
+ ## Host Selection
280
106
 
281
- Do not include raw protected content in the message.
107
+ `--agent-type` identifies the agent runtime. `--host` identifies where the
108
+ human sees the output. They are separate.
109
+
110
+ | Human surface | CLI options |
111
+ | --- | --- |
112
+ | Codex | `--host codex` |
113
+ | Claude Code | `--host claude-code` |
114
+ | Terminal | `--host terminal` |
115
+ | Telegram | `--host telegram --target <chat_id>` |
116
+ | Feishu/Lark | `--host feishu --target <id>` or `--host lark --target <id>` |
117
+
118
+ Run `itpay install <host>` for host-specific setup.
119
+
120
+ ## Progressive Disclosure
121
+
122
+ - Run one state-changing command at a time.
123
+ - Return the useful result, a short explanation, and the next executable step.
124
+ - Ask the human only for a missing required field such as delivery email.
125
+ - When checkout is ready, visibly attach the QR and print the payment link.
126
+ - Prefer CLI `next_actions`; do not dump internal timelines unless diagnosing.
127
+ - Use `--json` for agent parsing and normal rendering for the human handoff.
128
+
129
+ ## Safety Rules
130
+
131
+ 1. Never invent catalog, service, capability, result-item, checkout, or order IDs.
132
+ 2. Never expose provider credentials, raw provider metadata, bearer tokens, or device private keys.
133
+ 3. Do not treat QR rendering or a human statement as payment confirmation.
134
+ 4. Do not call `itpay pay` or use `buy --pay` for a normal checkout; those are operator escape hatches.
135
+ 5. Do not create a new execution or checkout until recovery confirms the prior one is unusable.
136
+ 6. Do not claim protected access before `services read-result` succeeds.
137
+ 7. Do not invent admin, account, grant-creation, or provider-specific CLI commands.
138
+
139
+ ## Built-in Docs
140
+
141
+ ```bash
142
+ itpay docs list
143
+ itpay docs search <term>
144
+ itpay docs show catalog-list
145
+ itpay docs show cart-checkout
146
+ itpay docs show payment-flow
147
+ itpay docs show orders-refunds
148
+ itpay docs show render-hosts
149
+ itpay docs show install-and-setup
150
+ ```
@@ -1,81 +0,0 @@
1
- {
2
- "schema_version": "itp.agent_doc.v1",
3
- "role": "buyer",
4
- "topic": "account-portal",
5
- "title": "Human Account Portal",
6
- "purpose": "Teach the agent how to help a human open the ItPay account/order portal without reading protected content.",
7
- "when_to_use": [
8
- "The human asks to see their ItPay account or previous orders.",
9
- "The original claim email link expired or was already used.",
10
- "The agent needs to explain that human UI and agent status share the same redacted order state."
11
- ],
12
- "required_state": {
13
- "needs": [
14
- "authenticated buyer account session"
15
- ],
16
- "must_not_need": [
17
- "claim token",
18
- "raw content",
19
- "portal page contents"
20
- ]
21
- },
22
- "commands": [
23
- {
24
- "intent": "create a one-time human account portal link",
25
- "command": "itp account login-link --host <client> --json",
26
- "success_signal": "response.status == account_portal_login_link_created and response.portal_login_link.one_time == true"
27
- },
28
- {
29
- "intent": "same command under buyer namespace",
30
- "command": "itp buyer account login-link --host <client> --json",
31
- "success_signal": "response.login_url is present"
32
- },
33
- {
34
- "intent": "agent-side state check without opening the human portal",
35
- "command": "itp buyer checkout status <checkout_id> --host <client> --json",
36
- "success_signal": "response contains redacted order/delivery state only"
37
- }
38
- ],
39
- "agent_rules": [
40
- "Give the one-time account portal link to the human buyer.",
41
- "Do not open the account portal link yourself.",
42
- "The human portal and agent APIs read the same redacted order/vault state.",
43
- "If the human chooses one-key agent authorization after Passkey reveal, use `itp buyer vault grants list ...` to discover the active grant; do not ask the human to copy the grant id.",
44
- "If the human reports an order status, verify it through buyer status/order commands instead of scraping the portal.",
45
- "Protected artifact reveal still requires a later Passkey/WebAuthn human reveal flow."
46
- ],
47
- "forbidden": [
48
- "Do not fetch, screenshot, scrape, cache, or summarize the account portal page.",
49
- "Do not ask the human to paste portal contents, claim links, keys, or raw results into chat.",
50
- "Do not claim the portal link is a raw content reveal link.",
51
- "Do not reuse a portal link after it has been opened."
52
- ],
53
- "next_docs": [
54
- {
55
- "condition": "The user asks where a delivered item is",
56
- "topic": "secure-delivery",
57
- "command": "itp docs show secure-delivery --role buyer --json"
58
- },
59
- {
60
- "condition": "The human approved agent access to selected fields",
61
- "topic": "vault-agent-read",
62
- "command": "itp docs show vault-agent-read --role buyer --json"
63
- },
64
- {
65
- "condition": "The user asks why the agent cannot open the portal",
66
- "topic": "safety-policy",
67
- "command": "itp docs show safety-policy --role buyer --json"
68
- }
69
- ],
70
- "search_terms": [
71
- "account portal",
72
- "orders",
73
- "login link",
74
- "one time link",
75
- "portal",
76
- "账号",
77
- "订单",
78
- "登录链接",
79
- "一次性链接"
80
- ]
81
- }
@@ -1,106 +0,0 @@
1
- {
2
- "schema_version": "itp.agent_doc.v1",
3
- "role": "buyer",
4
- "topic": "catalog-search",
5
- "title": "Catalog Search For Buyer Agents",
6
- "purpose": "Help the agent read the service shelf, search the public ItPay service catalog, and choose a purchase option without guessing.",
7
- "when_to_use": [
8
- "The user describes a need but has not chosen a service.",
9
- "The agent needs service and purchase option details before recommendation.",
10
- "The agent needs to search standardized API products such as ItPay enterprise data APIs."
11
- ],
12
- "required_state": {
13
- "needs": [
14
- "search query or service intent"
15
- ],
16
- "must_not_need": [
17
- "buyer login",
18
- "payment intent",
19
- "ops token"
20
- ]
21
- },
22
- "commands": [
23
- {
24
- "intent": "inspect the service shelf before guessing keywords or facets",
25
- "command": "itp buyer shelf manifest --host <client> --json",
26
- "success_signal": "response.snapshot_version and response.snapshot_url are present; use snapshot/delta when the agent needs a shopping-list view of available services"
27
- },
28
- {
29
- "intent": "search public catalog by natural language query",
30
- "command": "itp buyer catalog search --query \"企业工商信息 查询\" --host <client> --json",
31
- "success_signal": "response.products contains services with purchase options, id, title, price, metadata, and response.catalog_guidance explains how to choose safely"
32
- },
33
- {
34
- "intent": "search API services by stable category and safe facets",
35
- "command": "itp buyer catalog search --query \"企业工商信息 查询\" --category business_data_api --provider itpay_enterprise_data --service-type ai_api --delivery-mode managed_capability --use-case company_lookup --input-facet company_name --host <client> --json",
36
- "success_signal": "response.products only contains products matching the requested category/facets"
37
- },
38
- {
39
- "intent": "search fuzzy company lookup when the user only provides a partial company name",
40
- "command": "itp buyer catalog search --query \"企业 模糊 查询 公司简称\" --category business_data_api --provider itpay_enterprise_data --service-type ai_api --use-case company_disambiguation --input-facet company_name --host <client> --json",
41
- "success_signal": "response.products includes the fuzzy enterprise search product before precise lookup"
42
- },
43
- {
44
- "intent": "get exact service details for a selected purchase option",
45
- "command": "itp buyer catalog get --variant <variant_id> --host <client> --json",
46
- "success_signal": "response.selection.catalog_variant_id matches the selected purchase option and response.catalog_guidance says to explain before cart creation"
47
- }
48
- ],
49
- "agent_rules": [
50
- "Terminology: product means 服务, variant means 购买选项, variant_id means 购买选项 ID, catalog means 服务目录, shelf means 目录清单.",
51
- "Before searching, remember the local agent does not know the current service catalog. Use this doc and the shelf manifest/snapshot as the shopping-list view when keywords or facets are unclear.",
52
- "Catalog search is structured ItPay catalog search, not general web search. Convert the user's request into query plus category/provider/use-case/input-facet filters.",
53
- "Full search is allowed for explicit user search, not as a polling loop.",
54
- "For repeated discovery, prefer shelf manifest/snapshot/delta.",
55
- "For API services, map user intent to category/facet filters before relying on keyword ranking.",
56
- "Use stable categories: business_data_api, business_verification_api, identity_verification_api, phone_verification_api, risk_compliance_api, location_weather_api, finance_data_api.",
57
- "Use safe facets such as --use-case, --input-facet, --output-facet, --sensitivity-level, --delivery-mode, and --provider.",
58
- "Use service and purchase option metadata to explain options in user language.",
59
- "If search returns zero products, do not invent a service or conclude too early. Loosen filters, change query terms, or go back to the shelf.",
60
- "If search returns many products, narrow with category/provider/use-case/input-facet before recommending.",
61
- "If search returns a small set, compare service description, price, required input, sensitivity level, and delivery mode.",
62
- "Money values from catalog JSON use minor units. For CNY, amount=10 means CNY 0.10, not CNY 10. Prefer display_amount when present, or divide amount/amount_minor by 100 before telling the user.",
63
- "For products with requires_human_input=true, do not ask for identity numbers or phone numbers in chat; rely on ItPay human authorization/input.",
64
- "Selecting a service is not buying. Explain the selected service and purchase option to the human, then ask for confirmation before cart creation.",
65
- "Do not create checkout until the user intent maps to one selected purchase option and the user confirms the purchase."
66
- ],
67
- "forbidden": [
68
- "Do not require login for discovery.",
69
- "Do not invent catalog items, services, purchase options, or variant IDs.",
70
- "Do not assume search result order means the user has approved purchase."
71
- ],
72
- "next_docs": [
73
- {
74
- "condition": "Need to recommend among services or purchase options",
75
- "topic": "product-recommendation",
76
- "command": "itp docs show product-recommendation --role buyer --json"
77
- },
78
- {
79
- "condition": "The user has chosen and confirmed a purchase option",
80
- "topic": "cart-checkout",
81
- "command": "itp docs show cart-checkout --role buyer --json"
82
- }
83
- ],
84
- "search_terms": [
85
- "catalog",
86
- "search",
87
- "shelf",
88
- "product",
89
- "variant",
90
- "purchase option",
91
- "api",
92
- "enterprise_data",
93
- "category",
94
- "facet",
95
- "business_data_api",
96
- "企业查询",
97
- "工商信息",
98
- "企业工商数据精准查询",
99
- "企业工商数据模糊查询",
100
- "搜索",
101
- "商品",
102
- "服务目录",
103
- "目录清单",
104
- "购买选项"
105
- ]
106
- }