@curless/hotel-storefront 0.66.0 → 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 (78) hide show
  1. package/dist/account/fake-ota.d.ts.map +1 -1
  2. package/dist/account/fake-ota.js +2 -0
  3. package/dist/account/fake-ota.js.map +1 -1
  4. package/dist/account/index.d.ts +16 -0
  5. package/dist/account/index.d.ts.map +1 -1
  6. package/dist/account/index.js +55 -8
  7. package/dist/account/index.js.map +1 -1
  8. package/dist/account/ota-member.d.ts +2 -0
  9. package/dist/account/ota-member.d.ts.map +1 -1
  10. package/dist/account/ota-member.js +2 -0
  11. package/dist/account/ota-member.js.map +1 -1
  12. package/dist/account/pages.d.ts +11 -0
  13. package/dist/account/pages.d.ts.map +1 -1
  14. package/dist/account/pages.js +51 -7
  15. package/dist/account/pages.js.map +1 -1
  16. package/dist/account/store.d.ts +38 -1
  17. package/dist/account/store.d.ts.map +1 -1
  18. package/dist/account/store.js +32 -1
  19. package/dist/account/store.js.map +1 -1
  20. package/dist/card.generated.d.ts +1 -1
  21. package/dist/card.generated.js +2 -2
  22. package/dist/card.generated.js.map +1 -1
  23. package/dist/config.d.ts +10 -0
  24. package/dist/config.d.ts.map +1 -1
  25. package/dist/config.js.map +1 -1
  26. package/dist/otaless/backend.d.ts +2 -0
  27. package/dist/otaless/backend.d.ts.map +1 -1
  28. package/dist/otaless/backend.js +41 -5
  29. package/dist/otaless/backend.js.map +1 -1
  30. package/dist/otaless/booking.d.ts +77 -4
  31. package/dist/otaless/booking.d.ts.map +1 -1
  32. package/dist/otaless/booking.js +355 -43
  33. package/dist/otaless/booking.js.map +1 -1
  34. package/dist/otaless/client.d.ts +83 -7
  35. package/dist/otaless/client.d.ts.map +1 -1
  36. package/dist/otaless/client.js +117 -13
  37. package/dist/otaless/client.js.map +1 -1
  38. package/dist/otaless/fake.d.ts +39 -2
  39. package/dist/otaless/fake.d.ts.map +1 -1
  40. package/dist/otaless/fake.js +88 -7
  41. package/dist/otaless/fake.js.map +1 -1
  42. package/dist/otaless/make.d.ts +2 -0
  43. package/dist/otaless/make.d.ts.map +1 -1
  44. package/dist/otaless/make.js +29 -3
  45. package/dist/otaless/make.js.map +1 -1
  46. package/dist/otaless/places.d.ts +14 -0
  47. package/dist/otaless/places.d.ts.map +1 -1
  48. package/dist/otaless/places.js +108 -1
  49. package/dist/otaless/places.js.map +1 -1
  50. package/dist/pictures.d.ts +19 -0
  51. package/dist/pictures.d.ts.map +1 -0
  52. package/dist/pictures.js +74 -0
  53. package/dist/pictures.js.map +1 -0
  54. package/dist/server.d.ts +15 -2
  55. package/dist/server.d.ts.map +1 -1
  56. package/dist/server.js +216 -37
  57. package/dist/server.js.map +1 -1
  58. package/dist/sessions.d.ts +23 -0
  59. package/dist/sessions.d.ts.map +1 -1
  60. package/dist/sessions.js +39 -1
  61. package/dist/sessions.js.map +1 -1
  62. package/dist/supplier.js +4 -0
  63. package/dist/supplier.js.map +1 -1
  64. package/dist/surface.d.ts +24 -1
  65. package/dist/surface.d.ts.map +1 -1
  66. package/dist/surface.js +31 -4
  67. package/dist/surface.js.map +1 -1
  68. package/dist/tools.d.ts +24 -0
  69. package/dist/tools.d.ts.map +1 -1
  70. package/dist/tools.js +153 -19
  71. package/dist/tools.js.map +1 -1
  72. package/dist/trip-ids.d.ts +13 -1
  73. package/dist/trip-ids.d.ts.map +1 -1
  74. package/dist/trip-ids.js +30 -3
  75. package/dist/trip-ids.js.map +1 -1
  76. package/dist/types.d.ts +46 -1
  77. package/dist/types.d.ts.map +1 -1
  78. package/package.json +1 -1
