@fortrip/agent-contract 3.2.0 → 3.3.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 +3 -3
- package/dist/index.d.ts +226 -8
- package/dist/index.js +132 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,14 +23,14 @@ It exports:
|
|
|
23
23
|
`SEARCH_SORTS` and `FILTERABLE_AMENITIES`: paths, hosts, limits, error codes
|
|
24
24
|
and vocabularies;
|
|
25
25
|
- `searchHotelsInput`, `getHotelInput`, `hotelOffersInput`,
|
|
26
|
-
`createOrderInput`, `getOrderInput
|
|
27
|
-
of the requests, and `searchResult`, `hotel`, `hotelOffersResult`, `order`,
|
|
26
|
+
`createOrderInput`, `getOrderInput`, `listOrdersInput` and
|
|
27
|
+
`cancelOrderInput`, the zod schemas of the requests, and `searchResult`, `hotel`, `hotelOffersResult`, `order`,
|
|
28
28
|
`orderList` and `errorEnvelope`, the open schemas of the responses, with
|
|
29
29
|
`parseOpen`, a parser that keeps unknown fields and values;
|
|
30
30
|
- `COMMANDS`, `COMMAND_GROUPS` and `GLOBAL_FLAGS`, the CLI's commands, the
|
|
31
31
|
groups they are typed after and its flags, `commandInvocation(spec)`, a
|
|
32
32
|
command as it is typed (`fortrip hotels search`), and `TOOLS`, the MCP
|
|
33
|
-
tools, with `MCP_OUTPUT` and `
|
|
33
|
+
tools, with `MCP_OUTPUT`, `ORDER_NEXT_STEP` and `CANCEL_NEXT_STEP`;
|
|
34
34
|
- `renderToolResult(tool, data)` and `renderError(envelope)`, the compact
|
|
35
35
|
text of a result or an error, and `renderGuide(surface, topic)`, the agent
|
|
36
36
|
guide as Markdown for `"mcp"`, `"claude-skill"` or `"cli"`;
|
package/dist/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ declare function parseOpen<T>(schema: z.ZodType<T>, value: unknown): T;
|
|
|
52
52
|
*/
|
|
53
53
|
declare function strictOutput<T extends z.ZodType>(schema: T): T;
|
|
54
54
|
|
|
55
|
-
type ToolName = "get_planning_guide" | "search_hotels" | "get_hotel" | "get_hotel_offers" | "book_hotel" | "get_order" | "list_orders";
|
|
55
|
+
type ToolName = "get_planning_guide" | "search_hotels" | "get_hotel" | "get_hotel_offers" | "book_hotel" | "get_order" | "list_orders" | "cancel_order";
|
|
56
56
|
interface ToolSpec {
|
|
57
57
|
name: ToolName;
|
|
58
58
|
title: string;
|
|
@@ -74,6 +74,13 @@ interface ToolSpec {
|
|
|
74
74
|
* text: some clients never show the model the server instructions.
|
|
75
75
|
*/
|
|
76
76
|
declare const ORDER_NEXT_STEP = "Before you give the user an order's payment.url, show them its total and currency, the stay (hotel, room, dates, rooms and guests per room) and every term (meals, cancellation, fees payable at the property), then end your reply by asking them to confirm, and wait for a clear yes. Only after they say yes, give them payment.url exactly as returned.";
|
|
77
|
+
/**
|
|
78
|
+
* The consent rule of a cancellation (spec §5.7, C11). It rides as the last
|
|
79
|
+
* paragraph of the text of every MCP `get_order` and `list_orders` result
|
|
80
|
+
* that holds an order with `cancel.available`, after `ORDER_NEXT_STEP` when
|
|
81
|
+
* both apply, and never as `nextStep`, which keeps its payment-only meaning.
|
|
82
|
+
*/
|
|
83
|
+
declare const CANCEL_NEXT_STEP = "Before you call cancel_order, show the user the order's stay (hotel, dates), cancel.penalty and cancel.refund (amount and currency), then end your reply by asking them to confirm the cancellation, and wait for a clear yes. Pass maximumPenalty exactly as cancel.penalty.amount. Never state a refund the order did not return.";
|
|
77
84
|
/**
|
|
78
85
|
* How to present hotels (the `presentation` guide, in one line). It rides as
|
|
79
86
|
* the last paragraph of every MCP `search_hotels`, `get_hotel` and
|
|
@@ -81,8 +88,9 @@ declare const ORDER_NEXT_STEP = "Before you give the user an order's payment.url
|
|
|
81
88
|
* reliably than one in the server instructions.
|
|
82
89
|
*/
|
|
83
90
|
declare const 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 USD, and draw a map only from returned `location` coordinates. Offer the choices you need to ask anyway (dates, a locality, which offer) as options to pick. Otherwise use a short list. Keep hotel names as returned, and never invent photos, ratings, reviews, prices, terms or coordinates.";
|
|
84
|
-
/** The answers over MCP that
|
|
85
|
-
* `nextStep`, which only MCP
|
|
91
|
+
/** The answers over MCP that are orders. Those that can hold a
|
|
92
|
+
* `payment.url` are the HTTP answer plus `nextStep`, which only MCP
|
|
93
|
+
* declares; `cancel_order`'s never holds one, so it is the HTTP answer. */
|
|
86
94
|
declare const MCP_OUTPUT: {
|
|
87
95
|
readonly book_hotel: z.ZodObject<{
|
|
88
96
|
orderId: z.ZodString;
|
|
@@ -227,6 +235,12 @@ declare const MCP_OUTPUT: {
|
|
|
227
235
|
localCurrencyAtCheckout: z.ZodBoolean;
|
|
228
236
|
localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
229
237
|
}, z.core.$strip>;
|
|
238
|
+
cancel: z.ZodOptional<z.ZodObject<{
|
|
239
|
+
available: z.ZodBoolean;
|
|
240
|
+
reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
|
|
241
|
+
penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
242
|
+
refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
243
|
+
}, z.core.$strip>>;
|
|
230
244
|
manageUrl: z.ZodString;
|
|
231
245
|
nextStep: z.ZodOptional<z.ZodString>;
|
|
232
246
|
}, z.core.$strip>;
|
|
@@ -373,6 +387,12 @@ declare const MCP_OUTPUT: {
|
|
|
373
387
|
localCurrencyAtCheckout: z.ZodBoolean;
|
|
374
388
|
localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
375
389
|
}, z.core.$strip>;
|
|
390
|
+
cancel: z.ZodOptional<z.ZodObject<{
|
|
391
|
+
available: z.ZodBoolean;
|
|
392
|
+
reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
|
|
393
|
+
penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
394
|
+
refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
395
|
+
}, z.core.$strip>>;
|
|
376
396
|
manageUrl: z.ZodString;
|
|
377
397
|
nextStep: z.ZodOptional<z.ZodString>;
|
|
378
398
|
}, z.core.$strip>;
|
|
@@ -520,11 +540,168 @@ declare const MCP_OUTPUT: {
|
|
|
520
540
|
localCurrencyAtCheckout: z.ZodBoolean;
|
|
521
541
|
localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
522
542
|
}, z.core.$strip>;
|
|
543
|
+
cancel: z.ZodOptional<z.ZodObject<{
|
|
544
|
+
available: z.ZodBoolean;
|
|
545
|
+
reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
|
|
546
|
+
penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
547
|
+
refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
548
|
+
}, z.core.$strip>>;
|
|
523
549
|
manageUrl: z.ZodString;
|
|
524
550
|
}, z.core.$strip>>;
|
|
525
551
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
526
552
|
nextStep: z.ZodOptional<z.ZodString>;
|
|
527
553
|
}, z.core.$strip>;
|
|
554
|
+
readonly cancel_order: z.ZodObject<{
|
|
555
|
+
orderId: z.ZodString;
|
|
556
|
+
reference: z.ZodString;
|
|
557
|
+
status: z.ZodType<(string & {}) | "awaiting_payment" | "expired" | "confirming" | "confirmed" | "failed" | "cancelling" | "cancelled" | "needs_attention", unknown, z.core.$ZodTypeInternals<(string & {}) | "awaiting_payment" | "expired" | "confirming" | "confirmed" | "failed" | "cancelling" | "cancelled" | "needs_attention", unknown>>;
|
|
558
|
+
createdAt: z.ZodString;
|
|
559
|
+
updatedAt: z.ZodString;
|
|
560
|
+
items: z.ZodArray<z.ZodType<OpenUnionOutput<"type", readonly [z.ZodObject<{
|
|
561
|
+
type: z.ZodLiteral<"hotel">;
|
|
562
|
+
hotel: z.ZodObject<{
|
|
563
|
+
hotelId: z.ZodNullable<z.ZodString>;
|
|
564
|
+
name: z.ZodString;
|
|
565
|
+
names: z.ZodObject<{
|
|
566
|
+
en: z.ZodNullable<z.ZodString>;
|
|
567
|
+
zh: z.ZodNullable<z.ZodString>;
|
|
568
|
+
}, z.core.$strip>;
|
|
569
|
+
checkIn: z.ZodString;
|
|
570
|
+
checkOut: z.ZodString;
|
|
571
|
+
timeZone: z.ZodNullable<z.ZodString>;
|
|
572
|
+
rooms: z.ZodArray<z.ZodObject<{
|
|
573
|
+
adults: z.ZodNumber;
|
|
574
|
+
childrenAges: z.ZodArray<z.ZodNumber>;
|
|
575
|
+
}, z.core.$strip>>;
|
|
576
|
+
room: z.ZodObject<{
|
|
577
|
+
name: z.ZodNullable<z.ZodObject<{
|
|
578
|
+
text: z.ZodString;
|
|
579
|
+
locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
|
|
580
|
+
}, z.core.$strip>>;
|
|
581
|
+
beds: z.ZodNullable<z.ZodObject<{
|
|
582
|
+
text: z.ZodString;
|
|
583
|
+
locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
|
|
584
|
+
}, z.core.$strip>>;
|
|
585
|
+
}, z.core.$strip>;
|
|
586
|
+
meals: z.ZodObject<{
|
|
587
|
+
known: z.ZodBoolean;
|
|
588
|
+
included: z.ZodNullable<z.ZodArray<z.ZodType<(string & {}) | "breakfast" | "lunch" | "dinner", unknown, z.core.$ZodTypeInternals<(string & {}) | "breakfast" | "lunch" | "dinner", unknown>>>>;
|
|
589
|
+
unspecifiedMainMeals: z.ZodNullable<z.ZodNumber>;
|
|
590
|
+
allInclusive: z.ZodNullable<z.ZodBoolean>;
|
|
591
|
+
guestsCoveredPerRoom: z.ZodNullable<z.ZodNumber>;
|
|
592
|
+
label: z.ZodNullable<z.ZodObject<{
|
|
593
|
+
text: z.ZodString;
|
|
594
|
+
locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
|
|
595
|
+
}, z.core.$strip>>;
|
|
596
|
+
}, z.core.$strip>;
|
|
597
|
+
cancellation: z.ZodObject<{
|
|
598
|
+
status: z.ZodType<"unknown" | (string & {}) | "free" | "partial_penalty" | "non_refundable", unknown, z.core.$ZodTypeInternals<"unknown" | (string & {}) | "free" | "partial_penalty" | "non_refundable", unknown>>;
|
|
599
|
+
asOf: z.ZodString;
|
|
600
|
+
freeCancellationEndsAt: z.ZodNullable<z.ZodString>;
|
|
601
|
+
penalties: z.ZodArray<z.ZodObject<{
|
|
602
|
+
startsAt: z.ZodNullable<z.ZodString>;
|
|
603
|
+
amount: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
|
|
604
|
+
}, z.core.$strip>>;
|
|
605
|
+
timeZone: z.ZodNullable<z.ZodString>;
|
|
606
|
+
}, z.core.$strip>;
|
|
607
|
+
payAtProperty: z.ZodObject<{
|
|
608
|
+
disclosure: z.ZodType<(string & {}) | "complete" | "incomplete", unknown, z.core.$ZodTypeInternals<(string & {}) | "complete" | "incomplete", unknown>>;
|
|
609
|
+
items: z.ZodArray<z.ZodObject<{
|
|
610
|
+
label: z.ZodNullable<z.ZodObject<{
|
|
611
|
+
text: z.ZodString;
|
|
612
|
+
locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
|
|
613
|
+
}, z.core.$strip>>;
|
|
614
|
+
amount: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
615
|
+
mandatory: z.ZodBoolean;
|
|
616
|
+
basis: z.ZodType<"unknown" | (string & {}) | "per_stay" | "per_night" | "per_person" | "per_person_per_night", unknown, z.core.$ZodTypeInternals<"unknown" | (string & {}) | "per_stay" | "per_night" | "per_person" | "per_person_per_night", unknown>>;
|
|
617
|
+
collectedAt: z.ZodType<"unknown" | (string & {}) | "property", unknown, z.core.$ZodTypeInternals<"unknown" | (string & {}) | "property", unknown>>;
|
|
618
|
+
}, z.core.$strip>>;
|
|
619
|
+
}, z.core.$strip>;
|
|
620
|
+
confirmationNumber: z.ZodNullable<z.ZodString>;
|
|
621
|
+
}, z.core.$strip>;
|
|
622
|
+
}, z.core.$strip>]>, unknown, z.core.$ZodTypeInternals<OpenUnionOutput<"type", readonly [z.ZodObject<{
|
|
623
|
+
type: z.ZodLiteral<"hotel">;
|
|
624
|
+
hotel: z.ZodObject<{
|
|
625
|
+
hotelId: z.ZodNullable<z.ZodString>;
|
|
626
|
+
name: z.ZodString;
|
|
627
|
+
names: z.ZodObject<{
|
|
628
|
+
en: z.ZodNullable<z.ZodString>;
|
|
629
|
+
zh: z.ZodNullable<z.ZodString>;
|
|
630
|
+
}, z.core.$strip>;
|
|
631
|
+
checkIn: z.ZodString;
|
|
632
|
+
checkOut: z.ZodString;
|
|
633
|
+
timeZone: z.ZodNullable<z.ZodString>;
|
|
634
|
+
rooms: z.ZodArray<z.ZodObject<{
|
|
635
|
+
adults: z.ZodNumber;
|
|
636
|
+
childrenAges: z.ZodArray<z.ZodNumber>;
|
|
637
|
+
}, z.core.$strip>>;
|
|
638
|
+
room: z.ZodObject<{
|
|
639
|
+
name: z.ZodNullable<z.ZodObject<{
|
|
640
|
+
text: z.ZodString;
|
|
641
|
+
locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
|
|
642
|
+
}, z.core.$strip>>;
|
|
643
|
+
beds: z.ZodNullable<z.ZodObject<{
|
|
644
|
+
text: z.ZodString;
|
|
645
|
+
locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
|
|
646
|
+
}, z.core.$strip>>;
|
|
647
|
+
}, z.core.$strip>;
|
|
648
|
+
meals: z.ZodObject<{
|
|
649
|
+
known: z.ZodBoolean;
|
|
650
|
+
included: z.ZodNullable<z.ZodArray<z.ZodType<(string & {}) | "breakfast" | "lunch" | "dinner", unknown, z.core.$ZodTypeInternals<(string & {}) | "breakfast" | "lunch" | "dinner", unknown>>>>;
|
|
651
|
+
unspecifiedMainMeals: z.ZodNullable<z.ZodNumber>;
|
|
652
|
+
allInclusive: z.ZodNullable<z.ZodBoolean>;
|
|
653
|
+
guestsCoveredPerRoom: z.ZodNullable<z.ZodNumber>;
|
|
654
|
+
label: z.ZodNullable<z.ZodObject<{
|
|
655
|
+
text: z.ZodString;
|
|
656
|
+
locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
|
|
657
|
+
}, z.core.$strip>>;
|
|
658
|
+
}, z.core.$strip>;
|
|
659
|
+
cancellation: z.ZodObject<{
|
|
660
|
+
status: z.ZodType<"unknown" | (string & {}) | "free" | "partial_penalty" | "non_refundable", unknown, z.core.$ZodTypeInternals<"unknown" | (string & {}) | "free" | "partial_penalty" | "non_refundable", unknown>>;
|
|
661
|
+
asOf: z.ZodString;
|
|
662
|
+
freeCancellationEndsAt: z.ZodNullable<z.ZodString>;
|
|
663
|
+
penalties: z.ZodArray<z.ZodObject<{
|
|
664
|
+
startsAt: z.ZodNullable<z.ZodString>;
|
|
665
|
+
amount: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
|
|
666
|
+
}, z.core.$strip>>;
|
|
667
|
+
timeZone: z.ZodNullable<z.ZodString>;
|
|
668
|
+
}, z.core.$strip>;
|
|
669
|
+
payAtProperty: z.ZodObject<{
|
|
670
|
+
disclosure: z.ZodType<(string & {}) | "complete" | "incomplete", unknown, z.core.$ZodTypeInternals<(string & {}) | "complete" | "incomplete", unknown>>;
|
|
671
|
+
items: z.ZodArray<z.ZodObject<{
|
|
672
|
+
label: z.ZodNullable<z.ZodObject<{
|
|
673
|
+
text: z.ZodString;
|
|
674
|
+
locale: z.ZodNullable<z.ZodType<"en" | "zh" | (string & {}), unknown, z.core.$ZodTypeInternals<"en" | "zh" | (string & {}), unknown>>>;
|
|
675
|
+
}, z.core.$strip>>;
|
|
676
|
+
amount: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
677
|
+
mandatory: z.ZodBoolean;
|
|
678
|
+
basis: z.ZodType<"unknown" | (string & {}) | "per_stay" | "per_night" | "per_person" | "per_person_per_night", unknown, z.core.$ZodTypeInternals<"unknown" | (string & {}) | "per_stay" | "per_night" | "per_person" | "per_person_per_night", unknown>>;
|
|
679
|
+
collectedAt: z.ZodType<"unknown" | (string & {}) | "property", unknown, z.core.$ZodTypeInternals<"unknown" | (string & {}) | "property", unknown>>;
|
|
680
|
+
}, z.core.$strip>>;
|
|
681
|
+
}, z.core.$strip>;
|
|
682
|
+
confirmationNumber: z.ZodNullable<z.ZodString>;
|
|
683
|
+
}, z.core.$strip>;
|
|
684
|
+
}, z.core.$strip>]>, unknown>>>;
|
|
685
|
+
price: z.ZodObject<{
|
|
686
|
+
total: z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>;
|
|
687
|
+
}, z.core.$strip>;
|
|
688
|
+
payment: z.ZodObject<{
|
|
689
|
+
status: z.ZodType<(string & {}) | "unpaid" | "authorized" | "paid" | "released" | "refund_pending" | "refunded", unknown, z.core.$ZodTypeInternals<(string & {}) | "unpaid" | "authorized" | "paid" | "released" | "refund_pending" | "refunded", unknown>>;
|
|
690
|
+
url: z.ZodNullable<z.ZodString>;
|
|
691
|
+
requiresSignIn: z.ZodBoolean;
|
|
692
|
+
expiresAt: z.ZodNullable<z.ZodString>;
|
|
693
|
+
chargeCurrency: z.ZodString;
|
|
694
|
+
localCurrencyAtCheckout: z.ZodBoolean;
|
|
695
|
+
localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
696
|
+
}, z.core.$strip>;
|
|
697
|
+
cancel: z.ZodOptional<z.ZodObject<{
|
|
698
|
+
available: z.ZodBoolean;
|
|
699
|
+
reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
|
|
700
|
+
penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
701
|
+
refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
702
|
+
}, z.core.$strip>>;
|
|
703
|
+
manageUrl: z.ZodString;
|
|
704
|
+
}, z.core.$strip>;
|
|
528
705
|
};
|
|
529
706
|
declare const TOOLS: readonly ToolSpec[];
|
|
530
707
|
|
|
@@ -595,7 +772,7 @@ interface CommandSpec {
|
|
|
595
772
|
/** The group it is typed after; `null` for a command typed on its own. */
|
|
596
773
|
group: CommandGroupSpec["name"] | null;
|
|
597
774
|
/** Unique within its group. */
|
|
598
|
-
name: "search" | "get" | "offers" | "book" | "list" | "login" | "logout" | "whoami" | "guide" | "mcp";
|
|
775
|
+
name: "search" | "get" | "offers" | "book" | "list" | "cancel" | "login" | "logout" | "whoami" | "guide" | "mcp";
|
|
599
776
|
summary: string;
|
|
600
777
|
/** The MCP tool the command mirrors; `null` for one that is the CLI's own. */
|
|
601
778
|
tool: ToolName | null;
|
|
@@ -947,6 +1124,14 @@ declare const listOrdersInput: z.ZodObject<{
|
|
|
947
1124
|
}>>;
|
|
948
1125
|
}, z.core.$strict>;
|
|
949
1126
|
type ListOrdersInput = z.input<typeof listOrdersInput>;
|
|
1127
|
+
/** `POST /v1/orders/{orderId}/cancel` and the MCP `cancel_order` arguments:
|
|
1128
|
+
* the order, and the penalty the user agreed to as a ceiling. The server
|
|
1129
|
+
* computes the refund; a higher penalty now answers `cancellation_changed`. */
|
|
1130
|
+
declare const cancelOrderInput: z.ZodObject<{
|
|
1131
|
+
orderId: z.ZodString;
|
|
1132
|
+
maximumPenalty: z.ZodNumber;
|
|
1133
|
+
}, z.core.$strict>;
|
|
1134
|
+
type CancelOrderInput = z.input<typeof cancelOrderInput>;
|
|
950
1135
|
|
|
951
1136
|
/** The ceilings and floors every agent surface enforces and documents (spec §15). */
|
|
952
1137
|
declare const LIMITS: {
|
|
@@ -1044,7 +1229,7 @@ declare const stayEcho: z.ZodObject<{
|
|
|
1044
1229
|
}, z.core.$strip>;
|
|
1045
1230
|
|
|
1046
1231
|
/** Every code the v1 error envelope can carry (spec §11). */
|
|
1047
|
-
type ErrorCode = "invalid_request" | "cursor_invalid" | "unauthenticated" | "forbidden" | "not_found" | "order_removed" | "offer_expired" | "offer_changed" | "offer_already_ordered" | "order_exists" | "order_in_progress" | "order_attempts_exhausted" | "destination_ambiguous" | "destination_not_found" | "search_too_broad" | "stay_unsupported" | "stay_in_past" | "offer_unavailable" | "rate_limited" | "ordering_paused" | "service_unavailable" | "supplier_unavailable" | "internal";
|
|
1232
|
+
type ErrorCode = "invalid_request" | "cursor_invalid" | "unauthenticated" | "forbidden" | "not_found" | "order_removed" | "offer_expired" | "offer_changed" | "offer_already_ordered" | "order_exists" | "order_in_progress" | "order_attempts_exhausted" | "cancellation_changed" | "order_not_cancellable" | "destination_ambiguous" | "destination_not_found" | "search_too_broad" | "stay_unsupported" | "stay_in_past" | "offer_unavailable" | "rate_limited" | "ordering_paused" | "service_unavailable" | "supplier_unavailable" | "internal";
|
|
1048
1233
|
/** The HTTP statuses each code is sent with, and whether a retry can help. */
|
|
1049
1234
|
declare const ERROR_CODES: Readonly<Record<ErrorCode, {
|
|
1050
1235
|
status: readonly number[];
|
|
@@ -1351,6 +1536,10 @@ declare const ERROR_DETAILS: {
|
|
|
1351
1536
|
order_attempts_exhausted: z.ZodObject<{
|
|
1352
1537
|
orderId: z.ZodString;
|
|
1353
1538
|
}, z.core.$strip>;
|
|
1539
|
+
cancellation_changed: null;
|
|
1540
|
+
order_not_cancellable: z.ZodObject<{
|
|
1541
|
+
reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
|
|
1542
|
+
}, z.core.$strip>;
|
|
1354
1543
|
destination_ambiguous: z.ZodObject<{
|
|
1355
1544
|
name: z.ZodString;
|
|
1356
1545
|
countryCode: z.ZodString;
|
|
@@ -1496,7 +1685,7 @@ declare const ERROR_DETAILS: {
|
|
|
1496
1685
|
reason: z.ZodType<(string & {}) | "sold_out" | "refused", unknown, z.core.$ZodTypeInternals<(string & {}) | "sold_out" | "refused", unknown>>;
|
|
1497
1686
|
}, z.core.$strip>;
|
|
1498
1687
|
rate_limited: z.ZodObject<{
|
|
1499
|
-
scope: z.ZodType<"search" | "hotel" | (string & {}) | "offers" | "orders_read" | "orders_create", unknown, z.core.$ZodTypeInternals<"search" | "hotel" | (string & {}) | "offers" | "orders_read" | "orders_create", unknown>>;
|
|
1688
|
+
scope: z.ZodType<"search" | "hotel" | (string & {}) | "offers" | "orders_read" | "orders_create" | "orders_cancel", unknown, z.core.$ZodTypeInternals<"search" | "hotel" | (string & {}) | "offers" | "orders_read" | "orders_create" | "orders_cancel", unknown>>;
|
|
1500
1689
|
}, z.core.$strip>;
|
|
1501
1690
|
ordering_paused: null;
|
|
1502
1691
|
service_unavailable: null;
|
|
@@ -1893,6 +2082,12 @@ declare const ORDER_STATUSES: readonly ["awaiting_payment", "expired", "confirmi
|
|
|
1893
2082
|
type OrderStatus = (typeof ORDER_STATUSES)[number];
|
|
1894
2083
|
declare const PAYMENT_STATUSES: readonly ["unpaid", "authorized", "paid", "released", "refund_pending", "refunded"];
|
|
1895
2084
|
type PaymentStatus = (typeof PAYMENT_STATUSES)[number];
|
|
2085
|
+
/** Why an order can or can't be cancelled now (3.3): `cancellable` when it
|
|
2086
|
+
* can, else the first reason that holds. `non_refundable` is a rate the
|
|
2087
|
+
* hotel takes no cancellation for; `refused`, a cancellation the hotel
|
|
2088
|
+
* refused, the booking standing as it was. */
|
|
2089
|
+
declare const CANCEL_REASONS: readonly ["cancellable", "already_cancelled", "in_progress", "not_confirmed", "stay_started", "non_refundable", "refused", "terms_unknown", "needs_attention"];
|
|
2090
|
+
type CancelReason = (typeof CANCEL_REASONS)[number];
|
|
1896
2091
|
/** `FT-` and six characters with no 0, 1, I or O. */
|
|
1897
2092
|
declare const orderReference: z.ZodString;
|
|
1898
2093
|
declare const order: z.ZodObject<{
|
|
@@ -2038,6 +2233,16 @@ declare const order: z.ZodObject<{
|
|
|
2038
2233
|
localCurrencyAtCheckout: z.ZodBoolean;
|
|
2039
2234
|
localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
2040
2235
|
}, z.core.$strip>;
|
|
2236
|
+
/** Whether the user can cancel the order now and, when they can, its
|
|
2237
|
+
* penalty under the accepted terms (read a minute ahead) and the refund,
|
|
2238
|
+
* what was paid less the penalty, both in the charge currency. Absent
|
|
2239
|
+
* from servers before 3.3. */
|
|
2240
|
+
cancel: z.ZodOptional<z.ZodObject<{
|
|
2241
|
+
available: z.ZodBoolean;
|
|
2242
|
+
reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
|
|
2243
|
+
penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
2244
|
+
refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
2245
|
+
}, z.core.$strip>>;
|
|
2041
2246
|
manageUrl: z.ZodString;
|
|
2042
2247
|
}, z.core.$strip>;
|
|
2043
2248
|
type Order = z.infer<typeof order>;
|
|
@@ -2186,6 +2391,16 @@ declare const orderList: z.ZodObject<{
|
|
|
2186
2391
|
localCurrencyAtCheckout: z.ZodBoolean;
|
|
2187
2392
|
localCharge: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
2188
2393
|
}, z.core.$strip>;
|
|
2394
|
+
/** Whether the user can cancel the order now and, when they can, its
|
|
2395
|
+
* penalty under the accepted terms (read a minute ahead) and the refund,
|
|
2396
|
+
* what was paid less the penalty, both in the charge currency. Absent
|
|
2397
|
+
* from servers before 3.3. */
|
|
2398
|
+
cancel: z.ZodOptional<z.ZodObject<{
|
|
2399
|
+
available: z.ZodBoolean;
|
|
2400
|
+
reason: z.ZodType<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown, z.core.$ZodTypeInternals<(string & {}) | "non_refundable" | "needs_attention" | "cancellable" | "already_cancelled" | "in_progress" | "not_confirmed" | "stay_started" | "refused" | "terms_unknown", unknown>>;
|
|
2401
|
+
penalty: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
2402
|
+
refund: z.ZodNullable<z.ZodType<Money, unknown, z.core.$ZodTypeInternals<Money, unknown>>>;
|
|
2403
|
+
}, z.core.$strip>>;
|
|
2189
2404
|
manageUrl: z.ZodString;
|
|
2190
2405
|
}, z.core.$strip>>;
|
|
2191
2406
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
@@ -2798,6 +3013,7 @@ declare const API: {
|
|
|
2798
3013
|
readonly order: (id: string, opts?: {
|
|
2799
3014
|
locale?: "en" | "zh";
|
|
2800
3015
|
}) => string;
|
|
3016
|
+
readonly orderCancel: (id: string) => string;
|
|
2801
3017
|
};
|
|
2802
3018
|
/** The MCP server answers at the root of `PUBLIC_ORIGINS.mcp`. */
|
|
2803
3019
|
declare const MCP_PATH = "/";
|
|
@@ -2811,7 +3027,9 @@ type RenderedTool = Exclude<ToolName, "get_planning_guide">;
|
|
|
2811
3027
|
* open output schema: unknown fields are ignored and unknown values shown
|
|
2812
3028
|
* as they came. A result that does not parse is shown as JSON, never thrown.
|
|
2813
3029
|
* The consent rule (`ORDER_NEXT_STEP`) is the last paragraph whenever the
|
|
2814
|
-
* result holds a non-null `payment.url
|
|
3030
|
+
* result holds a non-null `payment.url`; the cancel rule (`CANCEL_NEXT_STEP`)
|
|
3031
|
+
* follows it when a `get_order` or `list_orders` result holds an order with
|
|
3032
|
+
* `cancel.available`.
|
|
2815
3033
|
*/
|
|
2816
3034
|
declare function renderToolResult(tool: RenderedTool, data: unknown): string;
|
|
2817
3035
|
|
|
@@ -2831,4 +3049,4 @@ declare const UNKNOWN_IS_NOT_NO_EXEMPTIONS: Readonly<Record<string, string>>;
|
|
|
2831
3049
|
/** The contract's version, from package.json, the one place a release bumps it. */
|
|
2832
3050
|
declare const CONTRACT_VERSION: string;
|
|
2833
3051
|
|
|
2834
|
-
export { AMENITY_CODES, API, type AmenityCode, type AuthConfig, CARD_NUMBER_MESSAGE, CENTER_BASES, COMMANDS, COMMAND_GROUPS, CONTRACT_VERSION, type Center, type CommandGroupSpec, type CommandSpec, type CreateOrderInput, DISPLAY_CURRENCIES, type Destination, ERROR_CODES, ERROR_DETAILS, type ErrorBody, type ErrorCode, type ErrorEnvelope, FILTERABLE_AMENITIES, type FilterableAmenity, type FlagSpec, GLOBAL_FLAGS, type GetHotelInput, type GetOrderInput, type GuideSurface, type GuideTopic, type Hotel, type HotelOffersInput, type HotelOffersResult, type HotelSummary, type IndicativePrice, type KnownErrorBody, LIMITS, type ListOrdersInput, MCP_OUTPUT, MCP_PATH, type MeResult, type Money, ORDER_NEXT_STEP, ORDER_STATUSES, type Offer, type OfferChange, type Omitted, type OptionSpec, type Order, type OrderList, type OrderStatus, PAYMENT_STATUSES, PLACE_KINDS, POLICY_TOPICS, PRESENTATION_HINT, PUBLIC_ORIGINS, type PaymentStatus, type Place, type PlaceRef, type PolicyTopic, type PositionalSpec, type RenderedTool, SEARCH_NOTE_CODES, SEARCH_SORTS, SUPPORT_EMAIL, type SearchHotelsInput, type SearchNoteCode, type SearchResult, type Stay, TOOLS, type ToolName, type ToolSpec, UNAVAILABLE_REASONS, UNKNOWN_IS_NOT_NO_EXEMPTIONS, addIsoDateDays, authConfig, 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, money, names, nonEmpty, offer, offerChange, offerId, omitted, oneOf, openEnum, openObject, openUnion, order, orderId, orderList, orderReference, parseOpen, payAtProperty, photo, place, placeId, placeRef, renderError, renderGuide, renderToolResult, roomFacts, searchHotelsInput, searchResult, stay, stayEcho, strictErrorEnvelope, strictInput, strictOutput, text, timeZone, usdMoney, wholeNumber };
|
|
3052
|
+
export { AMENITY_CODES, API, type AmenityCode, type AuthConfig, CANCEL_NEXT_STEP, CANCEL_REASONS, CARD_NUMBER_MESSAGE, CENTER_BASES, COMMANDS, COMMAND_GROUPS, CONTRACT_VERSION, type CancelOrderInput, type CancelReason, type Center, type CommandGroupSpec, type CommandSpec, type CreateOrderInput, DISPLAY_CURRENCIES, type Destination, ERROR_CODES, ERROR_DETAILS, type ErrorBody, type ErrorCode, type ErrorEnvelope, FILTERABLE_AMENITIES, type FilterableAmenity, type FlagSpec, GLOBAL_FLAGS, type GetHotelInput, type GetOrderInput, type GuideSurface, type GuideTopic, type Hotel, type HotelOffersInput, type HotelOffersResult, type HotelSummary, type IndicativePrice, type KnownErrorBody, LIMITS, type ListOrdersInput, MCP_OUTPUT, MCP_PATH, type MeResult, type Money, ORDER_NEXT_STEP, ORDER_STATUSES, type Offer, type OfferChange, type Omitted, type OptionSpec, type Order, type OrderList, type OrderStatus, PAYMENT_STATUSES, PLACE_KINDS, POLICY_TOPICS, PRESENTATION_HINT, PUBLIC_ORIGINS, type PaymentStatus, type Place, type PlaceRef, type PolicyTopic, type PositionalSpec, type RenderedTool, SEARCH_NOTE_CODES, SEARCH_SORTS, SUPPORT_EMAIL, type SearchHotelsInput, type SearchNoteCode, type SearchResult, type Stay, TOOLS, type ToolName, type ToolSpec, UNAVAILABLE_REASONS, UNKNOWN_IS_NOT_NO_EXEMPTIONS, addIsoDateDays, authConfig, 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, money, names, nonEmpty, offer, offerChange, offerId, omitted, oneOf, openEnum, openObject, openUnion, order, orderId, orderList, orderReference, parseOpen, payAtProperty, photo, place, placeId, placeRef, renderError, renderGuide, renderToolResult, roomFacts, searchHotelsInput, searchResult, stay, stayEcho, strictErrorEnvelope, strictInput, strictOutput, text, timeZone, usdMoney, wholeNumber };
|
package/dist/index.js
CHANGED
|
@@ -562,6 +562,13 @@ var listOrdersInput = strictInput({
|
|
|
562
562
|
),
|
|
563
563
|
locale: locale.optional()
|
|
564
564
|
});
|
|
565
|
+
var maximumPenaltyError = "maximumPenalty must be a number of 0 or more: the order's cancel.penalty.amount, such as 12.5 for 12.50";
|
|
566
|
+
var cancelOrderInput = strictInput({
|
|
567
|
+
orderId: orderId.describe("orderId of the order to cancel, from get order or list orders."),
|
|
568
|
+
maximumPenalty: z5.number({ error: maximumPenaltyError }).min(0, { error: maximumPenaltyError }).describe(
|
|
569
|
+
"The penalty the user agreed to: cancel.penalty.amount of the order, in its currency."
|
|
570
|
+
)
|
|
571
|
+
});
|
|
565
572
|
|
|
566
573
|
// src/commands.ts
|
|
567
574
|
function fieldDescription(json, field, sets = {}) {
|
|
@@ -798,6 +805,15 @@ var ordersListFlags = flagsOf(listOrdersInput, [
|
|
|
798
805
|
{ flag: "limit", field: "limit", type: "number", placeholder: COUNT },
|
|
799
806
|
localeFlag
|
|
800
807
|
]);
|
|
808
|
+
var cancelFlags = flagsOf(cancelOrderInput, [
|
|
809
|
+
{
|
|
810
|
+
flag: "max-penalty",
|
|
811
|
+
field: "maximumPenalty",
|
|
812
|
+
type: "number",
|
|
813
|
+
placeholder: "<amount>",
|
|
814
|
+
description: "The penalty the user agreed to, exactly as `orders get` shows it, in the order's currency, e.g. `12.50`. Without it, the command cancels nothing: it shows the penalty and the refund."
|
|
815
|
+
}
|
|
816
|
+
]);
|
|
801
817
|
var BODY_OPTION = {
|
|
802
818
|
flag: "body",
|
|
803
819
|
type: "string",
|
|
@@ -806,7 +822,7 @@ var BODY_OPTION = {
|
|
|
806
822
|
};
|
|
807
823
|
var COMMAND_GROUPS = [
|
|
808
824
|
{ name: "hotels", summary: "Search hotels, get offers and order one" },
|
|
809
|
-
{ name: "orders", summary: "Your orders and
|
|
825
|
+
{ name: "orders", summary: "Your orders, their status, and cancelling one" }
|
|
810
826
|
];
|
|
811
827
|
var COMMANDS = [
|
|
812
828
|
{
|
|
@@ -856,6 +872,14 @@ var COMMANDS = [
|
|
|
856
872
|
tool: "list_orders",
|
|
857
873
|
flags: ordersListFlags
|
|
858
874
|
},
|
|
875
|
+
{
|
|
876
|
+
group: "orders",
|
|
877
|
+
name: "cancel",
|
|
878
|
+
summary: "Cancel an order under its terms, for the penalty the user agreed to",
|
|
879
|
+
tool: "cancel_order",
|
|
880
|
+
flags: cancelFlags,
|
|
881
|
+
positionals: [positional(cancelOrderInput, "orderId")]
|
|
882
|
+
},
|
|
859
883
|
{
|
|
860
884
|
group: null,
|
|
861
885
|
name: "login",
|
|
@@ -1053,9 +1077,9 @@ var FRAGMENTS = {
|
|
|
1053
1077
|
"planning": "# Planning a hotel stay\n\nRead this when the request is more than one hotel for fixed dates: flexible dates, a budget, split stays, several destinations, or \"find me the best\". The rules in {{#if mcp}}the server instructions{{/if}}{{#if claude-skill}}SKILL.md{{/if}}{{#if cli}}`{{tool:guide}}`{{/if}} still apply (call order, destinations, one party per offer and order, confirming the order `{{tool:hotels book}}` returns before giving the payment link); this covers what to ask, how to compare and how to present.{{#if cli}} As there, `fortrip` is short for `npx -y fortrip@latest`.{{/if}}\n\n## What to collect\n\nKeep track of: dates (or the flexible window), nights, destination(s) with their country, rooms and the guests in each room, room constraints (beds, connecting rooms, accessibility), budget, and what the user said matters most (cheapest, most flexible, closest to X).\n\nOffers and orders take one party per call, every room the same, so if the party doesn't split evenly across the rooms, ask how it splits. Rooms for different parties are priced and ordered separately, each order with its own payment link.\n\nAsk only for what changes which hotels qualify or how they rank. \"4 stars\" as {{#if mcp claude-skill}}`{ min: 4, max: 4 }`{{/if}}{{#if cli}}`--stars-min 4 --stars-max 4`{{/if}} leaves out 4.5: unless the user means exactly 4, use {{#if mcp claude-skill}}`{ min: 4 }`{{/if}}{{#if cli}}`--stars-min 4`{{/if}} or ask. If children come along, ask each child's age; `{{tool:hotels offers}}` needs it. Don't ask for trip type or style: infer it from the conversation or leave it general. When a place name is ambiguous, ask which place the user means.\n\n## Evidence\n\n- A `{{tool:hotels search}}` price is an indicative estimate per room per night, not a quote. Never call a search result available or bookable, and once you have offers, compare offers only. A hotel without a search price can still have offers.\n- Use `{{tool:hotels get}}` only when a stated preference needs evidence (a pool, a policy, room size). An amenity or policy it doesn't list is unknown, not absent.\n- A hotel is available only once `{{tool:hotels offers}}` returned an offer for it.\n- Anything {{#if mcp claude-skill}}the tools{{/if}}{{#if cli}}the CLI{{/if}} didn't return, such as reviews, style, price trends or exchange rates other than `approx`, is unknown. Say so instead of filling it in.\n\n## Ranking\n\n1. Drop options that break a hard constraint (dates, guests, budget cap, required facility). Compare a budget in the unit the user gave it: per night, per room or for the whole stay. An offer's `price.total` covers the whole stay and every room, in USD.\n2. Keep only options with a live offer.\n3. Order by the user's stated main goal. Goals they didn't state don't count.\n4. Use other preferences only to break ties.\n\nUse the cheapest comparable offer as the baseline unless the user fixed the room type. Show at most three plans, each with its price difference from the baseline and what it trades off (meals, cancellation, location, confirmation). Keep hotel names as returned and dates in the user's notation.\n\nFor a split stay or several destinations, price each leg with its own `{{tool:hotels offers}}` call and add up the legs. Each leg is a separate `{{tool:hotels book}}` call, with its own confirmation and its own payment link.\n\n## Stop and say so\n\n- `{{tool:hotels offers}}` covers up to {{limit:offersHotels}} hotels per call and takes about 15 seconds, and its offers expire after about 30 minutes. If the request needs more hotels or date combinations than a few calls can cover, narrow it with the user, or present the result as a comparison of the hotels you priced, not the best overall.\n- When a search is too broad to price, show its localities and ask the user which they prefer, unless the request already names one of them; never pick one yourself.\n- Urgency is not consent. Call `{{tool:hotels book}}` only for the offer the user picked, and give its payment link only after the user confirms the total, currency, stay and terms of the order `{{tool:hotels book}}` returned.\n",
|
|
1054
1078
|
"presentation": "{{#if claude-skill}}\n## Presenting hotels\n\nIf your interface can show rich elements, show each hotel as a card with only what Fortrip's tools returned for it in this conversation: photo, name, stars, region and price, and once you have offers every term that changes the choice (meals and who they cover, cancellation, fees payable at the property, confirmation), an unknown one as unknown. Label a search's `price.fromPerRoomNight` as an estimate per room-night and an offer's `price.total` as the whole stay for all rooms, in USD, and draw a map only from returned `location` coordinates. Offer the choices you need to ask anyway (dates, a locality, which offer) as options to pick. Otherwise use a short list. Keep hotel names as returned, and never invent photos, ratings, reviews, prices, terms or coordinates.\n{{/if}}\n",
|
|
1055
1079
|
"prices": "{{#if claude-skill cli}}\n## Prices and currency\n\n- A search price (`price.fromPerRoomNight`) is indicative and not bookable: the lowest price of one unit (a room or, at a hostel, possibly a bed) per night, for any party and often any date, and it can be well above or below the offers. Call it an estimate, quote `{{tool:hotels offers}}` prices, and never call a search result available or bookable. `price: null` means there is no indicative price, not that the hotel is full; about half the hotels have none for given dates.\n{{/if}}\n{{#if mcp}}\n- Search prices are indicative, not bookable: quote `{{tool:hotels offers}}` prices.\n{{/if}}\n- {{#if claude-skill cli}}In an offer or order, {{/if}}`price.total` is the whole stay for all rooms and is what is charged, in USD for offers and the orders made from them.{{#if claude-skill cli}} `perNightAllRooms` is the total per night; to compare with a per-room budget, also divide by the rooms.{{/if}} Stripe's page may let the user pay in their card's local currency at Stripe's rate (Adaptive Pricing){{#if claude-skill cli}}: say so plainly, and that the USD total is the price{{/if}}. `approx`{{#if claude-skill cli}}, in `{{arg:displayCurrency}}`, with its `rateDate`,{{/if}} is an estimate, never the charge.\n{{#if claude-skill cli}}\n- `{{arg:displayCurrency}}`{{#if cli}} (or `FORTRIP_DISPLAY_CURRENCY`){{/if}} is `USD` or `CNY`: `CNY` adds `approx` in yuan to suit a user who thinks in it. It never changes the charge.\n- Fees payable at the property (`payAtProperty`) are separate, in the property's own currency, not converted.\n- After payment, `payment.localCharge` is what the card paid in its own currency. Orders made on the Fortrip website can be charged in another currency: `payment.chargeCurrency` says which.\n{{/if}}\n",
|
|
1056
|
-
"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
|
|
1080
|
+
"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 their orders; `{{tool:orders cancel}}` cancels one. `{{tool:guide}}` returns Fortrip's guidance for flexible dates, budgets or several destinations.\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 in USD, 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 |\n\nFor flexible dates, a budget, split stays, several destinations or \"find me the best\", {{#if claude-skill}}read [references/planning.md](references/planning.md){{/if}}{{#if cli}}also run `{{tool:guide}} planning`{{/if}} before searching.\n{{/if}}\n",
|
|
1057
1081
|
"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 Fortrip.\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 CI or a sandbox 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",
|
|
1058
|
-
"support": "{{#if claude-skill cli}}\n## Changes and support\n\n{{/if}}\n{{#if mcp claude-skill}}These tools{{/if}}{{#if cli}}The CLI
|
|
1082
|
+
"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`), and then the penalty under its terms (`cancel.penalty`) and the refund, what was paid less the penalty (`cancel.refund`), both in the charge currency; 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.amount` as shown. 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`.{{#if cli}} Without `--max-penalty`, `{{tool:orders cancel}}` cancels nothing: it prints the penalty and the refund 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"
|
|
1059
1083
|
};
|
|
1060
1084
|
|
|
1061
1085
|
// src/guide.ts
|
|
@@ -1233,6 +1257,8 @@ var ERROR_CODES = {
|
|
|
1233
1257
|
order_exists: { status: [409], retryable: false },
|
|
1234
1258
|
order_in_progress: { status: [409], retryable: true },
|
|
1235
1259
|
order_attempts_exhausted: { status: [409], retryable: false },
|
|
1260
|
+
cancellation_changed: { status: [409], retryable: false },
|
|
1261
|
+
order_not_cancellable: { status: [409], retryable: false },
|
|
1236
1262
|
destination_ambiguous: { status: [422], retryable: false },
|
|
1237
1263
|
destination_not_found: { status: [422], retryable: false },
|
|
1238
1264
|
search_too_broad: { status: [422], retryable: false },
|
|
@@ -1611,6 +1637,17 @@ var PAYMENT_STATUSES = [
|
|
|
1611
1637
|
"refund_pending",
|
|
1612
1638
|
"refunded"
|
|
1613
1639
|
];
|
|
1640
|
+
var CANCEL_REASONS = [
|
|
1641
|
+
"cancellable",
|
|
1642
|
+
"already_cancelled",
|
|
1643
|
+
"in_progress",
|
|
1644
|
+
"not_confirmed",
|
|
1645
|
+
"stay_started",
|
|
1646
|
+
"non_refundable",
|
|
1647
|
+
"refused",
|
|
1648
|
+
"terms_unknown",
|
|
1649
|
+
"needs_attention"
|
|
1650
|
+
];
|
|
1614
1651
|
var orderReference = z14.string().regex(/^FT-[2-9A-HJ-NP-Z]{6}$/);
|
|
1615
1652
|
var hotelItem = openObject({
|
|
1616
1653
|
type: z14.literal("hotel"),
|
|
@@ -1649,6 +1686,16 @@ var order = openObject({
|
|
|
1649
1686
|
localCurrencyAtCheckout: z14.boolean(),
|
|
1650
1687
|
localCharge: money.nullable()
|
|
1651
1688
|
}),
|
|
1689
|
+
/** Whether the user can cancel the order now and, when they can, its
|
|
1690
|
+
* penalty under the accepted terms (read a minute ahead) and the refund,
|
|
1691
|
+
* what was paid less the penalty, both in the charge currency. Absent
|
|
1692
|
+
* from servers before 3.3. */
|
|
1693
|
+
cancel: openObject({
|
|
1694
|
+
available: z14.boolean(),
|
|
1695
|
+
reason: openEnum(CANCEL_REASONS),
|
|
1696
|
+
penalty: money.nullable(),
|
|
1697
|
+
refund: money.nullable()
|
|
1698
|
+
}).optional(),
|
|
1652
1699
|
manageUrl: z14.string()
|
|
1653
1700
|
});
|
|
1654
1701
|
var orderList = openObject({
|
|
@@ -1695,6 +1742,8 @@ var ERROR_DETAILS = {
|
|
|
1695
1742
|
order_exists: openObject({ orderId, status: openEnum(ORDER_STATUSES) }),
|
|
1696
1743
|
order_in_progress: openObject({ orderId }),
|
|
1697
1744
|
order_attempts_exhausted: openObject({ orderId }),
|
|
1745
|
+
cancellation_changed: null,
|
|
1746
|
+
order_not_cancellable: openObject({ reason: openEnum(CANCEL_REASONS) }),
|
|
1698
1747
|
destination_ambiguous: openObject({
|
|
1699
1748
|
name: z15.string(),
|
|
1700
1749
|
countryCode: z15.string(),
|
|
@@ -1747,7 +1796,14 @@ var ERROR_DETAILS = {
|
|
|
1747
1796
|
reason: openEnum(["sold_out", "refused"])
|
|
1748
1797
|
}),
|
|
1749
1798
|
rate_limited: openObject({
|
|
1750
|
-
scope: openEnum([
|
|
1799
|
+
scope: openEnum([
|
|
1800
|
+
"search",
|
|
1801
|
+
"offers",
|
|
1802
|
+
"hotel",
|
|
1803
|
+
"orders_read",
|
|
1804
|
+
"orders_create",
|
|
1805
|
+
"orders_cancel"
|
|
1806
|
+
])
|
|
1751
1807
|
}),
|
|
1752
1808
|
ordering_paused: null,
|
|
1753
1809
|
service_unavailable: null,
|
|
@@ -1802,6 +1858,9 @@ var API = {
|
|
|
1802
1858
|
},
|
|
1803
1859
|
order(id, opts) {
|
|
1804
1860
|
return `/v1/orders/${encodeURIComponent(id)}${opts?.locale ? `?locale=${opts.locale}` : ""}`;
|
|
1861
|
+
},
|
|
1862
|
+
orderCancel(id) {
|
|
1863
|
+
return `/v1/orders/${encodeURIComponent(id)}/cancel`;
|
|
1805
1864
|
}
|
|
1806
1865
|
};
|
|
1807
1866
|
var MCP_PATH = "/";
|
|
@@ -1809,6 +1868,7 @@ var MCP_PATH = "/";
|
|
|
1809
1868
|
// src/tools.ts
|
|
1810
1869
|
import { z as z16 } from "zod";
|
|
1811
1870
|
var ORDER_NEXT_STEP = "Before you give the user an order's payment.url, show them its total and currency, the stay (hotel, room, dates, rooms and guests per room) and every term (meals, cancellation, fees payable at the property), then end your reply by asking them to confirm, and wait for a clear yes. Only after they say yes, give them payment.url exactly as returned.";
|
|
1871
|
+
var CANCEL_NEXT_STEP = "Before you call cancel_order, show the user the order's stay (hotel, dates), cancel.penalty and cancel.refund (amount and currency), then end your reply by asking them to confirm the cancellation, and wait for a clear yes. Pass maximumPenalty exactly as cancel.penalty.amount. Never state a refund the order did not return.";
|
|
1812
1872
|
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 USD, and draw a map only from returned `location` coordinates. Offer the choices you need to ask anyway (dates, a locality, which offer) as options to pick. Otherwise use a short list. Keep hotel names as returned, and never invent photos, ratings, reviews, prices, terms or coordinates.";
|
|
1813
1873
|
var nextStep = z16.string().optional().describe(
|
|
1814
1874
|
"What to show and ask before giving a payment.url. Present when the answer holds a non-null payment.url, and only then."
|
|
@@ -1816,7 +1876,8 @@ var nextStep = z16.string().optional().describe(
|
|
|
1816
1876
|
var MCP_OUTPUT = {
|
|
1817
1877
|
book_hotel: order.extend({ nextStep }),
|
|
1818
1878
|
get_order: order.extend({ nextStep }),
|
|
1819
|
-
list_orders: orderList.extend({ nextStep })
|
|
1879
|
+
list_orders: orderList.extend({ nextStep }),
|
|
1880
|
+
cancel_order: order
|
|
1820
1881
|
};
|
|
1821
1882
|
var READ = {
|
|
1822
1883
|
readOnlyHint: true,
|
|
@@ -1861,7 +1922,7 @@ var TOOLS = [
|
|
|
1861
1922
|
{
|
|
1862
1923
|
name: "book_hotel",
|
|
1863
1924
|
title: "Create hotel order and payment link",
|
|
1864
|
-
description: `Order one offer from get_hotel_offers. The answer is an unpaid order with a payment link: status awaiting_payment, the total, the stay and its terms, and payment.url, a Fortrip page where the user pays. Nothing is charged until the user pays there; anyone holding the link can pay. Send the contact and, for each room of the offer, at least one guest. If the price or terms changed since the offer, the answer is offer_changed with every change and a new offer: show the changes and ask the user again before ordering it. Sending the same details again returns the same order.
|
|
1925
|
+
description: `Order one offer from get_hotel_offers. The answer is an unpaid order with a payment link: status awaiting_payment, the total, the stay and its terms, and payment.url, a Fortrip page where the user pays. Nothing is charged until the user pays there; anyone holding the link can pay. Send the contact and, for each room of the offer, at least one guest. If the price or terms changed since the offer, the answer is offer_changed with every change and a new offer: show the changes and ask the user again before ordering it. Sending the same details again returns the same order. To cancel an order, use cancel_order; for changes, or a cancellation cancel_order can't make, the user emails ${SUPPORT_EMAIL} with the order's reference.`,
|
|
1865
1926
|
annotations: {
|
|
1866
1927
|
readOnlyHint: false,
|
|
1867
1928
|
idempotentHint: false,
|
|
@@ -1886,6 +1947,19 @@ var TOOLS = [
|
|
|
1886
1947
|
annotations: READ_OWN,
|
|
1887
1948
|
input: listOrdersInput,
|
|
1888
1949
|
output: MCP_OUTPUT.list_orders
|
|
1950
|
+
},
|
|
1951
|
+
{
|
|
1952
|
+
name: "cancel_order",
|
|
1953
|
+
title: "Cancel order",
|
|
1954
|
+
description: `Cancel one of the user's orders by orderId under its cancellation terms, when its cancel.available is true: the hotel booking is cancelled and cancel.refund, what was paid less cancel.penalty, is refunded. ${CANCEL_NEXT_STEP} If the penalty is now higher than maximumPenalty, the answer is cancellation_changed and nothing changes: read the order again and ask the user again. Answers the order: status cancelling, then cancelled once the hotel cancels and the refund is issued; poll get_order. If the hotel refuses, the order goes back to confirmed with cancel.reason refused. Calling it again for the same order answers the order as it is.`,
|
|
1955
|
+
annotations: {
|
|
1956
|
+
readOnlyHint: false,
|
|
1957
|
+
idempotentHint: true,
|
|
1958
|
+
openWorldHint: true,
|
|
1959
|
+
destructiveHint: true
|
|
1960
|
+
},
|
|
1961
|
+
input: cancelOrderInput,
|
|
1962
|
+
output: MCP_OUTPUT.cancel_order
|
|
1889
1963
|
}
|
|
1890
1964
|
];
|
|
1891
1965
|
|
|
@@ -2190,6 +2264,18 @@ var PAYMENT_WORDS = {
|
|
|
2190
2264
|
refund_pending: "refund pending",
|
|
2191
2265
|
refunded: "refunded"
|
|
2192
2266
|
};
|
|
2267
|
+
var SUPPORT = `for help, the user emails ${SUPPORT_EMAIL} with the order's reference`;
|
|
2268
|
+
var CANCEL_REASON_WORDS = {
|
|
2269
|
+
cancellable: "it can be cancelled",
|
|
2270
|
+
already_cancelled: "it is already cancelled",
|
|
2271
|
+
in_progress: "a cancellation is in progress",
|
|
2272
|
+
not_confirmed: "only a confirmed order that is paid can be cancelled",
|
|
2273
|
+
stay_started: `the stay has started; ${SUPPORT}`,
|
|
2274
|
+
non_refundable: "this rate can't be cancelled",
|
|
2275
|
+
refused: "the hotel refused the cancellation; the booking stands",
|
|
2276
|
+
terms_unknown: `its cancellation terms are not on record; ${SUPPORT}`,
|
|
2277
|
+
needs_attention: `Fortrip is looking into this order; ${SUPPORT}`
|
|
2278
|
+
};
|
|
2193
2279
|
function itemLines(item) {
|
|
2194
2280
|
if (item.type !== "hotel") {
|
|
2195
2281
|
return [`Item of type ${item.type}: not shown in this text. ${raw(item)}`];
|
|
@@ -2227,9 +2313,17 @@ function paymentLines(o) {
|
|
|
2227
2313
|
} else if (o.status === "awaiting_payment") {
|
|
2228
2314
|
lines.push("Payment link: could not be read this time; read this order again for it.");
|
|
2229
2315
|
}
|
|
2316
|
+
if (o.cancel) lines.push(cancelLine(o.cancel));
|
|
2230
2317
|
lines.push(`Manage: ${o.manageUrl}`);
|
|
2231
2318
|
return lines;
|
|
2232
2319
|
}
|
|
2320
|
+
function cancelLine(c) {
|
|
2321
|
+
const figure = (name, m) => `${name} ${m ? money2(m) : "not stated"}`;
|
|
2322
|
+
const figures = `${figure("penalty", c.penalty)}, ${figure("refund", c.refund)}`;
|
|
2323
|
+
if (c.available) return `Cancel: can cancel now: ${figures}`;
|
|
2324
|
+
const why = `Cancel: not available: ${label(CANCEL_REASON_WORDS, c.reason)}`;
|
|
2325
|
+
return c.penalty || c.refund ? `${why} \xB7 ${figures}` : why;
|
|
2326
|
+
}
|
|
2233
2327
|
function orderLines(o) {
|
|
2234
2328
|
return [
|
|
2235
2329
|
`Order ${o.orderId} \xB7 reference ${o.reference} \xB7 ${label(ORDER_STATUS_WORDS, o.status)} \xB7 created ${when(o.createdAt, null)} \xB7 updated ${when(o.updatedAt, null)}`,
|
|
@@ -2546,6 +2640,8 @@ function detailLines(e) {
|
|
|
2546
2640
|
return [`Order ${e.details.orderId}.`];
|
|
2547
2641
|
case "order_exists":
|
|
2548
2642
|
return [`Order ${e.details.orderId}, ${label(ORDER_STATUS_WORDS, e.details.status)}.`];
|
|
2643
|
+
case "order_not_cancellable":
|
|
2644
|
+
return [`Not cancellable: ${label(CANCEL_REASON_WORDS, e.details.reason)}.`];
|
|
2549
2645
|
case "destination_ambiguous":
|
|
2550
2646
|
return ambiguous(e.details);
|
|
2551
2647
|
case "destination_not_found":
|
|
@@ -2619,9 +2715,11 @@ function renderToolResult(tool, data) {
|
|
|
2619
2715
|
} catch {
|
|
2620
2716
|
const text2 = `This ${tool} result is not in the expected shape; as JSON:
|
|
2621
2717
|
${raw(data)}`;
|
|
2622
|
-
return
|
|
2623
|
-
|
|
2624
|
-
|
|
2718
|
+
return [
|
|
2719
|
+
text2,
|
|
2720
|
+
ORDER_TOOLS.has(tool) && holdsPaymentUrl(data) ? ORDER_NEXT_STEP : "",
|
|
2721
|
+
CANCEL_TOOLS.has(tool) && holdsCancellable(data) ? CANCEL_NEXT_STEP : ""
|
|
2722
|
+
].filter(Boolean).join("\n\n");
|
|
2625
2723
|
}
|
|
2626
2724
|
switch (tool) {
|
|
2627
2725
|
case "search_hotels":
|
|
@@ -2633,15 +2731,18 @@ ${ORDER_NEXT_STEP}` : text2;
|
|
|
2633
2731
|
case "book_hotel":
|
|
2634
2732
|
case "get_order": {
|
|
2635
2733
|
const order2 = parsed;
|
|
2636
|
-
return withConsent(renderOrder(order2), [order2]);
|
|
2734
|
+
return withConsent(tool, renderOrder(order2), [order2]);
|
|
2637
2735
|
}
|
|
2638
2736
|
case "list_orders": {
|
|
2639
2737
|
const list = parsed;
|
|
2640
|
-
return withConsent(renderOrderList(list), list.data);
|
|
2738
|
+
return withConsent(tool, renderOrderList(list), list.data);
|
|
2641
2739
|
}
|
|
2740
|
+
case "cancel_order":
|
|
2741
|
+
return renderOrder(parsed);
|
|
2642
2742
|
}
|
|
2643
2743
|
}
|
|
2644
2744
|
var ORDER_TOOLS = /* @__PURE__ */ new Set(["book_hotel", "get_order", "list_orders"]);
|
|
2745
|
+
var CANCEL_TOOLS = /* @__PURE__ */ new Set(["get_order", "list_orders"]);
|
|
2645
2746
|
function holdsPaymentUrl(value, seen = /* @__PURE__ */ new Set()) {
|
|
2646
2747
|
if (typeof value !== "object" || value === null || seen.has(value)) return false;
|
|
2647
2748
|
seen.add(value);
|
|
@@ -2651,10 +2752,21 @@ function holdsPaymentUrl(value, seen = /* @__PURE__ */ new Set()) {
|
|
|
2651
2752
|
}
|
|
2652
2753
|
return Object.values(value).some((v) => holdsPaymentUrl(v, seen));
|
|
2653
2754
|
}
|
|
2654
|
-
function
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2755
|
+
function holdsCancellable(value, seen = /* @__PURE__ */ new Set()) {
|
|
2756
|
+
if (typeof value !== "object" || value === null || seen.has(value)) return false;
|
|
2757
|
+
seen.add(value);
|
|
2758
|
+
const cancel = value.cancel;
|
|
2759
|
+
if (typeof cancel === "object" && cancel !== null && cancel.available === true) {
|
|
2760
|
+
return true;
|
|
2761
|
+
}
|
|
2762
|
+
return Object.values(value).some((v) => holdsCancellable(v, seen));
|
|
2763
|
+
}
|
|
2764
|
+
function withConsent(tool, text2, orders) {
|
|
2765
|
+
return [
|
|
2766
|
+
text2,
|
|
2767
|
+
orders.some((o) => o.payment.url !== null) ? ORDER_NEXT_STEP : "",
|
|
2768
|
+
CANCEL_TOOLS.has(tool) && orders.some((o) => o.cancel?.available === true) ? CANCEL_NEXT_STEP : ""
|
|
2769
|
+
].filter(Boolean).join("\n\n");
|
|
2658
2770
|
}
|
|
2659
2771
|
|
|
2660
2772
|
// src/conventions/unknown-is-not-no.ts
|
|
@@ -2682,6 +2794,7 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
|
|
|
2682
2794
|
worse: `${API_DECIDES} (whether a change is worse for the guest).`,
|
|
2683
2795
|
requiresSignIn: `${API_DECIDES} (whether the payment link needs a website sign-in).`,
|
|
2684
2796
|
localCurrencyAtCheckout: `${API_DECIDES} (whether checkout may charge in the card's currency).`,
|
|
2797
|
+
"cancel.available": `${API_DECIDES} (whether an order can be cancelled now).`,
|
|
2685
2798
|
bookable: `${API_DECIDES} (whether the hotel is still in the index).`,
|
|
2686
2799
|
cityLike: `${API_DECIDES} (frozen per gazetteer release; null where not computed).`,
|
|
2687
2800
|
known: `${THE_FLAG} (meals).`,
|
|
@@ -2691,7 +2804,7 @@ var UNKNOWN_IS_NOT_NO_EXEMPTIONS = {
|
|
|
2691
2804
|
// package.json
|
|
2692
2805
|
var package_default = {
|
|
2693
2806
|
name: "@fortrip/agent-contract",
|
|
2694
|
-
version: "3.
|
|
2807
|
+
version: "3.3.0",
|
|
2695
2808
|
license: "Apache-2.0",
|
|
2696
2809
|
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.",
|
|
2697
2810
|
type: "module",
|
|
@@ -2742,6 +2855,8 @@ var CONTRACT_VERSION = package_default.version;
|
|
|
2742
2855
|
export {
|
|
2743
2856
|
AMENITY_CODES,
|
|
2744
2857
|
API,
|
|
2858
|
+
CANCEL_NEXT_STEP,
|
|
2859
|
+
CANCEL_REASONS,
|
|
2745
2860
|
CARD_NUMBER_MESSAGE,
|
|
2746
2861
|
CENTER_BASES,
|
|
2747
2862
|
COMMANDS,
|
|
@@ -2773,6 +2888,7 @@ export {
|
|
|
2773
2888
|
UNKNOWN_IS_NOT_NO_EXEMPTIONS,
|
|
2774
2889
|
addIsoDateDays,
|
|
2775
2890
|
authConfig,
|
|
2891
|
+
cancelOrderInput,
|
|
2776
2892
|
cancellation,
|
|
2777
2893
|
center,
|
|
2778
2894
|
commandInvocation,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fortrip/agent-contract",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.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",
|