@itpay/cli 2.1.41 → 2.1.44

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 +12 -5
  2. package/assets/sell-preview/index.html +6 -0
  3. package/assets/sell-preview/preview.js +9 -0
  4. package/bin/darwin-amd64/itpay-sell +0 -0
  5. package/bin/darwin-arm64/itpay-sell +0 -0
  6. package/bin/linux-amd64/itpay-sell +0 -0
  7. package/bin/linux-arm64/itpay-sell +0 -0
  8. package/bin/windows-amd64/itpay-sell.exe +0 -0
  9. package/dist/src/client/backend.js +38 -2
  10. package/dist/src/client/http.js +2 -0
  11. package/dist/src/commands/aftercare.js +12 -0
  12. package/dist/src/commands/buy.js +17 -58
  13. package/dist/src/commands/cart.js +17 -15
  14. package/dist/src/commands/catalog.js +39 -14
  15. package/dist/src/commands/checkout.js +146 -5
  16. package/dist/src/commands/checkout_handoff.js +11 -61
  17. package/dist/src/commands/docs.js +7 -18
  18. package/dist/src/commands/guidance.js +1 -134
  19. package/dist/src/commands/install.js +6 -3
  20. package/dist/src/commands/order.js +34 -3
  21. package/dist/src/commands/orders.js +4 -9
  22. package/dist/src/commands/pay.js +1 -1
  23. package/dist/src/commands/presentation.js +153 -0
  24. package/dist/src/commands/rail_catalog.js +1 -0
  25. package/dist/src/commands/readyz.js +1 -1
  26. package/dist/src/commands/refund.js +13 -57
  27. package/dist/src/commands/services/actions.js +133 -0
  28. package/dist/src/commands/services/commerce.js +197 -0
  29. package/dist/src/commands/services/lifecycle.js +418 -0
  30. package/dist/src/commands/services/results.js +130 -0
  31. package/dist/src/commands/services.js +14 -1068
  32. package/dist/src/commands/skill.js +8 -5
  33. package/dist/src/commands/vault.js +27 -20
  34. package/dist/src/commands/vault_handoff.js +18 -0
  35. package/dist/src/main.js +332 -46
  36. package/dist/src/render/browser.js +65 -0
  37. package/dist/src/render/checkout_handoff.js +101 -0
  38. package/dist/src/render/checkout_plan.js +47 -0
  39. package/dist/src/render/markdown.js +0 -3
  40. package/dist/src/render/qr.js +1 -1
  41. package/dist/src/sell/commands.js +80 -0
  42. package/dist/src/sell/contract.js +86 -0
  43. package/dist/src/sell/local.js +260 -0
  44. package/dist/src/sell/mcp.js +49 -0
  45. package/dist/src/sell/preview.js +70 -0
  46. package/dist/src/sell/sync.js +145 -0
  47. package/dist/src/services/adapter.js +1 -0
  48. package/dist/src/services/presentation.js +198 -0
  49. package/dist/src/services/rail/actions.js +51 -0
  50. package/dist/src/services/rail/adapter.js +36 -0
  51. package/dist/src/services/rail/aftercare.js +45 -0
  52. package/dist/src/services/rail/catalog.js +261 -0
  53. package/dist/src/services/rail/checkout.js +19 -0
  54. package/dist/src/services/rail/fulfillment.js +76 -0
  55. package/dist/src/services/rail/guide.js +110 -0
  56. package/dist/src/services/rail/invocation.js +54 -0
  57. package/dist/src/services/rail/page.js +76 -0
  58. package/dist/src/services/rail/pagination.js +6 -0
  59. package/dist/src/services/rail/query.js +71 -0
  60. package/dist/src/services/rail/readers.js +107 -0
  61. package/dist/src/services/rail/reading.js +125 -0
  62. package/dist/src/services/rail/recovery.js +51 -0
  63. package/dist/src/services/rail/results.js +378 -0
  64. package/dist/src/services/rail/review.js +268 -0
  65. package/dist/src/services/rail/saved.js +49 -0
  66. package/dist/src/services/rail/wait.js +11 -0
  67. package/dist/src/services/registry.js +31 -0
  68. package/dist/src/services/schema.js +21 -0
  69. package/dist/src/services/shared/envelope.js +184 -0
  70. package/dist/src/services/shared/input.js +39 -0
  71. package/dist/src/services/shared/pagination.js +28 -0
  72. package/dist/src/services/shared/platform.js +365 -0
  73. package/dist/src/services/shared/refund.js +40 -0
  74. package/dist/src/services/shared/workflow.js +28 -0
  75. package/dist/src/state/account_auth.js +354 -0
  76. package/dist/src/state/cart_session.js +4 -1
  77. package/dist/src/state/client_context.js +72 -0
  78. package/dist/src/state/config.js +44 -14
  79. package/dist/src/state/device_authority.js +402 -72
  80. package/dist/src/state/task_journal.js +90 -0
  81. package/docs/agent/buyer/cart-checkout.json +8 -6
  82. package/docs/agent/buyer/catalog-list.json +29 -9
  83. package/docs/agent/buyer/identity-and-sessions.json +26 -9
  84. package/docs/agent/buyer/install-and-setup.json +17 -15
  85. package/docs/agent/buyer/orders-refunds.json +25 -9
  86. package/docs/agent/buyer/payment-flow.json +6 -4
  87. package/docs/agent/buyer/purchased-content.json +18 -4
  88. package/docs/agent/buyer/quickstart.json +26 -17
  89. package/docs/agent/buyer/rail-booking.json +176 -0
  90. package/docs/agent/buyer/rail-fast-checkout.json +48 -0
  91. package/docs/agent/buyer/render-hosts.json +23 -12
  92. package/docs/agent/buyer/service-feedback.json +4 -3
  93. package/docs/cli-reference/agent-types.md +7 -2
  94. package/docs/cli-reference/commands/aftercare.md +15 -0
  95. package/docs/cli-reference/commands/auth.md +96 -0
  96. package/docs/cli-reference/commands/buy.md +2 -1
  97. package/docs/cli-reference/commands/cart/add.md +5 -1
  98. package/docs/cli-reference/commands/cart/clear.md +1 -1
  99. package/docs/cli-reference/commands/cart/index.md +1 -1
  100. package/docs/cli-reference/commands/cart/next.md +5 -1
  101. package/docs/cli-reference/commands/cart/remove.md +1 -1
  102. package/docs/cli-reference/commands/cart/show.md +1 -1
  103. package/docs/cli-reference/commands/catalog/index.md +1 -1
  104. package/docs/cli-reference/commands/catalog/list.md +2 -2
  105. package/docs/cli-reference/commands/checkout.md +12 -2
  106. package/docs/cli-reference/commands/device.md +18 -11
  107. package/docs/cli-reference/commands/docs/index.md +1 -1
  108. package/docs/cli-reference/commands/docs/list.md +1 -1
  109. package/docs/cli-reference/commands/docs/search.md +1 -1
  110. package/docs/cli-reference/commands/docs/show.md +1 -1
  111. package/docs/cli-reference/commands/install.md +8 -6
  112. package/docs/cli-reference/commands/next.md +1 -1
  113. package/docs/cli-reference/commands/order.md +1 -1
  114. package/docs/cli-reference/commands/pay.md +1 -1
  115. package/docs/cli-reference/commands/readyz.md +11 -11
  116. package/docs/cli-reference/commands/refund/cancel.md +1 -1
  117. package/docs/cli-reference/commands/refund/create.md +1 -1
  118. package/docs/cli-reference/commands/refund/get.md +2 -2
  119. package/docs/cli-reference/commands/refund/index.md +1 -1
  120. package/docs/cli-reference/commands/refund/list.md +1 -1
  121. package/docs/cli-reference/commands/refund/watch.md +1 -1
  122. package/docs/cli-reference/commands/sell.md +1364 -0
  123. package/docs/cli-reference/commands/services/action.md +24 -3
  124. package/docs/cli-reference/commands/services/checkout.md +17 -2
  125. package/docs/cli-reference/commands/services/events.md +1 -1
  126. package/docs/cli-reference/commands/services/get.md +4 -2
  127. package/docs/cli-reference/commands/services/index.md +4 -3
  128. package/docs/cli-reference/commands/services/invoke.md +6 -4
  129. package/docs/cli-reference/commands/services/list.md +1 -1
  130. package/docs/cli-reference/commands/services/next.md +78 -12
  131. package/docs/cli-reference/commands/services/page.md +71 -0
  132. package/docs/cli-reference/commands/services/quote.md +4 -4
  133. package/docs/cli-reference/commands/services/read-result.md +17 -6
  134. package/docs/cli-reference/commands/services/run.md +152 -0
  135. package/docs/cli-reference/commands/services/start.md +5 -3
  136. package/docs/cli-reference/commands/vault/access.md +5 -1
  137. package/docs/cli-reference/conventions.md +4 -6
  138. package/docs/cli-reference/index.md +10 -1
  139. package/docs/sell.md +84 -0
  140. package/package.json +20 -12
  141. package/skills/itpay/SKILL.md +112 -102
  142. package/docs/skill-bundle-rollout/01-mcp-authentication.md +0 -134
  143. package/docs/skill-bundle-rollout/02-platform-bundle-repositories.md +0 -210
  144. package/docs/skill-bundle-rollout/03-platform-publishing.md +0 -161
  145. package/docs/skill-bundle-rollout/04-first-wave-platforms.md +0 -69
  146. package/docs/skill-bundle-rollout/05-sync-operations.md +0 -62
  147. package/docs/skill-bundle-rollout/README.md +0 -151
  148. /package/bin/{itp → itp.mjs} +0 -0
