@fortrip/agent-contract 3.3.1 → 3.5.0

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.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 handler'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 (3.5).
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,12 +53,13 @@ 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
 
55
- type ToolName = "get_planning_guide" | "search_hotels" | "get_hotel" | "get_hotel_offers" | "book_hotel" | "get_order" | "list_orders" | "cancel_order";
62
+ type ToolName = "get_planning_guide" | "search_hotels" | "get_hotel" | "get_hotel_offers" | "book_hotel" | "get_order" | "list_orders" | "cancel_order" | "pay_order";
56
63
  interface ToolSpec {
57
64
  name: ToolName;
58
65
  title: string;
@@ -81,6 +88,13 @@ declare const ORDER_NEXT_STEP = "Before you give the user an order's payment.url
81
88
  * both apply, and never as `nextStep`, which keeps its payment-only meaning.
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.";
91
+ /**
92
+ * How to pay without the link (3.4). It rides as the last paragraph of the
93
+ * text of every MCP `book_hotel`, `get_order` and `list_orders` result that
94
+ * holds an order with `payment.handlers`, after `ORDER_NEXT_STEP`, and in
95
+ * the description of `pay_order`; never as `nextStep`.
96
+ */
97
+ 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 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.";
84
98
  /**
85
99
  * How to present hotels (the `presentation` guide, in one line). It rides as
86
100
  * the last paragraph of every MCP `search_hotels`, `get_hotel` and
@@ -90,7 +104,8 @@ declare const CANCEL_NEXT_STEP = "Before you call cancel_order, show the user th
90
104
  declare const 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.";
91
105
  /** The answers over MCP that are orders. Those that can hold a
92
106
  * `payment.url` are the HTTP answer plus `nextStep`, which only MCP
93
- * declares; `cancel_order`'s never holds one, so it is the HTTP answer. */
107
+ * declares; `cancel_order`'s and `pay_order`'s never hold one, so they are
108
+ * the HTTP answer. */
94
109
  declare const MCP_OUTPUT: {
95
110
  readonly book_hotel: z.ZodObject<{
96
111
  orderId: z.ZodString;
@@ -234,6 +249,24 @@ declare const MCP_OUTPUT: {
234
249
  chargeCurrency: z.ZodString;
235
250
  localCurrencyAtCheckout: z.ZodBoolean;
236
251
  localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
252
+ handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
253
+ id: z.ZodString;
254
+ type: z.ZodString;
255
+ version: z.ZodString;
256
+ spec: z.ZodString;
257
+ schema: z.ZodOptional<z.ZodString>;
258
+ available_instruments: z.ZodOptional<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.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
263
+ networkId: z.ZodNullable<z.ZodString>;
264
+ }, z.core.$strip>>>;
265
+ credentialLimits: z.ZodOptional<z.ZodObject<{
266
+ maxAmount: z.ZodNumber;
267
+ currency: z.ZodString;
268
+ expiresAt: z.ZodString;
269
+ }, z.core.$strip>>;
237
270
  }, z.core.$strip>;
238
271
  cancel: z.ZodOptional<z.ZodObject<{
239
272
  available: z.ZodBoolean;
@@ -386,6 +419,24 @@ declare const MCP_OUTPUT: {
386
419
  chargeCurrency: z.ZodString;
387
420
  localCurrencyAtCheckout: z.ZodBoolean;
388
421
  localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
422
+ handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
423
+ id: z.ZodString;
424
+ type: z.ZodString;
425
+ version: z.ZodString;
426
+ spec: z.ZodString;
427
+ schema: z.ZodOptional<z.ZodString>;
428
+ available_instruments: z.ZodOptional<z.ZodArray<z.ZodObject<{
429
+ type: z.ZodString;
430
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
431
+ }, z.core.$strip>>>;
432
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
433
+ networkId: z.ZodNullable<z.ZodString>;
434
+ }, z.core.$strip>>>;
435
+ credentialLimits: z.ZodOptional<z.ZodObject<{
436
+ maxAmount: z.ZodNumber;
437
+ currency: z.ZodString;
438
+ expiresAt: z.ZodString;
439
+ }, z.core.$strip>>;
389
440
  }, z.core.$strip>;
390
441
  cancel: z.ZodOptional<z.ZodObject<{
391
442
  available: z.ZodBoolean;
@@ -539,6 +590,24 @@ declare const MCP_OUTPUT: {
539
590
  chargeCurrency: z.ZodString;
540
591
  localCurrencyAtCheckout: z.ZodBoolean;
541
592
  localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
593
+ handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
594
+ id: z.ZodString;
595
+ type: z.ZodString;
596
+ version: z.ZodString;
597
+ spec: z.ZodString;
598
+ schema: z.ZodOptional<z.ZodString>;
599
+ available_instruments: z.ZodOptional<z.ZodArray<z.ZodObject<{
600
+ type: z.ZodString;
601
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
602
+ }, z.core.$strip>>>;
603
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
604
+ networkId: z.ZodNullable<z.ZodString>;
605
+ }, z.core.$strip>>>;
606
+ credentialLimits: z.ZodOptional<z.ZodObject<{
607
+ maxAmount: z.ZodNumber;
608
+ currency: z.ZodString;
609
+ expiresAt: z.ZodString;
610
+ }, z.core.$strip>>;
542
611
  }, z.core.$strip>;
543
612
  cancel: z.ZodOptional<z.ZodObject<{
544
613
  available: z.ZodBoolean;
@@ -693,6 +762,193 @@ declare const MCP_OUTPUT: {
693
762
  chargeCurrency: z.ZodString;
694
763
  localCurrencyAtCheckout: z.ZodBoolean;
695
764
  localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
765
+ handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
766
+ id: z.ZodString;
767
+ type: z.ZodString;
768
+ version: z.ZodString;
769
+ spec: z.ZodString;
770
+ schema: z.ZodOptional<z.ZodString>;
771
+ available_instruments: z.ZodOptional<z.ZodArray<z.ZodObject<{
772
+ type: z.ZodString;
773
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
774
+ }, z.core.$strip>>>;
775
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
776
+ networkId: z.ZodNullable<z.ZodString>;
777
+ }, z.core.$strip>>>;
778
+ credentialLimits: z.ZodOptional<z.ZodObject<{
779
+ maxAmount: z.ZodNumber;
780
+ currency: z.ZodString;
781
+ expiresAt: z.ZodString;
782
+ }, z.core.$strip>>;
783
+ }, z.core.$strip>;
784
+ cancel: z.ZodOptional<z.ZodObject<{
785
+ available: z.ZodBoolean;
786
+ 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>>;
787
+ penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
788
+ refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
789
+ }, z.core.$strip>>;
790
+ manageUrl: z.ZodString;
791
+ }, z.core.$strip>;
792
+ readonly pay_order: z.ZodObject<{
793
+ orderId: z.ZodString;
794
+ reference: z.ZodString;
795
+ status: z.ZodType<(string & {}) | "awaiting_payment" | "expired" | "confirming" | "confirmed" | "failed" | "cancelling" | "cancelled" | "needs_attention", unknown, z.core.$ZodTypeInternals<(string & {}) | "awaiting_payment" | "expired" | "confirming" | "confirmed" | "failed" | "cancelling" | "cancelled" | "needs_attention", unknown>>;
796
+ createdAt: z.ZodString;
797
+ updatedAt: z.ZodString;
798
+ items: z.ZodArray<z.ZodType<OpenUnionOutput<"type", readonly [z.ZodObject<{
799
+ type: z.ZodLiteral<"hotel">;
800
+ hotel: z.ZodObject<{
801
+ hotelId: z.ZodNullable<z.ZodString>;
802
+ name: z.ZodString;
803
+ names: z.ZodObject<{
804
+ en: z.ZodNullable<z.ZodString>;
805
+ zh: z.ZodNullable<z.ZodString>;
806
+ }, z.core.$strip>;
807
+ checkIn: z.ZodString;
808
+ checkOut: z.ZodString;
809
+ timeZone: z.ZodNullable<z.ZodString>;
810
+ rooms: z.ZodArray<z.ZodObject<{
811
+ adults: z.ZodNumber;
812
+ childrenAges: z.ZodArray<z.ZodNumber>;
813
+ }, z.core.$strip>>;
814
+ room: z.ZodObject<{
815
+ name: z.ZodNullable<z.ZodObject<{
816
+ text: z.ZodString;
817
+ locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
818
+ }, z.core.$strip>>;
819
+ beds: z.ZodNullable<z.ZodObject<{
820
+ text: z.ZodString;
821
+ locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
822
+ }, z.core.$strip>>;
823
+ }, z.core.$strip>;
824
+ meals: z.ZodObject<{
825
+ known: z.ZodBoolean;
826
+ included: z.ZodNullable<z.ZodArray<z.ZodType<(string & {}) | "breakfast" | "lunch" | "dinner", unknown, z.core.$ZodTypeInternals<(string & {}) | "breakfast" | "lunch" | "dinner", unknown>>>>;
827
+ unspecifiedMainMeals: z.ZodNullable<z.ZodNumber>;
828
+ allInclusive: z.ZodNullable<z.ZodBoolean>;
829
+ guestsCoveredPerRoom: z.ZodNullable<z.ZodNumber>;
830
+ label: z.ZodNullable<z.ZodObject<{
831
+ text: z.ZodString;
832
+ locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
833
+ }, z.core.$strip>>;
834
+ }, z.core.$strip>;
835
+ cancellation: z.ZodObject<{
836
+ status: z.ZodType<"unknown" | (string & {}) | "free" | "partial_penalty" | "non_refundable", unknown, z.core.$ZodTypeInternals<"unknown" | (string & {}) | "free" | "partial_penalty" | "non_refundable", unknown>>;
837
+ asOf: z.ZodString;
838
+ freeCancellationEndsAt: z.ZodNullable<z.ZodString>;
839
+ penalties: z.ZodArray<z.ZodObject<{
840
+ startsAt: z.ZodNullable<z.ZodString>;
841
+ amount: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
842
+ }, z.core.$strip>>;
843
+ timeZone: z.ZodNullable<z.ZodString>;
844
+ }, z.core.$strip>;
845
+ payAtProperty: z.ZodObject<{
846
+ disclosure: z.ZodType<(string & {}) | "complete" | "incomplete", unknown, z.core.$ZodTypeInternals<(string & {}) | "complete" | "incomplete", unknown>>;
847
+ items: z.ZodArray<z.ZodObject<{
848
+ label: z.ZodNullable<z.ZodObject<{
849
+ text: z.ZodString;
850
+ locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
851
+ }, z.core.$strip>>;
852
+ amount: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
853
+ mandatory: z.ZodBoolean;
854
+ basis: z.ZodType<"unknown" | (string & {}) | "per_stay" | "per_night" | "per_person" | "per_person_per_night", unknown, z.core.$ZodTypeInternals<"unknown" | (string & {}) | "per_stay" | "per_night" | "per_person" | "per_person_per_night", unknown>>;
855
+ collectedAt: z.ZodType<"unknown" | (string & {}) | "property", unknown, z.core.$ZodTypeInternals<"unknown" | (string & {}) | "property", unknown>>;
856
+ }, z.core.$strip>>;
857
+ }, z.core.$strip>;
858
+ confirmationNumber: z.ZodNullable<z.ZodString>;
859
+ }, z.core.$strip>;
860
+ }, z.core.$strip>]>, unknown, z.core.$ZodTypeInternals<OpenUnionOutput<"type", readonly [z.ZodObject<{
861
+ type: z.ZodLiteral<"hotel">;
862
+ hotel: z.ZodObject<{
863
+ hotelId: z.ZodNullable<z.ZodString>;
864
+ name: z.ZodString;
865
+ names: z.ZodObject<{
866
+ en: z.ZodNullable<z.ZodString>;
867
+ zh: z.ZodNullable<z.ZodString>;
868
+ }, z.core.$strip>;
869
+ checkIn: z.ZodString;
870
+ checkOut: z.ZodString;
871
+ timeZone: z.ZodNullable<z.ZodString>;
872
+ rooms: z.ZodArray<z.ZodObject<{
873
+ adults: z.ZodNumber;
874
+ childrenAges: z.ZodArray<z.ZodNumber>;
875
+ }, z.core.$strip>>;
876
+ room: z.ZodObject<{
877
+ name: z.ZodNullable<z.ZodObject<{
878
+ text: z.ZodString;
879
+ locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
880
+ }, z.core.$strip>>;
881
+ beds: z.ZodNullable<z.ZodObject<{
882
+ text: z.ZodString;
883
+ locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
884
+ }, z.core.$strip>>;
885
+ }, z.core.$strip>;
886
+ meals: z.ZodObject<{
887
+ known: z.ZodBoolean;
888
+ included: z.ZodNullable<z.ZodArray<z.ZodType<(string & {}) | "breakfast" | "lunch" | "dinner", unknown, z.core.$ZodTypeInternals<(string & {}) | "breakfast" | "lunch" | "dinner", unknown>>>>;
889
+ unspecifiedMainMeals: z.ZodNullable<z.ZodNumber>;
890
+ allInclusive: z.ZodNullable<z.ZodBoolean>;
891
+ guestsCoveredPerRoom: z.ZodNullable<z.ZodNumber>;
892
+ label: z.ZodNullable<z.ZodObject<{
893
+ text: z.ZodString;
894
+ locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
895
+ }, z.core.$strip>>;
896
+ }, z.core.$strip>;
897
+ cancellation: z.ZodObject<{
898
+ status: z.ZodType<"unknown" | (string & {}) | "free" | "partial_penalty" | "non_refundable", unknown, z.core.$ZodTypeInternals<"unknown" | (string & {}) | "free" | "partial_penalty" | "non_refundable", unknown>>;
899
+ asOf: z.ZodString;
900
+ freeCancellationEndsAt: z.ZodNullable<z.ZodString>;
901
+ penalties: z.ZodArray<z.ZodObject<{
902
+ startsAt: z.ZodNullable<z.ZodString>;
903
+ amount: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
904
+ }, z.core.$strip>>;
905
+ timeZone: z.ZodNullable<z.ZodString>;
906
+ }, z.core.$strip>;
907
+ payAtProperty: z.ZodObject<{
908
+ disclosure: z.ZodType<(string & {}) | "complete" | "incomplete", unknown, z.core.$ZodTypeInternals<(string & {}) | "complete" | "incomplete", unknown>>;
909
+ items: z.ZodArray<z.ZodObject<{
910
+ label: z.ZodNullable<z.ZodObject<{
911
+ text: z.ZodString;
912
+ locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
913
+ }, z.core.$strip>>;
914
+ amount: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
915
+ mandatory: z.ZodBoolean;
916
+ basis: z.ZodType<"unknown" | (string & {}) | "per_stay" | "per_night" | "per_person" | "per_person_per_night", unknown, z.core.$ZodTypeInternals<"unknown" | (string & {}) | "per_stay" | "per_night" | "per_person" | "per_person_per_night", unknown>>;
917
+ collectedAt: z.ZodType<"unknown" | (string & {}) | "property", unknown, z.core.$ZodTypeInternals<"unknown" | (string & {}) | "property", unknown>>;
918
+ }, z.core.$strip>>;
919
+ }, z.core.$strip>;
920
+ confirmationNumber: z.ZodNullable<z.ZodString>;
921
+ }, z.core.$strip>;
922
+ }, z.core.$strip>]>, unknown>>>;
923
+ price: z.ZodObject<{
924
+ total: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
925
+ }, z.core.$strip>;
926
+ payment: z.ZodObject<{
927
+ status: z.ZodType<(string & {}) | "unpaid" | "authorized" | "paid" | "released" | "refund_pending" | "refunded", unknown, z.core.$ZodTypeInternals<(string & {}) | "unpaid" | "authorized" | "paid" | "released" | "refund_pending" | "refunded", unknown>>;
928
+ url: z.ZodNullable<z.ZodString>;
929
+ requiresSignIn: z.ZodBoolean;
930
+ expiresAt: z.ZodNullable<z.ZodString>;
931
+ chargeCurrency: z.ZodString;
932
+ localCurrencyAtCheckout: z.ZodBoolean;
933
+ localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
934
+ handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
935
+ id: z.ZodString;
936
+ type: z.ZodString;
937
+ version: z.ZodString;
938
+ spec: z.ZodString;
939
+ schema: z.ZodOptional<z.ZodString>;
940
+ available_instruments: z.ZodOptional<z.ZodArray<z.ZodObject<{
941
+ type: z.ZodString;
942
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
943
+ }, z.core.$strip>>>;
944
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
945
+ networkId: z.ZodNullable<z.ZodString>;
946
+ }, z.core.$strip>>>;
947
+ credentialLimits: z.ZodOptional<z.ZodObject<{
948
+ maxAmount: z.ZodNumber;
949
+ currency: z.ZodString;
950
+ expiresAt: z.ZodString;
951
+ }, z.core.$strip>>;
696
952
  }, z.core.$strip>;
697
953
  cancel: z.ZodOptional<z.ZodObject<{
698
954
  available: z.ZodBoolean;
@@ -772,7 +1028,7 @@ interface CommandSpec {
772
1028
  /** The group it is typed after; `null` for a command typed on its own. */
773
1029
  group: CommandGroupSpec["name"] | null;
774
1030
  /** Unique within its group. */
775
- name: "search" | "get" | "offers" | "book" | "list" | "cancel" | "login" | "logout" | "whoami" | "guide" | "mcp";
1031
+ name: "search" | "get" | "offers" | "book" | "list" | "cancel" | "pay" | "login" | "logout" | "whoami" | "guide" | "mcp";
776
1032
  summary: string;
777
1033
  /** The MCP tool the command mirrors; `null` for one that is the CLI's own. */
778
1034
  tool: ToolName | null;
@@ -1132,6 +1388,35 @@ declare const cancelOrderInput: z.ZodObject<{
1132
1388
  maximumPenalty: z.ZodNumber;
1133
1389
  }, z.core.$strict>;
1134
1390
  type CancelOrderInput = z.input<typeof cancelOrderInput>;
1391
+ /** `POST /v1/orders/{orderId}/pay` and the MCP `pay_order` arguments: the
1392
+ * order, a Stripe shared payment token granted for it, and the total the
1393
+ * user approved. The token is `sharedPaymentToken` or, as UCP's Complete
1394
+ * Checkout sends it, the credential of `payment`'s selected instrument
1395
+ * (3.5): exactly one of the two. A total other than the order's answers
1396
+ * `payment_total_changed` and charges nothing. */
1397
+ declare const payOrderInput: z.ZodObject<{
1398
+ orderId: z.ZodString;
1399
+ sharedPaymentToken: z.ZodOptional<z.ZodString>;
1400
+ payment: z.ZodOptional<z.ZodObject<{
1401
+ instruments: z.ZodArray<z.ZodObject<{
1402
+ id: z.ZodString;
1403
+ handler_id: z.ZodString;
1404
+ type: z.ZodString;
1405
+ selected: z.ZodOptional<z.ZodBoolean>;
1406
+ credential: z.ZodOptional<z.ZodObject<{
1407
+ type: z.ZodString;
1408
+ token: z.ZodOptional<z.ZodString>;
1409
+ }, z.core.$loose>>;
1410
+ display: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
1411
+ }, z.core.$loose>>;
1412
+ }, z.core.$strict>>;
1413
+ total: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
1414
+ }, z.core.$strict>;
1415
+ type PayOrderInput = z.input<typeof payOrderInput>;
1416
+ /** The shared payment token a `pay_order` call pays with: `sharedPaymentToken`,
1417
+ * or the credential of `payment`'s selected instrument (3.5). Takes what
1418
+ * `payOrderInput` parsed, which holds exactly one. */
1419
+ declare function sharedPaymentTokenOf(input: Pick<z.output<typeof payOrderInput>, "sharedPaymentToken" | "payment">): string;
1135
1420
 
1136
1421
  /** The ceilings and floors every agent surface enforces and documents (spec §15). */
1137
1422
  declare const LIMITS: {
@@ -1229,7 +1514,7 @@ declare const stayEcho: z.ZodObject<{
1229
1514
  }, z.core.$strip>;
1230
1515
 
1231
1516
  /** Every code the v1 error envelope can carry (spec §11). */
1232
- type ErrorCode = "invalid_request" | "cursor_invalid" | "unauthenticated" | "forbidden" | "not_found" | "order_removed" | "offer_expired" | "offer_changed" | "offer_already_ordered" | "order_exists" | "order_in_progress" | "order_attempts_exhausted" | "cancellation_changed" | "order_not_cancellable" | "destination_ambiguous" | "destination_not_found" | "search_too_broad" | "stay_unsupported" | "stay_in_past" | "offer_unavailable" | "rate_limited" | "ordering_paused" | "service_unavailable" | "supplier_unavailable" | "internal";
1517
+ type ErrorCode = "invalid_request" | "cursor_invalid" | "unauthenticated" | "forbidden" | "not_found" | "order_removed" | "offer_expired" | "offer_changed" | "offer_already_ordered" | "order_exists" | "order_in_progress" | "order_attempts_exhausted" | "cancellation_changed" | "order_not_cancellable" | "order_not_payable" | "payment_in_progress" | "payment_total_changed" | "payment_credential_invalid" | "payment_declined" | "payment_action_required" | "payment_method_unavailable" | "destination_ambiguous" | "destination_not_found" | "search_too_broad" | "stay_unsupported" | "stay_in_past" | "offer_unavailable" | "rate_limited" | "ordering_paused" | "service_unavailable" | "supplier_unavailable" | "internal";
1233
1518
  /** The HTTP statuses each code is sent with, and whether a retry can help. */
1234
1519
  declare const ERROR_CODES: Readonly<Record<ErrorCode, {
1235
1520
  status: readonly number[];
@@ -1540,6 +1825,25 @@ declare const ERROR_DETAILS: {
1540
1825
  order_not_cancellable: z.ZodObject<{
1541
1826
  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>>;
1542
1827
  }, z.core.$strip>;
1828
+ order_not_payable: z.ZodObject<{
1829
+ orderId: z.ZodString;
1830
+ status: z.ZodType<(string & {}) | "awaiting_payment" | "expired" | "confirming" | "confirmed" | "failed" | "cancelling" | "cancelled" | "needs_attention", unknown, z.core.$ZodTypeInternals<(string & {}) | "awaiting_payment" | "expired" | "confirming" | "confirmed" | "failed" | "cancelling" | "cancelled" | "needs_attention", unknown>>;
1831
+ }, z.core.$strip>;
1832
+ payment_in_progress: z.ZodObject<{
1833
+ orderId: z.ZodString;
1834
+ }, z.core.$strip>;
1835
+ payment_total_changed: z.ZodObject<{
1836
+ orderId: z.ZodString;
1837
+ total: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
1838
+ }, z.core.$strip>;
1839
+ payment_credential_invalid: z.ZodObject<{
1840
+ reason: z.ZodType<"amount" | "currency" | (string & {}) | "not_found" | "expired" | "deactivated" | "used" | "other_seller", unknown, z.core.$ZodTypeInternals<"amount" | "currency" | (string & {}) | "not_found" | "expired" | "deactivated" | "used" | "other_seller", unknown>>;
1841
+ }, z.core.$strip>;
1842
+ payment_declined: z.ZodObject<{
1843
+ declineCode: z.ZodNullable<z.ZodString>;
1844
+ }, z.core.$strip>;
1845
+ payment_action_required: null;
1846
+ payment_method_unavailable: null;
1543
1847
  destination_ambiguous: z.ZodObject<{
1544
1848
  name: z.ZodString;
1545
1849
  countryCode: z.ZodString;
@@ -1685,7 +1989,7 @@ declare const ERROR_DETAILS: {
1685
1989
  reason: z.ZodType<(string & {}) | "sold_out" | "refused", unknown, z.core.$ZodTypeInternals<(string & {}) | "sold_out" | "refused", unknown>>;
1686
1990
  }, z.core.$strip>;
1687
1991
  rate_limited: z.ZodObject<{
1688
- scope: z.ZodType<"search" | "hotel" | (string & {}) | "offers" | "orders_read" | "orders_create" | "orders_cancel", unknown, z.core.$ZodTypeInternals<"search" | "hotel" | (string & {}) | "offers" | "orders_read" | "orders_create" | "orders_cancel", unknown>>;
1992
+ scope: z.ZodType<"search" | "hotel" | (string & {}) | "offers" | "orders_read" | "orders_create" | "orders_cancel" | "orders_pay", unknown, z.core.$ZodTypeInternals<"search" | "hotel" | (string & {}) | "offers" | "orders_read" | "orders_create" | "orders_cancel" | "orders_pay", unknown>>;
1689
1993
  }, z.core.$strip>;
1690
1994
  ordering_paused: null;
1691
1995
  service_unavailable: null;
@@ -2088,6 +2392,33 @@ type PaymentStatus = (typeof PAYMENT_STATUSES)[number];
2088
2392
  * refused, the booking standing as it was. */
2089
2393
  declare const CANCEL_REASONS: readonly ["cancellable", "already_cancelled", "in_progress", "not_confirmed", "stay_started", "non_refundable", "refused", "terms_unknown", "needs_attention"];
2090
2394
  type CancelReason = (typeof CANCEL_REASONS)[number];
2395
+ /** Why a shared payment token can't pay an order (3.4). */
2396
+ declare const CREDENTIAL_INVALID_REASONS: readonly ["not_found", "currency", "amount", "expired", "deactivated", "used", "other_seller"];
2397
+ type CredentialInvalidReason = (typeof CREDENTIAL_INVALID_REASONS)[number];
2398
+ /** A way to pay an order other than its link, after the Universal Commerce
2399
+ * Protocol's payment handlers, its fields named as UCP and Stripe name
2400
+ * them (snake case): `type` names it (`com.stripe.payments`, which takes a
2401
+ * Stripe shared payment token), `version` and `spec` the handler
2402
+ * specification it follows, and, from 3.5, `schema` that specification's
2403
+ * JSON Schema, `config` its settings, whose `business_profile` is the
2404
+ * seller's id a wallet grants a payment credential for (Stripe's business
2405
+ * profile), and `available_instruments` the instruments it takes.
2406
+ * `networkId` is deprecated (3.5): the same as `config.business_profile`,
2407
+ * null when the handler names none. */
2408
+ declare const paymentHandler: z.ZodObject<{
2409
+ id: z.ZodString;
2410
+ type: z.ZodString;
2411
+ version: z.ZodString;
2412
+ spec: z.ZodString;
2413
+ schema: z.ZodOptional<z.ZodString>;
2414
+ available_instruments: z.ZodOptional<z.ZodArray<z.ZodObject<{
2415
+ type: z.ZodString;
2416
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
2417
+ }, z.core.$strip>>>;
2418
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
2419
+ networkId: z.ZodNullable<z.ZodString>;
2420
+ }, z.core.$strip>;
2421
+ type PaymentHandler = z.infer<typeof paymentHandler>;
2091
2422
  /** `FT-` and six characters with no 0, 1, I or O. */
2092
2423
  declare const orderReference: z.ZodString;
2093
2424
  declare const order: z.ZodObject<{
@@ -2232,6 +2563,31 @@ declare const order: z.ZodObject<{
2232
2563
  chargeCurrency: z.ZodString;
2233
2564
  localCurrencyAtCheckout: z.ZodBoolean;
2234
2565
  localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
2566
+ /** The ways to pay other than `url`, while the order can be paid that
2567
+ * way (3.4): a `com.stripe.payments` handler takes a shared payment
2568
+ * token through `pay_order`. Absent when there is none. */
2569
+ handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
2570
+ id: z.ZodString;
2571
+ type: z.ZodString;
2572
+ version: z.ZodString;
2573
+ spec: z.ZodString;
2574
+ schema: z.ZodOptional<z.ZodString>;
2575
+ available_instruments: z.ZodOptional<z.ZodArray<z.ZodObject<{
2576
+ type: z.ZodString;
2577
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
2578
+ }, z.core.$strip>>>;
2579
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
2580
+ networkId: z.ZodNullable<z.ZodString>;
2581
+ }, z.core.$strip>>>;
2582
+ /** What a payment credential for `pay_order` must allow, present with
2583
+ * `handlers` (3.4): `maxAmount` in minor units (cents) of `currency`,
2584
+ * lowercase as Stripe takes it, and `expiresAt`, past which the order
2585
+ * can't be paid. */
2586
+ credentialLimits: z.ZodOptional<z.ZodObject<{
2587
+ maxAmount: z.ZodNumber;
2588
+ currency: z.ZodString;
2589
+ expiresAt: z.ZodString;
2590
+ }, z.core.$strip>>;
2235
2591
  }, z.core.$strip>;
2236
2592
  /** Whether the user can cancel the order now and, when they can, its
2237
2593
  * penalty under the accepted terms (read a minute ahead) and the refund,
@@ -2390,6 +2746,31 @@ declare const orderList: z.ZodObject<{
2390
2746
  chargeCurrency: z.ZodString;
2391
2747
  localCurrencyAtCheckout: z.ZodBoolean;
2392
2748
  localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
2749
+ /** The ways to pay other than `url`, while the order can be paid that
2750
+ * way (3.4): a `com.stripe.payments` handler takes a shared payment
2751
+ * token through `pay_order`. Absent when there is none. */
2752
+ handlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
2753
+ id: z.ZodString;
2754
+ type: z.ZodString;
2755
+ version: z.ZodString;
2756
+ spec: z.ZodString;
2757
+ schema: z.ZodOptional<z.ZodString>;
2758
+ available_instruments: z.ZodOptional<z.ZodArray<z.ZodObject<{
2759
+ type: z.ZodString;
2760
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
2761
+ }, z.core.$strip>>>;
2762
+ config: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
2763
+ networkId: z.ZodNullable<z.ZodString>;
2764
+ }, z.core.$strip>>>;
2765
+ /** What a payment credential for `pay_order` must allow, present with
2766
+ * `handlers` (3.4): `maxAmount` in minor units (cents) of `currency`,
2767
+ * lowercase as Stripe takes it, and `expiresAt`, past which the order
2768
+ * can't be paid. */
2769
+ credentialLimits: z.ZodOptional<z.ZodObject<{
2770
+ maxAmount: z.ZodNumber;
2771
+ currency: z.ZodString;
2772
+ expiresAt: z.ZodString;
2773
+ }, z.core.$strip>>;
2393
2774
  }, z.core.$strip>;
2394
2775
  /** Whether the user can cancel the order now and, when they can, its
2395
2776
  * penalty under the accepted terms (read a minute ahead) and the refund,
@@ -3014,6 +3395,7 @@ declare const API: {
3014
3395
  locale?: "en" | "zh";
3015
3396
  }) => string;
3016
3397
  readonly orderCancel: (id: string) => string;
3398
+ readonly orderPay: (id: string) => string;
3017
3399
  };
3018
3400
  /** The MCP server answers at the root of `PUBLIC_ORIGINS.mcp`. */
3019
3401
  declare const MCP_PATH = "/";
@@ -3027,7 +3409,9 @@ type RenderedTool = Exclude<ToolName, "get_planning_guide">;
3027
3409
  * open output schema: unknown fields are ignored and unknown values shown
3028
3410
  * as they came. A result that does not parse is shown as JSON, never thrown.
3029
3411
  * The consent rule (`ORDER_NEXT_STEP`) is the last paragraph whenever the
3030
- * result holds a non-null `payment.url`; the cancel rule (`CANCEL_NEXT_STEP`)
3412
+ * result holds a non-null `payment.url`; the pay rule (`PAY_NEXT_STEP`)
3413
+ * follows it when a result holds an order with `payment.handlers`; the
3414
+ * cancel rule (`CANCEL_NEXT_STEP`)
3031
3415
  * follows it when a `get_order` or `list_orders` result holds an order with
3032
3416
  * `cancel.available`.
3033
3417
  */
@@ -3049,4 +3433,4 @@ declare const UNKNOWN_IS_NOT_NO_EXEMPTIONS: Readonly<Record<string, string>>;
3049
3433
  /** The contract's version, from package.json, the one place a release bumps it. */
3050
3434
  declare const CONTRACT_VERSION: string;
3051
3435
 
3052
- export { AMENITY_CODES, API, type AmenityCode, type AuthConfig, CANCEL_NEXT_STEP, CANCEL_REASONS, CARD_NUMBER_MESSAGE, CENTER_BASES, COMMANDS, COMMAND_GROUPS, CONTRACT_VERSION, type CancelOrderInput, type CancelReason, type Center, type CommandGroupSpec, type CommandSpec, type CreateOrderInput, 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, PLACE_KINDS, POLICY_TOPICS, PRESENTATION_HINT, PUBLIC_ORIGINS, 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, photo, place, placeId, placeRef, renderError, renderGuide, renderToolResult, roomFacts, searchHotelsInput, searchResult, stay, stayEcho, strictErrorEnvelope, strictInput, strictOutput, text, timeZone, usdMoney, wholeNumber };
3436
+ 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, strictErrorEnvelope, strictInput, strictOutput, text, timeZone, usdMoney, wholeNumber };
package/dist/index.js CHANGED
@@ -569,6 +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}$/;
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
+ }
625
+ var payOrderInput = strictInput({
626
+ orderId: orderId.describe("orderId of the order to pay, from create order or get order."),
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."
665
+ ),
666
+ total: usdMoney.describe(
667
+ "The total the user approved: the order's price.total, exactly as returned."
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
+ }
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
+ }
572
692
 
573
693
  // src/commands.ts
574
694
  function fieldDescription(json, field, sets = {}) {
@@ -814,6 +934,22 @@ var cancelFlags = flagsOf(cancelOrderInput, [
814
934
  description: "The penalty the user agreed to, exactly as `orders get` shows it, in the order's currency, e.g. `12.50`. Without it, the command cancels nothing: it shows the penalty and the refund."
815
935
  }
816
936
  ]);
937
+ var payFlags = flagsOf(payOrderInput, [
938
+ {
939
+ flag: "token",
940
+ field: "sharedPaymentToken",
941
+ type: "string",
942
+ placeholder: "<spt_\u2026>",
943
+ description: "The shared payment token the user's wallet granted for this order, with the order's credential limits."
944
+ },
945
+ {
946
+ flag: "total",
947
+ field: "total",
948
+ type: "string",
949
+ placeholder: "<USD decimal>",
950
+ description: "The total the user approved, exactly as `orders get` shows it, in USD, e.g. `125.00`."
951
+ }
952
+ ]);
817
953
  var BODY_OPTION = {
818
954
  flag: "body",
819
955
  type: "string",
@@ -822,7 +958,7 @@ var BODY_OPTION = {
822
958
  };
823
959
  var COMMAND_GROUPS = [
824
960
  { name: "hotels", summary: "Search hotels, get offers and order one" },
825
- { name: "orders", summary: "Your orders, their status, and cancelling one" }
961
+ { name: "orders", summary: "Your orders, their status, paying and cancelling one" }
826
962
  ];
827
963
  var COMMANDS = [
828
964
  {
@@ -880,6 +1016,14 @@ var COMMANDS = [
880
1016
  flags: cancelFlags,
881
1017
  positionals: [positional(cancelOrderInput, "orderId")]
882
1018
  },
1019
+ {
1020
+ group: "orders",
1021
+ name: "pay",
1022
+ summary: "Pay an order with a shared payment token instead of its link",
1023
+ tool: "pay_order",
1024
+ flags: payFlags,
1025
+ positionals: [positional(payOrderInput, "orderId")]
1026
+ },
883
1027
  {
884
1028
  group: null,
885
1029
  name: "login",
@@ -963,6 +1107,11 @@ function mark(schema, kind2) {
963
1107
  function openObject(shape) {
964
1108
  return z7.looseObject(shape);
965
1109
  }
1110
+ function protocolObject() {
1111
+ const schema = z7.record(z7.string(), z7.unknown());
1112
+ mark(schema, "protocol");
1113
+ return schema;
1114
+ }
966
1115
  function openEnum(values) {
967
1116
  const schema = z7.union([
968
1117
  z7.enum(values),
@@ -1026,6 +1175,7 @@ function strictify(schema) {
1026
1175
  delete next[OPEN];
1027
1176
  return schema.clone(next);
1028
1177
  };
1178
+ if (kind2 === "protocol") return schema;
1029
1179
  if (kind2 === "enum") return strictify(def.options[0]);
1030
1180
  if (kind2 === "union") {
1031
1181
  return rebuild({ options: def.options.slice(0, -1).map(strictify) });
@@ -1068,17 +1218,17 @@ function strictify(schema) {
1068
1218
 
1069
1219
  // src/guide-data.generated.ts
1070
1220
  var FRAGMENTS = {
1071
- "booking": "{{#if claude-skill cli}}\n## Ordering\n\n{{/if}}\n- Call `{{tool:hotels book}}` only for the offer the user picked, with at least one guest per room{{#if claude-skill cli}}, named as the user gave them{{/if}}; never invent guests.{{#if claude-skill cli}} Room 1 is the offer's first room, and a room takes no more guests than it sleeps.{{/if}}\n- Guest names: Latin letters as on the passport (M\xFCller \u2192 Mueller), first and last name 1\u2013{{limit:guestName}} characters each{{#if cli}}, as `--guest 1:John:Smith` (room 1, first name, last name){{/if}}.\n{{#if claude-skill cli}}\n- The contact's first and last name (up to {{limit:contactFirstName}} characters each), email and phone (with its country code) are all required. Special requests must be in English and aren't guaranteed.\n{{/if}}\n- `{{tool:hotels book}}` can take up to about two minutes{{#if cli}}: allow the command at least 3 minutes{{/if}}. If it times out, {{#if cli}}run it again with identical flags{{/if}}{{#if mcp claude-skill}}call it again with the same details{{/if}}: it returns the same order.\n{{#if mcp}}\n- On `offer_changed`, show the user every change and ask again before ordering the new offer.\n{{/if}}\n{{#if cli}}\n- `{{tool:hotels book}}` takes only these fields: a `--body` with any other field (such as `nationality`) is rejected with exit 2.\n{{/if}}\n",
1221
+ "booking": "{{#if claude-skill cli}}\n## Ordering\n\n{{/if}}\n- Call `{{tool:hotels book}}` only for the offer the user picked, with at least one guest per room{{#if claude-skill cli}}, named as the user gave them{{/if}}; never invent guests.{{#if claude-skill cli}} Room 1 is the offer's first room, and a room takes no more guests than it sleeps.{{/if}}\n- Guest names: Latin letters as on the passport (M\xFCller \u2192 Mueller), first and last name 1\u2013{{limit:guestName}} characters each{{#if cli}}, as `--guest 1:John:Smith` (room 1, first name, last name){{/if}}.\n{{#if claude-skill cli}}\n- The contact's first and last name (up to {{limit:contactFirstName}} characters each), email and phone (with its country code) are all required. Special requests must be in English and aren't guaranteed.\n{{/if}}\n- `{{tool:hotels book}}` can take about two minutes{{#if cli}}: allow the command at least 3 minutes{{/if}}. If it times out, {{#if cli}}run it again with identical flags{{/if}}{{#if mcp claude-skill}}call it again with the same details{{/if}}: it returns the same order.\n{{#if mcp}}\n- On `offer_changed`, show the user every change and ask again before ordering the new offer.\n{{/if}}\n{{#if cli}}\n- `{{tool:hotels book}}` takes only these fields: a `--body` with any other field (such as `nationality`) is rejected with exit 2.\n{{/if}}\n",
1072
1222
  "errors": "{{#if claude-skill cli}}\n## Errors\n\n{{#if claude-skill}}A tool error{{/if}}{{#if cli}}An error on stderr{{/if}} carries `code`, `message` and `retryable`, and `retryAfterSeconds` when waiting helps; many carry `details`. Search errors are under Search. Ordering errors:\n\n| `code` | Do this |\n|---|---|\n| `offer_changed` (409) | The price or terms changed since the offer: `changes` lists every change (`worse` says which are worse for the user) and `offer` is the new offer. Show the user every change and ask again; if they still want it, order the new offer, and confirm the new order before giving its link |\n| `offer_expired` (409) | Get offers again and let the user choose again |\n| `offer_unavailable` (422) | The offer is sold out or was refused: get offers again and let the user choose again |\n| `order_in_progress` (409) | The same order is still being created: wait `retryAfterSeconds`, then {{#if claude-skill}}call again with the same details{{/if}}{{#if cli}}run the command again with identical flags{{/if}} |\n| `offer_already_ordered` (409) | This offer was already ordered with other details: show that order (`orderId`) instead. An offer is ordered once |\n| `order_exists` (409) | This stay already has an open order for one of these guests (`orderId`, `status`): show it instead of ordering again. A party with none of its guests can order the stay from a new offer (get offers again), and so can the user once the stay's order is confirmed, cancelled or refused by the hotel. It also answers when the stay's earlier order failed at the hotel with its outcome unknown, or the stay has had 20 orders; for those, the user emails {{support}} |\n| `order_attempts_exhausted` (409) | This order can't be tried again: the user emails {{support}} with its `reference` |\n| `order_removed` (410) | The order was never completed and no payment is held: get offers again and order the new offer (the order keeps its `orderId`) |\n| `stay_unsupported` (422) | `mixed_occupancy`: order once per party; `max_nights`: at most `max` nights per order |\n| `stay_in_past` (422) | Check-in has passed in the hotel's time zone: ask for new dates |\n| `ordering_paused` (503) | Ordering is paused on Fortrip's side: tell the user, and try again only after `retryAfterSeconds` (10 minutes or more) |\n\nAny code:\n\n- `invalid_request` (400): `details.issues` lists each bad field; fix them. For amenities, `details.filterable` lists those that can filter.\n- `cursor_invalid` (400): the page is gone; search again from the first page.\n- `not_found` (404): no such hotel, or no such order for this user.\n- `rate_limited` (429): wait `retryAfterSeconds`, then retry once.\n- `service_unavailable` (503) and `supplier_unavailable` (503 or 504): wait `retryAfterSeconds`, then retry once with the same details; if it fails again, tell the user.\n- Any other code: read `message`. If `retryable` is true, wait `retryAfterSeconds` and retry once; otherwise tell the user instead of guessing.\n{{/if}}\n",
1073
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',
1074
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",
1075
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',
1076
- "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## 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 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 `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",
1077
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",
1078
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",
1079
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",
1080
- "scope": "{{#if claude-skill cli}}\n# Fortrip hotel stays\n\n{{/if}}\nFortrip: hotel search, live offers and orders with a payment link.{{#if claude-skill cli}} Not for flights, activities, or changing an existing order.{{/if}}\n\n{{#if mcp}}\nCall order: `{{tool:hotels search}}` \u2192 (optional) `{{tool:hotels get}}` \u2192 `{{tool:hotels offers}}` \u2192 `{{tool:hotels book}}`; after the user pays, `{{tool:orders get}}`; `{{tool:orders list}}` lists their orders; `{{tool:orders cancel}}` cancels one. `{{tool:guide}}` returns Fortrip's guidance for flexible dates, budgets or several destinations.\n{{/if}}\n{{#if claude-skill}}\nThe tools are on Fortrip's MCP server, named `fortrip` in this plugin (a Fortrip connector added on claude.ai can show under its own name). They're written `fortrip:<tool>` below:\n{{/if}}\n{{#if cli}}\nThe `fortrip` CLI (npm package `fortrip`) calls Fortrip as the signed-in user and prints each answer as compact text (`--json` prints its JSON):\n{{/if}}\n{{#if claude-skill cli}}\n\n| {{#if claude-skill}}Tool{{/if}}{{#if cli}}Command{{/if}} | Returns |\n|---|---|\n| `{{tool:hotels search}}` | Hotels in a place, near a point or matching a name (`{{arg:text}}`), with indicative prices |\n| `{{tool:hotels get}}` | One hotel's address, check-in and check-out times, description, policies, amenities and rooms; no prices |\n| `{{tool:hotels offers}}` | Live offers (room, meals, total in USD, cancellation terms) for up to {{limit:offersHotels}} hotels |\n| `{{tool:hotels book}}` | An unpaid order for one offer, with its terms and a payment link |\n| `{{tool:orders get}}` | One order and its status, including whether the hotel confirmed it |\n| `{{tool:orders list}}` | The user's orders, newest first, including those made on the Fortrip website |\n| `{{tool:orders cancel}}` | Cancels an order under its terms, for the penalty the user agreed to, and refunds the rest |\n\nFor flexible dates, a budget, split stays, several destinations or \"find me the best\", {{#if claude-skill}}read [references/planning.md](references/planning.md){{/if}}{{#if cli}}also run `{{tool:guide}} planning`{{/if}} before searching.\n{{/if}}\n",
1081
- "setup": "{{#if cli}}\n## Setup\n\nRun every command as `npx -y fortrip@latest <command>` (Node.js 22 or newer). The examples below shorten that to `fortrip`; `fortrip <command> --help` lists a command's flags. `{{tool:hotels search}}`, `{{tool:hotels offers}}` and `{{tool:hotels book}}` also take `--body '<json>'` (or `--body @file.json`), the raw request body; flags override its fields. Add `--json` to any command that calls Fortrip to get its answer as one line of JSON instead of text.\n\nWhen the user first asks about hotels, run `{{tool:whoami}}` before asking follow-up questions, so the sign-in can happen while they answer.\n\n{{/if}}\n{{#if claude-skill cli}}\n## Sign-in\n\n{{/if}}\nSign-in happens only in the browser. Never ask the user to paste a token.\n{{#if claude-skill}}\n\nIf none of these tools are available, Fortrip isn't connected: tell the user to add the Fortrip connector or plugin and sign in.\n{{/if}}\n{{#if mcp claude-skill}}\nIf a tool says the user isn't signed in, ask them to reconnect Fortrip.\n{{/if}}\n{{#if cli}}\n\nIf a command exits with code **3** and stderr has `loginUrl`, show it to the user as a link together with `userCode`, e.g. \"Sign in to Fortrip: <loginUrl> (code <userCode>), then tell me when you're done.\" When they confirm, rerun the same command; it finishes the sign-in itself. Don't run `{{tool:login}}`: it waits for up to 10 minutes. Commands that exit 3 together share one `loginUrl`; show it once. If the rerun gives a different `loginUrl`, show that one.\n\nWhen Fortrip no longer accepts the saved sign-in (it was revoked, or it expired and couldn't be renewed), the command also exits 3 with a `loginUrl`; handle it the same way. The saved sign-in is kept until the user approves the new link.\n\nIn CI or a sandbox without a browser, the user can set `FORTRIP_TOKEN` instead. Exit 3 with `tokenSource: \"FORTRIP_TOKEN\"` means Fortrip didn't accept that token: tell the user to replace or unset it.\n\n## Exit codes\n\n| Code | Meaning | What to do |\n|---|---|---|\n| 0 | Success; the answer on stdout | Continue |\n| 1 | Any other error: an error from Fortrip (see Errors), a network error or a timeout | Read the error on stderr. If `retryable` is true, wait `retryAfterSeconds` (or a few seconds) and retry once |\n| 2 | Invalid arguments, or `invalid_request` from Fortrip | Fix the flags; the error lists each bad field with a message |\n| 3 | Not signed in | Show `loginUrl` to the user, then rerun (above) |\n| 4 | Rate limited | Wait `retryAfterSeconds`, then retry once |\n\nOutput on stdout or stderr can carry `warning` (with `recoveryFile` when a sign-in couldn't be saved): pass it on to the user.\n{{/if}}\n",
1230
+ "scope": "{{#if claude-skill cli}}\n# Fortrip hotel stays\n\n{{/if}}\nFortrip: hotel search, live offers and orders with a payment link.{{#if claude-skill cli}} Not for flights, activities, or changing an existing order.{{/if}}\n\n{{#if mcp}}\nCall order: `{{tool:hotels search}}` \u2192 (optional) `{{tool:hotels get}}` \u2192 `{{tool:hotels offers}}` \u2192 `{{tool:hotels book}}`; after the user pays, `{{tool:orders get}}`; `{{tool:orders list}}` lists them; `{{tool:orders cancel}}` cancels one, `{{tool:orders pay}}` pays by token. `{{tool:guide}}` returns Fortrip's guidance for flexible dates, budgets or several destinations.\n{{/if}}\n{{#if claude-skill}}\nThe tools are on Fortrip's MCP server, named `fortrip` in this plugin (a Fortrip connector added on claude.ai can show under its own name). They're written `fortrip:<tool>` below:\n{{/if}}\n{{#if cli}}\nThe `fortrip` CLI (npm package `fortrip`) calls Fortrip as the signed-in user and prints each answer as compact text (`--json` prints its JSON):\n{{/if}}\n{{#if claude-skill cli}}\n\n| {{#if claude-skill}}Tool{{/if}}{{#if cli}}Command{{/if}} | Returns |\n|---|---|\n| `{{tool:hotels search}}` | Hotels in a place, near a point or matching a name (`{{arg:text}}`), with indicative prices |\n| `{{tool:hotels get}}` | One hotel's address, check-in and check-out times, description, policies, amenities and rooms; no prices |\n| `{{tool:hotels offers}}` | Live offers (room, meals, total in USD, cancellation terms) for up to {{limit:offersHotels}} hotels |\n| `{{tool:hotels book}}` | An unpaid order for one offer, with its terms and a payment link |\n| `{{tool:orders get}}` | One order and its status, including whether the hotel confirmed it |\n| `{{tool:orders list}}` | The user's orders, newest first, including those made on the Fortrip website |\n| `{{tool:orders cancel}}` | Cancels an order under its terms, for the penalty the user agreed to, and refunds the rest |\n| `{{tool:orders pay}}` | Pays an order without its link, with a shared payment token from the user's wallet |\n\nFor flexible dates, a budget, split stays, several destinations or \"find me the best\", {{#if claude-skill}}read [references/planning.md](references/planning.md){{/if}}{{#if cli}}also run `{{tool:guide}} planning`{{/if}} before searching.\n{{/if}}\n",
1231
+ "setup": "{{#if cli}}\n## Setup\n\nRun every command as `npx -y fortrip@latest <command>` (Node.js 22 or newer). The examples below shorten that to `fortrip`; `fortrip <command> --help` lists a command's flags. `{{tool:hotels search}}`, `{{tool:hotels offers}}` and `{{tool:hotels book}}` also take `--body '<json>'` (or `--body @file.json`), the raw request body; flags override its fields. Add `--json` to any command that calls Fortrip to get its answer as one line of JSON instead of text.\n\nWhen the user first asks about hotels, run `{{tool:whoami}}` before asking follow-up questions, so the sign-in can happen while they answer.\n\n{{/if}}\n{{#if claude-skill cli}}\n## Sign-in\n\n{{/if}}\nSign-in happens only in the browser. Never ask the user to paste a token.\n{{#if claude-skill}}\n\nIf none of these tools are available, Fortrip isn't connected: tell the user to add the Fortrip connector or plugin and sign in.\n{{/if}}\n{{#if mcp claude-skill}}\nIf a tool says the user isn't signed in, ask them to reconnect.\n{{/if}}\n{{#if cli}}\n\nIf a command exits with code **3** and stderr has `loginUrl`, show it to the user as a link together with `userCode`, e.g. \"Sign in to Fortrip: <loginUrl> (code <userCode>), then tell me when you're done.\" When they confirm, rerun the same command; it finishes the sign-in itself. Don't run `{{tool:login}}`: it waits for up to 10 minutes. Commands that exit 3 together share one `loginUrl`; show it once. If the rerun gives a different `loginUrl`, show that one.\n\nWhen Fortrip no longer accepts the saved sign-in (it was revoked, or it expired and couldn't be renewed), the command also exits 3 with a `loginUrl`; handle it the same way. The saved sign-in is kept until the user approves the new link.\n\nIn CI or a sandbox without a browser, the user can set `FORTRIP_TOKEN` instead. Exit 3 with `tokenSource: \"FORTRIP_TOKEN\"` means Fortrip didn't accept that token: tell the user to replace or unset it.\n\n## Exit codes\n\n| Code | Meaning | What to do |\n|---|---|---|\n| 0 | Success; the answer on stdout | Continue |\n| 1 | Any other error: an error from Fortrip (see Errors), a network error or a timeout | Read the error on stderr. If `retryable` is true, wait `retryAfterSeconds` (or a few seconds) and retry once |\n| 2 | Invalid arguments, or `invalid_request` from Fortrip | Fix the flags; the error lists each bad field with a message |\n| 3 | Not signed in | Show `loginUrl` to the user, then rerun (above) |\n| 4 | Rate limited | Wait `retryAfterSeconds`, then retry once |\n\nOutput on stdout or stderr can carry `warning` (with `recoveryFile` when a sign-in couldn't be saved): pass it on to the user.\n{{/if}}\n",
1082
1232
  "support": "{{#if claude-skill cli}}\n## Cancelling an order\n\n`{{tool:orders get}}` and `{{tool:orders list}}` say of each order whether the user can cancel it now (`cancel.available`), and then the penalty under its terms (`cancel.penalty`) and the refund, what was paid less the penalty (`cancel.refund`), both in the charge currency; otherwise `cancel.reason` says why not.\n\n1. Show the user the stay (hotel, dates), `cancel.penalty` and `cancel.refund` (amount and currency). A refund of 0 means nothing is paid back: say so plainly.\n2. End that reply by asking the user to confirm the cancellation, and wait for a clear yes.\n3. Then {{#if claude-skill}}call{{/if}}{{#if cli}}run{{/if}} `{{tool:orders cancel}}` with `{{arg:maximumPenalty}}` set to `cancel.penalty.amount` as shown. Never state a refund the order didn't return, and never choose or work out an amount yourself.\n\nThe order is then `cancelling`, and `cancelled` once the hotel has cancelled and the refund is issued: check it with `{{tool:orders get}}`. If the hotel refuses, the order is `confirmed` again with `cancel.reason` `refused`. `cancellation_changed` (409) means the penalty is now higher than the one the user agreed to: read the order again and ask the user again. `order_not_cancellable` (409) says why in `reason`.{{#if cli}} Without `--max-penalty`, `{{tool:orders cancel}}` cancels nothing: it prints the penalty and the refund and exits 2.{{/if}}\n\n## Changes and support\n\n{{/if}}\n{{#if mcp}}For changes{{/if}}{{#if claude-skill}}These tools can't change an order: for changes{{/if}}{{#if cli}}The CLI can't change an order: for changes{{/if}}, a cancellation that `{{tool:orders cancel}}` can't make, or other problems, the user emails {{support}} with the order's `reference` (never `payment.url`).\n"
1083
1233
  };
1084
1234
 
@@ -1259,6 +1409,13 @@ var ERROR_CODES = {
1259
1409
  order_attempts_exhausted: { status: [409], retryable: false },
1260
1410
  cancellation_changed: { status: [409], retryable: false },
1261
1411
  order_not_cancellable: { status: [409], retryable: false },
1412
+ order_not_payable: { status: [409], retryable: false },
1413
+ payment_in_progress: { status: [409], retryable: true },
1414
+ payment_total_changed: { status: [409], retryable: false },
1415
+ payment_credential_invalid: { status: [422], retryable: false },
1416
+ payment_declined: { status: [402], retryable: false },
1417
+ payment_action_required: { status: [402], retryable: false },
1418
+ payment_method_unavailable: { status: [403], retryable: false },
1262
1419
  destination_ambiguous: { status: [422], retryable: false },
1263
1420
  destination_not_found: { status: [422], retryable: false },
1264
1421
  search_too_broad: { status: [422], retryable: false },
@@ -1648,6 +1805,25 @@ var CANCEL_REASONS = [
1648
1805
  "terms_unknown",
1649
1806
  "needs_attention"
1650
1807
  ];
1808
+ var CREDENTIAL_INVALID_REASONS = [
1809
+ "not_found",
1810
+ "currency",
1811
+ "amount",
1812
+ "expired",
1813
+ "deactivated",
1814
+ "used",
1815
+ "other_seller"
1816
+ ];
1817
+ var paymentHandler = openObject({
1818
+ id: z14.string(),
1819
+ type: z14.string(),
1820
+ version: z14.string(),
1821
+ spec: z14.string(),
1822
+ schema: z14.string().optional(),
1823
+ available_instruments: z14.array(openObject({ type: z14.string(), config: protocolObject().optional() })).optional(),
1824
+ config: protocolObject().optional(),
1825
+ networkId: z14.string().nullable()
1826
+ });
1651
1827
  var orderReference = z14.string().regex(/^FT-[2-9A-HJ-NP-Z]{6}$/);
1652
1828
  var hotelItem = openObject({
1653
1829
  type: z14.literal("hotel"),
@@ -1684,7 +1860,20 @@ var order = openObject({
1684
1860
  expiresAt: instant.nullable(),
1685
1861
  chargeCurrency: z14.string(),
1686
1862
  localCurrencyAtCheckout: z14.boolean(),
1687
- localCharge: money.nullable()
1863
+ localCharge: money.nullable(),
1864
+ /** The ways to pay other than `url`, while the order can be paid that
1865
+ * way (3.4): a `com.stripe.payments` handler takes a shared payment
1866
+ * token through `pay_order`. Absent when there is none. */
1867
+ handlers: z14.array(paymentHandler).optional(),
1868
+ /** What a payment credential for `pay_order` must allow, present with
1869
+ * `handlers` (3.4): `maxAmount` in minor units (cents) of `currency`,
1870
+ * lowercase as Stripe takes it, and `expiresAt`, past which the order
1871
+ * can't be paid. */
1872
+ credentialLimits: openObject({
1873
+ maxAmount: z14.number().int(),
1874
+ currency: z14.string(),
1875
+ expiresAt: instant
1876
+ }).optional()
1688
1877
  }),
1689
1878
  /** Whether the user can cancel the order now and, when they can, its
1690
1879
  * penalty under the accepted terms (read a minute ahead) and the refund,
@@ -1744,6 +1933,15 @@ var ERROR_DETAILS = {
1744
1933
  order_attempts_exhausted: openObject({ orderId }),
1745
1934
  cancellation_changed: null,
1746
1935
  order_not_cancellable: openObject({ reason: openEnum(CANCEL_REASONS) }),
1936
+ order_not_payable: openObject({ orderId, status: openEnum(ORDER_STATUSES) }),
1937
+ payment_in_progress: openObject({ orderId }),
1938
+ payment_total_changed: openObject({ orderId, total: money }),
1939
+ payment_credential_invalid: openObject({
1940
+ reason: openEnum(CREDENTIAL_INVALID_REASONS)
1941
+ }),
1942
+ payment_declined: openObject({ declineCode: z15.string().nullable() }),
1943
+ payment_action_required: null,
1944
+ payment_method_unavailable: null,
1747
1945
  destination_ambiguous: openObject({
1748
1946
  name: z15.string(),
1749
1947
  countryCode: z15.string(),
@@ -1802,7 +2000,8 @@ var ERROR_DETAILS = {
1802
2000
  "hotel",
1803
2001
  "orders_read",
1804
2002
  "orders_create",
1805
- "orders_cancel"
2003
+ "orders_cancel",
2004
+ "orders_pay"
1806
2005
  ])
1807
2006
  }),
1808
2007
  ordering_paused: null,
@@ -1861,6 +2060,9 @@ var API = {
1861
2060
  },
1862
2061
  orderCancel(id) {
1863
2062
  return `/v1/orders/${encodeURIComponent(id)}/cancel`;
2063
+ },
2064
+ orderPay(id) {
2065
+ return `/v1/orders/${encodeURIComponent(id)}/pay`;
1864
2066
  }
1865
2067
  };
1866
2068
  var MCP_PATH = "/";
@@ -1869,6 +2071,7 @@ var MCP_PATH = "/";
1869
2071
  import { z as z16 } from "zod";
1870
2072
  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.";
1871
2073
  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.";
2074
+ 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 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.";
1872
2075
  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.";
1873
2076
  var nextStep = z16.string().optional().describe(
1874
2077
  "What to show and ask before giving a payment.url. Present when the answer holds a non-null payment.url, and only then."
@@ -1877,7 +2080,8 @@ var MCP_OUTPUT = {
1877
2080
  book_hotel: order.extend({ nextStep }),
1878
2081
  get_order: order.extend({ nextStep }),
1879
2082
  list_orders: orderList.extend({ nextStep }),
1880
- cancel_order: order
2083
+ cancel_order: order,
2084
+ pay_order: order
1881
2085
  };
1882
2086
  var READ = {
1883
2087
  readOnlyHint: true,
@@ -1960,6 +2164,19 @@ var TOOLS = [
1960
2164
  },
1961
2165
  input: cancelOrderInput,
1962
2166
  output: MCP_OUTPUT.cancel_order
2167
+ },
2168
+ {
2169
+ name: "pay_order",
2170
+ title: "Pay order with a shared payment token",
2171
+ 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 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.",
2172
+ annotations: {
2173
+ readOnlyHint: false,
2174
+ idempotentHint: true,
2175
+ openWorldHint: true,
2176
+ destructiveHint: false
2177
+ },
2178
+ input: payOrderInput,
2179
+ output: MCP_OUTPUT.pay_order
1963
2180
  }
1964
2181
  ];
1965
2182
 
@@ -2313,10 +2530,20 @@ function paymentLines(o) {
2313
2530
  } else if (o.status === "awaiting_payment") {
2314
2531
  lines.push("Payment link: could not be read this time; read this order again for it.");
2315
2532
  }
2533
+ if (p.handlers?.length) lines.push(handlersLine(p.handlers, p.credentialLimits));
2316
2534
  if (o.cancel) lines.push(cancelLine(o.cancel));
2317
2535
  lines.push(`Manage: ${o.manageUrl}`);
2318
2536
  return lines;
2319
2537
  }
2538
+ function handlersLine(handlers, limits) {
2539
+ const shown = handlers.map((h) => {
2540
+ const profile = h.config?.business_profile;
2541
+ const businessProfile = typeof profile === "string" ? profile : h.networkId;
2542
+ return `${h.type} (handler ${h.id}${businessProfile ? `, business_profile ${businessProfile}` : ""})`;
2543
+ });
2544
+ const limit = limits ? `; token limits: maxAmount ${limits.maxAmount} (cents), currency ${limits.currency}, expiresAt ${limits.expiresAt}` : "";
2545
+ return `Pay without the link: pay_order with a shared payment token via ${shown.join(", ")}${limit}`;
2546
+ }
2320
2547
  function cancelLine(c) {
2321
2548
  const figure = (name, m) => `${name} ${m ? money2(m) : "not stated"}`;
2322
2549
  const figures = `${figure("penalty", c.penalty)}, ${figure("refund", c.refund)}`;
@@ -2526,6 +2753,15 @@ function renderSearch(r) {
2526
2753
  }
2527
2754
 
2528
2755
  // src/render/errors.ts
2756
+ var CREDENTIAL_INVALID_WORDS = {
2757
+ not_found: "was not found",
2758
+ currency: "is for another currency than USD",
2759
+ amount: "allows less than the order's total",
2760
+ expired: "expires before it can be charged",
2761
+ deactivated: "was revoked",
2762
+ used: "was already used, or is held for another order",
2763
+ other_seller: "was granted to another seller"
2764
+ };
2529
2765
  var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
2530
2766
  function changeLine(c) {
2531
2767
  const worse = c.worse === true ? " (worse)" : c.worse === false ? " (not worse)" : "";
@@ -2642,6 +2878,24 @@ function detailLines(e) {
2642
2878
  return [`Order ${e.details.orderId}, ${label(ORDER_STATUS_WORDS, e.details.status)}.`];
2643
2879
  case "order_not_cancellable":
2644
2880
  return [`Not cancellable: ${label(CANCEL_REASON_WORDS, e.details.reason)}.`];
2881
+ case "order_not_payable":
2882
+ return [
2883
+ `Order ${e.details.orderId}, ${label(ORDER_STATUS_WORDS, e.details.status)}: read it with get_order; nothing was charged.`
2884
+ ];
2885
+ case "payment_in_progress":
2886
+ return [`Order ${e.details.orderId}: read it with get_order in a few seconds.`];
2887
+ case "payment_total_changed":
2888
+ return [
2889
+ `Order ${e.details.orderId} now totals ${money2(e.details.total)}: show the user the new total and ask again, then request a new token for it. Nothing was charged.`
2890
+ ];
2891
+ case "payment_credential_invalid":
2892
+ return [
2893
+ `The token ${label(CREDENTIAL_INVALID_WORDS, e.details.reason)}: request a new one with the order's payment.credentialLimits. Nothing was charged.`
2894
+ ];
2895
+ case "payment_declined":
2896
+ return [
2897
+ `Declined${e.details.declineCode ? ` (${e.details.declineCode})` : ""}: the user picks another payment method in their wallet for a new token, or pays by link (call book_hotel again with the same details for a new payment.url).`
2898
+ ];
2645
2899
  case "destination_ambiguous":
2646
2900
  return ambiguous(e.details);
2647
2901
  case "destination_not_found":
@@ -2718,6 +2972,7 @@ ${raw(data)}`;
2718
2972
  return [
2719
2973
  text2,
2720
2974
  ORDER_TOOLS.has(tool) && holdsPaymentUrl(data) ? ORDER_NEXT_STEP : "",
2975
+ ORDER_TOOLS.has(tool) && holdsHandlers(data) ? PAY_NEXT_STEP : "",
2721
2976
  CANCEL_TOOLS.has(tool) && holdsCancellable(data) ? CANCEL_NEXT_STEP : ""
2722
2977
  ].filter(Boolean).join("\n\n");
2723
2978
  }
@@ -2738,6 +2993,7 @@ ${raw(data)}`;
2738
2993
  return withConsent(tool, renderOrderList(list), list.data);
2739
2994
  }
2740
2995
  case "cancel_order":
2996
+ case "pay_order":
2741
2997
  return renderOrder(parsed);
2742
2998
  }
2743
2999
  }
@@ -2752,6 +3008,15 @@ function holdsPaymentUrl(value, seen = /* @__PURE__ */ new Set()) {
2752
3008
  }
2753
3009
  return Object.values(value).some((v) => holdsPaymentUrl(v, seen));
2754
3010
  }
3011
+ function holdsHandlers(value, seen = /* @__PURE__ */ new Set()) {
3012
+ if (typeof value !== "object" || value === null || seen.has(value)) return false;
3013
+ seen.add(value);
3014
+ const payment = value.payment;
3015
+ if (typeof payment === "object" && payment !== null && Array.isArray(payment.handlers) && payment.handlers.length > 0) {
3016
+ return true;
3017
+ }
3018
+ return Object.values(value).some((v) => holdsHandlers(v, seen));
3019
+ }
2755
3020
  function holdsCancellable(value, seen = /* @__PURE__ */ new Set()) {
2756
3021
  if (typeof value !== "object" || value === null || seen.has(value)) return false;
2757
3022
  seen.add(value);
@@ -2765,6 +3030,7 @@ function withConsent(tool, text2, orders) {
2765
3030
  return [
2766
3031
  text2,
2767
3032
  orders.some((o) => o.payment.url !== null) ? ORDER_NEXT_STEP : "",
3033
+ orders.some((o) => (o.payment.handlers?.length ?? 0) > 0) ? PAY_NEXT_STEP : "",
2768
3034
  CANCEL_TOOLS.has(tool) && orders.some((o) => o.cancel?.available === true) ? CANCEL_NEXT_STEP : ""
2769
3035
  ].filter(Boolean).join("\n\n");
2770
3036
  }
@@ -2795,6 +3061,8 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
2795
3061
  requiresSignIn: `${API_DECIDES} (whether the payment link needs a website sign-in).`,
2796
3062
  localCurrencyAtCheckout: `${API_DECIDES} (whether checkout may charge in the card's currency).`,
2797
3063
  "cancel.available": `${API_DECIDES} (whether an order can be cancelled now).`,
3064
+ "payment.handlers": `${RESULT_LIST} (the ways to pay an order other than its link; absent when there is none).`,
3065
+ available_instruments: `${RESULT_LIST} (the instruments a payment handler takes).`,
2798
3066
  bookable: `${API_DECIDES} (whether the hotel is still in the index).`,
2799
3067
  cityLike: `${API_DECIDES} (frozen per gazetteer release; null where not computed).`,
2800
3068
  known: `${THE_FLAG} (meals).`,
@@ -2804,7 +3072,7 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
2804
3072
  // package.json
2805
3073
  var package_default = {
2806
3074
  name: "@fortrip/agent-contract",
2807
- version: "3.3.1",
3075
+ version: "3.5.0",
2808
3076
  license: "Apache-2.0",
2809
3077
  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.",
2810
3078
  type: "module",
@@ -2862,6 +3130,7 @@ export {
2862
3130
  COMMANDS,
2863
3131
  COMMAND_GROUPS,
2864
3132
  CONTRACT_VERSION,
3133
+ CREDENTIAL_INVALID_REASONS,
2865
3134
  DISPLAY_CURRENCIES,
2866
3135
  ERROR_CODES,
2867
3136
  ERROR_DETAILS,
@@ -2876,6 +3145,7 @@ export {
2876
3145
  ORDER_NEXT_STEP,
2877
3146
  ORDER_STATUSES,
2878
3147
  PAYMENT_STATUSES,
3148
+ PAY_NEXT_STEP,
2879
3149
  PLACE_KINDS,
2880
3150
  POLICY_TOPICS,
2881
3151
  PRESENTATION_HINT,
@@ -2939,16 +3209,20 @@ export {
2939
3209
  orderReference,
2940
3210
  parseOpen,
2941
3211
  payAtProperty,
3212
+ payOrderInput,
3213
+ paymentHandler,
2942
3214
  photo,
2943
3215
  place,
2944
3216
  placeId,
2945
3217
  placeRef,
3218
+ protocolObject,
2946
3219
  renderError,
2947
3220
  renderGuide,
2948
3221
  renderToolResult,
2949
3222
  roomFacts,
2950
3223
  searchHotelsInput,
2951
3224
  searchResult,
3225
+ sharedPaymentTokenOf,
2952
3226
  stay,
2953
3227
  stayEcho,
2954
3228
  strictErrorEnvelope,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fortrip/agent-contract",
3
- "version": "3.3.1",
3
+ "version": "3.5.0",
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",