@curless/hotel-storefront 0.65.2 → 0.67.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 (82) hide show
  1. package/dist/account/fake-ota.d.ts +5 -0
  2. package/dist/account/fake-ota.d.ts.map +1 -1
  3. package/dist/account/fake-ota.js +8 -2
  4. package/dist/account/fake-ota.js.map +1 -1
  5. package/dist/account/index.d.ts +36 -0
  6. package/dist/account/index.d.ts.map +1 -1
  7. package/dist/account/index.js +208 -26
  8. package/dist/account/index.js.map +1 -1
  9. package/dist/account/ota-member.d.ts +2 -0
  10. package/dist/account/ota-member.d.ts.map +1 -1
  11. package/dist/account/ota-member.js +2 -0
  12. package/dist/account/ota-member.js.map +1 -1
  13. package/dist/account/pages.d.ts +51 -5
  14. package/dist/account/pages.d.ts.map +1 -1
  15. package/dist/account/pages.js +153 -23
  16. package/dist/account/pages.js.map +1 -1
  17. package/dist/account/requests.d.ts +2 -0
  18. package/dist/account/requests.d.ts.map +1 -1
  19. package/dist/account/requests.js.map +1 -1
  20. package/dist/account/store.d.ts +57 -2
  21. package/dist/account/store.d.ts.map +1 -1
  22. package/dist/account/store.js +52 -4
  23. package/dist/account/store.js.map +1 -1
  24. package/dist/card.generated.d.ts +1 -1
  25. package/dist/card.generated.js +2 -2
  26. package/dist/card.generated.js.map +1 -1
  27. package/dist/config.d.ts +10 -0
  28. package/dist/config.d.ts.map +1 -1
  29. package/dist/config.js.map +1 -1
  30. package/dist/otaless/backend.d.ts +6 -2
  31. package/dist/otaless/backend.d.ts.map +1 -1
  32. package/dist/otaless/backend.js +58 -9
  33. package/dist/otaless/backend.js.map +1 -1
  34. package/dist/otaless/booking.d.ts +190 -28
  35. package/dist/otaless/booking.d.ts.map +1 -1
  36. package/dist/otaless/booking.js +929 -374
  37. package/dist/otaless/booking.js.map +1 -1
  38. package/dist/otaless/client.d.ts +120 -34
  39. package/dist/otaless/client.d.ts.map +1 -1
  40. package/dist/otaless/client.js +133 -19
  41. package/dist/otaless/client.js.map +1 -1
  42. package/dist/otaless/fake.d.ts +59 -10
  43. package/dist/otaless/fake.d.ts.map +1 -1
  44. package/dist/otaless/fake.js +132 -34
  45. package/dist/otaless/fake.js.map +1 -1
  46. package/dist/otaless/make.d.ts +2 -0
  47. package/dist/otaless/make.d.ts.map +1 -1
  48. package/dist/otaless/make.js +56 -18
  49. package/dist/otaless/make.js.map +1 -1
  50. package/dist/otaless/places.d.ts +14 -0
  51. package/dist/otaless/places.d.ts.map +1 -1
  52. package/dist/otaless/places.js +108 -1
  53. package/dist/otaless/places.js.map +1 -1
  54. package/dist/pictures.d.ts +19 -0
  55. package/dist/pictures.d.ts.map +1 -0
  56. package/dist/pictures.js +74 -0
  57. package/dist/pictures.js.map +1 -0
  58. package/dist/server.d.ts +15 -2
  59. package/dist/server.d.ts.map +1 -1
  60. package/dist/server.js +236 -37
  61. package/dist/server.js.map +1 -1
  62. package/dist/sessions.d.ts +23 -0
  63. package/dist/sessions.d.ts.map +1 -1
  64. package/dist/sessions.js +39 -1
  65. package/dist/sessions.js.map +1 -1
  66. package/dist/supplier.js +4 -0
  67. package/dist/supplier.js.map +1 -1
  68. package/dist/surface.d.ts +24 -1
  69. package/dist/surface.d.ts.map +1 -1
  70. package/dist/surface.js +35 -6
  71. package/dist/surface.js.map +1 -1
  72. package/dist/tools.d.ts +24 -0
  73. package/dist/tools.d.ts.map +1 -1
  74. package/dist/tools.js +217 -23
  75. package/dist/tools.js.map +1 -1
  76. package/dist/trip-ids.d.ts +13 -1
  77. package/dist/trip-ids.d.ts.map +1 -1
  78. package/dist/trip-ids.js +30 -3
  79. package/dist/trip-ids.js.map +1 -1
  80. package/dist/types.d.ts +88 -2
  81. package/dist/types.d.ts.map +1 -1
  82. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -14,12 +14,13 @@ import { docsPage, privacyPage, termsPage } from './legal.js';