@@ -0,0 +1,90 @@
1
+ // Minimal local task journal: which Service Executions are paused at a human
2
+ // gate (login, rate limit) and how to resume the SAME execution. It stores
3
+ // no chat history, PII, credentials or tokens — only ids, stage and the
4
+ // resume command the owner flow already emitted. Business truth stays
5
+ // server-side; this file only makes "continue" point at the right task.
6
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
7
+ import { dirname } from "node:path";
8
+ export const PAUSED_STAGES = new Set([
9
+ "login_required",
10
+ "rate_limited",
11
+ "quota_paused",
12
+ "auth_pending",
13
+ "awaiting_input",
14
+ ]);
15
+ const TERMINAL_STAGES = new Set([
16
+ "completed",
17
+ "delivered",
18
+ "issued",
19
+ "failed",
20
+ "cancelled",
21
+ "refunded",
22
+ ]);
23
+ export class TaskJournal {
24
+ path;
25
+ constructor(path) {
26
+ this.path = path;
27
+ }
28
+ record(task) {
29
+ const file = this.readFile();
30
+ file.tasks[task.service_execution_id] = {
31
+ ...task,
32
+ updated_at: new Date().toISOString(),
33
+ };
34
+ this.writeFile(file);
35
+ }
36
+ clear(serviceExecutionID) {
37
+ const file = this.readFile();
38
+ if (!file.tasks[serviceExecutionID])
39
+ return;
40
+ delete file.tasks[serviceExecutionID];
41
+ this.writeFile(file);
42
+ }
43
+ // Observe the latest stage without deleting history; terminal stages stop
44
+ // the task from counting as resumable.
45
+ observe(serviceExecutionID, stage, resumeCommand) {
46
+ const file = this.readFile();
47
+ const existing = file.tasks[serviceExecutionID];
48
+ if (existing && existing.stage === stage && (resumeCommand === undefined || existing.resume_command === resumeCommand))
49
+ return;
50
+ file.tasks[serviceExecutionID] = {
51
+ service_execution_id: serviceExecutionID,
52
+ ...(existing?.service_id ? { service_id: existing.service_id } : {}),
53
+ stage,
54
+ ...(resumeCommand ?? existing?.resume_command ? { resume_command: resumeCommand ?? existing.resume_command } : {}),
55
+ updated_at: new Date().toISOString(),
56
+ };
57
+ this.writeFile(file);
58
+ }
59
+ // Tasks paused behind login/quota gates, newest first. Terminal or
60
+ // completed tasks never count as "still waiting for login".
61
+ pausedTasks() {
62
+ const file = this.readFile();
63
+ return Object.values(file.tasks)
64
+ .filter((task) => PAUSED_STAGES.has(task.stage) && !TERMINAL_STAGES.has(task.stage))
65
+ .sort((left, right) => right.updated_at.localeCompare(left.updated_at));
66
+ }
67
+ readFile() {
68
+ if (!existsSync(this.path))
69
+ return { schema_version: "itpay.task_journal.v1", tasks: {} };
70
+ try {
71
+ const parsed = JSON.parse(readFileSync(this.path, "utf8"));
72
+ if (parsed.schema_version !== "itpay.task_journal.v1" || !parsed.tasks || typeof parsed.tasks !== "object") {
73
+ return { schema_version: "itpay.task_journal.v1", tasks: {} };
74
+ }
75
+ return parsed;
76
+ }
77
+ catch {
78
+ return { schema_version: "itpay.task_journal.v1", tasks: {} };
79
+ }
80
+ }
81
+ writeFile(file) {
82
+ // Bound the journal: keep only the 50 most recent task records.
83
+ const entries = Object.entries(file.tasks).sort((left, right) => right[1].updated_at.localeCompare(left[1].updated_at));
84
+ file.tasks = Object.fromEntries(entries.slice(0, 50));
85
+ mkdirSync(dirname(this.path), { recursive: true, mode: 0o700 });
86
+ const tmp = `${this.path}.${process.pid}.tmp`;
87
+ writeFileSync(tmp, JSON.stringify(file), { mode: 0o600 });
88
+ renameSync(tmp, this.path);
89
+ }
90
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema_version": "itp.agent_doc.v1",
3
3
  "role": "buyer",
4
- "product_scope": "itpay is the single public CLI entry point, and $itpay is its user-facing Skill invocation. Under that one product entry point, the two top-level commerce actions are buy and sell: Buyer workflows are available now; Seller workflows will use the same entry point and are not implemented yet.",
4
+ "product_scope": "itpay is the single public CLI entry point for Buyer services and the existing itpay sell Seller workflow; $itpay is its user-facing Skill invocation.",
5
5
  "topic": "cart-checkout",
6
6
  "title": "Canonical Cart And Checkout Routing",
7
7
  "purpose": "Use the canonical server Cart and route service-backed lines through Service Execution without hardcoded service logic.",
@@ -32,11 +32,12 @@
32
32
  }
