@fortrip/agent-contract 3.4.0 → 4.0.0-rc.1

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/README.md CHANGED
@@ -8,7 +8,7 @@ apart.
8
8
 
9
9
  It has one peer dependency, `zod` (`^4.4.0`), and runs anywhere
10
10
  ES2023 does. Its major version changes when the contract breaks, not with
11
- the API: `3.x` serves Fortrip API v1.
11
+ the API: `4.x` serves Fortrip API v1.
12
12
 
13
13
  ```ts
14
14
  import { API, LIMITS, PUBLIC_ORIGINS, containsCardNumber } from "@fortrip/agent-contract";
package/dist/index.d.ts CHANGED
@@ -26,6 +26,12 @@ declare function containsCardNumber(text: string, minDigits?: number): boolean;
26
26
 
27
27
  /** An object that keeps fields it does not know. */
28
28
  declare function openObject<T extends z.ZodRawShape>(shape: T): z.ZodObject<T>;
29
+ /**
30
+ * An object another protocol defines (a UCP instrument's `config`), passed on
31
+ * as that protocol has it: any fields, any values. Its fields are not the
32
+ * contract's to close, so `strictOutput` keeps it as it is.
33
+ */
34
+ declare function protocolObject(): z.ZodType<Record<string, unknown>>;
29
35
  /** One of `values`, or any string. JSON Schema: `anyOf [enum, string]`. */
30
36
  declare function openEnum<const V extends readonly string[]>(values: V): z.ZodType<V[number] | (string & {})>;
31
37
  /**
@@ -47,8 +53,9 @@ declare function parseOpen<T>(schema: z.ZodType<T>, value: unknown): T;
47
53
  * no unknown enum values, no fallback union branch. Wrappers (optional,
48
54
  * nullable, default, readonly, pipe, lazy) and containers (object, array,
49
55
  * tuple, record) are rebuilt around their closed contents, keeping their
50
- * checks and metadata. A schema type it cannot close (any, unknown,
51
- * intersection, custom, ...) throws instead of silently staying open.
56
+ * checks and metadata. A protocol object stays as it is. A schema type it
57
+ * cannot close (any, unknown, intersection, custom, ...) throws instead of
58
+ * silently staying open.
52
59
  */
53
60
  declare function strictOutput<T extends z.ZodType>(schema: T): T;
54
61
 
@@ -82,12 +89,12 @@ declare const ORDER_NEXT_STEP = "Before you give the user an order's payment.url
82
89
  */
83
90
  declare const CANCEL_NEXT_STEP = "Before you call cancel_order, show the user the order's stay (hotel, dates), cancel.penalty and cancel.refund (amount and currency), then end your reply by asking them to confirm the cancellation, and wait for a clear yes. Pass maximumPenalty exactly as cancel.penalty.amount. Never state a refund the order did not return.";
84
91
  /**
85
- * How to pay without the link (3.4). It rides as the last paragraph of the
86
- * text of every MCP `book_hotel`, `get_order` and `list_orders` result that
87
- * holds an order with `payment.handlers`, after `ORDER_NEXT_STEP`, and in
92
+ * How to pay without the link. It rides as the last paragraph of the text
93
+ * of every MCP `book_hotel`, `get_order` and `list_orders` result that holds
94
+ * an order with non-empty `payment.handlers`, after `ORDER_NEXT_STEP`, and in
88
95
  * the description of `pay_order`; never as `nextStep`.
89
96
  */
90
- declare const PAY_NEXT_STEP = "To pay without the link, when the order has payment.handlers and the user's wallet can grant a Stripe shared payment token: first show and ask exactly as for payment.url, and wait for a clear yes. Then request the token for this order from the user's wallet with the handler's networkId and payment.credentialLimits (maxAmount in cents, currency, expiresAt), and call pay_order with it and the order's price.total. The charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once pay_order succeeds, payment.url stops working.";
97
+ declare const PAY_NEXT_STEP = "To pay without the link, when the order's payment.handlers isn't empty and the user's wallet can grant a Stripe shared payment token: first show and ask exactly as for payment.url, and wait for a clear yes. Then request the token for this order from the user's wallet with the handler's config.business_profile and payment.credentialLimits (maxAmount in cents, currency, expiresAt), and call pay_order with it and the order's price.total. The charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once pay_order succeeds, payment.url stops working.";
91
98
  /**
92
99
  * How to present hotels (the `presentation` guide, in one line). It rides as
93
100
  * the last paragraph of every MCP `search_hotels`, `get_hotel` and
@@ -242,25 +249,33 @@ declare const MCP_OUTPUT: {
242
249
  chargeCurrency: z.ZodString;
243
250
  localCurrencyAtCheckout: z.ZodBoolean;
244
251
  localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
245
- handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
252
+ handlers: z.ZodArray<z.ZodObject<{
246
253
  id: z.ZodString;
247
254
  type: z.ZodString;
248
255
  version: z.ZodString;
249
256
  spec: z.ZodString;
250
- networkId: z.ZodNullable<z.ZodString>;
251
- }, z.core.$strip>>>;
252
- credentialLimits: z.ZodOptional<z.ZodObject<{
257
+ schema: z.ZodString;
258
+ available_instruments: z.ZodArray<z.ZodObject<{
259
+ type: z.ZodString;
260
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
261
+ }, z.core.$strip>>;
262
+ config: z.ZodObject<{
263
+ environment: z.ZodType<(string & {}) | "livemode" | "testmode", unknown, z.core.$ZodTypeInternals<(string & {}) | "livemode" | "testmode", unknown>>;
264
+ business_profile: z.ZodString;
265
+ }, z.core.$strip>;
266
+ }, z.core.$strip>>;
267
+ credentialLimits: z.ZodNullable<z.ZodObject<{
253
268
  maxAmount: z.ZodNumber;
254
269
  currency: z.ZodString;
255
270
  expiresAt: z.ZodString;
256
271
  }, z.core.$strip>>;
257
272
  }, z.core.$strip>;
258
- cancel: z.ZodOptional<z.ZodObject<{
273
+ cancel: z.ZodObject<{
259
274
  available: z.ZodBoolean;
260
275
  reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
261
276
  penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
262
277
  refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
263
- }, z.core.$strip>>;
278
+ }, z.core.$strip>;
264
279
  manageUrl: z.ZodString;
265
280
  nextStep: z.ZodOptional<z.ZodString>;
266
281
  }, z.core.$strip>;
@@ -406,25 +421,33 @@ declare const MCP_OUTPUT: {
406
421
  chargeCurrency: z.ZodString;
407
422
  localCurrencyAtCheckout: z.ZodBoolean;
408
423
  localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
409
- handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
424
+ handlers: z.ZodArray<z.ZodObject<{
410
425
  id: z.ZodString;
411
426
  type: z.ZodString;
412
427
  version: z.ZodString;
413
428
  spec: z.ZodString;
414
- networkId: z.ZodNullable<z.ZodString>;
415
- }, z.core.$strip>>>;
416
- credentialLimits: z.ZodOptional<z.ZodObject<{
429
+ schema: z.ZodString;
430
+ available_instruments: z.ZodArray<z.ZodObject<{
431
+ type: z.ZodString;
432
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
433
+ }, z.core.$strip>>;
434
+ config: z.ZodObject<{
435
+ environment: z.ZodType<(string & {}) | "livemode" | "testmode", unknown, z.core.$ZodTypeInternals<(string & {}) | "livemode" | "testmode", unknown>>;
436
+ business_profile: z.ZodString;
437
+ }, z.core.$strip>;
438
+ }, z.core.$strip>>;
439
+ credentialLimits: z.ZodNullable<z.ZodObject<{
417
440
  maxAmount: z.ZodNumber;
418
441
  currency: z.ZodString;
419
442
  expiresAt: z.ZodString;
420
443
  }, z.core.$strip>>;
421
444
  }, z.core.$strip>;
422
- cancel: z.ZodOptional<z.ZodObject<{
445
+ cancel: z.ZodObject<{
423
446
  available: z.ZodBoolean;
424
447
  reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
425
448
  penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
426
449
  refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
427
- }, z.core.$strip>>;
450
+ }, z.core.$strip>;
428
451
  manageUrl: z.ZodString;
429
452
  nextStep: z.ZodOptional<z.ZodString>;
430
453
  }, z.core.$strip>;
@@ -571,25 +594,33 @@ declare const MCP_OUTPUT: {
571
594
  chargeCurrency: z.ZodString;
572
595
  localCurrencyAtCheckout: z.ZodBoolean;
573
596
  localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
574
- handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
597
+ handlers: z.ZodArray<z.ZodObject<{
575
598
  id: z.ZodString;
576
599
  type: z.ZodString;
577
600
  version: z.ZodString;
578
601
  spec: z.ZodString;
579
- networkId: z.ZodNullable<z.ZodString>;
580
- }, z.core.$strip>>>;
581
- credentialLimits: z.ZodOptional<z.ZodObject<{
602
+ schema: z.ZodString;
603
+ available_instruments: z.ZodArray<z.ZodObject<{
604
+ type: z.ZodString;
605
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
606
+ }, z.core.$strip>>;
607
+ config: z.ZodObject<{
608
+ environment: z.ZodType<(string & {}) | "livemode" | "testmode", unknown, z.core.$ZodTypeInternals<(string & {}) | "livemode" | "testmode", unknown>>;
609
+ business_profile: z.ZodString;
610
+ }, z.core.$strip>;
611
+ }, z.core.$strip>>;
612
+ credentialLimits: z.ZodNullable<z.ZodObject<{
582
613
  maxAmount: z.ZodNumber;
583
614
  currency: z.ZodString;
584
615
  expiresAt: z.ZodString;
585
616
  }, z.core.$strip>>;
586
617
  }, z.core.$strip>;
587
- cancel: z.ZodOptional<z.ZodObject<{
618
+ cancel: z.ZodObject<{
588
619
  available: z.ZodBoolean;
589
620
  reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
590
621
  penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
591
622
  refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
592
- }, z.core.$strip>>;
623
+ }, z.core.$strip>;
593
624
  manageUrl: z.ZodString;
594
625
  }, z.core.$strip>>;
595
626
  nextCursor: z.ZodNullable<z.ZodString>;
@@ -737,25 +768,33 @@ declare const MCP_OUTPUT: {
737
768
  chargeCurrency: z.ZodString;
738
769
  localCurrencyAtCheckout: z.ZodBoolean;
739
770
  localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
740
- handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
771
+ handlers: z.ZodArray<z.ZodObject<{
741
772
  id: z.ZodString;
742
773
  type: z.ZodString;
743
774
  version: z.ZodString;
744
775
  spec: z.ZodString;
745
- networkId: z.ZodNullable<z.ZodString>;
746
- }, z.core.$strip>>>;
747
- credentialLimits: z.ZodOptional<z.ZodObject<{
776
+ schema: z.ZodString;
777
+ available_instruments: z.ZodArray<z.ZodObject<{
778
+ type: z.ZodString;
779
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
780
+ }, z.core.$strip>>;
781
+ config: z.ZodObject<{
782
+ environment: z.ZodType<(string & {}) | "livemode" | "testmode", unknown, z.core.$ZodTypeInternals<(string & {}) | "livemode" | "testmode", unknown>>;
783
+ business_profile: z.ZodString;
784
+ }, z.core.$strip>;
785
+ }, z.core.$strip>>;
786
+ credentialLimits: z.ZodNullable<z.ZodObject<{
748
787
  maxAmount: z.ZodNumber;
749
788
  currency: z.ZodString;
750
789
  expiresAt: z.ZodString;
751
790
  }, z.core.$strip>>;
752
791
  }, z.core.$strip>;
753
- cancel: z.ZodOptional<z.ZodObject<{
792
+ cancel: z.ZodObject<{
754
793
  available: z.ZodBoolean;
755
794
  reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
756
795
  penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
757
796
  refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
758
- }, z.core.$strip>>;
797
+ }, z.core.$strip>;
759
798
  manageUrl: z.ZodString;
760
799
  }, z.core.$strip>;
761
800
  readonly pay_order: z.ZodObject<{
@@ -900,25 +939,33 @@ declare const MCP_OUTPUT: {
900
939
  chargeCurrency: z.ZodString;
901
940
  localCurrencyAtCheckout: z.ZodBoolean;
902
941
  localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
903
- handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
942
+ handlers: z.ZodArray<z.ZodObject<{
904
943
  id: z.ZodString;
905
944
  type: z.ZodString;
906
945
  version: z.ZodString;
907
946
  spec: z.ZodString;
908
- networkId: z.ZodNullable<z.ZodString>;
909
- }, z.core.$strip>>>;
910
- credentialLimits: z.ZodOptional<z.ZodObject<{
947
+ schema: z.ZodString;
948
+ available_instruments: z.ZodArray<z.ZodObject<{
949
+ type: z.ZodString;
950
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
951
+ }, z.core.$strip>>;
952
+ config: z.ZodObject<{
953
+ environment: z.ZodType<(string & {}) | "livemode" | "testmode", unknown, z.core.$ZodTypeInternals<(string & {}) | "livemode" | "testmode", unknown>>;
954
+ business_profile: z.ZodString;
955
+ }, z.core.$strip>;
956
+ }, z.core.$strip>>;
957
+ credentialLimits: z.ZodNullable<z.ZodObject<{
911
958
  maxAmount: z.ZodNumber;
912
959
  currency: z.ZodString;
913
960
  expiresAt: z.ZodString;
914
961
  }, z.core.$strip>>;
915
962
  }, z.core.$strip>;
916
- cancel: z.ZodOptional<z.ZodObject<{
963
+ cancel: z.ZodObject<{
917
964
  available: z.ZodBoolean;
918
965
  reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
919
966
  penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
920
967
  refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
921
- }, z.core.$strip>>;
968
+ }, z.core.$strip>;
922
969
  manageUrl: z.ZodString;
923
970
  }, z.core.$strip>;
924
971
  };
@@ -1353,14 +1400,33 @@ declare const cancelOrderInput: z.ZodObject<{
1353
1400
  type CancelOrderInput = z.input<typeof cancelOrderInput>;
1354
1401
  /** `POST /v1/orders/{orderId}/pay` and the MCP `pay_order` arguments: the
1355
1402
  * order, a Stripe shared payment token granted for it, and the total the
1356
- * user approved. A total other than the order's answers
1403
+ * user approved. The token is `sharedPaymentToken` or, as UCP's Complete
1404
+ * Checkout sends it, the credential of `payment`'s selected instrument:
1405
+ * exactly one of the two. A total other than the order's answers
1357
1406
  * `payment_total_changed` and charges nothing. */
1358
1407
  declare const payOrderInput: z.ZodObject<{
1359
1408
  orderId: z.ZodString;
1360
- sharedPaymentToken: z.ZodString;
1409
+ sharedPaymentToken: z.ZodOptional<z.ZodString>;
1410
+ payment: z.ZodOptional<z.ZodObject<{
1411
+ instruments: z.ZodArray<z.ZodObject<{
1412
+ id: z.ZodString;
1413
+ handler_id: z.ZodString;
1414
+ type: z.ZodString;
1415
+ selected: z.ZodOptional<z.ZodBoolean>;
1416
+ credential: z.ZodOptional<z.ZodObject<{
1417
+ type: z.ZodString;
1418
+ token: z.ZodOptional<z.ZodString>;
1419
+ }, z.core.$loose>>;
1420
+ display: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
1421
+ }, z.core.$loose>>;
1422
+ }, z.core.$strict>>;
1361
1423
  total: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
1362
1424
  }, z.core.$strict>;
1363
1425
  type PayOrderInput = z.input<typeof payOrderInput>;
1426
+ /** The shared payment token a `pay_order` call pays with: `sharedPaymentToken`,
1427
+ * or the credential of `payment`'s selected instrument. Takes what
1428
+ * `payOrderInput` parsed, which holds exactly one. */
1429
+ declare function sharedPaymentTokenOf(input: Pick<z.output<typeof payOrderInput>, "sharedPaymentToken" | "payment">): string;
1364
1430
 
1365
1431
  /** The ceilings and floors every agent surface enforces and documents (spec §15). */
1366
1432
  declare const LIMITS: {
@@ -1432,7 +1498,7 @@ declare const knownLocaleText: z.ZodObject<{
1432
1498
  locale: z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>;
1433
1499
  }, z.core.$strip>;
1434
1500
  /**
1435
- * A hotel photo on a first-party URL (3.1). `caption` is the catalogue's,
1501
+ * A hotel photo on a first-party URL. `caption` is the catalogue's,
1436
1502
  * with its locale; `null` without one.
1437
1503
  */
1438
1504
  declare const photo: z.ZodObject<{
@@ -1895,9 +1961,8 @@ declare const ERROR_DETAILS: {
1895
1961
  unassigned: z.ZodNumber;
1896
1962
  more: z.ZodNumber;
1897
1963
  }, z.core.$strip>;
1898
- /** The searched area's center, as a search echoes it; null for text only.
1899
- * Optional for clients; the server must send it (`SERVER_DETAILS`). */
1900
- center: z.ZodOptional<z.ZodNullable<z.ZodObject<{
1964
+ /** The searched area's center, as a search echoes it; null for text only. */
1965
+ center: z.ZodNullable<z.ZodObject<{
1901
1966
  location: z.ZodObject<{
1902
1967
  lat: z.ZodNumber;
1903
1968
  lng: z.ZodNumber;
@@ -1911,7 +1976,7 @@ declare const ERROR_DETAILS: {
1911
1976
  }, z.core.$strip>;
1912
1977
  }, z.core.$strip>>;
1913
1978
  basis: z.ZodType<"point" | (string & {}) | "seat" | "capital" | "busiest_settlement" | "hub", unknown, z.core.$ZodTypeInternals<"point" | (string & {}) | "seat" | "capital" | "busiest_settlement" | "hub", unknown>>;
1914
- }, z.core.$strip>>>;
1979
+ }, z.core.$strip>>;
1915
1980
  }, z.core.$strip>;
1916
1981
  stay_unsupported: z.ZodType<OpenUnionOutput<"reason", readonly [z.ZodObject<{
1917
1982
  reason: z.ZodLiteral<"mixed_occupancy">;
@@ -1952,7 +2017,7 @@ type ErrorBody<C extends ErrorCode> = {
1952
2017
  retryAfterSeconds?: number;
1953
2018
  requestId: string;
1954
2019
  } & (Details[C] extends z.ZodType ? {
1955
- details?: z.output<Details[C]>;
2020
+ details: z.output<Details[C]>;
1956
2021
  } : unknown);
1957
2022
  /** Any known code's error body; narrows by `code`. */
1958
2023
  type KnownErrorBody = {
@@ -1962,20 +2027,14 @@ type ErrorEnvelope = {
1962
2027
  error: KnownErrorBody | OpenFallback<"code">;
1963
2028
  };
1964
2029
  /**
1965
- * `{ error: { code, message, param?, retryable, retryAfterSeconds?, details?,
1966
- * requestId } }`, picked by `code`: a known code parses its own details, an
1967
- * unknown code falls back. `details` is optional here, for clients.
2030
+ * `{ error: { code, message, param?, retryable, retryAfterSeconds?, details,
2031
+ * requestId } }`, picked by `code`: a known code whose §11 row lists details
2032
+ * carries them, parsed as that code's; one whose row shows "–" has none. An
2033
+ * unknown code falls back.
1968
2034
  */
1969
2035
  declare const errorEnvelope: z.ZodType<ErrorEnvelope>;
1970
- /**
1971
- * Server tests only: the closed envelope, where a code whose §11 row lists
1972
- * details must carry them and a code whose row shows "–" must not.
1973
- */
1974
- declare function strictErrorEnvelope(): z.ZodType<{
1975
- error: KnownErrorBody;
1976
- }>;
1977
2036
 
1978
- /** 2.0's 14 policy topics in snake_case, plus `other`. */
2037
+ /** The 14 policy topics, in snake_case, plus `other`. */
1979
2038
  declare const POLICY_TOPICS: readonly ["check_in", "important_notices", "booking", "booking_tips", "check_in_out", "check_in_tips", "reception", "deposit", "meal", "extra_bed", "pets", "surroundings", "meetings", "non_smoking", "other"];
1980
2039
  type PolicyTopic = (typeof POLICY_TOPICS)[number];
1981
2040
  /** A room type's facts; shared with the offer's room. */
@@ -2025,14 +2084,14 @@ declare const hotel: z.ZodObject<{
2025
2084
  locale: z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>;
2026
2085
  }, z.core.$strip>>;
2027
2086
  /** Up to 8 hotel photos, the cover first; `null` when the catalogue lists
2028
- * none (unknown is not no). Absent from servers before 3.1. */
2029
- photos: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
2087
+ * none (unknown is not no). */
2088
+ photos: z.ZodNullable<z.ZodArray<z.ZodObject<{
2030
2089
  url: z.ZodString;
2031
2090
  caption: z.ZodNullable<z.ZodObject<{
2032
2091
  text: z.ZodString;
2033
2092
  locale: z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>;
2034
2093
  }, z.core.$strip>>;
2035
- }, z.core.$strip>>>>;
2094
+ }, z.core.$strip>>>;
2036
2095
  checkInTimes: z.ZodObject<{
2037
2096
  from: z.ZodNullable<z.ZodString>;
2038
2097
  until: z.ZodNullable<z.ZodString>;
@@ -2330,26 +2389,37 @@ declare const ORDER_STATUSES: readonly ["awaiting_payment", "expired", "confirmi
2330
2389
  type OrderStatus = (typeof ORDER_STATUSES)[number];
2331
2390
  declare const PAYMENT_STATUSES: readonly ["unpaid", "authorized", "paid", "released", "refund_pending", "refunded"];
2332
2391
  type PaymentStatus = (typeof PAYMENT_STATUSES)[number];
2333
- /** Why an order can or can't be cancelled now (3.3): `cancellable` when it
2392
+ /** Why an order can or can't be cancelled now: `cancellable` when it
2334
2393
  * can, else the first reason that holds. `non_refundable` is a rate the
2335
2394
  * hotel takes no cancellation for; `refused`, a cancellation the hotel
2336
2395
  * refused, the booking standing as it was. */
2337
2396
  declare const CANCEL_REASONS: readonly ["cancellable", "already_cancelled", "in_progress", "not_confirmed", "stay_started", "non_refundable", "refused", "terms_unknown", "needs_attention"];
2338
2397
  type CancelReason = (typeof CANCEL_REASONS)[number];
2339
- /** Why a shared payment token can't pay an order (3.4). */
2398
+ /** Why a shared payment token can't pay an order. */
2340
2399
  declare const CREDENTIAL_INVALID_REASONS: readonly ["not_found", "currency", "amount", "expired", "deactivated", "used", "other_seller"];
2341
2400
  type CredentialInvalidReason = (typeof CREDENTIAL_INVALID_REASONS)[number];
2342
- /** A way to pay an order other than its link, after the Universal Commerce
2343
- * Protocol's payment handlers: `type` names it (`com.stripe.payments`),
2344
- * `version` and `spec` the handler specification it follows, and
2345
- * `networkId` the seller's id a wallet grants a payment credential for
2346
- * (Stripe's business profile), null when the handler names none. */
2401
+ /** A way to pay an order other than its link: one of the Universal
2402
+ * Commerce Protocol's payment handlers, its fields named as UCP and Stripe
2403
+ * name them (snake case). `type` names it (`com.stripe.payments`, which
2404
+ * takes a Stripe shared payment token); `version`, `spec` and `schema` the
2405
+ * handler specification it follows; `available_instruments` the
2406
+ * instruments it takes; `config` its settings, whose `business_profile`
2407
+ * is the seller's id a wallet grants the token for (Stripe's business
2408
+ * profile). */
2347
2409
  declare const paymentHandler: z.ZodObject<{
2348
2410
  id: z.ZodString;
2349
2411
  type: z.ZodString;
2350
2412
  version: z.ZodString;
2351
2413
  spec: z.ZodString;
2352
- networkId: z.ZodNullable<z.ZodString>;
2414
+ schema: z.ZodString;
2415
+ available_instruments: z.ZodArray<z.ZodObject<{
2416
+ type: z.ZodString;
2417
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
2418
+ }, z.core.$strip>>;
2419
+ config: z.ZodObject<{
2420
+ environment: z.ZodType<(string & {}) | "livemode" | "testmode", unknown, z.core.$ZodTypeInternals<(string & {}) | "livemode" | "testmode", unknown>>;
2421
+ business_profile: z.ZodString;
2422
+ }, z.core.$strip>;
2353
2423
  }, z.core.$strip>;
2354
2424
  type PaymentHandler = z.infer<typeof paymentHandler>;
2355
2425
  /** `FT-` and six characters with no 0, 1, I or O. */
@@ -2497,20 +2567,28 @@ declare const order: z.ZodObject<{
2497
2567
  localCurrencyAtCheckout: z.ZodBoolean;
2498
2568
  localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
2499
2569
  /** The ways to pay other than `url`, while the order can be paid that
2500
- * way (3.4): a `com.stripe.payments` handler takes a shared payment
2501
- * token through `pay_order`. Absent when there is none. */
2502
- handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
2570
+ * way: a `com.stripe.payments` handler takes a shared payment token
2571
+ * through `pay_order`. Empty when there is none. */
2572
+ handlers: z.ZodArray<z.ZodObject<{
2503
2573
  id: z.ZodString;
2504
2574
  type: z.ZodString;
2505
2575
  version: z.ZodString;
2506
2576
  spec: z.ZodString;
2507
- networkId: z.ZodNullable<z.ZodString>;
2508
- }, z.core.$strip>>>;
2509
- /** What a payment credential for `pay_order` must allow, present with
2510
- * `handlers` (3.4): `maxAmount` in minor units (cents) of `currency`,
2577
+ schema: z.ZodString;
2578
+ available_instruments: z.ZodArray<z.ZodObject<{
2579
+ type: z.ZodString;
2580
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
2581
+ }, z.core.$strip>>;
2582
+ config: z.ZodObject<{
2583
+ environment: z.ZodType<(string & {}) | "livemode" | "testmode", unknown, z.core.$ZodTypeInternals<(string & {}) | "livemode" | "testmode", unknown>>;
2584
+ business_profile: z.ZodString;
2585
+ }, z.core.$strip>;
2586
+ }, z.core.$strip>>;
2587
+ /** What a payment credential for `pay_order` must allow, with
2588
+ * `handlers`: `maxAmount` in minor units (cents) of `currency`,
2511
2589
  * lowercase as Stripe takes it, and `expiresAt`, past which the order
2512
- * can't be paid. */
2513
- credentialLimits: z.ZodOptional<z.ZodObject<{
2590
+ * can't be paid. `null` when `handlers` is empty. */
2591
+ credentialLimits: z.ZodNullable<z.ZodObject<{
2514
2592
  maxAmount: z.ZodNumber;
2515
2593
  currency: z.ZodString;
2516
2594
  expiresAt: z.ZodString;
@@ -2518,14 +2596,13 @@ declare const order: z.ZodObject<{
2518
2596
  }, z.core.$strip>;
2519
2597
  /** Whether the user can cancel the order now and, when they can, its
2520
2598
  * penalty under the accepted terms (read a minute ahead) and the refund,
2521
- * what was paid less the penalty, both in the charge currency. Absent
2522
- * from servers before 3.3. */
2523
- cancel: z.ZodOptional<z.ZodObject<{
2599
+ * what was paid less the penalty, both in the charge currency. */
2600
+ cancel: z.ZodObject<{
2524
2601
  available: z.ZodBoolean;
2525
2602
  reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
2526
2603
  penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
2527
2604
  refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
2528
- }, z.core.$strip>>;
2605
+ }, z.core.$strip>;
2529
2606
  manageUrl: z.ZodString;
2530
2607
  }, z.core.$strip>;
2531
2608
  type Order = z.infer<typeof order>;
@@ -2674,20 +2751,28 @@ declare const orderList: z.ZodObject<{
2674
2751
  localCurrencyAtCheckout: z.ZodBoolean;
2675
2752
  localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
2676
2753
  /** The ways to pay other than `url`, while the order can be paid that
2677
- * way (3.4): a `com.stripe.payments` handler takes a shared payment
2678
- * token through `pay_order`. Absent when there is none. */
2679
- handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
2754
+ * way: a `com.stripe.payments` handler takes a shared payment token
2755
+ * through `pay_order`. Empty when there is none. */
2756
+ handlers: z.ZodArray<z.ZodObject<{
2680
2757
  id: z.ZodString;
2681
2758
  type: z.ZodString;
2682
2759
  version: z.ZodString;
2683
2760
  spec: z.ZodString;
2684
- networkId: z.ZodNullable<z.ZodString>;
2685
- }, z.core.$strip>>>;
2686
- /** What a payment credential for `pay_order` must allow, present with
2687
- * `handlers` (3.4): `maxAmount` in minor units (cents) of `currency`,
2761
+ schema: z.ZodString;
2762
+ available_instruments: z.ZodArray<z.ZodObject<{
2763
+ type: z.ZodString;
2764
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
2765
+ }, z.core.$strip>>;
2766
+ config: z.ZodObject<{
2767
+ environment: z.ZodType<(string & {}) | "livemode" | "testmode", unknown, z.core.$ZodTypeInternals<(string & {}) | "livemode" | "testmode", unknown>>;
2768
+ business_profile: z.ZodString;
2769
+ }, z.core.$strip>;
2770
+ }, z.core.$strip>>;
2771
+ /** What a payment credential for `pay_order` must allow, with
2772
+ * `handlers`: `maxAmount` in minor units (cents) of `currency`,
2688
2773
  * lowercase as Stripe takes it, and `expiresAt`, past which the order
2689
- * can't be paid. */
2690
- credentialLimits: z.ZodOptional<z.ZodObject<{
2774
+ * can't be paid. `null` when `handlers` is empty. */
2775
+ credentialLimits: z.ZodNullable<z.ZodObject<{
2691
2776
  maxAmount: z.ZodNumber;
2692
2777
  currency: z.ZodString;
2693
2778
  expiresAt: z.ZodString;
@@ -2695,14 +2780,13 @@ declare const orderList: z.ZodObject<{
2695
2780
  }, z.core.$strip>;
2696
2781
  /** Whether the user can cancel the order now and, when they can, its
2697
2782
  * penalty under the accepted terms (read a minute ahead) and the refund,
2698
- * what was paid less the penalty, both in the charge currency. Absent
2699
- * from servers before 3.3. */
2700
- cancel: z.ZodOptional<z.ZodObject<{
2783
+ * what was paid less the penalty, both in the charge currency. */
2784
+ cancel: z.ZodObject<{
2701
2785
  available: z.ZodBoolean;
2702
2786
  reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
2703
2787
  penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
2704
2788
  refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
2705
- }, z.core.$strip>>;
2789
+ }, z.core.$strip>;
2706
2790
  manageUrl: z.ZodString;
2707
2791
  }, z.core.$strip>>;
2708
2792
  nextCursor: z.ZodNullable<z.ZodString>;
@@ -3009,14 +3093,14 @@ declare const hotelSummary: z.ZodObject<{
3009
3093
  rateDate: z.ZodString;
3010
3094
  }, z.core.$strip>>;
3011
3095
  }, z.core.$strip>>;
3012
- /** The cover photo; `null` without one. Absent from servers before 3.1. */
3013
- photo: z.ZodOptional<z.ZodNullable<z.ZodObject<{
3096
+ /** The cover photo; `null` without one. */
3097
+ photo: z.ZodNullable<z.ZodObject<{
3014
3098
  url: z.ZodString;
3015
3099
  caption: z.ZodNullable<z.ZodObject<{
3016
3100
  text: z.ZodString;
3017
3101
  locale: z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>;
3018
3102
  }, z.core.$strip>>;
3019
- }, z.core.$strip>>>;
3103
+ }, z.core.$strip>>;
3020
3104
  }, z.core.$strip>;
3021
3105
  type HotelSummary = z.infer<typeof hotelSummary>;
3022
3106
  /** The top locality hubs of a scope (§7.6); also `search_too_broad` details. */
@@ -3279,14 +3363,14 @@ declare const searchResult: z.ZodObject<{
3279
3363
  rateDate: z.ZodString;
3280
3364
  }, z.core.$strip>>;
3281
3365
  }, z.core.$strip>>;
3282
- /** The cover photo; `null` without one. Absent from servers before 3.1. */
3283
- photo: z.ZodOptional<z.ZodNullable<z.ZodObject<{
3366
+ /** The cover photo; `null` without one. */
3367
+ photo: z.ZodNullable<z.ZodObject<{
3284
3368
  url: z.ZodString;
3285
3369
  caption: z.ZodNullable<z.ZodObject<{
3286
3370
  text: z.ZodString;
3287
3371
  locale: z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>;
3288
3372
  }, z.core.$strip>>;
3289
- }, z.core.$strip>>>;
3373
+ }, z.core.$strip>>;
3290
3374
  }, z.core.$strip>>;
3291
3375
  nextCursor: z.ZodNullable<z.ZodString>;
3292
3376
  notes: z.ZodArray<z.ZodObject<{
@@ -3331,10 +3415,9 @@ type RenderedTool = Exclude<ToolName, "get_planning_guide">;
3331
3415
  * as they came. A result that does not parse is shown as JSON, never thrown.
3332
3416
  * The consent rule (`ORDER_NEXT_STEP`) is the last paragraph whenever the
3333
3417
  * result holds a non-null `payment.url`; the pay rule (`PAY_NEXT_STEP`)
3334
- * follows it when a result holds an order with `payment.handlers`; the
3335
- * cancel rule (`CANCEL_NEXT_STEP`)
3336
- * follows it when a `get_order` or `list_orders` result holds an order with
3337
- * `cancel.available`.
3418
+ * follows it when a result holds an order with non-empty `payment.handlers`;
3419
+ * the cancel rule (`CANCEL_NEXT_STEP`) follows it when a `get_order` or
3420
+ * `list_orders` result holds an order with `cancel.available`.
3338
3421
  */
3339
3422
  declare function renderToolResult(tool: RenderedTool, data: unknown): string;
3340
3423
 
@@ -3354,4 +3437,4 @@ declare const UNKNOWN_IS_NOT_NO_EXEMPTIONS: Readonly<Record<string, string>>;
3354
3437
  /** The contract's version, from package.json, the one place a release bumps it. */
3355
3438
  declare const CONTRACT_VERSION: string;
3356
3439
 
3357
- export { AMENITY_CODES, API, type AmenityCode, type AuthConfig, CANCEL_NEXT_STEP, CANCEL_REASONS, CARD_NUMBER_MESSAGE, CENTER_BASES, COMMANDS, COMMAND_GROUPS, CONTRACT_VERSION, CREDENTIAL_INVALID_REASONS, type CancelOrderInput, type CancelReason, type Center, type CommandGroupSpec, type CommandSpec, type CreateOrderInput, type CredentialInvalidReason, DISPLAY_CURRENCIES, type Destination, ERROR_CODES, ERROR_DETAILS, type ErrorBody, type ErrorCode, type ErrorEnvelope, FILTERABLE_AMENITIES, type FilterableAmenity, type FlagSpec, GLOBAL_FLAGS, type GetHotelInput, type GetOrderInput, type GuideSurface, type GuideTopic, type Hotel, type HotelOffersInput, type HotelOffersResult, type HotelSummary, type IndicativePrice, type KnownErrorBody, LIMITS, type ListOrdersInput, MCP_OUTPUT, MCP_PATH, type MeResult, type Money, ORDER_NEXT_STEP, ORDER_STATUSES, type Offer, type OfferChange, type Omitted, type OptionSpec, type Order, type OrderList, type OrderStatus, PAYMENT_STATUSES, PAY_NEXT_STEP, PLACE_KINDS, POLICY_TOPICS, PRESENTATION_HINT, PUBLIC_ORIGINS, type PayOrderInput, type PaymentHandler, type PaymentStatus, type Place, type PlaceRef, type PolicyTopic, type PositionalSpec, type RenderedTool, SEARCH_NOTE_CODES, SEARCH_SORTS, SUPPORT_EMAIL, type SearchHotelsInput, type SearchNoteCode, type SearchResult, type Stay, TOOLS, type ToolName, type ToolSpec, UNAVAILABLE_REASONS, UNKNOWN_IS_NOT_NO_EXEMPTIONS, addIsoDateDays, authConfig, cancelOrderInput, cancellation, center, commandInvocation, confirmation, containsCardNumber, countIsoDateDays, createOrderInput, createSearchHotelsInput, destination, errorEnvelope, flag, formatMoney, getHotelInput, getOrderInput, hotel, hotelId, hotelOffersInput, hotelOffersResult, hotelSummary, indicativePrice, instant, isIsoDate, knownLocaleText, latLng, listOrdersInput, localDate, localTime, localities, localizedText, meResult, meals, money, names, nonEmpty, offer, offerChange, offerId, omitted, oneOf, openEnum, openObject, openUnion, order, orderId, orderList, orderReference, parseOpen, payAtProperty, payOrderInput, paymentHandler, photo, place, placeId, placeRef, renderError, renderGuide, renderToolResult, roomFacts, searchHotelsInput, searchResult, stay, stayEcho, strictErrorEnvelope, strictInput, strictOutput, text, timeZone, usdMoney, wholeNumber };
3440
+ export { AMENITY_CODES, API, type AmenityCode, type AuthConfig, CANCEL_NEXT_STEP, CANCEL_REASONS, CARD_NUMBER_MESSAGE, CENTER_BASES, COMMANDS, COMMAND_GROUPS, CONTRACT_VERSION, CREDENTIAL_INVALID_REASONS, type CancelOrderInput, type CancelReason, type Center, type CommandGroupSpec, type CommandSpec, type CreateOrderInput, type CredentialInvalidReason, DISPLAY_CURRENCIES, type Destination, ERROR_CODES, ERROR_DETAILS, type ErrorBody, type ErrorCode, type ErrorEnvelope, FILTERABLE_AMENITIES, type FilterableAmenity, type FlagSpec, GLOBAL_FLAGS, type GetHotelInput, type GetOrderInput, type GuideSurface, type GuideTopic, type Hotel, type HotelOffersInput, type HotelOffersResult, type HotelSummary, type IndicativePrice, type KnownErrorBody, LIMITS, type ListOrdersInput, MCP_OUTPUT, MCP_PATH, type MeResult, type Money, ORDER_NEXT_STEP, ORDER_STATUSES, type Offer, type OfferChange, type Omitted, type OptionSpec, type Order, type OrderList, type OrderStatus, PAYMENT_STATUSES, PAY_NEXT_STEP, PLACE_KINDS, POLICY_TOPICS, PRESENTATION_HINT, PUBLIC_ORIGINS, type PayOrderInput, type PaymentHandler, type PaymentStatus, type Place, type PlaceRef, type PolicyTopic, type PositionalSpec, type RenderedTool, SEARCH_NOTE_CODES, SEARCH_SORTS, SUPPORT_EMAIL, type SearchHotelsInput, type SearchNoteCode, type SearchResult, type Stay, TOOLS, type ToolName, type ToolSpec, UNAVAILABLE_REASONS, UNKNOWN_IS_NOT_NO_EXEMPTIONS, addIsoDateDays, authConfig, cancelOrderInput, cancellation, center, commandInvocation, confirmation, containsCardNumber, countIsoDateDays, createOrderInput, createSearchHotelsInput, destination, errorEnvelope, flag, formatMoney, getHotelInput, getOrderInput, hotel, hotelId, hotelOffersInput, hotelOffersResult, hotelSummary, indicativePrice, instant, isIsoDate, knownLocaleText, latLng, listOrdersInput, localDate, localTime, localities, localizedText, meResult, meals, money, names, nonEmpty, offer, offerChange, offerId, omitted, oneOf, openEnum, openObject, openUnion, order, orderId, orderList, orderReference, parseOpen, payAtProperty, payOrderInput, paymentHandler, photo, place, placeId, placeRef, protocolObject, renderError, renderGuide, renderToolResult, roomFacts, searchHotelsInput, searchResult, sharedPaymentTokenOf, stay, stayEcho, strictInput, strictOutput, text, timeZone, usdMoney, wholeNumber };
package/dist/index.js CHANGED
@@ -569,16 +569,126 @@ var cancelOrderInput = strictInput({
569
569
  "The penalty the user agreed to: cancel.penalty.amount of the order, in its currency."
570
570
  )
571
571
  });
572
+ var sharedPaymentTokenRe = /^spt_[A-Za-z0-9]{1,250}$/;
572
573
  var sharedPaymentTokenError = "sharedPaymentToken must be a Stripe shared payment token: spt_ followed by letters and digits";
574
+ var instrumentTokenError = "credential.token must be a Stripe shared payment token: spt_ followed by letters and digits";
575
+ var instrumentsError = "payment.instruments must be a list of 1 to 8 instruments";
576
+ var instrumentCardError = "payment.instruments must not hold card details: pay with the shared payment token alone";
577
+ var ucpInstrument = z5.looseObject(
578
+ {
579
+ id: nonEmpty("id").describe("The instrument's id, as the agent's UCP client names it."),
580
+ handler_id: nonEmpty("handler_id").describe(
581
+ "The id of the handler the instrument pays through: the order's stripe_payments for the selected one."
582
+ ),
583
+ type: nonEmpty("type").describe("The instrument type: card for the selected one."),
584
+ selected: flag("selected").optional().describe(
585
+ "Whether this is the instrument to pay with. Exactly one is selected; a lone instrument without it is the one."
586
+ ),
587
+ credential: z5.looseObject(
588
+ {
589
+ type: nonEmpty("credential.type").describe(
590
+ "The credential type: stripe_payment_token for the selected one."
591
+ ),
592
+ token: z5.string({ error: instrumentTokenError }).optional().describe(
593
+ "The shared payment token (spt_\u2026) the user approved for this order, requested with the order's payment.credentialLimits."
594
+ )
595
+ },
596
+ { error: "credential must be a JSON object" }
597
+ ).optional().describe("The instrument's credential: for the selected one, the shared payment token."),
598
+ display: z5.looseObject({}, { error: "display must be a JSON object" }).optional().describe("How the wallet shows the instrument, as UCP has it. Not used to pay.")
599
+ },
600
+ { error: "Each instrument must be a JSON object" }
601
+ ).describe("A UCP payment instrument.");
602
+ var selectedCard = z5.looseObject({
603
+ handler_id: z5.literal("stripe_payments", {
604
+ error: "The selected instrument's handler_id must be stripe_payments"
605
+ }),
606
+ type: z5.literal("card", { error: "The selected instrument's type must be card" }),
607
+ credential: z5.looseObject(
608
+ {
609
+ type: z5.literal("stripe_payment_token", {
610
+ error: "The selected instrument's credential.type must be stripe_payment_token"
611
+ }),
612
+ token: z5.string({ error: instrumentTokenError }).regex(sharedPaymentTokenRe, { error: instrumentTokenError })
613
+ },
614
+ { error: "The selected instrument needs a credential: its shared payment token" }
615
+ )
616
+ });
617
+ function selectedOf(instruments) {
618
+ const chosen = instruments.flatMap((i, at) => i?.selected === true ? [{ i, at }] : []);
619
+ const lone = instruments[0];
620
+ if (chosen.length === 0 && instruments.length === 1 && lone && lone.selected === void 0) {
621
+ return [{ i: lone, at: 0 }];
622
+ }
623
+ return chosen;
624
+ }
573
625
  var payOrderInput = strictInput({
574
626
  orderId: orderId.describe("orderId of the order to pay, from create order or get order."),
575
- sharedPaymentToken: z5.string({ error: sharedPaymentTokenError }).regex(/^spt_[A-Za-z0-9]{1,250}$/, { error: sharedPaymentTokenError }).describe(
576
- "The shared payment token (spt_\u2026) the user approved for this order, requested with the order's payment.credentialLimits."
627
+ sharedPaymentToken: z5.string({ error: sharedPaymentTokenError }).regex(sharedPaymentTokenRe, { error: sharedPaymentTokenError }).optional().describe(
628
+ "The shared payment token (spt_\u2026) the user approved for this order, requested with the order's payment.credentialLimits. Exactly one of sharedPaymentToken and payment."
629
+ ),
630
+ payment: strictInput({
631
+ instruments: z5.array(ucpInstrument, { error: instrumentsError }).min(1, { error: instrumentsError }).max(8, { error: instrumentsError }).describe("The instruments, exactly one of them selected.")
632
+ }).superRefine((payment, ctx) => {
633
+ if (payment.instruments.length < 1 || payment.instruments.length > 8) return;
634
+ const phones = [];
635
+ const rest = JSON.stringify(payment.instruments, (key, value) => {
636
+ if (key !== "phone_number") return value;
637
+ phones.push(value);
638
+ return void 0;
639
+ });
640
+ if (containsCardNumber(rest) || containsCardNumber(JSON.stringify(phones), 16)) {
641
+ ctx.addIssue({ code: "custom", path: ["instruments"], message: instrumentCardError });
642
+ return;
643
+ }
644
+ const chosen = selectedOf(payment.instruments);
645
+ const [only] = chosen;
646
+ if (chosen.length !== 1 || !only) {
647
+ ctx.addIssue({
648
+ code: "custom",
649
+ path: ["instruments"],
650
+ message: `payment.instruments must have exactly one instrument with selected: true, not ${chosen.length}`
651
+ });
652
+ return;
653
+ }
654
+ if (!ucpInstrument.safeParse(only.i).success) return;
655
+ const card = selectedCard.safeParse(only.i);
656
+ for (const issue of card.success ? [] : card.error.issues) {
657
+ ctx.addIssue({
658
+ code: "custom",
659
+ path: ["instruments", only.at, ...issue.path],
660
+ message: issue.message
661
+ });
662
+ }
663
+ }).optional().describe(
664
+ "UCP's Complete Checkout payment, in place of sharedPaymentToken: the token as the stripe_payment_token credential of the one selected stripe_payments card instrument. Exactly one of sharedPaymentToken and payment."
577
665
  ),
578
666
  total: usdMoney.describe(
579
667
  "The total the user approved: the order's price.total, exactly as returned."
580
668
  )
669
+ }).superRefine((input, ctx) => {
670
+ if (input.sharedPaymentToken !== void 0 && input.payment !== void 0) {
671
+ ctx.addIssue({
672
+ code: "custom",
673
+ path: ["payment"],
674
+ message: "Send sharedPaymentToken or payment, not both"
675
+ });
676
+ } else if (input.sharedPaymentToken === void 0 && input.payment === void 0) {
677
+ ctx.addIssue({
678
+ code: "custom",
679
+ path: ["sharedPaymentToken"],
680
+ message: sharedPaymentTokenError
681
+ });
682
+ }
581
683
  });
684
+ function sharedPaymentTokenOf(input) {
685
+ const chosen = input.payment ? selectedOf(input.payment.instruments) : [];
686
+ const token = input.sharedPaymentToken ?? (chosen.length === 1 ? chosen[0]?.i.credential?.token : void 0);
687
+ if (token === void 0) {
688
+ throw new Error("sharedPaymentTokenOf: no token; parse with payOrderInput first");
689
+ }
690
+ return token;
691
+ }
582
692
 
583
693
  // src/commands.ts
584
694
  function fieldDescription(json, field, sets = {}) {
@@ -997,6 +1107,11 @@ function mark(schema, kind2) {
997
1107
  function openObject(shape) {
998
1108
  return z7.looseObject(shape);
999
1109
  }
1110
+ function protocolObject() {
1111
+ const schema = z7.record(z7.string(), z7.unknown());
1112
+ mark(schema, "protocol");
1113
+ return schema;
1114
+ }
1000
1115
  function openEnum(values) {
1001
1116
  const schema = z7.union([
1002
1117
  z7.enum(values),
@@ -1060,6 +1175,7 @@ function strictify(schema) {
1060
1175
  delete next[OPEN];
1061
1176
  return schema.clone(next);
1062
1177
  };
1178
+ if (kind2 === "protocol") return schema;
1063
1179
  if (kind2 === "enum") return strictify(def.options[0]);
1064
1180
  if (kind2 === "union") {
1065
1181
  return rebuild({ options: def.options.slice(0, -1).map(strictify) });
@@ -1107,7 +1223,7 @@ var FRAGMENTS = {
1107
1223
  "meals": '{{#if claude-skill cli}}\n## Presenting an offer\n\nGive the user, for each offer:\n\n- the room (`room.name`, beds, size) and the total, as above;\n- the meals: `meals.included` (breakfast, lunch, dinner) or `allInclusive`, with `guestsCoveredPerRoom`. Fewer than the guests per room means not everyone gets the meals (breakfast for 1 with 2 adults in the room): say who is covered. `unspecifiedMainMeals` counts main meals the hotel didn\'t name. With `known: false`, the meals are unknown: say so, and don\'t call it room only;\n- cancellation: `status` (`free`, `partial_penalty`, `non_refundable` or `unknown`), `freeCancellationEndsAt` (null with `free`: free until check-in) and the `penalties`. Times are in UTC: also give them in the hotel\'s `timeZone`;\n- confirmation: `mode` `instant` or `on_request` (within `withinMinutes`);\n- fees payable at the property (`payAtProperty.items`), in the property\'s currency. `disclosure: "incomplete"` means there can be fees not listed: say so.\n\nAn offer expires at `expiresAt`, about 30 minutes after it was made; after that, get offers again.\n\n"Not listed" is not "no": `listed: false` (amenities, policies, rooms), `null` and `unknown` mean the source didn\'t say. Tell the user it\'s unknown instead of turning it into "no".\n{{/if}}\n{{#if mcp}}\n- "Not listed" or "unknown" is not "no".\n{{/if}}\n',
1108
1224
  "occupancy": "{{#if claude-skill cli}}\n## Rooms and guests\n\n- {{#if mcp claude-skill}}`stay.rooms` lists each room's party as `{ adults, childrenAges }`: two rooms of 2 adults, one with a child of 6, is `[{ adults: 2, childrenAges: [6] }, { adults: 2, childrenAges: [] }]`{{/if}}{{#if cli}}`--room <adults[:age,\u2026]>`, once per room, gives each room's party: two rooms of 2 adults, one with a child of 6, is `--room 2:6 --room 2`{{/if}}.\n- Ask each child's age; offers need it.\n- If the party doesn't split evenly across the rooms (3 adults in 2 rooms), ask the user how it splits.\n{{/if}}\n- Offers and orders take one party per call, every room the same: for different parties, order once per party.{{#if claude-skill cli}} `{{tool:hotels offers}}` answers `stay_unsupported` (`mixed_occupancy`) for mixed rooms; `{{tool:hotels search}}` accepts them but prices only from the dates, with the note `party_split_required`.{{/if}}\n{{#if claude-skill cli}}\n- Limits: 1\u2013{{limit:rooms}} rooms, 1\u2013{{limit:adultsPerRoom}} adults and 0\u2013{{limit:childrenPerRoom}} children (aged 0\u2013{{limit:childAgeMax}}) per room, 1\u2013{{limit:nightsSupplier}} nights, up to {{limit:offersHotels}} hotels per `{{tool:hotels offers}}` call. A longer stay answers `stay_unsupported` (`max_nights`): ask the user whether to split it into consecutive stays, each its own order.\n{{/if}}\n",
1109
1225
  "order": '{{#if claude-skill cli}}\n## Workflow\n\n1. **Search** with `{{tool:hotels search}}` for candidate hotels: a destination, `{{arg:text}}` or both, and the stay\'s dates and rooms for indicative prices.\n{{#if cli}}\n\n ```bash\n {{tool:hotels search}} --place-name Bangkok --country TH --check-in 2026-11-10 \\\n --check-out 2026-11-12 --room 2 --stars-min 4 --sort price_asc --limit 10\n ```\n\n{{/if}}\n2. **Details** (optional) with `{{tool:hotels get}}`, when the user asks about a hotel or a stated preference needs evidence (a pool, a policy, room size). For a details-only question, call it directly when you know the hotel\'s `hotelId`; otherwise find the hotel with `{{tool:hotels search}}`.\n{{#if cli}}\n\n ```bash\n {{tool:hotels get}} <hotelId> [--rooms]\n ```\n\n{{/if}}\n3. **Offers** with `{{tool:hotels offers}}` for a few shortlisted hotels, with the dates and rooms the user will order. It takes about 15 seconds. A hotel is available only once this returns an offer for it.\n{{#if cli}}\n\n ```bash\n {{tool:hotels offers}} --hotel <hotelId> --hotel <hotelId> --check-in 2026-11-10 \\\n --check-out 2026-11-12 --room 2 --room 2 [--require-free-cancellation]\n ```\n\n{{/if}}\n4. **Order** with `{{tool:hotels book}}`, once the user has picked one offer and given the guests and the contact (see Ordering).\n{{#if cli}}\n\n ```bash\n {{tool:hotels book}} --offer <offerId> --guest 1:John:Smith --guest 2:Mary:Smith \\\n --first-name John --last-name Smith --email john@example.com \\\n --phone "+8613800000000"\n ```\n\n{{/if}}\n5. **Confirm, then give the payment link**, as in "Before giving the payment link" below.\n6. **After payment**, check the order with `{{tool:orders get}}` (see After payment).\n\n## Search\n\n### Where\n\n- **A place by name:** {{#if mcp claude-skill}}`{ kind: "place_name", name, countryCode }`{{/if}}{{#if cli}}`--place-name <name> --country <CC>`{{/if}}, in any language (Kyoto or \u4EAC\u90FD). The country is required: ask the user when it isn\'t clear. Names match exactly, ignoring only case and spacing: accents, hyphens, apostrophes and periods count ("K\xF6ln" or "Cologne", not "Koln"; "St. Moritz", not "St Moritz").\n- If several places bear the name, the answer is `destination_ambiguous` with up to {{limit:candidatesShown}} candidates and their hotel counts: ask the user which one they mean, then search it by its `placeId`; never pick one yourself.\n- `destination_not_found` with `no_match` means no place of that name in that country: check the spelling and accents, or try another name for the place. Its `nameAsText` counts the hotels that a `{{arg:text}}` search for the name would find.\n- **A place from an earlier answer:** {{#if mcp claude-skill}}`{ kind: "place", placeId }`{{/if}}{{#if cli}}`--place <placeId>`{{/if}}.\n- **Near a point:** {{#if mcp claude-skill}}`{ kind: "point", location: { lat, lng } }`{{/if}}{{#if cli}}`--point <lat,lng>`{{/if}}, for "near X" when you know where X is.\n- **A whole country:** {{#if mcp claude-skill}}`{ kind: "country", countryCode }`{{/if}}{{#if cli}}`--country-only <CC>`{{/if}}, as for the Maldives.\n- Countries, regions (states, provinces), prefecture-level cities in China and main islands cover their whole area. Towns, neighbourhoods, districts, small islands and points cover a circle of {{limit:radiusMetersDefault}} meters; `{{arg:destination.radiusMeters}}` sets another, up to {{limit:radiusMetersMax}} meters, and narrows an area to a circle around its center.\n- **Localities:** an area search lists its `localities`, the towns its hotels belong to, each with a `placeId`, its hotel `count` and the places it `includes` (Patong is part of Phuket). To search one, pass it as {{#if mcp claude-skill}}`{ kind: "locality", placeId }`{{/if}}{{#if cli}}`--locality <placeId>`{{/if}}. A town that isn\'t a locality answers `destination_not_found` with `not_a_locality` and the `hub` it belongs to: search the hub, or the town itself with {{#if mcp claude-skill}}`kind: "place"`{{/if}}{{#if cli}}`--place`{{/if}} for a circle around it.\n- A price sort or price filter over more than {{limit:poolLimit}} hotels (in an area, or for text alone) answers `search_too_broad` with `matched` and the top `localities`: show them and ask the user which they prefer, unless the request already names one of them; search that one by its `placeId` as a locality, never by its name.\n\n### Text\n\n`{{arg:text}}` matches exact words in hotel names and addresses, in Chinese or English:\n\n- Every word must match as written: plurals, accents, spacing and abbreviations count ("hostel" and "hostels", "St Regis" and "Saint Regis" find different hotels). Hyphens and apostrophes don\'t (Ritz-Carlton finds Ritz Carlton).\n- In Chinese, matching follows word segmentation, so part of a name can match unrelated hotels (\u5E0C\u5C14 is not \u5E0C\u5C14\u987F).\n- Use only distinctive words: a hotel or brand name, a district or a landmark. Not "hotel", "near", "cheap" or "best".\n- Typos return nothing: "Shangahi" finds no hotel.\n- Place names belong in the destination: "Maldives" as text finds a hotel named Maldives in China.\n\n### Filters\n\n- Stars run from 1 to 5 in half steps{{#if mcp claude-skill}} (`filters.stars`){{/if}}. "4 stars" as {{#if mcp claude-skill}}`{ min: 4, max: 4 }`{{/if}}{{#if cli}}`--stars-min 4 --stars-max 4`{{/if}} leaves out 4.5: unless the user means exactly 4, use {{#if mcp claude-skill}}`{ min: 4 }`{{/if}}{{#if cli}}`--stars-min 4`{{/if}} or ask. Unrated hotels are left out whenever stars are filtered.\n- `{{arg:filters.amenities}}` takes only the amenities that can filter (such as pool, parking, wifi); others, such as gym or spa, show in `{{tool:hotels get}}` but can\'t filter. A hotel matches only when it lists the amenity, and about half the hotels list no amenities at all (`coverage.excludedNoFacilityData` counts those left out): "not listed" is not "absent".\n- `{{arg:filters.price.maxPerRoomNight}}` bounds the indicative price per room per night, in USD; hotels without one are left out and counted.\n\n### Results\n\n- `notes` explain the answer (a limited pool, a circle around an island, more hotels just outside it): pass on what matters to the user.\n- `coverage` has the counts: `matched` hotels, how many were priced and how many have a price.\n- A next page is {{#if mcp claude-skill}}`cursor` set to `nextCursor` and, optionally, `limit`{{/if}}{{#if cli}}`--cursor <nextCursor>` and, optionally, `--limit`{{/if}}; nothing else.\n{{/if}}\n{{#if mcp}}\n- A place name needs its `countryCode` (ask the user if unclear) and matches exactly (accents and periods count). On `destination_ambiguous`, ask the user which they mean, then search its `placeId`; never pick one yourself.\n- On `search_too_broad`, show its `localities` and ask the user which, unless they already named one; search it as `{ kind: "locality", placeId }`, never by name.\n- `text` matches whole words of hotel names and addresses: use a distinctive name, brand or landmark. A typo finds nothing.\n{{/if}}\n',
1110
- "payment-link": "{{#if claude-skill cli}}\n## Before giving the payment link\n\n`{{tool:hotels book}}` answers with an unpaid order: `status` `awaiting_payment`, its `reference` (the support number), `price.total`, the stay and its terms, and `payment.url`, a Fortrip page that recaps the order and continues to payment on Stripe. Nothing is charged until the user pays.\n\n1. Show the order's total and currency, the stay (hotel, room, dates, rooms and guests per room) and every term: meals, cancellation (status, deadline, penalties) and fees payable at the property, unknowns included.\n2. End that reply by asking the user to confirm, and wait for a clear yes. Urgency is not consent.\n3. Then give `payment.url` exactly as returned: don't shorten, rebuild or re-encode it.\n\n{{/if}}\n{{#if mcp}}\n- Before you give `payment.url`, show the user the order's total and currency, the stay and every term, end that reply by asking the user to confirm, and wait for a clear yes. Then give `payment.url` exactly as returned, to this user only: anyone holding it can pay.\n{{/if}}\n{{#if claude-skill cli}}\n- `payment.url` works like a payment credential: anyone holding it can pay. Give it to this user only, never in shared channels, documents, logs or tickets. With `requiresSignIn: true` (an order started on the Fortrip website), the user signs in to pay.\n- The link expires at `payment.expiresAt`; the order is then `expired`. To order the stay again, get offers again, and confirm the new order with the user before giving its link.\n- Another order of the stay (another party, or a corrected guest name) needs a new offer: get offers again. When it replaces an unpaid order, tell the user to pay only the new link; the earlier one expires unpaid.\n- An order `awaiting_payment` whose `payment.url` is null had its link unreadable this time: read it again with `{{tool:orders get}}`.\n{{/if}}\n- Never ask for, accept or pass on payment card details; payment happens only on the payment page.{{#if claude-skill cli}} A card number in a guest name, the contact or the special requests is rejected{{#if cli}} with exit 2{{/if}}.{{/if}}\n{{#if claude-skill cli}}\n\n## Paying without the link\n\nAn order with `payment.handlers` can also be paid with a Stripe shared payment token that the user's wallet (Link) grants for it, through `{{tool:orders pay}}`:\n\n1. Show and ask exactly as before giving the payment link, and wait for a clear yes. The token comes from the user's wallet, never from card details.\n2. Request the token from the user's wallet with the handler's `networkId` and `payment.credentialLimits`: `maxAmount` (in cents), `currency` and `expiresAt`.\n3. {{#if claude-skill}}Call{{/if}}{{#if cli}}Run{{/if}} `{{tool:orders pay}}` with the token and the order's `price.total`{{#if cli}} (`--token`, `--total`){{/if}}. The order is then `confirming`, its payment `authorized`: check it as after payment.\n\nThe charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once `{{tool:orders pay}}` succeeds, `payment.url` stops working; a payment that fails leaves the link open. `payment_total_changed` means the total changed: show the new total and ask again, for a new token. `payment_declined`: the user picks another payment method in their wallet, or pays by link. `payment_action_required`: the card needs a verification this can't give: pay by link. `payment_credential_invalid`: request a new token with the order's `payment.credentialLimits`. `service_unavailable`: call `{{tool:orders pay}}` again with the same token, never a new one. A token pays one order only.\n\n## After payment\n\nCheck the order with `{{tool:orders get}}`:\n\n- `confirming` while the hotel confirms, then `confirmed` with the hotel's `confirmationNumber`.\n- `failed`: no stay was booked; `payment.status` says whether the payment was released or refunded.\n- `needs_attention`: Fortrip is looking into it; the user can email {{support}} with the `reference`.\n- `manageUrl` is the user's own page for the order.\n{{/if}}\n",
1226
+ "payment-link": "{{#if claude-skill cli}}\n## Before giving the payment link\n\n`{{tool:hotels book}}` answers with an unpaid order: `status` `awaiting_payment`, its `reference` (the support number), `price.total`, the stay and its terms, and `payment.url`, a Fortrip page that recaps the order and continues to payment on Stripe. Nothing is charged until the user pays.\n\n1. Show the order's total and currency, the stay (hotel, room, dates, rooms and guests per room) and every term: meals, cancellation (status, deadline, penalties) and fees payable at the property, unknowns included.\n2. End that reply by asking the user to confirm, and wait for a clear yes. Urgency is not consent.\n3. Then give `payment.url` exactly as returned: don't shorten, rebuild or re-encode it.\n\n{{/if}}\n{{#if mcp}}\n- Before you give `payment.url`, show the user the order's total and currency, the stay and every term, end that reply by asking the user to confirm, and wait for a clear yes. Then give `payment.url` exactly as returned, to this user only: anyone holding it can pay.\n{{/if}}\n{{#if claude-skill cli}}\n- `payment.url` works like a payment credential: anyone holding it can pay. Give it to this user only, never in shared channels, documents, logs or tickets. With `requiresSignIn: true` (an order started on the Fortrip website), the user signs in to pay.\n- The link expires at `payment.expiresAt`; the order is then `expired`. To order the stay again, get offers again, and confirm the new order with the user before giving its link.\n- Another order of the stay (another party, or a corrected guest name) needs a new offer: get offers again. When it replaces an unpaid order, tell the user to pay only the new link; the earlier one expires unpaid.\n- An order `awaiting_payment` whose `payment.url` is null had its link unreadable this time: read it again with `{{tool:orders get}}`.\n{{/if}}\n- Never ask for, accept or pass on payment card details; payment happens only through Stripe.{{#if claude-skill cli}} A card number in a guest name, the contact or the special requests is rejected{{#if cli}} with exit 2{{/if}}.{{/if}}\n{{#if claude-skill cli}}\n\n## Paying without the link\n\nAn order whose `payment.handlers` isn't empty can also be paid with a Stripe shared payment token that the user's wallet (Link) grants for it, through `{{tool:orders pay}}`:\n\n1. Show and ask exactly as before giving the payment link, and wait for a clear yes. The token comes from the user's wallet, never from card details.\n2. Request the token from the user's wallet with the handler's `config.business_profile` and `payment.credentialLimits`: `maxAmount` (in cents), `currency` and `expiresAt`.\n3. {{#if claude-skill}}Call{{/if}}{{#if cli}}Run{{/if}} `{{tool:orders pay}}` with the token and the order's `price.total`{{#if cli}} (`--token`, `--total`){{/if}}{{#if claude-skill}}, the token as `sharedPaymentToken` or in UCP's `payment.instruments`{{/if}}. The order is then `confirming`, its payment `authorized`: check it as after payment.\n\nThe charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once `{{tool:orders pay}}` succeeds, `payment.url` stops working; a payment that fails leaves the link open. `payment_total_changed` means the total changed: show the new total and ask again, for a new token. `payment_declined`: the user picks another payment method in their wallet, or pays by link. `payment_action_required`: the card needs a verification this can't give: pay by link. `payment_credential_invalid`: request a new token with the order's `payment.credentialLimits`. `service_unavailable`: call `{{tool:orders pay}}` again with the same token, never a new one. A token pays one order only.\n\n## After payment\n\nCheck the order with `{{tool:orders get}}`:\n\n- `confirming` while the hotel confirms, then `confirmed` with the hotel's `confirmationNumber`.\n- `failed`: no stay was booked; `payment.status` says whether the payment was released or refunded.\n- `needs_attention`: Fortrip is looking into it; the user can email {{support}} with the `reference`.\n- `manageUrl` is the user's own page for the order.\n{{/if}}\n",
1111
1227
  "planning": "# Planning a hotel stay\n\nRead this when the request is more than one hotel for fixed dates: flexible dates, a budget, split stays, several destinations, or \"find me the best\". The rules in {{#if mcp}}the server instructions{{/if}}{{#if claude-skill}}SKILL.md{{/if}}{{#if cli}}`{{tool:guide}}`{{/if}} still apply (call order, destinations, one party per offer and order, confirming the order `{{tool:hotels book}}` returns before giving the payment link); this covers what to ask, how to compare and how to present.{{#if cli}} As there, `fortrip` is short for `npx -y fortrip@latest`.{{/if}}\n\n## What to collect\n\nKeep track of: dates (or the flexible window), nights, destination(s) with their country, rooms and the guests in each room, room constraints (beds, connecting rooms, accessibility), budget, and what the user said matters most (cheapest, most flexible, closest to X).\n\nOffers and orders take one party per call, every room the same, so if the party doesn't split evenly across the rooms, ask how it splits. Rooms for different parties are priced and ordered separately, each order with its own payment link.\n\nAsk only for what changes which hotels qualify or how they rank. \"4 stars\" as {{#if mcp claude-skill}}`{ min: 4, max: 4 }`{{/if}}{{#if cli}}`--stars-min 4 --stars-max 4`{{/if}} leaves out 4.5: unless the user means exactly 4, use {{#if mcp claude-skill}}`{ min: 4 }`{{/if}}{{#if cli}}`--stars-min 4`{{/if}} or ask. If children come along, ask each child's age; `{{tool:hotels offers}}` needs it. Don't ask for trip type or style: infer it from the conversation or leave it general. When a place name is ambiguous, ask which place the user means.\n\n## Evidence\n\n- A `{{tool:hotels search}}` price is an indicative estimate per room per night, not a quote. Never call a search result available or bookable, and once you have offers, compare offers only. A hotel without a search price can still have offers.\n- Use `{{tool:hotels get}}` only when a stated preference needs evidence (a pool, a policy, room size). An amenity or policy it doesn't list is unknown, not absent.\n- A hotel is available only once `{{tool:hotels offers}}` returned an offer for it.\n- Anything {{#if mcp claude-skill}}the tools{{/if}}{{#if cli}}the CLI{{/if}} didn't return, such as reviews, style, price trends or exchange rates other than `approx`, is unknown. Say so instead of filling it in.\n\n## Ranking\n\n1. Drop options that break a hard constraint (dates, guests, budget cap, required facility). Compare a budget in the unit the user gave it: per night, per room or for the whole stay. An offer's `price.total` covers the whole stay and every room, in USD.\n2. Keep only options with a live offer.\n3. Order by the user's stated main goal. Goals they didn't state don't count.\n4. Use other preferences only to break ties.\n\nUse the cheapest comparable offer as the baseline unless the user fixed the room type. Show at most three plans, each with its price difference from the baseline and what it trades off (meals, cancellation, location, confirmation). Keep hotel names as returned and dates in the user's notation.\n\nFor a split stay or several destinations, price each leg with its own `{{tool:hotels offers}}` call and add up the legs. Each leg is a separate `{{tool:hotels book}}` call, with its own confirmation and its own payment link.\n\n## Stop and say so\n\n- `{{tool:hotels offers}}` covers up to {{limit:offersHotels}} hotels per call and takes about 15 seconds, and its offers expire after about 30 minutes. If the request needs more hotels or date combinations than a few calls can cover, narrow it with the user, or present the result as a comparison of the hotels you priced, not the best overall.\n- When a search is too broad to price, show its localities and ask the user which they prefer, unless the request already names one of them; never pick one yourself.\n- Urgency is not consent. Call `{{tool:hotels book}}` only for the offer the user picked, and give its payment link only after the user confirms the total, currency, stay and terms of the order `{{tool:hotels book}}` returned.\n",
1112
1228
  "presentation": "{{#if claude-skill}}\n## Presenting hotels\n\nIf your interface can show rich elements, show each hotel as a card with only what Fortrip's tools returned for it in this conversation: photo, name, stars, region and price, and once you have offers every term that changes the choice (meals and who they cover, cancellation, fees payable at the property, confirmation), an unknown one as unknown. Label a search's `price.fromPerRoomNight` as an estimate per room-night and an offer's `price.total` as the whole stay for all rooms, in USD, and draw a map only from returned `location` coordinates. Offer the choices you need to ask anyway (dates, a locality, which offer) as options to pick. Otherwise use a short list. Keep hotel names as returned, and never invent photos, ratings, reviews, prices, terms or coordinates.\n{{/if}}\n",
1113
1229
  "prices": "{{#if claude-skill cli}}\n## Prices and currency\n\n- A search price (`price.fromPerRoomNight`) is indicative and not bookable: the lowest price of one unit (a room or, at a hostel, possibly a bed) per night, for any party and often any date, and it can be well above or below the offers. Call it an estimate, quote `{{tool:hotels offers}}` prices, and never call a search result available or bookable. `price: null` means there is no indicative price, not that the hotel is full; about half the hotels have none for given dates.\n{{/if}}\n{{#if mcp}}\n- Search prices are indicative, not bookable: quote `{{tool:hotels offers}}` prices.\n{{/if}}\n- {{#if claude-skill cli}}In an offer or order, {{/if}}`price.total` is the whole stay for all rooms and is what is charged, in USD for offers and the orders made from them.{{#if claude-skill cli}} `perNightAllRooms` is the total per night; to compare with a per-room budget, also divide by the rooms.{{/if}} Stripe's page may let the user pay in their card's local currency at Stripe's rate (Adaptive Pricing){{#if claude-skill cli}}: say so plainly, and that the USD total is the price{{/if}}. `approx`{{#if claude-skill cli}}, in `{{arg:displayCurrency}}`, with its `rateDate`,{{/if}} is an estimate, never the charge.\n{{#if claude-skill cli}}\n- `{{arg:displayCurrency}}`{{#if cli}} (or `FORTRIP_DISPLAY_CURRENCY`){{/if}} is `USD` or `CNY`: `CNY` adds `approx` in yuan to suit a user who thinks in it. It never changes the charge.\n- Fees payable at the property (`payAtProperty`) are separate, in the property's own currency, not converted.\n- After payment, `payment.localCharge` is what the card paid in its own currency. Orders made on the Fortrip website can be charged in another currency: `payment.chargeCurrency` says which.\n{{/if}}\n",
@@ -1405,8 +1521,8 @@ var hotelSummary = openObject({
1405
1521
  timeZone: z11.string().nullable(),
1406
1522
  distanceMeters: z11.number().nullable(),
1407
1523
  price: indicativePrice.nullable(),
1408
- /** The cover photo; `null` without one. Absent from servers before 3.1. */
1409
- photo: photo.nullable().optional()
1524
+ /** The cover photo; `null` without one. */
1525
+ photo: photo.nullable()
1410
1526
  });
1411
1527
  var localities = openObject({
1412
1528
  items: z11.array(
@@ -1526,8 +1642,8 @@ var hotel = openObject({
1526
1642
  timeZone: z12.string().nullable(),
1527
1643
  description: knownLocaleText.nullable(),
1528
1644
  /** Up to 8 hotel photos, the cover first; `null` when the catalogue lists
1529
- * none (unknown is not no). Absent from servers before 3.1. */
1530
- photos: z12.array(photo).nullable().optional(),
1645
+ * none (unknown is not no). */
1646
+ photos: z12.array(photo).nullable(),
1531
1647
  checkInTimes: timeRange,
1532
1648
  checkOutTimes: timeRange,
1533
1649
  policies: openObject({
@@ -1703,7 +1819,14 @@ var paymentHandler = openObject({
1703
1819
  type: z14.string(),
1704
1820
  version: z14.string(),
1705
1821
  spec: z14.string(),
1706
- networkId: z14.string().nullable()
1822
+ schema: z14.string(),
1823
+ available_instruments: z14.array(
1824
+ openObject({ type: z14.string(), config: protocolObject().optional() })
1825
+ ),
1826
+ config: openObject({
1827
+ environment: openEnum(["livemode", "testmode"]),
1828
+ business_profile: z14.string()
1829
+ })
1707
1830
  });
1708
1831
  var orderReference = z14.string().regex(/^FT-[2-9A-HJ-NP-Z]{6}$/);
1709
1832
  var hotelItem = openObject({
@@ -1743,29 +1866,28 @@ var order = openObject({
1743
1866
  localCurrencyAtCheckout: z14.boolean(),
1744
1867
  localCharge: money.nullable(),
1745
1868
  /** The ways to pay other than `url`, while the order can be paid that
1746
- * way (3.4): a `com.stripe.payments` handler takes a shared payment
1747
- * token through `pay_order`. Absent when there is none. */
1748
- handlers: z14.array(paymentHandler).optional(),
1749
- /** What a payment credential for `pay_order` must allow, present with
1750
- * `handlers` (3.4): `maxAmount` in minor units (cents) of `currency`,
1869
+ * way: a `com.stripe.payments` handler takes a shared payment token
1870
+ * through `pay_order`. Empty when there is none. */
1871
+ handlers: z14.array(paymentHandler),
1872
+ /** What a payment credential for `pay_order` must allow, with
1873
+ * `handlers`: `maxAmount` in minor units (cents) of `currency`,
1751
1874
  * lowercase as Stripe takes it, and `expiresAt`, past which the order
1752
- * can't be paid. */
1875
+ * can't be paid. `null` when `handlers` is empty. */
1753
1876
  credentialLimits: openObject({
1754
1877
  maxAmount: z14.number().int(),
1755
1878
  currency: z14.string(),
1756
1879
  expiresAt: instant
1757
- }).optional()
1880
+ }).nullable()
1758
1881
  }),
1759
1882
  /** Whether the user can cancel the order now and, when they can, its
1760
1883
  * penalty under the accepted terms (read a minute ahead) and the refund,
1761
- * what was paid less the penalty, both in the charge currency. Absent
1762
- * from servers before 3.3. */
1884
+ * what was paid less the penalty, both in the charge currency. */
1763
1885
  cancel: openObject({
1764
1886
  available: z14.boolean(),
1765
1887
  reason: openEnum(CANCEL_REASONS),
1766
1888
  penalty: money.nullable(),
1767
1889
  refund: money.nullable()
1768
- }).optional(),
1890
+ }),
1769
1891
  manageUrl: z14.string()
1770
1892
  });
1771
1893
  var orderList = openObject({
@@ -1858,9 +1980,8 @@ var ERROR_DETAILS = {
1858
1980
  matched: count2,
1859
1981
  poolLimit: count2,
1860
1982
  localities,
1861
- /** The searched area's center, as a search echoes it; null for text only.
1862
- * Optional for clients; the server must send it (`SERVER_DETAILS`). */
1863
- center: center.nullable().optional()
1983
+ /** The searched area's center, as a search echoes it; null for text only. */
1984
+ center: center.nullable()
1864
1985
  }),
1865
1986
  stay_unsupported: openUnion("reason", [
1866
1987
  openObject({ reason: z15.literal("mixed_occupancy") }),
@@ -1892,32 +2013,23 @@ var ERROR_DETAILS = {
1892
2013
  }),
1893
2014
  internal: null
1894
2015
  };
1895
- var SERVER_DETAILS = {
1896
- search_too_broad: ERROR_DETAILS.search_too_broad.extend({ center: center.nullable() })
1897
- };
1898
- function envelopeSchema(detailsRequired) {
1899
- return openObject({
1900
- error: openUnion(
1901
- "code",
1902
- Object.keys(ERROR_CODES).map((code) => {
1903
- const details = detailsRequired ? SERVER_DETAILS[code] ?? ERROR_DETAILS[code] : ERROR_DETAILS[code];
1904
- return openObject({
1905
- code: z15.literal(code),
1906
- message: z15.string(),
1907
- param: z15.string().optional(),
1908
- retryable: z15.boolean(),
1909
- retryAfterSeconds: z15.number().int().optional(),
1910
- ...details ? { details: detailsRequired ? details : details.optional() } : {},
1911
- requestId: z15.string()
1912
- });
1913
- })
1914
- )
1915
- });
1916
- }
1917
- var errorEnvelope = envelopeSchema(false);
1918
- function strictErrorEnvelope() {
1919
- return strictOutput(envelopeSchema(true));
1920
- }
2016
+ var errorEnvelope = openObject({
2017
+ error: openUnion(
2018
+ "code",
2019
+ Object.keys(ERROR_CODES).map((code) => {
2020
+ const details = ERROR_DETAILS[code];
2021
+ return openObject({
2022
+ code: z15.literal(code),
2023
+ message: z15.string(),
2024
+ param: z15.string().optional(),
2025
+ retryable: z15.boolean(),
2026
+ retryAfterSeconds: z15.number().int().optional(),
2027
+ ...details ? { details } : {},
2028
+ requestId: z15.string()
2029
+ });
2030
+ })
2031
+ )
2032
+ });
1921
2033
 
1922
2034
  // src/paths.ts
1923
2035
  var PUBLIC_ORIGINS = {
@@ -1952,7 +2064,7 @@ var MCP_PATH = "/";
1952
2064
  import { z as z16 } from "zod";
1953
2065
  var ORDER_NEXT_STEP = "Before you give the user an order's payment.url, show them its total and currency, the stay (hotel, room, dates, rooms and guests per room) and every term (meals, cancellation, fees payable at the property), then end your reply by asking them to confirm, and wait for a clear yes. Only after they say yes, give them payment.url exactly as returned.";
1954
2066
  var CANCEL_NEXT_STEP = "Before you call cancel_order, show the user the order's stay (hotel, dates), cancel.penalty and cancel.refund (amount and currency), then end your reply by asking them to confirm the cancellation, and wait for a clear yes. Pass maximumPenalty exactly as cancel.penalty.amount. Never state a refund the order did not return.";
1955
- var PAY_NEXT_STEP = "To pay without the link, when the order has payment.handlers and the user's wallet can grant a Stripe shared payment token: first show and ask exactly as for payment.url, and wait for a clear yes. Then request the token for this order from the user's wallet with the handler's networkId and payment.credentialLimits (maxAmount in cents, currency, expiresAt), and call pay_order with it and the order's price.total. The charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once pay_order succeeds, payment.url stops working.";
2067
+ var PAY_NEXT_STEP = "To pay without the link, when the order's payment.handlers isn't empty and the user's wallet can grant a Stripe shared payment token: first show and ask exactly as for payment.url, and wait for a clear yes. Then request the token for this order from the user's wallet with the handler's config.business_profile and payment.credentialLimits (maxAmount in cents, currency, expiresAt), and call pay_order with it and the order's price.total. The charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once pay_order succeeds, payment.url stops working.";
1956
2068
  var PRESENTATION_HINT = "Presentation: If your interface can show rich elements, show each hotel as a card with only what Fortrip's tools returned for it in this conversation: photo, name, stars, region and price, and once you have offers every term that changes the choice (meals and who they cover, cancellation, fees payable at the property, confirmation), an unknown one as unknown. Label a search's `price.fromPerRoomNight` as an estimate per room-night and an offer's `price.total` as the whole stay for all rooms, in USD, and draw a map only from returned `location` coordinates. Offer the choices you need to ask anyway (dates, a locality, which offer) as options to pick. Otherwise use a short list. Keep hotel names as returned, and never invent photos, ratings, reviews, prices, terms or coordinates.";
1957
2069
  var nextStep = z16.string().optional().describe(
1958
2070
  "What to show and ask before giving a payment.url. Present when the answer holds a non-null payment.url, and only then."
@@ -2049,7 +2161,7 @@ var TOOLS = [
2049
2161
  {
2050
2162
  name: "pay_order",
2051
2163
  title: "Pay order with a shared payment token",
2052
- description: "Pay an order awaiting payment without its link, with a Stripe shared payment token, when the order has payment.handlers. First show and ask exactly as for payment.url, and wait for a clear yes. Then request the token from the user's wallet with the handler's networkId and payment.credentialLimits, and pass it with the order's price.total. The charge is in USD. Once it succeeds, payment.url stops working; a payment that fails leaves the link open. Answers the order: status confirming, the payment authorized (held, charged once the hotel confirms); poll get_order. payment_total_changed: show details.total and ask again, for a new token. payment_declined: the user picks another payment method in their wallet, or pays by link. payment_action_required: the card needs a verification this can't give; pay by link. payment_credential_invalid: request a new token. service_unavailable: call pay_order again with the same token, never a new one. A token pays one order only; the same token again answers as before.",
2164
+ description: "Pay an order awaiting payment without its link, with a Stripe shared payment token, when the order's payment.handlers isn't empty. First show and ask exactly as for payment.url, and wait for a clear yes. Then request the token from the user's wallet with the handler's config.business_profile and payment.credentialLimits, and pass it with the order's price.total. The charge is in USD. Once it succeeds, payment.url stops working; a payment that fails leaves the link open. Answers the order: status confirming, the payment authorized (held, charged once the hotel confirms); poll get_order. payment_total_changed: show details.total and ask again, for a new token. payment_declined: the user picks another payment method in their wallet, or pays by link. payment_action_required: the card needs verification; pay by link. payment_credential_invalid: request a new token. service_unavailable: call pay_order again with the same token, never a new one. A token pays one order only; the same token again answers as before.",
2053
2165
  annotations: {
2054
2166
  readOnlyHint: false,
2055
2167
  idempotentHint: true,
@@ -2411,14 +2523,14 @@ function paymentLines(o) {
2411
2523
  } else if (o.status === "awaiting_payment") {
2412
2524
  lines.push("Payment link: could not be read this time; read this order again for it.");
2413
2525
  }
2414
- if (p.handlers?.length) lines.push(handlersLine(p.handlers, p.credentialLimits));
2415
- if (o.cancel) lines.push(cancelLine(o.cancel));
2526
+ if (p.handlers.length > 0) lines.push(handlersLine(p.handlers, p.credentialLimits));
2527
+ lines.push(cancelLine(o.cancel));
2416
2528
  lines.push(`Manage: ${o.manageUrl}`);
2417
2529
  return lines;
2418
2530
  }
2419
2531
  function handlersLine(handlers, limits) {
2420
2532
  const shown = handlers.map(
2421
- (h) => `${h.type} (handler ${h.id}${h.networkId ? `, networkId ${h.networkId}` : ""})`
2533
+ (h) => `${h.type} (handler ${h.id}, business_profile ${h.config.business_profile})`
2422
2534
  );
2423
2535
  const limit = limits ? `; token limits: maxAmount ${limits.maxAmount} (cents), currency ${limits.currency}, expiresAt ${limits.expiresAt}` : "";
2424
2536
  return `Pay without the link: pay_order with a shared payment token via ${shown.join(", ")}${limit}`;
@@ -2722,7 +2834,7 @@ function notFound(d) {
2722
2834
  }
2723
2835
  }
2724
2836
  function detailLines(e) {
2725
- if (!("details" in e) || e.details === void 0) return [];
2837
+ if (!("details" in e)) return [];
2726
2838
  switch (e.code) {
2727
2839
  case "invalid_request": {
2728
2840
  const d = e.details;
@@ -2909,8 +3021,8 @@ function withConsent(tool, text2, orders) {
2909
3021
  return [
2910
3022
  text2,
2911
3023
  orders.some((o) => o.payment.url !== null) ? ORDER_NEXT_STEP : "",
2912
- orders.some((o) => (o.payment.handlers?.length ?? 0) > 0) ? PAY_NEXT_STEP : "",
2913
- CANCEL_TOOLS.has(tool) && orders.some((o) => o.cancel?.available === true) ? CANCEL_NEXT_STEP : ""
3024
+ orders.some((o) => o.payment.handlers.length > 0) ? PAY_NEXT_STEP : "",
3025
+ CANCEL_TOOLS.has(tool) && orders.some((o) => o.cancel.available) ? CANCEL_NEXT_STEP : ""
2914
3026
  ].filter(Boolean).join("\n\n");
2915
3027
  }
2916
3028
 
@@ -2940,7 +3052,8 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
2940
3052
  requiresSignIn: `${API_DECIDES} (whether the payment link needs a website sign-in).`,
2941
3053
  localCurrencyAtCheckout: `${API_DECIDES} (whether checkout may charge in the card's currency).`,
2942
3054
  "cancel.available": `${API_DECIDES} (whether an order can be cancelled now).`,
2943
- "payment.handlers": `${RESULT_LIST} (the ways to pay an order other than its link; absent when there is none).`,
3055
+ "payment.handlers": `${RESULT_LIST} (the ways to pay an order other than its link; empty when there is none).`,
3056
+ available_instruments: `${RESULT_LIST} (the instruments a payment handler takes).`,
2944
3057
  bookable: `${API_DECIDES} (whether the hotel is still in the index).`,
2945
3058
  cityLike: `${API_DECIDES} (frozen per gazetteer release; null where not computed).`,
2946
3059
  known: `${THE_FLAG} (meals).`,
@@ -2950,7 +3063,7 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
2950
3063
  // package.json
2951
3064
  var package_default = {
2952
3065
  name: "@fortrip/agent-contract",
2953
- version: "3.4.0",
3066
+ version: "4.0.0-rc.1",
2954
3067
  license: "Apache-2.0",
2955
3068
  description: "The contract of Fortrip's agent API (https://api.fortrip.ai/v1) and its MCP server: limits, paths, request and response schemas, error codes and field rules.",
2956
3069
  type: "module",
@@ -3093,15 +3206,16 @@ export {
3093
3206
  place,
3094
3207
  placeId,
3095
3208
  placeRef,
3209
+ protocolObject,
3096
3210
  renderError,
3097
3211
  renderGuide,
3098
3212
  renderToolResult,
3099
3213
  roomFacts,
3100
3214
  searchHotelsInput,
3101
3215
  searchResult,
3216
+ sharedPaymentTokenOf,
3102
3217
  stay,
3103
3218
  stayEcho,
3104
- strictErrorEnvelope,
3105
3219
  strictInput,
3106
3220
  strictOutput,
3107
3221
  text,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fortrip/agent-contract",
3
- "version": "3.4.0",
3
+ "version": "4.0.0-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The contract of Fortrip's agent API (https://api.fortrip.ai/v1) and its MCP server: limits, paths, request and response schemas, error codes and field rules.",
6
6
  "type": "module",