@curless/hotel-storefront 0.74.6 → 0.75.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/tools.js CHANGED
@@ -75,6 +75,19 @@ const books = (title, openWorld) => ({
75
75
  idempotentHint: false,
76
76
  openWorldHint: openWorld,
77
77
  });
78
+ /**
79
+ * Places an order with the hotel's group - a booking, or the guest's agreement that sends it
80
+ * (0.75.0, T3). `destructiveHint: true`: OpenAI's rule gives it to "an irreversible send or a
81
+ * transaction", and that the group lets a booking be cancelled afterwards is not a reason to
82
+ * say false. Not idempotent: a second call is a second order.
83
+ */
84
+ const orders = (title, openWorld) => ({
85
+ title,
86
+ readOnlyHint: false,
87
+ destructiveHint: true,
88
+ idempotentHint: false,
89
+ openWorldHint: openWorld,
90
+ });
78
91
  const cancels = (title, openWorld) => ({
79
92
  title,
80
93
  readOnlyHint: false,
@@ -174,6 +187,14 @@ export const withheldTools = (n, caps) => new Set([
174
187
  ]
175
188
  : []),
176
189
  ]);
190
+ /**
191
+ * Orders are the ACCOUNT'S (Otaless, 0.75.0 T5/T6): the group's own checkout with booking on.
192
+ * A booking is found by the account that made it - never by a confirmation code and the email
193
+ * it was made with - and what it sends the group is the guest's name, phone, email, dates and
194
+ * rooms and nothing else (no requests, arrival time or notes). So no tool lists an `email` to
195
+ * find one, nor a field the order has nowhere to carry. (`groupCheckout` is only ever Otaless's.)
196
+ */
197
+ export const ordersByAccount = (caps) => !!caps.groupCheckout && !caps.readOnly;
177
198
  /**
178
199
  * What to tell a guest who wants to book where nothing can be booked yet
179
200
  * (`capabilities.readOnly`) - the same words in the instructions and in each
@@ -351,7 +372,7 @@ const forCapabilities = (tools, n, v, caps) => {
351
372
  if (t.name === n.requestBooking && caps.groupCheckout)
352
373
  out = {
353
374
  ...out,
354
- description: `Books the trip's rooms for a named guest through each hotel group's own checkout, one order per stay with the group that stay belongs to. The group may first send its booking terms back for the guest to read and agree to themselves - on the card or on a one-time page, not in the chat - and its payment page, with its host and the time to pay by, is then in the answer. A stay is booked once it is paid; the bookings list says when it has been. Preferences - a bed type, a floor, a late arrival - ride along on the booking as requests.`,
375
+ description: `Books the trip's rooms for a named guest through each hotel group's own checkout, one order per stay with the group that stay belongs to. The group may first send its booking terms back for the guest to read and agree to themselves - on the card or on a one-time page, not in the chat - and its payment page, with its host and the time to pay by, is then in the answer. A stay is booked once it is paid; the bookings list says when it has been.`,
355
376
  };
356
377
  // A market's suppliers book differently - its own description says so.
357
378
  if (t.name === n.requestBooking && caps.booking === 'pay-at-hotel' && !v.market) {
@@ -370,6 +391,39 @@ const forCapabilities = (tools, n, v, caps) => {
370
391
  };
371
392
  }
372
393
  }
394
+ // ⚠️ ORDERS ARE THE ACCOUNT'S (0.75.0, T5/T6; OpenAI: only the data that is needed).
395
+ // Old chats and old cards may still send `email`, `requests`, `arrivingAt` or `notes`:
396
+ // the server takes them and ignores them (`ordersByAccount`).
397
+ if (ordersByAccount(caps)) {
398
+ if (t.name === n.listBookings) {
399
+ out = {
400
+ ...out,
401
+ // The account's, in any conversation signed in to it (`otaless/booking.ts`
402
+ // `listBookings`: by the sign-in at each order's group) - and nothing when no one is.
403
+ description: `The bookings of the ${v.brand} account signed in here - made in any conversation signed in to it - newest to oldest, with their status, dates and confirmation codes. Nothing is listed when no account is signed in.`,
404
+ inputSchema: (() => {
405
+ const s = without(out.inputSchema, 'email');
406
+ return {
407
+ ...s,
408
+ properties: {
409
+ ...s.properties,
410
+ booking: {
411
+ ...s.properties.booking,
412
+ description: "A confirmation code of this account's",
413
+ },
414
+ },
415
+ };
416
+ })(),
417
+ };
418
+ }
419
+ if (t.name === n.previewCancellation || t.name === n.cancelBooking)
420
+ out = { ...out, inputSchema: without(out.inputSchema, 'email') };
421
+ if (t.name === n.requestBooking || t.name === n.bookPicked)
422
+ out = {
423
+ ...out,
424
+ inputSchema: without(out.inputSchema, 'requests', 'arrivingAt', 'notes'),
425
+ };
426
+ }
373
427
  // ⚠️ ONE CANCEL, WHICH ASKS THE REFUND TOO (0.74.2, robin 11-17): said by the tool
374
428
  // itself, for the model in every client - there is no refund tool to reach for.
375
429
  if (t.name === n.cancelBooking && caps.refunds && !caps.readOnly)
@@ -669,7 +723,7 @@ const allTools = (n, v) => {
669
723
  : v.demo
670
724
  ? `Makes a booking request for the trip's rooms, for a named guest: it returns a confirmation code and the moment the hold lapses on its own. ${v.brand} does not receive it and no real room is held. No payment is taken and no card is collected. Preferences - a bed type, a floor, a late arrival - ride along on the request.`
671
725
  : `Asks ${v.brand} to hold the trip's rooms for a named guest and returns a confirmation code and the moment the hold lapses. No payment is taken and no card is collected; the rooms are held, not paid for. Preferences - a bed type, a floor, a late arrival - ride along on the booking as requests the desk tries to meet.`,
672
- annotations: books(v.market ? `Request a booking on ${v.brand}` : `Request a ${v.brand} booking`, open),
726
+ annotations: orders(v.market ? `Request a booking on ${v.brand}` : `Request a ${v.brand} booking`, open),
673
727
  inputSchema: {
674
728
  type: 'object',
675
729
  properties: {
@@ -876,7 +930,7 @@ const allTools = (n, v) => {
876
930
  },
877
931
  {
878
932
  name: n.itinerary,
879
- description: `A day-by-day plan (行程) - one card, in an app that draws one - for a trip of several days, or for days a guest asked to have planned (a city with a span of dates and 行程 is one): the days are laid out by where they are spent, and each part of the trip has a ${v.noun} near those days, chosen from the ${v.nounPlural} read up as text. A week in a big city is usually two or three stays: its far-out sights fall on neighbouring days, and those nights have a ${v.noun} near them, with the reason in that day's \`why\` (Beijing's Summer Palace, Yuanmingyuan, Fragrant Hills and the Peking and Tsinghua campuses - 颐和园, 圆明园, 香山, 北大清华 - are days side by side in the north-west); a day out of town, such as the Great Wall, is a day of its own, there and back; one ${v.noun} for the whole week suits days that are all within about 45 minutes of it. Nothing here knows a sight's opening days: each day is laid out as it is given, with its date (many museums close on Mondays, the Palace Museum - 故宫 - among them). Each day carries its own label, an optional note, the moments of the day in order, and the ${v.nounPlural} and add-ons attached to it, with their details filled in from their own records - a ${v.noun} with its photograph and, given dates, the price of its nights. Each stay is marked with whether it is booked, in the trip or only in the plan, and the answer says how many of each. Nothing is added to the trip.`,
933
+ description: `A day-by-day plan (行程) - one card, in an app that draws one - for a trip of several days, or for days a guest asked to have planned (a city with a span of dates and 行程 is one): the days are laid out by where they are spent, and each part of the trip has a ${v.noun} near those days, chosen from the ${v.nounPlural} read up as text. Each day carries its own label, an optional note, the moments of the day in order, and the ${v.nounPlural} and add-ons attached to it, with their details filled in from their own records - a ${v.noun} with its photograph and, given dates, the price of its nights. Each stay is marked with whether it is booked, in the trip or only in the plan, and the answer says how many of each. Nothing is added to the trip.`,
880
934
  annotations: reads(v.market ? `Lay out an itinerary on ${v.brand}` : `Lay out a ${v.brand} itinerary`, open),
881
935
  inputSchema: {
882
936
  type: 'object',
@@ -1067,7 +1121,7 @@ const allTools = (n, v) => {
1067
1121
  // room comes from differs (`bookTripLines`).
1068
1122
  name: n.bookPicked,
1069
1123
  description: "The card's own step when the guest submits the booking form for the room they picked with Reserve: books that one room for the named guest, the way a trip's rooms are booked. Leaves the trip as it is.",
1070
- annotations: books(v.market ? `Book the picked room on ${v.brand}` : `Book the picked ${v.brand} room`, open),
1124
+ annotations: orders(v.market ? `Book the picked room on ${v.brand}` : `Book the picked ${v.brand} room`, open),
1071
1125
  inputSchema: {
1072
1126
  type: 'object',
1073
1127
  properties: {
@@ -1097,7 +1151,7 @@ const allTools = (n, v) => {
1097
1151
  // `ref` only says which terms the card was showing.
1098
1152
  name: n.acceptTerms,
1099
1153
  description: `The card's own step when the guest presses "Agree and continue" under a hotel group's booking terms: it sends the guest's agreement to the terms behind \`ref\` and the stay is then booked with the group. It answers like a booking: the group's payment page, the terms again, or why nothing was booked.`,
1100
- annotations: books(`Agree to booking terms on ${v.brand}`, open),
1154
+ annotations: orders(`Agree to booking terms on ${v.brand}`, open),
1101
1155
  inputSchema: {
1102
1156
  type: 'object',
1103
1157
  properties: {
@@ -4198,6 +4252,10 @@ const soldOutTypesOf = (detail, enough, wanted) => {
4198
4252
  ...(left > 0 ? { left } : {}),
4199
4253
  }));
4200
4254
  };
4255
+ /** A code that opens no booking here: where orders are the account's, no email would have opened it. */
4256
+ const noBookingLike = (deps) => ordersByAccount(deps.backend.capabilities ?? FULL_CAPABILITIES)
4257
+ ? 'No booking here matches that code. Only bookings made here by this account are known.'
4258
+ : 'No booking here matches that code. A booking made in another conversation needs the email it was made with.';
4201
4259
  const identity = (deps, ctx, key, args = {}) => {
4202
4260
  const email = str(args.email);
4203
4261
  const member = deps.members.read(key);
@@ -7944,9 +8002,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
7944
8002
  query: code,
7945
8003
  ...(tooMany ? { tooMany: true } : {}),
7946
8004
  },