14
14
  import { Misses, WindowCounter } from './limits.js';
15
15
  import { MemberStore } from './members.js';
16
16
  import { paidAnswer } from './paid.js';
17
+ import { picturesApart } from './pictures.js';
17
18
  import { Sessions, cardSupport } from './sessions.js';
18
19
  import { StateDir } from './state.js';
19
20
  import { makeSupplier } from './supplier.js';
20
21
  import { buildInstructions, listTools, tripToolNames } from './surface.js';
21
22
  import { TERMS_META_KEY, agreeToTerms, bookingRefusal, buildOutputSchemas, buildTools, commonFields, contextFor, handleTool, homeListing, identityFor, outputSchemasFor, tripGone, withheldTools, } from './tools.js';
22
- import { TripIds } from './trip-ids.js';
23
+ import { ID_TTL_MS, TripIds } from './trip-ids.js';
23
24
  import { TripStore, tripKey } from './trip.js';
24
25
  import { checkDemoData, resolveBrand } from './vocab.js';
25
26
  // The connector itself: one config in, one HTTP app out.
@@ -50,7 +51,7 @@ export const INITIALIZE_PER_MINUTE = 300;
50
51
  * number. Found by reading the boot banner of a container that had just been
51
52
  * deployed (2026-09-22): seventeen tools listed, and "0.7.0" above them.
52
53
  */
53
- export const VERSION = '0.65.2';
54
+ export const VERSION = '0.67.0';
54
55
  /**
55
56
  * The card's resource URI.
56
57
  *
@@ -59,7 +60,7 @@ export const VERSION = '0.65.2';
59
60
  * connector went storefront-v35 → v40 in a single day of UI work for exactly
60
61
  * this reason.
61
62
  */
62
- export const CARD_URI = 'ui://curless/hotel/booking-v129.html';
63
+ export const CARD_URI = 'ui://curless/hotel/booking-v131.html';
63
64
  /** The card as it ships, hashed once - what a host caches under the URI. */
64
65
  const CARD_HTML_SHA = createHash('sha256').update(HOTEL_CARD_HTML).digest('hex');
65
66
  /**
@@ -349,12 +350,37 @@ export const buildServer = (opts) => {
349
350
  * once a connection.
350
351
  */
351
352
  cardNamed: 0,
353
+ /**
354
+ * A new connection of a client that draws no card took over the
355
+ * conversation its first trip id named (0.67.0) - and connections that had
356
+ * a conversation and named another, refused.
357
+ */
358
+ carriedOver: 0,
359
+ notCarried: 0,
352
360
  };
353
361
  const cardNamedSeen = new Set();
354
362
  // Sessions that have acted on their own conversation: `sessions.anchor` -
355
363
  // kept with the session ids, on disk since 0.59.0 (review C1).
356
- /** Sessions whose headers have been noted once (diagnostics, 0.56.1). */
357
- const diagnosed = new Set();
364
+ /**
365
+ * How many times each app's header NAMES have been logged, by where (0.67.0,
366
+ * 总线程 11-11): does Manus - which started a new connection between two
367
+ * turns - send a conversation id of its own that outlives a connection? The
368
+ * first few of each app, at `initialize` and at `tools/call`, in every
369
+ * deployment; never a value. Made-up app names past `HEADER_APPS` are not
370
+ * logged at all: a flood of them would be all this log said.
371
+ */
372
+ const headerLogs = new Map();
373
+ const noteHeaders = (c, at, client, extra) => {
374
+ const who = printable(client ?? '-', 60);
375
+ const k = `${at} ${who}`;
376
+ const n = headerLogs.get(k) ?? 0;
377
+ if (n >= HEADER_LOGS_PER_APP)
378
+ return;
379
+ if (n === 0 && headerLogs.size >= HEADER_APPS)
380
+ return;
381
+ headerLogs.set(k, n + 1);
382
+ console.log(`[mcp] headers ${at} client=${who} n=${n + 1}${extra} ${headerNames(c)}`);
383
+ };
358
384
  // What has outlived its time goes off the disk too, even with nobody asking:
