@copilotkit/shared 2.0.0-rc.5 → 2.0.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +0 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -5
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +22 -187
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/telemetry/lambda-client.cjs.map +1 -1
- package/dist/telemetry/lambda-client.d.cts.map +1 -1
- package/dist/telemetry/lambda-client.d.mts.map +1 -1
- package/dist/telemetry/lambda-client.mjs.map +1 -1
- package/dist/telemetry/telemetry-client.cjs +3 -3
- package/dist/telemetry/telemetry-client.cjs.map +1 -1
- package/dist/telemetry/telemetry-client.mjs +3 -3
- package/dist/telemetry/telemetry-client.mjs.map +1 -1
- package/dist/types/message.d.cts +1 -18
- package/dist/types/message.d.cts.map +1 -1
- package/dist/types/message.d.mts +1 -18
- package/dist/types/message.d.mts.map +1 -1
- package/dist/utils/errors.cjs +4 -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 +5 -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 +2 -4
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts +2 -4
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +2 -4
- package/dist/utils/index.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 +3 -6
- package/src/telemetry/lambda-client.ts +3 -2
- package/src/telemetry/telemetry-client.ts +3 -3
- package/src/types/message.ts +1 -19
- package/src/utils/__tests__/errors.test.ts +44 -0
- package/src/utils/__tests__/random-id.test.ts +37 -0
- package/src/utils/errors.ts +27 -85
- package/src/utils/index.ts +0 -2
- package/src/utils/random-id.ts +17 -37
- package/tsdown.config.ts +1 -10
- 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/utils/__tests__/conditions.test.ts +0 -161
- package/src/utils/conditions.ts +0 -116
- package/src/utils/console-styling.ts +0 -126
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
executeConditions,
|
|
4
|
-
Condition,
|
|
5
|
-
ComparisonCondition,
|
|
6
|
-
LogicalCondition,
|
|
7
|
-
ExistenceCondition,
|
|
8
|
-
} from "../conditions";
|
|
9
|
-
|
|
10
|
-
describe("executeConditions", () => {
|
|
11
|
-
it("returns true when conditions is empty or undefined", () => {
|
|
12
|
-
expect(executeConditions({ value: { a: 1 } })).toBe(true);
|
|
13
|
-
expect(executeConditions({ conditions: [], value: { a: 1 } })).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("treats multiple conditions as an implicit AND", () => {
|
|
17
|
-
const conditions: Condition[] = [
|
|
18
|
-
{ rule: "EQUALS", path: "a", value: 1 },
|
|
19
|
-
{ rule: "EQUALS", path: "b", value: 2 },
|
|
20
|
-
];
|
|
21
|
-
expect(executeConditions({ conditions, value: { a: 1, b: 2 } })).toBe(true);
|
|
22
|
-
expect(executeConditions({ conditions, value: { a: 1, b: 3 } })).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe("comparison rules", () => {
|
|
26
|
-
it("EQUALS and NOT_EQUALS", () => {
|
|
27
|
-
const eq: ComparisonCondition = { rule: "EQUALS", path: "a", value: 5 };
|
|
28
|
-
const neq: ComparisonCondition = { rule: "NOT_EQUALS", path: "a", value: 5 };
|
|
29
|
-
expect(executeConditions({ conditions: [eq], value: { a: 5 } })).toBe(true);
|
|
30
|
-
expect(executeConditions({ conditions: [eq], value: { a: 6 } })).toBe(false);
|
|
31
|
-
expect(executeConditions({ conditions: [neq], value: { a: 6 } })).toBe(true);
|
|
32
|
-
expect(executeConditions({ conditions: [neq], value: { a: 5 } })).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("GREATER_THAN and LESS_THAN", () => {
|
|
36
|
-
const gt: ComparisonCondition = { rule: "GREATER_THAN", path: "n", value: 10 };
|
|
37
|
-
const lt: ComparisonCondition = { rule: "LESS_THAN", path: "n", value: 10 };
|
|
38
|
-
expect(executeConditions({ conditions: [gt], value: { n: 11 } })).toBe(true);
|
|
39
|
-
expect(executeConditions({ conditions: [gt], value: { n: 10 } })).toBe(false);
|
|
40
|
-
expect(executeConditions({ conditions: [lt], value: { n: 9 } })).toBe(true);
|
|
41
|
-
expect(executeConditions({ conditions: [lt], value: { n: 10 } })).toBe(false);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("CONTAINS and NOT_CONTAINS only apply to arrays", () => {
|
|
45
|
-
const contains: ComparisonCondition = { rule: "CONTAINS", path: "tags", value: "ts" };
|
|
46
|
-
const notContains: ComparisonCondition = { rule: "NOT_CONTAINS", path: "tags", value: "ts" };
|
|
47
|
-
expect(
|
|
48
|
-
executeConditions({ conditions: [contains], value: { tags: ["js", "ts"] } }),
|
|
49
|
-
).toBe(true);
|
|
50
|
-
expect(
|
|
51
|
-
executeConditions({ conditions: [contains], value: { tags: ["js"] } }),
|
|
52
|
-
).toBe(false);
|
|
53
|
-
expect(
|
|
54
|
-
executeConditions({ conditions: [notContains], value: { tags: ["js"] } }),
|
|
55
|
-
).toBe(true);
|
|
56
|
-
// non-array target always fails both CONTAINS and NOT_CONTAINS
|
|
57
|
-
expect(
|
|
58
|
-
executeConditions({ conditions: [contains], value: { tags: "ts" } }),
|
|
59
|
-
).toBe(false);
|
|
60
|
-
expect(
|
|
61
|
-
executeConditions({ conditions: [notContains], value: { tags: "ts" } }),
|
|
62
|
-
).toBe(false);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("MATCHES uses the value as a regular expression", () => {
|
|
66
|
-
const matches: ComparisonCondition = { rule: "MATCHES", path: "code", value: "^CK-[0-9]+$" };
|
|
67
|
-
expect(executeConditions({ conditions: [matches], value: { code: "CK-123" } })).toBe(true);
|
|
68
|
-
expect(executeConditions({ conditions: [matches], value: { code: "nope" } })).toBe(false);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("STARTS_WITH and ENDS_WITH", () => {
|
|
72
|
-
const sw: ComparisonCondition = { rule: "STARTS_WITH", path: "s", value: "foo" };
|
|
73
|
-
const ew: ComparisonCondition = { rule: "ENDS_WITH", path: "s", value: "bar" };
|
|
74
|
-
expect(executeConditions({ conditions: [sw], value: { s: "foobar" } })).toBe(true);
|
|
75
|
-
expect(executeConditions({ conditions: [sw], value: { s: "barfoo" } })).toBe(false);
|
|
76
|
-
expect(executeConditions({ conditions: [ew], value: { s: "foobar" } })).toBe(true);
|
|
77
|
-
expect(executeConditions({ conditions: [ew], value: { s: "barfoo" } })).toBe(false);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
describe("existence rules", () => {
|
|
82
|
-
it("EXISTS passes only for defined non-null values", () => {
|
|
83
|
-
const exists: ExistenceCondition = { rule: "EXISTS", path: "a" };
|
|
84
|
-
expect(executeConditions({ conditions: [exists], value: { a: 0 } })).toBe(true);
|
|
85
|
-
expect(executeConditions({ conditions: [exists], value: { a: "" } })).toBe(true);
|
|
86
|
-
expect(executeConditions({ conditions: [exists], value: { a: false } })).toBe(true);
|
|
87
|
-
expect(executeConditions({ conditions: [exists], value: { a: null } })).toBe(false);
|
|
88
|
-
expect(executeConditions({ conditions: [exists], value: {} })).toBe(false);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("NOT_EXISTS is the inverse of EXISTS", () => {
|
|
92
|
-
const notExists: ExistenceCondition = { rule: "NOT_EXISTS", path: "a" };
|
|
93
|
-
expect(executeConditions({ conditions: [notExists], value: { a: 1 } })).toBe(false);
|
|
94
|
-
expect(executeConditions({ conditions: [notExists], value: { a: null } })).toBe(true);
|
|
95
|
-
expect(executeConditions({ conditions: [notExists], value: {} })).toBe(true);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
describe("logical rules", () => {
|
|
100
|
-
it("AND requires all nested conditions to pass", () => {
|
|
101
|
-
const and: LogicalCondition = {
|
|
102
|
-
rule: "AND",
|
|
103
|
-
conditions: [
|
|
104
|
-
{ rule: "EQUALS", path: "a", value: 1 },
|
|
105
|
-
{ rule: "EQUALS", path: "b", value: 2 },
|
|
106
|
-
],
|
|
107
|
-
};
|
|
108
|
-
expect(executeConditions({ conditions: [and], value: { a: 1, b: 2 } })).toBe(true);
|
|
109
|
-
expect(executeConditions({ conditions: [and], value: { a: 1, b: 3 } })).toBe(false);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("OR passes when any nested condition passes", () => {
|
|
113
|
-
const or: LogicalCondition = {
|
|
114
|
-
rule: "OR",
|
|
115
|
-
conditions: [
|
|
116
|
-
{ rule: "EQUALS", path: "a", value: 1 },
|
|
117
|
-
{ rule: "EQUALS", path: "b", value: 2 },
|
|
118
|
-
],
|
|
119
|
-
};
|
|
120
|
-
expect(executeConditions({ conditions: [or], value: { a: 9, b: 2 } })).toBe(true);
|
|
121
|
-
expect(executeConditions({ conditions: [or], value: { a: 9, b: 9 } })).toBe(false);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it("NOT inverts the AND of nested conditions", () => {
|
|
125
|
-
const notAll: LogicalCondition = {
|
|
126
|
-
rule: "NOT",
|
|
127
|
-
conditions: [
|
|
128
|
-
{ rule: "EQUALS", path: "a", value: 1 },
|
|
129
|
-
{ rule: "EQUALS", path: "b", value: 2 },
|
|
130
|
-
],
|
|
131
|
-
};
|
|
132
|
-
// both true → NOT(AND) = false
|
|
133
|
-
expect(executeConditions({ conditions: [notAll], value: { a: 1, b: 2 } })).toBe(false);
|
|
134
|
-
// one false → NOT(AND) = true
|
|
135
|
-
expect(executeConditions({ conditions: [notAll], value: { a: 1, b: 3 } })).toBe(true);
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
describe("path resolution", () => {
|
|
140
|
-
it("resolves nested dot paths", () => {
|
|
141
|
-
const cond: ComparisonCondition = { rule: "EQUALS", path: "user.profile.age", value: 30 };
|
|
142
|
-
expect(
|
|
143
|
-
executeConditions({ conditions: [cond], value: { user: { profile: { age: 30 } } } }),
|
|
144
|
-
).toBe(true);
|
|
145
|
-
expect(
|
|
146
|
-
executeConditions({ conditions: [cond], value: { user: { profile: { age: 31 } } } }),
|
|
147
|
-
).toBe(false);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it("returns false for a missing nested path (undefined target)", () => {
|
|
151
|
-
const eq: ComparisonCondition = { rule: "EQUALS", path: "a.b.c", value: 1 };
|
|
152
|
-
expect(executeConditions({ conditions: [eq], value: {} })).toBe(false);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("uses the whole value when no path is given", () => {
|
|
156
|
-
const eq: ComparisonCondition = { rule: "EQUALS", value: 42 };
|
|
157
|
-
expect(executeConditions({ conditions: [eq], value: 42 })).toBe(true);
|
|
158
|
-
expect(executeConditions({ conditions: [eq], value: 43 })).toBe(false);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
});
|
package/src/utils/conditions.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
export type ComparisonRule =
|
|
2
|
-
| "EQUALS"
|
|
3
|
-
| "NOT_EQUALS"
|
|
4
|
-
| "GREATER_THAN"
|
|
5
|
-
| "LESS_THAN"
|
|
6
|
-
| "CONTAINS"
|
|
7
|
-
| "NOT_CONTAINS"
|
|
8
|
-
| "MATCHES"
|
|
9
|
-
| "STARTS_WITH"
|
|
10
|
-
| "ENDS_WITH";
|
|
11
|
-
export type LogicalRule = "AND" | "OR" | "NOT";
|
|
12
|
-
export type ExistenceRule = "EXISTS" | "NOT_EXISTS";
|
|
13
|
-
|
|
14
|
-
export type Rule = ComparisonRule | LogicalRule | ExistenceRule;
|
|
15
|
-
|
|
16
|
-
export interface BaseCondition {
|
|
17
|
-
rule: Rule;
|
|
18
|
-
path?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface ComparisonCondition extends BaseCondition {
|
|
22
|
-
rule: ComparisonRule;
|
|
23
|
-
value: any;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface LogicalCondition extends BaseCondition {
|
|
27
|
-
rule: LogicalRule;
|
|
28
|
-
conditions: Condition[];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface ExistenceCondition extends BaseCondition {
|
|
32
|
-
rule: ExistenceRule;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type Condition =
|
|
36
|
-
| ComparisonCondition
|
|
37
|
-
| LogicalCondition
|
|
38
|
-
| ExistenceCondition;
|
|
39
|
-
|
|
40
|
-
export function executeConditions({
|
|
41
|
-
conditions,
|
|
42
|
-
value,
|
|
43
|
-
}: {
|
|
44
|
-
conditions?: Condition[];
|
|
45
|
-
value: any;
|
|
46
|
-
}): boolean {
|
|
47
|
-
// If no conditions, consider it a pass
|
|
48
|
-
if (!conditions?.length) return true;
|
|
49
|
-
|
|
50
|
-
// Run all conditions (implicit AND)
|
|
51
|
-
return conditions.every((condition) => executeCondition(condition, value));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function executeCondition(condition: Condition, value: any): boolean {
|
|
55
|
-
const targetValue = condition.path
|
|
56
|
-
? getValueFromPath(value, condition.path)
|
|
57
|
-
: value;
|
|
58
|
-
|
|
59
|
-
switch (condition.rule) {
|
|
60
|
-
// Logical
|
|
61
|
-
case "AND":
|
|
62
|
-
return (condition as LogicalCondition).conditions.every((c) =>
|
|
63
|
-
executeCondition(c, value),
|
|
64
|
-
);
|
|
65
|
-
case "OR":
|
|
66
|
-
return (condition as LogicalCondition).conditions.some((c) =>
|
|
67
|
-
executeCondition(c, value),
|
|
68
|
-
);
|
|
69
|
-
case "NOT":
|
|
70
|
-
return !(condition as LogicalCondition).conditions.every((c) =>
|
|
71
|
-
executeCondition(c, value),
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
// Comparison
|
|
75
|
-
case "EQUALS":
|
|
76
|
-
return targetValue === (condition as ComparisonCondition).value;
|
|
77
|
-
case "NOT_EQUALS":
|
|
78
|
-
return targetValue !== (condition as ComparisonCondition).value;
|
|
79
|
-
case "GREATER_THAN":
|
|
80
|
-
return targetValue > (condition as ComparisonCondition).value;
|
|
81
|
-
case "LESS_THAN":
|
|
82
|
-
return targetValue < (condition as ComparisonCondition).value;
|
|
83
|
-
case "CONTAINS":
|
|
84
|
-
return (
|
|
85
|
-
Array.isArray(targetValue) &&
|
|
86
|
-
targetValue.includes((condition as ComparisonCondition).value)
|
|
87
|
-
);
|
|
88
|
-
case "NOT_CONTAINS":
|
|
89
|
-
return (
|
|
90
|
-
Array.isArray(targetValue) &&
|
|
91
|
-
!targetValue.includes((condition as ComparisonCondition).value)
|
|
92
|
-
);
|
|
93
|
-
case "MATCHES":
|
|
94
|
-
return new RegExp((condition as ComparisonCondition).value).test(
|
|
95
|
-
String(targetValue),
|
|
96
|
-
);
|
|
97
|
-
case "STARTS_WITH":
|
|
98
|
-
return String(targetValue).startsWith(
|
|
99
|
-
(condition as ComparisonCondition).value,
|
|
100
|
-
);
|
|
101
|
-
case "ENDS_WITH":
|
|
102
|
-
return String(targetValue).endsWith(
|
|
103
|
-
(condition as ComparisonCondition).value,
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
// Existence
|
|
107
|
-
case "EXISTS":
|
|
108
|
-
return targetValue !== undefined && targetValue !== null;
|
|
109
|
-
case "NOT_EXISTS":
|
|
110
|
-
return targetValue === undefined || targetValue === null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function getValueFromPath(obj: any, path: string): any {
|
|
115
|
-
return path.split(".").reduce((acc, part) => acc?.[part], obj);
|
|
116
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Console styling utilities for CopilotKit branded messages
|
|
3
|
-
* Provides consistent, readable colors across light and dark console themes
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Color palette optimized for console readability
|
|
8
|
-
*/
|
|
9
|
-
export const ConsoleColors = {
|
|
10
|
-
/** Primary brand blue - for titles and links */
|
|
11
|
-
primary: "#007acc",
|
|
12
|
-
/** Success green - for positive messaging */
|
|
13
|
-
success: "#22c55e",
|
|
14
|
-
/** Purple - for feature highlights */
|
|
15
|
-
feature: "#a855f7",
|
|
16
|
-
/** Red - for calls-to-action */
|
|
17
|
-
cta: "#ef4444",
|
|
18
|
-
/** Cyan - for closing statements */
|
|
19
|
-
info: "#06b6d4",
|
|
20
|
-
/** Inherit console default - for body text */
|
|
21
|
-
inherit: "inherit",
|
|
22
|
-
/** Warning style */
|
|
23
|
-
warning: "#f59e0b",
|
|
24
|
-
} as const;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Console style templates for common patterns
|
|
28
|
-
*/
|
|
29
|
-
export const ConsoleStyles = {
|
|
30
|
-
/** Large header style */
|
|
31
|
-
header: `color: ${ConsoleColors.warning}; font-weight: bold; font-size: 16px;`,
|
|
32
|
-
/** Section header style */
|
|
33
|
-
section: `color: ${ConsoleColors.success}; font-weight: bold;`,
|
|
34
|
-
/** Feature highlight style */
|
|
35
|
-
highlight: `color: ${ConsoleColors.feature}; font-weight: bold;`,
|
|
36
|
-
/** Call-to-action style */
|
|
37
|
-
cta: `color: ${ConsoleColors.success}; font-weight: bold;`,
|
|
38
|
-
/** Info style */
|
|
39
|
-
info: `color: ${ConsoleColors.info}; font-weight: bold;`,
|
|
40
|
-
/** Link style */
|
|
41
|
-
link: `color: ${ConsoleColors.primary}; text-decoration: underline;`,
|
|
42
|
-
/** Body text - inherits console theme */
|
|
43
|
-
body: `color: ${ConsoleColors.inherit};`,
|
|
44
|
-
/** Warning style */
|
|
45
|
-
warning: `color: ${ConsoleColors.cta}; font-weight: bold;`,
|
|
46
|
-
} as const;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Styled console message for CopilotKit Platform promotion
|
|
50
|
-
* Displays a beautiful, branded advertisement in the console
|
|
51
|
-
*/
|
|
52
|
-
export function logCopilotKitPlatformMessage() {
|
|
53
|
-
console.log(
|
|
54
|
-
`%cCopilotKit Warning%c
|
|
55
|
-
|
|
56
|
-
useCopilotChatHeadless_c provides full compatibility with CopilotKit's newly released Headless UI feature set. Headless UI requires a CopilotKit Intelligence license key, available for free at:
|
|
57
|
-
|
|
58
|
-
%chttps://dashboard.operations.copilotkit.ai%c
|
|
59
|
-
|
|
60
|
-
Alternatively, useCopilotChat is available for basic programmatic control, and does not require a license key.
|
|
61
|
-
|
|
62
|
-
To learn more about CopilotKit Intelligence, read the documentation here:
|
|
63
|
-
|
|
64
|
-
%chttps://docs.copilotkit.ai/intelligence/overview%c`,
|
|
65
|
-
ConsoleStyles.header,
|
|
66
|
-
ConsoleStyles.body,
|
|
67
|
-
ConsoleStyles.cta,
|
|
68
|
-
ConsoleStyles.body,
|
|
69
|
-
ConsoleStyles.link,
|
|
70
|
-
ConsoleStyles.body,
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function publicApiKeyRequired(feature: string) {
|
|
75
|
-
console.log(
|
|
76
|
-
`
|
|
77
|
-
%cCopilotKit Warning%c \n
|
|
78
|
-
In order to use ${feature}, you need to add your CopilotKit license key, available for free at https://dashboard.operations.copilotkit.ai.
|
|
79
|
-
`.trim(),
|
|
80
|
-
ConsoleStyles.header,
|
|
81
|
-
ConsoleStyles.body,
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Create a styled console message with custom content
|
|
87
|
-
*
|
|
88
|
-
* @param template - Template string with %c placeholders
|
|
89
|
-
* @param styles - Array of style strings matching the %c placeholders
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* ```typescript
|
|
93
|
-
* logStyled(
|
|
94
|
-
* '%cCopilotKit%c Welcome to the platform!',
|
|
95
|
-
* [ConsoleStyles.header, ConsoleStyles.body]
|
|
96
|
-
* );
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
export function logStyled(template: string, styles: string[]) {
|
|
100
|
-
console.log(template, ...styles);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Quick styled console methods for common use cases
|
|
105
|
-
*/
|
|
106
|
-
export const styledConsole = {
|
|
107
|
-
/** Log a success message */
|
|
108
|
-
success: (message: string) =>
|
|
109
|
-
logStyled(`%c✅ ${message}`, [ConsoleStyles.section]),
|
|
110
|
-
|
|
111
|
-
/** Log an info message */
|
|
112
|
-
info: (message: string) => logStyled(`%cℹ️ ${message}`, [ConsoleStyles.info]),
|
|
113
|
-
|
|
114
|
-
/** Log a feature highlight */
|
|
115
|
-
feature: (message: string) =>
|
|
116
|
-
logStyled(`%c✨ ${message}`, [ConsoleStyles.highlight]),
|
|
117
|
-
|
|
118
|
-
/** Log a call-to-action */
|
|
119
|
-
cta: (message: string) => logStyled(`%c🚀 ${message}`, [ConsoleStyles.cta]),
|
|
120
|
-
|
|
121
|
-
/** Log the CopilotKit platform promotion */
|
|
122
|
-
logCopilotKitPlatformMessage: logCopilotKitPlatformMessage,
|
|
123
|
-
|
|
124
|
-
/** Log a `publicApiKeyRequired` warning */
|
|
125
|
-
publicApiKeyRequired: publicApiKeyRequired,
|
|
126
|
-
} as const;
|