@ktemia/langchain 0.0.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ktemia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # @ktemia/langchain
2
+
3
+ [![npm](https://img.shields.io/npm/v/@ktemia/langchain)](https://www.npmjs.com/package/@ktemia/langchain)
4
+
5
+ LangChain.js tools for the [Ktemia](https://www.ktemia.com/) travel search API. Give your agent flight, hotel, and rental car search across airlines, booking sites, and rental companies, with each seller's price and a booking link.
6
+
7
+ Ktemia searches and compares. It does not book: results carry links that hand off to the seller's own site.
8
+
9
+ [Get a free API key](https://app.ktemia.com/api-keys) · [LangChain guide](https://www.ktemia.com/docs/langchain/) · [API reference](https://www.ktemia.com/docs/api/) · [Pricing](https://www.ktemia.com/pricing/)
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @ktemia/langchain @langchain/core zod
15
+ export KTEMIA_API_KEY=your-key
16
+ ```
17
+
18
+ ## Use with an agent
19
+
20
+ ```ts
21
+ import { createAgent } from "langchain";
22
+ import { ktemiaTools } from "@ktemia/langchain";
23
+
24
+ const agent = createAgent({ model: "openai:gpt-5-mini", tools: ktemiaTools() });
25
+
26
+ const result = await agent.invoke({
27
+ messages: [{ role: "user", content: "What is the cheapest flight from Los Angeles to London on 2027-03-14?" }],
28
+ });
29
+ console.log(result.messages.at(-1)?.content);
30
+ ```
31
+
32
+ Any chat model with tool calling works, and the tools also run in LangGraph. The agent looks up places, runs the search, and reads booking options on its own. Put today's date in the system prompt: models do not know it, and a search needs a future date.
33
+
34
+ ## Tools
35
+
36
+ `ktemiaTools()` returns all seven tools, sharing one client. `new KtemiaToolkit()` returns the same tools as a LangChain toolkit (`toolkit.getTools()`).
37
+
38
+ | Tool | Factory | Use it for |
39
+ | ---- | ------- | ---------- |
40
+ | `ktemia_key_status` | `keyStatus()` | Plan, rate limits, and requests left this month. Costs no quota. |
41
+ | `ktemia_lookup` | `lookup()` | Airport, airline, hotel, and car rental location codes |
42
+ | `ktemia_search_flights` | `searchFlights()` | One-way, return, and multi-city fares |
43
+ | `ktemia_search_hotels` | `searchHotels()` | Hotels and stays by location id |
44
+ | `ktemia_search_cars` | `searchCars()` | Rental cars by pickup location id |
45
+ | `ktemia_get_details` | `getDetails()` | Every seller's price and booking link for one result |
46
+ | `ktemia_get_hotel_reviews` | `hotelReviews()` | Guest reviews for one hotel, with filters |
47
+
48
+ Tool names and descriptions are the same as the [Ktemia MCP server](https://www.ktemia.com/docs/mcp/), the [Vercel AI SDK tools](https://www.ktemia.com/docs/vercel-ai-sdk/), and the Python [`langchain-ktemia`](https://pypi.org/project/langchain-ktemia/), so an agent behaves the same way on every framework.
49
+
50
+ To give the model fewer tools, use the factories. Keep `ktemia_lookup` with the search tools: their descriptions tell the model to call it first.
51
+
52
+ ```ts
53
+ import { hotelReviews, lookup, searchHotels } from "@ktemia/langchain";
54
+
55
+ const tools = [lookup(), searchHotels(), hotelReviews()];
56
+ ```
57
+
58
+ ## Paging, errors, and quota
59
+
60
+ - A search returns the first page and a `nextToken` when there are more. The model calls the same tool again with only `nextToken` to read the next page. Each result includes a `pagingHint` that says what to do next.
61
+ - Errors come back as `{"error": {"code", "message", "retryable"}}` JSON instead of throwing, so the model can react: ask for a missing date, or stop on `QUOTA_EXCEEDED`.
62
+ - Input that can only fail, such as a past date or a city name where an airport code belongs, is rejected before any request is sent, so it spends no quota.
63
+ - Rate limits are retried automatically using `Retry-After`. A spent monthly quota is never retried.
64
+ - Every call except `ktemia_key_status` counts against the account's monthly quota. A new search costs two requests: one to start it and one to read the first page.
65
+
66
+ ## Options
67
+
68
+ ```ts
69
+ ktemiaTools({
70
+ apiKey: process.env.MY_KTEMIA_KEY, // default: KTEMIA_API_KEY
71
+ timeoutMs: 60_000, // per request
72
+ maxRetries: 2, // retries after a rate limit
73
+ });
74
+
75
+ // Or share a configured client with the rest of your app
76
+ import { Ktemia } from "ktemia";
77
+ const tools = ktemiaTools({ client: new Ktemia() });
78
+ ```
79
+
80
+ Building the tools never fails, even without a key, so creating them at module scope is safe. A missing key shows up on the first call, as an error the model can read. Run the tools on the server so the key never reaches a browser.
81
+
82
+ ## Related
83
+
84
+ - [`ktemia`](https://www.npmjs.com/package/ktemia): the dependency-free client these tools are built on
85
+ - [`@ktemia/ai-sdk`](https://www.npmjs.com/package/@ktemia/ai-sdk): the same tools for the Vercel AI SDK
86
+ - [`@ktemia/mcp`](https://www.npmjs.com/package/@ktemia/mcp): the same tools as an MCP server
87
+ - Source: [Ktemiaa/ktemia-agent-toolkit](https://github.com/Ktemiaa/ktemia-agent-toolkit)
88
+
89
+ Requires Node 20+, `@langchain/core` 1.x, and zod 3.25 or 4. MIT licensed.
package/dist/index.cjs ADDED
@@ -0,0 +1,282 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Ktemia: () => import_ktemia2.Ktemia,
24
+ KtemiaError: () => import_ktemia2.KtemiaError,
25
+ KtemiaToolkit: () => KtemiaToolkit,
26
+ VERSION: () => VERSION,
27
+ getDetails: () => getDetails,
28
+ hotelReviews: () => hotelReviews,
29
+ keyStatus: () => keyStatus,
30
+ ktemiaTools: () => ktemiaTools,
31
+ lookup: () => lookup,
32
+ searchCars: () => searchCars,
33
+ searchFlights: () => searchFlights,
34
+ searchHotels: () => searchHotels
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+ var import_tools = require("@langchain/core/tools");
38
+ var import_zod = require("zod");
39
+ var import_ktemia = require("ktemia");
40
+ var import_ktemia2 = require("ktemia");
41
+ var VERSION = "0.1.1";
42
+ var NAME = {
43
+ keyStatus: "ktemia_key_status",
44
+ lookup: "ktemia_lookup",
45
+ searchFlights: "ktemia_search_flights",
46
+ searchHotels: "ktemia_search_hotels",
47
+ searchCars: "ktemia_search_cars",
48
+ getDetails: "ktemia_get_details",
49
+ hotelReviews: "ktemia_get_hotel_reviews"
50
+ };
51
+ var SEARCH_NOTES = ["askDoNotGuessNote", "tokenLifetimeNote", "quotaNote", "searchNotBookNote"];
52
+ var id = () => import_zod.z.union([import_zod.z.string().min(1), import_zod.z.number()]);
53
+ var price = (n, field) => import_zod.z.number().refine((v) => v > 0, { message: "Must be greater than 0" }).optional().describe((0, import_ktemia.paramDescription)(n, field));
54
+ var country = (n) => import_zod.z.string().length(2).optional().describe((0, import_ktemia.paramDescription)(n, "country"));
55
+ var sortOrder = (n) => import_zod.z.enum(["asc", "desc"]).optional().describe((0, import_ktemia.paramDescription)(n, "sortOrder"));
56
+ var nextToken = (n) => import_zod.z.string().optional().describe((0, import_ktemia.paramDescription)(n, "nextToken"));
57
+ var keyStatusSchema = import_zod.z.object({});
58
+ var lookupSchema = import_zod.z.object({
59
+ kind: import_zod.z.enum(["airport", "airline", "hotelLocation", "carLocation"]).describe((0, import_ktemia.paramDescription)(NAME.lookup, "kind")),
60
+ query: import_zod.z.string().min(1).describe((0, import_ktemia.paramDescription)(NAME.lookup, "query")),
61
+ type: import_zod.z.enum(["city", "airport", "all"]).optional().describe((0, import_ktemia.paramDescription)(NAME.lookup, "type")),
62
+ country: country(NAME.lookup),
63
+ locale: import_zod.z.string().optional().describe((0, import_ktemia.paramDescription)(NAME.lookup, "locale"))
64
+ });
65
+ var F = NAME.searchFlights;
66
+ var flightSchema = import_zod.z.object({
67
+ nextToken: nextToken(F),
68
+ origin: import_zod.z.string().optional().describe((0, import_ktemia.paramDescription)(F, "origin")),
69
+ destination: import_zod.z.string().optional().describe((0, import_ktemia.paramDescription)(F, "destination")),
70
+ departureDate: import_zod.z.string().optional().describe((0, import_ktemia.paramDescription)(F, "departureDate")),
71
+ returnDate: import_zod.z.string().optional().describe((0, import_ktemia.paramDescription)(F, "returnDate")),
72
+ legs: import_zod.z.array(import_zod.z.object({ origin: import_zod.z.string(), destination: import_zod.z.string(), date: import_zod.z.string() })).optional().describe((0, import_ktemia.paramDescription)(F, "legs")),
73
+ cabin: import_zod.z.enum(["economy", "premiumEconomy", "business", "first"]).optional().describe((0, import_ktemia.paramDescription)(F, "cabin")),
74
+ passengers: import_zod.z.object({
75
+ adults: import_zod.z.number().int().min(0).max(9).optional(),
76
+ children: import_zod.z.number().int().min(0).max(9).optional(),
77
+ infantsOnLap: import_zod.z.number().int().min(0).max(9).optional()
78
+ }).optional().describe((0, import_ktemia.paramDescription)(F, "passengers")),
79
+ maxStops: import_zod.z.number().int().min(0).max(2).optional().describe((0, import_ktemia.paramDescription)(F, "maxStops")),
80
+ airlines: import_zod.z.array(import_zod.z.string()).optional().describe((0, import_ktemia.paramDescription)(F, "airlines")),
81
+ alliances: import_zod.z.array(import_zod.z.enum(["oneworld", "skyteam", "starAlliance"])).optional().describe((0, import_ktemia.paramDescription)(F, "alliances")),
82
+ maxPrice: price(F, "maxPrice"),
83
+ sortBy: import_zod.z.enum(["bestValue", "price", "duration", "departure", "arrival"]).optional().describe((0, import_ktemia.paramDescription)(F, "sortBy")),
84
+ sortOrder: sortOrder(F),
85
+ country: country(F)
86
+ });
87
+ var H = NAME.searchHotels;
88
+ var hotelSchema = import_zod.z.object({
89
+ nextToken: nextToken(H),
90
+ location: id().optional().describe((0, import_ktemia.paramDescription)(H, "location")),
91
+ checkin: import_zod.z.string().optional().describe((0, import_ktemia.paramDescription)(H, "checkin")),
92
+ checkout: import_zod.z.string().optional().describe((0, import_ktemia.paramDescription)(H, "checkout")),
93
+ adults: import_zod.z.number().int().min(1).max(16).optional().describe((0, import_ktemia.paramDescription)(H, "adults")),
94
+ rooms: import_zod.z.number().int().min(1).max(8).optional().describe((0, import_ktemia.paramDescription)(H, "rooms")),
95
+ childAges: import_zod.z.array(import_zod.z.number().int().min(0).max(17)).optional().describe((0, import_ktemia.paramDescription)(H, "childAges")),
96
+ minStars: import_zod.z.number().int().min(2).max(5).optional().describe((0, import_ktemia.paramDescription)(H, "minStars")),
97
+ minRating: import_zod.z.number().optional().describe((0, import_ktemia.paramDescription)(H, "minRating")),
98
+ maxPrice: price(H, "maxPrice"),
99
+ freeCancellation: import_zod.z.boolean().optional().describe((0, import_ktemia.paramDescription)(H, "freeCancellation")),
100
+ amenities: import_zod.z.array(import_zod.z.string()).optional().describe((0, import_ktemia.paramDescription)(H, "amenities")),
101
+ providers: import_zod.z.array(import_zod.z.string()).optional().describe((0, import_ktemia.paramDescription)(H, "providers")),
102
+ sortBy: import_zod.z.enum(["bestValue", "price", "rating", "stars", "distance"]).optional().describe((0, import_ktemia.paramDescription)(H, "sortBy")),
103
+ sortOrder: sortOrder(H),
104
+ country: country(H)
105
+ });
106
+ var C = NAME.searchCars;
107
+ var carClasses = (0, import_ktemia.enumValues)("carClass");
108
+ var carSchema = import_zod.z.object({
109
+ nextToken: nextToken(C),
110
+ pickupLocation: id().optional().describe((0, import_ktemia.paramDescription)(C, "pickupLocation")),
111
+ dropoffLocation: id().optional().describe((0, import_ktemia.paramDescription)(C, "dropoffLocation")),
112
+ pickupDate: import_zod.z.string().optional().describe((0, import_ktemia.paramDescription)(C, "pickupDate")),
113
+ dropoffDate: import_zod.z.string().optional().describe((0, import_ktemia.paramDescription)(C, "dropoffDate")),
114
+ pickupTime: import_zod.z.string().optional().describe((0, import_ktemia.paramDescription)(C, "pickupTime")),
115
+ dropoffTime: import_zod.z.string().optional().describe((0, import_ktemia.paramDescription)(C, "dropoffTime")),
116
+ driverAge: import_zod.z.number().int().min(18).max(99).optional().describe((0, import_ktemia.paramDescription)(C, "driverAge")),
117
+ carClass: import_zod.z.enum(carClasses).optional().describe((0, import_ktemia.paramDescription)(C, "carClass")),
118
+ transmission: import_zod.z.enum(["automatic", "manual"]).optional().describe((0, import_ktemia.paramDescription)(C, "transmission")),
119
+ maxPrice: price(C, "maxPrice"),
120
+ providers: import_zod.z.array(import_zod.z.string()).optional().describe((0, import_ktemia.paramDescription)(C, "providers")),
121
+ agencies: import_zod.z.array(import_zod.z.string()).optional().describe((0, import_ktemia.paramDescription)(C, "agencies")),
122
+ sortBy: import_zod.z.enum(["bestValue", "price", "rating", "distance"]).optional().describe((0, import_ktemia.paramDescription)(C, "sortBy")),
123
+ sortOrder: sortOrder(C),
124
+ priceMode: import_zod.z.enum(["total", "perDay"]).optional().describe((0, import_ktemia.paramDescription)(C, "priceMode")),
125
+ country: country(C)
126
+ });
127
+ var D = NAME.getDetails;
128
+ var detailsSchema = import_zod.z.object({
129
+ vertical: import_zod.z.enum(["flights", "hotels", "cars"]).describe((0, import_ktemia.paramDescription)(D, "vertical")),
130
+ token: import_zod.z.string().min(1).describe((0, import_ktemia.paramDescription)(D, "token")),
131
+ resultId: id().describe((0, import_ktemia.paramDescription)(D, "resultId"))
132
+ });
133
+ var R = NAME.hotelReviews;
134
+ var reviewsSchema = import_zod.z.object({
135
+ hotelId: id().describe((0, import_ktemia.paramDescription)(R, "hotelId")),
136
+ sortBy: import_zod.z.enum(["recent", "oldest", "highestScore", "lowestScore"]).optional().describe((0, import_ktemia.paramDescription)(R, "sortBy")),
137
+ travelerTypes: import_zod.z.array(import_zod.z.enum(["families", "couples", "solo", "friends", "business"])).optional().describe((0, import_ktemia.paramDescription)(R, "travelerTypes")),
138
+ months: import_zod.z.array(import_zod.z.number().int().min(1).max(12)).optional().describe((0, import_ktemia.paramDescription)(R, "months")),
139
+ sources: import_zod.z.array(import_zod.z.enum(["booking", "agoda", "priceline"])).optional().describe((0, import_ktemia.paramDescription)(R, "sources")),
140
+ search: import_zod.z.string().optional().describe((0, import_ktemia.paramDescription)(R, "search")),
141
+ page: import_zod.z.number().int().min(1).max(1e3).optional().describe((0, import_ktemia.paramDescription)(R, "page"))
142
+ });
143
+ function resolveClient(options) {
144
+ const { client, ...rest } = options;
145
+ return client ?? new import_ktemia.Ktemia({ userAgent: `langchain-js/${VERSION}`, ...rest });
146
+ }
147
+ async function run(fn) {
148
+ try {
149
+ return JSON.stringify(await fn());
150
+ } catch (error) {
151
+ if (error instanceof import_ktemia.KtemiaError) return JSON.stringify({ error: error.toJSON() });
152
+ throw error;
153
+ }
154
+ }
155
+ function withHint(name, page) {
156
+ const pagingHint = page.noResults ? "The search matched nothing. Suggest other dates, a nearby airport, or fewer filters." : page.nextToken ? `More results are available. To read the next page, call ${name} with nextToken only.` : "This is the last page of results.";
157
+ return { ...page, pagingHint };
158
+ }
159
+ var str = (value) => value === void 0 ? "" : String(value);
160
+ function keyStatus(options = {}) {
161
+ const kt = resolveClient(options);
162
+ return (0, import_tools.tool)(async (_input, config) => run(() => kt.keyStatus({ signal: config?.signal })), {
163
+ name: NAME.keyStatus,
164
+ description: (0, import_ktemia.toolDescription)(NAME.keyStatus),
165
+ schema: keyStatusSchema
166
+ });
167
+ }
168
+ function lookup(options = {}) {
169
+ const kt = resolveClient(options);
170
+ return (0, import_tools.tool)(async (input, config) => run(() => kt.lookup(input, { signal: config?.signal })), {
171
+ name: NAME.lookup,
172
+ description: (0, import_ktemia.toolDescription)(NAME.lookup, ["quotaNote"]),
173
+ schema: lookupSchema
174
+ });
175
+ }
176
+ function searchFlights(options = {}) {
177
+ const kt = resolveClient(options);
178
+ return (0, import_tools.tool)(
179
+ async ({ nextToken: nextToken2, ...params }, config) => run(async () => {
180
+ const signal = config?.signal;
181
+ return withHint(
182
+ F,
183
+ nextToken2 ? await kt.flights.page(nextToken2, { signal }) : await kt.flights.search(params, { signal })
184
+ );
185
+ }),
186
+ { name: F, description: (0, import_ktemia.toolDescription)(F, SEARCH_NOTES), schema: flightSchema }
187
+ );
188
+ }
189
+ function searchHotels(options = {}) {
190
+ const kt = resolveClient(options);
191
+ return (0, import_tools.tool)(
192
+ async ({ nextToken: nextToken2, location, checkin, checkout, ...rest }, config) => run(async () => {
193
+ const signal = config?.signal;
194
+ return withHint(
195
+ H,
196
+ nextToken2 ? await kt.hotels.page(nextToken2, { signal }) : await kt.hotels.search(
197
+ { ...rest, location: str(location), checkin: str(checkin), checkout: str(checkout) },
198
+ { signal }
199
+ )
200
+ );
201
+ }),
202
+ { name: H, description: (0, import_ktemia.toolDescription)(H, SEARCH_NOTES), schema: hotelSchema }
203
+ );
204
+ }
205
+ function searchCars(options = {}) {
206
+ const kt = resolveClient(options);
207
+ return (0, import_tools.tool)(
208
+ async ({ nextToken: nextToken2, pickupLocation, dropoffLocation, pickupDate, dropoffDate, ...rest }, config) => run(async () => {
209
+ const signal = config?.signal;
210
+ return withHint(
211
+ C,
212
+ nextToken2 ? await kt.cars.page(nextToken2, { signal }) : await kt.cars.search(
213
+ {
214
+ ...rest,
215
+ pickupLocation: str(pickupLocation),
216
+ ...dropoffLocation !== void 0 ? { dropoffLocation: String(dropoffLocation) } : {},
217
+ pickupDate: str(pickupDate),
218
+ dropoffDate: str(dropoffDate)
219
+ },
220
+ { signal }
221
+ )
222
+ );
223
+ }),
224
+ { name: C, description: (0, import_ktemia.toolDescription)(C, SEARCH_NOTES), schema: carSchema }
225
+ );
226
+ }
227
+ function getDetails(options = {}) {
228
+ const kt = resolveClient(options);
229
+ return (0, import_tools.tool)(
230
+ async ({ vertical, token, resultId }, config) => run(async () => ({
231
+ vertical,
232
+ ...await kt[vertical].details(token, String(resultId), { signal: config?.signal })
233
+ })),
234
+ {
235
+ name: D,
236
+ description: (0, import_ktemia.toolDescription)(D, ["tokenLifetimeNote", "quotaNote", "searchNotBookNote"]),
237
+ schema: detailsSchema
238
+ }
239
+ );
240
+ }
241
+ function hotelReviews(options = {}) {
242
+ const kt = resolveClient(options);
243
+ return (0, import_tools.tool)(
244
+ async ({ hotelId, ...rest }, config) => run(() => kt.hotels.reviews({ ...rest, hotelId: String(hotelId) }, { signal: config?.signal })),
245
+ { name: R, description: (0, import_ktemia.toolDescription)(R, ["quotaNote"]), schema: reviewsSchema }
246
+ );
247
+ }
248
+ function ktemiaTools(options = {}) {
249
+ const shared = { client: resolveClient(options) };
250
+ return [
251
+ keyStatus(shared),
252
+ lookup(shared),
253
+ searchFlights(shared),
254
+ searchHotels(shared),
255
+ searchCars(shared),
256
+ getDetails(shared),
257
+ hotelReviews(shared)
258
+ ];
259
+ }
260
+ var KtemiaToolkit = class extends import_tools.BaseToolkit {
261
+ tools;
262
+ constructor(options = {}) {
263
+ super();
264
+ this.tools = ktemiaTools(options);
265
+ }
266
+ };
267
+ // Annotate the CommonJS export names for ESM import in node:
268
+ 0 && (module.exports = {
269
+ Ktemia,
270
+ KtemiaError,
271
+ KtemiaToolkit,
272
+ VERSION,
273
+ getDetails,
274
+ hotelReviews,
275
+ keyStatus,
276
+ ktemiaTools,
277
+ lookup,
278
+ searchCars,
279
+ searchFlights,
280
+ searchHotels
281
+ });
282
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Ktemia tools for LangChain.js.\n *\n * Each factory returns a LangChain `tool()`. Names and descriptions come from\n * the shared Ktemia tool spec, so a model sees the same guidance here as\n * through the Ktemia MCP server, the Vercel AI SDK tools, and the Python\n * `langchain-ktemia` package.\n *\n * Errors the model can act on (a past date, a spent quota, a rate limit) are\n * returned as `{\"error\": {...}}` JSON instead of thrown, so the model reads the\n * reason and decides what to do next, for example asking the user for a date.\n */\n\nimport { BaseToolkit, tool, type StructuredToolInterface } from \"@langchain/core/tools\";\nimport { z } from \"zod\";\nimport {\n Ktemia,\n KtemiaError,\n enumValues,\n paramDescription as p,\n toolDescription,\n type CarSearchParams,\n type KtemiaOptions,\n type SearchPage,\n type ToolName,\n} from \"ktemia\";\n\nexport const VERSION = \"0.1.1\";\n\nexport interface KtemiaToolOptions extends KtemiaOptions {\n /** Reuse an existing client instead of creating one from the options above. */\n client?: Ktemia;\n}\n\nconst NAME = {\n keyStatus: \"ktemia_key_status\",\n lookup: \"ktemia_lookup\",\n searchFlights: \"ktemia_search_flights\",\n searchHotels: \"ktemia_search_hotels\",\n searchCars: \"ktemia_search_cars\",\n getDetails: \"ktemia_get_details\",\n hotelReviews: \"ktemia_get_hotel_reviews\",\n} as const satisfies Record<string, ToolName>;\n\nconst SEARCH_NOTES = [\"askDoNotGuessNote\", \"tokenLifetimeNote\", \"quotaNote\", \"searchNotBookNote\"];\n\n// ── Schemas (limits match the live API) ──────────────────────────────────────\n\n/** Accepts ids a model copies as numbers: \"29230\" or 29230. */\nconst id = () => z.union([z.string().min(1), z.number()]);\n/**\n * A price above zero. Checked with refine, not `.positive()`: `.positive()`\n * emits `exclusiveMinimum`, which Gemini's API rejects outright (\"Unknown\n * name exclusiveMinimum\"), and @langchain/google-genai passes it through.\n */\nconst price = (n: ToolName, field: string) =>\n z\n .number()\n .refine((v) => v > 0, { message: \"Must be greater than 0\" })\n .optional()\n .describe(p(n, field));\nconst country = (n: ToolName) => z.string().length(2).optional().describe(p(n, \"country\"));\nconst sortOrder = (n: ToolName) => z.enum([\"asc\", \"desc\"]).optional().describe(p(n, \"sortOrder\"));\nconst nextToken = (n: ToolName) => z.string().optional().describe(p(n, \"nextToken\"));\n\nconst keyStatusSchema = z.object({});\n\nconst lookupSchema = z.object({\n kind: z.enum([\"airport\", \"airline\", \"hotelLocation\", \"carLocation\"]).describe(p(NAME.lookup, \"kind\")),\n query: z.string().min(1).describe(p(NAME.lookup, \"query\")),\n type: z.enum([\"city\", \"airport\", \"all\"]).optional().describe(p(NAME.lookup, \"type\")),\n country: country(NAME.lookup),\n locale: z.string().optional().describe(p(NAME.lookup, \"locale\")),\n});\n\nconst F = NAME.searchFlights;\nconst flightSchema = z.object({\n nextToken: nextToken(F),\n origin: z.string().optional().describe(p(F, \"origin\")),\n destination: z.string().optional().describe(p(F, \"destination\")),\n departureDate: z.string().optional().describe(p(F, \"departureDate\")),\n returnDate: z.string().optional().describe(p(F, \"returnDate\")),\n legs: z\n .array(z.object({ origin: z.string(), destination: z.string(), date: z.string() }))\n .optional()\n .describe(p(F, \"legs\")),\n cabin: z.enum([\"economy\", \"premiumEconomy\", \"business\", \"first\"]).optional().describe(p(F, \"cabin\")),\n passengers: z\n .object({\n adults: z.number().int().min(0).max(9).optional(),\n children: z.number().int().min(0).max(9).optional(),\n infantsOnLap: z.number().int().min(0).max(9).optional(),\n })\n .optional()\n .describe(p(F, \"passengers\")),\n maxStops: z.number().int().min(0).max(2).optional().describe(p(F, \"maxStops\")),\n airlines: z.array(z.string()).optional().describe(p(F, \"airlines\")),\n alliances: z.array(z.enum([\"oneworld\", \"skyteam\", \"starAlliance\"])).optional().describe(p(F, \"alliances\")),\n maxPrice: price(F, \"maxPrice\"),\n sortBy: z.enum([\"bestValue\", \"price\", \"duration\", \"departure\", \"arrival\"]).optional().describe(p(F, \"sortBy\")),\n sortOrder: sortOrder(F),\n country: country(F),\n});\n\nconst H = NAME.searchHotels;\nconst hotelSchema = z.object({\n nextToken: nextToken(H),\n location: id().optional().describe(p(H, \"location\")),\n checkin: z.string().optional().describe(p(H, \"checkin\")),\n checkout: z.string().optional().describe(p(H, \"checkout\")),\n adults: z.number().int().min(1).max(16).optional().describe(p(H, \"adults\")),\n rooms: z.number().int().min(1).max(8).optional().describe(p(H, \"rooms\")),\n childAges: z.array(z.number().int().min(0).max(17)).optional().describe(p(H, \"childAges\")),\n minStars: z.number().int().min(2).max(5).optional().describe(p(H, \"minStars\")),\n minRating: z.number().optional().describe(p(H, \"minRating\")),\n maxPrice: price(H, \"maxPrice\"),\n freeCancellation: z.boolean().optional().describe(p(H, \"freeCancellation\")),\n amenities: z.array(z.string()).optional().describe(p(H, \"amenities\")),\n providers: z.array(z.string()).optional().describe(p(H, \"providers\")),\n sortBy: z.enum([\"bestValue\", \"price\", \"rating\", \"stars\", \"distance\"]).optional().describe(p(H, \"sortBy\")),\n sortOrder: sortOrder(H),\n country: country(H),\n});\n\nconst C = NAME.searchCars;\nconst carClasses = enumValues(\"carClass\") as [\n NonNullable<CarSearchParams[\"carClass\"]>,\n ...NonNullable<CarSearchParams[\"carClass\"]>[],\n];\nconst carSchema = z.object({\n nextToken: nextToken(C),\n pickupLocation: id().optional().describe(p(C, \"pickupLocation\")),\n dropoffLocation: id().optional().describe(p(C, \"dropoffLocation\")),\n pickupDate: z.string().optional().describe(p(C, \"pickupDate\")),\n dropoffDate: z.string().optional().describe(p(C, \"dropoffDate\")),\n pickupTime: z.string().optional().describe(p(C, \"pickupTime\")),\n dropoffTime: z.string().optional().describe(p(C, \"dropoffTime\")),\n driverAge: z.number().int().min(18).max(99).optional().describe(p(C, \"driverAge\")),\n carClass: z.enum(carClasses).optional().describe(p(C, \"carClass\")),\n transmission: z.enum([\"automatic\", \"manual\"]).optional().describe(p(C, \"transmission\")),\n maxPrice: price(C, \"maxPrice\"),\n providers: z.array(z.string()).optional().describe(p(C, \"providers\")),\n agencies: z.array(z.string()).optional().describe(p(C, \"agencies\")),\n sortBy: z.enum([\"bestValue\", \"price\", \"rating\", \"distance\"]).optional().describe(p(C, \"sortBy\")),\n sortOrder: sortOrder(C),\n priceMode: z.enum([\"total\", \"perDay\"]).optional().describe(p(C, \"priceMode\")),\n country: country(C),\n});\n\nconst D = NAME.getDetails;\nconst detailsSchema = z.object({\n vertical: z.enum([\"flights\", \"hotels\", \"cars\"]).describe(p(D, \"vertical\")),\n token: z.string().min(1).describe(p(D, \"token\")),\n resultId: id().describe(p(D, \"resultId\")),\n});\n\nconst R = NAME.hotelReviews;\nconst reviewsSchema = z.object({\n hotelId: id().describe(p(R, \"hotelId\")),\n sortBy: z.enum([\"recent\", \"oldest\", \"highestScore\", \"lowestScore\"]).optional().describe(p(R, \"sortBy\")),\n travelerTypes: z\n .array(z.enum([\"families\", \"couples\", \"solo\", \"friends\", \"business\"]))\n .optional()\n .describe(p(R, \"travelerTypes\")),\n months: z.array(z.number().int().min(1).max(12)).optional().describe(p(R, \"months\")),\n sources: z.array(z.enum([\"booking\", \"agoda\", \"priceline\"])).optional().describe(p(R, \"sources\")),\n search: z.string().optional().describe(p(R, \"search\")),\n page: z.number().int().min(1).max(1000).optional().describe(p(R, \"page\")),\n});\n\nexport type LookupInput = z.infer<typeof lookupSchema>;\nexport type SearchFlightsInput = z.infer<typeof flightSchema>;\nexport type SearchHotelsInput = z.infer<typeof hotelSchema>;\nexport type SearchCarsInput = z.infer<typeof carSchema>;\nexport type GetDetailsInput = z.infer<typeof detailsSchema>;\nexport type HotelReviewsInput = z.infer<typeof reviewsSchema>;\n\n// ── Helpers ──────────────────────────────────────────────────────────────────\n\nfunction resolveClient(options: KtemiaToolOptions): Ktemia {\n const { client, ...rest } = options;\n return client ?? new Ktemia({ userAgent: `langchain-js/${VERSION}`, ...rest });\n}\n\n/** Runs a call and returns JSON for the model: the result, or the error it can act on. */\nasync function run(fn: () => Promise<unknown>): Promise<string> {\n try {\n return JSON.stringify(await fn());\n } catch (error) {\n if (error instanceof KtemiaError) return JSON.stringify({ error: error.toJSON() });\n throw error;\n }\n}\n\nfunction withHint(name: ToolName, page: SearchPage): SearchPage & { pagingHint: string } {\n const pagingHint = page.noResults\n ? \"The search matched nothing. Suggest other dates, a nearby airport, or fewer filters.\"\n : page.nextToken\n ? `More results are available. To read the next page, call ${name} with nextToken only.`\n : \"This is the last page of results.\";\n return { ...page, pagingHint };\n}\n\nconst str = (value: string | number | undefined): string => (value === undefined ? \"\" : String(value));\n\n// ── Tools ────────────────────────────────────────────────────────────────────\n\n/** Plan, rate limits, and remaining monthly quota. Free: never counts against the quota. */\nexport function keyStatus(options: KtemiaToolOptions = {}) {\n const kt = resolveClient(options);\n return tool(async (_input, config) => run(() => kt.keyStatus({ signal: config?.signal })), {\n name: NAME.keyStatus,\n description: toolDescription(NAME.keyStatus),\n schema: keyStatusSchema,\n });\n}\n\n/** Resolves place and airline names to the codes and location ids searches need. */\nexport function lookup(options: KtemiaToolOptions = {}) {\n const kt = resolveClient(options);\n return tool(async (input, config) => run(() => kt.lookup(input, { signal: config?.signal })), {\n name: NAME.lookup,\n description: toolDescription(NAME.lookup, [\"quotaNote\"]),\n schema: lookupSchema,\n });\n}\n\n/** Searches flights. Pass nextToken alone to read the next page. */\nexport function searchFlights(options: KtemiaToolOptions = {}) {\n const kt = resolveClient(options);\n return tool(\n async ({ nextToken, ...params }, config) =>\n run(async () => {\n const signal = config?.signal;\n return withHint(\n F,\n nextToken ? await kt.flights.page(nextToken, { signal }) : await kt.flights.search(params, { signal }),\n );\n }),\n { name: F, description: toolDescription(F, SEARCH_NOTES), schema: flightSchema },\n );\n}\n\n/** Searches hotels by locationId. Pass nextToken alone to read the next page. */\nexport function searchHotels(options: KtemiaToolOptions = {}) {\n const kt = resolveClient(options);\n return tool(\n async ({ nextToken, location, checkin, checkout, ...rest }, config) =>\n run(async () => {\n const signal = config?.signal;\n return withHint(\n H,\n nextToken\n ? await kt.hotels.page(nextToken, { signal })\n : await kt.hotels.search(\n { ...rest, location: str(location), checkin: str(checkin), checkout: str(checkout) },\n { signal },\n ),\n );\n }),\n { name: H, description: toolDescription(H, SEARCH_NOTES), schema: hotelSchema },\n );\n}\n\n/** Searches rental cars by locationId. Pass nextToken alone to read the next page. */\nexport function searchCars(options: KtemiaToolOptions = {}) {\n const kt = resolveClient(options);\n return tool(\n async ({ nextToken, pickupLocation, dropoffLocation, pickupDate, dropoffDate, ...rest }, config) =>\n run(async () => {\n const signal = config?.signal;\n return withHint(\n C,\n nextToken\n ? await kt.cars.page(nextToken, { signal })\n : await kt.cars.search(\n {\n ...rest,\n pickupLocation: str(pickupLocation),\n ...(dropoffLocation !== undefined ? { dropoffLocation: String(dropoffLocation) } : {}),\n pickupDate: str(pickupDate),\n dropoffDate: str(dropoffDate),\n },\n { signal },\n ),\n );\n }),\n { name: C, description: toolDescription(C, SEARCH_NOTES), schema: carSchema },\n );\n}\n\n/** Every price and booking link for one chosen result. */\nexport function getDetails(options: KtemiaToolOptions = {}) {\n const kt = resolveClient(options);\n return tool(\n async ({ vertical, token, resultId }, config) =>\n run(async () => ({\n vertical,\n ...(await kt[vertical].details(token, String(resultId), { signal: config?.signal })),\n })),\n {\n name: D,\n description: toolDescription(D, [\"tokenLifetimeNote\", \"quotaNote\", \"searchNotBookNote\"]),\n schema: detailsSchema,\n },\n );\n}\n\n/** Guest reviews for one hotel, with filters and numbered pages. */\nexport function hotelReviews(options: KtemiaToolOptions = {}) {\n const kt = resolveClient(options);\n return tool(\n async ({ hotelId, ...rest }, config) =>\n run(() => kt.hotels.reviews({ ...rest, hotelId: String(hotelId) }, { signal: config?.signal })),\n { name: R, description: toolDescription(R, [\"quotaNote\"]), schema: reviewsSchema },\n );\n}\n\n/**\n * All seven Ktemia tools, sharing one client.\n *\n * ```ts\n * import { createAgent } from \"langchain\";\n * import { ktemiaTools } from \"@ktemia/langchain\";\n *\n * const agent = createAgent({ model: \"openai:gpt-5-mini\", tools: ktemiaTools() });\n * ```\n */\nexport function ktemiaTools(options: KtemiaToolOptions = {}): StructuredToolInterface[] {\n const shared = { client: resolveClient(options) };\n return [\n keyStatus(shared),\n lookup(shared),\n searchFlights(shared),\n searchHotels(shared),\n searchCars(shared),\n getDetails(shared),\n hotelReviews(shared),\n ];\n}\n\n/** The seven Ktemia tools as a LangChain toolkit. Same tools as {@link ktemiaTools}. */\nexport class KtemiaToolkit extends BaseToolkit {\n tools: StructuredToolInterface[];\n\n constructor(options: KtemiaToolOptions = {}) {\n super();\n this.tools = ktemiaTools(options);\n }\n}\n\nexport { Ktemia, KtemiaError } from \"ktemia\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,mBAAgE;AAChE,iBAAkB;AAClB,oBAUO;AAsUP,IAAAA,iBAAoC;AApU7B,IAAM,UAAU;AAOvB,IAAM,OAAO;AAAA,EACX,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,cAAc;AAChB;AAEA,IAAM,eAAe,CAAC,qBAAqB,qBAAqB,aAAa,mBAAmB;AAKhG,IAAM,KAAK,MAAM,aAAE,MAAM,CAAC,aAAE,OAAO,EAAE,IAAI,CAAC,GAAG,aAAE,OAAO,CAAC,CAAC;AAMxD,IAAM,QAAQ,CAAC,GAAa,UAC1B,aACG,OAAO,EACP,OAAO,CAAC,M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