33
33
  ],
34
34
  "agent_rules": [
35
- "The Backend Cart is business truth; ~/.itpay-v3/cart.json only stores local recovery handles and explicit drafts.",
35
+ "The Backend Cart is business truth; the current backend-isolated local cart state file only stores local recovery handles and explicit drafts.",
36
36
  "Run the exact next.command returned by the CLI. Do not extract or invent a capability from a raw list.",
37
- "One service intent uses one Service Execution. Start another execution for another independent intent.",
38
- "Ask for email only when the selected capability requires protected delivery; never invent contact data.",
39
- "A lost Checkout response is retried with the same Cart and persisted idempotency operation."
37
+ "Railway query and booking use distinct Service Executions for one purchase journey. Start another execution for an independent intent.",
38
+ "Only non-rail capabilities explicitly requiring delivery email may ask its purpose and value. Railway notification contact belongs to the protected checkout page with verified account email reuse; the Agent must not guess or collect it in chat.",
39
+ "A lost Checkout response is retried with the same Cart and persisted idempotency operation.",
40
+ "A single railway service checkout normally follows its booking execution; Cart is used only when the returned flow calls for it."
40
41
  ],
41
42
  "forbidden": [
42
43
  "Do not call ordinary buy for a service-backed Cart line.",
@@ -59,5 +60,6 @@
59
60
  "service execution",
60
61
  "resume",
61
62
  "contact"
62
- ]
63
+ ],
64
+ "purchase_consent": "Candidate selection is not price approval. Service-backed quote/cart/checkout requires a current scoped approve_purchase record; use the complete server template, default false. Only genuine matching approval allows true; material price/subject/terms changes invalidate it. Restore an existing Checkout before creating anything."
63
65
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema_version": "itp.agent_doc.v1",
3
3
  "role": "buyer",
4
- "product_scope": "itpay is the single public CLI entry point, and $itpay is its user-facing Skill invocation. Under that one product entry point, the two top-level commerce actions are buy and sell: Buyer workflows are available now; Seller workflows will use the same entry point and are not implemented yet.",
4
+ "product_scope": "itpay is the single public CLI entry point for Buyer services and the existing itpay sell Seller workflow; $itpay is its user-facing Skill invocation.",
5
5
  "topic": "catalog-list",
6
6
  "title": "Browse ItPay V3 Service Catalog",
7
7
  "purpose": "Explain available services, outcomes, conditions, and prices in human language without exposing catalog identifiers.",
@@ -18,25 +18,44 @@
18
18
  ],
19
19
  "output_interpretation": {
20
20
  "item_format": "Explain the title, what the human receives, any auxiliary discovery step, and the published price.",
21
- "service_flow": "Explain discovery as an auxiliary identity-confirmation step, including free quota and paid continuation. Present primary_service as the actual paid outcome. Read all values from the manifest.",
21
+ "service_flow": "Legacy catalog only: read service_flow facts as published; do not reinterpret old discovery/paid identities as a new public definition. New definitions expose operations within one service.",
22
22
  "variant_selection": "Internal IDs are for the Agent's next command only and are never shown or requested from the human.",
23
- "price_note": "amount_minor is in minor units (e.g., 10000 = 100.00 CNY). The CLI formats prices as XX.YY currency automatically."
23
+ "price_note": "amount_minor is in minor units (e.g., 10000 = 100.00 CNY). The CLI formats prices as XX.YY currency automatically.",
24
+ "railway": "Railway entries point to itpay docs show rail-booking; use its query and booking contracts instead of a generic start→invoke→cart sequence.",
25
+ "service_definition": "Prefer immutable service_definition: one public service with declared operations, pinned schemas and billing modes. Free query does not mean free purchase; dynamic needs a real quote. Do not choose a zero placeholder variant."
24
26
  },
