@fortrip/agent-contract 3.4.0 → 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,8 +53,9 @@ declare function parseOpen<T>(schema: z.ZodType<T>, value: unknown): T;
47
53
  * no unknown enum values, no fallback union branch. Wrappers (optional,
48
54
  * nullable, default, readonly, pipe, lazy) and containers (object, array,
49
55
  * tuple, record) are rebuilt around their closed contents, keeping their
50
- * checks and metadata. A schema type it cannot close (any, unknown,
51
- * intersection, custom, ...) throws instead of silently staying open.
56
+ * checks and metadata. A protocol object stays as it is. A schema type it
57
+ * cannot close (any, unknown, intersection, custom, ...) throws instead of
58
+ * silently staying open.
52
59
  */
53
60
  declare function strictOutput<T extends z.ZodType>(schema: T): T;
54
61
 
@@ -87,7 +94,7 @@ declare const CANCEL_NEXT_STEP = "Before you call cancel_order, show the user th
87
94
  * holds an order with `payment.handlers`, after `ORDER_NEXT_STEP`, and in
88
95
  * the description of `pay_order`; never as `nextStep`.
89
96
  */
90
- declare const PAY_NEXT_STEP = "To pay without the link, when the order has payment.handlers and the user's wallet can grant a Stripe shared payment token: first show and ask exactly as for payment.url, and wait for a clear yes. Then request the token for this order from the user's wallet with the handler's networkId and payment.credentialLimits (maxAmount in cents, currency, expiresAt), and call pay_order with it and the order's price.total. The charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once pay_order succeeds, payment.url stops working.";
97
+ declare const PAY_NEXT_STEP = "To pay without the link, when the order 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.";
91
98
  /**
92
99
  * How to present hotels (the `presentation` guide, in one line). It rides as
93
100
  * the last paragraph of every MCP `search_hotels`, `get_hotel` and
@@ -247,6 +254,12 @@ declare const MCP_OUTPUT: {
247
254
  type: z.ZodString;
248
255
  version: z.ZodString;
249
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>>>;
250
263
  networkId: z.ZodNullable<z.ZodString>;
251
264
  }, z.core.$strip>>>;
252
265
  credentialLimits: z.ZodOptional<z.ZodObject<{
@@ -411,6 +424,12 @@ declare const MCP_OUTPUT: {
411
424
  type: z.ZodString;
412
425
  version: z.ZodString;
413
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>>>;
414
433
  networkId: z.ZodNullable<z.ZodString>;
415
434
  }, z.core.$strip>>>;
416
435
  credentialLimits: z.ZodOptional<z.ZodObject<{
@@ -576,6 +595,12 @@ declare const MCP_OUTPUT: {
576
595
  type: z.ZodString;
577
596
  version: z.ZodString;
578
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>>>;
579
604
  networkId: z.ZodNullable<z.ZodString>;
580
605
  }, z.core.$strip>>>;
581
606
  credentialLimits: z.ZodOptional<z.ZodObject<{
@@ -742,6 +767,12 @@ declare const MCP_OUTPUT: {
742
767
  type: z.ZodString;
743
768
  version: z.ZodString;
744
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>>>;
745
776
  networkId: z.ZodNullable<z.ZodString>;
746
777
  }, z.core.$strip>>>;
747
778
  credentialLimits: z.ZodOptional<z.ZodObject<{
@@ -905,6 +936,12 @@ declare const MCP_OUTPUT: {
905
936
  type: z.ZodString;
906
937
  version: z.ZodString;
907
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>>>;
908
945
  networkId: z.ZodNullable<z.ZodString>;
909
946
  }, z.core.$strip>>>;
910
947
  credentialLimits: z.ZodOptional<z.ZodObject<{
@@ -1353,14 +1390,33 @@ declare const cancelOrderInput: z.ZodObject<{
1353
1390
  type CancelOrderInput = z.input<typeof cancelOrderInput>;
1354
1391
  /** `POST /v1/orders/{orderId}/pay` and the MCP `pay_order` arguments: the
1355
1392
  * order, a Stripe shared payment token granted for it, and the total the
1356
- * user approved. A total other than the order's answers
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
1357
1396
  * `payment_total_changed` and charges nothing. */
1358
1397
  declare const payOrderInput: z.ZodObject<{
1359
1398
  orderId: z.ZodString;
1360
- sharedPaymentToken: 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>>;
1361
1413
  total: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
1362
1414
  }, z.core.$strict>;
1363
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;
1364
1420
 
1365
1421
  /** The ceilings and floors every agent surface enforces and documents (spec §15). */
