@itpay/cli 2.1.40 → 2.1.41
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 +5 -12
- package/dist/src/client/backend.js +2 -38
- package/dist/src/client/http.js +0 -2
- package/dist/src/commands/buy.js +58 -17
- package/dist/src/commands/cart.js +15 -17
- package/dist/src/commands/catalog.js +14 -39
- package/dist/src/commands/checkout.js +5 -146
- package/dist/src/commands/checkout_handoff.js +61 -11
- package/dist/src/commands/docs.js +18 -7
- package/dist/src/commands/guidance.js +134 -1
- package/dist/src/commands/install.js +3 -6
- package/dist/src/commands/order.js +3 -34
- package/dist/src/commands/orders.js +9 -4
- package/dist/src/commands/pay.js +1 -1
- package/dist/src/commands/readyz.js +1 -1
- package/dist/src/commands/refund.js +57 -13
- package/dist/src/commands/services.js +1068 -14
- package/dist/src/commands/skill.js +5 -8
- package/dist/src/commands/vault.js +20 -27
- package/dist/src/commands/vault_handoff.js +0 -18
- package/dist/src/main.js +43 -330
- package/dist/src/render/markdown.js +3 -0
- package/dist/src/render/qr.js +1 -1
- package/dist/src/state/cart_session.js +1 -4
- package/dist/src/state/client_context.js +0 -72
- package/dist/src/state/config.js +14 -44
- package/dist/src/state/device_authority.js +41 -141
- package/docs/agent/buyer/cart-checkout.json +6 -8
- package/docs/agent/buyer/catalog-list.json +9 -29
- package/docs/agent/buyer/identity-and-sessions.json +9 -26
- package/docs/agent/buyer/install-and-setup.json +9 -10
- package/docs/agent/buyer/orders-refunds.json +9 -25
- package/docs/agent/buyer/payment-flow.json +4 -6
- package/docs/agent/buyer/purchased-content.json +4 -18
- package/docs/agent/buyer/quickstart.json +17 -26
- package/docs/agent/buyer/render-hosts.json +12 -23
- package/docs/agent/buyer/service-feedback.json +3 -4
- package/docs/cli-reference/agent-types.md +2 -7
- package/docs/cli-reference/commands/buy.md +1 -2
- package/docs/cli-reference/commands/cart/add.md +1 -5
- package/docs/cli-reference/commands/cart/clear.md +1 -1
- package/docs/cli-reference/commands/cart/index.md +1 -1
- package/docs/cli-reference/commands/cart/next.md +1 -5
- package/docs/cli-reference/commands/cart/remove.md +1 -1
- package/docs/cli-reference/commands/cart/show.md +1 -1
- package/docs/cli-reference/commands/catalog/index.md +1 -1
- package/docs/cli-reference/commands/catalog/list.md +2 -2
- package/docs/cli-reference/commands/checkout.md +2 -12
- package/docs/cli-reference/commands/device.md +11 -18
- package/docs/cli-reference/commands/docs/index.md +1 -1
- package/docs/cli-reference/commands/docs/list.md +1 -1
- package/docs/cli-reference/commands/docs/search.md +1 -1
- package/docs/cli-reference/commands/docs/show.md +1 -1
- package/docs/cli-reference/commands/install.md +6 -8
- package/docs/cli-reference/commands/next.md +1 -1
- package/docs/cli-reference/commands/order.md +1 -1
- package/docs/cli-reference/commands/pay.md +1 -1
- package/docs/cli-reference/commands/readyz.md +11 -11
- package/docs/cli-reference/commands/refund/cancel.md +1 -1
- package/docs/cli-reference/commands/refund/create.md +1 -1
- package/docs/cli-reference/commands/refund/get.md +2 -2
- package/docs/cli-reference/commands/refund/index.md +1 -1
- package/docs/cli-reference/commands/refund/list.md +1 -1
- package/docs/cli-reference/commands/refund/watch.md +1 -1
- package/docs/cli-reference/commands/services/action.md +3 -24
- package/docs/cli-reference/commands/services/checkout.md +2 -17
- package/docs/cli-reference/commands/services/events.md +1 -1
- package/docs/cli-reference/commands/services/get.md +2 -4
- package/docs/cli-reference/commands/services/index.md +3 -4
- package/docs/cli-reference/commands/services/invoke.md +4 -6
- package/docs/cli-reference/commands/services/list.md +1 -1
- package/docs/cli-reference/commands/services/next.md +12 -78
- package/docs/cli-reference/commands/services/quote.md +4 -4
- package/docs/cli-reference/commands/services/read-result.md +6 -17
- package/docs/cli-reference/commands/services/start.md +3 -5
- package/docs/cli-reference/commands/vault/access.md +1 -5
- package/docs/cli-reference/conventions.md +6 -4
- package/docs/cli-reference/index.md +1 -10
- package/docs/skill-bundle-rollout/01-mcp-authentication.md +134 -0
- package/docs/skill-bundle-rollout/02-platform-bundle-repositories.md +210 -0
- package/docs/skill-bundle-rollout/03-platform-publishing.md +161 -0
- package/docs/skill-bundle-rollout/04-first-wave-platforms.md +69 -0
- package/docs/skill-bundle-rollout/05-sync-operations.md +62 -0
- package/docs/skill-bundle-rollout/README.md +151 -0
- package/package.json +12 -20
- package/skills/itpay/SKILL.md +102 -110
- package/assets/sell-preview/index.html +0 -6
- package/assets/sell-preview/preview.js +0 -9
- package/bin/darwin-amd64/itpay-sell +0 -0
- package/bin/darwin-arm64/itpay-sell +0 -0
- package/bin/linux-amd64/itpay-sell +0 -0
- package/bin/linux-arm64/itpay-sell +0 -0
- package/bin/windows-amd64/itpay-sell.exe +0 -0
- package/dist/src/commands/aftercare.js +0 -12
- package/dist/src/commands/presentation.js +0 -153
- package/dist/src/commands/rail_catalog.js +0 -1
- package/dist/src/commands/services/actions.js +0 -133
- package/dist/src/commands/services/commerce.js +0 -197
- package/dist/src/commands/services/lifecycle.js +0 -418
- package/dist/src/commands/services/results.js +0 -130
- package/dist/src/render/browser.js +0 -65
- package/dist/src/render/checkout_handoff.js +0 -101
- package/dist/src/render/checkout_plan.js +0 -47
- package/dist/src/sell/commands.js +0 -80
- package/dist/src/sell/contract.js +0 -86
- package/dist/src/sell/local.js +0 -260
- package/dist/src/sell/mcp.js +0 -49
- package/dist/src/sell/preview.js +0 -70
- package/dist/src/sell/sync.js +0 -145
- package/dist/src/services/adapter.js +0 -1
- package/dist/src/services/presentation.js +0 -198
- package/dist/src/services/rail/actions.js +0 -51
- package/dist/src/services/rail/adapter.js +0 -27
- package/dist/src/services/rail/aftercare.js +0 -45
- package/dist/src/services/rail/catalog.js +0 -261
- package/dist/src/services/rail/checkout.js +0 -19
- package/dist/src/services/rail/fulfillment.js +0 -76
- package/dist/src/services/rail/guide.js +0 -110
- package/dist/src/services/rail/invocation.js +0 -54
- package/dist/src/services/rail/page.js +0 -76
- package/dist/src/services/rail/pagination.js +0 -6
- package/dist/src/services/rail/query.js +0 -71
- package/dist/src/services/rail/readers.js +0 -107
- package/dist/src/services/rail/reading.js +0 -125
- package/dist/src/services/rail/recovery.js +0 -51
- package/dist/src/services/rail/results.js +0 -378
- package/dist/src/services/rail/review.js +0 -268
- package/dist/src/services/rail/saved.js +0 -49
- package/dist/src/services/rail/wait.js +0 -11
- package/dist/src/services/registry.js +0 -31
- package/dist/src/services/schema.js +0 -21
- package/dist/src/services/shared/envelope.js +0 -184
- package/dist/src/services/shared/input.js +0 -39
- package/dist/src/services/shared/pagination.js +0 -28
- package/dist/src/services/shared/platform.js +0 -365
- package/dist/src/services/shared/refund.js +0 -40
- package/dist/src/services/shared/workflow.js +0 -28
- package/dist/src/state/account_auth.js +0 -347
- package/dist/src/state/task_journal.js +0 -90
- package/docs/agent/buyer/rail-booking.json +0 -176
- package/docs/agent/buyer/rail-fast-checkout.json +0 -48
- package/docs/cli-reference/commands/aftercare.md +0 -15
- package/docs/cli-reference/commands/auth.md +0 -96
- package/docs/cli-reference/commands/sell.md +0 -1364
- package/docs/cli-reference/commands/services/page.md +0 -71
- package/docs/cli-reference/commands/services/run.md +0 -152
- package/docs/sell.md +0 -84
- /package/bin/{itp.mjs → itp} +0 -0
|
@@ -8,7 +8,7 @@ export async function runReadyz(backend, options = {}) {
|
|
|
8
8
|
status: response.status,
|
|
9
9
|
result: { backend: "available", backend_url: backendURL, environment, ...(options.agentType ? { agent_type: options.agentType } : {}) },
|
|
10
10
|
instruction: environment === "development"
|
|
11
|
-
?
|
|
11
|
+
? "ItPay dev 可用。只证明后端存活。尚未读此次包 Skill 时完整读取;已读同版本则无需重复,继续设备状态检查;后续必须执行返回的完整命令并保持同一 dev Backend。"
|
|
12
12
|
: "ItPay 可用。只证明后端存活。尚未读此次包 Skill 时完整读取;已读同版本则无需重复,继续设备状态检查;不自动登录或开始业务。",
|
|
13
13
|
next: { command: "itpay skill show itpay --json", reason: "加载完整操作与安全规则" },
|
|
14
14
|
recovery: [],
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { refundStateEnvelope } from "../services/shared/refund.js";
|
|
2
1
|
import { operationID } from "../state/config.js";
|
|
3
2
|
import { formatMoney } from "../render/output.js";
|
|
4
3
|
import { resolveOutput } from "../render/sink.js";
|
|
@@ -13,6 +12,46 @@ export async function runRefund(backend, config, options) {
|
|
|
13
12
|
plainResult: Object.entries(envelope.result).map(([key, value]) => `${key}: ${typeof value === "string" ? value : JSON.stringify(value)}`),
|
|
14
13
|
});
|
|
15
14
|
}
|
|
15
|
+
function refundStateEnvelope(refund, status) {
|
|
16
|
+
const terminal = ["succeeded", "failed", "cancelled", "rejected"].includes(refund.status);
|
|
17
|
+
let instruction = refund.decision_mode === "manual"
|
|
18
|
+
? "先告诉用户退款已进入人工审核,原交付保持冻结;人工审核不等于拒绝,等待服务器决定,不要重复申请或承诺结果。"
|
|
19
|
+
: "先告诉用户退款申请已经记录,原交付已冻结;自动路径表示系统会继续处理,但只有最终 succeeded 才能确认退款成功。然后只跟踪同一退款,不要重复申请、reveal、授权或读取结果。";
|
|
20
|
+
if (!refund.access_locked)
|
|
21
|
+
instruction = "先告诉用户退款当前没有锁定交付;按服务器事实解释当前状态,不要自行推断退款结果、到账时间或交付资格。";
|
|
22
|
+
if (refund.status === "succeeded")
|
|
23
|
+
instruction = "先告诉用户退款已由 ItPay 确认成功,原交付永久关闭;不需要继续跟踪或重复申请。";
|
|
24
|
+
if (refund.status === "cancelled" || refund.status === "rejected")
|
|
25
|
+
instruction = "先告诉用户退款没有执行,交付资格可以恢复;旧读取授权不会复活,需要用户重新授权。不要把取消或拒绝说成退款成功。";
|
|
26
|
+
if (refund.status === "failed") {
|
|
27
|
+
if (refund.failure_class === "known_no_effect")
|
|
28
|
+
instruction = "先告诉用户本次退款请求确认未发送,不能说退款已成功;Agent 不自行重试,请用户等待平台管理员决定是否重新执行。";
|
|
29
|
+
else if (refund.failure_class === "retryable")
|
|
30
|
+
instruction = "先告诉用户渠道明确返回可重试失败,但 Agent 不会自行重试或重复申请;请用户等待平台管理员处理。";
|
|
31
|
+
else if (refund.failure_class === "outcome_unknown")
|
|
32
|
+
instruction = "先告诉用户退款渠道结果未知,原交付继续锁定且必须先由平台对账;禁止重试、重复申请或承诺退款结果。";
|
|
33
|
+
else if (refund.failure_class === "permanent")
|
|
34
|
+
instruction = "先告诉用户渠道明确拒绝本次退款,当前不能承诺退款成功;不要重试,请用户联系平台支持。";
|
|
35
|
+
else
|
|
36
|
+
instruction = "先告诉用户退款没有正常完成,当前不能承诺退款成功;不要重试或重复申请,请用户联系平台支持。";
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
status,
|
|
40
|
+
result: {
|
|
41
|
+
refund_request_id: refund.refund_request_id,
|
|
42
|
+
order_id: refund.order_id,
|
|
43
|
+
decision_mode: refund.decision_mode,
|
|
44
|
+
refund_status: refund.status,
|
|
45
|
+
consumption_state: refund.consumption_state,
|
|
46
|
+
...(refund.failure_class ? { failure_class: refund.failure_class } : {}),
|
|
47
|
+
access_locked: refund.access_locked,
|
|
48
|
+
can_cancel: refund.can_cancel,
|
|
49
|
+
},
|
|
50
|
+
instruction,
|
|
51
|
+
next: terminal ? null : { command: `itpay refund watch ${refund.refund_request_id} --json`, reason: "跟踪同一退款" },
|
|
52
|
+
recovery: [],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
16
55
|
export async function runListRefunds(backend, options) {
|
|
17
56
|
const out = resolveOutput(options.output);
|
|
18
57
|
const response = await backend.listOrderRefunds(options.orderID);
|
|
@@ -34,7 +73,7 @@ export async function runListRefunds(backend, options) {
|
|
|
34
73
|
: "该订单没有退款记录;确认用户确实要求退款后再创建。",
|
|
35
74
|
next: selected
|
|
36
75
|
? { command: `itpay refund get ${selected.refund_request_id} --json`, reason: active ? "读取活跃退款" : "读取最新退款" }
|
|
37
|
-
:
|
|
76
|
+
: { command: `itpay refund create --order ${options.orderID} --json`, reason: "为该订单创建退款" },
|
|
38
77
|
recovery: [],
|
|
39
78
|
};
|
|
40
79
|
writeCommandEnvelope(envelope, {
|
|
@@ -57,13 +96,13 @@ export async function runGetRefund(backend, refundID, options = {}) {
|
|
|
57
96
|
export async function runCancelRefund(backend, refundID, reason, options = {}) {
|
|
58
97
|
const refund = await backend.cancelRefund(refundID, reason?.trim() || "buyer_cancelled");
|
|
59
98
|
const envelope = {
|
|
60
|
-
status:
|
|
99
|
+
status: "cancelled",
|
|
61
100
|
result: {
|
|
62
101
|
refund_request_id: refund.refund_request_id,
|
|
63
102
|
order_id: refund.order_id,
|
|
64
103
|
access_locked: refund.access_locked,
|
|
65
104
|
},
|
|
66
|
-
instruction:
|
|
105
|
+
instruction: "退款已取消;如需交付,重新进入订单并取得新的授权。",
|
|
67
106
|
next: { command: `itpay order ${refund.order_id} --json`, reason: "确认订单访问状态" },
|
|
68
107
|
recovery: [],
|
|
69
108
|
};
|
|
@@ -71,30 +110,36 @@ export async function runCancelRefund(backend, refundID, reason, options = {}) {
|
|
|
71
110
|
}
|
|
72
111
|
export async function runWatchRefund(backend, refundID, options = {}) {
|
|
73
112
|
const intervalSeconds = options.intervalSeconds ?? 2;
|
|
74
|
-
const timeoutSeconds = options.timeoutSeconds ??
|
|
113
|
+
const timeoutSeconds = options.timeoutSeconds ?? 120;
|
|
75
114
|
if (!Number.isFinite(intervalSeconds) || intervalSeconds < 1)
|
|
76
115
|
throw new Error("--interval must be at least 1 second");
|
|
77
116
|
if (!Number.isFinite(timeoutSeconds) || timeoutSeconds <= 0)
|
|
78
117
|
throw new Error("--timeout must be a positive number");
|
|
79
118
|
const deadline = Date.now() + timeoutSeconds * 1000;
|
|
80
119
|
let refund;
|
|
81
|
-
let initialState;
|
|
82
120
|
for (;;) {
|
|
83
121
|
refund = await backend.getRefund(refundID);
|
|
84
|
-
|
|
85
|
-
if (["succeeded", "failed", "cancelled", "rejected"].includes(refund.status) || refund.decision_mode === "manual" || refund.failure_class === "outcome_unknown" || (initialState !== undefined && state !== initialState)) {
|
|
122
|
+
if (["succeeded", "failed", "cancelled", "rejected"].includes(refund.status)) {
|
|
86
123
|
writeRefundEnvelope(refundStateEnvelope(refund, "watch_complete"), options);
|
|
87
124
|
return;
|
|
88
125
|
}
|
|
89
|
-
initialState ??= state;
|
|
90
126
|
const remaining = deadline - Date.now();
|
|
91
127
|
if (remaining <= 0)
|
|
92
128
|
break;
|
|
93
129
|
await new Promise((resolve) => setTimeout(resolve, Math.min(intervalSeconds * 1000, remaining)));
|
|
94
130
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
131
|
+
writeRefundEnvelope({
|
|
132
|
+
status: "watch_timeout",
|
|
133
|
+
result: {
|
|
134
|
+
refund_request_id: refund.refund_request_id,
|
|
135
|
+
last_status: refund.status,
|
|
136
|
+
access_locked: refund.access_locked,
|
|
137
|
+
can_cancel: refund.can_cancel,
|
|
138
|
+
},
|
|
139
|
+
instruction: "先告诉用户退款仍在处理,Timeout 只表示本次等待结束,并不表示退款失败;稍后继续跟踪同一退款,不要重复申请或承诺结果。",
|
|
140
|
+
next: { command: `itpay refund watch ${refund.refund_request_id} --json`, reason: "恢复轮询" },
|
|
141
|
+
recovery: [],
|
|
142
|
+
}, options);
|
|
98
143
|
}
|
|
99
144
|
function writeRefundEnvelope(envelope, options) {
|
|
100
145
|
writeCommandEnvelope(envelope, {
|
|
@@ -103,4 +148,3 @@ function writeRefundEnvelope(envelope, options) {
|
|
|
103
148
|
plainResult: Object.entries(envelope.result).map(([key, value]) => `${key}: ${typeof value === "string" ? value : JSON.stringify(value)}`),
|
|
104
149
|
});
|
|
105
150
|
}
|
|
106
|
-
export { refundStateEnvelope } from "../services/shared/refund.js";
|