@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.
Files changed (207) hide show
  1. package/dist/server.d.ts +1 -1
  2. package/dist/server.js +1 -1
  3. package/dist/tools/accept-terms.d.ts +4 -0
  4. package/dist/tools/accept-terms.d.ts.map +1 -0
  5. package/dist/tools/accept-terms.js +26 -0
  6. package/dist/tools/accept-terms.js.map +1 -0
  7. package/dist/tools/add-booking-addon.d.ts +4 -0
  8. package/dist/tools/add-booking-addon.d.ts.map +1 -0
  9. package/dist/tools/add-booking-addon.js +44 -0
  10. package/dist/tools/add-booking-addon.js.map +1 -0
  11. package/dist/tools/add-to-trip.d.ts +4 -0
  12. package/dist/tools/add-to-trip.d.ts.map +1 -0
  13. package/dist/tools/add-to-trip.js +49 -0
  14. package/dist/tools/add-to-trip.js.map +1 -0
  15. package/dist/tools/all-tools.d.ts +1342 -0
  16. package/dist/tools/all-tools.d.ts.map +1 -0
  17. package/dist/tools/all-tools.js +954 -0
  18. package/dist/tools/all-tools.js.map +1 -0
  19. package/dist/tools/answer.d.ts +3 -0
  20. package/dist/tools/answer.d.ts.map +1 -0
  21. package/dist/tools/answer.js +104 -0
  22. package/dist/tools/answer.js.map +1 -0
  23. package/dist/tools/args.d.ts +149 -0
  24. package/dist/tools/args.d.ts.map +1 -0
  25. package/dist/tools/args.js +176 -0
  26. package/dist/tools/args.js.map +1 -0
  27. package/dist/tools/base-output-schemas.d.ts +3 -0
  28. package/dist/tools/base-output-schemas.d.ts.map +1 -0
  29. package/dist/tools/base-output-schemas.js +380 -0
  30. package/dist/tools/base-output-schemas.js.map +1 -0
  31. package/dist/tools/book-picked.d.ts +4 -0
  32. package/dist/tools/book-picked.d.ts.map +1 -0
  33. package/dist/tools/book-picked.js +14 -0
  34. package/dist/tools/book-picked.js.map +1 -0
  35. package/dist/tools/booking-answer.d.ts +24 -0
  36. package/dist/tools/booking-answer.d.ts.map +1 -0
  37. package/dist/tools/booking-answer.js +485 -0
  38. package/dist/tools/booking-answer.js.map +1 -0
  39. package/dist/tools/buy-shop-item.d.ts +4 -0
  40. package/dist/tools/buy-shop-item.d.ts.map +1 -0
  41. package/dist/tools/buy-shop-item.js +45 -0
  42. package/dist/tools/buy-shop-item.js.map +1 -0
  43. package/dist/tools/call.d.ts +11 -0
  44. package/dist/tools/call.d.ts.map +1 -0
  45. package/dist/tools/call.js +2 -0
  46. package/dist/tools/call.js.map +1 -0
  47. package/dist/tools/cancel-facts.d.ts +281 -0
  48. package/dist/tools/cancel-facts.d.ts.map +1 -0
  49. package/dist/tools/cancel-facts.js +309 -0
  50. package/dist/tools/cancel-facts.js.map +1 -0
  51. package/dist/tools/cancel.d.ts +4 -0
  52. package/dist/tools/cancel.d.ts.map +1 -0
  53. package/dist/tools/cancel.js +364 -0
  54. package/dist/tools/cancel.js.map +1 -0
  55. package/dist/tools/card-addons.d.ts +4 -0
  56. package/dist/tools/card-addons.d.ts.map +1 -0
  57. package/dist/tools/card-addons.js +76 -0
  58. package/dist/tools/card-addons.js.map +1 -0
  59. package/dist/tools/change-booking.d.ts +4 -0
  60. package/dist/tools/change-booking.d.ts.map +1 -0
  61. package/dist/tools/change-booking.js +145 -0
  62. package/dist/tools/change-booking.js.map +1 -0
  63. package/dist/tools/clear-trip.d.ts +4 -0
  64. package/dist/tools/clear-trip.d.ts.map +1 -0
  65. package/dist/tools/clear-trip.js +10 -0
  66. package/dist/tools/clear-trip.js.map +1 -0
  67. package/dist/tools/compare.d.ts +4 -0
  68. package/dist/tools/compare.d.ts.map +1 -0
  69. package/dist/tools/compare.js +114 -0
  70. package/dist/tools/compare.js.map +1 -0
  71. package/dist/tools/current-trip.d.ts +70 -0
  72. package/dist/tools/current-trip.d.ts.map +1 -0
  73. package/dist/tools/current-trip.js +261 -0
  74. package/dist/tools/current-trip.js.map +1 -0
  75. package/dist/tools/deps.d.ts +229 -0
  76. package/dist/tools/deps.d.ts.map +1 -0
  77. package/dist/tools/deps.js +2 -0
  78. package/dist/tools/deps.js.map +1 -0
  79. package/dist/tools/follow-ups.d.ts +120 -0
  80. package/dist/tools/follow-ups.d.ts.map +1 -0
  81. package/dist/tools/follow-ups.js +369 -0
  82. package/dist/tools/follow-ups.js.map +1 -0
  83. package/dist/tools/forget-preferences.d.ts +4 -0
  84. package/dist/tools/forget-preferences.d.ts.map +1 -0
  85. package/dist/tools/forget-preferences.js +24 -0
  86. package/dist/tools/forget-preferences.js.map +1 -0
  87. package/dist/tools/get-hotel.d.ts +4 -0
  88. package/dist/tools/get-hotel.d.ts.map +1 -0
  89. package/dist/tools/get-hotel.js +324 -0
  90. package/dist/tools/get-hotel.js.map +1 -0
  91. package/dist/tools/hotel-choices.d.ts +132 -0
  92. package/dist/tools/hotel-choices.d.ts.map +1 -0
  93. package/dist/tools/hotel-choices.js +558 -0
  94. package/dist/tools/hotel-choices.js.map +1 -0
  95. package/dist/tools/itinerary.d.ts +4 -0
  96. package/dist/tools/itinerary.d.ts.map +1 -0
  97. package/dist/tools/itinerary.js +148 -0
  98. package/dist/tools/itinerary.js.map +1 -0
  99. package/dist/tools/list-booking-addons.d.ts +4 -0
  100. package/dist/tools/list-booking-addons.d.ts.map +1 -0
  101. package/dist/tools/list-booking-addons.js +21 -0
  102. package/dist/tools/list-booking-addons.js.map +1 -0
  103. package/dist/tools/list-bookings.d.ts +4 -0
  104. package/dist/tools/list-bookings.d.ts.map +1 -0
  105. package/dist/tools/list-bookings.js +119 -0
  106. package/dist/tools/list-bookings.js.map +1 -0
  107. package/dist/tools/list-extras.d.ts +4 -0
  108. package/dist/tools/list-extras.d.ts.map +1 -0
  109. package/dist/tools/list-extras.js +90 -0
  110. package/dist/tools/list-extras.js.map +1 -0
  111. package/dist/tools/list-hotels.d.ts +4 -0
  112. package/dist/tools/list-hotels.d.ts.map +1 -0
  113. package/dist/tools/list-hotels.js +891 -0
  114. package/dist/tools/list-hotels.js.map +1 -0
  115. package/dist/tools/list-shop-items.d.ts +4 -0
  116. package/dist/tools/list-shop-items.d.ts.map +1 -0
  117. package/dist/tools/list-shop-items.js +34 -0
  118. package/dist/tools/list-shop-items.js.map +1 -0
  119. package/dist/tools/list-shop-orders.d.ts +4 -0
  120. package/dist/tools/list-shop-orders.d.ts.map +1 -0
  121. package/dist/tools/list-shop-orders.js +22 -0
  122. package/dist/tools/list-shop-orders.js.map +1 -0
  123. package/dist/tools/look-up.d.ts +4 -0
  124. package/dist/tools/look-up.d.ts.map +1 -0
  125. package/dist/tools/look-up.js +170 -0
  126. package/dist/tools/look-up.js.map +1 -0
  127. package/dist/tools/output-schemas.d.ts +645 -0
  128. package/dist/tools/output-schemas.d.ts.map +1 -0
  129. package/dist/tools/output-schemas.js +503 -0
  130. package/dist/tools/output-schemas.js.map +1 -0
  131. package/dist/tools/paid-lines.d.ts +718 -0
  132. package/dist/tools/paid-lines.d.ts.map +1 -0
  133. package/dist/tools/paid-lines.js +359 -0
  134. package/dist/tools/paid-lines.js.map +1 -0
  135. package/dist/tools/pay-with-union-pay.d.ts +4 -0
  136. package/dist/tools/pay-with-union-pay.d.ts.map +1 -0
  137. package/dist/tools/pay-with-union-pay.js +112 -0
  138. package/dist/tools/pay-with-union-pay.js.map +1 -0
  139. package/dist/tools/payment-words.d.ts +269 -0
  140. package/dist/tools/payment-words.d.ts.map +1 -0
  141. package/dist/tools/payment-words.js +365 -0
  142. package/dist/tools/payment-words.js.map +1 -0
  143. package/dist/tools/pick-room.d.ts +4 -0
  144. package/dist/tools/pick-room.d.ts.map +1 -0
  145. package/dist/tools/pick-room.js +23 -0
  146. package/dist/tools/pick-room.js.map +1 -0
  147. package/dist/tools/policies.d.ts +4 -0
  148. package/dist/tools/policies.d.ts.map +1 -0
  149. package/dist/tools/policies.js +74 -0
  150. package/dist/tools/policies.js.map +1 -0
  151. package/dist/tools/pricing.d.ts +55 -0
  152. package/dist/tools/pricing.d.ts.map +1 -0
  153. package/dist/tools/pricing.js +260 -0
  154. package/dist/tools/pricing.js.map +1 -0
  155. package/dist/tools/put-room-line.d.ts +12 -0
  156. package/dist/tools/put-room-line.d.ts.map +1 -0
  157. package/dist/tools/put-room-line.js +314 -0
  158. package/dist/tools/put-room-line.js.map +1 -0
  159. package/dist/tools/quote-card.d.ts +234 -0
  160. package/dist/tools/quote-card.d.ts.map +1 -0
  161. package/dist/tools/quote-card.js +375 -0
  162. package/dist/tools/quote-card.js.map +1 -0
  163. package/dist/tools/refund-booking.d.ts +4 -0
  164. package/dist/tools/refund-booking.d.ts.map +1 -0
  165. package/dist/tools/refund-booking.js +112 -0
  166. package/dist/tools/refund-booking.js.map +1 -0
  167. package/dist/tools/request-booking.d.ts +4 -0
  168. package/dist/tools/request-booking.d.ts.map +1 -0
  169. package/dist/tools/request-booking.js +5 -0
  170. package/dist/tools/request-booking.js.map +1 -0
  171. package/dist/tools/request-words.d.ts +238 -0
  172. package/dist/tools/request-words.d.ts.map +1 -0
  173. package/dist/tools/request-words.js +487 -0
  174. package/dist/tools/request-words.js.map +1 -0
  175. package/dist/tools/room-choices.d.ts +64 -0
  176. package/dist/tools/room-choices.d.ts.map +1 -0
  177. package/dist/tools/room-choices.js +348 -0
  178. package/dist/tools/room-choices.js.map +1 -0
  179. package/dist/tools/session-notes.d.ts +164 -0
  180. package/dist/tools/session-notes.d.ts.map +1 -0
  181. package/dist/tools/session-notes.js +412 -0
  182. package/dist/tools/session-notes.js.map +1 -0
  183. package/dist/tools/sign-in.d.ts +4 -0
  184. package/dist/tools/sign-in.d.ts.map +1 -0
  185. package/dist/tools/sign-in.js +72 -0
  186. package/dist/tools/sign-in.js.map +1 -0
  187. package/dist/tools/sign-out.d.ts +4 -0
  188. package/dist/tools/sign-out.d.ts.map +1 -0
  189. package/dist/tools/sign-out.js +13 -0
  190. package/dist/tools/sign-out.js.map +1 -0
  191. package/dist/tools/terms-answer.d.ts +114 -0
  192. package/dist/tools/terms-answer.d.ts.map +1 -0
  193. package/dist/tools/terms-answer.js +475 -0
  194. package/dist/tools/terms-answer.js.map +1 -0
  195. package/dist/tools/tool-set.d.ts +1474 -0
  196. package/dist/tools/tool-set.d.ts.map +1 -0
  197. package/dist/tools/tool-set.js +497 -0
  198. package/dist/tools/tool-set.js.map +1 -0
  199. package/dist/tools/view-trip.d.ts +4 -0
  200. package/dist/tools/view-trip.d.ts.map +1 -0
  201. package/dist/tools/view-trip.js +7 -0
  202. package/dist/tools/view-trip.js.map +1 -0
  203. package/dist/tools.d.ts +13 -2089
  204. package/dist/tools.d.ts.map +1 -1
  205. package/dist/tools.js +11 -10685
  206. package/dist/tools.js.map +1 -1
  207. package/package.json +1 -1
