@fortrip/agent-contract 4.3.0 → 5.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/dist/index.d.ts +537 -248
- package/dist/index.js +325 -288
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -94,6 +94,53 @@ var placeId = z.string({ error: "placeId must be plc_ followed by 1 to 12 digits
|
|
|
94
94
|
|
|
95
95
|
// src/conventions/money.ts
|
|
96
96
|
import { z as z2 } from "zod";
|
|
97
|
+
|
|
98
|
+
// src/limits.ts
|
|
99
|
+
var LIMITS = {
|
|
100
|
+
rooms: 8,
|
|
101
|
+
adultsPerRoom: 8,
|
|
102
|
+
childrenPerRoom: 4,
|
|
103
|
+
childAgeMax: 17,
|
|
104
|
+
nightsFortrip: 30,
|
|
105
|
+
nightsSupplier: 15,
|
|
106
|
+
offersHotels: 15,
|
|
107
|
+
offersPerHotelDefault: 10,
|
|
108
|
+
offersPerHotelMax: 20,
|
|
109
|
+
pageSizeDefault: 20,
|
|
110
|
+
pageSizeMax: 50,
|
|
111
|
+
textLength: 128,
|
|
112
|
+
radiusMetersMax: 8e4,
|
|
113
|
+
radiusMetersDefault: 8e3,
|
|
114
|
+
amenityFilters: 9,
|
|
115
|
+
guestName: 60,
|
|
116
|
+
contactFirstName: 59,
|
|
117
|
+
contactLastName: 59,
|
|
118
|
+
contactPhoneMin: 3,
|
|
119
|
+
contactPhoneMax: 40,
|
|
120
|
+
specialRequests: 500,
|
|
121
|
+
poolLimit: 3e3,
|
|
122
|
+
candidatesShown: 8,
|
|
123
|
+
candidatesCounted: 200,
|
|
124
|
+
localitiesShown: 8,
|
|
125
|
+
tokenPaymentMaxUsd: 500,
|
|
126
|
+
/** Minutes that must be left before the order's payment window closes
|
|
127
|
+
* (`payment.expiresAt`) for the order to offer a token or wallet payment
|
|
128
|
+
* (an entry of `payment.methods`). */
|
|
129
|
+
payMinMinutesLeft: 15,
|
|
130
|
+
/** `pay_order` refuses (`order_not_payable`), by token or wallet, when the
|
|
131
|
+
* order's payment window (`payment.expiresAt`) closes within this many
|
|
132
|
+
* minutes. */
|
|
133
|
+
payCutoffMinutes: 2,
|
|
134
|
+
tokensPerOrder: 5,
|
|
135
|
+
wechatCodeMinutes: 120,
|
|
136
|
+
/** Orders one account can make for one stay (the same room, rate, dates
|
|
137
|
+
* and party); past it, ordering the stay answers `order_exists`. */
|
|
138
|
+
ordersPerStay: 20
|
|
139
|
+
};
|
|
140
|
+
var CURRENCIES = ["USD", "CNY"];
|
|
141
|
+
var SUPPORT_EMAIL = "info@fortrip.ai";
|
|
142
|
+
|
|
143
|
+
// src/conventions/money.ts
|
|
97
144
|
var amountError = "amount must be a decimal string such as 132.40";
|
|
98
145
|
var currencyError = "currency must be a 3-letter uppercase ISO 4217 code";
|
|
99
146
|
var money = z2.looseObject({
|
|
@@ -104,15 +151,26 @@ var money = z2.looseObject({
|
|
|
104
151
|
error: currencyError
|
|
105
152
|
})
|
|
106
153
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
154
|
+
function requestMoney(name) {
|
|
155
|
+
return z2.strictObject(
|
|
156
|
+
{
|
|
157
|
+
amount: z2.string({ error: amountError }).regex(/^\d+(\.\d+)?$/, { error: amountError }).describe("Decimal string such as 132.40, never a number."),
|
|
158
|
+
currency: z2.enum(CURRENCIES, { error: "currency must be USD or CNY" }).describe("USD or CNY.")
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
error: (issue) => issue.code === "unrecognized_keys" ? `Unknown field(s): ${issue.keys.join(", ")}` : `${name} must be Money: { amount: "132.40", currency: "USD" or "CNY" }`
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
function echoedMoney(name) {
|
|
166
|
+
return z2.looseObject(
|
|
167
|
+
{
|
|
168
|
+
amount: z2.string({ error: amountError }).regex(/^\d+(\.\d+)?$/, { error: amountError }).describe("Decimal string such as 132.40, never a number."),
|
|
169
|
+
currency: z2.string({ error: currencyError }).regex(/^[A-Z]{3}$/, { error: currencyError }).describe("3-letter uppercase ISO 4217 code, as returned.")
|
|
170
|
+
},
|
|
171
|
+
{ error: `${name} must be Money as returned: { amount: "132.40", currency: "USD" }` }
|
|
172
|
+
);
|
|
173
|
+
}
|
|
116
174
|
function formatMoney(m) {
|
|
117
175
|
return `${m.currency} ${m.amount}`;
|
|
118
176
|
}
|
|
@@ -165,51 +223,6 @@ function flag(name) {
|
|
|
165
223
|
return z4.boolean({ error: `${name} must be true or false` });
|
|
166
224
|
}
|
|
167
225
|
|
|
168
|
-
// src/limits.ts
|
|
169
|
-
var LIMITS = {
|
|
170
|
-
rooms: 8,
|
|
171
|
-
adultsPerRoom: 8,
|
|
172
|
-
childrenPerRoom: 4,
|
|
173
|
-
childAgeMax: 17,
|
|
174
|
-
nightsFortrip: 30,
|
|
175
|
-
nightsSupplier: 15,
|
|
176
|
-
offersHotels: 15,
|
|
177
|
-
offersPerHotelDefault: 10,
|
|
178
|
-
offersPerHotelMax: 20,
|
|
179
|
-
pageSizeDefault: 20,
|
|
180
|
-
pageSizeMax: 50,
|
|
181
|
-
textLength: 128,
|
|
182
|
-
radiusMetersMax: 8e4,
|
|
183
|
-
radiusMetersDefault: 8e3,
|
|
184
|
-
amenityFilters: 9,
|
|
185
|
-
guestName: 60,
|
|
186
|
-
contactFirstName: 59,
|
|
187
|
-
contactLastName: 59,
|
|
188
|
-
contactPhoneMin: 3,
|
|
189
|
-
contactPhoneMax: 40,
|
|
190
|
-
specialRequests: 500,
|
|
191
|
-
poolLimit: 3e3,
|
|
192
|
-
candidatesShown: 8,
|
|
193
|
-
candidatesCounted: 200,
|
|
194
|
-
localitiesShown: 8,
|
|
195
|
-
tokenPaymentMaxUsd: 500,
|
|
196
|
-
/** Minutes that must be left before the order's payment window closes
|
|
197
|
-
* (`payment.expiresAt`) for the order to offer a token or wallet payment
|
|
198
|
-
* (`payment.handlers`, `payment.wallets`). */
|
|
199
|
-
payMinMinutesLeft: 15,
|
|
200
|
-
/** `pay_order` refuses (`order_not_payable`), by token or wallet, when the
|
|
201
|
-
* order's payment window (`payment.expiresAt`) closes within this many
|
|
202
|
-
* minutes. */
|
|
203
|
-
payCutoffMinutes: 2,
|
|
204
|
-
tokensPerOrder: 5,
|
|
205
|
-
wechatCodeMinutes: 120,
|
|
206
|
-
/** Orders one account can make for one stay (the same room, rate, dates
|
|
207
|
-
* and party); past it, ordering the stay answers `order_exists`. */
|
|
208
|
-
ordersPerStay: 20
|
|
209
|
-
};
|
|
210
|
-
var DISPLAY_CURRENCIES = ["USD", "CNY"];
|
|
211
|
-
var SUPPORT_EMAIL = "info@fortrip.ai";
|
|
212
|
-
|
|
213
226
|
// src/vocabulary.ts
|
|
214
227
|
var FILTERABLE_AMENITIES = [
|
|
215
228
|
"parking",
|
|
@@ -246,12 +259,7 @@ var SEARCH_SORTS = [
|
|
|
246
259
|
var locale = oneOf("locale", ["en", "zh"]).describe(
|
|
247
260
|
"Language for names and text in the response: en or zh."
|
|
248
261
|
);
|
|
249
|
-
var
|
|
250
|
-
"USD",
|
|
251
|
-
"CNY"
|
|
252
|
-
]).describe(
|
|
253
|
-
"Currency to show prices in, USD or CNY. It never changes what is charged: payment is in USD."
|
|
254
|
-
);
|
|
262
|
+
var currencyDescription = "The currency to price and charge in: USD (default) or CNY, where available (otherwise the answer is currency_unavailable).";
|
|
255
263
|
var cursor = nonEmpty("cursor");
|
|
256
264
|
var nightsError = (name) => `${name} must be after the check-in date and at most ${LIMITS.nightsFortrip} nights later`;
|
|
257
265
|
var stay = strictInput({
|
|
@@ -333,7 +341,7 @@ var destination = z5.discriminatedUnion(
|
|
|
333
341
|
countryCode: countryCode.describe("ISO 3166-1 alpha-2 country, e.g. JP.")
|
|
334
342
|
}),
|
|
335
343
|
strictInput({
|
|
336
|
-
kind: z5.literal("locality", { error: "kind must be locality" }).describe("A locality
|
|
344
|
+
kind: z5.literal("locality", { error: "kind must be locality" }).describe("A locality listed in an earlier search response."),
|
|
337
345
|
placeId: placeId.describe("placeId of the locality."),
|
|
338
346
|
radiusMeters
|
|
339
347
|
})
|
|
@@ -375,8 +383,8 @@ var searchFilters = strictInput({
|
|
|
375
383
|
"Amenities every hotel must list. Only some codes can filter; asking for one that cannot is answered with the list that can."
|
|
376
384
|
),
|
|
377
385
|
price: strictInput({
|
|
378
|
-
maxPerRoomNight:
|
|
379
|
-
"Highest price per room per night, in
|
|
386
|
+
maxPerRoomNight: requestMoney("filters.price.maxPerRoomNight").describe(
|
|
387
|
+
"Highest price per room per night, in the search's currency."
|
|
380
388
|
)
|
|
381
389
|
}).optional().describe("Price limit. Needs indicative pricing, so a stay.")
|
|
382
390
|
}).optional().describe("Filters every hotel in the answer must pass.");
|
|
@@ -404,7 +412,7 @@ function createSearchHotelsInput(now = Date.now) {
|
|
|
404
412
|
"`nextCursor` from the previous response. A next page is the cursor and, optionally, `limit`; nothing else."
|
|
405
413
|
),
|
|
406
414
|
locale: locale.optional(),
|
|
407
|
-
|
|
415
|
+
currency: oneOf("currency", CURRENCIES).optional().describe(currencyDescription)
|
|
408
416
|
}).superRefine((input, ctx) => {
|
|
409
417
|
const issue = (path, message) => ctx.addIssue({ code: "custom", path, message });
|
|
410
418
|
if (input.cursor !== void 0) {
|
|
@@ -446,6 +454,14 @@ function createSearchHotelsInput(now = Date.now) {
|
|
|
446
454
|
);
|
|
447
455
|
}
|
|
448
456
|
}
|
|
457
|
+
const bound = input.filters?.price?.maxPerRoomNight;
|
|
458
|
+
const searchCurrency = input.currency ?? "USD";
|
|
459
|
+
if (bound !== void 0 && bound.currency !== searchCurrency) {
|
|
460
|
+
issue(
|
|
461
|
+
["filters", "price", "maxPerRoomNight", "currency"],
|
|
462
|
+
`filters.price.maxPerRoomNight.currency is ${bound.currency}, but the search is in ${searchCurrency}${input.currency === void 0 ? " (the default)" : ""}: send the price in ${searchCurrency}`
|
|
463
|
+
);
|
|
464
|
+
}
|
|
449
465
|
const checkIn = input.stay?.checkIn;
|
|
450
466
|
if (checkIn !== void 0 && isIsoDate(checkIn)) {
|
|
451
467
|
const earliest = new Date(now() - 12 * 36e5).toISOString().slice(0, 10);
|
|
@@ -477,7 +493,7 @@ var hotelOffersInput = strictInput({
|
|
|
477
493
|
`Offers per hotel, 1 to ${LIMITS.offersPerHotelMax}. Default ${LIMITS.offersPerHotelDefault}.`
|
|
478
494
|
),
|
|
479
495
|
locale: locale.optional(),
|
|
480
|
-
|
|
496
|
+
currency: oneOf("currency", CURRENCIES).optional().describe(`${currencyDescription} An order made from these offers is charged in this currency.`)
|
|
481
497
|
});
|
|
482
498
|
function cardFreeText(name, min, max, minDigits) {
|
|
483
499
|
return text(name, min, max).refine(
|
|
@@ -576,11 +592,10 @@ var listOrdersInput = strictInput({
|
|
|
576
592
|
),
|
|
577
593
|
locale: locale.optional()
|
|
578
594
|
});
|
|
579
|
-
var maximumPenaltyError = "maximumPenalty must be a number of 0 or more: the order's cancel.penalty.amount, such as 12.5 for 12.50";
|
|
580
595
|
var cancelOrderInput = strictInput({
|
|
581
596
|
orderId: orderId.describe("The orderId of the order to cancel."),
|
|
582
|
-
maximumPenalty:
|
|
583
|
-
|
|
597
|
+
maximumPenalty: echoedMoney("maximumPenalty").optional().describe(
|
|
598
|
+
"The penalty the user agreed to: the order's cancel.penalty, exactly as returned. Ignored when closing an unpaid order."
|
|
584
599
|
)
|
|
585
600
|
});
|
|
586
601
|
var sharedPaymentTokenRe = /^spt_[A-Za-z0-9]{1,250}$/;
|
|
@@ -606,7 +621,7 @@ var ucpInstrument = z5.looseObject(
|
|
|
606
621
|
"The credential type: stripe_payment_token for the selected one."
|
|
607
622
|
),
|
|
608
623
|
token: z5.string({ error: instrumentTokenError }).optional().describe(
|
|
609
|
-
"The shared payment token (spt_\u2026) the user approved for this order, requested with the order's
|
|
624
|
+
"The shared payment token (spt_\u2026) the user approved for this order, requested with the limits of the order's stripe_shared_payment_token method."
|
|
610
625
|
)
|
|
611
626
|
},
|
|
612
627
|
{ error: "credential must be a JSON object" }
|
|
@@ -638,16 +653,16 @@ function selectedOf(instruments) {
|
|
|
638
653
|
}
|
|
639
654
|
return chosen;
|
|
640
655
|
}
|
|
641
|
-
var PAY_WAYS = ["payment_link", "
|
|
656
|
+
var PAY_WAYS = ["payment_link", "stripe_shared_payment_token", "stripe_alipay_wechat_pay"];
|
|
642
657
|
var PAY_INPUT_WAYS = {
|
|
643
|
-
sharedPaymentToken: "
|
|
644
|
-
payment: "
|
|
645
|
-
method: "
|
|
658
|
+
sharedPaymentToken: "stripe_shared_payment_token",
|
|
659
|
+
payment: "stripe_shared_payment_token",
|
|
660
|
+
method: "stripe_alipay_wechat_pay"
|
|
646
661
|
};
|
|
647
662
|
var payOrderInput = strictInput({
|
|
648
663
|
orderId: orderId.describe("The orderId of the order to pay."),
|
|
649
664
|
sharedPaymentToken: z5.string({ error: sharedPaymentTokenError }).regex(sharedPaymentTokenRe, { error: sharedPaymentTokenError }).optional().describe(
|
|
650
|
-
"The shared payment token (spt_\u2026) the user approved for this order, requested with the order's
|
|
665
|
+
"The shared payment token (spt_\u2026) the user approved for this order, requested with the limits of the order's stripe_shared_payment_token method. Exactly one of sharedPaymentToken, payment and method."
|
|
651
666
|
),
|
|
652
667
|
payment: strictInput({
|
|
653
668
|
instruments: z5.array(ucpInstrument, { error: instrumentsError }).min(1, { error: instrumentsError }).max(8, { error: instrumentsError }).describe("The instruments, exactly one of them selected.")
|
|
@@ -685,11 +700,11 @@ var payOrderInput = strictInput({
|
|
|
685
700
|
}).optional().describe(
|
|
686
701
|
"UCP's Complete Checkout payment, in place of sharedPaymentToken: the token as the stripe_payment_token credential of the one selected stripe_payments card instrument. Exactly one of sharedPaymentToken, payment and method."
|
|
687
702
|
),
|
|
688
|
-
method: oneOf("method", ["
|
|
689
|
-
"Pay
|
|
703
|
+
method: oneOf("method", ["stripe_alipay_wechat_pay"]).optional().describe(
|
|
704
|
+
"Pay by a method in payment.methods other than the token, which is paid with sharedPaymentToken or payment. Exactly one of sharedPaymentToken, payment and method."
|
|
690
705
|
),
|
|
691
|
-
total:
|
|
692
|
-
"The total the user approved: the order's price.total, exactly as returned."
|
|
706
|
+
total: requestMoney("total").describe(
|
|
707
|
+
"The total the user approved: the order's price.total, in its currency, exactly as returned."
|
|
693
708
|
)
|
|
694
709
|
}).superRefine((input, ctx) => {
|
|
695
710
|
const given = [
|
|
@@ -766,11 +781,11 @@ var localeFlag = {
|
|
|
766
781
|
type: "string",
|
|
767
782
|
placeholder: LOCALES
|
|
768
783
|
};
|
|
769
|
-
var
|
|
770
|
-
flag: "
|
|
771
|
-
field: "
|
|
784
|
+
var currencyFlag = {
|
|
785
|
+
flag: "currency",
|
|
786
|
+
field: "currency",
|
|
772
787
|
type: "string",
|
|
773
|
-
placeholder:
|
|
788
|
+
placeholder: CURRENCIES.join("|")
|
|
774
789
|
};
|
|
775
790
|
function stayFlags(roomDescription) {
|
|
776
791
|
return [
|
|
@@ -872,8 +887,8 @@ var searchFlags = flagsOf(searchHotelsInput, [
|
|
|
872
887
|
flag: "price-max-per-room-night",
|
|
873
888
|
field: "filters.price.maxPerRoomNight",
|
|
874
889
|
type: "string",
|
|
875
|
-
placeholder: "<
|
|
876
|
-
description: "Highest indicative price per room per night, in USD, e.g. `150` or `149.50`. Needs a stay."
|
|
890
|
+
placeholder: "<decimal>",
|
|
891
|
+
description: "Highest indicative price per room per night, in the search's currency (`--currency`, else USD), e.g. `150` or `149.50`. Needs a stay."
|
|
877
892
|
},
|
|
878
893
|
{
|
|
879
894
|
flag: "sort",
|
|
@@ -890,7 +905,7 @@ var searchFlags = flagsOf(searchHotelsInput, [
|
|
|
890
905
|
description: "`nextCursor` from the previous page. A next page takes only `--cursor` and `--limit`."
|
|
891
906
|
},
|
|
892
907
|
localeFlag,
|
|
893
|
-
|
|
908
|
+
currencyFlag
|
|
894
909
|
]);
|
|
895
910
|
var hotelFlags = flagsOf(getHotelInput, [
|
|
896
911
|
{
|
|
@@ -922,7 +937,7 @@ var offersFlags = flagsOf(hotelOffersInput, [
|
|
|
922
937
|
},
|
|
923
938
|
{ flag: "limit-per-hotel", field: "limitPerHotel", type: "number", placeholder: COUNT },
|
|
924
939
|
localeFlag,
|
|
925
|
-
|
|
940
|
+
currencyFlag
|
|
926
941
|
]);
|
|
927
942
|
var bookFlags = flagsOf(createOrderInput, [
|
|
928
943
|
{
|
|
@@ -961,9 +976,9 @@ var cancelFlags = flagsOf(cancelOrderInput, [
|
|
|
961
976
|
{
|
|
962
977
|
flag: "max-penalty",
|
|
963
978
|
field: "maximumPenalty",
|
|
964
|
-
type: "
|
|
979
|
+
type: "string",
|
|
965
980
|
placeholder: "<amount>",
|
|
966
|
-
description: "
|
|
981
|
+
description: "To cancel a paid order: the penalty the user agreed to, exactly as `orders get` shows it, in the order's currency, e.g. `12.50`. Without it or --close, the command changes nothing: it shows the penalty and the refund, or that the order can be closed."
|
|
967
982
|
}
|
|
968
983
|
]);
|
|
969
984
|
var payFlags = flagsOf(payOrderInput, [
|
|
@@ -972,22 +987,22 @@ var payFlags = flagsOf(payOrderInput, [
|
|
|
972
987
|
field: "sharedPaymentToken",
|
|
973
988
|
type: "string",
|
|
974
989
|
placeholder: "<spt_\u2026>",
|
|
975
|
-
description: "Required unless --
|
|
990
|
+
description: "Required unless --method. The spt_\u2026 token the user's Link wallet issued for this order. For agents that can request a token from the user's Link wallet; people pay by the order's link or --method."
|
|
976
991
|
},
|
|
977
992
|
{
|
|
978
|
-
flag: "
|
|
993
|
+
flag: "method",
|
|
979
994
|
field: "method",
|
|
980
|
-
type: "
|
|
981
|
-
|
|
982
|
-
description: "Pay
|
|
995
|
+
type: "string",
|
|
996
|
+
placeholder: "stripe_alipay_wechat_pay",
|
|
997
|
+
description: "Pay by a method in the order's payment.methods instead of a token: stripe_alipay_wechat_pay is Alipay or WeChat Pay, and prints the WeChat Pay code and both links."
|
|
983
998
|
},
|
|
984
999
|
{
|
|
985
1000
|
flag: "total",
|
|
986
1001
|
field: "total",
|
|
987
1002
|
type: "string",
|
|
988
|
-
placeholder: "<
|
|
1003
|
+
placeholder: "<decimal>",
|
|
989
1004
|
required: "always",
|
|
990
|
-
description: "The total the user approved, exactly as `orders get` shows it, in
|
|
1005
|
+
description: "The total the user approved, exactly as `orders get` shows it, in the order's currency, e.g. `125.00`."
|
|
991
1006
|
}
|
|
992
1007
|
]);
|
|
993
1008
|
var BODY_OPTION = {
|
|
@@ -1051,15 +1066,22 @@ var COMMANDS = [
|
|
|
1051
1066
|
{
|
|
1052
1067
|
group: "orders",
|
|
1053
1068
|
name: "cancel",
|
|
1054
|
-
summary: "
|
|
1069
|
+
summary: "With the penalty the user agreed to (--max-penalty) it cancels a paid order under its terms, and --close closes an unpaid one; with neither it changes nothing and shows what the order allows",
|
|
1055
1070
|
tool: "cancel_order",
|
|
1056
1071
|
flags: cancelFlags,
|
|
1057
|
-
positionals: [positional(cancelOrderInput, "orderId")]
|
|
1072
|
+
positionals: [positional(cancelOrderInput, "orderId")],
|
|
1073
|
+
options: [
|
|
1074
|
+
{
|
|
1075
|
+
flag: "close",
|
|
1076
|
+
type: "boolean",
|
|
1077
|
+
description: "Close an unpaid order (cancel.reason unpaid), only once the user says they no longer want it: nothing is charged, and it becomes expired. Nothing is sent for an order that can't be closed."
|
|
1078
|
+
}
|
|
1079
|
+
]
|
|
1058
1080
|
},
|
|
1059
1081
|
{
|
|
1060
1082
|
group: "orders",
|
|
1061
1083
|
name: "pay",
|
|
1062
|
-
summary: "Pay an order with a Link
|
|
1084
|
+
summary: "Pay an order with a Link token (US and Canada) or with Alipay or WeChat Pay, instead of its payment link",
|
|
1063
1085
|
tool: "pay_order",
|
|
1064
1086
|
flags: payFlags,
|
|
1065
1087
|
positionals: [positional(payOrderInput, "orderId")]
|
|
@@ -1092,21 +1114,6 @@ var COMMANDS = [
|
|
|
1092
1114
|
tool: null,
|
|
1093
1115
|
flags: []
|
|
1094
1116
|
},
|
|
1095
|
-
{
|
|
1096
|
-
group: null,
|
|
1097
|
-
name: "guide",
|
|
1098
|
-
summary: "Print the guide for AI agents (Markdown); `fortrip guide planning` prints the planning guide",
|
|
1099
|
-
tool: "get_planning_guide",
|
|
1100
|
-
flags: [],
|
|
1101
|
-
positionals: [
|
|
1102
|
-
{
|
|
1103
|
-
name: "topic",
|
|
1104
|
-
field: null,
|
|
1105
|
-
optional: true,
|
|
1106
|
-
description: "`planning` for the planning guide; left out, the main guide."
|
|
1107
|
-
}
|
|
1108
|
-
]
|
|
1109
|
-
},
|
|
1110
1117
|
{
|
|
1111
1118
|
group: null,
|
|
1112
1119
|
name: "mcp",
|
|
@@ -1259,17 +1266,17 @@ function strictify(schema) {
|
|
|
1259
1266
|
// src/guide-data.generated.ts
|
|
1260
1267
|
var FRAGMENTS = {
|
|
1261
1268
|
"booking": "{{#if claude-skill cli}}\n## Ordering\n\n{{/if}}\n- Call `{{tool:hotels book}}` only for the offer the user picked, with at least one guest per room{{#if claude-skill cli}}, named as the user gave them{{/if}}; never invent guests.{{#if claude-skill cli}} Room 1 is the offer's first room, and a room takes no more guests than it sleeps.{{/if}}\n- Guest names: Latin letters as on the passport (M\xFCller \u2192 Mueller), first and last name 1\u2013{{limit:guestName}} characters each{{#if cli}}, as `--guest 1:John:Smith` (room 1, first name, last name){{/if}}.\n{{#if claude-skill cli}}\n- The contact's first and last name (up to {{limit:contactFirstName}} characters each), email and phone (with its country code) are all required. Special requests must be in English and aren't guaranteed.\n{{/if}}\n- `{{tool:hotels book}}` can take about two minutes{{#if cli}}: allow the command at least 3 minutes{{/if}}. If it times out, {{#if cli}}run it again with identical flags{{/if}}{{#if mcp claude-skill}}call it again with the same details{{/if}}: it returns the same order.\n{{#if mcp}}\n- On `offer_changed`, show the user every change and ask again before ordering the new offer.\n{{/if}}\n{{#if cli}}\n- `{{tool:hotels book}}` takes only these fields: a `--body` with any other field (such as `nationality`) is rejected with exit 2.\n{{/if}}\n",
|
|
1262
|
-
"errors": "{{#if claude-skill cli}}\n## Errors\n\n{{#if claude-skill}}A tool error{{/if}}{{#if cli}}An error on stderr{{/if}} carries `code`, `message` and `retryable`, and `retryAfterSeconds` when waiting helps; many carry `details`. Search errors are under Search. Ordering errors:\n\n| `code` | Do this |\n|---|---|\n| `offer_changed` (409) | The price or terms changed since the offer: `changes` lists every change (`worse` says which are worse for the user) and `offer` is the new offer. Show the user every change and ask again; if they still want it, order the new offer, and confirm the new order before giving its link |\n| `offer_expired` (409) | Get offers again and let the user choose again |\n| `offer_unavailable` (422) | The offer is sold out or was refused: get offers again and let the user choose again |\n| `order_in_progress` (409) | The same order is still being created: wait `retryAfterSeconds`, then {{#if claude-skill}}call again with the same details{{/if}}{{#if cli}}run the command again with identical flags{{/if}} |\n| `offer_already_ordered` (409) | This offer was already ordered with other details: show that order (`orderId`) instead. An offer is ordered once |\n| `order_exists` (409) | This stay already has an open order for one of these guests (`orderId`, `status`): show it instead of ordering again. A party with none of its guests can order the stay from a new offer (get offers again), and so can the user once the stay's order is confirmed, cancelled or refused by the hotel. It also answers when the stay's earlier order failed at the hotel with its outcome unknown, or the stay has had {{limit:ordersPerStay}} orders; for those, the user emails {{support}} |\n| `order_attempts_exhausted` (409) | This order can't be tried again: the user emails {{support}} with its `reference` |\n| `order_removed` (410) | The order was never completed and no payment is held: get offers again and order the new offer (the order keeps its `orderId`) |\n| `stay_unsupported` (422) | `mixed_occupancy`: order once per party; `max_nights`: at most `max` nights per order |\n| `stay_in_past` (422) | Check-in has passed in the hotel's time zone: ask for new dates |\n| `ordering_paused` (503) | Ordering is paused on Fortrip's side: tell the user, and try again only after `retryAfterSeconds`
|
|
1269
|
+
"errors": "{{#if claude-skill cli}}\n## Errors\n\n{{#if claude-skill}}A tool error{{/if}}{{#if cli}}An error on stderr{{/if}} carries `code`, `message` and `retryable`, and `retryAfterSeconds` when waiting helps; many carry `details`. Search errors are under Search. Ordering errors:\n\n| `code` | Do this |\n|---|---|\n| `offer_changed` (409) | The price or terms changed since the offer: `changes` lists every change (`worse` says which are worse for the user) and `offer` is the new offer. Show the user every change and ask again; if they still want it, order the new offer, and confirm the new order before giving its link |\n| `offer_expired` (409) | Get offers again and let the user choose again |\n| `offer_unavailable` (422) | The offer is sold out or was refused: get offers again and let the user choose again |\n| `order_in_progress` (409) | The same order is still being created: wait `retryAfterSeconds`, then {{#if claude-skill}}call again with the same details{{/if}}{{#if cli}}run the command again with identical flags{{/if}} |\n| `offer_already_ordered` (409) | This offer was already ordered with other details: show that order (`orderId`) instead. An offer is ordered once |\n| `order_exists` (409) | This stay already has an open order for one of these guests (`orderId`, `status`): show it instead of ordering again. A party with none of its guests can order the stay from a new offer (get offers again), and so can the user once the stay's order is confirmed, cancelled or refused by the hotel. It also answers when the stay's earlier order failed at the hotel with its outcome unknown, or the stay has had {{limit:ordersPerStay}} orders; for those, the user emails {{support}} |\n| `order_attempts_exhausted` (409) | This order can't be tried again: the user emails {{support}} with its `reference` |\n| `order_removed` (410) | The order was never completed and no payment is held: get offers again and order the new offer (the order keeps its `orderId`) |\n| `stay_unsupported` (422) | `mixed_occupancy`: order once per party; `max_nights`: at most `max` nights per order |\n| `currency_unavailable` (422) | Prices in `details.currency` aren't available yet: tell the user, and ask whether to see USD prices |\n| `stay_in_past` (422) | Check-in has passed in the hotel's time zone: ask for new dates |\n| `ordering_paused` (503) | Ordering is paused on Fortrip's side: tell the user, and try again only after `retryAfterSeconds` |\n\nAny code:\n\n- `invalid_request` (400): `details.issues` lists each bad field; fix them. For amenities, `details.filterable` lists those that can filter.\n- `cursor_invalid` (400): the page is gone; search again from the first page.\n- `not_found` (404): no such hotel, or no such order for this user.\n- `rate_limited` (429): wait `retryAfterSeconds`, then retry once.\n- `service_unavailable` (503) and `supplier_unavailable` (503 or 504): wait `retryAfterSeconds`, then retry once with the same details; if it fails again, tell the user.\n- Any other code: read `message`. If `retryable` is true, wait `retryAfterSeconds` and retry once; otherwise tell the user instead of guessing.\n{{/if}}\n",
|
|
1263
1270
|
"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',
|
|
1264
1271
|
"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",
|
|
1265
|
-
"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
|
|
1266
|
-
"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
|
|
1267
|
-
"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}}
|
|
1268
|
-
"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
|
|
1269
|
-
"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
|
|
1270
|
-
"scope": "{{#if claude-skill cli}}\n# Fortrip hotel stays\n\n{{/if}}\nFortrip: hotel search, live offers and orders with a payment link.{{#if claude-skill cli}} Not for flights, activities, or changing an existing order.{{/if}}\n\n{{#if mcp}}\nCall order: `{{tool:hotels search}}` \u2192 (optional) `{{tool:hotels get}}` \u2192 `{{tool:hotels offers}}` \u2192 `{{tool:hotels book}}`; after the user pays, `{{tool:orders get}}`; `{{tool:orders list}}` lists, `{{tool:orders cancel}}` cancels, `{{tool:orders pay}}` pays by token or Alipay/WeChat Pay
|
|
1271
|
-
"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
|
|
1272
|
-
"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`)
|
|
1272
|
+
"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, in `hub`, the locality it belongs to: search that locality, 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 the search\'s currency; hotels without one are left out and counted.\n\n### Results\n\n- `notes` explain the answer (a limited pool, a circle around an island, more hotels just outside it): pass on what matters to the user.\n- `coverage` has the counts: `matched` hotels, how many were priced and how many have a price.\n- A next page is {{#if mcp claude-skill}}`cursor` set to `nextCursor` and, optionally, `limit`{{/if}}{{#if cli}}`--cursor <nextCursor>` and, optionally, `--limit`{{/if}}; nothing else.\n{{/if}}\n{{#if mcp}}\n- A place name needs its `countryCode` (ask the user if unclear) and matches exactly (accents and periods count). On `destination_ambiguous`, ask the user which they mean, then search its `placeId`; never pick one yourself.\n- On `search_too_broad`, show its `localities` and ask the user which, unless they already named one; search it as `{ kind: "locality", placeId }`, never by name.\n- `text` matches whole words of hotel names and addresses: use a distinctive name, brand or landmark.\n{{/if}}\n',
|
|
1273
|
+
"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 the payment provider. 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, or can be closed now with `{{tool:orders cancel}}`{{#if cli}} and `--close`{{/if}} once the user says they no longer want it.\n- An order `awaiting_payment` with `payment.status` `unpaid` 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.methods` has the `stripe_shared_payment_token` entry (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 ${{limit:tokenPaymentMaxUsd}}, so only a USD order up to that has such an entry. 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 that entry's `handler.config.business_profile` and its `limits`: `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 that entry's `limits`. `service_unavailable`: call `{{tool:orders pay}}` again with the same token, never a new one. A token pays one order only.\n\n## Paying with Alipay or WeChat Pay\n\nAn order whose result text has the line \"Pay with Alipay or WeChat Pay\" can be paid in the user's Alipay or WeChat wallet, with no token: it is for users who have a mainland-China wallet. {{#if claude-skill}}Call{{/if}}{{#if cli}}Run{{/if}} `{{tool:orders pay}}` {{#if claude-skill}}with `method` `stripe_alipay_wechat_pay`{{/if}}{{#if cli}}the way that line shows{{/if}} and the order's `price.total`, only after the user has confirmed.\n\n1. Show the user the order's total 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. Pay one way only: `payment.url` or this.\n2. Then show the `stripe_alipay_wechat_pay` entry of `payment.methods`: the WeChat Pay code as an image if you can, and both links (WeChat Pay and Alipay). The user pays once, by either. Alipay and WeChat Pay charge at once; if the hotel can't confirm, the payment is refunded in full. The total is in the order's currency, and the wallets show it in yuan at their rate.\n3. Check the order with `{{tool:orders get}}` until it isn't `awaiting_payment`.\n\nA WeChat Pay code expires {{limit:wechatCodeMinutes}} minutes after it is made, and goes dead earlier if the user opens the Alipay link instead. Then that entry's `wechatPay.qrData` is null: tell the user to open the WeChat link again, or {{#if claude-skill}}call{{/if}}{{#if cli}}run{{/if}} `{{tool:orders pay}}` again for a new code.\n\nWeChat can't scan a code shown on the same phone's screen. Offer both ways, since you can't tell which device the user is on: save the image and scan it from the album (WeChat, then Scan, then Album), or open the WeChat link on another screen; on a phone, the Alipay link opens the Alipay app.\n\n## After payment\n\nCheck the order with `{{tool:orders get}}`:\n\n- `confirming` while the hotel confirms, then `confirmed` with the hotel's `confirmationNumber`.\n- `failed`: no stay was booked; `payment.status` says whether the payment was released or refunded.\n- `needs_attention`: Fortrip is looking into it; the user can email {{support}} with the `reference`.\n- `manageUrl` is the user's own page for the order.\n{{/if}}\n",
|
|
1274
|
+
"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 cli}}SKILL.md{{/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, 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 the offer's currency.\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",
|
|
1275
|
+
"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 its currency, 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",
|
|
1276
|
+
"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 the request's `{{arg:currency}}` (`USD` by default); an order is in the currency of the offer it was made from.{{#if claude-skill cli}} `perNightAllRooms` is the total per night; to compare with a per-room budget, also divide by the rooms.{{/if}} On a USD order, 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 total in that currency is the price{{/if}}.\n{{#if claude-skill cli}}\n- Every price of a response is in that one currency; don't convert it. `{{arg:currency}}`{{#if cli}} (or `FORTRIP_CURRENCY`){{/if}} is `USD` (the default) or `CNY`, where available; otherwise the answer is `currency_unavailable`.\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",
|
|
1277
|
+
"scope": "{{#if claude-skill cli}}\n# Fortrip hotel stays\n\n{{/if}}\nFortrip: hotel search, live offers and orders with a payment link.{{#if claude-skill cli}} Not for flights, activities, or changing an existing order.{{/if}}\n\n{{#if mcp}}\nCall order: `{{tool:hotels search}}` \u2192 (optional) `{{tool:hotels get}}` \u2192 `{{tool:hotels offers}}` \u2192 `{{tool:hotels book}}`; after the user pays, `{{tool:orders get}}`; `{{tool:orders list}}` lists, `{{tool:orders cancel}}` cancels or closes an unpaid one, `{{tool:orders pay}}` pays by token or Alipay/WeChat Pay.\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 and currency, 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; closes an unpaid one |\n| `{{tool:orders pay}}` | Pays an order without its link, by a shared payment token from the user's wallet, or with Alipay or WeChat Pay |\n\nFor flexible dates, a budget, split stays, several destinations or \"find me the best\", read [references/planning.md](references/planning.md) before searching.\n{{/if}}\n",
|
|
1278
|
+
"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 a remote agent environment or a CI run 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",
|
|
1279
|
+
"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`). A paid order (`cancel.reason` `cancellable`) then has the penalty under its terms (`cancel.penalty`) and the refund, what was paid less the penalty (`cancel.refund`), both in the charge currency; an unpaid one (`unpaid`) can be closed instead. 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` as shown{{#if cli}}, its amount: the CLI takes the currency from the order{{/if}}. 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`.\n\nClose an unpaid order only once the user says they no longer want it: {{#if claude-skill}}call{{/if}}{{#if cli}}run{{/if}} `{{tool:orders cancel}}` {{#if claude-skill}}without `maximumPenalty`{{/if}}{{#if cli}}with `--close`{{/if}}. It becomes `expired`, and nothing is charged. `payment_in_progress` (409) means a payment of it is under way: read it again shortly.{{#if cli}} Without `--max-penalty` or `--close`, `{{tool:orders cancel}}` changes nothing: it prints the penalty and the refund, or that the order can be closed, 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"
|
|
1273
1280
|
};
|
|
1274
1281
|
|
|
1275
1282
|
// src/guide.ts
|
|
@@ -1377,7 +1384,7 @@ function resolve(token, surface, shown) {
|
|
|
1377
1384
|
}
|
|
1378
1385
|
function toolName(spec, surface, token) {
|
|
1379
1386
|
if (surface === "cli") return commandInvocation(spec);
|
|
1380
|
-
if (spec.tool === null
|
|
1387
|
+
if (spec.tool === null) {
|
|
1381
1388
|
throw new Error(`Guide token ${token} has no tool on ${surface}`);
|
|
1382
1389
|
}
|
|
1383
1390
|
return surface === "mcp" ? spec.tool : `fortrip:${spec.tool}`;
|
|
@@ -1463,6 +1470,7 @@ var ERROR_CODES = {
|
|
|
1463
1470
|
stay_unsupported: { status: [422], retryable: false },
|
|
1464
1471
|
stay_in_past: { status: [422], retryable: false },
|
|
1465
1472
|
offer_unavailable: { status: [422], retryable: false },
|
|
1473
|
+
currency_unavailable: { status: [422], retryable: false },
|
|
1466
1474
|
rate_limited: { status: [429], retryable: true },
|
|
1467
1475
|
ordering_paused: { status: [503], retryable: true },
|
|
1468
1476
|
service_unavailable: { status: [503], retryable: true },
|
|
@@ -1541,12 +1549,7 @@ var indicativePrice = openObject({
|
|
|
1541
1549
|
kind: openEnum(["indicative"]),
|
|
1542
1550
|
basis: openEnum(["lowest_unit"]),
|
|
1543
1551
|
fromPerRoomNight: money,
|
|
1544
|
-
fromPerRoomStay: money
|
|
1545
|
-
approx: openObject({
|
|
1546
|
-
fromPerRoomNight: money,
|
|
1547
|
-
fromPerRoomStay: money,
|
|
1548
|
-
rateDate: localDate
|
|
1549
|
-
}).nullable()
|
|
1552
|
+
fromPerRoomStay: money
|
|
1550
1553
|
});
|
|
1551
1554
|
var hotelSummary = openObject({
|
|
1552
1555
|
hotelId,
|
|
@@ -1606,6 +1609,7 @@ var destination2 = openUnion("kind", [
|
|
|
1606
1609
|
})
|
|
1607
1610
|
]);
|
|
1608
1611
|
var count = z11.number().int();
|
|
1612
|
+
var hotels = (what) => count.nullable().describe(what);
|
|
1609
1613
|
var searchResult = openObject({
|
|
1610
1614
|
destination: destination2.nullable(),
|
|
1611
1615
|
text: openObject({
|
|
@@ -1626,17 +1630,31 @@ var searchResult = openObject({
|
|
|
1626
1630
|
"price_desc"
|
|
1627
1631
|
]),
|
|
1628
1632
|
coverage: openObject({
|
|
1629
|
-
matched: count
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1633
|
+
matched: count.describe(
|
|
1634
|
+
"Hotels that match the destination, the text and every filter but the price filter."
|
|
1635
|
+
),
|
|
1636
|
+
priced: hotels(
|
|
1637
|
+
"Hotels priced: those on this page, or with a price sort or price filter the whole priced set (pricing.scope); null without prices."
|
|
1638
|
+
),
|
|
1639
|
+
withPrice: hotels("Of those priced, how many have an indicative price; null when prices weren't asked for or are unavailable."),
|
|
1640
|
+
poolRadiusMeters: z11.number().nullable().describe(
|
|
1641
|
+
`When a price sort or price filter priced only the nearest ${LIMITS.poolLimit.toLocaleString("en-US")}: how far the farthest of them is from the center, in meters; otherwise null.`
|
|
1642
|
+
),
|
|
1643
|
+
excludedNoPrice: hotels("With a price filter: priced hotels left out for having no indicative price; otherwise null."),
|
|
1644
|
+
excludedNoFacilityData: hotels(
|
|
1645
|
+
"With an amenity filter: hotels left out for listing no facilities at all, though they may have the amenity; otherwise null."
|
|
1646
|
+
),
|
|
1647
|
+
withinMaxRadius: hotels(
|
|
1648
|
+
`For a radius under ${LIMITS.radiusMetersMax.toLocaleString("en-US")} m: how many would match within ${LIMITS.radiusMetersMax.toLocaleString("en-US")} m of the center; otherwise null.`
|
|
1649
|
+
),
|
|
1650
|
+
textAnywhere: hotels(
|
|
1651
|
+
"With text and a place: the hotels that match the text anywhere in the place's country; otherwise null."
|
|
1652
|
+
),
|
|
1653
|
+
localities: localities.nullable().describe("For an area: its top localities, the towns its matching hotels belong to; otherwise null."),
|
|
1654
|
+
nameAsText: hotels(
|
|
1655
|
+
"When a place_name search matched few hotels: how many in its country match the name as text; otherwise null."
|
|
1656
|
+
)
|
|
1657
|
+
}).describe("What the search covered: counts of hotels, each null when it doesn't apply."),
|
|
1640
1658
|
data: z11.array(hotelSummary),
|
|
1641
1659
|
nextCursor: z11.string().nullable().describe("Pass it back as cursor for the next page; null on the last page."),
|
|
1642
1660
|
notes: z11.array(
|
|
@@ -1722,11 +1740,17 @@ var hotel = openObject({
|
|
|
1722
1740
|
var meals = openObject({
|
|
1723
1741
|
known: z13.boolean(),
|
|
1724
1742
|
included: z13.array(openEnum(["breakfast", "lunch", "dinner"])).nullable(),
|
|
1725
|
-
unspecifiedMainMeals: z13.number().int().nullable()
|
|
1743
|
+
unspecifiedMainMeals: z13.number().int().nullable().describe(
|
|
1744
|
+
"Main meals a day beyond included that the rate doesn't name (e.g. 1 when a half-board rate doesn't say lunch or dinner); null when known is false."
|
|
1745
|
+
),
|
|
1726
1746
|
allInclusive: z13.boolean().nullable(),
|
|
1727
|
-
guestsCoveredPerRoom: z13.number().int().nullable()
|
|
1747
|
+
guestsCoveredPerRoom: z13.number().int().nullable().describe(
|
|
1748
|
+
"How many guests in each room the meals are for; fewer than the guests in the room means not everyone gets them. null when not stated."
|
|
1749
|
+
),
|
|
1728
1750
|
label: localizedText.nullable()
|
|
1729
|
-
})
|
|
1751
|
+
}).describe(
|
|
1752
|
+
"What the rate includes to eat. known false: the meals are unknown, not none, and included, unspecifiedMainMeals and allInclusive are null."
|
|
1753
|
+
);
|
|
1730
1754
|
var payAtProperty = openObject({
|
|
1731
1755
|
disclosure: openEnum(["complete", "incomplete"]),
|
|
1732
1756
|
items: z13.array(
|
|
@@ -1744,20 +1768,24 @@ var payAtProperty = openObject({
|
|
|
1744
1768
|
collectedAt: openEnum(["property", "unknown"])
|
|
1745
1769
|
})
|
|
1746
1770
|
)
|
|
1747
|
-
})
|
|
1771
|
+
}).describe(
|
|
1772
|
+
"Fees paid at the property, on top of price.total, in the property's currency, not converted. disclosure incomplete: there may be fees not listed."
|
|
1773
|
+
);
|
|
1748
1774
|
var cancellation = openObject({
|
|
1749
1775
|
status: openEnum(["free", "partial_penalty", "non_refundable", "unknown"]),
|
|
1750
|
-
asOf: instant,
|
|
1776
|
+
asOf: instant.describe("When these terms were read: status and penalties are as of this time."),
|
|
1751
1777
|
freeCancellationEndsAt: instant.nullable(),
|
|
1752
1778
|
penalties: z13.array(
|
|
1753
1779
|
openObject({ startsAt: instant.nullable(), amount: money })
|
|
1754
1780
|
),
|
|
1755
1781
|
timeZone: z13.string().nullable()
|
|
1756
|
-
});
|
|
1782
|
+
}).describe("The cancellation terms, read at asOf.");
|
|
1757
1783
|
var confirmation = openObject({
|
|
1758
|
-
mode: openEnum(["instant", "on_request", "unknown"])
|
|
1759
|
-
|
|
1760
|
-
|
|
1784
|
+
mode: openEnum(["instant", "on_request", "unknown"]).describe(
|
|
1785
|
+
"instant: the hotel confirms the booking as soon as it is made. on_request: the hotel confirms or refuses it later, within withinMinutes when stated. unknown: not stated."
|
|
1786
|
+
),
|
|
1787
|
+
withinMinutes: z13.number().int().nullable().describe("For on_request, the minutes the hotel takes to confirm; null when instant or not stated.")
|
|
1788
|
+
}).describe("How the hotel confirms a booking of this offer.");
|
|
1761
1789
|
var offer = openObject({
|
|
1762
1790
|
offerId,
|
|
1763
1791
|
type: openEnum(["hotel"]),
|
|
@@ -1770,24 +1798,26 @@ var offer = openObject({
|
|
|
1770
1798
|
}),
|
|
1771
1799
|
price: openObject({
|
|
1772
1800
|
total: money,
|
|
1773
|
-
perNightAllRooms: money
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
perNightAllRooms: money,
|
|
1777
|
-
rateDate: localDate
|
|
1778
|
-
}).nullable(),
|
|
1801
|
+
perNightAllRooms: money.describe(
|
|
1802
|
+
"price.total divided by the nights: all rooms, one night. A search's fromPerRoomNight is for one room; divide by roomCount to compare."
|
|
1803
|
+
),
|
|
1779
1804
|
payAtProperty
|
|
1780
1805
|
}),
|
|
1781
1806
|
cancellation,
|
|
1782
1807
|
confirmation
|
|
1783
1808
|
});
|
|
1809
|
+
var removed = (step) => z13.number().int().describe(`Offers left out ${step}.`);
|
|
1784
1810
|
var omitted = openObject({
|
|
1785
|
-
byNationality:
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1811
|
+
byNationality: removed(
|
|
1812
|
+
"because the hotel sells them only to guests of some nationalities; Fortrip can't book them"
|
|
1813
|
+
),
|
|
1814
|
+
byFilters: removed("by filters"),
|
|
1815
|
+
dominated: removed(
|
|
1816
|
+
"because another offer of the same room is as good on price and every term, or can't be told apart from one kept"
|
|
1817
|
+
),
|
|
1818
|
+
unreadable: removed("because their details came back incomplete or inconsistent"),
|
|
1819
|
+
byLimit: removed("by limitPerHotel")
|
|
1820
|
+
}).describe("How many offers each selection step left out.");
|
|
1791
1821
|
var UNAVAILABLE_REASONS = [
|
|
1792
1822
|
"sold_out",
|
|
1793
1823
|
"no_matching_offers",
|
|
@@ -1809,7 +1839,9 @@ var hotelOffersResult = openObject({
|
|
|
1809
1839
|
unavailable: z13.array(
|
|
1810
1840
|
openObject({
|
|
1811
1841
|
hotelId,
|
|
1812
|
-
reason: openEnum(UNAVAILABLE_REASONS)
|
|
1842
|
+
reason: openEnum(UNAVAILABLE_REASONS).describe(
|
|
1843
|
+
"Why the hotel has no offers: sold_out (nothing left for the stay), no_matching_offers (the filters left none), nationality_restricted (the hotel sells this stay only to guests of some nationalities; Fortrip can't book it), offers_unreadable (its offers came back incomplete or inconsistent), not_found (Fortrip has no bookable hotel with this hotelId), supplier_unavailable (offers couldn't be fetched this time; try again), stay_in_past (check-in has passed in the hotel's time zone)."
|
|
1844
|
+
),
|
|
1813
1845
|
omitted: omitted.nullable()
|
|
1814
1846
|
})
|
|
1815
1847
|
)
|
|
@@ -1837,6 +1869,7 @@ var PAYMENT_STATUSES = [
|
|
|
1837
1869
|
];
|
|
1838
1870
|
var CANCEL_REASONS = [
|
|
1839
1871
|
"cancellable",
|
|
1872
|
+
"unpaid",
|
|
1840
1873
|
"already_cancelled",
|
|
1841
1874
|
"in_progress",
|
|
1842
1875
|
"not_confirmed",
|
|
@@ -1869,6 +1902,39 @@ var paymentHandler = openObject({
|
|
|
1869
1902
|
business_profile: z14.string()
|
|
1870
1903
|
})
|
|
1871
1904
|
});
|
|
1905
|
+
var PAYMENT_METHOD_IDS = ["stripe_shared_payment_token", "stripe_alipay_wechat_pay"];
|
|
1906
|
+
var paymentMethod = openUnion("id", [
|
|
1907
|
+
openObject({
|
|
1908
|
+
id: z14.literal("stripe_shared_payment_token"),
|
|
1909
|
+
handler: paymentHandler.describe("The com.stripe.payments handler, which takes the token."),
|
|
1910
|
+
limits: openObject({
|
|
1911
|
+
maxAmount: z14.number().int().describe("Request the token for at least this amount, in cents; a token that allows less can't pay."),
|
|
1912
|
+
currency: z14.string().describe("The token's currency, lowercase as Stripe takes it: usd."),
|
|
1913
|
+
expiresAt: instant.describe(
|
|
1914
|
+
"Request the token valid until at least this time; the order can't be paid after it."
|
|
1915
|
+
)
|
|
1916
|
+
}).describe("What the shared payment token for pay_order must allow.")
|
|
1917
|
+
}).describe(
|
|
1918
|
+
`A Stripe shared payment token, through pay_order's sharedPaymentToken or payment. The entry is absent when a token can't pay the order: over $${LIMITS.tokenPaymentMaxUsd}, not charged in USD, an order started on the Fortrip website, a negotiated price, under ${LIMITS.payMinMinutesLeft} minutes left, ${LIMITS.tokensPerOrder} tokens tried, a token payment is under way, an Alipay or WeChat Pay payment is open, or token payment isn't offered for this order.`
|
|
1919
|
+
),
|
|
1920
|
+
openObject({
|
|
1921
|
+
id: z14.literal("stripe_alipay_wechat_pay"),
|
|
1922
|
+
open: z14.boolean().describe("Whether pay_order has opened an Alipay or WeChat Pay payment on this order."),
|
|
1923
|
+
current: openEnum(["wechat_pay", "alipay"]).nullable().describe("Which of the two the payment is on now; null until it is open."),
|
|
1924
|
+
wechatPay: openObject({
|
|
1925
|
+
qrData: z14.string().nullable().describe(
|
|
1926
|
+
"The WeChat Pay code's content, to draw as a QR code; null when there is no live code (open wechatPay.url for one)."
|
|
1927
|
+
),
|
|
1928
|
+
qrImageUrl: z14.string().nullable().describe("A 480 px PNG of the same code."),
|
|
1929
|
+
url: z14.string().describe("A link, on fortrip.ai, for the user to pay with WeChat Pay; anyone holding it can pay.")
|
|
1930
|
+
}).nullable().describe("The WeChat Pay code and link; null until the payment is open."),
|
|
1931
|
+
alipay: openObject({
|
|
1932
|
+
url: z14.string().describe("A link, on fortrip.ai, for the user to pay with Alipay; anyone holding it can pay.")
|
|
1933
|
+
}).nullable().describe("The Alipay link; null until the payment is open.")
|
|
1934
|
+
}).describe(
|
|
1935
|
+
"Paying with Alipay or WeChat Pay: pass method stripe_alipay_wechat_pay to pay_order to open it. The entry is absent when the order can't be paid this way and none is open."
|
|
1936
|
+
)
|
|
1937
|
+
]);
|
|
1872
1938
|
var orderReference = z14.string().regex(/^FT-[2-9A-HJ-NP-Z]{6}$/);
|
|
1873
1939
|
var hotelItem = openObject({
|
|
1874
1940
|
type: z14.literal("hotel"),
|
|
@@ -1885,7 +1951,9 @@ var hotelItem = openObject({
|
|
|
1885
1951
|
beds: localizedText.nullable()
|
|
1886
1952
|
}),
|
|
1887
1953
|
meals,
|
|
1888
|
-
cancellation
|
|
1954
|
+
cancellation: cancellation.describe(
|
|
1955
|
+
"The terms the order was made on, read at asOf; cancel says whether it can be cancelled now."
|
|
1956
|
+
),
|
|
1889
1957
|
payAtProperty,
|
|
1890
1958
|
confirmationNumber: z14.string().nullable()
|
|
1891
1959
|
})
|
|
@@ -1893,70 +1961,46 @@ var hotelItem = openObject({
|
|
|
1893
1961
|
var order = openObject({
|
|
1894
1962
|
orderId,
|
|
1895
1963
|
reference: orderReference,
|
|
1896
|
-
status: openEnum(ORDER_STATUSES)
|
|
1964
|
+
status: openEnum(ORDER_STATUSES).describe(
|
|
1965
|
+
"awaiting_payment: unpaid, nothing charged; payable until payment.expiresAt. expired: not paid; the time ran out or the order was closed. Nothing charged. confirming: paid or held, the booking is with the hotel. confirmed: the hotel confirmed and the payment is charged. failed: no stay was booked; payment.status says what became of the money. cancelling, then cancelled: a cancellation under the terms. needs_attention: a person at Fortrip has to resolve it."
|
|
1966
|
+
),
|
|
1897
1967
|
createdAt: instant,
|
|
1898
1968
|
updatedAt: instant,
|
|
1899
1969
|
items: z14.array(openUnion("type", [hotelItem])).min(1),
|
|
1900
|
-
price: openObject({
|
|
1970
|
+
price: openObject({
|
|
1971
|
+
total: money.describe(
|
|
1972
|
+
"The whole stay for all rooms, in payment.chargeCurrency: what paying charges, or once paid what was charged. Fees payable at the property are not in it."
|
|
1973
|
+
)
|
|
1974
|
+
}),
|
|
1901
1975
|
payment: openObject({
|
|
1902
1976
|
status: openEnum(PAYMENT_STATUSES),
|
|
1903
1977
|
url: z14.string().nullable().describe(
|
|
1904
|
-
"The payment page, on fortrip.ai
|
|
1978
|
+
"The payment page, on fortrip.ai; it continues to the payment provider. With requiresSignIn false 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 while a payment is held (authorized) or when the order isn't awaiting payment, or, while it is and its payment is unpaid, when the link couldn't be read this time: read the order again."
|
|
1905
1979
|
),
|
|
1906
1980
|
requiresSignIn: z14.boolean(),
|
|
1907
|
-
expiresAt: instant.nullable()
|
|
1908
|
-
|
|
1909
|
-
localCurrencyAtCheckout: z14.boolean(),
|
|
1910
|
-
localCharge: money.nullable(),
|
|
1911
|
-
/** The ways to pay other than `url`, while the order can be paid that
|
|
1912
|
-
* way: a `com.stripe.payments` handler takes a shared payment token
|
|
1913
|
-
* through `pay_order`. Empty when there is none. */
|
|
1914
|
-
handlers: z14.array(paymentHandler).describe(
|
|
1915
|
-
"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."
|
|
1981
|
+
expiresAt: instant.nullable().describe(
|
|
1982
|
+
"When the time to pay ends: an order unpaid by then expires, with nothing charged. null unless status is awaiting_payment."
|
|
1916
1983
|
),
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
* `currency`, lowercase as Stripe takes it, and valid until at least
|
|
1920
|
-
* `expiresAt`, past which the order can't be paid. `null` when
|
|
1921
|
-
* `handlers` is empty. */
|
|
1922
|
-
credentialLimits: openObject({
|
|
1923
|
-
maxAmount: z14.number().int().describe("Request the token for at least this amount, in cents; a token that allows less can't pay."),
|
|
1924
|
-
currency: z14.string().describe("The token's currency, lowercase as Stripe takes it: usd."),
|
|
1925
|
-
expiresAt: instant.describe(
|
|
1926
|
-
"Request the token valid until at least this time; the order can't be paid after it."
|
|
1927
|
-
)
|
|
1928
|
-
}).nullable().describe(
|
|
1929
|
-
"What the shared payment token for pay_order must allow. null exactly when handlers is []."
|
|
1984
|
+
chargeCurrency: z14.string().describe(
|
|
1985
|
+
"USD or CNY: the currency of the offer the order was made from. An order made on the Fortrip website may be in another currency."
|
|
1930
1986
|
),
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
),
|
|
1940
|
-
qrImageUrl: z14.string().nullable().describe("A 480 px PNG of the same code."),
|
|
1941
|
-
url: z14.string().describe("A link, on fortrip.ai, for the user to pay with WeChat Pay; anyone holding it can pay.")
|
|
1942
|
-
}).nullable().describe("The WeChat Pay code and link; null until the payment is open."),
|
|
1943
|
-
alipay: openObject({
|
|
1944
|
-
url: z14.string().describe("A link, on fortrip.ai, for the user to pay with Alipay; anyone holding it can pay.")
|
|
1945
|
-
}).nullable().describe("The Alipay link; null until the payment is open.")
|
|
1946
|
-
}).nullable().describe(
|
|
1947
|
-
"Paying with Alipay or WeChat Pay: pass method alipay_wechat_pay to pay_order to open it. null when the order can't be paid this way and none is open."
|
|
1987
|
+
localCurrencyAtCheckout: z14.boolean().describe(
|
|
1988
|
+
"Whether paying by url may charge the card in its own currency, converted by Stripe; false once paid by token, Alipay or WeChat Pay; always false on a CNY order."
|
|
1989
|
+
),
|
|
1990
|
+
localCharge: money.nullable().describe(
|
|
1991
|
+
"What the card was charged in its own currency, when Stripe converted the total; otherwise null. Always null on a CNY order."
|
|
1992
|
+
),
|
|
1993
|
+
methods: z14.array(paymentMethod).describe(
|
|
1994
|
+
"What pay_order accepts for this order now, by id. [] means: give the user payment.url, when it isn't null."
|
|
1948
1995
|
)
|
|
1949
1996
|
}),
|
|
1950
|
-
/** Whether the user can cancel the order now and, when they can, its
|
|
1951
|
-
* penalty under the accepted terms (read a minute ahead) and the refund,
|
|
1952
|
-
* what was paid less the penalty, both in the charge currency. */
|
|
1953
1997
|
cancel: openObject({
|
|
1954
|
-
available: z14.boolean().describe("Whether the user can cancel the order now."),
|
|
1998
|
+
available: z14.boolean().describe("Whether the user can cancel the order now, or, unpaid (reason unpaid), close it."),
|
|
1955
1999
|
reason: openEnum(CANCEL_REASONS).describe(
|
|
1956
|
-
"cancellable
|
|
2000
|
+
"cancellable: a paid order can be cancelled now; unpaid: an unpaid order can be closed; otherwise why not."
|
|
1957
2001
|
),
|
|
1958
2002
|
penalty: money.nullable().describe(
|
|
1959
|
-
"The penalty if cancelled now, under the accepted terms, in the charge currency; null when not stated."
|
|
2003
|
+
"The penalty if cancelled now, under the accepted terms, in the charge currency; null when not stated, except on an unpaid order (reason unpaid), where null means closing it charges nothing."
|
|
1960
2004
|
),
|
|
1961
2005
|
refund: money.nullable().describe(
|
|
1962
2006
|
"What a cancellation now refunds: what was paid less the penalty, in the charge currency; null when not stated."
|
|
@@ -2071,6 +2115,7 @@ var ERROR_DETAILS = {
|
|
|
2071
2115
|
offerId,
|
|
2072
2116
|
reason: openEnum(["sold_out", "refused"])
|
|
2073
2117
|
}),
|
|
2118
|
+
currency_unavailable: openObject({ currency: z15.string() }),
|
|
2074
2119
|
rate_limited: openObject({
|
|
2075
2120
|
scope: openEnum([
|
|
2076
2121
|
"search",
|
|
@@ -2191,19 +2236,21 @@ var ORDER_NEXT_STEP = "Before you give the user an order's payment.url, show the
|
|
|
2191
2236
|
var CALLS = {
|
|
2192
2237
|
mcp: {
|
|
2193
2238
|
cancel: "call cancel_order",
|
|
2194
|
-
penalty:
|
|
2239
|
+
penalty: "Pass maximumPenalty as cancel.penalty, exactly as returned.",
|
|
2240
|
+
close: "call cancel_order",
|
|
2195
2241
|
pay: "call pay_order",
|
|
2196
|
-
payWallet: " with method
|
|
2242
|
+
payWallet: " with method stripe_alipay_wechat_pay",
|
|
2197
2243
|
get: "call get_order",
|
|
2198
2244
|
poll: "poll get_order",
|
|
2199
2245
|
payWith: "call pay_order with it and the order's price.total",
|
|
2200
2246
|
paid: "pay_order"
|
|
2201
2247
|
},
|
|
2202
2248
|
cli: {
|
|
2203
|
-
cancel: "run `fortrip orders cancel <orderId> --max-penalty <
|
|
2249
|
+
cancel: "run `fortrip orders cancel <orderId> --max-penalty <amount>`",
|
|
2250
|
+
close: "run `fortrip orders cancel <orderId> --close`",
|
|
2204
2251
|
penalty: "Pass the penalty's amount as --max-penalty (120.00 for a penalty of USD 120.00).",
|
|
2205
2252
|
pay: "run `fortrip orders pay`",
|
|
2206
|
-
payWallet: " with --
|
|
2253
|
+
payWallet: " with --method stripe_alipay_wechat_pay",
|
|
2207
2254
|
get: "run `fortrip orders get <orderId>`",
|
|
2208
2255
|
poll: "poll it with `fortrip orders get <orderId>`",
|
|
2209
2256
|
payWith: "run `fortrip orders pay <orderId> --token <spt_\u2026> --total <total>` with the token and the order's total",
|
|
@@ -2217,15 +2264,15 @@ function cancelNextStep(surface) {
|
|
|
2217
2264
|
var CANCEL_NEXT_STEP = cancelNextStep("mcp");
|
|
2218
2265
|
function payNextStep(surface) {
|
|
2219
2266
|
const c = CALLS[surface];
|
|
2220
|
-
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.
|
|
2267
|
+
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.methods has the stripe_shared_payment_token entry. 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 that entry's handler config.business_profile and its limits (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.`;
|
|
2221
2268
|
}
|
|
2222
2269
|
var PAY_NEXT_STEP = payNextStep("mcp");
|
|
2223
2270
|
function walletNextStep(surface) {
|
|
2224
2271
|
const c = CALLS[surface];
|
|
2225
|
-
return `Before you ${c.pay}${c.payWallet}, show the user the order's total
|
|
2272
|
+
return `Before you ${c.pay}${c.payWallet}, 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 ask them to confirm, and wait for a clear yes. Then show the stripe_alipay_wechat_pay entry of payment.methods: the WeChat code as an image if you can, and both links. The user pays once, by one of them. Alipay and WeChat Pay charge at once; if the hotel can't confirm, the payment is refunded in full. Then ${c.poll}.`;
|
|
2226
2273
|
}
|
|
2227
2274
|
var WALLET_NEXT_STEP = walletNextStep("mcp");
|
|
2228
|
-
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
|
|
2275
|
+
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 its currency, 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.";
|
|
2229
2276
|
var nextStep = z16.string().optional().describe(
|
|
2230
2277
|
"What to show and ask before giving a payment.url. Present when the answer holds a non-null payment.url, and only then."
|
|
2231
2278
|
);
|
|
@@ -2244,14 +2291,6 @@ var READ = {
|
|
|
2244
2291
|
};
|
|
2245
2292
|
var READ_OWN = { ...READ, openWorldHint: false };
|
|
2246
2293
|
var TOOLS = [
|
|
2247
|
-
{
|
|
2248
|
-
name: "get_planning_guide",
|
|
2249
|
-
title: "Get hotel planning guide",
|
|
2250
|
-
description: `Returns Fortrip's planning guide for a request that is more than one hotel for fixed dates (flexible dates, a budget, split stays, several destinations, "find me the best"): what to ask the user, which results count as evidence, how to rank and how to present options.`,
|
|
2251
|
-
annotations: READ_OWN,
|
|
2252
|
-
input: null,
|
|
2253
|
-
output: null
|
|
2254
|
-
},
|
|
2255
2294
|
{
|
|
2256
2295
|
name: "search_hotels",
|
|
2257
2296
|
title: "Search hotels",
|
|
@@ -2262,7 +2301,7 @@ var TOOLS = [
|
|
|
2262
2301
|
},
|
|
2263
2302
|
{
|
|
2264
2303
|
name: "get_hotel",
|
|
2265
|
-
title: "
|
|
2304
|
+
title: "Hotel details",
|
|
2266
2305
|
description: `One hotel's catalogue facts: names, address, location, time zone, check-in and check-out times, the full description, every policy and the amenities, and its rooms with include: "rooms". "Not listed" is not "no". No prices or availability: get_hotel_offers has those.`,
|
|
2267
2306
|
annotations: READ,
|
|
2268
2307
|
input: getHotelInput,
|
|
@@ -2270,15 +2309,15 @@ var TOOLS = [
|
|
|
2270
2309
|
},
|
|
2271
2310
|
{
|
|
2272
2311
|
name: "get_hotel_offers",
|
|
2273
|
-
title: "
|
|
2274
|
-
description: `Live, bookable offers for up to ${LIMITS.offersHotels} hotels and one stay. Every room in stay.rooms must have the same party: for different parties, call once per party. Each offer has the room, the meals included, price.total in
|
|
2312
|
+
title: "Live offers",
|
|
2313
|
+
description: `Live, bookable offers for up to ${LIMITS.offersHotels} hotels and one stay. Every room in stay.rooms must have the same party: for different parties, call once per party. Each offer has the room, the meals included, price.total, in the request's currency, for the whole stay and every room (what is charged), fees payable at the property, the cancellation terms with times in UTC and the hotel's time zone, the confirmation mode, and an offerId for book_hotel that expires at expiresAt. Hotels with nothing to offer are listed under unavailable with the reason. Up to limitPerHotel offers per hotel, default ${LIMITS.offersPerHotelDefault}, chosen for a spread of choices in this order while room remains: the cheapest offer, the cheapest that can be cancelled free, the cheapest with breakfast, the cheapest of each other room, then the rest by price; listed cheapest first.`,
|
|
2275
2314
|
annotations: READ,
|
|
2276
2315
|
input: hotelOffersInput,
|
|
2277
2316
|
output: hotelOffersResult
|
|
2278
2317
|
},
|
|
2279
2318
|
{
|
|
2280
2319
|
name: "book_hotel",
|
|
2281
|
-
title: "Create
|
|
2320
|
+
title: "Create order",
|
|
2282
2321
|
description: `Order one offer from get_hotel_offers. The answer is an unpaid order with a payment link: status awaiting_payment, the total, the stay and its terms, and payment.url, a Fortrip page to pay on. Nothing is charged until the order is paid, on that page or with pay_order (or Alipay/WeChat Pay); anyone holding the link can pay. Send the contact and, for each room of the offer, at least one guest. If the price or terms changed since the offer, the answer is offer_changed with every change and a new offer: show the changes and ask the user again before ordering it. Sending the same details again returns the same order. An offer is ordered once: for another order of the stay (another party, or a corrected guest name), get offers again and order the new offer; when it replaces an unpaid order, tell the user to pay only the new link, as the earlier one expires unpaid. To cancel an order, use cancel_order; for changes, or a cancellation cancel_order can't make, the user emails ${SUPPORT_EMAIL} with the order's reference.`,
|
|
2283
2322
|
annotations: {
|
|
2284
2323
|
readOnlyHint: false,
|
|
@@ -2308,7 +2347,7 @@ var TOOLS = [
|
|
|
2308
2347
|
{
|
|
2309
2348
|
name: "cancel_order",
|
|
2310
2349
|
title: "Cancel order",
|
|
2311
|
-
description: `Cancel
|
|
2350
|
+
description: `Cancel a paid order under its terms, or close an unpaid one. Paid (cancel.reason cancellable): the hotel booking is cancelled and cancel.refund is refunded. ${CANCEL_NEXT_STEP} Penalty now above maximumPenalty: cancellation_changed, nothing changed; ask again. Then poll get_order: cancelling, then cancelled. Hotel refused: confirmed, reason refused. Unpaid (cancel.reason unpaid): close it only once the user says they no longer want it, without maximumPenalty; nothing is charged; it becomes expired. Paid meanwhile: the answer is the paid order or invalid_request; then cancel only under cancel.penalty, with the user's yes. payment_in_progress: read it again shortly. Repeat calls answer the order as it is.`,
|
|
2312
2351
|
annotations: {
|
|
2313
2352
|
readOnlyHint: false,
|
|
2314
2353
|
idempotentHint: true,
|
|
@@ -2320,8 +2359,8 @@ var TOOLS = [
|
|
|
2320
2359
|
},
|
|
2321
2360
|
{
|
|
2322
2361
|
name: "pay_order",
|
|
2323
|
-
title: "Pay order
|
|
2324
|
-
description: `Pay an order without its link, by shared payment token or Alipay/WeChat Pay (method
|
|
2362
|
+
title: "Pay order",
|
|
2363
|
+
description: `Pay an order without its link, by one of its payment.methods: a shared payment token, or Alipay/WeChat Pay (method stripe_alipay_wechat_pay). Token: only if you can request one from the user's Link wallet (US and Canadian accounts); never ask the user for one. First show the user the total and currency, the stay and every term (meals, cancellation, fees payable at the property), ask them to confirm and wait for a clear yes. Token: request it with the entry's handler config.business_profile and limits; pass it with price.total. Wallet: pass method, price.total; show the wallet entry (WeChat code as an image if you can, both links); they pay once by either; a code lasts ${LIMITS.wechatCodeMinutes} minutes; then the WeChat link opens a new one, or call again. Pay one way only: payment.url or pay_order. Success closes payment.url; failure leaves it open. Then poll get_order. payment_total_changed: confirm details.total, retry. payment_credential_invalid: new token. service_unavailable: retry. Else payment.url. A token pays one order.`,
|
|
2325
2364
|
annotations: {
|
|
2326
2365
|
readOnlyHint: false,
|
|
2327
2366
|
idempotentHint: true,
|
|
@@ -2554,10 +2593,7 @@ function roomText(r) {
|
|
|
2554
2593
|
}
|
|
2555
2594
|
function offerLine(o) {
|
|
2556
2595
|
const p = o.price;
|
|
2557
|
-
|
|
2558
|
-
if (p.approx) {
|
|
2559
|
-
price += ` \u2248 ${money2(p.approx.total)} (${money2(p.approx.perNightAllRooms)} per night), exchange rate of ${p.approx.rateDate}`;
|
|
2560
|
-
}
|
|
2596
|
+
const price = `${money2(p.total)} total (${money2(p.perNightAllRooms)} per night, all rooms)`;
|
|
2561
2597
|
return [
|
|
2562
2598
|
`${o.offerId}${o.type === "hotel" ? "" : ` (${o.type})`}`,
|
|
2563
2599
|
`${plural(o.hotel.roomCount, "room")}: ${roomText(o.hotel.room)}`,
|
|
@@ -2617,9 +2653,12 @@ function renderOffers(r, surface = "mcp") {
|
|
|
2617
2653
|
}
|
|
2618
2654
|
|
|
2619
2655
|
// src/render/order.ts
|
|
2656
|
+
function methodOf(o, id) {
|
|
2657
|
+
return o.payment.methods.find((m) => m.id === id);
|
|
2658
|
+
}
|
|
2620
2659
|
var ORDER_STATUS_WORDS = {
|
|
2621
2660
|
awaiting_payment: "awaiting payment",
|
|
2622
|
-
expired: "
|
|
2661
|
+
expired: "not paid: the time ran out or it was closed",
|
|
2623
2662
|
confirming: "confirming with the hotel",
|
|
2624
2663
|
confirmed: "confirmed",
|
|
2625
2664
|
failed: "failed",
|
|
@@ -2638,6 +2677,7 @@ var PAYMENT_WORDS = {
|
|
|
2638
2677
|
var SUPPORT = `for help, the user emails ${SUPPORT_EMAIL} with the order's reference`;
|
|
2639
2678
|
var CANCEL_REASON_WORDS = {
|
|
2640
2679
|
cancellable: "it can be cancelled",
|
|
2680
|
+
unpaid: "it isn't paid: it can be closed if the user no longer wants it",
|
|
2641
2681
|
already_cancelled: "it is already cancelled",
|
|
2642
2682
|
in_progress: "a cancellation is in progress",
|
|
2643
2683
|
not_confirmed: "only a confirmed order that is paid can be cancelled",
|
|
@@ -2681,24 +2721,22 @@ function paymentLines(o, surface) {
|
|
|
2681
2721
|
p.requiresSignIn ? "the user signs in to Fortrip to pay" : "no sign-in needed"
|
|
2682
2722
|
].filter(Boolean);
|
|
2683
2723
|
lines.push(`Payment link (${about.join("; ")}): ${p.url}`);
|
|
2684
|
-
} else if (o.status === "awaiting_payment") {
|
|
2724
|
+
} else if (o.status === "awaiting_payment" && p.status === "unpaid") {
|
|
2685
2725
|
lines.push("Payment link: could not be read this time; read this order again for it.");
|
|
2686
2726
|
}
|
|
2687
|
-
|
|
2688
|
-
if (
|
|
2689
|
-
|
|
2727
|
+
const token = methodOf(o, "stripe_shared_payment_token");
|
|
2728
|
+
if (token) lines.push(tokenLine(o, token, surface));
|
|
2729
|
+
const wallet = methodOf(o, "stripe_alipay_wechat_pay");
|
|
2730
|
+
if (wallet) lines.push(...walletLines(wallet, surface));
|
|
2731
|
+
lines.push(cancelLine(o, surface));
|
|
2690
2732
|
lines.push(`Manage: ${o.manageUrl}`);
|
|
2691
2733
|
return lines;
|
|
2692
2734
|
}
|
|
2693
|
-
function
|
|
2694
|
-
const {
|
|
2735
|
+
function tokenLine(o, token, surface) {
|
|
2736
|
+
const { handler: h, limits } = token;
|
|
2695
2737
|
const pay = surface === "cli" ? `\`fortrip orders pay ${o.orderId} --token <spt_\u2026> --total ${o.price.total.amount}\`` : "pay_order";
|
|
2696
|
-
const shown = handlers.map(
|
|
2697
|
-
(h) => `${h.type} (handler ${h.id}, business_profile ${h.config.business_profile})`
|
|
2698
|
-
);
|
|
2699
|
-
const limit = limits ? `; token limits: maxAmount ${limits.maxAmount} (cents), currency ${limits.currency}, expiresAt ${limits.expiresAt}` : "";
|
|
2700
2738
|
return [
|
|
2701
|
-
`Pay without the link: ${pay} with a shared payment token via ${
|
|
2739
|
+
`Pay without the link: ${pay} with a shared payment token via ${h.type} (handler ${h.id}, business_profile ${h.config.business_profile}); token limits: maxAmount ${limits.maxAmount} (cents), currency ${limits.currency}, expiresAt ${limits.expiresAt}.`,
|
|
2702
2740
|
"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.",
|
|
2703
2741
|
`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"}.`
|
|
2704
2742
|
].join(" ");
|
|
@@ -2706,7 +2744,7 @@ function handlersLine(o, surface) {
|
|
|
2706
2744
|
function walletLines(w, surface) {
|
|
2707
2745
|
const c = CALLS[surface];
|
|
2708
2746
|
if (!w.open) {
|
|
2709
|
-
const pay = surface === "cli" ? "run `fortrip orders pay <orderId> --
|
|
2747
|
+
const pay = surface === "cli" ? "run `fortrip orders pay <orderId> --method stripe_alipay_wechat_pay --total <total>`" : "call pay_order with method stripe_alipay_wechat_pay and the order's price.total";
|
|
2710
2748
|
return [`Pay with Alipay or WeChat Pay: ${pay}.`];
|
|
2711
2749
|
}
|
|
2712
2750
|
const lines = [];
|
|
@@ -2723,9 +2761,13 @@ function walletLines(w, surface) {
|
|
|
2723
2761
|
);
|
|
2724
2762
|
return lines;
|
|
2725
2763
|
}
|
|
2726
|
-
function cancelLine(o) {
|
|
2764
|
+
function cancelLine(o, surface) {
|
|
2727
2765
|
const c = o.cancel;
|
|
2766
|
+
if (c.available && c.reason === "unpaid") {
|
|
2767
|
+
return `Cancel: can be closed now, nothing is charged; close it only if the user says they no longer want it (${CALLS[surface].close})`;
|
|
2768
|
+
}
|
|
2728
2769
|
if (o.status === "awaiting_payment" && !c.available && c.reason === "not_confirmed") {
|
|
2770
|
+
if (!o.payment.requiresSignIn) return "Cancel: not now: a payment is under way; read the order again shortly";
|
|
2729
2771
|
const at = o.payment.expiresAt === null ? "" : ` at ${when(o.payment.expiresAt, null)}`;
|
|
2730
2772
|
return `Cancel: not needed: an unpaid order expires unpaid${at}`;
|
|
2731
2773
|
}
|
|
@@ -2769,7 +2811,7 @@ var CENTER_BASES2 = {
|
|
|
2769
2811
|
seat: "the seat",
|
|
2770
2812
|
capital: "the capital",
|
|
2771
2813
|
busiest_settlement: "the settlement with the most hotels",
|
|
2772
|
-
hub: "the locality
|
|
2814
|
+
hub: "the locality",
|
|
2773
2815
|
point: "its location"
|
|
2774
2816
|
};
|
|
2775
2817
|
function radiusWords(meters, source) {
|
|
@@ -2836,7 +2878,7 @@ function countsLine(r) {
|
|
|
2836
2878
|
if (c.excludedNoFacilityData !== null) {
|
|
2837
2879
|
parts.push(`${num(c.excludedNoFacilityData)} left out for listing no facilities`);
|
|
2838
2880
|
}
|
|
2839
|
-
if (c.withinMaxRadius !== null) parts.push(`${num(c.withinMaxRadius)} within
|
|
2881
|
+
if (c.withinMaxRadius !== null) parts.push(`${num(c.withinMaxRadius)} within ${LIMITS.radiusMetersMax / 1e3} km`);
|
|
2840
2882
|
if (c.textAnywhere !== null) {
|
|
2841
2883
|
parts.push(`${num(c.textAnywhere)} match the text anywhere in ${country}`);
|
|
2842
2884
|
}
|
|
@@ -2879,9 +2921,6 @@ function priceWords(h, status) {
|
|
|
2879
2921
|
return status === "ok" ? "no indicative price" : "price unavailable this time";
|
|
2880
2922
|
}
|
|
2881
2923
|
let text2 = `from ${money2(p.fromPerRoomNight)}/room-night (${money2(p.fromPerRoomStay)} per room for the stay)`;
|
|
2882
|
-
if (p.approx) {
|
|
2883
|
-
text2 += ` \u2248 ${money2(p.approx.fromPerRoomNight)}/room-night (${money2(p.approx.fromPerRoomStay)}), exchange rate of ${p.approx.rateDate}`;
|
|
2884
|
-
}
|
|
2885
2924
|
if (p.kind !== "indicative" || p.basis !== "lowest_unit") {
|
|
2886
2925
|
text2 += ` [${p.kind}, ${p.basis}]`;
|
|
2887
2926
|
}
|
|
@@ -2990,13 +3029,13 @@ function ambiguous(d, surface) {
|
|
|
2990
3029
|
for (const c of d.candidates) {
|
|
2991
3030
|
const other = [c.names.en, c.names.zh].find((n) => n && n !== c.name);
|
|
2992
3031
|
const where = [c.region && `${c.region.name} ${c.region.placeId}`, c.countryCode].filter(Boolean).join(", ");
|
|
2993
|
-
const
|
|
3032
|
+
const hotels2 = c.hotels.scope === "area" ? `${plural(c.hotels.count, "hotel")} in the area` : c.hotels.radiusMeters === null ? plural(c.hotels.count, "hotel") : `${plural(c.hotels.count, "hotel")} within ${km(c.hotels.radiusMeters)}`;
|
|
2994
3033
|
lines.push(
|
|
2995
3034
|
[
|
|
2996
3035
|
`- ${c.name}${other ? ` (${other})` : ""} ${c.placeId}`,
|
|
2997
3036
|
`${c.kind} in ${where}`,
|
|
2998
3037
|
c.population === null ? "population not recorded" : `population ${num(c.population)}`,
|
|
2999
|
-
|
|
3038
|
+
hotels2
|
|
3000
3039
|
].join(" \xB7 ")
|
|
3001
3040
|
);
|
|
3002
3041
|
}
|
|
@@ -3079,7 +3118,7 @@ function detailLines(e, surface) {
|
|
|
3079
3118
|
];
|
|
3080
3119
|
case "payment_credential_invalid":
|
|
3081
3120
|
return [
|
|
3082
|
-
`The token ${label(CREDENTIAL_INVALID_WORDS, e.details.reason)}: request a new one with the order's
|
|
3121
|
+
`The token ${label(CREDENTIAL_INVALID_WORDS, e.details.reason)}: request a new one with the limits of the order's stripe_shared_payment_token method. Nothing was charged.`
|
|
3083
3122
|
];
|
|
3084
3123
|
case "payment_declined":
|
|
3085
3124
|
return [
|
|
@@ -3101,6 +3140,8 @@ function detailLines(e, surface) {
|
|
|
3101
3140
|
return [
|
|
3102
3141
|
`Offer ${e.details.offerId}: ${label({ sold_out: "sold out", refused: "can no longer be booked" }, e.details.reason)}. Get fresh offers.`
|
|
3103
3142
|
];
|
|
3143
|
+
case "currency_unavailable":
|
|
3144
|
+
return [`Prices in ${e.details.currency} aren't available yet. Tell the user, and ask whether to see USD prices.`];
|
|
3104
3145
|
case "rate_limited":
|
|
3105
3146
|
return [`Limit reached for: ${e.details.scope}.`];
|
|
3106
3147
|
case "supplier_unavailable":
|
|
@@ -3165,8 +3206,8 @@ ${raw(data)}`;
|
|
|
3165
3206
|
return [
|
|
3166
3207
|
text2,
|
|
3167
3208
|
ORDER_TOOLS.has(tool) && holdsPaymentUrl(data) ? ORDER_NEXT_STEP : "",
|
|
3168
|
-
ORDER_TOOLS.has(tool) &&
|
|
3169
|
-
ORDER_TOOLS.has(tool) &&
|
|
3209
|
+
ORDER_TOOLS.has(tool) && holdsMethod(data, isTokenMethod) ? payNextStep(surface) : "",
|
|
3210
|
+
ORDER_TOOLS.has(tool) && holdsMethod(data, isWalletOffer) ? walletNextStep(surface) : "",
|
|
3170
3211
|
CANCEL_TOOLS.has(tool) && holdsCancellable(data) ? cancelNextStep(surface) : ""
|
|
3171
3212
|
].filter(Boolean).join("\n\n");
|
|
3172
3213
|
}
|
|
@@ -3202,32 +3243,23 @@ function holdsPaymentUrl(value, seen = /* @__PURE__ */ new Set()) {
|
|
|
3202
3243
|
}
|
|
3203
3244
|
return Object.values(value).some((v) => holdsPaymentUrl(v, seen));
|
|
3204
3245
|
}
|
|
3205
|
-
|
|
3246
|
+
var isTokenMethod = (m) => m.id === "stripe_shared_payment_token";
|
|
3247
|
+
var isWalletOffer = (m) => m.id === "stripe_alipay_wechat_pay" && m.open === false;
|
|
3248
|
+
function holdsMethod(value, match, seen = /* @__PURE__ */ new Set()) {
|
|
3206
3249
|
if (typeof value !== "object" || value === null || seen.has(value)) return false;
|
|
3207
3250
|
seen.add(value);
|
|
3208
3251
|
const payment = value.payment;
|
|
3209
|
-
|
|
3252
|
+
const methods = typeof payment === "object" && payment !== null ? payment.methods : void 0;
|
|
3253
|
+
if (Array.isArray(methods) && methods.some((m) => typeof m === "object" && m !== null && match(m))) {
|
|
3210
3254
|
return true;
|
|
3211
3255
|
}
|
|
3212
|
-
return Object.values(value).some((v) =>
|
|
3213
|
-
}
|
|
3214
|
-
function holdsWalletOffer(value, seen = /* @__PURE__ */ new Set()) {
|
|
3215
|
-
if (typeof value !== "object" || value === null || seen.has(value)) return false;
|
|
3216
|
-
seen.add(value);
|
|
3217
|
-
const payment = value.payment;
|
|
3218
|
-
if (typeof payment === "object" && payment !== null) {
|
|
3219
|
-
const wallets = payment.wallets;
|
|
3220
|
-
if (typeof wallets === "object" && wallets !== null && wallets.open === false) {
|
|
3221
|
-
return true;
|
|
3222
|
-
}
|
|
3223
|
-
}
|
|
3224
|
-
return Object.values(value).some((v) => holdsWalletOffer(v, seen));
|
|
3256
|
+
return Object.values(value).some((v) => holdsMethod(v, match, seen));
|
|
3225
3257
|
}
|
|
3226
3258
|
function holdsCancellable(value, seen = /* @__PURE__ */ new Set()) {
|
|
3227
3259
|
if (typeof value !== "object" || value === null || seen.has(value)) return false;
|
|
3228
3260
|
seen.add(value);
|
|
3229
3261
|
const cancel = value.cancel;
|
|
3230
|
-
if (typeof cancel === "object" && cancel !== null && cancel.available === true) {
|
|
3262
|
+
if (typeof cancel === "object" && cancel !== null && cancel.available === true && cancel.reason !== "unpaid") {
|
|
3231
3263
|
return true;
|
|
3232
3264
|
}
|
|
3233
3265
|
return Object.values(value).some((v) => holdsCancellable(v, seen));
|
|
@@ -3236,9 +3268,9 @@ function withConsent(tool, surface, text2, orders) {
|
|
|
3236
3268
|
return [
|
|
3237
3269
|
text2,
|
|
3238
3270
|
orders.some((o) => o.payment.url !== null) ? ORDER_NEXT_STEP : "",
|
|
3239
|
-
orders.some((o) => o
|
|
3240
|
-
orders.some((o) => o
|
|
3241
|
-
CANCEL_TOOLS.has(tool) && orders.some((o) => o.cancel.available) ? cancelNextStep(surface) : ""
|
|
3271
|
+
orders.some((o) => methodOf(o, "stripe_shared_payment_token")) ? payNextStep(surface) : "",
|
|
3272
|
+
orders.some((o) => methodOf(o, "stripe_alipay_wechat_pay")?.open === false) ? walletNextStep(surface) : "",
|
|
3273
|
+
CANCEL_TOOLS.has(tool) && orders.some((o) => o.cancel.available && o.cancel.reason !== "unpaid") ? cancelNextStep(surface) : ""
|
|
3242
3274
|
].filter(Boolean).join("\n\n");
|
|
3243
3275
|
}
|
|
3244
3276
|
|
|
@@ -3257,8 +3289,8 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
|
|
|
3257
3289
|
hotels: `${RESULT_LIST} (the hotels that have offers).`,
|
|
3258
3290
|
unavailable: `${RESULT_LIST} (the hotels without offers, each with a reason).`,
|
|
3259
3291
|
candidates: `${RESULT_LIST} (the places a name could mean).`,
|
|
3260
|
-
"localities.items": `${RESULT_LIST} (the top
|
|
3261
|
-
"localities.items.includes": `${RESULT_LIST} (other places
|
|
3292
|
+
"localities.items": `${RESULT_LIST} (the top localities of the scope).`,
|
|
3293
|
+
"localities.items.includes": `${RESULT_LIST} (other places a locality includes).`,
|
|
3262
3294
|
filterable: `${RESULT_LIST} (the amenity codes a search can filter by).`,
|
|
3263
3295
|
rooms: `${REQUEST_ECHO} (the rooms of the stay).`,
|
|
3264
3296
|
childrenAges: `${REQUEST_ECHO} (each child's age; empty means no children).`,
|
|
@@ -3268,8 +3300,8 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
|
|
|
3268
3300
|
requiresSignIn: `${API_DECIDES} (whether the payment link needs a website sign-in).`,
|
|
3269
3301
|
localCurrencyAtCheckout: `${API_DECIDES} (whether checkout may charge in the card's currency).`,
|
|
3270
3302
|
"cancel.available": `${API_DECIDES} (whether an order can be cancelled now).`,
|
|
3271
|
-
"payment.
|
|
3272
|
-
"payment.
|
|
3303
|
+
"payment.methods": `${RESULT_LIST} (the ways to pay an order other than its link; empty when there is none).`,
|
|
3304
|
+
"payment.methods.open": `${API_DECIDES} (the server always knows whether it opened a payment).`,
|
|
3273
3305
|
available_instruments: `${RESULT_LIST} (the instruments a payment handler takes).`,
|
|
3274
3306
|
bookable: `${API_DECIDES} (whether the hotel is still in the index).`,
|
|
3275
3307
|
cityLike: `${API_DECIDES} (frozen per gazetteer release; null where not computed).`,
|
|
@@ -3294,7 +3326,7 @@ var ME_SCOPES = { email: "email", name: "profile" };
|
|
|
3294
3326
|
// package.json
|
|
3295
3327
|
var package_default = {
|
|
3296
3328
|
name: "@fortrip/agent-contract",
|
|
3297
|
-
version: "
|
|
3329
|
+
version: "5.0.0-rc.1",
|
|
3298
3330
|
license: "Apache-2.0",
|
|
3299
3331
|
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.",
|
|
3300
3332
|
type: "module",
|
|
@@ -3317,7 +3349,10 @@ var package_default = {
|
|
|
3317
3349
|
import: "./dist/regions.js"
|
|
3318
3350
|
}
|
|
3319
3351
|
},
|
|
3320
|
-
files: [
|
|
3352
|
+
files: [
|
|
3353
|
+
"dist",
|
|
3354
|
+
"NOTICE"
|
|
3355
|
+
],
|
|
3321
3356
|
sideEffects: false,
|
|
3322
3357
|
engines: {
|
|
3323
3358
|
node: ">=22"
|
|
@@ -3358,7 +3393,7 @@ export {
|
|
|
3358
3393
|
COMMAND_GROUPS,
|
|
3359
3394
|
CONTRACT_VERSION,
|
|
3360
3395
|
CREDENTIAL_INVALID_REASONS,
|
|
3361
|
-
|
|
3396
|
+
CURRENCIES,
|
|
3362
3397
|
DOCS_ORIGIN,
|
|
3363
3398
|
ERROR_CODES,
|
|
3364
3399
|
ERROR_DETAILS,
|
|
@@ -3376,6 +3411,7 @@ export {
|
|
|
3376
3411
|
ORDER_HTTP,
|
|
3377
3412
|
ORDER_NEXT_STEP,
|
|
3378
3413
|
ORDER_STATUSES,
|
|
3414
|
+
PAYMENT_METHOD_IDS,
|
|
3379
3415
|
PAYMENT_STATUSES,
|
|
3380
3416
|
PAY_INPUT_WAYS,
|
|
3381
3417
|
PAY_NEXT_STEP,
|
|
@@ -3453,6 +3489,7 @@ export {
|
|
|
3453
3489
|
payNextStep,
|
|
3454
3490
|
payOrderInput,
|
|
3455
3491
|
paymentHandler,
|
|
3492
|
+
paymentMethod,
|
|
3456
3493
|
photo,
|
|
3457
3494
|
place,
|
|
3458
3495
|
placeId,
|
|
@@ -3461,6 +3498,7 @@ export {
|
|
|
3461
3498
|
renderError,
|
|
3462
3499
|
renderGuide,
|
|
3463
3500
|
renderToolResult,
|
|
3501
|
+
requestMoney,
|
|
3464
3502
|
roomFacts,
|
|
3465
3503
|
routePath,
|
|
3466
3504
|
searchHotelsInput,
|
|
@@ -3472,7 +3510,6 @@ export {
|
|
|
3472
3510
|
strictOutput,
|
|
3473
3511
|
text,
|
|
3474
3512
|
timeZone,
|
|
3475
|
-
usdMoney,
|
|
3476
3513
|
walletNextStep,
|
|
3477
3514
|
wholeNumber
|
|
3478
3515
|
};
|