@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
package/dist/src/main.js CHANGED
@@ -1,14 +1,9 @@
1
- import { runAftercareList, runAftercareCreate, runAftercareGet, runAftercareRespond } from "./commands/aftercare.js";
2
- import { agentAuth } from "./state/account_auth.js";
3
- import { registerSell } from "./sell/commands.js";
4
- import { readFileSync as readWorkflowInputFile, statSync as statWorkflowInputFile } from "node:fs";
5
- import { runServicesRun } from "./commands/services.js";
6
1
  // V3 CLI entrypoint. Each command maps 1:1 to a route family in
7
2
  // services/backend/internal/httpapi/handlers/*.go. Commands only
8
3
  // orchestrate; HTTP and rendering live in src/client and src/render.
9
4
  import { Command } from "commander";
10
5
  import { BackendOverrideError, API_CONTRACT_REVISION, CLI_VERSION, cliDistribution, loadConfig, cartSessionPath, newBackendClient } from "./state/config.js";
11
- import { DeviceAuthority, DeviceAuthorizationError, DeviceLockBusyError, DeviceStateError } from "./state/device_authority.js";
6
+ import { DeviceAuthority, DeviceAuthorizationError, DeviceStateError } from "./state/device_authority.js";
12
7
  import { CartSession } from "./state/cart_session.js";
13
8
  import { defaultHostForAgentType, normalizeHost, validateContext } from "./state/client_context.js";
14
9
  import { HttpError } from "./client/http.js";
