imprint-mcp 0.4.8 → 0.4.10

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.
@@ -17,9 +17,8 @@ const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
17
17
  // [0] is an ISO date string. We scan every nested array so we are robust to the
18
18
  // list living at payload[1] (the recorded shape) or being flattened.
19
19
  function collectEntries(payload: unknown): CalendarEntry[] {
20
- const entries: CalendarEntry[] = [];
21
- const seen = new Set<string>();
22
- if (!Array.isArray(payload)) return entries;
20
+ const entries = new Map<string, CalendarEntry>();
21
+ if (!Array.isArray(payload)) return [];
23
22
 
24
23
  const consider = (item: unknown) => {
25
24
  if (!Array.isArray(item)) return;
@@ -33,9 +32,10 @@ function collectEntries(payload: unknown): CalendarEntry[] {
33
32
  price = (priceContainer[0] as unknown[])[1];
34
33
  }
35
34
  if (typeof price !== 'number') return; // no fare found for that date -> omit
36
- if (seen.has(dep)) return;
37
- seen.add(dep);
38
- entries.push({ departureDate: dep, returnDate: ret, lowestPriceUSD: price });
35
+ const existing = entries.get(dep);
36
+ if (!existing || price < existing.lowestPriceUSD) {
37
+ entries.set(dep, { departureDate: dep, returnDate: ret, lowestPriceUSD: price });
38
+ }
39
39
  };
40
40
 
41
41
  for (const top of payload) {
@@ -45,7 +45,7 @@ function collectEntries(payload: unknown): CalendarEntry[] {
45
45
  for (const inner of top) consider(inner);
46
46
  }
47
47
  }
48
- return entries;
48
+ return [...entries.values()];
49
49
  }
50
50
 
51
51
  export function extract(
@@ -13,7 +13,7 @@ const ALLIANCES = new Set(['ONEWORLD', 'SKYTEAM', 'STAR_ALLIANCE']);
13
13
  function mapTripType(v: unknown): number {
14
14
  if (v == null || v === '') return 1;
15
15
  if (typeof v === 'number') return v;
16
- const s = String(v).toLowerCase();
16
+ const s = String(v).trim().toLowerCase().replace(/[\s-]+/g, '_');
17
17
  if (s === 'one_way' || s === 'oneway' || s === '2') return 2;
18
18
  if (s === 'multi_city' || s === 'multicity' || s === '3') return 3;
19
19
  return 1; // round_trip
@@ -69,7 +69,9 @@ export function transform(
69
69
  params?: Params,
70
70
  ): { url: string; body: string } {
71
71
  const p: Params = params ?? {};
72
- const tripType = mapTripType(p.trip_type);
72
+ const requestedTripType = mapTripType(p.trip_type);
73
+ const hasReturnDate = p.return_date != null && String(p.return_date).trim() !== '';
74
+ const tripType = requestedTripType === 1 && !hasReturnDate ? 2 : requestedTripType;
73
75
  const stops = p.max_stops != null && p.max_stops !== '' ? mapStops(p.max_stops) : 0;
74
76
  const { alliances, carriers } = parseAirlines(p.airlines);
75
77
  const maxDur = num(p.max_duration);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imprint-mcp",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
4
4
  "description": "Teach an AI agent how to use any website. Once. Records a real browser session + narration; generates a deterministic MCP tool plus a DOM-replay playbook fallback.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,6 +19,7 @@
19
19
  "src/",
20
20
  "prompts/",
21
21
  "examples/",
22
+ "tsconfig.json",
22
23
  "README.md",
23
24
  "LICENSE",
24
25
  "CHANGELOG.md"
package/tsconfig.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ES2022"],
7
+ "types": ["node", "bun"],
8
+
9
+ "strict": true,
10
+ "noUncheckedIndexedAccess": true,
11
+ "noImplicitOverride": true,
12
+ "noPropertyAccessFromIndexSignature": false,
13
+ "noFallthroughCasesInSwitch": true,
14
+ "noImplicitReturns": true,
15
+ "noUnusedLocals": true,
16
+ "noUnusedParameters": true,
17
+
18
+ "esModuleInterop": true,
19
+ "allowSyntheticDefaultImports": true,
20
+ "resolveJsonModule": true,
21
+ "skipLibCheck": true,
22
+ "forceConsistentCasingInFileNames": true,
23
+
24
+ "noEmit": true,
25
+ "allowImportingTsExtensions": true,
26
+ "verbatimModuleSyntax": false,
27
+
28
+ "paths": {
29
+ "imprint/runtime": ["./src/imprint/runtime.ts"],
30
+ "imprint/types": ["./src/imprint/types.ts"]
31
+ }
32
+ },
33
+ "include": ["src/**/*", "test/**/*", "examples/**/*"],
34
+ "exclude": ["node_modules", "dist"]
35
+ }