@@ -0,0 +1,412 @@
1
+ import { unansweredBy } from '../backend.js';
2
+ import { MAX_GUESTS } from '../dates.js';
3
+ import { MAX_EXTRA_QUANTITY, MAX_ROOMS_PER_LINE, tripKey } from '../trip.js';
4
+ import { keyBrandOf } from '../vocab.js';
5
+ import { str } from './args.js';
6
+ import { common } from './paid-lines.js';
7
+ import { listOrWords, withZh } from './quote-card.js';
8
+ export const identity = (deps, ctx, key, args = {}) => {
9
+ const email = str(args.email);
10
+ const member = deps.members.read(key);
11
+ const own = ctx.conversation ?? tripKey(ctx.session, keyBrandOf(deps.vocab));
12
+ return {
13
+ // ⚠️ THE CALLER'S OWN SESSION, NEVER THE TRIP IT NAMED. This was the trip
14
+ // key, so that the card - on a connection of its own - could cancel what
15
+ // the conversation booked. But a trip id travels in every card answer, and
16
+ // it opened every booking of that conversation, names and emails and all,
17
+ // from any connection or none (2026-10-05 audit). A trip id is for the
18
+ // trip; a booking opens by its conversation, or by its code AND email,
19
+ // which is what the card now sends.
20
+ sessionId: own,
21
+ ...(key !== own ? { tripOwner: key } : {}),
22
+ ...(email ? { email } : {}),
23
+ // ⚠️ THE MEMBER BUYS A RATE, NOT A LOOKUP. `listBookings` and the
24
+ // cancellation tools still key on the conversation and on the email the
25
+ // booking was made with - a membership number plus a surname is what a desk
26
+ // checks, not authentication, and it must never become a way to read
27
+ // somebody else's booking.
28
+ ...(member ? { member } : {}),
29
+ // Only a booking limit reads it - see `Identity.ip`.
30
+ ...(ctx.ip ? { ip: ctx.ip } : {}),
31
+ };
32
+ };
33
+ /**
34
+ * What the last preview of each booking's cancellation or change showed, per
35
+ * conversation.
36
+ *
37
+ * ⚠️ A CONFIRMATION CONFIRMS WHAT WAS SHOWN. A cancellation previewed at no
38
+ * charge and confirmed after the free window closed was cancelled for a
39
+ * night's rate nobody had been shown; a `confirmed` with no preview at all was
40
+ * cancelled on the spot (2026-09-28 audit). Now a confirmation goes through
41
+ * only when the fee - or the change's new total - is the one last shown in
42
+ * this conversation; otherwise it answers with the preview again.
43
+ */
44
+ const shownPreviews = new WeakMap();
45
+ const MAX_SHOWN = 5_000;
46
+ export const previewsOf = (deps) => {
47
+ let m = shownPreviews.get(deps);
48
+ if (!m) {
49
+ m = new Map();
50
+ shownPreviews.set(deps, m);
51
+ }
52
+ return m;
53
+ };
54
+ export const remember = (deps, k, amount) => {
55
+ const m = previewsOf(deps);
56
+ m.delete(k);
57
+ m.set(k, amount);
58
+ while (m.size > MAX_SHOWN) {
59
+ const oldest = m.keys().next().value;
60
+ if (oldest === undefined)
61
+ break;
62
+ m.delete(oldest);
63
+ }
64
+ };
65
+ /**
66
+ * The refund previews' tokens, per conversation and booking (`${key}|refund|${id}`).
67
+ * ⚠️ SERVER-SIDE ONLY: the token is what lets a refund be asked, and goes to
68
+ * neither the model nor the card - the card asks again with `confirmed`.
69
+ */
70
+ const refundTokens = new WeakMap();
71
+ export const refundTokensOf = (deps) => {
72
+ let m = refundTokens.get(deps);
73
+ if (!m) {
74
+ m = new Map();
75
+ refundTokens.set(deps, m);
76
+ }
77
+ return m;
78
+ };
79
+ export const rememberRefund = (deps, k, preview, until) => {
80
+ const m = refundTokensOf(deps);
81
+ m.delete(k);
82
+ m.set(k, { preview, until });
83
+ while (m.size > MAX_SHOWN) {
84
+ const oldest = m.keys().next().value;
85
+ if (oldest === undefined)
86
+ break;
87
+ m.delete(oldest);
88
+ }
89
+ };
90
+ /** "a, b and c" - "a and b" - "a". */
91
+ export const listAnd = (xs) => xs.length > 1 ? `${xs.slice(0, -1).join(', ')} and ${xs.at(-1)}` : (xs[0] ?? '');
92
+ /**
93
+ * What the model does when a hotel group did not answer: tells the guest, and
94
+ * leaves asking again to them - said after the sentence that names the groups,
95
+ * in the text and in `structuredContent` alike.
96
+ *
97
+ * ⚠️ NEVER "ASKING AGAIN IN A MOMENT MAY BRING THEM" (robin 11-04). Read as
98
+ * "ask again now", it had the model call the list a second time in the same
99
+ * turn: two of the same card under 「打开 Otaless」 on claude.ai, with every
100
+ * group of the backend silent. The guest asks again: with the card's 「重试」
101
+ * where a card was drawn, in words where none was.
102
+ */
103
+ export const askLater = (card) => card
104
+ ? 'Do not look again in this turn - no second call for it: tell the guest, who can press Try again (重试) on the card when they want to look again.'
105
+ : 'Do not look again in this turn - no second call for it: tell the guest, and that they can ask you to look again later.';
106
+ /** The groups a failed stay names (Otaless's `link-first`, 0.74.5) - codes only. */
107
+ export const groupsOfFailed = (f) => {
108
+ const g = f.groups;
109
+ return Array.isArray(g)
110
+ ? [...new Set(g.filter((x) => typeof x === 'string' && !!x))]
111
+ : [];
112
+ };
113
+ /** No group kept quiet about - `degradedOf`'s default. */
114
+ const NONE_QUIET = new Set();
115
+ /**
116
+ * The groups of a market that did not answer a search, as the sentence the
117
+ * model is told and the fields the card draws its own line from - the same
118
+ * list in both (`HotelSearchResult.degraded`).
119
+ *
120
+ * ⚠️ "DID NOT ANSWER" IS NOT "HAS NONE". A list without Atour's hotels, from
121
+ * an Atour that timed out, reads to a guest as a city where Atour has no
122
+ * hotel. The sentence says the first and denies the second, in the text and in
123
+ * `structuredContent` alike - a host with no card has only the words.
124
+ */
125
+ export const degradedOf = (deps, answer,
126
+ /** What is missing from the list: the hotels of a search, the bookings of "my bookings". */
127
+ noun = deps.vocab.nounPlural,
128
+ /**
129
+ * The client draws no card: each group's own Chinese name goes beside its
130
+ * name, as a hotel's does (`withZh`) - told only "JI Hotel", a model with no
131
+ * card called it 锦江之星, another group (11-03, text-only eval). A card host
132
+ * is told the English name alone; the card says the group in its own words.
133
+ */
134
+ noCards = false,
135
+ /** This answer draws a card, with its 「重试」 (`askLater`) - not so for `look_up`, which draws none. */
136
+ card = !noCards,
137
+ /**
138
+ * The groups kept quiet about here - a search's (`quietIn`), never a list of bookings.
139
+ *
140
+ * ⚠️ NOT A REMINDER EVERY TIME (robin 11-16: 「有 Accor 酒店的城市显示 Accor 就好了,没有的
141
+ * 默认就是不显示,没必要一直提醒」). A quiet group that did not answer, or was not looked
142
+ * up without a place, is left out of `degraded` - so no card draws a line for it, an
143
+ * old one neither - and said in `quietSaid` as a fact, in the text alike: mention it
144
+ * only if the guest asks about that group. No 「重试」, no "name a city".
145
+ */
146
+ quiet = NONE_QUIET,
147
+ /**
148
+ * ⚠️ A SEARCH THAT HAS SOMETHING TO SHOW DOES NOT REMIND THE GUEST OF A GROUP THAT DID NOT
149
+ * ANSWER (0.74.4, robin 11-17: 「没关系,报错的就这样灰着就行,不用有报错信息」 - Otaless's home
150
+ * with a grey 「shopify」 under 「shopify didn't respond just now… Try again」, its /site
151
+ * listing a group with no LIST_HOTELS, 60411). Set, a group that did not answer - every
152
+ * group, every deployment - is said as a group kept quiet about is: a fact in `quietSaid`
153
+ * and the text alike, to mention only if the guest asks about it; no 「重试」, no "do not
154
+ * look again". It stays in `degraded`, which the card draws as a greyed chip, nothing more.
155
+ * Not set where nothing is shown because of it (a search with nothing read), nor for "my
156
+ * bookings" and the rest. A search of the group the guest asked for by name is always that:
157
+ * only that group is asked, so one that did not answer leaves nothing read - and is said.
158
+ */
159
+ hush = false) => {
160
+ const all = answer.degraded ?? [];
161
+ if (all.length === 0)
162
+ return { structured: {}, said: '' };
163
+ const named = (d) => withZh(d.name, d.names, noCards);
164
+ const hushed = all.filter((d) => quiet.has(d.supplier));
165
+ const down = all.filter((d) => !quiet.has(d.supplier));
166
+ /** Did not answer, said only as the fact (`hush`) - and still drawn greyed. */
167
+ const softly = (d) => hush && d.why !== 'needs-place';
168
+ const loud = down.filter((d) => !softly(d));
169
+ // In the market's own order: a group kept quiet beside one said softly is one sentence.
170
+ const factSilent = all.filter((d) => d.why !== 'needs-place' && (quiet.has(d.supplier) || softly(d)));
171
+ const hushedUnplaced = hushed.filter((d) => d.why === 'needs-place');
172
+ const noneOf = (n) => `so none of ${n === 1 ? 'its' : 'their'} ${noun} is in this list`;
173
+ // ⚠️ A GROUP LOOKED UP ONLY WITH A PLACE IS ONE THE GUEST CAN STILL HAVE (0.74.6, robin 11-17
174
+ // (a): Accor on the home is a chip, pressed it asks for a country or a city): asked about it,
175
+ // the model asks which country or city - with the cities it is known to have hotels in.
176
+ const quietSaid = [
177
+ factSilent.length
178
+ ? `${listAnd(factSilent.map(named))} did not answer this time, ${noneOf(factSilent.length)}; mention this only if the guest asks about ${listOrWords(factSilent.map(named))}.`
179
+ : '',
180
+ hushedUnplaced.length
181
+ ? `${listAnd(hushedUnplaced.map(named))} ${hushedUnplaced.length === 1 ? 'is' : 'are'} looked up only once a country or a city is named, ${noneOf(hushedUnplaced.length)}; if the guest asks about ${listOrWords(hushedUnplaced.map(named))}, ask which country or city${placesWords(hushedUnplaced, named)}.`
182
+ : '',
183
+ ]
184
+ .filter(Boolean)
185
+ .join(' ');
186
+ const quietPart = {
187
+ ...(hushed.length
188
+ ? {
189
+ quietGroups: hushed.map((d) => ({
190
+ supplier: d.supplier,
191
+ name: d.name,
192
+ ...(d.why ? { why: d.why } : {}),
193
+ })),
194
+ }
195
+ : {}),
196
+ ...(quietSaid ? { quietSaid } : {}),
197
+ };
198
+ if (down.length === 0)
199
+ return { structured: quietPart, said: quietSaid };
200
+ // Every one that did not answer, greyed on the card - said aloud or not.
201
+ const degraded = down.map((d) => ({
202
+ supplier: d.supplier,
203
+ name: d.name,
204
+ ...(d.why ? { why: d.why } : {}),
205
+ }));
206
+ if (loud.length === 0)
207
+ return { structured: { degraded, ...quietPart }, said: quietSaid };
208
+ // ⚠️ A GROUP NOT LOOKED UP IS NOT A GROUP THAT DID NOT ANSWER (0.67.0, 总线程
209
+ // 11-11): Accor is found only with a country or a city named. Said as that,
210
+ // beside - not instead of - the groups that really were silent.
211
+ const silent = loud.filter((d) => d.why !== 'needs-place');
212
+ const unplaced = loud.filter((d) => d.why === 'needs-place');
213
+ const saidOf = (list) => listAnd(list.map((d) => withZh(d.name, d.names, noCards)));
214
+ const parts = [];
215
+ if (silent.length) {
216
+ const one = silent.length === 1;
217
+ parts.push(`${saidOf(silent)} did not answer in time, so none of ${one ? 'its' : 'their'} ${noun} is in this list - this does not mean ${one ? 'it has' : 'they have'} none here. ${askLater(card)}`);
218
+ }
219
+ if (unplaced.length) {
220
+ const one = unplaced.length === 1;
221
+ parts.push(`${saidOf(unplaced)} ${one ? 'is' : 'are'} looked up only once a country or a city is named - ask the guest which country or city${placesWords(unplaced, (d) => withZh(d.name, d.names, noCards))}, and name it to see ${one ? 'its' : 'their'} ${noun}.`);
222
+ }
223
+ const said = parts.join(' ');
224
+ return {
225
+ structured: {
226
+ degraded,
227
+ degradedSaid: said,
228
+ ...quietPart,
229
+ },
230
+ said: [said, quietSaid].filter(Boolean).join(' '),
231
+ };
232
+ };
233
+ /**
234
+ * " (Accor has hotels in Singapore, Paris and Tokyo, among others)" - the cities a group looked
235
+ * up only with a place is known to have hotels in (`Unanswered.places`, 0.74.6), or nothing.
236
+ */
237
+ const placesWords = (groups,
238
+ /** The group as the rest of the sentence names it (with its Chinese name to a host with no card). */
239
+ named = (g) => g.name) => {
240
+ const said = groups
241
+ .filter((g) => g.places?.length)
242
+ .map((g) => `${named(g)} has hotels in ${listAnd((g.places ?? []).map((p) => p.name))}`);
243
+ return said.length ? ` (${said.join('; ')}, among others)` : '';
244
+ };
245
+ /**
246
+ * The groups a search keeps quiet about (`ToolDeps.quietGroups`) - less the one
247
+ * the guest asked for (`filters.supplier`): a list of Accor's own hotels that
248
+ * has none because Accor did not answer says so, with its 「重试」.
249
+ */
250
+ export const quietIn = (deps, asked) => {
251
+ const quiet = deps.quietGroups;
252
+ if (!quiet?.size)
253
+ return NONE_QUIET;
254
+ if (!asked || !quiet.has(asked))
255
+ return quiet;
256
+ return new Set([...quiet].filter((g) => g !== asked));
257
+ };
258
+ /**
259
+ * A place no table here knows (`HotelSearchResult.unplaced`), as the sentence the
260
+ * model is told and the field the card draws its own line from.
261
+ *
262
+ * ⚠️ NEVER "N HOTELS IN REYKJAVIK" (总线程 11-04, 0.55.5). Words that name no
263
+ * place this market knows narrow nothing, and the backend answers a place it
264
+ * cannot match with every hotel each group has - so the list is Sanya's,
265
+ * Singapore's, Tokyo's. Said once, in the text and in `structuredContent`
266
+ * alike: a host with no card has only the words.
267
+ */
268
+ export const unplacedOf = (deps, answer,
269
+ /** The words were a `city` - or a guest's own words (`query`), a place looked for inside them. */
270
+ asCity) => {
271
+ const place = answer.unplaced?.trim();
272
+ if (!place)
273
+ return { structured: {}, said: '' };
274
+ const n = deps.vocab.nounPlural;
275
+ const said = `${asCity ? `"${place}" was not recognised as a place` : `No place was recognised in "${place}"`}, so these are the ${n} the groups returned, each in its own city - they are not ${n} in the place asked for, and are not to be called that.`;
276
+ return { structured: { unplaced: place, unplacedSaid: said }, said };
277
+ };
278
+ /**
279
+ * What is said when a read could not be had because hotel groups did not answer
280
+ * in time - one group, or several, or every one.
281
+ *
282
+ * ⚠️ NEVER JUST THE FIRST GROUP, NEVER "NONE HERE" (2026-11-03 review, C5/C8).
283
+ * Where every group of a market is silent it says so ("no group answered this
284
+ * time"), not the name of whichever was asked first; and in every case it
285
+ * denies the reading a guest would make of silence, that there is nothing.
286
+ */
287
+ export const notAnswered = (deps, key, down,
288
+ /** The answer draws a card, with its 「重试」 - see `askLater`. */
289
+ card) => {
290
+ const groups = deps.backend.suppliers?.().length ?? 0;
291
+ const names = listAnd(down.map((d) => d.name));
292
+ const one = down.length === 1;
293
+ const said = groups > 1 && down.length >= groups
294
+ ? `No hotel group answered this time: ${names} did not answer in time - this does not mean there is nothing here. ${askLater(card)}`
295
+ : `${names} did not answer in time, so nothing from ${one ? 'it' : 'them'} could be read just now - this does not mean ${one ? 'it has' : 'they have'} none here. ${askLater(card)}`;
296
+ return {
297
+ structured: {
298
+ view: 'error',
299
+ ...common(deps, key),
300
+ error: 'supplier-timeout',
301
+ detail: said,
302
+ degraded: down.map((d) => ({ supplier: d.supplier, name: d.name })),
303
+ degradedSaid: said,
304
+ },
305
+ text: said,
306
+ // Like `bad-count`: the card still draws it, and a host that checks a
307
+ // result against the tool's output schema does not hold an error to it.
308
+ isError: true,
309
+ };
310
+ };
311
+ /** The counts a call can carry, and what each may be. */
312
+ const COUNTS = ['guests', 'rooms', 'quantity'];
313
+ /** "2" is 2: a host that sends a count as a string has not asked for something else. */
314
+ export const countsAsNumbers = (args) => {
315
+ const out = { ...args };
316
+ for (const f of COUNTS) {
317
+ const v = out[f];
318
+ if (typeof v === 'string' && /^\s*-?\d+\s*$/.test(v))
319
+ out[f] = Number(v);
320
+ }
321
+ return out;
322
+ };
323
+ /**
324
+ * Why a count in this call is not one this connector takes - or nothing.
325
+ *
326
+ * ⚠️ REFUSED, NOT QUIETLY MADE INTO SOMETHING ELSE (2026-10-05 audit, P2):
327
+ * six rooms became five, -1 became 1 and a billion became five, and the answer
328
+ * spoke as if that was what had been asked. A guest who asked for six rooms
329
+ * has to hear that five is the most, not be booked five.
330
+ */
331
+ export const countProblem = (t, name, args) => {
332
+ const check = (field, min, max) => {
333
+ const v = args[field];
334
+ if (v === undefined || v === null)
335
+ return undefined;
336
+ if (typeof v === 'number' && Number.isInteger(v) && v >= min && v <= max)
337
+ return undefined;
338
+ return `\`${field}\` has to be a whole number from ${min} to ${max}, and ${JSON.stringify(v)} is not - nothing was changed. Ask the guest, or use a number in that range.`;
339
+ };
340
+ // 0 means something here: take the line out of the trip, or - on a change -
341
+ // the backend's own "a booking keeps at least one room; cancel it instead".
342
+ const removes = name === t.addToTrip ||
343
+ name === t.pickRoom ||
344
+ name === t.previewChange ||
345
+ name === t.changeBooking;
346
+ return (check('guests', 1, MAX_GUESTS) ??
347
+ check('rooms', removes ? 0 : 1, MAX_ROOMS_PER_LINE) ??
348
+ check('quantity', 0, MAX_EXTRA_QUANTITY));
349
+ };
350
+ /**
351
+ * What a backend's refusal says, for the guest - or, when the failure is the
352
+ * code's own, a sentence that says nothing about the code.
353
+ *
354
+ * ⚠️ A REFUSAL IS WORDS FOR THE GUEST; A FAULT IS NOT. Every backend refuses
355
+ * with a plain Error, or one carrying a `code`, and those words are written to
356
+ * be read back ("Nothing was booked: ..."). A TypeError's words - "Cannot read
357
+ * properties of null" - were read back too (2026-10-05 audit); they go to the
358
+ * log now.
359
+ */
360
+ export const guestWords = (err,
361
+ // Not "try again in a moment" (robin 11-04): the guest asks for it again.
362
+ fault = 'That could not be done just now - nothing was changed. Tell the guest; they can ask for it again later.') => {
363
+ const e = err;
364
+ // ⚠️ A READ THAT TIMED OUT IS NOT A REFUSAL (2026-11-03 review, C5). After a
365
+ // booking was made, "Atour did not answer within 8000 ms" would be read
366
+ // back as the booking's own answer - and sound like it was not made.
367
+ if (unansweredBy(err)) {
368
+ console.error('[tools] a read timed out:', e.message);
369
+ return fault;
370
+ }
371
+ if (e instanceof Error && (typeof e.code === 'string' || e.constructor === Error))
372
+ return e.message;
373
+ console.error('[tools] failed:', err);
374
+ return fault;
375
+ };
376
+ /**
377
+ * A booking's own fault sentence. ⚠️ IT CANNOT SAY "NOTHING WAS CHANGED": the
378
+ * fault may come after the backend has booked (华住's review, 2026-10-05), and
379
+ * a guest told nothing happened books again.
380
+ */
381
+ export const BOOKING_FAULT = 'It is not certain whether that booked - list the bookings before asking for it again.';
382
+ /** Said when a lookup has missed too often - see limits.ts. */
383
+ export const TOO_MANY_TRIES = 'Too many codes and emails that did not match, so looking a booking up by email is paused for a quarter of an hour. Check the code and the email on the confirmation, then try again.';
384
+ /**
385
+ * A booking lookup, with any email in it counted as a guess.
386
+ *
387
+ * ⚠️ A CODE AND AN EMAIL ARE ONLY A PAIR WHEN SOMETHING COUNTS THE MISSES. A
388
+ * miss that carried an email is counted against the conversation AND the
389
+ * email; after a few, lookups by email wait (limits.ts). A lookup of this
390
+ * conversation's own booking, with no email, is never counted and never waits.
391
+ */
392
+ export const guarded = async (deps, ctx, who, code, run) => {
393
+ // ⚠️ NOT ONLY THE CONVERSATION. Counted against the conversation alone, a
394
+ // guesser started a new one - or sent none - after every five (2026-10-05
395
+ // audit). So also against the CODE, which stops "I know the code, let me
396
+ // guess the email", and the network address, which stops the rest.
397
+ const keys = who.email
398
+ ? [
399
+ `lookup|${who.sessionId}`,
400
+ `email|${who.email.trim().toLowerCase()}`,
401
+ ...(code ? [`code|${code.trim().toLowerCase()}`] : []),
402
+ ...(ctx.ip ? [`ip|${ctx.ip}`] : []),
403
+ ]
404
+ : [];
405
+ if (keys.length && deps.misses?.blocked(keys))
406
+ return { found: null, tooMany: true };
407
+ const found = await run();
408
+ if (!found && keys.length)
409
+ deps.misses?.miss(keys);
410
+ return { found, tooMany: false };
411
+ };
412
+ //# sourceMappingURL=session-notes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-notes.js","sourceRoot":"","sources":["../../src/tools/session-notes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,IAAc,EACd,GAAgB,EAChB,GAAW,EACX,OAAgC,EAAE,E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AAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACpC;QACH,CAAC,CAAC,EAAE,CAAC;IACP,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACrF,MAAM,KAAK,GAAG,MAAM,GAAG,EAAE,CAAC;IAC1B,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM;QAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACnD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AACnC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ToolCall } from './call.js';
2
+ import type { ToolAnswer } from './deps.js';
3
+ export declare const answerSignIn: ({ deps, name, args, ctx, t, key, }: ToolCall) => Promise<ToolAnswer>;
4
+ //# sourceMappingURL=sign-in.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-in.d.ts","sourceRoot":"","sources":["../../src/tools/sign-in.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAI5C,eAAO,MAAM,YAAY,GAAU,oCAOhC,QAAQ,KAAG,OAAO,CAAC,UAAU,CAkE/B,CAAC"}
@@ -0,0 +1,72 @@
1
+ import { withTrip } from '../trip-ids.js';
2
+ import { aBrandOf } from '../vocab.js';
3
+ import { common } from './paid-lines.js';
4
+ import { MEMBER_NEVER_IN_CHAT, MEMBER_SIGN_IN_META_KEY, memberAnswer } from './quote-card.js';
5
+ export const answerSignIn = async ({ deps, name, args, ctx, t, key, }) => {
6
+ const fromCard = name === t.memberCard;
7
+ // ⚠️ THE CARD'S OWN WHERE A CARD IS DRAWN (app-only, server.ts): a client
8
+ // that draws none is refused it - the code it hands out is the card's alone.
9
+ if (fromCard && ctx.noCards)
10
+ return {
11
+ structured: { view: 'error', ...common(deps, key), code: 'card_only' },
12
+ text: `${t.memberCard} is the booking card's own. ${t.signIn} signs a member in from the chat.`,
13
+ isError: true,
14
+ };
15
+ const signedIn = deps.members.read(key);
16
+ if (signedIn)
17
+ return memberAnswer(deps, key, signedIn, fromCard ? '' : 'Already signed in');
18
+ if (fromCard && args.action !== 'sign_in') {
19
+ return {
20
+ structured: {
21
+ view: 'no-member',
22
+ ...common(deps, key),
23
+ ...(deps.memberLogin?.waiting(key) ? { waiting: true } : {}),
24
+ },
25
+ text: `Nobody is signed in as ${aBrandOf(deps.vocab)} member in this conversation.`,
26
+ };
27
+ }
28
+ const login = deps.memberLogin;
29
+ if (!login)
30
+ return {
31
+ structured: { view: 'error', ...common(deps, key), code: 'no_sign_in_page' },
32
+ text: `Signing in as ${aBrandOf(deps.vocab)} member is not open here.`,
33
+ isError: true,
34
+ };
35
+ const made = login.start(key, { noCards: ctx.noCards, lang: args.lang, ip: ctx.ip });
36
+ if (!made.ok)
37
+ return {
38
+ structured: { view: 'error', ...common(deps, key), code: made.code },
39
+ text: made.code === 'too_many_links'
40
+ ? `Too many sign-in links were asked for in this conversation just now. Wait a few minutes, then ask again. ${MEMBER_NEVER_IN_CHAT}`
41
+ : 'Too many sign-ins are being started just now. Try again in a minute.',
42
+ isError: true,
43
+ };
44
+ const said = { expiresAt: made.expiresAt, expiresInSeconds: made.expiresInSeconds };
45
+ if (ctx.noCards)
46
+ return {
47
+ structured: {
48
+ view: 'member-sign-in',
49
+ ...common(deps, key),
50
+ signedIn: false,
51
+ url: made.url,
52
+ shortCode: made.short,
53
+ ...said,
54
+ },
55
+ text: `A one-time ${deps.vocab.brand} member sign-in page is ready: ${made.url} - the guest opens it in their browser and types their membership number and the surname on it there. ${MEMBER_NEVER_IN_CHAT} The page shows the code ${made.short}: tell the guest it must match the code you give them here, and to close the page if it does not. The link works once, for ${made.minutes} minutes. When they say they are done, call ${t.signIn} again${withTrip(ctx.tripInWords)}: it then answers with their tier and member rate.`,
56
+ };
57
+ // ⚠️ THE LINK AND THE CODE ARE THE CARD'S (as the account's, Nexva's review
58
+ // P1-1): where a card is drawn the model is never handed the short code, so
59
+ // text a page slipped into the chat cannot show a matching one.
60
+ return {
61
+ structured: { view: 'member-sign-in', ...common(deps, key), signedIn: false, ...said },
62
+ text: `A one-time ${deps.vocab.brand} member sign-in page is ready for the guest, opened from the card: they type their membership number and surname on that page. ${MEMBER_NEVER_IN_CHAT} The card shows a code the page shows too, and shows them signed in when they are done; the link works once, for ${made.minutes} minutes.`,
63
+ meta: {
64
+ [MEMBER_SIGN_IN_META_KEY]: {
65
+ url: made.url,
66
+ shortCode: made.short,
67
+ expiresAt: made.expiresAt,
68
+ },
69
+ },
70
+ };
71
+ };
72
+ //# sourceMappingURL=sign-in.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-in.js","sourceRoot":"","sources":["../../src/tools/sign-in.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE9F,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,EACjC,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,CAAC,EACD,GAAG,GACM,EAAuB,EAAE;IAClC,MAAM,QAAQ,GAAG,IAAI,KAAK,CAAC,CAAC,UAAU,CAAC;IACvC,0EAA0E;IAC1E,6EAA6E;IAC7E,IAAI,QAAQ,IAAI,GAAG,CAAC,OAAO;QACzB,OAAO;YACL,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE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G,IAAI,EAAE;QACtF,IAAI,EAAE,cAAc,IAAI,CAAC,KAAK,CAAC,KAAK,kIAAkI,oBAAoB,oHAAoH,IAAI,CAAC,OAAO,WAAW;QACrU,IAAI,EAAE;YACJ,CAAC,uBAAuB,CAAC,EAAE;gBACzB,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,SAAS,EAAE,IAAI,CAAC,KAAK;gBACrB,SAAS,EAAE,IAAI,CAAC,SAAS;aAC1B;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ToolCall } from './call.js';
2
+ import type { ToolAnswer } from './deps.js';
3
+ export declare const answerSignOut: ({ deps, key }: ToolCall) => Promise<ToolAnswer>;
4
+ //# sourceMappingURL=sign-out.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-out.d.ts","sourceRoot":"","sources":["../../src/tools/sign-out.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAG5C,eAAO,MAAM,aAAa,GAAU,eAAe,QAAQ,KAAG,OAAO,CAAC,UAAU,CAU/E,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { common } from './paid-lines.js';
2
+ export const answerSignOut = async ({ deps, key }) => {
3
+ const was = deps.members.read(key);
4
+ deps.members.clear(key);
5
+ deps.memberLogin?.cancel(key);
6
+ return {
7
+ structured: { view: 'signed-out', ...common(deps, key) },
8
+ text: was
9
+ ? `Signed out of ${was.programme}. Rates are the public ones again; the trip and any bookings are untouched.`
10
+ : 'Nobody was signed in.',
11
+ };
12
+ };
13
+ //# sourceMappingURL=sign-out.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-out.js","sourceRoot":"","sources":["../../src/tools/sign-out.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,EAAY,EAAuB,EAAE;IAClF,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO;QACL,UAAU,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE;QACxD,IAAI,EAAE,GAAG;YACP,CAAC,CAAC,iBAAiB,GAAG,CAAC,SAAS,6EAA6E;YAC7G,CAAC,CAAC,uBAAuB;KAC5B,CAAC;AACJ,CAAC,CAAC"}