7947
- text: tooMany
7948
- ? TOO_MANY_TRIES
7949
- : 'No booking here matches that code. A booking made in another conversation needs the email it was made with.',
8005
+ text: tooMany ? TOO_MANY_TRIES : noBookingLike(deps),
7950
8006
  };
7951
8007
  }
7952
8008
  const wanted = booked ? booked.hotelId : str(args.hotel);
@@ -8277,9 +8333,11 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
8277
8333
  // Read here, before a filter or a spread drops it: the groups whose
8278
8334
  // bookings are not in `here` (2026-11-03 review, C5).
8279
8335
  const missing = degradedOf(deps, { degraded: here.degraded }, 'bookings', ctx?.noCards);
8280
- // Elsewhere, only with the code AND the email - see `listBookings`.
8336
+ // Elsewhere, only with the code AND the email - see `listBookings`. Where orders are the
8337
+ // account's (Otaless), the code alone finds this account's own, and an email is not asked.
8338
+ const byAccount = ordersByAccount(deps.backend.capabilities ?? FULL_CAPABILITIES);
8281
8339
  const code = str(args.booking);
8282
- const { found: there, tooMany } = code && str(args.email)
8340
+ const { found: there, tooMany } = code && (str(args.email) || byAccount)
8283
8341
  ? await guarded(deps, ctx, who, code, () => deps.backend.findBooking(code, who))