@@ -0,0 +1,74 @@
1
+ import { createHash } from 'node:crypto';
2
+ // A picture the backend sends as itself, not as an address (0.67.0, robin 11-11:
3
+ // 「后端 imageUrl 给什么就显示什么」) - Otaless's are 64×48 JPEGs in base64.
4
+ //
5
+ // ⚠️ ONLY A PICTURE, AND ONLY THREE KINDS. A `data:` address can be anything -
6
+ // an SVG with its own script, an HTML page - and the card's CSP can open `data:`
7
+ // to images only by scheme, never by kind. So the kind is checked here: a JPEG,
8
+ // a PNG or a WebP, in base64, and not past `MAX_DATA_PICTURE`. Anything else is
9
+ // dropped, as a hotel with no picture is drawn (its text, no picture's place).
10
+ //
11
+ // ⚠️ AND NEVER IN WHAT THE MODEL READS. A list of twenty hotels with a picture
12
+ // each is tens of kilobytes of base64 in `structuredContent`, which a host hands
13
+ // its model. The card's own pictures go beside the answer (`PICTURES_META_KEY`),
14
+ // by a short reference in the answer (`pic:…`), and the card puts them back
15
+ // (card.ts `withKept`); a host that draws no card gets none at all - there is
16
+ // nothing to show them on, and its `_meta` may reach the model.
17
+ export const PICTURES_META_KEY = 'curless/pictures';
18
+ /** A `data:` picture the card may show: a JPEG, a PNG or a WebP, in base64. */
19
+ export const DATA_PICTURE = /^data:image\/(?:jpeg|png|webp);base64,[A-Za-z0-9+/]+={0,2}$/;
20
+ /** The longest `data:` picture kept, in characters - a thumbnail is a few thousand. */
21
+ export const MAX_DATA_PICTURE = 256 * 1024;
22
+ /** What stands for a picture in the answer, beside it in `PICTURES_META_KEY`. */
23
+ export const PICTURE_REF = 'pic:';
24
+ export const isDataPicture = (u) => typeof u === 'string' && u.length <= MAX_DATA_PICTURE && DATA_PICTURE.test(u);
25
+ const isData = (u) => typeof u === 'string' && u.slice(0, 5).toLowerCase() === 'data:';
26
+ /**
27
+ * The answer with every `data:` picture (`imageUrl`, `images`) taken out: for a
28
+ * card (`card`), each one allowed is a `pic:` reference and is in `pictures`; for
29
+ * no card, it is gone. Any other picture is left exactly as it was - an answer
30
+ * with none comes back as the same object.
31
+ */
32
+ export const picturesApart = (answer, card) => {
33
+ const pictures = {};
34
+ const ref = (u) => {
35
+ if (!card || !isDataPicture(u))
36
+ return undefined;
37
+ const k = createHash('sha256').update(u).digest('base64url').slice(0, 12);
38
+ pictures[k] = u;
39
+ return `${PICTURE_REF}${k}`;
40
+ };
41
+ const walk = (v) => {
42
+ if (Array.isArray(v)) {
43
+ let changed = false;
44
+ const out = v.map((x) => {
45
+ const y = walk(x);
46
+ if (y !== x)
47
+ changed = true;
48
+ return y;
49
+ });
50
+ return changed ? out : v;
51
+ }
52
+ if (!v || typeof v !== 'object')
53
+ return v;
54
+ let changed = false;
55
+ const entries = [];
56
+ for (const [k, x] of Object.entries(v)) {
57
+ let y = x;
58
+ if (k === 'imageUrl' && isData(x))
59
+ y = ref(x);
60
+ else if (k === 'images' && Array.isArray(x) && x.some(isData))
61
+ y = x.flatMap((u) => (isData(u) ? (ref(u) ?? []) : [u]));
62
+ else
63
+ y = walk(x);
64
+ if (y !== x)
65
+ changed = true;
66
+ // A picture not kept is no picture: the key goes, as for a hotel that has none.
67
+ if (y !== undefined)
68
+ entries.push([k, y]);
69
+ }
70
+ return changed ? Object.fromEntries(entries) : v;
71
+ };
72
+ return { shown: walk(answer), pictures };
73
+ };
74
+ //# sourceMappingURL=pictures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pictures.js","sourceRoot":"","sources":["../src/pictures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,iFAAiF;AACjF,iEAAiE;AACjE,EAAE;AACF,+EAA+E;AAC/E,iFAAiF;AACjF,gFAAgF;AAChF,gFAAgF;AAChF,+EAA+E;AAC/E,EAAE;AACF,+EAA+E;AAC/E,iFAAiF;AACjF,iFAAiF;AACjF,4EAA4E;AAC5E,8EAA8E;AAC9E,gEAAgE;AAEhE,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AACpD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAG,6DAA6D,CAAC;AAC1F,uFAAuF;AACvF,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,GAAG,IAAI,CAAC;AAC3C,iFAAiF;AACjF,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC;AAElC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAU,EAAe,EAAE,CACvD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AAE,CAAC;AAChD,CAAC,CAAC"}
package/dist/server.d.ts CHANGED
@@ -29,7 +29,7 @@ export declare const INITIALIZE_PER_MINUTE = 300;
29
29
  * number. Found by reading the boot banner of a container that had just been
