@itpay/cli 2.1.34 → 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 -33
- package/dist/src/client/http.js +0 -2
- package/dist/src/commands/buy.js +4 -7
- package/dist/src/commands/cart.js +15 -15
- package/dist/src/commands/catalog.js +7 -17
- package/dist/src/commands/checkout.js +5 -146
- package/dist/src/commands/checkout_handoff.js +10 -48
- package/dist/src/commands/docs.js +18 -7
- package/dist/src/commands/guidance.js +19 -69
- package/dist/src/commands/install.js +3 -6
- package/dist/src/commands/order.js +1 -14
- package/dist/src/commands/orders.js +9 -4
- package/dist/src/commands/pay.js +1 -1
- package/dist/src/commands/readyz.js +2 -2
- package/dist/src/commands/refund.js +5 -5
- package/dist/src/commands/services.js +167 -1712
- 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 +58 -294
- 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 +5 -6
- package/docs/agent/buyer/catalog-list.json +6 -24
- package/docs/agent/buyer/identity-and-sessions.json +9 -25
- package/docs/agent/buyer/install-and-setup.json +15 -11
- package/docs/agent/buyer/orders-refunds.json +5 -12
- package/docs/agent/buyer/payment-flow.json +3 -4
- package/docs/agent/buyer/purchased-content.json +4 -18
- package/docs/agent/buyer/quickstart.json +16 -24
- package/docs/agent/buyer/render-hosts.json +12 -23
- package/docs/agent/buyer/service-feedback.json +1 -2
- 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 -1
- 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 -1
- 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 +10 -58
- 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 -13
- 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 -105
- package/docs/cli-reference/commands/services/quote.md +3 -3
- package/docs/cli-reference/commands/services/read-result.md +6 -17
- package/docs/cli-reference/commands/services/start.md +2 -2
- 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 -8
- 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 +13 -20
- package/skills/itpay/SKILL.md +105 -101
- 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/presentation.js +0 -153
- package/dist/src/commands/rail_catalog.js +0 -261
- package/dist/src/render/browser.js +0 -65
- 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/state/account_auth.js +0 -332
- package/dist/src/state/task_journal.js +0 -90
- package/docs/agent/buyer/rail-booking.json +0 -162
- package/docs/agent/buyer/rail-fast-checkout.json +0 -48
- 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 -156
- package/docs/sell.md +0 -84
- /package/bin/{itp.mjs → itp} +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { dirname, resolve } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { CODEX_WAIT_GUIDANCE } from "./install.js";
|
|
5
4
|
import { declaredAgentType } from "../state/agent_type.js";
|
|
6
5
|
import { CommandContractError, writeCommandEnvelope } from "./guidance.js";
|
|
7
6
|
const commandDir = dirname(fileURLToPath(import.meta.url));
|
|
@@ -20,14 +19,12 @@ export function runSkillShow(name, options = {}) {
|
|
|
20
19
|
}
|
|
21
20
|
validateSkill(content);
|
|
22
21
|
const agentType = options.agentType ?? declaredAgentType();
|
|
23
|
-
if (agentType?.startsWith("codex-"))
|
|
24
|
-
content += `\n## Codex command continuation\n\n${CODEX_WAIT_GUIDANCE}\n`;
|
|
25
22
|
const envelope = {
|
|
26
23
|
status: "shown",
|
|
27
24
|
result: { skill: ITPAY_SKILL, content },
|
|
28
25
|
instruction: agentType
|
|
29
26
|
? agentType === "workbuddy"
|
|
30
|
-
? "完整读取并遵守 Skill
|
|
27
|
+
? "完整读取并遵守 Skill;把自己视为服务用户的代理,先理解用户要购买新服务、查看已购内容、查询订单还是处理退款,并先解释用户权益,再选择对应的第一条命令。保持 workbuddy 和同一 Node/CLI launcher。运行会持久化 ~/.itpay-v3 的 ItPay Bash 命令前,把 Shell 工具参数 dangerouslyDisableSandbox 设为 true;用户拒绝权限时停止,不要切换 Node、删除 identity 或处理 lock。"
|
|
31
28
|
: `完整读取并遵守 Skill;把自己视为服务用户的代理,先理解用户意图和解释用户权益,再选择购买、已购内容、订单或退款对应的第一条命令。当前 Agent Type 是 ${agentType},后续命令保持不变。`
|
|
32
29
|
: "完整读取并遵守 Skill;先如实选择当前运行环境对应的 Agent Type。",
|
|
33
30
|
next: agentType
|
|
@@ -49,10 +46,10 @@ function findSkillPath() {
|
|
|
49
46
|
return directPath;
|
|
50
47
|
return resolve(configuredRoot, ITPAY_SKILL, "SKILL.md");
|
|
51
48
|
}
|
|
52
|
-
const
|
|
53
|
-
if (existsSync(
|
|
54
|
-
return
|
|
55
|
-
return resolve(commandDir, "..", "..", "skills", ITPAY_SKILL, "SKILL.md");
|
|
49
|
+
const sourcePath = resolve(commandDir, "..", "..", "skills", ITPAY_SKILL, "SKILL.md");
|
|
50
|
+
if (existsSync(sourcePath))
|
|
51
|
+
return sourcePath;
|
|
52
|
+
return resolve(commandDir, "..", "..", "..", "skills", ITPAY_SKILL, "SKILL.md");
|
|
56
53
|
}
|
|
57
54
|
function validateSkill(content) {
|
|
58
55
|
const frontmatter = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/)?.[1];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HttpError } from "../client/http.js";
|
|
2
|
-
import { requiresTarget
|
|
2
|
+
import { requiresTarget } from "../state/client_context.js";
|
|
3
3
|
import { formatMoney } from "../render/output.js";
|
|
4
|
-
import { CommandContractError,
|
|
4
|
+
import { CommandContractError, writeCommandEnvelope } from "./guidance.js";
|
|
5
5
|
import { buildVaultHandoff } from "./vault_handoff.js";
|
|
6
6
|
function outputOptions(options, plainResult) {
|
|
7
7
|
return {
|
|
@@ -19,21 +19,21 @@ export async function runVaultList(backend, input) {
|
|
|
19
19
|
const value = await backend.listBuyerVaultArtifacts(input);
|
|
20
20
|
writeCommandEnvelope({
|
|
21
21
|
status: value.items.length ? "vault_listed" : "no_vault_artifacts",
|
|
22
|
-
result: { items: value.items
|
|
22
|
+
result: { items: value.items, next_cursor: value.next_cursor || null },
|
|
23
23
|
instruction: value.items.length
|
|
24
|
-
? "
|
|
24
|
+
? "用编号、服务名称、内容主体、购买时间、金额和订单号说明匹配结果,不要向用户显示内部内容标识。一个精确匹配可按用户原始查看意图继续读取;多个匹配必须让用户选择。"
|
|
25
25
|
: "当前账号没有匹配的已购内容。向用户说明没有找到,不要猜测内容标识、自动购买或发起新的服务查询。",
|
|
26
|
-
next:
|
|
26
|
+
next: null,
|
|
27
27
|
recovery: [],
|
|
28
|
-
}, outputOptions(input));
|
|
28
|
+
}, outputOptions(input, value.items.map((item, index) => `${index + 1}. ${item.service_title}${item.subject_label ? ` · ${item.subject_label}` : ""} · ${formatMoney(item.amount_minor, item.currency)} · ${item.purchased_at} · ${item.order_code} · ${item.order_status}`)));
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
31
31
|
if (error instanceof HttpError && error.code === "vault_authorization_required") {
|
|
32
32
|
writeCommandEnvelope({
|
|
33
33
|
status: "human_authorization_required",
|
|
34
34
|
result: { intent: "list_purchased_content", query: input.query ?? "" },
|
|
35
|
-
instruction:
|
|
36
|
-
|
|
35
|
+
instruction: `需要用户确认一次身份和只读权限。执行 next.command 生成官方入口,不要声称链接已经创建;用户完成后重新运行原始 vault list 命令。${accessContextInstruction(input)}`,
|
|
36
|
+
next: { command: vaultAccessCommand(undefined, input), reason: "创建一次账号读取授权" }, recovery: [],
|
|
37
37
|
}, outputOptions(input));
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
@@ -41,9 +41,6 @@ export async function runVaultList(backend, input) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
export async function runVaultAccess(backend, artifactRef, options) {
|
|
44
|
-
const issue = validateContext(options.host, options.target);
|
|
45
|
-
if (issue)
|
|
46
|
-
throw new CommandContractError(issue.code, issue.message, "先补齐当前可信会话的真实宿主和目标;尚未创建授权请求。", [], { schema_version: "itpay.interaction.v1", stage: "input_required", input_template: { command: vaultAccessCommand(artifactRef, options), required_input: issue.code === "target_required" ? ["target"] : ["host"], executable: false } });
|
|
47
44
|
const value = await backend.createVaultAccessRequest(artifactRef
|
|
48
45
|
? { purpose: "artifact_reveal", artifact_ref: artifactRef }
|
|
49
46
|
: { purpose: "account_window" });
|
|
@@ -93,23 +90,23 @@ export async function runVaultRead(backend, artifactRef, sections, options) {
|
|
|
93
90
|
: value.status === "result_preparing"
|
|
94
91
|
? "这份已购内容仍在准备。稍后只重试同一 read,不要重新授权、购买或调用 Provider。"
|
|
95
92
|
: "这份已购内容当前不可用。停止,不要重试、重新购买或绕过退款锁。",
|
|
96
|
-
next:
|
|
93
|
+
next: null, recovery: [],
|
|
97
94
|
}, outputOptions(options));
|
|
98
95
|
}
|
|
99
96
|
catch (error) {
|
|
100
97
|
if (error instanceof HttpError && error.code === "artifact_authorization_required") {
|
|
101
98
|
writeCommandEnvelope({
|
|
102
99
|
status: "human_authorization_required", result: { artifact_ref: artifactRef },
|
|
103
|
-
instruction:
|
|
104
|
-
|
|
100
|
+
instruction: `这份内容需要用户单独确认读取权限。执行 next.command 生成一次官方入口;用户完成后重新运行原始 read,不要重复创建授权请求。${accessContextInstruction(options)}`,
|
|
101
|
+
next: { command: vaultAccessCommand(artifactRef, options), reason: "创建一次内容读取授权" }, recovery: [],
|
|
105
102
|
}, outputOptions(options));
|
|
106
103
|
return;
|
|
107
104
|
}
|
|
108
105
|
if (error instanceof HttpError && error.code === "vault_authorization_required") {
|
|
109
106
|
writeCommandEnvelope({
|
|
110
107
|
status: "human_authorization_required", result: { artifact_ref: artifactRef },
|
|
111
|
-
instruction:
|
|
112
|
-
|
|
108
|
+
instruction: `账号读取授权已缺失或过期。执行 next.command 生成一次官方入口;用户完成后重新运行原始 read。${accessContextInstruction(options)}`,
|
|
109
|
+
next: { command: vaultAccessCommand(undefined, options), reason: "创建一次账号读取授权" }, recovery: [],
|
|
113
110
|
}, outputOptions(options));
|
|
114
111
|
return;
|
|
115
112
|
}
|
|
@@ -124,7 +121,7 @@ export function vaultAccessCommand(artifactRef, options) {
|
|
|
124
121
|
const host = options.host ?? (openClaw ? "<host>" : undefined);
|
|
125
122
|
if (host)
|
|
126
123
|
parts.push("--host", host);
|
|
127
|
-
const target = options.target ?? (
|
|
124
|
+
const target = options.target ?? (openClaw && (!options.host || requiresTarget(options.host)) ? "<target>" : undefined);
|
|
128
125
|
if (target)
|
|
129
126
|
parts.push("--target", shellArgument(target));
|
|
130
127
|
parts.push("--json");
|
|
@@ -135,14 +132,10 @@ export function accessContextInstruction(options) {
|
|
|
135
132
|
? " 将 <host> 和 <target> 替换为当前可信 OpenClaw 会话的真实值,不要照抄占位符或猜测目标。"
|
|
136
133
|
: "";
|
|
137
134
|
}
|
|
138
|
-
function
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
export function vaultAccessGuidance(artifact, options) {
|
|
145
|
-
const command = vaultAccessCommand(artifact, options);
|
|
146
|
-
const missing = [...(options.agentType === "openclaw" && !options.host ? ["host"] : []), ...(options.host && requiresTarget(options.host) && !options.target || options.agentType === "openclaw" && !options.host && !options.target ? ["target"] : [])];
|
|
147
|
-
return missing.length ? { next: null, interaction: { schema_version: "itpay.interaction.v1", stage: "input_required", input_template: { command, required_input: missing, executable: false } } } : { next: { command, reason: "创建一次官方只读授权入口;用户完成后恢复原reader" } };
|
|
135
|
+
function shellArgument(value) {
|
|
136
|
+
if (value.startsWith("<") && value.endsWith(">"))
|
|
137
|
+
return value;
|
|
138
|
+
if (/^[\p{L}\p{N}._:=/-]+$/u.test(value))
|
|
139
|
+
return value;
|
|
140
|
+
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
148
141
|
}
|
|
@@ -20,13 +20,6 @@ export async function buildVaultHandoff(input) {
|
|
|
20
20
|
instruction: "向用户说明这是查看已购内容的只读授权,然后立即用 ZCode 内置浏览器打开 handoff.url。确认已发起打开后停止等待;不要只粘贴文字链接,也不要下载或重建二维码。只有内置浏览器明确不可用时,才展示同一个可点击 handoff.url。用户完成后重新运行最初的读取命令,不要再次创建授权请求。",
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
if (input.agentType?.trim().toLowerCase() === "doubao-work" && platform === "plain_chat") {
|
|
24
|
-
handoff.qr_image_url = input.qrPNGURL ?? vaultQRURL(input.authorizationURL, input.requestID);
|
|
25
|
-
return {
|
|
26
|
-
handoff,
|
|
27
|
-
instruction: "向用户说明这是查看已购内容的只读授权。在当前豆包工作对话中将 handoff.url 标为“直接打开授权页”,将 handoff.qr_image_url 标为“授权二维码图片(保存或用另一台设备扫码)”,然后停止等待。不要解析 URL credential、下载或重建二维码,也不要重复创建授权请求;用户完成后重新运行最初的读取命令。",
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
23
|
if (platform === "markdown") {
|
|
31
24
|
const downloaded = input.imageAttachEnabled && input.qrPNGURL
|
|
32
25
|
? await downloadBrandQRToTmp(input.qrPNGURL, "auth", input.requestID, {
|
|
@@ -60,17 +53,6 @@ export async function buildVaultHandoff(input) {
|
|
|
60
53
|
...(platform === "terminal" ? { terminalQR: await renderTerminalQR(input.authorizationURL, input.qrFormat ?? "unicode") } : {}),
|
|
61
54
|
};
|
|
62
55
|
}
|
|
63
|
-
function vaultQRURL(authorizationURL, requestID) {
|
|
64
|
-
const url = new URL(authorizationURL);
|
|
65
|
-
const startToken = url.searchParams.get("start_token");
|
|
66
|
-
if (!startToken)
|
|
67
|
-
throw new Error("Backend did not return a usable Vault authorization QR URL");
|
|
68
|
-
url.pathname = `/v1/vault/access-requests/${encodeURIComponent(requestID)}/qr.png`;
|
|
69
|
-
url.search = "";
|
|
70
|
-
url.searchParams.set("start_token", startToken);
|
|
71
|
-
url.hash = "";
|
|
72
|
-
return url.toString();
|
|
73
|
-
}
|
|
74
56
|
function authorizationMarkdown(url, localPath) {
|
|
75
57
|
const lines = ["### ItPay 已购内容授权"];
|
|
76
58
|
if (localPath)
|