sbb-mcp 0.4.3 → 0.5.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/LICENSE +50 -57
- package/README.md +25 -214
- package/dist/index.js +47 -19
- package/package.json +10 -33
- package/dist/auth.d.ts +0 -2
- package/dist/auth.js +0 -44
- package/dist/auth.js.map +0 -1
- package/dist/cache.d.ts +0 -14
- package/dist/cache.js +0 -62
- package/dist/cache.js.map +0 -1
- package/dist/client.d.ts +0 -17
- package/dist/client.js +0 -70
- package/dist/client.js.map +0 -1
- package/dist/formatters.d.ts +0 -35
- package/dist/formatters.js +0 -285
- package/dist/formatters.js.map +0 -1
- package/dist/http.d.ts +0 -2
- package/dist/http.js +0 -117
- package/dist/http.js.map +0 -1
- package/dist/i18n.d.ts +0 -22
- package/dist/i18n.js +0 -36
- package/dist/i18n.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js.map +0 -1
- package/dist/journey.d.ts +0 -5
- package/dist/journey.js +0 -67
- package/dist/journey.js.map +0 -1
- package/dist/look2book.d.ts +0 -98
- package/dist/look2book.js +0 -212
- package/dist/look2book.js.map +0 -1
- package/dist/prices.d.ts +0 -3
- package/dist/prices.js +0 -51
- package/dist/prices.js.map +0 -1
- package/dist/profile.d.ts +0 -16
- package/dist/profile.js +0 -84
- package/dist/profile.js.map +0 -1
- package/dist/rate-limit.d.ts +0 -5
- package/dist/rate-limit.js +0 -44
- package/dist/rate-limit.js.map +0 -1
- package/dist/shortlink.d.ts +0 -60
- package/dist/shortlink.js +0 -122
- package/dist/shortlink.js.map +0 -1
- package/dist/structured.d.ts +0 -125
- package/dist/structured.js +0 -134
- package/dist/structured.js.map +0 -1
- package/dist/swisstrip.d.ts +0 -41
- package/dist/swisstrip.js +0 -135
- package/dist/swisstrip.js.map +0 -1
- package/dist/tools.d.ts +0 -40
- package/dist/tools.js +0 -509
- package/dist/tools.js.map +0 -1
- package/dist/transport/index.d.ts +0 -10
- package/dist/transport/index.js +0 -13
- package/dist/transport/index.js.map +0 -1
- package/dist/transport/setup.d.ts +0 -1
- package/dist/transport/setup.js +0 -59
- package/dist/transport/setup.js.map +0 -1
- package/dist/transport/smapi-auth.d.ts +0 -14
- package/dist/transport/smapi-auth.js +0 -89
- package/dist/transport/smapi-auth.js.map +0 -1
- package/dist/transport/smapi-client.d.ts +0 -46
- package/dist/transport/smapi-client.js +0 -186
- package/dist/transport/smapi-client.js.map +0 -1
- package/dist/transport/smapi-journey.d.ts +0 -29
- package/dist/transport/smapi-journey.js +0 -91
- package/dist/transport/smapi-journey.js.map +0 -1
- package/dist/transport/smapi-mock.d.ts +0 -9
- package/dist/transport/smapi-mock.js +0 -151
- package/dist/transport/smapi-mock.js.map +0 -1
- package/dist/transport/smapi-prices.d.ts +0 -48
- package/dist/transport/smapi-prices.js +0 -144
- package/dist/transport/smapi-prices.js.map +0 -1
- package/dist/transport/smapi-types.d.ts +0 -181
- package/dist/transport/smapi-types.js +0 -2
- package/dist/transport/smapi-types.js.map +0 -1
- package/dist/types.d.ts +0 -139
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/widgets.d.ts +0 -60
- package/dist/widgets.js +0 -184
- package/dist/widgets.js.map +0 -1
- package/web/dist/widgets.css +0 -1
- package/web/dist/widgets.js +0 -1
package/dist/tools.js
DELETED
|
@@ -1,509 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { isSmapiConfigured, searchPlaces, searchTrips, getTrip, paginateTrips, getTripPrices, getTripOffers, mockSearchPlaces, mockSearchTrips, mockGetTripPrices, } from './transport/index.js';
|
|
4
|
-
import { formatStations, formatStationsTerse, formatConnections, formatConnectionsTerse, formatTripDetails, formatTripDetailsTerse, formatPrices, formatPricesTerse, formatTicketLink, } from './formatters.js';
|
|
5
|
-
import { buildShortLink } from './shortlink.js';
|
|
6
|
-
import { cacheGet, cacheSet, TTL } from './cache.js';
|
|
7
|
-
import { SmapiError } from './transport/smapi-client.js';
|
|
8
|
-
import { loadProfile, saveProfile, formatProfileSummary, isReductionCardExpired } from './profile.js';
|
|
9
|
-
import { isSwissTripConfigured, fetchProfile as fetchCloudProfile, fetchTravelers, toSmapiTraveler, formatTravelersList, formatCloudProfile, } from './swisstrip.js';
|
|
10
|
-
import { getWeatherSummary } from 'swiss-weather-mcp';
|
|
11
|
-
import { toStationsListDTO, toConnectionListDTO, toTripDetailsDTO, toPricesTableDTO, toTicketCardDTO, } from './structured.js';
|
|
12
|
-
import { isWidgetRenderingClient, registerWidgets, widgetResponseMeta, widgetToolMeta, WIDGETS, } from './widgets.js';
|
|
13
|
-
const useMock = !isSmapiConfigured();
|
|
14
|
-
// `useCloud` is intentionally NOT cached at module level. It's evaluated per
|
|
15
|
-
// handler call via `isSwissTripConfigured()` so tests can toggle
|
|
16
|
-
// SWISSTRIP_TOKEN between cases, and so runtime env changes (e.g. when
|
|
17
|
-
// embedded in a host process that sets the token later) take effect.
|
|
18
|
-
/** Match SwissTrip travelers by first name (case-insensitive, fuzzy) */
|
|
19
|
-
function matchTravelersByName(all, names) {
|
|
20
|
-
const matched = [];
|
|
21
|
-
for (const name of names) {
|
|
22
|
-
const lower = name.toLowerCase();
|
|
23
|
-
const found = all.find(t => t.first_name?.toLowerCase() === lower ||
|
|
24
|
-
t.label?.toLowerCase() === lower) || all.find(t => t.first_name?.toLowerCase().startsWith(lower) ||
|
|
25
|
-
t.last_name?.toLowerCase() === lower);
|
|
26
|
-
if (found && !matched.includes(found)) {
|
|
27
|
-
matched.push(found);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return matched;
|
|
31
|
-
}
|
|
32
|
-
export async function handleSaveProfile(input) {
|
|
33
|
-
try {
|
|
34
|
-
const updates = {};
|
|
35
|
-
if (input.first_name)
|
|
36
|
-
updates.first_name = input.first_name;
|
|
37
|
-
if (input.last_name)
|
|
38
|
-
updates.last_name = input.last_name;
|
|
39
|
-
if (input.date_of_birth)
|
|
40
|
-
updates.date_of_birth = input.date_of_birth;
|
|
41
|
-
if (input.reduction_card)
|
|
42
|
-
updates.reduction_card = input.reduction_card;
|
|
43
|
-
if (input.reduction_card_valid_until) {
|
|
44
|
-
updates.reduction_card_valid_until = input.reduction_card_valid_until;
|
|
45
|
-
}
|
|
46
|
-
saveProfile(updates);
|
|
47
|
-
const profile = loadProfile();
|
|
48
|
-
return { content: [{ type: 'text', text: formatProfileSummary(profile) }] };
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
return errorResult(err);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
export async function handleGetProfile() {
|
|
55
|
-
if (isSwissTripConfigured()) {
|
|
56
|
-
try {
|
|
57
|
-
const cloudProfile = await fetchCloudProfile();
|
|
58
|
-
return { content: [{ type: 'text', text: formatCloudProfile(cloudProfile) }] };
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
// Silent fallback to local profile — keeps the tool working when the
|
|
62
|
-
// SwissTrip API is down or the token is stale. Deliberate: users
|
|
63
|
-
// never see a cloud error message; they just get their local data.
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const profile = loadProfile();
|
|
67
|
-
if (!profile) {
|
|
68
|
-
return {
|
|
69
|
-
content: [{
|
|
70
|
-
type: 'text',
|
|
71
|
-
text: 'No travel profile saved. Ask the user: "Do you have a Halbtax or GA travelcard?" Then use save_profile to store their details for next time.',
|
|
72
|
-
}],
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
return { content: [{ type: 'text', text: formatProfileSummary(profile) }] };
|
|
76
|
-
}
|
|
77
|
-
export async function handleListTravelers() {
|
|
78
|
-
if (!isSwissTripConfigured()) {
|
|
79
|
-
return {
|
|
80
|
-
content: [{
|
|
81
|
-
type: 'text',
|
|
82
|
-
text: 'list_travelers requires a SwissTrip account connection (SWISSTRIP_TOKEN). Without it, use save_profile/get_profile for single-traveler local profiles.',
|
|
83
|
-
}],
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
const cacheKey = 'swisstrip:travelers';
|
|
88
|
-
const cached = cacheGet(cacheKey);
|
|
89
|
-
if (cached)
|
|
90
|
-
return { content: [{ type: 'text', text: cached }] };
|
|
91
|
-
const travelers = await fetchTravelers();
|
|
92
|
-
const text = formatTravelersList(travelers);
|
|
93
|
-
cacheSet(cacheKey, text, TTL.STATIONS);
|
|
94
|
-
return { content: [{ type: 'text', text }] };
|
|
95
|
-
}
|
|
96
|
-
catch (err) {
|
|
97
|
-
return errorResult(err);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function errorResult(err) {
|
|
101
|
-
if (err instanceof SmapiError) {
|
|
102
|
-
const msgs = err.displayMessages;
|
|
103
|
-
const detail = msgs.length ? msgs.join('. ') : err.message;
|
|
104
|
-
return { content: [{ type: 'text', text: `Error: ${detail} (HTTP ${err.status})` }], isError: true };
|
|
105
|
-
}
|
|
106
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
107
|
-
return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };
|
|
108
|
-
}
|
|
109
|
-
/** Compute Europe/Zurich ISO timestamp for a (date, HH:MM) pair. */
|
|
110
|
-
function zurichIso(date, time) {
|
|
111
|
-
const probe = new Date(`${date}T${time}:00Z`);
|
|
112
|
-
const zurichStr = probe.toLocaleString('en-US', { timeZone: 'Europe/Zurich' });
|
|
113
|
-
const zurichTime = new Date(zurichStr + ' UTC');
|
|
114
|
-
const offsetMs = zurichTime.getTime() - probe.getTime();
|
|
115
|
-
const offsetHours = Math.round(offsetMs / (60 * 60 * 1000));
|
|
116
|
-
const offsetStr = `${offsetHours >= 0 ? '+' : '-'}${String(Math.abs(offsetHours)).padStart(2, '0')}:00`;
|
|
117
|
-
return new Date(`${date}T${time}:00${offsetStr}`).toISOString();
|
|
118
|
-
}
|
|
119
|
-
export function createSbbMcpServer() {
|
|
120
|
-
const server = new McpServer({
|
|
121
|
-
name: 'sbb-mcp',
|
|
122
|
-
version: '0.4.3',
|
|
123
|
-
description: 'Swiss Federal Railways (SBB/CFF/FFS) — real-time train schedules, prices, and ticket purchase links for Switzerland',
|
|
124
|
-
});
|
|
125
|
-
// ─── Widget resources (ChatGPT Apps SDK) ───────────────────────────────
|
|
126
|
-
registerWidgets(server);
|
|
127
|
-
// ─── Prompts ───────────────────────────────────────────────────────────
|
|
128
|
-
server.prompt('plan_journey', 'Plan a train journey in Switzerland — finds connections, compares prices, and provides ticket links', {
|
|
129
|
-
from: z.string().describe('Origin station (e.g. "Zurich")'),
|
|
130
|
-
to: z.string().describe('Destination station (e.g. "Bern")'),
|
|
131
|
-
date: z.string().optional().describe('Travel date YYYY-MM-DD'),
|
|
132
|
-
}, async ({ from, to, date }) => ({
|
|
133
|
-
messages: [{
|
|
134
|
-
role: 'user',
|
|
135
|
-
content: {
|
|
136
|
-
type: 'text',
|
|
137
|
-
text: `Plan a train journey from ${from} to ${to}${date ? ` on ${date}` : ' today'}. Search for connections, get prices with Half-Fare card, and provide a ticket purchase link for the best option.`,
|
|
138
|
-
},
|
|
139
|
-
}],
|
|
140
|
-
}));
|
|
141
|
-
// ─── Resource: user profile ────────────────────────────────────────────
|
|
142
|
-
server.resource('profile', 'sbb://profile', {
|
|
143
|
-
description: 'The user\'s saved travel profile (name, DOB, reduction card). Read this before showing prices or generating ticket links. If empty, ask the user for their details and save with save_profile.',
|
|
144
|
-
mimeType: 'text/plain',
|
|
145
|
-
}, async () => {
|
|
146
|
-
if (isSwissTripConfigured()) {
|
|
147
|
-
try {
|
|
148
|
-
const cloudProfile = await fetchCloudProfile();
|
|
149
|
-
return {
|
|
150
|
-
contents: [{
|
|
151
|
-
uri: 'sbb://profile',
|
|
152
|
-
mimeType: 'text/plain',
|
|
153
|
-
text: formatCloudProfile(cloudProfile),
|
|
154
|
-
}],
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
// Fall through
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
const profile = loadProfile();
|
|
162
|
-
if (!profile) {
|
|
163
|
-
return {
|
|
164
|
-
contents: [{
|
|
165
|
-
uri: 'sbb://profile',
|
|
166
|
-
mimeType: 'text/plain',
|
|
167
|
-
text: 'No travel profile saved yet. Ask the user: "Do you have a Halbtax or GA travelcard?" and their name/date of birth. Then use save_profile to store it.',
|
|
168
|
-
}],
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
const expired = isReductionCardExpired(profile);
|
|
172
|
-
let text = formatProfileSummary(profile);
|
|
173
|
-
if (expired) {
|
|
174
|
-
text += '\n\n**Action needed:** Reduction card was confirmed over 1 year ago. Ask the user if they still have it.';
|
|
175
|
-
}
|
|
176
|
-
return {
|
|
177
|
-
contents: [{
|
|
178
|
-
uri: 'sbb://profile',
|
|
179
|
-
mimeType: 'text/plain',
|
|
180
|
-
text,
|
|
181
|
-
}],
|
|
182
|
-
};
|
|
183
|
-
});
|
|
184
|
-
// ─── Tool: save_profile ──────────────────────────────────────────────
|
|
185
|
-
server.registerTool('save_profile', {
|
|
186
|
-
title: 'Save Travel Profile',
|
|
187
|
-
description: 'Save the user\'s travel profile locally for future sessions. Call this after asking the user for their details (name, date of birth, reduction card). Data is stored at ~/.sbb-mcp/profile.json.',
|
|
188
|
-
inputSchema: {
|
|
189
|
-
first_name: z.string().optional().describe('First name (for ticket booking)'),
|
|
190
|
-
last_name: z.string().optional().describe('Last name (for ticket booking)'),
|
|
191
|
-
date_of_birth: z.string().optional().describe('Date of birth YYYY-MM-DD (for age-based pricing)'),
|
|
192
|
-
reduction_card: z.enum(['HALF_FARE', 'GA', 'NONE']).optional().describe('Swiss reduction card: HALF_FARE (Halbtax), GA (General Abonnement), or NONE'),
|
|
193
|
-
reduction_card_valid_until: z.string().optional().describe('Reduction card expiry date YYYY-MM-DD (ask the user when their Halbtax/GA expires)'),
|
|
194
|
-
},
|
|
195
|
-
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
196
|
-
}, handleSaveProfile);
|
|
197
|
-
// ─── Tool: get_profile ───────────────────────────────────────────────
|
|
198
|
-
server.registerTool('get_profile', {
|
|
199
|
-
title: 'Get Travel Profile',
|
|
200
|
-
description: 'Read the user\'s saved travel profile. Check this before showing prices to use correct reduction card. If no profile exists, ask the user for their details.',
|
|
201
|
-
inputSchema: {},
|
|
202
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
203
|
-
}, handleGetProfile);
|
|
204
|
-
// ─── Tool: list_travelers (SwissTrip cloud only) ─────────────────────
|
|
205
|
-
server.registerTool('list_travelers', {
|
|
206
|
-
title: 'List Travelers',
|
|
207
|
-
description: 'List all travelers in the user\'s SwissTrip account (self, partner, kids). Each traveler has their own reduction card. Use their names with get_prices for family trip pricing. Requires SWISSTRIP_TOKEN.',
|
|
208
|
-
inputSchema: {},
|
|
209
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
210
|
-
}, handleListTravelers);
|
|
211
|
-
// ─── Tool 1: search_stations ──────────────────────────────────────────
|
|
212
|
-
server.registerTool('search_stations', {
|
|
213
|
-
title: 'Search Stations',
|
|
214
|
-
description: 'Search for Swiss train stations, addresses, or points of interest by name. Returns station IDs needed for other tools.',
|
|
215
|
-
inputSchema: {
|
|
216
|
-
query: z.string().describe('Station name to search for (e.g. "Zurich", "Bern", "Interlaken")'),
|
|
217
|
-
limit: z.number().min(1).max(20).default(10).describe('Maximum number of results'),
|
|
218
|
-
},
|
|
219
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
220
|
-
_meta: widgetToolMeta(WIDGETS.STATIONS_LIST, 'Searching stations…', 'Stations ready'),
|
|
221
|
-
}, async ({ query, limit }) => {
|
|
222
|
-
try {
|
|
223
|
-
const stations = useMock
|
|
224
|
-
? await mockSearchPlaces({ name: query })
|
|
225
|
-
: await searchPlaces({ name: query, type: 'STOP', numberOfResults: limit });
|
|
226
|
-
const widgetClient = isWidgetRenderingClient(server);
|
|
227
|
-
return {
|
|
228
|
-
content: [{
|
|
229
|
-
type: 'text',
|
|
230
|
-
text: widgetClient ? formatStationsTerse(stations) : formatStations(stations),
|
|
231
|
-
}],
|
|
232
|
-
structuredContent: toStationsListDTO(query, stations),
|
|
233
|
-
_meta: widgetResponseMeta(WIDGETS.STATIONS_LIST, 'Searching stations…', 'Stations ready'),
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
catch (err) {
|
|
237
|
-
return errorResult(err);
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
// ─── Tool 2: search_connections ───────────────────────────────────────
|
|
241
|
-
server.registerTool('search_connections', {
|
|
242
|
-
title: 'Search Connections',
|
|
243
|
-
description: 'Find train connections between two Swiss stations. Returns schedules with departure/arrival times, duration, transfers, and trip IDs for pricing.',
|
|
244
|
-
inputSchema: {
|
|
245
|
-
from: z.string().describe('Origin station name or ID (e.g. "Zurich HB" or "8503000")'),
|
|
246
|
-
to: z.string().describe('Destination station name or ID (e.g. "Bern" or "8507000")'),
|
|
247
|
-
date: z.string().optional().describe('Travel date in YYYY-MM-DD format (default: today)'),
|
|
248
|
-
time: z.string().optional().describe('Departure time in HH:MM format (default: now)'),
|
|
249
|
-
arrival_time: z.boolean().optional().describe('If true, the time parameter is treated as desired arrival time'),
|
|
250
|
-
},
|
|
251
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
252
|
-
_meta: widgetToolMeta(WIDGETS.CONNECTION_LIST, 'Finding trains…', 'Connections ready'),
|
|
253
|
-
}, async ({ from, to, date, time, arrival_time }) => {
|
|
254
|
-
try {
|
|
255
|
-
let fromId = from;
|
|
256
|
-
let toId = to;
|
|
257
|
-
if (!/^\d{5,8}$/.test(from)) {
|
|
258
|
-
const stations = useMock
|
|
259
|
-
? await mockSearchPlaces({ name: from })
|
|
260
|
-
: await searchPlaces({ name: from, type: 'STOP', numberOfResults: 1 });
|
|
261
|
-
if (stations.length === 0) {
|
|
262
|
-
return { content: [{ type: 'text', text: `No station found matching "${from}". Try a different name.` }] };
|
|
263
|
-
}
|
|
264
|
-
fromId = stations[0].id;
|
|
265
|
-
}
|
|
266
|
-
if (!/^\d{5,8}$/.test(to)) {
|
|
267
|
-
const stations = useMock
|
|
268
|
-
? await mockSearchPlaces({ name: to })
|
|
269
|
-
: await searchPlaces({ name: to, type: 'STOP', numberOfResults: 1 });
|
|
270
|
-
if (stations.length === 0) {
|
|
271
|
-
return { content: [{ type: 'text', text: `No station found matching "${to}". Try a different name.` }] };
|
|
272
|
-
}
|
|
273
|
-
toId = stations[0].id;
|
|
274
|
-
}
|
|
275
|
-
let departureTime;
|
|
276
|
-
let arrivalTime;
|
|
277
|
-
if (date || time) {
|
|
278
|
-
const d = date || new Date().toISOString().split('T')[0];
|
|
279
|
-
const t = time || '08:00';
|
|
280
|
-
const dt = zurichIso(d, t);
|
|
281
|
-
if (arrival_time)
|
|
282
|
-
arrivalTime = dt;
|
|
283
|
-
else
|
|
284
|
-
departureTime = dt;
|
|
285
|
-
}
|
|
286
|
-
const collection = useMock
|
|
287
|
-
? await mockSearchTrips({ origin: fromId, destination: toId, departureTime })
|
|
288
|
-
: await searchTrips({
|
|
289
|
-
origin: fromId,
|
|
290
|
-
destination: toId,
|
|
291
|
-
...(departureTime && { departureTime }),
|
|
292
|
-
...(arrivalTime && { arrivalTime }),
|
|
293
|
-
});
|
|
294
|
-
const widgetClient = isWidgetRenderingClient(server);
|
|
295
|
-
let text = widgetClient ? formatConnectionsTerse(collection) : formatConnections(collection);
|
|
296
|
-
let weatherSummary;
|
|
297
|
-
if (collection.trips.length > 0) {
|
|
298
|
-
const dest = collection.trips[0].destination;
|
|
299
|
-
if (dest.geoPosition) {
|
|
300
|
-
const travelDate = date || new Date().toISOString().split('T')[0];
|
|
301
|
-
const name = dest.name || to;
|
|
302
|
-
try {
|
|
303
|
-
const summary = await getWeatherSummary(dest.geoPosition.latitude, dest.geoPosition.longitude, travelDate);
|
|
304
|
-
if (summary) {
|
|
305
|
-
weatherSummary = summary;
|
|
306
|
-
// Widget renders weather in its own footer (ConnectionListDTO
|
|
307
|
-
// carries the summary) — for non-widget clients we append it
|
|
308
|
-
// to the markdown so the LLM / plain text client sees it too.
|
|
309
|
-
if (!widgetClient) {
|
|
310
|
-
text = text + `\n\n**${name} weather:** ${summary}`;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
catch {
|
|
315
|
-
// Non-fatal
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
return {
|
|
320
|
-
content: [{ type: 'text', text }],
|
|
321
|
-
structuredContent: toConnectionListDTO(collection, weatherSummary ? { summary: weatherSummary } : undefined),
|
|
322
|
-
_meta: widgetResponseMeta(WIDGETS.CONNECTION_LIST, 'Finding trains…', 'Connections ready'),
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
catch (err) {
|
|
326
|
-
return errorResult(err);
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
// ─── Tool 3: get_trip_details ─────────────────────────────────────────
|
|
330
|
-
server.registerTool('get_trip_details', {
|
|
331
|
-
title: 'Get Trip Details',
|
|
332
|
-
description: 'Get detailed information about a specific train connection including all intermediate stops, platforms, and occupancy. Use a trip ID from search_connections results.',
|
|
333
|
-
inputSchema: {
|
|
334
|
-
trip_id: z.string().describe('Trip ID from search_connections results'),
|
|
335
|
-
},
|
|
336
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
337
|
-
_meta: widgetToolMeta(WIDGETS.TRIP_DETAILS, 'Loading trip details…', 'Trip details ready'),
|
|
338
|
-
}, async ({ trip_id }) => {
|
|
339
|
-
try {
|
|
340
|
-
if (useMock) {
|
|
341
|
-
return { content: [{ type: 'text', text: 'Detailed trip information is available with live API access. In mock mode, use search_connections to see trip summaries.' }] };
|
|
342
|
-
}
|
|
343
|
-
const trip = await getTrip(trip_id, 'REAL_BOARDING_ALIGHTING');
|
|
344
|
-
const widgetClient = isWidgetRenderingClient(server);
|
|
345
|
-
return {
|
|
346
|
-
content: [{
|
|
347
|
-
type: 'text',
|
|
348
|
-
text: widgetClient ? formatTripDetailsTerse(trip) : formatTripDetails(trip),
|
|
349
|
-
}],
|
|
350
|
-
structuredContent: toTripDetailsDTO(trip),
|
|
351
|
-
_meta: widgetResponseMeta(WIDGETS.TRIP_DETAILS, 'Loading trip details…', 'Trip details ready'),
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
catch (err) {
|
|
355
|
-
return errorResult(err);
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
// ─── Tool 4: get_more_connections ─────────────────────────────────────
|
|
359
|
-
server.registerTool('get_more_connections', {
|
|
360
|
-
title: 'Get More Connections',
|
|
361
|
-
description: 'Load earlier or later train connections for a previous search. Use the collection ID from search_connections results.',
|
|
362
|
-
inputSchema: {
|
|
363
|
-
collection_id: z.string().describe('Collection ID from search_connections results'),
|
|
364
|
-
direction: z.enum(['next', 'previous']).describe('"next" for later trains, "previous" for earlier trains'),
|
|
365
|
-
},
|
|
366
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
367
|
-
_meta: widgetToolMeta(WIDGETS.CONNECTION_LIST, 'Loading more trains…', 'More connections ready'),
|
|
368
|
-
}, async ({ collection_id, direction }) => {
|
|
369
|
-
try {
|
|
370
|
-
const collection = useMock
|
|
371
|
-
? await mockSearchTrips({
|
|
372
|
-
origin: '8503000',
|
|
373
|
-
destination: '8507000',
|
|
374
|
-
departureTime: new Date(Date.now() + (direction === 'next' ? 3 : -3) * 60 * 60 * 1000).toISOString(),
|
|
375
|
-
})
|
|
376
|
-
: await paginateTrips(collection_id, direction);
|
|
377
|
-
const widgetClient = isWidgetRenderingClient(server);
|
|
378
|
-
return {
|
|
379
|
-
content: [{
|
|
380
|
-
type: 'text',
|
|
381
|
-
text: widgetClient ? formatConnectionsTerse(collection) : formatConnections(collection),
|
|
382
|
-
}],
|
|
383
|
-
structuredContent: toConnectionListDTO(collection),
|
|
384
|
-
_meta: widgetResponseMeta(WIDGETS.CONNECTION_LIST, 'Loading more trains…', 'More connections ready'),
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
catch (err) {
|
|
388
|
-
return errorResult(err);
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
// ─── Tool 5: get_prices ───────────────────────────────────────────────
|
|
392
|
-
server.registerTool('get_prices', {
|
|
393
|
-
title: 'Get Prices',
|
|
394
|
-
description: 'Get ticket prices for one or more train connections. Supports Half-Fare card (Halbtax) and GA travelcard discounts. When connected to SwissTrip (SWISSTRIP_TOKEN), pass traveler_names to get family pricing for multiple travelers.',
|
|
395
|
-
inputSchema: {
|
|
396
|
-
trip_ids: z.array(z.string()).min(1).max(10).describe('Trip IDs from search_connections results'),
|
|
397
|
-
traveler_type: z.enum(['ADULT', 'CHILD']).default('ADULT').describe('Traveler type (used when no traveler_names given)'),
|
|
398
|
-
reduction_card: z.enum(['HALF_FARE', 'GA', 'NONE']).default('HALF_FARE').describe('Swiss reduction card (used when no traveler_names given)'),
|
|
399
|
-
traveler_names: z.array(z.string()).optional().describe('Names of SwissTrip travelers to price for (e.g. ["Fabian", "Anna"]). Requires SWISSTRIP_TOKEN. Each traveler\'s reduction card is applied automatically.'),
|
|
400
|
-
},
|
|
401
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
402
|
-
_meta: widgetToolMeta(WIDGETS.PRICES_TABLE, 'Fetching prices…', 'Prices ready'),
|
|
403
|
-
}, async ({ trip_ids, traveler_type, reduction_card, traveler_names }) => {
|
|
404
|
-
try {
|
|
405
|
-
let travelers;
|
|
406
|
-
if (traveler_names && traveler_names.length > 0 && isSwissTripConfigured()) {
|
|
407
|
-
const allTravelers = await fetchTravelers();
|
|
408
|
-
const matched = matchTravelersByName(allTravelers, traveler_names);
|
|
409
|
-
if (matched.length === 0) {
|
|
410
|
-
return { content: [{ type: 'text', text: `No matching travelers found. Available: ${allTravelers.map(t => t.first_name).filter(Boolean).join(', ')}. Use list_travelers to see all.` }] };
|
|
411
|
-
}
|
|
412
|
-
travelers = matched.map((t, i) => toSmapiTraveler(t, i));
|
|
413
|
-
}
|
|
414
|
-
else {
|
|
415
|
-
travelers = [{ id: 'traveler-1', type: traveler_type, reductionCard: reduction_card }];
|
|
416
|
-
}
|
|
417
|
-
const prices = useMock
|
|
418
|
-
? await mockGetTripPrices(trip_ids)
|
|
419
|
-
: await getTripPrices(trip_ids, travelers);
|
|
420
|
-
const widgetClient = isWidgetRenderingClient(server);
|
|
421
|
-
return {
|
|
422
|
-
content: [{
|
|
423
|
-
type: 'text',
|
|
424
|
-
text: widgetClient ? formatPricesTerse(prices) : formatPrices(prices),
|
|
425
|
-
}],
|
|
426
|
-
structuredContent: toPricesTableDTO(prices),
|
|
427
|
-
_meta: widgetResponseMeta(WIDGETS.PRICES_TABLE, 'Fetching prices…', 'Prices ready'),
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
catch (err) {
|
|
431
|
-
return errorResult(err);
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
// ─── Tool 6: get_ticket_link ──────────────────────────────────────────
|
|
435
|
-
server.registerTool('get_ticket_link', {
|
|
436
|
-
title: 'Get Ticket Link',
|
|
437
|
-
description: 'Get a direct purchase link to buy a train ticket on SBB.ch. Only call this when the user wants to buy a specific ticket. On mobile with SBB app installed, opens directly in the app with Halbtax/GA applied automatically. Pass traveler_names for family tickets when connected to SwissTrip.',
|
|
438
|
-
inputSchema: {
|
|
439
|
-
trip_id: z.string().describe('Trip ID to purchase'),
|
|
440
|
-
from_name: z.string().describe('Origin station name (e.g. "Zürich HB")'),
|
|
441
|
-
from_id: z.string().describe('Origin station ID (e.g. "8503000")'),
|
|
442
|
-
to_name: z.string().describe('Destination station name (e.g. "Bern")'),
|
|
443
|
-
to_id: z.string().describe('Destination station ID (e.g. "8507000")'),
|
|
444
|
-
date: z.string().describe('Travel date YYYY-MM-DD'),
|
|
445
|
-
time: z.string().describe('Departure time HH:MM'),
|
|
446
|
-
traveler_type: z.enum(['ADULT', 'CHILD']).default('ADULT').describe('Traveler type (used when no traveler_names given)'),
|
|
447
|
-
reduction_card: z.enum(['HALF_FARE', 'GA', 'NONE']).default('HALF_FARE').describe('Swiss reduction card (used when no traveler_names given)'),
|
|
448
|
-
traveler_names: z.array(z.string()).optional().describe('SwissTrip traveler names for family tickets. Requires SWISSTRIP_TOKEN.'),
|
|
449
|
-
},
|
|
450
|
-
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
451
|
-
_meta: widgetToolMeta(WIDGETS.TICKET_CARD, 'Preparing ticket link…', 'Ticket link ready'),
|
|
452
|
-
}, async ({ trip_id, from_name, from_id, to_name, to_id, date, time, traveler_type, reduction_card, traveler_names }) => {
|
|
453
|
-
try {
|
|
454
|
-
// Wrap in our /r/ redirect so the click is logged for SBB Look2Book
|
|
455
|
-
// telemetry and cross-channel attribution (ChatGPT vs Claude vs bots).
|
|
456
|
-
const sbbLink = buildShortLink({
|
|
457
|
-
tripId: trip_id,
|
|
458
|
-
fromId: from_id,
|
|
459
|
-
fromName: from_name,
|
|
460
|
-
toId: to_id,
|
|
461
|
-
toName: to_name,
|
|
462
|
-
date,
|
|
463
|
-
time,
|
|
464
|
-
});
|
|
465
|
-
let travelers;
|
|
466
|
-
if (traveler_names && traveler_names.length > 0 && isSwissTripConfigured()) {
|
|
467
|
-
const allTravelers = await fetchTravelers();
|
|
468
|
-
const matched = matchTravelersByName(allTravelers, traveler_names);
|
|
469
|
-
travelers = matched.length > 0
|
|
470
|
-
? matched.map((t, i) => toSmapiTraveler(t, i))
|
|
471
|
-
: [{ id: 'traveler-1', type: traveler_type, reductionCard: reduction_card }];
|
|
472
|
-
}
|
|
473
|
-
else {
|
|
474
|
-
travelers = [{ id: 'traveler-1', type: traveler_type, reductionCard: reduction_card }];
|
|
475
|
-
}
|
|
476
|
-
let affiliateLink;
|
|
477
|
-
if (!useMock) {
|
|
478
|
-
try {
|
|
479
|
-
const result = await getTripOffers(trip_id, travelers);
|
|
480
|
-
affiliateLink = result.affiliateDeepLink;
|
|
481
|
-
}
|
|
482
|
-
catch {
|
|
483
|
-
// Non-fatal
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
const depIso = zurichIso(date, time);
|
|
487
|
-
return {
|
|
488
|
-
content: [{ type: 'text', text: formatTicketLink(trip_id, affiliateLink, sbbLink) }],
|
|
489
|
-
structuredContent: toTicketCardDTO({
|
|
490
|
-
tripId: trip_id,
|
|
491
|
-
fromName: from_name,
|
|
492
|
-
fromId: from_id,
|
|
493
|
-
toName: to_name,
|
|
494
|
-
toId: to_id,
|
|
495
|
-
departureTime: depIso,
|
|
496
|
-
arrivalTime: depIso,
|
|
497
|
-
primaryLink: sbbLink,
|
|
498
|
-
affiliateLink,
|
|
499
|
-
}),
|
|
500
|
-
_meta: widgetResponseMeta(WIDGETS.TICKET_CARD, 'Preparing ticket link…', 'Ticket link ready'),
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
catch (err) {
|
|
504
|
-
return errorResult(err);
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
return server;
|
|
508
|
-
}
|
|
509
|
-
//# sourceMappingURL=tools.js.map
|
package/dist/tools.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,OAAO,EACP,aAAa,EACb,aAAa,EACb,aAAa,EACb,gBAA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AAA;QAAC,CAAC;IAC3C,CAAC,CACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { isSmapiConfigured } from './smapi-auth.js';
|
|
2
|
-
export { searchPlaces } from './smapi-journey.js';
|
|
3
|
-
export { searchTrips } from './smapi-journey.js';
|
|
4
|
-
export { getTrip } from './smapi-journey.js';
|
|
5
|
-
export { paginateTrips } from './smapi-journey.js';
|
|
6
|
-
export { getTripPrices } from './smapi-prices.js';
|
|
7
|
-
export { getTripOffers } from './smapi-prices.js';
|
|
8
|
-
export { mockSearchPlaces, mockSearchTrips, mockGetTripPrices, mockGetTripOffers, } from './smapi-mock.js';
|
|
9
|
-
export { installSbbTransportAdapters } from './setup.js';
|
|
10
|
-
export type { SmapiPlace, SmapiTrip, SmapiTripsCollection, SmapiTripSearchParams, SmapiPlaceSearchParams, SmapiPriceResult, SmapiOfferResult, SmapiTraveler, SmapiReductionCard, SmapiTimedLeg, SmapiTransferLeg, SmapiTripLeg, } from './smapi-types.js';
|
package/dist/transport/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Backwards-compatible re-export surface for `sbb-mcp/transport` consumers
|
|
2
|
-
// (sbb-bot-core, sbb-telegram, sbb-whatsapp). Underlying implementation
|
|
3
|
-
// lives in the `sbb-transport` workspace package.
|
|
4
|
-
export { isSmapiConfigured } from './smapi-auth.js';
|
|
5
|
-
export { searchPlaces } from './smapi-journey.js';
|
|
6
|
-
export { searchTrips } from './smapi-journey.js';
|
|
7
|
-
export { getTrip } from './smapi-journey.js';
|
|
8
|
-
export { paginateTrips } from './smapi-journey.js';
|
|
9
|
-
export { getTripPrices } from './smapi-prices.js';
|
|
10
|
-
export { getTripOffers } from './smapi-prices.js';
|
|
11
|
-
export { mockSearchPlaces, mockSearchTrips, mockGetTripPrices, mockGetTripOffers, } from './smapi-mock.js';
|
|
12
|
-
export { installSbbTransportAdapters } from './setup.js';
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,wEAAwE;AACxE,kDAAkD;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function installSbbTransportAdapters(): void;
|
package/dist/transport/setup.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wire MCP-side adapters into the SMAPI transport layer.
|
|
3
|
-
* Call this once at process startup, before any SMAPI request fires.
|
|
4
|
-
*
|
|
5
|
-
* The transport source lives in the workspace sibling `sbb-transport` but
|
|
6
|
-
* is copied into `./` at build time by `scripts/sync-transport.cjs`, so
|
|
7
|
-
* sbb-mcp stays self-contained for its Dockerfile build context on Railway.
|
|
8
|
-
*
|
|
9
|
-
* Recorder strategy:
|
|
10
|
-
* - Always log to the in-memory `look2book.ts` ratio tracker (drives
|
|
11
|
-
* Railway log drains for offline auditing — this is the legacy path).
|
|
12
|
-
* - Additionally, if `SUPABASE_URL` and `SUPABASE_SERVICE_ROLE_KEY` are
|
|
13
|
-
* present, fire-and-forget an INSERT into the cross-process
|
|
14
|
-
* `smapi_call_log` table so the MCP's contribution is visible alongside
|
|
15
|
-
* the website's calls in one ratio dashboard.
|
|
16
|
-
*
|
|
17
|
-
* The Supabase write is intentionally implemented as a raw fetch (no SDK
|
|
18
|
-
* dependency) to keep the MCP's npm bundle small.
|
|
19
|
-
*/
|
|
20
|
-
import { setApiCallRecorder } from './smapi-client.js';
|
|
21
|
-
import { recordApiCall } from '../look2book.js';
|
|
22
|
-
let installed = false;
|
|
23
|
-
export function installSbbTransportAdapters() {
|
|
24
|
-
if (installed)
|
|
25
|
-
return;
|
|
26
|
-
installed = true;
|
|
27
|
-
setApiCallRecorder((family, path) => {
|
|
28
|
-
// 1. In-memory ratio tracker (always on)
|
|
29
|
-
recordApiCall(family, path);
|
|
30
|
-
// 2. Cross-process Supabase log (when configured)
|
|
31
|
-
const url = process.env.SUPABASE_URL || process.env.NEXT_PUBLIC_SUPABASE_URL;
|
|
32
|
-
const key = process.env.SUPABASE_SERVICE_ROLE_KEY;
|
|
33
|
-
if (!url || !key)
|
|
34
|
-
return;
|
|
35
|
-
void supabaseInsert(url, key, family, path);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
async function supabaseInsert(url, serviceRoleKey, family, path) {
|
|
39
|
-
try {
|
|
40
|
-
const res = await fetch(`${url}/rest/v1/smapi_call_log`, {
|
|
41
|
-
method: 'POST',
|
|
42
|
-
headers: {
|
|
43
|
-
'Content-Type': 'application/json',
|
|
44
|
-
apikey: serviceRoleKey,
|
|
45
|
-
Authorization: `Bearer ${serviceRoleKey}`,
|
|
46
|
-
Prefer: 'return=minimal',
|
|
47
|
-
},
|
|
48
|
-
body: JSON.stringify({ family, path, channel: 'mcp' }),
|
|
49
|
-
});
|
|
50
|
-
if (!res.ok) {
|
|
51
|
-
const text = await res.text().catch(() => '');
|
|
52
|
-
console.error(`[sbb-mcp/setup] Supabase insert failed (${res.status}): ${text}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
catch (err) {
|
|
56
|
-
console.error('[sbb-mcp/setup] Supabase insert threw:', err);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=setup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/transport/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,IAAI,SAAS,GAAG,KAAK,CAAA;AAErB,MAAM,UAAU,2BAA2B;IACzC,IAAI,SAAS;QAAE,OAAM;IACrB,SAAS,GAAG,IAAI,CAAA;IAEhB,kBAAkB,CAAC,CAAC,MAAiB,EAAE,IAAY,EAAE,EAAE;QACrD,yCAAyC;QACzC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAE3B,kDAAkD;QAClD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAA;QAC5E,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAA;QACjD,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG;YAAE,OAAM;QAExB,KAAK,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;IAC7C,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,cAAc,CAC3B,GAAW,EACX,cAAsB,EACtB,MAAiB,EACjB,IAAY;IAEZ,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,GAAG,yBAAyB,EAAE;YACvD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,MAAM,EAAE,cAAc;gBACtB,aAAa,EAAE,UA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