30
30
  * deployed (2026-09-22): seventeen tools listed, and "0.7.0" above them.
31
31
  */
32
- export declare const VERSION = "0.66.0";
32
+ export declare const VERSION = "0.67.0";
33
33
  /**
34
34
  * The card's resource URI.
35
35
  *
@@ -38,7 +38,7 @@ export declare const VERSION = "0.66.0";
38
38
  * connector went storefront-v35 → v40 in a single day of UI work for exactly
39
39
  * this reason.
40
40
  */
41
- export declare const CARD_URI = "ui://curless/hotel/booking-v130.html";
41
+ export declare const CARD_URI = "ui://curless/hotel/booking-v131.html";
42
42
  /**
43
43
  * The URI one deployment names its card by: `CARD_URI` with a short hash of
44
44
  * everything a host caches under it - the card itself, and the hosts it may
@@ -222,6 +222,19 @@ export type ServerOptions = {
222
222
  };
223
223
  export { imageDomainsOf } from './supplier.js';
224
224
  export declare const buildServer: (opts: ServerOptions) => BuiltServer;
225
+ /**
226
+ * The line every answer to a client that draws no card ends with, once its
227
+ * conversation has an id (0.67.0): the id, and that every later call passes it.
228
+ * In `structuredContent` too, the same words (`conversation`): a host may hand
229
+ * its model that rather than the text.
230
+ */
231
+ export declare const conversationSaid: (id: string) => string;
232
+ /** A new connection's look at what its conversation holds, naming no trip: it holds nothing yet (0.67.0). */
233
+ export declare 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.";
234
+ /** Times each app's header names are logged at `initialize`, and at `tools/call` (0.67.0). */
235
+ export declare const HEADER_LOGS_PER_APP = 5;
236
+ /** Apps whose header names are logged at all, by where - past it, a new name is not (0.67.0). */
237
+ export declare const HEADER_APPS = 200;
225
238
  export declare const clientIp: (header: string | undefined) => string | undefined;
226
239
  /** Read a brand's config from disk. The path is the one `data.file` resolves against. */
227
240
  export declare const loadConfig: (path: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GAAG;IAC1B,MAAM,EAAE,WAAW,CAAC;IACpB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,mFAAmF;IACnF,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,qHAAqH;IACrH,YAAY,CAAC,EAAE,OAAO,KAAK,CAAC;IAC5B,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAoBF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,eAAO,MAAM,WAAW,GAAI,MAAM,aAAa,KAAG,WA6sCjD,CAAC;AAmCF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,IAAI,MAAM,KAAG,MACyK,CAAC;AAGxN,6GAA6G;AAC7G,eAAO,MAAM,mBAAmB,sMACqK,CAAC;AA4CtM,8FAA8F;AAC9F,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,iGAAiG;AACjG,eAAO,MAAM,WAAW,MAAM,CAAC;AAE/B,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SAG9D,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAOlF,CAAC"}
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.66.0';
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.66.0';
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-v130.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) {
@@ -532,9 +558,16 @@ export const buildServer = (opts) => {
532
558
  : {}),
533
559
  signInTool: account.names.signIn,
534
560
  };