359
385
  // "forgotten two hours after" is a promise the privacy page makes.
360
386
  if (state.persisted) {
@@ -442,6 +468,26 @@ export const buildServer = (opts) => {
442
468
  ? {
443
469
  terms: {
444
470
  pending: (key, ref) => backend.otalessBooking?.pendingTerms(ref, identityFor(deps, key)),
471
+ // The page's "Don't agree" (0.66.0): the terms go at once - and an order
472
+ // held back for them is cancelled (总线程 11-11, D).
473
+ discard: async (key, ref) => {
474
+ const ot = backend.otalessBooking;
475
+ if (!ot)
476
+ return {};
477
+ const { booking } = await ot.discardTerms(ref, identityFor(deps, key));
478
+ if (!booking)
479
+ return {};
480
+ return {
481
+ order: {
482
+ code: booking.confirmationCode,
483
+ state: booking.status === 'cancelled'
484
+ ? 'cancelled'
485
+ : booking.needsPerson
486
+ ? 'needs-person'
487
+ : 'unknown',
488
+ },
489
+ };
490
+ },
445
491
  accept: async (key, ref) => {
446
492
  try {
447
493
  const done = await agreeToTerms(deps, key, ref, contextFor(deps, key));
@@ -512,9 +558,16 @@ export const buildServer = (opts) => {
512
558
  : {}),
513
559
  signInTool: account.names.signIn,
514
560
  };
561
+ // The signed-in guest's details, for a booking they leave empty (0.67.0).
562
+ deps.guestProfile = account.profileFor;
515
563
  }
516
564
  const ACCOUNT_TOOLS = account ? account.tools() : [];
517
- const TOOLS = buildTools(brand.tools, brand.vocab, caps);
565
+ // ⚠️ WHERE A GUEST SIGNS IN TO AN ACCOUNT, A BOOKING NEEDS NO NAME OR EMAIL IN THE
566
+ // CALL (0.67.0, 总线程 11-11): the account's are used for what the guest leaves out
567
+ // (tools.ts `withProfile`) - and the model is never told them whole, so it could not
568
+ // pass them. A guest not signed in is still asked (`needs-guest`). Every other
569
+ // deployment's list is as it was.
570
+ const TOOLS = buildTools(brand.tools, brand.vocab, caps).map((t) => account && t.name === brand.tools.requestBooking ? profiledBooking(t) : t);
518
571
  const OFFERED = new Set([
519
572
  ...TOOLS.map((t) => t.name),
520
573
  ...ACCOUNT_TOOLS.map((t) => String(t.name)),
@@ -609,7 +662,26 @@ export const buildServer = (opts) => {
609
662
  // each answer, never in the tools. So a list read with no session - nothing
610
663
  // said about cards - is not a guess at which client it is. Were the lists
611
664
  // ever to differ, that one is the cardless list: nothing said is "none".
612
- const toolList = () => listTools([...TOOLS.map((t) => homeListing(t, brand, made.hotelCount())), ...ACCOUNT_TOOLS], { ...OUTPUT_SCHEMAS, ...(account?.outputSchemas() ?? {}) }, (name) => (CARDLESS.has(name) ? {} : APP_ONLY.has(name) ? appOnly(meta()) : meta()), TRIP_TOOLS);
665
+ //
666
+ // ⚠️ EXCEPT ONE THING, FOR A SESSION THAT SAID IT DRAWS NO CARD (0.67.0): every
667
+ // tool takes the conversation's `trip`, described as the id its answers give
668
+ // (`WORDS_TRIP_PARAM`) - see `words` in tools/call. A card host's list, and a
669
+ // list read with no session, are as they were, byte for byte.
670
+ const toolList = (words = false) => listTools([...TOOLS.map((t) => homeListing(t, brand, made.hotelCount())), ...ACCOUNT_TOOLS], { ...OUTPUT_SCHEMAS, ...(account?.outputSchemas() ?? {}) }, (name) => (CARDLESS.has(name) ? {} : APP_ONLY.has(name) ? appOnly(meta()) : meta()), TRIP_TOOLS, words);
671
+ /**
672
+ * The tools that change nothing, by their own annotations: called naming no
673
+ * trip by a client that draws no card, they do not anchor a new connection
674
+ * to a conversation of its own (0.67.0, `looking` in tools/call).
675
+ */
676
+ const READ_ONLY = new Set([...TOOLS, ...ACCOUNT_TOOLS]
677
+ .filter((t) => t.annotations?.readOnlyHint === true)
678
+ .map((t) => t.name));
679
+ /** …and of those, the ones that say what a conversation holds: a new connection's empty one is said to be new. */
680
+ const STATE_READS = new Set([
681
+ brand.tools.viewTrip,
682
+ brand.tools.listBookings,
683
+ ...(account ? [account.names.view] : []),
684
+ ]);
613
685
  /** The trip beside an answer, for the card's header - see `TRIP_META_KEY`. */
614
686
  /**
615
687
  * ⚠️ `withId` FALSE FOR A CALL THAT NAMED ANOTHER CONVERSATION'S TRIP (review
@@ -821,10 +893,10 @@ export const buildServer = (opts) => {
821
893
  });
822
894
  // Which app, and whether it said it shows cards - the one thing to look
823
895
  // at when an answer pointed at a card nobody drew. Never the address.
824
- console.log(`[mcp] initialize client=${printable(typeof client === 'string' ? client : '-', 60)} cards=${cards}${
825
- // Where there is an account (0.56.1 diagnostics): the session by an
826
- // 8-character fingerprint, and the NAMES of the headers it came with.
827
- account ? ` s=${h8(sessionId)} ${headerNames(c)}` : ''}`);
896
+ // The session by an 8-character fingerprint (0.56.1; every deployment
897
+ // since 0.67.0), so the lines of one connection can be followed.
898
+ console.log(`[mcp] initialize client=${printable(typeof client === 'string' ? client : '-', 60)} cards=${cards} s=${h8(sessionId)}`);
899
+ noteHeaders(c, 'initialize', typeof client === 'string' ? client : undefined, '');
828
900
  c.header('Mcp-Session-Id', sessionId);
829
901
  return ok(c, id, {
830
902
  protocolVersion: PROTOCOL_VERSION,
@@ -904,7 +976,7 @@ export const buildServer = (opts) => {
904
976
  if (method === 'notifications/initialized')
905
977
  return c.body(null, 202);
906
978
  if (method === 'tools/list')
907
- return ok(c, id, { tools: toolList() });
979
+ return ok(c, id, { tools: toolList(sessions.cardsOf(presented) === 'none') });
908
980
  if (method === 'resources/list') {
909
981
  const m = meta();
910
982
  return ok(c, id, {
@@ -963,6 +1035,41 @@ export const buildServer = (opts) => {
963
1035
  // Anything else it asked is still answered, but with no trip beside it:
964
1036
  // the card would take that trip's id as its own.
965
1037
  const lost = asked !== undefined && named === undefined;
1038
+ // ⚠️ ONLY A CLIENT THAT SAID IT DRAWS CARDS - never one we know nothing
1039
+ // of (`drawsCards` below; 总线程's review of 0.56.1): a session from
1040
+ // before a restart, or a connection that never initialized here, is not
1041
+ // handed the user name in `_meta`.
1042
+ const cardsSaid = sessions.cardsOf(presented);
1043
+ const saidCards = cardsSaid === 'extension' || cardsSaid === 'host';
1044
+ // ⚠️ A CLIENT THAT DRAWS NO CARD CARRIES ITS CONVERSATION BY ITS ID, IN
1045
+ // WORDS (0.67.0, robin's Manus test 11-11). For such a client "this
1046
+ // conversation" was this one connection: Manus started a new one between
1047
+ // two turns, the guest who had just signed in on the old one was a
1048
+ // stranger on the new one, and was sent a second link. Nothing it sends
1049
+ // was seen to outlive a connection (`noteHeaders` looks), so the
1050
+ // conversation's own trip id is given to the model in every answer, and
1051
+ // the model passes it on every call. See `Sessions.bind` for the rules.
1052
+ const words = cardsSaid === 'none';
1053
+ noteHeaders(c, 'tools/call', sessions.clientOf(presented), ` tool=${printable(name, 60)} s=${h8(presented)} trip=${asked === undefined ? 'none' : lost ? 'lost' : 'named'}`);
1054
+ const from = ip ? addressKey(ip) : undefined;
1055
+ /** This connection's conversation, in words - only once it has one (anchored). */
1056
+ const ownInWords = (k) => sessions.isAnchored(presented) ? tripIds.idFor(k, from, true) : undefined;
1057
+ let own = (words ? sessions.boundOf(presented) : undefined) ?? tripKey(session, config.brand);
1058
+ if (words && lost) {
1059
+ console.log(`[mcp] trip-gone tool=${printable(name, 60)} id=${h8(asked)} knownIds=${tripIds.size} client=${printable(sessions.clientOf(presented) ?? '-', 60)} cards=none`);
1060
+ const mine = ownInWords(own);
1061
+ return ok(c, id, {
1062
+ content: [{ type: 'text', text: tripLostSaid(mine) }],
1063
+ structuredContent: {
1064
+ view: 'error',
1065
+ brand: config.brand,
1066
+ error: 'trip-gone',
1067
+ code: 'trip-gone',
1068
+ ...(mine ? { conversation: conversationOf(mine) } : {}),
1069
+ },
1070
+ isError: true,
1071
+ });
1072
+ }
966
1073
  if (lost && TRIP_TOOLS.has(name)) {
967
1074
  // Which id, from what app - never the address, the arguments or
968
1075
  // anything said in it (2026-10-14: robin met this on a new
@@ -976,14 +1083,37 @@ export const buildServer = (opts) => {
976
1083
  _meta: meta(),
977
1084
  });
978
1085
  }
979
- const own = tripKey(session, config.brand);
1086
+ if (words && asked !== undefined && named !== undefined && named !== own) {
1087
+ if (!sessions.isAnchored(presented) && tripIds.inWords(asked)) {
1088
+ // A new connection's first word of a conversation it has not acted
1089
+ // in yet: it takes that conversation over, and keeps to it.
1090
+ sessions.bind(presented, named);
1091
+ own = named;
1092
+ calls.carriedOver += 1;
1093
+ console.log(`[mcp] carried over s=${h8(presented)} k=${h8(named)} tool=${printable(name, 60)} client=${printable(sessions.clientOf(presented) ?? '-', 60)} address=${tripIds.addressMatch(asked, from)}`);
1094
+ }
1095
+ else if (sessions.isAnchored(presented)) {
1096
+ // ⚠️ A CONNECTION THAT HAS ITS CONVERSATION NAMES NO OTHER - every tool,
1097
+ // in words (the rule of review P2-1, which the card's tools keep below):
1098
+ // with no card here, an id it did not get from its own answers is one
1099
+ // a page or a message put in front of the model.
1100
+ calls.notCarried += 1;
1101
+ console.log(`[mcp] ${printable(name, 60)} refused: not_this_conversation - client=${printable(sessions.clientOf(presented) ?? '-', 60)} cards=none`);
1102
+ const mine = ownInWords(own);
1103
+ return ok(c, id, {
1104
+ content: [{ type: 'text', text: notCarriedSaid(mine) }],
1105
+ structuredContent: {
1106
+ view: 'error',
1107
+ brand: config.brand,
1108
+ error: 'not_this_conversation',
1109
+ code: 'not_this_conversation',
1110
+ ...(mine ? { conversation: conversationOf(mine) } : {}),
1111
+ },
1112
+ isError: true,
1113
+ });
1114
+ }
1115
+ }
980
1116
  const key = named ?? own;
981
- // ⚠️ ONLY A CLIENT THAT SAID IT DRAWS CARDS - never one we know nothing
982
- // of (`drawsCards` below; 总线程's review of 0.56.1): a session from
983
- // before a restart, or a connection that never initialized here, is not
984
- // handed the user name in `_meta`.
985
- const cardsSaid = sessions.cardsOf(presented);
986
- const saidCards = cardsSaid === 'extension' || cardsSaid === 'host';
987
1117
  // Its own conversation, by naming none or its own: this session is
988
1118
  // the conversation's, not a card's.
989
1119
  const ours = asked === undefined || named === own;
@@ -994,6 +1124,8 @@ export const buildServer = (opts) => {
994
1124
  // to hand it to anyway. A session from before 0.59.0 (unknown) is still
995
1125
  // handed it: a card drawn in a claude.ai conversation open across the
996
1126
  // deploy would otherwise lose its conversation's trip (see sessions.ts).
1127
+ // (Since 0.67.0 such a client's model is given the id in the answer's
1128
+ // words instead, on purpose - `inWords` below - and never in `_meta`.)
997
1129
  const handsTripId = ours && cardsSaid !== 'none';
998
1130
  // ⚠️ DIAGNOSTICS, WHERE THERE IS AN ACCOUNT (0.56.1): which connection
999
1131
  // reached which conversation, by 8-character fingerprints - never an id,
@@ -1002,18 +1134,24 @@ export const buildServer = (opts) => {
1002
1134
  // assistant looked at another. These lines say how.
1003
1135
  if (account) {
1004
1136
  const trip = asked === undefined ? 'none' : lost ? 'lost' : named === own ? 'own' : 'named';
1005
- if (!diagnosed.has(presented)) {
1006
- diagnosed.add(presented);
1007
- if (diagnosed.size > 100_000)
1008
- diagnosed.clear();
1009
- console.log(`[mcp] first call s=${h8(presented)} ${headerNames(c)}`);
1010
- }
1011
1137
  console.log(`[mcp] call ${printable(name, 60)} s=${h8(presented)} k=${h8(key)} trip=${trip} client=${printable(sessions.clientOf(presented) ?? '-', 40)} cards=${sessions.cardsOf(presented) ?? '-'}`);
1012
1138
  }
1013
- if (ours)
1014
- sessions.anchor(presented);
1139
+ // ⚠️ LOOKING IS NOT ACTING, FOR A CLIENT THAT DRAWS NO CARD (0.67.0): a new
1140
+ // connection whose model looked something up before passing the trip id
1141
+ // it was given would otherwise be anchored to an empty conversation of
1142
+ // its own, and refused the guest's. Only what changes a conversation -
1143
+ // or names its id - anchors one.
1144
+ const looking = words && asked === undefined && READ_ONLY.has(name) && !sessions.isAnchored(presented);
1145
+ if (ours) {
1146
+ if (!looking)
1147
+ sessions.anchor(presented);
1148
+ }
1015
1149
  else if (sessions.isAnchored(presented))
1016
1150
  calls.foreignTrip += 1;
1151
+ /** The conversation's id for the model, in words: a client that draws no card, its own conversation. */
1152
+ const inWords = words && ours ? ownInWords(key) : undefined;
1153
+ /** What every answer to such a client says beside its own words - see `inWordsOf`. */
1154
+ const said = (text, structured) => inWordsOf(text, structured, inWords, looking && STATE_READS.has(name));
1017
1155
  if (account?.has(name)) {
1018
1156
  // ⚠️ WHO MAY NAME WHICH CONVERSATION (review P2-1). The assistant's
1019
1157
  // three: their own, never one a trip id names. The card's: the one
@@ -1064,12 +1202,18 @@ export const buildServer = (opts) => {
1064
1202
  // A card host answered in words is told the link and code it would
1065
1203
  // have drawn - the guest signs in either way.
1066
1204
  ...(saidCards ? {} : { noCards: true }),
1205
+ // The conversation's id, for what its words tell the model to pass on (0.67.0).
1206
+ ...(inWords ? { trip: inWords } : {}),
1067
1207
  });
1068
- return ok(c, id, {
1069
- content: [{ type: 'text', text: answer.text }],
1208
+ const told = said(answer.text, {
1070
1209
  // The deployment's name, logo and tools beside it, as every answer
1071
1210
  // has them: this may be the first card the conversation draws.
1072
- structuredContent: { ...commonFields(deps, key), ...answer.structured },
1211
+ ...commonFields(deps, key),
1212
+ ...answer.structured,
1213
+ });
1214
+ return ok(c, id, {
1215
+ content: [{ type: 'text', text: told.text }],
1216
+ structuredContent: told.structured,
1073
1217
  ...(answer.isError ? { isError: true } : {}),
1074
1218
  _meta: {
1075
1219
  ...(lost
@@ -1188,6 +1332,8 @@ export const buildServer = (opts) => {
1188
1332
  : {}),
1189
1333
  // Only a client that said it draws them - never one we know nothing of (`drawsCards`).
1190
1334
  ...(saidCards ? { drawsCards: true } : {}),
1335
+ // The conversation's id, for what its words tell the model to pass on (0.67.0).
1336
+ ...(inWords ? { tripInWords: inWords } : {}),
1191
1337
  });
1192
1338
  // The guest's own details beside the answer, never in it - see `guestsApart`.
1193
1339
  const { shown, guests } = guestsApart(answer.structured);
@@ -1195,9 +1341,15 @@ export const buildServer = (opts) => {
1195
1341
  const { shown: unnamed, who } = memberApart(shown);
1196
1342
  // And the city field's menu - see `CITIES_META_KEY`.
1197
1343
  const { allCities, ...drawn } = unnamed;
1344
+ const told = said(answer.text, drawn);
1345
+ // ⚠️ AND NO PICTURE SENT AS ITSELF, FOR ANY HOST (0.67.0, 总线程 11-12): the
1346
+ // card's CSP would have to name `data:` in `resourceDomains`, which hosts put
1347
+ // in script-src too - and ChatGPT's widgetCSP would change. The backend's
1348
+ // pictures are https now (`imageHosts`); a `data:` one is not drawn.
1349
+ const { shown: pictured } = picturesApart(told.structured, false);
1198
1350
  return ok(c, id, {
1199
- content: [{ type: 'text', text: answer.text }],
1200
- structuredContent: drawn,
1351
+ content: [{ type: 'text', text: told.text }],
1352
+ structuredContent: pictured,
1201
1353
  ...(answer.isError ? { isError: true } : {}),
1202
1354
  // Beside the answer, not inside it: the card needs the trip to badge
1203
1355
  // its header, and the model needs no such list - handing it one is
@@ -1256,18 +1408,65 @@ export const buildServer = (opts) => {
1256
1408
  const printable = (s, max) => s.replace(/[^\x20-\x7e]/g, '?').slice(0, max);
1257
1409
  /** An id as 8 characters of its SHA-256 - the same fingerprint the account's lines use (account/index.ts `tag`). */
1258
1410
  const h8 = (s) => createHash('sha256').update(s).digest('base64url').slice(0, 8);
1411
+ /** `request_*_booking` where an account's details fill what the guest leaves out - see `TOOLS`. */
1412
+ const profiledBooking = (t) => {
1413
+ const schema = t.inputSchema;
1414
+ const props = { ...(schema.properties ?? {}) };
1415
+ const said = (k, words) => {
1416
+ const p = props[k];
1417
+ if (p)
1418
+ props[k] = { ...p, description: `${p.description ?? ''}. ${words}` };
1419
+ };
1420
+ said('name', "Left out: the signed-in account's name, where it has one");
1421
+ said('email', "Left out: the signed-in account's email");
1422
+ said('phone', "Left out: the signed-in account's phone, where it has one");
1423
+ const { required: _was, ...rest } = schema;
1424
+ return { ...t, inputSchema: { ...rest, properties: props } };
1425
+ };
1426
+ /**
1427
+ * The line every answer to a client that draws no card ends with, once its
1428
+ * conversation has an id (0.67.0): the id, and that every later call passes it.
1429
+ * In `structuredContent` too, the same words (`conversation`): a host may hand
1430
+ * its model that rather than the text.
1431
+ */
1432
+ export const conversationSaid = (id) => `This conversation: trip="${id}". Pass trip="${id}" on every later call to these tools - the app may reconnect between turns, and that id is how the next call finds this conversation's trip, sign-in and bookings.`;
1433
+ const conversationOf = (id) => ({ trip: id, said: conversationSaid(id) });
1434
+ /** A new connection's look at what its conversation holds, naming no trip: it holds nothing yet (0.67.0). */
1435
+ export const NEW_CONNECTION_SAID = "This connection is new and holds nothing yet. If an earlier answer in this chat gave a trip id, call again with it as trip: that is how this conversation's trip, sign-in and bookings are found.";
1436
+ /** What an answer to a client that draws no card says beside its own words - see `conversationSaid`. */
1437
+ const inWordsOf = (text, structured, id, fresh) => id
1438
+ ? {
1439
+ text: `${text}\n\n${conversationSaid(id)}`,
1440
+ structured: { ...structured, conversation: conversationOf(id) },
1441
+ }
1442
+ : fresh
1443
+ ? {
1444
+ text: `${text}\n\n${NEW_CONNECTION_SAID}`,
1445
+ structured: { ...structured, conversation: { new: true, said: NEW_CONNECTION_SAID } },
1446
+ }
1447
+ : { text, structured };
1448
+ /** A trip id that names nothing, to a client that draws no card (0.67.0). `mine`: this connection's own, if it has one. */
1449
+ const tripLostSaid = (mine) => mine
1450
+ ? `Nothing was done: no conversation here goes by that trip id. This connection's conversation is trip="${mine}" - pass that one.`
1451
+ : `Nothing was done: no conversation here goes by that trip id - it may be mistyped, from another chat, or unused for ${ID_TTL_MS / 86_400_000} days. Call again without trip: that starts a new conversation, and nothing from before carries over to it.`;
1452
+ /** Another conversation's id, from a connection that has its own (0.67.0). */
1453
+ const notCarriedSaid = (mine) => `Nothing was done: this connection already has its conversation${mine ? `, trip="${mine}",` : ''} and acts on no other - a trip id that did not come from this conversation's own answers is not followed.${mine ? ` Pass trip="${mine}".` : ''}`;
1259
1454
  /**
1260
- * The headers a request came with - their NAMES, sorted, never a value - and
1261
- * its user-agent as it is (diagnostics, 0.56.1: is there a conversation id a
1262
- * host sends, as ChatGPT's x-openai-session?). Addresses and cookies are named
1263
- * only.
1455
+ * The headers a request came with - their NAMES, sorted, never a value
1456
+ * (diagnostics, 0.56.1: is there a conversation id a host sends, as ChatGPT's
1457
+ * x-openai-session?). Addresses, cookies and the user-agent are named only:
1458
+ * since 0.67.0 no value at all (总线程 11-11).
1264
1459
  */
1265
1460
  const headerNames = (c) => {
1266
1461
  const names = Object.keys(c.req.header())
1267
1462
  .map((n) => n.toLowerCase())
1268
1463
  .sort();
1269
- return `headers=[${printable(names.join(','), 400)}] ua=${printable(c.req.header('user-agent') ?? '-', 80)}`;
1464
+ return `headers=[${printable(names.join(','), 600)}]`;
1270
1465
  };
1466
+ /** Times each app's header names are logged at `initialize`, and at `tools/call` (0.67.0). */
1467
+ export const HEADER_LOGS_PER_APP = 5;
1468
+ /** Apps whose header names are logged at all, by where - past it, a new name is not (0.67.0). */
1469
+ export const HEADER_APPS = 200;
1271
1470
  export const clientIp = (header) => {
1272
1471
  const last = (header ?? '').split(',').at(-1)?.trim();
1273
1472
  return last || undefined;