fortrip 3.4.0 → 4.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,65 +27,6 @@ npm install --global fortrip
27
27
  commands, `fortrip <command> --help` one command's flags, and
28
28
  `fortrip --version` prints the version.
29
29
 
30
- ## Upgrading from 2.x
31
-
32
- 3.0 moves the CLI to Fortrip API v1. A 2.x CLI and the 2.x MCP server stop
33
- working when 3.0 is released, so upgrade the CLI and, if you added it, the
34
- hosted MCP server's address (see [MCP server](#mcp-server)).
35
-
36
- - **Sign in again.** The CLI keeps one sign-in per API URL. 2.x saved yours
37
- under `https://fortrip.ai`; 3.0's API is `https://api.fortrip.ai`, so run
38
- `fortrip login` once. The old sign-in is not revoked and is left in the file;
39
- `fortrip logout` removes only the new one.
40
- - **`hotels rates` is now `hotels offers`.** It prices up to 15 hotels with
41
- live, bookable offers. `hotels book` orders an offer by its `offerId`
42
- (`--offer`), and the guests are given per room (`--guest room:first:last`),
43
- instead of by room and rate plan. `hotels search`, `hotels get`, `login`,
44
- `logout`, `whoami`, `guide` and `mcp` keep their names; `orders get` and
45
- `orders list` are new.
46
- - **Flags changed with the API.** Run `fortrip <command> --help` for the flags
47
- of 3.0; these are the 2.x ones that moved.
48
- - Search: `--query` and `--city-code` are replaced by `--place-name` with its
49
- `--country` (or `--place`, `--locality`, `--point`, `--country-only`);
50
- `--text` matches a hotel name, brand or area. `--near` is
51
- `--point lat,lng` with `--radius-meters` (meters, where `--near` took km). `--star-min` and `--star-max`
52
- are `--stars-min` and `--stars-max`, `--facility` is `--amenity` and
53
- `--price-max` is `--price-max-per-room-night`. `--price-min` and the short `-q` are gone.
54
- - Paging: `--page` and `--page-size` are not renamed but replaced. Results
55
- are paged with a cursor: pass the `nextCursor` of the previous page to
56
- `--cursor`, and set the page size with `--limit`. There is no page number.
57
- - Rooms: `--rooms`, `--adults` and `--child-age` are replaced by
58
- `--room <adults[:age,…]>`, once per room, in `hotels search` and
59
- `hotels offers`. `hotels book` no longer takes the stay at all: the offer
60
- carries it.
61
- - `hotels get`: `--with-rooms` is `--rooms`.
62
- - `hotels offers` (was `hotels rates`): `--board` is `--require-breakfast`,
63
- `--free-cancellation` is `--require-free-cancellation`, and `--max-rooms`
64
- (rooms per hotel) is `--limit-per-hotel` (offers per hotel, 5 by default).
65
- `--nationality` and `--include-unbookable` are gone.
66
- - `hotels book`: `--hotel`, `--room-id` and `--rate-plan` are replaced by
67
- `--offer`, the `offerId` from `hotels offers`. `--guest "First Last:2"` is
68
- `--guest 2:First:Last` (room, first name, last name). `--contact-name` is
69
- `--first-name` and `--last-name`, `--contact-phone` is `--phone` and
70
- `--contact-email` is `--email`.
71
- - `--currency` is `--display-currency`, which only changes the currency
72
- prices are shown in: orders are paid in USD.
73
- - Ids are strings (`htl_…`, `off_…`, `ord_…`, `plc_…`) that you pass back as
74
- they were returned.
75
- - **New output.** A result is compact text by default, written for people and
76
- for models; `--json` prints the API's JSON instead (see
77
- [Output and exit codes](#output-and-exit-codes)). 2.x printed JSON.
78
- - **New environment names.** `FORTRIP_CURRENCY` is now
79
- `FORTRIP_DISPLAY_CURRENCY`, and the default `FORTRIP_API_URL` is
80
- `https://api.fortrip.ai`. `FORTRIP_MCP_URL` is new. See
81
- [Environment variables](#environment-variables).
82
- - **MCP.** The hosted MCP server is `https://mcp.fortrip.ai/`; its address on
83
- `fortrip.ai` is retired. `get_hotel_rates` is now `get_hotel_offers`, and
84
- `get_order` and `list_orders` are new.
85
-
86
- Commands of 1.x and earlier that were renamed (`hotel`, `rates`) are answered
87
- with the command to type instead.
88
-
89
30
  ## Sign in
90
31
 
91
32
  ```bash
@@ -164,7 +105,8 @@ differ; `hotels offers` takes one party per call, so every room must be the
164
105
  same.
165
106
 
166
107
  `hotels book` creates an unpaid order and prints a payment link for it.
167
- Nothing is charged until the person pays on the page the link opens. Orders
108
+ Nothing is charged until the person pays on the page the link opens, or
109
+ approves a shared payment token for `orders pay` in their wallet. Orders
168
110
  are paid in USD whatever `--display-currency` shows.
169
111
 
170
112
  `orders get` and `orders list` say of each order whether it can be cancelled
@@ -15074,15 +15074,117 @@ var cancelOrderInput = strictInput({
15074
15074
  "The penalty the user agreed to: cancel.penalty.amount of the order, in its currency."
15075
15075
  )
15076
15076
  });
15077
+ var sharedPaymentTokenRe = /^spt_[A-Za-z0-9]{1,250}$/;
15077
15078
  var sharedPaymentTokenError = "sharedPaymentToken must be a Stripe shared payment token: spt_ followed by letters and digits";
15079
+ var instrumentTokenError = "credential.token must be a Stripe shared payment token: spt_ followed by letters and digits";
15080
+ var instrumentsError = "payment.instruments must be a list of 1 to 8 instruments";
15081
+ var instrumentCardError = "payment.instruments must not hold card details: pay with the shared payment token alone";
15082
+ var ucpInstrument = external_exports.looseObject(
15083
+ {
15084
+ id: nonEmpty("id").describe("The instrument's id, as the agent's UCP client names it."),
15085
+ handler_id: nonEmpty("handler_id").describe(
15086
+ "The id of the handler the instrument pays through: the order's stripe_payments for the selected one."
15087
+ ),
15088
+ type: nonEmpty("type").describe("The instrument type: card for the selected one."),
15089
+ selected: flag("selected").optional().describe(
15090
+ "Whether this is the instrument to pay with. Exactly one is selected; a lone instrument without it is the one."
15091
+ ),
15092
+ credential: external_exports.looseObject(
15093
+ {
15094
+ type: nonEmpty("credential.type").describe(
15095
+ "The credential type: stripe_payment_token for the selected one."
15096
+ ),
15097
+ token: external_exports.string({ error: instrumentTokenError }).optional().describe(
15098
+ "The shared payment token (spt_\u2026) the user approved for this order, requested with the order's payment.credentialLimits."
15099
+ )
15100
+ },
15101
+ { error: "credential must be a JSON object" }
15102
+ ).optional().describe("The instrument's credential: for the selected one, the shared payment token."),
15103
+ display: external_exports.looseObject({}, { error: "display must be a JSON object" }).optional().describe("How the wallet shows the instrument, as UCP has it. Not used to pay.")
15104
+ },
15105
+ { error: "Each instrument must be a JSON object" }
15106
+ ).describe("A UCP payment instrument.");
15107
+ var selectedCard = external_exports.looseObject({
15108
+ handler_id: external_exports.literal("stripe_payments", {
15109
+ error: "The selected instrument's handler_id must be stripe_payments"
15110
+ }),
15111
+ type: external_exports.literal("card", { error: "The selected instrument's type must be card" }),
15112
+ credential: external_exports.looseObject(
15113
+ {
15114
+ type: external_exports.literal("stripe_payment_token", {
15115
+ error: "The selected instrument's credential.type must be stripe_payment_token"
15116
+ }),
15117
+ token: external_exports.string({ error: instrumentTokenError }).regex(sharedPaymentTokenRe, { error: instrumentTokenError })
15118
+ },
15119
+ { error: "The selected instrument needs a credential: its shared payment token" }
15120
+ )
15121
+ });
15122
+ function selectedOf(instruments) {
15123
+ const chosen = instruments.flatMap((i, at) => i?.selected === true ? [{ i, at }] : []);
15124
+ const lone = instruments[0];
15125
+ if (chosen.length === 0 && instruments.length === 1 && lone && lone.selected === void 0) {
15126
+ return [{ i: lone, at: 0 }];
15127
+ }
15128
+ return chosen;
15129
+ }
15078
15130
  var payOrderInput = strictInput({
15079
15131
  orderId: orderId.describe("orderId of the order to pay, from create order or get order."),
15080
- sharedPaymentToken: external_exports.string({ error: sharedPaymentTokenError }).regex(/^spt_[A-Za-z0-9]{1,250}$/, { error: sharedPaymentTokenError }).describe(
15081
- "The shared payment token (spt_\u2026) the user approved for this order, requested with the order's payment.credentialLimits."
15132
+ sharedPaymentToken: external_exports.string({ error: sharedPaymentTokenError }).regex(sharedPaymentTokenRe, { error: sharedPaymentTokenError }).optional().describe(
15133
+ "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."
15134
+ ),
15135
+ payment: strictInput({
15136
+ instruments: external_exports.array(ucpInstrument, { error: instrumentsError }).min(1, { error: instrumentsError }).max(8, { error: instrumentsError }).describe("The instruments, exactly one of them selected.")
15137
+ }).superRefine((payment, ctx) => {
15138
+ if (payment.instruments.length < 1 || payment.instruments.length > 8) return;
15139
+ const phones = [];
15140
+ const rest = JSON.stringify(payment.instruments, (key, value) => {
15141
+ if (key !== "phone_number") return value;
15142
+ phones.push(value);
15143
+ return void 0;
15144
+ });
15145
+ if (containsCardNumber(rest) || containsCardNumber(JSON.stringify(phones), 16)) {
15146
+ ctx.addIssue({ code: "custom", path: ["instruments"], message: instrumentCardError });
15147
+ return;
15148
+ }
15149
+ const chosen = selectedOf(payment.instruments);
15150
+ const [only] = chosen;
15151
+ if (chosen.length !== 1 || !only) {
15152
+ ctx.addIssue({
15153
+ code: "custom",
15154
+ path: ["instruments"],
15155
+ message: `payment.instruments must have exactly one instrument with selected: true, not ${chosen.length}`
15156
+ });
15157
+ return;
15158
+ }
15159
+ if (!ucpInstrument.safeParse(only.i).success) return;
15160
+ const card = selectedCard.safeParse(only.i);
15161
+ for (const issue2 of card.success ? [] : card.error.issues) {
15162
+ ctx.addIssue({
15163
+ code: "custom",
15164
+ path: ["instruments", only.at, ...issue2.path],
15165
+ message: issue2.message
15166
+ });
15167
+ }
15168
+ }).optional().describe(
15169
+ "UCP's Complete Checkout payment, in place of sharedPaymentToken: the token as the stripe_payment_token credential of the one selected stripe_payments card instrument. Exactly one of sharedPaymentToken and payment."
15082
15170
  ),
15083
15171
  total: usdMoney.describe(
15084
15172
  "The total the user approved: the order's price.total, exactly as returned."
15085
15173
  )
15174
+ }).superRefine((input, ctx) => {
15175
+ if (input.sharedPaymentToken !== void 0 && input.payment !== void 0) {
15176
+ ctx.addIssue({
15177
+ code: "custom",
15178
+ path: ["payment"],
15179
+ message: "Send sharedPaymentToken or payment, not both"
15180
+ });
15181
+ } else if (input.sharedPaymentToken === void 0 && input.payment === void 0) {
15182
+ ctx.addIssue({
15183
+ code: "custom",
15184
+ path: ["sharedPaymentToken"],
15185
+ message: sharedPaymentTokenError
15186
+ });
15187
+ }
15086
15188
  });
15087
15189
 
15088
15190
  // ../contract/src/commands.ts
@@ -15500,7 +15602,7 @@ var FRAGMENTS = {
15500
15602
  "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',
15501
15603
  "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",
15502
15604
  "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',
15503
- "payment-link": "{{#if claude-skill cli}}\n## Before giving the payment link\n\n`{{tool:hotels book}}` answers with an unpaid order: `status` `awaiting_payment`, its `reference` (the support number), `price.total`, the stay and its terms, and `payment.url`, a Fortrip page that recaps the order and continues to payment on Stripe. Nothing is charged until the user pays.\n\n1. Show the order's total and currency, the stay (hotel, room, dates, rooms and guests per room) and every term: meals, cancellation (status, deadline, penalties) and fees payable at the property, unknowns included.\n2. End that reply by asking the user to confirm, and wait for a clear yes. Urgency is not consent.\n3. Then give `payment.url` exactly as returned: don't shorten, rebuild or re-encode it.\n\n{{/if}}\n{{#if mcp}}\n- Before you give `payment.url`, show the user the order's total and currency, the stay and every term, end that reply by asking the user to confirm, and wait for a clear yes. Then give `payment.url` exactly as returned, to this user only: anyone holding it can pay.\n{{/if}}\n{{#if claude-skill cli}}\n- `payment.url` works like a payment credential: anyone holding it can pay. Give it to this user only, never in shared channels, documents, logs or tickets. With `requiresSignIn: true` (an order started on the Fortrip website), the user signs in to pay.\n- The link expires at `payment.expiresAt`; the order is then `expired`. To order the stay again, get offers again, and confirm the new order with the user before giving its link.\n- Another order of the stay (another party, or a corrected guest name) needs a new offer: get offers again. When it replaces an unpaid order, tell the user to pay only the new link; the earlier one expires unpaid.\n- An order `awaiting_payment` whose `payment.url` is null had its link unreadable this time: read it again with `{{tool:orders get}}`.\n{{/if}}\n- Never ask for, accept or pass on payment card details; payment happens only on the payment page.{{#if claude-skill cli}} A card number in a guest name, the contact or the special requests is rejected{{#if cli}} with exit 2{{/if}}.{{/if}}\n{{#if claude-skill cli}}\n\n## Paying without the link\n\nAn order with `payment.handlers` can also be paid with a Stripe shared payment token that the user's wallet (Link) grants for it, through `{{tool:orders pay}}`:\n\n1. Show and ask exactly as before giving the payment link, and wait for a clear yes. The token comes from the user's wallet, never from card details.\n2. Request the token from the user's wallet with the handler's `networkId` and `payment.credentialLimits`: `maxAmount` (in cents), `currency` and `expiresAt`.\n3. {{#if claude-skill}}Call{{/if}}{{#if cli}}Run{{/if}} `{{tool:orders pay}}` with the token and the order's `price.total`{{#if cli}} (`--token`, `--total`){{/if}}. The order is then `confirming`, its payment `authorized`: check it as after payment.\n\nThe charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once `{{tool:orders pay}}` succeeds, `payment.url` stops working; a payment that fails leaves the link open. `payment_total_changed` means the total changed: show the new total and ask again, for a new token. `payment_declined`: the user picks another payment method in their wallet, or pays by link. `payment_action_required`: the card needs a verification this can't give: pay by link. `payment_credential_invalid`: request a new token with the order's `payment.credentialLimits`. `service_unavailable`: call `{{tool:orders pay}}` again with the same token, never a new one. A token pays one order only.\n\n## After payment\n\nCheck the order with `{{tool:orders get}}`:\n\n- `confirming` while the hotel confirms, then `confirmed` with the hotel's `confirmationNumber`.\n- `failed`: no stay was booked; `payment.status` says whether the payment was released or refunded.\n- `needs_attention`: Fortrip is looking into it; the user can email {{support}} with the `reference`.\n- `manageUrl` is the user's own page for the order.\n{{/if}}\n",
15605
+ "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",
15504
15606
  "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",
15505
15607
  "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",
15506
15608
  "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",
@@ -15628,6 +15730,11 @@ function mark(schema, kind2) {
15628
15730
  function openObject(shape) {
15629
15731
  return external_exports.looseObject(shape);
15630
15732
  }
15733
+ function protocolObject() {
15734
+ const schema = external_exports.record(external_exports.string(), external_exports.unknown());
15735
+ mark(schema, "protocol");
15736
+ return schema;
15737
+ }
15631
15738
  function openEnum(values) {
15632
15739
  const schema = external_exports.union([
15633
15740
  external_exports.enum(values),
@@ -15769,8 +15876,8 @@ var hotelSummary = openObject({
15769
15876
  timeZone: external_exports.string().nullable(),
15770
15877
  distanceMeters: external_exports.number().nullable(),
15771
15878
  price: indicativePrice.nullable(),
15772
- /** The cover photo; `null` without one. Absent from servers before 3.1. */
15773
- photo: photo.nullable().optional()
15879
+ /** The cover photo; `null` without one. */
15880
+ photo: photo.nullable()
15774
15881
  });
15775
15882
  var localities = openObject({
15776
15883
  items: external_exports.array(
@@ -15890,8 +15997,8 @@ var hotel = openObject({
15890
15997
  timeZone: external_exports.string().nullable(),
15891
15998
  description: knownLocaleText.nullable(),
15892
15999
  /** Up to 8 hotel photos, the cover first; `null` when the catalogue lists
15893
- * none (unknown is not no). Absent from servers before 3.1. */
15894
- photos: external_exports.array(photo).nullable().optional(),
16000
+ * none (unknown is not no). */
16001
+ photos: external_exports.array(photo).nullable(),
15895
16002
  checkInTimes: timeRange,
15896
16003
  checkOutTimes: timeRange,
15897
16004
  policies: openObject({
@@ -16066,7 +16173,14 @@ var paymentHandler = openObject({
16066
16173
  type: external_exports.string(),
16067
16174
  version: external_exports.string(),
16068
16175
  spec: external_exports.string(),
16069
- networkId: external_exports.string().nullable()
16176
+ schema: external_exports.string(),
16177
+ available_instruments: external_exports.array(
16178
+ openObject({ type: external_exports.string(), config: protocolObject().optional() })
16179
+ ),
16180
+ config: openObject({
16181
+ environment: openEnum(["livemode", "testmode"]),
16182
+ business_profile: external_exports.string()
16183
+ })
16070
16184
  });
16071
16185
  var orderReference = external_exports.string().regex(/^FT-[2-9A-HJ-NP-Z]{6}$/);
16072
16186
  var hotelItem = openObject({
@@ -16106,29 +16220,28 @@ var order = openObject({
16106
16220
  localCurrencyAtCheckout: external_exports.boolean(),
16107
16221
  localCharge: money.nullable(),
16108
16222
  /** The ways to pay other than `url`, while the order can be paid that
16109
- * way (3.4): a `com.stripe.payments` handler takes a shared payment
16110
- * token through `pay_order`. Absent when there is none. */
16111
- handlers: external_exports.array(paymentHandler).optional(),
16112
- /** What a payment credential for `pay_order` must allow, present with
16113
- * `handlers` (3.4): `maxAmount` in minor units (cents) of `currency`,
16223
+ * way: a `com.stripe.payments` handler takes a shared payment token
16224
+ * through `pay_order`. Empty when there is none. */
16225
+ handlers: external_exports.array(paymentHandler),
16226
+ /** What a payment credential for `pay_order` must allow, with
16227
+ * `handlers`: `maxAmount` in minor units (cents) of `currency`,
16114
16228
  * lowercase as Stripe takes it, and `expiresAt`, past which the order
16115
- * can't be paid. */
16229
+ * can't be paid. `null` when `handlers` is empty. */
16116
16230
  credentialLimits: openObject({
16117
16231
  maxAmount: external_exports.number().int(),
16118
16232
  currency: external_exports.string(),
16119
16233
  expiresAt: instant
16120
- }).optional()
16234
+ }).nullable()
16121
16235
  }),
16122
16236
  /** Whether the user can cancel the order now and, when they can, its
16123
16237
  * penalty under the accepted terms (read a minute ahead) and the refund,
16124
- * what was paid less the penalty, both in the charge currency. Absent
16125
- * from servers before 3.3. */
16238
+ * what was paid less the penalty, both in the charge currency. */
16126
16239
  cancel: openObject({
16127
16240
  available: external_exports.boolean(),
16128
16241
  reason: openEnum(CANCEL_REASONS),
16129
16242
  penalty: money.nullable(),
16130
16243
  refund: money.nullable()
16131
- }).optional(),
16244
+ }),
16132
16245
  manageUrl: external_exports.string()
16133
16246
  });
16134
16247
  var orderList = openObject({
@@ -16154,7 +16267,7 @@ var offerChange = openUnion("field", [
16154
16267
  // ../contract/src/tools.ts
16155
16268
  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.";
16156
16269
  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.";
16157
- var PAY_NEXT_STEP = "To pay without the link, when the order has payment.handlers and the user's wallet can grant a Stripe shared payment token: first show and ask exactly as for payment.url, and wait for a clear yes. Then request the token for this order from the user's wallet with the handler's networkId and payment.credentialLimits (maxAmount in cents, currency, expiresAt), and call pay_order with it and the order's price.total. The charge is in USD: a card in another currency may add a foreign transaction fee. Pay one way only: once pay_order succeeds, payment.url stops working.";
16270
+ 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.";
16158
16271
  var nextStep = external_exports.string().optional().describe(
16159
16272
  "What to show and ask before giving a payment.url. Present when the answer holds a non-null payment.url, and only then."
16160
16273
  );
@@ -16250,7 +16363,7 @@ var TOOLS = [
16250
16363
  {
16251
16364
  name: "pay_order",
16252
16365
  title: "Pay order with a shared payment token",
16253
- description: "Pay an order awaiting payment without its link, with a Stripe shared payment token, when the order has payment.handlers. First show and ask exactly as for payment.url, and wait for a clear yes. Then request the token from the user's wallet with the handler's networkId and payment.credentialLimits, and pass it with the order's price.total. The charge is in USD. Once it succeeds, payment.url stops working; a payment that fails leaves the link open. Answers the order: status confirming, the payment authorized (held, charged once the hotel confirms); poll get_order. payment_total_changed: show details.total and ask again, for a new token. payment_declined: the user picks another payment method in their wallet, or pays by link. payment_action_required: the card needs a verification this can't give; pay by link. payment_credential_invalid: request a new token. service_unavailable: call pay_order again with the same token, never a new one. A token pays one order only; the same token again answers as before.",
16366
+ 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.",
16254
16367
  annotations: {
16255
16368
  readOnlyHint: false,
16256
16369
  idempotentHint: true,
@@ -16368,9 +16481,8 @@ var ERROR_DETAILS = {
16368
16481
  matched: count2,
16369
16482
  poolLimit: count2,
16370
16483
  localities,
16371
- /** The searched area's center, as a search echoes it; null for text only.
16372
- * Optional for clients; the server must send it (`SERVER_DETAILS`). */
16373
- center: center.nullable().optional()
16484
+ /** The searched area's center, as a search echoes it; null for text only. */
16485
+ center: center.nullable()
16374
16486
  }),
16375
16487
  stay_unsupported: openUnion("reason", [
16376
16488
  openObject({ reason: external_exports.literal("mixed_occupancy") }),
@@ -16402,29 +16514,23 @@ var ERROR_DETAILS = {
16402
16514
  }),
16403
16515
  internal: null
16404
16516
  };
16405
- var SERVER_DETAILS = {
16406
- search_too_broad: ERROR_DETAILS.search_too_broad.extend({ center: center.nullable() })
16407
- };
16408
- function envelopeSchema(detailsRequired) {
16409
- return openObject({
16410
- error: openUnion(
16411
- "code",
16412
- Object.keys(ERROR_CODES).map((code) => {
16413
- const details = detailsRequired ? SERVER_DETAILS[code] ?? ERROR_DETAILS[code] : ERROR_DETAILS[code];
16414
- return openObject({
16415
- code: external_exports.literal(code),
16416
- message: external_exports.string(),
16417
- param: external_exports.string().optional(),
16418
- retryable: external_exports.boolean(),
16419
- retryAfterSeconds: external_exports.number().int().optional(),
16420
- ...details ? { details: detailsRequired ? details : details.optional() } : {},
16421
- requestId: external_exports.string()
16422
- });
16423
- })
16424
- )
16425
- });
16426
- }
16427
- var errorEnvelope = envelopeSchema(false);
16517
+ var errorEnvelope = openObject({
16518
+ error: openUnion(
16519
+ "code",
16520
+ Object.keys(ERROR_CODES).map((code) => {
16521
+ const details = ERROR_DETAILS[code];
16522
+ return openObject({
16523
+ code: external_exports.literal(code),
16524
+ message: external_exports.string(),
16525
+ param: external_exports.string().optional(),
16526
+ retryable: external_exports.boolean(),
16527
+ retryAfterSeconds: external_exports.number().int().optional(),
16528
+ ...details ? { details } : {},
16529
+ requestId: external_exports.string()
16530
+ });
16531
+ })
16532
+ )
16533
+ });
16428
16534
 
16429
16535
  // ../contract/src/render/format.ts
16430
16536
  function num(n) {
@@ -16708,14 +16814,14 @@ function paymentLines(o) {
16708
16814
  } else if (o.status === "awaiting_payment") {
16709
16815
  lines.push("Payment link: could not be read this time; read this order again for it.");
16710
16816
  }
16711
- if (p.handlers?.length) lines.push(handlersLine(p.handlers, p.credentialLimits));
16712
- if (o.cancel) lines.push(cancelLine(o.cancel));
16817
+ if (p.handlers.length > 0) lines.push(handlersLine(p.handlers, p.credentialLimits));
16818
+ lines.push(cancelLine(o.cancel));
16713
16819
  lines.push(`Manage: ${o.manageUrl}`);
16714
16820
  return lines;
16715
16821
  }
16716
16822
  function handlersLine(handlers, limits) {
16717
16823
  const shown = handlers.map(
16718
- (h) => `${h.type} (handler ${h.id}${h.networkId ? `, networkId ${h.networkId}` : ""})`
16824
+ (h) => `${h.type} (handler ${h.id}, business_profile ${h.config.business_profile})`
16719
16825
  );
16720
16826
  const limit = limits ? `; token limits: maxAmount ${limits.maxAmount} (cents), currency ${limits.currency}, expiresAt ${limits.expiresAt}` : "";
16721
16827
  return `Pay without the link: pay_order with a shared payment token via ${shown.join(", ")}${limit}`;
@@ -17019,7 +17125,7 @@ function notFound(d) {
17019
17125
  }
17020
17126
  }
17021
17127
  function detailLines(e) {
17022
- if (!("details" in e) || e.details === void 0) return [];
17128
+ if (!("details" in e)) return [];
17023
17129
  switch (e.code) {
17024
17130
  case "invalid_request": {
17025
17131
  const d = e.details;
@@ -17274,15 +17380,15 @@ function withConsent(tool, text2, orders) {
17274
17380
  return [
17275
17381
  text2,
17276
17382
  orders.some((o) => o.payment.url !== null) ? ORDER_NEXT_STEP : "",
17277
- orders.some((o) => (o.payment.handlers?.length ?? 0) > 0) ? PAY_NEXT_STEP : "",
17278
- CANCEL_TOOLS.has(tool) && orders.some((o) => o.cancel?.available === true) ? CANCEL_NEXT_STEP : ""
17383
+ orders.some((o) => o.payment.handlers.length > 0) ? PAY_NEXT_STEP : "",
17384
+ CANCEL_TOOLS.has(tool) && orders.some((o) => o.cancel.available) ? CANCEL_NEXT_STEP : ""
17279
17385
  ].filter(Boolean).join("\n\n");
17280
17386
  }
17281
17387
 
17282
17388
  // ../contract/package.json
17283
17389
  var package_default = {
17284
17390
  name: "@fortrip/agent-contract",
17285
- version: "3.4.0",
17391
+ version: "4.0.0-rc.1",
17286
17392
  license: "Apache-2.0",
17287
17393
  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.",
17288
17394
  type: "module",
@@ -17412,8 +17518,6 @@ function localCode(failure) {
17412
17518
  return "invalid_request";
17413
17519
  case EXIT.unauthenticated:
17414
17520
  return "unauthenticated";
17415
- case EXIT.rateLimited:
17416
- return "rate_limited";
17417
17521
  default:
17418
17522
  return failure.details.retryable === true ? "service_unavailable" : "cli_error";
17419
17523
  }
@@ -17428,11 +17532,13 @@ function formatError2(failure, json2) {
17428
17532
  const inError = (name) => fromApi ? Object.hasOwn(fromApi, name) : ERROR_FIELDS.has(name);
17429
17533
  const own = Object.entries(failure.details);
17430
17534
  if (json2) {
17535
+ const code = localCode(failure);
17431
17536
  const error51 = fromApi ?? {
17432
- code: localCode(failure),
17537
+ code,
17433
17538
  message: failure.message,
17434
17539
  retryable: failure.details.retryable === true,
17435
17540
  requestId: localRequestId(),
17541
+ ...code === "invalid_request" ? { details: { issues: [] } } : {},
17436
17542
  ...Object.fromEntries(own.filter(([n]) => inError(n) && n !== "retryable"))
17437
17543
  };
17438
17544
  return JSON.stringify({ error: error51, ...Object.fromEntries(own.filter(([n]) => !inError(n))), ...notices });
@@ -17571,7 +17677,7 @@ function unwrap(response) {
17571
17677
  const retryAfter = Number(headers.get("retry-after"));
17572
17678
  throw new CliError(`Unexpected ${status} answer from the API`, exitCodeFor(void 0, status), {
17573
17679
  status,
17574
- ...status >= 500 ? { retryable: true } : {},
17680
+ ...status >= 500 || status === 429 ? { retryable: true } : {},
17575
17681
  ...Number.isFinite(retryAfter) && retryAfter > 0 ? { retryAfterSeconds: retryAfter } : {},
17576
17682
  ...raw2 ? { raw: raw2 } : {}
17577
17683
  });
@@ -17655,7 +17761,6 @@ function parse3(text2) {
17655
17761
  }
17656
17762
  if (!isObject3(raw2)) return null;
17657
17763
  const { version: version2, sessions, pendingLogins, ...other } = raw2;
17658
- if (version2 === void 0) return emptyCredentials();
17659
17764
  if (version2 !== 2) return null;
17660
17765
  const credentials = { sessions: {}, logins: {}, other };
17661
17766
  for (const [apiUrl, session] of Object.entries(isObject3(sessions) ? sessions : {})) {
@@ -18386,6 +18491,7 @@ export {
18386
18491
  commandInvocation,
18387
18492
  GLOBAL_FLAGS,
18388
18493
  renderGuide,
18494
+ order,
18389
18495
  API,
18390
18496
  TOOLS,
18391
18497
  renderError,
package/dist/cli.js CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  login,
19
19
  logout,
20
20
  notices,
21
+ order,
21
22
  renderGuide,
22
23
  renderToolResult,
23
24
  resolveApiUrl,
@@ -25,7 +26,7 @@ import {
25
26
  unwrap,
26
27
  usageError,
27
28
  whoami
28
- } from "./chunk-RXL4344N.js";
29
+ } from "./chunk-FKN3WGPP.js";
29
30
 
30
31
  // src/commands.ts
31
32
  import { readFileSync } from "fs";
@@ -445,11 +446,6 @@ function globalFlag(name) {
445
446
  var HELP_FLAGS = globalFlag("help");
446
447
  var VERSION_FLAGS = globalFlag("version");
447
448
  var JSON_FLAG = "--json";
448
- var RENAMED = /* @__PURE__ */ new Map([
449
- ["hotel", { group: "hotels", name: "get" }],
450
- ["rates", { group: "hotels", name: "offers" }],
451
- ["hotels rates", { group: "hotels", name: "offers" }]
452
- ]);
453
449
  function findCommand(argv) {
454
450
  const [word, ...afterWord] = argv;
455
451
  const group = COMMAND_GROUPS.find((candidate) => candidate.name === word);
@@ -462,9 +458,8 @@ function findCommand(argv) {
462
458
  (candidate) => candidate.group === group.name && candidate.name === name
463
459
  );
464
460
  if (!spec2) {
465
- const renamed2 = RENAMED.get(`${group.name} ${name}`);
466
461
  throw usageError(
467
- renamed2 ? `Unknown command "${group.name} ${name}". Did you mean \`${commandInvocation(renamed2)}\`?` : `Unknown command "${group.name} ${name}". Run \`fortrip ${group.name} --help\`.`
462
+ `Unknown command "${group.name} ${name}". Run \`fortrip ${group.name} --help\`.`
468
463
  );
469
464
  }