1366
1422
  declare const LIMITS: {
@@ -2340,15 +2396,26 @@ type CancelReason = (typeof CANCEL_REASONS)[number];
2340
2396
  declare const CREDENTIAL_INVALID_REASONS: readonly ["not_found", "currency", "amount", "expired", "deactivated", "used", "other_seller"];
2341
2397
  type CredentialInvalidReason = (typeof CREDENTIAL_INVALID_REASONS)[number];
2342
2398
  /** A way to pay an order other than its link, after the Universal Commerce
2343
- * Protocol's payment handlers: `type` names it (`com.stripe.payments`),
2344
- * `version` and `spec` the handler specification it follows, and
2345
- * `networkId` the seller's id a wallet grants a payment credential for
2346
- * (Stripe's business profile), null when the handler names none. */
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. */
2347
2408
  declare const paymentHandler: z.ZodObject<{
2348
2409
  id: z.ZodString;
2349
2410
  type: z.ZodString;
2350
2411
  version: z.ZodString;
2351
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>>>;
2352
2419
  networkId: z.ZodNullable<z.ZodString>;
2353
2420
  }, z.core.$strip>;
2354
2421
  type PaymentHandler = z.infer<typeof paymentHandler>;
@@ -2504,6 +2571,12 @@ declare const order: z.ZodObject<{
2504
2571
  type: z.ZodString;
2505
2572
  version: z.ZodString;
2506
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>>>;
2507
2580
  networkId: z.ZodNullable<z.ZodString>;
2508
2581
  }, z.core.$strip>>>;
2509
2582
  /** What a payment credential for `pay_order` must allow, present with
@@ -2681,6 +2754,12 @@ declare const orderList: z.ZodObject<{
2681
2754
  type: z.ZodString;
2682
2755
  version: z.ZodString;
2683
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>>>;
2684
2763
  networkId: z.ZodNullable<z.ZodString>;
2685
2764
  }, z.core.$strip>>>;
2686
2765
  /** What a payment credential for `pay_order` must allow, present with
@@ -3354,4 +3433,4 @@ declare const UNKNOWN_IS_NOT_NO_EXEMPTIONS: Readonly<Record<string, string>>;
3354
3433
  /** The contract's version, from package.json, the one place a release bumps it. */
3355
3434
  declare const CONTRACT_VERSION: string;
3356
3435
 
3357
- export { AMENITY_CODES, API, type AmenityCode, type AuthConfig, CANCEL_NEXT_STEP, CANCEL_REASONS, CARD_NUMBER_MESSAGE, CENTER_BASES, COMMANDS, COMMAND_GROUPS, CONTRACT_VERSION, CREDENTIAL_INVALID_REASONS, type CancelOrderInput, type CancelReason, type Center, type CommandGroupSpec, type CommandSpec, type CreateOrderInput, type CredentialInvalidReason, DISPLAY_CURRENCIES, type Destination, ERROR_CODES, ERROR_DETAILS, type ErrorBody, type ErrorCode, type ErrorEnvelope, FILTERABLE_AMENITIES, type FilterableAmenity, type FlagSpec, GLOBAL_FLAGS, type GetHotelInput, type GetOrderInput, type GuideSurface, type GuideTopic, type Hotel, type HotelOffersInput, type HotelOffersResult, type HotelSummary, type IndicativePrice, type KnownErrorBody, LIMITS, type ListOrdersInput, MCP_OUTPUT, MCP_PATH, type MeResult, type Money, ORDER_NEXT_STEP, ORDER_STATUSES, type Offer, type OfferChange, type Omitted, type OptionSpec, type Order, type OrderList, type OrderStatus, PAYMENT_STATUSES, PAY_NEXT_STEP, PLACE_KINDS, POLICY_TOPICS, PRESENTATION_HINT, PUBLIC_ORIGINS, type PayOrderInput, type PaymentHandler, type PaymentStatus, type Place, type PlaceRef, type PolicyTopic, type PositionalSpec, type RenderedTool, SEARCH_NOTE_CODES, SEARCH_SORTS, SUPPORT_EMAIL, type SearchHotelsInput, type SearchNoteCode, type SearchResult, type Stay, TOOLS, type ToolName, type ToolSpec, UNAVAILABLE_REASONS, UNKNOWN_IS_NOT_NO_EXEMPTIONS, addIsoDateDays, authConfig, cancelOrderInput, cancellation, center, commandInvocation, confirmation, containsCardNumber, countIsoDateDays, createOrderInput, createSearchHotelsInput, destination, errorEnvelope, flag, formatMoney, getHotelInput, getOrderInput, hotel, hotelId, hotelOffersInput, hotelOffersResult, hotelSummary, indicativePrice, instant, isIsoDate, knownLocaleText, latLng, listOrdersInput, localDate, localTime, localities, localizedText, meResult, meals, money, names, nonEmpty, offer, offerChange, offerId, omitted, oneOf, openEnum, openObject, openUnion, order, orderId, orderList, orderReference, parseOpen, payAtProperty, payOrderInput, paymentHandler, photo, place, placeId, placeRef, renderError, renderGuide, renderToolResult, roomFacts, searchHotelsInput, searchResult, stay, stayEcho, strictErrorEnvelope, strictInput, strictOutput, text, timeZone, usdMoney, wholeNumber };
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,16 +569,126 @@ var cancelOrderInput = strictInput({
569
569
  "The penalty the user agreed to: cancel.penalty.amount of the order, in its currency."
570
570
  )
571
571
  });
572
+ var sharedPaymentTokenRe = /^spt_[A-Za-z0-9]{1,250}$/;
572
573
  var sharedPaymentTokenError = "sharedPaymentToken must be a Stripe shared payment token: spt_ followed by letters and digits";
