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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,16 +23,24 @@ It exports:
23
23
  `SEARCH_SORTS` and `FILTERABLE_AMENITIES`: paths, hosts, limits, error codes
24
24
  and vocabularies;
25
25
  - `searchHotelsInput`, `getHotelInput`, `hotelOffersInput`,
26
- `createOrderInput`, `getOrderInput`, `listOrdersInput` and
27
- `cancelOrderInput`, the zod schemas of the requests, and `searchResult`, `hotel`, `hotelOffersResult`, `order`,
28
- `orderList` and `errorEnvelope`, the open schemas of the responses, with
26
+ `createOrderInput`, `getOrderInput`, `listOrdersInput`,
27
+ `cancelOrderInput` and `payOrderInput`, the zod schemas of the requests,
28
+ with `sharedPaymentTokenOf(input)`, the token a parsed `payOrderInput`
29
+ pays with, and `searchResult`, `hotel`, `hotelOffersResult`, `order`,
30
+ `orderList`, `paymentHandler` and `errorEnvelope`, the open schemas of the
31
+ responses, with `ERROR_DETAILS`, each error code's `details`, and
29
32
  `parseOpen`, a parser that keeps unknown fields and values;
30
33
  - `COMMANDS`, `COMMAND_GROUPS` and `GLOBAL_FLAGS`, the CLI's commands, the
31
34
  groups they are typed after and its flags, `commandInvocation(spec)`, a
32
35
  command as it is typed (`fortrip hotels search`), and `TOOLS`, the MCP
33
- tools, with `MCP_OUTPUT`, `ORDER_NEXT_STEP` and `CANCEL_NEXT_STEP`;
34
- - `renderToolResult(tool, data)` and `renderError(envelope)`, the compact
35
- text of a result or an error, and `renderGuide(surface, topic)`, the agent
36
+ tools, with `MCP_OUTPUT`, `ORDER_NEXT_STEP`, `CANCEL_NEXT_STEP`,
37
+ `PAY_NEXT_STEP` and `WALLET_NEXT_STEP` (`cancelNextStep(surface)`,
38
+ `payNextStep(surface)` and `walletNextStep(surface)` word the last three for
39
+ `"mcp"` or `"cli"`);
40
+ - `renderToolResult(tool, data, surface?)` and
41
+ `renderError(envelope, status?, surface?)`, the compact text of a result or
42
+ an error, naming tools (`"mcp"`, the default) or commands and flags
43
+ (`"cli"`), and `renderGuide(surface, topic)`, the agent
36
44
  guide as Markdown for `"mcp"`, `"claude-skill"` or `"cli"`;
37
45
  - field rules such as `containsCardNumber`, the guest-name rule and the date
38
46
  helpers, and `CONTRACT_VERSION`.
package/dist/index.d.ts CHANGED
@@ -81,20 +81,37 @@ interface ToolSpec {
81
81
  * text: some clients never show the model the server instructions.
82
82
  */
83
83
  declare const 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.";
84
+ /** Where a rendered result is read: an MCP client, which calls tools with
85
+ * JSON arguments, or the CLI, which runs commands with flags. */
86
+ type RenderSurface = "mcp" | "cli";
84
87
  /**
85
- * The consent rule of a cancellation (spec §5.7, C11). It rides as the last
86
- * paragraph of the text of every MCP `get_order` and `list_orders` result
87
- * that holds an order with `cancel.available`, after `ORDER_NEXT_STEP` when
88
- * both apply, and never as `nextStep`, which keeps its payment-only meaning.
88
+ * The consent rule of a cancellation (spec §5.7, C11), as `surface` names
89
+ * the call. It rides as the last paragraph of the text of every `get_order`
90
+ * and `list_orders` result that holds an order with `cancel.available`,
91
+ * after `ORDER_NEXT_STEP` when both apply, and never as `nextStep`, which
92
+ * keeps its payment-only meaning.
89
93
  */
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.";
94
+ declare function cancelNextStep(surface: RenderSurface): string;
95
+ /** `cancelNextStep` over MCP, also in the `cancel_order` description. */
96
+ declare const CANCEL_NEXT_STEP: string;
91
97
  /**
92
- * How to pay without the link. It rides as the last paragraph of the text
93
- * of every MCP `book_hotel`, `get_order` and `list_orders` result that holds
94
- * an order with non-empty `payment.handlers`, after `ORDER_NEXT_STEP`, and in
95
- * the description of `pay_order`; never as `nextStep`.
98
+ * How to pay without the link, as `surface` names the call. It rides as the
99
+ * last paragraph of the text of every `book_hotel`, `get_order` and
100
+ * `list_orders` result that holds an order with non-empty
101
+ * `payment.handlers`, after `ORDER_NEXT_STEP`; never as `nextStep`.
96
102
  */
97
- declare const PAY_NEXT_STEP = "To pay without the link, when the order's payment.handlers isn't empty and the user's wallet can grant a Stripe shared payment token: first show and ask exactly as for payment.url, and wait for a clear yes. Then request the token for this order from the user's wallet with the handler's config.business_profile and payment.credentialLimits (maxAmount in cents, currency, expiresAt), and call pay_order with it and the order's price.total. The charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once pay_order succeeds, payment.url stops working.";
103
+ declare function payNextStep(surface: RenderSurface): string;
104
+ /** `payNextStep` over MCP. */
105
+ declare const PAY_NEXT_STEP: string;
106
+ /**
107
+ * How to pay with Alipay or WeChat Pay (spec §7), as `surface` names the
108
+ * call. It rides as the last paragraph of the text of every `book_hotel`,
109
+ * `get_order` and `list_orders` result that holds an order whose
110
+ * `payment.wallets` offers it without having opened it; never as `nextStep`.
111
+ */
112
+ declare function walletNextStep(surface: RenderSurface): string;
113
+ /** `walletNextStep` over MCP. */
114
+ declare const WALLET_NEXT_STEP: string;
98
115
  /**
99
116
  * How to present hotels (the `presentation` guide, in one line). It rides as
100
117
  * the last paragraph of every MCP `search_hotels`, `get_hotel` and
@@ -269,6 +286,18 @@ declare const MCP_OUTPUT: {
269
286
  currency: z.ZodString;
270
287
  expiresAt: z.ZodString;
271
288
  }, z.core.$strip>>;
289
+ wallets: z.ZodNullable<z.ZodObject<{
290
+ open: z.ZodBoolean;
291
+ current: z.ZodNullable<z.ZodType<(string & {}) | "wechat_pay" | "alipay", unknown, z.core.$ZodTypeInternals<(string & {}) | "wechat_pay" | "alipay", unknown>>>;
292
+ wechatPay: z.ZodNullable<z.ZodObject<{
293
+ qrData: z.ZodNullable<z.ZodString>;
294
+ qrImageUrl: z.ZodNullable<z.ZodString>;
295
+ url: z.ZodString;
296
+ }, z.core.$strip>>;
297
+ alipay: z.ZodNullable<z.ZodObject<{
298
+ url: z.ZodString;
299
+ }, z.core.$strip>>;
300
+ }, z.core.$strip>>;
272
301
  }, z.core.$strip>;
273
302
  cancel: z.ZodObject<{
274
303
  available: z.ZodBoolean;
@@ -441,6 +470,18 @@ declare const MCP_OUTPUT: {
441
470
  currency: z.ZodString;
442
471
  expiresAt: z.ZodString;
443
472
  }, z.core.$strip>>;
473
+ wallets: z.ZodNullable<z.ZodObject<{
474
+ open: z.ZodBoolean;
475
+ current: z.ZodNullable<z.ZodType<(string & {}) | "wechat_pay" | "alipay", unknown, z.core.$ZodTypeInternals<(string & {}) | "wechat_pay" | "alipay", unknown>>>;
476
+ wechatPay: z.ZodNullable<z.ZodObject<{
477
+ qrData: z.ZodNullable<z.ZodString>;
478
+ qrImageUrl: z.ZodNullable<z.ZodString>;
479
+ url: z.ZodString;
480
+ }, z.core.$strip>>;
481
+ alipay: z.ZodNullable<z.ZodObject<{
482
+ url: z.ZodString;
483
+ }, z.core.$strip>>;
484
+ }, z.core.$strip>>;
444
485
  }, z.core.$strip>;
445
486
  cancel: z.ZodObject<{
446
487
  available: z.ZodBoolean;
@@ -614,6 +655,18 @@ declare const MCP_OUTPUT: {
614
655
  currency: z.ZodString;
615
656
  expiresAt: z.ZodString;
616
657
  }, z.core.$strip>>;
658
+ wallets: z.ZodNullable<z.ZodObject<{
659
+ open: z.ZodBoolean;
660
+ current: z.ZodNullable<z.ZodType<(string & {}) | "wechat_pay" | "alipay", unknown, z.core.$ZodTypeInternals<(string & {}) | "wechat_pay" | "alipay", unknown>>>;
661
+ wechatPay: z.ZodNullable<z.ZodObject<{
662
+ qrData: z.ZodNullable<z.ZodString>;
663
+ qrImageUrl: z.ZodNullable<z.ZodString>;
664
+ url: z.ZodString;
665
+ }, z.core.$strip>>;
666
+ alipay: z.ZodNullable<z.ZodObject<{
667
+ url: z.ZodString;
668
+ }, z.core.$strip>>;
669
+ }, z.core.$strip>>;
617
670
  }, z.core.$strip>;
618
671
  cancel: z.ZodObject<{
619
672
  available: z.ZodBoolean;
@@ -788,6 +841,18 @@ declare const MCP_OUTPUT: {
788
841
  currency: z.ZodString;
789
842
  expiresAt: z.ZodString;
790
843
  }, z.core.$strip>>;
844
+ wallets: z.ZodNullable<z.ZodObject<{
845
+ open: z.ZodBoolean;
846
+ current: z.ZodNullable<z.ZodType<(string & {}) | "wechat_pay" | "alipay", unknown, z.core.$ZodTypeInternals<(string & {}) | "wechat_pay" | "alipay", unknown>>>;
847
+ wechatPay: z.ZodNullable<z.ZodObject<{
848
+ qrData: z.ZodNullable<z.ZodString>;
849
+ qrImageUrl: z.ZodNullable<z.ZodString>;
850
+ url: z.ZodString;
851
+ }, z.core.$strip>>;
852
+ alipay: z.ZodNullable<z.ZodObject<{
853
+ url: z.ZodString;
854
+ }, z.core.$strip>>;
855
+ }, z.core.$strip>>;
791
856
  }, z.core.$strip>;
792
857
  cancel: z.ZodObject<{
793
858
  available: z.ZodBoolean;
@@ -959,6 +1024,18 @@ declare const MCP_OUTPUT: {
959
1024
  currency: z.ZodString;
960
1025
  expiresAt: z.ZodString;
961
1026
  }, z.core.$strip>>;
1027
+ wallets: z.ZodNullable<z.ZodObject<{
1028
+ open: z.ZodBoolean;
1029
+ current: z.ZodNullable<z.ZodType<(string & {}) | "wechat_pay" | "alipay", unknown, z.core.$ZodTypeInternals<(string & {}) | "wechat_pay" | "alipay", unknown>>>;
1030
+ wechatPay: z.ZodNullable<z.ZodObject<{
1031
+ qrData: z.ZodNullable<z.ZodString>;
1032
+ qrImageUrl: z.ZodNullable<z.ZodString>;
1033
+ url: z.ZodString;
1034
+ }, z.core.$strip>>;
1035
+ alipay: z.ZodNullable<z.ZodObject<{
1036
+ url: z.ZodString;
1037
+ }, z.core.$strip>>;
1038
+ }, z.core.$strip>>;
962
1039
  }, z.core.$strip>;
963
1040
  cancel: z.ZodObject<{
964
1041
  available: z.ZodBoolean;
@@ -1399,10 +1476,11 @@ declare const cancelOrderInput: z.ZodObject<{
1399
1476
  }, z.core.$strict>;
1400
1477
  type CancelOrderInput = z.input<typeof cancelOrderInput>;
1401
1478
  /** `POST /v1/orders/{orderId}/pay` and the MCP `pay_order` arguments: the
1402
- * order, a Stripe shared payment token granted for it, and the total the
1403
- * user approved. The token is `sharedPaymentToken` or, as UCP's Complete
1404
- * Checkout sends it, the credential of `payment`'s selected instrument:
1405
- * exactly one of the two. A total other than the order's answers
1479
+ * order, how to pay it, and the total the user approved. The way is a
1480
+ * Stripe shared payment token granted for the order, or `method`
1481
+ * (Alipay or WeChat Pay); with a token it is `sharedPaymentToken` or, as UCP's Complete
1482
+ * Checkout sends it, the credential of `payment`'s selected instrument.
1483
+ * Exactly one of `sharedPaymentToken`, `payment` and `method`. A total other than the order's answers
1406
1484
  * `payment_total_changed` and charges nothing. */
1407
1485
  declare const payOrderInput: z.ZodObject<{
1408
1486
  orderId: z.ZodString;
@@ -1420,6 +1498,9 @@ declare const payOrderInput: z.ZodObject<{
1420
1498
  display: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
1421
1499
  }, z.core.$loose>>;
1422
1500
  }, z.core.$strict>>;
1501
+ method: z.ZodOptional<z.ZodEnum<{
1502
+ alipay_wechat_pay: "alipay_wechat_pay";
1503
+ }>>;
1423
1504
  total: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
1424
1505
  }, z.core.$strict>;
1425
1506
  type PayOrderInput = z.input<typeof payOrderInput>;
@@ -1437,7 +1518,7 @@ declare const LIMITS: {
1437
1518
  readonly nightsFortrip: 30;
1438
1519
  readonly nightsSupplier: 15;
1439
1520
  readonly offersHotels: 15;
1440
- readonly offersPerHotelDefault: 5;
1521
+ readonly offersPerHotelDefault: 10;
1441
1522
  readonly offersPerHotelMax: 20;
1442
1523
  readonly pageSizeDefault: 20;
1443
1524
  readonly pageSizeMax: 50;
@@ -2585,14 +2666,29 @@ declare const order: z.ZodObject<{
2585
2666
  }, z.core.$strip>;
2586
2667
  }, z.core.$strip>>;
2587
2668
  /** What a payment credential for `pay_order` must allow, with
2588
- * `handlers`: `maxAmount` in minor units (cents) of `currency`,
2589
- * lowercase as Stripe takes it, and `expiresAt`, past which the order
2590
- * can't be paid. `null` when `handlers` is empty. */
2669
+ * `handlers`: at least `maxAmount`, in minor units (cents) of
2670
+ * `currency`, lowercase as Stripe takes it, and valid until at least
2671
+ * `expiresAt`, past which the order can't be paid. `null` when
2672
+ * `handlers` is empty. */
2591
2673
  credentialLimits: z.ZodNullable<z.ZodObject<{
2592
2674
  maxAmount: z.ZodNumber;
2593
2675
  currency: z.ZodString;
2594
2676
  expiresAt: z.ZodString;
2595
2677
  }, z.core.$strip>>;
2678
+ /** Paying with Alipay or WeChat Pay through `pay_order`'s `method`.
2679
+ * `null` when it is neither offered for the order nor open on it. */
2680
+ wallets: z.ZodNullable<z.ZodObject<{
2681
+ open: z.ZodBoolean;
2682
+ current: z.ZodNullable<z.ZodType<(string & {}) | "wechat_pay" | "alipay", unknown, z.core.$ZodTypeInternals<(string & {}) | "wechat_pay" | "alipay", unknown>>>;
2683
+ wechatPay: z.ZodNullable<z.ZodObject<{
2684
+ qrData: z.ZodNullable<z.ZodString>;
2685
+ qrImageUrl: z.ZodNullable<z.ZodString>;
2686
+ url: z.ZodString;
2687
+ }, z.core.$strip>>;
2688
+ alipay: z.ZodNullable<z.ZodObject<{
2689
+ url: z.ZodString;
2690
+ }, z.core.$strip>>;
2691
+ }, z.core.$strip>>;
2596
2692
  }, z.core.$strip>;
2597
2693
  /** Whether the user can cancel the order now and, when they can, its
2598
2694
  * penalty under the accepted terms (read a minute ahead) and the refund,
@@ -2769,14 +2865,29 @@ declare const orderList: z.ZodObject<{
2769
2865
  }, z.core.$strip>;
2770
2866
  }, z.core.$strip>>;
2771
2867
  /** What a payment credential for `pay_order` must allow, with
2772
- * `handlers`: `maxAmount` in minor units (cents) of `currency`,
2773
- * lowercase as Stripe takes it, and `expiresAt`, past which the order
2774
- * can't be paid. `null` when `handlers` is empty. */
2868
+ * `handlers`: at least `maxAmount`, in minor units (cents) of
2869
+ * `currency`, lowercase as Stripe takes it, and valid until at least
2870
+ * `expiresAt`, past which the order can't be paid. `null` when
2871
+ * `handlers` is empty. */
2775
2872
  credentialLimits: z.ZodNullable<z.ZodObject<{
2776
2873
  maxAmount: z.ZodNumber;
2777
2874
  currency: z.ZodString;
2778
2875
  expiresAt: z.ZodString;
2779
2876
  }, z.core.$strip>>;
2877
+ /** Paying with Alipay or WeChat Pay through `pay_order`'s `method`.
2878
+ * `null` when it is neither offered for the order nor open on it. */
2879
+ wallets: z.ZodNullable<z.ZodObject<{
2880
+ open: z.ZodBoolean;
2881
+ current: z.ZodNullable<z.ZodType<(string & {}) | "wechat_pay" | "alipay", unknown, z.core.$ZodTypeInternals<(string & {}) | "wechat_pay" | "alipay", unknown>>>;
2882
+ wechatPay: z.ZodNullable<z.ZodObject<{
2883
+ qrData: z.ZodNullable<z.ZodString>;
2884
+ qrImageUrl: z.ZodNullable<z.ZodString>;
2885
+ url: z.ZodString;
2886
+ }, z.core.$strip>>;
2887
+ alipay: z.ZodNullable<z.ZodObject<{
2888
+ url: z.ZodString;
2889
+ }, z.core.$strip>>;
2890
+ }, z.core.$strip>>;
2780
2891
  }, z.core.$strip>;
2781
2892
  /** Whether the user can cancel the order now and, when they can, its
2782
2893
  * penalty under the accepted terms (read a minute ahead) and the refund,
@@ -3405,8 +3516,10 @@ declare const API: {
3405
3516
  /** The MCP server answers at the root of `PUBLIC_ORIGINS.mcp`. */
3406
3517
  declare const MCP_PATH = "/";
3407
3518
 
3408
- /** The error envelope as text; `status` is the HTTP status, when known. */
3409
- declare function renderError(envelope: unknown, status?: number): string;
3519
+ /** The error envelope as text; `status` is the HTTP status, when known.
3520
+ * `surface` names the next calls: tools (`mcp`, the default) or commands
3521
+ * (`cli`). */
3522
+ declare function renderError(envelope: unknown, status?: number, surface?: RenderSurface): string;
3410
3523
 
3411
3524
  type RenderedTool = Exclude<ToolName, "get_planning_guide">;
3412
3525
  /**
@@ -3416,10 +3529,13 @@ type RenderedTool = Exclude<ToolName, "get_planning_guide">;
3416
3529
  * The consent rule (`ORDER_NEXT_STEP`) is the last paragraph whenever the
3417
3530
  * result holds a non-null `payment.url`; the pay rule (`PAY_NEXT_STEP`)
3418
3531
  * follows it when a result holds an order with non-empty `payment.handlers`;
3532
+ * the wallet rule (`WALLET_NEXT_STEP`) follows that when it holds an order
3533
+ * whose `payment.wallets` is offered and not open;
3419
3534
  * the cancel rule (`CANCEL_NEXT_STEP`) follows it when a `get_order` or
3420
- * `list_orders` result holds an order with `cancel.available`.
3535
+ * `list_orders` result holds an order with `cancel.available`. `surface`
3536
+ * names the next calls: tools (`mcp`, the default) or commands (`cli`).
3421
3537
  */
3422
- declare function renderToolResult(tool: RenderedTool, data: unknown): string;
3538
+ declare function renderToolResult(tool: RenderedTool, data: unknown, surface?: RenderSurface): string;
3423
3539
 
3424
3540
  /** Amenity codes a search can filter by (§7.7), in the order they are listed. */
3425
3541
  declare const FILTERABLE_AMENITIES: readonly ["parking", "wifi", "laundry", "restaurant", "room_service", "bar", "non_smoking", "business_center", "pool"];
@@ -3437,4 +3553,4 @@ declare const UNKNOWN_IS_NOT_NO_EXEMPTIONS: Readonly<Record<string, string>>;
3437
3553
  /** The contract's version, from package.json, the one place a release bumps it. */
3438
3554
  declare const CONTRACT_VERSION: string;
3439
3555
 
3440
- export { AMENITY_CODES, API, type AmenityCode, type AuthConfig, CANCEL_NEXT_STEP, CANCEL_REASONS, CARD_NUMBER_MESSAGE, CENTER_BASES, COMMANDS, COMMAND_GROUPS, CONTRACT_VERSION, CREDENTIAL_INVALID_REASONS, type CancelOrderInput, type CancelReason, type Center, type CommandGroupSpec, type CommandSpec, type CreateOrderInput, type CredentialInvalidReason, DISPLAY_CURRENCIES, type Destination, ERROR_CODES, ERROR_DETAILS, type ErrorBody, type ErrorCode, type ErrorEnvelope, FILTERABLE_AMENITIES, type FilterableAmenity, type FlagSpec, GLOBAL_FLAGS, type GetHotelInput, type GetOrderInput, type GuideSurface, type GuideTopic, type Hotel, type HotelOffersInput, type HotelOffersResult, type HotelSummary, type IndicativePrice, type KnownErrorBody, LIMITS, type ListOrdersInput, MCP_OUTPUT, MCP_PATH, type MeResult, type Money, ORDER_NEXT_STEP, ORDER_STATUSES, type Offer, type OfferChange, type Omitted, type OptionSpec, type Order, type OrderList, type OrderStatus, PAYMENT_STATUSES, PAY_NEXT_STEP, PLACE_KINDS, POLICY_TOPICS, PRESENTATION_HINT, PUBLIC_ORIGINS, type PayOrderInput, type PaymentHandler, type PaymentStatus, type Place, type PlaceRef, type PolicyTopic, type PositionalSpec, type RenderedTool, SEARCH_NOTE_CODES, SEARCH_SORTS, SUPPORT_EMAIL, type SearchHotelsInput, type SearchNoteCode, type SearchResult, type Stay, TOOLS, type ToolName, type ToolSpec, UNAVAILABLE_REASONS, UNKNOWN_IS_NOT_NO_EXEMPTIONS, addIsoDateDays, authConfig, cancelOrderInput, cancellation, center, commandInvocation, confirmation, containsCardNumber, countIsoDateDays, createOrderInput, createSearchHotelsInput, destination, errorEnvelope, flag, formatMoney, getHotelInput, getOrderInput, hotel, hotelId, hotelOffersInput, hotelOffersResult, hotelSummary, indicativePrice, instant, isIsoDate, knownLocaleText, latLng, listOrdersInput, localDate, localTime, localities, localizedText, meResult, meals, money, names, nonEmpty, offer, offerChange, offerId, omitted, oneOf, openEnum, openObject, openUnion, order, orderId, orderList, orderReference, parseOpen, payAtProperty, payOrderInput, paymentHandler, photo, place, placeId, placeRef, protocolObject, renderError, renderGuide, renderToolResult, roomFacts, searchHotelsInput, searchResult, sharedPaymentTokenOf, stay, stayEcho, strictInput, strictOutput, text, timeZone, usdMoney, wholeNumber };
3556
+ 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 RenderSurface, 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, WALLET_NEXT_STEP, addIsoDateDays, authConfig, cancelNextStep, 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, payNextStep, payOrderInput, paymentHandler, photo, place, placeId, placeRef, protocolObject, renderError, renderGuide, renderToolResult, roomFacts, searchHotelsInput, searchResult, sharedPaymentTokenOf, stay, stayEcho, strictInput, strictOutput, text, timeZone, usdMoney, walletNextStep, wholeNumber };
package/dist/index.js CHANGED
@@ -174,7 +174,7 @@ var LIMITS = {
174
174
  nightsFortrip: 30,
175
175
  nightsSupplier: 15,
176
176
  offersHotels: 15,
177
- offersPerHotelDefault: 5,
177
+ offersPerHotelDefault: 10,
178
178
  offersPerHotelMax: 20,
179
179
  pageSizeDefault: 20,
180
180
  pageSizeMax: 50,
@@ -245,7 +245,7 @@ var stay = strictInput({
245
245
  "Check-in date in the hotel's calendar, yyyy-MM-dd."
246
246
  ),
247
247
  checkOut: localDate.describe(
248
- `Check-out date in the hotel's calendar, yyyy-MM-dd. Stays are 1 to ${LIMITS.nightsFortrip} nights.`
248
+ `Check-out date in the hotel's calendar, yyyy-MM-dd. Stays are 1 to ${LIMITS.nightsSupplier} nights; a longer one answers stay_unsupported (max_nights), and past ${LIMITS.nightsFortrip} nights invalid_request: ask the user whether to split it into consecutive stays.`
249
249
  ),
250
250
  rooms: z5.array(
251
251
  strictInput({
@@ -264,7 +264,7 @@ var stay = strictInput({
264
264
  ).min(1, { error: `rooms must list 1 to ${LIMITS.rooms} rooms` }).max(LIMITS.rooms, {
265
265
  error: `rooms must list 1 to ${LIMITS.rooms} rooms`
266
266
  }).describe(
267
- `The rooms wanted, 1 to ${LIMITS.rooms}, each with its own party.`
267
+ `The rooms wanted, 1 to ${LIMITS.rooms}, each with its party; offers and orders need every room the same.`
268
268
  )
269
269
  }).superRefine((value, ctx) => {
270
270
  if (!isIsoDate(value.checkIn) || !isIsoDate(value.checkOut)) return;
@@ -548,10 +548,10 @@ var createOrderInput = strictInput({
548
548
  }).describe("What the hotel needs to know.")
549
549
  }),
550
550
  { error: "items must list exactly one offer" }
551
- ).min(1, { error: "items must list exactly one offer" }).max(1, { error: "items must list exactly one offer" }).describe("The offer to book. Exactly one in v1.")
551
+ ).min(1, { error: "items must list exactly one offer" }).max(1, { error: "items must list exactly one offer" }).describe("The offer to book: exactly one.")
552
552
  });
553
553
  var getOrderInput = strictInput({
554
- orderId: orderId.describe("orderId from create order or list orders."),
554
+ orderId: orderId.describe("The order's orderId."),
555
555
  locale: locale.optional()
556
556
  });
557
557
  var listLimitError = `limit must be a whole number from 1 to ${LIMITS.pageSizeMax}`;
@@ -564,9 +564,9 @@ var listOrdersInput = strictInput({
564
564
  });
565
565
  var maximumPenaltyError = "maximumPenalty must be a number of 0 or more: the order's cancel.penalty.amount, such as 12.5 for 12.50";
566
566
  var cancelOrderInput = strictInput({
567
- orderId: orderId.describe("orderId of the order to cancel, from get order or list orders."),
567
+ orderId: orderId.describe("The orderId of the order to cancel."),
568
568
  maximumPenalty: z5.number({ error: maximumPenaltyError }).min(0, { error: maximumPenaltyError }).describe(
569
- "The penalty the user agreed to: cancel.penalty.amount of the order, in its currency."
569
+ `The penalty the user agreed to, in the order's currency. Pass maximumPenalty as the number in cancel.penalty.amount ("120.00" \u2192 120).`
570
570
  )
571
571
  });
572
572
  var sharedPaymentTokenRe = /^spt_[A-Za-z0-9]{1,250}$/;
@@ -580,7 +580,9 @@ var ucpInstrument = z5.looseObject(
580
580
  handler_id: nonEmpty("handler_id").describe(
581
581
  "The id of the handler the instrument pays through: the order's stripe_payments for the selected one."
582
582
  ),
583
- type: nonEmpty("type").describe("The instrument type: card for the selected one."),
583
+ type: nonEmpty("type").describe(
584
+ "The instrument type: card for the selected one. A Link token is presented as a card instrument, whatever Link funds it with."
585
+ ),
584
586
  selected: flag("selected").optional().describe(
585
587
  "Whether this is the instrument to pay with. Exactly one is selected; a lone instrument without it is the one."
586
588
  ),
@@ -623,9 +625,9 @@ function selectedOf(instruments) {
623
625
  return chosen;
624
626
  }
625
627
  var payOrderInput = strictInput({
626
- orderId: orderId.describe("orderId of the order to pay, from create order or get order."),
628
+ orderId: orderId.describe("The orderId of the order to pay."),
627
629
  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."
630
+ "The shared payment token (spt_\u2026) the user approved for this order, requested with the order's payment.credentialLimits. Exactly one of sharedPaymentToken, payment and method."
629
631
  ),
630
632
  payment: strictInput({
631
633
  instruments: z5.array(ucpInstrument, { error: instrumentsError }).min(1, { error: instrumentsError }).max(8, { error: instrumentsError }).describe("The instruments, exactly one of them selected.")
@@ -661,19 +663,28 @@ var payOrderInput = strictInput({
661
663
  });
662
664
  }
663
665
  }).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."
666
+ "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, payment and method."
667
+ ),
668
+ method: oneOf("method", ["alipay_wechat_pay"]).optional().describe(
669
+ "Pay with Alipay or WeChat Pay instead of a token: opens the payment and returns payment.wallets. Exactly one of sharedPaymentToken, payment and method."
665
670
  ),
666
671
  total: usdMoney.describe(
667
672
  "The total the user approved: the order's price.total, exactly as returned."
668
673
  )
669
674
  }).superRefine((input, ctx) => {
670
- if (input.sharedPaymentToken !== void 0 && input.payment !== void 0) {
675
+ const given = [
676
+ ["sharedPaymentToken", input.sharedPaymentToken],
677
+ ["payment", input.payment],
678
+ ["method", input.method]
679
+ ].filter(([, value]) => value !== void 0);
680
+ const extra = given.length > 1 ? given.at(-1) : void 0;
681
+ if (extra) {
671
682
  ctx.addIssue({
672
683
  code: "custom",
673
- path: ["payment"],
674
- message: "Send sharedPaymentToken or payment, not both"
684
+ path: [extra[0]],
685
+ message: "Send exactly one of sharedPaymentToken, payment and method"
675
686
  });
676
- } else if (input.sharedPaymentToken === void 0 && input.payment === void 0) {
687
+ } else if (given.length === 0) {
677
688
  ctx.addIssue({
678
689
  code: "custom",
679
690
  path: ["sharedPaymentToken"],
@@ -710,10 +721,11 @@ function fieldDescription(json, field, sets = {}) {
710
721
  }
711
722
  function flagsOf(input, defs) {
712
723
  const json = z6.toJSONSchema(input, { io: "input" });
713
- return defs.map((def) => ({
714
- ...def,
715
- description: def.description ?? fieldDescription(json, def.field, def.sets)
716
- }));
724
+ return defs.map(({ required, ...def }) => {
725
+ const description = def.description ?? fieldDescription(json, def.field, def.sets);
726
+ const prefix = required === "always" ? "Required. " : required === "unless-body" ? "Required unless --body gives it. " : "";
727
+ return { ...def, description: `${prefix}${description}` };
728
+ });
717
729
  }
718
730
  function positional(input, name, description) {
719
731
  const json = z6.toJSONSchema(input, { io: "input" });
@@ -908,10 +920,10 @@ var bookFlags = flagsOf(createOrderInput, [
908
920
  placeholder: "<room>:<first>:<last>",
909
921
  description: "A guest, as `room:first:last`, e.g. `1:John:Smith` for room 1. Repeat for each guest: at least one per room of the offer, no more than the room sleeps. Names in Latin letters as on the passport; transliterate accents (M\xFCller \u2192 Mueller)."
910
922
  },
911
- { flag: "first-name", field: "contact.firstName", type: "string", placeholder: "<name>" },
912
- { flag: "last-name", field: "contact.lastName", type: "string", placeholder: "<name>" },
913
- { flag: "email", field: "contact.email", type: "string", placeholder: "<email>" },
914
- { flag: "phone", field: "contact.phone", type: "string", placeholder: "<phone>" },
923
+ { flag: "first-name", field: "contact.firstName", type: "string", placeholder: "<name>", required: "unless-body" },
924
+ { flag: "last-name", field: "contact.lastName", type: "string", placeholder: "<name>", required: "unless-body" },
925
+ { flag: "email", field: "contact.email", type: "string", placeholder: "<email>", required: "unless-body" },
926
+ { flag: "phone", field: "contact.phone", type: "string", placeholder: "<phone>", required: "unless-body" },
915
927
  {
916
928
  flag: "special-requests",
917
929
  field: "items.hotel.specialRequests",
@@ -940,13 +952,21 @@ var payFlags = flagsOf(payOrderInput, [
940
952
  field: "sharedPaymentToken",
941
953
  type: "string",
942
954
  placeholder: "<spt_\u2026>",
943
- description: "The shared payment token the user's wallet granted for this order, with the order's credential limits."
955
+ description: "Required unless --wallet. The spt_\u2026 token the user's Link wallet issued for this order."
956
+ },
957
+ {
958
+ flag: "wallet",
959
+ field: "method",
960
+ type: "boolean",
961
+ value: "alipay_wechat_pay",
962
+ description: "Pay with Alipay or WeChat Pay instead of a token: prints the WeChat Pay code and both links."
944
963
  },
945
964
  {
946
965
  flag: "total",
947
966
  field: "total",
948
967
  type: "string",
949
968
  placeholder: "<USD decimal>",
969
+ required: "always",
950
970
  description: "The total the user approved, exactly as `orders get` shows it, in USD, e.g. `125.00`."
951
971
  }
952
972
  ]);
@@ -1019,7 +1039,7 @@ var COMMANDS = [
1019
1039
  {
1020
1040
  group: "orders",
1021
1041
  name: "pay",
1022
- summary: "Pay an order with a shared payment token instead of its link",
1042
+ summary: "Pay an order with a Link wallet token (US and Canada) or with Alipay or WeChat Pay, instead of its payment link",
1023
1043
  tool: "pay_order",
1024
1044
  flags: payFlags,
1025
1045
  positionals: [positional(payOrderInput, "orderId")]
@@ -1027,7 +1047,7 @@ var COMMANDS = [
1027
1047
  {
1028
1048
  group: null,
1029
1049
  name: "login",
1030
- summary: "Sign in through the browser (device code)",
1050
+ summary: "Sign in through the browser",
1031
1051
  tool: null,
1032
1052
  flags: [],
1033
1053
  options: [
@@ -1055,7 +1075,7 @@ var COMMANDS = [
1055
1075
  {
1056
1076
  group: null,
1057
1077
  name: "guide",
1058
- summary: "Print the guide for AI agents (Markdown)",
1078
+ summary: "Print the guide for AI agents (Markdown); `fortrip guide planning` prints the planning guide",
1059
1079
  tool: "get_planning_guide",
1060
1080
  flags: [],
1061
1081
  positionals: [
@@ -1222,12 +1242,12 @@ var FRAGMENTS = {
1222
1242
  "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",
1223
1243
  "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',
1224
1244
  "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",
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',
1226
- "payment-link": "{{#if claude-skill cli}}\n## Before giving the payment link\n\n`{{tool:hotels book}}` answers with an unpaid order: `status` `awaiting_payment`, its `reference` (the support number), `price.total`, the stay and its terms, and `payment.url`, a Fortrip page that recaps the order and continues to payment on Stripe. Nothing is charged until the user pays.\n\n1. Show the order's total and currency, the stay (hotel, room, dates, rooms and guests per room) and every term: meals, cancellation (status, deadline, penalties) and fees payable at the property, unknowns included.\n2. End that reply by asking the user to confirm, and wait for a clear yes. Urgency is not consent.\n3. Then give `payment.url` exactly as returned: don't shorten, rebuild or re-encode it.\n\n{{/if}}\n{{#if mcp}}\n- Before you give `payment.url`, show the user the order's total and currency, the stay and every term, end that reply by asking the user to confirm, and wait for a clear yes. Then give `payment.url` exactly as returned, to this user only: anyone holding it can pay.\n{{/if}}\n{{#if claude-skill cli}}\n- `payment.url` works like a payment credential: anyone holding it can pay. Give it to this user only, never in shared channels, documents, logs or tickets. With `requiresSignIn: true` (an order started on the Fortrip website), the user signs in to pay.\n- The link expires at `payment.expiresAt`; the order is then `expired`. To order the stay again, get offers again, and confirm the new order with the user before giving its link.\n- Another order of the stay (another party, or a corrected guest name) needs a new offer: get offers again. When it replaces an unpaid order, tell the user to pay only the new link; the earlier one expires unpaid.\n- An order `awaiting_payment` whose `payment.url` is null had its link unreadable this time: read it again with `{{tool:orders get}}`.\n{{/if}}\n- Never ask for, accept or pass on payment card details; payment happens only through Stripe.{{#if claude-skill cli}} A card number in a guest name, the contact or the special requests is rejected{{#if cli}} with exit 2{{/if}}.{{/if}}\n{{#if claude-skill cli}}\n\n## Paying without the link\n\nAn order whose `payment.handlers` isn't empty can also be paid with a Stripe shared payment token that the user's wallet (Link) grants for it, through `{{tool:orders pay}}`:\n\n1. Show and ask exactly as before giving the payment link, and wait for a clear yes. The token comes from the user's wallet, never from card details.\n2. Request the token from the user's wallet with the handler's `config.business_profile` and `payment.credentialLimits`: `maxAmount` (in cents), `currency` and `expiresAt`.\n3. {{#if claude-skill}}Call{{/if}}{{#if cli}}Run{{/if}} `{{tool:orders pay}}` with the token and the order's `price.total`{{#if cli}} (`--token`, `--total`){{/if}}{{#if claude-skill}}, the token as `sharedPaymentToken` or in UCP's `payment.instruments`{{/if}}. The order is then `confirming`, its payment `authorized`: check it as after payment.\n\nThe charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once `{{tool:orders pay}}` succeeds, `payment.url` stops working; a payment that fails leaves the link open. `payment_total_changed` means the total changed: show the new total and ask again, for a new token. `payment_declined`: the user picks another payment method in their wallet, or pays by link. `payment_action_required`: the card needs a verification this can't give: pay by link. `payment_credential_invalid`: request a new token with the order's `payment.credentialLimits`. `service_unavailable`: call `{{tool:orders pay}}` again with the same token, never a new one. A token pays one order only.\n\n## After payment\n\nCheck the order with `{{tool:orders get}}`:\n\n- `confirming` while the hotel confirms, then `confirmed` with the hotel's `confirmationNumber`.\n- `failed`: no stay was booked; `payment.status` says whether the payment was released or refunded.\n- `needs_attention`: Fortrip is looking into it; the user can email {{support}} with the `reference`.\n- `manageUrl` is the user's own page for the order.\n{{/if}}\n",
1245
+ "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.\n{{/if}}\n',
1246
+ "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- Pay one way only: give `payment.url` or call `{{tool:orders pay}}`. First show the order's total and currency, the stay and every term, end that reply by asking the user to confirm, and wait for a clear yes. Then give `payment.url` exactly as returned, to this user only: anyone holding it can pay.\n{{/if}}\n{{#if claude-skill cli}}\n- `payment.url` works like a payment credential: anyone holding it can pay. Give it to this user only, never in shared channels, documents, logs or tickets. With `requiresSignIn: true` (an order started on the Fortrip website), the user signs in to pay.\n- The link expires at `payment.expiresAt`; the order is then `expired`. To order the stay again, get offers again, and confirm the new order with the user before giving its link.\n- Another order of the stay (another party, or a corrected guest name) needs a new offer: get offers again. When it replaces an unpaid order, tell the user to pay only the new link; the earlier one expires unpaid.\n- An order `awaiting_payment` whose `payment.url` is null had its link unreadable this time: read it again with `{{tool:orders get}}`.\n{{/if}}\n- Never ask for, accept or pass on payment card details; payment happens only through Stripe.{{#if claude-skill cli}} A card number in a guest name, the contact or the special requests is rejected{{#if cli}} with exit 2{{/if}}.{{/if}}\n{{#if claude-skill cli}}\n\n## Paying without the link\n\nAn order whose `payment.handlers` isn't empty (in {{#if claude-skill}}a result's text{{/if}}{{#if cli}}the text output{{/if}}, the line \"Pay without the link\") can also be paid through `{{tool:orders pay}}` with a Stripe shared payment token that the user's Link wallet grants for it. Use it only if you have a tool that can request such a token from the user's Link wallet: Link is for US and Canadian accounts, and caps a spend request at $500, so `payment.handlers` is empty for a larger order. Otherwise give `payment.url`, and never ask the user to create, type or paste a token.\n\n1. Show the user the order's total and currency, the stay (hotel, room, dates, rooms and guests per room) and every term: meals, cancellation and fees payable at the property. End that reply by asking the user to confirm, 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 Link 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: either give `payment.url` or {{#if claude-skill}}call{{/if}}{{#if cli}}run{{/if}} `{{tool:orders pay}}`. Once `{{tool:orders pay}}` succeeds, `payment.url` stops working; a payment that fails leaves the link open. `payment_total_changed` means the total sent isn't the order's (`details.total`); the order's total hasn't changed: confirm it with the user, then {{#if claude-skill}}call{{/if}}{{#if cli}}run{{/if}} `{{tool:orders pay}}` again with it and the same 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## Paying with Alipay or WeChat Pay\n\nAn order whose result text has the line \"Pay with Alipay or WeChat Pay\" can be paid in the user's Alipay or WeChat wallet, with no token: it is for users who have a mainland-China wallet. {{#if claude-skill}}Call{{/if}}{{#if cli}}Run{{/if}} `{{tool:orders pay}}` {{#if claude-skill}}with `method` `alipay_wechat_pay`{{/if}}{{#if cli}}the way that line shows{{/if}} and the order's `price.total`, only after the user has confirmed.\n\n1. Show the user the order's total in USD, the stay (hotel, room, dates, rooms and guests per room) and every term: meals, cancellation and fees payable at the property. End that reply by asking the user to confirm, and wait for a clear yes. Pay one way only: `payment.url` or this.\n2. Then show `payment.wallets`: the WeChat Pay code as an image if you can, and both links (WeChat Pay and Alipay). The user pays once, by either. Alipay and WeChat Pay charge at once; if the hotel can't confirm, the payment is refunded in full. The total is in US dollars, and the wallets show it in yuan at their rate.\n3. Check the order with `{{tool:orders get}}` until it isn't `awaiting_payment`.\n\nA code goes dead when the user opens the Alipay link instead, or when it expires. Then `payment.wallets.wechatPay.qrData` is null: tell the user to open the WeChat link again, or {{#if claude-skill}}call{{/if}}{{#if cli}}run{{/if}} `{{tool:orders pay}}` again for a new code.\n\nWeChat can't scan a code shown on the same phone's screen. Offer both ways, since you can't tell which device the user is on: save the image and scan it from the album (WeChat, then Scan, then Album), or open the WeChat link on another screen; on a phone, the Alipay link opens the Alipay app.\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",
1227
1247
  "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",
1228
1248
  "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",
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",
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",
1249
+ "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{{#if claude-skill cli}} (Adaptive Pricing): 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",
1250
+ "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, `{{tool:orders cancel}}` cancels, `{{tool:orders pay}}` pays by token or Alipay/WeChat Pay. `{{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, by a shared payment token from the user's wallet, or with Alipay or WeChat Pay |\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
1251
  "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",
1232
1252
  "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"
1233
1253
  };
@@ -1522,7 +1542,7 @@ var hotelSummary = openObject({
1522
1542
  distanceMeters: z11.number().nullable(),
1523
1543
  price: indicativePrice.nullable(),
1524
1544
  /** The cover photo; `null` without one. */
1525
- photo: photo.nullable()
1545
+ photo: photo.nullable().describe("The cover photo; null when there is none.")
1526
1546
  });
1527
1547
  var localities = openObject({
1528
1548
  items: z11.array(
@@ -1597,7 +1617,7 @@ var searchResult = openObject({
1597
1617
  nameAsText: count.nullable()
1598
1618
  }),
1599
1619
  data: z11.array(hotelSummary),
1600
- nextCursor: z11.string().nullable(),
1620
+ nextCursor: z11.string().nullable().describe("Pass it back as cursor for the next page; null on the last page."),
1601
1621
  notes: z11.array(
1602
1622
  openObject({ code: openEnum(SEARCH_NOTE_CODES), message: z11.string() })
1603
1623
  )
@@ -1643,7 +1663,7 @@ var hotel = openObject({
1643
1663
  description: knownLocaleText.nullable(),
1644
1664
  /** Up to 8 hotel photos, the cover first; `null` when the catalogue lists
1645
1665
  * none (unknown is not no). */
1646
- photos: z12.array(photo).nullable(),
1666
+ photos: z12.array(photo).nullable().describe("Up to 8 hotel photos, the cover first; null when the catalogue lists none."),
1647
1667
  checkInTimes: timeRange,
1648
1668
  checkOutTimes: timeRange,
1649
1669
  policies: openObject({
@@ -1859,7 +1879,9 @@ var order = openObject({
1859
1879
  price: openObject({ total: money }),
1860
1880
  payment: openObject({
1861
1881
  status: openEnum(PAYMENT_STATUSES),
1862
- url: z14.string().nullable(),
1882
+ url: z14.string().nullable().describe(
1883
+ "The payment page, on fortrip.ai. With requiresSignIn false it continues to Stripe Checkout, and anyone holding it can pay; with requiresSignIn true (an order started on the Fortrip website) it continues to the Fortrip booking page, where only the signed-in owner can pay. null when the order isn't awaiting payment, or, while it is, when the link couldn't be read this time: read the order again."
1884
+ ),
1863
1885
  requiresSignIn: z14.boolean(),
1864
1886
  expiresAt: instant.nullable(),
1865
1887
  chargeCurrency: z14.string(),
@@ -1868,31 +1890,62 @@ var order = openObject({
1868
1890
  /** The ways to pay other than `url`, while the order can be paid that
1869
1891
  * way: a `com.stripe.payments` handler takes a shared payment token
1870
1892
  * through `pay_order`. Empty when there is none. */
1871
- handlers: z14.array(paymentHandler),
1893
+ handlers: z14.array(paymentHandler).describe(
1894
+ "The ways to pay other than url: a com.stripe.payments handler takes a Stripe shared payment token through pay_order. [] when a token can't pay the order: over $500, not charged in USD, an order started on the Fortrip website, a negotiated price, under 15 minutes left, 5 tokens tried, a token payment is under way, or token payment isn't offered for this order."
1895
+ ),
1872
1896
  /** What a payment credential for `pay_order` must allow, with
1873
- * `handlers`: `maxAmount` in minor units (cents) of `currency`,
1874
- * lowercase as Stripe takes it, and `expiresAt`, past which the order
1875
- * can't be paid. `null` when `handlers` is empty. */
1897
+ * `handlers`: at least `maxAmount`, in minor units (cents) of
1898
+ * `currency`, lowercase as Stripe takes it, and valid until at least
1899
+ * `expiresAt`, past which the order can't be paid. `null` when
1900
+ * `handlers` is empty. */
1876
1901
  credentialLimits: openObject({
1877
- maxAmount: z14.number().int(),
1878
- currency: z14.string(),
1879
- expiresAt: instant
1880
- }).nullable()
1902
+ maxAmount: z14.number().int().describe("Request the token for at least this amount, in cents; a token that allows less can't pay."),
1903
+ currency: z14.string().describe("The token's currency, lowercase as Stripe takes it: usd."),
1904
+ expiresAt: instant.describe(
1905
+ "Request the token valid until at least this time; the order can't be paid after it."
1906
+ )
1907
+ }).nullable().describe(
1908
+ "What the shared payment token for pay_order must allow. null exactly when handlers is []."
1909
+ ),
1910
+ /** Paying with Alipay or WeChat Pay through `pay_order`'s `method`.
1911
+ * `null` when it is neither offered for the order nor open on it. */
1912
+ wallets: openObject({
1913
+ open: z14.boolean().describe("Whether pay_order has opened a wallet payment on this order."),
1914
+ current: openEnum(["wechat_pay", "alipay"]).nullable().describe("The wallet the payment is on now; null until it is open."),
1915
+ wechatPay: openObject({
1916
+ qrData: z14.string().nullable().describe(
1917
+ "The WeChat Pay code's content, to draw as a QR code; null when there is no live code (open wechatPay.url for one)."
1918
+ ),
1919
+ qrImageUrl: z14.string().nullable().describe("A 480 px PNG of the same code."),
1920
+ url: z14.string().describe("A link, on fortrip.ai, for the user to pay with WeChat Pay; anyone holding it can pay.")
1921
+ }).nullable().describe("The WeChat Pay code and link; null until the payment is open."),
1922
+ alipay: openObject({
1923
+ url: z14.string().describe("A link, on fortrip.ai, for the user to pay with Alipay; anyone holding it can pay.")
1924
+ }).nullable().describe("The Alipay link; null until the payment is open.")
1925
+ }).nullable().describe(
1926
+ "Paying with Alipay or WeChat Pay: pass method alipay_wechat_pay to pay_order to open it. null when the order can't be paid this way and none is open."
1927
+ )
1881
1928
  }),
1882
1929
  /** Whether the user can cancel the order now and, when they can, its
1883
1930
  * penalty under the accepted terms (read a minute ahead) and the refund,
1884
1931
  * what was paid less the penalty, both in the charge currency. */
1885
1932
  cancel: openObject({
1886
- available: z14.boolean(),
1887
- reason: openEnum(CANCEL_REASONS),
1888
- penalty: money.nullable(),
1889
- refund: money.nullable()
1890
- }),
1933
+ available: z14.boolean().describe("Whether the user can cancel the order now."),
1934
+ reason: openEnum(CANCEL_REASONS).describe(
1935
+ "cancellable when it can be cancelled now; otherwise why not."
1936
+ ),
1937
+ penalty: money.nullable().describe(
1938
+ "The penalty if cancelled now, under the accepted terms, in the charge currency; null when not stated."
1939
+ ),
1940
+ refund: money.nullable().describe(
1941
+ "What a cancellation now refunds: what was paid less the penalty, in the charge currency; null when not stated."
1942
+ )
1943
+ }).describe("Whether the order can be cancelled now, and for what penalty and refund."),
1891
1944
  manageUrl: z14.string()
1892
1945
  });
1893
1946
  var orderList = openObject({
1894
1947
  data: z14.array(order),
1895
- nextCursor: z14.string().nullable()
1948
+ nextCursor: z14.string().nullable().describe("Pass it back as cursor for the next page; null on the last page.")
1896
1949
  });
1897
1950
  function change(field, value) {
1898
1951
  return openObject({
@@ -2063,8 +2116,43 @@ var MCP_PATH = "/";
2063
2116
  // src/tools.ts
2064
2117
  import { z as z16 } from "zod";
2065
2118
  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.";
2066
- var CANCEL_NEXT_STEP = "Before you call cancel_order, show the user the order's stay (hotel, dates), cancel.penalty and cancel.refund (amount and currency), then end your reply by asking them to confirm the cancellation, and wait for a clear yes. Pass maximumPenalty exactly as cancel.penalty.amount. Never state a refund the order did not return.";
2067
- var PAY_NEXT_STEP = "To pay without the link, when the order's payment.handlers isn't empty and the user's wallet can grant a Stripe shared payment token: first show and ask exactly as for payment.url, and wait for a clear yes. Then request the token for this order from the user's wallet with the handler's config.business_profile and payment.credentialLimits (maxAmount in cents, currency, expiresAt), and call pay_order with it and the order's price.total. The charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once pay_order succeeds, payment.url stops working.";
2119
+ var CALLS = {
2120
+ mcp: {
2121
+ cancel: "call cancel_order",
2122
+ penalty: 'Pass maximumPenalty as the number in cancel.penalty.amount ("120.00" \u2192 120).',
2123
+ pay: "call pay_order",
2124
+ payWallet: " with method alipay_wechat_pay",
2125
+ get: "call get_order",
2126
+ poll: "poll get_order",
2127
+ payWith: "call pay_order with it and the order's price.total",
2128
+ paid: "pay_order"
2129
+ },
2130
+ cli: {
2131
+ cancel: "run `fortrip orders cancel <orderId> --max-penalty <n>`",
2132
+ penalty: "Pass the penalty's amount as --max-penalty (120.00 for a penalty of USD 120.00).",
2133
+ pay: "run `fortrip orders pay`",
2134
+ payWallet: " with --wallet",
2135
+ get: "run `fortrip orders get <orderId>`",
2136
+ poll: "poll it with `fortrip orders get <orderId>`",
2137
+ payWith: "run `fortrip orders pay <orderId> --token <spt_\u2026> --total <total>` with the token and the order's total",
2138
+ paid: "`fortrip orders pay`"
2139
+ }
2140
+ };
2141
+ function cancelNextStep(surface) {
2142
+ const c = CALLS[surface];
2143
+ return `Before you ${c.cancel}, 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. ${c.penalty} Never state a refund the order did not return.`;
2144
+ }
2145
+ var CANCEL_NEXT_STEP = cancelNextStep("mcp");
2146
+ function payNextStep(surface) {
2147
+ const c = CALLS[surface];
2148
+ return `To pay without the link: only if you have a tool that can request a Stripe shared payment token from the user's Link wallet (US and Canadian Link accounts), and the order's payment.handlers isn't empty. Otherwise give payment.url, and never ask the user to create, type or paste a token. Before you ${c.pay}, show the user the order's 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. Then request the token for this order from the user's Link wallet with the handler's config.business_profile and payment.credentialLimits (maxAmount in cents, currency, expiresAt), and ${c.payWith}. The charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: either give payment.url or ${c.pay}. Once ${c.paid} succeeds, payment.url stops working; a failed payment leaves it open.`;
2149
+ }
2150
+ var PAY_NEXT_STEP = payNextStep("mcp");
2151
+ function walletNextStep(surface) {
2152
+ const c = CALLS[surface];
2153
+ return `Before you ${c.pay}${c.payWallet}, show the user the order's total in USD, the stay (hotel, room, dates, rooms and guests per room) and every term (meals, cancellation, fees payable at the property), then ask them to confirm, and wait for a clear yes. Then show payment.wallets: the WeChat code as an image if you can, and both links. The user pays once, by one of them. Alipay and WeChat Pay charge at once; if the hotel can't confirm, the payment is refunded in full. Then ${c.poll}.`;
2154
+ }
2155
+ var WALLET_NEXT_STEP = walletNextStep("mcp");
2068
2156
  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.";
2069
2157
  var nextStep = z16.string().optional().describe(
2070
2158
  "What to show and ask before giving a payment.url. Present when the answer holds a non-null payment.url, and only then."
@@ -2119,7 +2207,7 @@ var TOOLS = [
2119
2207
  {
2120
2208
  name: "book_hotel",
2121
2209
  title: "Create hotel order and payment link",
2122
- description: `Order one offer from get_hotel_offers. The answer is an unpaid order with a payment link: status awaiting_payment, the total, the stay and its terms, and payment.url, a Fortrip page where the user pays. Nothing is charged until the user pays there; anyone holding the link can pay. Send the contact and, for each room of the offer, at least one guest. If the price or terms changed since the offer, the answer is offer_changed with every change and a new offer: show the changes and ask the user again before ordering it. Sending the same details again returns the same order. An offer is ordered once: for another order of the stay (another party, or a corrected guest name), get offers again and order the new offer; when it replaces an unpaid order, tell the user to pay only the new link, as the earlier one expires unpaid. To cancel an order, use cancel_order; for changes, or a cancellation cancel_order can't make, the user emails ${SUPPORT_EMAIL} with the order's reference.`,
2210
+ description: `Order one offer from get_hotel_offers. The answer is an unpaid order with a payment link: status awaiting_payment, the total, the stay and its terms, and payment.url, a Fortrip page to pay on. Nothing is charged until the order is paid, on that page or with pay_order (or Alipay/WeChat Pay); anyone holding the link can pay. Send the contact and, for each room of the offer, at least one guest. If the price or terms changed since the offer, the answer is offer_changed with every change and a new offer: show the changes and ask the user again before ordering it. Sending the same details again returns the same order. An offer is ordered once: for another order of the stay (another party, or a corrected guest name), get offers again and order the new offer; when it replaces an unpaid order, tell the user to pay only the new link, as the earlier one expires unpaid. To cancel an order, use cancel_order; for changes, or a cancellation cancel_order can't make, the user emails ${SUPPORT_EMAIL} with the order's reference.`,
2123
2211
  annotations: {
2124
2212
  readOnlyHint: false,
2125
2213
  idempotentHint: false,
@@ -2160,8 +2248,8 @@ var TOOLS = [
2160
2248
  },
2161
2249
  {
2162
2250
  name: "pay_order",
2163
- title: "Pay order with a shared payment token",
2164
- description: "Pay an order awaiting payment without its link, with a Stripe shared payment token, when the order's payment.handlers isn't empty. First show and ask exactly as for payment.url, and wait for a clear yes. Then request the token from the user's wallet with the handler's config.business_profile and payment.credentialLimits, and pass it with the order's price.total. The charge is in USD. Once it succeeds, payment.url stops working; a payment that fails leaves the link open. Answers the order: status confirming, the payment authorized (held, charged once the hotel confirms); poll get_order. payment_total_changed: show details.total and ask again, for a new token. payment_declined: the user picks another payment method in their wallet, or pays by link. payment_action_required: the card needs verification; pay by link. payment_credential_invalid: request a new token. service_unavailable: call pay_order again with the same token, never a new one. A token pays one order only; the same token again answers as before.",
2251
+ title: "Pay order by token or Alipay/WeChat Pay",
2252
+ description: "Pay an order without its link, by shared payment token or Alipay/WeChat Pay (method alipay_wechat_pay). Token: only if payment.handlers isn't empty and you can request one from the user's Link wallet (US and Canadian accounts); never ask the user for one. First show the user the USD total, the stay and every term (meals, cancellation, fees payable at the property), ask them to confirm, and wait for a clear yes. Token: request it with config.business_profile and payment.credentialLimits; pass it with price.total. Wallet: pass method, price.total; show payment.wallets (the WeChat code as an image if you can, both links); they pay once, by either; if the code is dead, the WeChat link opens a new one, or call again. Pay one way only: payment.url or pay_order. On success payment.url stops working; on failure it stays open. Then poll get_order. payment_total_changed: confirm details.total, retry. payment_credential_invalid: new token. service_unavailable: retry. Else payment.url. A token pays one order only.",
2165
2253
  annotations: {
2166
2254
  readOnlyHint: false,
2167
2255
  idempotentHint: true,
@@ -2415,9 +2503,10 @@ var OMITTED = {
2415
2503
  dominated: "beaten by or the same as another offer for the same room",
2416
2504
  unreadable: "unreadable"
2417
2505
  };
2418
- function limitText(o) {
2506
+ function limitText(o, surface) {
2419
2507
  const n = o.byLimit;
2420
- return typeof n === "number" && n > 0 ? `${plural(n, "more offer")} not shown (limitPerHotel); a filtered request (requireBreakfast / requireFreeCancellation) or a higher limitPerHotel may show them \u2014 don't conclude they don't exist` : "";
2508
+ const [limit, filters] = surface === "cli" ? ["--limit-per-hotel", "--require-breakfast / --require-free-cancellation"] : ["limitPerHotel", "requireBreakfast / requireFreeCancellation"];
2509
+ return typeof n === "number" && n > 0 ? `${plural(n, "more offer")} not shown (${limit}); a filtered request (${filters}) or a higher ${limit} may show them \u2014 don't conclude they don't exist` : "";
2421
2510
  }
2422
2511
  function omittedText(o) {
2423
2512
  return Object.entries(OMITTED).filter(([key]) => typeof o[key] === "number" && o[key] > 0).map(([key, words]) => `${o[key]} ${words}`).join(", ");
@@ -2431,7 +2520,7 @@ var UNAVAILABLE = {
2431
2520
  supplier_unavailable: "offers could not be fetched this time",
2432
2521
  stay_in_past: "check-in is already past"
2433
2522
  };
2434
- function renderOffers(r) {
2523
+ function renderOffers(r, surface = "mcp") {
2435
2524
  const lines = [
2436
2525
  `Live offers \xB7 ${stayLine(r.stay.checkIn, r.stay.checkOut)} \xB7 ${party(r.stay.rooms)}`,
2437
2526
  "total = the whole stay and every room, the amount charged. Fees not in the total are in the property's currency, not converted. Times are UTC, then the hotel's time zone."
@@ -2442,13 +2531,13 @@ function renderOffers(r) {
2442
2531
  h.offers.forEach((o, i) => lines.push(`${i + 1}. ${offerLine(o)}`));
2443
2532
  const omitted2 = omittedText(h.omitted);
2444
2533
  if (omitted2) lines.push(`Not shown: ${omitted2}.`);
2445
- const limited = limitText(h.omitted);
2534
+ const limited = limitText(h.omitted, surface);
2446
2535
  if (limited) lines.push(`${limited}.`);
2447
2536
  }
2448
2537
  if (r.unavailable.length > 0) {
2449
2538
  lines.push("", "Unavailable:");
2450
2539
  for (const u of r.unavailable) {
2451
- const omitted2 = u.omitted ? [omittedText(u.omitted), limitText(u.omitted)].filter(Boolean).join("; ") : "";
2540
+ const omitted2 = u.omitted ? [omittedText(u.omitted), limitText(u.omitted, surface)].filter(Boolean).join("; ") : "";
2452
2541
  lines.push(`- ${u.hotelId}: ${label(UNAVAILABLE, u.reason)}${omitted2 ? ` (${omitted2})` : ""}`);
2453
2542
  }
2454
2543
  }
@@ -2504,7 +2593,7 @@ function itemLines(item) {
2504
2593
  `Hotel confirmation number: ${h.confirmationNumber ?? "none yet"}`
2505
2594
  ];
2506
2595
  }
2507
- function paymentLines(o) {
2596
+ function paymentLines(o, surface) {
2508
2597
  const p = o.payment;
2509
2598
  const lines = [
2510
2599
  [
@@ -2523,43 +2612,75 @@ function paymentLines(o) {
2523
2612
  } else if (o.status === "awaiting_payment") {
2524
2613
  lines.push("Payment link: could not be read this time; read this order again for it.");
2525
2614
  }
2526
- if (p.handlers.length > 0) lines.push(handlersLine(p.handlers, p.credentialLimits));
2527
- lines.push(cancelLine(o.cancel));
2615
+ if (p.handlers.length > 0) lines.push(handlersLine(o, surface));
2616
+ if (p.wallets) lines.push(...walletLines(p.wallets, surface));
2617
+ lines.push(cancelLine(o));
2528
2618
  lines.push(`Manage: ${o.manageUrl}`);
2529
2619
  return lines;
2530
2620
  }
2531
- function handlersLine(handlers, limits) {
2621
+ function handlersLine(o, surface) {
2622
+ const { handlers, credentialLimits: limits } = o.payment;
2623
+ const pay = surface === "cli" ? `\`fortrip orders pay ${o.orderId} --token <spt_\u2026> --total ${o.price.total.amount}\`` : "pay_order";
2532
2624
  const shown = handlers.map(
2533
2625
  (h) => `${h.type} (handler ${h.id}, business_profile ${h.config.business_profile})`
2534
2626
  );
2535
2627
  const limit = limits ? `; token limits: maxAmount ${limits.maxAmount} (cents), currency ${limits.currency}, expiresAt ${limits.expiresAt}` : "";
2536
- return `Pay without the link: pay_order with a shared payment token via ${shown.join(", ")}${limit}`;
2628
+ return [
2629
+ `Pay without the link: ${pay} with a shared payment token via ${shown.join(", ")}${limit}.`,
2630
+ "Only if you have a tool that can request the token from the user's Link wallet (US and Canadian Link accounts); otherwise give the payment link, and never ask the user to create, type or paste a token.",
2631
+ `First show the user the total and currency, the stay and every term, and wait for a clear yes. Pay one way only: the link or ${surface === "cli" ? "`fortrip orders pay`" : "pay_order"}.`
2632
+ ].join(" ");
2633
+ }
2634
+ function walletLines(w, surface) {
2635
+ const c = CALLS[surface];
2636
+ if (!w.open) {
2637
+ const pay = surface === "cli" ? "run `fortrip orders pay <orderId> --wallet --total <total>`" : "call pay_order with method alipay_wechat_pay and the order's price.total";
2638
+ return [`Pay with Alipay or WeChat Pay: ${pay}.`];
2639
+ }
2640
+ const lines = [];
2641
+ const wechat = w.wechatPay;
2642
+ if (wechat) {
2643
+ const live = wechat.qrData !== null && wechat.qrImageUrl !== null;
2644
+ lines.push(
2645
+ !live ? `WeChat Pay: a new code at ${wechat.url}` : surface === "cli" ? `WeChat Pay: open ${wechat.url}` : `WeChat Pay: ![WeChat Pay QR code](${wechat.qrImageUrl}), or a full-size code at ${wechat.url}`
2646
+ );
2647
+ }
2648
+ if (w.alipay) lines.push(`Alipay: ${w.alipay.url}`);
2649
+ lines.push(
2650
+ `Show the user the WeChat Pay code as an image if you can, and both links. They pay once, by either. Then ${c.get} until the order isn't awaiting_payment.`
2651
+ );
2652
+ return lines;
2537
2653
  }
2538
- function cancelLine(c) {
2654
+ function cancelLine(o) {
2655
+ const c = o.cancel;
2656
+ if (o.status === "awaiting_payment" && !c.available && c.reason === "not_confirmed") {
2657
+ const at = o.payment.expiresAt === null ? "" : ` at ${when(o.payment.expiresAt, null)}`;
2658
+ return `Cancel: not needed: an unpaid order expires unpaid${at}`;
2659
+ }
2539
2660
  const figure = (name, m) => `${name} ${m ? money2(m) : "not stated"}`;
2540
2661
  const figures = `${figure("penalty", c.penalty)}, ${figure("refund", c.refund)}`;
2541
2662
  if (c.available) return `Cancel: can cancel now: ${figures}`;
2542
2663
  const why = `Cancel: not available: ${label(CANCEL_REASON_WORDS, c.reason)}`;
2543
2664
  return c.penalty || c.refund ? `${why} \xB7 ${figures}` : why;
2544
2665
  }
2545
- function orderLines(o) {
2666
+ function orderLines(o, surface = "mcp") {
2546
2667
  return [
2547
2668
  `Order ${o.orderId} \xB7 reference ${o.reference} \xB7 ${label(ORDER_STATUS_WORDS, o.status)} \xB7 created ${when(o.createdAt, null)} \xB7 updated ${when(o.updatedAt, null)}`,
2548
2669
  ...o.items.flatMap(itemLines),
2549
- ...paymentLines(o)
2670
+ ...paymentLines(o, surface)
2550
2671
  ];
2551
2672
  }
2552
- function renderOrder(o) {
2553
- return orderLines(o).join("\n");
2673
+ function renderOrder(o, surface = "mcp") {
2674
+ return orderLines(o, surface).join("\n");
2554
2675
  }
2555
- function renderOrderList(list) {
2676
+ function renderOrderList(list, surface = "mcp") {
2556
2677
  const lines = [
2557
2678
  list.data.length === 0 ? "No orders on this page." : `Orders, newest first: ${list.data.length} on this page.`
2558
2679
  ];
2559
- for (const o of list.data) lines.push("", ...orderLines(o));
2680
+ for (const o of list.data) lines.push("", ...orderLines(o, surface));
2560
2681
  lines.push(
2561
2682
  "",
2562
- list.nextCursor === null ? "Last page." : `Next page: call again with { cursor: "${list.nextCursor}" }.`
2683
+ list.nextCursor === null ? "Last page." : surface === "cli" ? `Next page: run again with --cursor ${list.nextCursor}.` : `Next page: call again with { cursor: "${list.nextCursor}" }.`
2563
2684
  );
2564
2685
  return lines.join("\n");
2565
2686
  }
@@ -2650,9 +2771,10 @@ function countsLine(r) {
2650
2771
  if (c.nameAsText !== null) parts.push(`${num(c.nameAsText)} have the name as text`);
2651
2772
  return `Counts: ${parts.join(", ")}.`;
2652
2773
  }
2653
- function localitiesLines(loc, areaName) {
2774
+ function localitiesLines(loc, areaName, surface = "mcp") {
2775
+ const back = surface === "cli" ? "--locality <placeId>" : 'destination { kind: "locality", placeId }';
2654
2776
  const lines = [
2655
- 'Localities: pass one back as destination { kind: "locality", placeId }, never the name. The number is its matching hotels; "incl." lists places inside it, with all their hotels regardless of filters ("hotels overall").'
2777
+ `Localities: pass one back as ${back}, never the name. The number is its matching hotels; "incl." lists places inside it, with all their hotels regardless of filters ("hotels overall").`
2656
2778
  ];
2657
2779
  for (const item of loc.items) {
2658
2780
  let line = `- ${item.place.name} ${item.place.placeId} ${num(item.count)}`;
@@ -2673,7 +2795,9 @@ function localitiesLines(loc, areaName) {
2673
2795
  lines.push(`${plural(loc.unassigned, "hotel")} in this search belong to no locality.`);
2674
2796
  }
2675
2797
  if (loc.more > 0) {
2676
- lines.push(`${num(loc.more)} more localities; name one with place_name.`);
2798
+ lines.push(
2799
+ `${num(loc.more)} more localities; name one with ${surface === "cli" ? "--place-name and --country" : "place_name"}.`
2800
+ );
2677
2801
  }
2678
2802
  return lines;
2679
2803
  }
@@ -2704,7 +2828,7 @@ function hotelLine(h, i, r) {
2704
2828
  h.hotelId
2705
2829
  ].filter(Boolean).join(" \xB7 ");
2706
2830
  }
2707
- function renderSearch(r) {
2831
+ function renderSearch(r, surface = "mcp") {
2708
2832
  const lines = [header(r)];
2709
2833
  lines.push(
2710
2834
  [
@@ -2728,7 +2852,7 @@ function renderSearch(r) {
2728
2852
  }
2729
2853
  if (r.coverage.localities) {
2730
2854
  const areaName = r.destination?.kind === "place" ? r.destination.place.name : null;
2731
- lines.push("", ...localitiesLines(r.coverage.localities, areaName));
2855
+ lines.push("", ...localitiesLines(r.coverage.localities, areaName, surface));
2732
2856
  }
2733
2857
  lines.push("");
2734
2858
  if (r.data.length === 0) lines.push("No hotels on this page.");
@@ -2738,7 +2862,7 @@ function renderSearch(r) {
2738
2862
  }
2739
2863
  lines.push(
2740
2864
  "",
2741
- r.nextCursor === null ? "Last page." : `Next page: call again with only the cursor and, optionally, limit: { cursor: "${r.nextCursor}" }.`
2865
+ r.nextCursor === null ? "Last page." : surface === "cli" ? `Next page: run again with only --cursor ${r.nextCursor} and, optionally, --limit.` : `Next page: call again with only the cursor and, optionally, limit: { cursor: "${r.nextCursor}" }.`
2742
2866
  );
2743
2867
  return lines.join("\n");
2744
2868
  }
@@ -2772,23 +2896,24 @@ function changeLine(c) {
2772
2896
  return `- ${c.field}: ${raw(c.previous)} \u2192 ${raw(c.current)}${worse}`;
2773
2897
  }
2774
2898
  }
2775
- function tooBroad(d) {
2899
+ function tooBroad(d, surface) {
2900
+ const locality = surface === "cli" ? "--locality <id>" : 'destination { kind: "locality", placeId: "<id>" }';
2776
2901
  const lines = [
2777
- 'Next: show the user these localities and ask which they prefer, unless their request already names one of them; then search again with destination { kind: "locality", placeId: "<id>" } and the same text, filters, stay and sort.',
2778
- ...localitiesLines(d.localities, null)
2902
+ `Next: show the user these localities and ask which they prefer, unless their request already names one of them; then search again with ${locality} and the same text, filters, stay and sort.`,
2903
+ ...localitiesLines(d.localities, null, surface)
2779
2904
  ];
2780
2905
  const top = d.localities.items[0];
2781
2906
  if (top && top.total > d.poolLimit && d.center?.place?.placeId === top.place.placeId) {
2782
2907
  lines.push(
2783
- `Or: ${top.place.name}, the area's center, alone has ${num(top.total)} matching hotels: the same destination with radiusMeters (up to ${LIMITS.radiusMetersMax}) prices nearly the same hotels (the nearest ${num(d.poolLimit)} around ${top.place.name}).`
2908
+ `Or: ${top.place.name}, the area's center, alone has ${num(top.total)} matching hotels: the same destination with ${surface === "cli" ? "--radius-meters" : "radiusMeters"} (up to ${LIMITS.radiusMetersMax}) prices nearly the same hotels (the nearest ${num(d.poolLimit)} around ${top.place.name}).`
2784
2909
  );
2785
2910
  }
2786
2911
  return lines;
2787
2912
  }
2788
- function ambiguous(d) {
2913
+ function ambiguous(d, surface) {
2789
2914
  const shown = d.candidatesTotal > d.candidates.length ? `${d.candidates.length} of ${d.candidatesTotal} shown` : `${d.candidatesTotal}`;
2790
2915
  const lines = [
2791
- `Places named "${d.name}" in ${d.countryCode} (${shown}). Ask the user which one, then search with destination { kind: "place", placeId: "<id>" }:`
2916
+ `Places named "${d.name}" in ${d.countryCode} (${shown}). Ask the user which one, then search with ${surface === "cli" ? "--place <id>" : 'destination { kind: "place", placeId: "<id>" }'}:`
2792
2917
  ];
2793
2918
  for (const c of d.candidates) {
2794
2919
  const other = [c.names.en, c.names.zh].find((n) => n && n !== c.name);
@@ -2808,7 +2933,7 @@ function ambiguous(d) {
2808
2933
  }
2809
2934
  return lines;
2810
2935
  }
2811
- function notFound(d) {
2936
+ function notFound(d, surface) {
2812
2937
  switch (d.reason) {
2813
2938
  case "no_match": {
2814
2939
  const m = d;
@@ -2819,22 +2944,23 @@ function notFound(d) {
2819
2944
  return [`Unknown placeId ${d.placeId}.`];
2820
2945
  case "not_a_locality": {
2821
2946
  const n = d;
2822
- const town = `{ kind: "place", placeId: "${n.placeId}" }`;
2947
+ const town = surface === "cli" ? `--place ${n.placeId}` : `{ kind: "place", placeId: "${n.placeId}" }`;
2823
2948
  if (n.hub === null) {
2824
2949
  return [`${n.placeId} belongs to no locality: search ${town} for an 8 km circle around it.`];
2825
2950
  }
2826
2951
  const total = n.hubTotal === null ? "" : ` (${plural(n.hubTotal, "matching hotel")})`;
2827
2952
  return [
2828
2953
  `${n.placeId} is not a locality. Its hotels belong to the locality ${n.hub.name} ${n.hub.placeId}${total}.`,
2829
- `Search { kind: "locality", placeId: "${n.hub.placeId}" } for those, or ${town} for an 8 km circle around the town itself.`
2954
+ `Search ${surface === "cli" ? `--locality ${n.hub.placeId}` : `{ kind: "locality", placeId: "${n.hub.placeId}" }`} for those, or ${town} for an 8 km circle around the town itself.`
2830
2955
  ];
2831
2956
  }
2832
2957
  default:
2833
2958
  return [`Details: ${raw(d)}`];
2834
2959
  }
2835
2960
  }
2836
- function detailLines(e) {
2961
+ function detailLines(e, surface) {
2837
2962
  if (!("details" in e)) return [];
2963
+ const getOrder = (id) => surface === "cli" ? `\`fortrip orders get ${id}\`` : "get_order";
2838
2964
  switch (e.code) {
2839
2965
  case "invalid_request": {
2840
2966
  const d = e.details;
@@ -2871,13 +2997,13 @@ function detailLines(e) {
2871
2997
  return [`Not cancellable: ${label(CANCEL_REASON_WORDS, e.details.reason)}.`];
2872
2998
  case "order_not_payable":
2873
2999
  return [
2874
- `Order ${e.details.orderId}, ${label(ORDER_STATUS_WORDS, e.details.status)}: read it with get_order; nothing was charged.`
3000
+ `Order ${e.details.orderId}, ${label(ORDER_STATUS_WORDS, e.details.status)}: read it with ${getOrder(e.details.orderId)}; this call charged nothing.`
2875
3001
  ];
2876
3002
  case "payment_in_progress":
2877
- return [`Order ${e.details.orderId}: read it with get_order in a few seconds.`];
3003
+ return [`Order ${e.details.orderId}: read it with ${getOrder(e.details.orderId)} in a few seconds.`];
2878
3004
  case "payment_total_changed":
2879
3005
  return [
2880
- `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.`
3006
+ `Order ${e.details.orderId} totals ${money2(e.details.total)}, not the total sent: confirm this total with the user, then ${surface === "cli" ? `run \`fortrip orders pay ${e.details.orderId} --token <spt_\u2026> --total ${e.details.total.amount}\` again with the same token` : "call pay_order again with it and the same token"}. Nothing was charged.`
2881
3007
  ];
2882
3008
  case "payment_credential_invalid":
2883
3009
  return [
@@ -2885,16 +3011,18 @@ function detailLines(e) {
2885
3011
  ];
2886
3012
  case "payment_declined":
2887
3013
  return [
2888
- `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).`
3014
+ `Declined${e.details.declineCode ? ` (${e.details.declineCode})` : ""}: the user picks another payment method in their wallet for a new token, or pays by link: read the order with ${getOrder("<orderId>")} and give its payment.url.`
2889
3015
  ];
2890
3016
  case "destination_ambiguous":
2891
- return ambiguous(e.details);
3017
+ return ambiguous(e.details, surface);
2892
3018
  case "destination_not_found":
2893
- return notFound(e.details);
3019
+ return notFound(e.details, surface);
2894
3020
  case "search_too_broad":
2895
- return tooBroad(e.details);
3021
+ return tooBroad(e.details, surface);
2896
3022
  case "stay_unsupported":
2897
- return e.details.reason === "mixed_occupancy" ? ["Every room must have the same party: ask once per party."] : e.details.reason === "max_nights" ? [`At most ${plural(e.details.max, "night")} per stay.`] : [`Details: ${raw(e.details)}`];
3023
+ return e.details.reason === "mixed_occupancy" ? ["Every room must have the same party: ask once per party."] : e.details.reason === "max_nights" ? [
3024
+ `At most ${plural(e.details.max, "night")} per stay: ask the user whether to split it into consecutive stays, each its own order.`
3025
+ ] : [`Details: ${raw(e.details)}`];
2898
3026
  case "stay_in_past":
2899
3027
  return [`Check-in ${e.details.checkIn} is already past${e.details.timeZone ? ` in ${e.details.timeZone}` : ""}.`];
2900
3028
  case "offer_unavailable":
@@ -2923,7 +3051,7 @@ function retryLine(retryable, after) {
2923
3051
  }
2924
3052
  return retryable === false ? "Not retryable." : "Retryable: unknown.";
2925
3053
  }
2926
- function renderError(envelope, status) {
3054
+ function renderError(envelope, status, surface = "mcp") {
2927
3055
  const http = status === void 0 ? "" : ` (HTTP ${status})`;
2928
3056
  let known = null;
2929
3057
  let body = null;
@@ -2944,48 +3072,51 @@ Retryable: unknown.`;
2944
3072
  retryLine(body.retryable, body.retryAfterSeconds)
2945
3073
  ];
2946
3074
  if (typeof body.param === "string") lines.push(`Field: ${body.param}`);
2947
- if (known) lines.push(...detailLines(known));
3075
+ if (known) lines.push(...detailLines(known, surface));
2948
3076
  else if (body.details !== void 0) lines.push(`Details: ${raw(body.details)}`);
2949
3077
  if (typeof body.requestId === "string") lines.push(`Request id: ${body.requestId}`);
2950
3078
  return lines.join("\n");
2951
3079
  }
2952
3080
 
2953
3081
  // src/render/index.ts
2954
- function renderToolResult(tool, data) {
3082
+ function renderToolResult(tool, data, surface = "mcp") {
2955
3083
  const schema = TOOLS.find((t) => t.name === tool)?.output;
2956
3084
  let parsed;
2957
3085
  try {
2958
3086
  if (!schema) throw new Error(`no output schema for ${tool}`);
2959
3087
  parsed = parseOpen(schema, data);
2960
3088
  } catch {
2961
- const text2 = `This ${tool} result is not in the expected shape; as JSON:
3089
+ const spec = COMMANDS.find((command) => command.tool === tool);
3090
+ const name = surface === "cli" && spec ? commandInvocation(spec) : tool;
3091
+ const text2 = `This ${name} result is not in the expected shape; as JSON:
2962
3092
  ${raw(data)}`;
2963
3093
  return [
2964
3094
  text2,
2965
3095
  ORDER_TOOLS.has(tool) && holdsPaymentUrl(data) ? ORDER_NEXT_STEP : "",
2966
- ORDER_TOOLS.has(tool) && holdsHandlers(data) ? PAY_NEXT_STEP : "",
2967
- CANCEL_TOOLS.has(tool) && holdsCancellable(data) ? CANCEL_NEXT_STEP : ""
3096
+ ORDER_TOOLS.has(tool) && holdsHandlers(data) ? payNextStep(surface) : "",
3097
+ ORDER_TOOLS.has(tool) && holdsWalletOffer(data) ? walletNextStep(surface) : "",
3098
+ CANCEL_TOOLS.has(tool) && holdsCancellable(data) ? cancelNextStep(surface) : ""
2968
3099
  ].filter(Boolean).join("\n\n");
2969
3100
  }
2970
3101
  switch (tool) {
2971
3102
  case "search_hotels":
2972
- return renderSearch(parsed);
3103
+ return renderSearch(parsed, surface);
2973
3104
  case "get_hotel":
2974
3105
  return renderHotel(parsed);
2975
3106
  case "get_hotel_offers":
2976
- return renderOffers(parsed);
3107
+ return renderOffers(parsed, surface);
2977
3108
  case "book_hotel":
2978
3109
  case "get_order": {
2979
3110
  const order2 = parsed;
2980
- return withConsent(tool, renderOrder(order2), [order2]);
3111
+ return withConsent(tool, surface, renderOrder(order2, surface), [order2]);
2981
3112
  }
2982
3113
  case "list_orders": {
2983
3114
  const list = parsed;
2984
- return withConsent(tool, renderOrderList(list), list.data);
3115
+ return withConsent(tool, surface, renderOrderList(list, surface), list.data);
2985
3116
  }
2986
3117
  case "cancel_order":
2987
3118
  case "pay_order":
2988
- return renderOrder(parsed);
3119
+ return renderOrder(parsed, surface);
2989
3120
  }
2990
3121
  }
2991
3122
  var ORDER_TOOLS = /* @__PURE__ */ new Set(["book_hotel", "get_order", "list_orders"]);
@@ -3008,6 +3139,18 @@ function holdsHandlers(value, seen = /* @__PURE__ */ new Set()) {
3008
3139
  }
3009
3140
  return Object.values(value).some((v) => holdsHandlers(v, seen));
3010
3141
  }
3142
+ function holdsWalletOffer(value, seen = /* @__PURE__ */ new Set()) {
3143
+ if (typeof value !== "object" || value === null || seen.has(value)) return false;
3144
+ seen.add(value);
3145
+ const payment = value.payment;
3146
+ if (typeof payment === "object" && payment !== null) {
3147
+ const wallets = payment.wallets;
3148
+ if (typeof wallets === "object" && wallets !== null && wallets.open === false) {
3149
+ return true;
3150
+ }
3151
+ }
3152
+ return Object.values(value).some((v) => holdsWalletOffer(v, seen));
3153
+ }
3011
3154
  function holdsCancellable(value, seen = /* @__PURE__ */ new Set()) {
3012
3155
  if (typeof value !== "object" || value === null || seen.has(value)) return false;
3013
3156
  seen.add(value);
@@ -3017,12 +3160,13 @@ function holdsCancellable(value, seen = /* @__PURE__ */ new Set()) {
3017
3160
  }
3018
3161
  return Object.values(value).some((v) => holdsCancellable(v, seen));
3019
3162
  }
3020
- function withConsent(tool, text2, orders) {
3163
+ function withConsent(tool, surface, text2, orders) {
3021
3164
  return [
3022
3165
  text2,
3023
3166
  orders.some((o) => o.payment.url !== null) ? ORDER_NEXT_STEP : "",
3024
- orders.some((o) => o.payment.handlers.length > 0) ? PAY_NEXT_STEP : "",
3025
- CANCEL_TOOLS.has(tool) && orders.some((o) => o.cancel.available) ? CANCEL_NEXT_STEP : ""
3167
+ orders.some((o) => o.payment.handlers.length > 0) ? payNextStep(surface) : "",
3168
+ orders.some((o) => o.payment.wallets?.open === false) ? walletNextStep(surface) : "",
3169
+ CANCEL_TOOLS.has(tool) && orders.some((o) => o.cancel.available) ? cancelNextStep(surface) : ""
3026
3170
  ].filter(Boolean).join("\n\n");
3027
3171
  }
3028
3172
 
@@ -3053,6 +3197,7 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
3053
3197
  localCurrencyAtCheckout: `${API_DECIDES} (whether checkout may charge in the card's currency).`,
3054
3198
  "cancel.available": `${API_DECIDES} (whether an order can be cancelled now).`,
3055
3199
  "payment.handlers": `${RESULT_LIST} (the ways to pay an order other than its link; empty when there is none).`,
3200
+ "payment.wallets.open": `${API_DECIDES} (the server always knows whether it opened a payment).`,
3056
3201
  available_instruments: `${RESULT_LIST} (the instruments a payment handler takes).`,
3057
3202
  bookable: `${API_DECIDES} (whether the hotel is still in the index).`,
3058
3203
  cityLike: `${API_DECIDES} (frozen per gazetteer release; null where not computed).`,
@@ -3063,7 +3208,7 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
3063
3208
  // package.json
3064
3209
  var package_default = {
3065
3210
  name: "@fortrip/agent-contract",
3066
- version: "4.0.0",
3211
+ version: "4.2.0-rc.1",
3067
3212
  license: "Apache-2.0",
3068
3213
  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.",
3069
3214
  type: "module",
@@ -3147,8 +3292,10 @@ export {
3147
3292
  TOOLS,
3148
3293
  UNAVAILABLE_REASONS,
3149
3294
  UNKNOWN_IS_NOT_NO_EXEMPTIONS,
3295
+ WALLET_NEXT_STEP,
3150
3296
  addIsoDateDays,
3151
3297
  authConfig,
3298
+ cancelNextStep,
3152
3299
  cancelOrderInput,
3153
3300
  cancellation,
3154
3301
  center,
@@ -3200,6 +3347,7 @@ export {
3200
3347
  orderReference,
3201
3348
  parseOpen,
3202
3349
  payAtProperty,
3350
+ payNextStep,
3203
3351
  payOrderInput,
3204
3352
  paymentHandler,
3205
3353
  photo,
@@ -3221,5 +3369,6 @@ export {
3221
3369
  text,
3222
3370
  timeZone,
3223
3371
  usdMoney,
3372
+ walletNextStep,
3224
3373
  wholeNumber
3225
3374
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fortrip/agent-contract",
3
- "version": "4.0.0",
3
+ "version": "4.2.0-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The contract of Fortrip's agent API (https://api.fortrip.ai/v1) and its MCP server: limits, paths, request and response schemas, error codes and field rules.",
6
6
  "type": "module",