25
27
  "agent_rules": [
26
28
  "Use catalog list only when the human asks for a new service, not when they want an earlier purchase.",
27
29
  "Read the variant IDs and prices from the output; do not invent them.",
28
- "Explain the customer journey from service_flow instead of presenting every variant as an unrelated service.",
30
+ "Explain the returned public service operations and pricing; use legacy service_flow only when no service_definition is present.",
29
31
  "State free quota, paid continuation price, email requirement, and claim purpose exactly as published; do not exaggerate or omit conditions.",
30
32
  "Ask the human to choose only when multiple services could satisfy the goal; never make them choose an internal variant or offer ID.",
31
- "After services start, submit service keywords only through the returned capability command's --input key=value options; --target is never a search keyword."
33
+ "Use each service’s returned input contract; railway planning and booking follow rail-booking, not a universal Cart route."
32
34
  ],
33
35
  "human_language": {
34
- "prefer": ["服务", "查询", "报告", "免费次数", "价格", "你会得到什么"],
35
- "avoid": ["service_id", "variant_id", "offer_id", "capability", "manifest"]
36
+ "prefer": [
37
+ "服务",
38
+ "查询",
39
+ "报告",
40
+ "免费次数",
41
+ "价格",
42
+ "你会得到什么"
43
+ ],
44
+ "avoid": [
45
+ "service_id",
46
+ "variant_id",
47
+ "offer_id",
48
+ "capability",
49
+ "manifest"
50
+ ]
36
51
  },
37
52
  "next_docs": [
38
53
  {
39
- "condition": "Buyer selected a service and wants to purchase",
54
+ "condition": "Railway service selected",
55
+ "topic": "rail-booking"
56
+ },
57
+ {
58
+ "condition": "Non-rail Buyer selected a service and wants to purchase",
40
59
  "topic": "cart-checkout",
41
60
  "file": "docs/agent/buyer/cart-checkout.json"
42
61
  }
@@ -50,5 +69,6 @@
50
69
  "what to buy",
51
70
  "有哪些",
52
71
  "服务列表"
53
- ]
72
+ ],
73
+ "purchase_consent": "Candidate selection is not price approval. Service-backed quote/cart/checkout requires a current scoped approve_purchase record; use the complete server template, default false. Only genuine matching approval allows true; material price/subject/terms changes invalidate it. Restore an existing Checkout before creating anything."
54
74
  }
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "schema_version": "itp.agent_doc.v1",
3
3
  "role": "buyer",
4
- "product_scope": "itpay is the single public CLI entry point, and $itpay is its user-facing Skill invocation. Under that one product entry point, the two top-level commerce actions are buy and sell: Buyer workflows are available now; Seller workflows will use the same entry point and are not implemented yet.",
4
+ "product_scope": "itpay is the single public CLI entry point for Buyer services and the existing itpay sell Seller workflow; $itpay is its user-facing Skill invocation.",
5
5
  "topic": "identity-and-sessions",
6
6
  "title": "Device Identity And Session Recovery",
7
7
  "purpose": "Explain stable local identity, official Backend-scoped registrations, Agent Type instances, and bounded automatic session recovery.",
8
8
  "when_to_use": [
9
9
  "A different Agent window or runtime starts using an existing CLI installation.",
10
- "The CLI reports device_state_unwritable, or the Backend reports agent_identity_required, agent_device_session_required, or agent_device_revoked.",
10
+ "The CLI reports device_state_unwritable, or the Backend reports agent_identity_required, agent_device_session_required, agent_device_not_found, or agent_device_revoked.",
11
11
  "An operator confirms that the currently selected official Backend registration database was reset."
12
12
  ],
13
13
  "identity_model": {
14
14
  "local_key": "One owner-only Ed25519 private key for the local installation.",
15
- "backend_registration": "One registration per official Backend: app.itpay.ai by default and dev.itpay.ai only with the exact test override.",
15
+ "backend_registration": "One registration per configured official Backend. Follow the current CLI backend allowlist; do not switch to evade failures.",
16
16
  "agent_instance": "One instance per agent_type under each Backend registration; same-type windows and chats reuse it.",
17
17
  "presentation": "Host and target route output only and never identify the Agent or provide business input."
18
18
  },
@@ -21,13 +21,15 @@
21
21
  "On one HTTP 401 with code agent_device_session_required, it invalidates only the current Backend and Agent Type session, renews it, and retries the exact request once.",
22
22
  "A second failure is returned to the Agent. The CLI does not loop, switch Agent Type, rotate the key, or create a replacement v2 device.",
23
23
  "When a previously unseen Agent Type is registered under an existing Device, the CLI skips locally known Agent Instances that the Backend reports as revoked and uses the first remaining valid Instance. It never reactivates a revoked Instance or replaces the Device; if none is valid, registration stops.",
24
- "A revoked v2 registration requires explicit operator recovery; it is never silently replaced."
24
+ "When the Backend reports agent_device_not_found (HTTP 404) for a locally known registration — for example after the Backend registration database was rebuilt — the CLI drops only that Backend's registration and re-enrolls once with the same private key, re-attaching to the same device and quota lineage where the Backend still holds the key.",
25
+ "A revoked v2 registration requires explicit operator recovery; it is never silently replaced.",
26
+ "Re-enrolling a public key the Backend already holds re-attaches to the existing device and quota lineage after proof-of-possession; it never creates a duplicate device. An internal_error is a server failure: preserve the key and wait for service recovery. If enrollment returns agent_device_key_rotated or agent_device_key_conflict, stop automatic recovery. Only an explicit human/operator decision to abandon the old identity permits reset-key; old execution access does not migrate."
25
27
  ],