@@ -26,11 +21,11 @@ import { runCancelRefund, runGetRefund, runListRefunds, runRefund, runWatchRefun
26
21
  import { runCartAdd, runCartAddQuoteServer, runCartAddServer, runCartAbandonServer, runCartClear, runCartNext, runCartRemove, runCartRemoveServer, runCartShow, runCartShowServer, } from "./commands/cart.js";
27
22
  import { CommandContractError, errorRecoveryActions, printErrorRecovery, writeCommandEnvelope } from "./commands/guidance.js";
28
23
  import { runDocsList, runDocsShow, runDocsSearch } from "./commands/docs.js";
29
- import { INSTALL_AGENT_TYPES, runInstall } from "./commands/install.js";
24
+ import { runInstall } from "./commands/install.js";
30
25
  import { runSkillShow } from "./commands/skill.js";
31
26
  import { runNext } from "./commands/next.js";
32
27
  import { runVaultAccess, runVaultList, runVaultRead } from "./commands/vault.js";
33
- import { collectOption, parseKeyValueList, runServicesAction, runServicesCheckout, runServicesEvents, runServicesGet, runServicesInvoke, runServicesList, runServicesNext, runServicesPage, runServicesReadResult, runServicesQuote, runServicesStart, } from "./commands/services.js";
28
+ import { collectOption, parseKeyValueList, runServicesAction, runServicesCheckout, runServicesEvents, runServicesGet, runServicesInvoke, runServicesList, runServicesNext, runServicesReadResult, runServicesQuote, runServicesStart, } from "./commands/services.js";
34
29
  const program = new Command();
35
30
  program
36
31
  .name("itpay")
@@ -117,7 +112,6 @@ function reportCLIError(error, contract) {
117
112
  const backendOverrideError = error instanceof BackendOverrideError ? error : undefined;
118
113
  const deviceError = error instanceof DeviceAuthorizationError ? error : undefined;
119
114
  const stateError = error instanceof DeviceStateError ? error : undefined;
120
- const lockError = error instanceof DeviceLockBusyError ? error : undefined;
121
115
  const transportError = error instanceof HttpTransportError ? error : undefined;
122
116
  const httpRecovery = errorRecoveryActions(error).map((action) => ({
123
117
  command: action.command,
@@ -136,45 +130,31 @@ function reportCLIError(error, contract) {
136
130
  const providerInputRejected = error instanceof HttpError && error.code === "provider_input_rejected";
137
131
  const providerContractMismatch = error instanceof HttpError && error.code === "provider_contract_mismatch";
138
132
  const capabilityInputInvalid = error instanceof HttpError && error.code === "capability_input_invalid";
139
- const deviceKeyResettable = Boolean(deviceError && (deviceError.code === "agent_device_key_rotated" ||
140
- deviceError.code === "agent_device_key_conflict"));
141
- const deviceRecovery = deviceError ? [
142
- {
133
+ const deviceRecovery = deviceError ? [{
143
134
  command: "itpay skill show itpay --json",
144
135
  reason: "读取 ItPay 身份边界;该错误需要用户或运营恢复 Backend 登记,不能通过换类型或删除本地身份绕过",
145
- },
146
- ] : [];
136
+ }] : [];
147
137
  const stateRecovery = stateError ? [{
148
138
  command: "itpay skill show itpay --json",
149
139
  reason: "读取 Device 状态边界;修复当前 Host 的持久写权限后重试原命令",
150
140
  }] : [];
151
- const lockRecovery = lockError ? [{
152
- command: "itpay device repair-lock --json",
153
- reason: "检查锁持有者;只回收已退出进程留下的锁,不改变设备身份",
154
- }] : [];
155
141
  const authorizationInstruction = stateError
156
- ? `当前运行环境无法写入 owner-only Device 状态;受阻路径 ${stateError.blockedPath ?? "~/.itpay-v3"},操作 ${stateError.operation}(${stateError.causeCode})。保持同一 Node、CLI 和 Agent Type,修复该路径持久写权限后重试原命令;不要手工创建 lock、删除 identity、随意更换 HOME 或换运行时。`
157
- : lockError
158
- ? "另一个进程仍在更新本地身份。执行 recovery 检查;若持有者仍活跃,等待后继续原任务,不要删除锁或重建身份。"
159
- : error instanceof HttpError && error.code === "agent_device_session_required"
160
- ? "CLI 已自动续期并重试同一请求一次,仍被拒绝;停止重试,不要切换 Agent Type 或旋转身份。"
161
- : deviceError?.code === "agent_device_revoked"
162
- ? "Backend 已撤销当前 Device 登记;CLI 没有自动创建替代身份。停止重试并请用户或运营恢复登记。"
163
- : deviceError?.enrollmentFailed && deviceError.status === 500
164
- ? "服务端未能完成设备登记;保持原密钥和Agent Type,说明系统故障,待服务端恢复后继续原任务。不要重置身份。"
165
- : deviceKeyResettable
166
- ? "服务端拒绝当前设备私钥登记(轮换或冲突)。停止自动恢复;换钥会放弃旧身份,旧执行访问不会迁移。仅用户或运营明确决定放弃旧身份后,按 device reset-key 帮助执行。"
167
- : deviceError
168
- ? "Device 身份验证失败;停止重试,不要切换 Agent Type、删除状态或旋转私钥。"
169
- : undefined;
170
- if (contract || commandError || backendOverrideError || lockError || stateError) {
142
+ ? "当前运行环境无法写入 owner-only Device 状态;请保持同一 Node、CLI 和 Agent Type,在允许持久写入 ~/.itpay-v3 的执行环境中重试。不要手工创建 lock、删除 identity 或换运行时碰运气。"
143
+ : error instanceof HttpError && error.code === "agent_device_session_required"
144
+ ? "CLI 已自动续期并重试同一请求一次,仍被拒绝;停止重试,不要切换 Agent Type 或旋转身份。"
145
+ : deviceError?.code === "agent_device_revoked"
146
+ ? "Backend 已撤销当前 Device 登记;CLI 没有自动创建替代身份。停止重试并请用户或运营恢复登记。"
147
+ : deviceError
148
+ ? "Device 身份验证失败;停止重试,不要切换 Agent Type、删除状态或旋转私钥。"
149
+ : undefined;
150
+ if (contract || commandError || backendOverrideError) {
171
151
  writeCommandEnvelope({
172
152
  status: "error",
173
153
  error: {
174
- code: incompatible ? "backend_contract_incompatible" : backendOverrideError?.code ?? commandError?.code ?? (error instanceof HttpError ? error.code : transportError?.code ?? stateError?.code ?? lockError?.code ?? deviceError?.code ?? contract?.code ?? "command_failed"),
154
+ code: incompatible ? "backend_contract_incompatible" : backendOverrideError?.code ?? commandError?.code ?? (error instanceof HttpError ? error.code : transportError?.code ?? stateError?.code ?? deviceError?.code ?? contract?.code ?? "command_failed"),
175
155
  message: error instanceof Error ? error.message : String(error),
176
156
  },
177
- ...(commandError?.result ? { result: commandError.result } : incompatible && error instanceof HttpError ? {
157
+ ...(incompatible && error instanceof HttpError ? {
178
158
  result: {
179
159
  current_cli_version: CLI_VERSION,
180
160
  current_api_contract_revision: API_CONTRACT_REVISION,
@@ -214,7 +194,7 @@ function reportCLIError(error, contract) {
214
194
  : providerRejected
215
195
  ? "告诉用户数据来源没有接受本次请求,但没有说明是输入错误,并按 result.quota 说明额度状态,然后停止。不要转述内部错误、修改输入、重试或创建新查询。"
216
196
  : capabilityInputInvalid
217
- ? "Agent按当前合同模板修正字段和JSON层级,保留用户原始需求,继续同一次服务。不要让用户修技术输入,只有真实业务歧义才询问。"
197
+ ? "告诉用户当前输入不完整或格式不正确;数据来源尚未调用,额度没有变化。不要转述技术错误或原样重试;用户提供修正信息后继续同一次服务。"
218
198
  : transportError
219
199
  ? contract?.initialization
220
200
  ? "本轮初始化检查未完成;CLI 已结束有限的网络尝试,尚未确认后端或设备就绪。结束本轮,网络恢复后可重新检查;不要继续登录或业务操作。"
@@ -222,18 +202,17 @@ function reportCLIError(error, contract) {
222
202
  ? "临时网络故障;CLI 已仅对可安全重放的操作完成有限自动重试,但仍未获得完整响应。按 recovery 查询同一资源的权威状态;不要创建替代 Checkout、Execution、Payment 或 Refund。"
223
203
  : "网络在完整响应前中断;当前写操作没有安全重放合同,因此 CLI 未自动重试。按 recovery 查询权威状态;不要原样重放或创建替代 Checkout、Execution、Payment 或 Refund。"
224
204
  : backendOverrideError
225
- ? "移除 ITPAY_BACKEND_URL 使用正式环境,或按当前测试目标准确设置为 https://sandbox.itpay.ai 或 https://dev.itpay.ai。不要通过切换环境规避当前错误。"
205
+ ? "移除 ITPAY_BACKEND_URL 使用正式环境,或准确设置为 https://dev.itpay.ai。"
226
206
  : commandError?.instruction ?? authorizationInstruction ?? contract?.instruction ?? "检查命令参数后重试。",
227
207
  next: null,
228
- ...(commandError?.interaction ? { interaction: commandError.interaction } : {}),
229
208
  recovery: incompatible || (transportError && contract?.initialization)
230
209
  ? []
231
210
  : backendInternal || providerConnectionUnavailable || providerTemporary || providerInputRejected || providerContractMismatch || providerRejected || capabilityInputInvalid
232
211
  ? []
233
- : backendOverrideError ? [] : commandError?.recovery ?? (stateError ? stateRecovery : lockError ? lockRecovery : deviceError ? deviceRecovery : identityRecovery ? httpRecovery : contract?.recovery ?? []),
212
+ : backendOverrideError ? [] : commandError?.recovery ?? (stateError ? stateRecovery : deviceError ? deviceRecovery : identityRecovery ? httpRecovery : contract?.recovery ?? []),
234
213
  }, {
235
- ...(contract?.jsonOutput !== undefined ? { jsonOutput: contract.jsonOutput } : backendOverrideError || lockError || stateError ? { jsonOutput: process.argv.includes("--json") } : {}),
236
- output: (text) => { process.stdout.write(text); },
214
+ ...(contract?.jsonOutput !== undefined ? { jsonOutput: contract.jsonOutput } : backendOverrideError ? { jsonOutput: process.argv.includes("--json") } : {}),
215
+ output: (text) => { process.stderr.write(text); },
237
216
  });
238
217
  process.exitCode = 1;
239
218
  return;
@@ -300,54 +279,31 @@ program
300
279
  });
301
280
  }
302
281
  });
303
- const authCmd = program.command("auth").description("Log in and bind this enrolled Agent to your ItPay account");
304
- for (const action of ["login", "status"]) {
305
- authCmd.command(action).option("--json", "output JSON").action(async (options) => {
306
- const config = loadConfig();
307
- try {
308
- const result = await agentAuth(action, config.baseURL, newBackendClient(config));
309
- // AUTH06: auth output goes through the same envelope renderer as every
310
- // other command — next/recovery keep Agent Type + Backend qualification
311
- // and non-JSON output is human-readable instead of a raw JSON dump.
312
- const envelope = {
313
- status: String(result.status ?? "error"),
314
- result: (result.result ?? Object.fromEntries(Object.entries(result).filter(([key]) => !["status", "instruction", "next", "recovery", "handoff"].includes(key)))),
315
- ...(result.handoff ? { handoff: result.handoff } : {}),
316
- instruction: typeof result.instruction === "string" ? result.instruction : "按返回状态继续。",
317
- next: (result.next ?? null),
318
- recovery: (result.recovery ?? []),
319
- };
320
- writeCommandEnvelope(envelope, { jsonOutput: Boolean(options.json) });
321
- }
322
- catch (error) {
323
- reportCLIError(error, { jsonOutput: Boolean(options.json), code: "account_login_failed", initialization: true, instruction: "本轮授权检查未完成;保留设备及已有授权状态,按明确错误原因恢复。不要自动发起新的登录。" });
324
- }
325
- });
326
- }
327
282
  // --- device ---------------------------------------------------------------
328
283
  const deviceCmd = program.command("device").description("Recover the current official Backend registration after an operator-confirmed reset");
329
- deviceCmd
330
- .command("repair-lock")
331
- .description("Safely inspect and recover a local Device identity lock left by an exited process")
284
+ deviceCmd.command("status")
285
+ .description("Verify this device with the current Backend; account binding is not queried")
332
286
  .option("--json", "output JSON instead of terminal text")
333
- .action((options) => {
287
+ .action(async (options) => {
288
+ const config = loadConfig();
334
289
  try {
335
- const config = loadConfig();
336
- const status = new DeviceAuthority({
290
+ await requirePlatformCompatibility(newBackendClient(config));
291
+ const authority = new DeviceAuthority({
337
292
  baseURL: config.baseURL,
338
293
  ...(config.agentType ? { requestedAgentType: config.agentType } : {}),
339
- compatibilityHeaders: {},
340
- }).repairLock();
294
+ compatibilityHeaders: { "X-ItPay-CLI-Version": CLI_VERSION, "X-ItPay-Contract-Revision": API_CONTRACT_REVISION },
295
+ });
296
+ const verified = await authority.status();
341
297
  writeCommandEnvelope({
342
- status: status === "recovered" ? "device_lock_recovered" : status === "active" ? "device_lock_active" : "device_lock_absent",
343
- result: { lock_status: status, device_identity_preserved: true },
344
- instruction: status === "active" ? "本地身份正由存活进程更新;稍后继续原任务。" : "本地锁无需进一步处理;继续原任务。",
298
+ status: "device_ready",
299
+ result: { ...verified, backend_url: config.baseURL, account_binding: "unavailable" },
300
+ instruction: "当前 Backend 已验证设备身份。此版本不查询账号绑定,不能据此认定已登录或未登录;无需在安装阶段登录,不自动开始业务。首次检查可登记设备,后续复用同一身份。",
345
301
  next: null,
346
302
  recovery: [],
347
- }, { jsonOutput: Boolean(options.json), plainResult: [`lock: ${status}`, "device_identity: preserved"] });
303
+ }, { jsonOutput: Boolean(options.json) });
348
304
  }
349
305
  catch (error) {
350
- reportCLIError(error, { jsonOutput: Boolean(options.json), code: "device_lock_repair_failed", instruction: "本地锁无法安全检查;保留设备身份并联系维护者。" });
306
+ reportCLIError(error, { jsonOutput: Boolean(options.json), code: "device_status_unavailable", initialization: true, instruction: "本轮设备检查未完成;停止本轮,保留原身份,不自动发起登录。" });
351
307
  }
352
308
  });
353
309
  deviceCmd
@@ -402,56 +358,6 @@ deviceCmd
402
358
  });
403
359
  }
404
360
  });
405
- deviceCmd
406
- .command("reset-key")
407
- .description("Discard the local Ed25519 device key and all Backend registrations so the next command enrolls as a new device")
408
- .option("--confirm-key-reset", "confirm that the current device key must be abandoned and a new identity created")
409
- .option("--json", "output JSON instead of terminal text")
410
- .action(async (options) => {
411
- const config = loadConfig();
412
- try {
413
- if (!config.agentType || !INSTALL_AGENT_TYPES.some(type => type === config.agentType)) {
414
- throw new CommandContractError("agent_type_required", "supported Agent Type required before key reset", "先按真实宿主配置正式支持的Agent Type;尚未修改本地密钥。", [{ command: "itpay install --json", reason: "读取当前宿主配置" }]);
415
- }
416
- if (!options.confirmKeyReset) {
417
- throw new CommandContractError("key_reset_confirmation_required", "--confirm-key-reset is required", "仅在用户或运营明确决定放弃旧身份后使用;会丢弃本地私钥,旧执行访问不会迁移。internal_error 需服务端恢复,不能换钥。", [{ command: "itpay docs show identity-and-sessions --json", reason: "检查适用边界" }]);
418
- }
419
- const reset = await new DeviceAuthority({
420
- baseURL: config.baseURL,
421
- ...(config.agentType ? { requestedAgentType: config.agentType } : {}),
422
- compatibilityHeaders: {},
423
- }).resetDeviceKey();
424
- writeCommandEnvelope({
425
- status: "device_key_reset",
426
- result: {
427
- removed_backend_registrations: reset.removedBackends,
428
- private_key_preserved: false,
429
- server_side_device: "orphaned_under_previous_key",
430
- },
431
- instruction: "本地设备私钥已重置;下一次需要设备身份的命令会以全新 Ed25519 密钥重新登记;这不能恢复旧身份的订单或用于刷新额度。服务端旧设备记录保留为孤儿;如需清理请走运营流程。",
432
- next: {
433
- command: `itpay --agent-type ${config.agentType} services list --limit 1 --json`,
434
- reason: "用无业务写入的签名请求完成新密钥的重新登记",
435
- },
436
- recovery: [],
437
- }, {
438
- jsonOutput: Boolean(options.json),
439
- plainResult: [
440
- `removed_backend_registrations: ${reset.removedBackends.join(", ") || "none"}`,
441
- "private_key: rotated (previous key discarded)",
442
- "server_side_device: orphaned under previous key",
443
- ],
444
- });
445
- }
446
- catch (error) {
447
- reportCLIError(error, {
448
- jsonOutput: Boolean(options.json),
449
- code: "device_key_reset_failed",
450
- instruction: "仅在确认要放弃当前设备私钥时使用;普通 session 失效或 revoked 不需要本命令。",
451
- recovery: [{ command: "itpay docs show identity-and-sessions --json", reason: "检查 Device 恢复边界" }],
452
- });
453
- }
454
- });
455
361
  // --- skill ----------------------------------------------------------------
456
362
  const skillCmd = program.command("skill").description("Read complete packaged Agent skills");
457
363
  skillCmd
@@ -926,13 +832,6 @@ program
926
832
  .option("--id <checkout_id>")
927
833
  .option("--token <display_token>")
928
834
  .option("--locale <locale>", "payment card language: zh-CN|en", "zh-CN")
929
- .option("--present <method>", "display once: auto|browser|image|link|none (JSON default plans only)")
930
- .option("--no-open", "never open a browser window")
931
- .option("--viewer <viewer>", "device the human is looking at: desktop|mobile|unknown")
932
- .option("--relay-option <ref>", "server-issued contact option reference for message relay")
933
- .option("--confirm-relay", "confirm the human explicitly consented to this relay send")
934
- .option("--request-key <key>", "stable idempotency key for a relay request")
935
- .option("--relay-status <relay_id>", "read a prior relay result; never resends")
936
835
  .option("--json", "output compact JSON")
937
836
  .action(async (options) => {
938
837
  const config = loadConfig();
@@ -950,22 +849,12 @@ program
950
849
  await runCheckoutPresentation(backend, {
951
850
  checkoutID,
952
851
  displayToken,
953
- ...(snap.lastCheckoutID === checkoutID && snap.lastCheckoutURL
954
- ? { savedCheckoutURL: snap.lastCheckoutURL }
955
- : {}),
956
852
  host,
957
853
  ...(options.target ? { target: options.target } : {}),
958
854
  ...(config.agentType ? { agentType: config.agentType } : {}),
959
855
  baseURL: config.baseURL,
960
856
  locale: options.locale,
961
857
  jsonOutput: Boolean(options.json),
962
- ...(options.present ? { present: options.present } : {}),
963
- ...(options.noOpen ? { noOpen: true } : {}),
964
- ...(options.viewer ? { viewer: options.viewer } : {}),
965
- ...(options.relayOption ? { relayOption: options.relayOption } : {}),
966
- ...(options.confirmRelay ? { confirmRelay: true } : {}),
967
- ...(options.requestKey ? { requestKey: options.requestKey } : {}),
968
- ...(options.relayStatus ? { relayStatus: options.relayStatus } : {}),
969
858
  });
970
859
  }
971
860
  catch (error) {
@@ -1133,49 +1022,6 @@ feedback
1133
1022
  });
1134
1023
  }
1135
1024
  });
1136
- const aftercare = program.command("aftercare").description("Railway manual refund/change requests; never automatic supplier operations");
1137
- aftercare.command("list").requiredOption("--order <order_id>").option("--json").action(async (options) => {
1138
- try {
1139
- const config = loadConfig();
1140
- writeCommandEnvelope(await runAftercareList(newBackendClient(config), options.order), { jsonOutput: Boolean(options.json) });
1141
- }
1142
- catch (error) {
1143
- reportCLIError(error, { jsonOutput: Boolean(options.json), code: "aftercare_read_failed", instruction: "核对原订单与当前身份;铁路人工售后不改变平台内容授权,不换身份绕过。", recovery: [{ command: "itpay services list --json", reason: "找回当前身份原订单" }] });
1144
- }
1145
- });
1146
- aftercare.command("create").requiredOption("--order <order_id>").requiredOption("--input-json <file>").option("--json").action(async (options) => {
1147
- const recovery = [{ command: `itpay aftercare list --order ${options.order} --json`, reason: "读取原订单当前行程与完整申请模板" }];
1148
- try {
1149
- const config = loadConfig();
1150
- const input = readInputJsonObject(options.inputJson, "rail_aftercare_input_invalid", recovery);
1151
- writeCommandEnvelope(await runAftercareCreate(newBackendClient(config), config, options.order, input), { jsonOutput: Boolean(options.json) });
1152
- }
1153
- catch (error) {
1154
- reportCLIError(error, { jsonOutput: Boolean(options.json), code: "aftercare_create_failed", instruction: "保留原申请与用户范围,按实际错误读取当前模板或办理状态;不猜金额/身份,不重复未知操作。", recovery });
1155
- }
1156
- });
1157
- aftercare.command("get").argument("<case_id>").option("--json").action(async (id, options) => {
1158
- try {
1159
- const config = loadConfig();
1160
- writeCommandEnvelope(await runAftercareGet(newBackendClient(config), id), { jsonOutput: Boolean(options.json) });
1161
- }
1162
- catch (error) {
1163
- reportCLIError(error, { jsonOutput: Boolean(options.json), code: "aftercare_read_failed", instruction: "核对当前身份的原申请,不换身份或探测其他申请。", recovery: [] });
1164
- }
1165
- });
1166
- for (const action of ["respond", "cancel"]) {
1167
- aftercare.command(action).argument("<case_id>").requiredOption("--input-json <file>").option("--json").action(async (id, options) => {
1168
- const recovery = [{ command: `itpay aftercare get ${id} --json`, reason: "读取原申请当前版本与明确下一步" }];
1169
- try {
1170
- const config = loadConfig();
1171
- const input = readInputJsonObject(options.inputJson, "rail_aftercare_input_invalid", recovery);
1172
- writeCommandEnvelope(await runAftercareRespond(newBackendClient(config), id, input, action === "cancel"), { jsonOutput: Boolean(options.json) });
1173
- }
1174
- catch (error) {
1175
- reportCLIError(error, { jsonOutput: Boolean(options.json), code: "aftercare_response_failed", instruction: "按原申请当前版本处理;取消不撤回供应商操作,未知资金不重试。", recovery });
1176
- }
1177
- });
1178
- }
1179
1025
  const refund = program
1180
1026
  .command("refund")
1181
1027
  .enablePositionalOptions()
@@ -1246,7 +1092,7 @@ refund.command("get").argument("<refund_request_id>").option("--json", "output J
1246
1092
  });
1247
1093
  }
