@copilotkit/shared 1.55.3 → 1.56.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.
Files changed (79) hide show
  1. package/dist/a2ui-prompts.cjs +31 -22
  2. package/dist/a2ui-prompts.cjs.map +1 -1
  3. package/dist/a2ui-prompts.d.cts +2 -2
  4. package/dist/a2ui-prompts.d.cts.map +1 -1
  5. package/dist/a2ui-prompts.d.mts +2 -2
  6. package/dist/a2ui-prompts.d.mts.map +1 -1
  7. package/dist/a2ui-prompts.mjs +31 -22
  8. package/dist/a2ui-prompts.mjs.map +1 -1
  9. package/dist/debug.cjs +38 -0
  10. package/dist/debug.cjs.map +1 -0
  11. package/dist/debug.d.cts +29 -0
  12. package/dist/debug.d.cts.map +1 -0
  13. package/dist/debug.d.mts +29 -0
  14. package/dist/debug.d.mts.map +1 -0
  15. package/dist/debug.mjs +37 -0
  16. package/dist/debug.mjs.map +1 -0
  17. package/dist/index.cjs +4 -0
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +3 -1
  20. package/dist/index.d.cts.map +1 -1
  21. package/dist/index.d.mts +3 -1
  22. package/dist/index.d.mts.map +1 -1
  23. package/dist/index.mjs +3 -1
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/index.umd.js +137 -30
  26. package/dist/index.umd.js.map +1 -1
  27. package/dist/package.cjs +1 -1
  28. package/dist/package.mjs +1 -1
  29. package/dist/standard-schema.cjs +4 -2
  30. package/dist/standard-schema.cjs.map +1 -1
  31. package/dist/standard-schema.d.cts +3 -2
  32. package/dist/standard-schema.d.cts.map +1 -1
  33. package/dist/standard-schema.d.mts +3 -2
  34. package/dist/standard-schema.d.mts.map +1 -1
  35. package/dist/standard-schema.mjs +4 -2
  36. package/dist/standard-schema.mjs.map +1 -1
  37. package/dist/utils/clipboard.cjs +28 -0
  38. package/dist/utils/clipboard.cjs.map +1 -0
  39. package/dist/utils/clipboard.d.cts +14 -0
  40. package/dist/utils/clipboard.d.cts.map +1 -0
  41. package/dist/utils/clipboard.d.mts +14 -0
  42. package/dist/utils/clipboard.d.mts.map +1 -0
  43. package/dist/utils/clipboard.mjs +27 -0
  44. package/dist/utils/clipboard.mjs.map +1 -0
  45. package/dist/utils/index.cjs +1 -0
  46. package/dist/utils/index.cjs.map +1 -1
  47. package/dist/utils/index.d.cts +1 -0
  48. package/dist/utils/index.d.cts.map +1 -1
  49. package/dist/utils/index.d.mts +1 -0
  50. package/dist/utils/index.d.mts.map +1 -1
  51. package/dist/utils/index.mjs +1 -0
  52. package/dist/utils/index.mjs.map +1 -1
  53. package/dist/utils/json-schema.cjs +36 -5
  54. package/dist/utils/json-schema.cjs.map +1 -1
  55. package/dist/utils/json-schema.d.cts +1 -1
  56. package/dist/utils/json-schema.d.cts.map +1 -1
  57. package/dist/utils/json-schema.d.mts +1 -1
  58. package/dist/utils/json-schema.d.mts.map +1 -1
  59. package/dist/utils/json-schema.mjs +36 -5
  60. package/dist/utils/json-schema.mjs.map +1 -1
  61. package/dist/utils/types.cjs.map +1 -1
  62. package/dist/utils/types.d.cts +3 -0
  63. package/dist/utils/types.d.cts.map +1 -1
  64. package/dist/utils/types.d.mts +3 -0
  65. package/dist/utils/types.d.mts.map +1 -1
  66. package/dist/utils/types.mjs.map +1 -1
  67. package/package.json +1 -1
  68. package/src/__tests__/debug.test.ts +116 -0
  69. package/src/__tests__/standard-schema.test.ts +92 -0
  70. package/src/a2ui-prompts.ts +31 -22
  71. package/src/debug.ts +55 -0
  72. package/src/index.ts +1 -0
  73. package/src/standard-schema.ts +9 -3
  74. package/src/utils/__tests__/clipboard.test.ts +87 -0
  75. package/src/utils/__tests__/json-schema.test.ts +250 -1
  76. package/src/utils/clipboard.ts +23 -0
  77. package/src/utils/index.ts +1 -0
  78. package/src/utils/json-schema.ts +84 -3
  79. package/src/utils/types.ts +3 -0