26
28
  "local_state_recovery": [
27
- "Device state updates use an atomic directory lock and owner-only atomic file replacement; no lock file is opened with fs.open or fs.openSync.",
29
+ "Device state uses an owner-only atomic file replacement and a lock that the CLI can inspect. On a stale lock, run the returned device repair-lock command; it only reclaims a proven stale owner.",
28
30
  "Operation idempotency uses one immutable owner-only record per operation key. Different commands and Agent processes do not share a global operation-journal lock; legacy operations.json is read only.",
29
31
  "On device_state_unwritable, use the reported operation and errno to diagnose the failing stage without exposing local paths; keep the same Agent Type and CLI/Node launcher, restore Host-approved persistent access to ~/.itpay-v3, then retry the original command.",
30
- "Do not manually create or delete state locks, switch Node runtimes, delete identity, or rotate Agent Type as a retry strategy."
32
+ "Do not delete a live lock, switch Node runtimes, delete identity, or rotate Agent Type as a retry strategy."
31
33
  ],
32
34
  "commands": [
33
35
  {
@@ -44,19 +46,24 @@
44
46
  "intent": "recover after an operator-confirmed reset of the selected official Backend registration database",
45
47
  "command": "itpay --agent-type <agent_type> device recover --confirm-backend-reset --json",
46
48
  "success_signal": "only the selected Backend registration is removed and the private key and other Backend registration remain"
49
+ },
50
+ {
51
+ "intent": "repair only a proven stale local device lock",
52
+ "command": "itpay device repair-lock --json",
53
+ "success_signal": "the CLI reports whether the lock was stale and reclaimed; an active owner stays protected"
47
54
  }
48
55
  ],
49
56
  "agent_rules": [
50
57
  "Use the real runtime type and keep it stable across every command in the flow.",
51
58
  "Keep the same CLI/Node launcher and Host-approved permission context for the whole flow.",
52
59
  "Treat a new window, chat, task, or process of the same runtime as the same Agent Type, not a new identity.",
53
- "Expect production traffic to use https://app.itpay.ai. Use https://dev.itpay.ai only for an explicit test and keep the complete returned Backend-prefixed command for that entire flow.",
60
+ "Production defaults to https://app.itpay.ai; explicit sandbox or dev testing uses https://sandbox.itpay.ai or https://dev.itpay.ai. Keep the complete returned Backend-prefixed command for that flow.",
54
61
  "After automatic recovery fails, stop and report the exact code, selected official Backend, Agent Type, and command family without exposing private keys or tokens."
55
62
  ],
56
63
  "forbidden": [
57
64
  "Do not delete ~/.itpay-v3, rotate the key, switch Agent Type, or repeatedly retry to obtain fresh quota.",
58
65
  "Do not use device recover for session expiry, revocation, quota recovery, or an unconfirmed Backend failure.",
59
- "Do not redirect the CLI to test, local, an IP, or any custom Backend; only the exact official dev.itpay.ai test override is allowed.",
66
+ "Do not switch Backend to evade a failure. Allowed public URLs are app.itpay.ai, sandbox.itpay.ai and dev.itpay.ai; local loopback requires the explicit CLI development flag.",
60
67
  "Do not use --target as identity or service input."
61
68
  ],
62
69
  "next_docs": [
@@ -83,5 +90,15 @@
83
90
  "lock",
84
91
  "window",
85
92
  "chat"
86
- ]
93
+ ],
94
+ "auth_session_states": {
95
+ "stages": "Report the actual server stage: waiting_provider (show the official handoff), email_verification_required (explicit or legacy identity verification; follow the current official page), merge_confirmation_required (the human must prove both accounts and explicitly confirm or cancel the frozen merge), provider_pending/pending (wait), completed (bind the original session and resume the same service). Ordinary login needs one verified supported identity; do not require both phone and email.",
96
+ "terminal_states": "auth_expired/auth_denied/auth_cancelled/auth_failed mean this session is over; say so plainly and respect denial or cancellation. Start a new session only on an explicit login request; never keep polling a dead one.",
97
+ "transport_unknown": "auth_status_unknown means a network error while polling — the outcome is unknown. Keep waiting on the SAME session (it may still complete); do NOT restart auth, and do not assume denial.",
98
+ "missing": "auth_session_missing means the cached session is gone. An explicit auth login opens one fresh official session in that call; auth status stays read-only.",
99
+ "completed_resume": "After login completes, execute the returned command to resume the same paused service execution. Login does not silently run that command.",
100
+ "path_b": "A buyer who reaches checkout without a login completes identity inside the protected checkout page; never force a separate itpay auth login first.",
101
+ "identity_binding": "Phone is recommended first, wallets next, email is a separate Other options choice. Extra identities are optional bindings. A phone conflict does not prove account ownership: independent target authentication and explicit human merge confirmation are required. Never use the same SMS proof twice, approve a merge for the user, or treat login/identity binding as payment consent. Service-specific contact requirements stay in the service."
102
+ },
103
+ "key_reset_decision": "Only after explicit user/operator acceptance of abandoning the old identity, consult device reset-key help; this is not automatic error recovery, and old execution access does not migrate."
87
104
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema_version": "itp.agent_doc.v1",
3
3
  "role": "buyer",
4
- "product_scope": "itpay is the single public CLI entry point, and $itpay is its user-facing Skill invocation. Under that one product entry point, the two top-level commerce actions are buy and sell: Buyer workflows are available now; Seller workflows will use the same entry point and are not implemented yet.",
4
+ "product_scope": "itpay is the public CLI entry point for Buyer services and existing itpay sell Seller workflows.",
5
5
  "topic": "install-and-setup",
