@copilotkit/shared 2.0.0-rc.2 → 2.0.0-rc.20
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/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 +17 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +10 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +9 -7
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +839 -447
- 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 +3 -6
- 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 +4 -6
- 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 +1 -2
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +4 -5
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts +4 -5
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +4 -5
- package/dist/utils/index.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/process-env.cjs +14 -0
- package/dist/utils/process-env.cjs.map +1 -0
- package/dist/utils/process-env.d.cts +10 -0
- package/dist/utils/process-env.d.cts.map +1 -0
- package/dist/utils/process-env.d.mts +10 -0
- package/dist/utils/process-env.d.mts.map +1 -0
- package/dist/utils/process-env.mjs +13 -0
- package/dist/utils/process-env.mjs.map +1 -0
- 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 +8 -32
- 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/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 +7 -12
- 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__/process-env.test.ts +22 -0
- package/src/utils/__tests__/random-id.test.ts +37 -0
- package/src/utils/errors.ts +28 -85
- package/src/utils/index.ts +1 -2
- package/src/utils/json-schema.ts +5 -152
- package/src/utils/process-env.ts +14 -0
- 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/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.
|
|
@@ -12,18 +27,6 @@ export type { StandardSchemaV1, StandardJSONSchemaV1 };
|
|
|
12
27
|
export type InferSchemaOutput<S> =
|
|
13
28
|
S extends StandardSchemaV1<any, infer O> ? O : never;
|
|
14
29
|
|
|
15
|
-
export interface SchemaToJsonSchemaOptions {
|
|
16
|
-
/**
|
|
17
|
-
* Injected `zodToJsonSchema` function so that `shared` does not depend on
|
|
18
|
-
* `zod-to-json-schema`. Required when the schema is a Zod v3 schema that
|
|
19
|
-
* does not implement Standard JSON Schema V1.
|
|
20
|
-
*/
|
|
21
|
-
zodToJsonSchema?: (
|
|
22
|
-
schema: unknown,
|
|
23
|
-
options?: { $refStrategy?: string },
|
|
24
|
-
) => Record<string, unknown>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
30
|
/**
|
|
28
31
|
* Check whether a schema implements the Standard JSON Schema V1 protocol.
|
|
29
32
|
*/
|
|
@@ -48,35 +51,29 @@ function hasStandardJsonSchema(
|
|
|
48
51
|
* Strategy:
|
|
49
52
|
* 1. If the schema implements Standard JSON Schema V1 (`~standard.jsonSchema`),
|
|
50
53
|
* call `schema['~standard'].jsonSchema.input({ target: 'draft-07' })`.
|
|
51
|
-
* 2
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
54
|
+
* Zod 4.2+, ArkType 2.1.28+ and Valibot (via `toStandardJsonSchema`) do.
|
|
55
|
+
* 2. If the schema exposes a `toJSONSchema()` method, call it directly.
|
|
56
|
+
* 3. Otherwise throw a descriptive error. Zod 3 schemas land here: they
|
|
57
|
+
* implement Standard Schema validation but cannot describe themselves as
|
|
58
|
+
* JSON Schema.
|
|
55
59
|
*/
|
|
56
60
|
export function schemaToJsonSchema(
|
|
57
61
|
schema: StandardSchemaV1,
|
|
58
|
-
options?: SchemaToJsonSchemaOptions,
|
|
59
62
|
): Record<string, unknown> {
|
|
60
63
|
// 1. Standard JSON Schema V1
|
|
61
64
|
if (hasStandardJsonSchema(schema)) {
|
|
62
65
|
return schema["~standard"].jsonSchema.input({ target: "draft-07" });
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
// 2.
|
|
68
|
+
// 2. Native toJSONSchema() method
|
|
66
69
|
if (typeof (schema as any).toJSONSchema === "function") {
|
|
67
70
|
return (schema as any).toJSONSchema() as Record<string, unknown>;
|
|
68
71
|
}
|
|
69
72
|
|
|
70
|
-
// 3. Zod v3 fallback
|
|
71
73
|
const vendor = schema["~standard"].vendor;
|
|
72
|
-
if (vendor === "zod" && options?.zodToJsonSchema) {
|
|
73
|
-
return options.zodToJsonSchema(schema, { $refStrategy: "none" });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
74
|
throw new Error(
|
|
77
|
-
`Cannot convert schema to JSON Schema. The schema (vendor: "${vendor}") does not implement Standard JSON Schema V1 ` +
|
|
78
|
-
`
|
|
79
|
-
`
|
|
80
|
-
`or pass a zodToJsonSchema function in options.`,
|
|
75
|
+
`Cannot convert schema to JSON Schema. The schema (vendor: "${vendor}") does not implement Standard JSON Schema V1. ` +
|
|
76
|
+
`Use a library that does: Zod 4.2+ (Zod 3 is not supported), Valibot v1+ wrapped with ` +
|
|
77
|
+
`toStandardJsonSchema() from @valibot/to-json-schema, or ArkType v2.1.28+.`,
|
|
81
78
|
);
|
|
82
79
|
}
|
|
@@ -109,7 +109,11 @@ export function parseTelemetryIdFromLicense(token?: string): string | null {
|
|
|
109
109
|
if (parts.length !== 3) return null;
|
|
110
110
|
try {
|
|
111
111
|
const payload = parts[1];
|
|
112
|
-
if (
|
|
112
|
+
if (
|
|
113
|
+
payload === undefined ||
|
|
114
|
+
!/^[A-Za-z0-9_-]+$/.test(payload) ||
|
|
115
|
+
payload.length % 4 === 1
|
|
116
|
+
) {
|
|
113
117
|
return null;
|
|
114
118
|
}
|
|
115
119
|
|
|
@@ -136,8 +140,9 @@ export function parseTelemetryIdFromLicense(token?: string): string | null {
|
|
|
136
140
|
// Parse the telemetry_id from a license token AND emit the rollout smoke
|
|
137
141
|
// signal if the parse returned null. Returning the parsed id lets callers
|
|
138
142
|
// cache it in one step (avoiding a second parseTelemetryIdFromLicense
|
|
139
|
-
// pass) while keeping the warn text in lockstep between v1 (shared)
|
|
140
|
-
// v2 (runtime)
|
|
143
|
+
// pass) while keeping the warn text in lockstep between the v1 (shared)
|
|
144
|
+
// TelemetryClient.setLicenseToken and the v2 (runtime)
|
|
145
|
+
// TelemetryClient.setTelemetryIdentity.
|
|
141
146
|
export function parseAndWarnTelemetryId(licenseToken: string): string | null {
|
|
142
147
|
const telemetryId = parseTelemetryIdFromLicense(licenseToken);
|
|
143
148
|
if (!telemetryId) {
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
MODEL_HOST_CLASSES,
|
|
5
|
-
type ModelHostClass,
|
|
6
|
-
} from "./model-host";
|
|
2
|
+
import { classifyModelHost, MODEL_HOST_CLASSES } from "./model-host";
|
|
3
|
+
import type { ModelHostClass } from "./model-host";
|
|
7
4
|
|
|
8
5
|
describe("classifyModelHost", () => {
|
|
9
6
|
describe("the case this exists for: an OpenAI-shaped client aimed elsewhere", () => {
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
+
import { processEnv } from "../utils/process-env";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Checks if telemetry is disabled via environment variables.
|
|
3
5
|
* Users can opt out by setting:
|
|
4
6
|
* - COPILOTKIT_TELEMETRY_DISABLED=true or COPILOTKIT_TELEMETRY_DISABLED=1
|
|
5
7
|
* - DO_NOT_TRACK=true or DO_NOT_TRACK=1
|
|
6
|
-
*
|
|
7
|
-
* Lives in its own module so that the browser-facing root entry can
|
|
8
|
-
* re-export it without pulling in `telemetry-client.ts`, whose
|
|
9
|
-
* `@segment/analytics-node` import drags Node built-ins into browser
|
|
10
|
-
* bundler module graphs. See the note in `../index.ts`.
|
|
11
8
|
*/
|
|
12
9
|
export function isTelemetryDisabled(): boolean {
|
|
10
|
+
const env = processEnv();
|
|
13
11
|
return (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(process.env as Record<string, string | undefined>).DO_NOT_TRACK ===
|
|
19
|
-
"true" ||
|
|
20
|
-
(process.env as Record<string, string | undefined>).DO_NOT_TRACK === "1"
|
|
12
|
+
env.COPILOTKIT_TELEMETRY_DISABLED === "true" ||
|
|
13
|
+
env.COPILOTKIT_TELEMETRY_DISABLED === "1" ||
|
|
14
|
+
env.DO_NOT_TRACK === "true" ||
|
|
15
|
+
env.DO_NOT_TRACK === "1"
|
|
21
16
|
);
|
|
22
17
|
}
|
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
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
CopilotKitError,
|
|
4
|
+
CopilotKitErrorCode,
|
|
5
|
+
ConfigurationError,
|
|
6
|
+
ErrorVisibility,
|
|
7
|
+
Severity,
|
|
8
|
+
} from "../errors";
|
|
9
|
+
|
|
10
|
+
describe("CopilotKitError", () => {
|
|
11
|
+
it("is a plain Error that keeps the structured extensions", () => {
|
|
12
|
+
const error = new CopilotKitError({
|
|
13
|
+
message: "boom",
|
|
14
|
+
code: CopilotKitErrorCode.NOT_FOUND,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(error).toBeInstanceOf(Error);
|
|
18
|
+
expect(error.message).toBe("boom");
|
|
19
|
+
expect(error.name).toBe("CopilotError");
|
|
20
|
+
expect(error.extensions).toMatchObject({
|
|
21
|
+
name: "CopilotError",
|
|
22
|
+
code: CopilotKitErrorCode.NOT_FOUND,
|
|
23
|
+
statusCode: 404,
|
|
24
|
+
visibility: ErrorVisibility.BANNER,
|
|
25
|
+
severity: Severity.CRITICAL,
|
|
26
|
+
originalError: { message: "boom" },
|
|
27
|
+
});
|
|
28
|
+
expect(error.extensions.troubleshootingUrl).toContain(
|
|
29
|
+
"network-errors-api-not-found",
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("sets troubleshootingUrl to null when the code has none", () => {
|
|
34
|
+
const error = new CopilotKitError({ code: CopilotKitErrorCode.UNKNOWN });
|
|
35
|
+
expect(error.extensions.troubleshootingUrl).toBeNull();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("keeps subclasses instanceof both the subclass and CopilotKitError", () => {
|
|
39
|
+
const error = new ConfigurationError("bad config");
|
|
40
|
+
expect(error).toBeInstanceOf(ConfigurationError);
|
|
41
|
+
expect(error).toBeInstanceOf(CopilotKitError);
|
|
42
|
+
expect(error.extensions.code).toBe(CopilotKitErrorCode.CONFIGURATION_ERROR);
|
|
43
|
+
});
|
|
44
|
+
});
|