@curless/hotel-storefront 0.58.2 → 0.60.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/account/fake-mall.d.ts +19 -0
- package/dist/account/fake-mall.d.ts.map +1 -1
- package/dist/account/fake-mall.js +81 -10
- package/dist/account/fake-mall.js.map +1 -1
- package/dist/account/index.d.ts +75 -3
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +765 -31
- package/dist/account/index.js.map +1 -1
- package/dist/account/mall.d.ts +3 -1
- package/dist/account/mall.d.ts.map +1 -1
- package/dist/account/mall.js +17 -2
- package/dist/account/mall.js.map +1 -1
- package/dist/account/ota-member.d.ts +72 -0
- package/dist/account/ota-member.d.ts.map +1 -0
- package/dist/account/ota-member.js +127 -0
- package/dist/account/ota-member.js.map +1 -0
- package/dist/account/pages.d.ts +99 -4
- package/dist/account/pages.d.ts.map +1 -1
- package/dist/account/pages.js +221 -16
- package/dist/account/pages.js.map +1 -1
- package/dist/account/requests.d.ts +13 -1
- package/dist/account/requests.d.ts.map +1 -1
- package/dist/account/requests.js +2 -1
- package/dist/account/requests.js.map +1 -1
- package/dist/account/store.d.ts +8 -0
- package/dist/account/store.d.ts.map +1 -1
- package/dist/account/store.js.map +1 -1
- package/dist/aggregate/places.d.ts +10 -0
- package/dist/aggregate/places.d.ts.map +1 -1
- package/dist/aggregate/places.js +21 -0
- package/dist/aggregate/places.js.map +1 -1
- package/dist/card.generated.d.ts +1 -1
- package/dist/card.generated.js +2 -2
- package/dist/card.generated.js.map +1 -1
- package/dist/choices.d.ts +88 -0
- package/dist/choices.d.ts.map +1 -0
- package/dist/choices.js +126 -0
- package/dist/choices.js.map +1 -0
- package/dist/otaless/backend.d.ts +28 -0
- package/dist/otaless/backend.d.ts.map +1 -1
- package/dist/otaless/backend.js +349 -93
- package/dist/otaless/backend.js.map +1 -1
- package/dist/otaless/client.d.ts +46 -4
- package/dist/otaless/client.d.ts.map +1 -1
- package/dist/otaless/client.js +138 -35
- package/dist/otaless/client.js.map +1 -1
- package/dist/otaless/limits.d.ts +58 -0
- package/dist/otaless/limits.d.ts.map +1 -0
- package/dist/otaless/limits.js +132 -0
- package/dist/otaless/limits.js.map +1 -0
- package/dist/otaless/make.d.ts.map +1 -1
- package/dist/otaless/make.js +14 -1
- package/dist/otaless/make.js.map +1 -1
- package/dist/otaless/places.d.ts +40 -4
- package/dist/otaless/places.d.ts.map +1 -1
- package/dist/otaless/places.js +152 -2
- package/dist/otaless/places.js.map +1 -1
- package/dist/present.d.ts +12 -1
- package/dist/present.d.ts.map +1 -1
- package/dist/present.js +27 -1
- package/dist/present.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +53 -35
- package/dist/server.js.map +1 -1
- package/dist/sessions.d.ts +23 -4
- package/dist/sessions.d.ts.map +1 -1
- package/dist/sessions.js +57 -7
- package/dist/sessions.js.map +1 -1
- package/dist/supplier.d.ts +6 -0
- package/dist/supplier.d.ts.map +1 -1
- package/dist/supplier.js.map +1 -1
- package/dist/surface.js +1 -1
- package/dist/surface.js.map +1 -1
- package/dist/tools.d.ts +11 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +424 -169
- package/dist/tools.js.map +1 -1
- package/dist/trip-ids.d.ts +35 -4
- package/dist/trip-ids.d.ts.map +1 -1
- package/dist/trip-ids.js +87 -19
- package/dist/trip-ids.js.map +1 -1
- package/dist/types.d.ts +35 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/tools.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { aboutLines } from './about.js';
|
|
2
2
|
import { DEFAULT_PAGE, FULL_CAPABILITIES, LASTING_REQUESTS, MAX_PAGE, REQUEST_KINDS, REQUEST_NOTE_MAX, guestTooLong, notPricedForNoAnswer, unansweredBy, unitWords, } from './backend.js';
|
|
3
|
+
import { PAY_WORDS, allOrEach, choiceBlock, payOf, paymentOf, saysOwn, sentenceOf, setsApart, sharedBy, spreadOf, } from './choices.js';
|
|
3
4
|
import { usedOnWords } from './coupon-words.js';
|
|
4
5
|
import { MAX_GUESTS, addDays, dateOptions, dayWords, isDay, nights as nightsBetween, stayDayWords, toDay, weekendOf, weekendWords, } from './dates.js';
|
|
5
6
|
import { FACILITIES } from './facilities.js';
|
|
@@ -8,7 +9,7 @@ import { clockOf, minutesOf, startProblem, stayWords, windowWords } from './hour
|
|
|
8
9
|
import { amountsIn, formatMoney, keepingAmounts, money, multiplyMoney, toMinor } from './money.js';
|
|
9
10
|
import { namedExactly, roomNamesOf, roomTypeNamed, withTraditional } from './names.js';
|
|
10
11
|
import { overlapsOf } from './overlap.js';
|
|
11
|
-
import { MAX_COMPARED, MAX_CONS, MAX_DAYS, MAX_ITEMS_PER_DAY, MAX_MOMENTS, MAX_PROS, buildItinerary, candidatesFor, compareHotels, namesMoreThanOne, } from './present.js';
|
|
12
|
+
import { MAX_COMPARED, MAX_CONS, MAX_DAYS, MAX_ITEMS_PER_DAY, MAX_MOMENTS, MAX_PROS, buildItinerary, candidatesFor, compareHotels, namesMoreThanOne, nightlyIncludesTaxes, } from './present.js';
|
|
12
13
|
import { withReference } from './reference.js';
|
|
13
14
|
import { regionOf } from './regions.js';
|
|
14
15
|
import { FAMILY_SLEEPS, activeKeysOf, byRoomType, facetsOf, keyWords, matchesTerms, optionsOf, roomTermsOf, termWords, } from './room-filters.js';
|
|
@@ -168,6 +169,16 @@ export const withheldTools = (n, caps) => new Set([
|
|
|
168
169
|
* answer that would otherwise say how to book.
|
|
169
170
|
*/
|
|
170
171
|
export const readOnlyWords = (v) => `Nothing can be booked through ${v.brand} yet: it shows ${v.noun}s, rooms and prices only. When the guest wants to book, say so plainly - nothing is booked or held - and suggest booking with the ${v.noun}'s own group directly, on its website or app, with the ${v.noun}, room and dates from here.`;
|
|
172
|
+
/**
|
|
173
|
+
* Said with every price where nothing can be booked yet (`capabilities.readOnly`;
|
|
174
|
+
* 总线程 11-09, Manus on Otaless after 0.59.0): asked for a hotel's rooms after a
|
|
175
|
+
* comparison, the model answered from the comparison - which said nothing of
|
|
176
|
+
* it - and called them "两种可订房型", with nowhere to book. On a list, a hotel's
|
|
177
|
+
* page, a comparison and a plan, in the text and, word for word, in the
|
|
178
|
+
* structure (`notBookable`); what `readOnlyWords` tells it to do when the guest
|
|
179
|
+
* asks to book, in one sentence.
|
|
180
|
+
*/
|
|
181
|
+
export const notBookableWords = (v) => `Nothing can be booked through ${v.brand} yet: never call a ${v.noun}, room or rate here bookable (可订) - to book, the guest uses the ${v.noun}'s own group, on its website or app, with the ${v.noun}, room and dates from here.`;
|
|
171
182
|
const forCapabilities = (tools, n, v, caps) => {
|
|
172
183
|
const withheld = withheldTools(n, caps);
|
|
173
184
|
const without = (schema, ...keys) => {
|
|
@@ -181,6 +192,14 @@ const forCapabilities = (tools, n, v, caps) => {
|
|
|
181
192
|
.filter((t) => !withheld.has(t.name))
|
|
182
193
|
.map((t) => {
|
|
183
194
|
let out = t;
|
|
195
|
+
// ⚠️ NOTHING TO BOOK, SO NO "TO BOOK" (2026-11-09 audit, T3): a read-only
|
|
196
|
+
// deployment's list is for looking through and picking one.
|
|
197
|
+
if (caps.readOnly && t.name === n.listHotels) {
|
|
198
|
+
out = {
|
|
199
|
+
...out,
|
|
200
|
+
description: out.description.replace(`pick one ${v.noun} to book.`, `pick one ${v.noun}.`),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
184
203
|
if (!caps.extras) {
|
|
185
204
|
if (t.name === n.addToTrip) {
|
|
186
205
|
out = {
|
|
@@ -1401,6 +1420,10 @@ export const buildOutputSchemas = (n) => ({
|
|
|
1401
1420
|
degraded: ARR,
|
|
1402
1421
|
/** What `degraded` means, as the text says it: not that those groups have none here. */
|
|
1403
1422
|
degradedSaid: STR,
|
|
1423
|
+
/** Nothing found because nothing could be read - every group silent or held back (0.59.0, U4). */
|
|
1424
|
+
unread: BOOL,
|
|
1425
|
+
/** What was asked and not done, in the backend's own sentences - a limit of ours, too. */
|
|
1426
|
+
unapplied: STRS,
|
|
1404
1427
|
/** In a market: the place asked for, when it was not recognised - the hotels are not that place's (`unplacedOf`). */
|
|
1405
1428
|
unplaced: STR,
|
|
1406
1429
|
/** What `unplaced` means, as the text says it. */
|
|
@@ -1654,7 +1677,24 @@ export const buildOutputSchemas = (n) => ({
|
|
|
1654
1677
|
required: ['view'],
|
|
1655
1678
|
},
|
|
1656
1679
|
});
|
|
1657
|
-
|
|
1680
|
+
/** At most `n` characters (code points, so no half of a pair is left), from a string cut short first. */
|
|
1681
|
+
const upTo = (s, n) => s.length <= n
|
|
1682
|
+
? s
|
|
1683
|
+
: Array.from(s.slice(0, n * 2))
|
|
1684
|
+
.slice(0, n)
|
|
1685
|
+
.join('');
|
|
1686
|
+
/**
|
|
1687
|
+
* A string argument, trimmed - and never longer than any field here needs.
|
|
1688
|
+
*
|
|
1689
|
+
* ⚠️ AN ARGUMENT WAS AS LONG AS THE BODY (0.59.0, review C6): a `query` of a
|
|
1690
|
+
* megabyte went whole into the search, the cache key and the request to the
|
|
1691
|
+
* group. Every field is capped here; a place - `query`, `city`, `group` - at
|
|
1692
|
+
* `PLACE_MAX` (`place`), as the Otaless backend caps it (otaless/limits.ts).
|
|
1693
|
+
*/
|
|
1694
|
+
const STR_MAX = 2_000;
|
|
1695
|
+
const PLACE_MAX = 200;
|
|
1696
|
+
const str = (v) => (typeof v === 'string' ? upTo(v, STR_MAX).trim() : '');
|
|
1697
|
+
const place = (v) => upTo(str(v), PLACE_MAX).trim();
|
|
1658
1698
|
const asStay = (args) => {
|
|
1659
1699
|
const checkIn = str(args.checkIn);
|
|
1660
1700
|
const checkOut = str(args.checkOut);
|
|
@@ -2698,7 +2738,7 @@ const planGap = (plan) => {
|
|
|
2698
2738
|
if (booked === planned)
|
|
2699
2739
|
return `All ${planned} are booked - held under their confirmation codes, nothing paid.`;
|
|
2700
2740
|
if (inTrip === planned)
|
|
2701
|
-
return `All ${planned} are in the trip.`;
|
|
2741
|
+
return planned === 1 ? 'It is in the trip.' : `All ${planned} are in the trip.`;
|
|
2702
2742
|
const parts = [
|
|
2703
2743
|
booked ? `${booked} of ${planned} booked` : '',
|
|
2704
2744
|
inTrip || !booked ? `${inTrip} of ${planned} in the trip` : '',
|
|
@@ -2723,7 +2763,7 @@ const offerCount = (rooms) => {
|
|
|
2723
2763
|
/** What one room costs, as the text says it: nights, or the hours of a room by the hour. */
|
|
2724
2764
|
const priceWords = (r, noCards) => r.hourly
|
|
2725
2765
|
? `${formatMoney(r.stayTotal)} for ${r.hourly.hours} hours incl. taxes and fees, starting between ${r.hourly.earliestStart} and ${r.hourly.latestStart} today and out by ${r.hourly.latestEnd}`
|
|
2726
|
-
: `${formatMoney(r.nightly)} ${nightWords(noCards)}, ${formatMoney(r.stayTotal)} for the stay incl. taxes and fees`;
|
|
2766
|
+
: `${formatMoney(r.nightly)} ${nightWords(noCards, nightlyIncludesTaxes(r))}, ${formatMoney(r.stayTotal)} for the stay incl. taxes and fees`;
|
|
2727
2767
|
/**
|
|
2728
2768
|
* "a night" - and to a client that draws no card, "a night before taxes".
|
|
2729
2769
|
*
|
|
@@ -2788,6 +2828,8 @@ const waysOnWords = (group, atHotel) => `give the ways on in the same reply, nev
|
|
|
2788
2828
|
* structure (`noRooms`): the model reads the structure.
|
|
2789
2829
|
*/
|
|
2790
2830
|
export const notOnSaleWords = (group, why) => `${why.replace(/[.\s]+$/, '')} - ${NOT_SOLD_OUT}. To book it, the guest can use ${group}'s own channels: its app, its website or by phone.`;
|
|
2831
|
+
/** `notBookableWords` where nothing can be booked here, else nothing - see there. */
|
|
2832
|
+
const notBookableOf = (deps) => (deps.backend.capabilities ?? FULL_CAPABILITIES).readOnly ? notBookableWords(deps.vocab) : '';
|
|
2791
2833
|
/** The group a hotel is with, by name - the deployment's own brand outside a market. */
|
|
2792
2834
|
const groupNameOf = (deps, hotelId) => holderOf(deps, deps.backend.supplierOf?.(hotelId)).name;
|
|
2793
2835
|
/** A rate's cancellation terms in the supplier's own words (`Room.terms`), quoted - or that none were given. */
|
|
@@ -2824,7 +2866,7 @@ const roomFactsWords = (r, rate = false) => {
|
|
|
2824
2866
|
/** The cheapest price a rate quotes, as the text says it: "from" a night, or the hours of a block. */
|
|
2825
2867
|
const fromWords = (r, noCards) => r.hourly
|
|
2826
2868
|
? `${formatMoney(r.stayTotal)} for ${r.hourly.hours} hours incl. taxes and fees`
|
|
2827
|
-
: `${formatMoney(r.nightly)} ${nightWords(noCards)}, ${formatMoney(r.stayTotal)} for the stay incl. taxes and fees`;
|
|
2869
|
+
: `${formatMoney(r.nightly)} ${nightWords(noCards, nightlyIncludesTaxes(r))}, ${formatMoney(r.stayTotal)} for the stay incl. taxes and fees`;
|
|
2828
2870
|
/**
|
|
2829
2871
|
* A hotel's rooms for the nights, one line per ROOM TYPE.
|
|
2830
2872
|
*
|
|
@@ -2877,75 +2919,167 @@ const breakfastColumn = (r) => {
|
|
|
2877
2919
|
const said = (r.labels ?? []).find((l) => l.startsWith('breakfast'));
|
|
2878
2920
|
return said ? LABEL_WORDS[said] : facetsOf(r).breakfast ? 'breakfast included' : 'no breakfast';
|
|
2879
2921
|
};
|
|
2880
|
-
/** A rate's labels other than its breakfast
|
|
2881
|
-
const
|
|
2922
|
+
/** A rate's labels other than its breakfast and its payment - "booked-ahead rate" - as words. */
|
|
2923
|
+
const otherLabelsOf = (r) => (r.labels ?? [])
|
|
2924
|
+
.filter((l) => !isMealLabel(l))
|
|
2925
|
+
.map((l) => LABEL_WORDS[l])
|
|
2926
|
+
.join(', ');
|
|
2882
2927
|
/**
|
|
2883
2928
|
* A hotel's rooms for the nights as the numbered choices a client that draws no
|
|
2884
|
-
* card tells the guest (robin 11-06:
|
|
2929
|
+
* card tells the guest (robin 11-06: 「房型选择…看看有没有办法在文字版优化下」;
|
|
2930
|
+
* as paragraphs since robin 11-09 - see choices.ts).
|
|
2885
2931
|
*
|
|
2886
|
-
* One
|
|
2887
|
-
* the
|
|
2888
|
-
*
|
|
2889
|
-
*
|
|
2890
|
-
*
|
|
2891
|
-
*
|
|
2892
|
-
*
|
|
2932
|
+
* One choice per ROOM TYPE, cheapest first, at its lowest rate, with how many
|
|
2933
|
+
* other rates the type has: what the card shows a guest who can tap, in lines
|
|
2934
|
+
* they can answer with a number. The room id `addToTrip` takes for that number
|
|
2935
|
+
* is not in them: the ids follow, in one line of their own (`idsByNumber`).
|
|
2936
|
+
* Every type is in the answer, numbered, so "the sixth" is one the model can
|
|
2937
|
+
* name when the guest asks for the rest; the guest is shown the first
|
|
2938
|
+
* `ROOM_CHOICES_SHOWN`, and the others as a count.
|
|
2893
2939
|
*
|
|
2894
|
-
*
|
|
2895
|
-
*
|
|
2896
|
-
*
|
|
2940
|
+
* What every type has - its breakfast, its terms, its price, its other rates,
|
|
2941
|
+
* how it is paid - is said once before them (`said`), and what most have once
|
|
2942
|
+
* as what holds unless one says otherwise; each type says only what sets it
|
|
2943
|
+
* apart (robin 11-09: the same sentence five times over, on Huazhu's five).
|
|
2944
|
+
*
|
|
2945
|
+
* ⚠️ HOW EACH IS PAID CAN BE TOLD (2026-11-02 audit, P1-5): see `paymentOf`.
|
|
2897
2946
|
*/
|
|
2898
|
-
const
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2947
|
+
const roomChoicesBlock = (rooms, roomsWanted,
|
|
2948
|
+
/** The group a stay paid in advance is booked with instead. */
|
|
2949
|
+
group,
|
|
2950
|
+
/** Nothing can be booked here (`capabilities.readOnly`): said once, and no payment told apart. */
|
|
2951
|
+
readOnly = false) => {
|
|
2952
|
+
const rows = byRoomType(rooms)
|
|
2953
|
+
.map((type) => ({
|
|
2954
|
+
type,
|
|
2955
|
+
r: type.rooms.reduce((a, b) => (b.stayTotal.minor < a.stayTotal.minor ? b : a)),
|
|
2956
|
+
}))
|
|
2957
|
+
.sort((a, b) => a.r.stayTotal.minor - b.r.stayTotal.minor)
|
|
2958
|
+
.map(({ type, r }) => ({ type, r, others: type.rooms.length - 1 }));
|
|
2959
|
+
const many = roomsWanted > 1;
|
|
2960
|
+
const price = (r) => r.hourly
|
|
2961
|
+
? `${formatMoney(r.stayTotal)} for ${r.hourly.hours} hours`
|
|
2962
|
+
: many
|
|
2963
|
+
? `${formatMoney(multiplyMoney(r.stayTotal, roomsWanted))} for ${roomsWanted} rooms`
|
|
2964
|
+
: formatMoney(r.stayTotal);
|
|
2965
|
+
// ⚠️ "BEFORE TAXES" ONLY WHERE IT IS SO (0.55.3): see `nightlyIncludesTaxes`.
|
|
2966
|
+
const nightly = (r) => r.hourly
|
|
2967
|
+
? ''
|
|
2968
|
+
: `${formatMoney(r.nightly)} ${nightWords(true, nightlyIncludesTaxes(r))}${many ? ', per room' : ''}`;
|
|
2969
|
+
const more = (n) => n ? `${n} more ${n === 1 ? 'rate' : 'rates'} on this room type` : '';
|
|
2970
|
+
// Breakfast and terms are said for most as "unless one says otherwise"; the
|
|
2971
|
+
// rest only where every one is the same.
|
|
2972
|
+
const spread = {
|
|
2973
|
+
beds: allOrEach(spreadOf(rows.map(({ r }) => r.beds ?? ''))),
|
|
2974
|
+
breakfast: spreadOf(rows.map(({ r }) => breakfastColumn(r))),
|
|
2975
|
+
cancel: spreadOf(rows.map(({ r }) => cancelWords(r))),
|
|
2976
|
+
labels: allOrEach(spreadOf(rows.map(({ r }) => otherLabelsOf(r)))),
|
|
2977
|
+
nightly: allOrEach(spreadOf(rows.map(({ r }) => nightly(r)))),
|
|
2978
|
+
more: allOrEach(spreadOf(rows.map(({ others }) => String(others)))),
|
|
2979
|
+
price: allOrEach(spreadOf(rows.map(({ r }) => price(r)))),
|
|
2980
|
+
};
|
|
2981
|
+
const pay = readOnly
|
|
2982
|
+
? { said: '', tags: [] }
|
|
2983
|
+
: paymentOf(rows.map(({ r }) => payOf(r)), 'room', group);
|
|
2984
|
+
const lowest = Math.min(...rows.map(({ r }) => r.stayTotal.minor));
|
|
2985
|
+
const apart = {
|
|
2986
|
+
cheapest: setsApart(rows.map(({ r }) => !r.hourly && r.stayTotal.minor === lowest)),
|
|
2987
|
+
breakfast: setsApart(rows.map(({ r }) => facetsOf(r).breakfast)),
|
|
2988
|
+
free: setsApart(rows.map(({ r }) => facetsOf(r).freeCancellation)),
|
|
2989
|
+
family: setsApart(rows.map(({ r }) => r.sleeps >= FAMILY_SLEEPS)),
|
|
2990
|
+
};
|
|
2991
|
+
const blocks = rows.map(({ type, r, others }, i) => {
|
|
2992
|
+
const family = r.sleeps >= FAMILY_SLEEPS ? `sleeps ${r.sleeps}` : '';
|
|
2993
|
+
const beds = saysOwn(spread.beds, r.beds ?? '') ? (r.beds ?? '') : '';
|
|
2994
|
+
return choiceBlock(i + 1, {
|
|
2995
|
+
title: withZh(type.name, r.roomType ? r.roomType.names : r.names, true),
|
|
2996
|
+
sentence: sentenceOf([
|
|
2997
|
+
// A room for a family says so: "three of us" is chosen by it.
|
|
2998
|
+
[beds, family]
|
|
2999
|
+
.filter(Boolean)
|
|
3000
|
+
.join(', '),
|
|
3001
|
+
saysOwn(spread.breakfast, breakfastColumn(r)) ? breakfastColumn(r) : '',
|
|
3002
|
+
saysOwn(spread.cancel, cancelWords(r)) ? cancelWords(r) : '',
|
|
3003
|
+
saysOwn(spread.labels, otherLabelsOf(r)) ? otherLabelsOf(r) : '',
|
|
3004
|
+
rows.length < 2 && !readOnly ? PAY_WORDS[payOf(r)] : '',
|
|
3005
|
+
r.hourly
|
|
3006
|
+
? `starting between ${r.hourly.earliestStart} and ${r.hourly.latestStart} today, out by ${r.hourly.latestEnd}`
|
|
3007
|
+
: '',
|
|
3008
|
+
[
|
|
3009
|
+
saysOwn(spread.nightly, nightly(r)) ? nightly(r) : '',
|
|
3010
|
+
saysOwn(spread.more, String(others)) ? more(others) : '',
|
|
3011
|
+
]
|
|
3012
|
+
.filter(Boolean)
|
|
3013
|
+
.join('; '),
|
|
3014
|
+
]),
|
|
3015
|
+
tags: [
|
|
3016
|
+
pay.tags[i] ?? '',
|
|
3017
|
+
apart.cheapest && r.stayTotal.minor === lowest ? 'Cheapest' : '',
|
|
3018
|
+
apart.breakfast && facetsOf(r).breakfast ? 'Breakfast' : '',
|
|
3019
|
+
apart.free && facetsOf(r).freeCancellation ? 'Free cancellation' : '',
|
|
3020
|
+
apart.family && r.sleeps >= FAMILY_SLEEPS ? `Sleeps ${r.sleeps}` : '',
|
|
3021
|
+
].filter(Boolean),
|
|
3022
|
+
price: price(r),
|
|
3023
|
+
});
|
|
3024
|
+
});
|
|
3025
|
+
// What every one has, and what most have, said once before them.
|
|
3026
|
+
const first = rows[0]?.r;
|
|
3027
|
+
const samePrice = sharedBy(spread.price);
|
|
3028
|
+
const shared = [
|
|
3029
|
+
sharedBy(spread.beds),
|
|
3030
|
+
sharedBy(spread.breakfast),
|
|
3031
|
+
sharedBy(spread.cancel),
|
|
3032
|
+
sharedBy(spread.labels),
|
|
3033
|
+
samePrice ? '' : sharedBy(spread.nightly),
|
|
3034
|
+
sharedBy(spread.more) && sharedBy(spread.more) !== '0'
|
|
3035
|
+
? `${sharedBy(spread.more)} more ${sharedBy(spread.more) === '1' ? 'rate' : 'rates'} on each`
|
|
3036
|
+
: '',
|
|
3037
|
+
].filter(Boolean);
|
|
3038
|
+
const most = [spread.breakfast, spread.cancel]
|
|
3039
|
+
.map((s) => (s.kind === 'most' ? s.value : ''))
|
|
3040
|
+
.filter(Boolean);
|
|
3041
|
+
const said = [
|
|
3042
|
+
first?.hourly
|
|
3043
|
+
? "Prices are for each room's hours, taxes and fees included."
|
|
3044
|
+
: samePrice && rows.length > 1
|
|
3045
|
+
? `All ${rows.length} are ${samePrice}${many ? '' : ' for the stay'}, taxes and fees included${sharedBy(spread.nightly) ? ` (${sharedBy(spread.nightly)})` : ''}.`
|
|
3046
|
+
: many
|
|
3047
|
+
? `Prices are for ${roomsWanted} rooms for the whole stay, taxes and fees included.`
|
|
3048
|
+
: 'Prices are for the stay, taxes and fees included.',
|
|
3049
|
+
shared.length ? `Every one: ${shared.join('; ')}.` : '',
|
|
3050
|
+
most.length ? `Unless a room says otherwise: ${most.join('; ')}.` : '',
|
|
3051
|
+
pay.said,
|
|
3052
|
+
readOnly
|
|
3053
|
+
? `Nothing can be booked here yet: to book, use these rooms and dates with ${group}, on its own website or app.`
|
|
3054
|
+
: '',
|
|
3055
|
+
]
|
|
3056
|
+
.filter(Boolean)
|
|
3057
|
+
.join(' ');
|
|
2918
3058
|
return {
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
r.sleeps >= FAMILY_SLEEPS ? `sleeps ${r.sleeps}` : '',
|
|
2924
|
-
breakfastColumn(r),
|
|
2925
|
-
cancelWords(r),
|
|
2926
|
-
total,
|
|
2927
|
-
]
|
|
2928
|
-
.filter(Boolean)
|
|
2929
|
-
.join(' · ')}${otherLabelWords(r)}`,
|
|
2930
|
-
id: r.id,
|
|
3059
|
+
said,
|
|
3060
|
+
blocks,
|
|
3061
|
+
ids: rows.map(({ r }) => r.id),
|
|
3062
|
+
notes: rows.map(({ r }) => readOnly ? '' : r.notSoldHere ? 'paid in advance - not booked here' : ''),
|
|
2931
3063
|
};
|
|
2932
|
-
}
|
|
3064
|
+
};
|
|
2933
3065
|
/**
|
|
2934
|
-
* The ids behind numbered
|
|
3066
|
+
* The ids behind numbered choices, in one line after them (总线程 11-09): with the
|
|
2935
3067
|
* id on each line - "— room `x`" - the model was to copy the line and drop its
|
|
2936
3068
|
* end, and on Manus it rewrote the lines and dropped the numbers instead. The
|
|
2937
|
-
*
|
|
3069
|
+
* choices are the guest's as they stand; this line is the model's - and it
|
|
3070
|
+
* marks each one not booked here too (P1-5), where the choices may say it once
|
|
3071
|
+
* for all.
|
|
2938
3072
|
*/
|
|
2939
|
-
const idsByNumber = (what, ids, from = 1) => `${what} ids by number, for your calls - never for the guest: ${ids
|
|
2940
|
-
.map((id, i) => `${from + i} = \`${id}
|
|
3073
|
+
const idsByNumber = (what, ids, from = 1, notes = []) => `${what} ids by number, for your calls - never for the guest: ${ids
|
|
3074
|
+
.map((id, i) => `${from + i} = \`${id}\`${notes[i] ? ` (${notes[i]})` : ''}`)
|
|
2941
3075
|
.join('; ')}.`;
|
|
2942
3076
|
/**
|
|
2943
|
-
* What the assistant is told to do with
|
|
2944
|
-
* word
|
|
3077
|
+
* What the assistant is told to do with the choices - in the text and, word for
|
|
3078
|
+
* word, in the structure (`roomChoices`): the model reads the structure.
|
|
2945
3079
|
*/
|
|
2946
|
-
const roomChoicesLead = (types, when) => `Say the dates first, as they are here - ${when} - then copy
|
|
3080
|
+
const roomChoicesLead = (types, when) => `Say the dates first, as they are here - ${when} - then copy what follows into your reply as it stands, in this order: the sentence of what the rooms share, then each room as its own lines - its number and name in bold ("**1. …**"${types === 1 ? ', the one room too' : ''}), the sentence of what sets it apart where there is one, and its tags ending in its price - with a blank line between rooms. In the guest's language, with every number and figure kept and nothing added; never a table, and nothing said again on a room that the sentence before them says - ${types > ROOM_CHOICES_SHOWN
|
|
2947
3081
|
? `the first ${ROOM_CHOICES_SHOWN}, then "${types - ROOM_CHOICES_SHOWN} more room ${types - ROOM_CHOICES_SHOWN === 1 ? 'type' : 'types'}" in one line (the rest are below, for a guest who asks)`
|
|
2948
|
-
: 'every one'}. The guest answers with a number or by describing one: a number is that
|
|
3082
|
+
: 'every one'}. The guest answers with a number or by describing one: a number is that room, by the ids after the rooms.`;
|
|
2949
3083
|
/**
|
|
2950
3084
|
* Today at a hotel, for the dates offered to a guest who named none: its own
|
|
2951
3085
|
* date where the backend gives it (`todayThere`); else the sun's, from where it
|
|
@@ -2978,27 +3112,32 @@ numbers) => {
|
|
|
2978
3112
|
.join(', or ')}, or dates of their own. Do not number those: the numbers are the ${numbers}'. Never ask for dates before showing the ${numbers}; a guest who names other nights is asked again with them.`;
|
|
2979
3113
|
};
|
|
2980
3114
|
/**
|
|
2981
|
-
* The lead and the
|
|
3115
|
+
* The lead, what the rooms share and the choices - in the text and, word for
|
|
3116
|
+
* word, in `roomChoices`.
|
|
2982
3117
|
*
|
|
2983
3118
|
* ⚠️ WHAT CANNOT BE BOOKED HERE IS SAID BEFORE THE LIST (robin's Manus run, 11-06,
|
|
2984
3119
|
* via 总线程): nine Huazhu rates, every one paid in advance, and "none of these can
|
|
2985
|
-
* be booked here" came after all of them. `before` is that sentence, first
|
|
3120
|
+
* be booked here" came after all of them. `before` is that sentence, first; the
|
|
3121
|
+
* sentence of what the rooms share says it to the guest.
|
|
2986
3122
|
*/
|
|
2987
|
-
const roomChoicesOf = (rooms, roomsWanted, when, before) => {
|
|
2988
|
-
const
|
|
3123
|
+
const roomChoicesOf = (rooms, roomsWanted, when, before, group, readOnly = false) => {
|
|
3124
|
+
const c = roomChoicesBlock(rooms, roomsWanted, group, readOnly);
|
|
2989
3125
|
return [
|
|
2990
3126
|
...(before ? [before] : []),
|
|
2991
|
-
roomChoicesLead(
|
|
2992
|
-
...
|
|
2993
|
-
|
|
3127
|
+
roomChoicesLead(c.blocks.length, when),
|
|
3128
|
+
...(c.said ? [c.said] : []),
|
|
3129
|
+
// The blank lines are in the strings: the text's lines are joined after
|
|
3130
|
+
// empty ones are dropped, and the text and `roomChoices` say the same.
|
|
3131
|
+
`\n${c.blocks.join('\n\n')}`,
|
|
3132
|
+
`\n${idsByNumber('Room', c.ids, 1, c.notes)}`,
|
|
2994
3133
|
];
|
|
2995
3134
|
};
|
|
2996
|
-
/**
|
|
3135
|
+
/** What is said before the rooms where some - or all - of them are paid in advance and not booked here. */
|
|
2997
3136
|
const notSoldFirst = (rooms, notSold) => !notSold
|
|
2998
3137
|
? ''
|
|
2999
3138
|
: rooms.length > 0 && rooms.every((r) => r.notSoldHere)
|
|
3000
|
-
? `Every rate here for these nights is paid in advance, so none of them can be booked here yet and none is paid at the hotel -
|
|
3001
|
-
: `${notSold}
|
|
3139
|
+
? `Every rate here for these nights is paid in advance, so none of them can be booked here yet and none is paid at the hotel - the sentence before the rooms says so; keep it first. ${notSold}`
|
|
3140
|
+
: `${notSold} The sentence before the rooms says which are not bookable here; keep it before them.`;
|
|
3002
3141
|
/**
|
|
3003
3142
|
* What a hotel's rooms look like to the assistant for the nights: one line per
|
|
3004
3143
|
* type, and with filters only the rates that meet ALL of them. None meeting
|
|
@@ -3016,11 +3155,15 @@ saidWhen,
|
|
|
3016
3155
|
* What is said before the list to a client that draws no card: rates paid in
|
|
3017
3156
|
* advance (`notSoldFirst`), and other arrivals that cost less (`dateFlex`).
|
|
3018
3157
|
*/
|
|
3019
|
-
before
|
|
3158
|
+
before,
|
|
3159
|
+
/** The group a stay paid in advance is booked with instead - see `paymentOf`. */
|
|
3160
|
+
group = '',
|
|
3161
|
+
/** Nothing can be booked here - see `roomChoicesBlock`. */
|
|
3162
|
+
readOnly = false) => {
|
|
3020
3163
|
// A type with several rates is priced from its cheapest: say how to reach another.
|
|
3021
3164
|
const lines = (rs) => [
|
|
3022
3165
|
...(noCards
|
|
3023
|
-
? roomChoicesOf(rs, roomsWanted, saidWhen ?? when, before)
|
|
3166
|
+
? roomChoicesOf(rs, roomsWanted, saidWhen ?? when, before, group, readOnly)
|
|
3024
3167
|
: roomTypeLines(rs, roomsWanted, terms)),
|
|
3025
3168
|
...(byRoomType(rs).some((t) => t.rooms.length > 1)
|
|
3026
3169
|
? [
|
|
@@ -3800,7 +3943,7 @@ const filtersOf = (args) => {
|
|
|
3800
3943
|
: [];
|
|
3801
3944
|
const f = {
|
|
3802
3945
|
...(str(args.brand) ? { brand: str(args.brand) } : {}),
|
|
3803
|
-
...(
|
|
3946
|
+
...(place(args.group) ? { supplier: place(args.group) } : {}),
|
|
3804
3947
|
...(facilities.length ? { facilities } : {}),
|
|
3805
3948
|
...(args.freeCancellation === true ? { freeCancellation: true } : {}),
|
|
3806
3949
|
...(args.breakfast === true ? { breakfast: true } : {}),
|
|
@@ -3900,7 +4043,9 @@ export const CITY_PICKER_MIN = 4;
|
|
|
3900
4043
|
* chooses a city first.
|
|
3901
4044
|
*/
|
|
3902
4045
|
export const HOME_LIST_MAX = 6;
|
|
3903
|
-
const suggestionsFor = async (deps, d
|
|
4046
|
+
const suggestionsFor = async (deps, d,
|
|
4047
|
+
// Whose look this is, for a backend that counts its own calls by it (Otaless's limits, C6).
|
|
4048
|
+
who) => {
|
|
3904
4049
|
const view = String(d.view ?? '');
|
|
3905
4050
|
const out = [];
|
|
3906
4051
|
const hotel = d.hotel;
|
|
@@ -3911,7 +4056,7 @@ const suggestionsFor = async (deps, d) => {
|
|
|
3911
4056
|
// The hotel view already has buttons for its add-ons and its policies; the
|
|
3912
4057
|
// one thing it cannot do alone is set it beside the others.
|
|
3913
4058
|
if (view === 'hotel' && hotel && Array.isArray(d.rooms) && d.rooms.length) {
|
|
3914
|
-
const nearby = await deps.backend.searchHotels({ city: hotel.city, limit: 2 });
|
|
4059
|
+
const nearby = await deps.backend.searchHotels({ city: hotel.city, limit: 2 }, who);
|
|
3915
4060
|
if (nearby.total > 1)
|
|
3916
4061
|
out.push({
|
|
3917
4062
|
// The label IS what is sent: a chip that sends more than it says is
|
|
@@ -4069,7 +4214,7 @@ export const handleTool = async (deps, name, rawArgs, ctx) => {
|
|
|
4069
4214
|
const card = !ctx.noCards && name !== deps.tools.lookUp && name !== deps.tools.policies;
|
|
4070
4215
|
return notAnswered(deps, ctx.tripKey ?? tripKey(ctx.session, deps.vocab.brand), down, card);
|
|
4071
4216
|
});
|
|
4072
|
-
const suggestions = await suggestionsFor(deps, answer.structured).catch(() => []);
|
|
4217
|
+
const suggestions = await suggestionsFor(deps, answer.structured, identity(deps, ctx, ctx.tripKey ?? tripKey(ctx.session, deps.vocab.brand))).catch(() => []);
|
|
4073
4218
|
return { answer, suggestions };
|
|
4074
4219
|
});
|
|
4075
4220
|
const { answer, suggestions } = result;
|
|
@@ -4153,76 +4298,72 @@ export const HOTEL_CHOICES_SHOWN = 6;
|
|
|
4153
4298
|
// a model handed one Huazhu hotel wrote it as a sentence with no number, and the
|
|
4154
4299
|
// guest's next 「第1家」 had nothing to point at. The lines are the guest's as
|
|
4155
4300
|
// they stand, a single one included; the ids are after them, for the model.
|
|
4156
|
-
export const LIST_NOT_DRAWN = `Nothing was drawn: this app shows no cards, so the guest has seen none of these hotels. Copy
|
|
4301
|
+
export const LIST_NOT_DRAWN = `Nothing was drawn: this app shows no cards, so the guest has seen none of these hotels. Copy what follows into your reply as it stands, in this order and with these numbers: the sentence of what the hotels share where there is one, then each hotel as its own lines - its number and name in bold ("**1. …**", a single hotel too), the sentence of what sets it apart, and its tags ending in its price - with a blank line between hotels. In the guest's language, with every figure kept and nothing that is not in them; never a table, and nothing said again on a hotel that the sentence before them says - at most ${HOTEL_CHOICES_SHOWN}, and any more as a count the guest can ask for, never a pick of your own. The guest answers with a number or a name; the ids after the hotels are for your calls:`;
|
|
4157
4302
|
/**
|
|
4158
|
-
*
|
|
4303
|
+
* A list's hotels as the numbered choices a client that shows no cards tells
|
|
4304
|
+
* the guest - one paragraph each (robin 11-09; see choices.ts): its name; a
|
|
4305
|
+
* sentence of where it is, its group where the name does not carry it, its
|
|
4306
|
+
* rating, a few of its own facilities and the room it is priced at; two tags
|
|
4307
|
+
* at most and its price. What every hotel here has - the same facilities, the
|
|
4308
|
+
* same terms, how the prices are paid - is said once before them.
|
|
4159
4309
|
*
|
|
4160
|
-
* ⚠️
|
|
4310
|
+
* ⚠️ ONLY WHAT THE GROUP SAYS OF IT (总线程 11-06): never a word the data does not
|
|
4311
|
+
* carry - a distance is not given, so "nearest" is not said.
|
|
4312
|
+
*
|
|
4313
|
+
* ⚠️ WHETHER EACH PRICE CAN BE BOOKED HERE CAN BE TOLD (2026-11-02 audit, P1-5): a
|
|
4161
4314
|
* Huazhu hotel whose only rate tonight is paid in advance was listed as
|
|
4162
|
-
* "¥783.02 for the stay"
|
|
4163
|
-
*
|
|
4164
|
-
* can be booked. Each priced line says how its rate is paid and what it costs
|
|
4165
|
-
* to cancel, as the card's tile does.
|
|
4315
|
+
* "¥783.02 for the stay" - a model reading the line could tell the guest it can
|
|
4316
|
+
* be booked. See `paymentOf`.
|
|
4166
4317
|
*/
|
|
4167
|
-
const
|
|
4168
|
-
|
|
4318
|
+
const hotelChoicesBlock = (hotels,
|
|
4319
|
+
/** The first hotel's number less one - a list is numbered across its pages. */
|
|
4320
|
+
offset,
|
|
4321
|
+
/** The group a hotel is with, in a market - its name is ours, not the backend's code. */
|
|
4322
|
+
groupOf,
|
|
4323
|
+
/** The group a price paid in advance is booked with instead. */
|
|
4324
|
+
group,
|
|
4325
|
+
/** Nothing can be booked here (`capabilities.readOnly`): said once, and no payment told apart. */
|
|
4326
|
+
readOnly = false) => {
|
|
4327
|
+
const n = hotels.length;
|
|
4328
|
+
const key = (x) => x.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '');
|
|
4329
|
+
// ⚠️ THE GROUP BY OUR NAME FOR IT (总线程 11-09): Otaless gives a hotel's brand as
|
|
4330
|
+
// its group's code - ATOUR, CLUBMED - and a brand that is only that is said as
|
|
4331
|
+
// the group is configured (Atour(亚朵)). A real brand of its own stays as given.
|
|
4332
|
+
const groupWords = (h) => {
|
|
4333
|
+
if (!h.brand)
|
|
4334
|
+
return '';
|
|
4335
|
+
const g = groupOf(h);
|
|
4336
|
+
const isGroup = !!g && (key(h.brand) === key(g.id) || key(h.brand) === key(g.name));
|
|
4337
|
+
const plain = isGroup && g ? g.name : hotelName(h.brand);
|
|
4338
|
+
const named = key(hotelName(h.name));
|
|
4339
|
+
if (named.includes(key(plain)) || (isGroup && g?.names?.zh && named.includes(key(g.names.zh))))
|
|
4340
|
+
return '';
|
|
4341
|
+
return isGroup && g ? withZh(g.name, g.names, true) : plain;
|
|
4342
|
+
};
|
|
4343
|
+
const cities = spreadOf(hotels.map((h) => (h.city ? hotelName(h.city) : '')));
|
|
4344
|
+
const whereOf = (h) => (cities.kind === 'all' ? [h.area] : [h.area, h.city])
|
|
4169
4345
|
.filter((x) => !!x)
|
|
4170
4346
|
.map((x) => hotelName(x))
|
|
4171
4347
|
.join(', ');
|
|
4172
|
-
const
|
|
4173
|
-
const
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
? `${formatMoney(f.total)} for the stay incl. taxes and fees, ${withZh(f.room, f.roomNames, true)}${f.rooms > 1 ? ` × ${f.rooms}` : ''}${terms.length ? ` [${terms.join(', ')}]` : ''}`
|
|
4187
|
-
: h.noRoomsForStay
|
|
4188
|
-
? // ⚠️ NOT SOLD HERE IS NOT SOLD OUT (2026-11-03 review, U11): a hotel with no
|
|
4189
|
-
// rooms on sale through this connector was told as "no room for those
|
|
4190
|
-
// nights", and the model said "no vacancy tonight" - as if another night
|
|
4191
|
-
// would do. It says what the hotel's own page says.
|
|
4192
|
-
h.noRoomsForStayCode === 'none-on-sale'
|
|
4193
|
-
? h.noRoomsForStay
|
|
4194
|
-
: 'no room for those nights'
|
|
4195
|
-
: h.fromNightly
|
|
4196
|
-
? `from ${formatMoney(h.fromNightly)} ${nightWords(true, h.fromNightlyTaxes === 'unknown')}`
|
|
4197
|
-
: '';
|
|
4198
|
-
// ⚠️ ONLY WHAT THE GROUP SAYS OF IT (总线程 11-06): its brand where the name
|
|
4199
|
-
// does not carry it, its rating where there is one, and a few of its own
|
|
4200
|
-
// facilities - a short line the guest can tell hotels apart by, nothing made up.
|
|
4201
|
-
const brand = h.brand && !hotelName(h.name).toLowerCase().includes(h.brand.toLowerCase())
|
|
4202
|
-
? hotelName(h.brand)
|
|
4203
|
-
: '';
|
|
4204
|
-
const rated = h.rating
|
|
4205
|
-
? `rated ${h.rating.value}/${h.rating.scaleMax}${h.rating.count ? ` from ${h.rating.count} reviews` : ''}`
|
|
4206
|
-
: '';
|
|
4207
|
-
const has = h.amenities.slice(0, 3).map(hotelName).filter(Boolean);
|
|
4208
|
-
return `${n}. ${withZh(h.name, h.names?.name, true)}${[where, brand, rated]
|
|
4209
|
-
.filter(Boolean)
|
|
4210
|
-
.map((x) => ` · ${x}`)
|
|
4211
|
-
.join('')}${price ? `: ${price}` : ''}${has.length ? `; has ${has.join(', ')}` : ''}${tags.length ? `\n tags: ${tags.join(' · ')}` : ''}`;
|
|
4212
|
-
};
|
|
4213
|
-
/**
|
|
4214
|
-
* What sets each hotel of a list apart, from what the list itself says (总线程
|
|
4215
|
-
* 11-06, after RollingGo's text answers - "Most central · 5-star · SGD 244"): the
|
|
4216
|
-
* lowest price and the best rating among them, and a stay's own free cancelling
|
|
4217
|
-
* and breakfast. Never a word the data does not carry - a distance is not given,
|
|
4218
|
-
* so none is said.
|
|
4219
|
-
*/
|
|
4220
|
-
const listTagsOf = (hotels) => {
|
|
4348
|
+
const facilitiesOf = (h) => h.amenities.slice(0, 3).map(hotelName).filter(Boolean).join(', ');
|
|
4349
|
+
const facilities = allOrEach(spreadOf(hotels.map(facilitiesOf)));
|
|
4350
|
+
const priced = hotels.filter((h) => h.forStay);
|
|
4351
|
+
const cancelOf = (h) => h.forStay?.refundable === false
|
|
4352
|
+
? 'non-refundable'
|
|
4353
|
+
: h.forStay?.freeCancellation
|
|
4354
|
+
? 'free to cancel'
|
|
4355
|
+
: '';
|
|
4356
|
+
const cancel = spreadOf(priced.map(cancelOf));
|
|
4357
|
+
const pay = readOnly
|
|
4358
|
+
? { said: '', tags: [] }
|
|
4359
|
+
: paymentOf(priced.map((h) => payOf(h.forStay ?? {})), 'hotel', group, `Every price here is a rate paid in advance, which cannot be booked here yet; a hotel's own rooms show any rate paid at the hotel, or book with ${group} in its own app or on its website.`);
|
|
4360
|
+
const payTag = (h) => (h.forStay ? (pay.tags[priced.indexOf(h)] ?? '') : '');
|
|
4361
|
+
// The cheapest, in one currency, and the best rated - among more than one.
|
|
4221
4362
|
const priceOf = (h) => h.forStay?.total ?? h.fromNightly;
|
|
4222
|
-
const
|
|
4223
|
-
const oneCurrency = new Set(
|
|
4224
|
-
const lowest =
|
|
4225
|
-
? Math.min(...
|
|
4363
|
+
const withPrice = hotels.filter((h) => priceOf(h));
|
|
4364
|
+
const oneCurrency = new Set(withPrice.map((h) => priceOf(h)?.currency)).size === 1;
|
|
4365
|
+
const lowest = withPrice.length > 1 && oneCurrency
|
|
4366
|
+
? Math.min(...withPrice.map((h) => priceOf(h)?.minor ?? Number.POSITIVE_INFINITY))
|
|
4226
4367
|
: undefined;
|
|
4227
4368
|
const score = (h) => (h.rating ? h.rating.value / h.rating.scaleMax : -1);
|
|
4228
4369
|
const rated = hotels.filter((h) => h.rating);
|
|
@@ -4231,14 +4372,91 @@ const listTagsOf = (hotels) => {
|
|
|
4231
4372
|
((!!h.forStay.meal && h.forStay.meal.plan !== 'none') ||
|
|
4232
4373
|
(h.forStay.labels ?? []).some((l) => l.startsWith('breakfast')));
|
|
4233
4374
|
const free = (h) => !!h.forStay?.freeCancellation;
|
|
4234
|
-
|
|
4235
|
-
const
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4375
|
+
const isLowest = (h) => lowest !== undefined && priceOf(h)?.minor === lowest;
|
|
4376
|
+
const isBest = (h) => best !== undefined && score(h) === best;
|
|
4377
|
+
const placeOf = (h) => hotelName((cities.kind === 'all' ? h.area : (h.area ?? h.city)) ?? '');
|
|
4378
|
+
const apart = {
|
|
4379
|
+
lowest: setsApart(hotels.map(isLowest)),
|
|
4380
|
+
best: setsApart(hotels.map(isBest)),
|
|
4381
|
+
free: setsApart(hotels.map(free)),
|
|
4382
|
+
breakfast: setsApart(hotels.map(breakfast)),
|
|
4383
|
+
};
|
|
4384
|
+
const blocks = hotels.map((h, i) => {
|
|
4385
|
+
const f = h.forStay;
|
|
4386
|
+
const owner = groupWords(h);
|
|
4387
|
+
const where = whereOf(h);
|
|
4388
|
+
const room = f
|
|
4389
|
+
? `${withZh(f.room, f.roomNames, true)}${f.rooms > 1 ? ` × ${f.rooms}` : ''}`
|
|
4390
|
+
: '';
|
|
4391
|
+
const terms = f &&
|
|
4392
|
+
saysOwn(cancel, cancelOf(h)) &&
|
|
4393
|
+
// A rate whose own name already says it is not told it again.
|
|
4394
|
+
!(cancelOf(h) === 'non-refundable' && SAYS_NON_REFUNDABLE.test(f.room)) &&
|
|
4395
|
+
!(cancelOf(h) === 'free to cancel' && /free cancellation|免费取消|可取消/i.test(f.room))
|
|
4396
|
+
? cancelOf(h)
|
|
4397
|
+
: '';
|
|
4398
|
+
const place = placeOf(h);
|
|
4399
|
+
return choiceBlock(offset + i + 1, {
|
|
4400
|
+
title: withZh(h.name, h.names?.name, true),
|
|
4401
|
+
sentence: sentenceOf([
|
|
4402
|
+
owner && where ? `${owner}, in ${where}` : owner || (where ? `in ${where}` : ''),
|
|
4403
|
+
h.rating
|
|
4404
|
+
? `rated ${h.rating.value}/${h.rating.scaleMax}${h.rating.count ? ` from ${h.rating.count} reviews` : ''}`
|
|
4405
|
+
: '',
|
|
4406
|
+
saysOwn(facilities, facilitiesOf(h)) ? facilitiesOf(h) : '',
|
|
4407
|
+
// "The price is for" - not "cheapest room", which the tag `Cheapest` means of the hotel.
|
|
4408
|
+
room ? `the price is for its ${room}${terms ? `, ${terms}` : ''}` : '',
|
|
4409
|
+
// One price alone has no tag to set it apart: its payment is in its sentence.
|
|
4410
|
+
f && priced.length < 2 && !readOnly ? PAY_WORDS[payOf(f)] : '',
|
|
4411
|
+
// ⚠️ NOT SOLD HERE IS NOT SOLD OUT (2026-11-03 review, U11): a hotel with no
|
|
4412
|
+
// rooms on sale through this connector says what its own page says.
|
|
4413
|
+
!f && h.noRoomsForStay
|
|
4414
|
+
? h.noRoomsForStayCode === 'none-on-sale'
|
|
4415
|
+
? h.noRoomsForStay
|
|
4416
|
+
: 'no room for those nights'
|
|
4417
|
+
: '',
|
|
4418
|
+
]),
|
|
4419
|
+
tags: [
|
|
4420
|
+
payTag(h),
|
|
4421
|
+
apart.lowest && isLowest(h) ? 'Cheapest' : '',
|
|
4422
|
+
apart.best && isBest(h) ? 'Best rated' : '',
|
|
4423
|
+
apart.free && free(h) ? 'Free cancellation' : '',
|
|
4424
|
+
apart.breakfast && breakfast(h) ? 'Breakfast' : '',
|
|
4425
|
+
// Where it is, when that sets it apart and there is room for it.
|
|
4426
|
+
n > 1 && place && setsApart(hotels.map((x) => placeOf(x) === place)) ? place : '',
|
|
4427
|
+
].filter(Boolean),
|
|
4428
|
+
price: f
|
|
4429
|
+
? f.hours
|
|
4430
|
+
? `${formatMoney(f.total)} for ${f.hours} hours`
|
|
4431
|
+
: `${formatMoney(f.total)}${f.rooms > 1 ? ` for ${f.rooms} rooms` : ''}`
|
|
4432
|
+
: h.noRoomsForStay
|
|
4433
|
+
? h.noRoomsForStayCode === 'none-on-sale'
|
|
4434
|
+
? 'Not on sale here'
|
|
4435
|
+
: 'No room for those nights'
|
|
4436
|
+
: h.fromNightly
|
|
4437
|
+
? `from ${formatMoney(h.fromNightly)} ${nightWords(true, h.fromNightlyTaxes === 'unknown')}`
|
|
4438
|
+
: '',
|
|
4439
|
+
});
|
|
4440
|
+
});
|
|
4441
|
+
const said = [
|
|
4442
|
+
sharedBy(facilities) && n > 1 ? `All have ${sharedBy(facilities)}.` : '',
|
|
4443
|
+
cancel.kind === 'all' && cancel.value
|
|
4444
|
+
? `Every price here is ${cancel.value}.`
|
|
4445
|
+
: cancel.kind === 'most' && cancel.value
|
|
4446
|
+
? `Unless a hotel says otherwise, its price is ${cancel.value}.`
|
|
4447
|
+
: '',
|
|
4448
|
+
pay.said,
|
|
4449
|
+
readOnly
|
|
4450
|
+
? 'Nothing can be booked here yet: to book, use the hotel and dates with its own group, on its website or app.'
|
|
4451
|
+
: '',
|
|
4452
|
+
]
|
|
4453
|
+
.filter(Boolean)
|
|
4454
|
+
.join(' ');
|
|
4455
|
+
return {
|
|
4456
|
+
said,
|
|
4457
|
+
blocks,
|
|
4458
|
+
notes: hotels.map((h) => !readOnly && h.forStay?.notSoldHere ? 'its price is paid in advance - not booked here' : ''),
|
|
4459
|
+
};
|
|
4242
4460
|
};
|
|
4243
4461
|
/**
|
|
4244
4462
|
* What a client that draws no card is told of a list asked for without dates
|
|
@@ -4273,7 +4491,7 @@ const comparedInWords = (c) => {
|
|
|
4273
4491
|
const p = c.price;
|
|
4274
4492
|
const priced = p
|
|
4275
4493
|
? [
|
|
4276
|
-
`${withZh(p.room, p.roomNames, true)} at ${p.nightly} ${nightWords(true)}, ${p.stayTotal} for the stay incl. taxes and fees`,
|
|
4494
|
+
`${withZh(p.room, p.roomNames, true)} at ${p.nightly} ${nightWords(true, p.nightlyTaxesIn)}, ${p.stayTotal} for the stay incl. taxes and fees`,
|
|
4277
4495
|
p.terms !== undefined
|
|
4278
4496
|
? termsWords(p.terms)
|
|
4279
4497
|
: p.freeCancellationUntil
|
|
@@ -4339,7 +4557,7 @@ const dayNames = (day, words) => {
|
|
|
4339
4557
|
* whose own words name another area's hotel is named here - also for a trip
|
|
4340
4558
|
* shorter than four nights - so the model does not have to find it again.
|
|
4341
4559
|
*/
|
|
4342
|
-
const longStayNudges = async (deps, stays, days) => {
|
|
4560
|
+
const longStayNudges = async (deps, stays, days, who) => {
|
|
4343
4561
|
// The areas the plan already uses are not "other" for any of its stays.
|
|
4344
4562
|
const used = new Set(stays.map((x) => x.area?.toLowerCase()).filter(Boolean));
|
|
4345
4563
|
const out = [];
|
|
@@ -4349,7 +4567,8 @@ const longStayNudges = async (deps, stays, days) => {
|
|
|
4349
4567
|
continue;
|
|
4350
4568
|
let hotels;
|
|
4351
4569
|
try {
|
|
4352
|
-
hotels = (await deps.backend.searchHotels({ city: x.city, limit: MAX_PAGE }))
|
|
4570
|
+
hotels = (await deps.backend.searchHotels({ city: place(x.city), limit: MAX_PAGE }, who))
|
|
4571
|
+
.hotels;
|
|
4353
4572
|
}
|
|
4354
4573
|
catch {
|
|
4355
4574
|
// The plan is already drawn; a city that cannot be read just gets no nudge.
|
|
@@ -4915,7 +5134,7 @@ const bookTripLines = async (deps, t, ctx, key, store, args, nothingThere) => {
|
|
|
4915
5134
|
// ⚠️ ONE GROUP AT A TIME, in a market: a booking cannot be all-or-nothing
|
|
4916
5135
|
// across two groups' systems (Marketplace, §6-1). `group` books one
|
|
4917
5136
|
// group's stays and leaves the rest in the trip.
|
|
4918
|
-
const asked = deps.backend.suppliers ?
|
|
5137
|
+
const asked = deps.backend.suppliers ? place(args.group) : '';
|
|
4919
5138
|
const group = asked ? groupNamed(deps, asked) : undefined;
|
|
4920
5139
|
const groupOf = (l) => deps.backend.supplierOf?.(l.hotelId);
|
|
4921
5140
|
const lines = group ? inTrip.filter((l) => groupOf(l) === group.id) : inTrip;
|
|
@@ -5253,8 +5472,8 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
5253
5472
|
// server instructions say otherwise, but a host may not pass them on; this
|
|
5254
5473
|
// answer always reaches the model, so it says it here, after the list.
|
|
5255
5474
|
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}.`;
|
|
5256
|
-
const query =
|
|
5257
|
-
const city =
|
|
5475
|
+
const query = place(args.query);
|
|
5476
|
+
const city = place(args.city);
|
|
5258
5477
|
const sort = SORTS.includes(str(args.sort))
|
|
5259
5478
|
? str(args.sort)
|
|
5260
5479
|
: 'group';
|
|
@@ -5654,6 +5873,13 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
5654
5873
|
const capCurrency = answer.currencies[0] ?? cheapest?.currency ?? 'HKD';
|
|
5655
5874
|
const cap = formatMoney(money(toMinor(Number(ceiling), capCurrency), capCurrency));
|
|
5656
5875
|
const pastTheEnd = answer.total > 0 && offset > 0;
|
|
5876
|
+
// ⚠️ NOTHING READ IS NOT "NOTHING MATCHES" (0.59.0, review U4): with every
|
|
5877
|
+
// group silent - or held back by a limit of ours (otaless/limits.ts) - the
|
|
5878
|
+
// answer said "No hotels match that" beside "did not answer in time", and
|
|
5879
|
+
// the card offered another city. What was not asked, or not answered, is
|
|
5880
|
+
// said as that; what our limit held back is said in its own words
|
|
5881
|
+
// (`unapplied`), which this branch did not read.
|
|
5882
|
+
const unread = !pastTheEnd && !filteredEmpty && !ceilingEmpty && !!degraded.structured.degraded;
|
|
5657
5883
|
const why = pastTheEnd
|
|
5658
5884
|
? `That page is past the end: ${answer.total} match, so \`offset\` 0 to ${answer.total - 1} is where they are.`
|
|
5659
5885
|
: filteredEmpty
|
|
@@ -5662,14 +5888,16 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
5662
5888
|
? `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` : ''}.`
|
|
5663
5889
|
: ceilingEmpty
|
|
5664
5890
|
? `None of the ${answer.beforeCeiling} that match has a room for those nights.`
|
|
5665
|
-
:
|
|
5666
|
-
`No ${branded(deps.vocab, deps.vocab.nounPlural)}
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5891
|
+
: unread
|
|
5892
|
+
? `No ${branded(deps.vocab, deps.vocab.nounPlural)} could be read this time.`
|
|
5893
|
+
: [
|
|
5894
|
+
`No ${branded(deps.vocab, deps.vocab.nounPlural)} match that.`,
|
|
5895
|
+
// What was tried and also failed is worth a sentence: it tells a
|
|
5896
|
+
// guest the word itself is the problem, not the narrowing.
|
|
5897
|
+
widened ? `${sentence(widened.to)} found nothing either.` : '',
|
|
5898
|
+
]
|
|
5899
|
+
.filter(Boolean)
|
|
5900
|
+
.join(' ');
|
|
5673
5901
|
return {
|
|
5674
5902
|
structured: {
|
|
5675
5903
|
view: 'no-hotels',
|
|
@@ -5682,6 +5910,9 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
5682
5910
|
...(widened?.found ? { widened } : {}),
|
|
5683
5911
|
// Nothing found while a group did not answer is not "none here".
|
|
5684
5912
|
...degraded.structured,
|
|
5913
|
+
// Nothing read at all: the card says so, with 「重试」, not "try another city" (U4).
|
|
5914
|
+
...(unread ? { unread: true } : {}),
|
|
5915
|
+
...(answer.unapplied?.length ? { unapplied: answer.unapplied } : {}),
|
|
5685
5916
|
// Why it is empty, in the words the model is told, so the card says
|
|
5686
5917
|
// the same thing rather than guessing at it.
|
|
5687
5918
|
why,
|
|
@@ -5695,8 +5926,10 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
5695
5926
|
beforeFilters: answer.beforeFilters,
|
|
5696
5927
|
}
|
|
5697
5928
|
: // A market's group asked for and with no hotel here (11-05): the card says
|
|
5698
|
-
// which group, and does not send the guest off to "try a city".
|
|
5699
|
-
|
|
5929
|
+
// which group, and does not send the guest off to "try a city". And
|
|
5930
|
+
// nothing read at all (U4): the same search, for the card to ask again
|
|
5931
|
+
// and to say where it looked.
|
|
5932
|
+
asked.filters?.supplier || unread
|
|
5700
5933
|
? { ask: echo(sort) }
|
|
5701
5934
|
: {}),
|
|
5702
5935
|
},
|
|
@@ -5704,6 +5937,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
5704
5937
|
widened?.found ? `Nothing matched ${widened.from}, so this looked in ${widened.to}.` : '',
|
|
5705
5938
|
why,
|
|
5706
5939
|
degraded.said,
|
|
5940
|
+
...(answer.unapplied ?? []),
|
|
5707
5941
|
]
|
|
5708
5942
|
.filter(Boolean)
|
|
5709
5943
|
.join(' '),
|
|
@@ -5815,11 +6049,19 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
5815
6049
|
// To a client that draws no card, the hotels as numbered lines - numbered
|
|
5816
6050
|
// across pages, so "the 23rd" on the second page is still one hotel. In the
|
|
5817
6051
|
// text and, word for word, in the structure (`hotelChoices`).
|
|
5818
|
-
const
|
|
5819
|
-
const
|
|
6052
|
+
const notBookable = notBookableOf(deps);
|
|
6053
|
+
const listed = ctx.noCards && hotels.length
|
|
6054
|
+
? hotelChoicesBlock(hotels, offset, (h) => {
|
|
6055
|
+
const id = deps.backend.supplierOf?.(h.id);
|
|
6056
|
+
return id ? deps.backend.suppliers?.().find((g) => g.id === id) : undefined;
|
|
6057
|
+
}, groupNameOf(deps, (notSoldOn ?? hotels[0]).id), !!notBookable)
|
|
6058
|
+
: undefined;
|
|
6059
|
+
const hotelChoices = listed
|
|
5820
6060
|
? [
|
|
5821
|
-
...
|
|
5822
|
-
|
|
6061
|
+
...(listed.said ? [listed.said, ''] : []),
|
|
6062
|
+
listed.blocks.join('\n\n'),
|
|
6063
|
+
'',
|
|
6064
|
+
idsByNumber('Hotel', hotels.map((h) => h.id), offset + 1, listed.notes),
|
|
5823
6065
|
].join('\n')
|
|
5824
6066
|
: '';
|
|
5825
6067
|
// …and, asked without dates, what its prices are - first of the notes.
|
|
@@ -5905,6 +6147,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
5905
6147
|
...(fromPrices ? { stayDefault: fromPrices } : {}),
|
|
5906
6148
|
...(ctx.drawsCards && hotels.length ? { cardShows: ON_CARD.hotels } : {}),
|
|
5907
6149
|
...(notSold ? { notSoldHere: notSold } : {}),
|
|
6150
|
+
...(notBookable ? { notBookable } : {}),
|
|
5908
6151
|
},
|
|
5909
6152
|
text: [
|
|
5910
6153
|
inAll ||
|
|
@@ -5917,6 +6160,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
5917
6160
|
more > 0
|
|
5918
6161
|
? `— ${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.`
|
|
5919
6162
|
: '',
|
|
6163
|
+
notBookable,
|
|
5920
6164
|
...priceNotes,
|
|
5921
6165
|
widened?.found ? `Nothing matched ${widened.from}, so this is ${widened.to}.` : '',
|
|
5922
6166
|
degraded.said,
|
|
@@ -6145,8 +6389,9 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
6145
6389
|
const saidWhen = byTheHour
|
|
6146
6390
|
? `today, ${dayWords(stay.checkIn)}, ${stay.guests} ${stay.guests === 1 ? 'guest' : 'guests'}`
|
|
6147
6391
|
: `${stayDayWords(stay.checkIn, stay.checkOut)}, ${stay.guests} ${stay.guests === 1 ? 'guest' : 'guests'}${roomsWanted > 1 ? `, ${roomsWanted} rooms` : ''}`;
|
|
6392
|
+
const notBookable = notBookableOf(deps);
|
|
6148
6393
|
const roomChoices = ctx.noCards && choosable.length
|
|
6149
|
-
? roomChoicesOf(choosable, roomsWanted, saidWhen, before).join('\n')
|
|
6394
|
+
? roomChoicesOf(choosable, roomsWanted, saidWhen, before, groupNameOf(deps, h.id), !!notBookable).join('\n')
|
|
6150
6395
|
: undefined;
|
|
6151
6396
|
// ⚠️ 「这周末」 WORKED OUT AS SATURDAY NIGHT (总线程 11-09, claude.ai and Manus
|
|
6152
6397
|
// both) is said back first, in both - see `weekendOf`.
|
|
@@ -6171,17 +6416,19 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
6171
6416
|
...(memberRates ? { memberRates } : {}),
|
|
6172
6417
|
...flex.structured,
|
|
6173
6418
|
...(ctx.drawsCards && enough.length ? { cardShows: ON_CARD.rooms } : {}),
|
|
6419
|
+
...(notBookable ? { notBookable } : {}),
|
|
6174
6420
|
},
|
|
6175
6421
|
text: [
|
|
6176
6422
|
weekend,
|
|
6177
6423
|
memberRates?.said ?? '',
|
|
6424
|
+
notBookable,
|
|
6178
6425
|
...roomsText(ctx.noCards ? withZh(h.name, h.names?.name, true) : h.name, byTheHour
|
|
6179
6426
|
? (rs) => `${rs.length} ${rs.length === 1 ? 'room' : 'rooms'} by the hour for today, ${stay.checkIn}, ${stay.guests} guests`
|
|
6180
6427
|
: (rs) =>
|
|
6181
6428
|
// ⚠️ THE WEEKDAYS, to a client that draws no card: the dates
|
|
6182
6429
|
// the model worked out of 「下周五住两晚」 are said back as the
|
|
6183
6430
|
// guest can check them (robin 11-06).
|
|
6184
|
-
`${offerCount(rs)} for ${ctx.noCards ? `${stayDayWords(stay.checkIn, stay.checkOut)}, ${stay.checkIn} to ${stay.checkOut}` : `${stay.checkIn} to ${stay.checkOut}`}, ${stay.guests} guests${roomsWanted > 1 ? `, ${roomsWanted} rooms` : ''}`, byTheHour ? `today, ${stay.checkIn}` : `${stay.checkIn} to ${stay.checkOut}`, enough, roomsWanted, terms, ctx.noCards, saidWhen, before),
|
|
6431
|
+
`${offerCount(rs)} for ${ctx.noCards ? `${stayDayWords(stay.checkIn, stay.checkOut)}, ${stay.checkIn} to ${stay.checkOut}` : `${stay.checkIn} to ${stay.checkOut}`}, ${stay.guests} guests${roomsWanted > 1 ? `, ${roomsWanted} rooms` : ''}`, byTheHour ? `today, ${stay.checkIn}` : `${stay.checkIn} to ${stay.checkOut}`, enough, roomsWanted, terms, ctx.noCards, saidWhen, before, groupNameOf(deps, h.id), !!notBookable),
|
|
6185
6432
|
// Said before the list to a client that draws no card (`before`).
|
|
6186
6433
|
ctx.noCards && choosable.length ? '' : flexSaid,
|
|
6187
6434
|
ctx.noCards && choosable.length ? '' : notSold,
|
|
@@ -6200,7 +6447,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
6200
6447
|
.map((x) => str(x))
|
|
6201
6448
|
.filter(Boolean)
|
|
6202
6449
|
.slice(0, LOOK_UP_MAX);
|
|
6203
|
-
const city =
|
|
6450
|
+
const city = place(args.city);
|
|
6204
6451
|
const ids = [];
|
|
6205
6452
|
const dropped = [];
|
|
6206
6453
|
/** For each name that fits more than one, which ones - see `namesLike`. */
|
|
@@ -7055,6 +7302,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7055
7302
|
const stayWords = comparison.stay
|
|
7056
7303
|
? ` for ${comparison.stay.checkIn} to ${comparison.stay.checkOut}`
|
|
7057
7304
|
: '';
|
|
7305
|
+
const notBookable = notBookableOf(deps);
|
|
7058
7306
|
return {
|
|
7059
7307
|
structured: {
|
|
7060
7308
|
view: 'comparison',
|
|
@@ -7067,8 +7315,10 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7067
7315
|
// In both, like the itinerary's: a host with no card may hand its
|
|
7068
7316
|
// model this rather than the text.
|
|
7069
7317
|
...(ctx.noCards ? { notDrawn: COMPARISON_NOT_DRAWN } : {}),
|
|
7318
|
+
...(notBookable ? { notBookable } : {}),
|
|
7070
7319
|
},
|
|
7071
7320
|
text: [
|
|
7321
|
+
notBookable,
|
|
7072
7322
|
// The card carries the table; the text carries only what the model
|
|
7073
7323
|
// could not see before it asked - what was dropped, and why.
|
|
7074
7324
|
//
|
|
@@ -7179,11 +7429,14 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7179
7429
|
// the model `structuredContent` rather than the text never saw what the
|
|
7180
7430
|
// text said of a long stay. The model's part of the answer is the same on
|
|
7181
7431
|
// either side.
|
|
7182
|
-
const nudges = stays.length
|
|
7432
|
+
const nudges = stays.length
|
|
7433
|
+
? await longStayNudges(deps, stayItems, plan.days, identity(deps, ctx, key))
|
|
7434
|
+
: [];
|
|
7183
7435
|
// Two hotels on the same nights of the plan - said, never refused (overlap.ts).
|
|
7184
7436
|
const overlaps = overlapsOf(stayItems.flatMap((x) => x.checkIn && x.checkOut
|
|
7185
7437
|
? [{ hotelId: x.id, name: hotelName(x.name), checkIn: x.checkIn, checkOut: x.checkOut }]
|
|
7186
7438
|
: []));
|
|
7439
|
+
const notBookable = notBookableOf(deps);
|
|
7187
7440
|
return {
|
|
7188
7441
|
structured: {
|
|
7189
7442
|
view: 'itinerary',
|
|
@@ -7201,9 +7454,11 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
|
|
|
7201
7454
|
// In both, like the nudges: a host with no card may hand its model
|
|
7202
7455
|
// this rather than the text.
|
|
7203
7456
|
...(ctx.noCards ? { notDrawn: PLAN_NOT_DRAWN } : {}),
|
|
7457
|
+
...(notBookable && stays.length ? { notBookable } : {}),
|
|
7204
7458
|
},
|
|
7205
7459
|
text: [
|
|
7206
7460
|
`**${plan.title}** · ${plan.days.length} ${plan.days.length === 1 ? 'day' : 'days'}. ${gap}`,
|
|
7461
|
+
stays.length ? notBookable : '',
|
|
7207
7462
|
...(stays.length
|
|
7208
7463
|
? [
|
|
7209
7464
|
`Priced stays (${plan.stay?.guests ?? 2} guests; ${t.addToTrip} takes each one's hotel id, room id and dates):`,
|