6
6
  "title": "Install And Identify The ItPay Agent Runtime",
7
7
  "purpose": "Select the real Agent Type, verify one official Backend, and load the packaged Skill through one linear setup path.",
@@ -18,7 +18,7 @@
18
18
  {
19
19
  "intent": "list supported Agent Types",
20
20
  "command": "itpay install --json",
21
- "success_signal": "status is install_targets and exactly eight supported Agent Type definitions are returned"
21
+ "success_signal": "status is install_targets and exactly nine supported Agent Type definitions are returned"
22
22
  },
23
23
  {
24
24
  "intent": "read setup for the real runtime",
@@ -28,33 +28,34 @@
28
28
  {
29
29
  "intent": "verify the selected official Backend",
30
30
  "command": "<execute the exact next.command returned by install>",
31
- "success_signal": "status is ready and next points to the packaged Skill with the same Agent Type and Backend"
31
+ "success_signal": "ready proves Backend liveness only; retain the actual Agent Type and Backend, then verify device access"
32
32
  },
33
33
  {
34
- "intent": "load the complete packaged operating contract",
35
- "command": "<execute the exact next.command returned by readyz>",
36
- "success_signal": "status is shown and next is null so the Agent can route the human's natural-language intent"
34
+ "intent": "verify device access after Backend liveness",
35
+ "command": "itpay auth status --json",
36
+ "success_signal": "authenticated or successful login_required proves device access; pending/unknown is not ready"
37
37
  }
38
38
  ],
39
39
  "agent_rules": [
40
40
  "For first setup, read the complete Skill from this installed package before network checks. Select the actual Agent Type once through install and retain the same launcher and Backend. Do not reread the same version Skill, repeat initialization for ordinary tasks, or start login or business to prove setup.",
41
- "After setup, tell the human only that ItPay is ready; never ask them to run setup commands or explain technical setup steps.",
42
- "Use the CLI distribution already provided by the current npm package, Skill, or plugin; update only through that distribution's own instructions.",
43
- "Production defaults to https://app.itpay.ai. Testing may set ITPAY_BACKEND_URL to the exact official URL https://dev.itpay.ai; no other Backend is allowed.",
44
- "minimum_cli_version is a protocol floor, not a verified matching artifact. If incompatible, stop and ask the maintainer for the matching distribution; do not guess a version or downgrade.",
45
- "Only use verified matching artifacts; never change Agent Type or Device identity to recover compatibility.",
46
- "Use one exact type: codex-desktop, codex-cli, claude-code-desktop, claude-code-cli, workbuddy, zcode, kimi-code, or openclaw.",
41
+ "Run installation separately and preserve full output and its exit code. Nonzero stops preparation even if an older CLI runs. Same-version reuse requires verified executable, registry channel target, contract and official source; do not force or bypass host protection.",
42
+ "Report ItPay ready only after Backend and device checks succeed; otherwise preparation is incomplete. Account login is not required for setup.",
43
+ "The current public setup link selects the channel and matching contract: latest/app for production, next/dev for beta. Do not let an old bundle or memory override this choice.",
44
+ "Production defaults to https://app.itpay.ai. Testing may set ITPAY_BACKEND_URL to the exact official URL the configured official test Backend only when explicitly requested; follow the CLI allowlist.",
45
+ "If Backend compatibility cannot be verified, stop this round. minimum_cli_version is a protocol floor, not a verified matching artifact. Ask the maintainer for the matching distribution; do not guess a version or downgrade.",
46
+ "Only install a replacement when its exact artifact and Backend contract have been verified; then reread that package Skill. Never change Agent Type or Device identity to recover compatibility.",
47
+ "Use one exact type: codex-desktop, codex-cli, claude-code-desktop, claude-code-cli, workbuddy, zcode, doubao-work, kimi-code, or openclaw.",
47
48
  "For compatibility, a global --agent-type codex declaration is normalized immediately to codex-desktop; all registration, output, and returned commands use codex-desktop. Never generate the alias, and do not use codex as an install target.",
48
- "One local private key is reused, while Device registrations and quota lineage remain separate for app.itpay.ai and dev.itpay.ai.",
49
+ "One local private key is reused, while Device registrations and quota lineage remain separate for app.itpay.ai, sandbox.itpay.ai and dev.itpay.ai.",
49
50
  "Within each official Backend registration, each Agent Type has one Agent Instance; all windows and chats of the same type reuse it.",
50
51
  "Agent Type identifies the runtime. Host and target only select a presentation destination; load render-hosts only when a handoff cannot be shown.",
51
52
  "Keep the exact Agent Type in every next or recovery command; do not fall back to a type previously used by another runtime.",
52
53
  "Do not change Agent Type or rotate local identity to reset quota or recover a failed command.",
53
- "For production setup, itpay device status --json verifies the device against the current Backend. device_ready does not establish account binding; binding is unavailable to this CLI and no auth login action is inferred."
54
+ "Skillhub and local host bundles are separate installed artifacts; verify their version and packaged Skill/docs instead of assuming an npm update changed them."
54
55
  ],
55
56
  "forbidden": [
56
57
  "Do not use terminal, claude-code, or plain-chat as Agent Types. Do not generate codex as an Agent Type; it is accepted only as a legacy global declaration and becomes codex-desktop before any request.",
57
- "Do not set or suggest any Backend except the default https://app.itpay.ai or the exact test override https://dev.itpay.ai.",
58
+ "Do not set or suggest a Backend outside the CLI allowlist: https://app.itpay.ai, https://sandbox.itpay.ai, https://dev.itpay.ai; local loopback requires the CLI development flag. Do not switch Backend to evade a failure.",
58
59
  "Do not claim that install writes host configuration or registers a device; it only prints instructions.",
59
60
  "Do not create a new identity for a different window, task, chat, or process of the same Agent Type."
60
61
  ],
@@ -77,6 +78,7 @@
77
78
  "claude code",
78
79
  "workbuddy",
79
80
  "zcode",
