@copilotkit/shared 1.9.2-next.7 → 1.9.2-next.8

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.
@@ -1,510 +0,0 @@
1
- "use strict";
2
-
3
- // src/utils/json-schema.test.ts
4
- var import_zod2 = require("zod");
5
-
6
- // src/utils/json-schema.ts
7
- var import_zod = require("zod");
8
- function actionParametersToJsonSchema(actionParameters) {
9
- let parameters = {};
10
- for (let parameter of actionParameters || []) {
11
- parameters[parameter.name] = convertAttribute(parameter);
12
- }
13
- let requiredParameterNames = [];
14
- for (let arg of actionParameters || []) {
15
- if (arg.required !== false) {
16
- requiredParameterNames.push(arg.name);
17
- }
18
- }
19
- return {
20
- type: "object",
21
- properties: parameters,
22
- required: requiredParameterNames
23
- };
24
- }
25
- function jsonSchemaToActionParameters(jsonSchema) {
26
- if (jsonSchema.type !== "object" || !jsonSchema.properties) {
27
- return [];
28
- }
29
- const parameters = [];
30
- const requiredFields = jsonSchema.required || [];
31
- for (const [name, schema] of Object.entries(jsonSchema.properties)) {
32
- const parameter = convertJsonSchemaToParameter(name, schema, requiredFields.includes(name));
33
- parameters.push(parameter);
34
- }
35
- return parameters;
36
- }
37
- function convertJsonSchemaToParameter(name, schema, isRequired) {
38
- const baseParameter = {
39
- name,
40
- description: schema.description
41
- };
42
- if (!isRequired) {
43
- baseParameter.required = false;
44
- }
45
- switch (schema.type) {
46
- case "string":
47
- return {
48
- ...baseParameter,
49
- type: "string",
50
- ...schema.enum && { enum: schema.enum }
51
- };
52
- case "number":
53
- case "boolean":
54
- return {
55
- ...baseParameter,
56
- type: schema.type
57
- };
58
- case "object":
59
- if (schema.properties) {
60
- const attributes = [];
61
- const requiredFields = schema.required || [];
62
- for (const [propName, propSchema] of Object.entries(schema.properties)) {
63
- attributes.push(
64
- convertJsonSchemaToParameter(propName, propSchema, requiredFields.includes(propName))
65
- );
66
- }
67
- return {
68
- ...baseParameter,
69
- type: "object",
70
- attributes
71
- };
72
- }
73
- return {
74
- ...baseParameter,
75
- type: "object"
76
- };
77
- case "array":
78
- if (schema.items.type === "object" && "properties" in schema.items) {
79
- const attributes = [];
80
- const requiredFields = schema.items.required || [];
81
- for (const [propName, propSchema] of Object.entries(schema.items.properties || {})) {
82
- attributes.push(
83
- convertJsonSchemaToParameter(propName, propSchema, requiredFields.includes(propName))
84
- );
85
- }
86
- return {
87
- ...baseParameter,
88
- type: "object[]",
89
- attributes
90
- };
91
- } else if (schema.items.type === "array") {
92
- throw new Error("Nested arrays are not supported");
93
- } else {
94
- return {
95
- ...baseParameter,
96
- type: `${schema.items.type}[]`
97
- };
98
- }
99
- default:
100
- return {
101
- ...baseParameter,
102
- type: "string"
103
- };
104
- }
105
- }
106
- function convertAttribute(attribute) {
107
- var _a, _b, _c;
108
- switch (attribute.type) {
109
- case "string":
110
- return {
111
- type: "string",
112
- description: attribute.description,
113
- ...attribute.enum && { enum: attribute.enum }
114
- };
115
- case "number":
116
- case "boolean":
117
- return {
118
- type: attribute.type,
119
- description: attribute.description
120
- };
121
- case "object":
122
- case "object[]":
123
- const properties = (_a = attribute.attributes) == null ? void 0 : _a.reduce(
124
- (acc, attr) => {
125
- acc[attr.name] = convertAttribute(attr);
126
- return acc;
127
- },
128
- {}
129
- );
130
- const required = (_b = attribute.attributes) == null ? void 0 : _b.filter((attr) => attr.required !== false).map((attr) => attr.name);
131
- if (attribute.type === "object[]") {
132
- return {
133
- type: "array",
134
- items: {
135
- type: "object",
136
- ...properties && { properties },
137
- ...required && required.length > 0 && { required }
138
- },
139
- description: attribute.description
140
- };
141
- }
142
- return {
143
- type: "object",
144
- description: attribute.description,
145
- ...properties && { properties },
146
- ...required && required.length > 0 && { required }
147
- };
148
- default:
149
- if ((_c = attribute.type) == null ? void 0 : _c.endsWith("[]")) {
150
- const itemType = attribute.type.slice(0, -2);
151
- return {
152
- type: "array",
153
- items: { type: itemType },
154
- description: attribute.description
155
- };
156
- }
157
- return {
158
- type: "string",
159
- description: attribute.description
160
- };
161
- }
162
- }
163
- function convertJsonSchemaToZodSchema(jsonSchema, required) {
164
- if (jsonSchema.type === "object") {
165
- const spec = {};
166
- if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {
167
- return !required ? import_zod.z.object(spec).optional() : import_zod.z.object(spec);
168
- }
169
- for (const [key, value] of Object.entries(jsonSchema.properties)) {
170
- spec[key] = convertJsonSchemaToZodSchema(
171
- value,
172
- jsonSchema.required ? jsonSchema.required.includes(key) : false
173
- );
174
- }
175
- let schema = import_zod.z.object(spec).describe(jsonSchema.description);
176
- return required ? schema : schema.optional();
177
- } else if (jsonSchema.type === "string") {
178
- let schema = import_zod.z.string().describe(jsonSchema.description);
179
- return required ? schema : schema.optional();
180
- } else if (jsonSchema.type === "number") {
181
- let schema = import_zod.z.number().describe(jsonSchema.description);
182
- return required ? schema : schema.optional();
183
- } else if (jsonSchema.type === "boolean") {
184
- let schema = import_zod.z.boolean().describe(jsonSchema.description);
185
- return required ? schema : schema.optional();
186
- } else if (jsonSchema.type === "array") {
187
- let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
188
- let schema = import_zod.z.array(itemSchema).describe(jsonSchema.description);
189
- return required ? schema : schema.optional();
190
- }
191
- throw new Error("Invalid JSON schema");
192
- }
193
-
194
- // src/utils/json-schema.test.ts
195
- var import_zod_to_json_schema = require("zod-to-json-schema");
196
- describe("convertJsonSchemaToZodSchema", () => {
197
- it("should convert a simple JSON schema to a Zod schema", () => {
198
- const jsonSchema = {
199
- type: "object",
200
- properties: {
201
- name: { type: "string" },
202
- age: { type: "number" }
203
- },
204
- required: ["name", "age"]
205
- };
206
- const expectedSchema = import_zod2.z.object({
207
- name: import_zod2.z.string(),
208
- age: import_zod2.z.number()
209
- });
210
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
211
- const resultSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(result);
212
- const expectedSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(expectedSchema);
213
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
214
- });
215
- it("should convert a JSON schema with nested objects to a Zod schema", () => {
216
- const jsonSchema = {
217
- type: "object",
218
- properties: {
219
- name: { type: "string" },
220
- address: {
221
- type: "object",
222
- properties: {
223
- street: { type: "string" },
224
- city: { type: "string" }
225
- },
226
- required: ["street", "city"]
227
- }
228
- },
229
- required: ["name", "address"]
230
- };
231
- const expectedSchema = import_zod2.z.object({
232
- name: import_zod2.z.string(),
233
- address: import_zod2.z.object({
234
- street: import_zod2.z.string(),
235
- city: import_zod2.z.string()
236
- })
237
- });
238
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
239
- const resultSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(result);
240
- const expectedSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(expectedSchema);
241
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
242
- });
243
- it("should convert a JSON schema with arrays to a Zod schema", () => {
244
- const jsonSchema = {
245
- type: "object",
246
- properties: {
247
- names: {
248
- type: "array",
249
- items: { type: "string" }
250
- }
251
- },
252
- required: ["names"]
253
- };
254
- const expectedSchema = import_zod2.z.object({
255
- names: import_zod2.z.array(import_zod2.z.string())
256
- });
257
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
258
- const resultSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(result);
259
- const expectedSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(expectedSchema);
260
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
261
- });
262
- it("should convert a JSON schema with optional properties to a Zod schema", () => {
263
- const jsonSchema = {
264
- type: "object",
265
- properties: {
266
- name: { type: "string" },
267
- age: { type: "number", required: false }
268
- }
269
- };
270
- const expectedSchema = import_zod2.z.object({
271
- name: import_zod2.z.string().optional(),
272
- age: import_zod2.z.number().optional()
273
- }).optional();
274
- const result = convertJsonSchemaToZodSchema(jsonSchema, false);
275
- console.log(convertJsonSchemaToZodSchema(jsonSchema, false));
276
- const resultSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(result);
277
- const expectedSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(expectedSchema);
278
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
279
- });
280
- it("should convert a JSON schema with different types to a Zod schema", () => {
281
- const jsonSchema = {
282
- type: "object",
283
- properties: {
284
- name: { type: "string" },
285
- age: { type: "number" },
286
- isAdmin: { type: "boolean" }
287
- },
288
- required: ["name", "age", "isAdmin"]
289
- };
290
- const expectedSchema = import_zod2.z.object({
291
- name: import_zod2.z.string(),
292
- age: import_zod2.z.number(),
293
- isAdmin: import_zod2.z.boolean()
294
- });
295
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
296
- const resultSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(result);
297
- const expectedSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(expectedSchema);
298
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
299
- });
300
- it("should handle edge case where JSON schema has no properties", () => {
301
- const jsonSchema = {
302
- type: "object"
303
- };
304
- const expectedSchema = import_zod2.z.object({});
305
- const result = convertJsonSchemaToZodSchema(jsonSchema, true);
306
- const resultSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(result);
307
- const expectedSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(expectedSchema);
308
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
309
- });
310
- it("should handle edge case where JSON schema has no required properties", () => {
311
- const jsonSchema = {
312
- type: "object",
313
- properties: {
314
- name: { type: "string" },
315
- age: { type: "number" }
316
- }
317
- };
318
- const expectedSchema = import_zod2.z.object({
319
- name: import_zod2.z.string().optional(),
320
- age: import_zod2.z.number().optional()
321
- }).optional();
322
- const result = convertJsonSchemaToZodSchema(jsonSchema, false);
323
- const resultSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(result);
324
- const expectedSchemaJson = (0, import_zod_to_json_schema.zodToJsonSchema)(expectedSchema);
325
- expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
326
- });
327
- });
328
- describe("jsonSchemaToActionParameters", () => {
329
- it("should convert a simple JSONSchema to Parameter array", () => {
330
- const jsonSchema = {
331
- type: "object",
332
- properties: {
333
- name: { type: "string", description: "User name" },
334
- age: { type: "number", description: "User age" }
335
- },
336
- required: ["name"]
337
- };
338
- const expectedParameters = [
339
- { name: "name", type: "string", description: "User name" },
340
- { name: "age", type: "number", description: "User age", required: false }
341
- ];
342
- const result = jsonSchemaToActionParameters(jsonSchema);
343
- expect(result).toEqual(expectedParameters);
344
- });
345
- it("should convert JSONSchema with enum to Parameter array", () => {
346
- const jsonSchema = {
347
- type: "object",
348
- properties: {
349
- role: { type: "string", enum: ["admin", "user", "guest"], description: "User role" }
350
- },
351
- required: ["role"]
352
- };
353
- const expectedParameters = [
354
- { name: "role", type: "string", enum: ["admin", "user", "guest"], description: "User role" }
355
- ];
356
- const result = jsonSchemaToActionParameters(jsonSchema);
357
- expect(result).toEqual(expectedParameters);
358
- });
359
- it("should convert nested object JSONSchema to Parameter array", () => {
360
- const jsonSchema = {
361
- type: "object",
362
- properties: {
363
- user: {
364
- type: "object",
365
- properties: {
366
- name: { type: "string", description: "User name" },
367
- age: { type: "number", description: "User age" }
368
- },
369
- required: ["name"],
370
- description: "User information"
371
- }
372
- },
373
- required: ["user"]
374
- };
375
- const expectedParameters = [
376
- {
377
- name: "user",
378
- type: "object",
379
- description: "User information",
380
- attributes: [
381
- { name: "name", type: "string", description: "User name" },
382
- { name: "age", type: "number", description: "User age", required: false }
383
- ]
384
- }
385
- ];
386
- const result = jsonSchemaToActionParameters(jsonSchema);
387
- expect(result).toEqual(expectedParameters);
388
- });
389
- it("should convert array JSONSchema to Parameter array", () => {
390
- const jsonSchema = {
391
- type: "object",
392
- properties: {
393
- tags: {
394
- type: "array",
395
- items: { type: "string" },
396
- description: "User tags"
397
- }
398
- },
399
- required: ["tags"]
400
- };
401
- const expectedParameters = [
402
- { name: "tags", type: "string[]", description: "User tags" }
403
- ];
404
- const result = jsonSchemaToActionParameters(jsonSchema);
405
- expect(result).toEqual(expectedParameters);
406
- });
407
- it("should convert object array JSONSchema to Parameter array", () => {
408
- const jsonSchema = {
409
- type: "object",
410
- properties: {
411
- addresses: {
412
- type: "array",
413
- items: {
414
- type: "object",
415
- properties: {
416
- street: { type: "string", description: "Street name" },
417
- city: { type: "string", description: "City name" }
418
- },
419
- required: ["street"]
420
- },
421
- description: "User addresses"
422
- }
423
- },
424
- required: ["addresses"]
425
- };
426
- const expectedParameters = [
427
- {
428
- name: "addresses",
429
- type: "object[]",
430
- description: "User addresses",
431
- attributes: [
432
- { name: "street", type: "string", description: "Street name" },
433
- { name: "city", type: "string", description: "City name", required: false }
434
- ]
435
- }
436
- ];
437
- const result = jsonSchemaToActionParameters(jsonSchema);
438
- expect(result).toEqual(expectedParameters);
439
- });
440
- it("should handle boolean types", () => {
441
- const jsonSchema = {
442
- type: "object",
443
- properties: {
444
- isAdmin: { type: "boolean", description: "Is user an admin" }
445
- },
446
- required: ["isAdmin"]
447
- };
448
- const expectedParameters = [
449
- { name: "isAdmin", type: "boolean", description: "Is user an admin" }
450
- ];
451
- const result = jsonSchemaToActionParameters(jsonSchema);
452
- expect(result).toEqual(expectedParameters);
453
- });
454
- it("should handle empty object schema", () => {
455
- const jsonSchema = {
456
- type: "object"
457
- };
458
- const expectedParameters = [];
459
- const result = jsonSchemaToActionParameters(jsonSchema);
460
- expect(result).toEqual(expectedParameters);
461
- });
462
- it("should throw error for nested arrays", () => {
463
- const jsonSchema = {
464
- type: "object",
465
- properties: {
466
- nestedArray: {
467
- type: "array",
468
- items: {
469
- type: "array",
470
- items: { type: "string" }
471
- },
472
- description: "Matrix of strings"
473
- }
474
- },
475
- required: ["nestedArray"]
476
- };
477
- expect(() => jsonSchemaToActionParameters(jsonSchema)).toThrow(
478
- "Nested arrays are not supported"
479
- );
480
- });
481
- it("should ensure round-trip conversion works", () => {
482
- const originalParameters = [
483
- { name: "name", type: "string", description: "User name" },
484
- { name: "age", type: "number", description: "User age", required: false },
485
- { name: "role", type: "string", enum: ["admin", "user"], description: "User role" },
486
- {
487
- name: "address",
488
- type: "object",
489
- description: "User address",
490
- attributes: [
491
- { name: "street", type: "string", description: "Street name" },
492
- { name: "city", type: "string", description: "City name" }
493
- ]
494
- },
495
- {
496
- name: "contacts",
497
- type: "object[]",
498
- description: "User contacts",
499
- attributes: [
500
- { name: "type", type: "string", description: "Contact type" },
501
- { name: "value", type: "string", description: "Contact value" }
502
- ]
503
- }
504
- ];
505
- const jsonSchema = actionParametersToJsonSchema(originalParameters);
506
- const roundTripParameters = jsonSchemaToActionParameters(jsonSchema);
507
- expect(roundTripParameters).toEqual(originalParameters);
508
- });
509
- });
510
- //# sourceMappingURL=json-schema.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/json-schema.test.ts","../../src/utils/json-schema.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {\n convertJsonSchemaToZodSchema,\n actionParametersToJsonSchema,\n jsonSchemaToActionParameters,\n JSONSchema,\n} from \"../utils/json-schema\";\nimport { zodToJsonSchema } from \"zod-to-json-schema\";\nimport { Parameter } from \"../types\";\n\ndescribe(\"convertJsonSchemaToZodSchema\", () => {\n it(\"should convert a simple JSON schema to a Zod schema\", () => {\n const jsonSchema = {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n age: { type: \"number\" },\n },\n required: [\"name\", \"age\"],\n };\n\n const expectedSchema = z.object({\n name: z.string(),\n age: z.number(),\n });\n\n const result = convertJsonSchemaToZodSchema(jsonSchema, true);\n const resultSchemaJson = zodToJsonSchema(result);\n const expectedSchemaJson = zodToJsonSchema(expectedSchema);\n\n expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);\n });\n\n it(\"should convert a JSON schema with nested objects to a Zod schema\", () => {\n const jsonSchema = {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n address: {\n type: \"object\",\n properties: {\n street: { type: \"string\" },\n city: { type: \"string\" },\n },\n required: [\"street\", \"city\"],\n },\n },\n required: [\"name\", \"address\"],\n };\n\n const expectedSchema = z.object({\n name: z.string(),\n address: z.object({\n street: z.string(),\n city: z.string(),\n }),\n });\n\n const result = convertJsonSchemaToZodSchema(jsonSchema, true);\n const resultSchemaJson = zodToJsonSchema(result);\n const expectedSchemaJson = zodToJsonSchema(expectedSchema);\n\n expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);\n });\n\n it(\"should convert a JSON schema with arrays to a Zod schema\", () => {\n const jsonSchema = {\n type: \"object\",\n properties: {\n names: {\n type: \"array\",\n items: { type: \"string\" },\n },\n },\n required: [\"names\"],\n };\n\n const expectedSchema = z.object({\n names: z.array(z.string()),\n });\n\n const result = convertJsonSchemaToZodSchema(jsonSchema, true);\n const resultSchemaJson = zodToJsonSchema(result);\n const expectedSchemaJson = zodToJsonSchema(expectedSchema);\n\n expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);\n });\n\n it(\"should convert a JSON schema with optional properties to a Zod schema\", () => {\n const jsonSchema = {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n age: { type: \"number\", required: false },\n },\n };\n\n const expectedSchema = z\n .object({\n name: z.string().optional(),\n age: z.number().optional(),\n })\n .optional();\n\n const result = convertJsonSchemaToZodSchema(jsonSchema, false);\n\n console.log(convertJsonSchemaToZodSchema(jsonSchema, false));\n\n const resultSchemaJson = zodToJsonSchema(result);\n const expectedSchemaJson = zodToJsonSchema(expectedSchema);\n\n expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);\n });\n\n it(\"should convert a JSON schema with different types to a Zod schema\", () => {\n const jsonSchema = {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n age: { type: \"number\" },\n isAdmin: { type: \"boolean\" },\n },\n required: [\"name\", \"age\", \"isAdmin\"],\n };\n\n const expectedSchema = z.object({\n name: z.string(),\n age: z.number(),\n isAdmin: z.boolean(),\n });\n\n const result = convertJsonSchemaToZodSchema(jsonSchema, true);\n const resultSchemaJson = zodToJsonSchema(result);\n const expectedSchemaJson = zodToJsonSchema(expectedSchema);\n\n expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);\n });\n\n it(\"should handle edge case where JSON schema has no properties\", () => {\n const jsonSchema = {\n type: \"object\",\n };\n\n const expectedSchema = z.object({});\n\n const result = convertJsonSchemaToZodSchema(jsonSchema, true);\n const resultSchemaJson = zodToJsonSchema(result);\n const expectedSchemaJson = zodToJsonSchema(expectedSchema);\n\n expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);\n });\n\n it(\"should handle edge case where JSON schema has no required properties\", () => {\n const jsonSchema = {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n age: { type: \"number\" },\n },\n };\n\n const expectedSchema = z\n .object({\n name: z.string().optional(),\n age: z.number().optional(),\n })\n .optional();\n\n const result = convertJsonSchemaToZodSchema(jsonSchema, false);\n const resultSchemaJson = zodToJsonSchema(result);\n const expectedSchemaJson = zodToJsonSchema(expectedSchema);\n\n expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);\n });\n});\n\ndescribe(\"jsonSchemaToActionParameters\", () => {\n it(\"should convert a simple JSONSchema to Parameter array\", () => {\n const jsonSchema: JSONSchema = {\n type: \"object\",\n properties: {\n name: { type: \"string\", description: \"User name\" },\n age: { type: \"number\", description: \"User age\" },\n },\n required: [\"name\"],\n };\n\n const expectedParameters: Parameter[] = [\n { name: \"name\", type: \"string\", description: \"User name\" },\n { name: \"age\", type: \"number\", description: \"User age\", required: false },\n ];\n\n const result = jsonSchemaToActionParameters(jsonSchema);\n expect(result).toEqual(expectedParameters);\n });\n\n it(\"should convert JSONSchema with enum to Parameter array\", () => {\n const jsonSchema: JSONSchema = {\n type: \"object\",\n properties: {\n role: { type: \"string\", enum: [\"admin\", \"user\", \"guest\"], description: \"User role\" },\n },\n required: [\"role\"],\n };\n\n const expectedParameters: Parameter[] = [\n { name: \"role\", type: \"string\", enum: [\"admin\", \"user\", \"guest\"], description: \"User role\" },\n ];\n\n const result = jsonSchemaToActionParameters(jsonSchema);\n expect(result).toEqual(expectedParameters);\n });\n\n it(\"should convert nested object JSONSchema to Parameter array\", () => {\n const jsonSchema: JSONSchema = {\n type: \"object\",\n properties: {\n user: {\n type: \"object\",\n properties: {\n name: { type: \"string\", description: \"User name\" },\n age: { type: \"number\", description: \"User age\" },\n },\n required: [\"name\"],\n description: \"User information\",\n },\n },\n required: [\"user\"],\n };\n\n const expectedParameters: Parameter[] = [\n {\n name: \"user\",\n type: \"object\",\n description: \"User information\",\n attributes: [\n { name: \"name\", type: \"string\", description: \"User name\" },\n { name: \"age\", type: \"number\", description: \"User age\", required: false },\n ],\n },\n ];\n\n const result = jsonSchemaToActionParameters(jsonSchema);\n expect(result).toEqual(expectedParameters);\n });\n\n it(\"should convert array JSONSchema to Parameter array\", () => {\n const jsonSchema: JSONSchema = {\n type: \"object\",\n properties: {\n tags: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"User tags\",\n },\n },\n required: [\"tags\"],\n };\n\n const expectedParameters: Parameter[] = [\n { name: \"tags\", type: \"string[]\", description: \"User tags\" },\n ];\n\n const result = jsonSchemaToActionParameters(jsonSchema);\n expect(result).toEqual(expectedParameters);\n });\n\n it(\"should convert object array JSONSchema to Parameter array\", () => {\n const jsonSchema: JSONSchema = {\n type: \"object\",\n properties: {\n addresses: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n street: { type: \"string\", description: \"Street name\" },\n city: { type: \"string\", description: \"City name\" },\n },\n required: [\"street\"],\n },\n description: \"User addresses\",\n },\n },\n required: [\"addresses\"],\n };\n\n const expectedParameters: Parameter[] = [\n {\n name: \"addresses\",\n type: \"object[]\",\n description: \"User addresses\",\n attributes: [\n { name: \"street\", type: \"string\", description: \"Street name\" },\n { name: \"city\", type: \"string\", description: \"City name\", required: false },\n ],\n },\n ];\n\n const result = jsonSchemaToActionParameters(jsonSchema);\n expect(result).toEqual(expectedParameters);\n });\n\n it(\"should handle boolean types\", () => {\n const jsonSchema: JSONSchema = {\n type: \"object\",\n properties: {\n isAdmin: { type: \"boolean\", description: \"Is user an admin\" },\n },\n required: [\"isAdmin\"],\n };\n\n const expectedParameters: Parameter[] = [\n { name: \"isAdmin\", type: \"boolean\", description: \"Is user an admin\" },\n ];\n\n const result = jsonSchemaToActionParameters(jsonSchema);\n expect(result).toEqual(expectedParameters);\n });\n\n it(\"should handle empty object schema\", () => {\n const jsonSchema: JSONSchema = {\n type: \"object\",\n };\n\n const expectedParameters: Parameter[] = [];\n\n const result = jsonSchemaToActionParameters(jsonSchema);\n expect(result).toEqual(expectedParameters);\n });\n\n it(\"should throw error for nested arrays\", () => {\n const jsonSchema: JSONSchema = {\n type: \"object\",\n properties: {\n nestedArray: {\n type: \"array\",\n items: {\n type: \"array\",\n items: { type: \"string\" },\n },\n description: \"Matrix of strings\",\n },\n },\n required: [\"nestedArray\"],\n };\n\n expect(() => jsonSchemaToActionParameters(jsonSchema)).toThrow(\n \"Nested arrays are not supported\",\n );\n });\n\n it(\"should ensure round-trip conversion works\", () => {\n const originalParameters: Parameter[] = [\n { name: \"name\", type: \"string\", description: \"User name\" },\n { name: \"age\", type: \"number\", description: \"User age\", required: false },\n { name: \"role\", type: \"string\", enum: [\"admin\", \"user\"], description: \"User role\" },\n {\n name: \"address\",\n type: \"object\",\n description: \"User address\",\n attributes: [\n { name: \"street\", type: \"string\", description: \"Street name\" },\n { name: \"city\", type: \"string\", description: \"City name\" },\n ],\n },\n {\n name: \"contacts\",\n type: \"object[]\",\n description: \"User contacts\",\n attributes: [\n { name: \"type\", type: \"string\", description: \"Contact type\" },\n { name: \"value\", type: \"string\", description: \"Contact value\" },\n ],\n },\n ];\n\n const jsonSchema = actionParametersToJsonSchema(originalParameters);\n const roundTripParameters = jsonSchemaToActionParameters(jsonSchema);\n\n expect(roundTripParameters).toEqual(originalParameters);\n });\n});\n","import { z } from \"zod\";\nimport { Parameter } from \"../types\";\n\nexport type JSONSchemaString = {\n type: \"string\";\n description?: string;\n enum?: string[];\n};\n\nexport type JSONSchemaNumber = {\n type: \"number\";\n description?: string;\n};\n\nexport type JSONSchemaBoolean = {\n type: \"boolean\";\n description?: string;\n};\n\nexport type JSONSchemaObject = {\n type: \"object\";\n properties?: Record<string, JSONSchema>;\n required?: string[];\n description?: string;\n};\n\nexport type JSONSchemaArray = {\n type: \"array\";\n items: JSONSchema;\n description?: string;\n};\n\nexport type JSONSchema =\n | JSONSchemaString\n | JSONSchemaNumber\n | JSONSchemaBoolean\n | JSONSchemaObject\n | JSONSchemaArray;\n\nexport function actionParametersToJsonSchema(actionParameters: Parameter[]): JSONSchema {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let parameter of actionParameters || []) {\n parameters[parameter.name] = convertAttribute(parameter);\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of actionParameters || []) {\n if (arg.required !== false) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n return {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n };\n}\n\n// Convert JSONSchema to Parameter[]\nexport function jsonSchemaToActionParameters(jsonSchema: JSONSchema): Parameter[] {\n if (jsonSchema.type !== \"object\" || !jsonSchema.properties) {\n return [];\n }\n\n const parameters: Parameter[] = [];\n const requiredFields = jsonSchema.required || [];\n\n for (const [name, schema] of Object.entries(jsonSchema.properties)) {\n const parameter = convertJsonSchemaToParameter(name, schema, requiredFields.includes(name));\n parameters.push(parameter);\n }\n\n return parameters;\n}\n\n// Convert JSONSchema property to Parameter\nfunction convertJsonSchemaToParameter(\n name: string,\n schema: JSONSchema,\n isRequired: boolean,\n): Parameter {\n const baseParameter: Parameter = {\n name,\n description: schema.description,\n };\n\n if (!isRequired) {\n baseParameter.required = false;\n }\n\n switch (schema.type) {\n case \"string\":\n return {\n ...baseParameter,\n type: \"string\",\n ...(schema.enum && { enum: schema.enum }),\n };\n case \"number\":\n case \"boolean\":\n return {\n ...baseParameter,\n type: schema.type,\n };\n case \"object\":\n if (schema.properties) {\n const attributes: Parameter[] = [];\n const requiredFields = schema.required || [];\n\n for (const [propName, propSchema] of Object.entries(schema.properties)) {\n attributes.push(\n convertJsonSchemaToParameter(propName, propSchema, requiredFields.includes(propName)),\n );\n }\n\n return {\n ...baseParameter,\n type: \"object\",\n attributes,\n };\n }\n return {\n ...baseParameter,\n type: \"object\",\n };\n case \"array\":\n if (schema.items.type === \"object\" && \"properties\" in schema.items) {\n const attributes: Parameter[] = [];\n const requiredFields = schema.items.required || [];\n\n for (const [propName, propSchema] of Object.entries(schema.items.properties || {})) {\n attributes.push(\n convertJsonSchemaToParameter(propName, propSchema, requiredFields.includes(propName)),\n );\n }\n\n return {\n ...baseParameter,\n type: \"object[]\",\n attributes,\n };\n } else if (schema.items.type === \"array\") {\n throw new Error(\"Nested arrays are not supported\");\n } else {\n return {\n ...baseParameter,\n type: `${schema.items.type}[]`,\n };\n }\n default:\n return {\n ...baseParameter,\n type: \"string\",\n };\n }\n}\n\nfunction convertAttribute(attribute: Parameter): JSONSchema {\n switch (attribute.type) {\n case \"string\":\n return {\n type: \"string\",\n description: attribute.description,\n ...(attribute.enum && { enum: attribute.enum }),\n };\n case \"number\":\n case \"boolean\":\n return {\n type: attribute.type,\n description: attribute.description,\n };\n case \"object\":\n case \"object[]\":\n const properties = attribute.attributes?.reduce(\n (acc, attr) => {\n acc[attr.name] = convertAttribute(attr);\n return acc;\n },\n {} as Record<string, any>,\n );\n const required = attribute.attributes\n ?.filter((attr) => attr.required !== false)\n .map((attr) => attr.name);\n if (attribute.type === \"object[]\") {\n return {\n type: \"array\",\n items: {\n type: \"object\",\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n },\n description: attribute.description,\n };\n }\n return {\n type: \"object\",\n description: attribute.description,\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n };\n default:\n // Handle arrays of primitive types and undefined attribute.type\n if (attribute.type?.endsWith(\"[]\")) {\n const itemType = attribute.type.slice(0, -2);\n return {\n type: \"array\",\n items: { type: itemType as any },\n description: attribute.description,\n };\n }\n // Fallback for undefined type or any other unexpected type\n return {\n type: \"string\",\n description: attribute.description,\n };\n }\n}\n\nexport function convertJsonSchemaToZodSchema(jsonSchema: any, required: boolean): z.ZodSchema {\n if (jsonSchema.type === \"object\") {\n const spec: { [key: string]: z.ZodSchema } = {};\n\n if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {\n return !required ? z.object(spec).optional() : z.object(spec);\n }\n\n for (const [key, value] of Object.entries(jsonSchema.properties)) {\n spec[key] = convertJsonSchemaToZodSchema(\n value,\n jsonSchema.required ? jsonSchema.required.includes(key) : false,\n );\n }\n let schema = z.object(spec).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"string\") {\n let schema = z.string().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"number\") {\n let schema = z.number().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"boolean\") {\n let schema = z.boolean().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"array\") {\n let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);\n let schema = z.array(itemSchema).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n }\n throw new Error(\"Invalid JSON schema\");\n}\n"],"mappings":";;;AAAA,IAAAA,cAAkB;;;ACAlB,iBAAkB;AAuCX,SAAS,6BAA6B,kBAA2C;AAEtF,MAAI,aAAqC,CAAC;AAC1C,WAAS,aAAa,oBAAoB,CAAC,GAAG;AAC5C,eAAW,UAAU,IAAI,IAAI,iBAAiB,SAAS;AAAA,EACzD;AAEA,MAAI,yBAAmC,CAAC;AACxC,WAAS,OAAO,oBAAoB,CAAC,GAAG;AACtC,QAAI,IAAI,aAAa,OAAO;AAC1B,6BAAuB,KAAK,IAAI,IAAI;AAAA,IACtC;AAAA,EACF;AAGA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,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