@fortrip/agent-contract 6.4.0 → 6.5.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/index.d.ts +92 -5
- package/dist/index.js +338 -10
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@ The contract of Fortrip API v1 (`https://api.fortrip.ai/v1`) and its MCP
|
|
|
4
4
|
server (`https://mcp.fortrip.ai/`): the limits, paths, request and response
|
|
5
5
|
schemas, error codes and field rules that the Fortrip CLI (`fortrip`), the
|
|
6
6
|
hosted MCP server and the store listings all share, so they cannot drift
|
|
7
|
-
apart.
|
|
7
|
+
apart. The API it describes is documented at
|
|
8
|
+
[docs.fortrip.ai](https://docs.fortrip.ai).
|
|
8
9
|
|
|
9
10
|
It has one peer dependency, `zod` (`^4.4.0`), and runs anywhere
|
|
10
11
|
ES2023 does. Its major version changes when the contract breaks, not with
|
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ declare const CARD_NUMBER_MESSAGE = "This looks like a payment card number. Paym
|
|
|
24
24
|
*/
|
|
25
25
|
declare function containsCardNumber(text: string, minDigits?: number): boolean;
|
|
26
26
|
|
|
27
|
-
type ToolName = "search_hotels" | "get_hotel" | "get_hotel_offers" | "create_order" | "get_order" | "list_orders" | "cancel_order" | "pay_order";
|
|
27
|
+
type ToolName = "search_hotels" | "get_hotel" | "get_hotel_offers" | "request_price_match" | "get_price_match" | "create_order" | "get_order" | "list_orders" | "cancel_order" | "pay_order";
|
|
28
28
|
interface ToolSpec {
|
|
29
29
|
name: ToolName;
|
|
30
30
|
title: string;
|
|
@@ -198,7 +198,7 @@ interface CommandSpec {
|
|
|
198
198
|
/** The group it is typed after; `null` for a command typed on its own. */
|
|
199
199
|
group: CommandGroupSpec["name"] | null;
|
|
200
200
|
/** Unique within its group. */
|
|
201
|
-
name: "search" | "get" | "offers" | "create" | "list" | "cancel" | "pay" | "login" | "logout" | "whoami" | "mcp";
|
|
201
|
+
name: "search" | "get" | "offers" | "price-match" | "price-match-status" | "create" | "list" | "cancel" | "pay" | "login" | "logout" | "whoami" | "mcp";
|
|
202
202
|
summary: string;
|
|
203
203
|
/** The MCP tool the command mirrors; `null` for one that is the CLI's own. */
|
|
204
204
|
tool: ToolName | null;
|
|
@@ -220,6 +220,8 @@ declare const GLOBAL_FLAGS: readonly OptionSpec[];
|
|
|
220
220
|
declare const hotelId: z.ZodString;
|
|
221
221
|
declare const offerId: z.ZodString;
|
|
222
222
|
declare const orderId: z.ZodString;
|
|
223
|
+
/** A price-match check, from the moment it starts. */
|
|
224
|
+
declare const claimId: z.ZodString;
|
|
223
225
|
/** `plc_` plus the GeoNames id in decimal (1 to 12 digits). */
|
|
224
226
|
declare const placeId: z.ZodString;
|
|
225
227
|
|
|
@@ -236,6 +238,12 @@ declare const money: z.ZodType<Money>;
|
|
|
236
238
|
* advice.
|
|
237
239
|
*/
|
|
238
240
|
declare function requestMoney(name: string, currencies?: readonly [string, ...string[]], otherCurrency?: string): z.ZodType<Money, Money>;
|
|
241
|
+
/**
|
|
242
|
+
* A Money a caller states from elsewhere, such as a price the user saw on
|
|
243
|
+
* another site: no unknown fields, in any currency, its code upper case.
|
|
244
|
+
* `name` is the field it is the value of, which the refusal names.
|
|
245
|
+
*/
|
|
246
|
+
declare function statedMoney(name: string): z.ZodType<Money, Money>;
|
|
239
247
|
declare function formatMoney(m: Money): string;
|
|
240
248
|
|
|
241
249
|
/** An object that keeps fields it does not know. */
|
|
@@ -619,6 +627,25 @@ declare const payOrderInput: z.ZodObject<{
|
|
|
619
627
|
total: z.ZodType<Money, Money, z.core.$ZodTypeInternals<Money, Money>>;
|
|
620
628
|
}, z.core.$strict>;
|
|
621
629
|
type PayOrderInput = z.input<typeof payOrderInput>;
|
|
630
|
+
/** `POST /v1/price-matches` and the MCP `request_price_match` arguments:
|
|
631
|
+
* the offer, the other site as the user named it, and what else the user
|
|
632
|
+
* gave of what they saw there. */
|
|
633
|
+
declare const requestPriceMatchInput: z.ZodObject<{
|
|
634
|
+
offerId: z.ZodString;
|
|
635
|
+
site: z.ZodString;
|
|
636
|
+
link: z.ZodOptional<z.ZodString>;
|
|
637
|
+
seenTotal: z.ZodOptional<z.ZodType<Money, Money, z.core.$ZodTypeInternals<Money, Money>>>;
|
|
638
|
+
locale: z.ZodOptional<z.ZodEnum<{
|
|
639
|
+
en: "en";
|
|
640
|
+
zh: "zh";
|
|
641
|
+
}>>;
|
|
642
|
+
}, z.core.$strict>;
|
|
643
|
+
type RequestPriceMatchInput = z.input<typeof requestPriceMatchInput>;
|
|
644
|
+
/** `GET /v1/price-matches/{claimId}` and the MCP `get_price_match` arguments. */
|
|
645
|
+
declare const getPriceMatchInput: z.ZodObject<{
|
|
646
|
+
claimId: z.ZodString;
|
|
647
|
+
}, z.core.$strict>;
|
|
648
|
+
type GetPriceMatchInput = z.input<typeof getPriceMatchInput>;
|
|
622
649
|
|
|
623
650
|
/** The ceilings and floors every agent surface enforces and documents (spec §15). */
|
|
624
651
|
declare const LIMITS: {
|
|
@@ -1233,7 +1260,7 @@ declare const ERROR_DETAILS: {
|
|
|
1233
1260
|
currency: z.ZodString;
|
|
1234
1261
|
}, z.core.$strip>;
|
|
1235
1262
|
rate_limited: z.ZodObject<{
|
|
1236
|
-
rateLimit: z.ZodType<"search" | "hotel" | (string & {}) | "offers" | "orders_read" | "orders_create" | "orders_cancel" | "orders_pay", unknown, z.core.$ZodTypeInternals<"search" | "hotel" | (string & {}) | "offers" | "orders_read" | "orders_create" | "orders_cancel" | "orders_pay", unknown>>;
|
|
1263
|
+
rateLimit: z.ZodType<"search" | "hotel" | (string & {}) | "offers" | "orders_read" | "orders_create" | "orders_cancel" | "orders_pay" | "price_match", unknown, z.core.$ZodTypeInternals<"search" | "hotel" | (string & {}) | "offers" | "orders_read" | "orders_create" | "orders_cancel" | "orders_pay" | "price_match", unknown>>;
|
|
1237
1264
|
}, z.core.$strip>;
|
|
1238
1265
|
ordering_paused: null;
|
|
1239
1266
|
service_unavailable: null;
|
|
@@ -2274,6 +2301,63 @@ declare const offerChange: z.ZodType<OpenUnionOutput<"field", readonly [z.ZodObj
|
|
|
2274
2301
|
}, z.core.$strip>]>, unknown>>;
|
|
2275
2302
|
type OfferChange = z.infer<typeof offerChange>;
|
|
2276
2303
|
|
|
2304
|
+
/** `checking`: the other site is being checked. `matched`: a new offer
|
|
2305
|
+
* whose total, with Fortrip's own fees paid at the hotel, is the other
|
|
2306
|
+
* site's total. `partial`: a new offer below ours that stops short of the
|
|
2307
|
+
* other site's total. `declined`: no new offer, and why. */
|
|
2308
|
+
declare const PRICE_MATCH_STATES: readonly ["checking", "matched", "partial", "declined"];
|
|
2309
|
+
type PriceMatchState = (typeof PRICE_MATCH_STATES)[number];
|
|
2310
|
+
/** Why a price match gave no new offer. */
|
|
2311
|
+
declare const PRICE_MATCH_REASONS: readonly ["not_lower", "not_offered", "site_unreadable", "site_not_credible", "unsupported", "daily_limit", "monthly_limit", "unfinished", "unavailable"];
|
|
2312
|
+
type PriceMatchReason = (typeof PRICE_MATCH_REASONS)[number];
|
|
2313
|
+
/** Where a price seen was read: the site's own page, or price data for
|
|
2314
|
+
* that site when its page could not be read. */
|
|
2315
|
+
declare const PRICE_SOURCES: readonly ["site", "data"];
|
|
2316
|
+
/** A price the check saw on the other site. */
|
|
2317
|
+
declare const priceSeen: z.ZodObject<{
|
|
2318
|
+
site: z.ZodString;
|
|
2319
|
+
total: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
|
|
2320
|
+
via: z.ZodType<"site" | (string & {}) | "data", unknown, z.core.$ZodTypeInternals<"site" | (string & {}) | "data", unknown>>;
|
|
2321
|
+
room: z.ZodOptional<z.ZodString>;
|
|
2322
|
+
terms: z.ZodOptional<z.ZodString>;
|
|
2323
|
+
}, z.core.$strip>;
|
|
2324
|
+
/** The new offer a match gives: the original offer at a lower total. */
|
|
2325
|
+
declare const matchedOffer: z.ZodObject<{
|
|
2326
|
+
offerId: z.ZodString;
|
|
2327
|
+
total: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
|
|
2328
|
+
expiresAt: z.ZodString;
|
|
2329
|
+
saved: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
|
|
2330
|
+
}, z.core.$strip>;
|
|
2331
|
+
declare const priceMatch: z.ZodObject<{
|
|
2332
|
+
state: z.ZodType<(string & {}) | "matched" | "partial" | "checking" | "declined", unknown, z.core.$ZodTypeInternals<(string & {}) | "matched" | "partial" | "checking" | "declined", unknown>>;
|
|
2333
|
+
offerId: z.ZodString;
|
|
2334
|
+
site: z.ZodString;
|
|
2335
|
+
ourTotal: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
|
|
2336
|
+
claimId: z.ZodOptional<z.ZodString>;
|
|
2337
|
+
progressUrl: z.ZodOptional<z.ZodString>;
|
|
2338
|
+
checkAgainAfterSeconds: z.ZodOptional<z.ZodNumber>;
|
|
2339
|
+
step: z.ZodOptional<z.ZodString>;
|
|
2340
|
+
seen: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
2341
|
+
site: z.ZodString;
|
|
2342
|
+
total: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
|
|
2343
|
+
via: z.ZodType<"site" | (string & {}) | "data", unknown, z.core.$ZodTypeInternals<"site" | (string & {}) | "data", unknown>>;
|
|
2344
|
+
room: z.ZodOptional<z.ZodString>;
|
|
2345
|
+
terms: z.ZodOptional<z.ZodString>;
|
|
2346
|
+
}, z.core.$strip>>>>;
|
|
2347
|
+
matchedOffer: z.ZodOptional<z.ZodObject<{
|
|
2348
|
+
offerId: z.ZodString;
|
|
2349
|
+
total: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
|
|
2350
|
+
expiresAt: z.ZodString;
|
|
2351
|
+
saved: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
|
|
2352
|
+
}, z.core.$strip>>;
|
|
2353
|
+
otherTotal: z.ZodOptional<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
2354
|
+
ourFeesAtProperty: z.ZodOptional<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
2355
|
+
reason: z.ZodOptional<z.ZodType<(string & {}) | "unavailable" | "not_lower" | "not_offered" | "site_unreadable" | "site_not_credible" | "unsupported" | "daily_limit" | "monthly_limit" | "unfinished", unknown, z.core.$ZodTypeInternals<(string & {}) | "unavailable" | "not_lower" | "not_offered" | "site_unreadable" | "site_not_credible" | "unsupported" | "daily_limit" | "monthly_limit" | "unfinished", unknown>>>;
|
|
2356
|
+
note: z.ZodOptional<z.ZodString>;
|
|
2357
|
+
propertyFeeLeftOut: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
2358
|
+
}, z.core.$strip>;
|
|
2359
|
+
type PriceMatch = z.infer<typeof priceMatch>;
|
|
2360
|
+
|
|
2277
2361
|
declare const PLACE_KINDS: readonly ["country", "region", "district", "settlement", "neighbourhood", "island"];
|
|
2278
2362
|
/** A place named in passing: its id and names. */
|
|
2279
2363
|
declare const placeRef: z.ZodObject<{
|
|
@@ -2746,9 +2830,12 @@ declare const RATE_LIMITS: Record<RateLimitName, {
|
|
|
2746
2830
|
/** The error envelope as text; `status` is the HTTP status, when known.
|
|
2747
2831
|
* `surface` names the next calls: tools (`mcp`, the default) or commands
|
|
2748
2832
|
* (`cli`). `options.tokenPay: false`, for a client not offered payment by
|
|
2749
|
-
* token: no line names one.
|
|
2833
|
+
* token: no line names one. `options.tool`, the tool that answered the
|
|
2834
|
+
* error, when known: a code some tools answer for another reason is then
|
|
2835
|
+
* worded for that tool. */
|
|
2750
2836
|
declare function renderError(envelope: unknown, status?: number, surface?: RenderSurface, options?: {
|
|
2751
2837
|
tokenPay?: boolean;
|
|
2838
|
+
tool?: ToolName;
|
|
2752
2839
|
}): string;
|
|
2753
2840
|
|
|
2754
2841
|
type RenderedTool = ToolName;
|
|
@@ -2823,4 +2910,4 @@ declare const ME_SCOPES: {
|
|
|
2823
2910
|
/** The contract's version, from package.json, the one place a release bumps it. */
|
|
2824
2911
|
declare const CONTRACT_VERSION: string;
|
|
2825
2912
|
|
|
2826
|
-
export { ACCOUNT_ROUTES, AMENITY_CODES, API, type AmenityCode, type AuthConfig, CANCEL_ACTIONS, CANCEL_BLOCKERS, CANCEL_NEXT_STEP, CARD_NUMBER_MESSAGE, CENTER_BASES, COMMANDS, COMMAND_GROUPS, CONTRACT_VERSION, CREDENTIAL_INVALID_REASONS, CURRENCIES, type CancelAction, type CancelBlocker, type CancelOrderInput, type Center, type CommandGroupSpec, type CommandSpec, type CreateOrderInput, type CredentialInvalidReason, type Currency, DOCS_ORIGIN, type Destination, ERROR_CODES, ERROR_DETAILS, type ErrorBody, type ErrorCode, type ErrorEnvelope, FAILURE_REASONS, FEE_KINDS, FILTERABLE_AMENITIES, type FailureReason, type FeeKind, type FilterableAmenity, type FlagSpec, GLOBAL_FLAGS, type GetHotelInput, type GetOrderInput, type GuideOptions, type GuideSurface, type GuideTopic, HTTP_ROUTES, type Hotel, type HotelOffersInput, type HotelOffersResult, type HotelSummary, type HttpRoute, type HttpToolName, type IndicativePrice, type KnownErrorBody, LIMITS, type ListOrdersInput, MCP_PATH, MCP_SERVER_URL, META_KEYS, ME_SCOPES, type MeResult, type MisplacedKey, type Money, ORDER_HTTP, ORDER_NEXT_STEP, ORDER_STATUSES, type Offer, type OfferChange, type Omitted, type OptionSpec, type Order, type OrderCancel, type OrderList, type OrderStatus, PAYMENT_METHOD_UNAVAILABLE_REASONS, PAYMENT_STATUSES, PAY_NEXT_STEP, PAY_WAYS, PLACE_KINDS, POLICY_TOPICS, PRESENTATION_HINT, PUBLIC_ORIGINS, type PayOrderInput, type PayWay, type PaymentHandler, type PaymentMethodUnavailableReason, type PaymentStatus, type Place, type PlaceRef, type PolicyTopic, type PositionalSpec, RATE_LIMITS, REPOSITORY_URL, type RateLimitName, type RenderSurface, type RenderedTool, type RoomType, SEARCH_NOTE_CODES, SEARCH_NOTE_DETAILS, SEARCH_RULES, SEARCH_SORTS, SERVER_INFO, SKILL_INSTALL_COMMAND, SUPPLIER_OUTCOME_STATUS, SUPPORT_EMAIL, type SearchHotelsInput, type SearchNote, type SearchNoteCode, type SearchResult, type Stay, TOOLS, type TokenUsageLimits, type ToolName, type ToolSpec, UNAVAILABLE_REASONS, UNKNOWN_IS_NOT_NO_EXEMPTIONS, addIsoDateDays, authConfig, cancelNextStep, cancelOrderInput, cancellation, center, commandInvocation, confirmation, containsCardNumber, countIsoDateDays, createOrderInput, createSearchHotelsInput, destination, errorEnvelope, flag, formatMoney, getHotelInput, getOrderInput, hotel, hotelId, hotelOffersInput, hotelOffersResult, hotelSummary, indicativePrice, instant, isIsoDate, knownLocaleText, latLng, listOrdersInput, localDate, localTime, localities, localizedText, meResult, meals, misplacedKeyHint, misplacedKeys, money, names, nonEmpty, offer, offerChange, offerId, offersPerHotel, omitted, oneOf, openEnum, openObject, openUnion, order, orderCancel, orderId, orderList, orderReference, parseOpen, payAtProperty, payNextStep, payOrderInput, paymentHandler, photo, place, placeId, placeRef, protocolObject, renderError, renderGuide, renderToolResult, requestMoney, roomType, routePath, searchHotelsInput, searchNote, searchResult, stay, stayEcho, strictInput, strictOutput, text, timeZone, tokenUsageLimits, toolsFor, unknownFieldsMessage, wholeNumber };
|
|
2913
|
+
export { ACCOUNT_ROUTES, AMENITY_CODES, API, type AmenityCode, type AuthConfig, CANCEL_ACTIONS, CANCEL_BLOCKERS, CANCEL_NEXT_STEP, CARD_NUMBER_MESSAGE, CENTER_BASES, COMMANDS, COMMAND_GROUPS, CONTRACT_VERSION, CREDENTIAL_INVALID_REASONS, CURRENCIES, type CancelAction, type CancelBlocker, type CancelOrderInput, type Center, type CommandGroupSpec, type CommandSpec, type CreateOrderInput, type CredentialInvalidReason, type Currency, DOCS_ORIGIN, type Destination, ERROR_CODES, ERROR_DETAILS, type ErrorBody, type ErrorCode, type ErrorEnvelope, FAILURE_REASONS, FEE_KINDS, FILTERABLE_AMENITIES, type FailureReason, type FeeKind, type FilterableAmenity, type FlagSpec, GLOBAL_FLAGS, type GetHotelInput, type GetOrderInput, type GetPriceMatchInput, type GuideOptions, type GuideSurface, type GuideTopic, HTTP_ROUTES, type Hotel, type HotelOffersInput, type HotelOffersResult, type HotelSummary, type HttpRoute, type HttpToolName, type IndicativePrice, type KnownErrorBody, LIMITS, type ListOrdersInput, MCP_PATH, MCP_SERVER_URL, META_KEYS, ME_SCOPES, type MeResult, type MisplacedKey, type Money, ORDER_HTTP, ORDER_NEXT_STEP, ORDER_STATUSES, type Offer, type OfferChange, type Omitted, type OptionSpec, type Order, type OrderCancel, type OrderList, type OrderStatus, PAYMENT_METHOD_UNAVAILABLE_REASONS, PAYMENT_STATUSES, PAY_NEXT_STEP, PAY_WAYS, PLACE_KINDS, POLICY_TOPICS, PRESENTATION_HINT, PRICE_MATCH_REASONS, PRICE_MATCH_STATES, PRICE_SOURCES, PUBLIC_ORIGINS, type PayOrderInput, type PayWay, type PaymentHandler, type PaymentMethodUnavailableReason, type PaymentStatus, type Place, type PlaceRef, type PolicyTopic, type PositionalSpec, type PriceMatch, type PriceMatchReason, type PriceMatchState, RATE_LIMITS, REPOSITORY_URL, type RateLimitName, type RenderSurface, type RenderedTool, type RequestPriceMatchInput, type RoomType, SEARCH_NOTE_CODES, SEARCH_NOTE_DETAILS, SEARCH_RULES, SEARCH_SORTS, SERVER_INFO, SKILL_INSTALL_COMMAND, SUPPLIER_OUTCOME_STATUS, SUPPORT_EMAIL, type SearchHotelsInput, type SearchNote, type SearchNoteCode, type SearchResult, type Stay, TOOLS, type TokenUsageLimits, type ToolName, type ToolSpec, UNAVAILABLE_REASONS, UNKNOWN_IS_NOT_NO_EXEMPTIONS, addIsoDateDays, authConfig, cancelNextStep, cancelOrderInput, cancellation, center, claimId, commandInvocation, confirmation, containsCardNumber, countIsoDateDays, createOrderInput, createSearchHotelsInput, destination, errorEnvelope, flag, formatMoney, getHotelInput, getOrderInput, getPriceMatchInput, hotel, hotelId, hotelOffersInput, hotelOffersResult, hotelSummary, indicativePrice, instant, isIsoDate, knownLocaleText, latLng, listOrdersInput, localDate, localTime, localities, localizedText, matchedOffer, meResult, meals, misplacedKeyHint, misplacedKeys, money, names, nonEmpty, offer, offerChange, offerId, offersPerHotel, omitted, oneOf, openEnum, openObject, openUnion, order, orderCancel, orderId, orderList, orderReference, parseOpen, payAtProperty, payNextStep, payOrderInput, paymentHandler, photo, place, placeId, placeRef, priceMatch, priceSeen, protocolObject, renderError, renderGuide, renderToolResult, requestMoney, requestPriceMatchInput, roomType, routePath, searchHotelsInput, searchNote, searchResult, statedMoney, stay, stayEcho, strictInput, strictOutput, text, timeZone, tokenUsageLimits, toolsFor, unknownFieldsMessage, wholeNumber };
|
package/dist/index.js
CHANGED
|
@@ -88,6 +88,7 @@ function prefixed(prefix, name) {
|
|
|
88
88
|
var hotelId = prefixed("htl", "hotelId");
|
|
89
89
|
var offerId = prefixed("off", "offerId");
|
|
90
90
|
var orderId = prefixed("ord", "orderId");
|
|
91
|
+
var claimId = prefixed("clm", "claimId");
|
|
91
92
|
var placeId = z.string({ error: "placeId must be plc_ followed by 1 to 12 digits" }).regex(/^plc_\d{1,12}$/, {
|
|
92
93
|
error: "placeId must be plc_ followed by 1 to 12 digits"
|
|
93
94
|
});
|
|
@@ -198,6 +199,19 @@ function requestMoney(name, currencies = CURRENCIES, otherCurrency) {
|
|
|
198
199
|
}
|
|
199
200
|
);
|
|
200
201
|
}
|
|
202
|
+
var STATED_AMOUNT_MAX = 16;
|
|
203
|
+
var statedAmountError = `amount must be a decimal string such as 132.40, of at most ${STATED_AMOUNT_MAX} characters`;
|
|
204
|
+
function statedMoney(name) {
|
|
205
|
+
return z3.strictObject(
|
|
206
|
+
{
|
|
207
|
+
amount: z3.string({ error: statedAmountError }).max(STATED_AMOUNT_MAX, { error: statedAmountError }).regex(/^\d+(\.\d+)?$/, { error: statedAmountError }).describe(`Decimal string such as 132.40, never a number; at most ${STATED_AMOUNT_MAX} characters.`),
|
|
208
|
+
currency: z3.string({ error: currencyError }).regex(/^[A-Z]{3}$/, { error: currencyError }).describe("3-letter uppercase ISO 4217 code, such as USD or EUR.")
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
error: (issue) => issue.code === "unrecognized_keys" ? unknownFieldsMessage(issue.keys) : `${name} must be Money: { amount: "132.40", currency: "EUR" }`
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
}
|
|
201
215
|
function echoedMoney(name) {
|
|
202
216
|
return z3.looseObject(
|
|
203
217
|
{
|
|
@@ -643,6 +657,36 @@ var payOrderInput = strictInput({
|
|
|
643
657
|
"The total the user approved: the order's total, amount and currency, exactly as the order gives it (total). In USD: a token pays a USD order only, and any other order is paid by its payment link."
|
|
644
658
|
)
|
|
645
659
|
});
|
|
660
|
+
var SITE_MAX = 64;
|
|
661
|
+
var LINK_MAX = 2048;
|
|
662
|
+
var linkError = `link must be an https URL of at most ${LINK_MAX} characters`;
|
|
663
|
+
var siteError = `site must be text of 1 to ${SITE_MAX} characters`;
|
|
664
|
+
var site = z5.string({ error: siteError }).trim().min(1, { error: siteError }).max(SITE_MAX, { error: siteError }).refine((value) => !containsCardNumber(value), { error: CARD_NUMBER_MESSAGE, abort: true });
|
|
665
|
+
function isHttpsUrl(value) {
|
|
666
|
+
try {
|
|
667
|
+
return new URL(value).protocol === "https:";
|
|
668
|
+
} catch {
|
|
669
|
+
return false;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
var requestPriceMatchInput = strictInput({
|
|
673
|
+
offerId: offerId.describe(
|
|
674
|
+
"The offerId of the offer the user saw cheaper on another site, as an offers answer gave it."
|
|
675
|
+
),
|
|
676
|
+
site: site.describe(
|
|
677
|
+
`The other site's name as the user gave it, such as a booking site or the hotel's own website; 1 to ${SITE_MAX} characters.`
|
|
678
|
+
),
|
|
679
|
+
link: cardFreeText("link", 1, LINK_MAX).refine(isHttpsUrl, { error: linkError }).optional().describe(
|
|
680
|
+
`The link to the page where the user saw the price: on that site, or on a comparison site that leads to it. Ask the user for it; the check starts from that page. An https URL of at most ${LINK_MAX} characters.`
|
|
681
|
+
),
|
|
682
|
+
seenTotal: statedMoney("seenTotal").optional().describe(
|
|
683
|
+
"The total the user says they saw on that site for the same stay, if they gave one, in the currency they saw it in."
|
|
684
|
+
),
|
|
685
|
+
locale: locale.optional()
|
|
686
|
+
});
|
|
687
|
+
var getPriceMatchInput = strictInput({
|
|
688
|
+
claimId: claimId.describe("The claimId the price-match request answered with.")
|
|
689
|
+
});
|
|
646
690
|
|
|
647
691
|
// src/commands.ts
|
|
648
692
|
function fieldDescription(json, field, sets = {}) {
|
|
@@ -847,6 +891,25 @@ var offersFlags = flagsOf(hotelOffersInput, [
|
|
|
847
891
|
localeFlag,
|
|
848
892
|
currencyFlag
|
|
849
893
|
]);
|
|
894
|
+
var priceMatchFlags = flagsOf(requestPriceMatchInput, [
|
|
895
|
+
{ flag: "site", field: "site", type: "string", placeholder: "<name>", required: "always" },
|
|
896
|
+
{ flag: "link", field: "link", type: "string", placeholder: "<url>" },
|
|
897
|
+
{
|
|
898
|
+
flag: "seen-total",
|
|
899
|
+
field: "seenTotal",
|
|
900
|
+
type: "string",
|
|
901
|
+
placeholder: "<amount>",
|
|
902
|
+
description: "The total the user says they saw on that site for the same stay, if they gave one, as an amount in `--seen-currency`, e.g. `320.00`."
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
flag: "seen-currency",
|
|
906
|
+
field: "seenTotal.currency",
|
|
907
|
+
type: "string",
|
|
908
|
+
placeholder: "<code>",
|
|
909
|
+
description: "The currency of `--seen-total`, a 3-letter code such as EUR. Default USD."
|
|
910
|
+
},
|
|
911
|
+
localeFlag
|
|
912
|
+
]);
|
|
850
913
|
var createFlags = flagsOf(createOrderInput, [
|
|
851
914
|
{
|
|
852
915
|
flag: "offer",
|
|
@@ -921,7 +984,7 @@ var BODY_OPTION = {
|
|
|
921
984
|
description: "The raw request body as a JSON object, or `@file.json` to read it from a file. Flags override its fields."
|
|
922
985
|
};
|
|
923
986
|
var COMMAND_GROUPS = [
|
|
924
|
-
{ name: "hotels", summary: "Search hotels, read one's details
|
|
987
|
+
{ name: "hotels", summary: "Search hotels, read one's details, get live offers and ask for a price match" },
|
|
925
988
|
{ name: "orders", summary: "Create an order from an offer; your orders, their status, paying and cancelling one" }
|
|
926
989
|
];
|
|
927
990
|
var COMMANDS = [
|
|
@@ -949,6 +1012,22 @@ var COMMANDS = [
|
|
|
949
1012
|
flags: offersFlags,
|
|
950
1013
|
options: [BODY_OPTION]
|
|
951
1014
|
},
|
|
1015
|
+
{
|
|
1016
|
+
group: "hotels",
|
|
1017
|
+
name: "price-match",
|
|
1018
|
+
summary: "Ask Fortrip to match a lower price the user saw for an offer on another site",
|
|
1019
|
+
tool: "request_price_match",
|
|
1020
|
+
flags: priceMatchFlags,
|
|
1021
|
+
positionals: [positional(requestPriceMatchInput, "offerId")]
|
|
1022
|
+
},
|
|
1023
|
+
{
|
|
1024
|
+
group: "hotels",
|
|
1025
|
+
name: "price-match-status",
|
|
1026
|
+
summary: "Show how a price match is going, and its new offer once matched",
|
|
1027
|
+
tool: "get_price_match",
|
|
1028
|
+
flags: [],
|
|
1029
|
+
positionals: [positional(getPriceMatchInput, "claimId")]
|
|
1030
|
+
},
|
|
952
1031
|
{
|
|
953
1032
|
group: "orders",
|
|
954
1033
|
name: "create",
|
|
@@ -2234,7 +2313,8 @@ var ERROR_DETAILS = {
|
|
|
2234
2313
|
"orders_read",
|
|
2235
2314
|
"orders_create",
|
|
2236
2315
|
"orders_cancel",
|
|
2237
|
-
"orders_pay"
|
|
2316
|
+
"orders_pay",
|
|
2317
|
+
"price_match"
|
|
2238
2318
|
]).describe("Which rate limit was hit, by the kind of call it counts.")
|
|
2239
2319
|
}),
|
|
2240
2320
|
ordering_paused: null,
|
|
@@ -2263,6 +2343,60 @@ var errorEnvelope = openObject({
|
|
|
2263
2343
|
)
|
|
2264
2344
|
});
|
|
2265
2345
|
|
|
2346
|
+
// src/outputs/price-match.ts
|
|
2347
|
+
import { z as z17 } from "zod";
|
|
2348
|
+
var PRICE_MATCH_STATES = ["checking", "matched", "partial", "declined"];
|
|
2349
|
+
var PRICE_MATCH_REASONS = [
|
|
2350
|
+
"not_lower",
|
|
2351
|
+
"not_offered",
|
|
2352
|
+
"site_unreadable",
|
|
2353
|
+
"site_not_credible",
|
|
2354
|
+
"unsupported",
|
|
2355
|
+
"daily_limit",
|
|
2356
|
+
"monthly_limit",
|
|
2357
|
+
"unfinished",
|
|
2358
|
+
"unavailable"
|
|
2359
|
+
];
|
|
2360
|
+
var PRICE_SOURCES = ["site", "data"];
|
|
2361
|
+
var priceSeen = openObject({
|
|
2362
|
+
site: z17.string().describe("The site the price was seen on."),
|
|
2363
|
+
total: money.describe("The total seen there for the stay."),
|
|
2364
|
+
via: openEnum(PRICE_SOURCES).describe(
|
|
2365
|
+
"site: read from the site's own page. data: from price data for that site, when its page could not be read."
|
|
2366
|
+
),
|
|
2367
|
+
room: z17.string().optional().describe("The room the price was for, as the site named it."),
|
|
2368
|
+
terms: z17.string().optional().describe("The terms that price came with, as the site gave them.")
|
|
2369
|
+
});
|
|
2370
|
+
var matchedOffer = openObject({
|
|
2371
|
+
offerId: offerId.describe("The new offer's offerId, to order as any offer."),
|
|
2372
|
+
total: money.describe("The new offer's total."),
|
|
2373
|
+
expiresAt: instant.describe("When the new offer can no longer be ordered."),
|
|
2374
|
+
saved: money.describe("How much less than the original offer's total it is.")
|
|
2375
|
+
});
|
|
2376
|
+
var priceMatch = openObject({
|
|
2377
|
+
state: openEnum(PRICE_MATCH_STATES).describe(
|
|
2378
|
+
"checking: the other site is being checked. matched: a new offer whose total, with ourFeesAtProperty when present, is the other site's total. partial: a new offer below the original, short of the other site's total. declined: no new offer; reason says why."
|
|
2379
|
+
),
|
|
2380
|
+
offerId: offerId.describe("The offer the price match is about."),
|
|
2381
|
+
site: z17.string().describe("The other site, as the request named it."),
|
|
2382
|
+
ourTotal: money.describe("That offer's total."),
|
|
2383
|
+
claimId: claimId.optional().describe("The price match's id, to read it again; absent only when it was declined before any check started."),
|
|
2384
|
+
progressUrl: z17.string().optional().describe("A page the user can follow the check on; present with claimId."),
|
|
2385
|
+
checkAgainAfterSeconds: z17.number().int().nonnegative().optional().describe("While checking: how many seconds to wait before reading the price match again."),
|
|
2386
|
+
step: z17.string().optional().describe("While checking: the latest step of the check."),
|
|
2387
|
+
seen: z17.array(priceSeen).nullable().optional().describe("The prices the check saw on the other site; null or absent when none is on record."),
|
|
2388
|
+
matchedOffer: matchedOffer.optional().describe("When matched or partial: the new offer."),
|
|
2389
|
+
otherTotal: money.optional().describe("When matched or partial: what the other site charges for the stay, with its taxes and fees."),
|
|
2390
|
+
ourFeesAtProperty: money.optional().describe(
|
|
2391
|
+
"Fortrip's own fees for this stay paid at the hotel, known and counted in the comparison; absent when there are none or they are not known."
|
|
2392
|
+
),
|
|
2393
|
+
reason: openEnum(PRICE_MATCH_REASONS).optional().describe(
|
|
2394
|
+
"When declined: not_lower, the site was not lower. not_offered: the site does not sell this room for these dates. site_unreadable: this stay's price could not be seen on the site. site_not_credible: not a site price match covers. unsupported: an offer price match does not cover. daily_limit: no more checks for now. monthly_limit: price match is not available for now. unfinished: the check could not finish in time; the same request again starts a new check. unavailable: price match is not available now."
|
|
2395
|
+
),
|
|
2396
|
+
note: z17.string().optional().describe("One sentence about the check."),
|
|
2397
|
+
propertyFeeLeftOut: z17.boolean().nullable().optional().describe("True when a fee payable at the property is left out of the comparison; null or absent when not known.")
|
|
2398
|
+
});
|
|
2399
|
+
|
|
2266
2400
|
// src/paths.ts
|
|
2267
2401
|
var PUBLIC_ORIGINS = {
|
|
2268
2402
|
api: "https://api.fortrip.ai",
|
|
@@ -2307,6 +2441,8 @@ var HTTP_ROUTES = {
|
|
|
2307
2441
|
search_hotels: route("POST", "/v1/hotels/search"),
|
|
2308
2442
|
get_hotel: route("GET", "/v1/hotels/{hotelId}", ["include", "locale"]),
|
|
2309
2443
|
get_hotel_offers: route("POST", "/v1/hotels/offers"),
|
|
2444
|
+
request_price_match: route("POST", "/v1/price-matches"),
|
|
2445
|
+
get_price_match: route("GET", "/v1/price-matches/{claimId}"),
|
|
2310
2446
|
create_order: route("POST", "/v1/orders"),
|
|
2311
2447
|
get_order: route("GET", "/v1/orders/{orderId}", ["locale"]),
|
|
2312
2448
|
list_orders: route("GET", "/v1/orders", ["cursor", "limit", "locale"]),
|
|
@@ -2338,11 +2474,12 @@ var RATE_LIMITS = {
|
|
|
2338
2474
|
orders_create: { limit: 20, windowSeconds: 60 },
|
|
2339
2475
|
orders_read: { limit: 60, windowSeconds: 60 },
|
|
2340
2476
|
orders_cancel: { limit: 10, windowSeconds: 60 },
|
|
2341
|
-
orders_pay: { limit: 10, windowSeconds: 60 }
|
|
2477
|
+
orders_pay: { limit: 10, windowSeconds: 60 },
|
|
2478
|
+
price_match: { limit: 60, windowSeconds: 60 }
|
|
2342
2479
|
};
|
|
2343
2480
|
|
|
2344
2481
|
// src/render/index.ts
|
|
2345
|
-
import { z as
|
|
2482
|
+
import { z as z19 } from "zod";
|
|
2346
2483
|
|
|
2347
2484
|
// src/tools.ts
|
|
2348
2485
|
import "zod";
|
|
@@ -2422,6 +2559,34 @@ var SPECS = [
|
|
|
2422
2559
|
input: hotelOffersInput,
|
|
2423
2560
|
output: hotelOffersResult
|
|
2424
2561
|
},
|
|
2562
|
+
{
|
|
2563
|
+
name: "request_price_match",
|
|
2564
|
+
title: "Request price match",
|
|
2565
|
+
description: "Use this when the user says they saw this stay cheaper on another site. Give the offer's offerId and the site's name as they said it. Ask the user for the link to the page where they saw it and send it; a comparison site's link that leads to the booking site counts. Send the total they saw if given. It answers at once: with a claimId and a progress link to show the user while Fortrip checks that site (up to ten minutes), or declined with the reason when no check starts. While checking, call get_price_match with the claimId after the seconds the answer states, not sooner; if you cannot wait, ask the user to ask again in a few minutes. Say nothing to the user about a match until the state is matched (or partial: lower, but short of the other site's price). A matched or partial answer carries a new offerId: order it with create_order, with the same consent before paying. The same call again answers the same price match while its check runs or its result stands; a new link or an unfinished check starts a new one.",
|
|
2566
|
+
// A write that destroys nothing: it starts a check and answers a claim,
|
|
2567
|
+
// and orders, pays for and cancels nothing. Not idempotent: the same
|
|
2568
|
+
// call answers the same claim while its check runs, while its matched
|
|
2569
|
+
// offer is valid, and after a decline that judged the site. After any
|
|
2570
|
+
// other decline (a check that ended unfinished, a limit, price match not
|
|
2571
|
+
// available) the same call can start another check, which counts
|
|
2572
|
+
// against the account's checks.
|
|
2573
|
+
annotations: {
|
|
2574
|
+
readOnlyHint: false,
|
|
2575
|
+
idempotentHint: false,
|
|
2576
|
+
openWorldHint: true,
|
|
2577
|
+
destructiveHint: false
|
|
2578
|
+
},
|
|
2579
|
+
input: requestPriceMatchInput,
|
|
2580
|
+
output: priceMatch
|
|
2581
|
+
},
|
|
2582
|
+
{
|
|
2583
|
+
name: "get_price_match",
|
|
2584
|
+
title: "Get price match",
|
|
2585
|
+
description: "Use this when the user asks how a price-match check is going, or once the wait a check stated has passed. Give the claimId request_price_match answered with. It returns the state: checking (with the latest step and when to look again), matched, partial or declined. While it is checking, look again only after the wait the answer states; if you cannot wait, ask the user to ask again in a few minutes. Only matched or partial carries a new offer, with its offerId, total, saving and expiry, to order with create_order. Declined says what was seen and why there is no new price.",
|
|
2586
|
+
annotations: READ_OWN,
|
|
2587
|
+
input: getPriceMatchInput,
|
|
2588
|
+
output: priceMatch
|
|
2589
|
+
},
|
|
2425
2590
|
{
|
|
2426
2591
|
name: "create_order",
|
|
2427
2592
|
title: "Create order",
|
|
@@ -3206,6 +3371,138 @@ function renderOrderList(list, surface = "mcp") {
|
|
|
3206
3371
|
return lines.join("\n");
|
|
3207
3372
|
}
|
|
3208
3373
|
|
|
3374
|
+
// src/render/price-match.ts
|
|
3375
|
+
var STATE_WORDS = {
|
|
3376
|
+
checking: "checking",
|
|
3377
|
+
matched: "matched",
|
|
3378
|
+
partial: "partly matched",
|
|
3379
|
+
declined: "declined"
|
|
3380
|
+
};
|
|
3381
|
+
var VIA_WORDS = {
|
|
3382
|
+
site: "read from the site's own page",
|
|
3383
|
+
data: "from price data for that site"
|
|
3384
|
+
};
|
|
3385
|
+
var REASON_WORDS = {
|
|
3386
|
+
not_lower: "the site was not lower than Fortrip's price.",
|
|
3387
|
+
not_offered: "that site does not sell this room for these dates, so there is no price to match.",
|
|
3388
|
+
site_unreadable: "Fortrip could not see this stay's price on that site, so it could not check it.",
|
|
3389
|
+
site_not_credible: "Fortrip only matches well-known booking sites and the hotel's own site.",
|
|
3390
|
+
unsupported: "price match is not available for this offer: for now it covers USD offers of one room, and not a price already matched.",
|
|
3391
|
+
daily_limit: "no more checks for now; try again later.",
|
|
3392
|
+
monthly_limit: "price match is not available for now.",
|
|
3393
|
+
unfinished: "the check could not finish in time; the same request again starts a new check.",
|
|
3394
|
+
unavailable: "price match is not available right now."
|
|
3395
|
+
};
|
|
3396
|
+
function lookCall(r, surface) {
|
|
3397
|
+
if (r.claimId === void 0) {
|
|
3398
|
+
return surface === "cli" ? ours`run the same \`fortrip hotels price-match\` command again` : ours`call request_price_match again with the same arguments`;
|
|
3399
|
+
}
|
|
3400
|
+
return surface === "cli" ? ours`run \`fortrip hotels price-match-status ${token("id", r.claimId)}\`` : ours`call get_price_match { claimId: ${theirs(r.claimId)} }`;
|
|
3401
|
+
}
|
|
3402
|
+
function orderCall(offerId2, surface) {
|
|
3403
|
+
return surface === "cli" ? ours`run \`fortrip orders create --offer ${token("id", offerId2)}\` with the guests and the contact` : ours`call create_order with offer ${token("id", offerId2)}`;
|
|
3404
|
+
}
|
|
3405
|
+
function headLine(r) {
|
|
3406
|
+
return joined(
|
|
3407
|
+
[
|
|
3408
|
+
r.claimId === void 0 ? ours`Price match` : ours`Price match ${token("id", r.claimId)}`,
|
|
3409
|
+
label(STATE_WORDS, r.state, ours`state not recognized`),
|
|
3410
|
+
ours`site ${theirs(r.site)}`,
|
|
3411
|
+
ours`offer ${token("id", r.offerId)}, Fortrip's total ${money2(r.ourTotal)}`
|
|
3412
|
+
],
|
|
3413
|
+
" \xB7 "
|
|
3414
|
+
);
|
|
3415
|
+
}
|
|
3416
|
+
function seenLines(r) {
|
|
3417
|
+
return (r.seen ?? []).map(
|
|
3418
|
+
(s) => joined(
|
|
3419
|
+
[
|
|
3420
|
+
ours`Seen on ${theirs(s.site)}: ${money2(s.total)}, ${label(VIA_WORDS, s.via, ours`from a source not recognized`)}`,
|
|
3421
|
+
s.room !== void 0 && ours`room ${theirs(s.room)}`,
|
|
3422
|
+
s.terms !== void 0 && ours`terms ${theirs(s.terms)}`
|
|
3423
|
+
],
|
|
3424
|
+
" \xB7 "
|
|
3425
|
+
)
|
|
3426
|
+
);
|
|
3427
|
+
}
|
|
3428
|
+
var progressLine = (r) => r.progressUrl === void 0 ? [] : [ours`Progress page, to share with the user: ${token("url", r.progressUrl)}`];
|
|
3429
|
+
var noteLine = (r) => r.note === void 0 ? [] : [ours`Note from the check: ${theirs(r.note)}`];
|
|
3430
|
+
var aboutLines = (r) => [...progressLine(r), ...noteLine(r)];
|
|
3431
|
+
function ourFeesLine(r) {
|
|
3432
|
+
const fees = r.ourFeesAtProperty;
|
|
3433
|
+
if (fees === void 0 || /^0+(?:\.0+)?$/.test(fees.amount)) return [];
|
|
3434
|
+
const due = ours`The comparison counts what is paid at the hotel: this offer also has ${money2(fees)} due at the property`;
|
|
3435
|
+
return [
|
|
3436
|
+
r.state === "matched" ? ours`${due}, so the new total can be below the other site's total by that amount.` : ours`${due}.`
|
|
3437
|
+
];
|
|
3438
|
+
}
|
|
3439
|
+
var feeLine = (r) => r.propertyFeeLeftOut === true ? [ours`A fee payable at the property is left out of this comparison.`] : [];
|
|
3440
|
+
function checkingLines(r, surface) {
|
|
3441
|
+
const wait = r.checkAgainAfterSeconds === void 0 ? ours`shortly` : ours`in ${plural(r.checkAgainAfterSeconds, "second")}`;
|
|
3442
|
+
const instead = r.progressUrl === void 0 ? ours`ask the user to ask again in a few minutes` : ours`give the user the progress page and ask them to ask again in a few minutes`;
|
|
3443
|
+
const sooner = r.checkAgainAfterSeconds === void 0 ? ours`If you cannot wait` : ours`Do not look sooner: if you cannot wait`;
|
|
3444
|
+
return [
|
|
3445
|
+
...progressLine(r),
|
|
3446
|
+
...r.step === void 0 ? [] : [ours`Latest step: ${theirs(r.step)}`],
|
|
3447
|
+
...noteLine(r),
|
|
3448
|
+
ours`Look again ${wait}: ${lookCall(r, surface)}. ${sooner}, ${instead}. The check can take up to ten minutes. Until the state is matched or partial, say nothing to the user about a match or a lower price.`
|
|
3449
|
+
];
|
|
3450
|
+
}
|
|
3451
|
+
function matchLines(r, surface) {
|
|
3452
|
+
const m = r.matchedOffer;
|
|
3453
|
+
if (m === void 0) {
|
|
3454
|
+
return [
|
|
3455
|
+
...seenLines(r),
|
|
3456
|
+
...aboutLines(r),
|
|
3457
|
+
ours`New offer: none in this answer; say nothing to the user about a match yet, and look again: ${lookCall(r, surface)}.`
|
|
3458
|
+
];
|
|
3459
|
+
}
|
|
3460
|
+
const other = r.state === "partial" ? [
|
|
3461
|
+
ours`Other site's total: ${r.otherTotal === void 0 ? ours`not stated` : money2(r.otherTotal)}. Fortrip's limit on a price match stopped short of it: the new offer is the lowest this price match can give.`
|
|
3462
|
+
] : [];
|
|
3463
|
+
return [
|
|
3464
|
+
ours`New offer: ${token("id", m.offerId)} · total ${money2(m.total)} · saves ${money2(m.saved)} · expires ${when(m.expiresAt, null)}`,
|
|
3465
|
+
...other,
|
|
3466
|
+
...ourFeesLine(r),
|
|
3467
|
+
...seenLines(r),
|
|
3468
|
+
ours`Every other term of the new offer is as in offer ${token("id", r.offerId)}: the room, meals, cancellation and fees payable at the property.`,
|
|
3469
|
+
...feeLine(r),
|
|
3470
|
+
...aboutLines(r),
|
|
3471
|
+
ours`To book at this price: ${orderCall(m.offerId, surface)}, as for any offer, before it expires.`
|
|
3472
|
+
];
|
|
3473
|
+
}
|
|
3474
|
+
function declinedLines(r) {
|
|
3475
|
+
const why = r.reason === void 0 ? ours`not stated.` : label(REASON_WORDS, r.reason, ours`a reason not recognized.`);
|
|
3476
|
+
return [
|
|
3477
|
+
...seenLines(r),
|
|
3478
|
+
ours`Why: ${why}`,
|
|
3479
|
+
...feeLine(r),
|
|
3480
|
+
...aboutLines(r),
|
|
3481
|
+
ours`No new offer: offer ${token("id", r.offerId)} stays as it was.`
|
|
3482
|
+
];
|
|
3483
|
+
}
|
|
3484
|
+
function renderPriceMatch(r, surface = "mcp") {
|
|
3485
|
+
let lines;
|
|
3486
|
+
switch (r.state) {
|
|
3487
|
+
case "checking":
|
|
3488
|
+
lines = checkingLines(r, surface);
|
|
3489
|
+
break;
|
|
3490
|
+
case "matched":
|
|
3491
|
+
case "partial":
|
|
3492
|
+
lines = matchLines(r, surface);
|
|
3493
|
+
break;
|
|
3494
|
+
case "declined":
|
|
3495
|
+
lines = declinedLines(r);
|
|
3496
|
+
break;
|
|
3497
|
+
default:
|
|
3498
|
+
lines = [
|
|
3499
|
+
...aboutLines(r),
|
|
3500
|
+
ours`State ${code(r.state, ours`not recognized`)}: say nothing to the user about a match, and look again: ${lookCall(r, surface)}.`
|
|
3501
|
+
];
|
|
3502
|
+
}
|
|
3503
|
+
return [headLine(r), ...lines].join("\n");
|
|
3504
|
+
}
|
|
3505
|
+
|
|
3209
3506
|
// src/render/search.ts
|
|
3210
3507
|
var SORTS = {
|
|
3211
3508
|
distance: "nearest first",
|
|
@@ -3544,6 +3841,15 @@ var HAPPENED = {
|
|
|
3544
3841
|
supplier_unavailable: "the hotel's side couldn't be reached this time.",
|
|
3545
3842
|
internal: "something went wrong on Fortrip's side."
|
|
3546
3843
|
};
|
|
3844
|
+
var HAPPENED_BY_TOOL = {
|
|
3845
|
+
request_price_match: {
|
|
3846
|
+
not_found: "no such offer.",
|
|
3847
|
+
offer_expired: "the offer expired, or Fortrip's own price for its room changed since the offer was made; no check was started."
|
|
3848
|
+
},
|
|
3849
|
+
get_price_match: {
|
|
3850
|
+
not_found: "no such price match for this user."
|
|
3851
|
+
}
|
|
3852
|
+
};
|
|
3547
3853
|
var CURSOR_WORDS = {
|
|
3548
3854
|
expired: "has expired",
|
|
3549
3855
|
mismatch: "is not this user's, or was changed",
|
|
@@ -3556,7 +3862,8 @@ var RATE_LIMIT_WORDS = {
|
|
|
3556
3862
|
orders_read: "reads of orders",
|
|
3557
3863
|
orders_create: "orders created",
|
|
3558
3864
|
orders_cancel: "cancellations",
|
|
3559
|
-
orders_pay: "payments"
|
|
3865
|
+
orders_pay: "payments",
|
|
3866
|
+
price_match: "price-match requests and reads"
|
|
3560
3867
|
};
|
|
3561
3868
|
var isObject3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
3562
3869
|
function changeLine(c) {
|
|
@@ -3670,7 +3977,7 @@ function notCancellable(d, surface) {
|
|
|
3670
3977
|
ours`This order can be neither cancelled nor closed now: ${blockerText(c)}.`
|
|
3671
3978
|
];
|
|
3672
3979
|
}
|
|
3673
|
-
function detailLines(e, surface, tokenPay) {
|
|
3980
|
+
function detailLines(e, surface, tokenPay, tool) {
|
|
3674
3981
|
const getOrder = (id) => surface === "cli" ? ours`\`fortrip orders get ${id}\`` : ours`get_order`;
|
|
3675
3982
|
switch (e.code) {
|
|
3676
3983
|
case "invalid_request": {
|
|
@@ -3690,6 +3997,12 @@ function detailLines(e, surface, tokenPay) {
|
|
|
3690
3997
|
case "not_found":
|
|
3691
3998
|
return [ours`Use an id an earlier answer showed, exactly as shown.`];
|
|
3692
3999
|
case "offer_expired":
|
|
4000
|
+
if (tool === "request_price_match") {
|
|
4001
|
+
const again = surface === "cli" ? ours`run \`fortrip hotels price-match\` again` : ours`call request_price_match again`;
|
|
4002
|
+
return [
|
|
4003
|
+
ours`Offer ${token("id", e.details.offerId)} can't be price-matched: get offers again, let the user choose again, then ${again} with the new offer.`
|
|
4004
|
+
];
|
|
4005
|
+
}
|
|
3693
4006
|
return [
|
|
3694
4007
|
ours`Offer ${token("id", e.details.offerId)} expired at ${when(e.details.expiredAt, null)}: get offers again and let the user choose again.`
|
|
3695
4008
|
];
|
|
@@ -3815,13 +4128,14 @@ function renderError(envelope, status, surface = "mcp", options = {}) {
|
|
|
3815
4128
|
}
|
|
3816
4129
|
const name = typeof body.code === "string" ? code(body.code, ours`unknown`) : ours`unknown`;
|
|
3817
4130
|
const head = status === void 0 ? ours`Error ${name}` : ours`Error ${name} (HTTP ${status})`;
|
|
3818
|
-
const
|
|
4131
|
+
const forTool = options.tool === void 0 ? void 0 : HAPPENED_BY_TOOL[options.tool]?.[body.code];
|
|
4132
|
+
const happened = typeof body.code === "string" && Object.hasOwn(HAPPENED, body.code) ? own(forTool ?? HAPPENED[body.code]) : typeof body.message === "string" ? theirs(body.message) : null;
|
|
3819
4133
|
const lines = [
|
|
3820
4134
|
happened === null ? head : ours`${head}: ${happened}`,
|
|
3821
4135
|
retryLine(body.retryable, body.retryAfterSeconds)
|
|
3822
4136
|
];
|
|
3823
4137
|
if (typeof body.pointer === "string") lines.push(ours`Field: ${token("pointer", body.pointer)}`);
|
|
3824
|
-
if (known) lines.push(...detailLines(known, surface, options.tokenPay !== false));
|
|
4138
|
+
if (known) lines.push(...detailLines(known, surface, options.tokenPay !== false, options.tool));
|
|
3825
4139
|
else if (body.details !== void 0) lines.push(ours`Details: ${raw(body.details)}`);
|
|
3826
4140
|
if (typeof body.requestId === "string" && (surface === "cli" || body.code === "internal")) {
|
|
3827
4141
|
lines.push(ours`Request id: ${token("id", body.requestId)}`);
|
|
@@ -3846,7 +4160,7 @@ function withoutTokenRequest(value) {
|
|
|
3846
4160
|
}
|
|
3847
4161
|
return out;
|
|
3848
4162
|
}
|
|
3849
|
-
var orderPage = openObject({ data:
|
|
4163
|
+
var orderPage = openObject({ data: z19.array(z19.unknown()), nextCursor: z19.string().nullable() });
|
|
3850
4164
|
function resultText(tool, data, surface) {
|
|
3851
4165
|
const schema = tool === "list_orders" ? orderPage : TOOLS.find((t) => t.name === tool)?.output;
|
|
3852
4166
|
let parsed;
|
|
@@ -3871,6 +4185,9 @@ function resultText(tool, data, surface) {
|
|
|
3871
4185
|
return renderHotel(parsed);
|
|
3872
4186
|
case "get_hotel_offers":
|
|
3873
4187
|
return renderOffers(parsed, surface);
|
|
4188
|
+
case "request_price_match":
|
|
4189
|
+
case "get_price_match":
|
|
4190
|
+
return renderPriceMatch(parsed, surface);
|
|
3874
4191
|
case "create_order":
|
|
3875
4192
|
case "get_order":
|
|
3876
4193
|
case "cancel_order":
|
|
@@ -3989,10 +4306,11 @@ var ME_SCOPES = { email: "email", name: "profile" };
|
|
|
3989
4306
|
// package.json
|
|
3990
4307
|
var package_default = {
|
|
3991
4308
|
name: "@fortrip/agent-contract",
|
|
3992
|
-
version: "6.
|
|
4309
|
+
version: "6.5.0-rc.0",
|
|
3993
4310
|
license: "Apache-2.0",
|
|
3994
4311
|
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.",
|
|
3995
4312
|
type: "module",
|
|
4313
|
+
homepage: "https://docs.fortrip.ai",
|
|
3996
4314
|
repository: {
|
|
3997
4315
|
type: "git",
|
|
3998
4316
|
url: "git+https://github.com/FortripEngineering/fortrip.git",
|
|
@@ -4084,6 +4402,9 @@ export {
|
|
|
4084
4402
|
PLACE_KINDS,
|
|
4085
4403
|
POLICY_TOPICS,
|
|
4086
4404
|
PRESENTATION_HINT,
|
|
4405
|
+
PRICE_MATCH_REASONS,
|
|
4406
|
+
PRICE_MATCH_STATES,
|
|
4407
|
+
PRICE_SOURCES,
|
|
4087
4408
|
PUBLIC_ORIGINS,
|
|
4088
4409
|
RATE_LIMITS,
|
|
4089
4410
|
REPOSITORY_URL,
|
|
@@ -4104,6 +4425,7 @@ export {
|
|
|
4104
4425
|
cancelOrderInput,
|
|
4105
4426
|
cancellation,
|
|
4106
4427
|
center,
|
|
4428
|
+
claimId,
|
|
4107
4429
|
commandInvocation,
|
|
4108
4430
|
confirmation,
|
|
4109
4431
|
containsCardNumber,
|
|
@@ -4116,6 +4438,7 @@ export {
|
|
|
4116
4438
|
formatMoney,
|
|
4117
4439
|
getHotelInput,
|
|
4118
4440
|
getOrderInput,
|
|
4441
|
+
getPriceMatchInput,
|
|
4119
4442
|
guestNameRe,
|
|
4120
4443
|
hotel,
|
|
4121
4444
|
hotelId,
|
|
@@ -4132,6 +4455,7 @@ export {
|
|
|
4132
4455
|
localTime,
|
|
4133
4456
|
localities,
|
|
4134
4457
|
localizedText,
|
|
4458
|
+
matchedOffer,
|
|
4135
4459
|
meResult,
|
|
4136
4460
|
meals,
|
|
4137
4461
|
misplacedKeyHint,
|
|
@@ -4163,16 +4487,20 @@ export {
|
|
|
4163
4487
|
place,
|
|
4164
4488
|
placeId,
|
|
4165
4489
|
placeRef,
|
|
4490
|
+
priceMatch,
|
|
4491
|
+
priceSeen,
|
|
4166
4492
|
protocolObject,
|
|
4167
4493
|
renderError,
|
|
4168
4494
|
renderGuide,
|
|
4169
4495
|
renderToolResult,
|
|
4170
4496
|
requestMoney,
|
|
4497
|
+
requestPriceMatchInput,
|
|
4171
4498
|
roomType,
|
|
4172
4499
|
routePath,
|
|
4173
4500
|
searchHotelsInput,
|
|
4174
4501
|
searchNote,
|
|
4175
4502
|
searchResult,
|
|
4503
|
+
statedMoney,
|
|
4176
4504
|
stay,
|
|
4177
4505
|
stayEcho,
|
|
4178
4506
|
strictInput,
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fortrip/agent-contract",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0-rc.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "The contract of Fortrip's agent API (https://api.fortrip.ai/v1) and its MCP server: limits, paths, request and response schemas, error codes and field rules.",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"homepage": "https://docs.fortrip.ai",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
10
|
"url": "git+https://github.com/FortripEngineering/fortrip.git",
|