@copilotkit/shared 2.0.0-rc.7 → 2.0.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.umd.js +14 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/standard-schema.cjs +13 -0
- package/dist/standard-schema.cjs.map +1 -1
- package/dist/standard-schema.d.cts +9 -1
- package/dist/standard-schema.d.cts.map +1 -1
- package/dist/standard-schema.d.mts +9 -1
- package/dist/standard-schema.d.mts.map +1 -1
- package/dist/standard-schema.mjs +13 -1
- package/dist/standard-schema.mjs.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/standard-schema.test.ts +26 -1
- package/src/standard-schema.ts +15 -0
package/dist/package.cjs
CHANGED
package/dist/package.mjs
CHANGED
package/dist/standard-schema.cjs
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/standard-schema.ts
|
|
3
3
|
/**
|
|
4
|
+
* A Standard Schema that accepts any value and returns it unchanged.
|
|
5
|
+
*
|
|
6
|
+
* Wildcard tool call renderers use it when they declare no `args` schema.
|
|
7
|
+
*
|
|
8
|
+
* @internal Application authors must not depend on this contract.
|
|
9
|
+
*/
|
|
10
|
+
const ɵanySchema = { "~standard": {
|
|
11
|
+
version: 1,
|
|
12
|
+
vendor: "copilotkit",
|
|
13
|
+
validate: (value) => ({ value })
|
|
14
|
+
} };
|
|
15
|
+
/**
|
|
4
16
|
* Check whether a schema implements the Standard JSON Schema V1 protocol.
|
|
5
17
|
*/
|
|
6
18
|
function hasStandardJsonSchema(schema) {
|
|
@@ -28,4 +40,5 @@ function schemaToJsonSchema(schema, options) {
|
|
|
28
40
|
|
|
29
41
|
//#endregion
|
|
30
42
|
exports.schemaToJsonSchema = schemaToJsonSchema;
|
|
43
|
+
exports.ɵanySchema = ɵanySchema;
|
|
31
44
|
//# sourceMappingURL=standard-schema.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard-schema.cjs","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":"
|
|
1
|
+
{"version":3,"file":"standard-schema.cjs","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 * A Standard Schema that accepts any value and returns it unchanged.\n *\n * Wildcard tool call renderers use it when they declare no `args` schema.\n *\n * @internal Application authors must not depend on this contract.\n */\nexport const ɵanySchema: StandardSchemaV1<unknown, unknown> = {\n \"~standard\": {\n version: 1,\n vendor: \"copilotkit\",\n validate: (value) => ({ value }),\n },\n};\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":";;;;;;;;;AAcA,MAAa,aAAiD,EAC5D,aAAa;CACX,SAAS;CACT,QAAQ;CACR,WAAW,WAAW,EAAE,OAAO;CAChC,EACF;;;;AAwBD,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"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
2
|
|
|
3
3
|
//#region src/standard-schema.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A Standard Schema that accepts any value and returns it unchanged.
|
|
6
|
+
*
|
|
7
|
+
* Wildcard tool call renderers use it when they declare no `args` schema.
|
|
8
|
+
*
|
|
9
|
+
* @internal Application authors must not depend on this contract.
|
|
10
|
+
*/
|
|
11
|
+
declare const ɵanySchema: StandardSchemaV1<unknown, unknown>;
|
|
4
12
|
/**
|
|
5
13
|
* Extract the Output type from a StandardSchemaV1 schema.
|
|
6
14
|
* Replaces `z.infer<S>` for generic schema inference.
|
|
@@ -29,5 +37,5 @@ interface SchemaToJsonSchemaOptions {
|
|
|
29
37
|
*/
|
|
30
38
|
declare function schemaToJsonSchema(schema: StandardSchemaV1, options?: SchemaToJsonSchemaOptions): Record<string, unknown>;
|
|
31
39
|
//#endregion
|
|
32
|
-
export { InferSchemaOutput, SchemaToJsonSchemaOptions, type StandardJSONSchemaV1, type StandardSchemaV1, schemaToJsonSchema };
|
|
40
|
+
export { InferSchemaOutput, SchemaToJsonSchemaOptions, type StandardJSONSchemaV1, type StandardSchemaV1, schemaToJsonSchema, ɵanySchema };
|
|
33
41
|
//# sourceMappingURL=standard-schema.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard-schema.d.cts","names":[],"sources":["../src/standard-schema.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"standard-schema.d.cts","names":[],"sources":["../src/standard-schema.ts"],"mappings":";;;;AAcA;;;;;AAYA;cAZa,UAAA,EAAY,gBAAA;;;;;KAYb,iBAAA,MACV,CAAA,SAAU,gBAAA,iBAAiC,CAAA;AAAA,UAE5B,yBAAA;EAF4B;;;AAE7C;;EAME,eAAA,IACE,MAAA,WACA,OAAA;IAAY,YAAA;EAAA,MACT,MAAA;AAAA;;;;;;AAgCP;;;;;;iBAAgB,kBAAA,CACd,MAAA,EAAQ,gBAAA,EACR,OAAA,GAAU,yBAAA,GACT,MAAA"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
2
|
|
|
3
3
|
//#region src/standard-schema.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A Standard Schema that accepts any value and returns it unchanged.
|
|
6
|
+
*
|
|
7
|
+
* Wildcard tool call renderers use it when they declare no `args` schema.
|
|
8
|
+
*
|
|
9
|
+
* @internal Application authors must not depend on this contract.
|
|
10
|
+
*/
|
|
11
|
+
declare const ɵanySchema: StandardSchemaV1<unknown, unknown>;
|
|
4
12
|
/**
|
|
5
13
|
* Extract the Output type from a StandardSchemaV1 schema.
|
|
6
14
|
* Replaces `z.infer<S>` for generic schema inference.
|
|
@@ -29,5 +37,5 @@ interface SchemaToJsonSchemaOptions {
|
|
|
29
37
|
*/
|
|
30
38
|
declare function schemaToJsonSchema(schema: StandardSchemaV1, options?: SchemaToJsonSchemaOptions): Record<string, unknown>;
|
|
31
39
|
//#endregion
|
|
32
|
-
export { InferSchemaOutput, SchemaToJsonSchemaOptions, type StandardJSONSchemaV1, type StandardSchemaV1, schemaToJsonSchema };
|
|
40
|
+
export { InferSchemaOutput, SchemaToJsonSchemaOptions, type StandardJSONSchemaV1, type StandardSchemaV1, schemaToJsonSchema, ɵanySchema };
|
|
33
41
|
//# sourceMappingURL=standard-schema.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard-schema.d.mts","names":[],"sources":["../src/standard-schema.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"standard-schema.d.mts","names":[],"sources":["../src/standard-schema.ts"],"mappings":";;;;AAcA;;;;;AAYA;cAZa,UAAA,EAAY,gBAAA;;;;;KAYb,iBAAA,MACV,CAAA,SAAU,gBAAA,iBAAiC,CAAA;AAAA,UAE5B,yBAAA;EAF4B;;;AAE7C;;EAME,eAAA,IACE,MAAA,WACA,OAAA;IAAY,YAAA;EAAA,MACT,MAAA;AAAA;;;;;;AAgCP;;;;;;iBAAgB,kBAAA,CACd,MAAA,EAAQ,gBAAA,EACR,OAAA,GAAU,yBAAA,GACT,MAAA"}
|
package/dist/standard-schema.mjs
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
//#region src/standard-schema.ts
|
|
2
2
|
/**
|
|
3
|
+
* A Standard Schema that accepts any value and returns it unchanged.
|
|
4
|
+
*
|
|
5
|
+
* Wildcard tool call renderers use it when they declare no `args` schema.
|
|
6
|
+
*
|
|
7
|
+
* @internal Application authors must not depend on this contract.
|
|
8
|
+
*/
|
|
9
|
+
const ɵanySchema = { "~standard": {
|
|
10
|
+
version: 1,
|
|
11
|
+
vendor: "copilotkit",
|
|
12
|
+
validate: (value) => ({ value })
|
|
13
|
+
} };
|
|
14
|
+
/**
|
|
3
15
|
* Check whether a schema implements the Standard JSON Schema V1 protocol.
|
|
4
16
|
*/
|
|
5
17
|
function hasStandardJsonSchema(schema) {
|
|
@@ -26,5 +38,5 @@ function schemaToJsonSchema(schema, options) {
|
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
//#endregion
|
|
29
|
-
export { schemaToJsonSchema };
|
|
41
|
+
export { schemaToJsonSchema, ɵanySchema };
|
|
30
42
|
//# sourceMappingURL=standard-schema.mjs.map
|
|
@@ -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 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":";;;;
|
|
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 * A Standard Schema that accepts any value and returns it unchanged.\n *\n * Wildcard tool call renderers use it when they declare no `args` schema.\n *\n * @internal Application authors must not depend on this contract.\n */\nexport const ɵanySchema: StandardSchemaV1<unknown, unknown> = {\n \"~standard\": {\n version: 1,\n vendor: \"copilotkit\",\n validate: (value) => ({ value }),\n },\n};\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":";;;;;;;;AAcA,MAAa,aAAiD,EAC5D,aAAa;CACX,SAAS;CACT,QAAQ;CACR,WAAW,WAAW,EAAE,OAAO;CAChC,EACF;;;;AAwBD,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"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import * as v from "valibot";
|
|
|
4
4
|
import { toStandardJsonSchema } from "@valibot/to-json-schema";
|
|
5
5
|
import { type } from "arktype";
|
|
6
6
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
7
|
-
import { schemaToJsonSchema } from "../standard-schema";
|
|
7
|
+
import { schemaToJsonSchema, ɵanySchema } from "../standard-schema";
|
|
8
8
|
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
9
9
|
|
|
10
10
|
describe("schemaToJsonSchema", () => {
|
|
@@ -357,3 +357,28 @@ describe("schemaToJsonSchema", () => {
|
|
|
357
357
|
});
|
|
358
358
|
});
|
|
359
359
|
});
|
|
360
|
+
|
|
361
|
+
describe("ɵanySchema", () => {
|
|
362
|
+
it("identifies itself as a CopilotKit Standard Schema V1", () => {
|
|
363
|
+
expect(ɵanySchema["~standard"].version).toBe(1);
|
|
364
|
+
expect(ɵanySchema["~standard"].vendor).toBe("copilotkit");
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it("returns the value it was given, unchanged", async () => {
|
|
368
|
+
const args = { city: "Berlin", days: [1, 2] };
|
|
369
|
+
|
|
370
|
+
const result = await ɵanySchema["~standard"].validate(args);
|
|
371
|
+
|
|
372
|
+
expect(result).toEqual({ value: { city: "Berlin", days: [1, 2] } });
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it.each([undefined, null, "", 0, false])(
|
|
376
|
+
"accepts %j without issues",
|
|
377
|
+
async (input) => {
|
|
378
|
+
const result = await ɵanySchema["~standard"].validate(input);
|
|
379
|
+
|
|
380
|
+
expect(result).toEqual({ value: input });
|
|
381
|
+
expect(result).not.toHaveProperty("issues");
|
|
382
|
+
},
|
|
383
|
+
);
|
|
384
|
+
});
|
package/src/standard-schema.ts
CHANGED
|
@@ -5,6 +5,21 @@ import type {
|
|
|
5
5
|
|
|
6
6
|
export type { StandardSchemaV1, StandardJSONSchemaV1 };
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* A Standard Schema that accepts any value and returns it unchanged.
|
|
10
|
+
*
|
|
11
|
+
* Wildcard tool call renderers use it when they declare no `args` schema.
|
|
12
|
+
*
|
|
13
|
+
* @internal Application authors must not depend on this contract.
|
|
14
|
+
*/
|
|
15
|
+
export const ɵanySchema: StandardSchemaV1<unknown, unknown> = {
|
|
16
|
+
"~standard": {
|
|
17
|
+
version: 1,
|
|
18
|
+
vendor: "copilotkit",
|
|
19
|
+
validate: (value) => ({ value }),
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
8
23
|
/**
|
|
9
24
|
* Extract the Output type from a StandardSchemaV1 schema.
|
|
10
25
|
* Replaces `z.infer<S>` for generic schema inference.
|