@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.
Files changed (148) hide show
  1. package/README.md +5 -12
  2. package/dist/src/client/backend.js +2 -38
  3. package/dist/src/client/http.js +0 -2
  4. package/dist/src/commands/buy.js +58 -17
  5. package/dist/src/commands/cart.js +15 -17
  6. package/dist/src/commands/catalog.js +14 -39
  7. package/dist/src/commands/checkout.js +5 -146
  8. package/dist/src/commands/checkout_handoff.js +61 -11
  9. package/dist/src/commands/docs.js +18 -7
  10. package/dist/src/commands/guidance.js +134 -1
  11. package/dist/src/commands/install.js +3 -6
  12. package/dist/src/commands/order.js +3 -34
  13. package/dist/src/commands/orders.js +9 -4
  14. package/dist/src/commands/pay.js +1 -1
  15. package/dist/src/commands/readyz.js +1 -1
  16. package/dist/src/commands/refund.js +57 -13
  17. package/dist/src/commands/services.js +1068 -14
  18. package/dist/src/commands/skill.js +5 -8
  19. package/dist/src/commands/vault.js +20 -27
  20. package/dist/src/commands/vault_handoff.js +0 -18
  21. package/dist/src/main.js +43 -330
  22. package/dist/src/render/markdown.js +3 -0
  23. package/dist/src/render/qr.js +1 -1
  24. package/dist/src/state/cart_session.js +1 -4
  25. package/dist/src/state/client_context.js +0 -72
  26. package/dist/src/state/config.js +14 -44
  27. package/dist/src/state/device_authority.js +41 -141
  28. package/docs/agent/buyer/cart-checkout.json +6 -8
  29. package/docs/agent/buyer/catalog-list.json +9 -29
  30. package/docs/agent/buyer/identity-and-sessions.json +9 -26
  31. package/docs/agent/buyer/install-and-setup.json +9 -10
  32. package/docs/agent/buyer/orders-refunds.json +9 -25
  33. package/docs/agent/buyer/payment-flow.json +4 -6
  34. package/docs/agent/buyer/purchased-content.json +4 -18
  35. package/docs/agent/buyer/quickstart.json +17 -26
  36. package/docs/agent/buyer/render-hosts.json +12 -23
  37. package/docs/agent/buyer/service-feedback.json +3 -4
  38. package/docs/cli-reference/agent-types.md +2 -7
  39. package/docs/cli-reference/commands/buy.md +1 -2
  40. package/docs/cli-reference/commands/cart/add.md +1 -5
  41. package/docs/cli-reference/commands/cart/clear.md +1 -1
  42. package/docs/cli-reference/commands/cart/index.md +1 -1
  43. package/docs/cli-reference/commands/cart/next.md +1 -5
  44. package/docs/cli-reference/commands/cart/remove.md +1 -1
  45. package/docs/cli-reference/commands/cart/show.md +1 -1
  46. package/docs/cli-reference/commands/catalog/index.md +1 -1
  47. package/docs/cli-reference/commands/catalog/list.md +2 -2
  48. package/docs/cli-reference/commands/checkout.md +2 -12
  49. package/docs/cli-reference/commands/device.md +11 -18
  50. package/docs/cli-reference/commands/docs/index.md +1 -1
  51. package/docs/cli-reference/commands/docs/list.md +1 -1
  52. package/docs/cli-reference/commands/docs/search.md +1 -1
  53. package/docs/cli-reference/commands/docs/show.md +1 -1
  54. package/docs/cli-reference/commands/install.md +6 -8
  55. package/docs/cli-reference/commands/next.md +1 -1
  56. package/docs/cli-reference/commands/order.md +1 -1
  57. package/docs/cli-reference/commands/pay.md +1 -1
  58. package/docs/cli-reference/commands/readyz.md +11 -11
  59. package/docs/cli-reference/commands/refund/cancel.md +1 -1
  60. package/docs/cli-reference/commands/refund/create.md +1 -1
  61. package/docs/cli-reference/commands/refund/get.md +2 -2
  62. package/docs/cli-reference/commands/refund/index.md +1 -1
  63. package/docs/cli-reference/commands/refund/list.md +1 -1
  64. package/docs/cli-reference/commands/refund/watch.md +1 -1
  65. package/docs/cli-reference/commands/services/action.md +3 -24
  66. package/docs/cli-reference/commands/services/checkout.md +2 -17
  67. package/docs/cli-reference/commands/services/events.md +1 -1
  68. package/docs/cli-reference/commands/services/get.md +2 -4
  69. package/docs/cli-reference/commands/services/index.md +3 -4
  70. package/docs/cli-reference/commands/services/invoke.md +4 -6
  71. package/docs/cli-reference/commands/services/list.md +1 -1
  72. package/docs/cli-reference/commands/services/next.md +12 -78
  73. package/docs/cli-reference/commands/services/quote.md +4 -4
  74. package/docs/cli-reference/commands/services/read-result.md +6 -17
  75. package/docs/cli-reference/commands/services/start.md +3 -5
  76. package/docs/cli-reference/commands/vault/access.md +1 -5
  77. package/docs/cli-reference/conventions.md +6 -4
  78. package/docs/cli-reference/index.md +1 -10
  79. package/docs/skill-bundle-rollout/01-mcp-authentication.md +134 -0
  80. package/docs/skill-bundle-rollout/02-platform-bundle-repositories.md +210 -0
  81. package/docs/skill-bundle-rollout/03-platform-publishing.md +161 -0
  82. package/docs/skill-bundle-rollout/04-first-wave-platforms.md +69 -0
  83. package/docs/skill-bundle-rollout/05-sync-operations.md +62 -0
  84. package/docs/skill-bundle-rollout/README.md +151 -0
  85. package/package.json +12 -20
  86. package/skills/itpay/SKILL.md +102 -110
  87. package/assets/sell-preview/index.html +0 -6
  88. package/assets/sell-preview/preview.js +0 -9
  89. package/bin/darwin-amd64/itpay-sell +0 -0
  90. package/bin/darwin-arm64/itpay-sell +0 -0
  91. package/bin/linux-amd64/itpay-sell +0 -0
  92. package/bin/linux-arm64/itpay-sell +0 -0
  93. package/bin/windows-amd64/itpay-sell.exe +0 -0
  94. package/dist/src/commands/aftercare.js +0 -12
  95. package/dist/src/commands/presentation.js +0 -153
  96. package/dist/src/commands/rail_catalog.js +0 -1
  97. package/dist/src/commands/services/actions.js +0 -133
  98. package/dist/src/commands/services/commerce.js +0 -197
  99. package/dist/src/commands/services/lifecycle.js +0 -418
  100. package/dist/src/commands/services/results.js +0 -130
  101. package/dist/src/render/browser.js +0 -65
  102. package/dist/src/render/checkout_handoff.js +0 -101
  103. package/dist/src/render/checkout_plan.js +0 -47
  104. package/dist/src/sell/commands.js +0 -80
  105. package/dist/src/sell/contract.js +0 -86
  106. package/dist/src/sell/local.js +0 -260
  107. package/dist/src/sell/mcp.js +0 -49
  108. package/dist/src/sell/preview.js +0 -70
  109. package/dist/src/sell/sync.js +0 -145
  110. package/dist/src/services/adapter.js +0 -1
  111. package/dist/src/services/presentation.js +0 -198
  112. package/dist/src/services/rail/actions.js +0 -51
  113. package/dist/src/services/rail/adapter.js +0 -27
  114. package/dist/src/services/rail/aftercare.js +0 -45
  115. package/dist/src/services/rail/catalog.js +0 -261
  116. package/dist/src/services/rail/checkout.js +0 -19
  117. package/dist/src/services/rail/fulfillment.js +0 -76
  118. package/dist/src/services/rail/guide.js +0 -110
  119. package/dist/src/services/rail/invocation.js +0 -54
  120. package/dist/src/services/rail/page.js +0 -76
  121. package/dist/src/services/rail/pagination.js +0 -6
  122. package/dist/src/services/rail/query.js +0 -71
  123. package/dist/src/services/rail/readers.js +0 -107
  124. package/dist/src/services/rail/reading.js +0 -125
  125. package/dist/src/services/rail/recovery.js +0 -51
  126. package/dist/src/services/rail/results.js +0 -378
  127. package/dist/src/services/rail/review.js +0 -268
  128. package/dist/src/services/rail/saved.js +0 -49
  129. package/dist/src/services/rail/wait.js +0 -11
  130. package/dist/src/services/registry.js +0 -31
  131. package/dist/src/services/schema.js +0 -21
  132. package/dist/src/services/shared/envelope.js +0 -184
  133. package/dist/src/services/shared/input.js +0 -39
  134. package/dist/src/services/shared/pagination.js +0 -28
  135. package/dist/src/services/shared/platform.js +0 -365
  136. package/dist/src/services/shared/refund.js +0 -40
  137. package/dist/src/services/shared/workflow.js +0 -28
  138. package/dist/src/state/account_auth.js +0 -347
  139. package/dist/src/state/task_journal.js +0 -90
  140. package/docs/agent/buyer/rail-booking.json +0 -176
  141. package/docs/agent/buyer/rail-fast-checkout.json +0 -48
  142. package/docs/cli-reference/commands/aftercare.md +0 -15
  143. package/docs/cli-reference/commands/auth.md +0 -96
  144. package/docs/cli-reference/commands/sell.md +0 -1364
  145. package/docs/cli-reference/commands/services/page.md +0 -71
  146. package/docs/cli-reference/commands/services/run.md +0 -152
  147. package/docs/sell.md +0 -84
  148. /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;按用户意图选择第一条命令。保持 workbuddy 和同一 CLI launcher,并为 ~/.itpay-v3 申请宿主允许的持久化权限;权限被拒时报告受阻操作,不删除 identity。"
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 packagePath = resolve(commandDir, "..", "..", "..", "skills", ITPAY_SKILL, "SKILL.md");
53
- if (existsSync(packagePath))
54
- return packagePath;
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, validateContext } from "../state/client_context.js";
2
+ import { requiresTarget } from "../state/client_context.js";
3
3
  import { formatMoney } from "../render/output.js";