470
465
  return { spec: spec2, rest };
@@ -473,11 +468,9 @@ function findCommand(argv) {
473
468
  (candidate) => candidate.group === null && candidate.name === word
474
469
  );
475
470
  if (spec) return { spec, rest: afterWord };
476
- const renamed = RENAMED.get(word ?? "");
477
- const meant = [
478
- ...COMMANDS.filter((candidate) => candidate.group !== null && candidate.name === word),
479
- ...renamed ? [renamed] : []
480
- ].map((candidate) => `\`${commandInvocation(candidate)}\``);
471
+ const meant = COMMANDS.filter(
472
+ (candidate) => candidate.group !== null && candidate.name === word
473
+ ).map((candidate) => `\`${commandInvocation(candidate)}\``);
481
474
  throw usageError(
482
475
  meant.length ? `Unknown command "${word}". Did you mean ${meant.join(" or ")}?` : `Unknown command "${word}". Run \`fortrip --help\`.`
483
476
  );
@@ -535,7 +528,7 @@ async function run(argv) {
535
528
  case "mcp": {
536
529
  parseOptions(spec, rest);
537
530
  const mcpUrl = resolveMcpUrl(apiUrl);
538
- const { runMcpBridge } = await import("./mcp-bridge-2QXRS5ZV.js");
531
+ const { runMcpBridge } = await import("./mcp-bridge-E5U3X55C.js");
539
532
  await runMcpBridge(mcpUrl, apiUrl);
540
533
  return void 0;
541
534
  }
@@ -543,21 +536,21 @@ async function run(argv) {
543
536
  }
544
537
  const preview = cancelPreview(spec, rest);
545
538
  if (preview) {
546
- const order = unwrap(await authorizedRequest(apiUrl, preview.path, { method: preview.method }));
547
- throw usageError(notCancelled(spec, preview.flag, order));
539
+ const order2 = unwrap(await authorizedRequest(apiUrl, preview.path, { method: preview.method }));
540
+ throw usageError(notCancelled(spec, preview.flag, order2));
548
541
  }
549
542
  const { method, path, body } = parseCommand(spec, rest, process.env);
550
543
  const data = unwrap(await authorizedRequest(apiUrl, path, { method, body }));
551
544
  return { data, text: renderToolResult(spec.tool, data) };
552
545
  }