@@ -12,12 +12,14 @@ function hasStandardJsonSchema(schema) {
12
12
  * Strategy:
13
13
  * 1. If the schema implements Standard JSON Schema V1 (`~standard.jsonSchema`),
14
14
  * call `schema['~standard'].jsonSchema.input({ target: 'draft-07' })`.
15
- * 2. If the schema is a Zod v3 schema (`~standard.vendor === 'zod'`), use the
15
+ * 2. If the schema exposes a `toJSONSchema()` method (Zod v4), call it directly.
16
+ * 3. If the schema is a Zod v3 schema (`~standard.vendor === 'zod'`), use the
16
17
  * injected `zodToJsonSchema()` function.
17
- * 3. Otherwise throw a descriptive error.
18
+ * 4. Otherwise throw a descriptive error.
18
19
  */
19
20
  function schemaToJsonSchema(schema, options) {
20
21
  if (hasStandardJsonSchema(schema)) return schema["~standard"].jsonSchema.input({ target: "draft-07" });
22
+ if (typeof schema.toJSONSchema === "function") return schema.toJSONSchema();
21
23
  const vendor = schema["~standard"].vendor;
22
24
  if (vendor === "zod" && options?.zodToJsonSchema) return options.zodToJsonSchema(schema, { $refStrategy: "none" });
23
25
  throw new Error(`Cannot convert schema to JSON Schema. The schema (vendor: "${vendor}") does not implement Standard JSON Schema V1 and no zodToJsonSchema fallback is available. Use a library that supports Standard JSON Schema (e.g., Zod 3.24+, Valibot v1+, ArkType v2+) or pass a zodToJsonSchema function in options.`);
@@ -1 +1 @@
1
- {"version":3,"file":"standard-schema.mjs","names":[],"sources":["../src/standard-schema.ts"],"sourcesContent":["import type {\n StandardSchemaV1,\n StandardJSONSchemaV1,\n} from \"@standard-schema/spec\";\n\nexport type { StandardSchemaV1, StandardJSONSchemaV1 };\n\n/**\n * Extract the Output type from a StandardSchemaV1 schema.\n * Replaces `z.infer<S>` for generic schema inference.\n */\nexport type InferSchemaOutput<S> =\n S extends StandardSchemaV1<any, infer O> ? O : never;\n\nexport interface SchemaToJsonSchemaOptions {\n /**\n * Injected `zodToJsonSchema` function so that `shared` does not depend on\n * `zod-to-json-schema`. Required when the schema is a Zod v3 schema that\n * does not implement Standard JSON Schema V1.\n */\n zodToJsonSchema?: (\n schema: unknown,\n options?: { $refStrategy?: string },\n ) => Record<string, unknown>;\n}\n\n/**\n * Check whether a schema implements the Standard JSON Schema V1 protocol.\n */\nfunction hasStandardJsonSchema(\n schema: StandardSchemaV1,\n): schema is StandardSchemaV1 & StandardJSONSchemaV1 {\n const props = schema[\"~standard\"];\n return (\n props != null &&\n typeof props === \"object\" &&\n \"jsonSchema\" in props &&\n props.jsonSchema != null &&\n typeof props.jsonSchema === \"object\" &&\n \"input\" in props.jsonSchema &&\n typeof props.jsonSchema.input === \"function\"\n );\n}\n\n/**\n * Convert any StandardSchemaV1-compatible schema to a JSON Schema object.\n *\n * Strategy:\n * 1. If the schema implements Standard JSON Schema V1 (`~standard.jsonSchema`),\n * call `schema['~standard'].jsonSchema.input({ target: 'draft-07' })`.\n * 2. If the schema is a Zod v3 schema (`~standard.vendor === 'zod'`), use the\n * injected `zodToJsonSchema()` function.\n * 3. Otherwise throw a descriptive error.\n */\nexport function schemaToJsonSchema(\n schema: StandardSchemaV1,\n options?: SchemaToJsonSchemaOptions,\n): Record<string, unknown> {\n // 1. Standard JSON Schema V1\n if (hasStandardJsonSchema(schema)) {\n return schema[\"~standard\"].jsonSchema.input({ target: \"draft-07\" });\n }\n\n // 2. Zod v3 fallback\n const vendor = schema[\"~standard\"].vendor;\n if (vendor === \"zod\" && options?.zodToJsonSchema) {\n return options.zodToJsonSchema(schema, { $refStrategy: \"none\" });\n }\n\n throw new Error(\n `Cannot convert schema to JSON Schema. The schema (vendor: \"${vendor}\") does not implement Standard JSON Schema V1 ` +\n `and no zodToJsonSchema fallback is available. ` +\n `Use a library that supports Standard JSON Schema (e.g., Zod 3.24+, Valibot v1+, ArkType v2+) ` +\n `or pass a zodToJsonSchema function in options.`,\n );\n}\n"],"mappings":";;;;AA6BA,SAAS,sBACP,QACmD;CACnD,MAAM,QAAQ,OAAO;AACrB,QACE,SAAS,QACT,OAAO,UAAU,YACjB,gBAAgB,SAChB,MAAM,cAAc,QACpB,OAAO,MAAM,eAAe,YAC5B,WAAW,MAAM,cACjB,OAAO,MAAM,WAAW,UAAU;;;;;;;;;;;;AActC,SAAgB,mBACd,QACA,SACyB;AAEzB,KAAI,sBAAsB,OAAO,CAC/B,QAAO,OAAO,aAAa,WAAW,MAAM,EAAE,QAAQ,YAAY,CAAC;CAIrE,MAAM,SAAS,OAAO,aAAa;AACnC,KAAI,WAAW,SAAS,SAAS,gBAC/B,QAAO,QAAQ,gBAAgB,QAAQ,EAAE,cAAc,QAAQ,CAAC;AAGlE,OAAM,IAAI,MACR,8DAA8D,OAAO,yOAItE"}
1
+ {"version":3,"file":"standard-schema.mjs","names":[],"sources":["../src/standard-schema.ts"],"sourcesContent":["import type {\n StandardSchemaV1,\n StandardJSONSchemaV1,\n} from \"@standard-schema/spec\";\n\nexport type { StandardSchemaV1, StandardJSONSchemaV1 };\n\n/**\n * Extract the Output type from a StandardSchemaV1 schema.\n * Replaces `z.infer<S>` for generic schema inference.\n */\nexport type InferSchemaOutput<S> =\n S extends StandardSchemaV1<any, infer O> ? O : never;\n\nexport interface SchemaToJsonSchemaOptions {\n /**\n * Injected `zodToJsonSchema` function so that `shared` does not depend on\n * `zod-to-json-schema`. Required when the schema is a Zod v3 schema that\n * does not implement Standard JSON Schema V1.\n */\n zodToJsonSchema?: (\n schema: unknown,\n options?: { $refStrategy?: string },\n ) => Record<string, unknown>;\n}\n\n/**\n * Check whether a schema implements the Standard JSON Schema V1 protocol.\n */\nfunction hasStandardJsonSchema(\n schema: StandardSchemaV1,\n): schema is StandardSchemaV1 & StandardJSONSchemaV1 {\n const props = schema[\"~standard\"];\n return (\n props != null &&\n typeof props === \"object\" &&\n \"jsonSchema\" in props &&\n props.jsonSchema != null &&\n typeof props.jsonSchema === \"object\" &&\n \"input\" in props.jsonSchema &&\n typeof props.jsonSchema.input === \"function\"\n );\n}\n\n/**\n * Convert any StandardSchemaV1-compatible schema to a JSON Schema object.\n *\n * Strategy:\n * 1. If the schema implements Standard JSON Schema V1 (`~standard.jsonSchema`),\n * call `schema['~standard'].jsonSchema.input({ target: 'draft-07' })`.\n * 2. If the schema exposes a `toJSONSchema()` method (Zod v4), call it directly.\n * 3. If the schema is a Zod v3 schema (`~standard.vendor === 'zod'`), use the\n * injected `zodToJsonSchema()` function.\n * 4. Otherwise throw a descriptive error.\n */\nexport function schemaToJsonSchema(\n schema: StandardSchemaV1,\n options?: SchemaToJsonSchemaOptions,\n): Record<string, unknown> {\n // 1. Standard JSON Schema V1\n if (hasStandardJsonSchema(schema)) {\n return schema[\"~standard\"].jsonSchema.input({ target: \"draft-07\" });\n }\n\n // 2. Zod v4 native — exposes toJSONSchema() on the schema itself\n if (typeof (schema as any).toJSONSchema === \"function\") {\n return (schema as any).toJSONSchema() as Record<string, unknown>;\n }\n\n // 3. Zod v3 fallback\n const vendor = schema[\"~standard\"].vendor;\n if (vendor === \"zod\" && options?.zodToJsonSchema) {\n return options.zodToJsonSchema(schema, { $refStrategy: \"none\" });\n }\n\n throw new Error(\n `Cannot convert schema to JSON Schema. The schema (vendor: \"${vendor}\") does not implement Standard JSON Schema V1 ` +\n `and no zodToJsonSchema fallback is available. ` +\n `Use a library that supports Standard JSON Schema (e.g., Zod 3.24+, Valibot v1+, ArkType v2+) ` +\n `or pass a zodToJsonSchema function in options.`,\n );\n}\n"],"mappings":";;;;AA6BA,SAAS,sBACP,QACmD;CACnD,MAAM,QAAQ,OAAO;AACrB,QACE,SAAS,QACT,OAAO,UAAU,YACjB,gBAAgB,SAChB,MAAM,cAAc,QACpB,OAAO,MAAM,eAAe,YAC5B,WAAW,MAAM,cACjB,OAAO,MAAM,WAAW,UAAU;;;;;;;;;;;;;AAetC,SAAgB,mBACd,QACA,SACyB;AAEzB,KAAI,sBAAsB,OAAO,CAC/B,QAAO,OAAO,aAAa,WAAW,MAAM,EAAE,QAAQ,YAAY,CAAC;AAIrE,KAAI,OAAQ,OAAe,iBAAiB,WAC1C,QAAQ,OAAe,cAAc;CAIvC,MAAM,SAAS,OAAO,aAAa;AACnC,KAAI,WAAW,SAAS,SAAS,gBAC/B,QAAO,QAAQ,gBAAgB,QAAQ,EAAE,cAAc,QAAQ,CAAC;AAGlE,OAAM,IAAI,MACR,8DAA8D,OAAO,yOAItE"}
@@ -0,0 +1,28 @@
1
+
2
+ //#region src/utils/clipboard.ts
3
+ /**
4
+ * Safely copies text to the clipboard.
5
+ *
6
+ * Checks that the Clipboard API is available before attempting the write,
7
+ * and catches any errors (e.g. permission denied, insecure context).
8
+ *
9
+ * @param text - The text to copy to the clipboard.
10
+ * @returns `true` if the text was successfully copied, `false` otherwise.
11
+ */
12
+ async function copyToClipboard(text) {
13
+ if (!navigator.clipboard?.writeText) {
14
+ console.error("Clipboard API is not available");
15
+ return false;
16
+ }
17
+ try {
18
+ await navigator.clipboard.writeText(text);
19
+ return true;
20
+ } catch (err) {
21
+ console.error("Failed to copy to clipboard:", err);
22
+ return false;
23
+ }
24
+ }
25
+
26
+ //#endregion
27
+ exports.copyToClipboard = copyToClipboard;
28
+ //# sourceMappingURL=clipboard.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.cjs","names":[],"sources":["../../src/utils/clipboard.ts"],"sourcesContent":["/**\n * Safely copies text to the clipboard.\n *\n * Checks that the Clipboard API is available before attempting the write,\n * and catches any errors (e.g. permission denied, insecure context).\n *\n * @param text - The text to copy to the clipboard.\n * @returns `true` if the text was successfully copied, `false` otherwise.\n */\nexport async function copyToClipboard(text: string): Promise<boolean> {\n if (!navigator.clipboard?.writeText) {\n console.error(\"Clipboard API is not available\");\n return false;\n }\n\n try {\n await navigator.clipboard.writeText(text);\n return true;\n } catch (err) {\n console.error(\"Failed to copy to clipboard:\", err);\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;AASA,eAAsB,gBAAgB,MAAgC;AACpE,KAAI,CAAC,UAAU,WAAW,WAAW;AACnC,UAAQ,MAAM,iCAAiC;AAC/C,SAAO;;AAGT,KAAI;AACF,QAAM,UAAU,UAAU,UAAU,KAAK;AACzC,SAAO;UACA,KAAK;AACZ,UAAQ,MAAM,gCAAgC,IAAI;AAClD,SAAO"}
@@ -0,0 +1,14 @@
1
+ //#region src/utils/clipboard.d.ts
2
+ /**
3
+ * Safely copies text to the clipboard.
4
+ *
5
+ * Checks that the Clipboard API is available before attempting the write,
6
+ * and catches any errors (e.g. permission denied, insecure context).
7
+ *
8
+ * @param text - The text to copy to the clipboard.
9
+ * @returns `true` if the text was successfully copied, `false` otherwise.
10
+ */
11
+ declare function copyToClipboard(text: string): Promise<boolean>;
12
+ //#endregion
13
+ export { copyToClipboard };
14
+ //# sourceMappingURL=clipboard.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.d.cts","names":[],"sources":["../../src/utils/clipboard.ts"],"mappings":";;AASA;;;;;;;;iBAAsB,eAAA,CAAgB,IAAA,WAAe,OAAA"}
@@ -0,0 +1,14 @@
1
+ //#region src/utils/clipboard.d.ts
2
+ /**
3
+ * Safely copies text to the clipboard.
4
+ *
5
+ * Checks that the Clipboard API is available before attempting the write,
6
+ * and catches any errors (e.g. permission denied, insecure context).
7
+ *
8
+ * @param text - The text to copy to the clipboard.
9
+ * @returns `true` if the text was successfully copied, `false` otherwise.
10
+ */
11
+ declare function copyToClipboard(text: string): Promise<boolean>;
12
+ //#endregion
13
+ export { copyToClipboard };
14
+ //# sourceMappingURL=clipboard.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.d.mts","names":[],"sources":["../../src/utils/clipboard.ts"],"mappings":";;AASA;;;;;;;;iBAAsB,eAAA,CAAgB,IAAA,WAAe,OAAA"}
@@ -0,0 +1,27 @@
1
+ //#region src/utils/clipboard.ts
2
+ /**
3
+ * Safely copies text to the clipboard.
4
+ *
5
+ * Checks that the Clipboard API is available before attempting the write,
6
+ * and catches any errors (e.g. permission denied, insecure context).
7
+ *
8
+ * @param text - The text to copy to the clipboard.
9
+ * @returns `true` if the text was successfully copied, `false` otherwise.
10
+ */
11
+ async function copyToClipboard(text) {
12
+ if (!navigator.clipboard?.writeText) {
13
+ console.error("Clipboard API is not available");
14
+ return false;
15
+ }
16
+ try {
17
+ await navigator.clipboard.writeText(text);
18
+ return true;
19
+ } catch (err) {
20
+ console.error("Failed to copy to clipboard:", err);
21
+ return false;
22
+ }
23
+ }
24
+
25
+ //#endregion
26
+ export { copyToClipboard };
27
+ //# sourceMappingURL=clipboard.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.mjs","names":[],"sources":["../../src/utils/clipboard.ts"],"sourcesContent":["/**\n * Safely copies text to the clipboard.\n *\n * Checks that the Clipboard API is available before attempting the write,\n * and catches any errors (e.g. permission denied, insecure context).\n *\n * @param text - The text to copy to the clipboard.\n * @returns `true` if the text was successfully copied, `false` otherwise.\n */\nexport async function copyToClipboard(text: string): Promise<boolean> {\n if (!navigator.clipboard?.writeText) {\n console.error(\"Clipboard API is not available\");\n return false;\n }\n\n try {\n await navigator.clipboard.writeText(text);\n return true;\n } catch (err) {\n console.error(\"Failed to copy to clipboard:\", err);\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,eAAsB,gBAAgB,MAAgC;AACpE,KAAI,CAAC,UAAU,WAAW,WAAW;AACnC,UAAQ,MAAM,iCAAiC;AAC/C,SAAO;;AAGT,KAAI;AACF,QAAM,UAAU,UAAU,UAAU,KAAK;AACzC,SAAO;UACA,KAAK;AACZ,UAAQ,MAAM,gCAAgC,IAAI;AAClD,SAAO"}
@@ -1,4 +1,5 @@
1
1
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ const require_clipboard = require('./clipboard.cjs');
2
3
  const require_conditions = require('./conditions.cjs');
3
4
  const require_console_styling = require('./console-styling.cjs');
4
5
  const require_errors = require('./errors.cjs');
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["PartialJSON"],"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from \"./conditions\";\nexport * from \"./console-styling\";\nexport * from \"./errors\";\nexport * from \"./json-schema\";\nexport * from \"./types\";\nexport * from \"./random-id\";\nexport * from \"./requests\";\n\nimport * as PartialJSON from \"partial-json\";\n\n/**\n * Safely parses a JSON string into an object\n * @param json The JSON string to parse\n * @param fallback Optional fallback value to return if parsing fails. If not provided or set to \"unset\", returns null\n * @returns The parsed JSON object, or the fallback value (or null) if parsing fails\n */\nexport function parseJson(json: string, fallback: any = \"unset\") {\n try {\n return JSON.parse(json);\n } catch (e) {\n return fallback === \"unset\" ? null : fallback;\n }\n}\n\n/**\n * Parses a partial/incomplete JSON string, returning as much valid data as possible.\n * Falls back to an empty object if parsing fails entirely.\n */\nexport function partialJSONParse(json: string) {\n try {\n const parsed = PartialJSON.parse(json);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n return parsed;\n }\n return {};\n } catch (error) {\n return {};\n }\n}\n\n/**\n * Returns an exponential backoff function suitable for Phoenix.js\n * `reconnectAfterMs` and `rejoinAfterMs` options.\n *\n * @param baseMs - Initial delay for the first retry attempt.\n * @param maxMs - Upper bound — delays are capped at this value.\n *\n * Phoenix calls the returned function with a 1-based `tries` count.\n * The delay doubles on each attempt: baseMs, 2×baseMs, 4×baseMs, …, maxMs.\n */\nexport function phoenixExponentialBackoff(\n baseMs: number,\n maxMs: number,\n): (tries: number) => number {\n return (tries: number) => Math.min(baseMs * 2 ** (tries - 1), maxMs);\n}\n\n/**\n * Maps an array of items to a new array, skipping items that throw errors during mapping\n * @param items The array to map\n * @param callback The mapping function to apply to each item\n * @returns A new array containing only the successfully mapped items\n */\nexport function tryMap<TItem, TMapped>(\n items: TItem[],\n callback: (item: TItem, index: number, array: TItem[]) => TMapped,\n): TMapped[] {\n return items.reduce<TMapped[]>((acc, item, index, array) => {\n try {\n acc.push(callback(item, index, array));\n } catch (error) {\n console.error(error);\n }\n return acc;\n }, []);\n}\n\n/**\n * Checks if the current environment is macOS\n * @returns {boolean} True if running on macOS, false otherwise\n */\nexport function isMacOS(): boolean {\n return /Mac|iMac|Macintosh/i.test(navigator.userAgent);\n}\n\n/**\n * Safely parses a JSON string into a tool arguments object.\n * Returns the parsed object only if it's a plain object (not an array, null, etc.).\n * Falls back to an empty object for any non-object JSON value or parse failure.\n */\nexport function safeParseToolArgs(raw: string): Record<string, unknown> {\n try {\n const parsed = JSON.parse(raw);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n return parsed;\n }\n console.warn(\n `[CopilotKit] Tool arguments parsed to non-object (${typeof parsed}), falling back to empty object`,\n );\n return {};\n } catch {\n console.warn(\n \"[CopilotKit] Failed to parse tool arguments, falling back to empty object\",\n );\n return {};\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,SAAgB,UAAU,MAAc,WAAgB,SAAS;AAC/D,KAAI;AACF,SAAO,KAAK,MAAM,KAAK;UAChB,GAAG;AACV,SAAO,aAAa,UAAU,OAAO;;;;;;;AAQzC,SAAgB,iBAAiB,MAAc;AAC7C,KAAI;EACF,MAAM,SAASA,aAAY,MAAM,KAAK;AACtC,MAAI,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,OAAO,CAChE,QAAO;AAET,SAAO,EAAE;UACF,OAAO;AACd,SAAO,EAAE;;;;;;;;;;;;;AAcb,SAAgB,0BACd,QACA,OAC2B;AAC3B,SAAQ,UAAkB,KAAK,IAAI,SAAS,MAAM,QAAQ,IAAI,MAAM;;;;;;;;AAStE,SAAgB,OACd,OACA,UACW;AACX,QAAO,MAAM,QAAmB,KAAK,MAAM,OAAO,UAAU;AAC1D,MAAI;AACF,OAAI,KAAK,SAAS,MAAM,OAAO,MAAM,CAAC;WAC/B,OAAO;AACd,WAAQ,MAAM,MAAM;;AAEtB,SAAO;IACN,EAAE,CAAC;;;;;;AAOR,SAAgB,UAAmB;AACjC,QAAO,sBAAsB,KAAK,UAAU,UAAU;;;;;;;AAQxD,SAAgB,kBAAkB,KAAsC;AACtE,KAAI;EACF,MAAM,SAAS,KAAK,MAAM,IAAI;AAC9B,MAAI,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,OAAO,CAChE,QAAO;AAET,UAAQ,KACN,qDAAqD,OAAO,OAAO,iCACpE;AACD,SAAO,EAAE;SACH;AACN,UAAQ,KACN,4EACD;AACD,SAAO,EAAE"}
1
+ {"version":3,"file":"index.cjs","names":["PartialJSON"],"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from \"./clipboard\";\nexport * from \"./conditions\";\nexport * from \"./console-styling\";\nexport * from \"./errors\";\nexport * from \"./json-schema\";\nexport * from \"./types\";\nexport * from \"./random-id\";\nexport * from \"./requests\";\n\nimport * as PartialJSON from \"partial-json\";\n\n/**\n * Safely parses a JSON string into an object\n * @param json The JSON string to parse\n * @param fallback Optional fallback value to return if parsing fails. If not provided or set to \"unset\", returns null\n * @returns The parsed JSON object, or the fallback value (or null) if parsing fails\n */\nexport function parseJson(json: string, fallback: any = \"unset\") {\n try {\n return JSON.parse(json);\n } catch (e) {\n return fallback === \"unset\" ? null : fallback;\n }\n}\n\n/**\n * Parses a partial/incomplete JSON string, returning as much valid data as possible.\n * Falls back to an empty object if parsing fails entirely.\n */\nexport function partialJSONParse(json: string) {\n try {\n const parsed = PartialJSON.parse(json);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n return parsed;\n }\n return {};\n } catch (error) {\n return {};\n }\n}\n\n/**\n * Returns an exponential backoff function suitable for Phoenix.js\n * `reconnectAfterMs` and `rejoinAfterMs` options.\n *\n * @param baseMs - Initial delay for the first retry attempt.\n * @param maxMs - Upper bound — delays are capped at this value.\n *\n * Phoenix calls the returned function with a 1-based `tries` count.\n * The delay doubles on each attempt: baseMs, 2×baseMs, 4×baseMs, …, maxMs.\n */\nexport function phoenixExponentialBackoff(\n baseMs: number,\n maxMs: number,\n): (tries: number) => number {\n return (tries: number) => Math.min(baseMs * 2 ** (tries - 1), maxMs);\n}\n\n/**\n * Maps an array of items to a new array, skipping items that throw errors during mapping\n * @param items The array to map\n * @param callback The mapping function to apply to each item\n * @returns A new array containing only the successfully mapped items\n */\nexport function tryMap<TItem, TMapped>(\n items: TItem[],\n callback: (item: TItem, index: number, array: TItem[]) => TMapped,\n): TMapped[] {\n return items.reduce<TMapped[]>((acc, item, index, array) => {\n try {\n acc.push(callback(item, index, array));\n } catch (error) {\n console.error(error);\n }\n return acc;\n }, []);\n}\n\n/**\n * Checks if the current environment is macOS\n * @returns {boolean} True if running on macOS, false otherwise\n */\nexport function isMacOS(): boolean {\n return /Mac|iMac|Macintosh/i.test(navigator.userAgent);\n}\n\n/**\n * Safely parses a JSON string into a tool arguments object.\n * Returns the parsed object only if it's a plain object (not an array, null, etc.).\n * Falls back to an empty object for any non-object JSON value or parse failure.\n */\nexport function safeParseToolArgs(raw: string): Record<string, unknown> {\n try {\n const parsed = JSON.parse(raw);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n return parsed;\n }\n console.warn(\n `[CopilotKit] Tool arguments parsed to non-object (${typeof parsed}), falling back to empty object`,\n );\n return {};\n } catch {\n console.warn(\n \"[CopilotKit] Failed to parse tool arguments, falling back to empty object\",\n );\n return {};\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,UAAU,MAAc,WAAgB,SAAS;AAC/D,KAAI;AACF,SAAO,KAAK,MAAM,KAAK;UAChB,GAAG;AACV,SAAO,aAAa,UAAU,OAAO;;;;;;;AAQzC,SAAgB,iBAAiB,MAAc;AAC7C,KAAI;EACF,MAAM,SAASA,aAAY,MAAM,KAAK;AACtC,MAAI,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,OAAO,CAChE,QAAO;AAET,SAAO,EAAE;UACF,OAAO;AACd,SAAO,EAAE;;;;;;;;;;;;;AAcb,SAAgB,0BACd,QACA,OAC2B;AAC3B,SAAQ,UAAkB,KAAK,IAAI,SAAS,MAAM,QAAQ,IAAI,MAAM;;;;;;;;AAStE,SAAgB,OACd,OACA,UACW;AACX,QAAO,MAAM,QAAmB,KAAK,MAAM,OAAO,UAAU;AAC1D,MAAI;AACF,OAAI,KAAK,SAAS,MAAM,OAAO,MAAM,CAAC;WAC/B,OAAO;AACd,WAAQ,MAAM,MAAM;;AAEtB,SAAO;IACN,EAAE,CAAC;;;;;;AAOR,SAAgB,UAAmB;AACjC,QAAO,sBAAsB,KAAK,UAAU,UAAU;;;;;;;AAQxD,SAAgB,kBAAkB,KAAsC;AACtE,KAAI;EACF,MAAM,SAAS,KAAK,MAAM,IAAI;AAC9B,MAAI,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,OAAO,CAChE,QAAO;AAET,UAAQ,KACN,qDAAqD,OAAO,OAAO,iCACpE;AACD,SAAO,EAAE;SACH;AACN,UAAQ,KACN,4EACD;AACD,SAAO,EAAE"}
@@ -1,3 +1,4 @@
1
+ import { copyToClipboard } from "./clipboard.cjs";
1
2
  import { BaseCondition, ComparisonCondition, ComparisonRule, Condition, ExistenceCondition, ExistenceRule, LogicalCondition, LogicalRule, Rule, executeConditions } from "./conditions.cjs";
2
3
  import { ConsoleColors, ConsoleStyles, logCopilotKitPlatformMessage, logStyled, publicApiKeyRequired, styledConsole } from "./console-styling.cjs";
3
4
  import { BANNER_ERROR_NAMES, COPILOT_CLOUD_ERROR_NAMES, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError, ensureStructuredError, getPossibleVersionMismatch, isStructuredCopilotKitError } from "./errors.cjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/utils/index.ts"],"mappings":";;;;;;;;;;;AAgBA;;;;iBAAgB,SAAA,CAAU,IAAA,UAAc,QAAA;AAYxC;;;;AAAA,iBAAgB,gBAAA,CAAiB,IAAA;AAsBjC;;;;;;;;;AAaA;AAbA,iBAAgB,yBAAA,CACd,MAAA,UACA,KAAA,YACE,KAAA;;;;;;;iBAUY,MAAA,gBAAA,CACd,KAAA,EAAO,KAAA,IACP,QAAA,GAAW,IAAA,EAAM,KAAA,EAAO,KAAA,UAAe,KAAA,EAAO,KAAA,OAAY,OAAA,GACzD,OAAA;;;;;iBAea,OAAA,CAAA;;;;;;iBASA,iBAAA,CAAkB,GAAA,WAAc,MAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/utils/index.ts"],"mappings":";;;;;;;;;;;;AAiBA;;;;iBAAgB,SAAA,CAAU,IAAA,UAAc,QAAA;AAYxC;;;;AAAA,iBAAgB,gBAAA,CAAiB,IAAA;AAsBjC;;;;;;;;;AAaA;AAbA,iBAAgB,yBAAA,CACd,MAAA,UACA,KAAA,YACE,KAAA;;;;;;;iBAUY,MAAA,gBAAA,CACd,KAAA,EAAO,KAAA,IACP,QAAA,GAAW,IAAA,EAAM,KAAA,EAAO,KAAA,UAAe,KAAA,EAAO,KAAA,OAAY,OAAA,GACzD,OAAA;;;;;iBAea,OAAA,CAAA;;;;;;iBASA,iBAAA,CAAkB,GAAA,WAAc,MAAA"}
