@copilotkit/shared 2.0.0-rc.6 → 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 +3 -3
- package/dist/index.d.mts +3 -3
- 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/dist/telemetry/lambda-client.cjs.map +1 -1
- package/dist/telemetry/lambda-client.d.cts.map +1 -1
- package/dist/telemetry/lambda-client.d.mts.map +1 -1
- package/dist/telemetry/lambda-client.mjs.map +1 -1
- package/dist/types/message.d.cts +1 -18
- package/dist/types/message.d.cts.map +1 -1
- package/dist/types/message.d.mts +1 -18
- package/dist/types/message.d.mts.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/src/telemetry/lambda-client.ts +3 -2
- package/src/types/message.ts +1 -19
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-client.cjs","names":[],"sources":["../../src/telemetry/lambda-client.ts"],"sourcesContent":["// Telemetry sink client.\n//\n// Posts events to a CopilotKit-controlled telemetry-sink endpoint, which\n// fans out to Scarf, Reo, and any future destinations. Replaces the direct\n// per-vendor calls (formerly a Scarf-specific client) so that vendor changes\n// don't require SDK releases and so that downstream services we don't want\n// exposed to OSS readers (e.g. the email-enrichment service backing Reo) stay\n// private.\n//\n// Two attribution modes:\n// - Identified: a standalone telemetry id or a CopilotKit license token is\n// configured. Standalone identity takes precedence. License tokens are\n// JWTs (header.payload.sig) whose payload carries `telemetry_id`; the SDK\n// base64url-decodes the payload — without verifying the Ed25519 signature,\n// which is the license-verifier's job. The resolved identity is emitted\n// only via `X-CopilotKit-Telemetry-Id`.\n// - Anonymous: no license token, or a malformed/non-JWT one. No\n// telemetry-id header; events still flow, attribution is best-effort\n// from request-level signals (IP, UA).\n//\n// Note: CopilotCloud customer API keys (`ck_<env>_<id>.<secret>`) are\n// unrelated to telemetry attribution. They flow into Segment / PostHog\n// via the v1 shared TelemetryClient and never reach this code path.\n//\n// Best-effort: every error is swallowed. Telemetry must not break the\n// host application.\n\nconst TELEMETRY_SINK_URL =\n (typeof process !== \"undefined\" && process.env?.COPILOTKIT_TELEMETRY_URL) ||\n \"https://telemetry.copilotkit.ai/ingest\";\n\nconst FETCH_TIMEOUT_MS = 3000;\nconst TELEMETRY_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;\n\nexport interface LambdaSendOptions {\n event: string;\n properties?: Record<string, unknown>;\n globalProperties?: Record<string, unknown>;\n packageName?: string;\n packageVersion?: string;\n /** Standalone analytics identity, resolved before any legacy license claim. */\n telemetryId?: string;\n // The CopilotKit license token (Ed25519-signed JWT), when one is\n // configured on the runtime. The sender base64url-decodes the payload\n // segment to extract `telemetry_id`; missing or malformed tokens\n // produce an anonymous send.\n licenseToken?: string;\n}\n\n/**\n * Return the first telemetry identity accepted by the ingest service.\n *\n * Empty and whitespace-only values are unconfigured placeholders and must not\n * suppress a later identity source. Leading and trailing HTTP spaces and tabs\n * are removed before validation. The ingest service accepts 1 to 128 ASCII\n * letters, digits, underscores, and hyphens.\n *\n * @internal\n */\nexport function firstNonBlankTelemetryId(\n ...candidates: ReadonlyArray<string | undefined>\n): string | undefined {\n for (const candidate of candidates) {\n if (candidate === undefined) {\n continue;\n }\n\n const normalized = candidate.replace(/^[\\t ]+|[\\t ]+$/g, \"\");\n if (TELEMETRY_ID_PATTERN.test(normalized)) {\n return normalized;\n }\n }\n\n return undefined;\n}\n\n// These fields aren't used by the telemetry service, so we strip them\n// at the wire boundary rather than rely on every caller to omit them.\n// Both the snake_case and camelCase variants are listed because callers\n// upstream use different conventions.\nconst STRIPPED_KEYS = new Set([\"cloud.public_api_key\", \"cloud.publicApiKey\"]);\n\nfunction stripCloudKeys(\n obj: Record<string, unknown> | undefined,\n): Record<string, unknown> {\n if (!obj) return {};\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n if (!STRIPPED_KEYS.has(k)) out[k] = v;\n }\n return out;\n}\n\n// Pull telemetry_id out of a CopilotKit license token without verifying\n// the signature. The token shape is a standard JWT\n// (`<header>.<payload>.<sig>`) with base64url-encoded segments; the\n// payload is UTF-8 JSON with a telemetry_id accepted by the ingest service.\n//\n// Verification (Ed25519, key rotation, expiry) is the license-verifier\n// package's job. For telemetry attribution we only need the claimed id —\n// the trust model is claim-only on the Lambda side anyway.\n//\n// Exported so TelemetryClient setters can detect unparseable tokens at\n// configuration time and surface a single warning, instead of silently\n// emitting anonymous events on every capture.\nexport function parseTelemetryIdFromLicense(token?: string): string | null {\n if (!token) return null;\n const parts = token.split(\".\");\n if (parts.length !== 3) return null;\n try {\n const payload = parts[1];\n if (!/^[A-Za-z0-9_-]+$/.test(payload) || payload.length % 4 === 1) {\n return null;\n }\n\n let b64 = payload.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padding = (4 - (b64.length % 4)) % 4;\n b64 += \"=\".repeat(padding);\n const json =\n typeof Buffer !== \"undefined\"\n ? Buffer.from(b64, \"base64\").toString(\"utf8\")\n : new TextDecoder().decode(\n Uint8Array.from(atob(b64), (character) => character.charCodeAt(0)),\n );\n const decoded = JSON.parse(json) as { telemetry_id?: unknown };\n const telemetryId =\n typeof decoded.telemetry_id === \"string\"\n ? decoded.telemetry_id\n : undefined;\n return firstNonBlankTelemetryId(telemetryId) ?? null;\n } catch {\n return null;\n }\n}\n\n// Parse the telemetry_id from a license token AND emit the rollout smoke\n// signal if the parse returned null. Returning the parsed id lets callers\n// cache it in one step (avoiding a second parseTelemetryIdFromLicense\n// pass) while keeping the warn text in lockstep between v1 (shared)
|
|
1
|
+
{"version":3,"file":"lambda-client.cjs","names":[],"sources":["../../src/telemetry/lambda-client.ts"],"sourcesContent":["// Telemetry sink client.\n//\n// Posts events to a CopilotKit-controlled telemetry-sink endpoint, which\n// fans out to Scarf, Reo, and any future destinations. Replaces the direct\n// per-vendor calls (formerly a Scarf-specific client) so that vendor changes\n// don't require SDK releases and so that downstream services we don't want\n// exposed to OSS readers (e.g. the email-enrichment service backing Reo) stay\n// private.\n//\n// Two attribution modes:\n// - Identified: a standalone telemetry id or a CopilotKit license token is\n// configured. Standalone identity takes precedence. License tokens are\n// JWTs (header.payload.sig) whose payload carries `telemetry_id`; the SDK\n// base64url-decodes the payload — without verifying the Ed25519 signature,\n// which is the license-verifier's job. The resolved identity is emitted\n// only via `X-CopilotKit-Telemetry-Id`.\n// - Anonymous: no license token, or a malformed/non-JWT one. No\n// telemetry-id header; events still flow, attribution is best-effort\n// from request-level signals (IP, UA).\n//\n// Note: CopilotCloud customer API keys (`ck_<env>_<id>.<secret>`) are\n// unrelated to telemetry attribution. They flow into Segment / PostHog\n// via the v1 shared TelemetryClient and never reach this code path.\n//\n// Best-effort: every error is swallowed. Telemetry must not break the\n// host application.\n\nconst TELEMETRY_SINK_URL =\n (typeof process !== \"undefined\" && process.env?.COPILOTKIT_TELEMETRY_URL) ||\n \"https://telemetry.copilotkit.ai/ingest\";\n\nconst FETCH_TIMEOUT_MS = 3000;\nconst TELEMETRY_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;\n\nexport interface LambdaSendOptions {\n event: string;\n properties?: Record<string, unknown>;\n globalProperties?: Record<string, unknown>;\n packageName?: string;\n packageVersion?: string;\n /** Standalone analytics identity, resolved before any legacy license claim. */\n telemetryId?: string;\n // The CopilotKit license token (Ed25519-signed JWT), when one is\n // configured on the runtime. The sender base64url-decodes the payload\n // segment to extract `telemetry_id`; missing or malformed tokens\n // produce an anonymous send.\n licenseToken?: string;\n}\n\n/**\n * Return the first telemetry identity accepted by the ingest service.\n *\n * Empty and whitespace-only values are unconfigured placeholders and must not\n * suppress a later identity source. Leading and trailing HTTP spaces and tabs\n * are removed before validation. The ingest service accepts 1 to 128 ASCII\n * letters, digits, underscores, and hyphens.\n *\n * @internal\n */\nexport function firstNonBlankTelemetryId(\n ...candidates: ReadonlyArray<string | undefined>\n): string | undefined {\n for (const candidate of candidates) {\n if (candidate === undefined) {\n continue;\n }\n\n const normalized = candidate.replace(/^[\\t ]+|[\\t ]+$/g, \"\");\n if (TELEMETRY_ID_PATTERN.test(normalized)) {\n return normalized;\n }\n }\n\n return undefined;\n}\n\n// These fields aren't used by the telemetry service, so we strip them\n// at the wire boundary rather than rely on every caller to omit them.\n// Both the snake_case and camelCase variants are listed because callers\n// upstream use different conventions.\nconst STRIPPED_KEYS = new Set([\"cloud.public_api_key\", \"cloud.publicApiKey\"]);\n\nfunction stripCloudKeys(\n obj: Record<string, unknown> | undefined,\n): Record<string, unknown> {\n if (!obj) return {};\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n if (!STRIPPED_KEYS.has(k)) out[k] = v;\n }\n return out;\n}\n\n// Pull telemetry_id out of a CopilotKit license token without verifying\n// the signature. The token shape is a standard JWT\n// (`<header>.<payload>.<sig>`) with base64url-encoded segments; the\n// payload is UTF-8 JSON with a telemetry_id accepted by the ingest service.\n//\n// Verification (Ed25519, key rotation, expiry) is the license-verifier\n// package's job. For telemetry attribution we only need the claimed id —\n// the trust model is claim-only on the Lambda side anyway.\n//\n// Exported so TelemetryClient setters can detect unparseable tokens at\n// configuration time and surface a single warning, instead of silently\n// emitting anonymous events on every capture.\nexport function parseTelemetryIdFromLicense(token?: string): string | null {\n if (!token) return null;\n const parts = token.split(\".\");\n if (parts.length !== 3) return null;\n try {\n const payload = parts[1];\n if (!/^[A-Za-z0-9_-]+$/.test(payload) || payload.length % 4 === 1) {\n return null;\n }\n\n let b64 = payload.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padding = (4 - (b64.length % 4)) % 4;\n b64 += \"=\".repeat(padding);\n const json =\n typeof Buffer !== \"undefined\"\n ? Buffer.from(b64, \"base64\").toString(\"utf8\")\n : new TextDecoder().decode(\n Uint8Array.from(atob(b64), (character) => character.charCodeAt(0)),\n );\n const decoded = JSON.parse(json) as { telemetry_id?: unknown };\n const telemetryId =\n typeof decoded.telemetry_id === \"string\"\n ? decoded.telemetry_id\n : undefined;\n return firstNonBlankTelemetryId(telemetryId) ?? null;\n } catch {\n return null;\n }\n}\n\n// Parse the telemetry_id from a license token AND emit the rollout smoke\n// signal if the parse returned null. Returning the parsed id lets callers\n// cache it in one step (avoiding a second parseTelemetryIdFromLicense\n// pass) while keeping the warn text in lockstep between the v1 (shared)\n// TelemetryClient.setLicenseToken and the v2 (runtime)\n// TelemetryClient.setTelemetryIdentity.\nexport function parseAndWarnTelemetryId(licenseToken: string): string | null {\n const telemetryId = parseTelemetryIdFromLicense(licenseToken);\n if (!telemetryId) {\n console.warn(\n \"[CopilotKit] License token did not yield a telemetry_id; telemetry events will be sent anonymously.\",\n );\n }\n return telemetryId;\n}\n\nexport async function send(opts: LambdaSendOptions): Promise<void> {\n try {\n const body = JSON.stringify({\n event: opts.event,\n properties: stripCloudKeys(opts.properties),\n global_properties: stripCloudKeys(opts.globalProperties),\n package: {\n name: opts.packageName,\n version: opts.packageVersion,\n },\n ts: Math.floor(Date.now() / 1000),\n });\n\n const telemetryId =\n firstNonBlankTelemetryId(opts.telemetryId) ??\n parseTelemetryIdFromLicense(opts.licenseToken);\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"User-Agent\": opts.packageName\n ? `CopilotKit-Runtime/${opts.packageVersion ?? \"unknown\"} (${opts.packageName})`\n : \"CopilotKit-Runtime\",\n };\n if (telemetryId) {\n headers[\"X-CopilotKit-Telemetry-Id\"] = telemetryId;\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n try {\n await fetch(TELEMETRY_SINK_URL, {\n method: \"POST\",\n headers,\n body,\n signal: controller.signal,\n });\n } finally {\n clearTimeout(timeoutId);\n }\n } catch {\n // Silent failure — telemetry must not break the application.\n }\n}\n\nexport const lambdaClient = { send };\n"],"mappings":";;AA2BA,MAAM,qBACH,OAAO,YAAY,eAAe,QAAQ,KAAK,4BAChD;AAEF,MAAM,mBAAmB;AACzB,MAAM,uBAAuB;;;;;;;;;;;AA2B7B,SAAgB,yBACd,GAAG,YACiB;AACpB,MAAK,MAAM,aAAa,YAAY;AAClC,MAAI,cAAc,OAChB;EAGF,MAAM,aAAa,UAAU,QAAQ,oBAAoB,GAAG;AAC5D,MAAI,qBAAqB,KAAK,WAAW,CACvC,QAAO;;;AAWb,MAAM,gBAAgB,IAAI,IAAI,CAAC,wBAAwB,qBAAqB,CAAC;AAE7E,SAAS,eACP,KACyB;AACzB,KAAI,CAAC,IAAK,QAAO,EAAE;CACnB,MAAM,MAA+B,EAAE;AACvC,MAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,IAAI,CACtC,KAAI,CAAC,cAAc,IAAI,EAAE,CAAE,KAAI,KAAK;AAEtC,QAAO;;AAeT,SAAgB,4BAA4B,OAA+B;AACzE,KAAI,CAAC,MAAO,QAAO;CACnB,MAAM,QAAQ,MAAM,MAAM,IAAI;AAC9B,KAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,KAAI;EACF,MAAM,UAAU,MAAM;AACtB,MAAI,CAAC,mBAAmB,KAAK,QAAQ,IAAI,QAAQ,SAAS,MAAM,EAC9D,QAAO;EAGT,IAAI,MAAM,QAAQ,QAAQ,MAAM,IAAI,CAAC,QAAQ,MAAM,IAAI;EACvD,MAAM,WAAW,IAAK,IAAI,SAAS,KAAM;AACzC,SAAO,IAAI,OAAO,QAAQ;EAC1B,MAAM,OACJ,OAAO,WAAW,cACd,OAAO,KAAK,KAAK,SAAS,CAAC,SAAS,OAAO,GAC3C,IAAI,aAAa,CAAC,OAChB,WAAW,KAAK,KAAK,IAAI,GAAG,cAAc,UAAU,WAAW,EAAE,CAAC,CACnE;EACP,MAAM,UAAU,KAAK,MAAM,KAAK;AAKhC,SAAO,yBAHL,OAAO,QAAQ,iBAAiB,WAC5B,QAAQ,eACR,OACsC,IAAI;SAC1C;AACN,SAAO;;;AAUX,SAAgB,wBAAwB,cAAqC;CAC3E,MAAM,cAAc,4BAA4B,aAAa;AAC7D,KAAI,CAAC,YACH,SAAQ,KACN,sGACD;AAEH,QAAO;;AAGT,eAAsB,KAAK,MAAwC;AACjE,KAAI;EACF,MAAM,OAAO,KAAK,UAAU;GAC1B,OAAO,KAAK;GACZ,YAAY,eAAe,KAAK,WAAW;GAC3C,mBAAmB,eAAe,KAAK,iBAAiB;GACxD,SAAS;IACP,MAAM,KAAK;IACX,SAAS,KAAK;IACf;GACD,IAAI,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;GAClC,CAAC;EAEF,MAAM,cACJ,yBAAyB,KAAK,YAAY,IAC1C,4BAA4B,KAAK,aAAa;EAChD,MAAM,UAAkC;GACtC,gBAAgB;GAChB,cAAc,KAAK,cACf,sBAAsB,KAAK,kBAAkB,UAAU,IAAI,KAAK,YAAY,KAC5E;GACL;AACD,MAAI,YACF,SAAQ,+BAA+B;EAGzC,MAAM,aAAa,IAAI,iBAAiB;EACxC,MAAM,YAAY,iBAAiB,WAAW,OAAO,EAAE,iBAAiB;AACxE,MAAI;AACF,SAAM,MAAM,oBAAoB;IAC9B,QAAQ;IACR;IACA;IACA,QAAQ,WAAW;IACpB,CAAC;YACM;AACR,gBAAa,UAAU;;SAEnB;;AAKV,MAAa,eAAe,EAAE,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-client.d.cts","names":[],"sources":["../../src/telemetry/lambda-client.ts"],"mappings":";UAkCiB,iBAAA;EACf,KAAA;EACA,UAAA,GAAa,MAAA;EACb,gBAAA,GAAmB,MAAA;EACnB,WAAA;EACA,cAAA;EAHA;EAKA,WAAA;EAKA,YAAA;AAAA;;;;;;;AAaF;;;;iBAAgB,wBAAA,CAAA,GACX,UAAA,EAAY,aAAA;AAAA,iBA6CD,2BAAA,CAA4B,KAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"lambda-client.d.cts","names":[],"sources":["../../src/telemetry/lambda-client.ts"],"mappings":";UAkCiB,iBAAA;EACf,KAAA;EACA,UAAA,GAAa,MAAA;EACb,gBAAA,GAAmB,MAAA;EACnB,WAAA;EACA,cAAA;EAHA;EAKA,WAAA;EAKA,YAAA;AAAA;;;;;;;AAaF;;;;iBAAgB,wBAAA,CAAA,GACX,UAAA,EAAY,aAAA;AAAA,iBA6CD,2BAAA,CAA4B,KAAA;AAAA,iBAoC5B,uBAAA,CAAwB,YAAA;AAAA,iBAUlB,IAAA,CAAK,IAAA,EAAM,iBAAA,GAAoB,OAAA;AAAA,cA2CxC,YAAA;eAAuB,IAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-client.d.mts","names":[],"sources":["../../src/telemetry/lambda-client.ts"],"mappings":";UAkCiB,iBAAA;EACf,KAAA;EACA,UAAA,GAAa,MAAA;EACb,gBAAA,GAAmB,MAAA;EACnB,WAAA;EACA,cAAA;EAHA;EAKA,WAAA;EAKA,YAAA;AAAA;;;;;;;AAaF;;;;iBAAgB,wBAAA,CAAA,GACX,UAAA,EAAY,aAAA;AAAA,iBA6CD,2BAAA,CAA4B,KAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"lambda-client.d.mts","names":[],"sources":["../../src/telemetry/lambda-client.ts"],"mappings":";UAkCiB,iBAAA;EACf,KAAA;EACA,UAAA,GAAa,MAAA;EACb,gBAAA,GAAmB,MAAA;EACnB,WAAA;EACA,cAAA;EAHA;EAKA,WAAA;EAKA,YAAA;AAAA;;;;;;;AAaF;;;;iBAAgB,wBAAA,CAAA,GACX,UAAA,EAAY,aAAA;AAAA,iBA6CD,2BAAA,CAA4B,KAAA;AAAA,iBAoC5B,uBAAA,CAAwB,YAAA;AAAA,iBAUlB,IAAA,CAAK,IAAA,EAAM,iBAAA,GAAoB,OAAA;AAAA,cA2CxC,YAAA;eAAuB,IAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-client.mjs","names":[],"sources":["../../src/telemetry/lambda-client.ts"],"sourcesContent":["// Telemetry sink client.\n//\n// Posts events to a CopilotKit-controlled telemetry-sink endpoint, which\n// fans out to Scarf, Reo, and any future destinations. Replaces the direct\n// per-vendor calls (formerly a Scarf-specific client) so that vendor changes\n// don't require SDK releases and so that downstream services we don't want\n// exposed to OSS readers (e.g. the email-enrichment service backing Reo) stay\n// private.\n//\n// Two attribution modes:\n// - Identified: a standalone telemetry id or a CopilotKit license token is\n// configured. Standalone identity takes precedence. License tokens are\n// JWTs (header.payload.sig) whose payload carries `telemetry_id`; the SDK\n// base64url-decodes the payload — without verifying the Ed25519 signature,\n// which is the license-verifier's job. The resolved identity is emitted\n// only via `X-CopilotKit-Telemetry-Id`.\n// - Anonymous: no license token, or a malformed/non-JWT one. No\n// telemetry-id header; events still flow, attribution is best-effort\n// from request-level signals (IP, UA).\n//\n// Note: CopilotCloud customer API keys (`ck_<env>_<id>.<secret>`) are\n// unrelated to telemetry attribution. They flow into Segment / PostHog\n// via the v1 shared TelemetryClient and never reach this code path.\n//\n// Best-effort: every error is swallowed. Telemetry must not break the\n// host application.\n\nconst TELEMETRY_SINK_URL =\n (typeof process !== \"undefined\" && process.env?.COPILOTKIT_TELEMETRY_URL) ||\n \"https://telemetry.copilotkit.ai/ingest\";\n\nconst FETCH_TIMEOUT_MS = 3000;\nconst TELEMETRY_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;\n\nexport interface LambdaSendOptions {\n event: string;\n properties?: Record<string, unknown>;\n globalProperties?: Record<string, unknown>;\n packageName?: string;\n packageVersion?: string;\n /** Standalone analytics identity, resolved before any legacy license claim. */\n telemetryId?: string;\n // The CopilotKit license token (Ed25519-signed JWT), when one is\n // configured on the runtime. The sender base64url-decodes the payload\n // segment to extract `telemetry_id`; missing or malformed tokens\n // produce an anonymous send.\n licenseToken?: string;\n}\n\n/**\n * Return the first telemetry identity accepted by the ingest service.\n *\n * Empty and whitespace-only values are unconfigured placeholders and must not\n * suppress a later identity source. Leading and trailing HTTP spaces and tabs\n * are removed before validation. The ingest service accepts 1 to 128 ASCII\n * letters, digits, underscores, and hyphens.\n *\n * @internal\n */\nexport function firstNonBlankTelemetryId(\n ...candidates: ReadonlyArray<string | undefined>\n): string | undefined {\n for (const candidate of candidates) {\n if (candidate === undefined) {\n continue;\n }\n\n const normalized = candidate.replace(/^[\\t ]+|[\\t ]+$/g, \"\");\n if (TELEMETRY_ID_PATTERN.test(normalized)) {\n return normalized;\n }\n }\n\n return undefined;\n}\n\n// These fields aren't used by the telemetry service, so we strip them\n// at the wire boundary rather than rely on every caller to omit them.\n// Both the snake_case and camelCase variants are listed because callers\n// upstream use different conventions.\nconst STRIPPED_KEYS = new Set([\"cloud.public_api_key\", \"cloud.publicApiKey\"]);\n\nfunction stripCloudKeys(\n obj: Record<string, unknown> | undefined,\n): Record<string, unknown> {\n if (!obj) return {};\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n if (!STRIPPED_KEYS.has(k)) out[k] = v;\n }\n return out;\n}\n\n// Pull telemetry_id out of a CopilotKit license token without verifying\n// the signature. The token shape is a standard JWT\n// (`<header>.<payload>.<sig>`) with base64url-encoded segments; the\n// payload is UTF-8 JSON with a telemetry_id accepted by the ingest service.\n//\n// Verification (Ed25519, key rotation, expiry) is the license-verifier\n// package's job. For telemetry attribution we only need the claimed id —\n// the trust model is claim-only on the Lambda side anyway.\n//\n// Exported so TelemetryClient setters can detect unparseable tokens at\n// configuration time and surface a single warning, instead of silently\n// emitting anonymous events on every capture.\nexport function parseTelemetryIdFromLicense(token?: string): string | null {\n if (!token) return null;\n const parts = token.split(\".\");\n if (parts.length !== 3) return null;\n try {\n const payload = parts[1];\n if (!/^[A-Za-z0-9_-]+$/.test(payload) || payload.length % 4 === 1) {\n return null;\n }\n\n let b64 = payload.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padding = (4 - (b64.length % 4)) % 4;\n b64 += \"=\".repeat(padding);\n const json =\n typeof Buffer !== \"undefined\"\n ? Buffer.from(b64, \"base64\").toString(\"utf8\")\n : new TextDecoder().decode(\n Uint8Array.from(atob(b64), (character) => character.charCodeAt(0)),\n );\n const decoded = JSON.parse(json) as { telemetry_id?: unknown };\n const telemetryId =\n typeof decoded.telemetry_id === \"string\"\n ? decoded.telemetry_id\n : undefined;\n return firstNonBlankTelemetryId(telemetryId) ?? null;\n } catch {\n return null;\n }\n}\n\n// Parse the telemetry_id from a license token AND emit the rollout smoke\n// signal if the parse returned null. Returning the parsed id lets callers\n// cache it in one step (avoiding a second parseTelemetryIdFromLicense\n// pass) while keeping the warn text in lockstep between v1 (shared)
|
|
1
|
+
{"version":3,"file":"lambda-client.mjs","names":[],"sources":["../../src/telemetry/lambda-client.ts"],"sourcesContent":["// Telemetry sink client.\n//\n// Posts events to a CopilotKit-controlled telemetry-sink endpoint, which\n// fans out to Scarf, Reo, and any future destinations. Replaces the direct\n// per-vendor calls (formerly a Scarf-specific client) so that vendor changes\n// don't require SDK releases and so that downstream services we don't want\n// exposed to OSS readers (e.g. the email-enrichment service backing Reo) stay\n// private.\n//\n// Two attribution modes:\n// - Identified: a standalone telemetry id or a CopilotKit license token is\n// configured. Standalone identity takes precedence. License tokens are\n// JWTs (header.payload.sig) whose payload carries `telemetry_id`; the SDK\n// base64url-decodes the payload — without verifying the Ed25519 signature,\n// which is the license-verifier's job. The resolved identity is emitted\n// only via `X-CopilotKit-Telemetry-Id`.\n// - Anonymous: no license token, or a malformed/non-JWT one. No\n// telemetry-id header; events still flow, attribution is best-effort\n// from request-level signals (IP, UA).\n//\n// Note: CopilotCloud customer API keys (`ck_<env>_<id>.<secret>`) are\n// unrelated to telemetry attribution. They flow into Segment / PostHog\n// via the v1 shared TelemetryClient and never reach this code path.\n//\n// Best-effort: every error is swallowed. Telemetry must not break the\n// host application.\n\nconst TELEMETRY_SINK_URL =\n (typeof process !== \"undefined\" && process.env?.COPILOTKIT_TELEMETRY_URL) ||\n \"https://telemetry.copilotkit.ai/ingest\";\n\nconst FETCH_TIMEOUT_MS = 3000;\nconst TELEMETRY_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;\n\nexport interface LambdaSendOptions {\n event: string;\n properties?: Record<string, unknown>;\n globalProperties?: Record<string, unknown>;\n packageName?: string;\n packageVersion?: string;\n /** Standalone analytics identity, resolved before any legacy license claim. */\n telemetryId?: string;\n // The CopilotKit license token (Ed25519-signed JWT), when one is\n // configured on the runtime. The sender base64url-decodes the payload\n // segment to extract `telemetry_id`; missing or malformed tokens\n // produce an anonymous send.\n licenseToken?: string;\n}\n\n/**\n * Return the first telemetry identity accepted by the ingest service.\n *\n * Empty and whitespace-only values are unconfigured placeholders and must not\n * suppress a later identity source. Leading and trailing HTTP spaces and tabs\n * are removed before validation. The ingest service accepts 1 to 128 ASCII\n * letters, digits, underscores, and hyphens.\n *\n * @internal\n */\nexport function firstNonBlankTelemetryId(\n ...candidates: ReadonlyArray<string | undefined>\n): string | undefined {\n for (const candidate of candidates) {\n if (candidate === undefined) {\n continue;\n }\n\n const normalized = candidate.replace(/^[\\t ]+|[\\t ]+$/g, \"\");\n if (TELEMETRY_ID_PATTERN.test(normalized)) {\n return normalized;\n }\n }\n\n return undefined;\n}\n\n// These fields aren't used by the telemetry service, so we strip them\n// at the wire boundary rather than rely on every caller to omit them.\n// Both the snake_case and camelCase variants are listed because callers\n// upstream use different conventions.\nconst STRIPPED_KEYS = new Set([\"cloud.public_api_key\", \"cloud.publicApiKey\"]);\n\nfunction stripCloudKeys(\n obj: Record<string, unknown> | undefined,\n): Record<string, unknown> {\n if (!obj) return {};\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n if (!STRIPPED_KEYS.has(k)) out[k] = v;\n }\n return out;\n}\n\n// Pull telemetry_id out of a CopilotKit license token without verifying\n// the signature. The token shape is a standard JWT\n// (`<header>.<payload>.<sig>`) with base64url-encoded segments; the\n// payload is UTF-8 JSON with a telemetry_id accepted by the ingest service.\n//\n// Verification (Ed25519, key rotation, expiry) is the license-verifier\n// package's job. For telemetry attribution we only need the claimed id —\n// the trust model is claim-only on the Lambda side anyway.\n//\n// Exported so TelemetryClient setters can detect unparseable tokens at\n// configuration time and surface a single warning, instead of silently\n// emitting anonymous events on every capture.\nexport function parseTelemetryIdFromLicense(token?: string): string | null {\n if (!token) return null;\n const parts = token.split(\".\");\n if (parts.length !== 3) return null;\n try {\n const payload = parts[1];\n if (!/^[A-Za-z0-9_-]+$/.test(payload) || payload.length % 4 === 1) {\n return null;\n }\n\n let b64 = payload.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padding = (4 - (b64.length % 4)) % 4;\n b64 += \"=\".repeat(padding);\n const json =\n typeof Buffer !== \"undefined\"\n ? Buffer.from(b64, \"base64\").toString(\"utf8\")\n : new TextDecoder().decode(\n Uint8Array.from(atob(b64), (character) => character.charCodeAt(0)),\n );\n const decoded = JSON.parse(json) as { telemetry_id?: unknown };\n const telemetryId =\n typeof decoded.telemetry_id === \"string\"\n ? decoded.telemetry_id\n : undefined;\n return firstNonBlankTelemetryId(telemetryId) ?? null;\n } catch {\n return null;\n }\n}\n\n// Parse the telemetry_id from a license token AND emit the rollout smoke\n// signal if the parse returned null. Returning the parsed id lets callers\n// cache it in one step (avoiding a second parseTelemetryIdFromLicense\n// pass) while keeping the warn text in lockstep between the v1 (shared)\n// TelemetryClient.setLicenseToken and the v2 (runtime)\n// TelemetryClient.setTelemetryIdentity.\nexport function parseAndWarnTelemetryId(licenseToken: string): string | null {\n const telemetryId = parseTelemetryIdFromLicense(licenseToken);\n if (!telemetryId) {\n console.warn(\n \"[CopilotKit] License token did not yield a telemetry_id; telemetry events will be sent anonymously.\",\n );\n }\n return telemetryId;\n}\n\nexport async function send(opts: LambdaSendOptions): Promise<void> {\n try {\n const body = JSON.stringify({\n event: opts.event,\n properties: stripCloudKeys(opts.properties),\n global_properties: stripCloudKeys(opts.globalProperties),\n package: {\n name: opts.packageName,\n version: opts.packageVersion,\n },\n ts: Math.floor(Date.now() / 1000),\n });\n\n const telemetryId =\n firstNonBlankTelemetryId(opts.telemetryId) ??\n parseTelemetryIdFromLicense(opts.licenseToken);\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"User-Agent\": opts.packageName\n ? `CopilotKit-Runtime/${opts.packageVersion ?? \"unknown\"} (${opts.packageName})`\n : \"CopilotKit-Runtime\",\n };\n if (telemetryId) {\n headers[\"X-CopilotKit-Telemetry-Id\"] = telemetryId;\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n try {\n await fetch(TELEMETRY_SINK_URL, {\n method: \"POST\",\n headers,\n body,\n signal: controller.signal,\n });\n } finally {\n clearTimeout(timeoutId);\n }\n } catch {\n // Silent failure — telemetry must not break the application.\n }\n}\n\nexport const lambdaClient = { send };\n"],"mappings":";AA2BA,MAAM,qBACH,OAAO,YAAY,eAAe,QAAQ,KAAK,4BAChD;AAEF,MAAM,mBAAmB;AACzB,MAAM,uBAAuB;;;;;;;;;;;AA2B7B,SAAgB,yBACd,GAAG,YACiB;AACpB,MAAK,MAAM,aAAa,YAAY;AAClC,MAAI,cAAc,OAChB;EAGF,MAAM,aAAa,UAAU,QAAQ,oBAAoB,GAAG;AAC5D,MAAI,qBAAqB,KAAK,WAAW,CACvC,QAAO;;;AAWb,MAAM,gBAAgB,IAAI,IAAI,CAAC,wBAAwB,qBAAqB,CAAC;AAE7E,SAAS,eACP,KACyB;AACzB,KAAI,CAAC,IAAK,QAAO,EAAE;CACnB,MAAM,MAA+B,EAAE;AACvC,MAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,IAAI,CACtC,KAAI,CAAC,cAAc,IAAI,EAAE,CAAE,KAAI,KAAK;AAEtC,QAAO;;AAeT,SAAgB,4BAA4B,OAA+B;AACzE,KAAI,CAAC,MAAO,QAAO;CACnB,MAAM,QAAQ,MAAM,MAAM,IAAI;AAC9B,KAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,KAAI;EACF,MAAM,UAAU,MAAM;AACtB,MAAI,CAAC,mBAAmB,KAAK,QAAQ,IAAI,QAAQ,SAAS,MAAM,EAC9D,QAAO;EAGT,IAAI,MAAM,QAAQ,QAAQ,MAAM,IAAI,CAAC,QAAQ,MAAM,IAAI;EACvD,MAAM,WAAW,IAAK,IAAI,SAAS,KAAM;AACzC,SAAO,IAAI,OAAO,QAAQ;EAC1B,MAAM,OACJ,OAAO,WAAW,cACd,OAAO,KAAK,KAAK,SAAS,CAAC,SAAS,OAAO,GAC3C,IAAI,aAAa,CAAC,OAChB,WAAW,KAAK,KAAK,IAAI,GAAG,cAAc,UAAU,WAAW,EAAE,CAAC,CACnE;EACP,MAAM,UAAU,KAAK,MAAM,KAAK;AAKhC,SAAO,yBAHL,OAAO,QAAQ,iBAAiB,WAC5B,QAAQ,eACR,OACsC,IAAI;SAC1C;AACN,SAAO;;;AAUX,SAAgB,wBAAwB,cAAqC;CAC3E,MAAM,cAAc,4BAA4B,aAAa;AAC7D,KAAI,CAAC,YACH,SAAQ,KACN,sGACD;AAEH,QAAO;;AAGT,eAAsB,KAAK,MAAwC;AACjE,KAAI;EACF,MAAM,OAAO,KAAK,UAAU;GAC1B,OAAO,KAAK;GACZ,YAAY,eAAe,KAAK,WAAW;GAC3C,mBAAmB,eAAe,KAAK,iBAAiB;GACxD,SAAS;IACP,MAAM,KAAK;IACX,SAAS,KAAK;IACf;GACD,IAAI,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;GAClC,CAAC;EAEF,MAAM,cACJ,yBAAyB,KAAK,YAAY,IAC1C,4BAA4B,KAAK,aAAa;EAChD,MAAM,UAAkC;GACtC,gBAAgB;GAChB,cAAc,KAAK,cACf,sBAAsB,KAAK,kBAAkB,UAAU,IAAI,KAAK,YAAY,KAC5E;GACL;AACD,MAAI,YACF,SAAQ,+BAA+B;EAGzC,MAAM,aAAa,IAAI,iBAAiB;EACxC,MAAM,YAAY,iBAAiB,WAAW,OAAO,EAAE,iBAAiB;AACxE,MAAI;AACF,SAAM,MAAM,oBAAoB;IAC9B,QAAQ;IACR;IACA;IACA,QAAQ,WAAW;IACpB,CAAC;YACM;AACR,gBAAa,UAAU;;SAEnB;;AAKV,MAAa,eAAe,EAAE,MAAM"}
|
package/dist/types/message.d.cts
CHANGED
|
@@ -2,17 +2,6 @@ import * as agui from "@ag-ui/core";
|
|
|
2
2
|
import { AudioInputPart, DocumentInputPart, ImageInputPart, InputContent as InputContent$1, InputContentDataSource as InputContentDataSource$1, InputContentSource, InputContentUrlSource as InputContentUrlSource$1, TextInputContent as TextInputPart, VideoInputPart } from "@ag-ui/core";
|
|
3
3
|
|
|
4
4
|
//#region src/types/message.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use `InputContentSource` from `@ag-ui/core` (re-exported from `@copilotkit/shared`) instead.
|
|
7
|
-
* `ImageData` only described base64 image payloads. `InputContentSource` supports
|
|
8
|
-
* data and URL sources for images, audio, video, and documents.
|
|
9
|
-
* See https://docs.copilotkit.ai/migration-guides/migrate-attachments
|
|
10
|
-
* @since 1.56.0
|
|
11
|
-
*/
|
|
12
|
-
interface ImageData {
|
|
13
|
-
format: string;
|
|
14
|
-
bytes: string;
|
|
15
|
-
}
|
|
16
5
|
type Role = agui.Role;
|
|
17
6
|
type SystemMessage = agui.SystemMessage;
|
|
18
7
|
type DeveloperMessage = agui.DeveloperMessage;
|
|
@@ -27,16 +16,10 @@ type AIMessage = agui.AssistantMessage & {
|
|
|
27
16
|
generativeUIPosition?: "before" | "after";
|
|
28
17
|
agentName?: string;
|
|
29
18
|
state?: any;
|
|
30
|
-
/**
|
|
31
|
-
* @deprecated Use multimodal `content` array with `InputContent` parts instead.
|
|
32
|
-
* See https://docs.copilotkit.ai/migration-guides/migrate-attachments
|
|
33
|
-
* @since 1.56.0
|
|
34
|
-
*/
|
|
35
|
-
image?: ImageData;
|
|
36
19
|
runId?: string;
|
|
37
20
|
};
|
|
38
21
|
type UserMessage = agui.UserMessage;
|
|
39
22
|
type Message$1 = AIMessage | ToolResult | UserMessage | SystemMessage | DeveloperMessage | ActivityMessage | ReasoningMessage;
|
|
40
23
|
//#endregion
|
|
41
|
-
export { AIMessage, ActivityMessage, type AudioInputPart, DeveloperMessage, type DocumentInputPart,
|
|
24
|
+
export { AIMessage, ActivityMessage, type AudioInputPart, DeveloperMessage, type DocumentInputPart, type ImageInputPart, type InputContent$1 as InputContent, type InputContentDataSource$1 as InputContentDataSource, type InputContentSource, type InputContentUrlSource$1 as InputContentUrlSource, Message$1 as Message, ReasoningMessage, Role, SystemMessage, type TextInputPart, ToolCall, ToolResult, UserMessage, type VideoInputPart };
|
|
42
25
|
//# sourceMappingURL=message.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.cts","names":[],"sources":["../../src/types/message.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"message.d.cts","names":[],"sources":["../../src/types/message.ts"],"mappings":";;;;KAiBY,IAAA,GAAO,IAAA,CAAK,IAAA;AAAA,KACZ,aAAA,GAAgB,IAAA,CAAK,aAAA;AAAA,KACrB,gBAAA,GAAmB,IAAA,CAAK,gBAAA;AAAA,KACxB,QAAA,GAAW,IAAA,CAAK,QAAA;AAAA,KAChB,eAAA,GAAkB,IAAA,CAAK,eAAA;AAAA,KACvB,gBAAA,GAAmB,IAAA,CAAK,gBAAA;AAAA,KAGxB,UAAA,GAAa,IAAA,CAAK,WAAA;EAC5B,QAAA;AAAA;AAAA,KAGU,SAAA,GAAY,IAAA,CAAK,gBAAA;EAC3B,YAAA,IAAgB,KAAA;EAChB,oBAAA;EACA,SAAA;EACA,KAAA;EACA,KAAA;AAAA;AAAA,KAGU,WAAA,GAAc,IAAA,CAAK,WAAA;AAAA,KAEnB,SAAA,GACR,SAAA,GACA,UAAA,GACA,WAAA,GACA,aAAA,GACA,gBAAA,GACA,eAAA,GACA,gBAAA"}
|
package/dist/types/message.d.mts
CHANGED
|
@@ -2,17 +2,6 @@ import * as agui from "@ag-ui/core";
|
|
|
2
2
|
import { AudioInputPart, DocumentInputPart, ImageInputPart, InputContent as InputContent$1, InputContentDataSource as InputContentDataSource$1, InputContentSource, InputContentUrlSource as InputContentUrlSource$1, TextInputContent as TextInputPart, VideoInputPart } from "@ag-ui/core";
|
|
3
3
|
|
|
4
4
|
//#region src/types/message.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use `InputContentSource` from `@ag-ui/core` (re-exported from `@copilotkit/shared`) instead.
|
|
7
|
-
* `ImageData` only described base64 image payloads. `InputContentSource` supports
|
|
8
|
-
* data and URL sources for images, audio, video, and documents.
|
|
9
|
-
* See https://docs.copilotkit.ai/migration-guides/migrate-attachments
|
|
10
|
-
* @since 1.56.0
|
|
11
|
-
*/
|
|
12
|
-
interface ImageData {
|
|
13
|
-
format: string;
|
|
14
|
-
bytes: string;
|
|
15
|
-
}
|
|
16
5
|
type Role = agui.Role;
|
|
17
6
|
type SystemMessage = agui.SystemMessage;
|
|
18
7
|
type DeveloperMessage = agui.DeveloperMessage;
|
|
@@ -27,16 +16,10 @@ type AIMessage = agui.AssistantMessage & {
|
|
|
27
16
|
generativeUIPosition?: "before" | "after";
|
|
28
17
|
agentName?: string;
|
|
29
18
|
state?: any;
|
|
30
|
-
/**
|
|
31
|
-
* @deprecated Use multimodal `content` array with `InputContent` parts instead.
|
|
32
|
-
* See https://docs.copilotkit.ai/migration-guides/migrate-attachments
|
|
33
|
-
* @since 1.56.0
|
|
34
|
-
*/
|
|
35
|
-
image?: ImageData;
|
|
36
19
|
runId?: string;
|
|
37
20
|
};
|
|
38
21
|
type UserMessage = agui.UserMessage;
|
|
39
22
|
type Message$1 = AIMessage | ToolResult | UserMessage | SystemMessage | DeveloperMessage | ActivityMessage | ReasoningMessage;
|
|
40
23
|
//#endregion
|
|
41
|
-
export { AIMessage, ActivityMessage, type AudioInputPart, DeveloperMessage, type DocumentInputPart,
|
|
24
|
+
export { AIMessage, ActivityMessage, type AudioInputPart, DeveloperMessage, type DocumentInputPart, type ImageInputPart, type InputContent$1 as InputContent, type InputContentDataSource$1 as InputContentDataSource, type InputContentSource, type InputContentUrlSource$1 as InputContentUrlSource, Message$1 as Message, ReasoningMessage, Role, SystemMessage, type TextInputPart, ToolCall, ToolResult, UserMessage, type VideoInputPart };
|
|
42
25
|
//# sourceMappingURL=message.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.mts","names":[],"sources":["../../src/types/message.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"message.d.mts","names":[],"sources":["../../src/types/message.ts"],"mappings":";;;;KAiBY,IAAA,GAAO,IAAA,CAAK,IAAA;AAAA,KACZ,aAAA,GAAgB,IAAA,CAAK,aAAA;AAAA,KACrB,gBAAA,GAAmB,IAAA,CAAK,gBAAA;AAAA,KACxB,QAAA,GAAW,IAAA,CAAK,QAAA;AAAA,KAChB,eAAA,GAAkB,IAAA,CAAK,eAAA;AAAA,KACvB,gBAAA,GAAmB,IAAA,CAAK,gBAAA;AAAA,KAGxB,UAAA,GAAa,IAAA,CAAK,WAAA;EAC5B,QAAA;AAAA;AAAA,KAGU,SAAA,GAAY,IAAA,CAAK,gBAAA;EAC3B,YAAA,IAAgB,KAAA;EAChB,oBAAA;EACA,SAAA;EACA,KAAA;EACA,KAAA;AAAA;AAAA,KAGU,WAAA,GAAc,IAAA,CAAK,WAAA;AAAA,KAEnB,SAAA,GACR,SAAA,GACA,UAAA,GACA,WAAA,GACA,aAAA,GACA,gBAAA,GACA,eAAA,GACA,gBAAA"}
|
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.
|
|
@@ -136,8 +136,9 @@ export function parseTelemetryIdFromLicense(token?: string): string | null {
|
|
|
136
136
|
// Parse the telemetry_id from a license token AND emit the rollout smoke
|
|
137
137
|
// signal if the parse returned null. Returning the parsed id lets callers
|
|
138
138
|
// cache it in one step (avoiding a second parseTelemetryIdFromLicense
|
|
139
|
-
// pass) while keeping the warn text in lockstep between v1 (shared)
|
|
140
|
-
// v2 (runtime)
|
|
139
|
+
// pass) while keeping the warn text in lockstep between the v1 (shared)
|
|
140
|
+
// TelemetryClient.setLicenseToken and the v2 (runtime)
|
|
141
|
+
// TelemetryClient.setTelemetryIdentity.
|
|
141
142
|
export function parseAndWarnTelemetryId(licenseToken: string): string | null {
|
|
142
143
|
const telemetryId = parseTelemetryIdFromLicense(licenseToken);
|
|
143
144
|
if (!telemetryId) {
|
package/src/types/message.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as agui from "@ag-ui/core";
|
|
1
|
+
import type * as agui from "@ag-ui/core";
|
|
2
2
|
|
|
3
3
|
// Re-export AG-UI multimodal input types.
|
|
4
4
|
// Note: AG-UI names the text variant TextInputContent; we export it as TextInputPart for consistency.
|
|
@@ -14,18 +14,6 @@ export type {
|
|
|
14
14
|
DocumentInputPart,
|
|
15
15
|
} from "@ag-ui/core";
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Use `InputContentSource` from `@ag-ui/core` (re-exported from `@copilotkit/shared`) instead.
|
|
19
|
-
* `ImageData` only described base64 image payloads. `InputContentSource` supports
|
|
20
|
-
* data and URL sources for images, audio, video, and documents.
|
|
21
|
-
* See https://docs.copilotkit.ai/migration-guides/migrate-attachments
|
|
22
|
-
* @since 1.56.0
|
|
23
|
-
*/
|
|
24
|
-
export interface ImageData {
|
|
25
|
-
format: string;
|
|
26
|
-
bytes: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
17
|
// Pass through types
|
|
30
18
|
export type Role = agui.Role;
|
|
31
19
|
export type SystemMessage = agui.SystemMessage;
|
|
@@ -44,12 +32,6 @@ export type AIMessage = agui.AssistantMessage & {
|
|
|
44
32
|
generativeUIPosition?: "before" | "after";
|
|
45
33
|
agentName?: string;
|
|
46
34
|
state?: any;
|
|
47
|
-
/**
|
|
48
|
-
* @deprecated Use multimodal `content` array with `InputContent` parts instead.
|
|
49
|
-
* See https://docs.copilotkit.ai/migration-guides/migrate-attachments
|
|
50
|
-
* @since 1.56.0
|
|
51
|
-
*/
|
|
52
|
-
image?: ImageData;
|
|
53
35
|
runId?: string;
|
|
54
36
|
};
|
|
55
37
|
|