@fortrip/agent-contract 4.3.1 → 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 -221
- package/dist/index.js +230 -232
- 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({
|
|
@@ -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,10 +976,9 @@ var cancelFlags = flagsOf(cancelOrderInput, [
|
|
|
961
976
|
{
|
|
962
977
|
flag: "max-penalty",
|
|
963
978
|
field: "maximumPenalty",
|
|
964
|
-
type: "
|
|
965
|
-
optional: true,
|
|
979
|
+
type: "string",
|
|
966
980
|
placeholder: "<amount>",
|
|
967
|
-
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."
|
|
968
982
|
}
|
|
969
983
|
]);
|
|
970
984
|
var payFlags = flagsOf(payOrderInput, [
|
|
@@ -973,22 +987,22 @@ var payFlags = flagsOf(payOrderInput, [
|
|
|
973
987
|
field: "sharedPaymentToken",
|
|
974
988
|
type: "string",
|
|
975
989
|
placeholder: "<spt_\u2026>",
|
|
976
|
-
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."
|
|
977
991
|
},
|
|
978
992
|
{
|
|
979
|
-
flag: "
|
|
993
|
+
flag: "method",
|
|
980
994
|
field: "method",
|
|
981
|
-
type: "
|
|
982
|
-
|
|
983
|
-
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."
|
|
984
998
|
},
|
|
985
999
|
{
|
|
986
1000
|
flag: "total",
|
|
987
1001
|
field: "total",
|
|
988
1002
|
type: "string",
|
|
989
|
-
placeholder: "<
|
|
1003
|
+
placeholder: "<decimal>",
|
|
990
1004
|
required: "always",
|
|
991
|
-
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`."
|
|
992
1006
|
}
|
|
993
1007
|
]);
|
|
994
1008
|
var BODY_OPTION = {
|
|
@@ -1052,10 +1066,17 @@ var COMMANDS = [
|
|
|
1052
1066
|
{
|
|
1053
1067
|
group: "orders",
|
|
1054
1068
|
name: "cancel",
|
|
1055
|
-
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",
|
|
1056
1070
|
tool: "cancel_order",
|
|
1057
1071
|
flags: cancelFlags,
|
|
1058
|
-
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
|
+
]
|
|
1059
1080
|
},
|
|
1060
1081
|
{
|
|
1061
1082
|
group: "orders",
|
|
@@ -1093,21 +1114,6 @@ var COMMANDS = [
|
|
|
1093
1114
|
tool: null,
|
|
1094
1115
|
flags: []
|
|
1095
1116
|
},
|
|
1096
|
-
{
|
|
1097
|
-
group: null,
|
|
1098
|
-
name: "guide",
|
|
1099
|
-
summary: "Print the guide for AI agents (Markdown); `fortrip guide planning` prints the planning guide",
|
|
1100
|
-
tool: "get_planning_guide",
|
|
1101
|
-
flags: [],
|
|
1102
|
-
positionals: [
|
|
1103
|
-
{
|
|
1104
|
-
name: "topic",
|
|
1105
|
-
field: null,
|
|
1106
|
-
optional: true,
|
|
1107
|
-
description: "`planning` for the planning guide; left out, the main guide."
|
|
1108
|
-
}
|
|
1109
|
-
]
|
|
1110
|
-
},
|
|
1111
1117
|
{
|
|
1112
1118
|
group: null,
|
|
1113
1119
|
name: "mcp",
|
|
@@ -1260,17 +1266,17 @@ function strictify(schema) {
|
|
|
1260
1266
|
// src/guide-data.generated.ts
|
|
1261
1267
|
var FRAGMENTS = {
|
|
1262
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",
|
|
1263
|
-
"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` |\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",
|
|
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",
|
|
1264
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',
|
|
1265
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",
|
|
1266
|
-
"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
|
|
1267
|
-
"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
|
|
1268
|
-
"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}}
|
|
1269
|
-
"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
|
|
1270
|
-
"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
|
|
1271
|
-
"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
|
|
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",
|
|
1272
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",
|
|
1273
|
-
"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`)
|
|
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"
|
|
1274
1280
|
};
|
|
1275
1281
|
|
|
1276
1282
|
// src/guide.ts
|
|
@@ -1378,7 +1384,7 @@ function resolve(token, surface, shown) {
|
|
|
1378
1384
|
}
|
|
1379
1385
|
function toolName(spec, surface, token) {
|
|
1380
1386
|
if (surface === "cli") return commandInvocation(spec);
|
|
1381
|
-
if (spec.tool === null
|
|
1387
|
+
if (spec.tool === null) {
|
|
1382
1388
|
throw new Error(`Guide token ${token} has no tool on ${surface}`);
|
|
1383
1389
|
}
|
|
1384
1390
|
return surface === "mcp" ? spec.tool : `fortrip:${spec.tool}`;
|
|
@@ -1464,6 +1470,7 @@ var ERROR_CODES = {
|
|
|
1464
1470
|
stay_unsupported: { status: [422], retryable: false },
|
|
1465
1471
|
stay_in_past: { status: [422], retryable: false },
|
|
1466
1472
|
offer_unavailable: { status: [422], retryable: false },
|
|
1473
|
+
currency_unavailable: { status: [422], retryable: false },
|
|
1467
1474
|
rate_limited: { status: [429], retryable: true },
|
|
1468
1475
|
ordering_paused: { status: [503], retryable: true },
|
|
1469
1476
|
service_unavailable: { status: [503], retryable: true },
|
|
@@ -1542,12 +1549,7 @@ var indicativePrice = openObject({
|
|
|
1542
1549
|
kind: openEnum(["indicative"]),
|
|
1543
1550
|
basis: openEnum(["lowest_unit"]),
|
|
1544
1551
|
fromPerRoomNight: money,
|
|
1545
|
-
fromPerRoomStay: money
|
|
1546
|
-
approx: openObject({
|
|
1547
|
-
fromPerRoomNight: money,
|
|
1548
|
-
fromPerRoomStay: money,
|
|
1549
|
-
rateDate: localDate
|
|
1550
|
-
}).nullable()
|
|
1552
|
+
fromPerRoomStay: money
|
|
1551
1553
|
});
|
|
1552
1554
|
var hotelSummary = openObject({
|
|
1553
1555
|
hotelId,
|
|
@@ -1799,11 +1801,6 @@ var offer = openObject({
|
|
|
1799
1801
|
perNightAllRooms: money.describe(
|
|
1800
1802
|
"price.total divided by the nights: all rooms, one night. A search's fromPerRoomNight is for one room; divide by roomCount to compare."
|
|
1801
1803
|
),
|
|
1802
|
-
approx: openObject({
|
|
1803
|
-
total: money,
|
|
1804
|
-
perNightAllRooms: money,
|
|
1805
|
-
rateDate: localDate
|
|
1806
|
-
}).nullable(),
|
|
1807
1804
|
payAtProperty
|
|
1808
1805
|
}),
|
|
1809
1806
|
cancellation,
|
|
@@ -1872,6 +1869,7 @@ var PAYMENT_STATUSES = [
|
|
|
1872
1869
|
];
|
|
1873
1870
|
var CANCEL_REASONS = [
|
|
1874
1871
|
"cancellable",
|
|
1872
|
+
"unpaid",
|
|
1875
1873
|
"already_cancelled",
|
|
1876
1874
|
"in_progress",
|
|
1877
1875
|
"not_confirmed",
|
|
@@ -1904,6 +1902,39 @@ var paymentHandler = openObject({
|
|
|
1904
1902
|
business_profile: z14.string()
|
|
1905
1903
|
})
|
|
1906
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
|
+
]);
|
|
1907
1938
|
var orderReference = z14.string().regex(/^FT-[2-9A-HJ-NP-Z]{6}$/);
|
|
1908
1939
|
var hotelItem = openObject({
|
|
1909
1940
|
type: z14.literal("hotel"),
|
|
@@ -1931,7 +1962,7 @@ var order = openObject({
|
|
|
1931
1962
|
orderId,
|
|
1932
1963
|
reference: orderReference,
|
|
1933
1964
|
status: openEnum(ORDER_STATUSES).describe(
|
|
1934
|
-
"awaiting_payment: unpaid, nothing charged; payable until payment.expiresAt. expired: not paid
|
|
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."
|
|
1935
1966
|
),
|
|
1936
1967
|
createdAt: instant,
|
|
1937
1968
|
updatedAt: instant,
|
|
@@ -1944,55 +1975,32 @@ var order = openObject({
|
|
|
1944
1975
|
payment: openObject({
|
|
1945
1976
|
status: openEnum(PAYMENT_STATUSES),
|
|
1946
1977
|
url: z14.string().nullable().describe(
|
|
1947
|
-
"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."
|
|
1948
1979
|
),
|
|
1949
1980
|
requiresSignIn: z14.boolean(),
|
|
1950
1981
|
expiresAt: instant.nullable().describe(
|
|
1951
1982
|
"When the time to pay ends: an order unpaid by then expires, with nothing charged. null unless status is awaiting_payment."
|
|
1952
1983
|
),
|
|
1953
1984
|
chargeCurrency: z14.string().describe(
|
|
1954
|
-
"
|
|
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."
|
|
1955
1986
|
),
|
|
1956
1987
|
localCurrencyAtCheckout: z14.boolean().describe(
|
|
1957
|
-
"Whether paying by url may charge the card in its own currency, converted by Stripe; false once paid by token, Alipay or WeChat Pay."
|
|
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."
|
|
1958
1989
|
),
|
|
1959
|
-
localCharge: money.nullable().describe(
|
|
1960
|
-
|
|
1961
|
-
`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 $${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.`
|
|
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."
|
|
1962
1992
|
),
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
currency: z14.string().describe("The token's currency, lowercase as Stripe takes it: usd."),
|
|
1966
|
-
expiresAt: instant.describe(
|
|
1967
|
-
"Request the token valid until at least this time; the order can't be paid after it."
|
|
1968
|
-
)
|
|
1969
|
-
}).nullable().describe(
|
|
1970
|
-
"What the shared payment token for pay_order must allow. null exactly when handlers is []."
|
|
1971
|
-
),
|
|
1972
|
-
wallets: openObject({
|
|
1973
|
-
open: z14.boolean().describe("Whether pay_order has opened an Alipay or WeChat Pay payment on this order."),
|
|
1974
|
-
current: openEnum(["wechat_pay", "alipay"]).nullable().describe("Which of the two the payment is on now; null until it is open."),
|
|
1975
|
-
wechatPay: openObject({
|
|
1976
|
-
qrData: z14.string().nullable().describe(
|
|
1977
|
-
"The WeChat Pay code's content, to draw as a QR code; null when there is no live code (open wechatPay.url for one)."
|
|
1978
|
-
),
|
|
1979
|
-
qrImageUrl: z14.string().nullable().describe("A 480 px PNG of the same code."),
|
|
1980
|
-
url: z14.string().describe("A link, on fortrip.ai, for the user to pay with WeChat Pay; anyone holding it can pay.")
|
|
1981
|
-
}).nullable().describe("The WeChat Pay code and link; null until the payment is open."),
|
|
1982
|
-
alipay: openObject({
|
|
1983
|
-
url: z14.string().describe("A link, on fortrip.ai, for the user to pay with Alipay; anyone holding it can pay.")
|
|
1984
|
-
}).nullable().describe("The Alipay link; null until the payment is open.")
|
|
1985
|
-
}).nullable().describe(
|
|
1986
|
-
"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."
|
|
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."
|
|
1987
1995
|
)
|
|
1988
1996
|
}),
|
|
1989
1997
|
cancel: openObject({
|
|
1990
|
-
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."),
|
|
1991
1999
|
reason: openEnum(CANCEL_REASONS).describe(
|
|
1992
|
-
"cancellable
|
|
2000
|
+
"cancellable: a paid order can be cancelled now; unpaid: an unpaid order can be closed; otherwise why not."
|
|
1993
2001
|
),
|
|
1994
2002
|
penalty: money.nullable().describe(
|
|
1995
|
-
"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."
|
|
1996
2004
|
),
|
|
1997
2005
|
refund: money.nullable().describe(
|
|
1998
2006
|
"What a cancellation now refunds: what was paid less the penalty, in the charge currency; null when not stated."
|
|
@@ -2107,6 +2115,7 @@ var ERROR_DETAILS = {
|
|
|
2107
2115
|
offerId,
|
|
2108
2116
|
reason: openEnum(["sold_out", "refused"])
|
|
2109
2117
|
}),
|
|
2118
|
+
currency_unavailable: openObject({ currency: z15.string() }),
|
|
2110
2119
|
rate_limited: openObject({
|
|
2111
2120
|
scope: openEnum([
|
|
2112
2121
|
"search",
|
|
@@ -2227,19 +2236,21 @@ var ORDER_NEXT_STEP = "Before you give the user an order's payment.url, show the
|
|
|
2227
2236
|
var CALLS = {
|
|
2228
2237
|
mcp: {
|
|
2229
2238
|
cancel: "call cancel_order",
|
|
2230
|
-
penalty:
|
|
2239
|
+
penalty: "Pass maximumPenalty as cancel.penalty, exactly as returned.",
|
|
2240
|
+
close: "call cancel_order",
|
|
2231
2241
|
pay: "call pay_order",
|
|
2232
|
-
payWallet: " with method
|
|
2242
|
+
payWallet: " with method stripe_alipay_wechat_pay",
|
|
2233
2243
|
get: "call get_order",
|
|
2234
2244
|
poll: "poll get_order",
|
|
2235
2245
|
payWith: "call pay_order with it and the order's price.total",
|
|
2236
2246
|
paid: "pay_order"
|
|
2237
2247
|
},
|
|
2238
2248
|
cli: {
|
|
2239
|
-
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`",
|
|
2240
2251
|
penalty: "Pass the penalty's amount as --max-penalty (120.00 for a penalty of USD 120.00).",
|
|
2241
2252
|
pay: "run `fortrip orders pay`",
|
|
2242
|
-
payWallet: " with --
|
|
2253
|
+
payWallet: " with --method stripe_alipay_wechat_pay",
|
|
2243
2254
|
get: "run `fortrip orders get <orderId>`",
|
|
2244
2255
|
poll: "poll it with `fortrip orders get <orderId>`",
|
|
2245
2256
|
payWith: "run `fortrip orders pay <orderId> --token <spt_\u2026> --total <total>` with the token and the order's total",
|
|
@@ -2253,15 +2264,15 @@ function cancelNextStep(surface) {
|
|
|
2253
2264
|
var CANCEL_NEXT_STEP = cancelNextStep("mcp");
|
|
2254
2265
|
function payNextStep(surface) {
|
|
2255
2266
|
const c = CALLS[surface];
|
|
2256
|
-
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.`;
|
|
2257
2268
|
}
|
|
2258
2269
|
var PAY_NEXT_STEP = payNextStep("mcp");
|
|
2259
2270
|
function walletNextStep(surface) {
|
|
2260
2271
|
const c = CALLS[surface];
|
|
2261
|
-
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}.`;
|
|
2262
2273
|
}
|
|
2263
2274
|
var WALLET_NEXT_STEP = walletNextStep("mcp");
|
|
2264
|
-
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.";
|
|
2265
2276
|
var nextStep = z16.string().optional().describe(
|
|
2266
2277
|
"What to show and ask before giving a payment.url. Present when the answer holds a non-null payment.url, and only then."
|
|
2267
2278
|
);
|
|
@@ -2280,14 +2291,6 @@ var READ = {
|
|
|
2280
2291
|
};
|
|
2281
2292
|
var READ_OWN = { ...READ, openWorldHint: false };
|
|
2282
2293
|
var TOOLS = [
|
|
2283
|
-
{
|
|
2284
|
-
name: "get_planning_guide",
|
|
2285
|
-
title: "Planning guide",
|
|
2286
|
-
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.`,
|
|
2287
|
-
annotations: READ_OWN,
|
|
2288
|
-
input: null,
|
|
2289
|
-
output: null
|
|
2290
|
-
},
|
|
2291
2294
|
{
|
|
2292
2295
|
name: "search_hotels",
|
|
2293
2296
|
title: "Search hotels",
|
|
@@ -2307,7 +2310,7 @@ var TOOLS = [
|
|
|
2307
2310
|
{
|
|
2308
2311
|
name: "get_hotel_offers",
|
|
2309
2312
|
title: "Live offers",
|
|
2310
|
-
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
|
|
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.`,
|
|
2311
2314
|
annotations: READ,
|
|
2312
2315
|
input: hotelOffersInput,
|
|
2313
2316
|
output: hotelOffersResult
|
|
@@ -2344,7 +2347,7 @@ var TOOLS = [
|
|
|
2344
2347
|
{
|
|
2345
2348
|
name: "cancel_order",
|
|
2346
2349
|
title: "Cancel order",
|
|
2347
|
-
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.`,
|
|
2348
2351
|
annotations: {
|
|
2349
2352
|
readOnlyHint: false,
|
|
2350
2353
|
idempotentHint: true,
|
|
@@ -2357,7 +2360,7 @@ var TOOLS = [
|
|
|
2357
2360
|
{
|
|
2358
2361
|
name: "pay_order",
|
|
2359
2362
|
title: "Pay order",
|
|
2360
|
-
description: `Pay an order without its link, by shared payment token or Alipay/WeChat Pay (method
|
|
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.`,
|
|
2361
2364
|
annotations: {
|
|
2362
2365
|
readOnlyHint: false,
|
|
2363
2366
|
idempotentHint: true,
|
|
@@ -2590,10 +2593,7 @@ function roomText(r) {
|
|
|
2590
2593
|
}
|
|
2591
2594
|
function offerLine(o) {
|
|
2592
2595
|
const p = o.price;
|
|
2593
|
-
|
|
2594
|
-
if (p.approx) {
|
|
2595
|
-
price += ` \u2248 ${money2(p.approx.total)} (${money2(p.approx.perNightAllRooms)} per night), exchange rate of ${p.approx.rateDate}`;
|
|
2596
|
-
}
|
|
2596
|
+
const price = `${money2(p.total)} total (${money2(p.perNightAllRooms)} per night, all rooms)`;
|
|
2597
2597
|
return [
|
|
2598
2598
|
`${o.offerId}${o.type === "hotel" ? "" : ` (${o.type})`}`,
|
|
2599
2599
|
`${plural(o.hotel.roomCount, "room")}: ${roomText(o.hotel.room)}`,
|
|
@@ -2653,9 +2653,12 @@ function renderOffers(r, surface = "mcp") {
|
|
|
2653
2653
|
}
|
|
2654
2654
|
|
|
2655
2655
|
// src/render/order.ts
|
|
2656
|
+
function methodOf(o, id) {
|
|
2657
|
+
return o.payment.methods.find((m) => m.id === id);
|
|
2658
|
+
}
|
|
2656
2659
|
var ORDER_STATUS_WORDS = {
|
|
2657
2660
|
awaiting_payment: "awaiting payment",
|
|
2658
|
-
expired: "
|
|
2661
|
+
expired: "not paid: the time ran out or it was closed",
|
|
2659
2662
|
confirming: "confirming with the hotel",
|
|
2660
2663
|
confirmed: "confirmed",
|
|
2661
2664
|
failed: "failed",
|
|
@@ -2674,6 +2677,7 @@ var PAYMENT_WORDS = {
|
|
|
2674
2677
|
var SUPPORT = `for help, the user emails ${SUPPORT_EMAIL} with the order's reference`;
|
|
2675
2678
|
var CANCEL_REASON_WORDS = {
|
|
2676
2679
|
cancellable: "it can be cancelled",
|
|
2680
|
+
unpaid: "it isn't paid: it can be closed if the user no longer wants it",
|
|
2677
2681
|
already_cancelled: "it is already cancelled",
|
|
2678
2682
|
in_progress: "a cancellation is in progress",
|
|
2679
2683
|
not_confirmed: "only a confirmed order that is paid can be cancelled",
|
|
@@ -2717,24 +2721,22 @@ function paymentLines(o, surface) {
|
|
|
2717
2721
|
p.requiresSignIn ? "the user signs in to Fortrip to pay" : "no sign-in needed"
|
|
2718
2722
|
].filter(Boolean);
|
|
2719
2723
|
lines.push(`Payment link (${about.join("; ")}): ${p.url}`);
|
|
2720
|
-
} else if (o.status === "awaiting_payment") {
|
|
2724
|
+
} else if (o.status === "awaiting_payment" && p.status === "unpaid") {
|
|
2721
2725
|
lines.push("Payment link: could not be read this time; read this order again for it.");
|
|
2722
2726
|
}
|
|
2723
|
-
|
|
2724
|
-
if (
|
|
2725
|
-
|
|
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));
|
|
2726
2732
|
lines.push(`Manage: ${o.manageUrl}`);
|
|
2727
2733
|
return lines;
|
|
2728
2734
|
}
|
|
2729
|
-
function
|
|
2730
|
-
const {
|
|
2735
|
+
function tokenLine(o, token, surface) {
|
|
2736
|
+
const { handler: h, limits } = token;
|
|
2731
2737
|
const pay = surface === "cli" ? `\`fortrip orders pay ${o.orderId} --token <spt_\u2026> --total ${o.price.total.amount}\`` : "pay_order";
|
|
2732
|
-
const shown = handlers.map(
|
|
2733
|
-
(h) => `${h.type} (handler ${h.id}, business_profile ${h.config.business_profile})`
|
|
2734
|
-
);
|
|
2735
|
-
const limit = limits ? `; token limits: maxAmount ${limits.maxAmount} (cents), currency ${limits.currency}, expiresAt ${limits.expiresAt}` : "";
|
|
2736
2738
|
return [
|
|
2737
|
-
`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}.`,
|
|
2738
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.",
|
|
2739
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"}.`
|
|
2740
2742
|
].join(" ");
|
|
@@ -2742,7 +2744,7 @@ function handlersLine(o, surface) {
|
|
|
2742
2744
|
function walletLines(w, surface) {
|
|
2743
2745
|
const c = CALLS[surface];
|
|
2744
2746
|
if (!w.open) {
|
|
2745
|
-
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";
|
|
2746
2748
|
return [`Pay with Alipay or WeChat Pay: ${pay}.`];
|
|
2747
2749
|
}
|
|
2748
2750
|
const lines = [];
|
|
@@ -2759,9 +2761,13 @@ function walletLines(w, surface) {
|
|
|
2759
2761
|
);
|
|
2760
2762
|
return lines;
|
|
2761
2763
|
}
|
|
2762
|
-
function cancelLine(o) {
|
|
2764
|
+
function cancelLine(o, surface) {
|
|
2763
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
|
+
}
|
|
2764
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";
|
|
2765
2771
|
const at = o.payment.expiresAt === null ? "" : ` at ${when(o.payment.expiresAt, null)}`;
|
|
2766
2772
|
return `Cancel: not needed: an unpaid order expires unpaid${at}`;
|
|
2767
2773
|
}
|
|
@@ -2915,9 +2921,6 @@ function priceWords(h, status) {
|
|
|
2915
2921
|
return status === "ok" ? "no indicative price" : "price unavailable this time";
|
|
2916
2922
|
}
|
|
2917
2923
|
let text2 = `from ${money2(p.fromPerRoomNight)}/room-night (${money2(p.fromPerRoomStay)} per room for the stay)`;
|
|
2918
|
-
if (p.approx) {
|
|
2919
|
-
text2 += ` \u2248 ${money2(p.approx.fromPerRoomNight)}/room-night (${money2(p.approx.fromPerRoomStay)}), exchange rate of ${p.approx.rateDate}`;
|
|
2920
|
-
}
|
|
2921
2924
|
if (p.kind !== "indicative" || p.basis !== "lowest_unit") {
|
|
2922
2925
|
text2 += ` [${p.kind}, ${p.basis}]`;
|
|
2923
2926
|
}
|
|
@@ -3115,7 +3118,7 @@ function detailLines(e, surface) {
|
|
|
3115
3118
|
];
|
|
3116
3119
|
case "payment_credential_invalid":
|
|
3117
3120
|
return [
|
|
3118
|
-
`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.`
|
|
3119
3122
|
];
|
|
3120
3123
|
case "payment_declined":
|
|
3121
3124
|
return [
|
|
@@ -3137,6 +3140,8 @@ function detailLines(e, surface) {
|
|
|
3137
3140
|
return [
|
|
3138
3141
|
`Offer ${e.details.offerId}: ${label({ sold_out: "sold out", refused: "can no longer be booked" }, e.details.reason)}. Get fresh offers.`
|
|
3139
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.`];
|
|
3140
3145
|
case "rate_limited":
|
|
3141
3146
|
return [`Limit reached for: ${e.details.scope}.`];
|
|
3142
3147
|
case "supplier_unavailable":
|
|
@@ -3201,8 +3206,8 @@ ${raw(data)}`;
|
|
|
3201
3206
|
return [
|
|
3202
3207
|
text2,
|
|
3203
3208
|
ORDER_TOOLS.has(tool) && holdsPaymentUrl(data) ? ORDER_NEXT_STEP : "",
|
|
3204
|
-
ORDER_TOOLS.has(tool) &&
|
|
3205
|
-
ORDER_TOOLS.has(tool) &&
|
|
3209
|
+
ORDER_TOOLS.has(tool) && holdsMethod(data, isTokenMethod) ? payNextStep(surface) : "",
|
|
3210
|
+
ORDER_TOOLS.has(tool) && holdsMethod(data, isWalletOffer) ? walletNextStep(surface) : "",
|
|
3206
3211
|
CANCEL_TOOLS.has(tool) && holdsCancellable(data) ? cancelNextStep(surface) : ""
|
|
3207
3212
|
].filter(Boolean).join("\n\n");
|
|
3208
3213
|
}
|
|
@@ -3238,32 +3243,23 @@ function holdsPaymentUrl(value, seen = /* @__PURE__ */ new Set()) {
|
|
|
3238
3243
|
}
|
|
3239
3244
|
return Object.values(value).some((v) => holdsPaymentUrl(v, seen));
|
|
3240
3245
|
}
|
|
3241
|
-
|
|
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()) {
|
|
3242
3249
|
if (typeof value !== "object" || value === null || seen.has(value)) return false;
|
|
3243
3250
|
seen.add(value);
|
|
3244
3251
|
const payment = value.payment;
|
|
3245
|
-
|
|
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))) {
|
|
3246
3254
|
return true;
|
|
3247
3255
|
}
|
|
3248
|
-
return Object.values(value).some((v) =>
|
|
3249
|
-
}
|
|
3250
|
-
function holdsWalletOffer(value, seen = /* @__PURE__ */ new Set()) {
|
|
3251
|
-
if (typeof value !== "object" || value === null || seen.has(value)) return false;
|
|
3252
|
-
seen.add(value);
|
|
3253
|
-
const payment = value.payment;
|
|
3254
|
-
if (typeof payment === "object" && payment !== null) {
|
|
3255
|
-
const wallets = payment.wallets;
|
|
3256
|
-
if (typeof wallets === "object" && wallets !== null && wallets.open === false) {
|
|
3257
|
-
return true;
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
return Object.values(value).some((v) => holdsWalletOffer(v, seen));
|
|
3256
|
+
return Object.values(value).some((v) => holdsMethod(v, match, seen));
|
|
3261
3257
|
}
|
|
3262
3258
|
function holdsCancellable(value, seen = /* @__PURE__ */ new Set()) {
|
|
3263
3259
|
if (typeof value !== "object" || value === null || seen.has(value)) return false;
|
|
3264
3260
|
seen.add(value);
|
|
3265
3261
|
const cancel = value.cancel;
|
|
3266
|
-
if (typeof cancel === "object" && cancel !== null && cancel.available === true) {
|
|
3262
|
+
if (typeof cancel === "object" && cancel !== null && cancel.available === true && cancel.reason !== "unpaid") {
|
|
3267
3263
|
return true;
|
|
3268
3264
|
}
|
|
3269
3265
|
return Object.values(value).some((v) => holdsCancellable(v, seen));
|
|
@@ -3272,9 +3268,9 @@ function withConsent(tool, surface, text2, orders) {
|
|
|
3272
3268
|
return [
|
|
3273
3269
|
text2,
|
|
3274
3270
|
orders.some((o) => o.payment.url !== null) ? ORDER_NEXT_STEP : "",
|
|
3275
|
-
orders.some((o) => o
|
|
3276
|
-
orders.some((o) => o
|
|
3277
|
-
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) : ""
|
|
3278
3274
|
].filter(Boolean).join("\n\n");
|
|
3279
3275
|
}
|
|
3280
3276
|
|
|
@@ -3304,8 +3300,8 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
|
|
|
3304
3300
|
requiresSignIn: `${API_DECIDES} (whether the payment link needs a website sign-in).`,
|
|
3305
3301
|
localCurrencyAtCheckout: `${API_DECIDES} (whether checkout may charge in the card's currency).`,
|
|
3306
3302
|
"cancel.available": `${API_DECIDES} (whether an order can be cancelled now).`,
|
|
3307
|
-
"payment.
|
|
3308
|
-
"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).`,
|
|
3309
3305
|
available_instruments: `${RESULT_LIST} (the instruments a payment handler takes).`,
|
|
3310
3306
|
bookable: `${API_DECIDES} (whether the hotel is still in the index).`,
|
|
3311
3307
|
cityLike: `${API_DECIDES} (frozen per gazetteer release; null where not computed).`,
|
|
@@ -3330,7 +3326,7 @@ var ME_SCOPES = { email: "email", name: "profile" };
|
|
|
3330
3326
|
// package.json
|
|
3331
3327
|
var package_default = {
|
|
3332
3328
|
name: "@fortrip/agent-contract",
|
|
3333
|
-
version: "
|
|
3329
|
+
version: "5.0.0-rc.1",
|
|
3334
3330
|
license: "Apache-2.0",
|
|
3335
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.",
|
|
3336
3332
|
type: "module",
|
|
@@ -3397,7 +3393,7 @@ export {
|
|
|
3397
3393
|
COMMAND_GROUPS,
|
|
3398
3394
|
CONTRACT_VERSION,
|
|
3399
3395
|
CREDENTIAL_INVALID_REASONS,
|
|
3400
|
-
|
|
3396
|
+
CURRENCIES,
|
|
3401
3397
|
DOCS_ORIGIN,
|
|
3402
3398
|
ERROR_CODES,
|
|
3403
3399
|
ERROR_DETAILS,
|
|
@@ -3415,6 +3411,7 @@ export {
|
|
|
3415
3411
|
ORDER_HTTP,
|
|
3416
3412
|
ORDER_NEXT_STEP,
|
|
3417
3413
|
ORDER_STATUSES,
|
|
3414
|
+
PAYMENT_METHOD_IDS,
|
|
3418
3415
|
PAYMENT_STATUSES,
|
|
3419
3416
|
PAY_INPUT_WAYS,
|
|
3420
3417
|
PAY_NEXT_STEP,
|
|
@@ -3492,6 +3489,7 @@ export {
|
|
|
3492
3489
|
payNextStep,
|
|
3493
3490
|
payOrderInput,
|
|
3494
3491
|
paymentHandler,
|
|
3492
|
+
paymentMethod,
|
|
3495
3493
|
photo,
|
|
3496
3494
|
place,
|
|
3497
3495
|
placeId,
|
|
@@ -3500,6 +3498,7 @@ export {
|
|
|
3500
3498
|
renderError,
|
|
3501
3499
|
renderGuide,
|
|
3502
3500
|
renderToolResult,
|
|
3501
|
+
requestMoney,
|
|
3503
3502
|
roomFacts,
|
|
3504
3503
|
routePath,
|
|
3505
3504
|
searchHotelsInput,
|
|
@@ -3511,7 +3510,6 @@ export {
|
|
|
3511
3510
|
strictOutput,
|
|
3512
3511
|
text,
|
|
3513
3512
|
timeZone,
|
|
3514
|
-
usdMoney,
|
|
3515
3513
|
walletNextStep,
|
|
3516
3514
|
wholeNumber
|
|
3517
3515
|
};
|