@itpay/cli 2.1.7 → 2.1.9
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/dist/src/client/backend.js +3 -2
- package/dist/src/commands/services.js +110 -20
- package/dist/src/main.js +127 -12
- package/dist/src/state/account_auth.js +87 -5
- package/dist/src/state/config.js +2 -2
- package/dist/src/state/device_authority.js +64 -12
- package/docs/agent/buyer/identity-and-sessions.json +9 -2
- package/docs/agent/buyer/rail-booking.json +97 -12
- package/docs/cli-reference/commands/auth.md +89 -4
- package/docs/cli-reference/commands/device.md +13 -1
- package/docs/cli-reference/commands/services/action.md +9 -1
- package/docs/cli-reference/commands/services/checkout.md +5 -1
- package/docs/cli-reference/commands/services/get.md +2 -0
- package/docs/cli-reference/commands/services/next.md +81 -0
- package/docs/cli-reference/commands/services/page.md +67 -0
- package/docs/cli-reference/commands/services/run.md +81 -1
- package/docs/cli-reference/index.md +1 -0
- package/package.json +1 -1
- package/skills/itpay/SKILL.md +19 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# `itpay services page`
|
|
2
|
+
|
|
3
|
+
> **Product boundary:** `itpay` is the single public CLI entry point, and `$itpay` is its user-facing Skill invocation. Under that one product entry point, the two top-level commerce actions are `buy` and `sell`: Buyer workflows are available now; Seller workflows will use the same entry point and are not implemented yet.
|
|
4
|
+
|
|
5
|
+
## 范围与意义
|
|
6
|
+
|
|
7
|
+
读取已保存 Result Item 的同版本分页。分页来自 Backend 存储的当前结果版本,不重新调用 Provider、不消耗查询额度,也不产生新的 Execution。
|
|
8
|
+
|
|
9
|
+
**上游:** `services run`、`services next` 返回的分页提示(`catalog_page.next_offset`)。
|
|
10
|
+
**下游:** 继续翻下一页,或在用户明确选择后用 `booking_offer` 承接购票。
|
|
11
|
+
|
|
12
|
+
本命令不接受 Buyer token、capability 或服务输入,不返回原始 Backend DTO 之外的额外事实;Agent 不向用户暴露 `safe_payload`、Execution 或内部 ID。
|
|
13
|
+
|
|
14
|
+
## 语法与参数
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
itpay services page <service_execution_id> <result_item_id> [--offset <offset>] [--limit <limit>] [--json]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
| 参数 | 必填 | 说明 |
|
|
21
|
+
| --- | --- | --- |
|
|
22
|
+
| `service_execution_id` | 是 | 产生该结果集的 Execution ID。 |
|
|
23
|
+
| `result_item_id` | 是 | `services next` 或分页响应中的 `service_capability_result_item_id`。 |
|
|
24
|
+
| `--offset` | 否 | 从零开始的候选偏移;默认 `0`,必须是非负整数。 |
|
|
25
|
+
| `--limit` | 否 | 页大小,`1` 到 `20` 的整数;默认 `5`。 |
|
|
26
|
+
| `--json` | 否 | 输出稳定 JSON 信封;未指定时输出本页候选标题的简洁文本。 |
|
|
27
|
+
|
|
28
|
+
需要有效 Agent Device session。
|
|
29
|
+
|
|
30
|
+
## 分页信封
|
|
31
|
+
|
|
32
|
+
有候选返回 `result_page`,读尽返回 `result_page_end`:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"status": "result_page",
|
|
37
|
+
"result": {
|
|
38
|
+
"service_execution_id": "<id>",
|
|
39
|
+
"service_capability_result_item_id": "<item_id>",
|
|
40
|
+
"offset": 0,
|
|
41
|
+
"limit": 5,
|
|
42
|
+
"total": 63,
|
|
43
|
+
"count": 5,
|
|
44
|
+
"next_offset": 5,
|
|
45
|
+
"page": { "catalog_page": { "...": "..." }, "candidates": [ { "title": "<title>" } ] }
|
|
46
|
+
},
|
|
47
|
+
"instruction": "读取的是已保存结果的同版本分页,不重新查询、不消耗额度。用普通语言向用户说明本页候选;铁路应付与地面估算费用分开表述;不要提及 safe_payload、Execution 或内部 ID。",
|
|
48
|
+
"next": { "command": "itpay services page <id> <item_id> --offset 5 --json", "reason": "读取同版本结果的下一页" },
|
|
49
|
+
"recovery": []
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`next_offset` 为 `null` 时 `next` 为 `null`;`offset > 0` 时 `recovery` 提供回到第一页的命令。页内候选可携带 `booking_offer`,承接方式与 `services next` 结果一致。
|
|
54
|
+
|
|
55
|
+
## 异常处理
|
|
56
|
+
|
|
57
|
+
`--offset` 非负整数、`--limit` 必须在 `1`–`20` 内,否则在发起请求前返回 `offset_invalid` / `limit_invalid` 信封,不消耗服务端分页。execution 或 result item 不存在、不属于当前设备/账号时返回错误信封,并仅建议:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
itpay services next <service_execution_id> --json
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
分页读取的是已保存的同版本结果;不要重新发起查询或新建 execution 来"刷新"分页。
|
|
64
|
+
|
|
65
|
+
## Agent Type / Host
|
|
66
|
+
|
|
67
|
+
所有正式支持的 Local Agent Type 返回完全相同的状态、分页事实、instruction 和 next。本命令不渲染二维码,也不包含 Host handoff。
|
|
@@ -21,7 +21,7 @@ itpay services run <service_id>
|
|
|
21
21
|
| 参数 | 说明 |
|
|
22
22
|
| --- | --- |
|
|
23
23
|
| `service_id` | Catalog 返回的服务 ID。恢复时必须与 Execution 所属服务一致。 |
|
|
24
|
-
| `--input-json` | UTF-8 JSON 文件;顶层必须是 object,并符合服务发布的 input schema
|
|
24
|
+
| `--input-json` | UTF-8 JSON 文件;顶层必须是 object,并符合服务发布的 input schema;文件不超过 256 KiB。文件不可读、非合法 JSON 或顶层非 object 时在本地报 `workflow_input_invalid`,不发生网络写。 |
|
|
25
25
|
| `--execution` | 恢复同一 Execution。不得用它切换服务或绕过原状态。 |
|
|
26
26
|
| `--timeout` | 本次等待 workflow 状态变化的秒数,默认 120,范围 0–600;超时只返回当前状态。 |
|
|
27
27
|
| `--host` / `--target` | Host 展示上下文,不是业务输入或 Buyer 身份。 |
|
|
@@ -60,6 +60,86 @@ itpay services run <service_id> --execution <execution_id> --json
|
|
|
60
60
|
|
|
61
61
|
只恢复当前状态。交付、Vault 授权和退款继续使用 `services next`、`services read-result`、`vault` 与 `refund` 的既有合同。
|
|
62
62
|
|
|
63
|
+
## 免费试用额度与 `login_required`
|
|
64
|
+
|
|
65
|
+
铁路查询类服务对未登录设备提供按服务独立计数的免费试用(`itpay-rail-exact` 与 `itpay-rail-smart` 各 2 次,互不共享)。额度在查询产生供应商副作用前由服务端原子记账:地点确认、内部多阶段、轮询和已保存结果分页不重复扣次;参数校验失败且未执行查询时不扣次。
|
|
66
|
+
|
|
67
|
+
试用耗尽时,查询在供应商调用**之前**被暂停,Execution 不失败,已提交的输入服务端保留:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"status": "login_required",
|
|
72
|
+
"result": {
|
|
73
|
+
"service_execution_id": "<execution_id>",
|
|
74
|
+
"service_id": "itpay-rail-exact",
|
|
75
|
+
"admission": "login_required",
|
|
76
|
+
"query_quota": [
|
|
77
|
+
{ "service_id": "itpay-rail-exact", "used": 2, "limit": 2, "remaining": 0 },
|
|
78
|
+
{ "service_id": "itpay-rail-smart", "used": 0, "limit": 2, "remaining": 2 }
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
"instruction": "该服务的免费查询次数已用完(exact 2/2,smart 仍剩 2/2)。请用户在官方页面完成登录后继续免费查询;本次查询输入已保留,登录后恢复同一执行即可,不要新建执行或让用户重述行程。smart 额度属于另一类服务,不能拿它顶替 exact 查询。",
|
|
82
|
+
"next": {
|
|
83
|
+
"command": "itpay auth login --json",
|
|
84
|
+
"reason": "完成官方登录绑定后继续免费查询"
|
|
85
|
+
},
|
|
86
|
+
"recovery": [
|
|
87
|
+
{
|
|
88
|
+
"command": "itpay services run itpay-rail-exact --execution <execution_id> --json",
|
|
89
|
+
"when": "auth_bound",
|
|
90
|
+
"reason": "登录绑定完成后恢复同一查询执行"
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`query_quota` 如实报告两类额度各自用量,一类为零不得宣称"四次全部用完"。第四次查询的结果先正常交付,下一次新查询才需要授权。
|
|
97
|
+
|
|
98
|
+
登录绑定完成后,再次运行同一条 `services run <service> --execution <id> --json`(不带输入文件):服务端重新读取当前设备绑定身份,被暂停的 Execution 从额度节点继续,不重放已成功的供应商调用,不要求重新输入。`failed`、`recovery_required` 或已完成付款的 Execution 不能以这种方式恢复。
|
|
99
|
+
|
|
100
|
+
## `rate_limited`
|
|
101
|
+
|
|
102
|
+
已注册账号查询不设累计次数上限,但受正常每分钟限流:
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"status": "rate_limited",
|
|
107
|
+
"result": {
|
|
108
|
+
"service_execution_id": "<execution_id>",
|
|
109
|
+
"service_id": "<service_id>",
|
|
110
|
+
"admission": "rate_limited",
|
|
111
|
+
"retry_after_ms": 42000
|
|
112
|
+
},
|
|
113
|
+
"instruction": "触发正常限流;等待后恢复同一执行,不要新建查询。",
|
|
114
|
+
"next": {
|
|
115
|
+
"command": "itpay services run <service_id> --execution <execution_id> --json",
|
|
116
|
+
"after_ms": 42000,
|
|
117
|
+
"reason": "限流窗口过后继续同一查询"
|
|
118
|
+
},
|
|
119
|
+
"recovery": []
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
限流不是收费、不是试用耗尽、不需要重新登录。等待中不得重复扣试用或发起新的供应商请求。
|
|
124
|
+
|
|
125
|
+
## 已选车次的购票输入(selection)
|
|
126
|
+
|
|
127
|
+
对 `itpay-rail-booking`,输入支持两种等价方式。优先使用查询结果里服务端签发的购买承接:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"passengers": 1,
|
|
132
|
+
"selection": {
|
|
133
|
+
"token": "<查询结果项中的 booking_offer.selection_token>",
|
|
134
|
+
"seat_type": "O"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`selection.token` 绑定一次具体查询结果快照与其中的班次/方案;服务端校验归属、快照版本、时效后推导权威 `legs` 并实时核价。Agent 只提交用户选定的承接、`seat_type`(必要时)与乘客人数,**绝不手工拼装 `legs`、站码、时刻或供应商形状**。显式 `legs` 输入仍然有效,字段即购票服务发布的 `input_schema`(`passengers` 为 1–5 整数人数,不是乘客身份数组)。
|
|
140
|
+
|
|
141
|
+
相同 selection 重复提交恢复同一购票执行,不会重复核价或建单。
|
|
142
|
+
|
|
63
143
|
## 终态和异常
|
|
64
144
|
|
|
65
145
|
- 成功、付款、交付、授权、退款锁等状态使用既有命令的标准信封,不额外包装 Seller 专用格式。
|
|
@@ -88,6 +88,7 @@ Commander 自动提供的 `itpay help [command]` 与 `itpay <group> help [subcom
|
|
|
88
88
|
- [`itpay services list`](commands/services/list.md)
|
|
89
89
|
- [`itpay services get`](commands/services/get.md)
|
|
90
90
|
- [`itpay services next`](commands/services/next.md)
|
|
91
|
+
- [`itpay services page`](commands/services/page.md)
|
|
91
92
|
- [`itpay services read-result`](commands/services/read-result.md)
|
|
92
93
|
- [`itpay services events`](commands/services/events.md)
|
|
93
94
|
|
package/package.json
CHANGED
package/skills/itpay/SKILL.md
CHANGED
|
@@ -31,6 +31,25 @@ purchase. If a request such as "查京东" could mean either old content or a ne
|
|
|
31
31
|
query, ask which one the human wants before calling ItPay. Do not spend quota,
|
|
32
32
|
request authorization, or start a purchase while the intent is ambiguous.
|
|
33
33
|
|
|
34
|
+
## Railway Services
|
|
35
|
+
|
|
36
|
+
Three services, three different jobs — pick by the human's input, never merge them:
|
|
37
|
+
|
|
38
|
+
| Human has | Service |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| Exact departure AND arrival station names | `itpay-rail-exact` (direct query) |
|
|
41
|
+
| City/area/address, or wants transfer planning | `itpay-rail-smart` (location resolution + planning) |
|
|
42
|
+
| Chose a train/seat and wants to buy | `itpay-rail-booking` (quote → protected checkout → issuance) |
|
|
43
|
+
|
|
44
|
+
Query results carry a server-issued `booking_offer.selection_token` on bookable
|
|
45
|
+
options; for a purchase submit that token plus passenger count — never
|
|
46
|
+
reconstruct train legs by hand. Passenger names, ID numbers and phone numbers
|
|
47
|
+
belong only on the protected checkout page, never in chat. Each query service
|
|
48
|
+
has its own free trial count (2+2, not a shared pool); `login_required` pauses
|
|
49
|
+
the query, it is not a failure — resume the same execution after `itpay auth
|
|
50
|
+
login`. For the full input contract and states, load the rail-booking topic via
|
|
51
|
+
`itpay docs search rail-booking --json`.
|
|
52
|
+
|
|
34
53
|
## Follow One Envelope
|
|
35
54
|
|
|
36
55
|
For each JSON response:
|