561
+ // The signed-in guest's details, for a booking they leave empty (0.67.0).
562
+ deps.guestProfile = account.profileFor;
535
563
  }
536
564
  const ACCOUNT_TOOLS = account ? account.tools() : [];
537
- 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);
538
571
  const OFFERED = new Set([
539
572
  ...TOOLS.map((t) => t.name),
540
573
  ...ACCOUNT_TOOLS.map((t) => String(t.name)),
@@ -629,7 +662,26 @@ export const buildServer = (opts) => {
629
662
  // each answer, never in the tools. So a list read with no session - nothing
630
663
  // said about cards - is not a guess at which client it is. Were the lists
631
664
  // ever to differ, that one is the cardless list: nothing said is "none".
632
- 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
+ ]);
633
685
  /** The trip beside an answer, for the card's header - see `TRIP_META_KEY`. */
634
686
  /**
635
687
  * ⚠️ `withId` FALSE FOR A CALL THAT NAMED ANOTHER CONVERSATION'S TRIP (review
@@ -841,10 +893,10 @@ export const buildServer = (opts) => {
841
893
  });
842
894
  // Which app, and whether it said it shows cards - the one thing to look
843
895
  // at when an answer pointed at a card nobody drew. Never the address.
844
- console.log(`[mcp] initialize client=${printable(typeof client === 'string' ? client : '-', 60)} cards=${cards}${
845
- // Where there is an account (0.56.1 diagnostics): the session by an
846
- // 8-character fingerprint, and the NAMES of the headers it came with.
847
- 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, '');
848
900
  c.header('Mcp-Session-Id', sessionId);
849
901
  return ok(c, id, {
850
902
  protocolVersion: PROTOCOL_VERSION,
@@ -924,7 +976,7 @@ export const buildServer = (opts) => {
924
976
  if (method === 'notifications/initialized')
925
977
  return c.body(null, 202);
926
978
  if (method === 'tools/list')
927
- return ok(c, id, { tools: toolList() });
979
+ return ok(c, id, { tools: toolList(sessions.cardsOf(presented) === 'none') });
928
980
  if (method === 'resources/list') {
929
981
  const m = meta();
930
982
  return ok(c, id, {
@@ -983,6 +1035,41 @@ export const buildServer = (opts) => {
983
1035
  // Anything else it asked is still answered, but with no trip beside it:
984
1036
  // the card would take that trip's id as its own.
985
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
+ }
986
1073
  if (lost && TRIP_TOOLS.has(name)) {
987
1074
  // Which id, from what app - never the address, the arguments or
988
1075
  // anything said in it (2026-10-14: robin met this on a new
@@ -996,14 +1083,37 @@ export const buildServer = (opts) => {
996
1083
  _meta: meta(),
997
1084
  });
998
1085
  }
999
- 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
+ }
1000
1116
  const key = named ?? own;
1001
- // ⚠️ ONLY A CLIENT THAT SAID IT DRAWS CARDS - never one we know nothing
1002
- // of (`drawsCards` below; 总线程's review of 0.56.1): a session from
1003
- // before a restart, or a connection that never initialized here, is not
1004
- // handed the user name in `_meta`.
1005
- const cardsSaid = sessions.cardsOf(presented);
1006
- const saidCards = cardsSaid === 'extension' || cardsSaid === 'host';
1007
1117
  // Its own conversation, by naming none or its own: this session is
1008
1118
  // the conversation's, not a card's.
1009
1119
  const ours = asked === undefined || named === own;
@@ -1014,6 +1124,8 @@ export const buildServer = (opts) => {
1014
1124
  // to hand it to anyway. A session from before 0.59.0 (unknown) is still
1015
1125
  // handed it: a card drawn in a claude.ai conversation open across the
1016
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`.)
1017
1129
  const handsTripId = ours && cardsSaid !== 'none';
1018
1130
  // ⚠️ DIAGNOSTICS, WHERE THERE IS AN ACCOUNT (0.56.1): which connection
1019
1131
  // reached which conversation, by 8-character fingerprints - never an id,
@@ -1022,18 +1134,24 @@ export const buildServer = (opts) => {
1022
1134
  // assistant looked at another. These lines say how.
1023
1135
  if (account) {
1024
1136
  const trip = asked === undefined ? 'none' : lost ? 'lost' : named === own ? 'own' : 'named';
1025
- if (!diagnosed.has(presented)) {
1026
- diagnosed.add(presented);
1027
- if (diagnosed.size > 100_000)
1028
- diagnosed.clear();
1029
- console.log(`[mcp] first call s=${h8(presented)} ${headerNames(c)}`);
1030
- }
1031
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) ?? '-'}`);
1032
1138
  }
1033
- if (ours)
1034
- 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
+ }
1035
1149
  else if (sessions.isAnchored(presented))
1036
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));
1037
1155
  if (account?.has(name)) {
1038
1156
  // ⚠️ WHO MAY NAME WHICH CONVERSATION (review P2-1). The assistant's
1039
1157
  // three: their own, never one a trip id names. The card's: the one
@@ -1084,12 +1202,18 @@ export const buildServer = (opts) => {
1084
1202
  // A card host answered in words is told the link and code it would
1085
1203
  // have drawn - the guest signs in either way.
1086
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 } : {}),
1087
1207
  });
1088
- return ok(c, id, {
1089
- content: [{ type: 'text', text: answer.text }],
1208
+ const told = said(answer.text, {
1090
1209
  // The deployment's name, logo and tools beside it, as every answer
1091
1210
  // has them: this may be the first card the conversation draws.
1092
- 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,
1093
1217
  ...(answer.isError ? { isError: true } : {}),
1094
1218
  _meta: {
1095
1219
  ...(lost
@@ -1208,6 +1332,8 @@ export const buildServer = (opts) => {
1208
1332
  : {}),
1209
1333
  // Only a client that said it draws them - never one we know nothing of (`drawsCards`).
1210
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 } : {}),
1211
1337
  });
1212
1338
  // The guest's own details beside the answer, never in it - see `guestsApart`.
1213
1339
  const { shown, guests } = guestsApart(answer.structured);
@@ -1215,9 +1341,15 @@ export const buildServer = (opts) => {
1215
1341
  const { shown: unnamed, who } = memberApart(shown);
1216
1342
  // And the city field's menu - see `CITIES_META_KEY`.
1217
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);
1218
1350
  return ok(c, id, {
1219
- content: [{ type: 'text', text: answer.text }],
1220
- structuredContent: drawn,
1351
+ content: [{ type: 'text', text: told.text }],
1352
+ structuredContent: pictured,
1221
1353
  ...(answer.isError ? { isError: true } : {}),
1222
1354
  // Beside the answer, not inside it: the card needs the trip to badge
1223
1355
  // its header, and the model needs no such list - handing it one is
@@ -1276,18 +1408,65 @@ export const buildServer = (opts) => {
1276
1408
  const printable = (s, max) => s.replace(/[^\x20-\x7e]/g, '?').slice(0, max);
1277
1409
  /** An id as 8 characters of its SHA-256 - the same fingerprint the account's lines use (account/index.ts `tag`). */
1278
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}".` : ''}`;
1279
1454
  /**
1280
- * The headers a request came with - their NAMES, sorted, never a value - and
1281
- * its user-agent as it is (diagnostics, 0.56.1: is there a conversation id a
1282
- * host sends, as ChatGPT's x-openai-session?). Addresses and cookies are named
1283
- * 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).
1284
1459
  */
1285
1460
  const headerNames = (c) => {
1286
1461
  const names = Object.keys(c.req.header())
1287
1462
  .map((n) => n.toLowerCase())
1288
1463
  .sort();
1289
- return `headers=[${printable(names.join(','), 400)}] ua=${printable(c.req.header('user-agent') ?? '-', 80)}`;
1464
+ return `headers=[${printable(names.join(','), 600)}]`;
1290
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;
1291
1470
  export const clientIp = (header) => {
1292
1471
  const last = (header ?? '').split(',').at(-1)?.trim();
1293
1472
  return last || undefined;