@@ -1,3 +1,4 @@
1
+ import { copyToClipboard } from "./clipboard.mjs";
1
2
  import { BaseCondition, ComparisonCondition, ComparisonRule, Condition, ExistenceCondition, ExistenceRule, LogicalCondition, LogicalRule, Rule, executeConditions } from "./conditions.mjs";
2
3
  import { ConsoleColors, ConsoleStyles, logCopilotKitPlatformMessage, logStyled, publicApiKeyRequired, styledConsole } from "./console-styling.mjs";
3
4
  import { BANNER_ERROR_NAMES, COPILOT_CLOUD_ERROR_NAMES, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError, ensureStructuredError, getPossibleVersionMismatch, isStructuredCopilotKitError } from "./errors.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/utils/index.ts"],"mappings":";;;;;;;;;;;AAgBA;;;;iBAAgB,SAAA,CAAU,IAAA,UAAc,QAAA;AAYxC;;;;AAAA,iBAAgB,gBAAA,CAAiB,IAAA;AAsBjC;;;;;;;;;AAaA;AAbA,iBAAgB,yBAAA,CACd,MAAA,UACA,KAAA,YACE,KAAA;;;;;;;iBAUY,MAAA,gBAAA,CACd,KAAA,EAAO,KAAA,IACP,QAAA,GAAW,IAAA,EAAM,KAAA,EAAO,KAAA,UAAe,KAAA,EAAO,KAAA,OAAY,OAAA,GACzD,OAAA;;;;;iBAea,OAAA,CAAA;;;;;;iBASA,iBAAA,CAAkB,GAAA,WAAc,MAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/utils/index.ts"],"mappings":";;;;;;;;;;;;AAiBA;;;;iBAAgB,SAAA,CAAU,IAAA,UAAc,QAAA;AAYxC;;;;AAAA,iBAAgB,gBAAA,CAAiB,IAAA;AAsBjC;;;;;;;;;AAaA;AAbA,iBAAgB,yBAAA,CACd,MAAA,UACA,KAAA,YACE,KAAA;;;;;;;iBAUY,MAAA,gBAAA,CACd,KAAA,EAAO,KAAA,IACP,QAAA,GAAW,IAAA,EAAM,KAAA,EAAO,KAAA,UAAe,KAAA,EAAO,KAAA,OAAY,OAAA,GACzD,OAAA;;;;;iBAea,OAAA,CAAA;;;;;;iBASA,iBAAA,CAAkB,GAAA,WAAc,MAAA"}
