@curless/hotel-storefront 0.67.0 → 0.67.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/index.d.ts +4 -0
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +32 -18
- package/dist/account/index.js.map +1 -1
- package/dist/account/pages.d.ts +5 -1
- package/dist/account/pages.d.ts.map +1 -1
- package/dist/account/pages.js +47 -13
- package/dist/account/pages.js.map +1 -1
- package/dist/account/requests.d.ts +1 -1
- package/dist/account/requests.d.ts.map +1 -1
- package/dist/card.generated.d.ts +1 -1
- package/dist/card.generated.js +2 -2
- package/dist/card.generated.js.map +1 -1
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/otaless/backend.d.ts +4 -0
- package/dist/otaless/backend.d.ts.map +1 -1
- package/dist/otaless/backend.js +31 -0
- package/dist/otaless/backend.js.map +1 -1
- package/dist/otaless/booking.d.ts +42 -1
- package/dist/otaless/booking.d.ts.map +1 -1
- package/dist/otaless/booking.js +130 -24
- package/dist/otaless/booking.js.map +1 -1
- package/dist/otaless/fake.d.ts +6 -0
- package/dist/otaless/fake.d.ts.map +1 -1
- package/dist/otaless/fake.js +6 -3
- package/dist/otaless/fake.js.map +1 -1
- package/dist/otaless/make.d.ts +6 -0
- package/dist/otaless/make.d.ts.map +1 -1
- package/dist/otaless/make.js +26 -1
- package/dist/otaless/make.js.map +1 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +245 -15
- package/dist/server.js.map +1 -1
- package/dist/surface.d.ts +1 -1
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +1 -1
- package/dist/surface.js.map +1 -1
- package/dist/tools.d.ts +6 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +77 -17
- package/dist/tools.js.map +1 -1
- package/dist/trip-ids.d.ts +27 -0
- package/dist/trip-ids.d.ts.map +1 -1
- package/dist/trip-ids.js +70 -0
- package/dist/trip-ids.js.map +1 -1
- package/dist/types.d.ts +23 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHash, timingSafeEqual } from 'node:crypto';
|
|
1
|
+
import { createHash, createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { dirname, resolve } from 'node:path';
|
|
4
4
|
import { BRAND_FONTS, BRAND_FONTS_VERSION, familiesOf, fontAsset, fontHeaders, isBrandFont, weightsOf, } from '@curless/brand-fonts';
|
|
@@ -20,7 +20,7 @@ import { StateDir } from './state.js';
|
|
|
20
20
|
import { makeSupplier } from './supplier.js';
|
|
21
21
|
import { buildInstructions, listTools, tripToolNames } from './surface.js';
|
|
22
22
|
import { TERMS_META_KEY, agreeToTerms, bookingRefusal, buildOutputSchemas, buildTools, commonFields, contextFor, handleTool, homeListing, identityFor, outputSchemasFor, tripGone, withheldTools, } from './tools.js';
|
|
23
|
-
import { ID_TTL_MS, TripIds } from './trip-ids.js';
|
|
23
|
+
import { ID_TTL_MS, SAME_NETWORK_MS, TAKE_OVER_MS, TripIds, networkOf } from './trip-ids.js';
|
|
24
24
|
import { TripStore, tripKey } from './trip.js';
|
|
25
25
|
import { checkDemoData, resolveBrand } from './vocab.js';
|
|
26
26
|
// The connector itself: one config in, one HTTP app out.
|
|
@@ -51,7 +51,7 @@ export const INITIALIZE_PER_MINUTE = 300;
|
|
|
51
51
|
* number. Found by reading the boot banner of a container that had just been
|
|
52
52
|
* deployed (2026-09-22): seventeen tools listed, and "0.7.0" above them.
|
|
53
53
|
*/
|
|
54
|
-
export const VERSION = '0.67.
|
|
54
|
+
export const VERSION = '0.67.2';
|
|
55
55
|
/**
|
|
56
56
|
* The card's resource URI.
|
|
57
57
|
*
|
|
@@ -332,6 +332,22 @@ export const buildServer = (opts) => {
|
|
|
332
332
|
const members = new MemberStore(now, state.file('members.json'));
|
|
333
333
|
const tripIds = new TripIds(now, state.file('trip-ids.json'));
|
|
334
334
|
const sessions = new Sessions(now, state.file('sessions.json'));
|
|
335
|
+
/**
|
|
336
|
+
* The key who-must-sign-in-again is kept under (0.67.2, 总线程's re-review: a plain
|
|
337
|
+
* sha256 of a membership number can be worked back). Kept in the state directory, so a
|
|
338
|
+
* restart still recognises the same member; with none, this process's own.
|
|
339
|
+
*/
|
|
340
|
+
const againFile = state.file('again-key.json');
|
|
341
|
+
const againKey = (() => {
|
|
342
|
+
const saved = againFile?.read()?.key;
|
|
343
|
+
const key = typeof saved === 'string' && saved.length >= 32
|
|
344
|
+
? saved
|
|
345
|
+
: randomBytes(32).toString('base64url');
|
|
346
|
+
againFile?.bind(() => ({ key }));
|
|
347
|
+
if (key !== saved)
|
|
348
|
+
againFile?.changed();
|
|
349
|
+
return key;
|
|
350
|
+
})();
|
|
335
351
|
const misses = new Misses(now);
|
|
336
352
|
const initializes = new WindowCounter(60_000, now);
|
|
337
353
|
// Tool calls answered, requests refused for carrying no session (P0-2), and
|
|
@@ -624,6 +640,12 @@ export const buildServer = (opts) => {
|
|
|
624
640
|
// a press on the card, never the model's - no tool it can see agrees.
|
|
625
641
|
brand.tools.acceptTerms,
|
|
626
642
|
]);
|
|
643
|
+
/** App-only tools with a refusal of their own for a client that draws no card (see tools/call). */
|
|
644
|
+
const OWN_REFUSALS = new Set([
|
|
645
|
+
...(account ? [account.names.card] : []),
|
|
646
|
+
...(memberLogin ? [brand.tools.memberCard] : []),
|
|
647
|
+
brand.tools.acceptTerms,
|
|
648
|
+
]);
|
|
627
649
|
const appOnly = (m) => ({
|
|
628
650
|
...m,
|
|
629
651
|
ui: { ...m.ui, visibility: ['app'] },
|
|
@@ -676,6 +698,43 @@ export const buildServer = (opts) => {
|
|
|
676
698
|
const READ_ONLY = new Set([...TOOLS, ...ACCOUNT_TOOLS]
|
|
677
699
|
.filter((t) => t.annotations?.readOnlyHint === true)
|
|
678
700
|
.map((t) => t.name));
|
|
701
|
+
/**
|
|
702
|
+
* The tools that reach a conversation's bookings - after a take-over from another
|
|
703
|
+
* network, only for the same account signed in again (0.67.1). The trip and the
|
|
704
|
+
* search are not among them.
|
|
705
|
+
*/
|
|
706
|
+
const BOOKING_TOOLS = new Set([
|
|
707
|
+
brand.tools.requestBooking,
|
|
708
|
+
brand.tools.bookPicked,
|
|
709
|
+
brand.tools.listBookings,
|
|
710
|
+
brand.tools.previewCancellation,
|
|
711
|
+
brand.tools.cancelBooking,
|
|
712
|
+
brand.tools.refundBooking,
|
|
713
|
+
brand.tools.previewChange,
|
|
714
|
+
brand.tools.changeBooking,
|
|
715
|
+
brand.tools.listBookingAddons,
|
|
716
|
+
brand.tools.addBookingAddon,
|
|
717
|
+
brand.tools.acceptTerms,
|
|
718
|
+
brand.tools.payWithUnionPay,
|
|
719
|
+
// …and the plan, which reads the bookings to mark what is booked (0.67.2, re-review).
|
|
720
|
+
brand.tools.itinerary,
|
|
721
|
+
]);
|
|
722
|
+
/** Last used longer ago than a take-over allows - or never said (0.67.1, `TAKE_OVER_MS`). */
|
|
723
|
+
const quietTooLong = (usedAt) => usedAt === undefined || now() - usedAt > TAKE_OVER_MS;
|
|
724
|
+
/** Who a conversation is signed in as, hashed: its account's id, its membership's number (0.67.1). */
|
|
725
|
+
const signedInAs = (key) => [
|
|
726
|
+
account?.whoOf(key) ? `account ${account.whoOf(key)}` : '',
|
|
727
|
+
deps.members.read(key)?.number ? `member ${deps.members.read(key)?.number}` : '',
|
|
728
|
+
]
|
|
729
|
+
.filter(Boolean)
|
|
730
|
+
.map((w) => createHmac('sha256', againKey).update(w).digest('base64url'));
|
|
731
|
+
/** A take-over from another network, at a booking: sign in again as the same account - or start over. */
|
|
732
|
+
const signInAgainSaid = (canSignIn) => {
|
|
733
|
+
const tool = account?.names.signIn ?? (memberLogin ? brand.tools.signIn : undefined);
|
|
734
|
+
return canSignIn && tool
|
|
735
|
+
? `Nothing was done: this conversation was picked up on a connection from another network, so its bookings are reached only once the guest signs in again here, to the same account or membership as before - ${tool} gives the link. The trip and the search are as they were.`
|
|
736
|
+
: 'Nothing was done: this conversation was picked up on a connection from another network, and nobody was signed in to it, so its bookings are not reached from here. Call again without trip to start a new conversation.';
|
|
737
|
+
};
|
|
679
738
|
/** …and of those, the ones that say what a conversation holds: a new connection's empty one is said to be new. */
|
|
680
739
|
const STATE_READS = new Set([
|
|
681
740
|
brand.tools.viewTrip,
|
|
@@ -1028,9 +1087,9 @@ export const buildServer = (opts) => {
|
|
|
1028
1087
|
const session = presented;
|
|
1029
1088
|
// The card names its trip; the conversation is known by its session. See
|
|
1030
1089
|
// trip-ids.ts for why both exist.
|
|
1031
|
-
|
|
1090
|
+
let asked = typeof args.trip === 'string' && args.trip ? args.trip : undefined;
|
|
1032
1091
|
calls.issued += 1;
|
|
1033
|
-
|
|
1092
|
+
let named = asked ? tripIds.keyFor(asked) : undefined;
|
|
1034
1093
|
// ⚠️ A TRIP THE CARD NAMES AND WE DO NOT KNOW IS SAID SO - see `tripGone`.
|
|
1035
1094
|
// Anything else it asked is still answered, but with no trip beside it:
|
|
1036
1095
|
// the card would take that trip's id as its own.
|
|
@@ -1050,13 +1109,35 @@ export const buildServer = (opts) => {
|
|
|
1050
1109
|
// conversation's own trip id is given to the model in every answer, and
|
|
1051
1110
|
// the model passes it on every call. See `Sessions.bind` for the rules.
|
|
1052
1111
|
const words = cardsSaid === 'none';
|
|
1112
|
+
// ⚠️ THE CARD'S OWN TOOLS, ONLY TO A CLIENT THAT SAID IT DRAWS CARDS (0.67.1,
|
|
1113
|
+
// 总线程's review of 0.67.0): Manus does not read `visibility: ['app']` and lists
|
|
1114
|
+
// them to its model - a pick, the booking form's submit, a UnionPay payment. The
|
|
1115
|
+
// account's card tool, the membership's and the terms' have refusals of their
|
|
1116
|
+
// own, with their own words (below); every other one is refused here.
|
|
1117
|
+
if (APP_ONLY.has(name) && !saidCards && !OWN_REFUSALS.has(name)) {
|
|
1118
|
+
calls.accountRefused += 1;
|
|
1119
|
+
console.log(`[mcp] ${printable(name, 60)} refused: card_only - client=${printable(sessions.clientOf(presented) ?? '-', 60)} cards=${cardsSaid ?? '-'}`);
|
|
1120
|
+
return ok(c, id, {
|
|
1121
|
+
content: [
|
|
1122
|
+
{
|
|
1123
|
+
type: 'text',
|
|
1124
|
+
text: `${name} is the booking card's own, and this app draws no card: nothing was done.`,
|
|
1125
|
+
},
|
|
1126
|
+
],
|
|
1127
|
+
structuredContent: { view: 'error', brand: config.brand, code: 'card_only' },
|
|
1128
|
+
isError: true,
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1053
1131
|
noteHeaders(c, 'tools/call', sessions.clientOf(presented), ` tool=${printable(name, 60)} s=${h8(presented)} trip=${asked === undefined ? 'none' : lost ? 'lost' : 'named'}`);
|
|
1054
1132
|
const from = ip ? addressKey(ip) : undefined;
|
|
1133
|
+
/** Its network, for "the same network" (0.67.1) - never written down or logged. */
|
|
1134
|
+
const network = networkOf(from);
|
|
1135
|
+
const client = sessions.clientOf(presented);
|
|
1055
1136
|
/** This connection's conversation, in words - only once it has one (anchored). */
|
|
1056
1137
|
const ownInWords = (k) => sessions.isAnchored(presented) ? tripIds.idFor(k, from, true) : undefined;
|
|
1057
1138
|
let own = (words ? sessions.boundOf(presented) : undefined) ?? tripKey(session, config.brand);
|
|
1058
1139
|
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`);
|
|
1140
|
+
console.log(`[mcp] trip-gone tool=${printable(name, 60)} id=${h8(asked ?? '')} knownIds=${tripIds.size} client=${printable(sessions.clientOf(presented) ?? '-', 60)} cards=none`);
|
|
1060
1141
|
const mine = ownInWords(own);
|
|
1061
1142
|
return ok(c, id, {
|
|
1062
1143
|
content: [{ type: 'text', text: tripLostSaid(mine) }],
|
|
@@ -1074,7 +1155,7 @@ export const buildServer = (opts) => {
|
|
|
1074
1155
|
// Which id, from what app - never the address, the arguments or
|
|
1075
1156
|
// anything said in it (2026-10-14: robin met this on a new
|
|
1076
1157
|
// conversation, and nothing said why).
|
|
1077
|
-
console.log(`[mcp] trip-gone tool=${printable(name, 60)} id=${h8(asked)} knownIds=${tripIds.size} client=${printable(sessions.clientOf(presented) ?? '-', 60)} ua=${printable(c.req.header('user-agent') ?? '-', 80)}`);
|
|
1158
|
+
console.log(`[mcp] trip-gone tool=${printable(name, 60)} id=${h8(asked ?? '')} knownIds=${tripIds.size} client=${printable(sessions.clientOf(presented) ?? '-', 60)} ua=${printable(c.req.header('user-agent') ?? '-', 80)}`);
|
|
1078
1159
|
const gone = tripGone(deps);
|
|
1079
1160
|
return ok(c, id, {
|
|
1080
1161
|
content: [{ type: 'text', text: gone.text }],
|
|
@@ -1083,17 +1164,96 @@ export const buildServer = (opts) => {
|
|
|
1083
1164
|
_meta: meta(),
|
|
1084
1165
|
});
|
|
1085
1166
|
}
|
|
1167
|
+
// ⚠️ AN ID HANDED OUT IN WORDS IS NEVER A CARD'S (0.67.1, 总线程's review of
|
|
1168
|
+
// 0.67.0): a connection that said it draws cards and names one is not the card of
|
|
1169
|
+
// that conversation - its card was never given it - and would reach the terms'
|
|
1170
|
+
// ref in `_meta` the card path hands over.
|
|
1171
|
+
if (!words && asked !== undefined && tripIds.inWords(asked)) {
|
|
1172
|
+
calls.notCarried += 1;
|
|
1173
|
+
console.log(`[mcp] ${printable(name, 60)} refused: not_this_conversation (an id in words, from a card client) - client=${printable(client ?? '-', 60)}`);
|
|
1174
|
+
return ok(c, id, {
|
|
1175
|
+
content: [{ type: 'text', text: notCarriedSaid(undefined) }],
|
|
1176
|
+
structuredContent: {
|
|
1177
|
+
view: 'error',
|
|
1178
|
+
brand: config.brand,
|
|
1179
|
+
error: 'not_this_conversation',
|
|
1180
|
+
code: 'not_this_conversation',
|
|
1181
|
+
},
|
|
1182
|
+
isError: true,
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
/** The conversation the trip id named was quiet too long to be taken over (0.67.1) - said in the answer. */
|
|
1186
|
+
let expired = false;
|
|
1187
|
+
/** This call took a conversation over: from the same network, or not ('-': not known). */
|
|
1188
|
+
let takenOver;
|
|
1086
1189
|
if (words && asked !== undefined && named !== undefined && named !== own) {
|
|
1087
|
-
|
|
1190
|
+
const held = tripIds.inWordsHeld(asked);
|
|
1191
|
+
if (!sessions.isAnchored(presented) && held && quietTooLong(held.usedAt)) {
|
|
1192
|
+
// ⚠️ NOT AFTER HALF AN HOUR (0.67.1): an id is a way back into a conversation
|
|
1193
|
+
// just left, not a pass for weeks - one in a shared or exported transcript is
|
|
1194
|
+
// worth nothing once the conversation has gone quiet. As if no id was passed:
|
|
1195
|
+
// a new, empty conversation, and the answer says so.
|
|
1196
|
+
expired = true;
|
|
1197
|
+
console.log(`[mcp] not carried over: quiet too long s=${h8(presented)} k=${h8(named)} client=${printable(client ?? '-', 60)}`);
|
|
1198
|
+
asked = undefined;
|
|
1199
|
+
named = undefined;
|
|
1200
|
+
}
|
|
1201
|
+
else if (!sessions.isAnchored(presented) &&
|
|
1202
|
+
held &&
|
|
1203
|
+
(held.client ?? '') !== (client ?? '')) {
|
|
1204
|
+
// ⚠️ AS THE SAME APP (0.67.1): Manus's next connection says it is Manus.
|
|
1205
|
+
calls.notCarried += 1;
|
|
1206
|
+
console.log(`[mcp] ${printable(name, 60)} refused: not_this_conversation (another app) - client=${printable(client ?? '-', 60)}`);
|
|
1207
|
+
return ok(c, id, {
|
|
1208
|
+
content: [{ type: 'text', text: otherAppSaid }],
|
|
1209
|
+
structuredContent: {
|
|
1210
|
+
view: 'error',
|
|
1211
|
+
brand: config.brand,
|
|
1212
|
+
error: 'not_this_conversation',
|
|
1213
|
+
code: 'not_this_conversation',
|
|
1214
|
+
},
|
|
1215
|
+
isError: true,
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
else if (!sessions.isAnchored(presented) && held) {
|
|
1088
1219
|
// A new connection's first word of a conversation it has not acted
|
|
1089
|
-
// in yet
|
|
1220
|
+
// in yet, used in the last half hour by the same app: it takes that
|
|
1221
|
+
// conversation over, and keeps to it - and the one that held it is
|
|
1222
|
+
// turned away from now on (below).
|
|
1090
1223
|
sessions.bind(presented, named);
|
|
1091
1224
|
own = named;
|
|
1092
1225
|
calls.carriedOver += 1;
|
|
1093
|
-
|
|
1226
|
+
takenOver = tripIds.networkMatch(asked, network);
|
|
1227
|
+
console.log(`[mcp] carried over s=${h8(presented)} k=${h8(named)} tool=${printable(name, 60)} client=${printable(client ?? '-', 60)} address=${takenOver}`);
|
|
1228
|
+
// ⚠️ THE SAME NETWORK KEEPS THE SIGN-IN ONLY RIGHT AFTER (0.67.2, 总线程's re-review):
|
|
1229
|
+
// Manus's and claude.ai's calls leave from their platforms' own addresses, and
|
|
1230
|
+
// someone else on the same platform may well be on the same network. A reconnect
|
|
1231
|
+
// is at once; past five minutes, as from another network.
|
|
1232
|
+
const fresh = held.usedAt !== undefined && now() - held.usedAt < SAME_NETWORK_MS;
|
|
1233
|
+
if (takenOver !== 'same' || !fresh) {
|
|
1234
|
+
// ⚠️ FROM ANOTHER NETWORK, THE SIGN-INS END AND THE BOOKINGS WAIT FOR THE SAME
|
|
1235
|
+
// ACCOUNT (0.67.1): an id read off a transcript is not the guest. Who the
|
|
1236
|
+
// conversation was signed in as is kept (hashed) - only that account or
|
|
1237
|
+
// membership signing in again here reaches its bookings; none, and nothing does.
|
|
1238
|
+
// ⚠️ AND NOT OVER A LIST THAT HAS NOT BEEN MET YET (0.67.2): taken over once and
|
|
1239
|
+
// signed in as someone else, a second take-over would have made that someone
|
|
1240
|
+
// the one to sign in again - and a second at once, an empty list, locked for
|
|
1241
|
+
// good. The first list stands until the guest it names signs in again.
|
|
1242
|
+
const who = held.again ?? signedInAs(named);
|
|
1243
|
+
account?.forget(named);
|
|
1244
|
+
deps.members.clear(named);
|
|
1245
|
+
memberLogin?.cancel(named);
|
|
1246
|
+
if (!held.again)
|
|
1247
|
+
tripIds.setAgain(asked, who);
|
|
1248
|
+
}
|
|
1249
|
+
// Held by this connection from now on - whatever this call comes to.
|
|
1250
|
+
tripIds.heldBy(asked, presented, client, network);
|
|
1094
1251
|
}
|
|
1095
|
-
else if (sessions.isAnchored(presented)) {
|
|
1252
|
+
else if (sessions.isAnchored(presented) || !held) {
|
|
1096
1253
|
// ⚠️ A CONNECTION THAT HAS ITS CONVERSATION NAMES NO OTHER - every tool,
|
|
1254
|
+
// and (0.67.2, 总线程's re-review) a client that draws no card names no id
|
|
1255
|
+
// that was not handed out in words: a card conversation's id would skip the
|
|
1256
|
+
// window, the holder and the network.
|
|
1097
1257
|
// in words (the rule of review P2-1, which the card's tools keep below):
|
|
1098
1258
|
// with no card here, an id it did not get from its own answers is one
|
|
1099
1259
|
// a page or a message put in front of the model.
|
|
@@ -1150,8 +1310,51 @@ export const buildServer = (opts) => {
|
|
|
1150
1310
|
calls.foreignTrip += 1;
|
|
1151
1311
|
/** The conversation's id for the model, in words: a client that draws no card, its own conversation. */
|
|
1152
1312
|
const inWords = words && ours ? ownInWords(key) : undefined;
|
|
1313
|
+
if (inWords) {
|
|
1314
|
+
const held = tripIds.inWordsHeld(inWords);
|
|
1315
|
+
// ⚠️ ONE CONNECTION AT A TIME (0.67.1): once a new connection has taken the
|
|
1316
|
+
// conversation over, the one that held it is turned away - a stolen id is not
|
|
1317
|
+
// used beside the guest, and the guest's own old connection is not a second door.
|
|
1318
|
+
if (held?.holder && held.holder !== presented && takenOver === undefined) {
|
|
1319
|
+
calls.notCarried += 1;
|
|
1320
|
+
console.log(`[mcp] ${printable(name, 60)} refused: not_this_conversation (taken over by another connection) - client=${printable(client ?? '-', 60)}`);
|
|
1321
|
+
return ok(c, id, {
|
|
1322
|
+
content: [{ type: 'text', text: movedSaid }],
|
|
1323
|
+
structuredContent: {
|
|
1324
|
+
view: 'error',
|
|
1325
|
+
brand: config.brand,
|
|
1326
|
+
error: 'not_this_conversation',
|
|
1327
|
+
code: 'not_this_conversation',
|
|
1328
|
+
},
|
|
1329
|
+
isError: true,
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1332
|
+
// ⚠️ ITS BOOKINGS, AFTER A TAKE-OVER FROM ANOTHER NETWORK, ONLY FOR THE SAME
|
|
1333
|
+
// ACCOUNT SIGNED IN AGAIN (0.67.1) - see `takenOver` above. The trip and the
|
|
1334
|
+
// search are as ever.
|
|
1335
|
+
if (held?.again && BOOKING_TOOLS.has(name)) {
|
|
1336
|
+
const now = signedInAs(key);
|
|
1337
|
+
if (!now.some((w) => held.again?.includes(w))) {
|
|
1338
|
+
calls.accountRefused += 1;
|
|
1339
|
+
console.log(`[mcp] ${printable(name, 60)} refused: sign_in_again`);
|
|
1340
|
+
return ok(c, id, {
|
|
1341
|
+
content: [{ type: 'text', text: signInAgainSaid(held.again.length > 0) }],
|
|
1342
|
+
structuredContent: {
|
|
1343
|
+
view: 'error',
|
|
1344
|
+
brand: config.brand,
|
|
1345
|
+
error: 'sign_in_again',
|
|
1346
|
+
code: 'sign_in_again',
|
|
1347
|
+
conversation: conversationOf(inWords),
|
|
1348
|
+
},
|
|
1349
|
+
isError: true,
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
tripIds.setAgain(inWords, undefined);
|
|
1353
|
+
}
|
|
1354
|
+
tripIds.heldBy(inWords, presented, client, network);
|
|
1355
|
+
}
|
|
1153
1356
|
/** 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));
|
|
1357
|
+
const said = (text, structured) => inWordsOf(text, structured, inWords, looking && STATE_READS.has(name), expired);
|
|
1155
1358
|
if (account?.has(name)) {
|
|
1156
1359
|
// ⚠️ WHO MAY NAME WHICH CONVERSATION (review P2-1). The assistant's
|
|
1157
1360
|
// three: their own, never one a trip id names. The card's: the one
|
|
@@ -1167,8 +1370,10 @@ export const buildServer = (opts) => {
|
|
|
1167
1370
|
console.log(`[mcp] ${printable(name, 60)} names a conversation from a fresh connection - client=${printable(sessions.clientOf(presented) ?? '-', 60)} cards=${sessions.cardsOf(presented) ?? '-'}`);
|
|
1168
1371
|
}
|
|
1169
1372
|
}
|
|
1373
|
+
// ⚠️ NOT ONLY 'none' (0.67.2, re-review): a session that never said it draws cards
|
|
1374
|
+
// (from before 0.59.0) is no card either.
|
|
1170
1375
|
const refusal = isCard
|
|
1171
|
-
?
|
|
1376
|
+
? !saidCards
|
|
1172
1377
|
? 'card_only'
|
|
1173
1378
|
: !ours && sessions.isAnchored(presented)
|
|
1174
1379
|
? 'not_this_conversation'
|
|
@@ -1327,13 +1532,16 @@ export const buildServer = (opts) => {
|
|
|
1327
1532
|
...(ip ? { ip } : {}),
|
|
1328
1533
|
// The assistant's membership sign-in, as the account's (0.59.0, review
|
|
1329
1534
|
// C1): in words unless the session said it draws cards.
|
|
1330
|
-
...(cardsSaid === 'none' ||
|
|
1535
|
+
...(cardsSaid === 'none' ||
|
|
1536
|
+
((name === brand.tools.signIn || name === brand.tools.memberCard) && !saidCards)
|
|
1331
1537
|
? { noCards: true }
|
|
1332
1538
|
: {}),
|
|
1333
1539
|
// Only a client that said it draws them - never one we know nothing of (`drawsCards`).
|
|
1334
1540
|
...(saidCards ? { drawsCards: true } : {}),
|
|
1335
1541
|
// The conversation's id, for what its words tell the model to pass on (0.67.0).
|
|
1336
1542
|
...(inWords ? { tripInWords: inWords } : {}),
|
|
1543
|
+
// …and the conversation it took over, whose bookings are its own (0.67.1).
|
|
1544
|
+
...(words && own !== tripKey(session, config.brand) ? { conversation: own } : {}),
|
|
1337
1545
|
});
|
|
1338
1546
|
// The guest's own details beside the answer, never in it - see `guestsApart`.
|
|
1339
1547
|
const { shown, guests } = guestsApart(answer.structured);
|
|
@@ -1434,7 +1642,29 @@ const conversationOf = (id) => ({ trip: id, said: conversationSaid(id) });
|
|
|
1434
1642
|
/** A new connection's look at what its conversation holds, naming no trip: it holds nothing yet (0.67.0). */
|
|
1435
1643
|
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
1644
|
/** What an answer to a client that draws no card says beside its own words - see `conversationSaid`. */
|
|
1437
|
-
const inWordsOf = (text, structured, id, fresh) =>
|
|
1645
|
+
const inWordsOf = (text, structured, id, fresh, expired = false) => {
|
|
1646
|
+
const told = inWordsOf0(text, structured, id, fresh);
|
|
1647
|
+
return expired
|
|
1648
|
+
? {
|
|
1649
|
+
text: `${EXPIRED_SAID}\n\n${told.text}`,
|
|
1650
|
+
structured: {
|
|
1651
|
+
...told.structured,
|
|
1652
|
+
conversation: {
|
|
1653
|
+
...(told.structured.conversation ?? {}),
|
|
1654
|
+
expired: true,
|
|
1655
|
+
expiredSaid: EXPIRED_SAID,
|
|
1656
|
+
},
|
|
1657
|
+
},
|
|
1658
|
+
}
|
|
1659
|
+
: told;
|
|
1660
|
+
};
|
|
1661
|
+
/** A trip id whose conversation was quiet too long to be taken over (0.67.1). */
|
|
1662
|
+
export const EXPIRED_SAID = 'The trip id passed names a conversation not used for more than 30 minutes, so it was not picked up: this is a new conversation, and nothing of the earlier one - its trip, sign-in or bookings - carries over. The guest signs in again if they need to.';
|
|
1663
|
+
/** Another app naming a conversation (0.67.1). */
|
|
1664
|
+
const otherAppSaid = 'Nothing was done: that trip id names a conversation of another app. Call again without trip to start a conversation here.';
|
|
1665
|
+
/** A connection whose conversation another connection has taken over (0.67.1). */
|
|
1666
|
+
const movedSaid = 'Nothing was done: this conversation has been picked up on another connection, and is reached there alone now. Call again without trip to start a new conversation here.';
|
|
1667
|
+
const inWordsOf0 = (text, structured, id, fresh) => id
|
|
1438
1668
|
? {
|
|
1439
1669
|
text: `${text}\n\n${conversationSaid(id)}`,
|
|
1440
1670
|
structured: { ...structured, conversation: conversationOf(id) },
|