@agentrhq/webcmd 0.4.2 → 0.4.3
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/cli-manifest.json +755 -174
- package/clis/_shared/site-auth.js +0 -1
- package/clis/_shared/site-auth.test.js +0 -1
- package/clis/amazon-in/checkout.js +0 -1
- package/clis/blinkit/checkout.js +0 -1
- package/clis/blinkit/place-order.js +0 -1
- package/clis/chatgpt/model.js +2 -2
- package/clis/chatgpt/model.test.js +7 -1
- package/clis/chatgpt/utils.js +8 -0
- package/clis/chatgpt/utils.test.js +92 -1
- package/clis/district/checkout.js +0 -1
- package/clis/district/seats.js +0 -1
- package/clis/district/set-location.js +0 -1
- package/clis/district/showtimes.js +0 -1
- package/clis/google/images.js +456 -0
- package/clis/google/images.test.js +375 -0
- package/clis/instagram/user.js +5 -13
- package/clis/instagram/user.test.js +66 -0
- package/clis/mercury/check-login.js +0 -1
- package/clis/mercury/reimbursement-draft.js +0 -1
- package/clis/practo/book-confirm.js +0 -1
- package/clis/practo/cancel.js +0 -1
- package/clis/trip/attraction.js +74 -0
- package/clis/trip/car.js +74 -0
- package/clis/trip/deals.js +61 -0
- package/clis/trip/flight-round.js +88 -0
- package/clis/trip/flight.js +83 -0
- package/clis/trip/hotel-search.js +80 -0
- package/clis/trip/hotel.js +54 -0
- package/clis/trip/package.js +93 -0
- package/clis/trip/search.js +43 -0
- package/clis/trip/tour.js +84 -0
- package/clis/trip/train.js +76 -0
- package/clis/trip/transfer.js +82 -0
- package/clis/trip/trip.test.js +1420 -0
- package/clis/trip/utils.js +911 -0
- package/dist/src/build-manifest.js +0 -1
- package/dist/src/build-manifest.test.js +4 -0
- package/dist/src/cli.js +7 -7
- package/dist/src/cli.test.js +26 -10
- package/dist/src/command-presentation.js +1 -1
- package/dist/src/command-presentation.test.js +3 -0
- package/dist/src/command-surface.js +1 -1
- package/dist/src/command-surface.test.js +4 -0
- package/dist/src/commands/auth.js +0 -2
- package/dist/src/commands/auth.test.js +0 -2
- package/dist/src/discovery.js +0 -1
- package/dist/src/execution.js +3 -3
- package/dist/src/execution.test.js +68 -15
- package/dist/src/hosted/browser-args.js +2 -2
- package/dist/src/hosted/browser-args.test.js +10 -0
- package/dist/src/hosted/client.js +2 -2
- package/dist/src/manifest-types.d.ts +0 -2
- package/dist/src/registry.d.ts +0 -2
- package/dist/src/registry.js +0 -1
- package/hosted-contract.json +767 -3
- package/package.json +2 -2
- package/skills/webcmd-browser/SKILL.md +2 -1
- package/skills/webcmd-usage/SKILL.md +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trip.com (international) airport-transfer listing.
|
|
3
|
+
*
|
|
4
|
+
* Trip.com files airport transfers under an SEO path keyed on the city slug plus
|
|
5
|
+
* the airport IATA code (`airport-transfers/<city>/airport-<iata>/`). A city that
|
|
6
|
+
* does not match the airport bounces to the transfer landing page, so this checks
|
|
7
|
+
* the landed path before extracting to avoid returning the generic landing list.
|
|
8
|
+
* Rows come from the rendered `.vehicle-card` cards (see `buildTransferExtractJs`
|
|
9
|
+
* in utils); the from-price is the site's representative fare, with the dated
|
|
10
|
+
* pickup quote behind the booking step.
|
|
11
|
+
*/
|
|
12
|
+
import { AuthRequiredError, CommandExecutionError, EmptyResultError } from '@agentrhq/webcmd/errors';
|
|
13
|
+
import { cli, Strategy } from '@agentrhq/webcmd/registry';
|
|
14
|
+
import {
|
|
15
|
+
WAIT_FOR_TRANSFERS_JS,
|
|
16
|
+
buildTransferExtractJs,
|
|
17
|
+
buildTransferListUrl,
|
|
18
|
+
parseIataCode,
|
|
19
|
+
parseKeyword,
|
|
20
|
+
parseListLimit,
|
|
21
|
+
} from './utils.js';
|
|
22
|
+
|
|
23
|
+
cli({
|
|
24
|
+
site: 'trip',
|
|
25
|
+
name: 'transfer',
|
|
26
|
+
access: 'read',
|
|
27
|
+
description: 'List Trip.com airport-transfer vehicles for a city + airport (type, seats, from-price)',
|
|
28
|
+
domain: 'trip.com',
|
|
29
|
+
strategy: Strategy.COOKIE,
|
|
30
|
+
browser: true,
|
|
31
|
+
navigateBefore: false,
|
|
32
|
+
args: [
|
|
33
|
+
{ name: 'city', required: true, positional: true, help: 'Airport city (e.g. Bangkok / Beijing / Da Nang)' },
|
|
34
|
+
{ name: 'airport', required: true, positional: true, help: '3-letter airport IATA code (e.g. DMK / PKX / DAD)' },
|
|
35
|
+
{ name: 'limit', type: 'int', default: 20, help: 'Number of vehicles (1-50)' },
|
|
36
|
+
],
|
|
37
|
+
columns: [
|
|
38
|
+
'rank',
|
|
39
|
+
'type',
|
|
40
|
+
'passengers', 'luggage',
|
|
41
|
+
'price', 'currency',
|
|
42
|
+
'url',
|
|
43
|
+
],
|
|
44
|
+
func: async (page, kwargs) => {
|
|
45
|
+
const city = parseKeyword('city', kwargs.city);
|
|
46
|
+
const airport = parseIataCode('airport', kwargs.airport);
|
|
47
|
+
const limit = parseListLimit(kwargs.limit);
|
|
48
|
+
|
|
49
|
+
const listUrl = buildTransferListUrl(city, airport);
|
|
50
|
+
await page.goto(listUrl);
|
|
51
|
+
const waitResult = await page.evaluate(WAIT_FOR_TRANSFERS_JS);
|
|
52
|
+
if (waitResult === 'captcha') {
|
|
53
|
+
throw new AuthRequiredError('trip.com', 'Trip.com is asking for a verification; complete it in your browser session and retry');
|
|
54
|
+
}
|
|
55
|
+
if (waitResult === 'empty') {
|
|
56
|
+
throw new EmptyResultError('trip transfer', `No airport transfers for ${city} (${airport})`);
|
|
57
|
+
}
|
|
58
|
+
if (waitResult !== 'content') {
|
|
59
|
+
throw new CommandExecutionError(`Trip.com transfer listing did not render (state=${String(waitResult)}); check the city and airport code`);
|
|
60
|
+
}
|
|
61
|
+
const landedPath = await page.evaluate('location.pathname');
|
|
62
|
+
if (!/\/airport-transfers\/[^/]+\/airport-[^/]+/i.test(String(landedPath))) {
|
|
63
|
+
throw new CommandExecutionError(`Trip.com bounced ${city} / ${airport} to the transfer landing; check the city name matches the airport IATA code`);
|
|
64
|
+
}
|
|
65
|
+
const raw = await page.evaluate(buildTransferExtractJs());
|
|
66
|
+
if (!Array.isArray(raw)) {
|
|
67
|
+
throw new CommandExecutionError('Trip.com transfer DOM extraction returned malformed rows');
|
|
68
|
+
}
|
|
69
|
+
if (raw.length === 0) {
|
|
70
|
+
throw new CommandExecutionError('Trip.com transfer cards rendered but parser did not find required price anchors');
|
|
71
|
+
}
|
|
72
|
+
return raw.slice(0, limit).map((r, i) => ({
|
|
73
|
+
rank: i + 1,
|
|
74
|
+
type: r.type,
|
|
75
|
+
passengers: r.passengers,
|
|
76
|
+
luggage: r.luggage,
|
|
77
|
+
price: r.price,
|
|
78
|
+
currency: r.currency,
|
|
79
|
+
url: listUrl,
|
|
80
|
+
}));
|
|
81
|
+
},
|
|
82
|
+
});
|