@@ -1,3 +1,4 @@
1
+ import { copyToClipboard } from "./clipboard.mjs";
1
2
  import { executeConditions } from "./conditions.mjs";
2
3
  import { ConsoleColors, ConsoleStyles, logCopilotKitPlatformMessage, logStyled, publicApiKeyRequired, styledConsole } from "./console-styling.mjs";
3
4
  import { BANNER_ERROR_NAMES, COPILOT_CLOUD_ERROR_NAMES, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError, ensureStructuredError, getPossibleVersionMismatch, isStructuredCopilotKitError } from "./errors.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from \"./conditions\";\nexport * from \"./console-styling\";\nexport * from \"./errors\";\nexport * from \"./json-schema\";\nexport * from \"./types\";\nexport * from \"./random-id\";\nexport * from \"./requests\";\n\nimport * as PartialJSON from \"partial-json\";\n\n/**\n * Safely parses a JSON string into an object\n * @param json The JSON string to parse\n * @param fallback Optional fallback value to return if parsing fails. If not provided or set to \"unset\", returns null\n * @returns The parsed JSON object, or the fallback value (or null) if parsing fails\n */\nexport function parseJson(json: string, fallback: any = \"unset\") {\n try {\n return JSON.parse(json);\n } catch (e) {\n return fallback === \"unset\" ? null : fallback;\n }\n}\n\n/**\n * Parses a partial/incomplete JSON string, returning as much valid data as possible.\n * Falls back to an empty object if parsing fails entirely.\n */\nexport function partialJSONParse(json: string) {\n try {\n const parsed = PartialJSON.parse(json);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n return parsed;\n }\n return {};\n } catch (error) {\n return {};\n }\n}\n\n/**\n * Returns an exponential backoff function suitable for Phoenix.js\n * `reconnectAfterMs` and `rejoinAfterMs` options.\n *\n * @param baseMs - Initial delay for the first retry attempt.\n * @param maxMs - Upper bound — delays are capped at this value.\n *\n * Phoenix calls the returned function with a 1-based `tries` count.\n * The delay doubles on each attempt: baseMs, 2×baseMs, 4×baseMs, …, maxMs.\n */\nexport function phoenixExponentialBackoff(\n baseMs: number,\n maxMs: number,\n): (tries: number) => number {\n return (tries: number) => Math.min(baseMs * 2 ** (tries - 1), maxMs);\n}\n\n/**\n * Maps an array of items to a new array, skipping items that throw errors during mapping\n * @param items The array to map\n * @param callback The mapping function to apply to each item\n * @returns A new array containing only the successfully mapped items\n */\nexport function tryMap<TItem, TMapped>(\n items: TItem[],\n callback: (item: TItem, index: number, array: TItem[]) => TMapped,\n): TMapped[] {\n return items.reduce<TMapped[]>((acc, item, index, array) => {\n try {\n acc.push(callback(item, index, array));\n } catch (error) {\n console.error(error);\n }\n return acc;\n }, []);\n}\n\n/**\n * Checks if the current environment is macOS\n * @returns {boolean} True if running on macOS, false otherwise\n */\nexport function isMacOS(): boolean {\n return /Mac|iMac|Macintosh/i.test(navigator.userAgent);\n}\n\n/**\n * Safely parses a JSON string into a tool arguments object.\n * Returns the parsed object only if it's a plain object (not an array, null, etc.).\n * Falls back to an empty object for any non-object JSON value or parse failure.\n */\nexport function safeParseToolArgs(raw: string): Record<string, unknown> {\n try {\n const parsed = JSON.parse(raw);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n return parsed;\n }\n console.warn(\n `[CopilotKit] Tool arguments parsed to non-object (${typeof parsed}), falling back to empty object`,\n );\n return {};\n } catch {\n console.warn(\n \"[CopilotKit] Failed to parse tool arguments, falling back to empty object\",\n );\n return {};\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAgB,UAAU,MAAc,WAAgB,SAAS;AAC/D,KAAI;AACF,SAAO,KAAK,MAAM,KAAK;UAChB,GAAG;AACV,SAAO,aAAa,UAAU,OAAO;;;;;;;AAQzC,SAAgB,iBAAiB,MAAc;AAC7C,KAAI;EACF,MAAM,SAAS,YAAY,MAAM,KAAK;AACtC,MAAI,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,OAAO,CAChE,QAAO;AAET,SAAO,EAAE;UACF,OAAO;AACd,SAAO,EAAE;;;;;;;;;;;;;AAcb,SAAgB,0BACd,QACA,OAC2B;AAC3B,SAAQ,UAAkB,KAAK,IAAI,SAAS,MAAM,QAAQ,IAAI,MAAM;;;;;;;;AAStE,SAAgB,OACd,OACA,UACW;AACX,QAAO,MAAM,QAAmB,KAAK,MAAM,OAAO,UAAU;AAC1D,MAAI;AACF,OAAI,KAAK,SAAS,MAAM,OAAO,MAAM,CAAC;WAC/B,OAAO;AACd,WAAQ,MAAM,MAAM;;AAEtB,SAAO;IACN,EAAE,CAAC;;;;;;AAOR,SAAgB,UAAmB;AACjC,QAAO,sBAAsB,KAAK,UAAU,UAAU;;;;;;;AAQxD,SAAgB,kBAAkB,KAAsC;AACtE,KAAI;EACF,MAAM,SAAS,KAAK,MAAM,IAAI;AAC9B,MAAI,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,OAAO,CAChE,QAAO;AAET,UAAQ,KACN,qDAAqD,OAAO,OAAO,iCACpE;AACD,SAAO,EAAE;SACH;AACN,UAAQ,KACN,4EACD;AACD,SAAO,EAAE"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from \"./clipboard\";\nexport * from \"./conditions\";\nexport * from \"./console-styling\";\nexport * from \"./errors\";\nexport * from \"./json-schema\";\nexport * from \"./types\";\nexport * from \"./random-id\";\nexport * from \"./requests\";\n\nimport * as PartialJSON from \"partial-json\";\n\n/**\n * Safely parses a JSON string into an object\n * @param json The JSON string to parse\n * @param fallback Optional fallback value to return if parsing fails. If not provided or set to \"unset\", returns null\n * @returns The parsed JSON object, or the fallback value (or null) if parsing fails\n */\nexport function parseJson(json: string, fallback: any = \"unset\") {\n try {\n return JSON.parse(json);\n } catch (e) {\n return fallback === \"unset\" ? null : fallback;\n }\n}\n\n/**\n * Parses a partial/incomplete JSON string, returning as much valid data as possible.\n * Falls back to an empty object if parsing fails entirely.\n */\nexport function partialJSONParse(json: string) {\n try {\n const parsed = PartialJSON.parse(json);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n return parsed;\n }\n return {};\n } catch (error) {\n return {};\n }\n}\n\n/**\n * Returns an exponential backoff function suitable for Phoenix.js\n * `reconnectAfterMs` and `rejoinAfterMs` options.\n *\n * @param baseMs - Initial delay for the first retry attempt.\n * @param maxMs - Upper bound — delays are capped at this value.\n *\n * Phoenix calls the returned function with a 1-based `tries` count.\n * The delay doubles on each attempt: baseMs, 2×baseMs, 4×baseMs, …, maxMs.\n */\nexport function phoenixExponentialBackoff(\n baseMs: number,\n maxMs: number,\n): (tries: number) => number {\n return (tries: number) => Math.min(baseMs * 2 ** (tries - 1), maxMs);\n}\n\n/**\n * Maps an array of items to a new array, skipping items that throw errors during mapping\n * @param items The array to map\n * @param callback The mapping function to apply to each item\n * @returns A new array containing only the successfully mapped items\n */\nexport function tryMap<TItem, TMapped>(\n items: TItem[],\n callback: (item: TItem, index: number, array: TItem[]) => TMapped,\n): TMapped[] {\n return items.reduce<TMapped[]>((acc, item, index, array) => {\n try {\n acc.push(callback(item, index, array));\n } catch (error) {\n console.error(error);\n }\n return acc;\n }, []);\n}\n\n/**\n * Checks if the current environment is macOS\n * @returns {boolean} True if running on macOS, false otherwise\n */\nexport function isMacOS(): boolean {\n return /Mac|iMac|Macintosh/i.test(navigator.userAgent);\n}\n\n/**\n * Safely parses a JSON string into a tool arguments object.\n * Returns the parsed object only if it's a plain object (not an array, null, etc.).\n * Falls back to an empty object for any non-object JSON value or parse failure.\n */\nexport function safeParseToolArgs(raw: string): Record<string, unknown> {\n try {\n const parsed = JSON.parse(raw);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n return parsed;\n }\n console.warn(\n `[CopilotKit] Tool arguments parsed to non-object (${typeof parsed}), falling back to empty object`,\n );\n return {};\n } catch {\n console.warn(\n \"[CopilotKit] Failed to parse tool arguments, falling back to empty object\",\n );\n return {};\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAgB,UAAU,MAAc,WAAgB,SAAS;AAC/D,KAAI;AACF,SAAO,KAAK,MAAM,KAAK;UAChB,GAAG;AACV,SAAO,aAAa,UAAU,OAAO;;;;;;;AAQzC,SAAgB,iBAAiB,MAAc;AAC7C,KAAI;EACF,MAAM,SAAS,YAAY,MAAM,KAAK;AACtC,MAAI,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,OAAO,CAChE,QAAO;AAET,SAAO,EAAE;UACF,OAAO;AACd,SAAO,EAAE;;;;;;;;;;;;;AAcb,SAAgB,0BACd,QACA,OAC2B;AAC3B,SAAQ,UAAkB,KAAK,IAAI,SAAS,MAAM,QAAQ,IAAI,MAAM;;;;;;;;AAStE,SAAgB,OACd,OACA,UACW;AACX,QAAO,MAAM,QAAmB,KAAK,MAAM,OAAO,UAAU;AAC1D,MAAI;AACF,OAAI,KAAK,SAAS,MAAM,OAAO,MAAM,CAAC;WAC/B,OAAO;AACd,WAAQ,MAAM,MAAM;;AAEtB,SAAO;IACN,EAAE,CAAC;;;;;;AAOR,SAAgB,UAAmB;AACjC,QAAO,sBAAsB,KAAK,UAAU,UAAU;;;;;;;AAQxD,SAAgB,kBAAkB,KAAsC;AACtE,KAAI;EACF,MAAM,SAAS,KAAK,MAAM,IAAI;AAC9B,MAAI,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,OAAO,CAChE,QAAO;AAET,UAAQ,KACN,qDAAqD,OAAO,OAAO,iCACpE;AACD,SAAO,EAAE;SACH;AACN,UAAQ,KACN,4EACD;AACD,SAAO,EAAE"}