553
- function notCancelled(spec, flag, order) {
554
- const line = renderToolResult("get_order", order).split("\n").find((text) => text.startsWith("Cancel: "));
555
- const cancel = order?.cancel;
556
- const amount = cancel?.available === true ? cancel.penalty?.amount : void 0;
546
+ function notCancelled(spec, flag, order2) {
547
+ const cancelLine = renderToolResult("get_order", order2).split("\n").filter((text) => text.startsWith("Cancel: "));
548
+ const parsed = order.safeParse(order2);
549
+ const cancel = parsed.success ? parsed.data.cancel : void 0;
557
550
  return [
558
551
  `Not cancelled: ${commandInvocation(spec)} needs ${flag}, the penalty the user agreed to.`,
559
- line ?? "Cancel: not stated for this order.",
560
- ...typeof amount === "string" ? [`Pass ${flag} ${amount} to cancel.`] : []
552
+ ...cancelLine,
553
+ ...cancel?.available && cancel.penalty ? [`Pass ${flag} ${cancel.penalty.amount} to cancel.`] : []
561
554
  ].join("\n");
562
555
  }
563
556
  function account(data) {
@@ -11,7 +11,7 @@ import {
11
11
  renderError,
12
12
  renderGuide,
13
13
  requireToken
14
- } from "./chunk-RXL4344N.js";
14
+ } from "./chunk-FKN3WGPP.js";
15
15
 
16
16
  // src/mcp-bridge.ts
17
17
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fortrip",
3
- "version": "3.4.0",
3
+ "version": "4.0.0-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Search, price and book Fortrip hotels from the terminal or an AI agent.",
6
6
  "mcpName": "io.github.FortripEngineering/fortrip",
@@ -32,7 +32,7 @@
32
32
  "tsx": "^4.20.0",
33
33
  "typescript": "^5.9.0",
34
34
  "zod": "4.4.3",
35
- "@fortrip/agent-contract": "3.4.0"
35
+ "@fortrip/agent-contract": "4.0.0-rc.1"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsup",