@copilotkit/shared 1.9.2-next.7 → 1.9.2-next.9
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/CHANGELOG.md +8 -0
- package/dist/{chunk-IZQALLRR.mjs → chunk-6NYTK7KK.mjs} +34 -21
- package/dist/chunk-6NYTK7KK.mjs.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +35 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/utils/errors.d.ts +25 -1
- package/dist/utils/errors.js +37 -22
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/errors.mjs +7 -3
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +35 -20
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +5 -1
- package/package.json +1 -1
- package/src/utils/errors.ts +54 -19
- package/tsup.config.ts +1 -6
- package/dist/chunk-IZQALLRR.mjs.map +0 -1
- package/dist/utils/json-schema.test.d.ts +0 -2
- package/dist/utils/json-schema.test.js +0 -510
- package/dist/utils/json-schema.test.js.map +0 -1
- package/dist/utils/json-schema.test.mjs +0 -324
- package/dist/utils/json-schema.test.mjs.map +0 -1
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
actionParametersToJsonSchema,
|
|
3
|
-
convertJsonSchemaToZodSchema,
|
|
4
|
-
jsonSchemaToActionParameters
|
|
5
|
-
} from "../chunk-2KQ6HEWZ.mjs";
|
|
6
|
-
|
|
7
|
-
// src/utils/json-schema.test.ts
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
10
|
-
describe("convertJsonSchemaToZodSchema", () => {
|
|
11
|
-
it("should convert a simple JSON schema to a Zod schema", () => {
|
|
12
|
-
const jsonSchema = {
|
|
13
|
-
type: "object",
|
|
14
|
-
properties: {
|
|
15
|
-
name: { type: "string" },
|
|
16
|
-
age: { type: "number" }
|
|
17
|
-
},
|
|
18
|
-
required: ["name", "age"]
|
|
19
|
-
};
|
|
20
|
-
const expectedSchema = z.object({
|
|
21
|
-
name: z.string(),
|
|
22
|
-
age: z.number()
|
|
23
|
-
});
|
|
24
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
25
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
26
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
27
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
28
|
-
});
|
|
29
|
-
it("should convert a JSON schema with nested objects to a Zod schema", () => {
|
|
30
|
-
const jsonSchema = {
|
|
31
|
-
type: "object",
|
|
32
|
-
properties: {
|
|
33
|
-
name: { type: "string" },
|
|
34
|
-
address: {
|
|
35
|
-
type: "object",
|
|
36
|
-
properties: {
|
|
37
|
-
street: { type: "string" },
|
|
38
|
-
city: { type: "string" }
|
|
39
|
-
},
|
|
40
|
-
required: ["street", "city"]
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
required: ["name", "address"]
|
|
44
|
-
};
|
|
45
|
-
const expectedSchema = z.object({
|
|
46
|
-
name: z.string(),
|
|
47
|
-
address: z.object({
|
|
48
|
-
street: z.string(),
|
|
49
|
-
city: z.string()
|
|
50
|
-
})
|
|
51
|
-
});
|
|
52
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
53
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
54
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
55
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
56
|
-
});
|
|
57
|
-
it("should convert a JSON schema with arrays to a Zod schema", () => {
|
|
58
|
-
const jsonSchema = {
|
|
59
|
-
type: "object",
|
|
60
|
-
properties: {
|
|
61
|
-
names: {
|
|
62
|
-
type: "array",
|
|
63
|
-
items: { type: "string" }
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
required: ["names"]
|
|
67
|
-
};
|
|
68
|
-
const expectedSchema = z.object({
|
|
69
|
-
names: z.array(z.string())
|
|
70
|
-
});
|
|
71
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
72
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
73
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
74
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
75
|
-
});
|
|
76
|
-
it("should convert a JSON schema with optional properties to a Zod schema", () => {
|
|
77
|
-
const jsonSchema = {
|
|
78
|
-
type: "object",
|
|
79
|
-
properties: {
|
|
80
|
-
name: { type: "string" },
|
|
81
|
-
age: { type: "number", required: false }
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const expectedSchema = z.object({
|
|
85
|
-
name: z.string().optional(),
|
|
86
|
-
age: z.number().optional()
|
|
87
|
-
}).optional();
|
|
88
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, false);
|
|
89
|
-
console.log(convertJsonSchemaToZodSchema(jsonSchema, false));
|
|
90
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
91
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
92
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
93
|
-
});
|
|
94
|
-
it("should convert a JSON schema with different types to a Zod schema", () => {
|
|
95
|
-
const jsonSchema = {
|
|
96
|
-
type: "object",
|
|
97
|
-
properties: {
|
|
98
|
-
name: { type: "string" },
|
|
99
|
-
age: { type: "number" },
|
|
100
|
-
isAdmin: { type: "boolean" }
|
|
101
|
-
},
|
|
102
|
-
required: ["name", "age", "isAdmin"]
|
|
103
|
-
};
|
|
104
|
-
const expectedSchema = z.object({
|
|
105
|
-
name: z.string(),
|
|
106
|
-
age: z.number(),
|
|
107
|
-
isAdmin: z.boolean()
|
|
108
|
-
});
|
|
109
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
110
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
111
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
112
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
113
|
-
});
|
|
114
|
-
it("should handle edge case where JSON schema has no properties", () => {
|
|
115
|
-
const jsonSchema = {
|
|
116
|
-
type: "object"
|
|
117
|
-
};
|
|
118
|
-
const expectedSchema = z.object({});
|
|
119
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, true);
|
|
120
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
121
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
122
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
123
|
-
});
|
|
124
|
-
it("should handle edge case where JSON schema has no required properties", () => {
|
|
125
|
-
const jsonSchema = {
|
|
126
|
-
type: "object",
|
|
127
|
-
properties: {
|
|
128
|
-
name: { type: "string" },
|
|
129
|
-
age: { type: "number" }
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
const expectedSchema = z.object({
|
|
133
|
-
name: z.string().optional(),
|
|
134
|
-
age: z.number().optional()
|
|
135
|
-
}).optional();
|
|
136
|
-
const result = convertJsonSchemaToZodSchema(jsonSchema, false);
|
|
137
|
-
const resultSchemaJson = zodToJsonSchema(result);
|
|
138
|
-
const expectedSchemaJson = zodToJsonSchema(expectedSchema);
|
|
139
|
-
expect(resultSchemaJson).toStrictEqual(expectedSchemaJson);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
describe("jsonSchemaToActionParameters", () => {
|
|
143
|
-
it("should convert a simple JSONSchema to Parameter array", () => {
|
|
144
|
-
const jsonSchema = {
|
|
145
|
-
type: "object",
|
|
146
|
-
properties: {
|
|
147
|
-
name: { type: "string", description: "User name" },
|
|
148
|
-
age: { type: "number", description: "User age" }
|
|
149
|
-
},
|
|
150
|
-
required: ["name"]
|
|
151
|
-
};
|
|
152
|
-
const expectedParameters = [
|
|
153
|
-
{ name: "name", type: "string", description: "User name" },
|
|
154
|
-
{ name: "age", type: "number", description: "User age", required: false }
|
|
155
|
-
];
|
|
156
|
-
const result = jsonSchemaToActionParameters(jsonSchema);
|
|
157
|
-
expect(result).toEqual(expectedParameters);
|
|
158
|
-
});
|
|
159
|
-
it("should convert JSONSchema with enum to Parameter array", () => {
|
|
160
|
-
const jsonSchema = {
|
|
161
|
-
type: "object",
|
|
162
|
-
properties: {
|
|
163
|
-
role: { type: "string", enum: ["admin", "user", "guest"], description: "User role" }
|
|
164
|
-
},
|
|
165
|
-
required: ["role"]
|
|
166
|
-
};
|
|
167
|
-
const expectedParameters = [
|
|
168
|
-
{ name: "role", type: "string", enum: ["admin", "user", "guest"], description: "User role" }
|
|
169
|
-
];
|
|
170
|
-
const result = jsonSchemaToActionParameters(jsonSchema);
|
|
171
|
-
expect(result).toEqual(expectedParameters);
|
|
172
|
-
});
|
|
173
|
-
it("should convert nested object JSONSchema to Parameter array", () => {
|
|
174
|
-
const jsonSchema = {
|
|
175
|
-
type: "object",
|
|
176
|
-
properties: {
|
|
177
|
-
user: {
|
|
178
|
-
type: "object",
|
|
179
|
-
properties: {
|
|
180
|
-
name: { type: "string", description: "User name" },
|
|
181
|
-
age: { type: "number", description: "User age" }
|
|
182
|
-
},
|
|
183
|
-
required: ["name"],
|
|
184
|
-
description: "User information"
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
required: ["user"]
|
|
188
|
-
};
|
|
189
|
-
const expectedParameters = [
|
|
190
|
-
{
|
|
191
|
-
name: "user",
|
|
192
|
-
type: "object",
|
|
193
|
-
description: "User information",
|
|
194
|
-
attributes: [
|
|
195
|
-
{ name: "name", type: "string", description: "User name" },
|
|
196
|
-
{ name: "age", type: "number", description: "User age", required: false }
|
|
197
|
-
]
|
|
198
|
-
}
|
|
199
|
-
];
|
|
200
|
-
const result = jsonSchemaToActionParameters(jsonSchema);
|
|
201
|
-
expect(result).toEqual(expectedParameters);
|
|
202
|
-
});
|
|
203
|
-
it("should convert array JSONSchema to Parameter array", () => {
|
|
204
|
-
const jsonSchema = {
|
|
205
|
-
type: "object",
|
|
206
|
-
properties: {
|
|
207
|
-
tags: {
|
|
208
|
-
type: "array",
|
|
209
|
-
items: { type: "string" },
|
|
210
|
-
description: "User tags"
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
required: ["tags"]
|
|
214
|
-
};
|
|
215
|
-
const expectedParameters = [
|
|
216
|
-
{ name: "tags", type: "string[]", description: "User tags" }
|
|
217
|
-
];
|
|
218
|
-
const result = jsonSchemaToActionParameters(jsonSchema);
|
|
219
|
-
expect(result).toEqual(expectedParameters);
|
|
220
|
-
});
|
|
221
|
-
it("should convert object array JSONSchema to Parameter array", () => {
|
|
222
|
-
const jsonSchema = {
|
|
223
|
-
type: "object",
|
|
224
|
-
properties: {
|
|
225
|
-
addresses: {
|
|
226
|
-
type: "array",
|
|
227
|
-
items: {
|
|
228
|
-
type: "object",
|
|
229
|
-
properties: {
|
|
230
|
-
street: { type: "string", description: "Street name" },
|
|
231
|
-
city: { type: "string", description: "City name" }
|
|
232
|
-
},
|
|
233
|
-
required: ["street"]
|
|
234
|
-
},
|
|
235
|
-
description: "User addresses"
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
required: ["addresses"]
|
|
239
|
-
};
|
|
240
|
-
const expectedParameters = [
|
|
241
|
-
{
|
|
242
|
-
name: "addresses",
|
|
243
|
-
type: "object[]",
|
|
244
|
-
description: "User addresses",
|
|
245
|
-
attributes: [
|
|
246
|
-
{ name: "street", type: "string", description: "Street name" },
|
|
247
|
-
{ name: "city", type: "string", description: "City name", required: false }
|
|
248
|
-
]
|
|
249
|
-
}
|
|
250
|
-
];
|
|
251
|
-
const result = jsonSchemaToActionParameters(jsonSchema);
|
|
252
|
-
expect(result).toEqual(expectedParameters);
|
|
253
|
-
});
|
|
254
|
-
it("should handle boolean types", () => {
|
|
255
|
-
const jsonSchema = {
|
|
256
|
-
type: "object",
|
|
257
|
-
properties: {
|
|
258
|
-
isAdmin: { type: "boolean", description: "Is user an admin" }
|
|
259
|
-
},
|
|
260
|
-
required: ["isAdmin"]
|
|
261
|
-
};
|
|
262
|
-
const expectedParameters = [
|
|
263
|
-
{ name: "isAdmin", type: "boolean", description: "Is user an admin" }
|
|
264
|
-
];
|
|
265
|
-
const result = jsonSchemaToActionParameters(jsonSchema);
|
|
266
|
-
expect(result).toEqual(expectedParameters);
|
|
267
|
-
});
|
|
268
|
-
it("should handle empty object schema", () => {
|
|
269
|
-
const jsonSchema = {
|
|
270
|
-
type: "object"
|
|
271
|
-
};
|
|
272
|
-
const expectedParameters = [];
|
|
273
|
-
const result = jsonSchemaToActionParameters(jsonSchema);
|
|
274
|
-
expect(result).toEqual(expectedParameters);
|
|
275
|
-
});
|
|
276
|
-
it("should throw error for nested arrays", () => {
|
|
277
|
-
const jsonSchema = {
|
|
278
|
-
type: "object",
|
|
279
|
-
properties: {
|
|
280
|
-
nestedArray: {
|
|
281
|
-
type: "array",
|
|
282
|
-
items: {
|
|
283
|
-
type: "array",
|
|
284
|
-
items: { type: "string" }
|
|
285
|
-
},
|
|
286
|
-
description: "Matrix of strings"
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
required: ["nestedArray"]
|
|
290
|
-
};
|
|
291
|
-
expect(() => jsonSchemaToActionParameters(jsonSchema)).toThrow(
|
|
292
|
-
"Nested arrays are not supported"
|
|
293
|
-
);
|
|
294
|
-
});
|
|
295
|
-
it("should ensure round-trip conversion works", () => {
|
|
296
|
-
const originalParameters = [
|
|
297
|
-
{ name: "name", type: "string", description: "User name" },
|
|
298
|
-
{ name: "age", type: "number", description: "User age", required: false },
|
|
299
|
-
{ name: "role", type: "string", enum: ["admin", "user"], description: "User role" },
|
|
300
|
-
{
|
|
301
|
-
name: "address",
|
|
302
|
-
type: "object",
|
|
303
|
-
description: "User address",
|
|
304
|
-
attributes: [
|
|
305
|
-
{ name: "street", type: "string", description: "Street name" },
|
|
306
|
-
{ name: "city", type: "string", description: "City name" }
|
|
307
|
-
]
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
name: "contacts",
|
|
311
|
-
type: "object[]",
|
|
312
|
-
description: "User contacts",
|
|
313
|
-
attributes: [
|
|
314
|
-
{ name: "type", type: "string", description: "Contact type" },
|
|
315
|
-
{ name: "value", type: "string", description: "Contact value" }
|
|
316
|
-
]
|
|
317
|
-
}
|
|
318
|
-
];
|
|
319
|
-
const jsonSchema = actionParametersToJsonSchema(originalParameters);
|
|
320
|
-
const roundTripParameters = jsonSchemaToActionParameters(jsonSchema);
|
|
321
|
-
expect(roundTripParameters).toEqual(originalParameters);
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
//# sourceMappingURL=json-schema.test.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/json-schema.test.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"],"mappings":";;;;;;;AAAA,SAAS,SAAS;AAOlB,SAAS,uBAAuB;AAGhC,SAAS,gCAAgC,MAAM;AAC7C,KAAG,uDAAuD,MAAM;AAC9D,UAAM,aAAa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