@itpay/cli 2.1.17 → 2.1.19

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.
@@ -13,12 +13,62 @@ Use the `itpay` CLI as the only ItPay control surface. Infer the human's goal,
13
13
  choose one first command, then follow each returned envelope. Run technology
14
14
  for the human; never ask them to run commands or learn internal concepts.
15
15
 
16
+ ## The Whole Trip
17
+
18
+ ItPay finds services, runs them and delivers results. A known railway request
19
+ starts with the railway commands below; use catalog only to discover an unknown
20
+ service. Existing purchases resume from their original execution or order.
21
+ Seller work uses `itpay sell`.
22
+
23
+ Railway: understand date, places, time limits, passengers and purchase intent →
24
+ query one station pair with exact, or plan uncertain places/routes with smart →
25
+ select a matching offer → create booking draft → obtain genuine human review
26
+ when required → refresh quote and hand over the official page → human pays →
27
+ check issuance. A comparison stops at the query result. A delegated purchase
28
+ continues until a required human step or the official handoff. Login and review
29
+ are pause points; a draft, payment entry, paid order and issued ticket are
30
+ different states.
31
+
32
+ | Stage | Command shape | What comes back |
33
+ | --- | --- | --- |
34
+ | Query | `itpay services run itpay-rail-exact --input-json <query-file> --json` or `itpay-rail-smart` | Query execution, effective request, recommendation, saved snapshot and bookable selection |
35
+ | Follow-up | `itpay services read-result <query-execution> --snapshot <snapshot> --json` | Full saved catalog; filter it for the new question before making another supplier query |
36
+ | Booking | `itpay services run itpay-rail-booking --input-json <booking-file> --json` | Separate booking execution, draft and current review requirement |
37
+ | Human review, if requested | `itpay services action <booking-execution> --action workflow:confirm_booking --actor-type human --status approved --input-json <review-file> --json` | Recorded confirmation and actual next step; approve only after real human consent, using the returned template |
38
+ | Continue, if requested | `itpay services run itpay-rail-booking --execution <booking-execution> --json` | Fresh quote and official page, or the next required action |
39
+ | After human payment | `itpay services next <booking-execution> --json` | Payment and issuance facts; report issuance only when confirmed |
40
+
41
+ Create the JSON files yourself. Exact query needs `origin`, `destination`,
42
+ `travel_date`; filter time limits against returned rows. Smart accepts those
43
+ fields plus actual constraints such as `arrive_before`, `priority`, and
44
+ `passengers`. Booking input uses the returned `selection.token`, selected
45
+ `seat_type`, and passenger count; never assemble legs from prose. Copy the
46
+ complete review template and revision from the current booking response.
47
+ For `booking_review_invalid`, re-read that same booking. If only a seat code
48
+ was written incorrectly and the confirmed train, actual seat class, passenger
49
+ count, price, and terms are unchanged, reuse the buyer's explicit approval.
50
+ Ask for confirmation if the draft materially changed or approval is missing.
51
+ Keep the query execution/snapshot for follow-ups, selection for booking, and
52
+ booking execution/order for review and payment. Do not substitute one ID for
53
+ another. `result` is the current fact, `instruction` its meaning, `next` the
54
+ current continuation, `handoff` the human entry, and `recovery` an exceptional
55
+ path. `next: null` can mean comparison complete or a human/template pause.
56
+
57
+ One exact comparison normally takes one query run. Chat review of a typical
58
+ booking targets query run, booking run, review action, and sometimes one
59
+ booking continuation before the official page; extra detail reads, login and
60
+ location ambiguity add calls. This is a guide, never a reason to skip consent.
61
+ You may test a few credible station-pair hypotheses with exact, reuse saved
62
+ results, continue under an existing delegation, and combine missing facts in
63
+ one question. Do not change date, relax a hard constraint, expand paid search
64
+ or pay without authorization.
65
+
16
66
  ## Route The Human's Intent
17
67
 
18
68
  | Human intent | First action |
19
69
  | --- | --- |
20
70
  | Create, sell or publish a service | `itpay sell guide --json`, then `itpay sell status --json` |
21
- | Discover services or make a new query | `itpay catalog list --json` |
71
+ | Discover an unknown service | `itpay catalog list --json` |
22
72
  | View previously purchased content | `itpay vault list --json` |
23
73
  | Find a previous result by subject | `itpay vault list --query <subject> --json` |
24
74
  | Inspect purchase history | `itpay orders --json` |
@@ -38,18 +88,60 @@ Three services, three different jobs — pick by the human's input, never merge
38
88
  | Human has | Service |
39
89
  | --- | --- |
40
90
  | Exact departure AND arrival station names | `itpay-rail-exact` (direct query) |
