@agenzo/merchant-cli 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -41,15 +41,6 @@ var CODE_NUM = {
41
41
  QUOTE_EXPIRED: 4202,
42
42
  BOOKING_FAILED: 4203,
43
43
  CANCELLATION_NOT_ALLOWED: 4204,
44
- PRICE_MISMATCH: 4205,
45
- VEHICLE_CLASS_MISMATCH: 4206,
46
- PAYMENT_METHOD_REQUIRED: 4207,
47
- QUOTE_CACHE_UNAVAILABLE: 4208,
48
- ARREARS_OUTSTANDING: 4209,
49
- CONTACT_REQUIRED: 4210,
50
- INVALID_PHONE: 4211,
51
- SEAT_LIMIT_EXCEEDED: 4213,
52
- RIDE_NOT_FOUND: 4212,
53
44
  NO_AVAILABILITY: 4301,
54
45
  PRICE_CHANGED: 4302,
55
46
  NAME_FORMAT_INVALID: 4303,
@@ -219,15 +210,6 @@ var STABLE_MESSAGE = {
219
210
  VEHICLE_UNAVAILABLE: "No vehicle is available for the requested trip. Please try a different time or class.",
220
211
  QUOTE_EXPIRED: "The quote has expired. Please request a new quote and retry.",
221
212
  BOOKING_FAILED: "The booking could not be completed. Please retry.",
222
- PRICE_MISMATCH: "The price does not match the quote. Re-quote and use the exact amount from the quote response.",
223
- VEHICLE_CLASS_MISMATCH: "The vehicle class does not match the quote. Use the vehicle class from the quote response.",
224
- PAYMENT_METHOD_REQUIRED: "Pay-per-call billing requires an active payment method. Please add a card first.",
225
- QUOTE_CACHE_UNAVAILABLE: "Quote cache is temporarily unavailable. Please request a new quote and retry.",
226
- ARREARS_OUTSTANDING: "You have outstanding arrears. Please settle your balance before booking a new ride.",
227
- CONTACT_REQUIRED: "Passenger contact information is required. Please provide a passenger name and phone number.",
228
- INVALID_PHONE: "The passenger phone number is not valid. Please provide a valid international number.",
229
- SEAT_LIMIT_EXCEEDED: "The number of child/infant/toddler seats exceeds the vehicle capacity. Reduce seats or choose a larger vehicle.",
230
- RIDE_NOT_FOUND: "The ride order was not found or does not belong to you.",
231
213
  CANCELLATION_NOT_ALLOWED: "This order cannot be cancelled in its current state.",
232
214
  NO_AVAILABILITY: "No rooms available for the selected hotel and dates.",
233
215
  PRICE_CHANGED: "The price changed since the quote. Re-quote and confirm.",
@@ -914,7 +896,9 @@ var quoteSchema = {
914
896
  "passenger-count": { type: "int", required: false, description: "Number of passengers" },
915
897
  "luggage-count": { type: "int", required: false, description: "Number of luggage items" },
916
898
  "passenger-email": { type: "string", required: false, description: "Passenger email address" },
917
- "children-count": { type: "int", required: false, description: "Number of children" }
899
+ "children-count": { type: "int", required: false, description: "Number of children" },
900
+ "infant-count": { type: "int", required: false, description: "Number of infants (passenger breakdown; affects seat pricing)" },
901
+ "toddler-count": { type: "int", required: false, description: "Number of toddlers (passenger breakdown; affects seat pricing)" }
918
902
  },
919
903
  response: {
920
904
  vehicle_classes: {
@@ -1308,7 +1292,7 @@ var hotelPayOrderSchema = {
1308
1292
  cli: CLI_NAME,
1309
1293
  noun: HOTEL_NOUN,
1310
1294
  verb: "pay-order",
1311
- description: 'Settle an existing AWAITING_PAYMENT order created by create-order. Takes only --order-id; the billing path is decided server-side by the order billing_mode. monthly_settlement deducts from the developer credit account then confirms with the supplier; pay_per_call verifies the user EVO payment \u2014 the EVO merchantTransID IS the order_id (the user pays via EVO under the order_id), so the platform queries EVO for that order_id and requires an exact amount/currency match before confirming (the response settlement_path is then "active_payment"). On success the order becomes PAID. Supports --watch to poll on PAYMENT_NOT_COMPLETED until PAID',
1295
+ description: 'Settle an existing AWAITING_PAYMENT order created by create-order. Takes only --order-id; the billing path is decided server-side by the order billing_mode. monthly_settlement deducts from the developer credit account then confirms with the supplier; pay_per_call verifies the user EVO payment \u2014 the EVO merchantTransID IS the order_id (the user pays via EVO under the order_id), so the platform queries EVO for that order_id and requires an exact amount/currency match before confirming (the response settlement_path is then "pay_per_call"). On success the order becomes PAID. Supports --watch to poll on PAYMENT_NOT_COMPLETED until PAID',
1312
1296
  flags: {
1313
1297
  "order-id": { type: "string", required: true, description: "Order to settle (create-order.response.order_id). For pay_per_call this is also the EVO merchantTransID the user paid under." },
1314
1298
  "idempotency-key": {
@@ -1323,7 +1307,7 @@ var hotelPayOrderSchema = {
1323
1307
  },
1324
1308
  response: {
1325
1309
  order_id: { type: "string", description: "Order reference." },
1326
- settlement_path: { type: "string", description: "Which billing path was used: 'monthly_settlement' or 'active_payment'." },
1310
+ settlement_path: { type: "string", description: "Which billing path was used: 'monthly_settlement' or 'pay_per_call' (same tokens as billing_mode)." },
1327
1311
  amount: { type: "float", description: "Settled amount in DECIMAL units." },
1328
1312
  currency: { type: "string", description: "ISO 4217 currency code of the settlement." },
1329
1313
  pay_status: { type: "int", description: "Upstream pay status (1 = paid). The order internal status is now PAID." },
@@ -1331,7 +1315,7 @@ var hotelPayOrderSchema = {
1331
1315
  },
1332
1316
  example: {
1333
1317
  command: "agenzo-merchant-cli hotel-redaug pay-order --order-id hho_01KWC63Z5CD6CKBM33Q7SC2ZDT --idempotency-key pay-h1n2",
1334
- output_summary: 'Settlement path is chosen server-side by billing_mode. monthly_settlement: deducts from the credit account, confirms with the supplier. Returns {order_id, settlement_path:"monthly_settlement", amount, currency, pay_status:1, settled_at}. Order becomes PAID. For pay_per_call the user must have already paid via EVO using the order_id as the merchantTransID; the same command settles it (settlement_path:"active_payment").'
1318
+ output_summary: 'Settlement path is chosen server-side by billing_mode. monthly_settlement: deducts from the credit account, confirms with the supplier. Returns {order_id, settlement_path:"monthly_settlement", amount, currency, pay_status:1, settled_at}. Order becomes PAID. For pay_per_call the user must have already paid via EVO using the order_id as the merchantTransID; the same command settles it (settlement_path:"pay_per_call").'
1335
1319
  },
1336
1320
  error_recovery: {
1337
1321
  PAYMENT_NOT_COMPLETED: "pay_per_call only: EVO has not yet confirmed the payment for this order_id. Retry with the SAME idempotency-key after a delay, or use --watch to poll automatically until PAID.",
@@ -2351,7 +2335,10 @@ function registerListOrdersCommand(parent, deps) {
2351
2335
  // src/services/registry.ts
2352
2336
  var SERVICE_REGISTRY = [
2353
2337
  {
2354
- service_id: "ride-elife",
2338
+ // service_id 是平台级不透明内部引用(svc_ 前缀 + ULID),不进 Agent 日常拼的命令
2339
+ // ——Agent 拼命令用的是 cli_noun="ride-elife"。与后端
2340
+ // services/merchant_service/discovery/catalog.py 的 RIDE_ELIFE_SERVICE_ID 保持一致。
2341
+ service_id: "svc_01KWTPBWDH5YZ52H717BFVWZA8",
2355
2342
  name: "Ride hailing (eLife)",
2356
2343
  description: "On-demand ride ordering: quote a fare, book it, poll status, and cancel.",
2357
2344
  category: "ride",
@@ -2368,7 +2355,9 @@ var SERVICE_REGISTRY = [
2368
2355
  },
2369
2356
  workflow: ["quote", "book", "get (poll for status)", "cancel (optional)"],
2370
2357
  since: "2026-06-01",
2371
- discovery: { help_command: "agenzo-merchant-cli ride-elife --help" }
2358
+ discovery: {
2359
+ help_command: "agenzo-merchant-cli ride-elife --help"
2360
+ }
2372
2361
  },
2373
2362
  {
2374
2363
  service_id: "svc_01J0HT5REDAUG0001",
@@ -2420,7 +2409,9 @@ var SERVICE_REGISTRY = [
2420
2409
  "cancel / checkout (optional)"
2421
2410
  ],
2422
2411
  since: "2026-06-25",
2423
- discovery: { help_command: "agenzo-merchant-cli hotel-redaug --help" }
2412
+ discovery: {
2413
+ help_command: "agenzo-merchant-cli hotel-redaug --help"
2414
+ }
2424
2415
  }
2425
2416
  ];
2426
2417
  function findService(serviceId) {
@@ -3362,10 +3353,29 @@ function formatGetOrder2(data) {
3362
3353
  if (data.check_in) lines.push(["Check-in", String(data.check_in)]);
3363
3354
  if (data.check_out) lines.push(["Check-out", String(data.check_out)]);
3364
3355
  if (data.total_amount !== void 0 && data.total_amount !== null) {
3365
- lines.push(["Total amount", String(data.total_amount)]);
3356
+ const currency = data.currency ? ` ${data.currency}` : "";
3357
+ lines.push(["Total amount", `${String(data.total_amount)}${currency}`]);
3358
+ }
3359
+ if (data.settlement_path) lines.push(["Settlement path", String(data.settlement_path)]);
3360
+ if (data.rooms && data.rooms.length > 0) {
3361
+ lines.push([
3362
+ "Rooms",
3363
+ data.rooms.map((r) => `${r.room_index}:${r.guest_name}`).join(", ")
3364
+ ]);
3365
+ }
3366
+ if (data.room_num !== void 0 && data.room_num !== null) {
3367
+ lines.push(["Rooms booked", String(data.room_num)]);
3366
3368
  }
3369
+ if (data.guest?.name) lines.push(["Guest", String(data.guest.name)]);
3370
+ if (data.contact?.name) {
3371
+ const phone2 = data.contact.phone ? ` (+${data.contact.country_code ?? ""} ${data.contact.phone})` : "";
3372
+ lines.push(["Contact", `${data.contact.name}${phone2}`]);
3373
+ }
3374
+ if (data.arrive_time) lines.push(["Arrive time", String(data.arrive_time)]);
3375
+ if (data.special_requests) lines.push(["Special requests", String(data.special_requests)]);
3367
3376
  if (data.channel_state) lines.push(["Channel state", String(data.channel_state)]);
3368
- if (data.source) lines.push(["Source", String(data.source)]);
3377
+ if (data.created_at) lines.push(["Created at", String(data.created_at)]);
3378
+ if (data.updated_at) lines.push(["Updated at", String(data.updated_at)]);
3369
3379
  return Formatter.keyValue(lines);
3370
3380
  }
3371
3381
  function registerHotelGetCommand(parent, deps) {
@@ -4134,7 +4144,7 @@ run \`hotel-redaug <verb> --help\`.
4134
4144
  - API key with merchant scope
4135
4145
  - Two billing modes supported (set on the developer, not chosen per-call):
4136
4146
  - **monthly_settlement**: developer has a settlement account with sufficient balance
4137
- - **pay_per_call**: developer collects payment from their end-user via EVO; the user pays using the create-order \`order_id\` as the EVO merchantTransID, and the platform verifies by querying EVO for that order_id (the pay-order response reports settlement_path "active_payment")
4147
+ - **pay_per_call**: developer collects payment from their end-user via EVO; the user pays using the create-order \`order_id\` as the EVO merchantTransID, and the platform verifies by querying EVO for that order_id (the pay-order response reports settlement_path "pay_per_call")
4138
4148
  - BILLING_MODE_MISMATCH means the order billing_mode is not one of the two modes above
4139
4149
  - Pass --api-key <key> --format json on every call; add --yes on writes
4140
4150
 
@@ -4179,32 +4189,40 @@ run \`hotel-redaug <verb> --help\`.
4179
4189
  - Generate a unique idempotency-key
4180
4190
  - Response \u2192 save order_id + fc_order_code + total_amount + currency
4181
4191
  - Order status: AWAITING_PAYMENT (no money charged yet)
4182
- - FOR pay_per_call: tell the user to pay total_amount+currency via EVO
4183
- USING THIS order_id as the EVO merchantTransID. The verification in step 6 works by
4184
- querying EVO for exactly this order_id, so paying under any other id will not settle.
4185
4192
 
4186
- 6. Pay order (settle the locked order) \u2014 MUST confirm with the user before calling this
4193
+ 6. BRANCH ON BILLING_MODE \u2014 decide THIS before calling pay-order, not inside it
4194
+ - You (the developer/Agent) know your own billing_mode; the order does not expose it.
4195
+ a) monthly_settlement \u2192 skip straight to step 7 (pay-order). Nothing to do here.
4196
+ b) pay_per_call \u2192 STOP. Do NOT call pay-order yet.
4197
+ - Drive YOUR OWN EVO payment integration now, using the order_id from step 5 AS THE
4198
+ EVO merchantTransID (this is the id you pass to your EVO payment call \u2014 not a new
4199
+ or random id).
4200
+ - Wait for the end-user to actually complete that EVO payment for total_amount+currency.
4201
+ - Only once EVO shows the payment as complete, proceed to step 7 \u2014 pay-order is what
4202
+ tells the platform "go verify and settle this", it does NOT itself collect payment.
4203
+
4204
+ 7. Pay order (settle the locked order) \u2014 MUST confirm with the user before calling this
4187
4205
  - Before calling: show the user total_amount + currency from create-order and which
4188
4206
  billing path applies, and get explicit go-ahead \u2014 pay-order is the step that actually
4189
- moves money
4207
+ moves money (for pay_per_call, confirm the EVO payment from step 6 was completed first)
4190
4208
  - pay-order --order-id <order_id from create-order> (that's the only identifier needed)
4191
4209
  - Billing path determined server-side by developer's billing_mode:
4192
4210
  a) monthly_settlement:
4193
4211
  - Platform deducts from settlement account \u2192 calls upstream payOrder
4194
4212
  b) pay_per_call:
4195
- - The user must have ALREADY paid via EVO using the order_id as the EVO
4196
- merchantTransID (see create-order step 5). Just call pay-order --order-id <id>;
4197
- the platform queries EVO for that order_id and verifies exact amount/currency.
4213
+ - Requires step 6 to have already happened (user paid via EVO under this order_id).
4214
+ Calling pay-order now just makes the platform query EVO for that order_id and
4215
+ verify exact amount/currency \u2014 it does NOT initiate the EVO payment itself.
4198
4216
  There is no merchant-transaction-id flag: the EVO key IS the order_id, so a
4199
4217
  foreign already-paid EVO transaction cannot be substituted.
4200
4218
  - If EVO not yet confirmed \u2192 PAYMENT_NOT_COMPLETED; use --watch to poll
4201
4219
  - On success \u2192 order status becomes PAID
4202
4220
 
4203
- 7. Confirm (upstream confirmation is async)
4221
+ 8. Confirm (upstream confirmation is async)
4204
4222
  - Poll get --order-id until CONFIRMED (success) or CANCELLED (failed)
4205
4223
  - Do not report success before CONFIRMED
4206
4224
 
4207
- 8. Post-booking (only when the user asks)
4225
+ 9. Post-booking (only when the user asks)
4208
4226
  - cancel: order_id + fc_order_code + reason
4209
4227
  - checkout: partial leave-early \u2192 then poll get-checkout with task_order_code
4210
4228
  - list-orders: view all orders
@@ -4215,8 +4233,9 @@ run \`hotel-redaug <verb> --help\`.
4215
4233
  - price_items : quote \u2192 create-order (JSON array; copy exactly)
4216
4234
  - order_id : create-order \u2192 pay-order / get / cancel
4217
4235
  - fc_order_code : create-order \u2192 cancel / checkout
4218
- - order_id (again): for pay_per_call it IS the EVO merchantTransID \u2014 the user pays via
4219
- EVO under the order_id; pay-order takes no separate merchant-transaction-id
4236
+ - order_id (again): for pay_per_call it IS the EVO merchantTransID \u2014 YOU (the developer/Agent)
4237
+ use it to drive your own EVO payment call BEFORE pay-order (see step 6); pay-order itself
4238
+ takes no separate merchant-transaction-id, it only verifies the payment already made
4220
4239
  - task_order_code : checkout \u2192 get-checkout
4221
4240
 
4222
4241
  ## Billing modes (chosen server-side by billing_mode)
@@ -4227,15 +4246,18 @@ routes purely by the order's billing_mode:
4227
4246
  | Developer billing_mode | Behavior |
4228
4247
  |------------------------|----------|
4229
4248
  | monthly_settlement | Deducts settlement balance \u2192 payOrder |
4230
- | pay_per_call | Platform queries EVO for the order_id \u2192 verify exact amount/currency \u2192 payOrder (response settlement_path is "active_payment") |
4249
+ | pay_per_call | Platform queries EVO for the order_id \u2192 verify exact amount/currency \u2192 payOrder (response settlement_path is "pay_per_call") |
4231
4250
  | anything else | ERROR: BILLING_MODE_MISMATCH (only the two modes above are valid) |
4232
4251
 
4233
4252
  ## pay_per_call flow \u2014 the EVO merchantTransID IS the order_id
4234
4253
 
4235
4254
  1. create-order returns order_id + total_amount + currency (no EVO credentials in response)
4236
- 2. User pays total_amount+currency via EVO, USING the order_id as the EVO merchantTransID
4237
- (the shared EVO parameters are onboarded separately, out of band)
4238
- 3. Agent calls pay-order --order-id <order_id> (no other identifier)
4255
+ 2. YOU drive your own EVO payment integration now, passing the order_id as the EVO
4256
+ merchantTransID, and get the user to pay total_amount+currency
4257
+ (the shared EVO parameters are onboarded separately, out of band \u2014 pay-order does not do
4258
+ this step for you)
4259
+ 3. ONLY once that EVO payment is complete, call pay-order --order-id <order_id>
4260
+ (no other identifier)
4239
4261
  4. Platform queries EVO for that order_id: paid + exact amount/currency match \u2192 payOrder \u2192 PAID
4240
4262
  5. If not yet paid \u2192 PAYMENT_NOT_COMPLETED; use --watch to auto-poll
4241
4263
  6. Why order_id (not an arbitrary id): it binds the payment to this exact order, so a caller
@@ -4252,7 +4274,7 @@ routes purely by the order's billing_mode:
4252
4274
  - IMPORTANT: --yes only skips this CLI's own interactive TTY prompt (needed because the Agent
4253
4275
  runs non-interactively). It is NOT a substitute for showing the user the hotel/rate/price and
4254
4276
  getting their decision in the chat UI. Passing --yes does not remove the confirmation steps in
4255
- step 3/4 (choose hotel + rate) or step 6 (confirm before pay-order) above.
4277
+ step 3/4 (choose hotel + rate) or step 7 (confirm before pay-order) above.
4256
4278
  - After a cancel call returns successfully (including the cancel_status='cancel_pending' shape),
4257
4279
  do NOT call cancel again for the same order \u2014 poll get instead. A pending acknowledgement is
4258
4280
  success, not failure.
@@ -4304,7 +4326,31 @@ async function main() {
4304
4326
  const flag = thisCommand.opts().format;
4305
4327
  process.env.AGENZO_FORMAT = resolveFormat(flag);
4306
4328
  });
4307
- const rideCmd = program.command("ride-elife").description("Ride ordering (eLife)");
4329
+ const rideCmd = program.command("ride-elife").description(
4330
+ `Ride ordering (eLife) \u2014 quote a fare, book it, poll status, and cancel.
4331
+
4332
+ Workflow (typical order):
4333
+ 1. quote Get fare quotes between two points \u2192 vehicle_classes[] each with a quote_id
4334
+ 2. book Book one vehicle_class using its quote_id \u2192 ride_id (write; needs --idempotency-key)
4335
+ 3. get Poll ride status by --order-id=<ride_id> until terminal (or use --watch for NDJSON)
4336
+ 4. cancel (optional) Cancel a ride by --order-id (write; may incur a fee)
4337
+ list-orders (standalone) List the developer's previous ride orders
4338
+
4339
+ Key notes:
4340
+ \u2022 Coordinates are NOT geocoded by the backend \u2014 supply --pickup-lat/lng and --dropoff-lat/lng.
4341
+ book must repeat the SAME pickup/dropoff coordinates+names and pickup-time used in quote;
4342
+ the quote_id does NOT carry them forward.
4343
+ \u2022 quote_id from quote is opaque and provider-specific \u2014 pass it unchanged to book, never reuse
4344
+ it across services.
4345
+ \u2022 vehicle_class values are case-sensitive literals (Sedan / SUV / MPV-5 / MPV-7 / Van / Luxury /
4346
+ Train) \u2014 pass back to book verbatim.
4347
+ \u2022 --pickup-time is UTC epoch seconds or the literal "now"; convert the user's local time to UTC.
4348
+ \u2022 All amounts are DECIMAL currency units (e.g. 42.50 = $42.50), never minor units (cents).
4349
+ \u2022 Billing mode is decided server-side: pay_per_call needs a PAID --payment-order-id (from
4350
+ payment-cli); monthly_settlement forbids it (settled against the developer's account).
4351
+ \u2022 Write verbs (book / cancel) require --idempotency-key; reuse the SAME key when retrying the
4352
+ same intent.`
4353
+ );
4308
4354
  registerQuoteCommand(rideCmd, deps);
4309
4355
  registerBookCommand(rideCmd, deps);
4310
4356
  registerRideGetCommand(rideCmd, deps);