81
+ "doubao work",
80
82
  "kimi code",
81
83
  "openclaw"
82
84
  ]
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema_version": "itp.agent_doc.v1",
3
3
  "role": "buyer",
4
- "product_scope": "itpay is the single public CLI entry point, and $itpay is its user-facing Skill invocation. Under that one product entry point, the two top-level commerce actions are buy and sell: Buyer workflows are available now; Seller workflows will use the same entry point and are not implemented yet.",
4
+ "product_scope": "itpay is the single public CLI entry point for Buyer services and the existing itpay sell Seller workflow; $itpay is its user-facing Skill invocation.",
5
5
  "topic": "orders-refunds",
6
6
  "title": "Order, Delivery, Customer Care And Refund Recovery",
7
7
  "purpose": "Explain paid-order and delivery problems to the human, then read or manage the same owned Order without guessing payment, consumption, or refund state.",
@@ -16,6 +16,11 @@
16
16
  "command": "itpay --agent-type <agent_type> order <order_id> --json",
17
17
  "success_signal": "one compact owned-order summary and one current next step are returned"
18
18
  },
19
+ {
20
+ "intent": "read railway refund/change targets and complete current input templates",
21
+ "command": "itpay --agent-type <agent_type> aftercare list --order <order_id> --json",
22
+ "success_signal": "safe original itinerary, available leg/passenger targets, requests and full refund/change templates"
23
+ },
19
24
  {
20
25
  "intent": "request a refund",
21
26
  "command": "itpay --agent-type <agent_type> refund create --order <order_id> --reason buyer_requested --json",
@@ -34,19 +39,23 @@
34
39
  {
35
40
  "intent": "cancel before provider submission",
36
41
  "command": "itpay --agent-type <agent_type> refund cancel <refund_request_id> --json",
37
- "success_signal": "the Refund Owner cancels the request and requires a new delivery authorization"
42
+ "success_signal": "the Refund Owner returns the current cancellation and access state; old grants do not revive"
38
43
  }
39
44
  ],
40
45
  "agent_rules": [
41
46
  "Act as the human's ItPay service representative: explain payment, delivery, access, and refund facts in plain language before giving the next action.",
42
47
  "After verified payment, say the Order is recorded and the human must not pay again. Recover that same Order or Service Execution if delivery is delayed or fails.",
43
48
  "ItPay derives payment, amount, currency, account ownership, and refund policy from the owned order; explain only their user-facing meaning.",
44
- "Unconsumed delivery normally follows the automatic policy; consumed delivery normally requires manual review. These are policy routes, not promises of a successful or instant refund.",
49
+ "A railway order can contain 1–3 legs paid together and issued separately. Report all-issued only when every leg is issued; retain issued tickets on a partial failure or unknown result. Railway return and platform refund follow per-leg supplier facts; do not promise a full refund or create replacement tickets.",
50
+ "Read this order’s current refund policy. Railway return depends on supplier ticket facts and may require manual review; platform refund status alone does not prove a train ticket was returned.",
45
51
  "A refund request freezes all delivery paths and revokes existing grants immediately.",
46
- "Cancellation or rejection restores eligibility but never reactivates an old grant.",
47
- "Use get or watch after interruption; do not infer success from elapsed time.",
52
+ "Cancellation or rejection follows the returned order policy and never reactivates an old grant automatically.",
53
+ "Use get after interruption; explicit watch defaults to a bounded 20-second window and returns on change or manual attention. Do not restart watch automatically or infer success from elapsed time.",
48
54
  "Never switch CLI/MCP lanes or identities to recover an order or refund error.",
49
- "A read-only MCP Agent may explain policy and order facts, but directs refund actions to the ItPay Dashboard or a full Local CLI Agent."
55
+ "A read-only MCP Agent may explain policy and order facts, but directs refund actions to the ItPay Dashboard or a full Local CLI Agent.",
56
+ "Railway refund or manual change: use aftercare list for structured ticket targets. Match the user’s explicit legs/passengers; only ask when that scope is missing. Explain the scope and manual handling before create using the returned complete JSON. No supplier reference or amount is needed from the user.",
57
+ "Aftercare acceptance, supplier completion and platform money status are separate. Only real scope consent may set user_confirmed_scope=true. A concrete change proposal requires fresh approval of the current proposal revision and fees; the original purchase consent cannot approve it. This release has no automatic change payment link.",
58
+ "Partial refunds do not mean every ticket was returned. The platform delivery lock remains; use the safe aftercare journey for remaining-ticket facts, never promise validity from historical issued state. Protected ticket numbers still require account authorization."
50
59
  ],
51
60
  "human_explanations": {
52
61
  "payment_verified": "Payment is confirmed and the Order is recorded. Do not ask the human to pay again; continue the same delivery.",
@@ -55,11 +64,11 @@
55
64
  "refund_automatic": "The request is on the automatic policy path because the delivery is reported unconsumed; only the final server status proves success.",
56
65
  "refund_manual": "The request requires human review, commonly because delivery was consumed. Manual review is not a rejection.",
57
66
  "refund_unknown": "The payment channel outcome is unknown. Delivery stays locked while ItPay reconciles; never submit or replay another refund.",
58
- "refund_succeeded": "ItPay confirms the refund succeeded and delivery is permanently closed."
67
+ "refund_succeeded": "ItPay confirms this request’s money refund succeeded. Verify its scope and the remaining-ticket facts separately; only the order’s full refunded state establishes all platform money returned."
59
68
  },
