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,182 +0,0 @@
|
|
|
1
|
-
// Parser for Google Flights GetBookingResults (batchexecute RPC).
|
|
2
|
-
// Decodes the streaming envelope with the shared helper, then walks the deeply
|
|
3
|
-
// nested positional payload to extract the itinerary's per-segment detail and
|
|
4
|
-
// the list of bookable fare options (price USD + booking provider).
|
|
5
|
-
import { decodeBatchExecute } from '../_shared/batchexecute.ts';
|
|
6
|
-
|
|
7
|
-
const AIRPORT = /^[A-Z]{3}$/;
|
|
8
|
-
|
|
9
|
-
interface Segment {
|
|
10
|
-
carrier: string;
|
|
11
|
-
carrierName: string | null;
|
|
12
|
-
flightNumber: string;
|
|
13
|
-
origin: string;
|
|
14
|
-
originName: string | null;
|
|
15
|
-
destination: string;
|
|
16
|
-
destinationName: string | null;
|
|
17
|
-
departDate: string | null;
|
|
18
|
-
departTime: string | null;
|
|
19
|
-
arriveDate: string | null;
|
|
20
|
-
arriveTime: string | null;
|
|
21
|
-
durationMinutes: number | null;
|
|
22
|
-
aircraft: string | null;
|
|
23
|
-
operatingCarrier: { carrier: string; flightNumber: string | null; name: string | null } | null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface FareOption {
|
|
27
|
-
priceUSD: number;
|
|
28
|
-
provider: string;
|
|
29
|
-
bookingUrl: string | null;
|
|
30
|
-
fareClass: string | null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function fmtTime(t: unknown): string | null {
|
|
34
|
-
if (!Array.isArray(t) || t.length === 0) return null;
|
|
35
|
-
const h = typeof t[0] === 'number' ? t[0] : 0;
|
|
36
|
-
const m = typeof t[1] === 'number' ? t[1] : 0;
|
|
37
|
-
return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function fmtDate(d: unknown): string | null {
|
|
41
|
-
if (!Array.isArray(d) || d.length < 3) return null;
|
|
42
|
-
const [y, mo, day] = d as number[];
|
|
43
|
-
if (typeof y !== 'number') return null;
|
|
44
|
-
return `${y}-${String(mo).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// A segment node: airport codes at [3]/[6], aircraft string at [17],
|
|
48
|
-
// and a marketing-flight tuple [carrier, number, _, carrierName] at [22].
|
|
49
|
-
function isSegment(node: unknown): node is unknown[] {
|
|
50
|
-
if (!Array.isArray(node)) return false;
|
|
51
|
-
if (typeof node[3] !== 'string' || !AIRPORT.test(node[3] as string)) return false;
|
|
52
|
-
if (typeof node[6] !== 'string' || !AIRPORT.test(node[6] as string)) return false;
|
|
53
|
-
const fn = node[22];
|
|
54
|
-
return Array.isArray(fn) && typeof fn[0] === 'string' && fn[1] != null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// A booking-option node: provider tuple at [1][0] = [carrier, providerName,...]
|
|
58
|
-
// and price at [7] = [[null, priceUSD], "<fareToken>"].
|
|
59
|
-
function isBookingOption(node: unknown): node is unknown[] {
|
|
60
|
-
if (!Array.isArray(node)) return false;
|
|
61
|
-
const provider = node[1];
|
|
62
|
-
if (!Array.isArray(provider) || !Array.isArray(provider[0])) return false;
|
|
63
|
-
if (typeof provider[0][1] !== 'string') return false;
|
|
64
|
-
const price = node[7];
|
|
65
|
-
if (!Array.isArray(price) || !Array.isArray(price[0])) return false;
|
|
66
|
-
return typeof price[0][1] === 'number';
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function toSegment(seg: unknown[]): Segment {
|
|
70
|
-
const fn = seg[22] as unknown[];
|
|
71
|
-
let operatingCarrier: Segment['operatingCarrier'] = null;
|
|
72
|
-
const op = seg[15];
|
|
73
|
-
if (Array.isArray(op) && Array.isArray(op[0]) && typeof op[0][0] === 'string') {
|
|
74
|
-
const o = op[0] as unknown[];
|
|
75
|
-
operatingCarrier = {
|
|
76
|
-
carrier: o[0] as string,
|
|
77
|
-
flightNumber: typeof o[1] === 'string' ? (o[1] as string) : null,
|
|
78
|
-
name: typeof o[3] === 'string' ? (o[3] as string) : null,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
carrier: typeof fn[0] === 'string' ? (fn[0] as string) : '',
|
|
83
|
-
carrierName: typeof fn[3] === 'string' ? (fn[3] as string) : null,
|
|
84
|
-
flightNumber: fn[1] != null ? String(fn[1]) : '',
|
|
85
|
-
origin: seg[3] as string,
|
|
86
|
-
originName: typeof seg[4] === 'string' ? (seg[4] as string) : null,
|
|
87
|
-
destination: seg[6] as string,
|
|
88
|
-
destinationName: typeof seg[5] === 'string' ? (seg[5] as string) : null,
|
|
89
|
-
departDate: fmtDate(seg[20]),
|
|
90
|
-
departTime: fmtTime(seg[8]),
|
|
91
|
-
arriveDate: fmtDate(seg[21]),
|
|
92
|
-
arriveTime: fmtTime(seg[10]),
|
|
93
|
-
durationMinutes: typeof seg[11] === 'number' ? (seg[11] as number) : null,
|
|
94
|
-
aircraft: typeof seg[17] === 'string' ? (seg[17] as string) : null,
|
|
95
|
-
operatingCarrier,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function toFareOption(node: unknown[]): FareOption {
|
|
100
|
-
const provider = node[1] as unknown[];
|
|
101
|
-
const price = node[7] as unknown[];
|
|
102
|
-
const link = node[5];
|
|
103
|
-
let bookingUrl: string | null = null;
|
|
104
|
-
if (Array.isArray(link) && typeof link[0] === 'string') bookingUrl = link[0] as string;
|
|
105
|
-
|
|
106
|
-
let fareClass: string | null = null;
|
|
107
|
-
const fc = node[14];
|
|
108
|
-
// node[14] = [[[null, ["WN","BASIC"], 1]]]
|
|
109
|
-
const inner = Array.isArray(fc) ? (fc[0] as unknown[]) : undefined;
|
|
110
|
-
const innerInner = Array.isArray(inner) ? (inner[0] as unknown[]) : undefined;
|
|
111
|
-
if (Array.isArray(innerInner) && Array.isArray(innerInner[1])) {
|
|
112
|
-
const code = (innerInner[1] as unknown[])[1];
|
|
113
|
-
if (typeof code === 'string') fareClass = code;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
priceUSD: (price[0] as unknown[])[1] as number,
|
|
118
|
-
provider: (provider[0] as unknown[])[1] as string,
|
|
119
|
-
bookingUrl,
|
|
120
|
-
fareClass,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function walk(node: unknown, segs: unknown[][], fares: unknown[][]): void {
|
|
125
|
-
if (!Array.isArray(node)) return;
|
|
126
|
-
if (isBookingOption(node)) {
|
|
127
|
-
fares.push(node);
|
|
128
|
-
// booking options also contain a nested segment listing; keep recursing
|
|
129
|
-
// so those segments are still discovered (dedup handles overlap).
|
|
130
|
-
}
|
|
131
|
-
if (isSegment(node)) {
|
|
132
|
-
segs.push(node);
|
|
133
|
-
return; // a segment is a leaf for our purposes
|
|
134
|
-
}
|
|
135
|
-
for (const child of node) walk(child, segs, fares);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function extract(
|
|
139
|
-
rawResponse: unknown,
|
|
140
|
-
_context?: { params: Record<string, string | number | boolean>; responses: unknown[] },
|
|
141
|
-
): unknown {
|
|
142
|
-
let frames: Array<{ rpcid: string | null; payload: any }> = [];
|
|
143
|
-
if (typeof rawResponse === 'string') {
|
|
144
|
-
frames = decodeBatchExecute(rawResponse);
|
|
145
|
-
} else if (rawResponse != null) {
|
|
146
|
-
frames = [{ rpcid: null, payload: rawResponse }];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const segNodes: unknown[][] = [];
|
|
150
|
-
const fareNodes: unknown[][] = [];
|
|
151
|
-
for (const f of frames) walk(f.payload, segNodes, fareNodes);
|
|
152
|
-
|
|
153
|
-
// Dedup segments by carrier+number+departDate+departTime.
|
|
154
|
-
const segMap = new Map<string, Segment>();
|
|
155
|
-
for (const s of segNodes) {
|
|
156
|
-
const seg = toSegment(s);
|
|
157
|
-
if (!seg.carrier && !seg.flightNumber) continue;
|
|
158
|
-
const key = `${seg.carrier}${seg.flightNumber}|${seg.departDate}|${seg.departTime}|${seg.origin}`;
|
|
159
|
-
if (!segMap.has(key)) segMap.set(key, seg);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Dedup fare options by fareClass + price + provider.
|
|
163
|
-
const fareMap = new Map<string, FareOption>();
|
|
164
|
-
for (const n of fareNodes) {
|
|
165
|
-
const fare = toFareOption(n);
|
|
166
|
-
if (!fare.provider || typeof fare.priceUSD !== 'number') continue;
|
|
167
|
-
const key = `${fare.fareClass}|${fare.priceUSD}|${fare.provider}`;
|
|
168
|
-
if (!fareMap.has(key)) fareMap.set(key, fare);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const segments = [...segMap.values()];
|
|
172
|
-
const fareOptions = [...fareMap.values()];
|
|
173
|
-
const prices = fareOptions.map((f) => f.priceUSD);
|
|
174
|
-
|
|
175
|
-
return {
|
|
176
|
-
segments,
|
|
177
|
-
fareOptions,
|
|
178
|
-
segmentCount: segments.length,
|
|
179
|
-
fareOptionCount: fareOptions.length,
|
|
180
|
-
lowestPriceUSD: prices.length ? Math.min(...prices) : null,
|
|
181
|
-
};
|
|
182
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
toolName: get_flight_booking_details
|
|
2
|
-
summary: "On Google Flights, search a route/date, open a selected flight itinerary, and capture its GetBookingResults fare/booking-provider detail."
|
|
3
|
-
parameters:
|
|
4
|
-
- name: origin
|
|
5
|
-
type: string
|
|
6
|
-
description: Origin airport code, e.g. SJC
|
|
7
|
-
- name: destination
|
|
8
|
-
type: string
|
|
9
|
-
description: Destination airport code, e.g. SAN
|
|
10
|
-
- name: departure_date
|
|
11
|
-
type: string
|
|
12
|
-
description: Outbound date, YYYY-MM-DD
|
|
13
|
-
- name: return_date
|
|
14
|
-
type: string
|
|
15
|
-
description: Return date YYYY-MM-DD. Omit for one-way (the recorded primary flow is one-way).
|
|
16
|
-
- name: outbound_flight
|
|
17
|
-
type: string
|
|
18
|
-
description: Selected outbound flight as carrier+number, e.g. "WN 3489". Used to pick the flight card whose booking details are fetched.
|
|
19
|
-
- name: return_flight
|
|
20
|
-
type: string
|
|
21
|
-
description: Selected return flight as carrier+number (round-trip only); omit for one-way.
|
|
22
|
-
steps:
|
|
23
|
-
- action: navigate
|
|
24
|
-
url: https://www.google.com/travel/flights
|
|
25
|
-
wait_for: networkidle
|
|
26
|
-
|
|
27
|
-
- action: type
|
|
28
|
-
locators:
|
|
29
|
-
- by: aria_label
|
|
30
|
-
value: Where from?
|
|
31
|
-
- by: css
|
|
32
|
-
value: div.wUiEcc.SOcuWe input.II2One.j0Ppje
|
|
33
|
-
value: ${origin}
|
|
34
|
-
wait_for:
|
|
35
|
-
sleep_ms: 500
|
|
36
|
-
- action: click
|
|
37
|
-
locators:
|
|
38
|
-
- by: aria_label
|
|
39
|
-
value_pattern: ${origin}
|
|
40
|
-
- by: text
|
|
41
|
-
value_pattern: ${origin}
|
|
42
|
-
wait_for: visible
|
|
43
|
-
|
|
44
|
-
- action: type
|
|
45
|
-
locators:
|
|
46
|
-
- by: aria_label
|
|
47
|
-
value: "Where to?"
|
|
48
|
-
- by: css
|
|
49
|
-
value: div.cQnuXe.k0gFV input.II2One.j0Ppje
|
|
50
|
-
value: ${destination}
|
|
51
|
-
wait_for:
|
|
52
|
-
sleep_ms: 500
|
|
53
|
-
- action: click
|
|
54
|
-
locators:
|
|
55
|
-
- by: aria_label
|
|
56
|
-
value_pattern: ${destination}
|
|
57
|
-
- by: text
|
|
58
|
-
value_pattern: ${destination}
|
|
59
|
-
wait_for: visible
|
|
60
|
-
|
|
61
|
-
# Trip type -> One way (omit these two steps for a round trip)
|
|
62
|
-
- action: click
|
|
63
|
-
locators:
|
|
64
|
-
- by: aria_label
|
|
65
|
-
value: "Select your ticket type."
|
|
66
|
-
- by: css
|
|
67
|
-
value: div.TQYpgc.gInvKb div.VfPpkd-aPP78e
|
|
68
|
-
wait_for:
|
|
69
|
-
sleep_ms: 300
|
|
70
|
-
- action: click
|
|
71
|
-
locators:
|
|
72
|
-
- by: text
|
|
73
|
-
value: One way
|
|
74
|
-
- by: role
|
|
75
|
-
value: option
|
|
76
|
-
name: One way
|
|
77
|
-
wait_for: visible
|
|
78
|
-
|
|
79
|
-
- action: type
|
|
80
|
-
locators:
|
|
81
|
-
- by: aria_label
|
|
82
|
-
value: Departure
|
|
83
|
-
- by: css
|
|
84
|
-
value: div.GYgkab.YICvqf input.TP4Lpb.eoY5cb
|
|
85
|
-
value: ${departure_date}
|
|
86
|
-
wait_for:
|
|
87
|
-
sleep_ms: 400
|
|
88
|
-
- action: click
|
|
89
|
-
locators:
|
|
90
|
-
- by: text
|
|
91
|
-
value: Done
|
|
92
|
-
- by: aria_label
|
|
93
|
-
value: Done
|
|
94
|
-
wait_for:
|
|
95
|
-
sleep_ms: 300
|
|
96
|
-
|
|
97
|
-
- action: click
|
|
98
|
-
locators:
|
|
99
|
-
- by: text
|
|
100
|
-
value: Search
|
|
101
|
-
- by: aria_label
|
|
102
|
-
value: Search
|
|
103
|
-
wait_for:
|
|
104
|
-
xhr: /GetShoppingResults
|
|
105
|
-
|
|
106
|
-
# Open the chosen flight; this is the click that triggers GetBookingResults.
|
|
107
|
-
- action: click
|
|
108
|
-
locators:
|
|
109
|
-
- by: text
|
|
110
|
-
value_pattern: ${outbound_flight}
|
|
111
|
-
- by: css
|
|
112
|
-
value: ul.Rk10dc > li.pIav2d div.yR1fYc
|
|
113
|
-
wait_for:
|
|
114
|
-
xhr: /GetBookingResults
|
|
115
|
-
result:
|
|
116
|
-
source: xhr
|
|
117
|
-
url_pattern: /data/travel.frontend.flights.FlightsFrontendService/GetBookingResults
|
|
118
|
-
extract: "[1][5][0]"
|
|
119
|
-
return_as: booking_details
|
|
120
|
-
notes: >
|
|
121
|
-
Response is a Google batchexecute payload prefixed with )]}' and split into length-prefixed
|
|
122
|
-
chunks; the parser must strip the prefix, split on the numeric length markers, and JSON.parse
|
|
123
|
-
each "wrb.fr" envelope's double-encoded inner JSON. Flight data is positional, not keyed: in the
|
|
124
|
-
first wrb.fr chunk, [1][5][0] holds the selected itinerary slices (each slice = [carrier,[airlineName],
|
|
125
|
-
[[segment...]], origCode,[y,m,d],[h,m], destCode,...], with segment carrier+number at the
|
|
126
|
-
[\"WN\",\"3489\",null,\"Southwest\"] tuple). The bookable fare options with provider and price live in
|
|
127
|
-
the SECOND wrb.fr chunk of the same response at [1][0]: each option is
|
|
128
|
-
[0,[[provider,providerName,...]],null,[[carrier,number]],false,[bookingUrl...],...,priceCents]; price is
|
|
129
|
-
in cents (e.g. 88008 = $880.08) and provider name is option[1][0][1]. Auth is session-bound:
|
|
130
|
-
f.sid (per-page session id) plus the X-Goog-BatchExecute-Bgr header are captured fresh from page
|
|
131
|
-
bootstrap and are NOT parameterized. The per-itinerary base64 flight token required by the underlying
|
|
132
|
-
GetBookingResults RPC is produced by the prior GetShoppingResults and is not user-controllable — the
|
|
133
|
-
DOM flow handles it automatically by clicking the rendered flight card, which is why this playbook
|
|
134
|
-
clicks rather than POSTs. For a round trip, do NOT set trip type to "One way"; supply return_date so
|
|
135
|
-
the search returns round-trip results, then after the outbound-flight click pick the return flight
|
|
136
|
-
(matching return_flight) before GetBookingResults fires. Result cards show airline name + times rather
|
|
137
|
-
than the raw flight number, so the ${outbound_flight} text locator may need the carrier/time; the
|
|
138
|
-
css fallback selects the first result card.
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// Adapter around the shared FlightsFrontendService body builder for
|
|
2
|
-
// GetBookingResults. The tool exposes flat snake_case params (origin,
|
|
3
|
-
// destination, departure_date, return_date, outbound_flight, return_flight,
|
|
4
|
-
// flight_token); the shared encoder consumes a structured shape
|
|
5
|
-
// ({ tripType, legs:[{origin,dest,date,selected:[{origin,date,dest,carrier,flightNumber}]}], flight_token }).
|
|
6
|
-
// We map between them here and delegate the byte-for-byte positional encoding
|
|
7
|
-
// (legs, trip-type, the [[null,token],sp,null,selIdx] outer wrapper, token
|
|
8
|
-
// injection, encodeFreq) to the shared module — required reuse.
|
|
9
|
-
import { transform as sharedTransform } from '../_shared/flights_request.ts';
|
|
10
|
-
|
|
11
|
-
type Params = Record<string, string | number | boolean | undefined | null>;
|
|
12
|
-
|
|
13
|
-
// "WN 3489" / "WN3489" -> { carrier:"WN", flightNumber:"3489" }
|
|
14
|
-
function parseFlight(v: unknown): { carrier: string; flightNumber: string } | null {
|
|
15
|
-
if (v == null || v === '') return null;
|
|
16
|
-
const s = String(v).trim();
|
|
17
|
-
const m = /^([A-Za-z0-9]{2})\s*([0-9]{1,5})$/.exec(s) ?? /^(\S+)\s+(\S+)$/.exec(s);
|
|
18
|
-
if (!m) return null;
|
|
19
|
-
const carrier = m[1];
|
|
20
|
-
const flightNumber = m[2];
|
|
21
|
-
if (carrier == null || flightNumber == null) return null;
|
|
22
|
-
return { carrier: carrier.toUpperCase(), flightNumber };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function transform(
|
|
26
|
-
method: string,
|
|
27
|
-
url: string,
|
|
28
|
-
responses: Record<string, any>,
|
|
29
|
-
params?: Params,
|
|
30
|
-
): { url: string; body: string } {
|
|
31
|
-
const p: Params = params ?? {};
|
|
32
|
-
const origin = p.origin != null ? String(p.origin) : '';
|
|
33
|
-
const destination = p.destination != null ? String(p.destination) : '';
|
|
34
|
-
const departureDate = p.departure_date ? String(p.departure_date) : null;
|
|
35
|
-
const returnDate = p.return_date != null ? String(p.return_date).trim() : '';
|
|
36
|
-
const roundTrip = returnDate !== '';
|
|
37
|
-
const tripType = roundTrip ? 1 : 2; // 1=round trip, 2=one way
|
|
38
|
-
|
|
39
|
-
const ob = parseFlight(p.outbound_flight);
|
|
40
|
-
const legs: any[] = [
|
|
41
|
-
{
|
|
42
|
-
origin,
|
|
43
|
-
dest: destination,
|
|
44
|
-
date: departureDate,
|
|
45
|
-
selected: ob
|
|
46
|
-
? [
|
|
47
|
-
{
|
|
48
|
-
origin,
|
|
49
|
-
date: departureDate,
|
|
50
|
-
dest: destination,
|
|
51
|
-
carrier: ob.carrier,
|
|
52
|
-
flightNumber: ob.flightNumber,
|
|
53
|
-
},
|
|
54
|
-
]
|
|
55
|
-
: null,
|
|
56
|
-
},
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
if (roundTrip) {
|
|
60
|
-
const rb = parseFlight(p.return_flight);
|
|
61
|
-
legs.push({
|
|
62
|
-
origin: destination,
|
|
63
|
-
dest: origin,
|
|
64
|
-
date: returnDate,
|
|
65
|
-
selected: rb
|
|
66
|
-
? [
|
|
67
|
-
{
|
|
68
|
-
origin: destination,
|
|
69
|
-
date: returnDate,
|
|
70
|
-
dest: origin,
|
|
71
|
-
carrier: rb.carrier,
|
|
72
|
-
flightNumber: rb.flightNumber,
|
|
73
|
-
},
|
|
74
|
-
]
|
|
75
|
-
: null,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const mapped: Record<string, any> = {
|
|
80
|
-
tripType,
|
|
81
|
-
legs,
|
|
82
|
-
flight_token: p.flight_token != null ? String(p.flight_token) : null,
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
return sharedTransform(method, url, responses, mapped);
|
|
86
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"toolName": "get_flight_booking_details",
|
|
3
|
-
"site": "google-flights",
|
|
4
|
-
"intent": {
|
|
5
|
-
"description": "Get booking/fare details and bookable options for a specific selected flight itinerary on Google Flights.",
|
|
6
|
-
"userSaid": "clicked one of the one-way fares to find more details and booking details; saw the options for another flight; chose round trip fares; kept exploring round trip fare details"
|
|
7
|
-
},
|
|
8
|
-
"parameters": [
|
|
9
|
-
{
|
|
10
|
-
"name": "origin",
|
|
11
|
-
"type": "string",
|
|
12
|
-
"description": "Origin airport IATA code for the outbound leg, e.g. SJC",
|
|
13
|
-
"verified": false,
|
|
14
|
-
"verifyNote": "annotated"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"name": "destination",
|
|
18
|
-
"type": "string",
|
|
19
|
-
"description": "Destination airport IATA code for the outbound leg, e.g. SAN",
|
|
20
|
-
"verified": false,
|
|
21
|
-
"verifyNote": "annotated"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"name": "departure_date",
|
|
25
|
-
"type": "string",
|
|
26
|
-
"description": "Outbound date in YYYY-MM-DD",
|
|
27
|
-
"verified": false,
|
|
28
|
-
"verifyNote": "annotated"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"name": "return_date",
|
|
32
|
-
"type": "string",
|
|
33
|
-
"description": "Return date in YYYY-MM-DD. Empty/omit for a one-way booking.",
|
|
34
|
-
"default": "",
|
|
35
|
-
"verified": true
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"name": "outbound_flight",
|
|
39
|
-
"type": "string",
|
|
40
|
-
"description": "Selected outbound flight as 'carrier number', e.g. 'WN 3489'",
|
|
41
|
-
"verified": false,
|
|
42
|
-
"verifyNote": "annotated"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"name": "return_flight",
|
|
46
|
-
"type": "string",
|
|
47
|
-
"description": "Selected return flight as 'carrier number' (round trip only), e.g. 'WN 3540'. Empty for one-way.",
|
|
48
|
-
"default": "",
|
|
49
|
-
"verified": false,
|
|
50
|
-
"verifyNote": "annotated"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"name": "flight_token",
|
|
54
|
-
"type": "string",
|
|
55
|
-
"description": "Opaque per-itinerary booking token minted by the search_flights tool's flight_token output for the selected itinerary."
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
"bootstrap": {
|
|
59
|
-
"url": "https://www.google.com/travel/flights",
|
|
60
|
-
"waitUntil": "domcontentloaded",
|
|
61
|
-
"timeoutMs": 30000,
|
|
62
|
-
"captures": [
|
|
63
|
-
{
|
|
64
|
-
"source": "html_regex",
|
|
65
|
-
"name": "f_sid",
|
|
66
|
-
"pattern": "\"FdrFJe\":\"([^\"]+)\"",
|
|
67
|
-
"group": 1,
|
|
68
|
-
"required": false,
|
|
69
|
-
"capability": "browser_bootstrap"
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"source": "html_regex",
|
|
73
|
-
"name": "bl",
|
|
74
|
-
"pattern": "\"cfb2h\":\"([^\"]+)\"",
|
|
75
|
-
"group": 1,
|
|
76
|
-
"required": false,
|
|
77
|
-
"capability": "browser_bootstrap"
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
},
|
|
81
|
-
"requests": [
|
|
82
|
-
{
|
|
83
|
-
"method": "POST",
|
|
84
|
-
"url": "https://www.google.com/_/FlightsFrontendUi/data/travel.frontend.flights.FlightsFrontendService/GetBookingResults?f.sid=${state.f_sid}&bl=${state.bl}&hl=en-US&soc-app=162&soc-platform=1&soc-device=1&_reqid=1659189&rt=c",
|
|
85
|
-
"headers": {
|
|
86
|
-
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
87
|
-
"X-Same-Domain": "1",
|
|
88
|
-
"Referer": "https://www.google.com/travel/flights",
|
|
89
|
-
"x-goog-ext-259736195-jspb": "[\"en-US\",\"US\",\"USD\",2,null,[420],null,null,7,[]]"
|
|
90
|
-
},
|
|
91
|
-
"body": "f.req=${param.origin}|${param.destination}|${param.departure_date}|${param.return_date}|${param.outbound_flight}|${param.return_flight}|${param.flight_token}&",
|
|
92
|
-
"effect": "safe"
|
|
93
|
-
}
|
|
94
|
-
],
|
|
95
|
-
"requestTransformModule": "./request-transform.ts",
|
|
96
|
-
"parserModule": "./parser.ts",
|
|
97
|
-
"liveVerified": true
|
|
98
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// Local adapter: maps this tool's user-facing params (origin/destination/
|
|
2
|
-
// start_date/end_date) into the shape the shared FlightsFrontendService body
|
|
3
|
-
// builder consumes (legs[]/startDate/endDate/tripType), then delegates the
|
|
4
|
-
// byte-for-byte f.req encoding to the assigned shared request-transform.
|
|
5
|
-
import { transform as sharedTransform } from '../_shared/flights_request.ts';
|
|
6
|
-
|
|
7
|
-
export function transform(
|
|
8
|
-
method: string,
|
|
9
|
-
url: string,
|
|
10
|
-
responses: Record<string, any>,
|
|
11
|
-
params?: Record<string, any>,
|
|
12
|
-
): { url: string; body: string } {
|
|
13
|
-
const p: Record<string, any> = params ?? {};
|
|
14
|
-
const origin = String(p.origin ?? '').toUpperCase();
|
|
15
|
-
const destination = String(p.destination ?? '').toUpperCase();
|
|
16
|
-
|
|
17
|
-
// GetCalendarPicker for this tool is a round-trip (tripType 1), 1 adult,
|
|
18
|
-
// with a mirrored outbound/return leg pair — exactly as recorded in seq 97.
|
|
19
|
-
const adapted = {
|
|
20
|
-
tripType: 1,
|
|
21
|
-
adults: 1,
|
|
22
|
-
legs: [
|
|
23
|
-
{ origin, dest: destination },
|
|
24
|
-
{ origin: destination, dest: origin },
|
|
25
|
-
],
|
|
26
|
-
startDate: p.start_date ?? null,
|
|
27
|
-
endDate: p.end_date ?? null,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
return sharedTransform(method, url, responses, adapted);
|
|
31
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { extractRpcPayload } from '../_shared/batchexecute.ts';
|
|
2
|
-
|
|
3
|
-
// Parse the tDoGIe (airport/place resolution) batchexecute response.
|
|
4
|
-
//
|
|
5
|
-
// Decoded payload shape (seq 69):
|
|
6
|
-
// [ [null,null,0,"<token>"],
|
|
7
|
-
// [ // <- payload[1]: array of matches
|
|
8
|
-
// [ ["SJC",0], "San Jose Mineta International Airport",
|
|
9
|
-
// ["/m/0f04v","San Jose",[[img],[img]]], [37.3627778,-121.92917],
|
|
10
|
-
// "US", false, "United States" ],
|
|
11
|
-
// [ ["/m/0f04v",4], "San Jose", ["/m/0f04v","San Jose",...], [37.33874,-121.8852525], ... ]
|
|
12
|
-
// ] ]
|
|
13
|
-
// Each match item: [0][0]=code (IATA or /m/ entity id), [1]=name,
|
|
14
|
-
// [2][1]=associated city, [3]=[lat,lng], [4]=country code, [6]=country name.
|
|
15
|
-
|
|
16
|
-
interface AirportMatch {
|
|
17
|
-
code: string | null;
|
|
18
|
-
name: string | null;
|
|
19
|
-
city: string | null;
|
|
20
|
-
lat: number | null;
|
|
21
|
-
lng: number | null;
|
|
22
|
-
country: string | null;
|
|
23
|
-
countryName: string | null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function parseItem(item: unknown): AirportMatch | null {
|
|
27
|
-
if (!Array.isArray(item)) return null;
|
|
28
|
-
const code = Array.isArray(item[0]) ? (item[0][0] ?? null) : null;
|
|
29
|
-
const name = typeof item[1] === 'string' ? item[1] : null;
|
|
30
|
-
const city = Array.isArray(item[2]) && typeof item[2][1] === 'string' ? item[2][1] : null;
|
|
31
|
-
const coords = item[3];
|
|
32
|
-
const lat = Array.isArray(coords) && typeof coords[0] === 'number' ? coords[0] : null;
|
|
33
|
-
const lng = Array.isArray(coords) && typeof coords[1] === 'number' ? coords[1] : null;
|
|
34
|
-
const country = typeof item[4] === 'string' ? item[4] : null;
|
|
35
|
-
const countryName = typeof item[6] === 'string' ? item[6] : null;
|
|
36
|
-
const m: AirportMatch = { code, name, city, lat, lng, country, countryName };
|
|
37
|
-
// Drop content-less placeholder records (API no-match sentinel).
|
|
38
|
-
if (m.code == null && m.name == null) return null;
|
|
39
|
-
return m;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function extract(
|
|
43
|
-
rawResponse: unknown,
|
|
44
|
-
context?: { params: Record<string, string | number | boolean>; responses: unknown[] },
|
|
45
|
-
): unknown {
|
|
46
|
-
const raw = typeof rawResponse === 'string' ? rawResponse : JSON.stringify(rawResponse);
|
|
47
|
-
const payload = extractRpcPayload(raw, 'tDoGIe');
|
|
48
|
-
|
|
49
|
-
const matchesRaw = Array.isArray(payload) && Array.isArray(payload[1]) ? payload[1] : [];
|
|
50
|
-
const matches = matchesRaw
|
|
51
|
-
.map(parseItem)
|
|
52
|
-
.filter((m): m is AirportMatch => m !== null);
|
|
53
|
-
|
|
54
|
-
const primary = matches[0] ?? null;
|
|
55
|
-
return {
|
|
56
|
-
query: context?.params?.query ?? null,
|
|
57
|
-
matchCount: matches.length,
|
|
58
|
-
matches,
|
|
59
|
-
// Convenience: hoist the best (first) match to the top level.
|
|
60
|
-
code: primary?.code ?? null,
|
|
61
|
-
name: primary?.name ?? null,
|
|
62
|
-
city: primary?.city ?? null,
|
|
63
|
-
lat: primary?.lat ?? null,
|
|
64
|
-
lng: primary?.lng ?? null,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
toolName: lookup_airport
|
|
2
|
-
summary: Resolve a city or airport query (e.g. "SJC" or "san jose") into structured airport matches via Google Flights' autocomplete RPC.
|
|
3
|
-
parameters:
|
|
4
|
-
- name: query
|
|
5
|
-
type: string
|
|
6
|
-
description: City or airport search text, e.g. "san jose" or "SJC".
|
|
7
|
-
steps:
|
|
8
|
-
- action: navigate
|
|
9
|
-
url: https://www.google.com/travel/flights
|
|
10
|
-
wait_for: networkidle
|
|
11
|
-
- action: click
|
|
12
|
-
locators:
|
|
13
|
-
- by: aria_label
|
|
14
|
-
value: "Where from?"
|
|
15
|
-
- by: css
|
|
16
|
-
value: "div.cQnuXe.k0gFV input.II2One.j0Ppje"
|
|
17
|
-
wait_for:
|
|
18
|
-
sleep_ms: 300
|
|
19
|
-
- action: type
|
|
20
|
-
locators:
|
|
21
|
-
- by: aria_label
|
|
22
|
-
value: "Where else?"
|
|
23
|
-
- by: aria_label
|
|
24
|
-
value: "Where from?"
|
|
25
|
-
- by: css
|
|
26
|
-
value: "input.II2One.j0Ppje"
|
|
27
|
-
value: ${query}
|
|
28
|
-
wait_for:
|
|
29
|
-
xhr: "batchexecute?rpcids=tDoGIe"
|
|
30
|
-
method: POST
|
|
31
|
-
result:
|
|
32
|
-
source: xhr
|
|
33
|
-
url_pattern: "rpcids=tDoGIe"
|
|
34
|
-
extract: "1[]"
|
|
35
|
-
return_as: airports
|
|
36
|
-
notes: >-
|
|
37
|
-
The tDoGIe response is a Google batchexecute payload, not plain JSON. The
|
|
38
|
-
downstream parser must: (1) strip the )]}' prefix and the numeric length-prefixed
|
|
39
|
-
chunk markers, (2) locate the ["wrb.fr","tDoGIe", <payload-string>, ...] envelope,
|
|
40
|
-
(3) JSON.parse the double-encoded <payload-string>. After decoding, the parsed
|
|
41
|
-
array's index [1] is the list of matches (the `extract` path "1[]" above). Each
|
|
42
|
-
match is positional: code = [0][0] (e.g. "SJC"), name = [1] (e.g. "San Jose Mineta
|
|
43
|
-
International Airport"), city = [2][1], lat = [3][0], lng = [3][1], country = [6].
|
|
44
|
-
Return one {code, name, city, lat, lng} object per match. The XHR is authorized by
|
|
45
|
-
the page-bootstrap session id (f.sid) and X-Goog-BatchExecute-Bgr header, which are
|
|
46
|
-
session-bound — they must come from a freshly loaded page (handled by the navigate
|
|
47
|
-
step), not parameterized. No login/auth is required.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Builds the tDoGIe (airport lookup) batchexecute POST body.
|
|
2
|
-
//
|
|
3
|
-
// The body is a single form field `f.req` whose value is a doubly-encoded JSON
|
|
4
|
-
// array: f.req=[[["tDoGIe","[null,[[\"<query>\",0]]]",null,"generic"]]]
|
|
5
|
-
// The inner element is itself a JSON STRING (JSON-in-JSON), so we build it with
|
|
6
|
-
// two JSON.stringify passes, then URL-encode the whole thing. Recorded seq 69
|
|
7
|
-
// used query="SJC". This is the tool's own transform (the shared flights_request
|
|
8
|
-
// module targets the FlightsFrontendService RPCs, not tDoGIe).
|
|
9
|
-
export function transform(
|
|
10
|
-
_method: string,
|
|
11
|
-
url: string,
|
|
12
|
-
_responses: unknown[],
|
|
13
|
-
params?: Record<string, string | number | boolean>,
|
|
14
|
-
): { url: string; body: string } {
|
|
15
|
-
const query = String(params?.query ?? '').trim();
|
|
16
|
-
const inner = JSON.stringify([null, [[query, 0]]]);
|
|
17
|
-
const outer = JSON.stringify([[['tDoGIe', inner, null, 'generic']]]);
|
|
18
|
-
const body = 'f.req=' + encodeURIComponent(outer) + '&';
|
|
19
|
-
return { url, body };
|
|
20
|
-
}
|