@copilotkit/shared 2.0.0-rc.3 → 2.0.0-rc.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -14
- package/dist/a2ui-envelope.cjs +2 -2
- package/dist/a2ui-envelope.cjs.map +1 -1
- package/dist/a2ui-envelope.d.cts +1 -1
- package/dist/a2ui-envelope.d.cts.map +1 -1
- package/dist/a2ui-envelope.d.mts +1 -1
- package/dist/a2ui-envelope.d.mts.map +1 -1
- package/dist/a2ui-envelope.mjs +2 -2
- package/dist/a2ui-envelope.mjs.map +1 -1
- package/dist/a2ui-prompts.cjs +21 -62
- package/dist/a2ui-prompts.cjs.map +1 -1
- package/dist/a2ui-prompts.d.cts +8 -1
- package/dist/a2ui-prompts.d.cts.map +1 -1
- package/dist/a2ui-prompts.d.mts +8 -1
- package/dist/a2ui-prompts.d.mts.map +1 -1
- package/dist/a2ui-prompts.mjs +22 -62
- package/dist/a2ui-prompts.mjs.map +1 -1
- package/dist/attachments/types.d.cts +1 -3
- package/dist/attachments/types.d.cts.map +1 -1
- package/dist/attachments/types.d.mts +1 -3
- package/dist/attachments/types.d.mts.map +1 -1
- package/dist/attachments/utils.cjs +16 -5
- package/dist/attachments/utils.cjs.map +1 -1
- package/dist/attachments/utils.d.cts +3 -1
- package/dist/attachments/utils.d.cts.map +1 -1
- package/dist/attachments/utils.d.mts +3 -1
- package/dist/attachments/utils.d.mts.map +1 -1
- package/dist/attachments/utils.mjs +16 -5
- package/dist/attachments/utils.mjs.map +1 -1
- package/dist/finalize-events.cjs +16 -0
- package/dist/finalize-events.cjs.map +1 -1
- package/dist/finalize-events.d.cts.map +1 -1
- package/dist/finalize-events.d.mts.map +1 -1
- package/dist/finalize-events.mjs +16 -0
- package/dist/finalize-events.mjs.map +1 -1
- package/dist/generative-ui/basic-functions.cjs +1 -1
- package/dist/generative-ui/basic-functions.cjs.map +1 -1
- package/dist/generative-ui/basic-functions.mjs +1 -1
- package/dist/generative-ui/basic-functions.mjs.map +1 -1
- package/dist/generative-ui/child-refs.cjs +3 -3
- package/dist/generative-ui/child-refs.cjs.map +1 -1
- package/dist/generative-ui/child-refs.d.cts.map +1 -1
- package/dist/generative-ui/child-refs.d.mts.map +1 -1
- package/dist/generative-ui/child-refs.mjs +3 -3
- package/dist/generative-ui/child-refs.mjs.map +1 -1
- package/dist/generative-ui/compact-schema.cjs +187 -0
- package/dist/generative-ui/compact-schema.cjs.map +1 -0
- package/dist/generative-ui/compact-schema.d.cts +55 -0
- package/dist/generative-ui/compact-schema.d.cts.map +1 -0
- package/dist/generative-ui/compact-schema.d.mts +55 -0
- package/dist/generative-ui/compact-schema.d.mts.map +1 -0
- package/dist/generative-ui/compact-schema.mjs +185 -0
- package/dist/generative-ui/compact-schema.mjs.map +1 -0
- package/dist/generative-ui/prompt-spec.cjs +225 -0
- package/dist/generative-ui/prompt-spec.cjs.map +1 -0
- package/dist/generative-ui/prompt-spec.d.cts +94 -0
- package/dist/generative-ui/prompt-spec.d.cts.map +1 -0
- package/dist/generative-ui/prompt-spec.d.mts +94 -0
- package/dist/generative-ui/prompt-spec.d.mts.map +1 -0
- package/dist/generative-ui/prompt-spec.mjs +220 -0
- package/dist/generative-ui/prompt-spec.mjs.map +1 -0
- package/dist/generative-ui/prompt.cjs +10 -36
- package/dist/generative-ui/prompt.cjs.map +1 -1
- package/dist/generative-ui/prompt.d.cts +2 -1
- package/dist/generative-ui/prompt.d.cts.map +1 -1
- package/dist/generative-ui/prompt.d.mts +2 -1
- package/dist/generative-ui/prompt.d.mts.map +1 -1
- package/dist/generative-ui/prompt.mjs +12 -38
- package/dist/generative-ui/prompt.mjs.map +1 -1
- package/dist/generative-ui/render-ui-args.cjs +1 -0
- package/dist/generative-ui/render-ui-args.cjs.map +1 -1
- package/dist/generative-ui/render-ui-args.d.cts.map +1 -1
- package/dist/generative-ui/render-ui-args.d.mts.map +1 -1
- package/dist/generative-ui/render-ui-args.mjs +1 -0
- package/dist/generative-ui/render-ui-args.mjs.map +1 -1
- package/dist/generative-ui/schema-render.cjs +242 -0
- package/dist/generative-ui/schema-render.cjs.map +1 -0
- package/dist/generative-ui/schema-render.d.cts +44 -0
- package/dist/generative-ui/schema-render.d.cts.map +1 -0
- package/dist/generative-ui/schema-render.d.mts +44 -0
- package/dist/generative-ui/schema-render.d.mts.map +1 -0
- package/dist/generative-ui/schema-render.mjs +239 -0
- package/dist/generative-ui/schema-render.mjs.map +1 -0
- package/dist/generative-ui/types.cjs +2 -2
- package/dist/generative-ui/types.cjs.map +1 -1
- package/dist/generative-ui/types.d.cts +7 -7
- package/dist/generative-ui/types.d.cts.map +1 -1
- package/dist/generative-ui/types.d.mts +7 -7
- package/dist/generative-ui/types.d.mts.map +1 -1
- package/dist/generative-ui/types.mjs +2 -2
- package/dist/generative-ui/types.mjs.map +1 -1
- package/dist/generative-ui/validate-operation.cjs +2 -2
- package/dist/generative-ui/validate-operation.cjs.map +1 -1
- package/dist/generative-ui/validate-operation.mjs +2 -2
- package/dist/generative-ui/validate-operation.mjs.map +1 -1
- package/dist/index.cjs +16 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +10 -10
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +9 -8
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +866 -455
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/standard-schema.cjs +20 -7
- package/dist/standard-schema.cjs.map +1 -1
- package/dist/standard-schema.d.cts +15 -16
- package/dist/standard-schema.d.cts.map +1 -1
- package/dist/standard-schema.d.mts +15 -16
- package/dist/standard-schema.d.mts.map +1 -1
- package/dist/standard-schema.mjs +20 -8
- package/dist/standard-schema.mjs.map +1 -1
- package/dist/telemetry/lambda-client.cjs +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 +1 -1
- package/dist/telemetry/lambda-client.mjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.cjs +0 -5
- package/dist/telemetry/telemetry-disabled.cjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.d.cts +0 -5
- package/dist/telemetry/telemetry-disabled.d.cts.map +1 -1
- package/dist/telemetry/telemetry-disabled.d.mts +0 -5
- package/dist/telemetry/telemetry-disabled.d.mts.map +1 -1
- package/dist/telemetry/telemetry-disabled.mjs +0 -5
- package/dist/telemetry/telemetry-disabled.mjs.map +1 -1
- package/dist/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/dist/utils/errors.cjs +5 -42
- package/dist/utils/errors.cjs.map +1 -1
- package/dist/utils/errors.d.cts +16 -34
- package/dist/utils/errors.d.cts.map +1 -1
- package/dist/utils/errors.d.mts +16 -34
- package/dist/utils/errors.d.mts.map +1 -1
- package/dist/utils/errors.mjs +6 -41
- package/dist/utils/errors.mjs.map +1 -1
- package/dist/utils/index.cjs +0 -2
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +4 -6
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts +4 -6
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +4 -6
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/inspector-visibility.cjs +25 -3
- package/dist/utils/inspector-visibility.cjs.map +1 -1
- package/dist/utils/inspector-visibility.d.cts +26 -3
- package/dist/utils/inspector-visibility.d.cts.map +1 -1
- package/dist/utils/inspector-visibility.d.mts +26 -3
- package/dist/utils/inspector-visibility.d.mts.map +1 -1
- package/dist/utils/inspector-visibility.mjs +25 -4
- package/dist/utils/inspector-visibility.mjs.map +1 -1
- package/dist/utils/json-schema.cjs +4 -79
- package/dist/utils/json-schema.cjs.map +1 -1
- package/dist/utils/json-schema.d.cts +1 -4
- package/dist/utils/json-schema.d.cts.map +1 -1
- package/dist/utils/json-schema.d.mts +1 -4
- package/dist/utils/json-schema.d.mts.map +1 -1
- package/dist/utils/json-schema.mjs +5 -78
- package/dist/utils/json-schema.mjs.map +1 -1
- package/dist/utils/random-id.cjs +13 -26
- package/dist/utils/random-id.cjs.map +1 -1
- package/dist/utils/random-id.d.cts +6 -3
- package/dist/utils/random-id.d.cts.map +1 -1
- package/dist/utils/random-id.d.mts +6 -3
- package/dist/utils/random-id.d.mts.map +1 -1
- package/dist/utils/random-id.mjs +14 -25
- package/dist/utils/random-id.mjs.map +1 -1
- package/package.json +10 -34
- package/scripts/verify-cjs-exports.cjs +1 -1
- package/src/__tests__/a2ui-envelope.test.ts +18 -13
- package/src/__tests__/a2ui-prompts.test.ts +47 -14
- package/src/__tests__/fixtures/prompt-goldens.json +354 -0
- package/src/__tests__/prompt-spec.test.ts +191 -0
- package/src/__tests__/root-entry-browser-safety.test.ts +5 -7
- package/src/__tests__/schema-render.test.ts +245 -0
- package/src/__tests__/standard-schema.test.ts +61 -101
- package/src/a2ui-envelope.ts +7 -6
- package/src/a2ui-prompts.ts +47 -96
- package/src/attachments/__tests__/utils.test.ts +22 -0
- package/src/attachments/types.ts +1 -3
- package/src/attachments/utils.ts +23 -5
- package/src/finalize-events.ts +16 -0
- package/src/generative-ui/__tests__/render-ui-args.test.ts +7 -7
- package/src/generative-ui/__tests__/validate-operation.test.ts +19 -13
- package/src/generative-ui/basic-functions.ts +1 -1
- package/src/generative-ui/child-refs.ts +5 -4
- package/src/generative-ui/compact-schema.ts +277 -0
- package/src/generative-ui/index.ts +3 -0
- package/src/generative-ui/prompt-spec.ts +335 -0
- package/src/generative-ui/prompt.ts +25 -75
- package/src/generative-ui/render-ui-args.ts +3 -0
- package/src/generative-ui/schema-render.ts +377 -0
- package/src/generative-ui/types.ts +10 -7
- package/src/generative-ui/validate-operation.ts +2 -2
- package/src/index.ts +3 -16
- package/src/standard-schema.ts +24 -27
- package/src/telemetry/lambda-client.ts +8 -3
- package/src/telemetry/model-host.test.ts +2 -5
- package/src/telemetry/telemetry-disabled.ts +0 -5
- package/src/types/message.ts +1 -19
- package/src/utils/__tests__/errors.test.ts +44 -0
- package/src/utils/__tests__/json-schema.test.ts +3 -479
- package/src/utils/__tests__/random-id.test.ts +37 -0
- package/src/utils/errors.ts +28 -85
- package/src/utils/index.ts +0 -2
- package/src/utils/inspector-visibility.test.ts +26 -0
- package/src/utils/inspector-visibility.ts +35 -3
- package/src/utils/json-schema.ts +5 -152
- package/src/utils/random-id.ts +17 -37
- package/tsconfig.json +3 -1
- package/tsdown.config.ts +2 -19
- package/dist/event-transforms/index.cjs +0 -15
- package/dist/event-transforms/index.d.cts +0 -4
- package/dist/event-transforms/index.d.mts +0 -4
- package/dist/event-transforms/index.mjs +0 -5
- package/dist/event-transforms/open-generative-ui-middleware.cjs +0 -286
- package/dist/event-transforms/open-generative-ui-middleware.cjs.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.d.cts +0 -60
- package/dist/event-transforms/open-generative-ui-middleware.d.cts.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.d.mts +0 -60
- package/dist/event-transforms/open-generative-ui-middleware.d.mts.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.mjs +0 -283
- package/dist/event-transforms/open-generative-ui-middleware.mjs.map +0 -1
- package/dist/event-transforms/recorded-events.cjs +0 -59
- package/dist/event-transforms/recorded-events.cjs.map +0 -1
- package/dist/event-transforms/recorded-events.d.cts +0 -23
- package/dist/event-transforms/recorded-events.d.cts.map +0 -1
- package/dist/event-transforms/recorded-events.d.mts +0 -23
- package/dist/event-transforms/recorded-events.d.mts.map +0 -1
- package/dist/event-transforms/recorded-events.mjs +0 -58
- package/dist/event-transforms/recorded-events.mjs.map +0 -1
- package/dist/telemetry/events.d.cts +0 -72
- package/dist/telemetry/events.d.cts.map +0 -1
- package/dist/telemetry/events.d.mts +0 -72
- package/dist/telemetry/events.d.mts.map +0 -1
- package/dist/telemetry/index.cjs +0 -18
- package/dist/telemetry/index.d.cts +0 -5
- package/dist/telemetry/index.d.mts +0 -5
- package/dist/telemetry/index.mjs +0 -6
- package/dist/telemetry/telemetry-client.cjs +0 -165
- package/dist/telemetry/telemetry-client.cjs.map +0 -1
- package/dist/telemetry/telemetry-client.d.cts +0 -87
- package/dist/telemetry/telemetry-client.d.cts.map +0 -1
- package/dist/telemetry/telemetry-client.d.mts +0 -87
- package/dist/telemetry/telemetry-client.d.mts.map +0 -1
- package/dist/telemetry/telemetry-client.mjs +0 -164
- package/dist/telemetry/telemetry-client.mjs.map +0 -1
- package/dist/telemetry/utils.cjs +0 -14
- package/dist/telemetry/utils.cjs.map +0 -1
- package/dist/telemetry/utils.mjs +0 -13
- package/dist/telemetry/utils.mjs.map +0 -1
- package/dist/utils/conditions.cjs +0 -32
- package/dist/utils/conditions.cjs.map +0 -1
- package/dist/utils/conditions.d.cts +0 -31
- package/dist/utils/conditions.d.cts.map +0 -1
- package/dist/utils/conditions.d.mts +0 -31
- package/dist/utils/conditions.d.mts.map +0 -1
- package/dist/utils/conditions.mjs +0 -31
- package/dist/utils/conditions.mjs.map +0 -1
- package/dist/utils/console-styling.cjs +0 -91
- package/dist/utils/console-styling.cjs.map +0 -1
- package/dist/utils/console-styling.d.cts +0 -65
- package/dist/utils/console-styling.d.cts.map +0 -1
- package/dist/utils/console-styling.d.mts +0 -65
- package/dist/utils/console-styling.d.mts.map +0 -1
- package/dist/utils/console-styling.mjs +0 -85
- package/dist/utils/console-styling.mjs.map +0 -1
- package/src/__tests__/zod-regression.test.ts +0 -319
- package/src/event-transforms/index.ts +0 -5
- package/src/event-transforms/open-generative-ui-middleware.ts +0 -392
- package/src/event-transforms/recorded-events.test.ts +0 -166
- package/src/event-transforms/recorded-events.ts +0 -74
- package/src/telemetry/events.ts +0 -68
- package/src/telemetry/index.ts +0 -9
- package/src/telemetry/telemetry-blank-license-identity.test.ts +0 -128
- package/src/telemetry/telemetry-client.test.ts +0 -798
- package/src/telemetry/telemetry-client.ts +0 -328
- package/src/telemetry/utils.ts +0 -15
- package/src/utils/__tests__/conditions.test.ts +0 -161
- package/src/utils/conditions.ts +0 -116
- package/src/utils/console-styling.ts +0 -126
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) {
|
|
@@ -13,19 +25,20 @@ function hasStandardJsonSchema(schema) {
|
|
|
13
25
|
* Strategy:
|
|
14
26
|
* 1. If the schema implements Standard JSON Schema V1 (`~standard.jsonSchema`),
|
|
15
27
|
* call `schema['~standard'].jsonSchema.input({ target: 'draft-07' })`.
|
|
16
|
-
* 2
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
28
|
+
* Zod 4.2+, ArkType 2.1.28+ and Valibot (via `toStandardJsonSchema`) do.
|
|
29
|
+
* 2. If the schema exposes a `toJSONSchema()` method, call it directly.
|
|
30
|
+
* 3. Otherwise throw a descriptive error. Zod 3 schemas land here: they
|
|
31
|
+
* implement Standard Schema validation but cannot describe themselves as
|
|
32
|
+
* JSON Schema.
|
|
20
33
|
*/
|
|
21
|
-
function schemaToJsonSchema(schema
|
|
34
|
+
function schemaToJsonSchema(schema) {
|
|
22
35
|
if (hasStandardJsonSchema(schema)) return schema["~standard"].jsonSchema.input({ target: "draft-07" });
|
|
23
36
|
if (typeof schema.toJSONSchema === "function") return schema.toJSONSchema();
|
|
24
37
|
const vendor = schema["~standard"].vendor;
|
|
25
|
-
|
|
26
|
-
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.`);
|
|
38
|
+
throw new Error(`Cannot convert schema to JSON Schema. The schema (vendor: "${vendor}") does not implement Standard JSON Schema V1. Use a library that does: Zod 4.2+ (Zod 3 is not supported), Valibot v1+ wrapped with toStandardJsonSchema() from @valibot/to-json-schema, or ArkType v2.1.28+.`);
|
|
27
39
|
}
|
|
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 *
|
|
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\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 * Zod 4.2+, ArkType 2.1.28+ and Valibot (via `toStandardJsonSchema`) do.\n * 2. If the schema exposes a `toJSONSchema()` method, call it directly.\n * 3. Otherwise throw a descriptive error. Zod 3 schemas land here: they\n * implement Standard Schema validation but cannot describe themselves as\n * JSON Schema.\n */\nexport function schemaToJsonSchema(\n schema: StandardSchemaV1,\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. Native toJSONSchema() method\n if (typeof (schema as any).toJSONSchema === \"function\") {\n return (schema as any).toJSONSchema() as Record<string, unknown>;\n }\n\n const vendor = schema[\"~standard\"].vendor;\n throw new Error(\n `Cannot convert schema to JSON Schema. The schema (vendor: \"${vendor}\") does not implement Standard JSON Schema V1. ` +\n `Use a library that does: Zod 4.2+ (Zod 3 is not supported), Valibot v1+ wrapped with ` +\n `toStandardJsonSchema() from @valibot/to-json-schema, or ArkType v2.1.28+.`,\n );\n}\n"],"mappings":";;;;;;;;;AAcA,MAAa,aAAiD,EAC5D,aAAa;CACX,SAAS;CACT,QAAQ;CACR,WAAW,WAAW,EAAE,OAAO;CAChC,EACF;;;;AAYD,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;;;;;;;;;;;;;;AAgBtC,SAAgB,mBACd,QACyB;AAEzB,KAAI,sBAAsB,OAAO,CAC/B,QAAO,OAAO,aAAa,WAAW,MAAM,EAAE,QAAQ,YAAY,CAAC;AAIrE,KAAI,OAAQ,OAAe,iBAAiB,WAC1C,QAAQ,OAAe,cAAc;CAGvC,MAAM,SAAS,OAAO,aAAa;AACnC,OAAM,IAAI,MACR,8DAA8D,OAAO,+MAGtE"}
|
|
@@ -1,33 +1,32 @@
|
|
|
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.
|
|
7
15
|
*/
|
|
8
16
|
type InferSchemaOutput<S> = S extends StandardSchemaV1<any, infer O> ? O : never;
|
|
9
|
-
interface SchemaToJsonSchemaOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Injected `zodToJsonSchema` function so that `shared` does not depend on
|
|
12
|
-
* `zod-to-json-schema`. Required when the schema is a Zod v3 schema that
|
|
13
|
-
* does not implement Standard JSON Schema V1.
|
|
14
|
-
*/
|
|
15
|
-
zodToJsonSchema?: (schema: unknown, options?: {
|
|
16
|
-
$refStrategy?: string;
|
|
17
|
-
}) => Record<string, unknown>;
|
|
18
|
-
}
|
|
19
17
|
/**
|
|
20
18
|
* Convert any StandardSchemaV1-compatible schema to a JSON Schema object.
|
|
21
19
|
*
|
|
22
20
|
* Strategy:
|
|
23
21
|
* 1. If the schema implements Standard JSON Schema V1 (`~standard.jsonSchema`),
|
|
24
22
|
* call `schema['~standard'].jsonSchema.input({ target: 'draft-07' })`.
|
|
25
|
-
* 2
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
23
|
+
* Zod 4.2+, ArkType 2.1.28+ and Valibot (via `toStandardJsonSchema`) do.
|
|
24
|
+
* 2. If the schema exposes a `toJSONSchema()` method, call it directly.
|
|
25
|
+
* 3. Otherwise throw a descriptive error. Zod 3 schemas land here: they
|
|
26
|
+
* implement Standard Schema validation but cannot describe themselves as
|
|
27
|
+
* JSON Schema.
|
|
29
28
|
*/
|
|
30
|
-
declare function schemaToJsonSchema(schema: StandardSchemaV1
|
|
29
|
+
declare function schemaToJsonSchema(schema: StandardSchemaV1): Record<string, unknown>;
|
|
31
30
|
//#endregion
|
|
32
|
-
export { InferSchemaOutput,
|
|
31
|
+
export { InferSchemaOutput, type StandardJSONSchemaV1, type StandardSchemaV1, schemaToJsonSchema, ɵanySchema };
|
|
33
32
|
//# 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;;;;;AAgC7C;;;;;;;;iBAAgB,kBAAA,CACd,MAAA,EAAQ,gBAAA,GACP,MAAA"}
|
|
@@ -1,33 +1,32 @@
|
|
|
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.
|
|
7
15
|
*/
|
|
8
16
|
type InferSchemaOutput<S> = S extends StandardSchemaV1<any, infer O> ? O : never;
|
|
9
|
-
interface SchemaToJsonSchemaOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Injected `zodToJsonSchema` function so that `shared` does not depend on
|
|
12
|
-
* `zod-to-json-schema`. Required when the schema is a Zod v3 schema that
|
|
13
|
-
* does not implement Standard JSON Schema V1.
|
|
14
|
-
*/
|
|
15
|
-
zodToJsonSchema?: (schema: unknown, options?: {
|
|
16
|
-
$refStrategy?: string;
|
|
17
|
-
}) => Record<string, unknown>;
|
|
18
|
-
}
|
|
19
17
|
/**
|
|
20
18
|
* Convert any StandardSchemaV1-compatible schema to a JSON Schema object.
|
|
21
19
|
*
|
|
22
20
|
* Strategy:
|
|
23
21
|
* 1. If the schema implements Standard JSON Schema V1 (`~standard.jsonSchema`),
|
|
24
22
|
* call `schema['~standard'].jsonSchema.input({ target: 'draft-07' })`.
|
|
25
|
-
* 2
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
23
|
+
* Zod 4.2+, ArkType 2.1.28+ and Valibot (via `toStandardJsonSchema`) do.
|
|
24
|
+
* 2. If the schema exposes a `toJSONSchema()` method, call it directly.
|
|
25
|
+
* 3. Otherwise throw a descriptive error. Zod 3 schemas land here: they
|
|
26
|
+
* implement Standard Schema validation but cannot describe themselves as
|
|
27
|
+
* JSON Schema.
|
|
29
28
|
*/
|
|
30
|
-
declare function schemaToJsonSchema(schema: StandardSchemaV1
|
|
29
|
+
declare function schemaToJsonSchema(schema: StandardSchemaV1): Record<string, unknown>;
|
|
31
30
|
//#endregion
|
|
32
|
-
export { InferSchemaOutput,
|
|
31
|
+
export { InferSchemaOutput, type StandardJSONSchemaV1, type StandardSchemaV1, schemaToJsonSchema, ɵanySchema };
|
|
33
32
|
//# 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;;;;;AAgC7C;;;;;;;;iBAAgB,kBAAA,CACd,MAAA,EAAQ,gBAAA,GACP,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) {
|
|
@@ -12,19 +24,19 @@ function hasStandardJsonSchema(schema) {
|
|
|
12
24
|
* Strategy:
|
|
13
25
|
* 1. If the schema implements Standard JSON Schema V1 (`~standard.jsonSchema`),
|
|
14
26
|
* call `schema['~standard'].jsonSchema.input({ target: 'draft-07' })`.
|
|
15
|
-
* 2
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
27
|
+
* Zod 4.2+, ArkType 2.1.28+ and Valibot (via `toStandardJsonSchema`) do.
|
|
28
|
+
* 2. If the schema exposes a `toJSONSchema()` method, call it directly.
|
|
29
|
+
* 3. Otherwise throw a descriptive error. Zod 3 schemas land here: they
|
|
30
|
+
* implement Standard Schema validation but cannot describe themselves as
|
|
31
|
+
* JSON Schema.
|
|
19
32
|
*/
|
|
20
|
-
function schemaToJsonSchema(schema
|
|
33
|
+
function schemaToJsonSchema(schema) {
|
|
21
34
|
if (hasStandardJsonSchema(schema)) return schema["~standard"].jsonSchema.input({ target: "draft-07" });
|
|
22
35
|
if (typeof schema.toJSONSchema === "function") return schema.toJSONSchema();
|
|
23
36
|
const vendor = schema["~standard"].vendor;
|
|
24
|
-
|
|
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.`);
|
|
37
|
+
throw new Error(`Cannot convert schema to JSON Schema. The schema (vendor: "${vendor}") does not implement Standard JSON Schema V1. Use a library that does: Zod 4.2+ (Zod 3 is not supported), Valibot v1+ wrapped with toStandardJsonSchema() from @valibot/to-json-schema, or ArkType v2.1.28+.`);
|
|
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 *
|
|
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\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 * Zod 4.2+, ArkType 2.1.28+ and Valibot (via `toStandardJsonSchema`) do.\n * 2. If the schema exposes a `toJSONSchema()` method, call it directly.\n * 3. Otherwise throw a descriptive error. Zod 3 schemas land here: they\n * implement Standard Schema validation but cannot describe themselves as\n * JSON Schema.\n */\nexport function schemaToJsonSchema(\n schema: StandardSchemaV1,\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. Native toJSONSchema() method\n if (typeof (schema as any).toJSONSchema === \"function\") {\n return (schema as any).toJSONSchema() as Record<string, unknown>;\n }\n\n const vendor = schema[\"~standard\"].vendor;\n throw new Error(\n `Cannot convert schema to JSON Schema. The schema (vendor: \"${vendor}\") does not implement Standard JSON Schema V1. ` +\n `Use a library that does: Zod 4.2+ (Zod 3 is not supported), Valibot v1+ wrapped with ` +\n `toStandardJsonSchema() from @valibot/to-json-schema, or ArkType v2.1.28+.`,\n );\n}\n"],"mappings":";;;;;;;;AAcA,MAAa,aAAiD,EAC5D,aAAa;CACX,SAAS;CACT,QAAQ;CACR,WAAW,WAAW,EAAE,OAAO;CAChC,EACF;;;;AAYD,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;;;;;;;;;;;;;;AAgBtC,SAAgB,mBACd,QACyB;AAEzB,KAAI,sBAAsB,OAAO,CAC/B,QAAO,OAAO,aAAa,WAAW,MAAM,EAAE,QAAQ,YAAY,CAAC;AAIrE,KAAI,OAAQ,OAAe,iBAAiB,WAC1C,QAAQ,OAAe,cAAc;CAGvC,MAAM,SAAS,OAAO,aAAa;AACnC,OAAM,IAAI,MACR,8DAA8D,OAAO,+MAGtE"}
|
|
@@ -33,7 +33,7 @@ function parseTelemetryIdFromLicense(token) {
|
|
|
33
33
|
if (parts.length !== 3) return null;
|
|
34
34
|
try {
|
|
35
35
|
const payload = parts[1];
|
|
36
|
-
if (!/^[A-Za-z0-9_-]+$/.test(payload) || payload.length % 4 === 1) return null;
|
|
36
|
+
if (payload === void 0 || !/^[A-Za-z0-9_-]+$/.test(payload) || payload.length % 4 === 1) return null;
|
|
37
37
|
let b64 = payload.replace(/-/g, "+").replace(/_/g, "/");
|
|
38
38
|
const padding = (4 - b64.length % 4) % 4;
|
|
39
39
|
b64 += "=".repeat(padding);
|
|
@@ -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)
|
|
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 (\n payload === undefined ||\n !/^[A-Za-z0-9_-]+$/.test(payload) ||\n payload.length % 4 === 1\n ) {\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,MACE,YAAY,UACZ,CAAC,mBAAmB,KAAK,QAAQ,IACjC,QAAQ,SAAS,MAAM,EAEvB,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,iBAwC5B,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,iBAwC5B,uBAAA,CAAwB,YAAA;AAAA,iBAUlB,IAAA,CAAK,IAAA,EAAM,iBAAA,GAAoB,OAAA;AAAA,cA2CxC,YAAA;eAAuB,IAAA;AAAA"}
|
|
@@ -32,7 +32,7 @@ function parseTelemetryIdFromLicense(token) {
|
|
|
32
32
|
if (parts.length !== 3) return null;
|
|
33
33
|
try {
|
|
34
34
|
const payload = parts[1];
|
|
35
|
-
if (!/^[A-Za-z0-9_-]+$/.test(payload) || payload.length % 4 === 1) return null;
|
|
35
|
+
if (payload === void 0 || !/^[A-Za-z0-9_-]+$/.test(payload) || payload.length % 4 === 1) return null;
|
|
36
36
|
let b64 = payload.replace(/-/g, "+").replace(/_/g, "/");
|
|
37
37
|
const padding = (4 - b64.length % 4) % 4;
|
|
38
38
|
b64 += "=".repeat(padding);
|
|
@@ -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)
|
|
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 (\n payload === undefined ||\n !/^[A-Za-z0-9_-]+$/.test(payload) ||\n payload.length % 4 === 1\n ) {\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,MACE,YAAY,UACZ,CAAC,mBAAmB,KAAK,QAAQ,IACjC,QAAQ,SAAS,MAAM,EAEvB,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"}
|
|
@@ -6,11 +6,6 @@ const require_process_env = require('../utils/process-env.cjs');
|
|
|
6
6
|
* Users can opt out by setting:
|
|
7
7
|
* - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1
|
|
8
8
|
* - DO_NOT_TRACK=true or DO_NOT_TRACK=1
|
|
9
|
-
*
|
|
10
|
-
* Lives in its own module so that the browser-facing root entry can
|
|
11
|
-
* re-export it without pulling in `telemetry-client.ts`, whose
|
|
12
|
-
* `@segment/analytics-node` import drags Node built-ins into browser
|
|
13
|
-
* bundler module graphs. See the note in `../index.ts`.
|
|
14
9
|
*/
|
|
15
10
|
function isTelemetryDisabled() {
|
|
16
11
|
const env = require_process_env.processEnv();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-disabled.cjs","names":["processEnv"],"sources":["../../src/telemetry/telemetry-disabled.ts"],"sourcesContent":["import { processEnv } from \"../utils/process-env\";\n\n/**\n * Checks if telemetry is disabled via environment variables.\n * Users can opt out by setting:\n * - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1\n * - DO_NOT_TRACK=true or DO_NOT_TRACK=1\n
|
|
1
|
+
{"version":3,"file":"telemetry-disabled.cjs","names":["processEnv"],"sources":["../../src/telemetry/telemetry-disabled.ts"],"sourcesContent":["import { processEnv } from \"../utils/process-env\";\n\n/**\n * Checks if telemetry is disabled via environment variables.\n * Users can opt out by setting:\n * - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1\n * - DO_NOT_TRACK=true or DO_NOT_TRACK=1\n */\nexport function isTelemetryDisabled(): boolean {\n const env = processEnv();\n return (\n env.COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n env.COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n env.DO_NOT_TRACK === \"true\" ||\n env.DO_NOT_TRACK === \"1\"\n );\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,sBAA+B;CAC7C,MAAM,MAAMA,gCAAY;AACxB,QACE,IAAI,kCAAkC,UACtC,IAAI,kCAAkC,OACtC,IAAI,iBAAiB,UACrB,IAAI,iBAAiB"}
|
|
@@ -4,11 +4,6 @@
|
|
|
4
4
|
* Users can opt out by setting:
|
|
5
5
|
* - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1
|
|
6
6
|
* - DO_NOT_TRACK=true or DO_NOT_TRACK=1
|
|
7
|
-
*
|
|
8
|
-
* Lives in its own module so that the browser-facing root entry can
|
|
9
|
-
* re-export it without pulling in `telemetry-client.ts`, whose
|
|
10
|
-
* `@segment/analytics-node` import drags Node built-ins into browser
|
|
11
|
-
* bundler module graphs. See the note in `../index.ts`.
|
|
12
7
|
*/
|
|
13
8
|
declare function isTelemetryDisabled(): boolean;
|
|
14
9
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-disabled.d.cts","names":[],"sources":["../../src/telemetry/telemetry-disabled.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"telemetry-disabled.d.cts","names":[],"sources":["../../src/telemetry/telemetry-disabled.ts"],"mappings":";;AAQA;;;;;iBAAgB,mBAAA,CAAA"}
|
|
@@ -4,11 +4,6 @@
|
|
|
4
4
|
* Users can opt out by setting:
|
|
5
5
|
* - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1
|
|
6
6
|
* - DO_NOT_TRACK=true or DO_NOT_TRACK=1
|
|
7
|
-
*
|
|
8
|
-
* Lives in its own module so that the browser-facing root entry can
|
|
9
|
-
* re-export it without pulling in `telemetry-client.ts`, whose
|
|
10
|
-
* `@segment/analytics-node` import drags Node built-ins into browser
|
|
11
|
-
* bundler module graphs. See the note in `../index.ts`.
|
|
12
7
|
*/
|
|
13
8
|
declare function isTelemetryDisabled(): boolean;
|
|
14
9
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-disabled.d.mts","names":[],"sources":["../../src/telemetry/telemetry-disabled.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"telemetry-disabled.d.mts","names":[],"sources":["../../src/telemetry/telemetry-disabled.ts"],"mappings":";;AAQA;;;;;iBAAgB,mBAAA,CAAA"}
|
|
@@ -6,11 +6,6 @@ import { processEnv } from "../utils/process-env.mjs";
|
|
|
6
6
|
* Users can opt out by setting:
|
|
7
7
|
* - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1
|
|
8
8
|
* - DO_NOT_TRACK=true or DO_NOT_TRACK=1
|
|
9
|
-
*
|
|
10
|
-
* Lives in its own module so that the browser-facing root entry can
|
|
11
|
-
* re-export it without pulling in `telemetry-client.ts`, whose
|
|
12
|
-
* `@segment/analytics-node` import drags Node built-ins into browser
|
|
13
|
-
* bundler module graphs. See the note in `../index.ts`.
|
|
14
9
|
*/
|
|
15
10
|
function isTelemetryDisabled() {
|
|
16
11
|
const env = processEnv();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-disabled.mjs","names":[],"sources":["../../src/telemetry/telemetry-disabled.ts"],"sourcesContent":["import { processEnv } from \"../utils/process-env\";\n\n/**\n * Checks if telemetry is disabled via environment variables.\n * Users can opt out by setting:\n * - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1\n * - DO_NOT_TRACK=true or DO_NOT_TRACK=1\n
|
|
1
|
+
{"version":3,"file":"telemetry-disabled.mjs","names":[],"sources":["../../src/telemetry/telemetry-disabled.ts"],"sourcesContent":["import { processEnv } from \"../utils/process-env\";\n\n/**\n * Checks if telemetry is disabled via environment variables.\n * Users can opt out by setting:\n * - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1\n * - DO_NOT_TRACK=true or DO_NOT_TRACK=1\n */\nexport function isTelemetryDisabled(): boolean {\n const env = processEnv();\n return (\n env.COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n env.COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n env.DO_NOT_TRACK === \"true\" ||\n env.DO_NOT_TRACK === \"1\"\n );\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,sBAA+B;CAC7C,MAAM,MAAM,YAAY;AACxB,QACE,IAAI,kCAAkC,UACtC,IAAI,kCAAkC,OACtC,IAAI,iBAAiB,UACrB,IAAI,iBAAiB"}
|
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"}
|