4
- import { CommandContractError, shellArgument, writeCommandEnvelope } from "./guidance.js";
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.map(item => ({ ...item, amount: formatMoney(item.amount_minor, item.currency), reader: { command: vaultReadCommand(item.artifact_ref, [], input), reason: "读取这一已购内容" } })), next_cursor: value.next_cursor || null },
22
+ result: { items: value.items, next_cursor: value.next_cursor || null },
23
23
  instruction: value.items.length
24
- ? "用编号、服务名称、内容主体、购买时间、金额和订单号说明匹配结果,不要向用户显示内部内容标识。一个精确匹配可按用户原始查看意图继续读取;已有任务可明确匹配时读取对应行;只有真实歧义才让用户选择。"
24
+ ? "用编号、服务名称、内容主体、购买时间、金额和订单号说明匹配结果,不要向用户显示内部内容标识。一个精确匹配可按用户原始查看意图继续读取;多个匹配必须让用户选择。"
25
25
  : "当前账号没有匹配的已购内容。向用户说明没有找到,不要猜测内容标识、自动购买或发起新的服务查询。",
26
- next: value.next_cursor ? { command: `itpay vault list --limit ${input.limit}${input.query ? ` --query ${shellArgument(input.query)}` : ""} --cursor ${shellArgument(value.next_cursor)}${contextFlags(input)} --json`, reason: "读取同一筛选的下一页" } : null,
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: `需要用户确认一次身份和只读权限。按当前动作或待填模板生成官方入口,不要声称链接已经创建;用户完成后重新运行原始 vault list 命令。${accessContextInstruction(input)}`,
36
- ...vaultAccessGuidance(undefined, input), recovery: [],
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: value.status === "result_preparing" ? { command: vaultReadCommand(artifactRef, normalized, options), reason: "稍后读取同一内容及原sections;不重新授权或购买" } : null, recovery: [],
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: `这份内容需要用户单独确认读取权限。按当前动作或待填模板生成一次官方入口;用户完成后重新运行原始 read,不要重复创建授权请求。${accessContextInstruction(options)}`,
104
- ...vaultAccessGuidance(artifactRef, options), recovery: [],
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: `账号读取授权已缺失或过期。按当前动作或待填模板生成一次官方入口;用户完成后重新运行原始 read。${accessContextInstruction(options)}`,
112
- ...vaultAccessGuidance(undefined, options), recovery: [],
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 ?? (((openClaw && !options.host) || (options.host && requiresTarget(options.host))) ? "<target>" : undefined);
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 contextFlags(options) {
139
- return `${options.host ? ` --host ${options.host}` : ""}${options.target ? ` --target ${shellArgument(options.target)}` : ""}`;
140
- }
141
- function vaultReadCommand(artifact, sections, options) {
142
- return `itpay vault read --artifact ${shellArgument(artifact)}${sections.map(section => ` --section ${shellArgument(section)}`).join("")}${contextFlags(options)} --json`;
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)