60
69
  "forbidden": [
61
70
  "Do not fabricate Buyer sessions, Device IDs or payment references.",
62
- "Do not read delivery while refund access_locked is true.",
71
+ "Do not consume locked platform delivery; authorized safe remaining-ticket status reads are separate.",
63
72
  "Do not claim a refund succeeded before the Refund Owner says succeeded.",
64
73
  "Do not promise an unconditional refund, instant arrival, or a channel result that ItPay has not confirmed.",
65
74
  "Do not blame the human for a Provider, delivery, platform, or payment-channel failure."
@@ -92,5 +101,12 @@
92
101
  "交付失败",
93
102
  "没有收到结果",
94
103
  "能不能退"
95
- ]
104
+ ],
105
+ "rail_notifications": {
106
+ "channels": "Delivery notices reach the checkout-confirmed contact: email always works; a verified mainland SMS recipient is optional and checkout-scoped. The passenger phone, the login phone and the notification recipient are independent facts.",
107
+ "status_read": "Use the current returned reader for ticket state; order summaries do not expose per-leg notification delivery records. Do not infer a sent or delivered notification.",
108
+ "truthfulness": "Provider acceptance is not delivery; an uncertain send outcome is reconciled, not silently retried. A notification failure never changes ticket or refund state; report it as a delivery detail, not an order failure.",
109
+ "unavailable": "If SMS is not configured or a recipient is unverified, email still satisfies the contact policy — never present an unverified phone as enabled."
110
+ },
111
+ "consumption_and_access": "Platform content consumption is not train usage; access_locked freezes platform delivery and does not prove ticket validity. Read actual refund/ticket facts; a future departure does not guarantee eligibility."
96
112
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema_version": "itp.agent_doc.v1",
3
3
  "role": "buyer",
4
- "product_scope": "itpay is the single public CLI entry point, and $itpay is its user-facing Skill invocation. Under that one product entry point, the two top-level commerce actions are buy and sell: Buyer workflows are available now; Seller workflows will use the same entry point and are not implemented yet.",
4
+ "product_scope": "itpay is the single public CLI entry point for Buyer services and the existing itpay sell Seller workflow; $itpay is its user-facing Skill invocation.",
5
5
  "topic": "payment-flow",
6
6
  "title": "Human Checkout Handoff And Payment Verification",
7
7
  "purpose": "Show the ItPay Checkout to the human and recover authoritative payment state without creating duplicate payment resources.",
@@ -13,7 +13,7 @@
13
13
  {
14
14
  "intent": "present the Checkout handoff",
15
15
  "command": "<execute the exact command returned by buy or services checkout>",
16
- "success_signal": "the human can see both the ItPay Checkout QR or image and the Checkout URL"
16
+ "success_signal": "the returned official URL and/or QR supported by the actual Host is visible to the human"
17
17
  },
18
18
  {
19
19
  "intent": "read authoritative Checkout state",
@@ -29,7 +29,8 @@
29
29
  "agent_rules": [
30
30
  "Normal buyer flow opens the ItPay Checkout page; itpay pay and buy --pay are operator escape hatches.",
31
31
  "Use only handoff fields returned for the current Host and make them actually visible to the human.",
32
- "Before creating a single-Service Checkout, send the exact price confirmation requested by the current instruction, stop, and wait for explicit human agreement.",
32
+ "Obtain only missing required agreement or material price/term changes. Reuse a valid explicit confirmation for unchanged terms; never invent it.",
33
+ "For a railway journey, show one official checkout for all legs: one total/payment, separate issuance. The page shares its authoritative payment_deadline_at/server_now/payment_remaining_seconds; reaching zero requires reading current status, not declaring cancellation.",
33
34
  "After presenting a Checkout, stop. Run the returned next.command only after the human completes the payment action or asks to query the same Checkout.",
34
35
  "Use only the handoff fields returned for the current Host. Load render-hosts if the official handoff is not visible.",
35
36
  "Payment is verified only by Backend Checkout or Order state, never by QR rendering, redirect, or user claim.",
@@ -65,5 +66,6 @@
65
66
  "付款后",
66
67
  "不要重复付款",
67
68
  "支付确认"
68
- ]
69
+ ],
70
+ "purchase_consent": "Candidate selection is not price approval. Service-backed quote/cart/checkout requires a current scoped approve_purchase record; use the complete server template, default false. Only genuine matching approval allows true; material price/subject/terms changes invalidate it. Restore an existing Checkout before creating anything."
69
71
  }
@@ -29,20 +29,34 @@
29
29
  "intent_routing": {
30
30
  "previous_content": "Use vault list, optionally with the subject as --query.",
31
31
  "purchase_history": "Use orders.",
32
- "new_service": "Use catalog only when the human asks for a new query or purchase.",
32
+ "new_service": "For a new railway request, read rail-booking; for other new services, use catalog. No previous-content match does not block a separately requested new railway query.",
33
33
  "ambiguous": "Ask whether the human wants an earlier purchase or a new query before calling ItPay."
34
34
  },
35
35
  "authorization_flow": [
36
36
  "Run the original list, orders, or read command.",
37
37
  "OpenClaw must pass its current trusted host and required target on the original command so the authorization continuation preserves the real presentation destination.",
38
- "If it returns human_authorization_required, run only its next.command once.",
38
+ "If it returns human_authorization_required and context is complete, run its executable next.command once. If next is null or context/consent is missing, fill the returned interaction/input_template first; never invent host, target or consent.",
39
39
  "Make the returned handoff genuinely visible and stop.",
40
40
  "After the human says authorization is complete, rerun the original read command unchanged.",
41
41
  "Never rerun vault access as a status check."
42
42
  ],
43
43
  "human_language": {
44
- "prefer": ["previously purchased content", "past report", "purchase history", "已购内容", "以前购买的报告", "购买记录"],
45
- "avoid": ["Vault", "artifact", "Device", "Buyer", "grant", "start token"]
44
+ "prefer": [
45
+ "previously purchased content",
46
+ "past report",
47
+ "purchase history",
48
+ "已购内容",
49
+ "以前购买的报告",
50
+ "购买记录"
51
+ ],
52
+ "avoid": [
53
+ "Vault",
54
+ "artifact",
55
+ "Device",
56
+ "Buyer",
57
+ "grant",
58
+ "start token"
59
+ ]
46
60
  },
47
61
  "partial_results": {
48
62
  "available": "Explain the returned section normally.",