@copilotkit/shared 2.0.0-rc.7 → 2.0.0-rc.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/README.md +3 -14
- package/dist/index.cjs +1 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +25 -95
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/standard-schema.cjs +20 -7
- package/dist/standard-schema.cjs.map +1 -1
- package/dist/standard-schema.d.cts +15 -16
- package/dist/standard-schema.d.cts.map +1 -1
- package/dist/standard-schema.d.mts +15 -16
- package/dist/standard-schema.d.mts.map +1 -1
- package/dist/standard-schema.mjs +20 -8
- package/dist/standard-schema.mjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.cjs +0 -5
- package/dist/telemetry/telemetry-disabled.cjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.d.cts +0 -5
- package/dist/telemetry/telemetry-disabled.d.cts.map +1 -1
- package/dist/telemetry/telemetry-disabled.d.mts +0 -5
- package/dist/telemetry/telemetry-disabled.d.mts.map +1 -1
- package/dist/telemetry/telemetry-disabled.mjs +0 -5
- package/dist/telemetry/telemetry-disabled.mjs.map +1 -1
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/json-schema.cjs +0 -79
- package/dist/utils/json-schema.cjs.map +1 -1
- package/dist/utils/json-schema.d.cts +1 -4
- package/dist/utils/json-schema.d.cts.map +1 -1
- package/dist/utils/json-schema.d.mts +1 -4
- package/dist/utils/json-schema.d.mts.map +1 -1
- package/dist/utils/json-schema.mjs +1 -78
- package/dist/utils/json-schema.mjs.map +1 -1
- package/package.json +7 -28
- package/src/__tests__/root-entry-browser-safety.test.ts +5 -7
- package/src/__tests__/standard-schema.test.ts +61 -101
- package/src/index.ts +3 -16
- package/src/standard-schema.ts +24 -27
- package/src/telemetry/telemetry-disabled.ts +0 -5
- package/src/utils/__tests__/json-schema.test.ts +3 -479
- package/src/utils/json-schema.ts +1 -152
- package/tsdown.config.ts +2 -10
- package/dist/event-transforms/index.cjs +0 -15
- package/dist/event-transforms/index.d.cts +0 -4
- package/dist/event-transforms/index.d.mts +0 -4
- package/dist/event-transforms/index.mjs +0 -5
- package/dist/event-transforms/open-generative-ui-middleware.cjs +0 -286
- package/dist/event-transforms/open-generative-ui-middleware.cjs.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.d.cts +0 -60
- package/dist/event-transforms/open-generative-ui-middleware.d.cts.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.d.mts +0 -60
- package/dist/event-transforms/open-generative-ui-middleware.d.mts.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.mjs +0 -283
- package/dist/event-transforms/open-generative-ui-middleware.mjs.map +0 -1
- package/dist/event-transforms/recorded-events.cjs +0 -59
- package/dist/event-transforms/recorded-events.cjs.map +0 -1
- package/dist/event-transforms/recorded-events.d.cts +0 -23
- package/dist/event-transforms/recorded-events.d.cts.map +0 -1
- package/dist/event-transforms/recorded-events.d.mts +0 -23
- package/dist/event-transforms/recorded-events.d.mts.map +0 -1
- package/dist/event-transforms/recorded-events.mjs +0 -58
- package/dist/event-transforms/recorded-events.mjs.map +0 -1
- package/dist/telemetry/events.d.cts +0 -72
- package/dist/telemetry/events.d.cts.map +0 -1
- package/dist/telemetry/events.d.mts +0 -72
- package/dist/telemetry/events.d.mts.map +0 -1
- package/dist/telemetry/index.cjs +0 -18
- package/dist/telemetry/index.d.cts +0 -5
- package/dist/telemetry/index.d.mts +0 -5
- package/dist/telemetry/index.mjs +0 -6
- package/dist/telemetry/telemetry-client.cjs +0 -165
- package/dist/telemetry/telemetry-client.cjs.map +0 -1
- package/dist/telemetry/telemetry-client.d.cts +0 -87
- package/dist/telemetry/telemetry-client.d.cts.map +0 -1
- package/dist/telemetry/telemetry-client.d.mts +0 -87
- package/dist/telemetry/telemetry-client.d.mts.map +0 -1
- package/dist/telemetry/telemetry-client.mjs +0 -164
- package/dist/telemetry/telemetry-client.mjs.map +0 -1
- package/dist/telemetry/utils.cjs +0 -14
- package/dist/telemetry/utils.cjs.map +0 -1
- package/dist/telemetry/utils.mjs +0 -13
- package/dist/telemetry/utils.mjs.map +0 -1
- package/src/__tests__/zod-regression.test.ts +0 -319
- package/src/event-transforms/index.ts +0 -5
- package/src/event-transforms/open-generative-ui-middleware.ts +0 -392
- package/src/event-transforms/recorded-events.test.ts +0 -166
- package/src/event-transforms/recorded-events.ts +0 -74
- package/src/telemetry/events.ts +0 -68
- package/src/telemetry/index.ts +0 -9
- package/src/telemetry/telemetry-blank-license-identity.test.ts +0 -128
- package/src/telemetry/telemetry-client.test.ts +0 -798
- package/src/telemetry/telemetry-client.ts +0 -328
- package/src/telemetry/utils.ts +0 -15
package/dist/telemetry/utils.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/telemetry/utils.ts
|
|
2
|
-
function flattenObject(obj, parentKey = "", res = {}) {
|
|
3
|
-
for (let key in obj) {
|
|
4
|
-
const propName = parentKey ? `${parentKey}.${key}` : key;
|
|
5
|
-
if (typeof obj[key] === "object" && obj[key] !== null) flattenObject(obj[key], propName, res);
|
|
6
|
-
else res[propName] = obj[key];
|
|
7
|
-
}
|
|
8
|
-
return res;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
export { flattenObject };
|
|
13
|
-
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/telemetry/utils.ts"],"sourcesContent":["export function flattenObject(\n obj: Record<string, any>,\n parentKey = \"\",\n res: Record<string, any> = {},\n): Record<string, any> {\n for (let key in obj) {\n const propName = parentKey ? `${parentKey}.${key}` : key;\n if (typeof obj[key] === \"object\" && obj[key] !== null) {\n flattenObject(obj[key], propName, res);\n } else {\n res[propName] = obj[key];\n }\n }\n return res;\n}\n"],"mappings":";AAAA,SAAgB,cACd,KACA,YAAY,IACZ,MAA2B,EAAE,EACR;AACrB,MAAK,IAAI,OAAO,KAAK;EACnB,MAAM,WAAW,YAAY,GAAG,UAAU,GAAG,QAAQ;AACrD,MAAI,OAAO,IAAI,SAAS,YAAY,IAAI,SAAS,KAC/C,eAAc,IAAI,MAAM,UAAU,IAAI;MAEtC,KAAI,YAAY,IAAI;;AAGxB,QAAO"}
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Regression tests proving that `schemaToJsonSchema` produces identical output
|
|
3
|
-
* to a direct `zodToJsonSchema` call for all common Zod patterns.
|
|
4
|
-
*
|
|
5
|
-
* These tests exist to guarantee that the Standard Schema migration did not
|
|
6
|
-
* change the JSON Schema output for existing Zod users.
|
|
7
|
-
*/
|
|
8
|
-
import { describe, it, expect } from "vitest";
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
11
|
-
import { schemaToJsonSchema } from "../standard-schema";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Helper: call zodToJsonSchema the same way the old code path did, then
|
|
15
|
-
* compare with the new schemaToJsonSchema path.
|
|
16
|
-
*/
|
|
17
|
-
function expectIdenticalOutput(schema: z.ZodTypeAny) {
|
|
18
|
-
const direct = zodToJsonSchema(schema, { $refStrategy: "none" });
|
|
19
|
-
const migrated = schemaToJsonSchema(schema, { zodToJsonSchema });
|
|
20
|
-
expect(migrated).toEqual(direct);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe("Zod regression — schemaToJsonSchema produces identical output to direct zodToJsonSchema", () => {
|
|
24
|
-
describe("simple object schemas", () => {
|
|
25
|
-
it("required string and number fields", () => {
|
|
26
|
-
expectIdenticalOutput(z.object({ name: z.string(), age: z.number() }));
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("optional fields", () => {
|
|
30
|
-
expectIdenticalOutput(
|
|
31
|
-
z.object({
|
|
32
|
-
city: z.string(),
|
|
33
|
-
units: z.enum(["celsius", "fahrenheit"]).optional(),
|
|
34
|
-
}),
|
|
35
|
-
);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("empty object", () => {
|
|
39
|
-
expectIdenticalOutput(z.object({}));
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("object with default values", () => {
|
|
43
|
-
expectIdenticalOutput(
|
|
44
|
-
z.object({
|
|
45
|
-
page: z.number().default(1),
|
|
46
|
-
perPage: z.number().default(20),
|
|
47
|
-
query: z.string(),
|
|
48
|
-
}),
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe("nested objects", () => {
|
|
54
|
-
it("single level nesting", () => {
|
|
55
|
-
expectIdenticalOutput(
|
|
56
|
-
z.object({
|
|
57
|
-
user: z.object({ name: z.string(), email: z.string() }),
|
|
58
|
-
}),
|
|
59
|
-
);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("deep nesting", () => {
|
|
63
|
-
expectIdenticalOutput(
|
|
64
|
-
z.object({
|
|
65
|
-
level1: z.object({
|
|
66
|
-
level2: z.object({
|
|
67
|
-
level3: z.object({
|
|
68
|
-
value: z.boolean(),
|
|
69
|
-
}),
|
|
70
|
-
}),
|
|
71
|
-
}),
|
|
72
|
-
}),
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe("arrays", () => {
|
|
78
|
-
it("string array", () => {
|
|
79
|
-
expectIdenticalOutput(z.object({ tags: z.array(z.string()) }));
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("object array", () => {
|
|
83
|
-
expectIdenticalOutput(
|
|
84
|
-
z.object({
|
|
85
|
-
items: z.array(z.object({ id: z.number(), label: z.string() })),
|
|
86
|
-
}),
|
|
87
|
-
);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("nested arrays", () => {
|
|
91
|
-
expectIdenticalOutput(z.object({ matrix: z.array(z.array(z.number())) }));
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
describe("enums and literals", () => {
|
|
96
|
-
it("z.enum", () => {
|
|
97
|
-
expectIdenticalOutput(
|
|
98
|
-
z.object({ status: z.enum(["active", "inactive", "pending"]) }),
|
|
99
|
-
);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("z.literal string", () => {
|
|
103
|
-
expectIdenticalOutput(z.object({ type: z.literal("user") }));
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("z.literal number", () => {
|
|
107
|
-
expectIdenticalOutput(z.object({ version: z.literal(2) }));
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("z.nativeEnum", () => {
|
|
111
|
-
enum Color {
|
|
112
|
-
Red = "red",
|
|
113
|
-
Green = "green",
|
|
114
|
-
Blue = "blue",
|
|
115
|
-
}
|
|
116
|
-
expectIdenticalOutput(z.object({ color: z.nativeEnum(Color) }));
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
describe("unions and discriminated unions", () => {
|
|
121
|
-
it("z.union of primitives", () => {
|
|
122
|
-
expectIdenticalOutput(
|
|
123
|
-
z.object({ value: z.union([z.string(), z.number()]) }),
|
|
124
|
-
);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it("z.union of objects", () => {
|
|
128
|
-
expectIdenticalOutput(
|
|
129
|
-
z.object({
|
|
130
|
-
result: z.union([
|
|
131
|
-
z.object({ ok: z.literal(true), data: z.string() }),
|
|
132
|
-
z.object({ ok: z.literal(false), error: z.string() }),
|
|
133
|
-
]),
|
|
134
|
-
}),
|
|
135
|
-
);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it("z.discriminatedUnion", () => {
|
|
139
|
-
expectIdenticalOutput(
|
|
140
|
-
z.object({
|
|
141
|
-
event: z.discriminatedUnion("type", [
|
|
142
|
-
z.object({
|
|
143
|
-
type: z.literal("click"),
|
|
144
|
-
x: z.number(),
|
|
145
|
-
y: z.number(),
|
|
146
|
-
}),
|
|
147
|
-
z.object({ type: z.literal("keypress"), key: z.string() }),
|
|
148
|
-
]),
|
|
149
|
-
}),
|
|
150
|
-
);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
describe("nullable and nullish", () => {
|
|
155
|
-
it("z.nullable", () => {
|
|
156
|
-
expectIdenticalOutput(z.object({ bio: z.string().nullable() }));
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it("z.nullish (optional + nullable)", () => {
|
|
160
|
-
expectIdenticalOutput(z.object({ nickname: z.string().nullish() }));
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
describe("records and tuples", () => {
|
|
165
|
-
it("z.record", () => {
|
|
166
|
-
expectIdenticalOutput(
|
|
167
|
-
z.object({ metadata: z.record(z.string(), z.unknown()) }),
|
|
168
|
-
);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("z.tuple", () => {
|
|
172
|
-
expectIdenticalOutput(
|
|
173
|
-
z.object({ point: z.tuple([z.number(), z.number()]) }),
|
|
174
|
-
);
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
describe("intersections", () => {
|
|
179
|
-
it("z.intersection", () => {
|
|
180
|
-
expectIdenticalOutput(
|
|
181
|
-
z.intersection(
|
|
182
|
-
z.object({ id: z.number() }),
|
|
183
|
-
z.object({ name: z.string() }),
|
|
184
|
-
),
|
|
185
|
-
);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
describe("string constraints", () => {
|
|
190
|
-
it("z.string with min/max", () => {
|
|
191
|
-
expectIdenticalOutput(z.object({ username: z.string().min(3).max(20) }));
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it("z.string with email", () => {
|
|
195
|
-
expectIdenticalOutput(z.object({ email: z.string().email() }));
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it("z.string with url", () => {
|
|
199
|
-
expectIdenticalOutput(z.object({ website: z.string().url() }));
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it("z.string with regex", () => {
|
|
203
|
-
expectIdenticalOutput(
|
|
204
|
-
z.object({ code: z.string().regex(/^[A-Z]{3}-\d{4}$/) }),
|
|
205
|
-
);
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
describe("number constraints", () => {
|
|
210
|
-
it("z.number with min/max", () => {
|
|
211
|
-
expectIdenticalOutput(z.object({ score: z.number().min(0).max(100) }));
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it("z.number.int", () => {
|
|
215
|
-
expectIdenticalOutput(z.object({ count: z.number().int() }));
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it("z.number.positive", () => {
|
|
219
|
-
expectIdenticalOutput(z.object({ amount: z.number().positive() }));
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
describe("catchall and passthrough", () => {
|
|
224
|
-
it("z.object with catchall", () => {
|
|
225
|
-
expectIdenticalOutput(z.object({}).catchall(z.string()));
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it("z.object with passthrough", () => {
|
|
229
|
-
expectIdenticalOutput(z.object({ id: z.number() }).passthrough());
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
describe("z.any and z.unknown", () => {
|
|
234
|
-
it("z.any", () => {
|
|
235
|
-
expectIdenticalOutput(z.any());
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it("z.unknown", () => {
|
|
239
|
-
expectIdenticalOutput(z.unknown());
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
it("object with z.any field", () => {
|
|
243
|
-
expectIdenticalOutput(z.object({ data: z.any() }));
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
describe("complex real-world schemas", () => {
|
|
248
|
-
it("tool-like schema with multiple field types", () => {
|
|
249
|
-
expectIdenticalOutput(
|
|
250
|
-
z.object({
|
|
251
|
-
query: z.string().describe("Search query"),
|
|
252
|
-
filters: z
|
|
253
|
-
.object({
|
|
254
|
-
category: z.enum(["books", "movies", "music"]).optional(),
|
|
255
|
-
minRating: z.number().min(0).max(5).optional(),
|
|
256
|
-
tags: z.array(z.string()).optional(),
|
|
257
|
-
})
|
|
258
|
-
.optional(),
|
|
259
|
-
pagination: z
|
|
260
|
-
.object({
|
|
261
|
-
page: z.number().int().positive().default(1),
|
|
262
|
-
perPage: z.number().int().positive().default(20),
|
|
263
|
-
})
|
|
264
|
-
.optional(),
|
|
265
|
-
sortBy: z.enum(["relevance", "date", "rating"]).default("relevance"),
|
|
266
|
-
}),
|
|
267
|
-
);
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it("CopilotKit-like weather tool schema", () => {
|
|
271
|
-
expectIdenticalOutput(
|
|
272
|
-
z.object({
|
|
273
|
-
city: z.string().describe("The city to get weather for"),
|
|
274
|
-
units: z
|
|
275
|
-
.enum(["celsius", "fahrenheit"])
|
|
276
|
-
.optional()
|
|
277
|
-
.describe("Temperature units"),
|
|
278
|
-
}),
|
|
279
|
-
);
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it("agent-like action schema with nested results", () => {
|
|
283
|
-
expectIdenticalOutput(
|
|
284
|
-
z.object({
|
|
285
|
-
action: z.discriminatedUnion("type", [
|
|
286
|
-
z.object({
|
|
287
|
-
type: z.literal("search"),
|
|
288
|
-
query: z.string(),
|
|
289
|
-
maxResults: z.number().int().optional(),
|
|
290
|
-
}),
|
|
291
|
-
z.object({
|
|
292
|
-
type: z.literal("navigate"),
|
|
293
|
-
url: z.string().url(),
|
|
294
|
-
}),
|
|
295
|
-
z.object({
|
|
296
|
-
type: z.literal("execute"),
|
|
297
|
-
code: z.string(),
|
|
298
|
-
language: z.enum(["javascript", "python", "shell"]),
|
|
299
|
-
}),
|
|
300
|
-
]),
|
|
301
|
-
context: z.record(z.string(), z.unknown()).optional(),
|
|
302
|
-
}),
|
|
303
|
-
);
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
describe("described schemas (common in tool definitions)", () => {
|
|
308
|
-
it("preserves .describe() metadata", () => {
|
|
309
|
-
expectIdenticalOutput(
|
|
310
|
-
z
|
|
311
|
-
.object({
|
|
312
|
-
city: z.string().describe("The city name"),
|
|
313
|
-
count: z.number().describe("Number of results"),
|
|
314
|
-
})
|
|
315
|
-
.describe("Weather tool parameters"),
|
|
316
|
-
);
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
});
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// Server-only entry: A2UI depends on node:crypto. Do not re-export from the root.
|
|
2
|
-
export { A2UIMiddleware } from "@ag-ui/a2ui-middleware";
|
|
3
|
-
export type { A2UIMiddlewareConfig } from "@ag-ui/a2ui-middleware";
|
|
4
|
-
export * from "./open-generative-ui-middleware";
|
|
5
|
-
export * from "./recorded-events";
|