8284
8342
  : { found: null, tooMany: false };
8285
8343
  const bookings = there && !here.some((b) => b.id === there.id) ? [there, ...here] : here;
@@ -8289,9 +8347,11 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
8289
8347
  const missed = code && !there;
8290
8348
  const missLine = tooMany
8291
8349
  ? TOO_MANY_TRIES
8292
- : code && !str(args.email)
8293
- ? 'A booking made elsewhere needs the email it was made with as well as its code.'
8294
- : 'No booking matches that confirmation code and email. Both are needed, as they are on the confirmation.';
8350
+ : byAccount
8351
+ ? 'No booking of this account matches that confirmation code.'
8352
+ : code && !str(args.email)
8353
+ ? 'A booking made elsewhere needs the email it was made with as well as its code.'
8354
+ : 'No booking matches that confirmation code and email. Both are needed, as they are on the confirmation.';
8295
8355
  return {
8296
8356
  structured: {
8297
8357
  view: 'bookings',
@@ -8313,7 +8373,9 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
8313
8373
  : // ⚠️ NOT "NO BOOKINGS" when a group did not answer: it may hold them.
8314
8374
  missing.said
8315
8375
  ? ''
8316
- : 'No bookings in this conversation. A booking made elsewhere is found with its confirmation code and the email it was made with.',
8376
+ : byAccount
8377
+ ? 'No bookings on this account.'
8378
+ : 'No bookings in this conversation. A booking made elsewhere is found with its confirmation code and the email it was made with.',
8317
8379
  missing.said,
8318
8380
  ]
8319
8381
  .filter(Boolean)
@@ -8445,9 +8507,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
8445
8507
  query: ref,
8446
8508
  ...(tooMany ? { tooMany: true } : {}),
8447
8509
  },
8448
- text: tooMany
8449
- ? TOO_MANY_TRIES
8450
- : 'No booking here matches that code. A booking made in another conversation needs the email it was made with.',
8510
+ text: tooMany ? TOO_MANY_TRIES : noBookingLike(deps),
8451
8511
  };
8452
8512
  }
8453
8513
  const stayOf = (x) => ({
@@ -8575,9 +8635,7 @@ const answerTool = async (deps, name, rawArgs, ctx) => {
8575
8635
  query: ref,
8576
8636
  ...(tooMany ? { tooMany: true } : {}),
8577
8637
  },
8578
- text: tooMany
8579
- ? TOO_MANY_TRIES
8580
- : 'No booking here matches that code. A booking made in another conversation needs the email it was made with.',
8638
+ text: tooMany ? TOO_MANY_TRIES : noBookingLike(deps),
8581
8639
  };
8582
8640
  }
8583
8641
  // What is being cancelled, and on what terms, for the card to say in the