@ai-me-chat/core 0.0.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/dist/index.js ADDED
@@ -0,0 +1,621 @@
1
+ // src/tools/generate-tools.ts
2
+ import { z } from "zod";
3
+ var DEFAULT_WRITE_METHODS = ["POST", "PUT", "PATCH", "DELETE"];
4
+ function generateToolDefinitions(routes, confirmation) {
5
+ const confirmMethods = confirmation?.methods ?? DEFAULT_WRITE_METHODS;
6
+ const tools = [];
7
+ for (const route of routes) {
8
+ for (const method of route.methods) {
9
+ const toolName = buildToolName(method, route.path);
10
+ const description = `${method} ${route.path}`;
11
+ tools.push({
12
+ name: toolName,
13
+ description,
14
+ parameters: buildParametersSchema(method, route.pathParams),
15
+ requiresConfirmation: confirmMethods.includes(method),
16
+ httpMethod: method,
17
+ path: route.path
18
+ });
19
+ }
20
+ }
21
+ return tools;
22
+ }
23
+ function buildToolName(method, routePath) {
24
+ const pathPart = routePath.replace(/^\/api\//, "").replace(/:/g, "").replace(/\*/g, "").replace(/\//g, "_").replace(/_+/g, "_").replace(/_$/, "");
25
+ return `${method.toLowerCase()}_${pathPart}`;
26
+ }
27
+ function generateToolDefinitionsWithSchemas(routes, schemas, confirmation) {
28
+ const confirmMethods = confirmation?.methods ?? DEFAULT_WRITE_METHODS;
29
+ const tools = [];
30
+ for (const route of routes) {
31
+ const fileSchemas = schemas.get(route.filePath) ?? [];
32
+ for (const method of route.methods) {
33
+ const toolName = buildToolName(method, route.path);
34
+ const description = `${method} ${route.path}`;
35
+ const matchingSchema = pickBestSchema(fileSchemas, method);
36
+ tools.push({
37
+ name: toolName,
38
+ description,
39
+ parameters: matchingSchema ? buildParametersSchemaFromExtracted(method, route.pathParams, matchingSchema) : buildParametersSchema(method, route.pathParams),
40
+ requiresConfirmation: confirmMethods.includes(method),
41
+ httpMethod: method,
42
+ path: route.path
43
+ });
44
+ }
45
+ }
46
+ return tools;
47
+ }
48
+ function pickBestSchema(fileSchemas, method) {
49
+ const exact = fileSchemas.find((s) => s.method === method);
50
+ if (exact) return exact;
51
+ if (method === "GET") {
52
+ return fileSchemas.find(
53
+ (s) => s.exportName.toLowerCase().includes("query") || s.exportName.toLowerCase().includes("search")
54
+ );
55
+ }
56
+ if (["POST", "PUT", "PATCH"].includes(method)) {
57
+ return fileSchemas.find(
58
+ (s) => s.exportName.toLowerCase().includes("body") || s.exportName.toLowerCase().includes("request")
59
+ );
60
+ }
61
+ return void 0;
62
+ }
63
+ function buildParametersSchemaFromExtracted(method, pathParams, extracted) {
64
+ const shape = {};
65
+ for (const param of pathParams) {
66
+ shape[param] = z.string().describe(`Path parameter: ${param}`);
67
+ }
68
+ const props = extracted.jsonSchema["properties"];
69
+ const requiredFields = new Set(
70
+ Array.isArray(extracted.jsonSchema["required"]) ? extracted.jsonSchema["required"] : []
71
+ );
72
+ if (props) {
73
+ const innerShape = {};
74
+ for (const [key, propSchema] of Object.entries(props)) {
75
+ const zodField = jsonSchemaScalarToZod(propSchema);
76
+ innerShape[key] = requiredFields.has(key) ? zodField : zodField.optional();
77
+ }
78
+ if (method === "GET") {
79
+ shape["query"] = z.object(innerShape).optional().describe("Query parameters");
80
+ } else if (["POST", "PUT", "PATCH"].includes(method)) {
81
+ shape["body"] = z.object(innerShape).optional().describe("Request body");
82
+ }
83
+ } else {
84
+ if (method === "GET") {
85
+ shape["query"] = z.object({}).passthrough().optional().describe("Query string parameters");
86
+ } else if (["POST", "PUT", "PATCH"].includes(method)) {
87
+ shape["body"] = z.object({}).passthrough().optional().describe("Request body (JSON object with any properties)");
88
+ }
89
+ }
90
+ return z.object(shape);
91
+ }
92
+ function jsonSchemaScalarToZod(schema) {
93
+ const anyOf = schema["anyOf"];
94
+ if (Array.isArray(anyOf)) {
95
+ const nonNull = anyOf.filter(
96
+ (s) => s["type"] !== "null"
97
+ );
98
+ if (nonNull.length === 1 && nonNull[0]) {
99
+ return jsonSchemaScalarToZod(nonNull[0]);
100
+ }
101
+ return z.unknown();
102
+ }
103
+ if (Array.isArray(schema["enum"])) {
104
+ const values = schema["enum"];
105
+ if (values.every((v) => typeof v === "string") && values.length >= 2) {
106
+ const [first, second, ...rest] = values;
107
+ return z.enum([first, second, ...rest]);
108
+ }
109
+ }
110
+ switch (schema["type"]) {
111
+ case "string":
112
+ return z.string();
113
+ case "number":
114
+ case "integer":
115
+ return z.number();
116
+ case "boolean":
117
+ return z.boolean();
118
+ case "array": {
119
+ const items = schema["items"];
120
+ return items ? z.array(jsonSchemaScalarToZod(items)) : z.array(z.unknown());
121
+ }
122
+ case "object":
123
+ return z.record(z.string(), z.unknown());
124
+ default:
125
+ return z.unknown();
126
+ }
127
+ }
128
+ function buildParametersSchema(method, pathParams) {
129
+ const shape = {};
130
+ for (const param of pathParams) {
131
+ shape[param] = z.string().describe(`Path parameter: ${param}`);
132
+ }
133
+ if (method === "GET") {
134
+ shape["query"] = z.record(z.string(), z.string()).optional().describe("Query string parameters");
135
+ } else if (["POST", "PUT", "PATCH"].includes(method)) {
136
+ shape["body"] = z.record(z.string(), z.unknown()).optional().describe("Request body");
137
+ }
138
+ return z.object(shape);
139
+ }
140
+
141
+ // src/tools/schema-extractor.ts
142
+ function extractSchemasFromFile(_filePath, fileContent) {
143
+ const results = [];
144
+ const exportPattern = /export\s+const\s+(\w+)\s*=\s*z\.object\s*\(\s*\{([^]*?)\}\s*\)/g;
145
+ let match;
146
+ while ((match = exportPattern.exec(fileContent)) !== null) {
147
+ const exportName = match[1];
148
+ const objectBody = match[2];
149
+ if (!exportName) continue;
150
+ const jsonSchema = buildJsonSchema(objectBody);
151
+ const method = inferMethod(exportName);
152
+ results.push({ exportName, jsonSchema, method });
153
+ }
154
+ return results;
155
+ }
156
+ function inferMethod(exportName) {
157
+ const lower = exportName.toLowerCase();
158
+ if (lower.includes("body") || lower.includes("request")) return "POST";
159
+ if (lower.includes("query") || lower.includes("search")) return "GET";
160
+ return void 0;
161
+ }
162
+ function buildJsonSchema(objectBody) {
163
+ const properties = {};
164
+ const required = [];
165
+ const fields = splitFields(objectBody);
166
+ for (const field of fields) {
167
+ const fieldMatch = field.match(/^\s*(\w+)\s*:\s*(.+?)\s*$/s);
168
+ if (!fieldMatch) continue;
169
+ const fieldName = fieldMatch[1];
170
+ const typeExpr = fieldMatch[2];
171
+ if (!fieldName || !typeExpr) continue;
172
+ const { schema, isOptional } = parseZodType(typeExpr.trim());
173
+ properties[fieldName] = schema;
174
+ if (!isOptional) {
175
+ required.push(fieldName);
176
+ }
177
+ }
178
+ const jsonSchema = {
179
+ type: "object",
180
+ properties
181
+ };
182
+ if (required.length > 0) {
183
+ jsonSchema["required"] = required;
184
+ }
185
+ return jsonSchema;
186
+ }
187
+ function splitFields(body) {
188
+ const fields = [];
189
+ let depth = 0;
190
+ let current = "";
191
+ for (const char of body) {
192
+ if (char === "(" || char === "[" || char === "{") {
193
+ depth++;
194
+ current += char;
195
+ } else if (char === ")" || char === "]" || char === "}") {
196
+ depth--;
197
+ current += char;
198
+ } else if (char === "," && depth === 0) {
199
+ const trimmed2 = current.trim();
200
+ if (trimmed2) fields.push(trimmed2);
201
+ current = "";
202
+ } else {
203
+ current += char;
204
+ }
205
+ }
206
+ const trimmed = current.trim();
207
+ if (trimmed) fields.push(trimmed);
208
+ return fields;
209
+ }
210
+ function parseZodType(expr) {
211
+ const { base, modifiers } = tokeniseExpr(expr);
212
+ let schema = resolveBaseType(base);
213
+ let isOptional = false;
214
+ for (const mod of modifiers) {
215
+ if (mod.startsWith(".optional")) {
216
+ isOptional = true;
217
+ schema = { anyOf: [schema, { type: "null" }] };
218
+ } else if (mod.startsWith(".nullable")) {
219
+ schema = { anyOf: [schema, { type: "null" }] };
220
+ } else if (mod.startsWith(".array")) {
221
+ schema = { type: "array", items: schema };
222
+ } else if (mod.startsWith(".default")) {
223
+ isOptional = true;
224
+ }
225
+ }
226
+ return { schema, isOptional };
227
+ }
228
+ function tokeniseExpr(expr) {
229
+ const modifiers = [];
230
+ let rest = expr.trim();
231
+ let depth = 0;
232
+ let baseEnd = 0;
233
+ let foundBase = false;
234
+ for (let i = 0; i < rest.length; i++) {
235
+ const ch = rest[i];
236
+ if (ch === "(") depth++;
237
+ else if (ch === ")") {
238
+ depth--;
239
+ if (depth === 0) {
240
+ baseEnd = i + 1;
241
+ foundBase = true;
242
+ break;
243
+ }
244
+ }
245
+ }
246
+ if (!foundBase) {
247
+ return { base: rest, modifiers: [] };
248
+ }
249
+ const base = rest.slice(0, baseEnd);
250
+ rest = rest.slice(baseEnd);
251
+ while (rest.startsWith(".")) {
252
+ depth = 0;
253
+ let modEnd = 0;
254
+ let foundMod = false;
255
+ for (let i = 1; i < rest.length; i++) {
256
+ const ch = rest[i];
257
+ if (ch === "(") depth++;
258
+ else if (ch === ")") {
259
+ depth--;
260
+ if (depth === 0) {
261
+ modEnd = i + 1;
262
+ foundMod = true;
263
+ break;
264
+ }
265
+ }
266
+ }
267
+ if (!foundMod) break;
268
+ modifiers.push(rest.slice(0, modEnd));
269
+ rest = rest.slice(modEnd);
270
+ }
271
+ return { base, modifiers };
272
+ }
273
+ function resolveBaseType(base) {
274
+ const trimmed = base.trim();
275
+ if (trimmed.startsWith("z.string")) return { type: "string" };
276
+ if (trimmed.startsWith("z.number")) return { type: "number" };
277
+ if (trimmed.startsWith("z.boolean")) return { type: "boolean" };
278
+ if (trimmed.startsWith("z.null")) return { type: "null" };
279
+ if (trimmed.startsWith("z.unknown") || trimmed.startsWith("z.any"))
280
+ return {};
281
+ if (trimmed.startsWith("z.enum")) {
282
+ const enumValues = extractEnumValues(trimmed);
283
+ return { type: "string", enum: enumValues };
284
+ }
285
+ if (trimmed.startsWith("z.array")) {
286
+ const inner = extractSingleArg(trimmed);
287
+ if (inner) {
288
+ const { schema: items } = parseZodType(inner);
289
+ return { type: "array", items };
290
+ }
291
+ return { type: "array" };
292
+ }
293
+ if (trimmed.startsWith("z.object")) {
294
+ return { type: "object" };
295
+ }
296
+ if (trimmed.startsWith("z.record")) return { type: "object" };
297
+ if (trimmed.startsWith("z.literal")) {
298
+ const val = extractLiteralValue(trimmed);
299
+ return val !== void 0 ? { const: val } : {};
300
+ }
301
+ return {};
302
+ }
303
+ function extractEnumValues(expr) {
304
+ const inner = extractSingleArg(expr);
305
+ if (!inner) return [];
306
+ const values = [];
307
+ const valuePattern = /["']([^"']+)["']/g;
308
+ let m;
309
+ while ((m = valuePattern.exec(inner)) !== null) {
310
+ if (m[1]) values.push(m[1]);
311
+ }
312
+ return values;
313
+ }
314
+ function extractSingleArg(expr) {
315
+ const openParen = expr.indexOf("(");
316
+ if (openParen === -1) return null;
317
+ let depth = 0;
318
+ for (let i = openParen; i < expr.length; i++) {
319
+ const ch = expr[i];
320
+ if (ch === "(") depth++;
321
+ else if (ch === ")") {
322
+ depth--;
323
+ if (depth === 0) {
324
+ return expr.slice(openParen + 1, i);
325
+ }
326
+ }
327
+ }
328
+ return null;
329
+ }
330
+ function extractLiteralValue(expr) {
331
+ const inner = extractSingleArg(expr)?.trim();
332
+ if (!inner) return void 0;
333
+ if (inner.startsWith('"') && inner.endsWith('"') || inner.startsWith("'") && inner.endsWith("'")) {
334
+ return inner.slice(1, -1);
335
+ }
336
+ if (inner === "true") return true;
337
+ if (inner === "false") return false;
338
+ const num = Number(inner);
339
+ if (!Number.isNaN(num)) return num;
340
+ return void 0;
341
+ }
342
+
343
+ // src/tools/openapi-parser.ts
344
+ import { z as z2 } from "zod";
345
+ var HTTP_METHODS = /* @__PURE__ */ new Set([
346
+ "get",
347
+ "post",
348
+ "put",
349
+ "patch",
350
+ "delete",
351
+ "head",
352
+ "options",
353
+ "trace"
354
+ ]);
355
+ var DEFAULT_WRITE_METHODS2 = ["POST", "PUT", "PATCH", "DELETE"];
356
+ function parseOpenAPISpec(spec) {
357
+ const routes = [];
358
+ for (const [rawPath, pathItem] of Object.entries(spec.paths ?? {})) {
359
+ const methods = [];
360
+ for (const key of Object.keys(pathItem)) {
361
+ if (HTTP_METHODS.has(key.toLowerCase())) {
362
+ methods.push(key.toUpperCase());
363
+ }
364
+ }
365
+ if (methods.length === 0) continue;
366
+ const expressPath = openApiPathToExpress(rawPath);
367
+ const pathParams = extractPathParams(rawPath);
368
+ routes.push({
369
+ path: expressPath,
370
+ methods,
371
+ pathParams,
372
+ // No real file path — use the spec path as a synthetic identifier.
373
+ filePath: `openapi:${rawPath}`
374
+ });
375
+ }
376
+ return routes;
377
+ }
378
+ function generateToolsFromOpenAPI(spec, confirmation) {
379
+ const confirmMethods = confirmation?.methods ?? DEFAULT_WRITE_METHODS2;
380
+ const tools = [];
381
+ for (const [rawPath, pathItem] of Object.entries(spec.paths ?? {})) {
382
+ for (const [methodKey, operation] of Object.entries(pathItem)) {
383
+ if (!HTTP_METHODS.has(methodKey.toLowerCase())) continue;
384
+ const method = methodKey.toUpperCase();
385
+ const op = operation;
386
+ const toolName = buildToolName2(method, rawPath, op.operationId);
387
+ const description = buildDescription(method, rawPath, op);
388
+ const expressPath = openApiPathToExpress(rawPath);
389
+ const parameters = buildZodSchema(method, rawPath, op, spec);
390
+ tools.push({
391
+ name: toolName,
392
+ description,
393
+ parameters,
394
+ requiresConfirmation: confirmMethods.includes(method),
395
+ httpMethod: method,
396
+ path: expressPath
397
+ });
398
+ }
399
+ }
400
+ return tools;
401
+ }
402
+ async function fetchOpenAPISpec(url) {
403
+ const response = await fetch(url);
404
+ if (!response.ok) {
405
+ throw new Error(`Failed to fetch OpenAPI spec: ${response.status} ${response.statusText}`);
406
+ }
407
+ const spec = await response.json();
408
+ return spec;
409
+ }
410
+ function buildToolName2(method, rawPath, operationId) {
411
+ if (operationId) {
412
+ return operationId.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[-\s]+/g, "_").toLowerCase().replace(/_+/g, "_").replace(/^_|_$/g, "");
413
+ }
414
+ const pathPart = rawPath.replace(/^\//, "").replace(/\{([^}]+)\}/g, "$1").replace(/\//g, "_").replace(/_+/g, "_").replace(/_$/, "");
415
+ return `${method.toLowerCase()}_${pathPart}`;
416
+ }
417
+ function buildDescription(method, rawPath, op) {
418
+ if (op.summary) return op.summary;
419
+ if (op.description) return op.description;
420
+ return `${method} ${rawPath}`;
421
+ }
422
+ function openApiPathToExpress(path) {
423
+ return path.replace(/\{([^}]+)\}/g, ":$1");
424
+ }
425
+ function extractPathParams(path) {
426
+ const params = [];
427
+ const re = /\{([^}]+)\}/g;
428
+ let m;
429
+ while ((m = re.exec(path)) !== null) {
430
+ if (m[1]) params.push(m[1]);
431
+ }
432
+ return params;
433
+ }
434
+ function buildZodSchema(method, rawPath, op, spec) {
435
+ const shape = {};
436
+ for (const paramName of extractPathParams(rawPath)) {
437
+ shape[paramName] = z2.string().describe(`Path parameter: ${paramName}`);
438
+ }
439
+ for (const param of op.parameters ?? []) {
440
+ if (param.in !== "path" && param.in !== "query") continue;
441
+ if (param.in === "path") {
442
+ if (param.description) {
443
+ shape[param.name] = z2.string().describe(param.description);
444
+ }
445
+ continue;
446
+ }
447
+ const resolved = resolveSchema(param.schema ?? {}, spec);
448
+ let zodField = jsonSchemaToZod(resolved);
449
+ if (param.description) zodField = zodField.describe(param.description);
450
+ shape[param.name] = param.required ? zodField : zodField.optional();
451
+ }
452
+ if (["POST", "PUT", "PATCH"].includes(method) && op.requestBody) {
453
+ const jsonContent = op.requestBody.content["application/json"] ?? Object.values(op.requestBody.content)[0];
454
+ if (jsonContent?.schema) {
455
+ const resolved = resolveSchema(jsonContent.schema, spec);
456
+ const bodySchema = jsonSchemaObjectToZod(resolved, spec);
457
+ shape["body"] = op.requestBody.required ? bodySchema : bodySchema.optional();
458
+ } else {
459
+ shape["body"] = z2.record(z2.string(), z2.unknown()).optional().describe("Request body");
460
+ }
461
+ }
462
+ return z2.object(shape);
463
+ }
464
+ function resolveSchema(schema, spec) {
465
+ const ref = schema["$ref"];
466
+ if (typeof ref !== "string") return schema;
467
+ const prefix = "#/components/schemas/";
468
+ if (!ref.startsWith(prefix)) return schema;
469
+ const schemaName = ref.slice(prefix.length);
470
+ const resolved = spec.components?.schemas?.[schemaName];
471
+ return resolved ?? schema;
472
+ }
473
+ function jsonSchemaObjectToZod(schema, spec) {
474
+ if (schema["type"] !== "object") {
475
+ return jsonSchemaToZod(schema);
476
+ }
477
+ const props = schema["properties"];
478
+ if (!props) {
479
+ return z2.record(z2.string(), z2.unknown()).describe("Request body");
480
+ }
481
+ const required = new Set(
482
+ Array.isArray(schema["required"]) ? schema["required"] : []
483
+ );
484
+ const shape = {};
485
+ for (const [propName, propSchema] of Object.entries(props)) {
486
+ const resolved = resolveSchema(propSchema, spec);
487
+ const zodField = jsonSchemaToZod(resolved);
488
+ shape[propName] = required.has(propName) ? zodField : zodField.optional();
489
+ }
490
+ return z2.object(shape);
491
+ }
492
+ function jsonSchemaToZod(schema) {
493
+ const type = schema["type"];
494
+ const anyOf = schema["anyOf"] ?? schema["oneOf"];
495
+ if (Array.isArray(anyOf) && anyOf.length >= 2) {
496
+ const members = anyOf.map(
497
+ (s) => jsonSchemaToZod(s)
498
+ );
499
+ const [first, second, ...rest] = members;
500
+ return z2.union([first, second, ...rest]);
501
+ }
502
+ if (schema["enum"] !== void 0) {
503
+ const values = schema["enum"];
504
+ if (values.every((v) => typeof v === "string")) {
505
+ const [first, second, ...rest] = values;
506
+ if (first !== void 0 && second !== void 0) {
507
+ return z2.enum([first, second, ...rest]);
508
+ }
509
+ if (first !== void 0) return z2.literal(first);
510
+ }
511
+ return z2.unknown();
512
+ }
513
+ switch (type) {
514
+ case "string":
515
+ return z2.string();
516
+ case "number":
517
+ case "integer":
518
+ return z2.number();
519
+ case "boolean":
520
+ return z2.boolean();
521
+ case "null":
522
+ return z2.null();
523
+ case "array": {
524
+ const items = schema["items"];
525
+ return items ? z2.array(jsonSchemaToZod(items)) : z2.array(z2.unknown());
526
+ }
527
+ case "object": {
528
+ const props = schema["properties"];
529
+ if (!props) return z2.record(z2.string(), z2.unknown());
530
+ const required = new Set(
531
+ Array.isArray(schema["required"]) ? schema["required"] : []
532
+ );
533
+ const innerShape = {};
534
+ for (const [k, v] of Object.entries(props)) {
535
+ const field = jsonSchemaToZod(v);
536
+ innerShape[k] = required.has(k) ? field : field.optional();
537
+ }
538
+ return z2.object(innerShape);
539
+ }
540
+ default:
541
+ return z2.unknown();
542
+ }
543
+ }
544
+
545
+ // src/executor.ts
546
+ async function executeTool(tool, params, context) {
547
+ const id = crypto.randomUUID();
548
+ const startTime = /* @__PURE__ */ new Date();
549
+ try {
550
+ let response;
551
+ if (tool.execute) {
552
+ response = await tool.execute(params);
553
+ } else if (tool.httpMethod && tool.path) {
554
+ response = await executeHttpTool(tool, params, context);
555
+ } else {
556
+ throw new Error(`Tool "${tool.name}" has no execute function or HTTP path`);
557
+ }
558
+ return {
559
+ id,
560
+ toolName: tool.name,
561
+ parameters: params,
562
+ statusCode: 200,
563
+ response,
564
+ confirmed: !tool.requiresConfirmation,
565
+ executedAt: startTime
566
+ };
567
+ } catch (error) {
568
+ return {
569
+ id,
570
+ toolName: tool.name,
571
+ parameters: params,
572
+ statusCode: 500,
573
+ response: { error: error instanceof Error ? error.message : "Unknown error" },
574
+ confirmed: false,
575
+ executedAt: startTime
576
+ };
577
+ }
578
+ }
579
+ async function executeHttpTool(tool, params, context) {
580
+ const method = tool.httpMethod;
581
+ let url = `${context.baseUrl}${tool.path}`;
582
+ for (const [key, value] of Object.entries(params)) {
583
+ if (url.includes(`:${key}`)) {
584
+ url = url.replace(`:${key}`, encodeURIComponent(String(value)));
585
+ }
586
+ }
587
+ const fetchOptions = {
588
+ method,
589
+ headers: {
590
+ "Content-Type": "application/json",
591
+ ...context.headers
592
+ }
593
+ };
594
+ if (method === "GET" && params.query) {
595
+ const queryParams = new URLSearchParams(
596
+ params.query
597
+ );
598
+ url += `?${queryParams.toString()}`;
599
+ } else if (["POST", "PUT", "PATCH"].includes(method) && params.body) {
600
+ fetchOptions.body = JSON.stringify(params.body);
601
+ }
602
+ const response = await fetch(url, fetchOptions);
603
+ if (!response.ok) {
604
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
605
+ }
606
+ const contentType = response.headers.get("content-type") ?? "";
607
+ if (contentType.includes("application/json")) {
608
+ return response.json();
609
+ }
610
+ return response.text();
611
+ }
612
+ export {
613
+ executeTool,
614
+ extractSchemasFromFile,
615
+ fetchOpenAPISpec,
616
+ generateToolDefinitions,
617
+ generateToolDefinitionsWithSchemas,
618
+ generateToolsFromOpenAPI,
619
+ parseOpenAPISpec
620
+ };
621
+ //# sourceMappingURL=index.js.map