@copilotkit/shared 2.0.0-rc.4 → 2.0.0-rc.6
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 +3 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -5
- 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/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/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/telemetry-client.ts +3 -3
- 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
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { randomId, randomUUID } from "../random-id";
|
|
3
|
+
|
|
4
|
+
const UUID_V4 =
|
|
5
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
6
|
+
|
|
7
|
+
describe("randomUUID", () => {
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
vi.unstubAllGlobals();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("returns crypto.randomUUID() when it exists", () => {
|
|
13
|
+
vi.stubGlobal("crypto", {
|
|
14
|
+
randomUUID: () => "11111111-2222-4333-8444-555555555555",
|
|
15
|
+
});
|
|
16
|
+
expect(randomUUID()).toBe("11111111-2222-4333-8444-555555555555");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("builds a v4 UUID from getRandomValues when randomUUID is missing", () => {
|
|
20
|
+
vi.stubGlobal("crypto", {
|
|
21
|
+
getRandomValues: (bytes: Uint8Array) => bytes.fill(0xff),
|
|
22
|
+
});
|
|
23
|
+
const id = randomUUID();
|
|
24
|
+
expect(id).toBe("ffffffff-ffff-4fff-bfff-ffffffffffff");
|
|
25
|
+
expect(id).toMatch(UUID_V4);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("throws a clear error when the runtime has no crypto", () => {
|
|
29
|
+
vi.stubGlobal("crypto", undefined);
|
|
30
|
+
expect(() => randomUUID()).toThrow(/getRandomValues/);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("prefixes randomId with ck-", () => {
|
|
34
|
+
expect(randomId()).toMatch(/^ck-/);
|
|
35
|
+
expect(randomId().slice(3)).toMatch(UUID_V4);
|
|
36
|
+
});
|
|
37
|
+
});
|
package/src/utils/errors.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { GraphQLError } from "graphql";
|
|
2
|
-
import { COPILOTKIT_VERSION } from "../index";
|
|
3
|
-
|
|
4
1
|
export enum Severity {
|
|
5
2
|
CRITICAL = "critical", // Critical errors that block core functionality
|
|
6
3
|
WARNING = "warning", // Configuration/setup issues that need attention
|
|
@@ -21,7 +18,6 @@ export const ERROR_NAMES = {
|
|
|
21
18
|
"CopilotKitRemoteEndpointDiscoveryError",
|
|
22
19
|
COPILOT_KIT_AGENT_DISCOVERY_ERROR: "CopilotKitAgentDiscoveryError",
|
|
23
20
|
COPILOT_KIT_LOW_LEVEL_ERROR: "CopilotKitLowLevelError",
|
|
24
|
-
COPILOT_KIT_VERSION_MISMATCH_ERROR: "CopilotKitVersionMismatchError",
|
|
25
21
|
RESOLVED_COPILOT_KIT_ERROR: "ResolvedCopilotKitError",
|
|
26
22
|
CONFIGURATION_ERROR: "ConfigurationError",
|
|
27
23
|
MISSING_PUBLIC_API_KEY_ERROR: "MissingPublicApiKeyError",
|
|
@@ -134,7 +130,19 @@ export const ERROR_CONFIG = {
|
|
|
134
130
|
},
|
|
135
131
|
};
|
|
136
132
|
|
|
137
|
-
export
|
|
133
|
+
export interface CopilotKitErrorExtensions {
|
|
134
|
+
name: string;
|
|
135
|
+
statusCode: number;
|
|
136
|
+
code: CopilotKitErrorCode;
|
|
137
|
+
visibility: ErrorVisibility;
|
|
138
|
+
severity?: Severity;
|
|
139
|
+
troubleshootingUrl: string | null;
|
|
140
|
+
originalError: { message: string; stack?: string };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export class CopilotKitError extends Error {
|
|
144
|
+
/** Structured error details, kept in the shape GraphQL errors used in 1.x. */
|
|
145
|
+
extensions: CopilotKitErrorExtensions;
|
|
138
146
|
code: CopilotKitErrorCode;
|
|
139
147
|
statusCode: number;
|
|
140
148
|
severity?: Severity;
|
|
@@ -159,22 +167,21 @@ export class CopilotKitError extends GraphQLError {
|
|
|
159
167
|
const resolvedSeverity =
|
|
160
168
|
severity ?? ("severity" in config ? config.severity : undefined);
|
|
161
169
|
|
|
162
|
-
super(message
|
|
163
|
-
extensions: {
|
|
164
|
-
name,
|
|
165
|
-
statusCode,
|
|
166
|
-
code,
|
|
167
|
-
visibility: resolvedVisibility,
|
|
168
|
-
severity: resolvedSeverity,
|
|
169
|
-
troubleshootingUrl:
|
|
170
|
-
"troubleshootingUrl" in config ? config.troubleshootingUrl : null,
|
|
171
|
-
originalError: {
|
|
172
|
-
message,
|
|
173
|
-
stack: new Error().stack,
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
});
|
|
170
|
+
super(message);
|
|
177
171
|
|
|
172
|
+
this.extensions = {
|
|
173
|
+
name,
|
|
174
|
+
statusCode,
|
|
175
|
+
code,
|
|
176
|
+
visibility: resolvedVisibility,
|
|
177
|
+
severity: resolvedSeverity,
|
|
178
|
+
troubleshootingUrl:
|
|
179
|
+
"troubleshootingUrl" in config ? config.troubleshootingUrl : null,
|
|
180
|
+
originalError: {
|
|
181
|
+
message,
|
|
182
|
+
stack: new Error().stack,
|
|
183
|
+
},
|
|
184
|
+
};
|
|
178
185
|
this.code = code;
|
|
179
186
|
this.name = name;
|
|
180
187
|
this.statusCode = statusCode;
|
|
@@ -208,36 +215,6 @@ export class CopilotKitMisuseError extends CopilotKitError {
|
|
|
208
215
|
}
|
|
209
216
|
}
|
|
210
217
|
|
|
211
|
-
const getVersionMismatchErrorMessage = ({
|
|
212
|
-
reactCoreVersion,
|
|
213
|
-
runtimeVersion,
|
|
214
|
-
runtimeClientGqlVersion,
|
|
215
|
-
}: VersionMismatchResponse) =>
|
|
216
|
-
`Version mismatch detected: @copilotkit/runtime@${runtimeVersion ?? ""} is not compatible with @copilotkit/react-core@${reactCoreVersion} and @copilotkit/runtime-client-gql@${runtimeClientGqlVersion}. Please ensure all installed copilotkit packages are on the same version.`;
|
|
217
|
-
/**
|
|
218
|
-
* Error thrown when CPK versions does not match
|
|
219
|
-
*
|
|
220
|
-
* @extends CopilotKitError
|
|
221
|
-
*/
|
|
222
|
-
export class CopilotKitVersionMismatchError extends CopilotKitError {
|
|
223
|
-
constructor({
|
|
224
|
-
reactCoreVersion,
|
|
225
|
-
runtimeVersion,
|
|
226
|
-
runtimeClientGqlVersion,
|
|
227
|
-
}: VersionMismatchResponse) {
|
|
228
|
-
const code = CopilotKitErrorCode.VERSION_MISMATCH;
|
|
229
|
-
super({
|
|
230
|
-
message: getVersionMismatchErrorMessage({
|
|
231
|
-
reactCoreVersion,
|
|
232
|
-
runtimeVersion,
|
|
233
|
-
runtimeClientGqlVersion,
|
|
234
|
-
}),
|
|
235
|
-
code,
|
|
236
|
-
});
|
|
237
|
-
this.name = ERROR_NAMES.COPILOT_KIT_VERSION_MISMATCH_ERROR;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
218
|
/**
|
|
242
219
|
* Error thrown when the CopilotKit API endpoint cannot be discovered or accessed.
|
|
243
220
|
* This typically occurs when:
|
|
@@ -477,41 +454,6 @@ export function ensureStructuredError<T extends CopilotKitError>(
|
|
|
477
454
|
return isStructuredCopilotKitError(error) ? error : converter(error);
|
|
478
455
|
}
|
|
479
456
|
|
|
480
|
-
interface VersionMismatchResponse {
|
|
481
|
-
runtimeVersion?: string;
|
|
482
|
-
runtimeClientGqlVersion: string;
|
|
483
|
-
reactCoreVersion: string;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
export async function getPossibleVersionMismatch({
|
|
487
|
-
runtimeVersion,
|
|
488
|
-
runtimeClientGqlVersion,
|
|
489
|
-
}: {
|
|
490
|
-
runtimeVersion?: string;
|
|
491
|
-
runtimeClientGqlVersion: string;
|
|
492
|
-
}) {
|
|
493
|
-
if (!runtimeVersion || runtimeVersion === "" || !runtimeClientGqlVersion)
|
|
494
|
-
return;
|
|
495
|
-
if (
|
|
496
|
-
COPILOTKIT_VERSION !== runtimeVersion ||
|
|
497
|
-
COPILOTKIT_VERSION !== runtimeClientGqlVersion ||
|
|
498
|
-
runtimeVersion !== runtimeClientGqlVersion
|
|
499
|
-
) {
|
|
500
|
-
return {
|
|
501
|
-
runtimeVersion,
|
|
502
|
-
runtimeClientGqlVersion,
|
|
503
|
-
reactCoreVersion: COPILOTKIT_VERSION,
|
|
504
|
-
message: getVersionMismatchErrorMessage({
|
|
505
|
-
runtimeVersion,
|
|
506
|
-
runtimeClientGqlVersion,
|
|
507
|
-
reactCoreVersion: COPILOTKIT_VERSION,
|
|
508
|
-
}),
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
457
|
const resolveLowLevelErrorMessage = ({
|
|
516
458
|
errorCode,
|
|
517
459
|
url,
|
package/src/utils/index.ts
CHANGED
package/src/utils/random-id.ts
CHANGED
|
@@ -1,45 +1,25 @@
|
|
|
1
|
-
import { v4 as uuidv4, validate, v5 as uuidv5 } from "uuid";
|
|
2
|
-
|
|
3
1
|
export function randomId() {
|
|
4
|
-
return "ck-" +
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function randomUUID() {
|
|
8
|
-
return uuidv4();
|
|
2
|
+
return "ck-" + randomUUID();
|
|
9
3
|
}
|
|
10
4
|
|
|
11
5
|
/**
|
|
12
|
-
*
|
|
6
|
+
* Returns an RFC 4122 version 4 UUID. Uses `crypto.randomUUID()` when it
|
|
7
|
+
* exists, and builds the UUID from `crypto.getRandomValues()` when it does not
|
|
8
|
+
* (React Native's Hermes has no `randomUUID`).
|
|
13
9
|
*/
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
export function randomUUID(): string {
|
|
11
|
+
const crypto = globalThis.crypto;
|
|
12
|
+
if (typeof crypto?.randomUUID === "function") {
|
|
13
|
+
return crypto.randomUUID();
|
|
17
14
|
}
|
|
18
|
-
if (
|
|
19
|
-
|
|
15
|
+
if (typeof crypto?.getRandomValues !== "function") {
|
|
16
|
+
throw new Error(
|
|
17
|
+
"crypto.getRandomValues() is not available. In React Native, install a polyfill such as react-native-get-random-values.",
|
|
18
|
+
);
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function dataToUUID(input: string | object, namespace?: string): string {
|
|
32
|
-
const BASE_NAMESPACE = "e4b01160-ff74-4c6e-9b27-d53cd930fe8e";
|
|
33
|
-
// Since namespace needs to be a uuid, we are creating a uuid for it.
|
|
34
|
-
const boundNamespace = namespace
|
|
35
|
-
? uuidv5(namespace, BASE_NAMESPACE)
|
|
36
|
-
: BASE_NAMESPACE;
|
|
37
|
-
|
|
38
|
-
const stringInput =
|
|
39
|
-
typeof input === "string" ? input : JSON.stringify(toSerializable(input));
|
|
40
|
-
return uuidv5(stringInput, boundNamespace);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function isValidUUID(uuid: string) {
|
|
44
|
-
return validate(uuid);
|
|
20
|
+
const bytes = crypto.getRandomValues(new Uint8Array(16));
|
|
21
|
+
bytes[6] = (bytes[6]! & 0x0f) | 0x40;
|
|
22
|
+
bytes[8] = (bytes[8]! & 0x3f) | 0x80;
|
|
23
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0"));
|
|
24
|
+
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
45
25
|
}
|
package/tsdown.config.ts
CHANGED
|
@@ -24,20 +24,11 @@ export default defineConfig([
|
|
|
24
24
|
sourcemap: true,
|
|
25
25
|
target: "es2018",
|
|
26
26
|
outDir: "dist",
|
|
27
|
-
external: [
|
|
28
|
-
"zod",
|
|
29
|
-
"graphql",
|
|
30
|
-
"uuid",
|
|
31
|
-
"@ag-ui/core",
|
|
32
|
-
"@ag-ui/client",
|
|
33
|
-
"partial-json",
|
|
34
|
-
],
|
|
27
|
+
external: ["zod", "@ag-ui/core", "@ag-ui/client", "partial-json"],
|
|
35
28
|
outputOptions(options) {
|
|
36
29
|
options.entryFileNames = "[name].umd.js";
|
|
37
30
|
options.globals = {
|
|
38
31
|
zod: "Zod",
|
|
39
|
-
graphql: "GraphQL",
|
|
40
|
-
uuid: "UUID",
|
|
41
32
|
"@ag-ui/core": "AgUICore",
|
|
42
33
|
"@ag-ui/client": "AgUIClient",
|
|
43
34
|
"@segment/analytics-node": "SegmentAnalyticsNode",
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/utils/conditions.ts
|
|
3
|
-
function executeConditions({ conditions, value }) {
|
|
4
|
-
if (!conditions?.length) return true;
|
|
5
|
-
return conditions.every((condition) => executeCondition(condition, value));
|
|
6
|
-
}
|
|
7
|
-
function executeCondition(condition, value) {
|
|
8
|
-
const targetValue = condition.path ? getValueFromPath(value, condition.path) : value;
|
|
9
|
-
switch (condition.rule) {
|
|
10
|
-
case "AND": return condition.conditions.every((c) => executeCondition(c, value));
|
|
11
|
-
case "OR": return condition.conditions.some((c) => executeCondition(c, value));
|
|
12
|
-
case "NOT": return !condition.conditions.every((c) => executeCondition(c, value));
|
|
13
|
-
case "EQUALS": return targetValue === condition.value;
|
|
14
|
-
case "NOT_EQUALS": return targetValue !== condition.value;
|
|
15
|
-
case "GREATER_THAN": return targetValue > condition.value;
|
|
16
|
-
case "LESS_THAN": return targetValue < condition.value;
|
|
17
|
-
case "CONTAINS": return Array.isArray(targetValue) && targetValue.includes(condition.value);
|
|
18
|
-
case "NOT_CONTAINS": return Array.isArray(targetValue) && !targetValue.includes(condition.value);
|
|
19
|
-
case "MATCHES": return new RegExp(condition.value).test(String(targetValue));
|
|
20
|
-
case "STARTS_WITH": return String(targetValue).startsWith(condition.value);
|
|
21
|
-
case "ENDS_WITH": return String(targetValue).endsWith(condition.value);
|
|
22
|
-
case "EXISTS": return targetValue !== void 0 && targetValue !== null;
|
|
23
|
-
case "NOT_EXISTS": return targetValue === void 0 || targetValue === null;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function getValueFromPath(obj, path) {
|
|
27
|
-
return path.split(".").reduce((acc, part) => acc?.[part], obj);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
exports.executeConditions = executeConditions;
|
|
32
|
-
//# sourceMappingURL=conditions.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.cjs","names":[],"sources":["../../src/utils/conditions.ts"],"sourcesContent":["export type ComparisonRule =\n | \"EQUALS\"\n | \"NOT_EQUALS\"\n | \"GREATER_THAN\"\n | \"LESS_THAN\"\n | \"CONTAINS\"\n | \"NOT_CONTAINS\"\n | \"MATCHES\"\n | \"STARTS_WITH\"\n | \"ENDS_WITH\";\nexport type LogicalRule = \"AND\" | \"OR\" | \"NOT\";\nexport type ExistenceRule = \"EXISTS\" | \"NOT_EXISTS\";\n\nexport type Rule = ComparisonRule | LogicalRule | ExistenceRule;\n\nexport interface BaseCondition {\n rule: Rule;\n path?: string;\n}\n\nexport interface ComparisonCondition extends BaseCondition {\n rule: ComparisonRule;\n value: any;\n}\n\nexport interface LogicalCondition extends BaseCondition {\n rule: LogicalRule;\n conditions: Condition[];\n}\n\nexport interface ExistenceCondition extends BaseCondition {\n rule: ExistenceRule;\n}\n\nexport type Condition =\n | ComparisonCondition\n | LogicalCondition\n | ExistenceCondition;\n\nexport function executeConditions({\n conditions,\n value,\n}: {\n conditions?: Condition[];\n value: any;\n}): boolean {\n // If no conditions, consider it a pass\n if (!conditions?.length) return true;\n\n // Run all conditions (implicit AND)\n return conditions.every((condition) => executeCondition(condition, value));\n}\n\nfunction executeCondition(condition: Condition, value: any): boolean {\n const targetValue = condition.path\n ? getValueFromPath(value, condition.path)\n : value;\n\n switch (condition.rule) {\n // Logical\n case \"AND\":\n return (condition as LogicalCondition).conditions.every((c) =>\n executeCondition(c, value),\n );\n case \"OR\":\n return (condition as LogicalCondition).conditions.some((c) =>\n executeCondition(c, value),\n );\n case \"NOT\":\n return !(condition as LogicalCondition).conditions.every((c) =>\n executeCondition(c, value),\n );\n\n // Comparison\n case \"EQUALS\":\n return targetValue === (condition as ComparisonCondition).value;\n case \"NOT_EQUALS\":\n return targetValue !== (condition as ComparisonCondition).value;\n case \"GREATER_THAN\":\n return targetValue > (condition as ComparisonCondition).value;\n case \"LESS_THAN\":\n return targetValue < (condition as ComparisonCondition).value;\n case \"CONTAINS\":\n return (\n Array.isArray(targetValue) &&\n targetValue.includes((condition as ComparisonCondition).value)\n );\n case \"NOT_CONTAINS\":\n return (\n Array.isArray(targetValue) &&\n !targetValue.includes((condition as ComparisonCondition).value)\n );\n case \"MATCHES\":\n return new RegExp((condition as ComparisonCondition).value).test(\n String(targetValue),\n );\n case \"STARTS_WITH\":\n return String(targetValue).startsWith(\n (condition as ComparisonCondition).value,\n );\n case \"ENDS_WITH\":\n return String(targetValue).endsWith(\n (condition as ComparisonCondition).value,\n );\n\n // Existence\n case \"EXISTS\":\n return targetValue !== undefined && targetValue !== null;\n case \"NOT_EXISTS\":\n return targetValue === undefined || targetValue === null;\n }\n}\n\nfunction getValueFromPath(obj: any, path: string): any {\n return path.split(\".\").reduce((acc, part) => acc?.[part], obj);\n}\n"],"mappings":";;AAuCA,SAAgB,kBAAkB,EAChC,YACA,SAIU;AAEV,KAAI,CAAC,YAAY,OAAQ,QAAO;AAGhC,QAAO,WAAW,OAAO,cAAc,iBAAiB,WAAW,MAAM,CAAC;;AAG5E,SAAS,iBAAiB,WAAsB,OAAqB;CACnE,MAAM,cAAc,UAAU,OAC1B,iBAAiB,OAAO,UAAU,KAAK,GACvC;AAEJ,SAAQ,UAAU,MAAlB;EAEE,KAAK,MACH,QAAQ,UAA+B,WAAW,OAAO,MACvD,iBAAiB,GAAG,MAAM,CAC3B;EACH,KAAK,KACH,QAAQ,UAA+B,WAAW,MAAM,MACtD,iBAAiB,GAAG,MAAM,CAC3B;EACH,KAAK,MACH,QAAO,CAAE,UAA+B,WAAW,OAAO,MACxD,iBAAiB,GAAG,MAAM,CAC3B;EAGH,KAAK,SACH,QAAO,gBAAiB,UAAkC;EAC5D,KAAK,aACH,QAAO,gBAAiB,UAAkC;EAC5D,KAAK,eACH,QAAO,cAAe,UAAkC;EAC1D,KAAK,YACH,QAAO,cAAe,UAAkC;EAC1D,KAAK,WACH,QACE,MAAM,QAAQ,YAAY,IAC1B,YAAY,SAAU,UAAkC,MAAM;EAElE,KAAK,eACH,QACE,MAAM,QAAQ,YAAY,IAC1B,CAAC,YAAY,SAAU,UAAkC,MAAM;EAEnE,KAAK,UACH,QAAO,IAAI,OAAQ,UAAkC,MAAM,CAAC,KAC1D,OAAO,YAAY,CACpB;EACH,KAAK,cACH,QAAO,OAAO,YAAY,CAAC,WACxB,UAAkC,MACpC;EACH,KAAK,YACH,QAAO,OAAO,YAAY,CAAC,SACxB,UAAkC,MACpC;EAGH,KAAK,SACH,QAAO,gBAAgB,UAAa,gBAAgB;EACtD,KAAK,aACH,QAAO,gBAAgB,UAAa,gBAAgB;;;AAI1D,SAAS,iBAAiB,KAAU,MAAmB;AACrD,QAAO,KAAK,MAAM,IAAI,CAAC,QAAQ,KAAK,SAAS,MAAM,OAAO,IAAI"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
//#region src/utils/conditions.d.ts
|
|
2
|
-
type ComparisonRule = "EQUALS" | "NOT_EQUALS" | "GREATER_THAN" | "LESS_THAN" | "CONTAINS" | "NOT_CONTAINS" | "MATCHES" | "STARTS_WITH" | "ENDS_WITH";
|
|
3
|
-
type LogicalRule = "AND" | "OR" | "NOT";
|
|
4
|
-
type ExistenceRule = "EXISTS" | "NOT_EXISTS";
|
|
5
|
-
type Rule = ComparisonRule | LogicalRule | ExistenceRule;
|
|
6
|
-
interface BaseCondition {
|
|
7
|
-
rule: Rule;
|
|
8
|
-
path?: string;
|
|
9
|
-
}
|
|
10
|
-
interface ComparisonCondition extends BaseCondition {
|
|
11
|
-
rule: ComparisonRule;
|
|
12
|
-
value: any;
|
|
13
|
-
}
|
|
14
|
-
interface LogicalCondition extends BaseCondition {
|
|
15
|
-
rule: LogicalRule;
|
|
16
|
-
conditions: Condition[];
|
|
17
|
-
}
|
|
18
|
-
interface ExistenceCondition extends BaseCondition {
|
|
19
|
-
rule: ExistenceRule;
|
|
20
|
-
}
|
|
21
|
-
type Condition = ComparisonCondition | LogicalCondition | ExistenceCondition;
|
|
22
|
-
declare function executeConditions({
|
|
23
|
-
conditions,
|
|
24
|
-
value
|
|
25
|
-
}: {
|
|
26
|
-
conditions?: Condition[];
|
|
27
|
-
value: any;
|
|
28
|
-
}): boolean;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { BaseCondition, ComparisonCondition, ComparisonRule, Condition, ExistenceCondition, ExistenceRule, LogicalCondition, LogicalRule, Rule, executeConditions };
|
|
31
|
-
//# sourceMappingURL=conditions.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.d.cts","names":[],"sources":["../../src/utils/conditions.ts"],"mappings":";KAAY,cAAA;AAAA,KAUA,WAAA;AAAA,KACA,aAAA;AAAA,KAEA,IAAA,GAAO,cAAA,GAAiB,WAAA,GAAc,aAAA;AAAA,UAEjC,aAAA;EACf,IAAA,EAAM,IAAA;EACN,IAAA;AAAA;AAAA,UAGe,mBAAA,SAA4B,aAAA;EAC3C,IAAA,EAAM,cAAA;EACN,KAAA;AAAA;AAAA,UAGe,gBAAA,SAAyB,aAAA;EACxC,IAAA,EAAM,WAAA;EACN,UAAA,EAAY,SAAA;AAAA;AAAA,UAGG,kBAAA,SAA2B,aAAA;EAC1C,IAAA,EAAM,aAAA;AAAA;AAAA,KAGI,SAAA,GACR,mBAAA,GACA,gBAAA,GACA,kBAAA;AAAA,iBAEY,iBAAA,CAAA;EACd,UAAA;EACA;AAAA;EAEA,UAAA,GAAa,SAAA;EACb,KAAA;AAAA"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
//#region src/utils/conditions.d.ts
|
|
2
|
-
type ComparisonRule = "EQUALS" | "NOT_EQUALS" | "GREATER_THAN" | "LESS_THAN" | "CONTAINS" | "NOT_CONTAINS" | "MATCHES" | "STARTS_WITH" | "ENDS_WITH";
|
|
3
|
-
type LogicalRule = "AND" | "OR" | "NOT";
|
|
4
|
-
type ExistenceRule = "EXISTS" | "NOT_EXISTS";
|
|
5
|
-
type Rule = ComparisonRule | LogicalRule | ExistenceRule;
|
|
6
|
-
interface BaseCondition {
|
|
7
|
-
rule: Rule;
|
|
8
|
-
path?: string;
|
|
9
|
-
}
|
|
10
|
-
interface ComparisonCondition extends BaseCondition {
|
|
11
|
-
rule: ComparisonRule;
|
|
12
|
-
value: any;
|
|
13
|
-
}
|
|
14
|
-
interface LogicalCondition extends BaseCondition {
|
|
15
|
-
rule: LogicalRule;
|
|
16
|
-
conditions: Condition[];
|
|
17
|
-
}
|
|
18
|
-
interface ExistenceCondition extends BaseCondition {
|
|
19
|
-
rule: ExistenceRule;
|
|
20
|
-
}
|
|
21
|
-
type Condition = ComparisonCondition | LogicalCondition | ExistenceCondition;
|
|
22
|
-
declare function executeConditions({
|
|
23
|
-
conditions,
|
|
24
|
-
value
|
|
25
|
-
}: {
|
|
26
|
-
conditions?: Condition[];
|
|
27
|
-
value: any;
|
|
28
|
-
}): boolean;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { BaseCondition, ComparisonCondition, ComparisonRule, Condition, ExistenceCondition, ExistenceRule, LogicalCondition, LogicalRule, Rule, executeConditions };
|
|
31
|
-
//# sourceMappingURL=conditions.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.d.mts","names":[],"sources":["../../src/utils/conditions.ts"],"mappings":";KAAY,cAAA;AAAA,KAUA,WAAA;AAAA,KACA,aAAA;AAAA,KAEA,IAAA,GAAO,cAAA,GAAiB,WAAA,GAAc,aAAA;AAAA,UAEjC,aAAA;EACf,IAAA,EAAM,IAAA;EACN,IAAA;AAAA;AAAA,UAGe,mBAAA,SAA4B,aAAA;EAC3C,IAAA,EAAM,cAAA;EACN,KAAA;AAAA;AAAA,UAGe,gBAAA,SAAyB,aAAA;EACxC,IAAA,EAAM,WAAA;EACN,UAAA,EAAY,SAAA;AAAA;AAAA,UAGG,kBAAA,SAA2B,aAAA;EAC1C,IAAA,EAAM,aAAA;AAAA;AAAA,KAGI,SAAA,GACR,mBAAA,GACA,gBAAA,GACA,kBAAA;AAAA,iBAEY,iBAAA,CAAA;EACd,UAAA;EACA;AAAA;EAEA,UAAA,GAAa,SAAA;EACb,KAAA;AAAA"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
//#region src/utils/conditions.ts
|
|
2
|
-
function executeConditions({ conditions, value }) {
|
|
3
|
-
if (!conditions?.length) return true;
|
|
4
|
-
return conditions.every((condition) => executeCondition(condition, value));
|
|
5
|
-
}
|
|
6
|
-
function executeCondition(condition, value) {
|
|
7
|
-
const targetValue = condition.path ? getValueFromPath(value, condition.path) : value;
|
|
8
|
-
switch (condition.rule) {
|
|
9
|
-
case "AND": return condition.conditions.every((c) => executeCondition(c, value));
|
|
10
|
-
case "OR": return condition.conditions.some((c) => executeCondition(c, value));
|
|
11
|
-
case "NOT": return !condition.conditions.every((c) => executeCondition(c, value));
|
|
12
|
-
case "EQUALS": return targetValue === condition.value;
|
|
13
|
-
case "NOT_EQUALS": return targetValue !== condition.value;
|
|
14
|
-
case "GREATER_THAN": return targetValue > condition.value;
|
|
15
|
-
case "LESS_THAN": return targetValue < condition.value;
|
|
16
|
-
case "CONTAINS": return Array.isArray(targetValue) && targetValue.includes(condition.value);
|
|
17
|
-
case "NOT_CONTAINS": return Array.isArray(targetValue) && !targetValue.includes(condition.value);
|
|
18
|
-
case "MATCHES": return new RegExp(condition.value).test(String(targetValue));
|
|
19
|
-
case "STARTS_WITH": return String(targetValue).startsWith(condition.value);
|
|
20
|
-
case "ENDS_WITH": return String(targetValue).endsWith(condition.value);
|
|
21
|
-
case "EXISTS": return targetValue !== void 0 && targetValue !== null;
|
|
22
|
-
case "NOT_EXISTS": return targetValue === void 0 || targetValue === null;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function getValueFromPath(obj, path) {
|
|
26
|
-
return path.split(".").reduce((acc, part) => acc?.[part], obj);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
export { executeConditions };
|
|
31
|
-
//# sourceMappingURL=conditions.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.mjs","names":[],"sources":["../../src/utils/conditions.ts"],"sourcesContent":["export type ComparisonRule =\n | \"EQUALS\"\n | \"NOT_EQUALS\"\n | \"GREATER_THAN\"\n | \"LESS_THAN\"\n | \"CONTAINS\"\n | \"NOT_CONTAINS\"\n | \"MATCHES\"\n | \"STARTS_WITH\"\n | \"ENDS_WITH\";\nexport type LogicalRule = \"AND\" | \"OR\" | \"NOT\";\nexport type ExistenceRule = \"EXISTS\" | \"NOT_EXISTS\";\n\nexport type Rule = ComparisonRule | LogicalRule | ExistenceRule;\n\nexport interface BaseCondition {\n rule: Rule;\n path?: string;\n}\n\nexport interface ComparisonCondition extends BaseCondition {\n rule: ComparisonRule;\n value: any;\n}\n\nexport interface LogicalCondition extends BaseCondition {\n rule: LogicalRule;\n conditions: Condition[];\n}\n\nexport interface ExistenceCondition extends BaseCondition {\n rule: ExistenceRule;\n}\n\nexport type Condition =\n | ComparisonCondition\n | LogicalCondition\n | ExistenceCondition;\n\nexport function executeConditions({\n conditions,\n value,\n}: {\n conditions?: Condition[];\n value: any;\n}): boolean {\n // If no conditions, consider it a pass\n if (!conditions?.length) return true;\n\n // Run all conditions (implicit AND)\n return conditions.every((condition) => executeCondition(condition, value));\n}\n\nfunction executeCondition(condition: Condition, value: any): boolean {\n const targetValue = condition.path\n ? getValueFromPath(value, condition.path)\n : value;\n\n switch (condition.rule) {\n // Logical\n case \"AND\":\n return (condition as LogicalCondition).conditions.every((c) =>\n executeCondition(c, value),\n );\n case \"OR\":\n return (condition as LogicalCondition).conditions.some((c) =>\n executeCondition(c, value),\n );\n case \"NOT\":\n return !(condition as LogicalCondition).conditions.every((c) =>\n executeCondition(c, value),\n );\n\n // Comparison\n case \"EQUALS\":\n return targetValue === (condition as ComparisonCondition).value;\n case \"NOT_EQUALS\":\n return targetValue !== (condition as ComparisonCondition).value;\n case \"GREATER_THAN\":\n return targetValue > (condition as ComparisonCondition).value;\n case \"LESS_THAN\":\n return targetValue < (condition as ComparisonCondition).value;\n case \"CONTAINS\":\n return (\n Array.isArray(targetValue) &&\n targetValue.includes((condition as ComparisonCondition).value)\n );\n case \"NOT_CONTAINS\":\n return (\n Array.isArray(targetValue) &&\n !targetValue.includes((condition as ComparisonCondition).value)\n );\n case \"MATCHES\":\n return new RegExp((condition as ComparisonCondition).value).test(\n String(targetValue),\n );\n case \"STARTS_WITH\":\n return String(targetValue).startsWith(\n (condition as ComparisonCondition).value,\n );\n case \"ENDS_WITH\":\n return String(targetValue).endsWith(\n (condition as ComparisonCondition).value,\n );\n\n // Existence\n case \"EXISTS\":\n return targetValue !== undefined && targetValue !== null;\n case \"NOT_EXISTS\":\n return targetValue === undefined || targetValue === null;\n }\n}\n\nfunction getValueFromPath(obj: any, path: string): any {\n return path.split(\".\").reduce((acc, part) => acc?.[part], obj);\n}\n"],"mappings":";AAuCA,SAAgB,kBAAkB,EAChC,YACA,SAIU;AAEV,KAAI,CAAC,YAAY,OAAQ,QAAO;AAGhC,QAAO,WAAW,OAAO,cAAc,iBAAiB,WAAW,MAAM,CAAC;;AAG5E,SAAS,iBAAiB,WAAsB,OAAqB;CACnE,MAAM,cAAc,UAAU,OAC1B,iBAAiB,OAAO,UAAU,KAAK,GACvC;AAEJ,SAAQ,UAAU,MAAlB;EAEE,KAAK,MACH,QAAQ,UAA+B,WAAW,OAAO,MACvD,iBAAiB,GAAG,MAAM,CAC3B;EACH,KAAK,KACH,QAAQ,UAA+B,WAAW,MAAM,MACtD,iBAAiB,GAAG,MAAM,CAC3B;EACH,KAAK,MACH,QAAO,CAAE,UAA+B,WAAW,OAAO,MACxD,iBAAiB,GAAG,MAAM,CAC3B;EAGH,KAAK,SACH,QAAO,gBAAiB,UAAkC;EAC5D,KAAK,aACH,QAAO,gBAAiB,UAAkC;EAC5D,KAAK,eACH,QAAO,cAAe,UAAkC;EAC1D,KAAK,YACH,QAAO,cAAe,UAAkC;EAC1D,KAAK,WACH,QACE,MAAM,QAAQ,YAAY,IAC1B,YAAY,SAAU,UAAkC,MAAM;EAElE,KAAK,eACH,QACE,MAAM,QAAQ,YAAY,IAC1B,CAAC,YAAY,SAAU,UAAkC,MAAM;EAEnE,KAAK,UACH,QAAO,IAAI,OAAQ,UAAkC,MAAM,CAAC,KAC1D,OAAO,YAAY,CACpB;EACH,KAAK,cACH,QAAO,OAAO,YAAY,CAAC,WACxB,UAAkC,MACpC;EACH,KAAK,YACH,QAAO,OAAO,YAAY,CAAC,SACxB,UAAkC,MACpC;EAGH,KAAK,SACH,QAAO,gBAAgB,UAAa,gBAAgB;EACtD,KAAK,aACH,QAAO,gBAAgB,UAAa,gBAAgB;;;AAI1D,SAAS,iBAAiB,KAAU,MAAmB;AACrD,QAAO,KAAK,MAAM,IAAI,CAAC,QAAQ,KAAK,SAAS,MAAM,OAAO,IAAI"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/utils/console-styling.ts
|
|
3
|
-
/**
|
|
4
|
-
* Console styling utilities for CopilotKit branded messages
|
|
5
|
-
* Provides consistent, readable colors across light and dark console themes
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Color palette optimized for console readability
|
|
9
|
-
*/
|
|
10
|
-
const ConsoleColors = {
|
|
11
|
-
primary: "#007acc",
|
|
12
|
-
success: "#22c55e",
|
|
13
|
-
feature: "#a855f7",
|
|
14
|
-
cta: "#ef4444",
|
|
15
|
-
info: "#06b6d4",
|
|
16
|
-
inherit: "inherit",
|
|
17
|
-
warning: "#f59e0b"
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Console style templates for common patterns
|
|
21
|
-
*/
|
|
22
|
-
const ConsoleStyles = {
|
|
23
|
-
header: `color: ${ConsoleColors.warning}; font-weight: bold; font-size: 16px;`,
|
|
24
|
-
section: `color: ${ConsoleColors.success}; font-weight: bold;`,
|
|
25
|
-
highlight: `color: ${ConsoleColors.feature}; font-weight: bold;`,
|
|
26
|
-
cta: `color: ${ConsoleColors.success}; font-weight: bold;`,
|
|
27
|
-
info: `color: ${ConsoleColors.info}; font-weight: bold;`,
|
|
28
|
-
link: `color: ${ConsoleColors.primary}; text-decoration: underline;`,
|
|
29
|
-
body: `color: ${ConsoleColors.inherit};`,
|
|
30
|
-
warning: `color: ${ConsoleColors.cta}; font-weight: bold;`
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Styled console message for CopilotKit Platform promotion
|
|
34
|
-
* Displays a beautiful, branded advertisement in the console
|
|
35
|
-
*/
|
|
36
|
-
function logCopilotKitPlatformMessage() {
|
|
37
|
-
console.log(`%cCopilotKit Warning%c
|
|
38
|
-
|
|
39
|
-
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:
|
|
40
|
-
|
|
41
|
-
%chttps://dashboard.operations.copilotkit.ai%c
|
|
42
|
-
|
|
43
|
-
Alternatively, useCopilotChat is available for basic programmatic control, and does not require a license key.
|
|
44
|
-
|
|
45
|
-
To learn more about CopilotKit Intelligence, read the documentation here:
|
|
46
|
-
|
|
47
|
-
%chttps://docs.copilotkit.ai/intelligence/overview%c`, ConsoleStyles.header, ConsoleStyles.body, ConsoleStyles.cta, ConsoleStyles.body, ConsoleStyles.link, ConsoleStyles.body);
|
|
48
|
-
}
|
|
49
|
-
function publicApiKeyRequired(feature) {
|
|
50
|
-
console.log(`
|
|
51
|
-
%cCopilotKit Warning%c \n
|
|
52
|
-
In order to use ${feature}, you need to add your CopilotKit license key, available for free at https://dashboard.operations.copilotkit.ai.
|
|
53
|
-
`.trim(), ConsoleStyles.header, ConsoleStyles.body);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Create a styled console message with custom content
|
|
57
|
-
*
|
|
58
|
-
* @param template - Template string with %c placeholders
|
|
59
|
-
* @param styles - Array of style strings matching the %c placeholders
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* logStyled(
|
|
64
|
-
* '%cCopilotKit%c Welcome to the platform!',
|
|
65
|
-
* [ConsoleStyles.header, ConsoleStyles.body]
|
|
66
|
-
* );
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
function logStyled(template, styles) {
|
|
70
|
-
console.log(template, ...styles);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Quick styled console methods for common use cases
|
|
74
|
-
*/
|
|
75
|
-
const styledConsole = {
|
|
76
|
-
success: (message) => logStyled(`%c✅ ${message}`, [ConsoleStyles.section]),
|
|
77
|
-
info: (message) => logStyled(`%cℹ️ ${message}`, [ConsoleStyles.info]),
|
|
78
|
-
feature: (message) => logStyled(`%c✨ ${message}`, [ConsoleStyles.highlight]),
|
|
79
|
-
cta: (message) => logStyled(`%c🚀 ${message}`, [ConsoleStyles.cta]),
|
|
80
|
-
logCopilotKitPlatformMessage,
|
|
81
|
-
publicApiKeyRequired
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
//#endregion
|
|
85
|
-
exports.ConsoleColors = ConsoleColors;
|
|
86
|
-
exports.ConsoleStyles = ConsoleStyles;
|
|
87
|
-
exports.logCopilotKitPlatformMessage = logCopilotKitPlatformMessage;
|
|
88
|
-
exports.logStyled = logStyled;
|
|
89
|
-
exports.publicApiKeyRequired = publicApiKeyRequired;
|
|
90
|
-
exports.styledConsole = styledConsole;
|
|
91
|
-
//# sourceMappingURL=console-styling.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"console-styling.cjs","names":[],"sources":["../../src/utils/console-styling.ts"],"sourcesContent":["/**\n * Console styling utilities for CopilotKit branded messages\n * Provides consistent, readable colors across light and dark console themes\n */\n\n/**\n * Color palette optimized for console readability\n */\nexport const ConsoleColors = {\n /** Primary brand blue - for titles and links */\n primary: \"#007acc\",\n /** Success green - for positive messaging */\n success: \"#22c55e\",\n /** Purple - for feature highlights */\n feature: \"#a855f7\",\n /** Red - for calls-to-action */\n cta: \"#ef4444\",\n /** Cyan - for closing statements */\n info: \"#06b6d4\",\n /** Inherit console default - for body text */\n inherit: \"inherit\",\n /** Warning style */\n warning: \"#f59e0b\",\n} as const;\n\n/**\n * Console style templates for common patterns\n */\nexport const ConsoleStyles = {\n /** Large header style */\n header: `color: ${ConsoleColors.warning}; font-weight: bold; font-size: 16px;`,\n /** Section header style */\n section: `color: ${ConsoleColors.success}; font-weight: bold;`,\n /** Feature highlight style */\n highlight: `color: ${ConsoleColors.feature}; font-weight: bold;`,\n /** Call-to-action style */\n cta: `color: ${ConsoleColors.success}; font-weight: bold;`,\n /** Info style */\n info: `color: ${ConsoleColors.info}; font-weight: bold;`,\n /** Link style */\n link: `color: ${ConsoleColors.primary}; text-decoration: underline;`,\n /** Body text - inherits console theme */\n body: `color: ${ConsoleColors.inherit};`,\n /** Warning style */\n warning: `color: ${ConsoleColors.cta}; font-weight: bold;`,\n} as const;\n\n/**\n * Styled console message for CopilotKit Platform promotion\n * Displays a beautiful, branded advertisement in the console\n */\nexport function logCopilotKitPlatformMessage() {\n console.log(\n `%cCopilotKit Warning%c\n\nuseCopilotChatHeadless_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:\n\n%chttps://dashboard.operations.copilotkit.ai%c\n\nAlternatively, useCopilotChat is available for basic programmatic control, and does not require a license key.\n\nTo learn more about CopilotKit Intelligence, read the documentation here:\n\n%chttps://docs.copilotkit.ai/intelligence/overview%c`,\n ConsoleStyles.header,\n ConsoleStyles.body,\n ConsoleStyles.cta,\n ConsoleStyles.body,\n ConsoleStyles.link,\n ConsoleStyles.body,\n );\n}\n\nexport function publicApiKeyRequired(feature: string) {\n console.log(\n `\n%cCopilotKit Warning%c \\n\nIn order to use ${feature}, you need to add your CopilotKit license key, available for free at https://dashboard.operations.copilotkit.ai.\n `.trim(),\n ConsoleStyles.header,\n ConsoleStyles.body,\n );\n}\n\n/**\n * Create a styled console message with custom content\n *\n * @param template - Template string with %c placeholders\n * @param styles - Array of style strings matching the %c placeholders\n *\n * @example\n * ```typescript\n * logStyled(\n * '%cCopilotKit%c Welcome to the platform!',\n * [ConsoleStyles.header, ConsoleStyles.body]\n * );\n * ```\n */\nexport function logStyled(template: string, styles: string[]) {\n console.log(template, ...styles);\n}\n\n/**\n * Quick styled console methods for common use cases\n */\nexport const styledConsole = {\n /** Log a success message */\n success: (message: string) =>\n logStyled(`%c✅ ${message}`, [ConsoleStyles.section]),\n\n /** Log an info message */\n info: (message: string) => logStyled(`%cℹ️ ${message}`, [ConsoleStyles.info]),\n\n /** Log a feature highlight */\n feature: (message: string) =>\n logStyled(`%c✨ ${message}`, [ConsoleStyles.highlight]),\n\n /** Log a call-to-action */\n cta: (message: string) => logStyled(`%c🚀 ${message}`, [ConsoleStyles.cta]),\n\n /** Log the CopilotKit platform promotion */\n logCopilotKitPlatformMessage: logCopilotKitPlatformMessage,\n\n /** Log a `publicApiKeyRequired` warning */\n publicApiKeyRequired: publicApiKeyRequired,\n} as const;\n"],"mappings":";;;;;;;;;AAQA,MAAa,gBAAgB;CAE3B,SAAS;CAET,SAAS;CAET,SAAS;CAET,KAAK;CAEL,MAAM;CAEN,SAAS;CAET,SAAS;CACV;;;;AAKD,MAAa,gBAAgB;CAE3B,QAAQ,UAAU,cAAc,QAAQ;CAExC,SAAS,UAAU,cAAc,QAAQ;CAEzC,WAAW,UAAU,cAAc,QAAQ;CAE3C,KAAK,UAAU,cAAc,QAAQ;CAErC,MAAM,UAAU,cAAc,KAAK;CAEnC,MAAM,UAAU,cAAc,QAAQ;CAEtC,MAAM,UAAU,cAAc,QAAQ;CAEtC,SAAS,UAAU,cAAc,IAAI;CACtC;;;;;AAMD,SAAgB,+BAA+B;AAC7C,SAAQ,IACN;;;;;;;;;;uDAWA,cAAc,QACd,cAAc,MACd,cAAc,KACd,cAAc,MACd,cAAc,MACd,cAAc,KACf;;AAGH,SAAgB,qBAAqB,SAAiB;AACpD,SAAQ,IACN;;kBAEc,QAAQ;MACpB,MAAM,EACR,cAAc,QACd,cAAc,KACf;;;;;;;;;;;;;;;;AAiBH,SAAgB,UAAU,UAAkB,QAAkB;AAC5D,SAAQ,IAAI,UAAU,GAAG,OAAO;;;;;AAMlC,MAAa,gBAAgB;CAE3B,UAAU,YACR,UAAU,OAAO,WAAW,CAAC,cAAc,QAAQ,CAAC;CAGtD,OAAO,YAAoB,UAAU,QAAQ,WAAW,CAAC,cAAc,KAAK,CAAC;CAG7E,UAAU,YACR,UAAU,OAAO,WAAW,CAAC,cAAc,UAAU,CAAC;CAGxD,MAAM,YAAoB,UAAU,QAAQ,WAAW,CAAC,cAAc,IAAI,CAAC;CAG7C;CAGR;CACvB"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
//#region src/utils/console-styling.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Console styling utilities for CopilotKit branded messages
|
|
4
|
-
* Provides consistent, readable colors across light and dark console themes
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Color palette optimized for console readability
|
|
8
|
-
*/
|
|
9
|
-
declare const ConsoleColors: {
|
|
10
|
-
/** Primary brand blue - for titles and links */readonly primary: "#007acc"; /** Success green - for positive messaging */
|
|
11
|
-
readonly success: "#22c55e"; /** Purple - for feature highlights */
|
|
12
|
-
readonly feature: "#a855f7"; /** Red - for calls-to-action */
|
|
13
|
-
readonly cta: "#ef4444"; /** Cyan - for closing statements */
|
|
14
|
-
readonly info: "#06b6d4"; /** Inherit console default - for body text */
|
|
15
|
-
readonly inherit: "inherit"; /** Warning style */
|
|
16
|
-
readonly warning: "#f59e0b";
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Console style templates for common patterns
|
|
20
|
-
*/
|
|
21
|
-
declare const ConsoleStyles: {
|
|
22
|
-
/** Large header style */readonly header: "color: #f59e0b; font-weight: bold; font-size: 16px;"; /** Section header style */
|
|
23
|
-
readonly section: "color: #22c55e; font-weight: bold;"; /** Feature highlight style */
|
|
24
|
-
readonly highlight: "color: #a855f7; font-weight: bold;"; /** Call-to-action style */
|
|
25
|
-
readonly cta: "color: #22c55e; font-weight: bold;"; /** Info style */
|
|
26
|
-
readonly info: "color: #06b6d4; font-weight: bold;"; /** Link style */
|
|
27
|
-
readonly link: "color: #007acc; text-decoration: underline;"; /** Body text - inherits console theme */
|
|
28
|
-
readonly body: "color: inherit;"; /** Warning style */
|
|
29
|
-
readonly warning: "color: #ef4444; font-weight: bold;";
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Styled console message for CopilotKit Platform promotion
|
|
33
|
-
* Displays a beautiful, branded advertisement in the console
|
|
34
|
-
*/
|
|
35
|
-
declare function logCopilotKitPlatformMessage(): void;
|
|
36
|
-
declare function publicApiKeyRequired(feature: string): void;
|
|
37
|
-
/**
|
|
38
|
-
* Create a styled console message with custom content
|
|
39
|
-
*
|
|
40
|
-
* @param template - Template string with %c placeholders
|
|
41
|
-
* @param styles - Array of style strings matching the %c placeholders
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* logStyled(
|
|
46
|
-
* '%cCopilotKit%c Welcome to the platform!',
|
|
47
|
-
* [ConsoleStyles.header, ConsoleStyles.body]
|
|
48
|
-
* );
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
declare function logStyled(template: string, styles: string[]): void;
|
|
52
|
-
/**
|
|
53
|
-
* Quick styled console methods for common use cases
|
|
54
|
-
*/
|
|
55
|
-
declare const styledConsole: {
|
|
56
|
-
/** Log a success message */readonly success: (message: string) => void; /** Log an info message */
|
|
57
|
-
readonly info: (message: string) => void; /** Log a feature highlight */
|
|
58
|
-
readonly feature: (message: string) => void; /** Log a call-to-action */
|
|
59
|
-
readonly cta: (message: string) => void; /** Log the CopilotKit platform promotion */
|
|
60
|
-
readonly logCopilotKitPlatformMessage: typeof logCopilotKitPlatformMessage; /** Log a `publicApiKeyRequired` warning */
|
|
61
|
-
readonly publicApiKeyRequired: typeof publicApiKeyRequired;
|
|
62
|
-
};
|
|
63
|
-
//#endregion
|
|
64
|
-
export { ConsoleColors, ConsoleStyles, logCopilotKitPlatformMessage, logStyled, publicApiKeyRequired, styledConsole };
|
|
65
|
-
//# sourceMappingURL=console-styling.d.cts.map
|