imprint-mcp 0.5.0 → 0.6.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/README.md +6 -4
- package/examples/discoverandgo/README.md +1 -1
- package/examples/discoverandgo/book_discoverandgo_museum_pass/workflow.json +7 -0
- package/examples/google-flights/README.md +41 -14
- package/examples/google-flights/_shared/google_batchexecute_parser.ts +165 -0
- package/examples/google-flights/_shared/google_flights_transport.ts +70 -0
- package/examples/google-flights/_shared/google_flights_types.ts +56 -0
- package/examples/google-flights/get_flight_booking_options/backends.json +43 -0
- package/examples/google-flights/get_flight_booking_options/index.ts +129 -0
- package/examples/google-flights/get_flight_booking_options/parser.ts +209 -0
- package/examples/google-flights/get_flight_booking_options/playbook.yaml +46 -0
- package/examples/google-flights/get_flight_booking_options/request-transform.ts +210 -0
- package/examples/google-flights/get_flight_booking_options/workflow.json +85 -0
- package/examples/google-flights/get_flight_calendar_prices/backends.json +27 -0
- package/examples/google-flights/get_flight_calendar_prices/index.ts +44 -29
- package/examples/google-flights/get_flight_calendar_prices/parser.ts +76 -69
- package/examples/google-flights/get_flight_calendar_prices/playbook.yaml +67 -40
- package/examples/google-flights/get_flight_calendar_prices/workflow.json +29 -17
- package/examples/google-flights/get_flight_location_details/backends.json +27 -0
- package/examples/google-flights/{lookup_airport → get_flight_location_details}/index.ts +30 -20
- package/examples/google-flights/get_flight_location_details/parser.ts +103 -0
- package/examples/google-flights/get_flight_location_details/playbook.yaml +59 -0
- package/examples/google-flights/{lookup_airport → get_flight_location_details}/workflow.json +19 -12
- package/examples/google-flights/lookup_flight_locations/backends.json +27 -0
- package/examples/google-flights/lookup_flight_locations/index.ts +111 -0
- package/examples/google-flights/lookup_flight_locations/package.json +9 -0
- package/examples/google-flights/lookup_flight_locations/parser.ts +135 -0
- package/examples/google-flights/lookup_flight_locations/playbook.yaml +47 -0
- package/examples/google-flights/lookup_flight_locations/request-transform.ts +53 -0
- package/examples/google-flights/lookup_flight_locations/workflow.json +64 -0
- package/examples/google-flights/search_flights/backends.json +42 -0
- package/examples/google-flights/search_flights/index.ts +105 -69
- package/examples/google-flights/search_flights/parser.ts +186 -183
- package/examples/google-flights/search_flights/playbook.yaml +295 -88
- package/examples/google-flights/search_flights/request-transform.ts +247 -92
- package/examples/google-flights/search_flights/workflow.json +66 -40
- package/examples/google-flights/validate_flight_itinerary/backends.json +27 -0
- package/examples/google-flights/validate_flight_itinerary/index.ts +103 -0
- package/examples/google-flights/validate_flight_itinerary/package.json +9 -0
- package/examples/google-flights/validate_flight_itinerary/parser.ts +101 -0
- package/examples/google-flights/validate_flight_itinerary/playbook.yaml +84 -0
- package/examples/google-flights/validate_flight_itinerary/request-transform.ts +92 -0
- package/examples/google-flights/validate_flight_itinerary/workflow.json +59 -0
- package/examples/google-hotels/README.md +40 -15
- package/examples/google-hotels/get_hotel_details/backends.json +16 -0
- package/examples/google-hotels/get_hotel_details/index.ts +122 -0
- package/examples/google-hotels/get_hotel_details/parser.ts +275 -0
- package/examples/google-hotels/get_hotel_details/playbook.yaml +40 -0
- package/examples/google-hotels/get_hotel_details/request-transform.ts +67 -0
- package/examples/google-hotels/get_hotel_details/workflow.json +67 -0
- package/examples/google-hotels/get_hotel_photos/backends.json +16 -0
- package/examples/google-hotels/get_hotel_photos/index.ts +90 -0
- package/examples/google-hotels/get_hotel_photos/parser.ts +75 -0
- package/examples/google-hotels/get_hotel_photos/playbook.yaml +23 -0
- package/examples/google-hotels/get_hotel_photos/request-transform.ts +27 -0
- package/examples/google-hotels/get_hotel_photos/workflow.json +44 -0
- package/examples/google-hotels/get_hotel_reviews/backends.json +16 -0
- package/examples/google-hotels/get_hotel_reviews/index.ts +14 -17
- package/examples/google-hotels/get_hotel_reviews/parser.ts +177 -105
- package/examples/google-hotels/get_hotel_reviews/playbook.yaml +9 -54
- package/examples/google-hotels/get_hotel_reviews/workflow.json +10 -13
- package/examples/google-hotels/get_travel_area_boundaries/backends.json +16 -0
- package/examples/google-hotels/get_travel_area_boundaries/index.ts +104 -0
- package/examples/google-hotels/get_travel_area_boundaries/package.json +9 -0
- package/examples/google-hotels/get_travel_area_boundaries/parser.ts +127 -0
- package/examples/google-hotels/get_travel_area_boundaries/playbook.yaml +38 -0
- package/examples/google-hotels/get_travel_area_boundaries/request-transform.ts +52 -0
- package/examples/google-hotels/get_travel_area_boundaries/workflow.json +54 -0
- package/examples/google-hotels/list_hotel_booking_options/backends.json +16 -0
- package/examples/google-hotels/list_hotel_booking_options/index.ts +123 -0
- package/examples/google-hotels/list_hotel_booking_options/package.json +9 -0
- package/examples/google-hotels/list_hotel_booking_options/parser.ts +308 -0
- package/examples/google-hotels/list_hotel_booking_options/playbook.yaml +95 -0
- package/examples/google-hotels/list_hotel_booking_options/request-transform.ts +77 -0
- package/examples/google-hotels/list_hotel_booking_options/workflow.json +67 -0
- package/examples/google-hotels/search_hotel_web_links/backends.json +16 -0
- package/examples/google-hotels/search_hotel_web_links/index.ts +90 -0
- package/examples/google-hotels/search_hotel_web_links/package.json +9 -0
- package/examples/google-hotels/search_hotel_web_links/parser.ts +96 -0
- package/examples/google-hotels/search_hotel_web_links/playbook.yaml +53 -0
- package/examples/google-hotels/search_hotel_web_links/request-transform.ts +17 -0
- package/examples/google-hotels/search_hotel_web_links/workflow.json +43 -0
- package/examples/google-hotels/search_hotels/backends.json +16 -0
- package/examples/google-hotels/search_hotels/index.ts +32 -102
- package/examples/google-hotels/search_hotels/parser.ts +237 -216
- package/examples/google-hotels/search_hotels/playbook.yaml +177 -42
- package/examples/google-hotels/search_hotels/request-transform.ts +101 -170
- package/examples/google-hotels/search_hotels/workflow.json +24 -73
- package/examples/google-hotels/suggest_hotel_destinations/backends.json +16 -0
- package/examples/google-hotels/{autocomplete_hotel_location → suggest_hotel_destinations}/index.ts +30 -19
- package/examples/google-hotels/suggest_hotel_destinations/package.json +9 -0
- package/examples/google-hotels/suggest_hotel_destinations/parser.ts +138 -0
- package/examples/google-hotels/suggest_hotel_destinations/playbook.yaml +47 -0
- package/examples/google-hotels/suggest_hotel_destinations/request-transform.ts +33 -0
- package/examples/google-hotels/suggest_hotel_destinations/workflow.json +44 -0
- package/examples/southwest/README.md +31 -70
- package/examples/southwest/get_account_details/backends.json +22 -0
- package/examples/southwest/get_account_details/credentials.manifest.json +17 -0
- package/examples/southwest/get_account_details/index.ts +138 -0
- package/examples/{google-hotels/_shared → southwest/get_account_details}/package.json +2 -2
- package/examples/southwest/get_account_details/parser.ts +136 -0
- package/examples/southwest/get_account_details/playbook.yaml +19 -0
- package/examples/southwest/get_account_details/workflow.json +93 -0
- package/examples/southwest/get_flight_status/backends.json +21 -0
- package/examples/southwest/get_flight_status/index.ts +130 -0
- package/examples/southwest/get_flight_status/package.json +9 -0
- package/examples/southwest/get_flight_status/parser.ts +138 -0
- package/examples/southwest/get_flight_status/playbook.yaml +58 -0
- package/examples/southwest/get_flight_status/workflow.json +77 -0
- package/examples/southwest/get_low_fare_calendar/backends.json +21 -0
- package/examples/southwest/get_low_fare_calendar/index.ts +134 -0
- package/examples/southwest/get_low_fare_calendar/package.json +9 -0
- package/examples/southwest/get_low_fare_calendar/parser.ts +107 -0
- package/examples/southwest/get_low_fare_calendar/playbook.yaml +41 -0
- package/examples/southwest/get_low_fare_calendar/workflow.json +81 -0
- package/examples/southwest/list_upcoming_trips/backends.json +22 -0
- package/examples/southwest/list_upcoming_trips/credentials.manifest.json +17 -0
- package/examples/southwest/list_upcoming_trips/index.ts +123 -0
- package/examples/southwest/list_upcoming_trips/package.json +9 -0
- package/examples/southwest/list_upcoming_trips/parser.ts +160 -0
- package/examples/southwest/list_upcoming_trips/playbook.yaml +24 -0
- package/examples/southwest/list_upcoming_trips/workflow.json +78 -0
- package/examples/southwest/search_flights/backends.json +21 -0
- package/examples/southwest/search_flights/index.ts +150 -0
- package/examples/southwest/search_flights/package.json +9 -0
- package/examples/southwest/search_flights/parser.ts +214 -0
- package/examples/southwest/search_flights/playbook.yaml +52 -0
- package/examples/southwest/search_flights/workflow.json +88 -0
- package/package.json +1 -1
- package/prompts/audit-agent.md +2 -1
- package/prompts/build-planning.md +22 -1
- package/prompts/compile-agent.md +66 -53
- package/prompts/prereq-builder.md +3 -1
- package/prompts/tool-planning.md +2 -0
- package/src/cli.ts +8 -3
- package/src/imprint/audit.ts +337 -44
- package/src/imprint/backend-cache.ts +114 -0
- package/src/imprint/backend-ladder.ts +74 -24
- package/src/imprint/bot-defense.ts +12 -0
- package/src/imprint/build-plan.ts +346 -53
- package/src/imprint/cdp-browser-fetch.ts +96 -43
- package/src/imprint/cdp-jar-cache.ts +6 -5
- package/src/imprint/chromium.ts +34 -0
- package/src/imprint/codex-cli-compile.ts +13 -2
- package/src/imprint/compile-agent.ts +3 -1
- package/src/imprint/compile-tools.ts +715 -138
- package/src/imprint/compile.ts +41 -9
- package/src/imprint/concurrency.ts +26 -3
- package/src/imprint/cron.ts +0 -3
- package/src/imprint/endpoint-key.ts +23 -0
- package/src/imprint/llm-url.ts +69 -0
- package/src/imprint/llm.ts +366 -47
- package/src/imprint/login.ts +83 -75
- package/src/imprint/mcp-compile-server.ts +4 -1
- package/src/imprint/mcp-server.ts +51 -16
- package/src/imprint/param-grounding.ts +61 -52
- package/src/imprint/probe-backends.ts +21 -115
- package/src/imprint/redact.ts +17 -15
- package/src/imprint/request-capture.ts +94 -0
- package/src/imprint/runtime.ts +1 -78
- package/src/imprint/session-diff.ts +14 -1
- package/src/imprint/stealth-fetch.ts +30 -20
- package/src/imprint/stealth-token-cache.ts +2 -2
- package/src/imprint/teach-plan.ts +2 -0
- package/src/imprint/teach-state.ts +14 -9
- package/src/imprint/teach.ts +41 -7
- package/src/imprint/telemetry.ts +3 -0
- package/src/imprint/tool-candidates.ts +8 -7
- package/src/imprint/tool-plan.ts +29 -3
- package/src/imprint/tracing.ts +18 -2
- package/examples/google-flights/_shared/batchexecute.ts +0 -63
- package/examples/google-flights/_shared/flights_request.ts +0 -97
- package/examples/google-flights/get_flight_booking_details/index.ts +0 -159
- package/examples/google-flights/get_flight_booking_details/parser.ts +0 -182
- package/examples/google-flights/get_flight_booking_details/playbook.yaml +0 -138
- package/examples/google-flights/get_flight_booking_details/request-transform.ts +0 -86
- package/examples/google-flights/get_flight_booking_details/workflow.json +0 -98
- package/examples/google-flights/get_flight_calendar_prices/request-transform.ts +0 -31
- package/examples/google-flights/lookup_airport/parser.ts +0 -66
- package/examples/google-flights/lookup_airport/playbook.yaml +0 -47
- package/examples/google-flights/lookup_airport/request-transform.ts +0 -20
- package/examples/google-hotels/_shared/batchexecute.ts +0 -73
- package/examples/google-hotels/_shared/freq.ts +0 -158
- package/examples/google-hotels/autocomplete_hotel_location/parser.ts +0 -71
- package/examples/google-hotels/autocomplete_hotel_location/playbook.yaml +0 -36
- package/examples/google-hotels/autocomplete_hotel_location/request-transform.ts +0 -37
- package/examples/google-hotels/autocomplete_hotel_location/workflow.json +0 -36
- package/examples/google-hotels/get_hotel_booking_options/index.ts +0 -143
- package/examples/google-hotels/get_hotel_booking_options/parser.ts +0 -271
- package/examples/google-hotels/get_hotel_booking_options/playbook.yaml +0 -154
- package/examples/google-hotels/get_hotel_booking_options/request-transform.ts +0 -154
- package/examples/google-hotels/get_hotel_booking_options/workflow.json +0 -84
- package/examples/google-hotels/get_hotel_reviews/request-transform.ts +0 -42
- package/examples/southwest/search_southwest_flights/backends.json +0 -23
- package/examples/southwest/search_southwest_flights/cron.json +0 -19
- package/examples/southwest/search_southwest_flights/index.ts +0 -127
- package/examples/southwest/search_southwest_flights/playbook.yaml +0 -46
- package/examples/southwest/search_southwest_flights/workflow.json +0 -71
- /package/examples/google-flights/{get_flight_booking_details → get_flight_booking_options}/package.json +0 -0
- /package/examples/google-flights/{lookup_airport → get_flight_location_details}/package.json +0 -0
- /package/examples/google-hotels/{autocomplete_hotel_location → get_hotel_details}/package.json +0 -0
- /package/examples/google-hotels/{get_hotel_booking_options → get_hotel_photos}/package.json +0 -0
|
@@ -1,113 +1,268 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import { transform as transportTransform } from '../_shared/google_flights_transport.ts';
|
|
2
|
+
|
|
3
|
+
type Params = Record<string, string | number | boolean>;
|
|
4
|
+
|
|
5
|
+
type MultiCityLeg = { origin: string; destination: string; date: string };
|
|
6
|
+
type SegmentTuple = [string, string, string, null, string, string];
|
|
7
|
+
|
|
8
|
+
function asString(params: Params | undefined, key: string, fallback = ''): string {
|
|
9
|
+
const value = params?.[key];
|
|
10
|
+
return value === undefined || value === null ? fallback : String(value);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function asNumber(params: Params | undefined, key: string, fallback: number): number {
|
|
14
|
+
const value = params?.[key];
|
|
15
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
16
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
17
|
+
const parsed = Number(value);
|
|
18
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
19
|
+
}
|
|
20
|
+
return fallback;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function location(value: string): [string, number] {
|
|
24
|
+
const trimmed = value.trim();
|
|
25
|
+
if (trimmed.startsWith('/m/')) return [trimmed, 5];
|
|
26
|
+
return [trimmed.toUpperCase(), 0];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function locGroup(value: string): [[[string, number]]] {
|
|
30
|
+
return [[location(value)]];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function tripTypeCode(value: string): number {
|
|
34
|
+
switch (value.trim().toLowerCase()) {
|
|
35
|
+
case 'one_way':
|
|
36
|
+
case 'one-way':
|
|
37
|
+
case 'one way':
|
|
38
|
+
case '2':
|
|
39
|
+
return 2;
|
|
40
|
+
case 'multi_city':
|
|
41
|
+
case 'multi-city':
|
|
42
|
+
case 'multi city':
|
|
43
|
+
case '3':
|
|
44
|
+
return 3;
|
|
45
|
+
case 'round_trip':
|
|
46
|
+
case 'round-trip':
|
|
47
|
+
case 'round trip':
|
|
48
|
+
case '1':
|
|
49
|
+
default:
|
|
50
|
+
return 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function stopCode(value: string): number {
|
|
55
|
+
switch (value.trim().toLowerCase()) {
|
|
56
|
+
case 'nonstop_only':
|
|
57
|
+
case 'nonstop':
|
|
58
|
+
case 'non_stop':
|
|
25
59
|
return 1;
|
|
26
|
-
case
|
|
60
|
+
case 'one_stop_or_fewer':
|
|
61
|
+
case 'one stop or fewer':
|
|
27
62
|
return 2;
|
|
28
|
-
case
|
|
63
|
+
case 'two_stops_or_fewer':
|
|
64
|
+
case 'two stops or fewer':
|
|
29
65
|
return 3;
|
|
66
|
+
case 'any':
|
|
30
67
|
default:
|
|
31
|
-
return 0;
|
|
68
|
+
return 0;
|
|
32
69
|
}
|
|
33
70
|
}
|
|
34
71
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
72
|
+
function parseTimeRange(value: string): [number, number] | null {
|
|
73
|
+
const match = value.trim().match(/^(\d{1,2})(?::\d{2})?-(\d{1,2})(?::\d{2})?$/);
|
|
74
|
+
if (!match) return null;
|
|
75
|
+
const start = Number(match[1]);
|
|
76
|
+
const end = Number(match[2]);
|
|
77
|
+
if (!Number.isFinite(start) || !Number.isFinite(end)) return null;
|
|
78
|
+
return [start, end];
|
|
41
79
|
}
|
|
42
80
|
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.split(',')
|
|
47
|
-
.map((x) => x.trim())
|
|
48
|
-
.filter(Boolean)
|
|
49
|
-
.map((p) => p.toUpperCase());
|
|
50
|
-
return includeAirlines.length ? includeAirlines : null;
|
|
81
|
+
function airlineList(value: string): string[] | null {
|
|
82
|
+
const items = value.split(',').map((item) => item.trim().toUpperCase()).filter(Boolean);
|
|
83
|
+
return items.length > 0 ? items : null;
|
|
51
84
|
}
|
|
52
85
|
|
|
53
|
-
function
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
86
|
+
function normalizeSegment(value: unknown): SegmentTuple | null {
|
|
87
|
+
if (Array.isArray(value)) {
|
|
88
|
+
const [origin, date, destination, ignored, carrier, flightNumber] = value;
|
|
89
|
+
if (typeof origin === 'string' && typeof date === 'string' && typeof destination === 'string' && typeof carrier === 'string' && String(flightNumber)) {
|
|
90
|
+
return [origin, date, destination, ignored === null ? null : null, carrier, String(flightNumber)];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (value && typeof value === 'object') {
|
|
94
|
+
const obj = value as Record<string, unknown>;
|
|
95
|
+
const origin = obj.origin;
|
|
96
|
+
const date = obj.date ?? obj.departureDate;
|
|
97
|
+
const destination = obj.destination;
|
|
98
|
+
const carrier = obj.carrier ?? obj.carrierCode;
|
|
99
|
+
const flightNumber = obj.flightNumber ?? obj.flight_number;
|
|
100
|
+
if (typeof origin === 'string' && typeof date === 'string' && typeof destination === 'string' && typeof carrier === 'string' && flightNumber != null) {
|
|
101
|
+
return [origin, date, destination, null, carrier, String(flightNumber)];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
57
105
|
}
|
|
58
106
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
107
|
+
function parseSelectedFlights(raw: unknown): SegmentTuple[] {
|
|
108
|
+
if (Array.isArray(raw)) return raw.map(normalizeSegment).filter((item): item is SegmentTuple => Boolean(item));
|
|
109
|
+
if (typeof raw !== 'string') return [];
|
|
110
|
+
const trimmed = raw.trim();
|
|
111
|
+
if (!trimmed) return [];
|
|
112
|
+
try {
|
|
113
|
+
return parseSelectedFlights(JSON.parse(trimmed));
|
|
114
|
+
} catch {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function sameCode(left: string, right: string): boolean {
|
|
120
|
+
return left.trim().toUpperCase() === right.trim().toUpperCase();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function dateDeltaDays(left: string, right: string): number | null {
|
|
124
|
+
const leftTime = Date.parse(`${left}T00:00:00Z`);
|
|
125
|
+
const rightTime = Date.parse(`${right}T00:00:00Z`);
|
|
126
|
+
if (!Number.isFinite(leftTime) || !Number.isFinite(rightTime)) return null;
|
|
127
|
+
return Math.round((rightTime - leftTime) / 86_400_000);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function groupSelectedSegments(segments: SegmentTuple[]): SegmentTuple[][] {
|
|
131
|
+
const groups: SegmentTuple[][] = [];
|
|
132
|
+
for (const segment of segments) {
|
|
133
|
+
const current = groups[groups.length - 1];
|
|
134
|
+
const previous = current?.[current.length - 1];
|
|
135
|
+
const startsReturnToGroupOrigin = current ? sameCode(segment[2], current[0]![0]) : false;
|
|
136
|
+
const dateDelta = previous ? dateDeltaDays(previous[1], segment[1]) : null;
|
|
137
|
+
const continuesConnection = previous
|
|
138
|
+
&& sameCode(segment[0], previous[2])
|
|
139
|
+
&& (dateDelta === null || (dateDelta >= 0 && dateDelta <= 1))
|
|
140
|
+
&& !startsReturnToGroupOrigin;
|
|
141
|
+
if (current && continuesConnection) {
|
|
142
|
+
current.push(segment);
|
|
143
|
+
} else {
|
|
144
|
+
groups.push([segment]);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return groups;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function leg(
|
|
151
|
+
origin: string,
|
|
152
|
+
destination: string,
|
|
153
|
+
date: string,
|
|
154
|
+
stops: number,
|
|
155
|
+
airlines: string[] | null,
|
|
156
|
+
timeRange: [number, number] | null,
|
|
157
|
+
bags: number,
|
|
158
|
+
legFlag = 3,
|
|
159
|
+
selectedSegments: SegmentTuple[] | null = null,
|
|
160
|
+
): unknown[] {
|
|
161
|
+
return [
|
|
162
|
+
locGroup(origin),
|
|
163
|
+
locGroup(destination),
|
|
164
|
+
timeRange,
|
|
165
|
+
stops,
|
|
166
|
+
airlines,
|
|
167
|
+
null,
|
|
168
|
+
date,
|
|
169
|
+
bags > 0 ? [bags * 90] : null,
|
|
170
|
+
selectedSegments,
|
|
171
|
+
null,
|
|
172
|
+
null,
|
|
173
|
+
null,
|
|
174
|
+
null,
|
|
175
|
+
null,
|
|
176
|
+
stops || airlines || timeRange || bags > 0 ? 1 : legFlag,
|
|
87
177
|
];
|
|
178
|
+
}
|
|
88
179
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
180
|
+
function parseMultiCityLegs(value: string): MultiCityLeg[] {
|
|
181
|
+
const legs: MultiCityLeg[] = [];
|
|
182
|
+
for (const part of value.split(';').map((item) => item.trim()).filter(Boolean)) {
|
|
183
|
+
const [origin, destination, date] = part.split(',').map((item) => item.trim());
|
|
184
|
+
if (origin && destination && date) legs.push({ origin, destination, date });
|
|
185
|
+
}
|
|
186
|
+
return legs;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function buildInner(params?: Params): unknown[] {
|
|
190
|
+
const itinerary = asString(params, 'itinerary', '');
|
|
191
|
+
let tripCode = itinerary.trim() ? 3 : tripTypeCode(asString(params, 'trip_type', 'round_trip'));
|
|
192
|
+
if (tripCode === 1 && !asString(params, 'return_date', '').trim()) tripCode = 2;
|
|
193
|
+
const adults = Math.max(1, asNumber(params, 'adults', 1));
|
|
194
|
+
const bags = Math.max(0, asNumber(params, 'bags', 0));
|
|
195
|
+
const stops = stopCode(asString(params, 'stops', 'any'));
|
|
196
|
+
const airlines = airlineList(asString(params, 'airlines', ''));
|
|
197
|
+
const maxPrice = asNumber(params, 'max_price', 0);
|
|
198
|
+
const maxDuration = asNumber(params, 'max_duration_minutes', 0);
|
|
199
|
+
const outboundTimeRange = parseTimeRange(asString(params, 'outbound_time_range', ''));
|
|
200
|
+
const returnTimeRange = parseTimeRange(asString(params, 'return_time_range', ''));
|
|
201
|
+
const selectedFlightGroups = groupSelectedSegments(parseSelectedFlights(params?.selected_flights));
|
|
202
|
+
const selectionToken = asString(params, 'selection_token', '');
|
|
203
|
+
|
|
204
|
+
let legs: unknown[];
|
|
205
|
+
if (tripCode === 3) {
|
|
206
|
+
const parsedLegs = parseMultiCityLegs(itinerary);
|
|
207
|
+
const sourceLegs = parsedLegs.length > 0
|
|
208
|
+
? parsedLegs
|
|
209
|
+
: [{ origin: asString(params, 'origin', 'SJC'), destination: asString(params, 'destination', 'SAN'), date: asString(params, 'departure_date', '2026-07-12') }];
|
|
210
|
+
legs = sourceLegs.map((item, index) => {
|
|
211
|
+
const selectedSegments = selectedFlightGroups[index];
|
|
212
|
+
return leg(item.origin, item.destination, item.date, stops, airlines, outboundTimeRange, bags, 1, selectedSegments ?? null);
|
|
99
213
|
});
|
|
214
|
+
} else {
|
|
215
|
+
const origin = asString(params, 'origin', 'SJC');
|
|
216
|
+
const destination = asString(params, 'destination', 'SAN');
|
|
217
|
+
const departureDate = asString(params, 'departure_date', '2026-07-12');
|
|
218
|
+
legs = [leg(origin, destination, departureDate, stops, airlines, outboundTimeRange, bags, 3)];
|
|
219
|
+
if (tripCode === 1) {
|
|
220
|
+
const returnDate = asString(params, 'return_date', '2026-07-16');
|
|
221
|
+
legs.push(leg(destination, origin, returnDate, stops, airlines, returnTimeRange, bags, 1));
|
|
222
|
+
}
|
|
100
223
|
}
|
|
101
224
|
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
225
|
+
const filters = [
|
|
226
|
+
null,
|
|
227
|
+
null,
|
|
228
|
+
tripCode,
|
|
229
|
+
null,
|
|
230
|
+
[],
|
|
231
|
+
adults,
|
|
232
|
+
[adults, 0, 0, 0],
|
|
233
|
+
maxPrice > 0 ? [null, maxPrice] : null,
|
|
234
|
+
null,
|
|
235
|
+
null,
|
|
236
|
+
maxDuration > 0 ? [1, 1] : null,
|
|
237
|
+
null,
|
|
238
|
+
null,
|
|
105
239
|
legs,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
240
|
+
null,
|
|
241
|
+
null,
|
|
242
|
+
null,
|
|
243
|
+
1,
|
|
244
|
+
];
|
|
245
|
+
|
|
246
|
+
if (selectionToken && selectedFlightGroups.length > 0) return [[null, selectionToken], filters, 0, 0, 0, 1];
|
|
247
|
+
return [[], filters, 0, 0, 0, 1];
|
|
248
|
+
}
|
|
111
249
|
|
|
112
|
-
|
|
250
|
+
export function transform(
|
|
251
|
+
method: string,
|
|
252
|
+
url: string,
|
|
253
|
+
responses: unknown[],
|
|
254
|
+
params?: Params,
|
|
255
|
+
): { url: string; body: string; headers: Record<string, string> } {
|
|
256
|
+
return transportTransform(method, url, responses, {
|
|
257
|
+
fReq: [null, JSON.stringify(buildInner(params))],
|
|
258
|
+
sourcePath: '/travel/flights',
|
|
259
|
+
referer: 'https://www.google.com/travel/flights/search?tfs=CBwQAhoeEgoyMDI2LTA2LTA4agcIARIDU0pDcgcIARIDU0FOGh4SCjIwMjYtMDYtMTFqBwgBEgNTQU5yBwgBEgNTSkNAAUgBcAGCAQsI____________AZgBAQ',
|
|
260
|
+
headers: {
|
|
261
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
|
|
262
|
+
'X-Same-Domain': '1',
|
|
263
|
+
'Accept-Language': 'en-US,en;q=0.9',
|
|
264
|
+
'sec-ch-ua-full-version': '"148.0.7778.96"',
|
|
265
|
+
'x-goog-ext-259736195-jspb': '["en-US","US","USD",2,null,[420],null,null,7,[]]',
|
|
266
|
+
},
|
|
267
|
+
}) as { url: string; body: string; headers: Record<string, string> };
|
|
113
268
|
}
|
|
@@ -1,114 +1,138 @@
|
|
|
1
1
|
{
|
|
2
2
|
"toolName": "search_flights",
|
|
3
|
-
"site": "google-flights",
|
|
4
3
|
"intent": {
|
|
5
|
-
"description": "Search Google Flights for
|
|
6
|
-
"userSaid": "searched for a round trip flight; searched for a one way flight; played with the stops and the airlines filters; added bags; played with the price and time filters; played with the duration filter
|
|
4
|
+
"description": "Search Google Flights for one-way, round-trip, or multi-city flight options with filters.",
|
|
5
|
+
"userSaid": "searched for a round trip flight; searched for a one way flight; played with the stops and the airlines filters; added bags; played with the price and time filters; played with the duration filter"
|
|
7
6
|
},
|
|
7
|
+
"site": "google-flights",
|
|
8
8
|
"parameters": [
|
|
9
|
+
{
|
|
10
|
+
"name": "trip_type",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Ticket type such as round_trip, one_way, or multi_city.",
|
|
13
|
+
"default": "round_trip",
|
|
14
|
+
"verified": false,
|
|
15
|
+
"verifyNote": "annotated"
|
|
16
|
+
},
|
|
9
17
|
{
|
|
10
18
|
"name": "origin",
|
|
11
19
|
"type": "string",
|
|
12
|
-
"description": "Origin airport
|
|
20
|
+
"description": "Origin airport code, city code, or place identifier for one-way and round-trip searches.",
|
|
21
|
+
"default": "SJC",
|
|
13
22
|
"verified": false,
|
|
14
23
|
"verifyNote": "annotated"
|
|
15
24
|
},
|
|
16
25
|
{
|
|
17
26
|
"name": "destination",
|
|
18
27
|
"type": "string",
|
|
19
|
-
"description": "Destination airport
|
|
28
|
+
"description": "Destination airport code, city code, or place identifier for one-way and round-trip searches.",
|
|
29
|
+
"default": "SAN",
|
|
20
30
|
"verified": false,
|
|
21
31
|
"verifyNote": "annotated"
|
|
22
32
|
},
|
|
23
33
|
{
|
|
24
34
|
"name": "departure_date",
|
|
25
35
|
"type": "string",
|
|
26
|
-
"description": "
|
|
36
|
+
"description": "Departure date in YYYY-MM-DD format.",
|
|
37
|
+
"default": "2026-07-12",
|
|
27
38
|
"verified": false,
|
|
28
39
|
"verifyNote": "annotated"
|
|
29
40
|
},
|
|
30
41
|
{
|
|
31
42
|
"name": "return_date",
|
|
32
43
|
"type": "string",
|
|
33
|
-
"description": "Return date in YYYY-MM-DD
|
|
34
|
-
"default": "",
|
|
44
|
+
"description": "Return date in YYYY-MM-DD format for round-trip searches.",
|
|
45
|
+
"default": "2026-07-16",
|
|
35
46
|
"verified": false,
|
|
36
47
|
"verifyNote": "annotated"
|
|
37
48
|
},
|
|
38
49
|
{
|
|
39
|
-
"name": "
|
|
50
|
+
"name": "itinerary",
|
|
40
51
|
"type": "string",
|
|
41
|
-
"description": "
|
|
42
|
-
"default": "
|
|
52
|
+
"description": "Multi-city itinerary as semicolon-separated origin,destination,date legs, such as SFO,LAX,2026-09-01;LAX,JFK,2026-09-04. Supplying this value selects multi-city search semantics.",
|
|
53
|
+
"default": "",
|
|
43
54
|
"verified": false,
|
|
44
55
|
"verifyNote": "annotated"
|
|
45
56
|
},
|
|
46
57
|
{
|
|
47
|
-
"name": "
|
|
48
|
-
"type": "
|
|
49
|
-
"description": "
|
|
50
|
-
"default":
|
|
51
|
-
"verified":
|
|
52
|
-
"verifyNote": "annotated"
|
|
58
|
+
"name": "selection_token",
|
|
59
|
+
"type": "string",
|
|
60
|
+
"description": "Selection token from a prior search_flights result. For staged round-trip or multi-city selection, pass this with selected_flights to fetch the next leg options.",
|
|
61
|
+
"default": "",
|
|
62
|
+
"verified": true
|
|
53
63
|
},
|
|
54
64
|
{
|
|
55
|
-
"name": "
|
|
65
|
+
"name": "selected_flights",
|
|
56
66
|
"type": "string",
|
|
57
|
-
"description": "
|
|
67
|
+
"description": "JSON array of already selected leg tuples from a prior search_flights result. For staged round-trip or multi-city selection, pass this with selection_token to fetch the next leg options and emit a complete selected_flights array.",
|
|
58
68
|
"default": "",
|
|
59
|
-
"verified":
|
|
60
|
-
"verifyNote": "annotated"
|
|
69
|
+
"verified": true
|
|
61
70
|
},
|
|
62
71
|
{
|
|
63
|
-
"name": "
|
|
72
|
+
"name": "adults",
|
|
64
73
|
"type": "number",
|
|
65
|
-
"description": "
|
|
66
|
-
"default":
|
|
74
|
+
"description": "Number of adult passengers.",
|
|
75
|
+
"default": 1,
|
|
67
76
|
"verified": false,
|
|
68
77
|
"verifyNote": "annotated"
|
|
69
78
|
},
|
|
70
79
|
{
|
|
71
|
-
"name": "
|
|
80
|
+
"name": "stops",
|
|
72
81
|
"type": "string",
|
|
73
|
-
"description": "
|
|
74
|
-
"default": "",
|
|
82
|
+
"description": "Stops filter for routes with both nonstop and connecting options, such as any, nonstop_only, one_stop_or_fewer, or two_stops_or_fewer.",
|
|
83
|
+
"default": "any",
|
|
75
84
|
"verified": false,
|
|
76
85
|
"verifyNote": "annotated"
|
|
77
86
|
},
|
|
78
87
|
{
|
|
79
|
-
"name": "
|
|
88
|
+
"name": "airlines",
|
|
80
89
|
"type": "string",
|
|
81
|
-
"description": "
|
|
90
|
+
"description": "Comma-separated airline or alliance codes to include, such as AS, AA, WN, ONEWORLD, SKYTEAM, or STAR_ALLIANCE.",
|
|
82
91
|
"default": "",
|
|
83
92
|
"verified": false,
|
|
84
93
|
"verifyNote": "annotated"
|
|
85
94
|
},
|
|
86
95
|
{
|
|
87
|
-
"name": "
|
|
96
|
+
"name": "bags",
|
|
97
|
+
"type": "number",
|
|
98
|
+
"description": "Number of bags to include in fare filtering.",
|
|
99
|
+
"default": 0,
|
|
100
|
+
"verified": false,
|
|
101
|
+
"verifyNote": "annotated"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "max_price",
|
|
88
105
|
"type": "number",
|
|
89
|
-
"description": "Maximum
|
|
106
|
+
"description": "Maximum fare price in USD.",
|
|
90
107
|
"default": 0,
|
|
91
108
|
"verified": false,
|
|
92
109
|
"verifyNote": "annotated"
|
|
93
110
|
},
|
|
94
111
|
{
|
|
95
|
-
"name": "
|
|
112
|
+
"name": "outbound_time_range",
|
|
113
|
+
"type": "string",
|
|
114
|
+
"description": "Outbound departure or arrival time constraints encoded as start and end hours, such as 2-21.",
|
|
115
|
+
"default": "",
|
|
116
|
+
"verified": false,
|
|
117
|
+
"verifyNote": "annotated"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"name": "max_duration_minutes",
|
|
96
121
|
"type": "number",
|
|
97
|
-
"description": "
|
|
122
|
+
"description": "Maximum flight duration in minutes.",
|
|
98
123
|
"default": 0,
|
|
99
124
|
"verified": false,
|
|
100
125
|
"verifyNote": "annotated"
|
|
101
126
|
}
|
|
102
127
|
],
|
|
103
128
|
"bootstrap": {
|
|
104
|
-
"url": "https://www.google.com/travel/flights",
|
|
129
|
+
"url": "https://www.google.com/travel/flights/search?tfs=CBwQAhoeEgoyMDI2LTA2LTA4agcIARIDU0pDcgcIARIDU0FOGh4SCjIwMjYtMDYtMTFqBwgBEgNTQU5yBwgBEgNTSkNAAUgBcAGCAQsI____________AZgBAQ",
|
|
105
130
|
"waitUntil": "domcontentloaded",
|
|
106
|
-
"timeoutMs": 30000,
|
|
107
131
|
"captures": [
|
|
108
132
|
{
|
|
109
133
|
"source": "html_regex",
|
|
110
134
|
"name": "f_sid",
|
|
111
|
-
"pattern": "\"FdrFJe\":\"(
|
|
135
|
+
"pattern": "\"FdrFJe\":\"(-?\\d+)\"",
|
|
112
136
|
"group": 1,
|
|
113
137
|
"required": true,
|
|
114
138
|
"capability": "browser_bootstrap"
|
|
@@ -126,18 +150,20 @@
|
|
|
126
150
|
"requests": [
|
|
127
151
|
{
|
|
128
152
|
"method": "POST",
|
|
129
|
-
"url": "https://www.google.com/_/FlightsFrontendUi/data/travel.frontend.flights.FlightsFrontendService/GetShoppingResults?f.sid=${state.f_sid}&bl=${state.bl}&hl=en-US&soc-app=162&soc-platform=1&soc-device=1&_reqid
|
|
153
|
+
"url": "https://www.google.com/_/FlightsFrontendUi/data/travel.frontend.flights.FlightsFrontendService/GetShoppingResults?f.sid=${state.f_sid}&bl=${state.bl}&hl=en-US&soc-app=162&soc-platform=1&soc-device=1&_reqid=${generated.nonce}&rt=c",
|
|
130
154
|
"headers": {
|
|
131
155
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
132
156
|
"X-Same-Domain": "1",
|
|
133
|
-
"Referer": "https://www.google.com/travel/flights",
|
|
157
|
+
"Referer": "https://www.google.com/travel/flights/search?tfs=CBwQAhoeEgoyMDI2LTA2LTA4agcIARIDU0pDcgcIARIDU0FOGh4SCjIwMjYtMDYtMTFqBwgBEgNTQU5yBwgBEgNTSkNAAUgBcAGCAQsI____________AZgBAQ",
|
|
158
|
+
"Accept-Language": "en-US,en;q=0.9",
|
|
159
|
+
"sec-ch-ua-full-version": "\"148.0.7778.96\"",
|
|
134
160
|
"x-goog-ext-259736195-jspb": "[\"en-US\",\"US\",\"USD\",2,null,[420],null,null,7,[]]"
|
|
135
161
|
},
|
|
136
|
-
"body": "
|
|
162
|
+
"body": "trip_type=${param.trip_type}&origin=${param.origin}&destination=${param.destination}&departure_date=${param.departure_date}&return_date=${param.return_date}&itinerary=${param.itinerary}&selection_token=${param.selection_token}&selected_flights=${param.selected_flights}&adults=${param.adults}&stops=${param.stops}&airlines=${param.airlines}&bags=${param.bags}&max_price=${param.max_price}&outbound_time_range=${param.outbound_time_range}&max_duration_minutes=${param.max_duration_minutes}",
|
|
137
163
|
"effect": "safe"
|
|
138
164
|
}
|
|
139
165
|
],
|
|
140
|
-
"requestTransformModule": "./request-transform.ts",
|
|
141
166
|
"parserModule": "./parser.ts",
|
|
167
|
+
"requestTransformModule": "./request-transform.ts",
|
|
142
168
|
"liveVerified": true
|
|
143
169
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"probedAt": "2026-07-01T01:16:12.910Z",
|
|
3
|
+
"imprintVersion": "0.5.0",
|
|
4
|
+
"schemaVersion": 2,
|
|
5
|
+
"workflowHash": "7d73e606e5380f03e1188a8d91e9c76208d7df316d59d020cf87a41c97d1064d",
|
|
6
|
+
"capabilityHash": "5fc16811cd65aff7afee349ddca05c806a65c9c2c96948192ea1bafba9284c38",
|
|
7
|
+
"preferredOrder": [
|
|
8
|
+
"cdp-replay"
|
|
9
|
+
],
|
|
10
|
+
"results": {
|
|
11
|
+
"fetch": {
|
|
12
|
+
"outcome": "failed",
|
|
13
|
+
"durationMs": 23,
|
|
14
|
+
"error": "STATE_MISSING",
|
|
15
|
+
"detail": "STATE_MISSING: Workflow placeholder ${state.bl} but state \"bl\" has not been captured yet"
|
|
16
|
+
},
|
|
17
|
+
"fetch-bootstrap": {
|
|
18
|
+
"outcome": "forbidden",
|
|
19
|
+
"durationMs": 30307,
|
|
20
|
+
"detail": "FORBIDDEN: fetch-bootstrap: cdp-minted jar did not validate; cdp-replay (in-page) required."
|
|
21
|
+
},
|
|
22
|
+
"cdp-replay": {
|
|
23
|
+
"outcome": "ok",
|
|
24
|
+
"durationMs": 525
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|