@@ -121,11 +121,36 @@ function convertAttribute(attribute) {
121
121
  };
122
122
  }
123
123
  }
124
- function convertJsonSchemaToZodSchema(jsonSchema, required) {
124
+ function convertJsonSchemaToZodSchema(jsonSchema, required, definitions, visitedRefs) {
125
+ if (jsonSchema.$ref && definitions) {
126
+ const refPath = jsonSchema.$ref.replace(/^#\/\$defs\/|^#\/definitions\//, "");
127
+ const refs = visitedRefs ?? /* @__PURE__ */ new Set();
128
+ if (refs.has(refPath)) {
129
+ console.warn(`[CopilotKit] Circular $ref detected for "${refPath}" — falling back to z.any()`);
130
+ let schema = zod.z.any();
131
+ if (jsonSchema.description) schema = schema.describe(jsonSchema.description);
132
+ return required ? schema : schema.optional();
133
+ }
134
+ const resolved = definitions[refPath];
135
+ if (resolved) {
136
+ const nextRefs = new Set(refs);
137
+ nextRefs.add(refPath);
138
+ return convertJsonSchemaToZodSchema(resolved, required, definitions, nextRefs);
139
+ }
140
+ }
141
+ const defs = definitions ?? jsonSchema.$defs ?? jsonSchema.definitions;
142
+ const unionVariants = jsonSchema.anyOf ?? jsonSchema.oneOf;
143
+ if (Array.isArray(unionVariants) && unionVariants.length > 0) {
144
+ if (unionVariants.length === 1) return convertJsonSchemaToZodSchema(unionVariants[0], required, defs, visitedRefs);
145
+ const schemas = unionVariants.map((v) => convertJsonSchemaToZodSchema(v, true, defs, visitedRefs));
146
+ let schema = zod.z.union(schemas);
147
+ if (jsonSchema.description) schema = schema.describe(jsonSchema.description);
148
+ return required ? schema : schema.optional();
149
+ }
125
150
  if (jsonSchema.type === "object") {
126
151
  const spec = {};
127
152
  if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) return !required ? zod.z.object(spec).optional() : zod.z.object(spec);
128
- for (const [key, value] of Object.entries(jsonSchema.properties)) spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false);
153
+ for (const [key, value] of Object.entries(jsonSchema.properties)) spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false, defs, visitedRefs);
129
154
  let schema = zod.z.object(spec).describe(jsonSchema.description);
130
155
  return required ? schema : schema.optional();
131
156
  } else if (jsonSchema.type === "string") {
@@ -135,18 +160,24 @@ function convertJsonSchemaToZodSchema(jsonSchema, required) {
135
160
  }
136
161
  let schema = zod.z.string().describe(jsonSchema.description);
137
162
  return required ? schema : schema.optional();
138
- } else if (jsonSchema.type === "number") {
163
+ } else if (jsonSchema.type === "number" || jsonSchema.type === "integer") {
139
164
  let schema = zod.z.number().describe(jsonSchema.description);
140
165
  return required ? schema : schema.optional();
141
166
  } else if (jsonSchema.type === "boolean") {
142
167
  let schema = zod.z.boolean().describe(jsonSchema.description);
143
168
  return required ? schema : schema.optional();
144
169
  } else if (jsonSchema.type === "array") {
145
- let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
170
+ let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true, defs, visitedRefs);
146
171
  let schema = zod.z.array(itemSchema).describe(jsonSchema.description);
147
172
  return required ? schema : schema.optional();
173
+ } else if (jsonSchema.type === "null") {
174
+ let schema = zod.z.null().describe(jsonSchema.description);
175
+ return required ? schema : schema.optional();
148
176
  }
149
- throw new Error("Invalid JSON schema");
177
+ console.warn(`[CopilotKit] Unsupported JSON schema type "${jsonSchema.type ?? "unknown"}" — falling back to z.any()`);
178
+ let schema = zod.z.any();
179
+ if (jsonSchema.description) schema = schema.describe(jsonSchema.description);
180
+ return required ? schema : schema.optional();
150
181
  }
