@itpay/cli 2.0.2 → 2.0.5
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 +92 -142
- package/dist/src/client/backend.js +27 -9
- package/dist/src/commands/buy.js +84 -132
- package/dist/src/commands/cart.js +274 -169
- package/dist/src/commands/catalog.js +63 -38
- package/dist/src/commands/checkout.js +117 -78
- package/dist/src/commands/docs.js +97 -51
- package/dist/src/commands/guidance.js +87 -15
- package/dist/src/commands/install.js +50 -87
- package/dist/src/commands/next.js +45 -0
- package/dist/src/commands/order.js +44 -69
- package/dist/src/commands/orders.js +43 -15
- package/dist/src/commands/pay.js +51 -22
- package/dist/src/commands/readyz.js +8 -4
- package/dist/src/commands/refund.js +132 -14
- package/dist/src/commands/services.js +719 -148
- package/dist/src/main.js +711 -201
- package/dist/src/render/output.js +2 -3
- package/dist/src/state/cart_session.js +13 -17
- package/dist/src/state/client_context.js +4 -2
- package/dist/src/state/config.js +3 -5
- package/dist/src/state/device_authority.js +1 -1
- package/docs/agent/buyer/cart-checkout.json +27 -83
- package/docs/agent/buyer/install-and-setup.json +23 -67
- package/docs/agent/buyer/orders-refunds.json +31 -53
- package/docs/agent/buyer/payment-flow.json +24 -57
- package/docs/agent/buyer/quickstart.json +39 -162
- package/docs/agent/buyer/render-hosts.json +43 -57
- package/docs/cli-reference/agent-types.md +45 -0
- package/docs/cli-reference/commands/buy.md +167 -0
- package/docs/cli-reference/commands/cart/add.md +86 -0
- package/docs/cli-reference/commands/cart/clear.md +53 -0
- package/docs/cli-reference/commands/cart/index.md +30 -0
- package/docs/cli-reference/commands/cart/next.md +71 -0
- package/docs/cli-reference/commands/cart/remove.md +53 -0
- package/docs/cli-reference/commands/cart/show.md +65 -0
- package/docs/cli-reference/commands/catalog/index.md +26 -0
- package/docs/cli-reference/commands/catalog/list.md +45 -0
- package/docs/cli-reference/commands/checkout.md +74 -0
- package/docs/cli-reference/commands/docs/index.md +28 -0
- package/docs/cli-reference/commands/docs/list.md +51 -0
- package/docs/cli-reference/commands/docs/search.md +69 -0
- package/docs/cli-reference/commands/docs/show.md +68 -0
- package/docs/cli-reference/commands/install.md +112 -0
- package/docs/cli-reference/commands/next.md +87 -0
- package/docs/cli-reference/commands/order.md +92 -0
- package/docs/cli-reference/commands/orders.md +83 -0
- package/docs/cli-reference/commands/pay.md +103 -0
- package/docs/cli-reference/commands/readyz.md +39 -0
- package/docs/cli-reference/commands/refund/cancel.md +62 -0
- package/docs/cli-reference/commands/refund/create.md +85 -0
- package/docs/cli-reference/commands/refund/get.md +60 -0
- package/docs/cli-reference/commands/refund/index.md +33 -0
- package/docs/cli-reference/commands/refund/list.md +68 -0
- package/docs/cli-reference/commands/refund/watch.md +73 -0
- package/docs/cli-reference/commands/services/action.md +43 -0
- package/docs/cli-reference/commands/services/checkout.md +82 -0
- package/docs/cli-reference/commands/services/events.md +73 -0
- package/docs/cli-reference/commands/services/get.md +66 -0
- package/docs/cli-reference/commands/services/index.md +45 -0
- package/docs/cli-reference/commands/services/invoke.md +67 -0
- package/docs/cli-reference/commands/services/list.md +61 -0
- package/docs/cli-reference/commands/services/next.md +162 -0
- package/docs/cli-reference/commands/services/quote.md +59 -0
- package/docs/cli-reference/commands/services/read-result.md +98 -0
- package/docs/cli-reference/commands/services/start.md +53 -0
- package/docs/cli-reference/conventions.md +94 -0
- package/docs/cli-reference/index.md +64 -0
- package/package.json +1 -1
- package/skills/itpay-buyer/SKILL.md +47 -113
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# `itpay services invoke`
|
|
2
|
+
|
|
3
|
+
## 范围与意义
|
|
4
|
+
|
|
5
|
+
调用当前 phase 允许的非付费 Agent-visible capability。输入先按 capability schema 校验,校验失败不得迁移 execution 或记录 Provider 已调用。
|
|
6
|
+
|
|
7
|
+
**上游:** `services start/next` 明确返回 invoke。
|
|
8
|
+
**下游:** 候选结果、人工 action、付费 Quote 或新 execution。
|
|
9
|
+
|
|
10
|
+
## 语法与参数
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
itpay services invoke <service_execution_id> --capability <capability_id>
|
|
14
|
+
[--input <key=value> ...] [--json]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`--input` 可重复;必填 key 来自 `input_schema.required`,值按 schema 类型解析。Agent 不猜字段名。
|
|
18
|
+
|
|
19
|
+
## 有结果输出
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"status": "result_ready",
|
|
24
|
+
"result": {
|
|
25
|
+
"service_execution_id": "<id>",
|
|
26
|
+
"capability_id": "<capability_id>",
|
|
27
|
+
"items": [{ "rank": 1, "title": "<title>", "safe_payload": {} }],
|
|
28
|
+
"quota": { "remaining": 2, "limit": 3 }
|
|
29
|
+
},
|
|
30
|
+
"instruction": "向用户展示编号和 safe_payload;用户选择后只在当前 Execution 提交对应 rank,不要新建 Execution。",
|
|
31
|
+
"next": { "command": "itpay services action <id> --action <action_type> --actor-type human --status approved --candidate <rank> --json", "reason": "记录用户选择" },
|
|
32
|
+
"recovery": []
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 无结果与额度耗尽
|
|
37
|
+
|
|
38
|
+
无结果时明确说明 Provider 已返回空结果,并根据服务端 graph 决定重试同一 execution 或启动新 execution。额度耗尽时返回付费 capability 的完整 `services quote` 命令,不要求 CLI 自己识别服务。
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"status": "quota_exhausted",
|
|
43
|
+
"result": {
|
|
44
|
+
"service_execution_id": "<id>",
|
|
45
|
+
"capability_id": "<capability_id>",
|
|
46
|
+
"items": [],
|
|
47
|
+
"quota": { "remaining": 0, "limit": 3 },
|
|
48
|
+
"checkout": {
|
|
49
|
+
"capability_id": "<paid_capability_id>",
|
|
50
|
+
"price": { "amount_minor": 10, "currency": "CNY" },
|
|
51
|
+
"delivery_email_required": false
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"instruction": "免费额度已用完且本次未调用 Provider;先向用户说明价格并确认购买。",
|
|
55
|
+
"next": {
|
|
56
|
+
"command": "itpay services quote <id> --capability <paid_capability_id> --input <key=value> --json",
|
|
57
|
+
"reason": "准备当前服务的付费 continuation 报价"
|
|
58
|
+
},
|
|
59
|
+
"recovery": []
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
缺少 required input 时返回 `capability_input_invalid`,recovery 给出带占位符的同一 invoke 命令;CLI 和 Backend 都必须在 Provider 调用前拒绝,Backend 还必须在 execution/event/quota/invocation 写入前拒绝。错误调用付费 capability 时返回 `checkout_required` 和可直接运行的 quote 命令;execution 状态、event、ProviderCalled 均保持不变。
|
|
64
|
+
|
|
65
|
+
## Agent Type / Host
|
|
66
|
+
|
|
67
|
+
`codex-desktop`、`codex-cli`、`claude-code-desktop`、`claude-code-cli`、`workbuddy` 五种 Agent Type 的 safe result 一致。instruction 可以适配对话表述,但不得隐藏 quota、价格或 schema 错误。
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# `itpay services list`
|
|
2
|
+
|
|
3
|
+
## 范围与意义
|
|
4
|
+
|
|
5
|
+
恢复当前已登记设备或账号可见的 Service Execution 摘要。它不是批量 timeline 导出。
|
|
6
|
+
|
|
7
|
+
**上游:** 本地句柄丢失、404 recovery 或用户要求查看历史任务。
|
|
8
|
+
**下游:** `services next <selected_id>`。
|
|
9
|
+
|
|
10
|
+
## 语法与参数
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
itpay services list [--limit <number>] [--json]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
| 参数 | 必填 | 说明 |
|
|
17
|
+
| --- | --- | --- |
|
|
18
|
+
| `--limit <number>` | 否 | 返回数量,默认 10;必须是 1 到 100 的整数。只有最近结果找不到目标时才扩大。 |
|
|
19
|
+
| `--json` | 否 | 输出单个标准 JSON envelope;默认输出每条一行的简洁文本。 |
|
|
20
|
+
|
|
21
|
+
命令使用签名 Agent Device session。Backend 按 `updated_at DESC` 返回当前设备或已绑定 Buyer account 可见的执行;CLI 保留该顺序,不在本地推断归属。
|
|
22
|
+
|
|
23
|
+
## 标准输出
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"status": "listed",
|
|
28
|
+
"result": {
|
|
29
|
+
"executions": [
|
|
30
|
+
{ "service_execution_id": "<id>", "service_id": "<service_id>", "status": "<status>", "phase": "<phase>", "updated_at": "<time>" }
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"instruction": "结果按最新到最旧排列,默认只列最近 10 条;找不到目标时再扩大 limit。",
|
|
34
|
+
"next": { "command": "itpay services next <latest_service_execution_id> --json", "reason": "默认恢复最新执行" },
|
|
35
|
+
"recovery": []
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
不得为每条 execution 附加完整 guidance、capabilities、result items、events、candidate hash、client context 或内部 binding。若用户指定了另一条,Agent 应用该行 ID 替换默认最新 ID 后运行 `services next`。
|
|
40
|
+
|
|
41
|
+
无结果时返回 `no_executions`、空数组和 `itpay catalog list --json`。
|
|
42
|
+
|
|
43
|
+
非法 limit 在请求 Backend 前返回:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"status": "error",
|
|
48
|
+
"error": { "code": "limit_invalid", "message": "--limit must be an integer from 1 to 100" },
|
|
49
|
+
"instruction": "使用 1 到 100 的整数 limit;本次未读取服务端列表。",
|
|
50
|
+
"next": null,
|
|
51
|
+
"recovery": [
|
|
52
|
+
{ "command": "itpay services list --limit 10 --json", "reason": "使用默认上限重试" }
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
身份或 Backend 错误保留服务端错误码,只建议 `readyz` 和重新读取列表;不得猜测 ID。
|
|
58
|
+
|
|
59
|
+
## Agent Type / Host
|
|
60
|
+
|
|
61
|
+
`codex-desktop`、`codex-cli`、`claude-code-desktop`、`claude-code-cli`、`workbuddy` 五种 Agent Type 返回相同列表格式;Agent instance 权限决定可见范围。本命令没有 Host handoff。
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# `itpay services next`
|
|
2
|
+
|
|
3
|
+
## 范围与意义
|
|
4
|
+
|
|
5
|
+
读取一笔 Service Execution 的当前状态,并只返回一个首选下一步。若交付模式允许 Agent 直接读取,本命令同时返回完整 safe result。
|
|
6
|
+
|
|
7
|
+
**上游:** `services start`、`invoke`、`action`、`checkout`,或一次中断恢复。
|
|
8
|
+
**下游:** 一个可执行命令、需要用户完成的候选选择或授权,或 Graph 真正到达终态。
|
|
9
|
+
|
|
10
|
+
本命令不返回原始 Backend DTO、capability 列表、内部 result ID/hash、graph、binding 或重复 guidance。
|
|
11
|
+
|
|
12
|
+
Backend 会根据当前 capability 选择 `current_delivery`;完整 `delivery_bindings` 仅是历史记录。CLI 不按数组位置猜测当前交付,同一 Execution 后续产生的新交付会取代旧交付成为默认结果。
|
|
13
|
+
|
|
14
|
+
## 语法与参数
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
itpay services next <service_execution_id> [--json]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
| 参数 | 必填 | 说明 |
|
|
21
|
+
| --- | --- | --- |
|
|
22
|
+
| `service_execution_id` | 是 | `services start` 或后续命令返回的 execution ID。 |
|
|
23
|
+
| `--json` | 否 | 输出稳定 JSON 信封;未指定时输出相同事实的简洁文本。 |
|
|
24
|
+
|
|
25
|
+
需要有效 Agent Device session。命令不接受 Buyer token、capability 或服务输入。
|
|
26
|
+
|
|
27
|
+
## 候选选择
|
|
28
|
+
|
|
29
|
+
免费或付费候选已经产生、Graph 允许继续选择时,恢复输出必须包含当前 Result Set 的安全候选:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"status": "candidate_selection_available",
|
|
34
|
+
"result": {
|
|
35
|
+
"service_execution_id": "<id>",
|
|
36
|
+
"items": [
|
|
37
|
+
{ "rank": 1, "title": "<title>", "safe_payload": { "<public_field>": "<value>" } }
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"instruction": "向用户展示编号和 safe_payload;用户选择后只在当前 Execution 提交对应 rank,不要新建 Execution。",
|
|
41
|
+
"next": {
|
|
42
|
+
"command": "itpay services action <id> --action select_candidate --actor-type human --status approved --candidate <rank> --json",
|
|
43
|
+
"reason": "仅在用户明确选择后锁定来源候选"
|
|
44
|
+
},
|
|
45
|
+
"recovery": []
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
该列表来自 Backend 的 `current_result_items`,CLI 不缓存或合并其他 Execution 的候选。
|
|
50
|
+
|
|
51
|
+
## Agent-visible 结果
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"status": "result_ready",
|
|
56
|
+
"result": {
|
|
57
|
+
"service_execution_id": "<id>",
|
|
58
|
+
"capability_id": "<capability_id>",
|
|
59
|
+
"delivery_mode": "agent_visible_result",
|
|
60
|
+
"items": [
|
|
61
|
+
{
|
|
62
|
+
"rank": 1,
|
|
63
|
+
"title": "<title>",
|
|
64
|
+
"safe_payload": { "<public_field>": "<value>" }
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"instruction": "这是当前 Graph 步骤对应的交付。向用户展示编号和 safe_payload;如用户选择,必须在当前 Execution 提交对应 rank。",
|
|
69
|
+
"next": {
|
|
70
|
+
"command": "itpay services action <id> --action select_candidate --actor-type human --status approved --candidate <rank> --json",
|
|
71
|
+
"reason": "仅在用户明确选择后锁定来源候选"
|
|
72
|
+
},
|
|
73
|
+
"recovery": []
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
只有 Graph 允许继续选择时才返回上述 `next`。若结果本身就是最终交付,则 instruction 为“只使用 safe_payload,不调用 read-result”,且 `next: null`。文本输出依次显示 `status`、Execution、`delivery_mode`、候选及 instruction,不暴露 Result Item ID、Invocation ID 或 Hash。
|
|
78
|
+
|
|
79
|
+
## Vault 交付
|
|
80
|
+
|
|
81
|
+
未授权时不返回 result item 或 protected payload:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"status": "human_authorization_required",
|
|
86
|
+
"result": {
|
|
87
|
+
"service_execution_id": "<id>",
|
|
88
|
+
"capability_id": "<capability_id>",
|
|
89
|
+
"delivery_mode": "vault_artifact",
|
|
90
|
+
"grant_status": "none"
|
|
91
|
+
},
|
|
92
|
+
"instruction": "这是当前 Graph 步骤对应的交付;请用户在订单页面授权,未授权前不要读取或猜测内容。",
|
|
93
|
+
"next": {
|
|
94
|
+
"command": "itpay services read-result <id> --json",
|
|
95
|
+
"reason": "仅在用户确认授权后执行"
|
|
96
|
+
},
|
|
97
|
+
"recovery": []
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
有效 grant 存在时:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"status": "grant_active",
|
|
106
|
+
"result": {
|
|
107
|
+
"service_execution_id": "<id>",
|
|
108
|
+
"capability_id": "<capability_id>",
|
|
109
|
+
"delivery_mode": "vault_artifact",
|
|
110
|
+
"grant_status": "active",
|
|
111
|
+
"grant_expires_at": "<RFC3339 time>"
|
|
112
|
+
},
|
|
113
|
+
"instruction": "这是当前 Graph 步骤对应的交付;用户授权有效,立即读取并遵守字段范围与到期时间。",
|
|
114
|
+
"next": {
|
|
115
|
+
"command": "itpay services read-result <id> --json",
|
|
116
|
+
"reason": "读取当前有效 grant 的结果"
|
|
117
|
+
},
|
|
118
|
+
"recovery": []
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
其他执行阶段只返回 Execution、service、phase、类型化 `allowed_actions` 和一个服务端状态导出的命令。CLI 只把 Backend 的动作类型渲染成命令,不执行 Publication 中的任意 shell 文本。完成或空结果后不得建议重放已失效的 invoke。
|
|
123
|
+
|
|
124
|
+
## 退款访问锁
|
|
125
|
+
|
|
126
|
+
订单存在 active 或永久退款锁时,该状态优先于 Agent-visible、Vault 和 grant guidance,不返回交付结果,也不再要求用户授权:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"status": "delivery_locked",
|
|
131
|
+
"result": {
|
|
132
|
+
"service_execution_id": "<id>",
|
|
133
|
+
"access_locked": true,
|
|
134
|
+
"refund": {
|
|
135
|
+
"refund_request_id": "<refund_id>",
|
|
136
|
+
"status": "<refund_status>"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"instruction": "退款处理中,交付已冻结;不要 reveal、创建 grant 或读取结果。",
|
|
140
|
+
"next": {
|
|
141
|
+
"command": "itpay refund get <refund_id> --json",
|
|
142
|
+
"reason": "读取退款权威状态"
|
|
143
|
+
},
|
|
144
|
+
"recovery": []
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`succeeded` 退款改为“交付永久关闭”,并返回 `next: null`。取消、拒绝或确定未产生资金影响的失败退款不再阻塞,但旧 grant 不会复活;用户必须重新授权。
|
|
149
|
+
|
|
150
|
+
## 异常处理
|
|
151
|
+
|
|
152
|
+
execution 不存在或不属于当前设备/账号时返回错误信封,并仅建议:
|
|
153
|
+
|
|
154
|
+
```text
|
|
155
|
+
itpay services get <service_execution_id> --json
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
不要创建替代 execution 来掩盖归属或状态错误。
|
|
159
|
+
|
|
160
|
+
## Agent Type / Host
|
|
161
|
+
|
|
162
|
+
`codex-desktop`、`codex-cli`、`claude-code-desktop`、`claude-code-cli`、`workbuddy` 返回完全相同的状态、safe payload、instruction 和 next。本命令不渲染二维码,也不包含 Host handoff。
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# `itpay services quote`
|
|
2
|
+
|
|
3
|
+
## 范围与意义
|
|
4
|
+
|
|
5
|
+
为当前 Service Execution 的一个付费 Capability 准备 Quote Lock。它只锁定可信输入、候选来源、价格、币种和有效期,不创建 Cart、Checkout、订单或 Provider 调用。
|
|
6
|
+
|
|
7
|
+
**上游:** `services next` 返回 `prepare_quote`,以及当前 Execution 内已批准的候选或完整 required input。
|
|
8
|
+
|
|
9
|
+
**下游:** `cart add --quote`。多个独立 Execution 的 Quote 可以加入同一 Cart。
|
|
10
|
+
|
|
11
|
+
## 语法与参数
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
itpay services quote <service_execution_id> --capability <capability_id>
|
|
15
|
+
[--input <key=value> ...] [--email <delivery_email>] [--json]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
| 参数 | 必填 | 说明 |
|
|
19
|
+
|---|---:|---|
|
|
20
|
+
| `service_execution_id` | 是 | 候选或输入所属的来源 Execution。 |
|
|
21
|
+
| `--capability` | 是 | 当前 `allowed_actions` 明确允许报价的付费 Capability。 |
|
|
22
|
+
| `--input` | 条件必填 | 不依赖已批准候选时,提供 schema 要求的输入;可重复。 |
|
|
23
|
+
| `--email` | 条件必填 | 仅 `delivery_email_required=true` 时需要,必须来自用户;随 Quote Lock 持久化。 |
|
|
24
|
+
| `--json` | 否 | 输出紧凑机器合同。 |
|
|
25
|
+
|
|
26
|
+
若 Capability 依赖候选,Backend 只从当前 Execution 的 approved Candidate Action 读取 Result Item、Invocation 和 Stable Hash;CLI 不重新提交公司名、候选 ID 或 Hash。
|
|
27
|
+
|
|
28
|
+
交付联系信息属于 Quote 的锁定事实。多个 Quote 合并付款时,Checkout Owner 汇总它们的联系信息;相同字段值冲突时拒绝创建 Checkout,不由 CLI 选择或覆盖。
|
|
29
|
+
|
|
30
|
+
## 标准输出
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"status": "quote_ready",
|
|
35
|
+
"result": {
|
|
36
|
+
"service_quote_lock_id": "<quote_id>",
|
|
37
|
+
"service_execution_id": "<execution_id>",
|
|
38
|
+
"capability_id": "<capability_id>",
|
|
39
|
+
"price": "<amount> <currency>",
|
|
40
|
+
"expires_at": "<RFC3339>"
|
|
41
|
+
},
|
|
42
|
+
"instruction": "报价已锁定当前 Execution 的可信输入和价格;可单独付款,也可与其他独立 Execution 的报价合并。",
|
|
43
|
+
"next": { "command": "itpay cart add --quote <quote_id> --json", "reason": "加入 canonical Cart" },
|
|
44
|
+
"recovery": [{ "command": "itpay services next <execution_id> --json", "reason": "重新读取当前 Execution 状态" }]
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
不得返回 locked input、Candidate Hash、Provider 元数据或完整 Execution DTO。
|
|
49
|
+
|
|
50
|
+
## 异常处理
|
|
51
|
+
|
|
52
|
+
- `capability_not_quoteable`:Capability 不存在、免费或当前不可报价;回到同一 Execution 的 `services next`。
|
|
53
|
+
- `capability_input_invalid`:缺少 required input;不创建 Quote、Cart 或 Checkout。
|
|
54
|
+
- `delivery_email_required`:先说明邮箱用于交付 claim link,再询问用户;禁止代填。
|
|
55
|
+
- 候选未确认、来自其他 Execution、Quote 已存在冲突:Backend 拒绝且不改变 Execution。
|
|
56
|
+
|
|
57
|
+
## Agent Type / Host
|
|
58
|
+
|
|
59
|
+
`codex-desktop`、`codex-cli`、`claude-code-desktop`、`claude-code-cli`、`workbuddy` 返回相同 Quote 事实、instruction 和 next。本命令不显示二维码;Agent Type 只作为设备与审计上下文,不改变价格或候选规则。
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# `itpay services read-result`
|
|
2
|
+
|
|
3
|
+
## 范围与意义
|
|
4
|
+
|
|
5
|
+
使用当前 Agent Device Authority,在用户创建的有效、未过期且范围匹配的 grant 内读取 Vault 保护结果。它不适用于 `agent_visible_result`。
|
|
6
|
+
|
|
7
|
+
**上游:** `services next` 返回 `vault_artifact`,且用户已在订单页面授权。
|
|
8
|
+
**下游:** Agent 仅在 grant scope 和 TTL 内使用返回字段;没有自动后续命令。
|
|
9
|
+
|
|
10
|
+
## 语法与参数
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
itpay services read-result <service_execution_id> [--json]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
| 参数 | 必填 | 说明 |
|
|
17
|
+
| --- | --- | --- |
|
|
18
|
+
| `service_execution_id` | 是 | Vault 交付对应的 execution ID。 |
|
|
19
|
+
| `--json` | 否 | 输出稳定 JSON 信封;未指定时输出相同事实的简洁文本。 |
|
|
20
|
+
|
|
21
|
+
CLI 使用已登记设备的签名 session,不接受 Checkout token、Buyer token、`agent_device_id` 参数或开发者凭证。
|
|
22
|
+
|
|
23
|
+
CLI 直接请求 Backend 的当前有效 Grant。历史 `delivery_bindings` 不作为访问判断;Backend 负责验证当前 Vault、Agent instance、Buyer、scope、TTL 和退款锁。
|
|
24
|
+
|
|
25
|
+
## 标准输出
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"status": "granted_result_ready",
|
|
30
|
+
"result": {
|
|
31
|
+
"service_execution_id": "<id>",
|
|
32
|
+
"grant_expires_at": "<RFC3339 time>",
|
|
33
|
+
"granted_fields": ["<field>"],
|
|
34
|
+
"payload": { "<granted_field>": "<value>" }
|
|
35
|
+
},
|
|
36
|
+
"instruction": "结果来自当前有效 Vault Grant;只使用本次授权字段,过期后停止读取并重新请求用户同意。",
|
|
37
|
+
"next": null,
|
|
38
|
+
"recovery": []
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
文本输出显示相同的 execution、到期时间、字段名和 payload,不附带 Vault ID、grant ID 或原始 scope。
|
|
43
|
+
|
|
44
|
+
## 异常处理
|
|
45
|
+
|
|
46
|
+
没有当前有效 Vault Grant(包括只有 Agent-visible 历史交付、未授权、过期、撤销或 wrong-scope)时,Backend 返回 `agent_access_denied`。CLI 指向:
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
itpay services next <id> --json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
不要从历史 Delivery Binding 推断当前模式,也不要使用数据库、Admin API 或新 Device ID 绕过授权。
|
|
53
|
+
|
|
54
|
+
退款访问锁由 Backend 在读取 Vault payload 的同一事务中拒绝:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"status": "error",
|
|
59
|
+
"error": {
|
|
60
|
+
"code": "delivery_locked_by_refund",
|
|
61
|
+
"message": "delivery is locked by refund <refund_id>"
|
|
62
|
+
},
|
|
63
|
+
"instruction": "退款访问锁已生效;不要 reveal、创建 grant 或读取交付结果。",
|
|
64
|
+
"next": null,
|
|
65
|
+
"recovery": [
|
|
66
|
+
{
|
|
67
|
+
"command": "itpay refund get <refund_id> --json",
|
|
68
|
+
"reason": "读取退款权威状态"
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
其他 `agent_access_denied` 返回:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"status": "error",
|
|
79
|
+
"error": {
|
|
80
|
+
"code": "agent_access_denied",
|
|
81
|
+
"message": "<server reason>"
|
|
82
|
+
},
|
|
83
|
+
"instruction": "请用户在订单页面重新授权;不要使用开发者权限绕过授权或退款锁。",
|
|
84
|
+
"next": null,
|
|
85
|
+
"recovery": [
|
|
86
|
+
{
|
|
87
|
+
"command": "itpay services next <id> --json",
|
|
88
|
+
"reason": "检查交付模式和 grant 状态"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
一个 grant 只允许读取对应订单、execution、Agent instance 和批准字段。拒绝时不得改用数据库、Admin API 或新 Device ID 绕过。
|
|
95
|
+
|
|
96
|
+
## Agent Type / Host
|
|
97
|
+
|
|
98
|
+
同一 Buyer account 下已登记的 `codex-desktop`、`codex-cli`、`claude-code-desktop`、`claude-code-cli`、`workbuddy` 可按政策领取同一订单授权;每个类型仍需自己的有效 Device Authority。五种类型返回相同字段、TTL 和错误,不因 Host 扩大 grant scope。
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# `itpay services start`
|
|
2
|
+
|
|
3
|
+
## 范围与意义
|
|
4
|
+
|
|
5
|
+
按 Catalog 中的 `service_id` 启动一次 Service Execution,并返回当前可执行的唯一首选动作。不会调用 Provider、创建 Checkout 或订单。
|
|
6
|
+
|
|
7
|
+
**上游:** `catalog list` 或服务端明确要求新 execution。
|
|
8
|
+
**下游:** `services invoke`、`action`、`checkout` 或 `next`。
|
|
9
|
+
|
|
10
|
+
## 语法与参数
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
itpay --agent-type <agent_type> services start <service_id>
|
|
14
|
+
[--host <host>] [--target <target>] [--json]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`service_id` 必须来自 Catalog。`--target` 只用于需要稳定消息目标的 Host。Buyer、Device 和 Agent instance 均来自签名 Agent session,不接受请求参数覆盖。
|
|
18
|
+
|
|
19
|
+
## 标准输出
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"status": "ready",
|
|
24
|
+
"result": {
|
|
25
|
+
"service_execution_id": "<execution_id>",
|
|
26
|
+
"service_id": "<service_id>",
|
|
27
|
+
"phase": "<phase>",
|
|
28
|
+
"capability": {
|
|
29
|
+
"capability_id": "<capability_id>",
|
|
30
|
+
"required_input": ["<field>"],
|
|
31
|
+
"free_quota_limit": 3
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"instruction": "填写首选 capability 的 required_input;一次只提交当前 execution 所代表的服务意图。",
|
|
35
|
+
"next": {
|
|
36
|
+
"command": "itpay services invoke <execution_id> --capability <capability_id> --input <key=value> --json",
|
|
37
|
+
"reason": "执行当前允许的能力"
|
|
38
|
+
},
|
|
39
|
+
"recovery": []
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Start API 只提供免费额度上限,不提供当前剩余额度,因此本命令不得虚构 `remaining`。不得输出全部 capability DTO、contract version、graph ID、buyer/device ID 或重复 guidance。若服务不存在,recovery 为 `catalog list`。设备 session 应由 CLI 自动登记或刷新;仅无法恢复时返回明确 enrollment 错误。
|
|
44
|
+
|
|
45
|
+
## Agent Type / Host
|
|
46
|
+
|
|
47
|
+
| Agent Type | 默认行为 |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `codex-desktop` | 登记该类型并使用 `codex` Host instruction。 |
|
|
50
|
+
| `codex-cli` | 登记该类型并使用 terminal instruction。 |
|
|
51
|
+
| `claude-code-desktop` | 登记该类型并使用 `claude-code` Host instruction。 |
|
|
52
|
+
| `claude-code-cli` | 登记该类型并使用 terminal instruction。 |
|
|
53
|
+
| `workbuddy` | 登记该类型并使用 plain-chat instruction。 |
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Output And Error Contract
|
|
2
|
+
|
|
3
|
+
## 目标
|
|
4
|
+
|
|
5
|
+
CLI 输出是给 Agent 执行的协议,不是后端 DTO 的调试转储。默认输出适合人阅读;`--json` 使用同一语义的稳定机器合同。调试事实只由明确的诊断命令返回。
|
|
6
|
+
|
|
7
|
+
## 标准 JSON 外壳
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"status": "<command_state>",
|
|
12
|
+
"result": {},
|
|
13
|
+
"instruction": "<one concise instruction>",
|
|
14
|
+
"next": {
|
|
15
|
+
"command": "itpay <next-command>",
|
|
16
|
+
"reason": "<why this is next>"
|
|
17
|
+
},
|
|
18
|
+
"recovery": []
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
规则:
|
|
23
|
+
|
|
24
|
+
- `status`:当前命令的业务结果,不是 HTTP 状态。
|
|
25
|
+
- `result`:仅包含当前步骤必须使用或向用户说明的事实。
|
|
26
|
+
- `instruction`:一条可直接当作 Agent prompt 使用的自然语言指令,不复述 `result`。
|
|
27
|
+
- `next`:最多一个首选动作;流程结束时为 `null`。
|
|
28
|
+
- `recovery`:成功时通常为空;失败或中断时最多两个动作。
|
|
29
|
+
- 相同事实不得同时出现在顶层、`agent_guidance`、`next_actions` 等多个位置。
|
|
30
|
+
- 默认隐藏 buyer、device、contract version、compiled graph、quote lock、内部 event ID 等实现细节。
|
|
31
|
+
- token、付款 URL 和本地二维码路径只在确实需要交给用户时返回,并不得写入日志型命令。
|
|
32
|
+
|
|
33
|
+
## 默认文本输出
|
|
34
|
+
|
|
35
|
+
文本输出与 JSON 字段一一对应,最多四段:
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
<status summary>
|
|
39
|
+
<necessary result lines>
|
|
40
|
+
instruction: <what the agent must do>
|
|
41
|
+
next: <one command>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
无下一步时省略 `next`;无异常时省略 `recovery`。
|
|
45
|
+
|
|
46
|
+
## 标准错误
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"status": "error",
|
|
51
|
+
"error": {
|
|
52
|
+
"code": "<stable_error_code>",
|
|
53
|
+
"message": "<human-readable reason>"
|
|
54
|
+
},
|
|
55
|
+
"instruction": "<what not to do and what to correct>",
|
|
56
|
+
"next": null,
|
|
57
|
+
"recovery": [
|
|
58
|
+
{ "command": "itpay <recovery-command>", "reason": "<reason>" }
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
错误必须满足:
|
|
64
|
+
|
|
65
|
+
- 参数和前置条件在产生订单、锁价、扣费、Provider 调用或状态迁移前验证。
|
|
66
|
+
- 不得只返回 `invalid_state`;必须说明当前状态和合法恢复入口。
|
|
67
|
+
- 重试应复用同一 cart、checkout、execution、order 或 refund ID,不得默认创建新资源。
|
|
68
|
+
- 用户口头说“已付款”不是支付事实;仅服务端 `verified` 状态有效。
|
|
69
|
+
|
|
70
|
+
## Instruction 模板
|
|
71
|
+
|
|
72
|
+
Instruction 只回答当前最重要的一件事:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
说明结果的意义 + 明确 Agent 现在必须做或禁止做的动作。
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
示例:
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
把付款二维码和链接展示给用户;确认用户可见前不要查询付款状态,也不要创建新 Checkout。
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
不得使用空洞 instruction,例如“继续下一步”“按需处理”“查看详情”。
|
|
85
|
+
|
|
86
|
+
## 通用性边界
|
|
87
|
+
|
|
88
|
+
- CLI 不识别企知道、企业查询、某个 capability 名称或某个字段名。
|
|
89
|
+
- 必填输入来自 `input_schema.required`。
|
|
90
|
+
- 是否收费来自 `requires_payment` 和价格元数据。
|
|
91
|
+
- 是否需要邮箱来自 `delivery_email_required`。
|
|
92
|
+
- 是否可直接给 Agent 来自 `agent_visible` / `delivery_mode`。
|
|
93
|
+
- 下一步来自 Service Execution read model,不由 CLI 猜业务流程。
|
|
94
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# ItPay CLI Command Reference
|
|
2
|
+
|
|
3
|
+
本目录是 ItPay CLI 的规范性命令合同。它定义命令应向人和 Agent 返回什么、如何指导下一步,以及失败后如何恢复。当前实现与本文档不一致时,以本文档作为后续校准目标。
|
|
4
|
+
|
|
5
|
+
企知道可以作为示例数据出现,但任何命令、字段、状态和 instruction 都不得依赖某个服务。服务差异只能来自 Catalog、Service Contract、Capability metadata 和服务端状态。
|
|
6
|
+
|
|
7
|
+
## 使用约定
|
|
8
|
+
|
|
9
|
+
- [输出与错误合同](conventions.md)
|
|
10
|
+
- [Agent Type 与 Host](agent-types.md)
|
|
11
|
+
- 所有示例中的 `<...>` 都是占位符,不得原样提交。
|
|
12
|
+
- 所有 commerce 命令必须使用真实的 `--agent-type`,不得为刷新额度伪造类型。
|
|
13
|
+
- 每条命令只返回当前步骤所需事实、一条 instruction、一个首选 next;异常时最多返回两个 recovery。
|
|
14
|
+
|
|
15
|
+
## 命令目录
|
|
16
|
+
|
|
17
|
+
### 环境与发现
|
|
18
|
+
|
|
19
|
+
- [`itpay readyz`](commands/readyz.md) - 检查后端是否可用
|
|
20
|
+
- [`itpay next`](commands/next.md) - 从本地保存的服务端句柄恢复下一步
|
|
21
|
+
- [`itpay catalog`](commands/catalog/index.md)
|
|
22
|
+
- [`itpay catalog list`](commands/catalog/list.md)
|
|
23
|
+
- [`itpay install`](commands/install.md) - 查看指定 Agent 的安装说明
|
|
24
|
+
- [`itpay docs`](commands/docs/index.md)
|
|
25
|
+
- [`itpay docs list`](commands/docs/list.md)
|
|
26
|
+
- [`itpay docs show`](commands/docs/show.md)
|
|
27
|
+
- [`itpay docs search`](commands/docs/search.md)
|
|
28
|
+
|
|
29
|
+
### 购物与支付
|
|
30
|
+
|
|
31
|
+
- [`itpay cart`](commands/cart/index.md)
|
|
32
|
+
- [`itpay cart add`](commands/cart/add.md)
|
|
33
|
+
- [`itpay cart next`](commands/cart/next.md)
|
|
34
|
+
- [`itpay cart remove`](commands/cart/remove.md)
|
|
35
|
+
- [`itpay cart show`](commands/cart/show.md)
|
|
36
|
+
- [`itpay cart clear`](commands/cart/clear.md)
|
|
37
|
+
- [`itpay buy`](commands/buy.md)
|
|
38
|
+
- [`itpay checkout`](commands/checkout.md)
|
|
39
|
+
- [`itpay pay`](commands/pay.md)
|
|
40
|
+
- [`itpay order`](commands/order.md)
|
|
41
|
+
- [`itpay orders`](commands/orders.md)
|
|
42
|
+
|
|
43
|
+
### 退款
|
|
44
|
+
|
|
45
|
+
- [`itpay refund`](commands/refund/index.md)
|
|
46
|
+
- [`itpay refund create`](commands/refund/create.md)
|
|
47
|
+
- [`itpay refund list`](commands/refund/list.md)
|
|
48
|
+
- [`itpay refund get`](commands/refund/get.md)
|
|
49
|
+
- [`itpay refund watch`](commands/refund/watch.md)
|
|
50
|
+
- [`itpay refund cancel`](commands/refund/cancel.md)
|
|
51
|
+
|
|
52
|
+
### 通用服务执行
|
|
53
|
+
|
|
54
|
+
- [`itpay services`](commands/services/index.md)
|
|
55
|
+
- [`itpay services start`](commands/services/start.md)
|
|
56
|
+
- [`itpay services invoke`](commands/services/invoke.md)
|
|
57
|
+
- [`itpay services action`](commands/services/action.md)
|
|
58
|
+
- [`itpay services quote`](commands/services/quote.md)
|
|
59
|
+
- [`itpay services checkout`](commands/services/checkout.md)
|
|
60
|
+
- [`itpay services list`](commands/services/list.md)
|
|
61
|
+
- [`itpay services get`](commands/services/get.md)
|
|
62
|
+
- [`itpay services next`](commands/services/next.md)
|
|
63
|
+
- [`itpay services read-result`](commands/services/read-result.md)
|
|
64
|
+
- [`itpay services events`](commands/services/events.md)
|