1248
1094
  });
1249
- refund.command("watch").argument("<refund_request_id>").option("--interval <seconds>", "poll interval", Number, 2).option("--timeout <seconds>", "bounded wait; returns on change/manual attention", Number, 20).option("--json", "output JSON instead of terminal text").action(async (id, options) => {
1095
+ refund.command("watch").argument("<refund_request_id>").option("--interval <seconds>", "poll interval", Number, 2).option("--timeout <seconds>", "timeout", Number, 120).option("--json", "output JSON instead of terminal text").action(async (id, options) => {
1250
1096
  const config = loadConfig();
1251
1097
  try {
1252
1098
  await runWatchRefund(newBackendClient(config), id, {
@@ -1384,114 +1230,7 @@ vault
1384
1230
  }
1385
1231
  });
1386
1232
  // --- service execution ----------------------------------------------------
1387
- const WORKFLOW_INPUT_JSON_MAX_BYTES = 256 * 1024;
1388
- function readInputJsonObject(file, code, recovery) {
1389
- let parsed;
1390
- try {
1391
- if (statWorkflowInputFile(file).size > WORKFLOW_INPUT_JSON_MAX_BYTES) {
1392
- throw new CommandContractError(code, `--input-json file exceeds ${WORKFLOW_INPUT_JSON_MAX_BYTES} bytes`, "输入文件过大;只提交服务端 input_schema 声明的字段。", recovery);
1393
- }
1394
- parsed = JSON.parse(readWorkflowInputFile(file, "utf8"));
1395
- }
1396
- catch (error) {
1397
- if (error instanceof CommandContractError)
1398
- throw error;
1399
- throw new CommandContractError(code, `--input-json is not readable valid JSON: ${error instanceof Error ? error.message : String(error)}`, "确认文件存在且为合法 JSON;按服务端 input_schema 字段填写。", recovery);
1400
- }
1401
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
1402
- throw new CommandContractError(code, "--input-json must contain a JSON object", "确认输入必须是 JSON 对象;按服务端 input_schema 字段填写。", recovery);
1403
- }
1404
- return parsed;
1405
- }
1406
1233
  const services = program.command("services").description("Generic V3 Service Execution commands");
1407
- services
1408
- .command("run")
1409
- .description("Run a declared service operation; preparation approval is required before Checkout")
1410
- .option("--operation <operation_id>", "operation declared by the public service definition")
1411
- .argument("<service_id>")
1412
- .option("--input-json <file>", "JSON object containing the service input")
1413
- .option("--execution <execution_id>", "resume the same execution")
1414
- .option("--timeout <seconds>", "maximum wait before returning current progress", Number, 120)
1415
- .option("--host <host>")
1416
- .option("--target <target>")
1417
- .option("--json", "output JSON")
1418
- .action(async (serviceID, options) => {
1419
- const config = loadConfig();
1420
- try {
1421
- let input = options.inputJson
1422
- ? readInputJsonObject(options.inputJson, "workflow_input_invalid", [
1423
- { command: `itpay services run ${serviceID} --json`, reason: "重新读取服务输入声明" },
1424
- ])
1425
- : undefined;
1426
- let continuation;
1427
- if (options.operation && input !== undefined) {
1428
- const parameters = input.input;
1429
- if (typeof parameters !== "object" || parameters === null || Array.isArray(parameters))
1430
- throw new CommandContractError("operation_input_invalid", "operation JSON must include an input object", "使用公开操作返回的完整JSON模板,顶层input是业务输入;保留服务端continuation。", []);
1431
- const reference = input.continuation;
1432
- if (reference !== undefined) {
1433
- if (typeof reference !== "object" || reference === null || Array.isArray(reference) || !("service_execution_id" in reference) || !("snapshot_id" in reference) || typeof reference.service_execution_id !== "string" || typeof reference.snapshot_id !== "string")
1434
- throw new CommandContractError("operation_input_invalid", "invalid continuation reference", "保留结果详情返回的continuation,不猜执行或snapshot。", []);
1435
- continuation = { service_execution_id: reference.service_execution_id, snapshot_id: reference.snapshot_id };
1436
- }
1437
- input = Object.fromEntries(Object.entries(parameters));
1438
- }
1439
- if (!Number.isFinite(options.timeout) || options.timeout < 0 || options.timeout > 600) {
1440
- throw new Error("timeout must be between 0 and 600 seconds");
1441
- }
1442
- await runServicesRun(newBackendClient(config), config, serviceID, input, {
1443
- ...(options.execution ? { executionID: options.execution } : {}),
1444
- ...(options.operation ? { operationID: options.operation } : {}),
1445
- ...(continuation ? { continuation } : {}),
1446
- jsonOutput: Boolean(options.json),
1447
- host: withHost(options.host, config.agentType, options.target),
1448
- ...(options.target ? { target: options.target } : {}),
1449
- timeoutSeconds: options.timeout,
1450
- });
1451
- }
1452
- catch (error) {
1453
- reportCLIError(error, {
1454
- jsonOutput: Boolean(options.json), code: "workflow_run_failed",
1455
- instruction: "本次操作失败;按已返回的具体原因和恢复动作处理。没有恢复动作时停止,不猜字段或重复创建购买。", recovery: [],
1456
- });
1457
- }
1458
- });
1459
- services
1460
- .command("page")
1461
- .description("Read one page of a saved service result set (same stored version, no re-query, no quota)")
1462
- .argument("<service_execution_id>")
1463
- .argument("<result_item_id>")
1464
- .option("--offset <offset>", "zero-based candidate offset", Number, 0)
1465
- .option("--cursor <cursor>", "opaque v2 page cursor (rcur_<offset>); takes precedence over --offset")
1466
- .option("--limit <limit>", "page size (1-20)", Number, 20)
1467
- .option("--json", "output JSON")
1468
- .action(async (serviceExecutionID, resultItemID, options) => {
1469
- const config = loadConfig();
1470
- const backend = newBackendClient(config);
1471
- try {
1472
- const cursorOffset = typeof options.cursor === "string" && /^rcur_\d+$/.test(options.cursor)
1473
- ? Number(options.cursor.slice(5))
1474
- : undefined;
1475
- if (options.cursor !== undefined && cursorOffset === undefined) {
1476
- throw new CommandContractError("cursor_invalid", "--cursor must be an opaque rcur_<offset> token from a previous page response", "--cursor 需为上一页返回的 rcur_<offset> 不透明游标。", []);
1477
- }
1478
- await runServicesPage(backend, serviceExecutionID, resultItemID, {
1479
- offset: cursorOffset ?? options.offset,
1480
- limit: options.limit,
1481
- jsonOutput: Boolean(options.json),
1482
- });
1483
- }
1484
- catch (error) {
1485
- reportCLIError(error, {
1486
- jsonOutput: Boolean(options.json),
1487
- code: "service_page_failed",
1488
- instruction: "分页读取的是已保存的同版本结果;不要重新发起查询或新建 execution。",
1489
- recovery: [
1490
- { command: `itpay services next ${serviceExecutionID} --json`, reason: "读取当前结果页与合法动作" },
1491
- ],
1492
- });
1493
- }
1494
- });
1495
1234
  services
1496
1235
  .command("start")
1497
1236
  .description("Start a contract-backed service execution")
@@ -1527,18 +1266,12 @@ services
1527
1266
  .argument("<service_execution_id>")
1528
1267
  .requiredOption("--capability <capability_id>")
1529
1268
  .option("--input <key=value>", "redacted input summary", collectOption, [])
1530
- .option("--input-json <file>", "JSON object containing the complete capability input")
1531
1269
  .option("--json", "output JSON")
1532
1270
  .action(async (serviceExecutionID, options) => {
1533
1271
  const config = loadConfig();
1534
1272
  const backend = newBackendClient(config);
1535
1273
  try {
1536
- const recovery = [{ command: `itpay services next ${serviceExecutionID} --json`, reason: "读取当前动作要求" }];
1537
- if (options.inputJson && options.input.length > 0) {
1538
- throw new CommandContractError("capability_input_invalid", "--input and --input-json cannot be combined", "嵌套输入用 --input-json <file>,扁平输入用 --input key=value,二选一;本次未调用供应商。", recovery);
1539
- }
1540
- const input = options.inputJson ? readInputJsonObject(options.inputJson, "capability_input_invalid", recovery) : parseKeyValueList(options.input);
1541
- await runServicesInvoke(backend, config, serviceExecutionID, options.capability, input, { jsonOutput: Boolean(options.json) });
1274
+ await runServicesInvoke(backend, config, serviceExecutionID, options.capability, parseKeyValueList(options.input), { jsonOutput: Boolean(options.json) });
1542
1275
  }
1543
1276
  catch (error) {
1544
1277
  reportCLIError(error, {
@@ -1564,18 +1297,12 @@ services
1564
1297
  .option("--result-item <service_capability_result_item_id>")
1565
1298
  .option("--required-before <step>")
1566
1299
  .option("--input <key=value>", "action input snapshot", collectOption, [])
1567
- .option("--input-json <file>", "JSON object containing the full action input snapshot")
1568
1300
  .option("--json", "output JSON instead of terminal text")
1569
1301
  .action(async (serviceExecutionID, options) => {
1570
1302
  const config = loadConfig();
1571
1303
  const backend = newBackendClient(config);
1572
1304
  try {
1573
- const recovery = [{ command: `itpay services next ${serviceExecutionID} --json`, reason: "读取当前动作要求" }];
1574
- if (options.inputJson && options.input.length > 0) {
1575
- throw new CommandContractError("service_action_invalid", "--input and --input-json cannot be combined", "--input 与 --input-json 只能二选一:嵌套结构用 --input-json <file>,扁平键值用 --input key=value。", recovery);
1576
- }
1577
- const fileInput = options.inputJson ? readInputJsonObject(options.inputJson, "service_action_invalid", recovery) : {};
1578
- await runServicesAction(backend, serviceExecutionID, options.action, { ...fileInput, ...parseKeyValueList(options.input) }, {
1305
+ await runServicesAction(backend, serviceExecutionID, options.action, parseKeyValueList(options.input), {
1579
1306
  ...(options.actorType ? { actorType: options.actorType } : {}),
1580
1307
  ...(options.actorId ? { actorID: options.actorId } : {}),
1581
1308
  ...(options.status ? { status: options.status } : {}),
@@ -1720,17 +1447,12 @@ services
1720
1447
  .command("next")
1721
1448
  .description("Show the next recommended agent action for a Service Execution")
1722
1449
  .argument("<service_execution_id>")
1723
- .option("--since-snapshot <snapshot_id>", "delta read: suppress the journey payload when unchanged")
1724
- .option("--timeout <seconds>", "wait up to 120 seconds for a useful result on this execution", (value) => Number(value))
1725
1450
  .option("--json", "output JSON instead of terminal text")
1726
1451
  .action(async (serviceExecutionID, options) => {
1727
1452
  const config = loadConfig();
1728
1453
  const backend = newBackendClient(config);
1729
1454
  try {
1730
- if (options.timeout !== undefined && (!Number.isInteger(options.timeout) || options.timeout < 0 || options.timeout > 120)) {
1731
- throw new Error("--timeout must be an integer from 0 to 120");
1732
- }
1733
- await runServicesNext(backend, serviceExecutionID, { jsonOutput: Boolean(options.json), sinceSnapshot: options.sinceSnapshot, timeoutSeconds: options.timeout });
1455
+ await runServicesNext(backend, serviceExecutionID, { jsonOutput: Boolean(options.json) });
1734
1456
  }
1735
1457
  catch (error) {
1736
1458
  reportCLIError(error, {
@@ -1743,28 +1465,20 @@ services
1743
1465
  });
1744
1466
  services
1745
1467
  .command("read-result")
1746
- .description("Read saved railway results or human-granted service content")
1468
+ .description("Read a human-granted service result for this agent")
1747
1469
  .argument("<service_execution_id>")
1748
- .option("--snapshot <snapshot_id>", "Smart: saved snapshot catalog; add --journey for a journey detail. Exact: saved station-pair rows without --snapshot")
1749
- .option("--journey <journey_id>", "rail.progressive.v2: journey id to read")
1750
- .option("--offset <offset>", "saved journey offset", Number, 0)
1751
- .option("--limit <limit>", "rows per page (1-20): Exact 20, Smart 3", Number)
1752
- .option("--all", "read every saved journey page")
1753
1470
  .option("--json", "output JSON instead of terminal text")
1754
1471
  .action(async (serviceExecutionID, options) => {
1755
1472
  const config = loadConfig();
1756
1473
  const backend = newBackendClient(config);
1757
1474
  try {
1758
- await runServicesReadResult(backend, serviceExecutionID, { jsonOutput: Boolean(options.json), snapshot: options.snapshot, journey: options.journey,
1759
- offset: options.offset, limit: options.limit, all: Boolean(options.all) });
1475
+ await runServicesReadResult(backend, serviceExecutionID, { jsonOutput: Boolean(options.json) });
1760
1476
  }
1761
1477
  catch (error) {
1762
1478
  reportCLIError(error, {
1763
1479
  jsonOutput: Boolean(options.json),
1764
- code: error instanceof HttpError && error.code === "agent_access_denied" ? "agent_access_denied" : "service_result_read_failed",
1765
- instruction: error instanceof HttpError && error.code === "agent_access_denied"
1766
- ? "请用户在订单页面重新授权;不要使用开发者权限绕过授权或退款锁。"
1767
- : "读取同一服务的已保存结果;若快照已不可读,先查看该服务当前状态和有效动作。",
1480
+ code: "agent_access_denied",
1481
+ instruction: "请用户在订单页面重新授权;不要使用开发者权限绕过授权或退款锁。",
1768
1482
  recovery: [{ command: `itpay services next ${serviceExecutionID} --json`, reason: "检查交付模式和 grant 状态" }],
1769
1483
  });
1770
1484
  }
@@ -1798,7 +1512,6 @@ services
1798
1512
  });
1799
1513
  }
1800
1514
  });
1801
- registerSell(program);
1802
1515
  program.parseAsync(process.argv).catch((error) => {
1803
1516
  reportCLIError(error);
1804
1517
  });
@@ -24,6 +24,9 @@ export function buildAgentChatHandoff(plan) {
24
24
  if (plan.orderItems?.length) {
25
25
  lines.push(`项目:${plan.orderItems.map((item) => `${item.title} x${item.quantity}`).join("、")}`);
26
26
  }
27
+ if (plan.afterActionCommand) {
28
+ lines.push("", `付款后查询:\`${plan.afterActionCommand}\``);
29
+ }
27
30
  return {
28
31
  type: "send_payment_handoff",
29
32
  must_send_to_user: true,
@@ -20,7 +20,7 @@ export async function renderTerminalQR(url, format) {
20
20
  });
21
21
  }
22
22
  export async function writeLocalPNG(url) {
23
- const dir = await fs.mkdtemp(path.join(process.env.ITPAY_STATE_DIR || os.tmpdir(), "itpay-v3-"));
23
+ const dir = await fs.mkdtemp(path.join(os.tmpdir(), "itpay-v3-"));
24
24
  const filePath = path.join(dir, `itpay-${randomUUID()}.png`);
25
25
  await QRCode.toFile(filePath, url, {
26
26
  type: "png",
@@ -55,12 +55,9 @@ export class CartSession {
55
55
  ...(this.state.lastDisplayToken ? { lastDisplayToken: this.state.lastDisplayToken } : {}),
56
56
  ...(this.state.lastCheckoutURL ? { lastCheckoutURL: this.state.lastCheckoutURL } : {}),
57
57
  };
58
- const contents = JSON.stringify(toSave, null, 2);
59
- if (existsSync(path) && readFileSync(path, "utf-8") === contents)
60
- return;
61
58
  mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
62
59
  const temporary = `${path}.${process.pid}.${randomUUID()}.tmp`;
63
- writeFileSync(temporary, contents, { encoding: "utf-8", mode: 0o600 });
60
+ writeFileSync(temporary, JSON.stringify(toSave, null, 2), { encoding: "utf-8", mode: 0o600 });
64
61
  chmodSync(temporary, 0o600);
65
62
  renameSync(temporary, path);
66
63
  chmodSync(path, 0o600);