574
+ var instrumentTokenError = "credential.token must be a Stripe shared payment token: spt_ followed by letters and digits";
575
+ var instrumentsError = "payment.instruments must be a list of 1 to 8 instruments";
576
+ var instrumentCardError = "payment.instruments must not hold card details: pay with the shared payment token alone";
577
+ var ucpInstrument = z5.looseObject(
578
+ {
579
+ id: nonEmpty("id").describe("The instrument's id, as the agent's UCP client names it."),
580
+ handler_id: nonEmpty("handler_id").describe(
581
+ "The id of the handler the instrument pays through: the order's stripe_payments for the selected one."
582
+ ),
583
+ type: nonEmpty("type").describe("The instrument type: card for the selected one."),
584
+ selected: flag("selected").optional().describe(
585
+ "Whether this is the instrument to pay with. Exactly one is selected; a lone instrument without it is the one."
586
+ ),
587
+ credential: z5.looseObject(
588
+ {
589
+ type: nonEmpty("credential.type").describe(
590
+ "The credential type: stripe_payment_token for the selected one."
591
+ ),
592
+ token: z5.string({ error: instrumentTokenError }).optional().describe(
593
+ "The shared payment token (spt_\u2026) the user approved for this order, requested with the order's payment.credentialLimits."
594
+ )
595
+ },
596
+ { error: "credential must be a JSON object" }
597
+ ).optional().describe("The instrument's credential: for the selected one, the shared payment token."),
598
+ display: z5.looseObject({}, { error: "display must be a JSON object" }).optional().describe("How the wallet shows the instrument, as UCP has it. Not used to pay.")
599
+ },
600
+ { error: "Each instrument must be a JSON object" }
601
+ ).describe("A UCP payment instrument.");
602
+ var selectedCard = z5.looseObject({
603
+ handler_id: z5.literal("stripe_payments", {
604
+ error: "The selected instrument's handler_id must be stripe_payments"
605
+ }),
606
+ type: z5.literal("card", { error: "The selected instrument's type must be card" }),
607
+ credential: z5.looseObject(
608
+ {
609
+ type: z5.literal("stripe_payment_token", {
610
+ error: "The selected instrument's credential.type must be stripe_payment_token"
611
+ }),
612
+ token: z5.string({ error: instrumentTokenError }).regex(sharedPaymentTokenRe, { error: instrumentTokenError })
613
+ },
614
+ { error: "The selected instrument needs a credential: its shared payment token" }
615
+ )
616
+ });
617
+ function selectedOf(instruments) {
618
+ const chosen = instruments.flatMap((i, at) => i?.selected === true ? [{ i, at }] : []);
619
+ const lone = instruments[0];
620
+ if (chosen.length === 0 && instruments.length === 1 && lone && lone.selected === void 0) {
621
+ return [{ i: lone, at: 0 }];
622
+ }
623
+ return chosen;
624
+ }
573
625
  var payOrderInput = strictInput({
574
626
  orderId: orderId.describe("orderId of the order to pay, from create order or get order."),
575
- sharedPaymentToken: z5.string({ error: sharedPaymentTokenError }).regex(/^spt_[A-Za-z0-9]{1,250}$/, { error: sharedPaymentTokenError }).describe(
576
- "The shared payment token (spt_\u2026) the user approved for this order, requested with the order's payment.credentialLimits."
627
+ sharedPaymentToken: z5.string({ error: sharedPaymentTokenError }).regex(sharedPaymentTokenRe, { error: sharedPaymentTokenError }).optional().describe(
628
+ "The shared payment token (spt_\u2026) the user approved for this order, requested with the order's payment.credentialLimits. Exactly one of sharedPaymentToken and payment."
629
+ ),
630
+ payment: strictInput({
631
+ instruments: z5.array(ucpInstrument, { error: instrumentsError }).min(1, { error: instrumentsError }).max(8, { error: instrumentsError }).describe("The instruments, exactly one of them selected.")
632
+ }).superRefine((payment, ctx) => {
633
+ if (payment.instruments.length < 1 || payment.instruments.length > 8) return;
634
+ const phones = [];
635
+ const rest = JSON.stringify(payment.instruments, (key, value) => {
636
+ if (key !== "phone_number") return value;
637
+ phones.push(value);
638
+ return void 0;
639
+ });
640
+ if (containsCardNumber(rest) || containsCardNumber(JSON.stringify(phones), 16)) {
641
+ ctx.addIssue({ code: "custom", path: ["instruments"], message: instrumentCardError });
642
+ return;
643
+ }
644
+ const chosen = selectedOf(payment.instruments);
645
+ const [only] = chosen;
646
+ if (chosen.length !== 1 || !only) {
647
+ ctx.addIssue({
648
+ code: "custom",
649
+ path: ["instruments"],
650
+ message: `payment.instruments must have exactly one instrument with selected: true, not ${chosen.length}`
651
+ });
652
+ return;
653
+ }
654
+ if (!ucpInstrument.safeParse(only.i).success) return;
655
+ const card = selectedCard.safeParse(only.i);
656
+ for (const issue of card.success ? [] : card.error.issues) {
657
+ ctx.addIssue({
658
+ code: "custom",
659
+ path: ["instruments", only.at, ...issue.path],
660
+ message: issue.message
661
+ });
662
+ }
663
+ }).optional().describe(
664
+ "UCP's Complete Checkout payment, in place of sharedPaymentToken: the token as the stripe_payment_token credential of the one selected stripe_payments card instrument. Exactly one of sharedPaymentToken and payment."
577
665
  ),
578
666
  total: usdMoney.describe(
579
667
  "The total the user approved: the order's price.total, exactly as returned."
580
668
  )
669
+ }).superRefine((input, ctx) => {
670
+ if (input.sharedPaymentToken !== void 0 && input.payment !== void 0) {
671
+ ctx.addIssue({
672
+ code: "custom",
673
+ path: ["payment"],
674
+ message: "Send sharedPaymentToken or payment, not both"
675
+ });
676
+ } else if (input.sharedPaymentToken === void 0 && input.payment === void 0) {
677
+ ctx.addIssue({
678
+ code: "custom",
679
+ path: ["sharedPaymentToken"],
680
+ message: sharedPaymentTokenError
681
+ });
682
+ }
581
683
  });
684
+ function sharedPaymentTokenOf(input) {
685
+ const chosen = input.payment ? selectedOf(input.payment.instruments) : [];
686
+ const token = input.sharedPaymentToken ?? (chosen.length === 1 ? chosen[0]?.i.credential?.token : void 0);
687
+ if (token === void 0) {
688
+ throw new Error("sharedPaymentTokenOf: no token; parse with payOrderInput first");
689
+ }
690
+ return token;
691
+ }
582
692
 
583
693
  // src/commands.ts
584
694
  function fieldDescription(json, field, sets = {}) {
@@ -997,6 +1107,11 @@ function mark(schema, kind2) {
997
1107
  function openObject(shape) {
998
1108
  return z7.looseObject(shape);
999
1109
  }
1110
+ function protocolObject() {
1111
+ const schema = z7.record(z7.string(), z7.unknown());
1112
+ mark(schema, "protocol");
1113
+ return schema;
1114
+ }
1000
1115
  function openEnum(values) {
1001
1116
  const schema = z7.union([
1002
1117
  z7.enum(values),
@@ -1060,6 +1175,7 @@ function strictify(schema) {
1060
1175
  delete next[OPEN];
1061
1176
  return schema.clone(next);
1062
1177
  };
1178
+ if (kind2 === "protocol") return schema;
1063
1179
  if (kind2 === "enum") return strictify(def.options[0]);
1064
1180
  if (kind2 === "union") {
1065
1181
  return rebuild({ options: def.options.slice(0, -1).map(strictify) });
@@ -1107,7 +1223,7 @@ var FRAGMENTS = {
1107
1223
  "meals": '{{#if claude-skill cli}}\n## Presenting an offer\n\nGive the user, for each offer:\n\n- the room (`room.name`, beds, size) and the total, as above;\n- the meals: `meals.included` (breakfast, lunch, dinner) or `allInclusive`, with `guestsCoveredPerRoom`. Fewer than the guests per room means not everyone gets the meals (breakfast for 1 with 2 adults in the room): say who is covered. `unspecifiedMainMeals` counts main meals the hotel didn\'t name. With `known: false`, the meals are unknown: say so, and don\'t call it room only;\n- cancellation: `status` (`free`, `partial_penalty`, `non_refundable` or `unknown`), `freeCancellationEndsAt` (null with `free`: free until check-in) and the `penalties`. Times are in UTC: also give them in the hotel\'s `timeZone`;\n- confirmation: `mode` `instant` or `on_request` (within `withinMinutes`);\n- fees payable at the property (`payAtProperty.items`), in the property\'s currency. `disclosure: "incomplete"` means there can be fees not listed: say so.\n\nAn offer expires at `expiresAt`, about 30 minutes after it was made; after that, get offers again.\n\n"Not listed" is not "no": `listed: false` (amenities, policies, rooms), `null` and `unknown` mean the source didn\'t say. Tell the user it\'s unknown instead of turning it into "no".\n{{/if}}\n{{#if mcp}}\n- "Not listed" or "unknown" is not "no".\n{{/if}}\n',
1108
1224
  "occupancy": "{{#if claude-skill cli}}\n## Rooms and guests\n\n- {{#if mcp claude-skill}}`stay.rooms` lists each room's party as `{ adults, childrenAges }`: two rooms of 2 adults, one with a child of 6, is `[{ adults: 2, childrenAges: [6] }, { adults: 2, childrenAges: [] }]`{{/if}}{{#if cli}}`--room <adults[:age,\u2026]>`, once per room, gives each room's party: two rooms of 2 adults, one with a child of 6, is `--room 2:6 --room 2`{{/if}}.\n- Ask each child's age; offers need it.\n- If the party doesn't split evenly across the rooms (3 adults in 2 rooms), ask the user how it splits.\n{{/if}}\n- Offers and orders take one party per call, every room the same: for different parties, order once per party.{{#if claude-skill cli}} `{{tool:hotels offers}}` answers `stay_unsupported` (`mixed_occupancy`) for mixed rooms; `{{tool:hotels search}}` accepts them but prices only from the dates, with the note `party_split_required`.{{/if}}\n{{#if claude-skill cli}}\n- Limits: 1\u2013{{limit:rooms}} rooms, 1\u2013{{limit:adultsPerRoom}} adults and 0\u2013{{limit:childrenPerRoom}} children (aged 0\u2013{{limit:childAgeMax}}) per room, 1\u2013{{limit:nightsSupplier}} nights, up to {{limit:offersHotels}} hotels per `{{tool:hotels offers}}` call. A longer stay answers `stay_unsupported` (`max_nights`): ask the user whether to split it into consecutive stays, each its own order.\n{{/if}}\n",
1109
1225
  "order": '{{#if claude-skill cli}}\n## Workflow\n\n1. **Search** with `{{tool:hotels search}}` for candidate hotels: a destination, `{{arg:text}}` or both, and the stay\'s dates and rooms for indicative prices.\n{{#if cli}}\n\n ```bash\n {{tool:hotels search}} --place-name Bangkok --country TH --check-in 2026-11-10 \\\n --check-out 2026-11-12 --room 2 --stars-min 4 --sort price_asc --limit 10\n ```\n\n{{/if}}\n2. **Details** (optional) with `{{tool:hotels get}}`, when the user asks about a hotel or a stated preference needs evidence (a pool, a policy, room size). For a details-only question, call it directly when you know the hotel\'s `hotelId`; otherwise find the hotel with `{{tool:hotels search}}`.\n{{#if cli}}\n\n ```bash\n {{tool:hotels get}} <hotelId> [--rooms]\n ```\n\n{{/if}}\n3. **Offers** with `{{tool:hotels offers}}` for a few shortlisted hotels, with the dates and rooms the user will order. It takes about 15 seconds. A hotel is available only once this returns an offer for it.\n{{#if cli}}\n\n ```bash\n {{tool:hotels offers}} --hotel <hotelId> --hotel <hotelId> --check-in 2026-11-10 \\\n --check-out 2026-11-12 --room 2 --room 2 [--require-free-cancellation]\n ```\n\n{{/if}}\n4. **Order** with `{{tool:hotels book}}`, once the user has picked one offer and given the guests and the contact (see Ordering).\n{{#if cli}}\n\n ```bash\n {{tool:hotels book}} --offer <offerId> --guest 1:John:Smith --guest 2:Mary:Smith \\\n --first-name John --last-name Smith --email john@example.com \\\n --phone "+8613800000000"\n ```\n\n{{/if}}\n5. **Confirm, then give the payment link**, as in "Before giving the payment link" below.\n6. **After payment**, check the order with `{{tool:orders get}}` (see After payment).\n\n## Search\n\n### Where\n\n- **A place by name:** {{#if mcp claude-skill}}`{ kind: "place_name", name, countryCode }`{{/if}}{{#if cli}}`--place-name <name> --country <CC>`{{/if}}, in any language (Kyoto or \u4EAC\u90FD). The country is required: ask the user when it isn\'t clear. Names match exactly, ignoring only case and spacing: accents, hyphens, apostrophes and periods count ("K\xF6ln" or "Cologne", not "Koln"; "St. Moritz", not "St Moritz").\n- If several places bear the name, the answer is `destination_ambiguous` with up to {{limit:candidatesShown}} candidates and their hotel counts: ask the user which one they mean, then search it by its `placeId`; never pick one yourself.\n- `destination_not_found` with `no_match` means no place of that name in that country: check the spelling and accents, or try another name for the place. Its `nameAsText` counts the hotels that a `{{arg:text}}` search for the name would find.\n- **A place from an earlier answer:** {{#if mcp claude-skill}}`{ kind: "place", placeId }`{{/if}}{{#if cli}}`--place <placeId>`{{/if}}.\n- **Near a point:** {{#if mcp claude-skill}}`{ kind: "point", location: { lat, lng } }`{{/if}}{{#if cli}}`--point <lat,lng>`{{/if}}, for "near X" when you know where X is.\n- **A whole country:** {{#if mcp claude-skill}}`{ kind: "country", countryCode }`{{/if}}{{#if cli}}`--country-only <CC>`{{/if}}, as for the Maldives.\n- Countries, regions (states, provinces), prefecture-level cities in China and main islands cover their whole area. Towns, neighbourhoods, districts, small islands and points cover a circle of {{limit:radiusMetersDefault}} meters; `{{arg:destination.radiusMeters}}` sets another, up to {{limit:radiusMetersMax}} meters, and narrows an area to a circle around its center.\n- **Localities:** an area search lists its `localities`, the towns its hotels belong to, each with a `placeId`, its hotel `count` and the places it `includes` (Patong is part of Phuket). To search one, pass it as {{#if mcp claude-skill}}`{ kind: "locality", placeId }`{{/if}}{{#if cli}}`--locality <placeId>`{{/if}}. A town that isn\'t a locality answers `destination_not_found` with `not_a_locality` and the `hub` it belongs to: search the hub, or the town itself with {{#if mcp claude-skill}}`kind: "place"`{{/if}}{{#if cli}}`--place`{{/if}} for a circle around it.\n- A price sort or price filter over more than {{limit:poolLimit}} hotels (in an area, or for text alone) answers `search_too_broad` with `matched` and the top `localities`: show them and ask the user which they prefer, unless the request already names one of them; search that one by its `placeId` as a locality, never by its name.\n\n### Text\n\n`{{arg:text}}` matches exact words in hotel names and addresses, in Chinese or English:\n\n- Every word must match as written: plurals, accents, spacing and abbreviations count ("hostel" and "hostels", "St Regis" and "Saint Regis" find different hotels). Hyphens and apostrophes don\'t (Ritz-Carlton finds Ritz Carlton).\n- In Chinese, matching follows word segmentation, so part of a name can match unrelated hotels (\u5E0C\u5C14 is not \u5E0C\u5C14\u987F).\n- Use only distinctive words: a hotel or brand name, a district or a landmark. Not "hotel", "near", "cheap" or "best".\n- Typos return nothing: "Shangahi" finds no hotel.\n- Place names belong in the destination: "Maldives" as text finds a hotel named Maldives in China.\n\n### Filters\n\n- Stars run from 1 to 5 in half steps{{#if mcp claude-skill}} (`filters.stars`){{/if}}. "4 stars" as {{#if mcp claude-skill}}`{ min: 4, max: 4 }`{{/if}}{{#if cli}}`--stars-min 4 --stars-max 4`{{/if}} leaves out 4.5: unless the user means exactly 4, use {{#if mcp claude-skill}}`{ min: 4 }`{{/if}}{{#if cli}}`--stars-min 4`{{/if}} or ask. Unrated hotels are left out whenever stars are filtered.\n- `{{arg:filters.amenities}}` takes only the amenities that can filter (such as pool, parking, wifi); others, such as gym or spa, show in `{{tool:hotels get}}` but can\'t filter. A hotel matches only when it lists the amenity, and about half the hotels list no amenities at all (`coverage.excludedNoFacilityData` counts those left out): "not listed" is not "absent".\n- `{{arg:filters.price.maxPerRoomNight}}` bounds the indicative price per room per night, in USD; hotels without one are left out and counted.\n\n### Results\n\n- `notes` explain the answer (a limited pool, a circle around an island, more hotels just outside it): pass on what matters to the user.\n- `coverage` has the counts: `matched` hotels, how many were priced and how many have a price.\n- A next page is {{#if mcp claude-skill}}`cursor` set to `nextCursor` and, optionally, `limit`{{/if}}{{#if cli}}`--cursor <nextCursor>` and, optionally, `--limit`{{/if}}; nothing else.\n{{/if}}\n{{#if mcp}}\n- A place name needs its `countryCode` (ask the user if unclear) and matches exactly (accents and periods count). On `destination_ambiguous`, ask the user which they mean, then search its `placeId`; never pick one yourself.\n- On `search_too_broad`, show its `localities` and ask the user which, unless they already named one; search it as `{ kind: "locality", placeId }`, never by name.\n- `text` matches whole words of hotel names and addresses: use a distinctive name, brand or landmark. A typo finds nothing.\n{{/if}}\n',
1110
- "payment-link": "{{#if claude-skill cli}}\n## Before giving the payment link\n\n`{{tool:hotels book}}` answers with an unpaid order: `status` `awaiting_payment`, its `reference` (the support number), `price.total`, the stay and its terms, and `payment.url`, a Fortrip page that recaps the order and continues to payment on Stripe. Nothing is charged until the user pays.\n\n1. Show the order's total and currency, the stay (hotel, room, dates, rooms and guests per room) and every term: meals, cancellation (status, deadline, penalties) and fees payable at the property, unknowns included.\n2. End that reply by asking the user to confirm, and wait for a clear yes. Urgency is not consent.\n3. Then give `payment.url` exactly as returned: don't shorten, rebuild or re-encode it.\n\n{{/if}}\n{{#if mcp}}\n- Before you give `payment.url`, show the user the order's total and currency, the stay and every term, end that reply by asking the user to confirm, and wait for a clear yes. Then give `payment.url` exactly as returned, to this user only: anyone holding it can pay.\n{{/if}}\n{{#if claude-skill cli}}\n- `payment.url` works like a payment credential: anyone holding it can pay. Give it to this user only, never in shared channels, documents, logs or tickets. With `requiresSignIn: true` (an order started on the Fortrip website), the user signs in to pay.\n- The link expires at `payment.expiresAt`; the order is then `expired`. To order the stay again, get offers again, and confirm the new order with the user before giving its link.\n- Another order of the stay (another party, or a corrected guest name) needs a new offer: get offers again. When it replaces an unpaid order, tell the user to pay only the new link; the earlier one expires unpaid.\n- An order `awaiting_payment` whose `payment.url` is null had its link unreadable this time: read it again with `{{tool:orders get}}`.\n{{/if}}\n- Never ask for, accept or pass on payment card details; payment happens only on the payment page.{{#if claude-skill cli}} A card number in a guest name, the contact or the special requests is rejected{{#if cli}} with exit 2{{/if}}.{{/if}}\n{{#if claude-skill cli}}\n\n## Paying without the link\n\nAn order with `payment.handlers` can also be paid with a Stripe shared payment token that the user's wallet (Link) grants for it, through `{{tool:orders pay}}`:\n\n1. Show and ask exactly as before giving the payment link, and wait for a clear yes. The token comes from the user's wallet, never from card details.\n2. Request the token from the user's wallet with the handler's `networkId` and `payment.credentialLimits`: `maxAmount` (in cents), `currency` and `expiresAt`.\n3. {{#if claude-skill}}Call{{/if}}{{#if cli}}Run{{/if}} `{{tool:orders pay}}` with the token and the order's `price.total`{{#if cli}} (`--token`, `--total`){{/if}}. The order is then `confirming`, its payment `authorized`: check it as after payment.\n\nThe charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once `{{tool:orders pay}}` succeeds, `payment.url` stops working; a payment that fails leaves the link open. `payment_total_changed` means the total changed: show the new total and ask again, for a new token. `payment_declined`: the user picks another payment method in their wallet, or pays by link. `payment_action_required`: the card needs a verification this can't give: pay by link. `payment_credential_invalid`: request a new token with the order's `payment.credentialLimits`. `service_unavailable`: call `{{tool:orders pay}}` again with the same token, never a new one. A token pays one order only.\n\n## After payment\n\nCheck the order with `{{tool:orders get}}`:\n\n- `confirming` while the hotel confirms, then `confirmed` with the hotel's `confirmationNumber`.\n- `failed`: no stay was booked; `payment.status` says whether the payment was released or refunded.\n- `needs_attention`: Fortrip is looking into it; the user can email {{support}} with the `reference`.\n- `manageUrl` is the user's own page for the order.\n{{/if}}\n",
1226
+ "payment-link": "{{#if claude-skill cli}}\n## Before giving the payment link\n\n`{{tool:hotels book}}` answers with an unpaid order: `status` `awaiting_payment`, its `reference` (the support number), `price.total`, the stay and its terms, and `payment.url`, a Fortrip page that recaps the order and continues to payment on Stripe. Nothing is charged until the user pays.\n\n1. Show the order's total and currency, the stay (hotel, room, dates, rooms and guests per room) and every term: meals, cancellation (status, deadline, penalties) and fees payable at the property, unknowns included.\n2. End that reply by asking the user to confirm, and wait for a clear yes. Urgency is not consent.\n3. Then give `payment.url` exactly as returned: don't shorten, rebuild or re-encode it.\n\n{{/if}}\n{{#if mcp}}\n- Before you give `payment.url`, show the user the order's total and currency, the stay and every term, end that reply by asking the user to confirm, and wait for a clear yes. Then give `payment.url` exactly as returned, to this user only: anyone holding it can pay.\n{{/if}}\n{{#if claude-skill cli}}\n- `payment.url` works like a payment credential: anyone holding it can pay. Give it to this user only, never in shared channels, documents, logs or tickets. With `requiresSignIn: true` (an order started on the Fortrip website), the user signs in to pay.\n- The link expires at `payment.expiresAt`; the order is then `expired`. To order the stay again, get offers again, and confirm the new order with the user before giving its link.\n- Another order of the stay (another party, or a corrected guest name) needs a new offer: get offers again. When it replaces an unpaid order, tell the user to pay only the new link; the earlier one expires unpaid.\n- An order `awaiting_payment` whose `payment.url` is null had its link unreadable this time: read it again with `{{tool:orders get}}`.\n{{/if}}\n- Never ask for, accept or pass on payment card details; payment happens only through Stripe.{{#if claude-skill cli}} A card number in a guest name, the contact or the special requests is rejected{{#if cli}} with exit 2{{/if}}.{{/if}}\n{{#if claude-skill cli}}\n\n## Paying without the link\n\nAn order 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",
1111
1227
  "planning": "# Planning a hotel stay\n\nRead this when the request is more than one hotel for fixed dates: flexible dates, a budget, split stays, several destinations, or \"find me the best\". The rules in {{#if mcp}}the server instructions{{/if}}{{#if claude-skill}}SKILL.md{{/if}}{{#if cli}}`{{tool:guide}}`{{/if}} still apply (call order, destinations, one party per offer and order, confirming the order `{{tool:hotels book}}` returns before giving the payment link); this covers what to ask, how to compare and how to present.{{#if cli}} As there, `fortrip` is short for `npx -y fortrip@latest`.{{/if}}\n\n## What to collect\n\nKeep track of: dates (or the flexible window), nights, destination(s) with their country, rooms and the guests in each room, room constraints (beds, connecting rooms, accessibility), budget, and what the user said matters most (cheapest, most flexible, closest to X).\n\nOffers and orders take one party per call, every room the same, so if the party doesn't split evenly across the rooms, ask how it splits. Rooms for different parties are priced and ordered separately, each order with its own payment link.\n\nAsk only for what changes which hotels qualify or how they rank. \"4 stars\" as {{#if mcp claude-skill}}`{ min: 4, max: 4 }`{{/if}}{{#if cli}}`--stars-min 4 --stars-max 4`{{/if}} leaves out 4.5: unless the user means exactly 4, use {{#if mcp claude-skill}}`{ min: 4 }`{{/if}}{{#if cli}}`--stars-min 4`{{/if}} or ask. If children come along, ask each child's age; `{{tool:hotels offers}}` needs it. Don't ask for trip type or style: infer it from the conversation or leave it general. When a place name is ambiguous, ask which place the user means.\n\n## Evidence\n\n- A `{{tool:hotels search}}` price is an indicative estimate per room per night, not a quote. Never call a search result available or bookable, and once you have offers, compare offers only. A hotel without a search price can still have offers.\n- Use `{{tool:hotels get}}` only when a stated preference needs evidence (a pool, a policy, room size). An amenity or policy it doesn't list is unknown, not absent.\n- A hotel is available only once `{{tool:hotels offers}}` returned an offer for it.\n- Anything {{#if mcp claude-skill}}the tools{{/if}}{{#if cli}}the CLI{{/if}} didn't return, such as reviews, style, price trends or exchange rates other than `approx`, is unknown. Say so instead of filling it in.\n\n## Ranking\n\n1. Drop options that break a hard constraint (dates, guests, budget cap, required facility). Compare a budget in the unit the user gave it: per night, per room or for the whole stay. An offer's `price.total` covers the whole stay and every room, in USD.\n2. Keep only options with a live offer.\n3. Order by the user's stated main goal. Goals they didn't state don't count.\n4. Use other preferences only to break ties.\n\nUse the cheapest comparable offer as the baseline unless the user fixed the room type. Show at most three plans, each with its price difference from the baseline and what it trades off (meals, cancellation, location, confirmation). Keep hotel names as returned and dates in the user's notation.\n\nFor a split stay or several destinations, price each leg with its own `{{tool:hotels offers}}` call and add up the legs. Each leg is a separate `{{tool:hotels book}}` call, with its own confirmation and its own payment link.\n\n## Stop and say so\n\n- `{{tool:hotels offers}}` covers up to {{limit:offersHotels}} hotels per call and takes about 15 seconds, and its offers expire after about 30 minutes. If the request needs more hotels or date combinations than a few calls can cover, narrow it with the user, or present the result as a comparison of the hotels you priced, not the best overall.\n- When a search is too broad to price, show its localities and ask the user which they prefer, unless the request already names one of them; never pick one yourself.\n- Urgency is not consent. Call `{{tool:hotels book}}` only for the offer the user picked, and give its payment link only after the user confirms the total, currency, stay and terms of the order `{{tool:hotels book}}` returned.\n",
1112
1228
  "presentation": "{{#if claude-skill}}\n## Presenting hotels\n\nIf your interface can show rich elements, show each hotel as a card with only what Fortrip's tools returned for it in this conversation: photo, name, stars, region and price, and once you have offers every term that changes the choice (meals and who they cover, cancellation, fees payable at the property, confirmation), an unknown one as unknown. Label a search's `price.fromPerRoomNight` as an estimate per room-night and an offer's `price.total` as the whole stay for all rooms, in USD, and draw a map only from returned `location` coordinates. Offer the choices you need to ask anyway (dates, a locality, which offer) as options to pick. Otherwise use a short list. Keep hotel names as returned, and never invent photos, ratings, reviews, prices, terms or coordinates.\n{{/if}}\n",
1113
1229
  "prices": "{{#if claude-skill cli}}\n## Prices and currency\n\n- A search price (`price.fromPerRoomNight`) is indicative and not bookable: the lowest price of one unit (a room or, at a hostel, possibly a bed) per night, for any party and often any date, and it can be well above or below the offers. Call it an estimate, quote `{{tool:hotels offers}}` prices, and never call a search result available or bookable. `price: null` means there is no indicative price, not that the hotel is full; about half the hotels have none for given dates.\n{{/if}}\n{{#if mcp}}\n- Search prices are indicative, not bookable: quote `{{tool:hotels offers}}` prices.\n{{/if}}\n- {{#if claude-skill cli}}In an offer or order, {{/if}}`price.total` is the whole stay for all rooms and is what is charged, in USD for offers and the orders made from them.{{#if claude-skill cli}} `perNightAllRooms` is the total per night; to compare with a per-room budget, also divide by the rooms.{{/if}} Stripe's page may let the user pay in their card's local currency at Stripe's rate (Adaptive Pricing){{#if claude-skill cli}}: say so plainly, and that the USD total is the price{{/if}}. `approx`{{#if claude-skill cli}}, in `{{arg:displayCurrency}}`, with its `rateDate`,{{/if}} is an estimate, never the charge.\n{{#if claude-skill cli}}\n- `{{arg:displayCurrency}}`{{#if cli}} (or `FORTRIP_DISPLAY_CURRENCY`){{/if}} is `USD` or `CNY`: `CNY` adds `approx` in yuan to suit a user who thinks in it. It never changes the charge.\n- Fees payable at the property (`payAtProperty`) are separate, in the property's own currency, not converted.\n- After payment, `payment.localCharge` is what the card paid in its own currency. Orders made on the Fortrip website can be charged in another currency: `payment.chargeCurrency` says which.\n{{/if}}\n",
@@ -1703,6 +1819,9 @@ var paymentHandler = openObject({
1703
1819
  type: z14.string(),
1704
1820
  version: z14.string(),
1705
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(),
1706
1825
  networkId: z14.string().nullable()
1707
1826
  });
1708
1827
  var orderReference = z14.string().regex(/^FT-[2-9A-HJ-NP-Z]{6}$/);
@@ -1952,7 +2071,7 @@ var MCP_PATH = "/";
1952
2071
  import { z as z16 } from "zod";
1953
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.";
1954
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.";
1955
- var PAY_NEXT_STEP = "To pay without the link, when the order has payment.handlers and the user's wallet can grant a Stripe shared payment token: first show and ask exactly as for payment.url, and wait for a clear yes. Then request the token for this order from the user's wallet with the handler's networkId and payment.credentialLimits (maxAmount in cents, currency, expiresAt), and call pay_order with it and the order's price.total. The charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once pay_order succeeds, payment.url stops working.";
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.";
1956
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.";
1957
2076
  var nextStep = z16.string().optional().describe(
1958
2077
  "What to show and ask before giving a payment.url. Present when the answer holds a non-null payment.url, and only then."
@@ -2049,7 +2168,7 @@ var TOOLS = [
2049
2168
  {
2050
2169
  name: "pay_order",
2051
2170
  title: "Pay order with a shared payment token",
2052
- description: "Pay an order awaiting payment without its link, with a Stripe shared payment token, when the order has payment.handlers. First show and ask exactly as for payment.url, and wait for a clear yes. Then request the token from the user's wallet with the handler's networkId and payment.credentialLimits, and pass it with the order's price.total. The charge is in USD. Once it succeeds, payment.url stops working; a payment that fails leaves the link open. Answers the order: status confirming, the payment authorized (held, charged once the hotel confirms); poll get_order. payment_total_changed: show details.total and ask again, for a new token. payment_declined: the user picks another payment method in their wallet, or pays by link. payment_action_required: the card needs a verification this can't give; pay by link. payment_credential_invalid: request a new token. service_unavailable: call pay_order again with the same token, never a new one. A token pays one order only; the same token again answers as before.",
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.",
2053
2172
  annotations: {
2054
2173
  readOnlyHint: false,
2055
2174
  idempotentHint: true,
@@ -2417,9 +2536,11 @@ function paymentLines(o) {
2417
2536
  return lines;
2418
2537
  }
2419
2538
  function handlersLine(handlers, limits) {
2420
- const shown = handlers.map(
2421
- (h) => `${h.type} (handler ${h.id}${h.networkId ? `, networkId ${h.networkId}` : ""})`
2422
- );
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
+ });
2423
2544
  const limit = limits ? `; token limits: maxAmount ${limits.maxAmount} (cents), currency ${limits.currency}, expiresAt ${limits.expiresAt}` : "";
2424
2545
  return `Pay without the link: pay_order with a shared payment token via ${shown.join(", ")}${limit}`;
2425
2546
  }
@@ -2941,6 +3062,7 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
2941
3062
  localCurrencyAtCheckout: `${API_DECIDES} (whether checkout may charge in the card's currency).`,
2942
3063
  "cancel.available": `${API_DECIDES} (whether an order can be cancelled now).`,
2943
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).`,
2944
3066
  bookable: `${API_DECIDES} (whether the hotel is still in the index).`,
2945
3067
  cityLike: `${API_DECIDES} (frozen per gazetteer release; null where not computed).`,
2946
3068
  known: `${THE_FLAG} (meals).`,
@@ -2950,7 +3072,7 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
2950
3072
  // package.json
2951
3073
  var package_default = {
2952
3074
  name: "@fortrip/agent-contract",
2953
- version: "3.4.0",
3075
+ version: "3.5.0",
2954
3076
  license: "Apache-2.0",
2955
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.",
2956
3078
  type: "module",
@@ -3093,12 +3215,14 @@ export {
3093
3215
  place,
3094
3216
  placeId,
3095
3217
  placeRef,
3218
+ protocolObject,
3096
3219
  renderError,
3097
3220
  renderGuide,
3098
3221
  renderToolResult,
3099
3222
  roomFacts,
3100
3223
  searchHotelsInput,
3101
3224
  searchResult,
3225
+ sharedPaymentTokenOf,
3102
3226
  stay,
3103
3227
  stayEcho,
3104
3228
  strictErrorEnvelope,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fortrip/agent-contract",
3
- "version": "3.4.0",
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",