@fortrip/agent-contract 4.3.1 → 5.0.0-rc.2
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 +540 -238
- package/dist/index.js +227 -243
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -94,6 +94,50 @@ 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
|
+
};
|
|
137
|
+
var CURRENCIES = ["USD", "CNY"];
|
|
138
|
+
var SUPPORT_EMAIL = "info@fortrip.ai";
|
|
139
|
+
|
|
140
|
+
// src/conventions/money.ts
|
|
97
141
|
var amountError = "amount must be a decimal string such as 132.40";
|
|
98
142
|
var currencyError = "currency must be a 3-letter uppercase ISO 4217 code";
|
|
99
143
|
var money = z2.looseObject({
|
|
@@ -104,15 +148,26 @@ var money = z2.looseObject({
|
|
|
104
148
|
error: currencyError
|
|
105
149
|
})
|
|
106
150
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
151
|
+
function requestMoney(name) {
|
|
152
|
+
return z2.strictObject(
|
|
153
|
+
{
|
|
154
|
+
amount: z2.string({ error: amountError }).regex(/^\d+(\.\d+)?$/, { error: amountError }).describe("Decimal string such as 132.40, never a number."),
|
|
155
|
+
currency: z2.enum(CURRENCIES, { error: "currency must be USD or CNY" }).describe("USD or CNY.")
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
error: (issue) => issue.code === "unrecognized_keys" ? `Unknown field(s): ${issue.keys.join(", ")}` : `${name} must be Money: { amount: "132.40", currency: "USD" or "CNY" }`
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
function echoedMoney(name) {
|
|
163
|
+
return z2.looseObject(
|
|
164
|
+
{
|
|
165
|
+
amount: z2.string({ error: amountError }).regex(/^\d+(\.\d+)?$/, { error: amountError }).describe("Decimal string such as 132.40, never a number."),
|
|
166
|
+
currency: z2.string({ error: currencyError }).regex(/^[A-Z]{3}$/, { error: currencyError }).describe("3-letter uppercase ISO 4217 code, as returned.")
|
|
167
|
+
},
|
|
168
|
+
{ error: `${name} must be Money as returned: { amount: "132.40", currency: "USD" }` }
|
|
169
|
+
);
|
|
170
|
+
}
|
|
116
171
|
function formatMoney(m) {
|
|
117
172
|
return `${m.currency} ${m.amount}`;
|
|
118
173
|
}
|
|
@@ -165,51 +220,6 @@ function flag(name) {
|
|
|
165
220
|
return z4.boolean({ error: `${name} must be true or false` });
|
|
166
221
|
}
|
|
167
222
|
|
|
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
223
|
// src/vocabulary.ts
|
|
214
224
|
var FILTERABLE_AMENITIES = [
|
|
215
225
|
"parking",
|
|
@@ -246,12 +256,7 @@ var SEARCH_SORTS = [
|
|
|
246
256
|
var locale = oneOf("locale", ["en", "zh"]).describe(
|
|
247
257
|
"Language for names and text in the response: en or zh."
|
|
248
258
|
);
|
|
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
|
-
);
|
|
259
|
+
var currencyDescription = "The currency to price and charge in: USD (default) or CNY, where available (otherwise the answer is currency_unavailable).";
|
|
255
260
|
var cursor = nonEmpty("cursor");
|
|
256
261
|
var nightsError = (name) => `${name} must be after the check-in date and at most ${LIMITS.nightsFortrip} nights later`;
|
|
257
262
|
var stay = strictInput({
|
|
@@ -375,8 +380,8 @@ var searchFilters = strictInput({
|
|
|
375
380
|
"Amenities every hotel must list. Only some codes can filter; asking for one that cannot is answered with the list that can."
|
|
376
381
|
),
|
|
377
382
|
price: strictInput({
|
|
378
|
-
maxPerRoomNight:
|
|
379
|
-
"Highest price per room per night, in
|
|
383
|
+
maxPerRoomNight: requestMoney("filters.price.maxPerRoomNight").describe(
|
|
384
|
+
"Highest price per room per night, in the search's currency."
|
|
380
385
|
)
|
|
381
386
|
}).optional().describe("Price limit. Needs indicative pricing, so a stay.")
|
|
382
387
|
}).optional().describe("Filters every hotel in the answer must pass.");
|
|
@@ -404,7 +409,7 @@ function createSearchHotelsInput(now = Date.now) {
|
|
|
404
409
|
"`nextCursor` from the previous response. A next page is the cursor and, optionally, `limit`; nothing else."
|
|
405
410
|
),
|
|
406
411
|
locale: locale.optional(),
|
|
407
|
-
|
|
412
|
+
currency: oneOf("currency", CURRENCIES).optional().describe(currencyDescription)
|
|
408
413
|
}).superRefine((input, ctx) => {
|
|
409
414
|
const issue = (path, message) => ctx.addIssue({ code: "custom", path, message });
|
|
410
415
|
if (input.cursor !== void 0) {
|
|
@@ -446,6 +451,14 @@ function createSearchHotelsInput(now = Date.now) {
|
|
|
446
451
|
);
|
|
447
452
|
}
|
|
448
453
|
}
|
|
454
|
+
const bound = input.filters?.price?.maxPerRoomNight;
|
|
455
|
+
const searchCurrency = input.currency ?? "USD";
|
|
456
|
+
if (bound !== void 0 && bound.currency !== searchCurrency) {
|
|
457
|
+
issue(
|
|
458
|
+
["filters", "price", "maxPerRoomNight", "currency"],
|
|
459
|
+
`filters.price.maxPerRoomNight.currency is ${bound.currency}, but the search is in ${searchCurrency}${input.currency === void 0 ? " (the default)" : ""}: send the price in ${searchCurrency}`
|
|
460
|
+
);
|
|
461
|
+
}
|
|
449
462
|
const checkIn = input.stay?.checkIn;
|
|
450
463
|
if (checkIn !== void 0 && isIsoDate(checkIn)) {
|
|
451
464
|
const earliest = new Date(now() - 12 * 36e5).toISOString().slice(0, 10);
|
|
@@ -477,7 +490,7 @@ var hotelOffersInput = strictInput({
|
|
|
477
490
|
`Offers per hotel, 1 to ${LIMITS.offersPerHotelMax}. Default ${LIMITS.offersPerHotelDefault}.`
|
|
478
491
|
),
|
|
479
492
|
locale: locale.optional(),
|
|
480
|
-
|
|
493
|
+
currency: oneOf("currency", CURRENCIES).optional().describe(`${currencyDescription} An order made from these offers is charged in this currency.`)
|
|
481
494
|
});
|
|
482
495
|
function cardFreeText(name, min, max, minDigits) {
|
|
483
496
|
return text(name, min, max).refine(
|
|
@@ -576,11 +589,10 @@ var listOrdersInput = strictInput({
|
|
|
576
589
|
),
|
|
577
590
|
locale: locale.optional()
|
|
578
591
|
});
|
|
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
592
|
var cancelOrderInput = strictInput({
|
|
581
593
|
orderId: orderId.describe("The orderId of the order to cancel."),
|
|
582
|
-
maximumPenalty:
|
|
583
|
-
|
|
594
|
+
maximumPenalty: echoedMoney("maximumPenalty").optional().describe(
|
|
595
|
+
"The penalty the user agreed to: the order's cancel.penalty, exactly as returned. Ignored when closing an unpaid order."
|
|
584
596
|
)
|
|
585
597
|
});
|
|
586
598
|
var sharedPaymentTokenRe = /^spt_[A-Za-z0-9]{1,250}$/;
|
|
@@ -606,7 +618,7 @@ var ucpInstrument = z5.looseObject(
|
|
|
606
618
|
"The credential type: stripe_payment_token for the selected one."
|
|
607
619
|
),
|
|
608
620
|
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
|
|
621
|
+
"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
622
|
)
|
|
611
623
|
},
|
|
612
624
|
{ error: "credential must be a JSON object" }
|
|
@@ -638,16 +650,16 @@ function selectedOf(instruments) {
|
|
|
638
650
|
}
|
|
639
651
|
return chosen;
|
|
640
652
|
}
|
|
641
|
-
var PAY_WAYS = ["payment_link", "
|
|
653
|
+
var PAY_WAYS = ["payment_link", "stripe_shared_payment_token", "stripe_alipay_wechat_pay"];
|
|
642
654
|
var PAY_INPUT_WAYS = {
|
|
643
|
-
sharedPaymentToken: "
|
|
644
|
-
payment: "
|
|
645
|
-
method: "
|
|
655
|
+
sharedPaymentToken: "stripe_shared_payment_token",
|
|
656
|
+
payment: "stripe_shared_payment_token",
|
|
657
|
+
method: "stripe_alipay_wechat_pay"
|
|
646
658
|
};
|
|
647
659
|
var payOrderInput = strictInput({
|
|
648
660
|
orderId: orderId.describe("The orderId of the order to pay."),
|
|
649
661
|
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
|
|
662
|
+
"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
663
|
),
|
|
652
664
|
payment: strictInput({
|
|
653
665
|
instruments: z5.array(ucpInstrument, { error: instrumentsError }).min(1, { error: instrumentsError }).max(8, { error: instrumentsError }).describe("The instruments, exactly one of them selected.")
|
|
@@ -685,11 +697,11 @@ var payOrderInput = strictInput({
|
|
|
685
697
|
}).optional().describe(
|
|
686
698
|
"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
699
|
),
|
|
688
|
-
method: oneOf("method", ["
|
|
689
|
-
"Pay
|
|
700
|
+
method: oneOf("method", ["stripe_alipay_wechat_pay"]).optional().describe(
|
|
701
|
+
"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
702
|
),
|
|
691
|
-
total:
|
|
692
|
-
"The total the user approved: the order's price.total, exactly as returned."
|
|
703
|
+
total: requestMoney("total").describe(
|
|
704
|
+
"The total the user approved: the order's price.total, in its currency, exactly as returned."
|
|
693
705
|
)
|
|
694
706
|
}).superRefine((input, ctx) => {
|
|
695
707
|
const given = [
|
|
@@ -766,11 +778,11 @@ var localeFlag = {
|
|
|
766
778
|
type: "string",
|
|
767
779
|
placeholder: LOCALES
|
|
768
780
|
};
|
|
769
|
-
var
|
|
770
|
-
flag: "
|
|
771
|
-
field: "
|
|
781
|
+
var currencyFlag = {
|
|
782
|
+
flag: "currency",
|
|
783
|
+
field: "currency",
|
|
772
784
|
type: "string",
|
|
773
|
-
placeholder:
|
|
785
|
+
placeholder: CURRENCIES.join("|")
|
|
774
786
|
};
|
|
775
787
|
function stayFlags(roomDescription) {
|
|
776
788
|
return [
|
|
@@ -872,8 +884,8 @@ var searchFlags = flagsOf(searchHotelsInput, [
|
|
|
872
884
|
flag: "price-max-per-room-night",
|
|
873
885
|
field: "filters.price.maxPerRoomNight",
|
|
874
886
|
type: "string",
|
|
875
|
-
placeholder: "<
|
|
876
|
-
description: "Highest indicative price per room per night, in USD, e.g. `150` or `149.50`. Needs a stay."
|
|
887
|
+
placeholder: "<decimal>",
|
|
888
|
+
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
889
|
},
|
|
878
890
|
{
|
|
879
891
|
flag: "sort",
|
|
@@ -890,7 +902,7 @@ var searchFlags = flagsOf(searchHotelsInput, [
|
|
|
890
902
|
description: "`nextCursor` from the previous page. A next page takes only `--cursor` and `--limit`."
|
|
891
903
|
},
|
|
892
904
|
localeFlag,
|
|
893
|
-
|
|
905
|
+
currencyFlag
|
|
894
906
|
]);
|
|
895
907
|
var hotelFlags = flagsOf(getHotelInput, [
|
|
896
908
|
{
|
|
@@ -922,7 +934,7 @@ var offersFlags = flagsOf(hotelOffersInput, [
|
|
|
922
934
|
},
|
|
923
935
|
{ flag: "limit-per-hotel", field: "limitPerHotel", type: "number", placeholder: COUNT },
|
|
924
936
|
localeFlag,
|
|
925
|
-
|
|
937
|
+
currencyFlag
|
|
926
938
|
]);
|
|
927
939
|
var bookFlags = flagsOf(createOrderInput, [
|
|
928
940
|
{
|
|
@@ -961,10 +973,9 @@ var cancelFlags = flagsOf(cancelOrderInput, [
|
|
|
961
973
|
{
|
|
962
974
|
flag: "max-penalty",
|
|
963
975
|
field: "maximumPenalty",
|
|
964
|
-
type: "
|
|
965
|
-
optional: true,
|
|
976
|
+
type: "string",
|
|
966
977
|
placeholder: "<amount>",
|
|
967
|
-
description: "
|
|
978
|
+
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
979
|
}
|
|
969
980
|
]);
|
|
970
981
|
var payFlags = flagsOf(payOrderInput, [
|
|
@@ -973,22 +984,22 @@ var payFlags = flagsOf(payOrderInput, [
|
|
|
973
984
|
field: "sharedPaymentToken",
|
|
974
985
|
type: "string",
|
|
975
986
|
placeholder: "<spt_\u2026>",
|
|
976
|
-
description: "Required unless --
|
|
987
|
+
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
988
|
},
|
|
978
989
|
{
|
|
979
|
-
flag: "
|
|
990
|
+
flag: "method",
|
|
980
991
|
field: "method",
|
|
981
|
-
type: "
|
|
982
|
-
|
|
983
|
-
description: "Pay
|
|
992
|
+
type: "string",
|
|
993
|
+
placeholder: "stripe_alipay_wechat_pay",
|
|
994
|
+
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
995
|
},
|
|
985
996
|
{
|
|
986
997
|
flag: "total",
|
|
987
998
|
field: "total",
|
|
988
999
|
type: "string",
|
|
989
|
-
placeholder: "<
|
|
1000
|
+
placeholder: "<decimal>",
|
|
990
1001
|
required: "always",
|
|
991
|
-
description: "The total the user approved, exactly as `orders get` shows it, in
|
|
1002
|
+
description: "The total the user approved, exactly as `orders get` shows it, in the order's currency, e.g. `125.00`."
|
|
992
1003
|
}
|
|
993
1004
|
]);
|
|
994
1005
|
var BODY_OPTION = {
|
|
@@ -1052,10 +1063,17 @@ var COMMANDS = [
|
|
|
1052
1063
|
{
|
|
1053
1064
|
group: "orders",
|
|
1054
1065
|
name: "cancel",
|
|
1055
|
-
summary: "
|
|
1066
|
+
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
1067
|
tool: "cancel_order",
|
|
1057
1068
|
flags: cancelFlags,
|
|
1058
|
-
positionals: [positional(cancelOrderInput, "orderId")]
|
|
1069
|
+
positionals: [positional(cancelOrderInput, "orderId")],
|
|
1070
|
+
options: [
|
|
1071
|
+
{
|
|
1072
|
+
flag: "close",
|
|
1073
|
+
type: "boolean",
|
|
1074
|
+
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."
|
|
1075
|
+
}
|
|
1076
|
+
]
|
|
1059
1077
|
},
|
|
1060
1078
|
{
|
|
1061
1079
|
group: "orders",
|
|
@@ -1093,21 +1111,6 @@ var COMMANDS = [
|
|
|
1093
1111
|
tool: null,
|
|
1094
1112
|
flags: []
|
|
1095
1113
|
},
|
|
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
1114
|
{
|
|
1112
1115
|
group: null,
|
|
1113
1116
|
name: "mcp",
|
|
@@ -1260,17 +1263,17 @@ function strictify(schema) {
|
|
|
1260
1263
|
// src/guide-data.generated.ts
|
|
1261
1264
|
var FRAGMENTS = {
|
|
1262
1265
|
"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
|
|
1266
|
+
"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, even when its order failed or expired: to order with other details, get offers again |\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
1267
|
"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
1268
|
"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
|
|
1269
|
+
"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',
|
|
1270
|
+
"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",
|
|
1271
|
+
"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",
|
|
1272
|
+
"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",
|
|
1273
|
+
"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",
|
|
1274
|
+
"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
1275
|
"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`)
|
|
1276
|
+
"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
1277
|
};
|
|
1275
1278
|
|
|
1276
1279
|
// src/guide.ts
|
|
@@ -1378,7 +1381,7 @@ function resolve(token, surface, shown) {
|
|
|
1378
1381
|
}
|
|
1379
1382
|
function toolName(spec, surface, token) {
|
|
1380
1383
|
if (surface === "cli") return commandInvocation(spec);
|
|
1381
|
-
if (spec.tool === null
|
|
1384
|
+
if (spec.tool === null) {
|
|
1382
1385
|
throw new Error(`Guide token ${token} has no tool on ${surface}`);
|
|
1383
1386
|
}
|
|
1384
1387
|
return surface === "mcp" ? spec.tool : `fortrip:${spec.tool}`;
|
|
@@ -1442,13 +1445,10 @@ var ERROR_CODES = {
|
|
|
1442
1445
|
unauthenticated: { status: [401], retryable: false },
|
|
1443
1446
|
forbidden: { status: [403], retryable: false },
|
|
1444
1447
|
not_found: { status: [404], retryable: false },
|
|
1445
|
-
order_removed: { status: [410], retryable: false },
|
|
1446
1448
|
offer_expired: { status: [409], retryable: false },
|
|
1447
1449
|
offer_changed: { status: [409], retryable: false },
|
|
1448
1450
|
offer_already_ordered: { status: [409], retryable: false },
|
|
1449
|
-
order_exists: { status: [409], retryable: false },
|
|
1450
1451
|
order_in_progress: { status: [409], retryable: true },
|
|
1451
|
-
order_attempts_exhausted: { status: [409], retryable: false },
|
|
1452
1452
|
cancellation_changed: { status: [409], retryable: false },
|
|
1453
1453
|
order_not_cancellable: { status: [409], retryable: false },
|
|
1454
1454
|
order_not_payable: { status: [409], retryable: false },
|
|
@@ -1464,6 +1464,7 @@ var ERROR_CODES = {
|
|
|
1464
1464
|
stay_unsupported: { status: [422], retryable: false },
|
|
1465
1465
|
stay_in_past: { status: [422], retryable: false },
|
|
1466
1466
|
offer_unavailable: { status: [422], retryable: false },
|
|
1467
|
+
currency_unavailable: { status: [422], retryable: false },
|
|
1467
1468
|
rate_limited: { status: [429], retryable: true },
|
|
1468
1469
|
ordering_paused: { status: [503], retryable: true },
|
|
1469
1470
|
service_unavailable: { status: [503], retryable: true },
|
|
@@ -1542,12 +1543,7 @@ var indicativePrice = openObject({
|
|
|
1542
1543
|
kind: openEnum(["indicative"]),
|
|
1543
1544
|
basis: openEnum(["lowest_unit"]),
|
|
1544
1545
|
fromPerRoomNight: money,
|
|
1545
|
-
fromPerRoomStay: money
|
|
1546
|
-
approx: openObject({
|
|
1547
|
-
fromPerRoomNight: money,
|
|
1548
|
-
fromPerRoomStay: money,
|
|
1549
|
-
rateDate: localDate
|
|
1550
|
-
}).nullable()
|
|
1546
|
+
fromPerRoomStay: money
|
|
1551
1547
|
});
|
|
1552
1548
|
var hotelSummary = openObject({
|
|
1553
1549
|
hotelId,
|
|
@@ -1799,11 +1795,6 @@ var offer = openObject({
|
|
|
1799
1795
|
perNightAllRooms: money.describe(
|
|
1800
1796
|
"price.total divided by the nights: all rooms, one night. A search's fromPerRoomNight is for one room; divide by roomCount to compare."
|
|
1801
1797
|
),
|
|
1802
|
-
approx: openObject({
|
|
1803
|
-
total: money,
|
|
1804
|
-
perNightAllRooms: money,
|
|
1805
|
-
rateDate: localDate
|
|
1806
|
-
}).nullable(),
|
|
1807
1798
|
payAtProperty
|
|
1808
1799
|
}),
|
|
1809
1800
|
cancellation,
|
|
@@ -1872,6 +1863,7 @@ var PAYMENT_STATUSES = [
|
|
|
1872
1863
|
];
|
|
1873
1864
|
var CANCEL_REASONS = [
|
|
1874
1865
|
"cancellable",
|
|
1866
|
+
"unpaid",
|
|
1875
1867
|
"already_cancelled",
|
|
1876
1868
|
"in_progress",
|
|
1877
1869
|
"not_confirmed",
|
|
@@ -1904,6 +1896,39 @@ var paymentHandler = openObject({
|
|
|
1904
1896
|
business_profile: z14.string()
|
|
1905
1897
|
})
|
|
1906
1898
|
});
|
|
1899
|
+
var PAYMENT_METHOD_IDS = ["stripe_shared_payment_token", "stripe_alipay_wechat_pay"];
|
|
1900
|
+
var paymentMethod = openUnion("id", [
|
|
1901
|
+
openObject({
|
|
1902
|
+
id: z14.literal("stripe_shared_payment_token"),
|
|
1903
|
+
handler: paymentHandler.describe("The com.stripe.payments handler, which takes the token."),
|
|
1904
|
+
limits: openObject({
|
|
1905
|
+
maxAmount: z14.number().int().describe("Request the token for at least this amount, in cents; a token that allows less can't pay."),
|
|
1906
|
+
currency: z14.string().describe("The token's currency, lowercase as Stripe takes it: usd."),
|
|
1907
|
+
expiresAt: instant.describe(
|
|
1908
|
+
"Request the token valid until at least this time; the order can't be paid after it."
|
|
1909
|
+
)
|
|
1910
|
+
}).describe("What the shared payment token for pay_order must allow.")
|
|
1911
|
+
}).describe(
|
|
1912
|
+
`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.`
|
|
1913
|
+
),
|
|
1914
|
+
openObject({
|
|
1915
|
+
id: z14.literal("stripe_alipay_wechat_pay"),
|
|
1916
|
+
open: z14.boolean().describe("Whether pay_order has opened an Alipay or WeChat Pay payment on this order."),
|
|
1917
|
+
current: openEnum(["wechat_pay", "alipay"]).nullable().describe("Which of the two the payment is on now; null until it is open."),
|
|
1918
|
+
wechatPay: openObject({
|
|
1919
|
+
qrData: z14.string().nullable().describe(
|
|
1920
|
+
"The WeChat Pay code's content, to draw as a QR code; null when there is no live code (open wechatPay.url for one)."
|
|
1921
|
+
),
|
|
1922
|
+
qrImageUrl: z14.string().nullable().describe("A 480 px PNG of the same code."),
|
|
1923
|
+
url: z14.string().describe("A link, on fortrip.ai, for the user to pay with WeChat Pay; anyone holding it can pay.")
|
|
1924
|
+
}).nullable().describe("The WeChat Pay code and link; null until the payment is open."),
|
|
1925
|
+
alipay: openObject({
|
|
1926
|
+
url: z14.string().describe("A link, on fortrip.ai, for the user to pay with Alipay; anyone holding it can pay.")
|
|
1927
|
+
}).nullable().describe("The Alipay link; null until the payment is open.")
|
|
1928
|
+
}).describe(
|
|
1929
|
+
"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."
|
|
1930
|
+
)
|
|
1931
|
+
]);
|
|
1907
1932
|
var orderReference = z14.string().regex(/^FT-[2-9A-HJ-NP-Z]{6}$/);
|
|
1908
1933
|
var hotelItem = openObject({
|
|
1909
1934
|
type: z14.literal("hotel"),
|
|
@@ -1931,7 +1956,7 @@ var order = openObject({
|
|
|
1931
1956
|
orderId,
|
|
1932
1957
|
reference: orderReference,
|
|
1933
1958
|
status: openEnum(ORDER_STATUSES).describe(
|
|
1934
|
-
"awaiting_payment: unpaid, nothing charged; payable until payment.expiresAt. expired: not paid
|
|
1959
|
+
"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
1960
|
),
|
|
1936
1961
|
createdAt: instant,
|
|
1937
1962
|
updatedAt: instant,
|
|
@@ -1944,55 +1969,32 @@ var order = openObject({
|
|
|
1944
1969
|
payment: openObject({
|
|
1945
1970
|
status: openEnum(PAYMENT_STATUSES),
|
|
1946
1971
|
url: z14.string().nullable().describe(
|
|
1947
|
-
"The payment page, on fortrip.ai
|
|
1972
|
+
"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
1973
|
),
|
|
1949
1974
|
requiresSignIn: z14.boolean(),
|
|
1950
1975
|
expiresAt: instant.nullable().describe(
|
|
1951
1976
|
"When the time to pay ends: an order unpaid by then expires, with nothing charged. null unless status is awaiting_payment."
|
|
1952
1977
|
),
|
|
1953
1978
|
chargeCurrency: z14.string().describe(
|
|
1954
|
-
"
|
|
1979
|
+
"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
1980
|
),
|
|
1956
1981
|
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."
|
|
1982
|
+
"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
1983
|
),
|
|
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.`
|
|
1984
|
+
localCharge: money.nullable().describe(
|
|
1985
|
+
"What the card was charged in its own currency, when Stripe converted the total; otherwise null. Always null on a CNY order."
|
|
1962
1986
|
),
|
|
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."
|
|
1987
|
+
methods: z14.array(paymentMethod).describe(
|
|
1988
|
+
"What pay_order accepts for this order now, by id. [] means: give the user payment.url, when it isn't null."
|
|
1987
1989
|
)
|
|
1988
1990
|
}),
|
|
1989
1991
|
cancel: openObject({
|
|
1990
|
-
available: z14.boolean().describe("Whether the user can cancel the order now."),
|
|
1992
|
+
available: z14.boolean().describe("Whether the user can cancel the order now, or, unpaid (reason unpaid), close it."),
|
|
1991
1993
|
reason: openEnum(CANCEL_REASONS).describe(
|
|
1992
|
-
"cancellable
|
|
1994
|
+
"cancellable: a paid order can be cancelled now; unpaid: an unpaid order can be closed; otherwise why not."
|
|
1993
1995
|
),
|
|
1994
1996
|
penalty: money.nullable().describe(
|
|
1995
|
-
"The penalty if cancelled now, under the accepted terms, in the charge currency; null when not stated."
|
|
1997
|
+
"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
1998
|
),
|
|
1997
1999
|
refund: money.nullable().describe(
|
|
1998
2000
|
"What a cancellation now refunds: what was paid less the penalty, in the charge currency; null when not stated."
|
|
@@ -2039,13 +2041,10 @@ var ERROR_DETAILS = {
|
|
|
2039
2041
|
unauthenticated: null,
|
|
2040
2042
|
forbidden: null,
|
|
2041
2043
|
not_found: null,
|
|
2042
|
-
order_removed: openObject({ orderId, reference: orderReference }),
|
|
2043
2044
|
offer_expired: openObject({ offerId, expiredAt: instant }),
|
|
2044
2045
|
offer_changed: openObject({ changes: z15.array(offerChange).min(1), offer }),
|
|
2045
2046
|
offer_already_ordered: openObject({ orderId }),
|
|
2046
|
-
order_exists: openObject({ orderId, status: openEnum(ORDER_STATUSES) }),
|
|
2047
2047
|
order_in_progress: openObject({ orderId }),
|
|
2048
|
-
order_attempts_exhausted: openObject({ orderId }),
|
|
2049
2048
|
cancellation_changed: null,
|
|
2050
2049
|
order_not_cancellable: openObject({ reason: openEnum(CANCEL_REASONS) }),
|
|
2051
2050
|
order_not_payable: openObject({ orderId, status: openEnum(ORDER_STATUSES) }),
|
|
@@ -2107,6 +2106,7 @@ var ERROR_DETAILS = {
|
|
|
2107
2106
|
offerId,
|
|
2108
2107
|
reason: openEnum(["sold_out", "refused"])
|
|
2109
2108
|
}),
|
|
2109
|
+
currency_unavailable: openObject({ currency: z15.string() }),
|
|
2110
2110
|
rate_limited: openObject({
|
|
2111
2111
|
scope: openEnum([
|
|
2112
2112
|
"search",
|
|
@@ -2227,19 +2227,21 @@ var ORDER_NEXT_STEP = "Before you give the user an order's payment.url, show the
|
|
|
2227
2227
|
var CALLS = {
|
|
2228
2228
|
mcp: {
|
|
2229
2229
|
cancel: "call cancel_order",
|
|
2230
|
-
penalty:
|
|
2230
|
+
penalty: "Pass maximumPenalty as cancel.penalty, exactly as returned.",
|
|
2231
|
+
close: "call cancel_order",
|
|
2231
2232
|
pay: "call pay_order",
|
|
2232
|
-
payWallet: " with method
|
|
2233
|
+
payWallet: " with method stripe_alipay_wechat_pay",
|
|
2233
2234
|
get: "call get_order",
|
|
2234
2235
|
poll: "poll get_order",
|
|
2235
2236
|
payWith: "call pay_order with it and the order's price.total",
|
|
2236
2237
|
paid: "pay_order"
|
|
2237
2238
|
},
|
|
2238
2239
|
cli: {
|
|
2239
|
-
cancel: "run `fortrip orders cancel <orderId> --max-penalty <
|
|
2240
|
+
cancel: "run `fortrip orders cancel <orderId> --max-penalty <amount>`",
|
|
2241
|
+
close: "run `fortrip orders cancel <orderId> --close`",
|
|
2240
2242
|
penalty: "Pass the penalty's amount as --max-penalty (120.00 for a penalty of USD 120.00).",
|
|
2241
2243
|
pay: "run `fortrip orders pay`",
|
|
2242
|
-
payWallet: " with --
|
|
2244
|
+
payWallet: " with --method stripe_alipay_wechat_pay",
|
|
2243
2245
|
get: "run `fortrip orders get <orderId>`",
|
|
2244
2246
|
poll: "poll it with `fortrip orders get <orderId>`",
|
|
2245
2247
|
payWith: "run `fortrip orders pay <orderId> --token <spt_\u2026> --total <total>` with the token and the order's total",
|
|
@@ -2253,15 +2255,15 @@ function cancelNextStep(surface) {
|
|
|
2253
2255
|
var CANCEL_NEXT_STEP = cancelNextStep("mcp");
|
|
2254
2256
|
function payNextStep(surface) {
|
|
2255
2257
|
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.
|
|
2258
|
+
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
2259
|
}
|
|
2258
2260
|
var PAY_NEXT_STEP = payNextStep("mcp");
|
|
2259
2261
|
function walletNextStep(surface) {
|
|
2260
2262
|
const c = CALLS[surface];
|
|
2261
|
-
return `Before you ${c.pay}${c.payWallet}, show the user the order's total
|
|
2263
|
+
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
2264
|
}
|
|
2263
2265
|
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
|
|
2266
|
+
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
2267
|
var nextStep = z16.string().optional().describe(
|
|
2266
2268
|
"What to show and ask before giving a payment.url. Present when the answer holds a non-null payment.url, and only then."
|
|
2267
2269
|
);
|
|
@@ -2280,14 +2282,6 @@ var READ = {
|
|
|
2280
2282
|
};
|
|
2281
2283
|
var READ_OWN = { ...READ, openWorldHint: false };
|
|
2282
2284
|
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
2285
|
{
|
|
2292
2286
|
name: "search_hotels",
|
|
2293
2287
|
title: "Search hotels",
|
|
@@ -2307,7 +2301,7 @@ var TOOLS = [
|
|
|
2307
2301
|
{
|
|
2308
2302
|
name: "get_hotel_offers",
|
|
2309
2303
|
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
|
|
2304
|
+
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
2305
|
annotations: READ,
|
|
2312
2306
|
input: hotelOffersInput,
|
|
2313
2307
|
output: hotelOffersResult
|
|
@@ -2344,7 +2338,7 @@ var TOOLS = [
|
|
|
2344
2338
|
{
|
|
2345
2339
|
name: "cancel_order",
|
|
2346
2340
|
title: "Cancel order",
|
|
2347
|
-
description: `Cancel
|
|
2341
|
+
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
2342
|
annotations: {
|
|
2349
2343
|
readOnlyHint: false,
|
|
2350
2344
|
idempotentHint: true,
|
|
@@ -2357,7 +2351,7 @@ var TOOLS = [
|
|
|
2357
2351
|
{
|
|
2358
2352
|
name: "pay_order",
|
|
2359
2353
|
title: "Pay order",
|
|
2360
|
-
description: `Pay an order without its link, by shared payment token or Alipay/WeChat Pay (method
|
|
2354
|
+
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
2355
|
annotations: {
|
|
2362
2356
|
readOnlyHint: false,
|
|
2363
2357
|
idempotentHint: true,
|
|
@@ -2590,10 +2584,7 @@ function roomText(r) {
|
|
|
2590
2584
|
}
|
|
2591
2585
|
function offerLine(o) {
|
|
2592
2586
|
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
|
-
}
|
|
2587
|
+
const price = `${money2(p.total)} total (${money2(p.perNightAllRooms)} per night, all rooms)`;
|
|
2597
2588
|
return [
|
|
2598
2589
|
`${o.offerId}${o.type === "hotel" ? "" : ` (${o.type})`}`,
|
|
2599
2590
|
`${plural(o.hotel.roomCount, "room")}: ${roomText(o.hotel.room)}`,
|
|
@@ -2653,9 +2644,12 @@ function renderOffers(r, surface = "mcp") {
|
|
|
2653
2644
|
}
|
|
2654
2645
|
|
|
2655
2646
|
// src/render/order.ts
|
|
2647
|
+
function methodOf(o, id) {
|
|
2648
|
+
return o.payment.methods.find((m) => m.id === id);
|
|
2649
|
+
}
|
|
2656
2650
|
var ORDER_STATUS_WORDS = {
|
|
2657
2651
|
awaiting_payment: "awaiting payment",
|
|
2658
|
-
expired: "
|
|
2652
|
+
expired: "not paid: the time ran out or it was closed",
|
|
2659
2653
|
confirming: "confirming with the hotel",
|
|
2660
2654
|
confirmed: "confirmed",
|
|
2661
2655
|
failed: "failed",
|
|
@@ -2674,6 +2668,7 @@ var PAYMENT_WORDS = {
|
|
|
2674
2668
|
var SUPPORT = `for help, the user emails ${SUPPORT_EMAIL} with the order's reference`;
|
|
2675
2669
|
var CANCEL_REASON_WORDS = {
|
|
2676
2670
|
cancellable: "it can be cancelled",
|
|
2671
|
+
unpaid: "it isn't paid: it can be closed if the user no longer wants it",
|
|
2677
2672
|
already_cancelled: "it is already cancelled",
|
|
2678
2673
|
in_progress: "a cancellation is in progress",
|
|
2679
2674
|
not_confirmed: "only a confirmed order that is paid can be cancelled",
|
|
@@ -2717,24 +2712,22 @@ function paymentLines(o, surface) {
|
|
|
2717
2712
|
p.requiresSignIn ? "the user signs in to Fortrip to pay" : "no sign-in needed"
|
|
2718
2713
|
].filter(Boolean);
|
|
2719
2714
|
lines.push(`Payment link (${about.join("; ")}): ${p.url}`);
|
|
2720
|
-
} else if (o.status === "awaiting_payment") {
|
|
2715
|
+
} else if (o.status === "awaiting_payment" && p.status === "unpaid") {
|
|
2721
2716
|
lines.push("Payment link: could not be read this time; read this order again for it.");
|
|
2722
2717
|
}
|
|
2723
|
-
|
|
2724
|
-
if (
|
|
2725
|
-
|
|
2718
|
+
const token = methodOf(o, "stripe_shared_payment_token");
|
|
2719
|
+
if (token) lines.push(tokenLine(o, token, surface));
|
|
2720
|
+
const wallet = methodOf(o, "stripe_alipay_wechat_pay");
|
|
2721
|
+
if (wallet) lines.push(...walletLines(wallet, surface));
|
|
2722
|
+
lines.push(cancelLine(o, surface));
|
|
2726
2723
|
lines.push(`Manage: ${o.manageUrl}`);
|
|
2727
2724
|
return lines;
|
|
2728
2725
|
}
|
|
2729
|
-
function
|
|
2730
|
-
const {
|
|
2726
|
+
function tokenLine(o, token, surface) {
|
|
2727
|
+
const { handler: h, limits } = token;
|
|
2731
2728
|
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
2729
|
return [
|
|
2737
|
-
`Pay without the link: ${pay} with a shared payment token via ${
|
|
2730
|
+
`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
2731
|
"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
2732
|
`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
2733
|
].join(" ");
|
|
@@ -2742,7 +2735,7 @@ function handlersLine(o, surface) {
|
|
|
2742
2735
|
function walletLines(w, surface) {
|
|
2743
2736
|
const c = CALLS[surface];
|
|
2744
2737
|
if (!w.open) {
|
|
2745
|
-
const pay = surface === "cli" ? "run `fortrip orders pay <orderId> --
|
|
2738
|
+
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
2739
|
return [`Pay with Alipay or WeChat Pay: ${pay}.`];
|
|
2747
2740
|
}
|
|
2748
2741
|
const lines = [];
|
|
@@ -2759,9 +2752,13 @@ function walletLines(w, surface) {
|
|
|
2759
2752
|
);
|
|
2760
2753
|
return lines;
|
|
2761
2754
|
}
|
|
2762
|
-
function cancelLine(o) {
|
|
2755
|
+
function cancelLine(o, surface) {
|
|
2763
2756
|
const c = o.cancel;
|
|
2757
|
+
if (c.available && c.reason === "unpaid") {
|
|
2758
|
+
return `Cancel: can be closed now, nothing is charged; close it only if the user says they no longer want it (${CALLS[surface].close})`;
|
|
2759
|
+
}
|
|
2764
2760
|
if (o.status === "awaiting_payment" && !c.available && c.reason === "not_confirmed") {
|
|
2761
|
+
if (!o.payment.requiresSignIn) return "Cancel: not now: a payment is under way; read the order again shortly";
|
|
2765
2762
|
const at = o.payment.expiresAt === null ? "" : ` at ${when(o.payment.expiresAt, null)}`;
|
|
2766
2763
|
return `Cancel: not needed: an unpaid order expires unpaid${at}`;
|
|
2767
2764
|
}
|
|
@@ -2915,9 +2912,6 @@ function priceWords(h, status) {
|
|
|
2915
2912
|
return status === "ok" ? "no indicative price" : "price unavailable this time";
|
|
2916
2913
|
}
|
|
2917
2914
|
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
2915
|
if (p.kind !== "indicative" || p.basis !== "lowest_unit") {
|
|
2922
2916
|
text2 += ` [${p.kind}, ${p.basis}]`;
|
|
2923
2917
|
}
|
|
@@ -3083,8 +3077,6 @@ function detailLines(e, surface) {
|
|
|
3083
3077
|
}
|
|
3084
3078
|
case "cursor_invalid":
|
|
3085
3079
|
return [`The cursor is ${e.details.reason}: search again without a cursor.`];
|
|
3086
|
-
case "order_removed":
|
|
3087
|
-
return [`Order ${e.details.orderId}, reference ${e.details.reference}.`];
|
|
3088
3080
|
case "offer_expired":
|
|
3089
3081
|
return [`Offer ${e.details.offerId} expired at ${when(e.details.expiredAt, null)}: get fresh offers.`];
|
|
3090
3082
|
case "offer_changed":
|
|
@@ -3097,10 +3089,7 @@ function detailLines(e, surface) {
|
|
|
3097
3089
|
];
|
|
3098
3090
|
case "offer_already_ordered":
|
|
3099
3091
|
case "order_in_progress":
|
|
3100
|
-
case "order_attempts_exhausted":
|
|
3101
3092
|
return [`Order ${e.details.orderId}.`];
|
|
3102
|
-
case "order_exists":
|
|
3103
|
-
return [`Order ${e.details.orderId}, ${label(ORDER_STATUS_WORDS, e.details.status)}.`];
|
|
3104
3093
|
case "order_not_cancellable":
|
|
3105
3094
|
return [`Not cancellable: ${label(CANCEL_REASON_WORDS, e.details.reason)}.`];
|
|
3106
3095
|
case "order_not_payable":
|
|
@@ -3115,7 +3104,7 @@ function detailLines(e, surface) {
|
|
|
3115
3104
|
];
|
|
3116
3105
|
case "payment_credential_invalid":
|
|
3117
3106
|
return [
|
|
3118
|
-
`The token ${label(CREDENTIAL_INVALID_WORDS, e.details.reason)}: request a new one with the order's
|
|
3107
|
+
`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
3108
|
];
|
|
3120
3109
|
case "payment_declined":
|
|
3121
3110
|
return [
|
|
@@ -3137,6 +3126,8 @@ function detailLines(e, surface) {
|
|
|
3137
3126
|
return [
|
|
3138
3127
|
`Offer ${e.details.offerId}: ${label({ sold_out: "sold out", refused: "can no longer be booked" }, e.details.reason)}. Get fresh offers.`
|
|
3139
3128
|
];
|
|
3129
|
+
case "currency_unavailable":
|
|
3130
|
+
return [`Prices in ${e.details.currency} aren't available yet. Tell the user, and ask whether to see USD prices.`];
|
|
3140
3131
|
case "rate_limited":
|
|
3141
3132
|
return [`Limit reached for: ${e.details.scope}.`];
|
|
3142
3133
|
case "supplier_unavailable":
|
|
@@ -3201,8 +3192,8 @@ ${raw(data)}`;
|
|
|
3201
3192
|
return [
|
|
3202
3193
|
text2,
|
|
3203
3194
|
ORDER_TOOLS.has(tool) && holdsPaymentUrl(data) ? ORDER_NEXT_STEP : "",
|
|
3204
|
-
ORDER_TOOLS.has(tool) &&
|
|
3205
|
-
ORDER_TOOLS.has(tool) &&
|
|
3195
|
+
ORDER_TOOLS.has(tool) && holdsMethod(data, isTokenMethod) ? payNextStep(surface) : "",
|
|
3196
|
+
ORDER_TOOLS.has(tool) && holdsMethod(data, isWalletOffer) ? walletNextStep(surface) : "",
|
|
3206
3197
|
CANCEL_TOOLS.has(tool) && holdsCancellable(data) ? cancelNextStep(surface) : ""
|
|
3207
3198
|
].filter(Boolean).join("\n\n");
|
|
3208
3199
|
}
|
|
@@ -3238,32 +3229,23 @@ function holdsPaymentUrl(value, seen = /* @__PURE__ */ new Set()) {
|
|
|
3238
3229
|
}
|
|
3239
3230
|
return Object.values(value).some((v) => holdsPaymentUrl(v, seen));
|
|
3240
3231
|
}
|
|
3241
|
-
|
|
3232
|
+
var isTokenMethod = (m) => m.id === "stripe_shared_payment_token";
|
|
3233
|
+
var isWalletOffer = (m) => m.id === "stripe_alipay_wechat_pay" && m.open === false;
|
|
3234
|
+
function holdsMethod(value, match, seen = /* @__PURE__ */ new Set()) {
|
|
3242
3235
|
if (typeof value !== "object" || value === null || seen.has(value)) return false;
|
|
3243
3236
|
seen.add(value);
|
|
3244
3237
|
const payment = value.payment;
|
|
3245
|
-
|
|
3238
|
+
const methods = typeof payment === "object" && payment !== null ? payment.methods : void 0;
|
|
3239
|
+
if (Array.isArray(methods) && methods.some((m) => typeof m === "object" && m !== null && match(m))) {
|
|
3246
3240
|
return true;
|
|
3247
3241
|
}
|
|
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));
|
|
3242
|
+
return Object.values(value).some((v) => holdsMethod(v, match, seen));
|
|
3261
3243
|
}
|
|
3262
3244
|
function holdsCancellable(value, seen = /* @__PURE__ */ new Set()) {
|
|
3263
3245
|
if (typeof value !== "object" || value === null || seen.has(value)) return false;
|
|
3264
3246
|
seen.add(value);
|
|
3265
3247
|
const cancel = value.cancel;
|
|
3266
|
-
if (typeof cancel === "object" && cancel !== null && cancel.available === true) {
|
|
3248
|
+
if (typeof cancel === "object" && cancel !== null && cancel.available === true && cancel.reason !== "unpaid") {
|
|
3267
3249
|
return true;
|
|
3268
3250
|
}
|
|
3269
3251
|
return Object.values(value).some((v) => holdsCancellable(v, seen));
|
|
@@ -3272,9 +3254,9 @@ function withConsent(tool, surface, text2, orders) {
|
|
|
3272
3254
|
return [
|
|
3273
3255
|
text2,
|
|
3274
3256
|
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) : ""
|
|
3257
|
+
orders.some((o) => methodOf(o, "stripe_shared_payment_token")) ? payNextStep(surface) : "",
|
|
3258
|
+
orders.some((o) => methodOf(o, "stripe_alipay_wechat_pay")?.open === false) ? walletNextStep(surface) : "",
|
|
3259
|
+
CANCEL_TOOLS.has(tool) && orders.some((o) => o.cancel.available && o.cancel.reason !== "unpaid") ? cancelNextStep(surface) : ""
|
|
3278
3260
|
].filter(Boolean).join("\n\n");
|
|
3279
3261
|
}
|
|
3280
3262
|
|
|
@@ -3304,8 +3286,8 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
|
|
|
3304
3286
|
requiresSignIn: `${API_DECIDES} (whether the payment link needs a website sign-in).`,
|
|
3305
3287
|
localCurrencyAtCheckout: `${API_DECIDES} (whether checkout may charge in the card's currency).`,
|
|
3306
3288
|
"cancel.available": `${API_DECIDES} (whether an order can be cancelled now).`,
|
|
3307
|
-
"payment.
|
|
3308
|
-
"payment.
|
|
3289
|
+
"payment.methods": `${RESULT_LIST} (the ways to pay an order other than its link; empty when there is none).`,
|
|
3290
|
+
"payment.methods.open": `${API_DECIDES} (the server always knows whether it opened a payment).`,
|
|
3309
3291
|
available_instruments: `${RESULT_LIST} (the instruments a payment handler takes).`,
|
|
3310
3292
|
bookable: `${API_DECIDES} (whether the hotel is still in the index).`,
|
|
3311
3293
|
cityLike: `${API_DECIDES} (frozen per gazetteer release; null where not computed).`,
|
|
@@ -3330,7 +3312,7 @@ var ME_SCOPES = { email: "email", name: "profile" };
|
|
|
3330
3312
|
// package.json
|
|
3331
3313
|
var package_default = {
|
|
3332
3314
|
name: "@fortrip/agent-contract",
|
|
3333
|
-
version: "
|
|
3315
|
+
version: "5.0.0-rc.2",
|
|
3334
3316
|
license: "Apache-2.0",
|
|
3335
3317
|
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
3318
|
type: "module",
|
|
@@ -3397,7 +3379,7 @@ export {
|
|
|
3397
3379
|
COMMAND_GROUPS,
|
|
3398
3380
|
CONTRACT_VERSION,
|
|
3399
3381
|
CREDENTIAL_INVALID_REASONS,
|
|
3400
|
-
|
|
3382
|
+
CURRENCIES,
|
|
3401
3383
|
DOCS_ORIGIN,
|
|
3402
3384
|
ERROR_CODES,
|
|
3403
3385
|
ERROR_DETAILS,
|
|
@@ -3415,6 +3397,7 @@ export {
|
|
|
3415
3397
|
ORDER_HTTP,
|
|
3416
3398
|
ORDER_NEXT_STEP,
|
|
3417
3399
|
ORDER_STATUSES,
|
|
3400
|
+
PAYMENT_METHOD_IDS,
|
|
3418
3401
|
PAYMENT_STATUSES,
|
|
3419
3402
|
PAY_INPUT_WAYS,
|
|
3420
3403
|
PAY_NEXT_STEP,
|
|
@@ -3492,6 +3475,7 @@ export {
|
|
|
3492
3475
|
payNextStep,
|
|
3493
3476
|
payOrderInput,
|
|
3494
3477
|
paymentHandler,
|
|
3478
|
+
paymentMethod,
|
|
3495
3479
|
photo,
|
|
3496
3480
|
place,
|
|
3497
3481
|
placeId,
|
|
@@ -3500,6 +3484,7 @@ export {
|
|
|
3500
3484
|
renderError,
|
|
3501
3485
|
renderGuide,
|
|
3502
3486
|
renderToolResult,
|
|
3487
|
+
requestMoney,
|
|
3503
3488
|
roomFacts,
|
|
3504
3489
|
routePath,
|
|
3505
3490
|
searchHotelsInput,
|
|
@@ -3511,7 +3496,6 @@ export {
|
|
|
3511
3496
|
strictOutput,
|
|
3512
3497
|
text,
|
|
3513
3498
|
timeZone,
|
|
3514
|
-
usdMoney,
|
|
3515
3499
|
walletNextStep,
|
|
3516
3500
|
wholeNumber
|
|
3517
3501
|
};
|