@ai.ntellect/core 0.6.0 → 0.6.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.
@@ -0,0 +1,81 @@
1
+ export interface NetworkConfig {
2
+ name: string;
3
+ id?: number;
4
+ rpc: string;
5
+ explorerUrl: string;
6
+ nativeToken: string; // WETH
7
+ }
8
+ export const networkConfigs: Record<string, NetworkConfig> = {
9
+ ethereum: {
10
+ name: "Ethereum Mainnet",
11
+ id: 1,
12
+ rpc: "https://eth.llamarpc.com",
13
+ explorerUrl: "https://etherscan.io",
14
+ nativeToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
15
+ },
16
+ polygon: {
17
+ name: "Polygon Mainnet",
18
+ id: 137,
19
+ rpc: "https://polygon.llamarpc.com",
20
+ explorerUrl: "https://polygonscan.com",
21
+ nativeToken: "0x0000000000000000000000000000000000001010",
22
+ },
23
+ arbitrum: {
24
+ name: "Arbitrum Mainnet",
25
+ id: 42161,
26
+ rpc: "https://arbitrum.llamarpc.com",
27
+ explorerUrl: "https://arbiscan.io",
28
+ nativeToken: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
29
+ },
30
+ base: {
31
+ name: "Base Mainnet",
32
+ id: 8453,
33
+ rpc: "https://base.llamarpc.com",
34
+ explorerUrl: "https://basescan.org",
35
+ nativeToken: "0x4200000000000000000000000000000000000006",
36
+ },
37
+ solana: {
38
+ name: "Solana Mainnet",
39
+ rpc: "https://api.mainnet-beta.solana.com",
40
+ explorerUrl: "https://solscan.io",
41
+ nativeToken: "So11111111111111111111111111111111111111112",
42
+ },
43
+ sepolia: {
44
+ name: "Sepolia Testnet",
45
+ id: 11155111,
46
+ rpc: "https://rpc.sepolia.ethpandaops.io",
47
+ explorerUrl: "https://sepolia.etherscan.io",
48
+ nativeToken: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14",
49
+ },
50
+ baseSepolia: {
51
+ name: "Base Sepolia Testnet",
52
+ id: 84532,
53
+ rpc: "https://base-sepolia-rpc.publicnode.com",
54
+ explorerUrl: "https://sepolia.basescan.org",
55
+ nativeToken: "0x4200000000000000000000000000000000000006",
56
+ },
57
+ };
58
+
59
+ export const getNetworkProvider = (networkName: string) => {
60
+ const config = networkConfigs[networkName.toLowerCase()];
61
+ if (!config) {
62
+ throw new Error(`Network ${networkName} not supported`);
63
+ }
64
+ return { config };
65
+ };
66
+
67
+ export const ROUTER_ADDRESSES: { [key: string]: string } = {
68
+ ethereum: "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
69
+ sepolia: "0xeE567Fe1712Faf6149d80dA1E6934E354124CfE3",
70
+ arbitrum: "0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24",
71
+ polygon: "0xedf6066a2b290C185783862C7F4776A2C8077AD1",
72
+ base: "0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24",
73
+ optimism: "0x4A7b5Da61326A6379179b40d00F57E5bbDC962c2",
74
+ blast: "0xBB66Eb1c5e875933D44DAe661dbD80e5D9B03035",
75
+ zora: "0xa00F34A632630EFd15223B1968358bA4845bEEC7",
76
+ worldchain: "0x541aB7c31A119441eF3575F6973277DE0eF460bd",
77
+ };
78
+
79
+ export const getRouterAddress = (networkName: string) => {
80
+ return ROUTER_ADDRESSES[networkName.toLowerCase()];
81
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai.ntellect/core",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -35,11 +35,9 @@ describe("Graph", () => {
35
35
  description: "Starting node",
36
36
  execute: async (_params: any, state: SharedState<TestState>) => {
37
37
  return graph.updateState({
38
- context: {
39
- ...state.context,
40
- status: "started",
41
- step: 1,
42
- },
38
+ ...state.context,
39
+ status: "started",
40
+ step: 1,
43
41
  });
44
42
  },
45
43
  relationships: [{ name: "process" }],
@@ -49,11 +47,9 @@ describe("Graph", () => {
49
47
  description: "Processing node",
50
48
  execute: async (_params: any, state: SharedState<TestState>) => {
51
49
  return graph.updateState({
52
- context: {
53
- ...state.context,
54
- status: "processing",
55
- step: 2,
56
- },
50
+ ...state.context,
51
+ status: "processing",
52
+ step: 2,
57
53
  });
58
54
  },
59
55
  condition: (state) => state.context.step === 1,
@@ -64,11 +60,9 @@ describe("Graph", () => {
64
60
  description: "End node",
65
61
  execute: async (_params: any, state: SharedState<TestState>) => {
66
62
  return graph.updateState({
67
- context: {
68
- ...state.context,
69
- status: "completed",
70
- step: 3,
71
- },
63
+ ...state.context,
64
+ status: "completed",
65
+ step: 3,
72
66
  });
73
67
  },
74
68
  relationships: [],
@@ -145,18 +139,15 @@ describe("Graph", () => {
145
139
  description: "A new test node",
146
140
  execute: async (_params: any, state: SharedState<TestState>) => {
147
141
  return graph.updateState({
148
- context: {
149
- ...state.context,
150
- status: "new",
151
- step: 4,
152
- },
142
+ ...state.context,
143
+ status: "new",
144
+ step: 4,
153
145
  });
154
146
  },
147
+ relationships: [{ name: "end" }],
155
148
  };
156
149
 
157
- graph.addNode(newNode, {
158
- relationships: [{ name: "end" }],
159
- });
150
+ graph.addNode(newNode);
160
151
 
161
152
  expect(graph.nodes.has("new-node")).to.be.true;
162
153
  const addedNode = graph.nodes.get("new-node");
@@ -174,11 +165,9 @@ describe("Graph", () => {
174
165
  description: "New step node",
175
166
  execute: async (_params: any, state: SharedState<TestState>) => {
176
167
  return graph.updateState({
177
- context: {
178
- ...state.context,
179
- status: "new-step",
180
- step: 4,
181
- },
168
+ ...state.context,
169
+ status: "new-step",
170
+ step: 4,
182
171
  });
183
172
  },
184
173
  relationships: [],
@@ -218,9 +207,7 @@ describe("Graph", () => {
218
207
  graph.setState(initialState);
219
208
 
220
209
  const partialUpdate = {
221
- context: {
222
- status: "updated",
223
- },
210
+ status: "updated",
224
211
  };
225
212
 
226
213
  const updatedState = graph.updateState(partialUpdate);
@@ -241,7 +228,7 @@ describe("Graph", () => {
241
228
  },
242
229
  };
243
230
 
244
- graph.addNode(errorNode, {});
231
+ graph.addNode(errorNode);
245
232
 
246
233
  let errorCaught = false;
247
234
  try {
@@ -316,7 +303,7 @@ describe("Graph", () => {
316
303
  }));
317
304
 
318
305
  parallelNodes.forEach((node) => {
319
- graph.addNode(node, {});
306
+ graph.addNode(node);
320
307
  });
321
308
 
322
309
  await graph.executeParallel(
@@ -341,17 +328,15 @@ describe("Graph", () => {
341
328
  name: "event-node",
342
329
  execute: async (_params: any, state: SharedState<TestState>) => {
343
330
  return graph.updateState({
344
- context: {
345
- ...state.context,
346
- status: "event-triggered",
347
- step: 10,
348
- },
331
+ ...state.context,
332
+ status: "event-triggered",
333
+ step: 10,
349
334
  });
350
335
  },
351
336
  events: ["test-event"],
352
337
  };
353
338
 
354
- graph.addNode(eventNode, { events: ["test-event"] });
339
+ graph.addNode(eventNode);
355
340
 
356
341
  // Émettre l'événement
357
342
  graph.emit("test-event", {
@@ -382,11 +367,9 @@ describe("Graph", () => {
382
367
  name: "sub-start",
383
368
  execute: async (_params: any, state: SharedState<TestState>) => {
384
369
  return graph.updateState({
385
- context: {
386
- ...state.context,
387
- status: "sub-completed",
388
- step: 100,
389
- },
370
+ ...state.context,
371
+ status: "sub-completed",
372
+ step: 100,
390
373
  });
391
374
  },
392
375
  relationships: [],
package/tsconfig.json CHANGED
@@ -12,5 +12,5 @@
12
12
  },
13
13
  "outDir": "./dist"
14
14
  },
15
- "exclude": ["examples"]
15
+ "exclude": ["node_modules", "examples", "test"]
16
16
  }
package/types/index.ts CHANGED
@@ -192,9 +192,7 @@ export type GraphDefinition<T> = {
192
192
  * @typedef {Object} SharedState
193
193
  * @property {Partial<T>} context - The execution context.
194
194
  */
195
- export type SharedState<T> = {
196
- context: Partial<T>;
197
- };
195
+ export type SharedState<T> = T;
198
196
 
199
197
  /**
200
198
  * Defines a graph node within a graph execution structure.
@@ -268,3 +266,13 @@ export type MeilisearchSettings = {
268
266
  searchableAttributes?: string[];
269
267
  sortableAttributes?: string[];
270
268
  };
269
+
270
+ /* ======================== ACTIONS ======================== */
271
+
272
+ export type Action = {
273
+ name: string;
274
+ parameters: {
275
+ name: string;
276
+ value: string;
277
+ }[];
278
+ };
@@ -0,0 +1,45 @@
1
+ import { GraphEngine } from "../graph/engine";
2
+ import { Action, GraphDefinition, SharedState } from "../types";
3
+
4
+ export function setupGraphsWithActions<T>(
5
+ actions: Action[],
6
+ baseStateMapping: Record<string, SharedState<T>>,
7
+ graphMaps: GraphDefinition<T>[]
8
+ ): {
9
+ initialStates: SharedState<T>[];
10
+ graphs: GraphEngine<T>[];
11
+ startNodes: string[];
12
+ } {
13
+ const initialStates = actions.map((action) => {
14
+ const parametersObject = Object.fromEntries(
15
+ action.parameters.map((param) => [
16
+ param.name,
17
+ param.value !== undefined ? param.value : null,
18
+ ]) // Handle optional values
19
+ );
20
+
21
+ const baseState = baseStateMapping[action.name] || {};
22
+
23
+ return {
24
+ ...baseState,
25
+ ...parametersObject,
26
+ };
27
+ });
28
+
29
+ const selectedGraphs = actions
30
+ .map((action) => graphMaps.find((graph) => graph.name === action.name))
31
+ .filter((graph): graph is GraphDefinition<T> => graph !== undefined);
32
+
33
+ if (selectedGraphs.length !== actions.length) {
34
+ throw new Error("Graph not found");
35
+ }
36
+
37
+ const startNodes = selectedGraphs.map((graph) => graph.entryNode);
38
+ const graphEngines = selectedGraphs.map((graph) => new GraphEngine(graph));
39
+
40
+ return {
41
+ initialStates: initialStates as SharedState<T>[],
42
+ graphs: graphEngines,
43
+ startNodes,
44
+ };
45
+ }
@@ -0,0 +1,45 @@
1
+ import { Node } from "@/types";
2
+ import { z } from "zod";
3
+
4
+ export const stringifyZodSchema = <T>(nodes: Node<T>[]) => {
5
+ return nodes
6
+ .map((node) => {
7
+ const schemaStr = node.schema
8
+ ? getSchemaString(node.schema)
9
+ : "No parameters";
10
+ return `Workflow: ${node.name}\nDescription: ${node.description}\nParameters: ${schemaStr}`;
11
+ })
12
+ .join("\n\n");
13
+ };
14
+
15
+ const getSchemaString = (schema: z.ZodType): string => {
16
+ if (schema instanceof z.ZodObject) {
17
+ const entries = Object.entries(schema.shape);
18
+ const fields = entries.map(([key, value]) => {
19
+ const description = (value as any)._def.description;
20
+ const schemaStr = getSchemaString(value as z.ZodType);
21
+ return description
22
+ ? `${key}: ${schemaStr} // ${description}`
23
+ : `${key}: ${schemaStr}`;
24
+ });
25
+ return `z.object({${fields.join(", ")}})`;
26
+ }
27
+
28
+ if (schema instanceof z.ZodArray) {
29
+ return `z.array(${getSchemaString(schema.element)})`;
30
+ }
31
+
32
+ if (schema instanceof z.ZodString) {
33
+ return "z.string()";
34
+ }
35
+
36
+ if (schema instanceof z.ZodNumber) {
37
+ return "z.number()";
38
+ }
39
+
40
+ if (schema instanceof z.ZodBoolean) {
41
+ return "z.boolean()";
42
+ }
43
+
44
+ return `z.unknown()`;
45
+ };
@@ -1,111 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.generateObject = exports.describeZodSchema = void 0;
13
- const ai_1 = require("ai");
14
- const zod_1 = require("zod");
15
- const describeZodSchema = (schema) => {
16
- if (schema instanceof zod_1.z.ZodObject) {
17
- const entries = Object.entries(schema.shape);
18
- const fields = entries.map(([key, value]) => {
19
- const description = value._def.description || "";
20
- const fieldSchema = (0, exports.describeZodSchema)(value);
21
- return description
22
- ? `${key}: ${fieldSchema} // ${description}`
23
- : `${key}: ${fieldSchema}`;
24
- });
25
- return `z.object({${fields.join(", ")}})`;
26
- }
27
- if (schema instanceof zod_1.z.ZodArray) {
28
- return `z.array(${(0, exports.describeZodSchema)(schema.element)})`;
29
- }
30
- if (schema instanceof zod_1.z.ZodString) {
31
- return "z.string()";
32
- }
33
- if (schema instanceof zod_1.z.ZodNumber) {
34
- return "z.number()";
35
- }
36
- if (schema instanceof zod_1.z.ZodBoolean) {
37
- return "z.boolean()";
38
- }
39
- if (schema instanceof zod_1.z.ZodOptional) {
40
- return `z.optional(${(0, exports.describeZodSchema)(schema._def.innerType)})`;
41
- }
42
- if (schema instanceof zod_1.z.ZodUnion) {
43
- return `z.union([${schema._def.options
44
- .map((option) => (0, exports.describeZodSchema)(option))
45
- .join(", ")}])`;
46
- }
47
- if (schema instanceof zod_1.z.ZodEnum) {
48
- return `z.enum(${JSON.stringify(schema._def.values)})`;
49
- }
50
- if (schema instanceof zod_1.z.ZodLiteral) {
51
- return `z.literal(${JSON.stringify(schema._def.value)})`;
52
- }
53
- return "z.unknown()"; // Fallback for unknown types
54
- };
55
- exports.describeZodSchema = describeZodSchema;
56
- const generateObject = (config) => __awaiter(void 0, void 0, void 0, function* () {
57
- var _a;
58
- // Generate a detailed description of the schema
59
- const schemaDescription = (0, exports.describeZodSchema)(config.schema);
60
- const baseContext = `
61
- ${config.system}
62
- EXPECTED SCHEMA:
63
- ${schemaDescription}
64
-
65
- BAD EXAMPLE:
66
- \`\`\`json
67
- {
68
- "key": "value"
69
- }
70
- \`\`\`
71
-
72
- GOOD EXAMPLE:
73
- {
74
- "key": "value"
75
- }
76
-
77
- OUTPUT ONLY THE JSON SCHEMA, NO 'TRIPLE QUOTES'JSON OR ANY OTHER TEXT. ONLY THE JSON SCHEMA.
78
- `;
79
- console.log("🔍 Generating object with context:");
80
- console.log(`${config.prompt}\n${baseContext}\n`);
81
- const response = yield (0, ai_1.generateText)({
82
- model: config.model,
83
- messages: !config.prompt
84
- ? [
85
- {
86
- role: "system",
87
- content: baseContext,
88
- },
89
- ...((_a = config.messages) !== null && _a !== void 0 ? _a : []),
90
- ]
91
- : undefined,
92
- system: config.system,
93
- temperature: config.temperature,
94
- prompt: !config.prompt ? undefined : `${config.prompt}\n\n${baseContext}`,
95
- });
96
- try {
97
- // Clean the response text from any markdown or code block markers
98
- const cleanText = response.text
99
- .replace(/```json\s*/g, "")
100
- .replace(/```\s*$/g, "")
101
- .trim();
102
- const parsedResponse = JSON.parse(cleanText);
103
- const validatedResponse = config.schema.parse(parsedResponse);
104
- return { object: validatedResponse };
105
- }
106
- catch (error) {
107
- console.error("Error parsing or validating JSON response:", error);
108
- throw new Error("Failed to generate valid JSON response");
109
- }
110
- });
111
- exports.generateObject = generateObject;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LLMHeaderBuilder = void 0;
4
- class LLMHeaderBuilder {
5
- constructor() {
6
- this.headers = new Map();
7
- this._result = "";
8
- }
9
- addHeader(key, value) {
10
- if (Array.isArray(value)) {
11
- this.headers.set(key, value.join("\n"));
12
- }
13
- else {
14
- this.headers.set(key, value);
15
- }
16
- // Build result immediately
17
- this._result = Array.from(this.headers.entries())
18
- .filter(([_, value]) => value !== undefined)
19
- .map(([key, value]) => `# ${key}: ${value}`)
20
- .join("\n")
21
- .trim();
22
- return this;
23
- }
24
- valueOf() {
25
- return this._result;
26
- }
27
- toString() {
28
- return this._result;
29
- }
30
- static create() {
31
- return new LLMHeaderBuilder();
32
- }
33
- }
34
- exports.LLMHeaderBuilder = LLMHeaderBuilder;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.injectActions = void 0;
4
- const injectActions = (actions) => {
5
- return actions.map((action) => {
6
- const parameters = action.parameters;
7
- const schemaShape = Object.keys(parameters._def.shape()).join(", ");
8
- const actionString = `* ${action.name}( { ${schemaShape} }) (${action.description}) ${action.examples
9
- ? `Eg: ${action.examples.map((example) => {
10
- return JSON.stringify(example);
11
- })}`
12
- : ""}`;
13
- return actionString;
14
- });
15
- };
16
- exports.injectActions = injectActions;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueueItemTransformer = void 0;
4
- class QueueItemTransformer {
5
- static transformActionToQueueItem(action) {
6
- return {
7
- name: action.name || "",
8
- parameters: QueueItemTransformer.transformParameters(action.parameters || {}),
9
- };
10
- }
11
- static transformFromSimilarActions(similarActions) {
12
- return similarActions === null || similarActions === void 0 ? void 0 : similarActions.map((action) => QueueItemTransformer.transformActionToQueueItem(action));
13
- }
14
- static transformParameters(parameters) {
15
- return Object.entries(parameters).map(([name, value]) => ({
16
- name,
17
- value: typeof value === "object" ? JSON.stringify(value) : String(value),
18
- }));
19
- }
20
- static transformActionsToQueueItems(actions) {
21
- return actions === null || actions === void 0 ? void 0 : actions.map((action) => this.transformActionToQueueItem(action));
22
- }
23
- }
24
- exports.QueueItemTransformer = QueueItemTransformer;
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResultSanitizer = void 0;
4
- /**
5
- * Utility class to sanitize JSON results for evaluation
6
- */
7
- class ResultSanitizer {
8
- /**
9
- * Sanitizes JSON results by removing special characters and formatting
10
- * @param results - The results to sanitize
11
- * @returns Sanitized string
12
- */
13
- static sanitize(results) {
14
- if (!results)
15
- return "";
16
- try {
17
- const jsonString = JSON.stringify(results);
18
- return (jsonString
19
- // Basic cleanup
20
- .replace(/\\n/g, " ") // Remove newlines
21
- .replace(/\s+/g, " ") // Remove extra spaces
22
- .replace(/\\"/g, '"') // Fix escaped quotes
23
- .replace(/\\+/g, "") // Remove extra backslashes
24
- // Remove unnecessary quotes around objects and arrays
25
- .replace(/"\[/g, "[") // Remove quotes around arrays start
26
- .replace(/\]"/g, "]") // Remove quotes around arrays end
27
- .replace(/"{/g, "{") // Remove quotes around objects start
28
- .replace(/}"/g, "}") // Remove quotes around objects end
29
- // Clean up numbers and values
30
- .replace(/"(\d+\.?\d*)"/g, "$1") // Remove quotes around numbers
31
- .replace(/:\s*"(true|false|null)"/g, ": $1") // Remove quotes around booleans and null
32
- // Clean up URLs and content
33
- .replace(/(?<=content":")([^"]+)(?=")/g, (match) => match.trim().replace(/\s+/g, " ") // Clean content spacing
34
- )
35
- .replace(/(?<=link":")([^"]+)(?=")/g, (match) => match.replace(/&amp;/g, "&") // Fix URL encodings
36
- )
37
- // Final cleanup
38
- .replace(/,\s*([}\]])/g, "$1") // Remove trailing commas
39
- .replace(/:\s+/g, ":") // Remove spaces after colons
40
- .replace(/,\s+/g, ",") // Remove spaces after commas
41
- .trim()); // Remove leading/trailing whitespace
42
- }
43
- catch (error) {
44
- console.error("Error sanitizing results:", error);
45
- return String(results);
46
- }
47
- }
48
- /**
49
- * Formats numbers to a consistent format
50
- * @param value - The number to format
51
- * @returns Formatted number string
52
- */
53
- static formatNumber(value) {
54
- return value.toLocaleString("en-US", {
55
- maximumFractionDigits: 2,
56
- useGrouping: false,
57
- });
58
- }
59
- }
60
- exports.ResultSanitizer = ResultSanitizer;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SchemaGenerator = void 0;
4
- const zod_1 = require("zod");
5
- class SchemaGenerator {
6
- static generate(config) {
7
- const { schema, instructions = "Output only the JSON schema, no 'triple quotes'json or any other text. Only the JSON schema.", outputExamples = [], } = config;
8
- const getSchemaString = (schema) => {
9
- if (schema instanceof zod_1.z.ZodObject) {
10
- const entries = Object.entries(schema.shape);
11
- const fields = entries.map(([key, value]) => {
12
- const description = value._def.description;
13
- const schemaStr = getSchemaString(value);
14
- return description
15
- ? `${key}: ${schemaStr} // ${description}`
16
- : `${key}: ${schemaStr}`;
17
- });
18
- return `z.object({${fields.join(", ")}})`;
19
- }
20
- if (schema instanceof zod_1.z.ZodArray) {
21
- return `z.array(${getSchemaString(schema.element)})`;
22
- }
23
- if (schema instanceof zod_1.z.ZodString) {
24
- return "z.string()";
25
- }
26
- if (schema instanceof zod_1.z.ZodNumber) {
27
- return "z.number()";
28
- }
29
- if (schema instanceof zod_1.z.ZodBoolean) {
30
- return "z.boolean()";
31
- }
32
- // Fallback for other Zod types
33
- return `z.unknown()`;
34
- };
35
- const schemaString = getSchemaString(schema);
36
- return {
37
- schema: schemaString,
38
- instructions,
39
- outputExamples: outputExamples
40
- .map((example) => `Input: ${JSON.stringify(example.input)}, Output: ${JSON.stringify(example.output)}`)
41
- .join("\n")
42
- .trim(),
43
- };
44
- }
45
- }
46
- exports.SchemaGenerator = SchemaGenerator;