@curless/hotel-storefront 0.85.0 → 0.86.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/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/tools/accept-terms.d.ts +4 -0
- package/dist/tools/accept-terms.d.ts.map +1 -0
- package/dist/tools/accept-terms.js +26 -0
- package/dist/tools/accept-terms.js.map +1 -0
- package/dist/tools/add-booking-addon.d.ts +4 -0
- package/dist/tools/add-booking-addon.d.ts.map +1 -0
- package/dist/tools/add-booking-addon.js +44 -0
- package/dist/tools/add-booking-addon.js.map +1 -0
- package/dist/tools/add-to-trip.d.ts +4 -0
- package/dist/tools/add-to-trip.d.ts.map +1 -0
- package/dist/tools/add-to-trip.js +49 -0
- package/dist/tools/add-to-trip.js.map +1 -0
- package/dist/tools/all-tools.d.ts +1342 -0
- package/dist/tools/all-tools.d.ts.map +1 -0
- package/dist/tools/all-tools.js +954 -0
- package/dist/tools/all-tools.js.map +1 -0
- package/dist/tools/answer.d.ts +3 -0
- package/dist/tools/answer.d.ts.map +1 -0
- package/dist/tools/answer.js +104 -0
- package/dist/tools/answer.js.map +1 -0
- package/dist/tools/args.d.ts +149 -0
- package/dist/tools/args.d.ts.map +1 -0
- package/dist/tools/args.js +176 -0
- package/dist/tools/args.js.map +1 -0
- package/dist/tools/base-output-schemas.d.ts +3 -0
- package/dist/tools/base-output-schemas.d.ts.map +1 -0
- package/dist/tools/base-output-schemas.js +380 -0
- package/dist/tools/base-output-schemas.js.map +1 -0
- package/dist/tools/book-picked.d.ts +4 -0
- package/dist/tools/book-picked.d.ts.map +1 -0
- package/dist/tools/book-picked.js +14 -0
- package/dist/tools/book-picked.js.map +1 -0
- package/dist/tools/booking-answer.d.ts +24 -0
- package/dist/tools/booking-answer.d.ts.map +1 -0
- package/dist/tools/booking-answer.js +485 -0
- package/dist/tools/booking-answer.js.map +1 -0
- package/dist/tools/buy-shop-item.d.ts +4 -0
- package/dist/tools/buy-shop-item.d.ts.map +1 -0
- package/dist/tools/buy-shop-item.js +45 -0
- package/dist/tools/buy-shop-item.js.map +1 -0
- package/dist/tools/call.d.ts +11 -0
- package/dist/tools/call.d.ts.map +1 -0
- package/dist/tools/call.js +2 -0
- package/dist/tools/call.js.map +1 -0
- package/dist/tools/cancel-facts.d.ts +281 -0
- package/dist/tools/cancel-facts.d.ts.map +1 -0
- package/dist/tools/cancel-facts.js +309 -0
- package/dist/tools/cancel-facts.js.map +1 -0
- package/dist/tools/cancel.d.ts +4 -0
- package/dist/tools/cancel.d.ts.map +1 -0
- package/dist/tools/cancel.js +364 -0
- package/dist/tools/cancel.js.map +1 -0
- package/dist/tools/card-addons.d.ts +4 -0
- package/dist/tools/card-addons.d.ts.map +1 -0
- package/dist/tools/card-addons.js +76 -0
- package/dist/tools/card-addons.js.map +1 -0
- package/dist/tools/change-booking.d.ts +4 -0
- package/dist/tools/change-booking.d.ts.map +1 -0
- package/dist/tools/change-booking.js +145 -0
- package/dist/tools/change-booking.js.map +1 -0
- package/dist/tools/clear-trip.d.ts +4 -0
- package/dist/tools/clear-trip.d.ts.map +1 -0
- package/dist/tools/clear-trip.js +10 -0
- package/dist/tools/clear-trip.js.map +1 -0
- package/dist/tools/compare.d.ts +4 -0
- package/dist/tools/compare.d.ts.map +1 -0
- package/dist/tools/compare.js +114 -0
- package/dist/tools/compare.js.map +1 -0
- package/dist/tools/current-trip.d.ts +70 -0
- package/dist/tools/current-trip.d.ts.map +1 -0
- package/dist/tools/current-trip.js +261 -0
- package/dist/tools/current-trip.js.map +1 -0
- package/dist/tools/deps.d.ts +229 -0
- package/dist/tools/deps.d.ts.map +1 -0
- package/dist/tools/deps.js +2 -0
- package/dist/tools/deps.js.map +1 -0
- package/dist/tools/follow-ups.d.ts +120 -0
- package/dist/tools/follow-ups.d.ts.map +1 -0
- package/dist/tools/follow-ups.js +369 -0
- package/dist/tools/follow-ups.js.map +1 -0
- package/dist/tools/forget-preferences.d.ts +4 -0
- package/dist/tools/forget-preferences.d.ts.map +1 -0
- package/dist/tools/forget-preferences.js +24 -0
- package/dist/tools/forget-preferences.js.map +1 -0
- package/dist/tools/get-hotel.d.ts +4 -0
- package/dist/tools/get-hotel.d.ts.map +1 -0
- package/dist/tools/get-hotel.js +324 -0
- package/dist/tools/get-hotel.js.map +1 -0
- package/dist/tools/hotel-choices.d.ts +132 -0
- package/dist/tools/hotel-choices.d.ts.map +1 -0
- package/dist/tools/hotel-choices.js +558 -0
- package/dist/tools/hotel-choices.js.map +1 -0
- package/dist/tools/itinerary.d.ts +4 -0
- package/dist/tools/itinerary.d.ts.map +1 -0
- package/dist/tools/itinerary.js +148 -0
- package/dist/tools/itinerary.js.map +1 -0
- package/dist/tools/list-booking-addons.d.ts +4 -0
- package/dist/tools/list-booking-addons.d.ts.map +1 -0
- package/dist/tools/list-booking-addons.js +21 -0
- package/dist/tools/list-booking-addons.js.map +1 -0
- package/dist/tools/list-bookings.d.ts +4 -0
- package/dist/tools/list-bookings.d.ts.map +1 -0
- package/dist/tools/list-bookings.js +119 -0
- package/dist/tools/list-bookings.js.map +1 -0
- package/dist/tools/list-extras.d.ts +4 -0
- package/dist/tools/list-extras.d.ts.map +1 -0
- package/dist/tools/list-extras.js +90 -0
- package/dist/tools/list-extras.js.map +1 -0
- package/dist/tools/list-hotels.d.ts +4 -0
- package/dist/tools/list-hotels.d.ts.map +1 -0
- package/dist/tools/list-hotels.js +891 -0
- package/dist/tools/list-hotels.js.map +1 -0
- package/dist/tools/list-shop-items.d.ts +4 -0
- package/dist/tools/list-shop-items.d.ts.map +1 -0
- package/dist/tools/list-shop-items.js +34 -0
- package/dist/tools/list-shop-items.js.map +1 -0
- package/dist/tools/list-shop-orders.d.ts +4 -0
- package/dist/tools/list-shop-orders.d.ts.map +1 -0
- package/dist/tools/list-shop-orders.js +22 -0
- package/dist/tools/list-shop-orders.js.map +1 -0
- package/dist/tools/look-up.d.ts +4 -0
- package/dist/tools/look-up.d.ts.map +1 -0
- package/dist/tools/look-up.js +170 -0
- package/dist/tools/look-up.js.map +1 -0
- package/dist/tools/output-schemas.d.ts +645 -0
- package/dist/tools/output-schemas.d.ts.map +1 -0
- package/dist/tools/output-schemas.js +503 -0
- package/dist/tools/output-schemas.js.map +1 -0
- package/dist/tools/paid-lines.d.ts +718 -0
- package/dist/tools/paid-lines.d.ts.map +1 -0
- package/dist/tools/paid-lines.js +359 -0
- package/dist/tools/paid-lines.js.map +1 -0
- package/dist/tools/pay-with-union-pay.d.ts +4 -0
- package/dist/tools/pay-with-union-pay.d.ts.map +1 -0
- package/dist/tools/pay-with-union-pay.js +112 -0
- package/dist/tools/pay-with-union-pay.js.map +1 -0
- package/dist/tools/payment-words.d.ts +269 -0
- package/dist/tools/payment-words.d.ts.map +1 -0
- package/dist/tools/payment-words.js +365 -0
- package/dist/tools/payment-words.js.map +1 -0
- package/dist/tools/pick-room.d.ts +4 -0
- package/dist/tools/pick-room.d.ts.map +1 -0
- package/dist/tools/pick-room.js +23 -0
- package/dist/tools/pick-room.js.map +1 -0
- package/dist/tools/policies.d.ts +4 -0
- package/dist/tools/policies.d.ts.map +1 -0
- package/dist/tools/policies.js +74 -0
- package/dist/tools/policies.js.map +1 -0
- package/dist/tools/pricing.d.ts +55 -0
- package/dist/tools/pricing.d.ts.map +1 -0
- package/dist/tools/pricing.js +260 -0
- package/dist/tools/pricing.js.map +1 -0
- package/dist/tools/put-room-line.d.ts +12 -0
- package/dist/tools/put-room-line.d.ts.map +1 -0
- package/dist/tools/put-room-line.js +314 -0
- package/dist/tools/put-room-line.js.map +1 -0
- package/dist/tools/quote-card.d.ts +234 -0
- package/dist/tools/quote-card.d.ts.map +1 -0
- package/dist/tools/quote-card.js +375 -0
- package/dist/tools/quote-card.js.map +1 -0
- package/dist/tools/refund-booking.d.ts +4 -0
- package/dist/tools/refund-booking.d.ts.map +1 -0
- package/dist/tools/refund-booking.js +112 -0
- package/dist/tools/refund-booking.js.map +1 -0
- package/dist/tools/request-booking.d.ts +4 -0
- package/dist/tools/request-booking.d.ts.map +1 -0
- package/dist/tools/request-booking.js +5 -0
- package/dist/tools/request-booking.js.map +1 -0
- package/dist/tools/request-words.d.ts +238 -0
- package/dist/tools/request-words.d.ts.map +1 -0
- package/dist/tools/request-words.js +487 -0
- package/dist/tools/request-words.js.map +1 -0
- package/dist/tools/room-choices.d.ts +64 -0
- package/dist/tools/room-choices.d.ts.map +1 -0
- package/dist/tools/room-choices.js +348 -0
- package/dist/tools/room-choices.js.map +1 -0
- package/dist/tools/session-notes.d.ts +164 -0
- package/dist/tools/session-notes.d.ts.map +1 -0
- package/dist/tools/session-notes.js +412 -0
- package/dist/tools/session-notes.js.map +1 -0
- package/dist/tools/sign-in.d.ts +4 -0
- package/dist/tools/sign-in.d.ts.map +1 -0
- package/dist/tools/sign-in.js +72 -0
- package/dist/tools/sign-in.js.map +1 -0
- package/dist/tools/sign-out.d.ts +4 -0
- package/dist/tools/sign-out.d.ts.map +1 -0
- package/dist/tools/sign-out.js +13 -0
- package/dist/tools/sign-out.js.map +1 -0
- package/dist/tools/terms-answer.d.ts +114 -0
- package/dist/tools/terms-answer.d.ts.map +1 -0
- package/dist/tools/terms-answer.js +475 -0
- package/dist/tools/terms-answer.js.map +1 -0
- package/dist/tools/tool-set.d.ts +1474 -0
- package/dist/tools/tool-set.d.ts.map +1 -0
- package/dist/tools/tool-set.js +497 -0
- package/dist/tools/tool-set.js.map +1 -0
- package/dist/tools/view-trip.d.ts +4 -0
- package/dist/tools/view-trip.d.ts.map +1 -0
- package/dist/tools/view-trip.js +7 -0
- package/dist/tools/view-trip.js.map +1 -0
- package/dist/tools.d.ts +13 -2089
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +11 -10685
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,891 @@
|
|
|
1
|
+
import { DEFAULT_PAGE, FULL_CAPABILITIES, MAX_PAGE, unpaidBookingNote } from '../backend.js';
|
|
2
|
+
import { addDays, stayDayWords, weekendOf, weekendWords } from '../dates.js';
|
|
3
|
+
import { DESCRIPTION_MAX, hotelName, hotelText } from '../fence.js';
|
|
4
|
+
import { formatMoney, money, toMinor } from '../money.js';
|
|
5
|
+
import { regionOf } from '../regions.js';
|
|
6
|
+
import { MAX_ROOMS_PER_LINE } from '../trip.js';
|
|
7
|
+
import { branded } from '../vocab.js';
|
|
8
|
+
import { answerTool } from './answer.js';
|
|
9
|
+
import { asStay, groupNamed, place, str } from './args.js';
|
|
10
|
+
import { CITY_PICKER_MIN, HOME_LIST_MAX, emptiedBy, filterWords, filtersOf, refineFor, } from './current-trip.js';
|
|
11
|
+
import { LIST_NOT_DRAWN, ON_CARD } from './follow-ups.js';
|
|
12
|
+
import { fromPricesWords, hotelChoicesBlock } from './hotel-choices.js';
|
|
13
|
+
import { common } from './paid-lines.js';
|
|
14
|
+
import { withZh } from './quote-card.js';
|
|
15
|
+
import { NOT_NO_ROOM, NOT_SOLD_OUT, OWN_WHY, SORTS, everyCityOf, groupNameOf, guestsOf, notBookableOf, notSoldHereWords, sentence, unpaidBookingWords, widen, } from './request-words.js';
|
|
16
|
+
import { idsByNumber, stayDefaultWords, todayOfHotel } from './room-choices.js';
|
|
17
|
+
import { degradedOf, identity, quietIn, unplacedOf } from './session-notes.js';
|
|
18
|
+
import { TONIGHT_PAGE_MAX } from './tool-set.js';
|
|
19
|
+
export const answerListHotels = async ({ deps, args, ctx, t, key, }) => {
|
|
20
|
+
// ⚠️ A TRIP TO PLAN IS NOT MORE BROWSING (robin's own claude.ai, live 0.47.7,
|
|
21
|
+
// read by 总线程 2026-10-26): 「打开亚朵」 drew this list - right - and then
|
|
22
|
+
// 「11月1号到7号北京行程」 carried on from it: a look-up and a table of four
|
|
23
|
+
// hotels' prices, or this list again for Beijing, and no day planned. The
|
|
24
|
+
// server instructions say otherwise, but a host may not pass them on; this
|
|
25
|
+
// answer always reaches the model, so it says it here, after the list.
|
|
26
|
+
const forPlans = `A stay of several days with its days to plan (行程, an itinerary) is laid out day by day with ${t.itinerary}, its ${deps.vocab.nounPlural} read up with ${t.lookUp} near where each part of the trip is spent - also right after this list; this list is for a guest looking through ${deps.vocab.nounPlural}.`;
|
|
27
|
+
const query = place(args.query);
|
|
28
|
+
const city = place(args.city);
|
|
29
|
+
const sort = SORTS.includes(str(args.sort))
|
|
30
|
+
? str(args.sort)
|
|
31
|
+
: 'group';
|
|
32
|
+
const ceiling = Number(args.maxNightly) > 0 ? Number(args.maxNightly) : undefined;
|
|
33
|
+
const ask = {
|
|
34
|
+
query: query || undefined,
|
|
35
|
+
city: city || undefined,
|
|
36
|
+
limit: typeof args.limit === 'number' ? args.limit : undefined,
|
|
37
|
+
offset: Number(args.offset) > 0 ? Math.floor(Number(args.offset)) : undefined,
|
|
38
|
+
sort,
|
|
39
|
+
maxNightly: ceiling,
|
|
40
|
+
stay: asStay(args),
|
|
41
|
+
// Clamped here, so what is said and echoed is what was priced: "9 rooms"
|
|
42
|
+
// was said over prices for five.
|
|
43
|
+
rooms: typeof args.rooms === 'number' && Number.isFinite(args.rooms)
|
|
44
|
+
? Math.max(1, Math.min(MAX_ROOMS_PER_LINE, Math.floor(args.rooms)))
|
|
45
|
+
: undefined,
|
|
46
|
+
filters: filtersOf(args),
|
|
47
|
+
// Tonight by default: the page alone is priced (`listsTonight`, below).
|
|
48
|
+
...(ctx.pricePageOnly ? { pricePageOnly: true } : {}),
|
|
49
|
+
};
|
|
50
|
+
// A group as a guest names it, to the id the market files it under.
|
|
51
|
+
const named = ask.filters?.supplier ? groupNamed(deps, ask.filters.supplier) : undefined;
|
|
52
|
+
if (ask.filters?.supplier && named)
|
|
53
|
+
ask.filters = { ...ask.filters, supplier: named.id };
|
|
54
|
+
const who = identity(deps, ctx, key, args);
|
|
55
|
+
// ⚠️ A MARKET'S CITY FIELD, ASKED BESIDE THE SEARCH (0.68.0): a narrowed list's menu is
|
|
56
|
+
// every city, so the market is asked once more with nothing - at the same time, not
|
|
57
|
+
// after: a group that hangs would otherwise be waited for twice. Kept a minute whatever
|
|
58
|
+
// came back, and asked as no guest's (`everyCityOf`). One that fails is no menu.
|
|
59
|
+
const narrowedAsk = !!(ask.query || ask.city || ask.filters || ask.maxNightly);
|
|
60
|
+
const marketCities = narrowedAsk && (deps.backend.suppliers || deps.vocab.market) ? everyCityOf(deps) : undefined;
|
|
61
|
+
let answer = await deps.backend.searchHotels(ask, who);
|
|
62
|
+
// A brand as the data spells it, so its chip shows as ON and can be turned
|
|
63
|
+
// off: `brand: 'kerry'` filtered, and then no chip matched it.
|
|
64
|
+
const brandAsked = ask.filters?.brand?.toLowerCase();
|
|
65
|
+
const brandNamed = answer.refine?.brands.find((b) => b.name.toLowerCase() === brandAsked)?.name;
|
|
66
|
+
if (ask.filters && brandNamed)
|
|
67
|
+
ask.filters = { ...ask.filters, brand: brandNamed };
|
|
68
|
+
// The search the answer actually came from - the widened one, when it was
|
|
69
|
+
// widened - so its next page is the next page of THAT.
|
|
70
|
+
let asked = ask;
|
|
71
|
+
// ⚠️ ONE WIDER SEARCH BEFORE THE WORD "NO". A group with ninety-six
|
|
72
|
+
// properties and a guest who typed "Shangri La Tokyo" into `city` gets
|
|
73
|
+
// nothing, and "no hotels match that" is a lie about a group with two in
|
|
74
|
+
// Tokyo. One retry, named in the answer so nobody presents a widening as a
|
|
75
|
+
// match - and only ONE, because a search that keeps loosening until it
|
|
76
|
+
// finds something will always find something.
|
|
77
|
+
//
|
|
78
|
+
// ⚠️ AND IT ONLY WIDENS THE PLACE AND THE WORDS. A `maxNightly` that
|
|
79
|
+
// excluded everything is not a failed search: the place matched, the words
|
|
80
|
+
// matched, and the prices were the answer. Widening there dropped "Hong
|
|
81
|
+
// Kong" and came back with five hotels in two countries, ceiling silently
|
|
82
|
+
// unapplied because the wider set no longer shared a currency (found by
|
|
83
|
+
// reading the output, 2026-09-22) - which is the runaway loosening this
|
|
84
|
+
// comment was written to forbid, committed by the code under it.
|
|
85
|
+
// `overBudget` is how the seam says the place and the words did match.
|
|
86
|
+
let widened;
|
|
87
|
+
// ⚠️ A FILTER OR A CEILING THAT EMPTIED THE LIST IS NOT A SEARCH THAT
|
|
88
|
+
// FAILED either, for the same reason as the ceiling above: the place
|
|
89
|
+
// matched. What matched the place and the words, before either:
|
|
90
|
+
const placedCount = (a) => a.beforeFilters ?? a.beforeCeiling ?? a.total;
|
|
91
|
+
// ⚠️ AND NOT WHEN A GROUP DID NOT ANSWER (2026-11-03 review, C4). The place
|
|
92
|
+
// "matched nothing" among the groups that answered; the one that did not
|
|
93
|
+
// may have it. A wider search then found something else, took over as the
|
|
94
|
+
// answer, and the first search's "X did not answer" went with it - "nothing
|
|
95
|
+
// matched Hong Kong, so this is Shenzhen", with Hong Kong's group silent.
|
|
96
|
+
// It also cost another time limit. The empty answer is given as it is, with
|
|
97
|
+
// the sentence that the group did not answer (`degradedOf`).
|
|
98
|
+
if (placedCount(answer) === 0 && !answer.degraded?.length) {
|
|
99
|
+
const wider = widen(ask);
|
|
100
|
+
if (wider) {
|
|
101
|
+
const second = await deps.backend.searchHotels(wider.ask, who);
|
|
102
|
+
// Found when the wider PLACE matched - a wider search emptied by the
|
|
103
|
+
// same ceiling or filter is still the place, and "Hong Kong found
|
|
104
|
+
// nothing either" was said of four hotels over the ceiling.
|
|
105
|
+
const { ask: _wider, ...said } = wider;
|
|
106
|
+
widened = { ...said, found: placedCount(second) > 0 };
|
|
107
|
+
if (widened.found) {
|
|
108
|
+
answer = second;
|
|
109
|
+
asked = { ...ask, ...wider.ask };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const filteredEmpty = !!asked.filters &&
|
|
114
|
+
answer.total === 0 &&
|
|
115
|
+
placedCount(answer) > 0 &&
|
|
116
|
+
(answer.beforeCeiling ?? 0) === 0;
|
|
117
|
+
const ceilingEmpty = answer.total === 0 && (answer.beforeCeiling ?? 0) > 0;
|
|
118
|
+
// The ceiling again on this side of the seam. MAX_PAGE is part of the
|
|
119
|
+
// backend contract, but "the next backend honours it" is not something the
|
|
120
|
+
// card can be built on - and the cost of it being wrong is the whole group
|
|
121
|
+
// in the model's context.
|
|
122
|
+
// ⚠️ A HOTEL NOT ON SALE HERE SAYS WHERE IT IS (review r2, T5): its page said
|
|
123
|
+
// the group's own channels, its tile on a list - the answer a model often
|
|
124
|
+
// stops at - only that nothing was on sale. In the text and the structure.
|
|
125
|
+
const hotels = answer.hotels.slice(0, MAX_PAGE).map((h) => h.noRoomsForStayCode === 'none-on-sale' && h.noRoomsForStay
|
|
126
|
+
? {
|
|
127
|
+
...h,
|
|
128
|
+
noRoomsForStay: `${h.noRoomsForStay.replace(/[.\s]+$/, '')} - it can be booked through ${groupNameOf(deps, h.id)}'s own channels: its app, its website or by phone.`,
|
|
129
|
+
}
|
|
130
|
+
: h);
|
|
131
|
+
const offset = asked.offset ?? 0;
|
|
132
|
+
const total = Math.max(answer.total, offset + hotels.length);
|
|
133
|
+
// One city however its group writes it (0.74.5: Accor's "SINGAPORE" beside "Singapore").
|
|
134
|
+
const cities = [
|
|
135
|
+
...hotels
|
|
136
|
+
.reduce((m, h) => {
|
|
137
|
+
const k = h.city.trim().toLowerCase();
|
|
138
|
+
if (!m.has(k))
|
|
139
|
+
m.set(k, h.city);
|
|
140
|
+
return m;
|
|
141
|
+
}, new Map())
|
|
142
|
+
.values(),
|
|
143
|
+
];
|
|
144
|
+
// How many were left behind. The group has ninety-odd properties, so an
|
|
145
|
+
// unnarrowed browse is a page of a much longer list, and neither the card
|
|
146
|
+
// nor the model may present the page as the whole answer.
|
|
147
|
+
const more = Math.max(0, total - offset - hotels.length);
|
|
148
|
+
// ⚠️ THE WAYS IN, COUNTED ACROSS EVERYTHING THAT MATCHED. "Showing 20 of 96
|
|
149
|
+
// - name a city" left a guest to type a place they could not see (robin,
|
|
150
|
+
// 2026-09-28: 「是否要加一个城市筛选之类的功能,然后可以选择查看更多」). An
|
|
151
|
+
// unnarrowed browse offers the countries; a country with several cities
|
|
152
|
+
// offers its cities; one city offers nothing, because it is already there.
|
|
153
|
+
const facets = answer.facets;
|
|
154
|
+
const narrowedTo = asked.city?.toLowerCase();
|
|
155
|
+
// A place as a chip: its own name is what it is asked by again, and its
|
|
156
|
+
// names - or its country's code - what the card says it in (robin, 2026-10-15).
|
|
157
|
+
const cityPlace = (c) => ({
|
|
158
|
+
label: c.name,
|
|
159
|
+
place: c.name,
|
|
160
|
+
count: c.count,
|
|
161
|
+
...(c.names ? { names: c.names } : {}),
|
|
162
|
+
});
|
|
163
|
+
const countryPlace = (c) => ({
|
|
164
|
+
label: c.name,
|
|
165
|
+
place: c.name,
|
|
166
|
+
count: c.count,
|
|
167
|
+
...(c.code ? { code: c.code } : {}),
|
|
168
|
+
});
|
|
169
|
+
const places = !facets
|
|
170
|
+
? []
|
|
171
|
+
: asked.query
|
|
172
|
+
? facets.cities.length > 1
|
|
173
|
+
? facets.cities.map(cityPlace)
|
|
174
|
+
: []
|
|
175
|
+
: !narrowedTo
|
|
176
|
+
? facets.countries.length > 1
|
|
177
|
+
? facets.countries.map(countryPlace)
|
|
178
|
+
: []
|
|
179
|
+
: facets.cities.length > 1
|
|
180
|
+
? facets.cities.map(cityPlace)
|
|
181
|
+
: [];
|
|
182
|
+
// ⚠️ THE MISSES ARE THE ANSWER when a ceiling is what emptied the list. A
|
|
183
|
+
// guest asking for under HK$1,000 learns nothing from "no hotels"; told the
|
|
184
|
+
// cheapest is HK$1,180 they can decide. They are named as misses and kept
|
|
185
|
+
// out of `hotels`, so no card and no model can show them as matches.
|
|
186
|
+
// ⚠️ SOMEWHERE FIRST, THEN A HOTEL (robin, 2026-09-28: 「和温德姆一样,先让人
|
|
187
|
+
// 选国家和城市,然后再选酒店」). An unnarrowed browse used to be twenty tiles
|
|
188
|
+
// of ninety-six under a row of country chips; a country of forty cities
|
|
189
|
+
// was the same. Neither is a choice a guest can make. Where nothing - or
|
|
190
|
+
// only a country with many cities - was named, the answer is the PLACES:
|
|
191
|
+
// regions, countries and cities, each with how many there are, and a city
|
|
192
|
+
// is the way to its hotels. `all` still lists the hotels themselves.
|
|
193
|
+
// The nights and rooms, as a search asks for them again: kept on a place,
|
|
194
|
+
// a sort, a next page.
|
|
195
|
+
const stayArgs = ask.stay
|
|
196
|
+
? {
|
|
197
|
+
checkIn: ask.stay.checkIn,
|
|
198
|
+
checkOut: ask.stay.checkOut,
|
|
199
|
+
guests: ask.stay.guests,
|
|
200
|
+
...(ask.rooms && ask.rooms > 1 ? { rooms: ask.rooms } : {}),
|
|
201
|
+
}
|
|
202
|
+
: {};
|
|
203
|
+
// How many the whole deployment has: the server says, and an unnarrowed
|
|
204
|
+
// answer is it. A deployment of up to HOME_LIST_MAX fits on one page -
|
|
205
|
+
// never a market, whose home is its groups.
|
|
206
|
+
const unnarrowed = !ask.query && !ask.city && !ask.filters && !ask.maxNightly;
|
|
207
|
+
const deployed = deps.hotelCount?.() ?? (unnarrowed ? answer.total : 0);
|
|
208
|
+
// ⚠️ A BACKEND THAT HAS NO PRICE FOR A STAY (11-05; Otaless, whose /rooms is empty
|
|
209
|
+
// and whose from-price says nothing of taxes - `Hotel.fromNightlyTaxes`) lists a
|
|
210
|
+
// from-price a night and no stay total, with dates or without. The list must not
|
|
211
|
+
// promise one ("priced for the nights you choose", "each price is for the whole
|
|
212
|
+
// stay"); it says what the price is. The card reads the same flag.
|
|
213
|
+
const fromPricesOnly = hotels.length > 0 &&
|
|
214
|
+
hotels.every((h) => h.fromNightly && h.fromNightlyTaxes === 'unknown' && !h.forStay && !h.noRoomsForStay);
|
|
215
|
+
const fitsOnePage = !deps.backend.suppliers && !deps.vocab.market && deployed >= 1 && deployed <= HOME_LIST_MAX;
|
|
216
|
+
// ⚠️ THE SEARCH AS ASKED, `all` INCLUDED. The echo dropped `all`, so every
|
|
217
|
+
// re-query the card made from a "Browse all" list - new dates, the default
|
|
218
|
+
// order, clearing a filter - met no place, no words and no filter, and
|
|
219
|
+
// came back as the destinations page (2026-09-28 audit). Built once, for
|
|
220
|
+
// the list and for the list a filter or a ceiling emptied.
|
|
221
|
+
//
|
|
222
|
+
// ⚠️ WHERE IT ALL FITS ON ONE PAGE, `all` IS THE HOME (robin, 2026-10-30:
|
|
223
|
+
// 「华住默认还是没有日期呀」). Huazhu's production has two; asked to open
|
|
224
|
+
// Huazhu, the model sent `all: true` - "lists the hotels themselves" - and
|
|
225
|
+
// that skipped the home: no tonight, no prices, "All hotels · add dates".
|
|
226
|
+
// Here every hotel is on the home already, so `all` asks for nothing more.
|
|
227
|
+
const listAll = args.all === true && !fitsOnePage;
|
|
228
|
+
const echo = (applied) => ({
|
|
229
|
+
...(asked.query ? { query: asked.query } : {}),
|
|
230
|
+
...(asked.city ? { city: asked.city } : {}),
|
|
231
|
+
...(applied !== 'group' ? { sort: applied } : {}),
|
|
232
|
+
...(asked.maxNightly ? { maxNightly: asked.maxNightly } : {}),
|
|
233
|
+
...(asked.filters ?? {}),
|
|
234
|
+
...(listAll ? { all: true } : {}),
|
|
235
|
+
...stayArgs,
|
|
236
|
+
});
|
|
237
|
+
// A country, said as the data spells it - or by another name the backend
|
|
238
|
+
// understood (中国, from a place's aliases or a market's): the answer is
|
|
239
|
+
// one country and many cities, none of them the place asked for. "中国"
|
|
240
|
+
// drew fifty hotels where "China" drew the city picker (Marketplace,
|
|
241
|
+
// 2026-10-08).
|
|
242
|
+
const namedCountry = !!asked.city &&
|
|
243
|
+
facets?.countries.length === 1 &&
|
|
244
|
+
(facets.countries[0]?.name.toLowerCase() === asked.city.toLowerCase() ||
|
|
245
|
+
(facets.cities.length > 1 &&
|
|
246
|
+
!facets.cities.some((c) => c.name.toLowerCase() === asked.city?.toLowerCase())));
|
|
247
|
+
const choosing = facets &&
|
|
248
|
+
!asked.filters &&
|
|
249
|
+
!asked.query &&
|
|
250
|
+
sort === 'group' &&
|
|
251
|
+
!asked.maxNightly &&
|
|
252
|
+
!offset &&
|
|
253
|
+
!listAll &&
|
|
254
|
+
// A widened search is a list with the miss said over it: as a page of
|
|
255
|
+
// places, "helipad" matching nothing in China was never said at all.
|
|
256
|
+
!widened &&
|
|
257
|
+
(!asked.city || (namedCountry && facets.cities.length >= CITY_PICKER_MIN));
|
|
258
|
+
// "Today" where the hotels are - earliest and latest - for a page that has
|
|
259
|
+
// no one hotel's clock to fill its date bar from (see the card's
|
|
260
|
+
// `todayRange`): the UTC date was yesterday in Asia before 8am.
|
|
261
|
+
const days = answer.hotels
|
|
262
|
+
.map((h) => h.todayThere)
|
|
263
|
+
.filter((x) => !!x)
|
|
264
|
+
.sort();
|
|
265
|
+
const today = days.length ? { min: days[0], max: days.at(-1) } : undefined;
|
|
266
|
+
// ⚠️ THE HOME OF A FEW OPENS ON TONIGHT, PRICED (robin, 2026-10-30: 「我刚刚
|
|
267
|
+
// 打开华住,没自动选日期」 - of three ways, he chose 「默认今晚并直接出价」).
|
|
268
|
+
// 0.50.3 left the dates empty because dates over prices that were not
|
|
269
|
+
// theirs read as that night's prices; here the dates and the prices are
|
|
270
|
+
// the same night, so that cannot happen. Tonight is the hotels' own date
|
|
271
|
+
// (the earliest of them, `todayThere`), for the default party; asked again
|
|
272
|
+
// with those nights, the answer is the home as before - priced.
|
|
273
|
+
//
|
|
274
|
+
// ⚠️ AND EVERY LIST THERE WITHOUT DATES, NOT THE HOME ALONE (0.51.1). In a
|
|
275
|
+
// deployment that fits on one page a list - a city, words, a filter, `all`
|
|
276
|
+
// - is the home or a part of it: without dates it was the same hotels with
|
|
277
|
+
// tonight's prices taken away, "add dates to see what a stay costs" one
|
|
278
|
+
// turn after the home showed them. It costs what the home costs, a quote
|
|
279
|
+
// per hotel (six at most). A group of many still chooses a city first and
|
|
280
|
+
// lists twenty at a time without prices, a market its group; rooms by the
|
|
281
|
+
// hour are today's by their own rule; dates the model gave are used as given.
|
|
282
|
+
//
|
|
283
|
+
// ⚠️ AND IN A DEPLOYMENT PRICED FOR TONIGHT, AT ANY SIZE (`listsTonight`, 0.75.1 -
|
|
284
|
+
// robin 11-18 at Huazhu's 88: 「怎么变成要选日期了,不是默认当天的吗」). Its home is still
|
|
285
|
+
// the cities to choose from, unpriced (`choosing`); every list - a city, words, a brand,
|
|
286
|
+
// a filter, `all` - is tonight's, priced: this page only, at most TONIGHT_PAGE_MAX,
|
|
287
|
+
// through the group's own limit on calls and its minute of kept prices. A hotel whose
|
|
288
|
+
// price cannot be read is listed without one, said as that (`noRoomsForStayCode`
|
|
289
|
+
// 'unreachable'); a list that cannot be priced at all is the list as it was.
|
|
290
|
+
const tonightLists = !fitsOnePage &&
|
|
291
|
+
!choosing &&
|
|
292
|
+
deps.backend.capabilities?.listsTonight === true &&
|
|
293
|
+
!deps.backend.suppliers &&
|
|
294
|
+
!deps.vocab.market;
|
|
295
|
+
if ((fitsOnePage || tonightLists) &&
|
|
296
|
+
!ask.stay &&
|
|
297
|
+
!ask.filters?.hourly &&
|
|
298
|
+
hotels.length &&
|
|
299
|
+
today?.min) {
|
|
300
|
+
const tonight = {
|
|
301
|
+
checkIn: today.min,
|
|
302
|
+
checkOut: addDays(today.min, 1),
|
|
303
|
+
guests: guestsOf(args),
|
|
304
|
+
};
|
|
305
|
+
const pageAsked = typeof args.limit === 'number' ? args.limit : DEFAULT_PAGE;
|
|
306
|
+
const tonightArgs = {
|
|
307
|
+
...args,
|
|
308
|
+
...tonight,
|
|
309
|
+
...(tonightLists ? { limit: Math.min(pageAsked, TONIGHT_PAGE_MAX) } : {}),
|
|
310
|
+
};
|
|
311
|
+
// Where the deployment is priced for tonight at any size, a list that could not be
|
|
312
|
+
// priced at all is the list as it was - never no list (a deployment of a few as before).
|
|
313
|
+
const priced = tonightLists
|
|
314
|
+
? await answerTool(deps, t.listHotels, tonightArgs, { ...ctx, pricePageOnly: true }).then((a) => (a.isError ? undefined : a), () => undefined)
|
|
315
|
+
: await answerTool(deps, t.listHotels, tonightArgs, ctx);
|
|
316
|
+
if (priced) {
|
|
317
|
+
// ⚠️ THE ROOMS ASKED FOR, not "one room" (2026-11-03 review, C12): `rooms: 2`
|
|
318
|
+
// rides along into the priced list, and every price in it is two rooms'.
|
|
319
|
+
const roomCount = ask.rooms ?? 1;
|
|
320
|
+
// In both, in the same words: the model reads the structure.
|
|
321
|
+
// ⚠️ TO A CLIENT THAT DRAWS NO CARD, THE OTHER NIGHTS ARE NAMED BY THEIR
|
|
322
|
+
// DATES (robin 11-06): the card has a date bar to change; in words it is
|
|
323
|
+
// the reply's first sentence - see `stayDefaultWords`.
|
|
324
|
+
const stayDefault = ctx.noCards
|
|
325
|
+
? stayDefaultWords(tonight.checkIn, tonight.guests, roomCount, 'hotels')
|
|
326
|
+
: `No dates were asked for, so this opens on tonight by default: ${tonight.checkIn} to ${tonight.checkOut} (one night, on the hotels' own date), ${tonight.guests} ${tonight.guests === 1 ? 'guest' : 'guests'}, ${roomCount === 1 ? 'one room' : `${roomCount} rooms`} - every price here is for that night. Say so: the prices shown are tonight's, and the guest can change the dates on the card or name others. Do not ask for dates before showing them.`;
|
|
327
|
+
// Right after what is here - "every one, and no others" stays the first thing said.
|
|
328
|
+
const inAll = String(priced.structured.inAll ?? '');
|
|
329
|
+
return {
|
|
330
|
+
...priced,
|
|
331
|
+
structured: { ...priced.structured, stayDefault },
|
|
332
|
+
text: inAll && priced.text.startsWith(inAll)
|
|
333
|
+
? `${inAll} ${stayDefault}${priced.text.slice(inAll.length)}`
|
|
334
|
+
: `${stayDefault}\n\n${priced.text}`,
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
// ⚠️ ONE HOTEL IS NO CHOICE OF PLACES (robin, 2026-10-15: 「现在只有杭州一家
|
|
339
|
+
// 了,首页也要改」). Huazhu's test system has one hotel, and "where to?" over
|
|
340
|
+
// a search box, one city chip and "browse all 1 hotel" was a page of ways
|
|
341
|
+
// to the only thing there is. Where the whole deployment is one hotel -
|
|
342
|
+
// never a market, whose home is its groups - the home is that hotel's
|
|
343
|
+
// page: for the nights asked, or asking for them. `only` tells the card it
|
|
344
|
+
// is the home, so the home's own ways (my bookings, a booking by its code)
|
|
345
|
+
// stay on it.
|
|
346
|
+
const [sole] = hotels;
|
|
347
|
+
if (choosing && total === 1 && sole && !deps.backend.suppliers) {
|
|
348
|
+
const page = await answerTool(deps, t.getHotel, { hotel: sole.id, ...stayArgs }, ctx);
|
|
349
|
+
// ⚠️ NOT "THE ONLY ONE HERE": read as "in this list", it had the
|
|
350
|
+
// assistant ask which city to list the rest in (2026-10-15 smoke run).
|
|
351
|
+
// And not "tell me another city": the second run said there was one
|
|
352
|
+
// hotel, then offered to look in another city (2026-10-15).
|
|
353
|
+
const inAll = `There is one ${branded(deps.vocab, deps.vocab.noun)} here in all, ${sole.name}${sole.city ? ` in ${sole.city}` : ''}. There is no other hotel and no other city here - nothing else to search for or to offer.`;
|
|
354
|
+
return {
|
|
355
|
+
...page,
|
|
356
|
+
// In both, in the same words: a host may hand its model this rather
|
|
357
|
+
// than the text.
|
|
358
|
+
structured: { ...page.structured, only: true, inAll },
|
|
359
|
+
text: `${inAll} Its page:\n\n${page.text}`,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
// ⚠️ A FEW HOTELS ARE NO CHOICE OF PLACES EITHER (robin, 2026-10-30):
|
|
363
|
+
// Huazhu's production had two, in two cities, and its home was "where to?"
|
|
364
|
+
// over two city chips and "browse all 2" - the model then listed them
|
|
365
|
+
// again, a second card for the same question. Where the whole deployment
|
|
366
|
+
// fits on one page - never a market, whose home is its groups - the home
|
|
367
|
+
// is the list of all of them, marked `home` so the card keeps the home's
|
|
368
|
+
// own ways in on it.
|
|
369
|
+
const homeList = !!choosing &&
|
|
370
|
+
!asked.city &&
|
|
371
|
+
!deps.backend.suppliers &&
|
|
372
|
+
total > 1 &&
|
|
373
|
+
total <= HOME_LIST_MAX &&
|
|
374
|
+
hotels.length === total;
|
|
375
|
+
if (choosing && facets && !homeList) {
|
|
376
|
+
const countries = facets.countries.map((c) => ({
|
|
377
|
+
name: c.name,
|
|
378
|
+
count: c.count,
|
|
379
|
+
...(c.code ? { code: c.code } : {}),
|
|
380
|
+
cities: facets.cities
|
|
381
|
+
.filter((x) => x.country === c.name)
|
|
382
|
+
.map((x) => ({ name: x.name, count: x.count, ...(x.names ? { names: x.names } : {}) })),
|
|
383
|
+
}));
|
|
384
|
+
// Every place, counted: a host with no card has only this sentence, and
|
|
385
|
+
// "the most are in" three of forty cities left the other thirty-seven
|
|
386
|
+
// for a guest to guess at.
|
|
387
|
+
const every = (xs) => xs.map((x) => `${x.name} (${x.count})`).join(', ');
|
|
388
|
+
// ⚠️ AND TO A CLIENT THAT DRAWS NO CARD, EVERY CITY (2026-11-02 audit,
|
|
389
|
+
// P3-2): told to name the places, a model had "China (54)" and nothing
|
|
390
|
+
// to name. A country of one city named like it says no more.
|
|
391
|
+
const everyWithCities = (xs) => xs
|
|
392
|
+
.map((c) => c.cities.length > 1 || (c.cities[0] && c.cities[0].name !== c.name)
|
|
393
|
+
? `${c.name} (${c.count}: ${c.cities.map((x) => `${x.name} ${x.count}`).join(', ')})`
|
|
394
|
+
: `${c.name} (${c.count})`)
|
|
395
|
+
.join(', ');
|
|
396
|
+
const n = deps.vocab.nounPlural;
|
|
397
|
+
// Places to choose from: a group that did not answer is a greyed chip, said only if asked
|
|
398
|
+
// (0.74.4) - with nothing to show, it is why, and said.
|
|
399
|
+
const degraded = degradedOf(deps, answer, undefined, ctx?.noCards, undefined, quietIn(deps, asked.filters?.supplier), total > 0);
|
|
400
|
+
if (namedCountry) {
|
|
401
|
+
const [only] = countries;
|
|
402
|
+
return {
|
|
403
|
+
structured: {
|
|
404
|
+
view: 'destinations',
|
|
405
|
+
...common(deps, key),
|
|
406
|
+
total,
|
|
407
|
+
scope: only,
|
|
408
|
+
ask: { city: asked.city, ...stayArgs },
|
|
409
|
+
...(ask.stay ? { stay: ask.stay } : {}),
|
|
410
|
+
...(today ? { today } : {}),
|
|
411
|
+
...degraded.structured,
|
|
412
|
+
},
|
|
413
|
+
text: `${total} ${branded(deps.vocab, n)} in ${only?.name}, in ${only?.cities.length} cities to choose from: ${every(only?.cities ?? [])}. A city lists its ${n}; \`all\` lists every one in ${only?.name}. ${degraded.said ? `${degraded.said} ` : ''}${forPlans}`,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
const regions = [
|
|
417
|
+
...countries
|
|
418
|
+
.reduce((acc, c) => {
|
|
419
|
+
const r = regionOf(c.name);
|
|
420
|
+
const at = acc.get(r) ?? { name: r, count: 0, countries: [] };
|
|
421
|
+
at.count += c.count;
|
|
422
|
+
at.countries.push(c);
|
|
423
|
+
return acc.set(r, at);
|
|
424
|
+
}, new Map())
|
|
425
|
+
.values(),
|
|
426
|
+
].sort((a, b) => b.count - a.count);
|
|
427
|
+
// The places page counts a group asked only with a place where it is known to have hotels (0.75.1).
|
|
428
|
+
const placesTotal = total + (answer.elsewhere ?? 0);
|
|
429
|
+
// ⚠️ ONE COUNTRY IS A CHOICE OF CITIES (robin 11-18, Huazhu's 88 in 32 cities, all in
|
|
430
|
+
// China: 「华住首页改成城市选择的吧」). "88 hotels in 32 cities across 1 country, to choose
|
|
431
|
+
// from by region, country and city - Asia: China (88)" named no city the guest could
|
|
432
|
+
// choose. Where a list is priced for tonight (`listsTonight`), every city, counted - with
|
|
433
|
+
// a card and without - and what choosing one does.
|
|
434
|
+
const cityHome = deps.backend.capabilities?.listsTonight === true &&
|
|
435
|
+
!deps.backend.suppliers &&
|
|
436
|
+
!deps.vocab.market &&
|
|
437
|
+
countries.length === 1 &&
|
|
438
|
+
facets.cities.length > 1;
|
|
439
|
+
return {
|
|
440
|
+
structured: {
|
|
441
|
+
view: 'destinations',
|
|
442
|
+
...common(deps, key),
|
|
443
|
+
total: placesTotal,
|
|
444
|
+
regions,
|
|
445
|
+
ask: { ...stayArgs },
|
|
446
|
+
...(ask.stay ? { stay: ask.stay } : {}),
|
|
447
|
+
...(today ? { today } : {}),
|
|
448
|
+
...(fromPricesOnly ? { fromPricesOnly: true } : {}),
|
|
449
|
+
// ⚠️ IN A MARKET, HOW MANY HOTELS EACH GROUP HAS HERE (11-03): the card
|
|
450
|
+
// says "from N groups" of the groups that have one - not of every group
|
|
451
|
+
// on the market's list, six of which may have none. Only the counts.
|
|
452
|
+
...(deps.backend.suppliers && answer.refine?.suppliers
|
|
453
|
+
? { refine: { suppliers: answer.refine.suppliers } }
|
|
454
|
+
: {}),
|
|
455
|
+
...degraded.structured,
|
|
456
|
+
},
|
|
457
|
+
// ⚠️ NOTHING TO SHOW IS SAID AS THAT (0.55.1), as the card says it: 「0 hotels in 0
|
|
458
|
+
// cities across 0 countries, to choose from by region, country and city - .」 was a
|
|
459
|
+
// home of places over none - Otaless on a backend with no group answering. Then the
|
|
460
|
+
// groups that did not answer, by name; no places, no plans.
|
|
461
|
+
text: total === 0
|
|
462
|
+
? `There are no ${n} to show right now.${degraded.said ? ` ${degraded.said}` : ''}`
|
|
463
|
+
: cityHome
|
|
464
|
+
? `${sentence(branded(deps.vocab, n))} in ${facets.cities.length} cities, to choose from by city: ${every(facets.cities)}. A city lists its ${n}, priced for tonight unless other nights are named; \`all\` lists every one, a page at a time - only for a guest who asked to see every one. ${degraded.said ? `${degraded.said} ` : ''}${forPlans}`
|
|
465
|
+
: `${sentence(branded(deps.vocab, n))} in ${facets.cities.length} cities across ${countries.length} ${countries.length === 1 ? 'country' : 'countries'}, to choose from by region, country and city - ${regions.map((r) => `${r.name}: ${ctx.noCards ? everyWithCities(r.countries) : every(r.countries)}`).join('; ')}. A city or a country lists its ${n}. ${degraded.said ? `${degraded.said} ` : ''}${forPlans}`,
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
if (hotels.length === 0) {
|
|
469
|
+
const nearest = (answer.nearest ?? []).map((h) => ({
|
|
470
|
+
...h,
|
|
471
|
+
summary: hotelText('description', h.name, h.summary, DESCRIPTION_MAX).text,
|
|
472
|
+
fromNightly: h.fromNightly ? formatMoney(h.fromNightly) : undefined,
|
|
473
|
+
...(h.forStay
|
|
474
|
+
? {
|
|
475
|
+
forStay: {
|
|
476
|
+
...h.forStay,
|
|
477
|
+
total: formatMoney(h.forStay.total),
|
|
478
|
+
nightly: formatMoney(h.forStay.nightly),
|
|
479
|
+
},
|
|
480
|
+
}
|
|
481
|
+
: {}),
|
|
482
|
+
}));
|
|
483
|
+
const [first] = answer.nearest ?? [];
|
|
484
|
+
// On named nights, a night of the stay that was priced - the list rate
|
|
485
|
+
// was quoted beside a ceiling it was never held against.
|
|
486
|
+
const cheapest = first?.forStay?.nightly ?? first?.fromNightly;
|
|
487
|
+
const capCurrency = answer.currencies[0] ?? cheapest?.currency ?? 'HKD';
|
|
488
|
+
const cap = formatMoney(money(toMinor(Number(ceiling), capCurrency), capCurrency));
|
|
489
|
+
const pastTheEnd = answer.total > 0 && offset > 0;
|
|
490
|
+
/** Empty for a reason of its own - a page past the end, the filters, the ceiling. */
|
|
491
|
+
const emptyOfItself = pastTheEnd || filteredEmpty || ceilingEmpty;
|
|
492
|
+
// ⚠️ SAID ONLY IF ASKED WHERE IT IS NOT WHY IT IS EMPTY (0.74.4): where nothing could be
|
|
493
|
+
// read at all, the groups that did not answer are the reason, and said.
|
|
494
|
+
const degraded = degradedOf(deps, answer, undefined, ctx?.noCards, undefined, quietIn(deps, asked.filters?.supplier), emptyOfItself);
|
|
495
|
+
// ⚠️ NOTHING READ IS NOT "NOTHING MATCHES" (0.59.0, review U4): with every
|
|
496
|
+
// group silent - or held back by a limit of ours (otaless/limits.ts) - the
|
|
497
|
+
// answer said "No hotels match that" beside "did not answer in time", and
|
|
498
|
+
// the card offered another city. What was not asked, or not answered, is
|
|
499
|
+
// said as that; what our limit held back is said in its own words
|
|
500
|
+
// (`unapplied`), which this branch did not read.
|
|
501
|
+
// ⚠️ A GROUP LOOKED UP ONLY WITH A PLACE, CHOSEN WITH NONE (0.74.6, robin 11-17 (a): Accor's
|
|
502
|
+
// chip on the home): not "nothing could be read" - the page to choose its country or city
|
|
503
|
+
// on, with the cities it is known to have hotels in (`Unanswered.places`). An older card
|
|
504
|
+
// draws the empty list it drew before, its words the same.
|
|
505
|
+
const unplacedGroup = !emptyOfItself && !asked.city && !asked.query && asked.filters?.supplier
|
|
506
|
+
? answer.degraded?.find((d) => d.supplier === asked.filters?.supplier && d.why === 'needs-place')
|
|
507
|
+
: undefined;
|
|
508
|
+
const placeFirst = unplacedGroup
|
|
509
|
+
? {
|
|
510
|
+
supplier: unplacedGroup.supplier,
|
|
511
|
+
name: unplacedGroup.name,
|
|
512
|
+
...(unplacedGroup.names ? { names: unplacedGroup.names } : {}),
|
|
513
|
+
places: (unplacedGroup.places ?? []).map((p) => ({
|
|
514
|
+
name: p.name,
|
|
515
|
+
...(p.names ? { names: p.names } : {}),
|
|
516
|
+
})),
|
|
517
|
+
}
|
|
518
|
+
: undefined;
|
|
519
|
+
const unread = !emptyOfItself && !placeFirst && !!degraded.structured.degraded;
|
|
520
|
+
const why = pastTheEnd
|
|
521
|
+
? `That page is past the end: ${answer.total} match, so \`offset\` 0 to ${answer.total - 1} is where they are.`
|
|
522
|
+
: filteredEmpty
|
|
523
|
+
? emptiedBy(asked.filters ?? {}, answer.beforeFilters ?? 0, deps.vocab.nounPlural)
|
|
524
|
+
: ceilingEmpty && nearest.length
|
|
525
|
+
? `Nothing under ${cap} a night. The cheapest that matched is ${first?.name} at ${cheapest ? formatMoney(cheapest) : '-'}${answer.overBudget && answer.overBudget > 1 ? `, of ${answer.overBudget} over the ceiling` : ''}.`
|
|
526
|
+
: ceilingEmpty
|
|
527
|
+
? `None of the ${answer.beforeCeiling} that match has a room for those nights.`
|
|
528
|
+
: placeFirst
|
|
529
|
+
? `${withZh(placeFirst.name, placeFirst.names, ctx?.noCards)}'s ${deps.vocab.nounPlural} are looked up by country or city, and none was named.`
|
|
530
|
+
: unread
|
|
531
|
+
? `No ${branded(deps.vocab, deps.vocab.nounPlural)} could be read this time.`
|
|
532
|
+
: [
|
|
533
|
+
`No ${branded(deps.vocab, deps.vocab.nounPlural)} match that.`,
|
|
534
|
+
// What was tried and also failed is worth a sentence: it tells a
|
|
535
|
+
// guest the word itself is the problem, not the narrowing.
|
|
536
|
+
widened ? `${sentence(widened.to)} found nothing either.` : '',
|
|
537
|
+
]
|
|
538
|
+
.filter(Boolean)
|
|
539
|
+
.join(' ');
|
|
540
|
+
return {
|
|
541
|
+
structured: {
|
|
542
|
+
view: 'no-hotels',
|
|
543
|
+
...common(deps, key),
|
|
544
|
+
hotels: [],
|
|
545
|
+
total: 0,
|
|
546
|
+
query,
|
|
547
|
+
...(nearest.length ? { nearest, overBudget: answer.overBudget } : {}),
|
|
548
|
+
...(ask.stay ? { stay: ask.stay } : {}),
|
|
549
|
+
...(widened?.found ? { widened } : {}),
|
|
550
|
+
// Nothing found while a group did not answer is not "none here".
|
|
551
|
+
...degraded.structured,
|
|
552
|
+
// Nothing read at all: the card says so, with 「重试」, not "try another city" (U4).
|
|
553
|
+
...(unread ? { unread: true } : {}),
|
|
554
|
+
// The group to choose a place for, and the cities it is known to be in (0.74.6).
|
|
555
|
+
...(placeFirst ? { placeFirst } : {}),
|
|
556
|
+
...(answer.unapplied?.length ? { unapplied: answer.unapplied } : {}),
|
|
557
|
+
// Why it is empty, in the words the model is told, so the card says
|
|
558
|
+
// the same thing rather than guessing at it.
|
|
559
|
+
why,
|
|
560
|
+
// The way back out of a filter that emptied it: the same search -
|
|
561
|
+
// its order, its ceiling and its nights too - with the chips to take
|
|
562
|
+
// one off. Taking one off dropped the sort and the ceiling.
|
|
563
|
+
...(filteredEmpty
|
|
564
|
+
? {
|
|
565
|
+
ask: echo(sort),
|
|
566
|
+
...(answer.refine ? { refine: refineFor(answer.refine, asked.filters, 0) } : {}),
|
|
567
|
+
beforeFilters: answer.beforeFilters,
|
|
568
|
+
}
|
|
569
|
+
: // A market's group asked for and with no hotel here (11-05): the card says
|
|
570
|
+
// which group, and does not send the guest off to "try a city". And
|
|
571
|
+
// nothing read at all (U4): the same search, for the card to ask again
|
|
572
|
+
// and to say where it looked.
|
|
573
|
+
asked.filters?.supplier || unread
|
|
574
|
+
? { ask: echo(sort) }
|
|
575
|
+
: {}),
|
|
576
|
+
},
|
|
577
|
+
text: [
|
|
578
|
+
widened?.found ? `Nothing matched ${widened.from}, so this looked in ${widened.to}.` : '',
|
|
579
|
+
why,
|
|
580
|
+
degraded.said,
|
|
581
|
+
...(answer.unapplied ?? []),
|
|
582
|
+
]
|
|
583
|
+
.filter(Boolean)
|
|
584
|
+
.join(' '),
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
// ⚠️ THE CHEAPEST, SAID BY US - the card never compares two prices it was
|
|
588
|
+
// handed as text. Only on named nights, in one currency, with two or more
|
|
589
|
+
// priced to compare; every hotel that ties is marked (总线程, 2026-10-12).
|
|
590
|
+
// A room by the hour is priced for its own hours, and is not in the race.
|
|
591
|
+
const stays = hotels.filter((h) => h.forStay && !h.forStay.hours);
|
|
592
|
+
const lowest = stays.length >= 2 && new Set(stays.map((h) => h.forStay?.total.currency)).size === 1
|
|
593
|
+
? Math.min(...stays.map((h) => h.forStay?.total.minor ?? Number.POSITIVE_INFINITY))
|
|
594
|
+
: undefined;
|
|
595
|
+
const forCard = hotels.map((h) => ({
|
|
596
|
+
...h,
|
|
597
|
+
...(lowest !== undefined && h.forStay && !h.forStay.hours && h.forStay.total.minor === lowest
|
|
598
|
+
? { lowest: true }
|
|
599
|
+
: {}),
|
|
600
|
+
summary: hotelText('description', h.name, h.summary, DESCRIPTION_MAX).text,
|
|
601
|
+
fromNightly: h.fromNightly ? formatMoney(h.fromNightly) : undefined,
|
|
602
|
+
...(h.forStay
|
|
603
|
+
? {
|
|
604
|
+
forStay: {
|
|
605
|
+
...h.forStay,
|
|
606
|
+
total: formatMoney(h.forStay.total),
|
|
607
|
+
nightly: formatMoney(h.forStay.nightly),
|
|
608
|
+
},
|
|
609
|
+
}
|
|
610
|
+
: {}),
|
|
611
|
+
}));
|
|
612
|
+
// The whole shortlist, never one pick: a city is not a hotel.
|
|
613
|
+
const where = cities.length === 1 ? ` in ${cities[0]}` : '';
|
|
614
|
+
// ⚠️ A PRICE KNOB ACROSS CURRENCIES IS DROPPED, AND SAYING SO IS THE WHOLE
|
|
615
|
+
// POINT. Applied silently it would be an exchange rate we picked; dropped
|
|
616
|
+
// silently it would be a list the guest reads as ordered by price when it
|
|
617
|
+
// is not. The currencies are named, because that is what tells a guest
|
|
618
|
+
// which narrowing would make the question answerable.
|
|
619
|
+
const oneCurrency = answer.currencies.length === 1;
|
|
620
|
+
const wantedPrice = sort === 'price-low' || sort === 'price-high';
|
|
621
|
+
// …UNLESS THE BACKEND ORDERS THEM BY ONE CURRENCY THEY ARE ALL WORTH (0.68.0, robin
|
|
622
|
+
// 11-12 - Otaless, by the US dollars it settles in): then the order is applied and
|
|
623
|
+
// said as what it is by; the prices are still each hotel's own.
|
|
624
|
+
const inUsd = !oneCurrency && answer.priceOrderIn === 'USD';
|
|
625
|
+
const applied = (wantedPrice && !oneCurrency && !inUsd) || answer.ignored?.sort ? 'group' : sort;
|
|
626
|
+
// Room terms the backend could not apply are not "filtered to".
|
|
627
|
+
const filtersSaid = asked.filters && answer.ignored?.roomTerms
|
|
628
|
+
? { ...asked.filters, freeCancellation: undefined, breakfast: undefined, bed: undefined }
|
|
629
|
+
: asked.filters;
|
|
630
|
+
// ⚠️ IN BOTH (0.69.1, 总线程 11-12 on claude.ai): dated, and only from-prices back -
|
|
631
|
+
// the sentence was in the text alone, and a host that hands its model the
|
|
632
|
+
// structure (claude.ai) had `fromPricesOnly: true` and no word of what it means.
|
|
633
|
+
// `fromPricesSaid` is the same sentence.
|
|
634
|
+
// ⚠️ A HOTEL NOT PRICED FOR THE NIGHTS SAYS SO, BY NAME (0.76.1, 总线程 11-18 - Otaless prices a
|
|
635
|
+
// dated list's page; the review of 11-18, H1: a from-price beside stays' totals, the same size,
|
|
636
|
+
// read as one): what it shows is its from-price a night. In both, in the same words.
|
|
637
|
+
const stayPriced = hotels.some((h) => h.forStay);
|
|
638
|
+
const unpriced = ask.stay ? hotels.filter((h) => h.stayUnpriced) : [];
|
|
639
|
+
const unpricedSaid = unpriced.length && !fromPricesOnly
|
|
640
|
+
? `${unpriced.length === 1 ? 'One' : unpriced.length} of these could not be priced for those nights just now: ${unpriced
|
|
641
|
+
.map((h) => hotelName(h.name))
|
|
642
|
+
.join('; ')}. ${unpriced.length === 1 ? 'Its price is its' : 'Their prices are their'} from-price a night, not a total for those nights - say so, and do not quote ${unpriced.length === 1 ? 'it' : 'them'} as one; ${unpriced.length === 1 ? 'its' : "each one's"} own page prices it for the nights.`
|
|
643
|
+
: '';
|
|
644
|
+
const fromOnlySaid = ask.stay && fromPricesOnly
|
|
645
|
+
? `No price for ${ctx.noCards
|
|
646
|
+
? `${stayDayWords(ask.stay.checkIn, ask.stay.checkOut)} - ${ask.stay.checkIn} to ${ask.stay.checkOut} (open your reply with those nights in one sentence, by weekday and date) -`
|
|
647
|
+
: `${ask.stay.checkIn} to ${ask.stay.checkOut}`} is available here: each price is the ${deps.vocab.noun}'s from-price a night, not a total for the stay. Say so; do not quote a stay total.`
|
|
648
|
+
: '';
|
|
649
|
+
const priceNotes = [
|
|
650
|
+
// What the backend was asked and did not do, in its own words.
|
|
651
|
+
...(answer.unapplied ?? []),
|
|
652
|
+
wantedPrice && !oneCurrency
|
|
653
|
+
? inUsd
|
|
654
|
+
? `In price order, ${sort === 'price-low' ? 'lowest' : 'highest'} first, by each ${deps.vocab.noun}'s price in US dollars as the hotel groups give it. The prices here are each ${deps.vocab.noun}'s own, in ${answer.currencies.join(', ')}: quote them as they are, never converted.`
|
|
655
|
+
: `These are quoted in ${answer.currencies.length} currencies (${answer.currencies.join(', ')}), and no rate is applied here, so they are not in price order — one city or one country gives one currency.`
|
|
656
|
+
: // How a client with no card puts them in price order: it has no Sort to press.
|
|
657
|
+
inUsd && ctx?.noCards && hotels.length > 1
|
|
658
|
+
? `These are quoted in ${answer.currencies.join(', ')}; asked again with \`sort: "price-low"\` or \`"price-high"\` they are put in price order by each ${deps.vocab.noun}'s price in US dollars, the prices still shown in their own currencies.`
|
|
659
|
+
: '',
|
|
660
|
+
ceiling !== undefined && !oneCurrency
|
|
661
|
+
? inUsd
|
|
662
|
+
? 'The price ceiling is not applied: it is only applied within one currency.'
|
|
663
|
+
: 'The price ceiling is not applied for the same reason.'
|
|
664
|
+
: '',
|
|
665
|
+
answer.overBudget && hotels.length
|
|
666
|
+
? `${answer.overBudget} more matched and came in over the ceiling.`
|
|
667
|
+
: '',
|
|
668
|
+
filtersSaid && filterWords(filtersSaid) ? `Filtered to ${filterWords(filtersSaid)}.` : '',
|
|
669
|
+
// ⚠️ THE SAME ROOMS ON THE HOTEL OPENED FROM IT (0.55.7, 总线程 11-05): a list with
|
|
670
|
+
// free cancellation on priced each hotel at its cheapest free-to-cancel room, and
|
|
671
|
+
// the hotel asked without it opened at a cheaper one that cannot be cancelled. The
|
|
672
|
+
// card's own press carries them; the model is told to, as one line.
|
|
673
|
+
filtersSaid && (filtersSaid.freeCancellation || filtersSaid.breakfast || filtersSaid.bed)
|
|
674
|
+
? `To open one of these, pass ${[
|
|
675
|
+
filtersSaid.freeCancellation ? '`freeCancellation`' : '',
|
|
676
|
+
filtersSaid.breakfast ? '`breakfast`' : '',
|
|
677
|
+
filtersSaid.bed ? `\`bed: "${filtersSaid.bed}"\`` : '',
|
|
678
|
+
]
|
|
679
|
+
.filter(Boolean)
|
|
680
|
+
.join(' and ')} to ${deps.tools.getHotel} too, so its rooms are priced as here.`
|
|
681
|
+
: '',
|
|
682
|
+
// What the prices on a dated list are, in one line - and how many cannot
|
|
683
|
+
// be had at all, so a sold-out hotel is not described as a choice.
|
|
684
|
+
ask.filters?.hourly && hotels.some((h) => h.forStay?.hours)
|
|
685
|
+
? `By the hour, today: each price is that ${deps.vocab.noun}'s cheapest room by the hour, for its hours, taxes included.`
|
|
686
|
+
: fromOnlySaid
|
|
687
|
+
? fromOnlySaid
|
|
688
|
+
: ask.stay
|
|
689
|
+
? `${
|
|
690
|
+
// Nothing priced for the stay here is not "priced for" it (0.76.1).
|
|
691
|
+
stayPriced || !unpriced.length ? 'Priced for' : 'Asked for'} ${
|
|
692
|
+
// ⚠️ THE NIGHTS BY THEIR WEEKDAYS, SAID FIRST (总线程 11-09, Manus: a
|
|
693
|
+
// list for 「这周末」 came back and the reply never said which nights).
|
|
694
|
+
ctx.noCards
|
|
695
|
+
? `${stayDayWords(ask.stay.checkIn, ask.stay.checkOut)} - ${ask.stay.checkIn} to ${ask.stay.checkOut}, ${ask.stay.guests} ${ask.stay.guests === 1 ? 'guest' : 'guests'} (open your reply with those nights in one sentence, by weekday and date)`
|
|
696
|
+
: `${ask.stay.checkIn} to ${ask.stay.checkOut}`}${ask.rooms && ask.rooms > 1 ? `, ${ask.rooms} rooms` : ''}: ${[
|
|
697
|
+
stayPriced || !unpriced.length
|
|
698
|
+
? `each price is that ${deps.vocab.noun}'s cheapest room for the whole stay, taxes included`
|
|
699
|
+
: '',
|
|
700
|
+
hotels.some((h) => h.noRoomsForStay && !NOT_NO_ROOM.has(h.noRoomsForStayCode ?? ''))
|
|
701
|
+
? `${hotels.filter((h) => h.noRoomsForStay && !NOT_NO_ROOM.has(h.noRoomsForStayCode ?? '')).length} in this answer ${hotels.filter((h) => h.noRoomsForStay && !NOT_NO_ROOM.has(h.noRoomsForStayCode ?? '')).length === 1 ? 'has' : 'have'} no room for those nights`
|
|
702
|
+
: '',
|
|
703
|
+
// The other kind, said as its own (U11): other nights will not help.
|
|
704
|
+
hotels.some((h) => h.noRoomsForStayCode === 'none-on-sale')
|
|
705
|
+
? `${hotels.filter((h) => h.noRoomsForStayCode === 'none-on-sale').length} in this answer ${hotels.filter((h) => h.noRoomsForStayCode === 'none-on-sale').length === 1 ? 'has' : 'have'} no rooms on sale here - ${NOT_SOLD_OUT}`
|
|
706
|
+
: '',
|
|
707
|
+
// ⚠️ AND A GROUP THAT DID NOT ANSWER IS NOT "NO ROOM" (总线程 11-13): the
|
|
708
|
+
// hotel's prices could not be read this time - its own page asks again.
|
|
709
|
+
hotels.some((h) => h.noRoomsForStay && h.noRoomsForStayCode === 'unreachable')
|
|
710
|
+
? `${hotels.filter((h) => h.noRoomsForStay && h.noRoomsForStayCode === 'unreachable').length} in this answer could not be priced just now - ${hotels.filter((h) => h.noRoomsForStay && h.noRoomsForStayCode === 'unreachable').length === 1 ? 'its group did not answer, which does not mean it has' : 'their group did not answer, which does not mean they have'} no room`
|
|
711
|
+
: '',
|
|
712
|
+
// Each of the other whys by itself, never as no room (review of 0.71.0, P3 4).
|
|
713
|
+
...Object.entries(OWN_WHY).map(([code, w]) => {
|
|
714
|
+
const n = hotels.filter((h) => h.noRoomsForStay && h.noRoomsForStayCode === code).length;
|
|
715
|
+
return n ? w.many(n) : '';
|
|
716
|
+
}),
|
|
717
|
+
]
|
|
718
|
+
.filter(Boolean)
|
|
719
|
+
.join('; ')}.`
|
|
720
|
+
: '',
|
|
721
|
+
unpricedSaid,
|
|
722
|
+
].filter(Boolean);
|
|
723
|
+
// A price on the list that is not booked here (`notSoldHere`): said as on
|
|
724
|
+
// the hotel's page, in both - see `notSoldHereWords`. ⚠️ NOT FIRST ANY MORE (0.75.1,
|
|
725
|
+
// robin 11-18): 0.58.2 had a list whose every price was one say so before the list
|
|
726
|
+
// (总线程 11-09, Manus: 「选最便宜那个」 met "it cannot be booked here" and nothing more);
|
|
727
|
+
// now it is said when the guest wants one, with the ways on - as on the hotel's page.
|
|
728
|
+
// …and a price paid in advance that IS booked here, without payment (0.77.5).
|
|
729
|
+
const unpaidOn = hotels.find((h) => h.forStay?.paymentNotConnected);
|
|
730
|
+
// …and, where the deployment books some hotels so and one of them is listed, that
|
|
731
|
+
// one sentence whether or not a priced rate is among its rows (0.77.6): the first thing
|
|
732
|
+
// a model read said "paid at the hotel" of the whole connector.
|
|
733
|
+
const unpaidListed = (deps.backend.capabilities ?? FULL_CAPABILITIES).unpaidBooking?.hotels.filter((u) => hotels.some((h) => h.id === u.id));
|
|
734
|
+
const unpaidHere = [
|
|
735
|
+
unpaidListed?.length
|
|
736
|
+
? unpaidBookingNote(groupNameOf(deps, unpaidListed[0]?.id ?? ''), unpaidListed)
|
|
737
|
+
: '',
|
|
738
|
+
unpaidOn ? unpaidBookingWords(groupNameOf(deps, unpaidOn.id)) : '',
|
|
739
|
+
]
|
|
740
|
+
.filter(Boolean)
|
|
741
|
+
.join(' ');
|
|
742
|
+
const notSoldOn = hotels.find((h) => h.forStay?.notSoldHere);
|
|
743
|
+
const notSold = notSoldOn ? notSoldHereWords(groupNameOf(deps, notSoldOn.id), !!unpaidOn) : '';
|
|
744
|
+
// To a client that draws no card, the hotels as numbered lines - numbered
|
|
745
|
+
// across pages, so "the 23rd" on the second page is still one hotel. In the
|
|
746
|
+
// text and, word for word, in the structure (`hotelChoices`).
|
|
747
|
+
const notBookable = notBookableOf(deps);
|
|
748
|
+
const listed = ctx.noCards && hotels.length
|
|
749
|
+
? hotelChoicesBlock(hotels, offset, (h) => {
|
|
750
|
+
const id = deps.backend.supplierOf?.(h.id);
|
|
751
|
+
return id ? deps.backend.suppliers?.().find((g) => g.id === id) : undefined;
|
|
752
|
+
}, groupNameOf(deps, (notSoldOn ?? hotels[0]).id), !!notBookable)
|
|
753
|
+
: undefined;
|
|
754
|
+
const hotelChoices = listed
|
|
755
|
+
? [
|
|
756
|
+
...(listed.said ? [listed.said, ''] : []),
|
|
757
|
+
listed.blocks.join('\n\n'),
|
|
758
|
+
'',
|
|
759
|
+
idsByNumber('Hotel', hotels.map((h) => h.id), offset + 1, listed.notes),
|
|
760
|
+
].join('\n')
|
|
761
|
+
: '';
|
|
762
|
+
// …and, asked without dates, what its prices are - first of the notes.
|
|
763
|
+
const fromPrices = ctx.noCards && hotels.length && !ask.stay && !ask.filters?.hourly
|
|
764
|
+
? fromPricesWords(today?.min ?? todayOfHotel(hotels[0], deps.trips.now()))
|
|
765
|
+
: '';
|
|
766
|
+
if (fromPrices)
|
|
767
|
+
priceNotes.unshift(fromPrices);
|
|
768
|
+
// ⚠️ 「这周末」 WORKED OUT AS SATURDAY NIGHT (总线程 11-09) is said first, in
|
|
769
|
+
// both - see `weekendOf`.
|
|
770
|
+
const weekendFor = ask.stay && !ask.filters?.hourly && hotels.length
|
|
771
|
+
? weekendOf(ask.stay.checkIn, ask.stay.checkOut, today?.min ?? todayOfHotel(hotels[0], deps.trips.now()))
|
|
772
|
+
: null;
|
|
773
|
+
const weekend = weekendFor ? weekendWords(weekendFor) : '';
|
|
774
|
+
if (weekend)
|
|
775
|
+
priceNotes.unshift(weekend);
|
|
776
|
+
// Every one by name and city, and that there are no others - or, told
|
|
777
|
+
// only "2 hotels", the model asked for the list again to learn which.
|
|
778
|
+
// Hotels to show: a group that did not answer is a greyed chip, said only if asked (0.74.4).
|
|
779
|
+
const degraded = degradedOf(deps, answer, undefined, ctx?.noCards, undefined, quietIn(deps, asked.filters?.supplier), true);
|
|
780
|
+
const unplaced = unplacedOf(deps, answer, !!asked.city);
|
|
781
|
+
const inAll = homeList
|
|
782
|
+
? `This answer lists every one of the ${branded(deps.vocab, deps.vocab.nounPlural)} here: ${hotels
|
|
783
|
+
.map((h) => `${hotelName(h.name)}${h.city ? ` in ${h.city}` : ''}`)
|
|
784
|
+
.join('; ')}. There is no other ${deps.vocab.noun} and no other city here - nothing else to list, search for or offer.`
|
|
785
|
+
: '';
|
|
786
|
+
// ⚠️ EVERY LIST HAS A CITY FIELD (robin, 2026-10-30: 「亚朵上面的筛选有城市选择,
|
|
787
|
+
// 华住的没有掉了」), AND IT IS THE SAME FIELD EVERYWHERE (robin, 2026-10-30, 0.51.4:
|
|
788
|
+
// 「华住和亚朵这个all,逻辑不一样」). The card's field is a menu of the
|
|
789
|
+
// deployment's cities - a group of two as a group of ninety-six; it went to
|
|
790
|
+
// the destinations page where there were more than six. A list narrowed to
|
|
791
|
+
// one still names the others. Counted across the whole deployment: the
|
|
792
|
+
// unnarrowed answer's own, or the catalogue asked once more with nothing (no
|
|
793
|
+
// nights, so nothing is priced). Names and counts only, never a hotel - and
|
|
794
|
+
// for the card only: the server puts it beside the answer (`CITIES_META_KEY`).
|
|
795
|
+
// ⚠️ A MARKET'S TOO (0.68.0, robin 11-12): with none, its 「全部 ▾」 went to the
|
|
796
|
+
// destinations page - 「全部」 answered with the home. Asked beside the search
|
|
797
|
+
// (`marketCities`); one that fails leaves the field going to the destinations page,
|
|
798
|
+
// as before, and the list is answered all the same.
|
|
799
|
+
// ⚠️ A HOTEL'S PHONE, OPENING YEAR AND ROOM COUNT ARE NOT IN A LIST (0.77.3, Manus 11-19 went to
|
|
800
|
+
// Ctrip for them): they come with that hotel's own answer - said once, where the group has them.
|
|
801
|
+
const factsNote = deps.backend.capabilities?.hotelFacts && hotels.length
|
|
802
|
+
? `A hotel's phone number, the year it opened and its room count come with that hotel's own answer (\`${t.getHotel}\`): ask for that hotel, never the web.`
|
|
803
|
+
: '';
|
|
804
|
+
const allCities = unnarrowed
|
|
805
|
+
? (answer.facets?.cities ?? [])
|
|
806
|
+
: marketCities
|
|
807
|
+
? await marketCities
|
|
808
|
+
: ((await deps.backend.searchHotels({}, who)).facets?.cities ?? []);
|
|
809
|
+
return {
|
|
810
|
+
structured: {
|
|
811
|
+
view: 'hotels',
|
|
812
|
+
...common(deps, key),
|
|
813
|
+
// The home, as a list - see `homeList`. The same sentence as the text.
|
|
814
|
+
...(homeList ? { home: true, inAll } : {}),
|
|
815
|
+
...(allCities.length
|
|
816
|
+
? {
|
|
817
|
+
allCities: allCities.map((c) => ({
|
|
818
|
+
name: c.name,
|
|
819
|
+
count: c.count,
|
|
820
|
+
...(c.names ? { names: c.names } : {}),
|
|
821
|
+
})),
|
|
822
|
+
}
|
|
823
|
+
: {}),
|
|
824
|
+
hotels: forCard,
|
|
825
|
+
total,
|
|
826
|
+
shown: hotels.length,
|
|
827
|
+
offset,
|
|
828
|
+
cities,
|
|
829
|
+
query,
|
|
830
|
+
sort: applied,
|
|
831
|
+
// The search as asked, so "show more" is this search's next page and
|
|
832
|
+
// not a new one - and a place chip keeps the order the guest chose.
|
|
833
|
+
ask: echo(applied),
|
|
834
|
+
...(ask.stay ? { stay: ask.stay } : {}),
|
|
835
|
+
...(weekend ? { weekend } : {}),
|
|
836
|
+
...(fromPricesOnly ? { fromPricesOnly: true } : {}),
|
|
837
|
+
...(fromOnlySaid ? { fromPricesSaid: fromOnlySaid } : {}),
|
|
838
|
+
// The hotels not priced for the nights, by name - the same sentence as the text (0.76.1).
|
|
839
|
+
...(unpricedSaid ? { stayUnpricedSaid: unpricedSaid } : {}),
|
|
840
|
+
...(answer.refine
|
|
841
|
+
? { refine: refineFor(answer.refine, asked.filters, total, !!ask.stay) }
|
|
842
|
+
: {}),
|
|
843
|
+
...(places.length ? { places } : {}),
|
|
844
|
+
...(answer.overBudget ? { overBudget: answer.overBudget } : {}),
|
|
845
|
+
...(widened?.found ? { widened } : {}),
|
|
846
|
+
...(answer.currencies.length > 1 ? { currencies: answer.currencies } : {}),
|
|
847
|
+
// A price order across them is by US dollars here (0.68.0) - the card offers it and says so.
|
|
848
|
+
...(inUsd ? { priceOrderIn: 'USD' } : {}),
|
|
849
|
+
// A group that did not answer, in both: the card draws a line from it.
|
|
850
|
+
...degraded.structured,
|
|
851
|
+
// A place not recognised, in both: the card heads the list without it.
|
|
852
|
+
...unplaced.structured,
|
|
853
|
+
// In both, like a plan's: a host with no card may hand its model this
|
|
854
|
+
// rather than the text.
|
|
855
|
+
...(ctx.noCards ? { notDrawn: LIST_NOT_DRAWN } : {}),
|
|
856
|
+
...(hotelChoices ? { hotelChoices } : {}),
|
|
857
|
+
...(factsNote ? { hotelFactsNote: factsNote } : {}),
|
|
858
|
+
...(fromPrices ? { stayDefault: fromPrices } : {}),
|
|
859
|
+
...(ctx.drawsCards && hotels.length ? { cardShows: ON_CARD.hotels } : {}),
|
|
860
|
+
...(unpaidHere ? { bookedWithoutPayment: unpaidHere } : {}),
|
|
861
|
+
...(notSold ? { notSoldHere: notSold } : {}),
|
|
862
|
+
...(notBookable ? { notBookable } : {}),
|
|
863
|
+
},
|
|
864
|
+
text: [
|
|
865
|
+
inAll ||
|
|
866
|
+
`${total} ${branded(deps.vocab, total === 1 ? deps.vocab.noun : deps.vocab.nounPlural)}${where}.`,
|
|
867
|
+
unplaced.said,
|
|
868
|
+
// ⚠️ NO "BELOW", NO "TAP". This sentence is read out by a voice
|
|
869
|
+
// assistant as often as it is drawn next to a card, and a guest whose
|
|
870
|
+
// host has no card at all cannot tap the one it tells them to tap. The
|
|
871
|
+
// count and the name of the next step say the same thing everywhere.
|
|
872
|
+
more > 0
|
|
873
|
+
? `— ${offset ? `${offset + 1} to ${offset + hotels.length}` : hotels.length} in this answer and ${more} more. A city, a country or a filter narrows it; \`offset\` ${offset + hotels.length} is the next page.`
|
|
874
|
+
: '',
|
|
875
|
+
notBookable,
|
|
876
|
+
...priceNotes,
|
|
877
|
+
widened?.found ? `Nothing matched ${widened.from}, so this is ${widened.to}.` : '',
|
|
878
|
+
degraded.said,
|
|
879
|
+
hotelChoices ? `\n${LIST_NOT_DRAWN}\n${hotelChoices}\n` : '',
|
|
880
|
+
// After the hotels, never before them: for when the guest wants one (0.75.1).
|
|
881
|
+
unpaidHere,
|
|
882
|
+
notSold,
|
|
883
|
+
factsNote,
|
|
884
|
+
ctx.drawsCards && hotels.length ? ON_CARD.hotels : '',
|
|
885
|
+
forPlans,
|
|
886
|
+
]
|
|
887
|
+
.filter(Boolean)
|
|
888
|
+
.join(' '),
|
|
889
|
+
};
|
|
890
|
+
};
|
|
891
|
+
//# sourceMappingURL=list-hotels.js.map
|