41
- | City/area/address, or wants transfer planning | `itpay-rail-smart` (location resolution + planning) |
91
+ | Station pair or route is uncertain after a few credible hypotheses, or needs broad transfer planning | `itpay-rail-smart` (location resolution + planning) |
42
92
  | Chose a train/seat and wants to buy | `itpay-rail-booking` (quote → protected checkout → issuance) |
43
93
 
94
+ ### Choose The Goal First
95
+
96
+ From the full context — negations, conditions, references, the latest
97
+ withdrawal — decide locally between two goals. Never use keyword lists,
98
+ regular expressions, or field-completeness as a classifier, and never ask the
99
+ human to name a mode. There is no `--mode` flag.
100
+
101
+ - `compare` — the human wants to see options and keeps the final choice.
102
+ Present one preferred option plus at most two meaningful alternatives, then
103
+ stop and wait. All fields being present does not authorize a purchase.
104
+ - `prepare_checkout` — the human named the product, or delegated selection
105
+ under explicit rules and asked for the purchase entry. Select a valid option
106
+ under those rules, then continue to the official confirmation/payment entry
107
+ without asking "要不要买" again. If the delegation is clear but one required
108
+ fact (e.g. the date) is missing, ask only for that fact — not whether to buy.
109
+
110
+ Default to `compare` when delegation is unclear. A pending, login, or error
111
+ state is never new user intent; withdrawal updates the goal immediately but
112
+ never rewrites a completed payment.
113
+
114
+ Explicit user rules outrank default recommendations: "13:00之后最早够两张二等座,
115
+ 没有就往后找" means same date, same station pair, seat-class + quantity filter,
116
+ departure-time order — not per-train re-queries, date changes, station swaps,
117
+ upgrades, waitlists, or endless retries. Missing facts are `unknown`, never
118
+ assumed satisfied. "08:00出门" includes ground transfer and station buffer;
119
+ "当天到" checks the calendar date, not just the clock time.
120
+
121
+ `itpay-rail-exact` is one station-pair + date query — filter the returned list
122
+ locally rather than re-querying per remembered train number. Model memory
123
+ supports route hypotheses only, never same-day schedule/price/inventory facts.
124
+ A saved snapshot's pages, journey detail and rerank are free reads; a new live
125
+ observation needs the owner's authorization.
126
+
127
+ Read the `rail-fast-checkout` topic only for a stage detail the current return
128
+ does not explain. Continue from the original execution and current return.
129
+
44
130
  Query results carry a server-issued `booking_offer.selection_token` on bookable
45
131
  options; for a purchase submit that token plus passenger count — never
46
132
  reconstruct train legs by hand. Passenger names, ID numbers and phone numbers
47
133
  belong only on the protected checkout page, never in chat. Each query service
48
- has its own free trial count (2+2, not a shared pool); `login_required` pauses
49
- the query, it is not a failure — resume the same execution after `itpay auth
50
- login`. For the full input contract and states, load the rail-booking topic via
134
+ has its own free trial count
135
+ (2+2, not a shared pool); `login_required` pauses the query, it is not a
136
+ failure — resume the same execution after `itpay auth login`. For the full
137
+ input contract and states, load the rail-booking topic via
51
138
  `itpay docs search rail-booking --json`.
52
139
 
140
+ At checkout, an official login page can be the normal entry to traveler
141
+ confirmation and then payment. Tell the human what the page currently asks
142
+ them to do; do not call a draft a reserved ticket or a payment link a paid
143
+ order. A seat preference may be requested but is not a seat guarantee.
144
+
53
145
  ## Follow One Envelope
54
146
 
55
147
  For each JSON response:
@@ -61,6 +153,18 @@ For each JSON response:
61
153
  and any required human action is complete.
62
154
  5. Use `recovery` only when the normal continuation cannot proceed.
63
155
 
156
+ Newer envelopes may also carry an `interaction` block (`stage`, `by_goal`,
157
+ `input_template`, `recipe`) and a `communication` block (`status_line`,
158
+ `recommended_reason`, `human_steps`, `next_expectation`, `must_convey`). These
159
+ are the same meaning in three languages: the schema for machines, `instruction`
160
+ for you, `communication` for what the human hears. They never disagree; if a
161
+ host renders only one lane, `instruction` still tells you what to do.
162
+
163
+ Two `input_template` details matter: entries whose `placeholders` field lists
164
+ unresolved values are NOT executable — fill them and submit via `--input-json
165
+ <file>`; and when `next` is `null`, the honest `input_template`/`recipe` path
166
+ in `interaction` is the continuation — do not invent a direct command.
167
+
64
168
  Never print raw envelopes, commands, internal IDs, error classes, or technical
65
169
  diagnostics to the human. Explain the service result and the next human choice
66
170
  in ordinary language. When a boundary is unclear, load one topic only: