@fortrip/agent-contract 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,16 +23,23 @@ 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` and
37
+ `PAY_NEXT_STEP` (`cancelNextStep(surface)` and `payNextStep(surface)`
38
+ word the last two for `"mcp"` or `"cli"`);
39
+ - `renderToolResult(tool, data, surface?)` and
40
+ `renderError(envelope, status?, surface?)`, the compact text of a result or
41
+ an error, naming tools (`"mcp"`, the default) or commands and flags
42
+ (`"cli"`), and `renderGuide(surface, topic)`, the agent
36
43
  guide as Markdown for `"mcp"`, `"claude-skill"` or `"cli"`;
37
44
  - field rules such as `containsCardNumber`, the guest-name rule and the date
38
45
  helpers, and `CONTRACT_VERSION`.
package/dist/index.d.ts CHANGED
@@ -81,20 +81,28 @@ 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;
98
106
  /**
99
107
  * How to present hotels (the `presentation` guide, in one line). It rides as
100
108
  * the last paragraph of every MCP `search_hotels`, `get_hotel` and
@@ -2585,9 +2593,10 @@ declare const order: z.ZodObject<{
2585
2593
  }, z.core.$strip>;
2586
2594
  }, z.core.$strip>>;
2587
2595
  /** 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. */
2596
+ * `handlers`: at least `maxAmount`, in minor units (cents) of
2597
+ * `currency`, lowercase as Stripe takes it, and valid until at least
2598
+ * `expiresAt`, past which the order can't be paid. `null` when
2599
+ * `handlers` is empty. */
2591
2600
  credentialLimits: z.ZodNullable<z.ZodObject<{
2592
2601
  maxAmount: z.ZodNumber;
2593
2602
  currency: z.ZodString;
@@ -2769,9 +2778,10 @@ declare const orderList: z.ZodObject<{
2769
2778
  }, z.core.$strip>;
2770
2779
  }, z.core.$strip>>;
2771
2780
  /** 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. */
2781
+ * `handlers`: at least `maxAmount`, in minor units (cents) of
2782
+ * `currency`, lowercase as Stripe takes it, and valid until at least
2783
+ * `expiresAt`, past which the order can't be paid. `null` when
2784
+ * `handlers` is empty. */
2775
2785
  credentialLimits: z.ZodNullable<z.ZodObject<{
2776
2786
  maxAmount: z.ZodNumber;
2777
2787
  currency: z.ZodString;
@@ -3405,8 +3415,10 @@ declare const API: {
3405
3415
  /** The MCP server answers at the root of `PUBLIC_ORIGINS.mcp`. */
3406
3416
  declare const MCP_PATH = "/";
3407
3417
 
3408
- /** The error envelope as text; `status` is the HTTP status, when known. */
3409
- declare function renderError(envelope: unknown, status?: number): string;
3418
+ /** The error envelope as text; `status` is the HTTP status, when known.
3419
+ * `surface` names the next calls: tools (`mcp`, the default) or commands
3420
+ * (`cli`). */
3421
+ declare function renderError(envelope: unknown, status?: number, surface?: RenderSurface): string;
3410
3422
 
3411
3423
  type RenderedTool = Exclude<ToolName, "get_planning_guide">;
3412
3424
  /**
@@ -3417,9 +3429,10 @@ type RenderedTool = Exclude<ToolName, "get_planning_guide">;
3417
3429
  * result holds a non-null `payment.url`; the pay rule (`PAY_NEXT_STEP`)
3418
3430
  * follows it when a result holds an order with non-empty `payment.handlers`;
3419
3431
  * the cancel rule (`CANCEL_NEXT_STEP`) follows it when a `get_order` or
3420
- * `list_orders` result holds an order with `cancel.available`.
3432
+ * `list_orders` result holds an order with `cancel.available`. `surface`
3433
+ * names the next calls: tools (`mcp`, the default) or commands (`cli`).
3421
3434
  */
3422
- declare function renderToolResult(tool: RenderedTool, data: unknown): string;
3435
+ declare function renderToolResult(tool: RenderedTool, data: unknown, surface?: RenderSurface): string;
3423
3436
 
3424
3437
  /** Amenity codes a search can filter by (§7.7), in the order they are listed. */
3425
3438
  declare const FILTERABLE_AMENITIES: readonly ["parking", "wifi", "laundry", "restaurant", "room_service", "bar", "non_smoking", "business_center", "pool"];
@@ -3437,4 +3450,4 @@ declare const UNKNOWN_IS_NOT_NO_EXEMPTIONS: Readonly<Record<string, string>>;
3437
3450
  /** The contract's version, from package.json, the one place a release bumps it. */
3438
3451
  declare const CONTRACT_VERSION: string;
3439
3452
 
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 };
3453
+ 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, 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, wholeNumber };
package/dist/index.js CHANGED
@@ -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,7 +625,7 @@ 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
630
  "The shared payment token (spt_\u2026) the user approved for this order, requested with the order's payment.credentialLimits. Exactly one of sharedPaymentToken and payment."
629
631
  ),
@@ -710,10 +712,11 @@ function fieldDescription(json, field, sets = {}) {
710
712
  }
711
713
  function flagsOf(input, defs) {
712
714
  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
- }));
715
+ return defs.map(({ required, ...def }) => {
716
+ const description = def.description ?? fieldDescription(json, def.field, def.sets);
717
+ const prefix = required === "always" ? "Required. " : required === "unless-body" ? "Required unless --body gives it. " : "";
718
+ return { ...def, description: `${prefix}${description}` };
719
+ });
717
720
  }
718
721
  function positional(input, name, description) {
719
722
  const json = z6.toJSONSchema(input, { io: "input" });
@@ -908,10 +911,10 @@ var bookFlags = flagsOf(createOrderInput, [
908
911
  placeholder: "<room>:<first>:<last>",
909
912
  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
913
  },
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>" },
914
+ { flag: "first-name", field: "contact.firstName", type: "string", placeholder: "<name>", required: "unless-body" },
915
+ { flag: "last-name", field: "contact.lastName", type: "string", placeholder: "<name>", required: "unless-body" },
916
+ { flag: "email", field: "contact.email", type: "string", placeholder: "<email>", required: "unless-body" },
917
+ { flag: "phone", field: "contact.phone", type: "string", placeholder: "<phone>", required: "unless-body" },
915
918
  {
916
919
  flag: "special-requests",
917
920
  field: "items.hotel.specialRequests",
@@ -940,13 +943,15 @@ var payFlags = flagsOf(payOrderInput, [
940
943
  field: "sharedPaymentToken",
941
944
  type: "string",
942
945
  placeholder: "<spt_\u2026>",
943
- description: "The shared payment token the user's wallet granted for this order, with the order's credential limits."
946
+ required: "always",
947
+ description: "The spt_\u2026 token the user's Link wallet issued for this order."
944
948
  },
945
949
  {
946
950
  flag: "total",
947
951
  field: "total",
948
952
  type: "string",
949
953
  placeholder: "<USD decimal>",
954
+ required: "always",
950
955
  description: "The total the user approved, exactly as `orders get` shows it, in USD, e.g. `125.00`."
951
956
  }
952
957
  ]);
@@ -1019,7 +1024,7 @@ var COMMANDS = [
1019
1024
  {
1020
1025
  group: "orders",
1021
1026
  name: "pay",
1022
- summary: "Pay an order with a shared payment token instead of its link",
1027
+ summary: "Pay an order from the user's Link wallet (US and Canada) instead of its payment link",
1023
1028
  tool: "pay_order",
1024
1029
  flags: payFlags,
1025
1030
  positionals: [positional(payOrderInput, "orderId")]
@@ -1027,7 +1032,7 @@ var COMMANDS = [
1027
1032
  {
1028
1033
  group: null,
1029
1034
  name: "login",
1030
- summary: "Sign in through the browser (device code)",
1035
+ summary: "Sign in through the browser",
1031
1036
  tool: null,
1032
1037
  flags: [],
1033
1038
  options: [
@@ -1055,7 +1060,7 @@ var COMMANDS = [
1055
1060
  {
1056
1061
  group: null,
1057
1062
  name: "guide",
1058
- summary: "Print the guide for AI agents (Markdown)",
1063
+ summary: "Print the guide for AI agents (Markdown); `fortrip guide planning` prints the planning guide",
1059
1064
  tool: "get_planning_guide",
1060
1065
  flags: [],
1061
1066
  positionals: [
@@ -1223,10 +1228,10 @@ var FRAGMENTS = {
1223
1228
  "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
1229
  "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
1230
  "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",
1231
+ "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## 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
1232
  "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
1233
  "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",
1234
+ "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",
1230
1235
  "scope": "{{#if claude-skill cli}}\n# Fortrip hotel stays\n\n{{/if}}\nFortrip: hotel search, live offers and orders with a payment link.{{#if claude-skill cli}} Not for flights, activities, or changing an existing order.{{/if}}\n\n{{#if mcp}}\nCall order: `{{tool:hotels search}}` \u2192 (optional) `{{tool:hotels get}}` \u2192 `{{tool:hotels offers}}` \u2192 `{{tool:hotels book}}`; after the user pays, `{{tool:orders get}}`; `{{tool:orders list}}` lists them; `{{tool:orders cancel}}` cancels one, `{{tool:orders pay}}` pays by token. `{{tool:guide}}` returns Fortrip's guidance for flexible dates, budgets or several destinations.\n{{/if}}\n{{#if claude-skill}}\nThe tools are on Fortrip's MCP server, named `fortrip` in this plugin (a Fortrip connector added on claude.ai can show under its own name). They're written `fortrip:<tool>` below:\n{{/if}}\n{{#if cli}}\nThe `fortrip` CLI (npm package `fortrip`) calls Fortrip as the signed-in user and prints each answer as compact text (`--json` prints its JSON):\n{{/if}}\n{{#if claude-skill cli}}\n\n| {{#if claude-skill}}Tool{{/if}}{{#if cli}}Command{{/if}} | Returns |\n|---|---|\n| `{{tool:hotels search}}` | Hotels in a place, near a point or matching a name (`{{arg:text}}`), with indicative prices |\n| `{{tool:hotels get}}` | One hotel's address, check-in and check-out times, description, policies, amenities and rooms; no prices |\n| `{{tool:hotels offers}}` | Live offers (room, meals, total in USD, cancellation terms) for up to {{limit:offersHotels}} hotels |\n| `{{tool:hotels book}}` | An unpaid order for one offer, with its terms and a payment link |\n| `{{tool:orders get}}` | One order and its status, including whether the hotel confirmed it |\n| `{{tool:orders list}}` | The user's orders, newest first, including those made on the Fortrip website |\n| `{{tool:orders cancel}}` | Cancels an order under its terms, for the penalty the user agreed to, and refunds the rest |\n| `{{tool:orders pay}}` | Pays an order without its link, with a shared payment token from the user's wallet |\n\nFor flexible dates, a budget, split stays, several destinations or \"find me the best\", {{#if claude-skill}}read [references/planning.md](references/planning.md){{/if}}{{#if cli}}also run `{{tool:guide}} planning`{{/if}} before searching.\n{{/if}}\n",
1231
1236
  "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
1237
  "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"
@@ -1522,7 +1527,7 @@ var hotelSummary = openObject({
1522
1527
  distanceMeters: z11.number().nullable(),
1523
1528
  price: indicativePrice.nullable(),
1524
1529
  /** The cover photo; `null` without one. */
1525
- photo: photo.nullable()
1530
+ photo: photo.nullable().describe("The cover photo; null when there is none.")
1526
1531
  });
1527
1532
  var localities = openObject({
1528
1533
  items: z11.array(
@@ -1597,7 +1602,7 @@ var searchResult = openObject({
1597
1602
  nameAsText: count.nullable()
1598
1603
  }),
1599
1604
  data: z11.array(hotelSummary),
1600
- nextCursor: z11.string().nullable(),
1605
+ nextCursor: z11.string().nullable().describe("Pass it back as cursor for the next page; null on the last page."),
1601
1606
  notes: z11.array(
1602
1607
  openObject({ code: openEnum(SEARCH_NOTE_CODES), message: z11.string() })
1603
1608
  )
@@ -1643,7 +1648,7 @@ var hotel = openObject({
1643
1648
  description: knownLocaleText.nullable(),
1644
1649
  /** Up to 8 hotel photos, the cover first; `null` when the catalogue lists
1645
1650
  * none (unknown is not no). */
1646
- photos: z12.array(photo).nullable(),
1651
+ photos: z12.array(photo).nullable().describe("Up to 8 hotel photos, the cover first; null when the catalogue lists none."),
1647
1652
  checkInTimes: timeRange,
1648
1653
  checkOutTimes: timeRange,
1649
1654
  policies: openObject({
@@ -1859,7 +1864,9 @@ var order = openObject({
1859
1864
  price: openObject({ total: money }),
1860
1865
  payment: openObject({
1861
1866
  status: openEnum(PAYMENT_STATUSES),
1862
- url: z14.string().nullable(),
1867
+ url: z14.string().nullable().describe(
1868
+ "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."
1869
+ ),
1863
1870
  requiresSignIn: z14.boolean(),
1864
1871
  expiresAt: instant.nullable(),
1865
1872
  chargeCurrency: z14.string(),
@@ -1868,31 +1875,44 @@ var order = openObject({
1868
1875
  /** The ways to pay other than `url`, while the order can be paid that
1869
1876
  * way: a `com.stripe.payments` handler takes a shared payment token
1870
1877
  * through `pay_order`. Empty when there is none. */
1871
- handlers: z14.array(paymentHandler),
1878
+ handlers: z14.array(paymentHandler).describe(
1879
+ "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."
1880
+ ),
1872
1881
  /** 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. */
1882
+ * `handlers`: at least `maxAmount`, in minor units (cents) of
1883
+ * `currency`, lowercase as Stripe takes it, and valid until at least
1884
+ * `expiresAt`, past which the order can't be paid. `null` when
1885
+ * `handlers` is empty. */
1876
1886
  credentialLimits: openObject({
1877
- maxAmount: z14.number().int(),
1878
- currency: z14.string(),
1879
- expiresAt: instant
1880
- }).nullable()
1887
+ maxAmount: z14.number().int().describe("Request the token for at least this amount, in cents; a token that allows less can't pay."),
1888
+ currency: z14.string().describe("The token's currency, lowercase as Stripe takes it: usd."),
1889
+ expiresAt: instant.describe(
1890
+ "Request the token valid until at least this time; the order can't be paid after it."
1891
+ )
1892
+ }).nullable().describe(
1893
+ "What the shared payment token for pay_order must allow. null exactly when handlers is []."
1894
+ )
1881
1895
  }),
1882
1896
  /** Whether the user can cancel the order now and, when they can, its
1883
1897
  * penalty under the accepted terms (read a minute ahead) and the refund,
1884
1898
  * what was paid less the penalty, both in the charge currency. */
1885
1899
  cancel: openObject({
1886
- available: z14.boolean(),
1887
- reason: openEnum(CANCEL_REASONS),
1888
- penalty: money.nullable(),
1889
- refund: money.nullable()
1890
- }),
1900
+ available: z14.boolean().describe("Whether the user can cancel the order now."),
1901
+ reason: openEnum(CANCEL_REASONS).describe(
1902
+ "cancellable when it can be cancelled now; otherwise why not."
1903
+ ),
1904
+ penalty: money.nullable().describe(
1905
+ "The penalty if cancelled now, under the accepted terms, in the charge currency; null when not stated."
1906
+ ),
1907
+ refund: money.nullable().describe(
1908
+ "What a cancellation now refunds: what was paid less the penalty, in the charge currency; null when not stated."
1909
+ )
1910
+ }).describe("Whether the order can be cancelled now, and for what penalty and refund."),
1891
1911
  manageUrl: z14.string()
1892
1912
  });
1893
1913
  var orderList = openObject({
1894
1914
  data: z14.array(order),
1895
- nextCursor: z14.string().nullable()
1915
+ nextCursor: z14.string().nullable().describe("Pass it back as cursor for the next page; null on the last page.")
1896
1916
  });
1897
1917
  function change(field, value) {
1898
1918
  return openObject({
@@ -2063,8 +2083,32 @@ var MCP_PATH = "/";
2063
2083
  // src/tools.ts
2064
2084
  import { z as z16 } from "zod";
2065
2085
  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.";
2086
+ var CALLS = {
2087
+ mcp: {
2088
+ cancel: "call cancel_order",
2089
+ penalty: 'Pass maximumPenalty as the number in cancel.penalty.amount ("120.00" \u2192 120).',
2090
+ pay: "call pay_order",
2091
+ payWith: "call pay_order with it and the order's price.total",
2092
+ paid: "pay_order"
2093
+ },
2094
+ cli: {
2095
+ cancel: "run `fortrip orders cancel <orderId> --max-penalty <n>`",
2096
+ penalty: "Pass the penalty's amount as --max-penalty (120.00 for a penalty of USD 120.00).",
2097
+ pay: "run `fortrip orders pay`",
2098
+ payWith: "run `fortrip orders pay <orderId> --token <spt_\u2026> --total <total>` with the token and the order's total",
2099
+ paid: "`fortrip orders pay`"
2100
+ }
2101
+ };
2102
+ function cancelNextStep(surface) {
2103
+ const c = CALLS[surface];
2104
+ 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.`;
2105
+ }
2106
+ var CANCEL_NEXT_STEP = cancelNextStep("mcp");
2107
+ function payNextStep(surface) {
2108
+ const c = CALLS[surface];
2109
+ 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.`;
2110
+ }
2111
+ var PAY_NEXT_STEP = payNextStep("mcp");
2068
2112
  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
2113
  var nextStep = z16.string().optional().describe(
2070
2114
  "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 +2163,7 @@ var TOOLS = [
2119
2163
  {
2120
2164
  name: "book_hotel",
2121
2165
  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.`,
2166
+ 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 order is paid, on that page or with pay_order; 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
2167
  annotations: {
2124
2168
  readOnlyHint: false,
2125
2169
  idempotentHint: false,
@@ -2161,7 +2205,7 @@ var TOOLS = [
2161
2205
  {
2162
2206
  name: "pay_order",
2163
2207
  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.",
2208
+ description: "Pay an order with a Stripe shared payment token, not its link, when payment.handlers isn't empty. Only if you have a tool to request the token from the user's Link wallet (US and Canadian Link accounts); otherwise give payment.url, and never ask the user to create, type or paste a token. 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. Then request the token with the handler's config.business_profile and payment.credentialLimits, and pass it with price.total. Pay one way only: payment.url or pay_order. Once this succeeds, payment.url stops working; a failure leaves it open. Then poll get_order. payment_total_changed: confirm details.total with the user, then retry with it. payment_declined: another wallet method or the link. payment_action_required: give the user payment.url. payment_credential_invalid: a new token. service_unavailable: retry with the same token. A token pays one order only.",
2165
2209
  annotations: {
2166
2210
  readOnlyHint: false,
2167
2211
  idempotentHint: true,
@@ -2415,9 +2459,10 @@ var OMITTED = {
2415
2459
  dominated: "beaten by or the same as another offer for the same room",
2416
2460
  unreadable: "unreadable"
2417
2461
  };
2418
- function limitText(o) {
2462
+ function limitText(o, surface) {
2419
2463
  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` : "";
2464
+ const [limit, filters] = surface === "cli" ? ["--limit-per-hotel", "--require-breakfast / --require-free-cancellation"] : ["limitPerHotel", "requireBreakfast / requireFreeCancellation"];
2465
+ 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
2466
  }
2422
2467
  function omittedText(o) {
2423
2468
  return Object.entries(OMITTED).filter(([key]) => typeof o[key] === "number" && o[key] > 0).map(([key, words]) => `${o[key]} ${words}`).join(", ");
@@ -2431,7 +2476,7 @@ var UNAVAILABLE = {
2431
2476
  supplier_unavailable: "offers could not be fetched this time",
2432
2477
  stay_in_past: "check-in is already past"
2433
2478
  };
2434
- function renderOffers(r) {
2479
+ function renderOffers(r, surface = "mcp") {
2435
2480
  const lines = [
2436
2481
  `Live offers \xB7 ${stayLine(r.stay.checkIn, r.stay.checkOut)} \xB7 ${party(r.stay.rooms)}`,
2437
2482
  "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 +2487,13 @@ function renderOffers(r) {
2442
2487
  h.offers.forEach((o, i) => lines.push(`${i + 1}. ${offerLine(o)}`));
2443
2488
  const omitted2 = omittedText(h.omitted);
2444
2489
  if (omitted2) lines.push(`Not shown: ${omitted2}.`);
2445
- const limited = limitText(h.omitted);
2490
+ const limited = limitText(h.omitted, surface);
2446
2491
  if (limited) lines.push(`${limited}.`);
2447
2492
  }
2448
2493
  if (r.unavailable.length > 0) {
2449
2494
  lines.push("", "Unavailable:");
2450
2495
  for (const u of r.unavailable) {
2451
- const omitted2 = u.omitted ? [omittedText(u.omitted), limitText(u.omitted)].filter(Boolean).join("; ") : "";
2496
+ const omitted2 = u.omitted ? [omittedText(u.omitted), limitText(u.omitted, surface)].filter(Boolean).join("; ") : "";
2452
2497
  lines.push(`- ${u.hotelId}: ${label(UNAVAILABLE, u.reason)}${omitted2 ? ` (${omitted2})` : ""}`);
2453
2498
  }
2454
2499
  }
@@ -2504,7 +2549,7 @@ function itemLines(item) {
2504
2549
  `Hotel confirmation number: ${h.confirmationNumber ?? "none yet"}`
2505
2550
  ];
2506
2551
  }
2507
- function paymentLines(o) {
2552
+ function paymentLines(o, surface) {
2508
2553
  const p = o.payment;
2509
2554
  const lines = [
2510
2555
  [
@@ -2523,43 +2568,54 @@ function paymentLines(o) {
2523
2568
  } else if (o.status === "awaiting_payment") {
2524
2569
  lines.push("Payment link: could not be read this time; read this order again for it.");
2525
2570
  }
2526
- if (p.handlers.length > 0) lines.push(handlersLine(p.handlers, p.credentialLimits));
2527
- lines.push(cancelLine(o.cancel));
2571
+ if (p.handlers.length > 0) lines.push(handlersLine(o, surface));
2572
+ lines.push(cancelLine(o));
2528
2573
  lines.push(`Manage: ${o.manageUrl}`);
2529
2574
  return lines;
2530
2575
  }
2531
- function handlersLine(handlers, limits) {
2576
+ function handlersLine(o, surface) {
2577
+ const { handlers, credentialLimits: limits } = o.payment;
2578
+ const pay = surface === "cli" ? `\`fortrip orders pay ${o.orderId} --token <spt_\u2026> --total ${o.price.total.amount}\`` : "pay_order";
2532
2579
  const shown = handlers.map(
2533
2580
  (h) => `${h.type} (handler ${h.id}, business_profile ${h.config.business_profile})`
2534
2581
  );
2535
2582
  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}`;
2583
+ return [
2584
+ `Pay without the link: ${pay} with a shared payment token via ${shown.join(", ")}${limit}.`,
2585
+ "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.",
2586
+ `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"}.`
2587
+ ].join(" ");
2537
2588
  }
2538
- function cancelLine(c) {
2589
+ function cancelLine(o) {
2590
+ const c = o.cancel;
2591
+ if (o.status === "awaiting_payment" && !c.available && c.reason === "not_confirmed") {
2592
+ const at = o.payment.expiresAt === null ? "" : ` at ${when(o.payment.expiresAt, null)}`;
2593
+ return `Cancel: not needed: an unpaid order expires unpaid${at}`;
2594
+ }
2539
2595
  const figure = (name, m) => `${name} ${m ? money2(m) : "not stated"}`;
2540
2596
  const figures = `${figure("penalty", c.penalty)}, ${figure("refund", c.refund)}`;
2541
2597
  if (c.available) return `Cancel: can cancel now: ${figures}`;
2542
2598
  const why = `Cancel: not available: ${label(CANCEL_REASON_WORDS, c.reason)}`;
2543
2599
  return c.penalty || c.refund ? `${why} \xB7 ${figures}` : why;
2544
2600
  }
2545
- function orderLines(o) {
2601
+ function orderLines(o, surface = "mcp") {
2546
2602
  return [
2547
2603
  `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
2604
  ...o.items.flatMap(itemLines),
2549
- ...paymentLines(o)
2605
+ ...paymentLines(o, surface)
2550
2606
  ];
2551
2607
  }
2552
- function renderOrder(o) {
2553
- return orderLines(o).join("\n");
2608
+ function renderOrder(o, surface = "mcp") {
2609
+ return orderLines(o, surface).join("\n");
2554
2610
  }
2555
- function renderOrderList(list) {
2611
+ function renderOrderList(list, surface = "mcp") {
2556
2612
  const lines = [
2557
2613
  list.data.length === 0 ? "No orders on this page." : `Orders, newest first: ${list.data.length} on this page.`
2558
2614
  ];
2559
- for (const o of list.data) lines.push("", ...orderLines(o));
2615
+ for (const o of list.data) lines.push("", ...orderLines(o, surface));
2560
2616
  lines.push(
2561
2617
  "",
2562
- list.nextCursor === null ? "Last page." : `Next page: call again with { cursor: "${list.nextCursor}" }.`
2618
+ list.nextCursor === null ? "Last page." : surface === "cli" ? `Next page: run again with --cursor ${list.nextCursor}.` : `Next page: call again with { cursor: "${list.nextCursor}" }.`
2563
2619
  );
2564
2620
  return lines.join("\n");
2565
2621
  }
@@ -2650,9 +2706,10 @@ function countsLine(r) {
2650
2706
  if (c.nameAsText !== null) parts.push(`${num(c.nameAsText)} have the name as text`);
2651
2707
  return `Counts: ${parts.join(", ")}.`;
2652
2708
  }
2653
- function localitiesLines(loc, areaName) {
2709
+ function localitiesLines(loc, areaName, surface = "mcp") {
2710
+ const back = surface === "cli" ? "--locality <placeId>" : 'destination { kind: "locality", placeId }';
2654
2711
  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").'
2712
+ `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
2713
  ];
2657
2714
  for (const item of loc.items) {
2658
2715
  let line = `- ${item.place.name} ${item.place.placeId} ${num(item.count)}`;
@@ -2673,7 +2730,9 @@ function localitiesLines(loc, areaName) {
2673
2730
  lines.push(`${plural(loc.unassigned, "hotel")} in this search belong to no locality.`);
2674
2731
  }
2675
2732
  if (loc.more > 0) {
2676
- lines.push(`${num(loc.more)} more localities; name one with place_name.`);
2733
+ lines.push(
2734
+ `${num(loc.more)} more localities; name one with ${surface === "cli" ? "--place-name and --country" : "place_name"}.`
2735
+ );
2677
2736
  }
2678
2737
  return lines;
2679
2738
  }
@@ -2704,7 +2763,7 @@ function hotelLine(h, i, r) {
2704
2763
  h.hotelId
2705
2764
  ].filter(Boolean).join(" \xB7 ");
2706
2765
  }
2707
- function renderSearch(r) {
2766
+ function renderSearch(r, surface = "mcp") {
2708
2767
  const lines = [header(r)];
2709
2768
  lines.push(
2710
2769
  [
@@ -2728,7 +2787,7 @@ function renderSearch(r) {
2728
2787
  }
2729
2788
  if (r.coverage.localities) {
2730
2789
  const areaName = r.destination?.kind === "place" ? r.destination.place.name : null;
2731
- lines.push("", ...localitiesLines(r.coverage.localities, areaName));
2790
+ lines.push("", ...localitiesLines(r.coverage.localities, areaName, surface));
2732
2791
  }
2733
2792
  lines.push("");
2734
2793
  if (r.data.length === 0) lines.push("No hotels on this page.");
@@ -2738,7 +2797,7 @@ function renderSearch(r) {
2738
2797
  }
2739
2798
  lines.push(
2740
2799
  "",
2741
- r.nextCursor === null ? "Last page." : `Next page: call again with only the cursor and, optionally, limit: { cursor: "${r.nextCursor}" }.`
2800
+ 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
2801
  );
2743
2802
  return lines.join("\n");
2744
2803
  }
@@ -2772,23 +2831,24 @@ function changeLine(c) {
2772
2831
  return `- ${c.field}: ${raw(c.previous)} \u2192 ${raw(c.current)}${worse}`;
2773
2832
  }
2774
2833
  }
2775
- function tooBroad(d) {
2834
+ function tooBroad(d, surface) {
2835
+ const locality = surface === "cli" ? "--locality <id>" : 'destination { kind: "locality", placeId: "<id>" }';
2776
2836
  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)
2837
+ `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.`,
2838
+ ...localitiesLines(d.localities, null, surface)
2779
2839
  ];
2780
2840
  const top = d.localities.items[0];
2781
2841
  if (top && top.total > d.poolLimit && d.center?.place?.placeId === top.place.placeId) {
2782
2842
  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}).`
2843
+ `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
2844
  );
2785
2845
  }
2786
2846
  return lines;
2787
2847
  }
2788
- function ambiguous(d) {
2848
+ function ambiguous(d, surface) {
2789
2849
  const shown = d.candidatesTotal > d.candidates.length ? `${d.candidates.length} of ${d.candidatesTotal} shown` : `${d.candidatesTotal}`;
2790
2850
  const lines = [
2791
- `Places named "${d.name}" in ${d.countryCode} (${shown}). Ask the user which one, then search with destination { kind: "place", placeId: "<id>" }:`
2851
+ `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
2852
  ];
2793
2853
  for (const c of d.candidates) {
2794
2854
  const other = [c.names.en, c.names.zh].find((n) => n && n !== c.name);
@@ -2808,7 +2868,7 @@ function ambiguous(d) {
2808
2868
  }
2809
2869
  return lines;
2810
2870
  }
2811
- function notFound(d) {
2871
+ function notFound(d, surface) {
2812
2872
  switch (d.reason) {
2813
2873
  case "no_match": {
2814
2874
  const m = d;
@@ -2819,22 +2879,23 @@ function notFound(d) {
2819
2879
  return [`Unknown placeId ${d.placeId}.`];
2820
2880
  case "not_a_locality": {
2821
2881
  const n = d;
2822
- const town = `{ kind: "place", placeId: "${n.placeId}" }`;
2882
+ const town = surface === "cli" ? `--place ${n.placeId}` : `{ kind: "place", placeId: "${n.placeId}" }`;
2823
2883
  if (n.hub === null) {
2824
2884
  return [`${n.placeId} belongs to no locality: search ${town} for an 8 km circle around it.`];
2825
2885
  }
2826
2886
  const total = n.hubTotal === null ? "" : ` (${plural(n.hubTotal, "matching hotel")})`;
2827
2887
  return [
2828
2888
  `${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.`
2889
+ `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
2890
  ];
2831
2891
  }
2832
2892
  default:
2833
2893
  return [`Details: ${raw(d)}`];
2834
2894
  }
2835
2895
  }
2836
- function detailLines(e) {
2896
+ function detailLines(e, surface) {
2837
2897
  if (!("details" in e)) return [];
2898
+ const getOrder = (id) => surface === "cli" ? `\`fortrip orders get ${id}\`` : "get_order";
2838
2899
  switch (e.code) {
2839
2900
  case "invalid_request": {
2840
2901
  const d = e.details;
@@ -2871,13 +2932,13 @@ function detailLines(e) {
2871
2932
  return [`Not cancellable: ${label(CANCEL_REASON_WORDS, e.details.reason)}.`];
2872
2933
  case "order_not_payable":
2873
2934
  return [
2874
- `Order ${e.details.orderId}, ${label(ORDER_STATUS_WORDS, e.details.status)}: read it with get_order; nothing was charged.`
2935
+ `Order ${e.details.orderId}, ${label(ORDER_STATUS_WORDS, e.details.status)}: read it with ${getOrder(e.details.orderId)}; this call charged nothing.`
2875
2936
  ];
2876
2937
  case "payment_in_progress":
2877
- return [`Order ${e.details.orderId}: read it with get_order in a few seconds.`];
2938
+ return [`Order ${e.details.orderId}: read it with ${getOrder(e.details.orderId)} in a few seconds.`];
2878
2939
  case "payment_total_changed":
2879
2940
  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.`
2941
+ `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
2942
  ];
2882
2943
  case "payment_credential_invalid":
2883
2944
  return [
@@ -2885,16 +2946,18 @@ function detailLines(e) {
2885
2946
  ];
2886
2947
  case "payment_declined":
2887
2948
  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).`
2949
+ `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
2950
  ];
2890
2951
  case "destination_ambiguous":
2891
- return ambiguous(e.details);
2952
+ return ambiguous(e.details, surface);
2892
2953
  case "destination_not_found":
2893
- return notFound(e.details);
2954
+ return notFound(e.details, surface);
2894
2955
  case "search_too_broad":
2895
- return tooBroad(e.details);
2956
+ return tooBroad(e.details, surface);
2896
2957
  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)}`];
2958
+ return e.details.reason === "mixed_occupancy" ? ["Every room must have the same party: ask once per party."] : e.details.reason === "max_nights" ? [
2959
+ `At most ${plural(e.details.max, "night")} per stay: ask the user whether to split it into consecutive stays, each its own order.`
2960
+ ] : [`Details: ${raw(e.details)}`];
2898
2961
  case "stay_in_past":
2899
2962
  return [`Check-in ${e.details.checkIn} is already past${e.details.timeZone ? ` in ${e.details.timeZone}` : ""}.`];
2900
2963
  case "offer_unavailable":
@@ -2923,7 +2986,7 @@ function retryLine(retryable, after) {
2923
2986
  }
2924
2987
  return retryable === false ? "Not retryable." : "Retryable: unknown.";
2925
2988
  }
2926
- function renderError(envelope, status) {
2989
+ function renderError(envelope, status, surface = "mcp") {
2927
2990
  const http = status === void 0 ? "" : ` (HTTP ${status})`;
2928
2991
  let known = null;
2929
2992
  let body = null;
@@ -2944,48 +3007,50 @@ Retryable: unknown.`;
2944
3007
  retryLine(body.retryable, body.retryAfterSeconds)
2945
3008
  ];
2946
3009
  if (typeof body.param === "string") lines.push(`Field: ${body.param}`);
2947
- if (known) lines.push(...detailLines(known));
3010
+ if (known) lines.push(...detailLines(known, surface));
2948
3011
  else if (body.details !== void 0) lines.push(`Details: ${raw(body.details)}`);
2949
3012
  if (typeof body.requestId === "string") lines.push(`Request id: ${body.requestId}`);
2950
3013
  return lines.join("\n");
2951
3014
  }
2952
3015
 
2953
3016
  // src/render/index.ts
2954
- function renderToolResult(tool, data) {
3017
+ function renderToolResult(tool, data, surface = "mcp") {
2955
3018
  const schema = TOOLS.find((t) => t.name === tool)?.output;
2956
3019
  let parsed;
2957
3020
  try {
2958
3021
  if (!schema) throw new Error(`no output schema for ${tool}`);
2959
3022
  parsed = parseOpen(schema, data);
2960
3023
  } catch {
2961
- const text2 = `This ${tool} result is not in the expected shape; as JSON:
3024
+ const spec = COMMANDS.find((command) => command.tool === tool);
3025
+ const name = surface === "cli" && spec ? commandInvocation(spec) : tool;
3026
+ const text2 = `This ${name} result is not in the expected shape; as JSON:
2962
3027
  ${raw(data)}`;
2963
3028
  return [
2964
3029
  text2,
2965
3030
  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 : ""
3031
+ ORDER_TOOLS.has(tool) && holdsHandlers(data) ? payNextStep(surface) : "",
3032
+ CANCEL_TOOLS.has(tool) && holdsCancellable(data) ? cancelNextStep(surface) : ""
2968
3033
  ].filter(Boolean).join("\n\n");
2969
3034
  }
2970
3035
  switch (tool) {
2971
3036
  case "search_hotels":
2972
- return renderSearch(parsed);
3037
+ return renderSearch(parsed, surface);
2973
3038
  case "get_hotel":
2974
3039
  return renderHotel(parsed);
2975
3040
  case "get_hotel_offers":
2976
- return renderOffers(parsed);
3041
+ return renderOffers(parsed, surface);
2977
3042
  case "book_hotel":
2978
3043
  case "get_order": {
2979
3044
  const order2 = parsed;
2980
- return withConsent(tool, renderOrder(order2), [order2]);
3045
+ return withConsent(tool, surface, renderOrder(order2, surface), [order2]);
2981
3046
  }
2982
3047
  case "list_orders": {
2983
3048
  const list = parsed;
2984
- return withConsent(tool, renderOrderList(list), list.data);
3049
+ return withConsent(tool, surface, renderOrderList(list, surface), list.data);
2985
3050
  }
2986
3051
  case "cancel_order":
2987
3052
  case "pay_order":
2988
- return renderOrder(parsed);
3053
+ return renderOrder(parsed, surface);
2989
3054
  }
2990
3055
  }
2991
3056
  var ORDER_TOOLS = /* @__PURE__ */ new Set(["book_hotel", "get_order", "list_orders"]);
@@ -3017,12 +3082,12 @@ function holdsCancellable(value, seen = /* @__PURE__ */ new Set()) {
3017
3082
  }
3018
3083
  return Object.values(value).some((v) => holdsCancellable(v, seen));
3019
3084
  }
3020
- function withConsent(tool, text2, orders) {
3085
+ function withConsent(tool, surface, text2, orders) {
3021
3086
  return [
3022
3087
  text2,
3023
3088
  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 : ""
3089
+ orders.some((o) => o.payment.handlers.length > 0) ? payNextStep(surface) : "",
3090
+ CANCEL_TOOLS.has(tool) && orders.some((o) => o.cancel.available) ? cancelNextStep(surface) : ""
3026
3091
  ].filter(Boolean).join("\n\n");
3027
3092
  }
3028
3093
 
@@ -3063,7 +3128,7 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
3063
3128
  // package.json
3064
3129
  var package_default = {
3065
3130
  name: "@fortrip/agent-contract",
3066
- version: "4.0.0",
3131
+ version: "4.1.0",
3067
3132
  license: "Apache-2.0",
3068
3133
  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
3134
  type: "module",
@@ -3149,6 +3214,7 @@ export {
3149
3214
  UNKNOWN_IS_NOT_NO_EXEMPTIONS,
3150
3215
  addIsoDateDays,
3151
3216
  authConfig,
3217
+ cancelNextStep,
3152
3218
  cancelOrderInput,
3153
3219
  cancellation,
3154
3220
  center,
@@ -3200,6 +3266,7 @@ export {
3200
3266
  orderReference,
3201
3267
  parseOpen,
3202
3268
  payAtProperty,
3269
+ payNextStep,
3203
3270
  payOrderInput,
3204
3271
  paymentHandler,
3205
3272
  photo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fortrip/agent-contract",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The contract of Fortrip's agent API (https://api.fortrip.ai/v1) and its MCP server: limits, paths, request and response schemas, error codes and field rules.",
6
6
  "type": "module",