151
182
  function getZodParameters(parameters) {
152
183
  if (!parameters) return zod.z.object({});
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema.cjs","names":["z"],"sources":["../../src/utils/json-schema.ts"],"sourcesContent":["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(\n actionParameters: Parameter[],\n): 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(\n jsonSchema: JSONSchema,\n): 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(\n name,\n schema,\n requiredFields.includes(name),\n );\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(\n schema.properties,\n )) {\n attributes.push(\n convertJsonSchemaToParameter(\n propName,\n propSchema,\n requiredFields.includes(propName),\n ),\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(\n schema.items.properties || {},\n )) {\n attributes.push(\n convertJsonSchemaToParameter(\n propName,\n propSchema,\n requiredFields.includes(propName),\n ),\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(\n jsonSchema: any,\n required: boolean,\n): 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 if (jsonSchema.enum && jsonSchema.enum.length > 0) {\n let schema = z\n .enum(jsonSchema.enum as [string, ...string[]])\n .describe(jsonSchema.description);\n return required ? schema : schema.optional();\n }\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\nexport function getZodParameters<T extends [] | Parameter[] | undefined>(\n parameters: T,\n): any {\n if (!parameters) return z.object({});\n const jsonParams = actionParametersToJsonSchema(parameters);\n return convertJsonSchemaToZodSchema(jsonParams, true);\n}\n"],"mappings":";;;;AAuCA,SAAgB,6BACd,kBACY;CAEZ,IAAI,aAAqC,EAAE;AAC3C,MAAK,IAAI,aAAa,oBAAoB,EAAE,CAC1C,YAAW,UAAU,QAAQ,iBAAiB,UAAU;CAG1D,IAAI,yBAAmC,EAAE;AACzC,MAAK,IAAI,OAAO,oBAAoB,EAAE,CACpC,KAAI,IAAI,aAAa,MACnB,wBAAuB,KAAK,IAAI,KAAK;AAKzC,QAAO;EACL,MAAM;EACN,YAAY;EACZ,UAAU;EACX;;AAIH,SAAgB,6BACd,YACa;AACb,KAAI,WAAW,SAAS,YAAY,CAAC,WAAW,WAC9C,QAAO,EAAE;CAGX,MAAM,aAA0B,EAAE;CAClC,MAAM,iBAAiB,WAAW,YAAY,EAAE;AAEhD,MAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,WAAW,WAAW,EAAE;EAClE,MAAM,YAAY,6BAChB,MACA,QACA,eAAe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IAAI,GAAG,MAC3D;EAEH,IAAI,SAASA,MAAE,OAAO,KAAK,CAAC,SAAS,WAAW,YAAY;AAC5D,SAAO,WAAW,SAAS,OAAO,UAAU;YACnC,WAAW,SAAS,UAAU;AACvC,MAAI,WAAW,QAAQ,WAAW,KAAK,SAAS,GAAG;GACjD,IAAI,SAASA,MACV,KAAK,WAAW,KAA8B,CAC9C,SAAS,WAAW,YAAY;AACnC,UAAO,WAAW,SAAS,OAAO,UAAU;;EAE9C,IAAI,SAASA,MAAE,QAAQ,CAAC,SAAS,WAAW,YAAY;AACxD,SAAO,WAAW,SAAS,OAAO,UAAU;YACnC,WAAW,SAAS,UAAU;EACvC,IAAI,SAASA,MAAE,QAAQ,CAAC,SAAS,WAAW,YAAY;AACxD,SAAO,WAAW,SAAS,OAAO,UAAU;YACnC,WAAW,SAAS,WAAW;EACxC,IAAI,SAASA,MAAE,SAAS,CAAC,SAAS,WAAW,YAAY;AACzD,SAAO,WAAW,SAAS,OAAO,UAAU;YACnC,WAAW,SAAS,SAAS;EACtC,IAAI,aAAa,6BAA6B,WAAW,OAAO,KAAK;EACrE,IAAI,SAASA,MAAE,MAAM,WAAW,CAAC,SAAS,WAAW,YAAY;AACjE,SAAO,WAAW,SAAS,OAAO,UAAU;;AAE9C,OAAM,IAAI,MAAM,sBAAsB;;AAGxC,SAAgB,iBACd,YACK;AACL,KAAI,CAAC,WAAY,QAAOA,MAAE,OAAO,EAAE,CAAC;AAEpC,QAAO,6BADY,6BAA6B,WAAW,EACX,KAAK"}
1
+ {"version":3,"file":"json-schema.cjs","names":["z"],"sources":["../../src/utils/json-schema.ts"],"sourcesContent":["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(\n actionParameters: Parameter[],\n): 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(\n jsonSchema: JSONSchema,\n): 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(\n name,\n schema,\n requiredFields.includes(name),\n );\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(\n schema.properties,\n )) {\n attributes.push(\n convertJsonSchemaToParameter(\n propName,\n propSchema,\n requiredFields.includes(propName),\n ),\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(\n schema.items.properties || {},\n )) {\n attributes.push(\n convertJsonSchemaToParameter(\n propName,\n propSchema,\n requiredFields.includes(propName),\n ),\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(\n jsonSchema: any,\n required: boolean,\n definitions?: Record<string, any>,\n visitedRefs?: Set<string>,\n): z.ZodSchema {\n // Resolve $ref references\n if (jsonSchema.$ref && definitions) {\n const refPath = jsonSchema.$ref.replace(\n /^#\\/\\$defs\\/|^#\\/definitions\\//,\n \"\",\n );\n\n // Detect circular $ref cycles\n const refs = visitedRefs ?? new Set<string>();\n if (refs.has(refPath)) {\n console.warn(\n `[CopilotKit] Circular $ref detected for \"${refPath}\" — falling back to z.any()`,\n );\n let schema = z.any();\n if (jsonSchema.description) {\n schema = schema.describe(jsonSchema.description);\n }\n return required ? schema : schema.optional();\n }\n\n const resolved = definitions[refPath];\n if (resolved) {\n // Clone the set so sibling branches don't see each other's visited refs\n const nextRefs = new Set(refs);\n nextRefs.add(refPath);\n return convertJsonSchemaToZodSchema(\n resolved,\n required,\n definitions,\n nextRefs,\n );\n }\n }\n\n // Collect top-level definitions for $ref resolution\n const defs = definitions ?? jsonSchema.$defs ?? jsonSchema.definitions;\n\n // Handle anyOf / oneOf as z.union\n const unionVariants = jsonSchema.anyOf ?? jsonSchema.oneOf;\n if (Array.isArray(unionVariants) && unionVariants.length > 0) {\n if (unionVariants.length === 1) {\n return convertJsonSchemaToZodSchema(\n unionVariants[0],\n required,\n defs,\n visitedRefs,\n );\n }\n const schemas = unionVariants.map((v: any) =>\n convertJsonSchemaToZodSchema(v, true, defs, visitedRefs),\n );\n let schema = z.union(\n schemas as [z.ZodSchema, z.ZodSchema, ...z.ZodSchema[]],\n );\n if (jsonSchema.description) {\n schema = schema.describe(jsonSchema.description);\n }\n return required ? schema : schema.optional();\n }\n\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 defs,\n visitedRefs,\n );\n }\n let schema = z.object(spec).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"string\") {\n if (jsonSchema.enum && jsonSchema.enum.length > 0) {\n let schema = z\n .enum(jsonSchema.enum as [string, ...string[]])\n .describe(jsonSchema.description);\n return required ? schema : schema.optional();\n }\n let schema = z.string().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"number\" || jsonSchema.type === \"integer\") {\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(\n jsonSchema.items,\n true,\n defs,\n visitedRefs,\n );\n let schema = z.array(itemSchema).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"null\") {\n let schema = z.null().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n }\n\n // Fallback: accept any value rather than throwing\n console.warn(\n `[CopilotKit] Unsupported JSON schema type \"${jsonSchema.type ?? \"unknown\"}\" — falling back to z.any()`,\n );\n let schema = z.any();\n if (jsonSchema.description) {\n schema = schema.describe(jsonSchema.description);\n }\n return required ? schema : schema.optional();\n}\n\nexport function getZodParameters<T extends [] | Parameter[] | undefined>(\n parameters: T,\n): any {\n if (!parameters) return z.object({});\n const jsonParams = actionParametersToJsonSchema(parameters);\n return convertJsonSchemaToZodSchema(jsonParams, true);\n}\n"],"mappings":";;;;AAuCA,SAAgB,6BACd,kBACY;CAEZ,IAAI,aAAqC,EAAE;AAC3C,MAAK,IAAI,aAAa,oBAAoB,EAAE,CAC1C,YAAW,UAAU,QAAQ,iBAAiB,UAAU;CAG1D,IAAI,yBAAmC,EAAE;AACzC,MAAK,IAAI,OAAO,oBAAoB,EAAE,CACpC,K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"}
@@ -29,7 +29,7 @@ type JSONSchemaArray = {
29
29
  type JSONSchema = JSONSchemaString | JSONSchemaNumber | JSONSchemaBoolean | JSONSchemaObject | JSONSchemaArray;
30
30
  declare function actionParametersToJsonSchema(actionParameters: Parameter[]): JSONSchema;
31
31
  declare function jsonSchemaToActionParameters(jsonSchema: JSONSchema): Parameter[];
32
- declare function convertJsonSchemaToZodSchema(jsonSchema: any, required: boolean): z.ZodSchema;
32
+ declare function convertJsonSchemaToZodSchema(jsonSchema: any, required: boolean, definitions?: Record<string, any>, visitedRefs?: Set<string>): z.ZodSchema;
33
33
  declare function getZodParameters<T extends [] | Parameter[] | undefined>(parameters: T): any;
34
34
  //#endregion
35
35
  export { JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, actionParametersToJsonSchema, convertJsonSchemaToZodSchema, getZodParameters, jsonSchemaToActionParameters };
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema.d.cts","names":[],"sources":["../../src/utils/json-schema.ts"],"mappings":";;;;KAGY,gBAAA;EACV,IAAA;EACA,WAAA;EACA,IAAA;AAAA;AAAA,KAGU,gBAAA;EACV,IAAA;EACA,WAAA;AAAA;AAAA,KAGU,iBAAA;EACV,IAAA;EACA,WAAA;AAAA;AAAA,KAGU,gBAAA;EACV,IAAA;EACA,UAAA,GAAa,MAAA,SAAe,UAAA;EAC5B,QAAA;EACA,WAAA;AAAA;AAAA,KAGU,eAAA;EACV,IAAA;EACA,KAAA,EAAO,UAAA;EACP,WAAA;AAAA;AAAA,KAGU,UAAA,GACR,gBAAA,GACA,gBAAA,GACA,iBAAA,GACA,gBAAA,GACA,eAAA;AAAA,iBAEY,4BAAA,CACd,gBAAA,EAAkB,SAAA,KACjB,UAAA;AAAA,iBAuBa,4BAAA,CACd,UAAA,EAAY,UAAA,GACX,SAAA;AAAA,iBA8Ka,4BAAA,CACd,UAAA,OACA,QAAA,YACC,CAAA,CAAE,SAAA;AAAA,iBAuCW,gBAAA,gBAAgC,SAAA,eAAA,CAC9C,UAAA,EAAY,CAAA"}
1
+ {"version":3,"file":"json-schema.d.cts","names":[],"sources":["../../src/utils/json-schema.ts"],"mappings":";;;;KAGY,gBAAA;EACV,IAAA;EACA,WAAA;EACA,IAAA;AAAA;AAAA,KAGU,gBAAA;EACV,IAAA;EACA,WAAA;AAAA;AAAA,KAGU,iBAAA;EACV,IAAA;EACA,WAAA;AAAA;AAAA,KAGU,gBAAA;EACV,IAAA;EACA,UAAA,GAAa,MAAA,SAAe,UAAA;EAC5B,QAAA;EACA,WAAA;AAAA;AAAA,KAGU,eAAA;EACV,IAAA;EACA,KAAA,EAAO,UAAA;EACP,WAAA;AAAA;AAAA,KAGU,UAAA,GACR,gBAAA,GACA,gBAAA,GACA,iBAAA,GACA,gBAAA,GACA,eAAA;AAAA,iBAEY,4BAAA,CACd,gBAAA,EAAkB,SAAA,KACjB,UAAA;AAAA,iBAuBa,4BAAA,CACd,UAAA,EAAY,UAAA,GACX,SAAA;AAAA,iBA8Ka,4BAAA,CACd,UAAA,OACA,QAAA,WACA,WAAA,GAAc,MAAA,eACd,WAAA,GAAc,GAAA,WACb,CAAA,CAAE,SAAA;AAAA,iBAsHW,gBAAA,gBAAgC,SAAA,eAAA,CAC9C,UAAA,EAAY,CAAA"}
@@ -29,7 +29,7 @@ type JSONSchemaArray = {
29
29
  type JSONSchema = JSONSchemaString | JSONSchemaNumber | JSONSchemaBoolean | JSONSchemaObject | JSONSchemaArray;
30
30
  declare function actionParametersToJsonSchema(actionParameters: Parameter[]): JSONSchema;
31
31
  declare function jsonSchemaToActionParameters(jsonSchema: JSONSchema): Parameter[];
32
- declare function convertJsonSchemaToZodSchema(jsonSchema: any, required: boolean): z.ZodSchema;
32
+ declare function convertJsonSchemaToZodSchema(jsonSchema: any, required: boolean, definitions?: Record<string, any>, visitedRefs?: Set<string>): z.ZodSchema;
33
33
  declare function getZodParameters<T extends [] | Parameter[] | undefined>(parameters: T): any;
34
34
  //#endregion
35
35
  export { JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, actionParametersToJsonSchema, convertJsonSchemaToZodSchema, getZodParameters, jsonSchemaToActionParameters };
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema.d.mts","names":[],"sources":["../../src/utils/json-schema.ts"],"mappings":";;;;KAGY,gBAAA;EACV,IAAA;EACA,WAAA;EACA,IAAA;AAAA;AAAA,KAGU,gBAAA;EACV,IAAA;EACA,WAAA;AAAA;AAAA,KAGU,iBAAA;EACV,IAAA;EACA,WAAA;AAAA;AAAA,KAGU,gBAAA;EACV,IAAA;EACA,UAAA,GAAa,MAAA,SAAe,UAAA;EAC5B,QAAA;EACA,WAAA;AAAA;AAAA,KAGU,eAAA;EACV,IAAA;EACA,KAAA,EAAO,UAAA;EACP,WAAA;AAAA;AAAA,KAGU,UAAA,GACR,gBAAA,GACA,gBAAA,GACA,iBAAA,GACA,gBAAA,GACA,eAAA;AAAA,iBAEY,4BAAA,CACd,gBAAA,EAAkB,SAAA,KACjB,UAAA;AAAA,iBAuBa,4BAAA,CACd,UAAA,EAAY,UAAA,GACX,SAAA;AAAA,iBA8Ka,4BAAA,CACd,UAAA,OACA,QAAA,YACC,CAAA,CAAE,SAAA;AAAA,iBAuCW,gBAAA,gBAAgC,SAAA,eAAA,CAC9C,UAAA,EAAY,CAAA"}
1
+ {"version":3,"file":"json-schema.d.mts","names":[],"sources":["../../src/utils/json-schema.ts"],"mappings":";;;;KAGY,gBAAA;EACV,IAAA;EACA,WAAA;EACA,IAAA;AAAA;AAAA,KAGU,gBAAA;EACV,IAAA;EACA,WAAA;AAAA;AAAA,KAGU,iBAAA;EACV,IAAA;EACA,WAAA;AAAA;AAAA,KAGU,gBAAA;EACV,IAAA;EACA,UAAA,GAAa,MAAA,SAAe,UAAA;EAC5B,QAAA;EACA,WAAA;AAAA;AAAA,KAGU,eAAA;EACV,IAAA;EACA,KAAA,EAAO,UAAA;EACP,WAAA;AAAA;AAAA,KAGU,UAAA,GACR,gBAAA,GACA,gBAAA,GACA,iBAAA,GACA,gBAAA,GACA,eAAA;AAAA,iBAEY,4BAAA,CACd,gBAAA,EAAkB,SAAA,KACjB,UAAA;AAAA,iBAuBa,4BAAA,CACd,UAAA,EAAY,UAAA,GACX,SAAA;AAAA,iBA8Ka,4BAAA,CACd,UAAA,OACA,QAAA,WACA,WAAA,GAAc,MAAA,eACd,WAAA,GAAc,GAAA,WACb,CAAA,CAAE,SAAA;AAAA,iBAsHW,gBAAA,gBAAgC,SAAA,eAAA,CAC9C,UAAA,EAAY,CAAA"}
@@ -120,11 +120,36 @@ function convertAttribute(attribute) {
120
120
  };
121
121
  }
122
122
  }
123
- function convertJsonSchemaToZodSchema(jsonSchema, required) {
123
+ function convertJsonSchemaToZodSchema(jsonSchema, required, definitions, visitedRefs) {
124
+ if (jsonSchema.$ref && definitions) {
125
+ const refPath = jsonSchema.$ref.replace(/^#\/\$defs\/|^#\/definitions\//, "");
126
+ const refs = visitedRefs ?? /* @__PURE__ */ new Set();
127
+ if (refs.has(refPath)) {
128
+ console.warn(`[CopilotKit] Circular $ref detected for "${refPath}" — falling back to z.any()`);
129
+ let schema = z.any();
130
+ if (jsonSchema.description) schema = schema.describe(jsonSchema.description);
131
+ return required ? schema : schema.optional();
132
+ }
133
+ const resolved = definitions[refPath];
134
+ if (resolved) {
135
+ const nextRefs = new Set(refs);
136
+ nextRefs.add(refPath);
137
+ return convertJsonSchemaToZodSchema(resolved, required, definitions, nextRefs);
138
+ }
139
+ }
140
+ const defs = definitions ?? jsonSchema.$defs ?? jsonSchema.definitions;
141
+ const unionVariants = jsonSchema.anyOf ?? jsonSchema.oneOf;
142
+ if (Array.isArray(unionVariants) && unionVariants.length > 0) {
143
+ if (unionVariants.length === 1) return convertJsonSchemaToZodSchema(unionVariants[0], required, defs, visitedRefs);
144
+ const schemas = unionVariants.map((v) => convertJsonSchemaToZodSchema(v, true, defs, visitedRefs));
145
+ let schema = z.union(schemas);
146
+ if (jsonSchema.description) schema = schema.describe(jsonSchema.description);
147
+ return required ? schema : schema.optional();
148
+ }
124
149
  if (jsonSchema.type === "object") {
125
150
  const spec = {};
126
151
  if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) return !required ? z.object(spec).optional() : z.object(spec);
127
- for (const [key, value] of Object.entries(jsonSchema.properties)) spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false);
152
+ for (const [key, value] of Object.entries(jsonSchema.properties)) spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false, defs, visitedRefs);
128
153
  let schema = z.object(spec).describe(jsonSchema.description);
129
154
  return required ? schema : schema.optional();
130
155
  } else if (jsonSchema.type === "string") {
@@ -134,18 +159,24 @@ function convertJsonSchemaToZodSchema(jsonSchema, required) {
134
159
  }
135
160
  let schema = z.string().describe(jsonSchema.description);
136
161
  return required ? schema : schema.optional();
137
- } else if (jsonSchema.type === "number") {
162
+ } else if (jsonSchema.type === "number" || jsonSchema.type === "integer") {
138
163
  let schema = z.number().describe(jsonSchema.description);
139
164
  return required ? schema : schema.optional();
140
165
  } else if (jsonSchema.type === "boolean") {
141
166
  let schema = z.boolean().describe(jsonSchema.description);
142
167
  return required ? schema : schema.optional();
143
168
  } else if (jsonSchema.type === "array") {
144
- let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
169
+ let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true, defs, visitedRefs);
145
170
  let schema = z.array(itemSchema).describe(jsonSchema.description);
146
171
  return required ? schema : schema.optional();
172
+ } else if (jsonSchema.type === "null") {
173
+ let schema = z.null().describe(jsonSchema.description);
174
+ return required ? schema : schema.optional();
147
175
  }
148
- throw new Error("Invalid JSON schema");
176
+ console.warn(`[CopilotKit] Unsupported JSON schema type "${jsonSchema.type ?? "unknown"}" — falling back to z.any()`);
177
+ let schema = z.any();
178
+ if (jsonSchema.description) schema = schema.describe(jsonSchema.description);
179
+ return required ? schema : schema.optional();
149
180
  }
150
181
  function getZodParameters(parameters) {
151
182
  if (!parameters) return z.object({});
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema.mjs","names":[],"sources":["../../src/utils/json-schema.ts"],"sourcesContent":["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(\n actionParameters: Parameter[],\n): 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(\n jsonSchema: JSONSchema,\n): 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(\n name,\n schema,\n requiredFields.includes(name),\n );\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(\n schema.properties,\n )) {\n attributes.push(\n convertJsonSchemaToParameter(\n propName,\n propSchema,\n requiredFields.includes(propName),\n ),\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(\n schema.items.properties || {},\n )) {\n attributes.push(\n convertJsonSchemaToParameter(\n propName,\n propSchema,\n requiredFields.includes(propName),\n ),\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(\n jsonSchema: any,\n required: boolean,\n): 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 if (jsonSchema.enum && jsonSchema.enum.length > 0) {\n let schema = z\n .enum(jsonSchema.enum as [string, ...string[]])\n .describe(jsonSchema.description);\n return required ? schema : schema.optional();\n }\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\nexport function getZodParameters<T extends [] | Parameter[] | undefined>(\n parameters: T,\n): any {\n if (!parameters) return z.object({});\n const jsonParams = actionParametersToJsonSchema(parameters);\n return convertJsonSchemaToZodSchema(jsonParams, true);\n}\n"],"mappings":";;;AAuCA,SAAgB,6BACd,kBACY;CAEZ,IAAI,aAAqC,EAAE;AAC3C,MAAK,IAAI,aAAa,oBAAoB,EAAE,CAC1C,YAAW,UAAU,QAAQ,iBAAiB,UAAU;CAG1D,IAAI,yBAAmC,EAAE;AACzC,MAAK,IAAI,OAAO,oBAAoB,EAAE,CACpC,KAAI,IAAI,aAAa,MACnB,wBAAuB,KAAK,IAAI,KAAK;AAKzC,QAAO;EACL,MAAM;EACN,YAAY;EACZ,UAAU;EACX;;AAIH,SAAgB,6BACd,YACa;AACb,KAAI,WAAW,SAAS,YAAY,CAAC,WAAW,WAC9C,QAAO,EAAE;CAGX,MAAM,aAA0B,EAAE;CAClC,MAAM,iBAAiB,WAAW,YAAY,EAAE;AAEhD,MAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,WAAW,WAAW,EAAE;EAClE,MAAM,YAAY,6BAChB,MACA,QACA,eAAe,SAAS,KAAK,CAC9B;AACD,aAAW,KAAK,UAAU;;AAG5B,QAAO;;AAIT,SAAS,6BACP,MACA,QACA,YACW;CACX,MAAM,gBAA2B;EAC/B;EACA,aAAa,OAAO;EACrB;AAED,KAAI,CAAC,WACH,eAAc,WAAW;AAG3B,SAAQ,OAAO,MAAf;EACE,KAAK,SACH,QAAO;GACL,GAAG;GACH,MAAM;GACN,GAAI,OAAO,QAAQ,EAAE,MAAM,OAAO,MAAM;GACzC;EACH,KAAK;EACL,KAAK,UACH,QAAO;GACL,GAAG;GACH,MAAM,OAAO;GACd;EACH,KAAK;AACH,OAAI,OAAO,YAAY;IACrB,MAAM,aAA0B,EAAE;IAClC,MAAM,iBAAiB,OAAO,YAAY,EAAE;AAE5C,SAAK,MAAM,CAAC,UAAU,eAAe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AU;YACnC,WAAW,SAAS,WAAW;EACxC,IAAI,SAAS,EAAE,SAAS,CAAC,SAAS,WAAW,YAAY;AACzD,SAAO,WAAW,SAAS,OAAO,UAAU;YACnC,WAAW,SAAS,SAAS;EACtC,IAAI,aAAa,6BAA6B,WAAW,OAAO,KAAK;EACrE,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC,SAAS,WAAW,YAAY;AACjE,SAAO,WAAW,SAAS,OAAO,UAAU;;AAE9C,OAAM,IAAI,MAAM,sBAAsB;;AAGxC,SAAgB,iBACd,YACK;AACL,KAAI,CAAC,WAAY,QAAO,EAAE,OAAO,EAAE,CAAC;AAEpC,QAAO,6BADY,6BAA6B,WAAW,EACX,KAAK"}
1
+ {"version":3,"file":"json-schema.mjs","names":[],"sources":["../../src/utils/json-schema.ts"],"sourcesContent":["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(\n actionParameters: Parameter[],\n): 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(\n jsonSchema: JSONSchema,\n): 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(\n name,\n schema,\n requiredFields.includes(name),\n );\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(\n schema.properties,\n )) {\n attributes.push(\n convertJsonSchemaToParameter(\n propName,\n propSchema,\n requiredFields.includes(propName),\n ),\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(\n schema.items.properties || {},\n )) {\n attributes.push(\n convertJsonSchemaToParameter(\n propName,\n propSchema,\n requiredFields.includes(propName),\n ),\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(\n jsonSchema: any,\n required: boolean,\n definitions?: Record<string, any>,\n visitedRefs?: Set<string>,\n): z.ZodSchema {\n // Resolve $ref references\n if (jsonSchema.$ref && definitions) {\n const refPath = jsonSchema.$ref.replace(\n /^#\\/\\$defs\\/|^#\\/definitions\\//,\n \"\",\n );\n\n // Detect circular $ref cycles\n const refs = visitedRefs ?? new Set<string>();\n if (refs.has(refPath)) {\n console.warn(\n `[CopilotKit] Circular $ref detected for \"${refPath}\" — falling back to z.any()`,\n );\n let schema = z.any();\n if (jsonSchema.description) {\n schema = schema.describe(jsonSchema.description);\n }\n return required ? schema : schema.optional();\n }\n\n const resolved = definitions[refPath];\n if (resolved) {\n // Clone the set so sibling branches don't see each other's visited refs\n const nextRefs = new Set(refs);\n nextRefs.add(refPath);\n return convertJsonSchemaToZodSchema(\n resolved,\n required,\n definitions,\n nextRefs,\n );\n }\n }\n\n // Collect top-level definitions for $ref resolution\n const defs = definitions ?? jsonSchema.$defs ?? jsonSchema.definitions;\n\n // Handle anyOf / oneOf as z.union\n const unionVariants = jsonSchema.anyOf ?? jsonSchema.oneOf;\n if (Array.isArray(unionVariants) && unionVariants.length > 0) {\n if (unionVariants.length === 1) {\n return convertJsonSchemaToZodSchema(\n unionVariants[0],\n required,\n defs,\n visitedRefs,\n );\n }\n const schemas = unionVariants.map((v: any) =>\n convertJsonSchemaToZodSchema(v, true, defs, visitedRefs),\n );\n let schema = z.union(\n schemas as [z.ZodSchema, z.ZodSchema, ...z.ZodSchema[]],\n );\n if (jsonSchema.description) {\n schema = schema.describe(jsonSchema.description);\n }\n return required ? schema : schema.optional();\n }\n\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 defs,\n visitedRefs,\n );\n }\n let schema = z.object(spec).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"string\") {\n if (jsonSchema.enum && jsonSchema.enum.length > 0) {\n let schema = z\n .enum(jsonSchema.enum as [string, ...string[]])\n .describe(jsonSchema.description);\n return required ? schema : schema.optional();\n }\n let schema = z.string().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"number\" || jsonSchema.type === \"integer\") {\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(\n jsonSchema.items,\n true,\n defs,\n visitedRefs,\n );\n let schema = z.array(itemSchema).describe(jsonSchema.description);\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"null\") {\n let schema = z.null().describe(jsonSchema.description);\n return required ? schema : schema.optional();\n }\n\n // Fallback: accept any value rather than throwing\n console.warn(\n `[CopilotKit] Unsupported JSON schema type \"${jsonSchema.type ?? \"unknown\"}\" — falling back to z.any()`,\n );\n let schema = z.any();\n if (jsonSchema.description) {\n schema = schema.describe(jsonSchema.description);\n }\n return required ? schema : schema.optional();\n}\n\nexport function getZodParameters<T extends [] | Parameter[] | undefined>(\n parameters: T,\n): any {\n if (!parameters) return z.object({});\n const jsonParams = actionParametersToJsonSchema(parameters);\n return convertJsonSchemaToZodSchema(jsonParams, true);\n}\n"],"mappings":";;;AAuCA,SAAgB,6BACd,kBACY;CAEZ,IAAI,aAAqC,EAAE;AAC3C,MAAK,IAAI,aAAa,oBAAoB,EAAE,CAC1C,YAAW,UAAU,QAAQ,iBAAiB,UAAU;CAG1D,IAAI,yBAAmC,EAAE;AACzC,MAAK,IAAI,OAAO,oBAAoB,EAAE,CACpC,KAAI,IAAI,aAAa,MACnB,wBAAuB,KAAK,IAAI,KAAK;AAKzC,QAAO;EACL,MAAM;EACN,YAAY;EACZ,UAAU;EACX;;AAIH,SAAgB,6BACd,YACa;AACb,KAAI,WAAW,SAAS,YAAY,CAAC,WAAW,WAC9C,QAAO,EAAE;CAGX,MAAM,aAA0B,EAAE;CAClC,MAAM,iBAAiB,WAAW,YAAY,EAAE;AAEhD,MAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,WAAW,WAAW,EAAE;EAClE,MAAM,YAAY,6BAChB,MACA,QACA,eAAe,SAAS,KAAK,CAC9B;AACD,aAAW,KAAK,UAAU;;AAG5B,QAAO;;AAIT,SAAS,6BACP,MACA,QACA,YACW;CACX,MAAM,gBAA2B;EAC/B;EACA,aAAa,OAAO;EACrB;AAED,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AAO,WAAW,SAAS,OAAO,UAAU;YACnC,WAAW,SAAS,WAAW;EACxC,IAAI,SAAS,EAAE,SAAS,CAAC,SAAS,WAAW,YAAY;AACzD,SAAO,WAAW,SAAS,OAAO,UAAU;YACnC,WAAW,SAAS,SAAS;EACtC,IAAI,aAAa,6BACf,WAAW,OACX,MACA,MACA,YACD;EACD,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC,SAAS,WAAW,YAAY;AACjE,SAAO,WAAW,SAAS,OAAO,UAAU;YACnC,WAAW,SAAS,QAAQ;EACrC,IAAI,SAAS,EAAE,MAAM,CAAC,SAAS,WAAW,YAAY;AACtD,SAAO,WAAW,SAAS,OAAO,UAAU;;AAI9C,SAAQ,KACN,8CAA8C,WAAW,QAAQ,UAAU,6BAC5E;CACD,IAAI,SAAS,EAAE,KAAK;AACpB,KAAI,WAAW,YACb,UAAS,OAAO,SAAS,WAAW,YAAY;AAElD,QAAO,WAAW,SAAS,OAAO,UAAU;;AAG9C,SAAgB,iBACd,YACK;AACL,KAAI,CAAC,WAAY,QAAO,EAAE,OAAO,EAAE,CAAC;AAEpC,QAAO,6BADY,6BAA6B,WAAW,EACX,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","names":[],"sources":["../../src/utils/types.ts"],"sourcesContent":["export type MaybePromise<T> = T | PromiseLike<T>;\n\n/**\n * More specific utility for records with at least one key\n */\nexport type NonEmptyRecord<T> =\n T extends Record<string, unknown>\n ? keyof T extends never\n ? never\n : T\n : never;\n\n/**\n * Type representing an agent's basic information\n */\nexport interface AgentDescription {\n name: string;\n className: string;\n description: string;\n}\n\nexport type RuntimeMode = \"sse\" | \"intelligence\";\n\nexport const RUNTIME_MODE_SSE = \"sse\" as const;\nexport const RUNTIME_MODE_INTELLIGENCE = \"intelligence\" as const;\n\nexport interface IntelligenceRuntimeInfo {\n wsUrl: string;\n}\n\nexport type RuntimeLicenseStatus =\n | \"valid\"\n | \"none\"\n | \"expired\"\n | \"expiring\"\n | \"invalid\"\n | \"unknown\";\n\nexport interface RuntimeInfo {\n version: string;\n agents: Record<string, AgentDescription>;\n audioFileTranscriptionEnabled: boolean;\n mode: RuntimeMode;\n intelligence?: IntelligenceRuntimeInfo;\n a2uiEnabled?: boolean;\n openGenerativeUIEnabled?: boolean;\n licenseStatus?: RuntimeLicenseStatus;\n}\n"],"mappings":";;AAuBA,MAAa,mBAAmB;AAChC,MAAa,4BAA4B"}
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../../src/utils/types.ts"],"sourcesContent":["import type { AgentCapabilities } from \"@ag-ui/core\";\n\nexport type MaybePromise<T> = T | PromiseLike<T>;\n\n/**\n * More specific utility for records with at least one key\n */\nexport type NonEmptyRecord<T> =\n T extends Record<string, unknown>\n ? keyof T extends never\n ? never\n : T\n : never;\n\n/**\n * Type representing an agent's basic information\n */\nexport interface AgentDescription {\n name: string;\n className: string;\n description: string;\n capabilities?: AgentCapabilities;\n}\n\nexport type RuntimeMode = \"sse\" | \"intelligence\";\n\nexport const RUNTIME_MODE_SSE = \"sse\" as const;\nexport const RUNTIME_MODE_INTELLIGENCE = \"intelligence\" as const;\n\nexport interface IntelligenceRuntimeInfo {\n wsUrl: string;\n}\n\nexport type RuntimeLicenseStatus =\n | \"valid\"\n | \"none\"\n | \"expired\"\n | \"expiring\"\n | \"invalid\"\n | \"unknown\";\n\nexport interface RuntimeInfo {\n version: string;\n agents: Record<string, AgentDescription>;\n audioFileTranscriptionEnabled: boolean;\n mode: RuntimeMode;\n intelligence?: IntelligenceRuntimeInfo;\n a2uiEnabled?: boolean;\n openGenerativeUIEnabled?: boolean;\n licenseStatus?: RuntimeLicenseStatus;\n}\n"],"mappings":";;AA0BA,MAAa,mBAAmB;AAChC,MAAa,4BAA4B"}
@@ -1,3 +1,5 @@
1
+ import { AgentCapabilities } from "@ag-ui/core";
2
+
1
3
  //#region src/utils/types.d.ts
2
4
  type MaybePromise<T> = T | PromiseLike<T>;
3
5
  /**
@@ -11,6 +13,7 @@ interface AgentDescription {
11
13
  name: string;
12
14
  className: string;
13
15
  description: string;
16
+ capabilities?: AgentCapabilities;
14
17
  }
15
18
  type RuntimeMode = "sse" | "intelligence";
16
19
  declare const RUNTIME_MODE_SSE: "sse";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/utils/types.ts"],"mappings":";KAAY,YAAA,MAAkB,CAAA,GAAI,WAAA,CAAY,CAAA;AAA9C;;;AAAA,KAKY,cAAA,MACV,CAAA,SAAU,MAAA,0BACA,CAAA,yBAEJ,CAAA;;;;UAMS,gBAAA;EACf,IAAA;EACA,SAAA;EACA,WAAA;AAAA;AAAA,KAGU,WAAA;AAAA,cAEC,gBAAA;AAAA,cACA,yBAAA;AAAA,UAEI,uBAAA;EACf,KAAA;AAAA;AAAA,KAGU,oBAAA;AAAA,UAQK,WAAA;EACf,OAAA;EACA,MAAA,EAAQ,MAAA,SAAe,gBAAA;EACvB,6BAAA;EACA,IAAA,EAAM,WAAA;EACN,YAAA,GAAe,uBAAA;EACf,WAAA;EACA,uBAAA;EACA,aAAA,GAAgB,oBAAA;AAAA"}
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/utils/types.ts"],"mappings":";;;KAEY,YAAA,MAAkB,CAAA,GAAI,WAAA,CAAY,CAAA;;AAA9C;;KAKY,cAAA,MACV,CAAA,SAAU,MAAA,0BACA,CAAA,yBAEJ,CAAA;;;;UAMS,gBAAA;EACf,IAAA;EACA,SAAA;EACA,WAAA;EACA,YAAA,GAAe,iBAAA;AAAA;AAAA,KAGL,WAAA;AAAA,cAEC,gBAAA;AAAA,cACA,yBAAA;AAAA,UAEI,uBAAA;EACf,KAAA;AAAA;AAAA,KAGU,oBAAA;AAAA,UAQK,WAAA;EACf,OAAA;EACA,MAAA,EAAQ,MAAA,SAAe,gBAAA;EACvB,6BAAA;EACA,IAAA,EAAM,WAAA;EACN,YAAA,GAAe,uBAAA;EACf,WAAA;EACA,uBAAA;EACA,aAAA,GAAgB,oBAAA;AAAA"}
@@ -1,3 +1,5 @@
1
+ import { AgentCapabilities } from "@ag-ui/core";
2
+
1
3
  //#region src/utils/types.d.ts
2
4
  type MaybePromise<T> = T | PromiseLike<T>;
3
5
  /**
@@ -11,6 +13,7 @@ interface AgentDescription {
11
13
  name: string;
12
14
  className: string;
13
15
  description: string;
16
+ capabilities?: AgentCapabilities;
14
17
  }
15
18
  type RuntimeMode = "sse" | "intelligence";
16
19
  declare const RUNTIME_MODE_SSE: "sse";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/utils/types.ts"],"mappings":";KAAY,YAAA,MAAkB,CAAA,GAAI,WAAA,CAAY,CAAA;AAA9C;;;AAAA,KAKY,cAAA,MACV,CAAA,SAAU,MAAA,0BACA,CAAA,yBAEJ,CAAA;;;;UAMS,gBAAA;EACf,IAAA;EACA,SAAA;EACA,WAAA;AAAA;AAAA,KAGU,WAAA;AAAA,cAEC,gBAAA;AAAA,cACA,yBAAA;AAAA,UAEI,uBAAA;EACf,KAAA;AAAA;AAAA,KAGU,oBAAA;AAAA,UAQK,WAAA;EACf,OAAA;EACA,MAAA,EAAQ,MAAA,SAAe,gBAAA;EACvB,6BAAA;EACA,IAAA,EAAM,WAAA;EACN,YAAA,GAAe,uBAAA;EACf,WAAA;EACA,uBAAA;EACA,aAAA,GAAgB,oBAAA;AAAA"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/utils/types.ts"],"mappings":";;;KAEY,YAAA,MAAkB,CAAA,GAAI,WAAA,CAAY,CAAA;;AAA9C;;KAKY,cAAA,MACV,CAAA,SAAU,MAAA,0BACA,CAAA,yBAEJ,CAAA;;;;UAMS,gBAAA;EACf,IAAA;EACA,SAAA;EACA,WAAA;EACA,YAAA,GAAe,iBAAA;AAAA;AAAA,KAGL,WAAA;AAAA,cAEC,gBAAA;AAAA,cACA,yBAAA;AAAA,UAEI,uBAAA;EACf,KAAA;AAAA;AAAA,KAGU,oBAAA;AAAA,UAQK,WAAA;EACf,OAAA;EACA,MAAA,EAAQ,MAAA,SAAe,gBAAA;EACvB,6BAAA;EACA,IAAA,EAAM,WAAA;EACN,YAAA,GAAe,uBAAA;EACf,WAAA;EACA,uBAAA;EACA,aAAA,GAAgB,oBAAA;AAAA"}